drm: bridge/dw_hdmi: adjust pixel clock values in N calculation
authorRussell King <rmk+kernel@arm.linux.org.uk>
Wed, 22 Jul 2015 09:39:27 +0000 (10:39 +0100)
committerRussell King <rmk+kernel@arm.linux.org.uk>
Fri, 9 Oct 2015 16:17:34 +0000 (17:17 +0100)
Adjust the pixel clock values in the N calculation to match the more
accurate clock values we're given by the DRM subsystem, which are the
kHz pixel rate, with any fractional kHz rounded down in the case of
the non-240, non-480 line modes, or rounded up for the others.  So,

 25.20 / 1.001 =>  25175
 27.00 * 1.001 =>  27027
 74.25 / 1.001 =>  74176
148.50 / 1.001 => 148352

DRM derives these rates from the EDID CEA mode identifiers, which are
looked up in the tables in drivers/gpu/drm/drm_edid.c.  The values on
the right are the clock values found in these tables, and are
currently expected to be passed to the HDMI driver unchanged.

Tested-by: Fabio Estevam <fabio.estevam@freescale.com>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
drivers/gpu/drm/bridge/dw_hdmi.c

index e5ee92370f49e73d73c414359d1eb2b76e499a43..2ef13d92eaaedea0c65abe4f7fbe70b7c2747407 100644 (file)
@@ -230,11 +230,11 @@ static unsigned int hdmi_compute_n(unsigned int freq, unsigned long pixel_clk,
 
        switch (freq) {
        case 32000:
-               if (pixel_clk == 25170000)
+               if (pixel_clk == 25175000)
                        n = (ratio == 150) ? 9152 : 4576;
-               else if (pixel_clk == 27020000)
+               else if (pixel_clk == 27027000)
                        n = (ratio == 150) ? 8192 : 4096;
-               else if (pixel_clk == 74170000 || pixel_clk == 148350000)
+               else if (pixel_clk == 74176000 || pixel_clk == 148352000)
                        n = 11648;
                else
                        n = 4096;
@@ -242,11 +242,11 @@ static unsigned int hdmi_compute_n(unsigned int freq, unsigned long pixel_clk,
                break;
 
        case 44100:
-               if (pixel_clk == 25170000)
+               if (pixel_clk == 25175000)
                        n = 7007;
-               else if (pixel_clk == 74170000)
+               else if (pixel_clk == 74176000)
                        n = 17836;
-               else if (pixel_clk == 148350000)
+               else if (pixel_clk == 148352000)
                        n = (ratio == 150) ? 17836 : 8918;
                else
                        n = 6272;
@@ -254,13 +254,13 @@ static unsigned int hdmi_compute_n(unsigned int freq, unsigned long pixel_clk,
                break;
 
        case 48000:
-               if (pixel_clk == 25170000)
+               if (pixel_clk == 25175000)
                        n = (ratio == 150) ? 9152 : 6864;
-               else if (pixel_clk == 27020000)
+               else if (pixel_clk == 27027000)
                        n = (ratio == 150) ? 8192 : 6144;
-               else if (pixel_clk == 74170000)
+               else if (pixel_clk == 74176000)
                        n = 11648;
-               else if (pixel_clk == 148350000)
+               else if (pixel_clk == 148352000)
                        n = (ratio == 150) ? 11648 : 5824;
                else
                        n = 6144;