Skip to content

Commit

Permalink
drm/sun4i: tcon: Move out the tcon0 common setup
Browse files Browse the repository at this point in the history
Some channel0 setup has to be done, no matter what the output interface is
(RGB, CPU, LVDS). Move that code into a common function in order to avoid
duplication.

Reviewed-by: Chen-Yu Tsai <[email protected]>
Signed-off-by: Maxime Ripard <[email protected]>
Link: https://patchwork.freedesktop.org/patch/183100/
  • Loading branch information
mripard committed Oct 17, 2017
1 parent 5b8f091 commit ba19c53
Showing 1 changed file with 16 additions and 10 deletions.
26 changes: 16 additions & 10 deletions drivers/gpu/drm/sun4i/sun4i_tcon.c
Original file line number Diff line number Diff line change
Expand Up @@ -158,27 +158,33 @@ static int sun4i_tcon_get_clk_delay(const struct drm_display_mode *mode,
return delay;
}

static void sun4i_tcon0_mode_set(struct sun4i_tcon *tcon,
const struct drm_display_mode *mode)
static void sun4i_tcon0_mode_set_common(struct sun4i_tcon *tcon,
const struct drm_display_mode *mode)
{
/* Configure the dot clock */
clk_set_rate(tcon->dclk, mode->crtc_clock * 1000);

/* Set the resolution */
regmap_write(tcon->regs, SUN4I_TCON0_BASIC0_REG,
SUN4I_TCON0_BASIC0_X(mode->crtc_hdisplay) |
SUN4I_TCON0_BASIC0_Y(mode->crtc_vdisplay));
}

static void sun4i_tcon0_mode_set_rgb(struct sun4i_tcon *tcon,
const struct drm_display_mode *mode)
{
unsigned int bp, hsync, vsync;
u8 clk_delay;
u32 val = 0;

/* Configure the dot clock */
clk_set_rate(tcon->dclk, mode->crtc_clock * 1000);
sun4i_tcon0_mode_set_common(tcon, mode);

/* Adjust clock delay */
clk_delay = sun4i_tcon_get_clk_delay(mode, 0);
regmap_update_bits(tcon->regs, SUN4I_TCON0_CTL_REG,
SUN4I_TCON0_CTL_CLK_DELAY_MASK,
SUN4I_TCON0_CTL_CLK_DELAY(clk_delay));

/* Set the resolution */
regmap_write(tcon->regs, SUN4I_TCON0_BASIC0_REG,
SUN4I_TCON0_BASIC0_X(mode->crtc_hdisplay) |
SUN4I_TCON0_BASIC0_Y(mode->crtc_vdisplay));

/*
* This is called a backporch in the register documentation,
* but it really is the back porch + hsync
Expand Down Expand Up @@ -329,7 +335,7 @@ void sun4i_tcon_mode_set(struct sun4i_tcon *tcon,
{
switch (encoder->encoder_type) {
case DRM_MODE_ENCODER_NONE:
sun4i_tcon0_mode_set(tcon, mode);
sun4i_tcon0_mode_set_rgb(tcon, mode);
sun4i_tcon_set_mux(tcon, 0, encoder);
break;
case DRM_MODE_ENCODER_TVDAC:
Expand Down

0 comments on commit ba19c53

Please sign in to comment.