Skip to content

Commit ef87d3e

Browse files
atseanpaulckhu-mediatek
authored andcommitted
drm/mediatek: Plumb supported rotation values from components to plane init
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 <[email protected]> Signed-off-by: CK Hu <[email protected]>
1 parent f7c710d commit ef87d3e

File tree

4 files changed

+27
-3
lines changed

4 files changed

+27
-3
lines changed

drivers/gpu/drm/mediatek/mtk_drm_crtc.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -600,13 +600,15 @@ static int mtk_drm_crtc_init_comp_planes(struct drm_device *drm_dev,
600600
int comp_idx, int pipe)
601601
{
602602
int num_planes = mtk_drm_crtc_num_comp_planes(mtk_crtc, comp_idx);
603+
struct mtk_ddp_comp *comp = mtk_crtc->ddp_comp[comp_idx];
603604
int i, ret;
604605

605606
for (i = 0; i < num_planes; i++) {
606607
ret = mtk_plane_init(drm_dev,
607608
&mtk_crtc->planes[mtk_crtc->layer_nr],
608609
BIT(pipe),
609-
mtk_drm_crtc_plane_type(mtk_crtc->layer_nr));
610+
mtk_drm_crtc_plane_type(mtk_crtc->layer_nr),
611+
mtk_ddp_comp_supported_rotations(comp));
610612
if (ret)
611613
return ret;
612614

drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ struct mtk_ddp_comp_funcs {
7777
void (*stop)(struct mtk_ddp_comp *comp);
7878
void (*enable_vblank)(struct mtk_ddp_comp *comp, struct drm_crtc *crtc);
7979
void (*disable_vblank)(struct mtk_ddp_comp *comp);
80+
unsigned int (*supported_rotations)(struct mtk_ddp_comp *comp);
8081
unsigned int (*layer_nr)(struct mtk_ddp_comp *comp);
8182
void (*layer_on)(struct mtk_ddp_comp *comp, unsigned int idx);
8283
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)
133134
comp->funcs->disable_vblank(comp);
134135
}
135136

137+
static inline
138+
unsigned int mtk_ddp_comp_supported_rotations(struct mtk_ddp_comp *comp)
139+
{
140+
if (comp->funcs && comp->funcs->supported_rotations)
141+
return comp->funcs->supported_rotations(comp);
142+
143+
return 0;
144+
}
145+
136146
static inline unsigned int mtk_ddp_comp_layer_nr(struct mtk_ddp_comp *comp)
137147
{
138148
if (comp->funcs && comp->funcs->layer_nr)

drivers/gpu/drm/mediatek/mtk_drm_plane.c

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,7 @@ static void mtk_plane_atomic_update(struct drm_plane *plane,
144144
state->pending.y = plane->state->dst.y1;
145145
state->pending.width = drm_rect_width(&plane->state->dst);
146146
state->pending.height = drm_rect_height(&plane->state->dst);
147+
state->pending.rotation = plane->state->rotation;
147148
wmb(); /* Make sure the above parameters are set before update */
148149
state->pending.dirty = true;
149150
}
@@ -166,7 +167,8 @@ static const struct drm_plane_helper_funcs mtk_plane_helper_funcs = {
166167
};
167168

168169
int mtk_plane_init(struct drm_device *dev, struct drm_plane *plane,
169-
unsigned long possible_crtcs, enum drm_plane_type type)
170+
unsigned long possible_crtcs, enum drm_plane_type type,
171+
unsigned int supported_rotations)
170172
{
171173
int err;
172174

@@ -178,6 +180,14 @@ int mtk_plane_init(struct drm_device *dev, struct drm_plane *plane,
178180
return err;
179181
}
180182

183+
if (supported_rotations & ~DRM_MODE_ROTATE_0) {
184+
err = drm_plane_create_rotation_property(plane,
185+
DRM_MODE_ROTATE_0,
186+
supported_rotations);
187+
if (err)
188+
DRM_INFO("Create rotation property failed\n");
189+
}
190+
181191
drm_plane_helper_add(plane, &mtk_plane_helper_funcs);
182192

183193
return 0;

drivers/gpu/drm/mediatek/mtk_drm_plane.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ struct mtk_plane_pending_state {
2020
unsigned int y;
2121
unsigned int width;
2222
unsigned int height;
23+
unsigned int rotation;
2324
bool dirty;
2425
};
2526

@@ -35,6 +36,7 @@ to_mtk_plane_state(struct drm_plane_state *state)
3536
}
3637

3738
int mtk_plane_init(struct drm_device *dev, struct drm_plane *plane,
38-
unsigned long possible_crtcs, enum drm_plane_type type);
39+
unsigned long possible_crtcs, enum drm_plane_type type,
40+
unsigned int supported_rotations);
3941

4042
#endif

0 commit comments

Comments
 (0)