Commit f6e396e5 authored by Liu Ying's avatar Liu Ying Committed by Philipp Zabel

drm/imx: atomic phase 3 step 2: Legacy callback fixups

Now that we can use atomic configurations, all the legacy callbacks
of CRTCs, encoders and connectors can be switched to the atomic version.
For the imx-ldb driver, there is a clock parent setting mismatch bewteen
->enable and ->disable after the switch, so a fixup is added.  For the
imx-tve driver, since the encoder's callback ->dpms is replaced by
->disable, we need to move the setting for the IPU_CLK_EN bit(in register
TVE_COM_CONF_REG) from ->enable/->disable to ->mode_set, otherwise, the
relevant CRTC cannot be disabled correctly with a warning on DC stop timeout.
Signed-off-by: default avatarLiu Ying <gnuiyl@gmail.com>
Acked-by: default avatarDaniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: default avatarPhilipp Zabel <p.zabel@pengutronix.de>
parent 6b7279e1
...@@ -117,7 +117,7 @@ static void dw_hdmi_imx_encoder_mode_set(struct drm_encoder *encoder, ...@@ -117,7 +117,7 @@ static void dw_hdmi_imx_encoder_mode_set(struct drm_encoder *encoder,
{ {
} }
static void dw_hdmi_imx_encoder_commit(struct drm_encoder *encoder) static void dw_hdmi_imx_encoder_enable(struct drm_encoder *encoder)
{ {
struct imx_drm_encoder *imx_encoder = enc_to_imx_enc(encoder); struct imx_drm_encoder *imx_encoder = enc_to_imx_enc(encoder);
struct imx_hdmi *hdmi = imx_enc_to_imx_hdmi(imx_encoder); struct imx_hdmi *hdmi = imx_enc_to_imx_hdmi(imx_encoder);
...@@ -130,7 +130,7 @@ static void dw_hdmi_imx_encoder_commit(struct drm_encoder *encoder) ...@@ -130,7 +130,7 @@ static void dw_hdmi_imx_encoder_commit(struct drm_encoder *encoder)
static const struct drm_encoder_helper_funcs dw_hdmi_imx_encoder_helper_funcs = { static const struct drm_encoder_helper_funcs dw_hdmi_imx_encoder_helper_funcs = {
.mode_set = dw_hdmi_imx_encoder_mode_set, .mode_set = dw_hdmi_imx_encoder_mode_set,
.commit = dw_hdmi_imx_encoder_commit, .enable = dw_hdmi_imx_encoder_enable,
.disable = dw_hdmi_imx_encoder_disable, .disable = dw_hdmi_imx_encoder_disable,
}; };
......
...@@ -172,10 +172,6 @@ static struct drm_encoder *imx_ldb_connector_best_encoder( ...@@ -172,10 +172,6 @@ static struct drm_encoder *imx_ldb_connector_best_encoder(
return &imx_ldb_ch->imx_encoder.encoder; return &imx_ldb_ch->imx_encoder.encoder;
} }
static void imx_ldb_encoder_dpms(struct drm_encoder *encoder, int mode)
{
}
static void imx_ldb_set_clock(struct imx_ldb *ldb, int mux, int chno, static void imx_ldb_set_clock(struct imx_ldb *ldb, int mux, int chno,
unsigned long serial_clk, unsigned long di_clk) unsigned long serial_clk, unsigned long di_clk)
{ {
...@@ -204,7 +200,7 @@ static void imx_ldb_set_clock(struct imx_ldb *ldb, int mux, int chno, ...@@ -204,7 +200,7 @@ static void imx_ldb_set_clock(struct imx_ldb *ldb, int mux, int chno,
chno); chno);
} }
static void imx_ldb_encoder_commit(struct drm_encoder *encoder) static void imx_ldb_encoder_enable(struct drm_encoder *encoder)
{ {
struct imx_drm_encoder *imx_encoder = enc_to_imx_enc(encoder); struct imx_drm_encoder *imx_encoder = enc_to_imx_enc(encoder);
struct imx_ldb_channel *imx_ldb_ch = imx_enc_to_imx_ldb_ch(imx_encoder); struct imx_ldb_channel *imx_ldb_ch = imx_enc_to_imx_ldb_ch(imx_encoder);
...@@ -215,8 +211,13 @@ static void imx_ldb_encoder_commit(struct drm_encoder *encoder) ...@@ -215,8 +211,13 @@ static void imx_ldb_encoder_commit(struct drm_encoder *encoder)
drm_panel_prepare(imx_ldb_ch->panel); drm_panel_prepare(imx_ldb_ch->panel);
if (dual) { if (dual) {
clk_set_parent(ldb->clk_sel[mux], ldb->clk[0]);
clk_set_parent(ldb->clk_sel[mux], ldb->clk[1]);
clk_prepare_enable(ldb->clk[0]); clk_prepare_enable(ldb->clk[0]);
clk_prepare_enable(ldb->clk[1]); clk_prepare_enable(ldb->clk[1]);
} else {
clk_set_parent(ldb->clk_sel[mux], ldb->clk[imx_ldb_ch->chno]);
} }
if (imx_ldb_ch == &ldb->channel[0] || dual) { if (imx_ldb_ch == &ldb->channel[0] || dual) {
...@@ -356,7 +357,7 @@ static void imx_ldb_encoder_disable(struct drm_encoder *encoder) ...@@ -356,7 +357,7 @@ static void imx_ldb_encoder_disable(struct drm_encoder *encoder)
} }
static const struct drm_connector_funcs imx_ldb_connector_funcs = { static const struct drm_connector_funcs imx_ldb_connector_funcs = {
.dpms = drm_helper_connector_dpms, .dpms = drm_atomic_helper_connector_dpms,
.fill_modes = drm_helper_probe_single_connector_modes, .fill_modes = drm_helper_probe_single_connector_modes,
.detect = imx_ldb_connector_detect, .detect = imx_ldb_connector_detect,
.destroy = imx_drm_connector_destroy, .destroy = imx_drm_connector_destroy,
...@@ -375,9 +376,8 @@ static const struct drm_encoder_funcs imx_ldb_encoder_funcs = { ...@@ -375,9 +376,8 @@ static const struct drm_encoder_funcs imx_ldb_encoder_funcs = {
}; };
static const struct drm_encoder_helper_funcs imx_ldb_encoder_helper_funcs = { static const struct drm_encoder_helper_funcs imx_ldb_encoder_helper_funcs = {
.dpms = imx_ldb_encoder_dpms,
.commit = imx_ldb_encoder_commit,
.mode_set = imx_ldb_encoder_mode_set, .mode_set = imx_ldb_encoder_mode_set,
.enable = imx_ldb_encoder_enable,
.disable = imx_ldb_encoder_disable, .disable = imx_ldb_encoder_disable,
}; };
......
...@@ -147,8 +147,7 @@ static void tve_enable(struct imx_tve *tve) ...@@ -147,8 +147,7 @@ static void tve_enable(struct imx_tve *tve)
tve->enabled = true; tve->enabled = true;
clk_prepare_enable(tve->clk); clk_prepare_enable(tve->clk);
ret = regmap_update_bits(tve->regmap, TVE_COM_CONF_REG, ret = regmap_update_bits(tve->regmap, TVE_COM_CONF_REG,
TVE_IPU_CLK_EN | TVE_EN, TVE_EN, TVE_EN);
TVE_IPU_CLK_EN | TVE_EN);
} }
/* clear interrupt status register */ /* clear interrupt status register */
...@@ -171,7 +170,7 @@ static void tve_disable(struct imx_tve *tve) ...@@ -171,7 +170,7 @@ static void tve_disable(struct imx_tve *tve)
if (tve->enabled) { if (tve->enabled) {
tve->enabled = false; tve->enabled = false;
ret = regmap_update_bits(tve->regmap, TVE_COM_CONF_REG, ret = regmap_update_bits(tve->regmap, TVE_COM_CONF_REG,
TVE_IPU_CLK_EN | TVE_EN, 0); TVE_EN, 0);
clk_disable_unprepare(tve->clk); clk_disable_unprepare(tve->clk);
} }
} }
...@@ -274,18 +273,6 @@ static struct drm_encoder *imx_tve_connector_best_encoder( ...@@ -274,18 +273,6 @@ static struct drm_encoder *imx_tve_connector_best_encoder(
return &tve->imx_encoder.encoder; return &tve->imx_encoder.encoder;
} }
static void imx_tve_encoder_dpms(struct drm_encoder *encoder, int mode)
{
struct imx_drm_encoder *imx_encoder = enc_to_imx_enc(encoder);
struct imx_tve *tve = imx_enc_to_tve(imx_encoder);
int ret;
ret = regmap_update_bits(tve->regmap, TVE_COM_CONF_REG,
TVE_TV_OUT_MODE_MASK, TVE_TV_OUT_DISABLE);
if (ret < 0)
dev_err(tve->dev, "failed to disable TVOUT: %d\n", ret);
}
static void imx_tve_encoder_mode_set(struct drm_encoder *encoder, static void imx_tve_encoder_mode_set(struct drm_encoder *encoder,
struct drm_display_mode *orig_mode, struct drm_display_mode *orig_mode,
struct drm_display_mode *mode) struct drm_display_mode *mode)
...@@ -315,6 +302,9 @@ static void imx_tve_encoder_mode_set(struct drm_encoder *encoder, ...@@ -315,6 +302,9 @@ static void imx_tve_encoder_mode_set(struct drm_encoder *encoder,
ret); ret);
} }
regmap_update_bits(tve->regmap, TVE_COM_CONF_REG,
TVE_IPU_CLK_EN, TVE_IPU_CLK_EN);
if (tve->mode == TVE_MODE_VGA) if (tve->mode == TVE_MODE_VGA)
ret = tve_setup_vga(tve); ret = tve_setup_vga(tve);
else else
...@@ -323,7 +313,7 @@ static void imx_tve_encoder_mode_set(struct drm_encoder *encoder, ...@@ -323,7 +313,7 @@ static void imx_tve_encoder_mode_set(struct drm_encoder *encoder,
dev_err(tve->dev, "failed to set configuration: %d\n", ret); dev_err(tve->dev, "failed to set configuration: %d\n", ret);
} }
static void imx_tve_encoder_commit(struct drm_encoder *encoder) static void imx_tve_encoder_enable(struct drm_encoder *encoder)
{ {
struct imx_drm_encoder *imx_encoder = enc_to_imx_enc(encoder); struct imx_drm_encoder *imx_encoder = enc_to_imx_enc(encoder);
struct imx_tve *tve = imx_enc_to_tve(imx_encoder); struct imx_tve *tve = imx_enc_to_tve(imx_encoder);
...@@ -340,7 +330,7 @@ static void imx_tve_encoder_disable(struct drm_encoder *encoder) ...@@ -340,7 +330,7 @@ static void imx_tve_encoder_disable(struct drm_encoder *encoder)
} }
static const struct drm_connector_funcs imx_tve_connector_funcs = { static const struct drm_connector_funcs imx_tve_connector_funcs = {
.dpms = drm_helper_connector_dpms, .dpms = drm_atomic_helper_connector_dpms,
.fill_modes = drm_helper_probe_single_connector_modes, .fill_modes = drm_helper_probe_single_connector_modes,
.detect = imx_tve_connector_detect, .detect = imx_tve_connector_detect,
.destroy = imx_drm_connector_destroy, .destroy = imx_drm_connector_destroy,
...@@ -360,9 +350,8 @@ static const struct drm_encoder_funcs imx_tve_encoder_funcs = { ...@@ -360,9 +350,8 @@ static const struct drm_encoder_funcs imx_tve_encoder_funcs = {
}; };
static const struct drm_encoder_helper_funcs imx_tve_encoder_helper_funcs = { static const struct drm_encoder_helper_funcs imx_tve_encoder_helper_funcs = {
.dpms = imx_tve_encoder_dpms,
.mode_set = imx_tve_encoder_mode_set, .mode_set = imx_tve_encoder_mode_set,
.commit = imx_tve_encoder_commit, .enable = imx_tve_encoder_enable,
.disable = imx_tve_encoder_disable, .disable = imx_tve_encoder_disable,
}; };
......
...@@ -48,8 +48,9 @@ struct ipu_crtc { ...@@ -48,8 +48,9 @@ struct ipu_crtc {
#define to_ipu_crtc(x) container_of(x, struct ipu_crtc, base) #define to_ipu_crtc(x) container_of(x, struct ipu_crtc, base)
static void ipu_crtc_enable(struct ipu_crtc *ipu_crtc) static void ipu_crtc_enable(struct drm_crtc *crtc)
{ {
struct ipu_crtc *ipu_crtc = to_ipu_crtc(crtc);
struct ipu_soc *ipu = dev_get_drvdata(ipu_crtc->dev->parent); struct ipu_soc *ipu = dev_get_drvdata(ipu_crtc->dev->parent);
ipu_dc_enable(ipu); ipu_dc_enable(ipu);
...@@ -57,10 +58,10 @@ static void ipu_crtc_enable(struct ipu_crtc *ipu_crtc) ...@@ -57,10 +58,10 @@ static void ipu_crtc_enable(struct ipu_crtc *ipu_crtc)
ipu_di_enable(ipu_crtc->di); ipu_di_enable(ipu_crtc->di);
} }
static void ipu_crtc_disable(struct ipu_crtc *ipu_crtc) static void ipu_crtc_disable(struct drm_crtc *crtc)
{ {
struct ipu_crtc *ipu_crtc = to_ipu_crtc(crtc);
struct ipu_soc *ipu = dev_get_drvdata(ipu_crtc->dev->parent); struct ipu_soc *ipu = dev_get_drvdata(ipu_crtc->dev->parent);
struct drm_crtc *crtc = &ipu_crtc->base;
ipu_dc_disable_channel(ipu_crtc->dc); ipu_dc_disable_channel(ipu_crtc->dc);
ipu_di_disable(ipu_crtc->di); ipu_di_disable(ipu_crtc->di);
...@@ -74,24 +75,6 @@ static void ipu_crtc_disable(struct ipu_crtc *ipu_crtc) ...@@ -74,24 +75,6 @@ static void ipu_crtc_disable(struct ipu_crtc *ipu_crtc)
spin_unlock_irq(&crtc->dev->event_lock); spin_unlock_irq(&crtc->dev->event_lock);
} }
static void ipu_crtc_dpms(struct drm_crtc *crtc, int mode)
{
struct ipu_crtc *ipu_crtc = to_ipu_crtc(crtc);
dev_dbg(ipu_crtc->dev, "%s mode: %d\n", __func__, mode);
switch (mode) {
case DRM_MODE_DPMS_ON:
ipu_crtc_enable(ipu_crtc);
break;
case DRM_MODE_DPMS_STANDBY:
case DRM_MODE_DPMS_SUSPEND:
case DRM_MODE_DPMS_OFF:
ipu_crtc_disable(ipu_crtc);
break;
}
}
static const struct drm_crtc_funcs ipu_crtc_funcs = { static const struct drm_crtc_funcs ipu_crtc_funcs = {
.set_config = drm_atomic_helper_set_config, .set_config = drm_atomic_helper_set_config,
.destroy = drm_crtc_cleanup, .destroy = drm_crtc_cleanup,
...@@ -132,20 +115,6 @@ static bool ipu_crtc_mode_fixup(struct drm_crtc *crtc, ...@@ -132,20 +115,6 @@ static bool ipu_crtc_mode_fixup(struct drm_crtc *crtc,
return true; return true;
} }
static void ipu_crtc_prepare(struct drm_crtc *crtc)
{
struct ipu_crtc *ipu_crtc = to_ipu_crtc(crtc);
ipu_crtc_disable(ipu_crtc);
}
static void ipu_crtc_commit(struct drm_crtc *crtc)
{
struct ipu_crtc *ipu_crtc = to_ipu_crtc(crtc);
ipu_crtc_enable(ipu_crtc);
}
static int ipu_crtc_atomic_check(struct drm_crtc *crtc, static int ipu_crtc_atomic_check(struct drm_crtc *crtc,
struct drm_crtc_state *state) struct drm_crtc_state *state)
{ {
...@@ -225,13 +194,12 @@ static void ipu_crtc_mode_set_nofb(struct drm_crtc *crtc) ...@@ -225,13 +194,12 @@ static void ipu_crtc_mode_set_nofb(struct drm_crtc *crtc)
} }
static const struct drm_crtc_helper_funcs ipu_helper_funcs = { static const struct drm_crtc_helper_funcs ipu_helper_funcs = {
.dpms = ipu_crtc_dpms,
.mode_fixup = ipu_crtc_mode_fixup, .mode_fixup = ipu_crtc_mode_fixup,
.mode_set_nofb = ipu_crtc_mode_set_nofb, .mode_set_nofb = ipu_crtc_mode_set_nofb,
.prepare = ipu_crtc_prepare,
.commit = ipu_crtc_commit,
.atomic_check = ipu_crtc_atomic_check, .atomic_check = ipu_crtc_atomic_check,
.atomic_begin = ipu_crtc_atomic_begin, .atomic_begin = ipu_crtc_atomic_begin,
.disable = ipu_crtc_disable,
.enable = ipu_crtc_enable,
}; };
static int ipu_enable_vblank(struct drm_crtc *crtc) static int ipu_enable_vblank(struct drm_crtc *crtc)
......
...@@ -92,18 +92,7 @@ static struct drm_encoder *imx_pd_connector_best_encoder( ...@@ -92,18 +92,7 @@ static struct drm_encoder *imx_pd_connector_best_encoder(
return &imxpd->imx_encoder.encoder; return &imxpd->imx_encoder.encoder;
} }
static void imx_pd_encoder_dpms(struct drm_encoder *encoder, int mode) static void imx_pd_encoder_enable(struct drm_encoder *encoder)
{
struct imx_drm_encoder *imx_encoder = enc_to_imx_enc(encoder);
struct imx_parallel_display *imxpd = imx_enc_to_imxpd(imx_encoder);
if (mode != DRM_MODE_DPMS_ON)
drm_panel_disable(imxpd->panel);
else
drm_panel_enable(imxpd->panel);
}
static void imx_pd_encoder_commit(struct drm_encoder *encoder)
{ {
struct imx_drm_encoder *imx_encoder = enc_to_imx_enc(encoder); struct imx_drm_encoder *imx_encoder = enc_to_imx_enc(encoder);
struct imx_parallel_display *imxpd = imx_enc_to_imxpd(imx_encoder); struct imx_parallel_display *imxpd = imx_enc_to_imxpd(imx_encoder);
...@@ -128,7 +117,7 @@ static void imx_pd_encoder_disable(struct drm_encoder *encoder) ...@@ -128,7 +117,7 @@ static void imx_pd_encoder_disable(struct drm_encoder *encoder)
} }
static const struct drm_connector_funcs imx_pd_connector_funcs = { static const struct drm_connector_funcs imx_pd_connector_funcs = {
.dpms = drm_helper_connector_dpms, .dpms = drm_atomic_helper_connector_dpms,
.fill_modes = drm_helper_probe_single_connector_modes, .fill_modes = drm_helper_probe_single_connector_modes,
.detect = imx_pd_connector_detect, .detect = imx_pd_connector_detect,
.destroy = imx_drm_connector_destroy, .destroy = imx_drm_connector_destroy,
...@@ -147,9 +136,8 @@ static const struct drm_encoder_funcs imx_pd_encoder_funcs = { ...@@ -147,9 +136,8 @@ static const struct drm_encoder_funcs imx_pd_encoder_funcs = {
}; };
static const struct drm_encoder_helper_funcs imx_pd_encoder_helper_funcs = { static const struct drm_encoder_helper_funcs imx_pd_encoder_helper_funcs = {
.dpms = imx_pd_encoder_dpms,
.commit = imx_pd_encoder_commit,
.mode_set = imx_pd_encoder_mode_set, .mode_set = imx_pd_encoder_mode_set,
.enable = imx_pd_encoder_enable,
.disable = imx_pd_encoder_disable, .disable = imx_pd_encoder_disable,
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment