Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp2970805rdg; Mon, 16 Oct 2023 23:48:37 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGqBepx6csKmLltS5WAUQRNakRRmZ2pPG2o1wjZ+pRDYT0C5CiYdhswR+bFhySRkIkae0ee X-Received: by 2002:a05:6a21:a101:b0:16a:4480:647f with SMTP id aq1-20020a056a21a10100b0016a4480647fmr1169018pzc.19.1697525316821; Mon, 16 Oct 2023 23:48:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697525316; cv=none; d=google.com; s=arc-20160816; b=lg4POLj6vXNSpPY7RuXZnKA+EUcI550GmlUEnu9JC/1lawQuqSjujQdCF7ox4C4bFW rQHNVf/H2gsKxBZhfSuWu/wbQpgQmabCkLaiz0yJjo31EAOk37NC4j5/yqpH+JrC1Qz0 yaDER/nWV6XNguF7q+QbjG+T93P6fPJRo4BdvrLMo2AzNPm9U/95KGMnASNy2hJfQVGi xNp7AQKFG2TQvzFKXHS3bPfWPKGZ9q4XxdOjFcXrgFwSjY0/BWyDpxvTzm6FpIS/l67s 8wGK2bhQ+k3wHShgLZtHKZ5AXWb51hM1OfS55mxodPF7WsJ14TUlga2UUbcM2bp3CdTL 08Lw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=TmWMoMNwy1Vj/2pYXEudaUwW19Ln7StYihfj7Lm+CSM=; fh=LsFoaGySu0ehlpBAbbjqTnZPNWvefanEoueL/ZpNhfU=; b=laiKp+LxovlvyvI0AaZASOBpAkuZyGiIXeTJD7imV9/z2Eg0ClM6PdHS5/3a9mFfAK LpJYiE/7Kb6oACn1iDcQBpY8kBoyftpjC7ktxmHH7L7Wm/Nz0WXWt3gB8dSb2mMODnWo OeWwYi8440KQAAMgmJi0uujvmPIODmDxqoKJe0vSGeKcop5PcWCtL5MyH6V/qONxGpue Z/gOCYCjWrPdhnNx3DKbKEsS8MuqfPBwfZkeVJeCNbSgPX/K46haKRMBNAzua0ErtcvP WVvyn8KwFQktsZ2gAnacDoGjTZnVdYSYZpcw5PFNCE6jtcx3paGOknoc+Ij9niYsBJj3 v3SA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mediatek.com header.s=dk header.b=Au+Xr0ud; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=mediatek.com Return-Path: Received: from groat.vger.email (groat.vger.email. [2620:137:e000::3:5]) by mx.google.com with ESMTPS id bu15-20020a63294f000000b005ae22729b09si1068702pgb.683.2023.10.16.23.48.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Oct 2023 23:48:36 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) client-ip=2620:137:e000::3:5; Authentication-Results: mx.google.com; dkim=pass header.i=@mediatek.com header.s=dk header.b=Au+Xr0ud; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=mediatek.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id 3DAF080A8B85; Mon, 16 Oct 2023 23:48:34 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234575AbjJQGsC (ORCPT + 99 others); Tue, 17 Oct 2023 02:48:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34272 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234605AbjJQGrn (ORCPT ); Tue, 17 Oct 2023 02:47:43 -0400 Received: from mailgw02.mediatek.com (unknown [210.61.82.184]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E7E75F0; Mon, 16 Oct 2023 23:47:37 -0700 (PDT) X-UUID: 04d371b46cb911ee8051498923ad61e6-20231017 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mediatek.com; s=dk; h=Content-Type:MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:CC:To:From; bh=TmWMoMNwy1Vj/2pYXEudaUwW19Ln7StYihfj7Lm+CSM=; b=Au+Xr0ud2xwe02kESKJ9mcrBySYJfNw8qay6N07PyzRtz6kugvMhGsaCbXAVNM38j9CXRtqDrCPe4nXIrdaOiNq8Xq6toXFWewveH0LpXPYtQSWGGR1TyaJS9cVmrWcKMpqbFxH+gPBhCzt3I5/kOgQNG9LS1UAi7M/DTE/IgoU=; X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.32,REQID:4abe5145-5f9c-4dd4-9763-b51afc6f585b,IP:0,U RL:0,TC:0,Content:-5,EDM:0,RT:0,SF:0,FILE:0,BULK:0,RULE:Release_Ham,ACTION :release,TS:-5 X-CID-META: VersionHash:5f78ec9,CLOUDID:1725e2f0-9a6e-4c39-b73e-f2bc08ca3dc5,B ulkID:nil,BulkQuantity:0,Recheck:0,SF:102,TC:nil,Content:0,EDM:-3,IP:nil,U RL:0,File:nil,Bulk:nil,QS:nil,BEC:nil,COL:0,OSI:0,OSA:0,AV:0,LES:1,SPR:NO, DKR:0,DKP:0,BRR:0,BRE:0 X-CID-BVR: 0 X-CID-BAS: 0,_,0,_ X-CID-FACTOR: TF_CID_SPAM_SNR X-UUID: 04d371b46cb911ee8051498923ad61e6-20231017 Received: from mtkmbs11n2.mediatek.inc [(172.21.101.187)] by mailgw02.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-GCM-SHA384 256/256) with ESMTP id 1242859224; Tue, 17 Oct 2023 14:47:20 +0800 Received: from mtkmbs11n2.mediatek.inc (172.21.101.187) by mtkmbs10n1.mediatek.inc (172.21.101.34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.26; Tue, 17 Oct 2023 14:47:19 +0800 Received: from mtksdccf07.mediatek.inc (172.21.84.99) by mtkmbs11n2.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.2.1118.26 via Frontend Transport; Tue, 17 Oct 2023 14:47:19 +0800 From: Hsiao Chien Sung To: AngeloGioacchino Del Regno , Chun-Kuang Hu , Krzysztof Kozlowski , Matthias Brugger CC: Philipp Zabel , David Airlie , Daniel Vetter , Rob Herring , "Chen-Yu Tsai" , Sean Paul , , , , , , Singo Chang , Nancy Lin , Jason-JH Lin , Hsiao Chien Sung Subject: [PATCH v3 06/11] drm/mediatek: Support alpha blending in display driver Date: Tue, 17 Oct 2023 14:47:12 +0800 Message-ID: <20231017064717.21616-7-shawn.sung@mediatek.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20231017064717.21616-1-shawn.sung@mediatek.com> References: <20231017064717.21616-1-shawn.sung@mediatek.com> MIME-Version: 1.0 Content-Type: text/plain X-TM-AS-Product-Ver: SMEX-14.0.0.3152-9.1.1006-23728.005 X-TM-AS-Result: No-10--13.241300-8.000000 X-TMASE-MatchedRID: sHBNP13/Fsz2fv0LTPfvM6MVgdN9w+TCG9Itfzsy8/Xvnm3ZesFzgrxX z8rVhwNp09NQNrxIpFaXO2uBwefMOJOD/r6k201R4pdq9sdj8LW4vBuE2X0HlfNhzIgXtFJVqcT eK67rgVPgN525AmZSDlrpZ2UgV/eS1x+eOID2gFVIOSHptb5tx5qCl1R34jDPtxF8SAx8/RmOx7 X7h9Du63wAGFxWrqclKSiRRLHTYarlRxm3A2wKuhRFJJyf5BJe3QfwsVk0UbtuRXh7bFKB7j4Mm vPrGH5K+6DJezH7jeu8YBKVTOFKeAwhFEZZKPcO66XHIc5w+gc= X-TM-AS-User-Approved-Sender: No X-TM-AS-User-Blocked-Sender: No X-TMASE-Result: 10--13.241300-8.000000 X-TMASE-Version: SMEX-14.0.0.3152-9.1.1006-23728.005 X-TM-SNTS-SMTP: 00459956C72CDF8663DBAED2D777653D33981E0D0B403A95CF843A006A2041D42000:8 X-MTK: N X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,UNPARSEABLE_RELAY autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Mon, 16 Oct 2023 23:48:34 -0700 (PDT) Support alpha blending by adding correct blend mode and alpha property in plane initialization. Signed-off-by: Hsiao Chien Sung --- 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 #include +#include #include #include #include @@ -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