How to get the display settings right on Raspberry Pi

When you connect your raspberry pi to your TV or monitor via HDMI, Pi attempts to guess the resolution, hdmi mode, overscan values etc., that best fits your display. But it might get this wrong and you may come across various problems with display such as :

- Picture doesn't fill the entire size of the screen and you can see black borders on left, right, top, bottom or all sides.

- Picture spills off the size of the screen and some parts of the picture are outside the screen.

- The resolution and HDMI modes are not the best values for your screen

This article explains how these can be manually corrected.

Picture doesn't fill the entire size of the screen and you can see black borders on left, right, top, bottom or all sides.

This is possibly because Pi is adding overscan to the signal. Modern TVs and monitors don't need overscan and hence disabling overscan altogether can make the Pi graphics fill the entire screen.

Check the settings on the TV or monitor first. Eg: On a Sony Bravia TV these settings are under Screen Format (Normal, Zoom, Wide Zoom etc.,). If this doesn't remove the black borders, then try disabling overscan on the Pi. This can be done by setting the parameter disable_overscan to 1 in /boot/config.txt and commenting other parameters related to overscan.

  1. Take a backup of /boot/config.txt
    sudo cp /boot/config.txt /boot/config.txt.backup
    
  2. Open config.txt for editing
    sudo nano /boot/config.txt
    
  3. Uncomment the #disable_overscan=1 (Remove the #)
  4. Comment all other overscan parameters
    #overscan_left=10
    #overscan_right=10
    #overscan_top=15
    #overscan_bottom=15
    
  5. Save and exit. ( CTRL+X followed by Y to save)
  6. Reboot
    sudo reboot
    

On most monitors/TVs this would remove the black borders and make the desktop fill the whole screen. However if your display stil has some overscan you may need to keep the overscan parameters in config.txt file, but adjust the values:

overscan_left=-10
overscan_right=-10
overscan_top=-30
overscan_bottom=-30

More negative values means less black borders. Centre the display by trying different values for feft, right, top, bottom.

Picture spills off the size of the screen and some parts of the picture are outside the screen

This means you need positive overscan values.

overscan_left=10
overscan_right=10
overscan_top=30
overscan_bottom=30

The resolution and HDMI modes are not the best values for your screen

Try to change monitor settings from Preferences → Monitor settings

However if it says "Unable to get monitor information", find out the modes supported by your monitor by running tvservice command and set the correct mode in /boot/config.txt as below

  1. Run the tvservice command to output the result to a file.
    $ tvservice -d edid.dat
    Written 256 bytes to edid.dat
    
  2. Pipe the file to edidparser to generate a readable text file.
    $ edidparser edid.dat > edid.txt
    
  3. Grep the desired resolution to check if it is available. For example if you are checking for 1080p resolution
    $ cat edid.txt | grep 1080p
      HDMI:EDID found preferred CEA detail timing format: 1920x1080p @ 60 Hz (16)
      HDMI:EDID found CEA detail timing format: 1920x1080p @ 50 Hz (31)
      HDMI:EDID found CEA format: code 31, 1920x1080p @ 50Hz 
      HDMI:EDID found CEA format: code 16, 1920x1080p @ 60Hz 
      HDMI:EDID found CEA format: code 32, 1920x1080p @ 24Hz 
      HDMI:EDID found CEA format: code 34, 1920x1080p @ 30Hz 
      HDMI:EDID best score mode is now CEA (16) 1920x1080p @ 60 Hz with pixel clock 148 MHz (score 5398248)
      HDMI:EDID CEA mode (31) 1920x1080p @ 50 Hz with pixel clock 148 MHz has a score of 4232360
      HDMI:EDID CEA mode (32) 1920x1080p @ 24 Hz with pixel clock 74 MHz has a score of 124532
      HDMI:EDID CEA mode (34) 1920x1080p @ 30 Hz with pixel clock 74 MHz has a score of 149416
      HDMI:EDID preferred mode remained as CEA (16) 1920x1080p @ 60 Hz with pixel clock 148 MHz
    
      HDMI:EDID best score mode is now CEA (16) 1920x1080p @ 60 Hz with pixel clock 148 MHz (score 5398248)

    "CEA" corresponds to hdmi_group=1
    "DMT" corresponds to hdmi_group=2
    The value inside () corresponds to hdmi_mode.

    From the above result:
    hdmi_group=1
    hdmi_mode=16

  4. Take a backup of /boot/config.txt
     sudo cp /boot/config.txt /boot/config.txt.backup
  5. Edit /boot/config.txt
     sudo nano /boot/config.txt 
  6. Uncomment hdmi_group and hdmi_mode and set the right values
     hdmi_group=1
     hdmi_mode=16 
  7. Save and exit; Ctrl+X followed by Y to save
  8. Reboot
    $ sudo reboot 


Post a comment

Name

Your Comment

Email (We dont publish it)

Comments

bobby | January 3, 2015 10:41 AM |

this didnt do anything. still off the screen on both sides

Martin | February 10, 2015 10:15 PM |

Sure did the trick for me :-)

Lukas | March 5, 2015 2:29 AM |

Uncomment: Disable_overscan=1 In /boot/config.txt And you are done Mate.

zoor | March 25, 2015 10:16 PM |

please the display is too tiny i cant see anything to even make changes, what do i do?

Pascal | July 27, 2015 8:01 PM |

Thank you, I was able to fix it with your guide

modom | August 9, 2015 6:08 AM |

Worked for me, thanks.

Mark | November 27, 2015 12:29 PM |

If you have used NOOBS to run Raspbian you may find that there is a set of settings already at the bottom of the config.txt file. I missed those when uncommenting the above suggestions so it looked like nothing was being fixed.

Lee | December 8, 2015 9:30 AM |

Thanks, seems to stop the screen detection errors when booting ubuntu mate on the pi now after removing the overscan. Much appreciated!

Sander | December 18, 2015 9:53 AM |

(I'm using Raspbian Jessie) I had black borders around my screen. I followed the 6 steps, but it didn't work. Adding another step fixed it for me. After: Comment all other overscan parameters #overscan_left=10 #overscan_right=10 #overscan_top=15 #overscan_bottom=15 I also had to comment a line "disable_overscan=0" before saving the file. Located at line number 75 in my file.

Eike | January 14, 2016 11:55 PM |

Worked like a charm on my Samsung TV. Thanks!

N/A | February 18, 2016 9:52 AM |

This solution worked for me, thank you.

Zaffre | April 8, 2016 9:14 AM |

Thank you Lukas. Simple and it works. I'm very new to this. :)

Alvaro | May 9, 2016 10:22 AM |

Works for a 7'' monitor. Thank you very very much. Now I don't have black borders

John Wiggins | May 9, 2016 10:22 AM |

Another tip, you can change the default console font with: sudo dpkg-reconfigure console-setup Then select utf-8, Guess optimal char set, Terminus Bold, thenot pick one to see if it is better. You can always retry if it isn't to your liking

Huub Knops | November 1, 2016 10:39 AM |

Great! Worked for me!