drm/mediatek: Plumb supported rotation values from components to plane init
authorSean Paul <seanpaul@chromium.org>
Tue, 5 Nov 2019 21:10:21 +0000 (16:10 -0500)
committerCK Hu <ck.hu@mediatek.com>
Wed, 6 Nov 2019 08:00:44 +0000 (16:00 +0800)
This patch adds the ability for components to expose supported rotations
which will be exposed to userspace via a plane rotation property.

No functional changes in this patch.

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_ddp_comp.h
drivers/gpu/drm/mediatek/mtk_drm_plane.c
drivers/gpu/drm/mediatek/mtk_drm_plane.h

index 04e7e4bdbdb5f63a64fb53b110d7af7c2b3c3296..f80a8ba759770f82fa435cc97f5b63649477c52e 100644 (file)
@@ -600,13 +600,15 @@ static int mtk_drm_crtc_init_comp_planes(struct drm_device *drm_dev,
                                         int comp_idx, int pipe)
 {
        int num_planes = mtk_drm_crtc_num_comp_planes(mtk_crtc, comp_idx);
+       struct mtk_ddp_comp *comp = mtk_crtc->ddp_comp[comp_idx];
        int i, ret;
 
        for (i = 0; i < num_planes; i++) {
                ret = mtk_plane_init(drm_dev,
                                &mtk_crtc->planes[mtk_crtc->layer_nr],
                                BIT(pipe),
-                               mtk_drm_crtc_plane_type(mtk_crtc->layer_nr));
+                               mtk_drm_crtc_plane_type(mtk_crtc->layer_nr),
+                               mtk_ddp_comp_supported_rotations(comp));
                if (ret)
                        return ret;
 
index 3de371e28bdf5c075038762ac818221119e94846..2f1e9e75b8da4699c4e8cc5ae4a228061d3fda8c 100644 (file)
@@ -77,6 +77,7 @@ struct mtk_ddp_comp_funcs {
        void (*stop)(struct mtk_ddp_comp *comp);
        void (*enable_vblank)(struct mtk_ddp_comp *comp, struct drm_crtc *crtc);
        void (*disable_vblank)(struct mtk_ddp_comp *comp);
+       unsigned int (*supported_rotations)(struct mtk_ddp_comp *comp);
        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);
@@ -133,6 +134,15 @@ static inline void mtk_ddp_comp_disable_vblank(struct mtk_ddp_comp *comp)
                comp->funcs->disable_vblank(comp);
 }
 
+static inline
+unsigned int mtk_ddp_comp_supported_rotations(struct mtk_ddp_comp *comp)
+{
+       if (comp->funcs && comp->funcs->supported_rotations)
+               return comp->funcs->supported_rotations(comp);
+
+       return 0;
+}
+
 static inline unsigned int mtk_ddp_comp_layer_nr(struct mtk_ddp_comp *comp)
 {
        if (comp->funcs && comp->funcs->layer_nr)
index 53231938228e6f3c2584cb72c4a0f3e71226c77e..3b0cc91c7023aa91c62631c09145631449c717fa 100644 (file)
@@ -144,6 +144,7 @@ static void mtk_plane_atomic_update(struct drm_plane *plane,
        state->pending.y = plane->state->dst.y1;
        state->pending.width = drm_rect_width(&plane->state->dst);
        state->pending.height = drm_rect_height(&plane->state->dst);
+       state->pending.rotation = plane->state->rotation;
        wmb(); /* Make sure the above parameters are set before update */
        state->pending.dirty = true;
 }
@@ -166,7 +167,8 @@ static const struct drm_plane_helper_funcs mtk_plane_helper_funcs = {
 };
 
 int mtk_plane_init(struct drm_device *dev, struct drm_plane *plane,
-                  unsigned long possible_crtcs, enum drm_plane_type type)
+                  unsigned long possible_crtcs, enum drm_plane_type type,
+                  unsigned int supported_rotations)
 {
        int err;
 
@@ -178,6 +180,14 @@ int mtk_plane_init(struct drm_device *dev, struct drm_plane *plane,
                return err;
        }
 
+       if (supported_rotations & ~DRM_MODE_ROTATE_0) {
+               err = drm_plane_create_rotation_property(plane,
+                                                        DRM_MODE_ROTATE_0,
+                                                        supported_rotations);
+               if (err)
+                       DRM_INFO("Create rotation property failed\n");
+       }
+
        drm_plane_helper_add(plane, &mtk_plane_helper_funcs);
 
        return 0;
index 6f842df722c7cc2ac99ea8c125d949b26dec6cb9..760885e35b275c36c713bae2d31c02e5d551bd8b 100644 (file)
@@ -20,6 +20,7 @@ struct mtk_plane_pending_state {
        unsigned int                    y;
        unsigned int                    width;
        unsigned int                    height;
+       unsigned int                    rotation;
        bool                            dirty;
 };
 
@@ -35,6 +36,7 @@ to_mtk_plane_state(struct drm_plane_state *state)
 }
 
 int mtk_plane_init(struct drm_device *dev, struct drm_plane *plane,
-                  unsigned long possible_crtcs, enum drm_plane_type type);
+                  unsigned long possible_crtcs, enum drm_plane_type type,
+                  unsigned int supported_rotations);
 
 #endif