Skip to content

Commit 103b907

Browse files
AngeloGioacchino Del RegnoChun-Kuang Hu
authored andcommitted
drm/mediatek: Declare Z Position for all planes
MediaTek SoCs support multiple planes, one of which is the primary and all the others are overlays (and CURSOR is the last overlay). In all currently supported SoCs, the Z order of the overlays can't be changed with any fast muxing action, and can only be changed by swapping the contents of the entire register set of one overlay with the other to internally reorder the layer properties, which is indeed feasible, but probably more expensive than desired. Declare the Z position for all planes with an immutable property at least for now, so that the userspace can take its decisions accordingly. Signed-off-by: AngeloGioacchino Del Regno <[email protected]> Reviewed-by: Fei Shao <[email protected]> Acked-by: Daniel Stone <[email protected]> Reviewed-by: CK Hu <[email protected]> Link: https://patchwork.kernel.org/project/dri-devel/patch/[email protected]/ Signed-off-by: Chun-Kuang Hu <[email protected]>
1 parent 6a4ae7f commit 103b907

File tree

3 files changed

+19
-4
lines changed

3 files changed

+19
-4
lines changed

drivers/gpu/drm/mediatek/mtk_crtc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -887,7 +887,7 @@ static int mtk_crtc_init_comp_planes(struct drm_device *drm_dev,
887887
mtk_crtc_plane_type(mtk_crtc->layer_nr, num_planes),
888888
mtk_ddp_comp_supported_rotations(comp),
889889
mtk_ddp_comp_get_formats(comp),
890-
mtk_ddp_comp_get_num_formats(comp));
890+
mtk_ddp_comp_get_num_formats(comp), i);
891891
if (ret)
892892
return ret;
893893

drivers/gpu/drm/mediatek/mtk_plane.c

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,7 @@ static const struct drm_plane_helper_funcs mtk_plane_helper_funcs = {
321321
int mtk_plane_init(struct drm_device *dev, struct drm_plane *plane,
322322
unsigned long possible_crtcs, enum drm_plane_type type,
323323
unsigned int supported_rotations, const u32 *formats,
324-
size_t num_formats)
324+
size_t num_formats, unsigned int plane_idx)
325325
{
326326
int err;
327327

@@ -338,6 +338,22 @@ int mtk_plane_init(struct drm_device *dev, struct drm_plane *plane,
338338
return err;
339339
}
340340

341+
/*
342+
* The hardware does not support repositioning planes by muxing: their
343+
* Z-position is infact fixed and the only way to change the actual
344+
* order is to swap the contents of the entire register set of one
345+
* overlay with another, which may be more expensive than desired.
346+
*
347+
* With no repositioning, the caller of this function guarantees that
348+
* the plane_idx is correct. This means that, for example, the PRIMARY
349+
* plane fed to this function will always have plane_idx zero.
350+
*/
351+
err = drm_plane_create_zpos_immutable_property(plane, plane_idx);
352+
if (err) {
353+
DRM_ERROR("Failed to create zpos property for plane %u\n", plane_idx);
354+
return err;
355+
}
356+
341357
if (supported_rotations) {
342358
err = drm_plane_create_rotation_property(plane,
343359
DRM_MODE_ROTATE_0,

drivers/gpu/drm/mediatek/mtk_plane.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,5 @@ to_mtk_plane_state(struct drm_plane_state *state)
4949
int mtk_plane_init(struct drm_device *dev, struct drm_plane *plane,
5050
unsigned long possible_crtcs, enum drm_plane_type type,
5151
unsigned int supported_rotations, const u32 *formats,
52-
size_t num_formats);
53-
52+
size_t num_formats, unsigned int plane_idx);
5453
#endif

0 commit comments

Comments
 (0)