Skip to content

Commit 8d121a8

Browse files
IcenowyChun-Kuang Hu
authored andcommitted
drm/mediatek: only announce AFBC if really supported
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: c410fa9 ("drm/mediatek: Add AFBC support to Mediatek DRM driver") Signed-off-by: Icenowy Zheng <[email protected]> Reviewed-by: CK Hu <[email protected]> Link: https://patchwork.kernel.org/project/linux-mediatek/patch/[email protected]/ Signed-off-by: Chun-Kuang Hu <[email protected]>
1 parent d208261 commit 8d121a8

File tree

7 files changed

+27
-4
lines changed

7 files changed

+27
-4
lines changed

drivers/gpu/drm/mediatek/mtk_crtc.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -963,7 +963,8 @@ static int mtk_crtc_init_comp_planes(struct drm_device *drm_dev,
963963
mtk_ddp_comp_supported_rotations(comp),
964964
mtk_ddp_comp_get_blend_modes(comp),
965965
mtk_ddp_comp_get_formats(comp),
966-
mtk_ddp_comp_get_num_formats(comp), i);
966+
mtk_ddp_comp_get_num_formats(comp),
967+
mtk_ddp_comp_is_afbc_supported(comp), i);
967968
if (ret)
968969
return ret;
969970

drivers/gpu/drm/mediatek/mtk_ddp_comp.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -366,6 +366,7 @@ static const struct mtk_ddp_comp_funcs ddp_ovl = {
366366
.get_blend_modes = mtk_ovl_get_blend_modes,
367367
.get_formats = mtk_ovl_get_formats,
368368
.get_num_formats = mtk_ovl_get_num_formats,
369+
.is_afbc_supported = mtk_ovl_is_afbc_supported,
369370
};
370371

371372
static const struct mtk_ddp_comp_funcs ddp_postmask = {

drivers/gpu/drm/mediatek/mtk_ddp_comp.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ struct mtk_ddp_comp_funcs {
8383
u32 (*get_blend_modes)(struct device *dev);
8484
const u32 *(*get_formats)(struct device *dev);
8585
size_t (*get_num_formats)(struct device *dev);
86+
bool (*is_afbc_supported)(struct device *dev);
8687
void (*connect)(struct device *dev, struct device *mmsys_dev, unsigned int next);
8788
void (*disconnect)(struct device *dev, struct device *mmsys_dev, unsigned int next);
8889
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)
294295
return 0;
295296
}
296297

298+
static inline bool mtk_ddp_comp_is_afbc_supported(struct mtk_ddp_comp *comp)
299+
{
300+
if (comp->funcs && comp->funcs->is_afbc_supported)
301+
return comp->funcs->is_afbc_supported(comp->dev);
302+
303+
return false;
304+
}
305+
297306
static inline bool mtk_ddp_comp_add(struct mtk_ddp_comp *comp, struct mtk_mutex *mutex)
298307
{
299308
if (comp->funcs && comp->funcs->add) {

drivers/gpu/drm/mediatek/mtk_disp_drv.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ void mtk_ovl_disable_vblank(struct device *dev);
106106
u32 mtk_ovl_get_blend_modes(struct device *dev);
107107
const u32 *mtk_ovl_get_formats(struct device *dev);
108108
size_t mtk_ovl_get_num_formats(struct device *dev);
109+
bool mtk_ovl_is_afbc_supported(struct device *dev);
109110

110111
void mtk_ovl_adaptor_add_comp(struct device *dev, struct mtk_mutex *mutex);
111112
void mtk_ovl_adaptor_remove_comp(struct device *dev, struct mtk_mutex *mutex);

drivers/gpu/drm/mediatek/mtk_disp_ovl.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,13 @@ size_t mtk_ovl_get_num_formats(struct device *dev)
236236
return ovl->data->num_formats;
237237
}
238238

239+
bool mtk_ovl_is_afbc_supported(struct device *dev)
240+
{
241+
struct mtk_disp_ovl *ovl = dev_get_drvdata(dev);
242+
243+
return ovl->data->supports_afbc;
244+
}
245+
239246
int mtk_ovl_clk_enable(struct device *dev)
240247
{
241248
struct mtk_disp_ovl *ovl = dev_get_drvdata(dev);

drivers/gpu/drm/mediatek/mtk_plane.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,8 @@ static const struct drm_plane_helper_funcs mtk_plane_helper_funcs = {
326326
int mtk_plane_init(struct drm_device *dev, struct drm_plane *plane,
327327
unsigned long possible_crtcs, enum drm_plane_type type,
328328
unsigned int supported_rotations, const u32 blend_modes,
329-
const u32 *formats, size_t num_formats, unsigned int plane_idx)
329+
const u32 *formats, size_t num_formats,
330+
bool supports_afbc, unsigned int plane_idx)
330331
{
331332
int err;
332333

@@ -337,7 +338,9 @@ int mtk_plane_init(struct drm_device *dev, struct drm_plane *plane,
337338

338339
err = drm_universal_plane_init(dev, plane, possible_crtcs,
339340
&mtk_plane_funcs, formats,
340-
num_formats, modifiers, type, NULL);
341+
num_formats,
342+
supports_afbc ? modifiers : NULL,
343+
type, NULL);
341344
if (err) {
342345
DRM_ERROR("failed to initialize plane\n");
343346
return err;

drivers/gpu/drm/mediatek/mtk_plane.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,5 +49,6 @@ 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 blend_modes,
52-
const u32 *formats, size_t num_formats, unsigned int plane_idx);
52+
const u32 *formats, size_t num_formats,
53+
bool supports_afbc, unsigned int plane_idx);
5354
#endif

0 commit comments

Comments
 (0)