]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
drm/mediatek: only announce AFBC if really supported
authorIcenowy Zheng <uwu@icenowy.me>
Sat, 31 May 2025 12:11:40 +0000 (20:11 +0800)
committerChun-Kuang Hu <chunkuang.hu@kernel.org>
Thu, 17 Jul 2025 23:19:05 +0000 (23:19 +0000)
Currently even the SoC's OVL does not declare the support of AFBC, AFBC
is still announced to the userspace within the IN_FORMATS blob, which
breaks modern Wayland compositors like KWin Wayland and others.

Gate passing modifiers to drm_universal_plane_init() behind querying the
driver of the hardware block for AFBC support.

Fixes: c410fa9b07c3 ("drm/mediatek: Add AFBC support to Mediatek DRM driver")
Signed-off-by: Icenowy Zheng <uwu@icenowy.me>
Reviewed-by: CK Hu <ck.hu@medaitek.com>
Link: https://patchwork.kernel.org/project/linux-mediatek/patch/20250531121140.387661-1-uwu@icenowy.me/
Signed-off-by: Chun-Kuang Hu <chunkuang.hu@kernel.org>
drivers/gpu/drm/mediatek/mtk_crtc.c
drivers/gpu/drm/mediatek/mtk_ddp_comp.c
drivers/gpu/drm/mediatek/mtk_ddp_comp.h
drivers/gpu/drm/mediatek/mtk_disp_drv.h
drivers/gpu/drm/mediatek/mtk_disp_ovl.c
drivers/gpu/drm/mediatek/mtk_plane.c
drivers/gpu/drm/mediatek/mtk_plane.h

index 6916c8925b412bdc840f8ab2e7179f486382155a..bc7527542fdc6fb89fc36794cee7d6dc26f7dcce 100644 (file)
@@ -963,7 +963,8 @@ static int mtk_crtc_init_comp_planes(struct drm_device *drm_dev,
                                mtk_ddp_comp_supported_rotations(comp),
                                mtk_ddp_comp_get_blend_modes(comp),
                                mtk_ddp_comp_get_formats(comp),
-                               mtk_ddp_comp_get_num_formats(comp), i);
+                               mtk_ddp_comp_get_num_formats(comp),
+                               mtk_ddp_comp_is_afbc_supported(comp), i);
                if (ret)
                        return ret;
 
index edc6417639e64286e809cc28b4a959a895a38fb6..ac6620e10262e3b9a4a82093f13c3101f79520de 100644 (file)
@@ -366,6 +366,7 @@ static const struct mtk_ddp_comp_funcs ddp_ovl = {
        .get_blend_modes = mtk_ovl_get_blend_modes,
        .get_formats = mtk_ovl_get_formats,
        .get_num_formats = mtk_ovl_get_num_formats,
+       .is_afbc_supported = mtk_ovl_is_afbc_supported,
 };
 
 static const struct mtk_ddp_comp_funcs ddp_postmask = {
index 39720b27f4e9eda8e4f3c31020d6ec7124638017..7289b3dcf22f22f344016beee0c7c144cf7b93c8 100644 (file)
@@ -83,6 +83,7 @@ struct mtk_ddp_comp_funcs {
        u32 (*get_blend_modes)(struct device *dev);
        const u32 *(*get_formats)(struct device *dev);
        size_t (*get_num_formats)(struct device *dev);
+       bool (*is_afbc_supported)(struct device *dev);
        void (*connect)(struct device *dev, struct device *mmsys_dev, unsigned int next);
        void (*disconnect)(struct device *dev, struct device *mmsys_dev, unsigned int next);
        void (*add)(struct device *dev, struct mtk_mutex *mutex);
@@ -294,6 +295,14 @@ size_t mtk_ddp_comp_get_num_formats(struct mtk_ddp_comp *comp)
        return 0;
 }
 
+static inline bool mtk_ddp_comp_is_afbc_supported(struct mtk_ddp_comp *comp)
+{
+       if (comp->funcs && comp->funcs->is_afbc_supported)
+               return comp->funcs->is_afbc_supported(comp->dev);
+
+       return false;
+}
+
 static inline bool mtk_ddp_comp_add(struct mtk_ddp_comp *comp, struct mtk_mutex *mutex)
 {
        if (comp->funcs && comp->funcs->add) {
index 04217a36939cdf1932b7735e77af6cc9e100b9df..679d413bf10be1e2fc4804a60a3fbe5d734614f6 100644 (file)
@@ -106,6 +106,7 @@ void mtk_ovl_disable_vblank(struct device *dev);
 u32 mtk_ovl_get_blend_modes(struct device *dev);
 const u32 *mtk_ovl_get_formats(struct device *dev);
 size_t mtk_ovl_get_num_formats(struct device *dev);
+bool mtk_ovl_is_afbc_supported(struct device *dev);
 
 void mtk_ovl_adaptor_add_comp(struct device *dev, struct mtk_mutex *mutex);
 void mtk_ovl_adaptor_remove_comp(struct device *dev, struct mtk_mutex *mutex);
index d0581c4e3c999cf865fdd0aaf4c2f38dd404926e..e0236353d4997e6af1000b0c30a98a1e74f794f3 100644 (file)
@@ -236,6 +236,13 @@ size_t mtk_ovl_get_num_formats(struct device *dev)
        return ovl->data->num_formats;
 }
 
+bool mtk_ovl_is_afbc_supported(struct device *dev)
+{
+       struct mtk_disp_ovl *ovl = dev_get_drvdata(dev);
+
+       return ovl->data->supports_afbc;
+}
+
 int mtk_ovl_clk_enable(struct device *dev)
 {
        struct mtk_disp_ovl *ovl = dev_get_drvdata(dev);
index 59edbe26f01ee3d56f353867eca07a7fdcba261b..cbc4f37da8ba81ff9c8b3b58f66363837ffc21ec 100644 (file)
@@ -326,7 +326,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 int supported_rotations, const u32 blend_modes,
-                  const u32 *formats, size_t num_formats, unsigned int plane_idx)
+                  const u32 *formats, size_t num_formats,
+                  bool supports_afbc, unsigned int plane_idx)
 {
        int err;
 
@@ -337,7 +338,9 @@ int mtk_plane_init(struct drm_device *dev, struct drm_plane *plane,
 
        err = drm_universal_plane_init(dev, plane, possible_crtcs,
                                       &mtk_plane_funcs, formats,
-                                      num_formats, modifiers, type, NULL);
+                                      num_formats,
+                                      supports_afbc ? modifiers : NULL,
+                                      type, NULL);
        if (err) {
                DRM_ERROR("failed to initialize plane\n");
                return err;
index 3b13b89989c7e46449cc37b20283417642ae774d..95c5fa5295d8acd3ee79fff1ed35ee707f47073b 100644 (file)
@@ -49,5 +49,6 @@ 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 blend_modes,
-                  const u32 *formats, size_t num_formats, unsigned int plane_idx);
+                  const u32 *formats, size_t num_formats,
+                  bool supports_afbc, unsigned int plane_idx);
 #endif