Bug 23833 - [i945G KMS] X uses different refresh rate to that set by kernel module
Summary: [i945G KMS] X uses different refresh rate to that set by kernel module
Status: RESOLVED FIXED
Alias: None
Product: xorg
Classification: Unclassified
Component: Driver/intel (show other bugs)
Version: git
Hardware: x86 (IA32) Linux (All)
: medium normal
Assignee: Chris Wilson
QA Contact: Xorg Project Team
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-09-10 01:38 UTC by Fabio Pedretti
Modified: 2010-08-30 04:36 UTC (History)
0 users

See Also:
i915 platform:
i915 features:


Attachments
dmesg (38.52 KB, text/plain)
2009-09-10 01:38 UTC, Fabio Pedretti
no flags Details
Xorg.0.log (42.41 KB, text/plain)
2009-09-10 01:38 UTC, Fabio Pedretti
no flags Details
Xorg log when booting with "nomodeset" (50.90 KB, text/plain)
2009-10-09 08:35 UTC, Fabio Pedretti
no flags Details
Xorg log when booting with default kms (50.24 KB, text/plain)
2009-10-09 08:36 UTC, Fabio Pedretti
no flags Details
xrandr --verbose when booting with "nomodeset" (2.85 KB, text/plain)
2009-10-09 08:37 UTC, Fabio Pedretti
no flags Details
xrandr --verbose with default kms (3.05 KB, text/plain)
2009-10-09 08:37 UTC, Fabio Pedretti
no flags Details

Description Fabio Pedretti 2009-09-10 01:38:04 UTC
Created attachment 29370 [details]
dmesg

