lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20231017064717.21616-7-shawn.sung@mediatek.com>
Date:   Tue, 17 Oct 2023 14:47:12 +0800
From:   Hsiao Chien Sung <shawn.sung@...iatek.com>
To:     AngeloGioacchino Del Regno 
        <angelogioacchino.delregno@...labora.com>,
        Chun-Kuang Hu <chunkuang.hu@...nel.org>,
        Krzysztof Kozlowski <krzysztof.kozlowski+dt@...aro.org>,
        Matthias Brugger <matthias.bgg@...il.com>
CC:     Philipp Zabel <p.zabel@...gutronix.de>,
        David Airlie <airlied@...il.com>,
        Daniel Vetter <daniel@...ll.ch>,
        Rob Herring <robh+dt@...nel.org>,
        "Chen-Yu Tsai" <wenst@...omium.org>, Sean Paul <sean@...rly.run>,
        <dri-devel@...ts.freedesktop.org>,
        <linux-mediatek@...ts.infradead.org>, <devicetree@...r.kernel.org>,
        <linux-kernel@...r.kernel.org>,
        <linux-arm-kernel@...ts.infradead.org>,
        Singo Chang <singo.chang@...iatek.com>,
        Nancy Lin <nancy.lin@...iatek.com>,
        Jason-JH Lin <jason-jh.lin@...iatek.com>,
        Hsiao Chien Sung <shawn.sung@...iatek.com>
Subject: [PATCH v3 06/11] drm/mediatek: Support alpha blending in display driver

Support alpha blending by adding correct blend mode and
alpha property in plane initialization.

Signed-off-by: Hsiao Chien Sung <shawn.sung@...iatek.com>
---
 drivers/gpu/drm/mediatek/mtk_drm_drv.c   | 10 ++++++++++
 drivers/gpu/drm/mediatek/mtk_drm_drv.h   |  2 ++
 drivers/gpu/drm/mediatek/mtk_drm_plane.c | 11 +++++++++++
 3 files changed, 23 insertions(+)

diff --git a/drivers/gpu/drm/mediatek/mtk_drm_drv.c b/drivers/gpu/drm/mediatek/mtk_drm_drv.c
index a4b740420ebb..0467e80444d3 100644
--- a/drivers/gpu/drm/mediatek/mtk_drm_drv.c
+++ b/drivers/gpu/drm/mediatek/mtk_drm_drv.c
@@ -14,6 +14,7 @@
 
 #include <drm/drm_atomic.h>
 #include <drm/drm_atomic_helper.h>
+#include <drm/drm_blend.h>
 #include <drm/drm_drv.h>
 #include <drm/drm_fbdev_generic.h>
 #include <drm/drm_fourcc.h>
@@ -305,6 +306,9 @@ static const struct mtk_mmsys_driver_data mt8188_vdosys0_driver_data = {
 	.conn_routes_num = ARRAY_SIZE(mt8188_mtk_ddp_main_routes),
 	.mmsys_dev_num = 2,
 	.max_pitch = GENMASK(15, 0),
+	.blend_mode = BIT(DRM_MODE_BLEND_PIXEL_NONE) |
+		      BIT(DRM_MODE_BLEND_PREMULTI)   |
+		      BIT(DRM_MODE_BLEND_COVERAGE),
 };
 
 static const struct mtk_mmsys_driver_data mt8192_mmsys_driver_data = {
@@ -320,6 +324,9 @@ static const struct mtk_mmsys_driver_data mt8195_vdosys0_driver_data = {
 	.main_len = ARRAY_SIZE(mt8195_mtk_ddp_main),
 	.mmsys_dev_num = 2,
 	.max_pitch = GENMASK(15, 0),
+	.blend_mode = BIT(DRM_MODE_BLEND_PIXEL_NONE) |
+		      BIT(DRM_MODE_BLEND_PREMULTI)   |
+		      BIT(DRM_MODE_BLEND_COVERAGE),
 };
 
 static const struct mtk_mmsys_driver_data mt8195_vdosys1_driver_data = {
@@ -328,6 +335,9 @@ static const struct mtk_mmsys_driver_data mt8195_vdosys1_driver_data = {
 	.mmsys_id = 1,
 	.mmsys_dev_num = 2,
 	.max_pitch = GENMASK(15, 0),
+	.blend_mode = BIT(DRM_MODE_BLEND_PIXEL_NONE) |
+		      BIT(DRM_MODE_BLEND_PREMULTI)   |
+		      BIT(DRM_MODE_BLEND_COVERAGE),
 };
 
 static const struct of_device_id mtk_drm_of_ids[] = {
diff --git a/drivers/gpu/drm/mediatek/mtk_drm_drv.h b/drivers/gpu/drm/mediatek/mtk_drm_drv.h
index 833ecee855bb..27865f8f1160 100644
--- a/drivers/gpu/drm/mediatek/mtk_drm_drv.h
+++ b/drivers/gpu/drm/mediatek/mtk_drm_drv.h
@@ -42,6 +42,7 @@ struct mtk_drm_route {
  * @mmsys_id: multi-media system ID
  * @mmsys_dev_num: number of devices for in the mmsys as a whole
  * @max_pitch: maximum pitch in bytes that the mmsys supports
+ * @blend_mode: alpha blend modes that the mmsys supports
  */
 struct mtk_mmsys_driver_data {
 	const unsigned int *main_path;
@@ -58,6 +59,7 @@ struct mtk_mmsys_driver_data {
 	unsigned int mmsys_dev_num;
 
 	u32 max_pitch;
+	u32 blend_mode;
 };
 
 struct mtk_drm_private {
diff --git a/drivers/gpu/drm/mediatek/mtk_drm_plane.c b/drivers/gpu/drm/mediatek/mtk_drm_plane.c
index 9208f03b3f8c..a6cf1ab94e42 100644
--- a/drivers/gpu/drm/mediatek/mtk_drm_plane.c
+++ b/drivers/gpu/drm/mediatek/mtk_drm_plane.c
@@ -327,6 +327,7 @@ int mtk_plane_init(struct drm_device *dev, struct drm_plane *plane,
 		   size_t num_formats)
 {
 	int err;
+	struct mtk_drm_private *priv = dev->dev_private;
 
 	if (!formats || !num_formats) {
 		DRM_ERROR("no formats for plane\n");
@@ -349,6 +350,16 @@ 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");
+
+	if (priv->data->blend_mode) {
+		err = drm_plane_create_blend_mode_property(plane, priv->data->blend_mode);
+		if (err)
+			DRM_ERROR("failed to create property: blend_mode\n");
+	}
+
 	drm_plane_helper_add(plane, &mtk_plane_helper_funcs);
 
 	return 0;
-- 
2.18.0

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