]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
drm/mediatek: Declare Z Position for all planes
authorAngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Thu, 18 Jul 2024 08:25:07 +0000 (10:25 +0200)
committerChun-Kuang Hu <chunkuang.hu@kernel.org>
Thu, 29 Aug 2024 14:26:14 +0000 (14:26 +0000)
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 <angelogioacchino.delregno@collabora.com>
Reviewed-by: Fei Shao <fshao@chromium.org>
Acked-by: Daniel Stone <daniels@collabora.com>
Reviewed-by: CK Hu <ck.hu@mediatek.com>
Link: https://patchwork.kernel.org/project/dri-devel/patch/20240718082507.216764-1-angelogioacchino.delregno@collabora.com/
Signed-off-by: Chun-Kuang Hu <chunkuang.hu@kernel.org>
drivers/gpu/drm/mediatek/mtk_crtc.c
drivers/gpu/drm/mediatek/mtk_plane.c
drivers/gpu/drm/mediatek/mtk_plane.h

index 5413c0c3dfe8e03cd319569e4ce58acb7854b0ed..07ff6b9637e3bf6bc367219370649c138d6548f1 100644 (file)
@@ -887,7 +887,7 @@ static int mtk_crtc_init_comp_planes(struct drm_device *drm_dev,
                                mtk_crtc_plane_type(mtk_crtc->layer_nr, num_planes),
                                mtk_ddp_comp_supported_rotations(comp),
                                mtk_ddp_comp_get_formats(comp),
-                               mtk_ddp_comp_get_num_formats(comp));
+                               mtk_ddp_comp_get_num_formats(comp), i);
                if (ret)
                        return ret;
 
index 5bf757a3ef202f90cfcd20fdcbf079c2c6448f69..7d2cb4e0fafad1e4f31933cbbf83f7de9b954907 100644 (file)
@@ -321,7 +321,7 @@ 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 int supported_rotations, const u32 *formats,
-                  size_t num_formats)
+                  size_t num_formats, unsigned int plane_idx)
 {
        int err;
 
@@ -338,6 +338,22 @@ int mtk_plane_init(struct drm_device *dev, struct drm_plane *plane,
                return err;
        }
 
+       /*
+        * The hardware does not support repositioning planes by muxing: their
+        * Z-position is infact fixed and the only way to change the actual
+        * order is to swap the contents of the entire register set of one
+        * overlay with another, which may be more expensive than desired.
+        *
+        * With no repositioning, the caller of this function guarantees that
+        * the plane_idx is correct. This means that, for example, the PRIMARY
+        * plane fed to this function will always have plane_idx zero.
+        */
+       err = drm_plane_create_zpos_immutable_property(plane, plane_idx);
+       if (err) {
+               DRM_ERROR("Failed to create zpos property for plane %u\n", plane_idx);
+               return err;
+       }
+
        if (supported_rotations) {
                err = drm_plane_create_rotation_property(plane,
                                                         DRM_MODE_ROTATE_0,
index 231bb7aac94736df914cb6f417fba9cf539dd582..5b177eac67b7aa874229963d02ec3841bea6843d 100644 (file)
@@ -49,6 +49,5 @@ 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 int supported_rotations, const u32 *formats,
-                  size_t num_formats);
-
+                  size_t num_formats, unsigned int plane_idx);
 #endif