[v4,08/17] drm/mediatek: Support alpha blending in display driver

Message ID 20231212121957.19231-9-shawn.sung@mediatek.com
State New
Headers
Series Support IGT in display driver |

Commit Message

Shawn Sung (宋孝謙) Dec. 12, 2023, 12:19 p.m. UTC
  Support alpha blending by adding correct blend mode and
alpha property in plane initialization.

Signed-off-by: Hsiao Chien Sung <shawn.sung@mediatek.com>
---
 drivers/gpu/drm/mediatek/mtk_drm_plane.c | 11 +++++++++++
 1 file changed, 11 insertions(+)
  

Comments

CK Hu (胡俊光) Jan. 2, 2024, 6:13 a.m. UTC | #1
Hi, Hsiao-chien:

On Tue, 2023-12-12 at 20:19 +0800, Hsiao Chien Sung wrote:
> Support alpha blending by adding correct blend mode and
> alpha property in plane initialization.

Reviewed-by: CK Hu <ck.hu@mediatek.com>

> 
> Signed-off-by: Hsiao Chien Sung <shawn.sung@mediatek.com>
> ---
>  drivers/gpu/drm/mediatek/mtk_drm_plane.c | 11 +++++++++++
>  1 file changed, 11 insertions(+)
> 
> diff --git a/drivers/gpu/drm/mediatek/mtk_drm_plane.c
> b/drivers/gpu/drm/mediatek/mtk_drm_plane.c
> index 9208f03b3f8c..dfd81172a940 100644
> --- a/drivers/gpu/drm/mediatek/mtk_drm_plane.c
> +++ b/drivers/gpu/drm/mediatek/mtk_drm_plane.c
> @@ -349,6 +349,17 @@ int mtk_plane_init(struct drm_device *dev,
> struct drm_plane *plane,
>  			DRM_INFO("Create rotation property failed\n");
>  	}
>  
> +	err = drm_plane_create_alpha_property(plane);
> +	if (err)
> +		DRM_ERROR("failed to create property: alpha\n");
> +
> +	err = drm_plane_create_blend_mode_property(plane,
> +						   BIT(DRM_MODE_BLEND_P
> REMULTI) |
> +						   BIT(DRM_MODE_BLEND_C
> OVERAGE) |
> +						   BIT(DRM_MODE_BLEND_P
> IXEL_NONE));
> +	if (err)
> +		DRM_ERROR("failed to create property: blend_mode\n");
> +
>  	drm_plane_helper_add(plane, &mtk_plane_helper_funcs);
>  
>  	return 0;
  

Patch

diff --git a/drivers/gpu/drm/mediatek/mtk_drm_plane.c b/drivers/gpu/drm/mediatek/mtk_drm_plane.c
index 9208f03b3f8c..dfd81172a940 100644
--- a/drivers/gpu/drm/mediatek/mtk_drm_plane.c
+++ b/drivers/gpu/drm/mediatek/mtk_drm_plane.c
@@ -349,6 +349,17 @@  int mtk_plane_init(struct drm_device *dev, struct drm_plane *plane,
 			DRM_INFO("Create rotation property failed\n");
 	}
 
+	err = drm_plane_create_alpha_property(plane);
+	if (err)
+		DRM_ERROR("failed to create property: alpha\n");
+
+	err = drm_plane_create_blend_mode_property(plane,
+						   BIT(DRM_MODE_BLEND_PREMULTI) |
+						   BIT(DRM_MODE_BLEND_COVERAGE) |
+						   BIT(DRM_MODE_BLEND_PIXEL_NONE));
+	if (err)
+		DRM_ERROR("failed to create property: blend_mode\n");
+
 	drm_plane_helper_add(plane, &mtk_plane_helper_funcs);
 
 	return 0;