ganzgustav22
Posts: 204
Joined: Tue Feb 11, 2020 1:04 pm

Convert X.Org modelines to config.txt hdmi_timings?

Thu May 06, 2021 2:34 pm

I have an X modeline that I'd like to configure in config.txt (so that the additional screen flickering during bootup when X changes the mode doesn't occur).

This is the X modeline syntax:
pclk hdisp hsyncstart hsyncend htotal vdisp vsyncstart vsyncend vtotal [flags] Flags (optional): +HSync, -HSync, +VSync, -VSync, Interlace, DoubleScan, CSync, +CSync, -CSync

This is the config.txt hdmi_timings syntax:
hdmi_timings=<h_active_pixels> <h_sync_polarity <h_front_porch> <h_sync_pulse> <h_back_porch> <v_active_lines> <v_sync_polarity> <v_front_porch> <v_sync_pulse> <v_back_porch> <v_sync_offset_a> <v_sync_offset_b> <pixel_rep> <frame_rate> <interlaced> <pixel_freq> <aspect_ratio>

This is the modeline that X is actually using that I'd like to convert to config.txt hdmi_timings syntax:
"1920x1080" 148.50 1920 2008 2052 2200 1080 1084 1089 1125 +hsync -vsync

But I'm totally lost on how to do that.

Is it possible to display the current hdmi_timings somewhere with tvservice or vcgencmd or something so that I can get an idea on how to convert it? Or does anybody know how to convert it? Or maybe even has a ready-to-use modeline-to-hdmi_timings converter tool?

6by9
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 11216
Joined: Wed Dec 04, 2013 11:27 am
Location: ZZ9 Plural Z Alpha, aka just outside Cambridge.

Re: Convert X.Org modelines to config.txt hdmi_timings?

Thu May 06, 2021 4:07 pm

The definition of DRM and X.org modes is at https://elixir.bootlin.com/linux/v5.12/ ... des.h#L173

[h|v]_active_pixels = [h|v]display
[h|v]_front_porch = [h|v]sync_start - [h|v]display
[h|v]_sync_pulse = [h|v]sync_end - [h|v]sync_start
[h|v]_back_porch = [h|v]total - [h|v]sync_end

"1920x1080" 148.50 1920 2008 2052 2200 1080 1084 1089 1125 +hsync -vsync" is the standard 1080p timing (CEA mode 16), although with inverted vsync (or DMT mode 82 with inverted hsync if you prefer). Most monitors don't actually care about sync polarities as it's not a physical signal on an HDMI link.
Software Engineer at Raspberry Pi Trading. Views expressed are still personal views.
I'm not interested in doing contracts for bespoke functionality - please don't ask.

ganzgustav22
Posts: 204
Joined: Tue Feb 11, 2020 1:04 pm

Re: Convert X.Org modelines to config.txt hdmi_timings?

Wed May 12, 2021 11:48 am

Thanks for your help.

I've now configured this in config.txt:

Code: Select all

hdmi_force_hotplug=1
hdmi_group=2
hdmi_mode=87

#hdmi_timings=1920 1 88 44 148 1080 0 4 5 36 0 0 0 60 0 148500000 3
#hdmi_timings=1920 0 88 44 148 1080 0 4 5 36 0 0 0 60 0 148500000 3
#hdmi_timings=1920 0 88 44 148 1080 1 4 5 36 0 0 0 60 0 148500000 3
hdmi_timings=1920 1 88 44 148 1080 1 4 5 36 0 0 0 60 0 148500000 3
(Because I wasn't sure about v/h sync polarity, I simply tried all possible 4 combinations).

But still, the monitor re-initializes/flickers when the X Server starts.

When checking with vcgencmd hdmi_timings I see the settings seem to have been applied:

Code: Select all

user@raspberry(ro):~$ vcgencmd hdmi_timings
hdmi_timings=1920 1 88 44 148 1080 1 4 5 36 0 0 0 60 0 148500000 0

6by9
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 11216
Joined: Wed Dec 04, 2013 11:27 am
Location: ZZ9 Plural Z Alpha, aka just outside Cambridge.

Re: Convert X.Org modelines to config.txt hdmi_timings?

Wed May 12, 2021 12:02 pm

You don't say, but I'm guessing a Pi4.

In which case X inherently reinitialises the display as it starts because the resolution chosen by the console during boot may not be the same as X wants for the desktop.
The Screen Configuration app normally saves the last requested desktop resolution in /usr/share/disp_setup.sh, so that issuing xrandr commands may also trigger a resolution change. It's safe to remove it.
I believe each xrandr mode change request will disable and reenable the pipeline, even if the mode is the same/there is only one mode.
Software Engineer at Raspberry Pi Trading. Views expressed are still personal views.
I'm not interested in doing contracts for bespoke functionality - please don't ask.

drtechno
Posts: 230
Joined: Fri Apr 09, 2021 6:33 pm

Re: Convert X.Org modelines to config.txt hdmi_timings?

Wed May 12, 2021 12:15 pm

The one screen flicker is for detection of additional displays. I think there is a way to disable it in xinit but finding what you need to do is going to involve looking at the x11 misc. supplement manual. You might have to declare the displays you are running manually.

ganzgustav22
Posts: 204
Joined: Tue Feb 11, 2020 1:04 pm

Re: Convert X.Org modelines to config.txt hdmi_timings?

Wed May 12, 2021 1:38 pm

You don't say, but I'm guessing a Pi4.
Yes, Pi4. with:

Code: Select all

dtoverlay=vc4-fkms-v3d
disable_fw_kms_setup=1
in config.txt The disable_fw_kms_setup line made one screen flickering disappear already, now I'm trying to make the remaining screen flickering disappear :)
In which case X inherently reinitialises the display as it starts because the resolution chosen by the console during boot may not be the same as X wants for the desktop.
I thought putting exactly the same modeline settings that Xorg uses into config.txt would get rid of that, because then, it is actually the same.
The Screen Configuration app normally saves the last requested desktop resolution in /usr/share/disp_setup.sh, so that issuing xrandr commands may also trigger a resolution change. It's safe to remove it.
I believe each xrandr mode change request will disable and reenable the pipeline, even if the mode is the same/there is only one mode.
D'ohh. I don't use that app (Raspberry Pi OS Lite with xorg started via xinit.sh script in /etc/profile.d/, it's a Kiosk system) but indeed use xrandr to set rotation, I'll look into that. Maybe I can supply the rotation settings in the xorg conf before X starts (?)

Return to “General discussion”