]> git.baikalelectronics.ru Git - kernel.git/commitdiff
drm/mediatek: Add plumbing for layer_check hook
authorSean Paul <seanpaul@chromium.org>
Tue, 5 Nov 2019 21:10:20 +0000 (16:10 -0500)
committerCK Hu <ck.hu@mediatek.com>
Wed, 6 Nov 2019 08:00:44 +0000 (16:00 +0800)
This allows components to implement a .layer_check callback for their
layers which is called during atomic_check.

Signed-off-by: Sean Paul <seanpaul@chromium.org>
Signed-off-by: CK Hu <ck.hu@mediatek.com>
drivers/gpu/drm/mediatek/mtk_drm_crtc.c
drivers/gpu/drm/mediatek/mtk_drm_crtc.h
drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.h
drivers/gpu/drm/mediatek/mtk_drm_plane.c

index ccf395f17a9932b5776efd8862a07caa6f680dca..04e7e4bdbdb5f63a64fb53b110d7af7c2b3c3296 100644 (file)
@@ -394,6 +394,16 @@ static void mtk_crtc_ddp_config(struct drm_crtc *crtc)
        }
 }
 
+int mtk_drm_crtc_plane_check(struct drm_crtc *crtc, struct drm_plane *plane,
+                            struct mtk_plane_state *state)
+{
+       unsigned int local_layer;
+       struct mtk_ddp_comp *comp;
+
+       comp = mtk_drm_ddp_comp_for_plane(crtc, plane, &local_layer);
+       return mtk_ddp_comp_layer_check(comp, local_layer, state);
+}
+
 static void mtk_drm_crtc_atomic_enable(struct drm_crtc *crtc,
                                       struct drm_crtc_state *old_state)
 {
index fcc134eb00c9259a58d645aa1f9da68c702db100..6afe1c19557a4de4a18851fb20059a69dd87c07d 100644 (file)
@@ -19,5 +19,7 @@ void mtk_crtc_ddp_irq(struct drm_crtc *crtc, struct mtk_ddp_comp *comp);
 int mtk_drm_crtc_create(struct drm_device *drm_dev,
                        const enum mtk_ddp_comp_id *path,
                        unsigned int path_len);
+int mtk_drm_crtc_plane_check(struct drm_crtc *crtc, struct drm_plane *plane,
+                            struct mtk_plane_state *state);
 
 #endif /* MTK_DRM_CRTC_H */
index 26441f4d1ad377f4c9e2bc8f5f177d06b384566d..3de371e28bdf5c075038762ac818221119e94846 100644 (file)
@@ -80,6 +80,9 @@ struct mtk_ddp_comp_funcs {
        unsigned int (*layer_nr)(struct mtk_ddp_comp *comp);
        void (*layer_on)(struct mtk_ddp_comp *comp, unsigned int idx);
        void (*layer_off)(struct mtk_ddp_comp *comp, unsigned int idx);
+       int (*layer_check)(struct mtk_ddp_comp *comp,
+                          unsigned int idx,
+                          struct mtk_plane_state *state);
        void (*layer_config)(struct mtk_ddp_comp *comp, unsigned int idx,
                             struct mtk_plane_state *state);
        void (*gamma_set)(struct mtk_ddp_comp *comp,
@@ -152,6 +155,15 @@ static inline void mtk_ddp_comp_layer_off(struct mtk_ddp_comp *comp,
                comp->funcs->layer_off(comp, idx);
 }
 
+static inline int mtk_ddp_comp_layer_check(struct mtk_ddp_comp *comp,
+                                          unsigned int idx,
+                                          struct mtk_plane_state *state)
+{
+       if (comp->funcs && comp->funcs->layer_check)
+               return comp->funcs->layer_check(comp, idx, state);
+       return 0;
+}
+
 static inline void mtk_ddp_comp_layer_config(struct mtk_ddp_comp *comp,
                                             unsigned int idx,
                                             struct mtk_plane_state *state)
index 49d59470cc1140cb4041752d7936acdbcbd7cb4c..53231938228e6f3c2584cb72c4a0f3e71226c77e 100644 (file)
@@ -90,6 +90,7 @@ static int mtk_plane_atomic_check(struct drm_plane *plane,
 {
        struct drm_framebuffer *fb = state->fb;
        struct drm_crtc_state *crtc_state;
+       int ret;
 
        if (!fb)
                return 0;
@@ -97,6 +98,11 @@ static int mtk_plane_atomic_check(struct drm_plane *plane,
        if (!state->crtc)
                return 0;
 
+       ret = mtk_drm_crtc_plane_check(state->crtc, plane,
+                                      to_mtk_plane_state(state));
+       if (ret)
+               return ret;
+
        crtc_state = drm_atomic_get_crtc_state(state->state, state->crtc);
        if (IS_ERR(crtc_state))
                return PTR_ERR(crtc_state);