Commit 8d121a82 authored by Icenowy Zheng's avatar Icenowy Zheng Committed by Chun-Kuang Hu
Browse files

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: c410fa9b ("drm/mediatek: Add AFBC support to Mediatek DRM driver")
Signed-off-by: default avatarIcenowy Zheng <uwu@icenowy.me>
Reviewed-by: default avatarCK Hu <ck.hu@medaitek.com>
Link: https://patchwork.kernel.org/project/linux-mediatek/patch/20250531121140.387661-1-uwu@icenowy.me/


Signed-off-by: default avatarChun-Kuang Hu <chunkuang.hu@kernel.org>
parent d208261e
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -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;

+1 −0
Original line number Diff line number Diff line
@@ -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 = {
+9 −0
Original line number Diff line number Diff line
@@ -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) {
+1 −0
Original line number Diff line number Diff line
@@ -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);
+7 −0
Original line number Diff line number Diff line
@@ -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);
Loading