Skip to content

Commit 333ab43

Browse files
Jason-JH.LinChun-Kuang Hu
authored andcommitted
drm/mediatek: ovl: Add blend_modes to driver data
OVL_CON_CLRFMT_MAN is a configuration for extending color format settings of DISP_REG_OVL_CON(n). It will change some of the original color format settings. Take the settings of (3 << 12) for example. - If OVL_CON_CLRFMT_MAN = 0 means OVL_CON_CLRFMT_RGBA8888. - If OVL_CON_CLRFMT_MAN = 1 means OVL_CON_CLRFMT_PARGB8888. Since previous SoCs did not support OVL_CON_CLRFMT_MAN, this means that the SoC does not support the premultiplied color format. It will break the original color format setting of MT8173. Therefore, the blend_modes is added to the driver data and then mtk_ovl_fmt_convert() will check the blend_modes to see if pre-multiplied is supported in the current platform. If it is not supported, use coverage mode to set it to the supported color formats to solve the degradation problem. Fixes: a3f7f7e ("drm/mediatek: Support "Pre-multiplied" blending in OVL") Signed-off-by: Jason-JH.Lin <[email protected]> Reviewed-by: AngeloGioacchino Del Regno <[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 41607c3 commit 333ab43

File tree

1 file changed

+31
-3
lines changed

1 file changed

+31
-3
lines changed

drivers/gpu/drm/mediatek/mtk_disp_ovl.c

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,7 @@ struct mtk_disp_ovl_data {
146146
bool fmt_rgb565_is_0;
147147
bool smi_id_en;
148148
bool supports_afbc;
149+
const u32 blend_modes;
149150
const u32 *formats;
150151
size_t num_formats;
151152
bool supports_clrfmt_ext;
@@ -386,9 +387,27 @@ void mtk_ovl_layer_off(struct device *dev, unsigned int idx,
386387
DISP_REG_OVL_RDMA_CTRL(idx));
387388
}
388389

389-
static unsigned int ovl_fmt_convert(struct mtk_disp_ovl *ovl, unsigned int fmt,
390-
unsigned int blend_mode)
390+
static unsigned int mtk_ovl_fmt_convert(struct mtk_disp_ovl *ovl,
391+
struct mtk_plane_state *state)
391392
{
393+
unsigned int fmt = state->pending.format;
394+
unsigned int blend_mode = DRM_MODE_BLEND_COVERAGE;
395+
396+
/*
397+
* For the platforms where OVL_CON_CLRFMT_MAN is defined in the hardware data sheet
398+
* and supports premultiplied color formats, such as OVL_CON_CLRFMT_PARGB8888.
399+
*
400+
* Check blend_modes in the driver data to see if premultiplied mode is supported.
401+
* If not, use coverage mode instead to set it to the supported color formats.
402+
*
403+
* Current DRM assumption is that alpha is default premultiplied, so the bitmask of
404+
* blend_modes must include BIT(DRM_MODE_BLEND_PREMULTI). Otherwise, mtk_plane_init()
405+
* will get an error return from drm_plane_create_blend_mode_property() and
406+
* state->base.pixel_blend_mode should not be used.
407+
*/
408+
if (ovl->data->blend_modes & BIT(DRM_MODE_BLEND_PREMULTI))
409+
blend_mode = state->base.pixel_blend_mode;
410+
392411
switch (fmt) {
393412
default:
394413
case DRM_FORMAT_RGB565:
@@ -466,7 +485,7 @@ void mtk_ovl_layer_config(struct device *dev, unsigned int idx,
466485
return;
467486
}
468487

469-
con = ovl_fmt_convert(ovl, fmt, blend_mode);
488+
con = mtk_ovl_fmt_convert(ovl, state);
470489
if (state->base.fb) {
471490
con |= state->base.alpha & OVL_CON_ALPHA;
472491

@@ -664,6 +683,9 @@ static const struct mtk_disp_ovl_data mt8192_ovl_driver_data = {
664683
.layer_nr = 4,
665684
.fmt_rgb565_is_0 = true,
666685
.smi_id_en = true,
686+
.blend_modes = BIT(DRM_MODE_BLEND_PREMULTI) |
687+
BIT(DRM_MODE_BLEND_COVERAGE) |
688+
BIT(DRM_MODE_BLEND_PIXEL_NONE),
667689
.formats = mt8173_formats,
668690
.num_formats = ARRAY_SIZE(mt8173_formats),
669691
};
@@ -674,6 +696,9 @@ static const struct mtk_disp_ovl_data mt8192_ovl_2l_driver_data = {
674696
.layer_nr = 2,
675697
.fmt_rgb565_is_0 = true,
676698
.smi_id_en = true,
699+
.blend_modes = BIT(DRM_MODE_BLEND_PREMULTI) |
700+
BIT(DRM_MODE_BLEND_COVERAGE) |
701+
BIT(DRM_MODE_BLEND_PIXEL_NONE),
677702
.formats = mt8173_formats,
678703
.num_formats = ARRAY_SIZE(mt8173_formats),
679704
};
@@ -685,6 +710,9 @@ static const struct mtk_disp_ovl_data mt8195_ovl_driver_data = {
685710
.fmt_rgb565_is_0 = true,
686711
.smi_id_en = true,
687712
.supports_afbc = true,
713+
.blend_modes = BIT(DRM_MODE_BLEND_PREMULTI) |
714+
BIT(DRM_MODE_BLEND_COVERAGE) |
715+
BIT(DRM_MODE_BLEND_PIXEL_NONE),
688716
.formats = mt8195_formats,
689717
.num_formats = ARRAY_SIZE(mt8195_formats),
690718
.supports_clrfmt_ext = true,

0 commit comments

Comments
 (0)