@@ -291,18 +291,6 @@ static int sun4i_tcon_get_clk_delay(const struct drm_display_mode *mode,
291291 return delay ;
292292}
293293
294- static void sun4i_tcon0_mode_set_common (struct sun4i_tcon * tcon ,
295- const struct drm_display_mode * mode )
296- {
297- /* Configure the dot clock */
298- clk_set_rate (tcon -> dclk , mode -> crtc_clock * 1000 );
299-
300- /* Set the resolution */
301- regmap_write (tcon -> regs , SUN4I_TCON0_BASIC0_REG ,
302- SUN4I_TCON0_BASIC0_X (mode -> crtc_hdisplay ) |
303- SUN4I_TCON0_BASIC0_Y (mode -> crtc_vdisplay ));
304- }
305-
306294static void sun4i_tcon0_mode_set_dithering (struct sun4i_tcon * tcon ,
307295 const struct drm_connector * connector )
308296{
@@ -367,10 +355,18 @@ static void sun4i_tcon0_mode_set_cpu(struct sun4i_tcon *tcon,
367355 u32 block_space , start_delay ;
368356 u32 tcon_div ;
369357
358+ /*
359+ * dclk is required to run at 1/4 the DSI per-lane bit rate.
360+ */
370361 tcon -> dclk_min_div = SUN6I_DSI_TCON_DIV ;
371362 tcon -> dclk_max_div = SUN6I_DSI_TCON_DIV ;
363+ clk_set_rate (tcon -> dclk , mode -> crtc_clock * 1000 * (bpp / lanes )
364+ / SUN6I_DSI_TCON_DIV );
372365
373- sun4i_tcon0_mode_set_common (tcon , mode );
366+ /* Set the resolution */
367+ regmap_write (tcon -> regs , SUN4I_TCON0_BASIC0_REG ,
368+ SUN4I_TCON0_BASIC0_X (mode -> crtc_hdisplay ) |
369+ SUN4I_TCON0_BASIC0_Y (mode -> crtc_vdisplay ));
374370
375371 /* Set dithering if needed */
376372 sun4i_tcon0_mode_set_dithering (tcon , sun4i_tcon_get_connector (encoder ));
@@ -438,7 +434,12 @@ static void sun4i_tcon0_mode_set_lvds(struct sun4i_tcon *tcon,
438434
439435 tcon -> dclk_min_div = 7 ;
440436 tcon -> dclk_max_div = 7 ;
441- sun4i_tcon0_mode_set_common (tcon , mode );
437+ clk_set_rate (tcon -> dclk , mode -> crtc_clock * 1000 );
438+
439+ /* Set the resolution */
440+ regmap_write (tcon -> regs , SUN4I_TCON0_BASIC0_REG ,
441+ SUN4I_TCON0_BASIC0_X (mode -> crtc_hdisplay ) |
442+ SUN4I_TCON0_BASIC0_Y (mode -> crtc_vdisplay ));
442443
443444 /* Set dithering if needed */
444445 sun4i_tcon0_mode_set_dithering (tcon , sun4i_tcon_get_connector (encoder ));
@@ -515,7 +516,12 @@ static void sun4i_tcon0_mode_set_rgb(struct sun4i_tcon *tcon,
515516
516517 tcon -> dclk_min_div = tcon -> quirks -> dclk_min_div ;
517518 tcon -> dclk_max_div = 127 ;
518- sun4i_tcon0_mode_set_common (tcon , mode );
519+ clk_set_rate (tcon -> dclk , mode -> crtc_clock * 1000 );
520+
521+ /* Set the resolution */
522+ regmap_write (tcon -> regs , SUN4I_TCON0_BASIC0_REG ,
523+ SUN4I_TCON0_BASIC0_X (mode -> crtc_hdisplay ) |
524+ SUN4I_TCON0_BASIC0_Y (mode -> crtc_vdisplay ));
519525
520526 /* Set dithering if needed */
521527 sun4i_tcon0_mode_set_dithering (tcon , connector );
0 commit comments