Skip to content

Commit a3f7f7e

Browse files
Hsiao Chien SungChun-Kuang Hu
authored andcommitted
drm/mediatek: Support "Pre-multiplied" blending in OVL
Support "Pre-multiplied" alpha blending mode on in OVL. Before this patch, only the "coverage" mode is supported. As whether OVL_CON_CLRFMT_MAN bit is enabled, (3 << 12) means different formats in the datasheet. To prevent misunderstandings going forward, instead of reusing OVL_CON_CLRFMT_RGBA8888, we intetionally defined OVL_CON_CLRFMT_PARGB8888 with bit operation again. Reviewed-by: CK Hu <[email protected]> Signed-off-by: Hsiao Chien Sung <[email protected]> Reviewed-by: AngeloGioacchino Del Regno <[email protected]> Link: https://patchwork.kernel.org/project/dri-devel/patch/[email protected]/ Signed-off-by: Chun-Kuang Hu <[email protected]>
1 parent eb17c59 commit a3f7f7e

File tree

1 file changed

+25
-7
lines changed

1 file changed

+25
-7
lines changed

drivers/gpu/drm/mediatek/mtk_disp_ovl.c

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -56,15 +56,24 @@
5656
#define GMC_THRESHOLD_HIGH ((1 << GMC_THRESHOLD_BITS) / 4)
5757
#define GMC_THRESHOLD_LOW ((1 << GMC_THRESHOLD_BITS) / 8)
5858

59+
#define OVL_CON_CLRFMT_MAN BIT(23)
5960
#define OVL_CON_BYTE_SWAP BIT(24)
60-
#define OVL_CON_MTX_YUV_TO_RGB (6 << 16)
61+
62+
/* OVL_CON_RGB_SWAP works only if OVL_CON_CLRFMT_MAN is enabled */
63+
#define OVL_CON_RGB_SWAP BIT(25)
64+
6165
#define OVL_CON_CLRFMT_RGB (1 << 12)
6266
#define OVL_CON_CLRFMT_ARGB8888 (2 << 12)
6367
#define OVL_CON_CLRFMT_RGBA8888 (3 << 12)
6468
#define OVL_CON_CLRFMT_ABGR8888 (OVL_CON_CLRFMT_RGBA8888 | OVL_CON_BYTE_SWAP)
6569
#define OVL_CON_CLRFMT_BGRA8888 (OVL_CON_CLRFMT_ARGB8888 | OVL_CON_BYTE_SWAP)
6670
#define OVL_CON_CLRFMT_UYVY (4 << 12)
6771
#define OVL_CON_CLRFMT_YUYV (5 << 12)
72+
#define OVL_CON_MTX_YUV_TO_RGB (6 << 16)
73+
#define OVL_CON_CLRFMT_PARGB8888 ((3 << 12) | OVL_CON_CLRFMT_MAN)
74+
#define OVL_CON_CLRFMT_PABGR8888 (OVL_CON_CLRFMT_PARGB8888 | OVL_CON_RGB_SWAP)
75+
#define OVL_CON_CLRFMT_PBGRA8888 (OVL_CON_CLRFMT_PARGB8888 | OVL_CON_BYTE_SWAP)
76+
#define OVL_CON_CLRFMT_PRGBA8888 (OVL_CON_CLRFMT_PABGR8888 | OVL_CON_BYTE_SWAP)
6877
#define OVL_CON_CLRFMT_RGB565(ovl) ((ovl)->data->fmt_rgb565_is_0 ? \
6978
0 : OVL_CON_CLRFMT_RGB)
7079
#define OVL_CON_CLRFMT_RGB888(ovl) ((ovl)->data->fmt_rgb565_is_0 ? \
@@ -377,7 +386,8 @@ void mtk_ovl_layer_off(struct device *dev, unsigned int idx,
377386
DISP_REG_OVL_RDMA_CTRL(idx));
378387
}
379388

380-
static unsigned int ovl_fmt_convert(struct mtk_disp_ovl *ovl, unsigned int fmt)
389+
static unsigned int ovl_fmt_convert(struct mtk_disp_ovl *ovl, unsigned int fmt,
390+
unsigned int blend_mode)
381391
{
382392
/* The return value in switch "MEM_MODE_INPUT_FORMAT_XXX"
383393
* is defined in mediatek HW data sheet.
@@ -398,22 +408,30 @@ static unsigned int ovl_fmt_convert(struct mtk_disp_ovl *ovl, unsigned int fmt)
398408
case DRM_FORMAT_RGBA8888:
399409
case DRM_FORMAT_RGBX1010102:
400410
case DRM_FORMAT_RGBA1010102:
401-
return OVL_CON_CLRFMT_RGBA8888;
411+
return blend_mode == DRM_MODE_BLEND_COVERAGE ?
412+
OVL_CON_CLRFMT_RGBA8888 :
413+
OVL_CON_CLRFMT_PRGBA8888;
402414
case DRM_FORMAT_BGRX8888:
403415
case DRM_FORMAT_BGRA8888:
404416
case DRM_FORMAT_BGRX1010102:
405417
case DRM_FORMAT_BGRA1010102:
406-
return OVL_CON_CLRFMT_BGRA8888;
418+
return blend_mode == DRM_MODE_BLEND_COVERAGE ?
419+
OVL_CON_CLRFMT_BGRA8888 :
420+
OVL_CON_CLRFMT_PBGRA8888;
407421
case DRM_FORMAT_XRGB8888:
408422
case DRM_FORMAT_ARGB8888:
409423
case DRM_FORMAT_XRGB2101010:
410424
case DRM_FORMAT_ARGB2101010:
411-
return OVL_CON_CLRFMT_ARGB8888;
425+
return blend_mode == DRM_MODE_BLEND_COVERAGE ?
426+
OVL_CON_CLRFMT_ARGB8888 :
427+
OVL_CON_CLRFMT_PARGB8888;
412428
case DRM_FORMAT_XBGR8888:
413429
case DRM_FORMAT_ABGR8888:
414430
case DRM_FORMAT_XBGR2101010:
415431
case DRM_FORMAT_ABGR2101010:
416-
return OVL_CON_CLRFMT_ABGR8888;
432+
return blend_mode == DRM_MODE_BLEND_COVERAGE ?
433+
OVL_CON_CLRFMT_ABGR8888 :
434+
OVL_CON_CLRFMT_PABGR8888;
417435
case DRM_FORMAT_UYVY:
418436
return OVL_CON_CLRFMT_UYVY | OVL_CON_MTX_YUV_TO_RGB;
419437
case DRM_FORMAT_YUYV:
@@ -453,7 +471,7 @@ void mtk_ovl_layer_config(struct device *dev, unsigned int idx,
453471
return;
454472
}
455473

456-
con = ovl_fmt_convert(ovl, fmt);
474+
con = ovl_fmt_convert(ovl, fmt, blend_mode);
457475
if (state->base.fb) {
458476
con |= OVL_CON_AEN;
459477
con |= state->base.alpha & OVL_CON_ALPHA;

0 commit comments

Comments
 (0)