On Mon, Oct 28, 2019 at 04:49:26PM +0100, Thomas Zimmermann wrote: > As the CRTC code has already been prepared for a split between mode > setting and plane handling, most of the CRTC's atomic modesetting is > build upon primitives of the non-atomic implementation. > > Signed-off-by: Thomas Zimmermann <tzimmermann@xxxxxxx> Acked-by: Gerd Hoffmann <kraxel@xxxxxxxxxx> > --- > drivers/gpu/drm/ast/ast_mode.c | 105 ++++++++++++++++++++++++++++++++- > 1 file changed, 104 insertions(+), 1 deletion(-) > > diff --git a/drivers/gpu/drm/ast/ast_mode.c b/drivers/gpu/drm/ast/ast_mode.c > index dbbfc4d44cb5..7667f4502eb9 100644 > --- a/drivers/gpu/drm/ast/ast_mode.c > +++ b/drivers/gpu/drm/ast/ast_mode.c > @@ -728,6 +728,103 @@ static void ast_crtc_commit(struct drm_crtc *crtc) > ast_crtc_load_lut(crtc); > } > > +static int ast_crtc_helper_atomic_check(struct drm_crtc *crtc, > + struct drm_crtc_state *state) > +{ > + struct ast_private *ast = crtc->dev->dev_private; > + struct drm_plane_state *plane_state; > + bool succ; > + struct drm_display_mode adjusted_mode; > + struct ast_vbios_mode_info vbios_mode; > + > + if (ast->chip == AST1180) { > + DRM_ERROR("AST 1180 modesetting not supported\n"); > + return -EINVAL; > + } > + > + plane_state = crtc->primary->state; > + > + if (plane_state && plane_state->fb) { > + succ = ast_get_vbios_mode_info(plane_state->fb, &state->mode, > + &adjusted_mode, &vbios_mode); > + if (!succ) > + return -EINVAL; > + } > + > + return 0; > +} > + > +static void ast_crtc_helper_atomic_begin(struct drm_crtc *crtc, > + struct drm_crtc_state *old_crtc_state) > +{ > + struct ast_private *ast = crtc->dev->dev_private; > + > + ast_open_key(ast); > +} > + > +static void ast_crtc_helper_atomic_flush(struct drm_crtc *crtc, > + struct drm_crtc_state *old_crtc_state) > +{ > + const struct drm_framebuffer *fb = crtc->primary->state->fb; > + struct drm_display_mode adjusted_mode; > + struct ast_vbios_mode_info vbios_mode; > + bool succ; > + > + crtc->state->no_vblank = true; > + > + if (!fb) > + return; > + > + ast_set_color_reg(crtc, fb); > + > + memset(&adjusted_mode, 0, sizeof(adjusted_mode)); > + drm_mode_copy(&adjusted_mode, &crtc->state->adjusted_mode); > + > + succ = ast_get_vbios_mode_info(fb, &crtc->state->adjusted_mode, > + &adjusted_mode, &vbios_mode); > + if (WARN_ON_ONCE(!succ)) > + return; > + > + ast_set_vbios_color_reg(crtc, fb, &vbios_mode); > +} > + > +static void > +ast_crtc_helper_atomic_enable(struct drm_crtc *crtc, > + struct drm_crtc_state *old_crtc_state) > +{ > + struct drm_device *dev = crtc->dev; > + struct ast_private *ast = crtc->dev->dev_private; > + const struct drm_framebuffer *fb = crtc->primary->state->fb; > + struct drm_display_mode adjusted_mode; > + struct ast_vbios_mode_info vbios_mode; > + bool succ; > + > + memset(&adjusted_mode, 0, sizeof(adjusted_mode)); > + drm_mode_copy(&adjusted_mode, &crtc->state->adjusted_mode); > + > + succ = ast_get_vbios_mode_info(fb, &crtc->state->adjusted_mode, > + &adjusted_mode, &vbios_mode); > + if (WARN_ON_ONCE(!succ)) > + return; > + > + ast_set_vbios_mode_reg(crtc, &adjusted_mode, &vbios_mode); > + ast_set_index_reg(ast, AST_IO_CRTC_PORT, 0xa1, 0x06); > + ast_set_std_reg(crtc, &adjusted_mode, &vbios_mode); > + ast_set_crtc_reg(crtc, &adjusted_mode, &vbios_mode); > + ast_set_dclk_reg(dev, &adjusted_mode, &vbios_mode); > + ast_set_crtthd_reg(crtc); > + ast_set_sync_reg(dev, &adjusted_mode, &vbios_mode); > + ast_set_dac_reg(crtc, &adjusted_mode, &vbios_mode); > + > + ast_crtc_dpms(crtc, DRM_MODE_DPMS_ON); > +} > + > +static void > +ast_crtc_helper_atomic_disable(struct drm_crtc *crtc, > + struct drm_crtc_state *old_crtc_state) > +{ > + ast_crtc_dpms(crtc, DRM_MODE_DPMS_OFF); > +} > > static const struct drm_crtc_helper_funcs ast_crtc_helper_funcs = { > .dpms = ast_crtc_dpms, > @@ -736,7 +833,11 @@ static const struct drm_crtc_helper_funcs ast_crtc_helper_funcs = { > .disable = ast_crtc_disable, > .prepare = ast_crtc_prepare, > .commit = ast_crtc_commit, > - > + .atomic_check = ast_crtc_helper_atomic_check, > + .atomic_begin = ast_crtc_helper_atomic_begin, > + .atomic_flush = ast_crtc_helper_atomic_flush, > + .atomic_enable = ast_crtc_helper_atomic_enable, > + .atomic_disable = ast_crtc_helper_atomic_disable, > }; > > static void ast_crtc_reset(struct drm_crtc *crtc) > @@ -767,6 +868,8 @@ static const struct drm_crtc_funcs ast_crtc_funcs = { > .set_config = drm_crtc_helper_set_config, > .gamma_set = ast_crtc_gamma_set, > .destroy = ast_crtc_destroy, > + .atomic_duplicate_state = drm_atomic_helper_crtc_duplicate_state, > + .atomic_destroy_state = drm_atomic_helper_crtc_destroy_state, > }; > > static int ast_crtc_init(struct drm_device *dev) > -- > 2.23.0 > _______________________________________________ dri-devel mailing list dri-devel@xxxxxxxxxxxxxxxxxxxxx https://lists.freedesktop.org/mailman/listinfo/dri-devel