On Tue, 2025-12-23 at 16:44 -0300, Nícolas F. R. A. Prado wrote:
> External email : Please do not click links or open attachments until you have 
> verified the sender or the content.
> 
> 
> Add an atomic check hook for the CRTC and use it to verify that any 3x3
> Matrix colorop, which requires the DATA property to be set, does in fact
> have it set.

Reviewed-by: CK Hu <[email protected]>

> 
> Signed-off-by: Nícolas F. R. A. Prado <[email protected]>
> ---
>  drivers/gpu/drm/mediatek/mtk_crtc.c | 26 ++++++++++++++++++++++++++
>  1 file changed, 26 insertions(+)
> 
> diff --git a/drivers/gpu/drm/mediatek/mtk_crtc.c 
> b/drivers/gpu/drm/mediatek/mtk_crtc.c
> index f7db235d986f..1a55d5df6dbe 100644
> --- a/drivers/gpu/drm/mediatek/mtk_crtc.c
> +++ b/drivers/gpu/drm/mediatek/mtk_crtc.c
> @@ -897,6 +897,31 @@ static void mtk_crtc_atomic_flush(struct drm_crtc *crtc,
>         mtk_crtc_update_config(mtk_crtc, !!mtk_crtc->event);
>  }
> 
> +static int mtk_crtc_atomic_check(struct drm_crtc *crtc,
> +                                struct drm_atomic_state *state)
> +{
> +       struct drm_colorop_state *new_colorop_state;
> +       struct drm_colorop *colorop;
> +       int i;
> +
> +       for_each_new_colorop_in_state(state, colorop, new_colorop_state, i) {
> +               switch (colorop->type) {
> +               case DRM_COLOROP_CTM_3X3:
> +                       if (!new_colorop_state->bypass && 
> !new_colorop_state->data) {
> +                               drm_dbg_atomic(crtc->dev,
> +                                              "Missing required DATA 
> property for COLOROP:%d\n",
> +                                              colorop->base.id);
> +                               return -EINVAL;
> +                       }
> +                       break;
> +               default:
> +                       break;
> +               }
> +       }
> +
> +       return 0;
> +}
> +
>  static const struct drm_crtc_funcs mtk_crtc_funcs = {
>         .set_config             = drm_atomic_helper_set_config,
>         .page_flip              = drm_atomic_helper_page_flip,
> @@ -914,6 +939,7 @@ static const struct drm_crtc_helper_funcs 
> mtk_crtc_helper_funcs = {
>         .mode_valid     = mtk_crtc_mode_valid,
>         .atomic_begin   = mtk_crtc_atomic_begin,
>         .atomic_flush   = mtk_crtc_atomic_flush,
> +       .atomic_check   = mtk_crtc_atomic_check,
>         .atomic_enable  = mtk_crtc_atomic_enable,
>         .atomic_disable = mtk_crtc_atomic_disable,
>  };
> 
> --
> 2.51.0
> 

Reply via email to