Skip to content

Commit 65eab9a

Browse files
author
Jyri Sarha
committed
drm/tilcdc: Add tilcdc_crtc_atomic_check()
commit db380c5 upstream. (back ported for older struct drm_atomic_state) Add tilcdc_crtc_atomic_check(). Checks the display mode validity and the presence of the mandatory primary plane. The drm_crtc_helper_funcs mode_fixup() callback is left untouched and the check function does no try to do its job on purpose, despite what the mode_fixup() callback's documentations suggests. The plane's check() callback needs to set drm_crtc_state's ->mode_changed to true if the pixel format for the framebuffer changes. Because of this drm_mode_config_funcs atomic_check() callback needs to call drm_atomic_helper_check_modeset() once more after it has called drm_atomic_helper_check_planes(). If the fixing of the adjusted_mode would be done in drm_crtc_helper_funcs atomic_check() callback, it would get over written by the extra drm_atomic_helper_check_modeset() call. Signed-off-by: Jyri Sarha <[email protected]>
1 parent e6cbc04 commit 65eab9a

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

drivers/gpu/drm/tilcdc/tilcdc_crtc.c

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -474,6 +474,32 @@ static void tilcdc_crtc_mode_set_nofb(struct drm_crtc *crtc)
474474
crtc->hwmode = crtc->state->adjusted_mode;
475475
}
476476

477+
static int tilcdc_crtc_atomic_check(struct drm_crtc *crtc,
478+
struct drm_crtc_state *state)
479+
{
480+
struct drm_display_mode *mode = &state->mode;
481+
int ret;
482+
483+
/* If we are not active we don't care */
484+
if (!state->active)
485+
return 0;
486+
487+
if (state->state->planes[0] != crtc->primary ||
488+
state->state->plane_states[0] == NULL ||
489+
state->state->plane_states[0]->crtc != crtc) {
490+
dev_dbg(crtc->dev->dev, "CRTC primary plane must be present");
491+
return -EINVAL;
492+
}
493+
494+
ret = tilcdc_crtc_mode_valid(crtc, mode);
495+
if (ret) {
496+
dev_dbg(crtc->dev->dev, "Mode \"%s\" not valid", mode->name);
497+
return -EINVAL;
498+
}
499+
500+
return 0;
501+
}
502+
477503
static int tilcdc_crtc_mode_set(struct drm_crtc *crtc,
478504
struct drm_display_mode *mode,
479505
struct drm_display_mode *adjusted_mode,
@@ -690,6 +716,7 @@ static const struct drm_crtc_helper_funcs tilcdc_crtc_helper_funcs = {
690716
.commit = tilcdc_crtc_commit,
691717
.mode_set = tilcdc_crtc_mode_set,
692718
.mode_set_base = tilcdc_crtc_mode_set_base,
719+
.atomic_check = tilcdc_crtc_atomic_check,
693720
.mode_set_nofb = tilcdc_crtc_mode_set_nofb,
694721
};
695722

0 commit comments

Comments
 (0)