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 to set the correct display resolution on Raspberry Pi.
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.
- Take a backup of the file /boot/config.txt
sudo cp /boot/config.txt /boot/config.txt.backup
- Open config.txt for editing
sudo nano /boot/config.txt
- Uncomment the #disable_overscan=1 (Remove the #)
- Comment all other overscan parameters
#overscan_left=10 #overscan_right=10 #overscan_top=15 #overscan_bottom=15
- Save and exit. ( CTRL+X followed by Y to save)
- 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
- Run the tvservice command to output the result to a file.
$ tvservice -d edid.dat Written 256 bytes to edid.dat
- Pipe the file to edidparser to generate a readable text file.
$ edidparser edid.dat > edid.txt
- 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 - Take a backup of /boot/config.txt
sudo cp /boot/config.txt /boot/config.txt.backup
- Edit /boot/config.txt
sudo nano /boot/config.txt
- Uncomment hdmi_group and hdmi_mode and set the right values
hdmi_group=1 hdmi_mode=16
- Save and exit; Ctrl+X followed by Y to save
- Reboot
$ sudo reboot