[This problem was already reported in https://bugs.freedesktop.org/show_bug.cgi?id=22716#c38]

I am using drm-next linux up to c746e205f2fb6f74b4a622382607f065eca5eb49. I noticed that when X starts it uses a different mode (same resolution but different refresh rate) of that set by the kernel module during boot. This also make X <-> VT switching slow as without KMS.

This is what I see using my monitor OSD:
X: 1280x1024 Hf:63KHz Vf:59.9Hz
boot and VT: 1280x1024 Hf:79KHz Vf:74.6Hz

I'll attaching dmesg and Xorg.0.log.
Comment 1 Fabio Pedretti 2009-09-10 01:38:51 UTC
Created attachment 29371 [details]
Xorg.0.log
Comment 2 Fabio Pedretti 2009-10-09 08:35:38 UTC
Created attachment 30224 [details]
Xorg log when booting with "nomodeset"

Any news on this? I am attaching Xorg log and xrandr --verbose output using 2.6.32-rc3 and intel 2.9.0.
Comment 3 Fabio Pedretti 2009-10-09 08:36:14 UTC
Created attachment 30225 [details]
Xorg log when booting with default kms
Comment 4 Fabio Pedretti 2009-10-09 08:37:00 UTC
Created attachment 30226 [details]
xrandr --verbose when booting with "nomodeset"
Comment 5 Fabio Pedretti 2009-10-09 08:37:28 UTC
Created attachment 30227 [details]
xrandr --verbose with default kms
Comment 6 ykzhao 2009-10-10 01:25:57 UTC
(In reply to comment #5)
> Created an attachment (id=30227) [details]
> xrandr --verbose with default kms
Does the system still work well although the different refresh rate is used in X and console mode?

From the log it seems that the 1280x1024@75Hz standard mode is removed by x-server as the pixel clock is beyond the range obtained from EDID.
  >The pixel clock of 1280x1024@75Hz is 135MHz. But the max pixel clock from EDID is 130MHz. (Ranges: V min: 56 V max: 75 Hz, H min: 31 H max: 80 kHz, PixClock max 130 MHz)

In the console mode the 1280x1024@75Hz is not removed as the max pixel clock in EDID is not used to validate the given display modeline.

Thanks.
> 

Comment 7 Fabio Pedretti 2009-10-12 00:16:59 UTC
> Does the system still work well although the different refresh rate is used in
> X and console mode?

Yes.

> From the log it seems that the 1280x1024@75Hz standard mode is removed by
> x-server as the pixel clock is beyond the range obtained from EDID.
>   >The pixel clock of 1280x1024@75Hz is 135MHz. But the max pixel clock from
> EDID is 130MHz. (Ranges: V min: 56 V max: 75 Hz, H min: 31 H max: 80 kHz,
> PixClock max 130 MHz)
> 
> In the console mode the 1280x1024@75Hz is not removed as the max pixel clock in
> EDID is not used to validate the given display modeline.

So it is a kernel bug. I am available to test any patch if needed.

Thanks
Comment 8 Fabio Pedretti 2009-12-11 08:35:17 UTC
Just to remind this is still not fixed on 2.6.32 final.
Comment 9 Jesse Barnes 2010-07-15 10:47:39 UTC
This one should be fixed in 2.6.35-rc kernels; I think we'll pick 60Hz on TFTs now.
Comment 10 Fabio Pedretti 2010-08-04 08:10:53 UTC
I am using 2.6.35 final but this is still not fixed.
Comment 11 Chris Wilson 2010-08-05 07:02:48 UTC
The discrepancy appears to be due to:

drivers/gpu/drm/drm_edid.c:
static u32
range_pixel_clock(struct edid *edid, u8 *t)
{
        /* unspecified */
        if (t[9] == 0 || t[9] == 255)
                return 0;

        /* 1.4 with CVT support gives us real precision, yay */
        if (edid->revision >= 4 && t[10] == 0x04)
                return (t[9] * 10000) - ((t[12] >> 2) * 250);

        /* 1.3 is pathetic, so fuzz up a bit */
        return t[9] * 10000 + 5001;
}

The addition of 5MHz for the non-CVT EDID is just enough make the 135MHz pixel clock mode valid given the 130MHz max. The X EDID parser has no fuzz and so removes the detailed mode.

I wonder what is the best approach here? Fix X to interpret the EDID the same as the kernel, fix the drivers to trust the modes supplied by the kernel, or something else?
Comment 12 Chris Wilson 2010-08-05 07:23:43 UTC
Adam Jackson pointed out that X should be doing a similar fixup, but sadly fails because at the point it does so, it doesn't have all the information to hand...

commit fc2ec95664d55f45f77f1ebb039a7c17a1fcdaa3
Author: Ma Ling <ling.ma@intel.com>
Date:   Wed Feb 18 17:41:26 2009 +0800

    EDID: CEA extension support
    
    Reviewed-by: Adam Jackson <ajax@redhat.com>

His recommendation is that we just use the KMS modes and not reparse the EDID in the ddx.
Comment 13 Chris Wilson 2010-08-05 08:56:33 UTC
Sigh, xf86ProbeOutputModes() makes this hard.
Comment 14 Chris Wilson 2010-08-05 08:58:30 UTC
Temporary hack:

diff --git a/hw/xfree86/ddc/interpret_edid.c b/hw/xfree86/ddc/interpret_edid.c
index acb7efa..46958f7 100644
--- a/hw/xfree86/ddc/interpret_edid.c
+++ b/hw/xfree86/ddc/interpret_edid.c
@@ -552,7 +552,7 @@ get_monitor_ranges(Uchar *c, struct monitor_ranges *r)
     r->max_h = MAX_H;
     r->max_clock = 0;
     if(MAX_CLOCK != 0xff) /* is specified? */
-       r->max_clock = MAX_CLOCK * 10;
+       r->max_clock = MAX_CLOCK * 10 + 5;
     if (HAVE_2ND_GTF) {
        r->gtf_2nd_f = F_2ND_GTF;
        r->gtf_2nd_c = C_2ND_GTF;
Comment 15 Fabio Pedretti 2010-08-19 23:49:03 UTC
(In reply to comment #14)
> Temporary hack:
> 
> diff --git a/hw/xfree86/ddc/interpret_edid.c b/hw/xfree86/ddc/interpret_edid.c
> index acb7efa..46958f7 100644
> --- a/hw/xfree86/ddc/interpret_edid.c
> +++ b/hw/xfree86/ddc/interpret_edid.c
> @@ -552,7 +552,7 @@ get_monitor_ranges(Uchar *c, struct monitor_ranges *r)
>      r->max_h = MAX_H;
>      r->max_clock = 0;
>      if(MAX_CLOCK != 0xff) /* is specified? */
> -       r->max_clock = MAX_CLOCK * 10;
> +       r->max_clock = MAX_CLOCK * 10 + 5;
>      if (HAVE_2ND_GTF) {
>         r->gtf_2nd_f = F_2ND_GTF;
>         r->gtf_2nd_c = C_2ND_GTF;

I applied the patch to the xserver and now X also uses the 75Hz refresh and switch to VT is very fast. So what's the right refresh, 60Hz of unpatched X or 75Hz of kernel and patched X? Note that on the same machine Windows XP also uses 60Hz.

Anyway it would make sense that when using KMS X shouldn't change the resolution unless a different one is specified in the xorg.conf file.
Comment 16 Chris Wilson 2010-08-20 00:55:48 UTC
> --- Comment #15 from Fabio Pedretti <fabio.ped@libero.it> 2010-08-19 23:49:03 PDT ---
> I applied the patch to the xserver and now X also uses the 75Hz refresh and
> switch to VT is very fast. So what's the right refresh, 60Hz of unpatched X or
> 75Hz of kernel and patched X? Note that on the same machine Windows XP also
> uses 60Hz.

The monitor lists the 75Hz amongst the detailed modes that it supports.
However, that mode conflicts with the EDID's maximum pixel clock, though
that is arguably due to limited accuracy of the field (and a rounding
error, on whose part the spec is unclear). As the monitor explicitly
supports the mode, we should be using it.
Comment 17 Fabio Pedretti 2010-08-20 01:12:18 UTC
(In reply to comment #16)
> The monitor lists the 75Hz amongst the detailed modes that it supports.
> However, that mode conflicts with the EDID's maximum pixel clock, though
> that is arguably due to limited accuracy of the field (and a rounding
> error, on whose part the spec is unclear). As the monitor explicitly
> supports the mode, we should be using it.

OK, just for completeness I noticed that on Windows 70, 72, 75Hz are also selectable and work fine.
Comment 18 Chris Wilson 2010-08-20 05:54:35 UTC
I have not found a clean way to simply use the KMS modes in X due to the ability of the user to override them. So let's go with the simple patch...
Comment 19 Julien Cristau 2010-08-20 09:07:36 UTC
Patch is upstream for 1.9:

commit 951605b4660290044fb238bcf1d6d9e498567e8c
Author: Chris Wilson <chris@chris-wilson.co.uk>
Date:   Fri Aug 20 13:51:04 2010 +0100

    edid: Adjust rounding of max_clock
Comment 20 Fabio Pedretti 2010-08-30 04:36:55 UTC
Does, by the way, using refresh rate > 60Hz on LCDs improve end user visual experience or not? I usually hears that LCDs work fine with 60Hz (also Windows default to it).


Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.