How to force the monitor resolution in a Raspbian – Raspberry PI

I was trying to configure a Raspberry pi using a SAMSUNG monitor recently, and I noticed that the resolution  picked up automatically was awful. It seems that, by default, Raspbian tries to detect the resolution that better suits your monitor and uses it automatically.

It can do it wrongly. In fact, it was what happened to me: the option chosen by default was extremely wrong, so I needed to figure out how to change it manually.

The steps to follow are:

1. Get the list of what’s supported by your monitor:

Video configuration settings are stored in an EDID file in the monitor itself. To obtain a list of the modes supported, you can use the tvservice command

1.1. Run “tvservice –d <file>” to capture a monitor’s EDID in <file>
1.2. Pass this file to edidparser. Run “edidparser <file>”.

Example:

tvservice -d edidgonzalo
edidparser edidgonzalo

2. Now you need to find the mode that you want to use in the resulting list.

My monitor is a SAMSUNG S22B350T

I find out that the resolution native is 1920×1080 @ 60 HZ

With edidparser I checked what were the modes for a resolution of 1920 pixels:

pi@raspberrypi ~ $ edidparser edidgonzalo | grep “1920”
HDMI:EDID found preferred CEA detail timing format: 1920x1080p @ 60 Hz (16)
HDMI:EDID found CEA format: code 16, 1920x1080p @ 60Hz (native)
HDMI:EDID found CEA format: code 31, 1920x1080p @ 50Hz
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 232360
HDMI:EDID preferred mode remained as CEA (16) 1920x1080p @ 60 Hz with pixel clock 148 MHz

As showed above (in bold)  the native mode is CEA format code 16

3. Edit the config file to reflect the desired resolution:

Now, with the information obtained you need to edit the config file and manually force the resolution to the one you desire.

You can achieve this editing the file /boot/config.txt

nano /boot/config.txt

Find the section about HDMI, uncomment it (remove the #) and set the right group and mode from step 2 (If your mode description contains “DMT”, the group should be 2, and if it contains “CEA”, it should be 1)

So in my case:

hdmi_group=1
hdmi_mode=16

Exit the editor with CTRL+X, followed by Y.

4. Reboot:

shutdown -r now

Everything should be as expected now