Received: by 2002:a05:7412:1e0b:b0:fc:a2b0:25d7 with SMTP id kr11csp357481rdb; Thu, 15 Feb 2024 02:14:05 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXkLcez48Vxr72Aaq82+v9Ic2brSgtYeMay56y8+UkPJET9c2TMYpcKUIRAKUYZFMA5BQPN4EYrKcfWbZaehi4ASs6GyZjuUiAvjM0f8Q== X-Google-Smtp-Source: AGHT+IH4uuQTBtTE4uOAKPl6uTumqCgflcyjhaClGEic4/tldalCJDbDRz5HTrhvqKQkzpsGI/To X-Received: by 2002:a17:906:298c:b0:a3c:11a0:8d10 with SMTP id x12-20020a170906298c00b00a3c11a08d10mr1109510eje.3.1707992045510; Thu, 15 Feb 2024 02:14:05 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707992045; cv=pass; d=google.com; s=arc-20160816; b=LLktfnCiv5Oku6rYud/7apjr9M/GzLm/be+dKxLCFaUrni9uQiM+L6sDSrX0n5WIG2 y7AMDmiJ5PdzxENItiNLpwQOaTR2nVXTPRQgsEWqgAn8PsA1xAeDnXRzxfKJtjfiAOWT ccZArO9LlAoa/1tjpn6aWhuIC1cEThp34wMiJ7H91jQf3ph8YfoUWufwn43YcYLlF0Bz XufEheICVvdy2RfcyiPIZSaNKlooY2GEGg/Cj+dLUytYTqStU++iFKgkrbYIcWK2CrU9 /vBS5Vg4mVqUf5pqq2bkvFSArUIOByiQLvQXUYXPYGPAI1Hyz2qI3b8UyyfNF5i6sbrV 0irw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:list-unsubscribe:list-subscribe:list-id:precedence :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=k7GSG8F4GUsljl8fwatv0FWuLYxLL+lQMic2cNt5zmw=; fh=PWpMUFySz/+abNBcZMGAF+1x8Vi76p56GtPU1dgQSG4=; b=jUUrEt6t1rHuUQNgXxm7p6aylZ99jkPX8aoBJBLvvNtt0rU2Smc5LvHy7COj7YLoHT YhHt7cOBQODYc8d/7BIUuGTZrXCTa8W8E8lNO+YkJlP2Y5tGpMzoLKasZLmgSNbqmZhR HnoXE4neSMb7QFtRckL8ew14bPCkhVxiDb3kf3wbE1ab7p4JgTowUJPEnfiHEhJBV6Fv o43TwZoYdcMn7u95aGLxHg1RAjl8DRzyi1Q+gGLbe7YgGWZbZerYUXAm8m8KafTxegPv 4bEias+/rZmMXAYgyVCl3DlKRrSNiGv2Nr7VAAaiAbPTvjo7pA+7JrOv+b0EnP6TbaFc 9C4Q==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@mediatek.com header.s=dk header.b="cUr2IR/A"; arc=pass (i=1 spf=pass spfdomain=mediatek.com dkim=pass dkdomain=mediatek.com dmarc=pass fromdomain=mediatek.com); spf=pass (google.com: domain of linux-kernel+bounces-66608-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-66608-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=mediatek.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id b21-20020a170906039500b00a3d6161b3ecsi478765eja.248.2024.02.15.02.14.05 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Feb 2024 02:14:05 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-66608-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@mediatek.com header.s=dk header.b="cUr2IR/A"; arc=pass (i=1 spf=pass spfdomain=mediatek.com dkim=pass dkdomain=mediatek.com dmarc=pass fromdomain=mediatek.com); spf=pass (google.com: domain of linux-kernel+bounces-66608-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-66608-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=mediatek.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 3F7DA1F24311 for ; Thu, 15 Feb 2024 10:14:05 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6297A7316F; Thu, 15 Feb 2024 10:11:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=mediatek.com header.i=@mediatek.com header.b="cUr2IR/A" Received: from mailgw02.mediatek.com (unknown [210.61.82.184]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 470F36A011 for ; Thu, 15 Feb 2024 10:11:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=210.61.82.184 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707991894; cv=none; b=Rg23b6vKcSsTO1vP5Ms7NxS8htCKRjFnvWM4dAN7Lb72b2HEayLce+530iz7WaH2arqqy+6DpE7P45iz9rMdZi7Bw/ka6dX4S2Owu+rvUuZZAt6gWc+AZCGxz5T1rk+6rbsvk17y39mlz/z8uCau1Rsy1CxT8+4JBGH9DE19ZPg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707991894; c=relaxed/simple; bh=w40LHJ1vzM8KYnewAkjCmXsAVaCNeNk9uspcrRmbsEA=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=G4i36zY+Y9uGiZA+820qAQeNs1Q+v9wJOAy2bN2/2ck9ThGe21PjneCwtGn9HdyHQKgbmUpCpbidUhR5A214p2SQsHGTC8/DG8u59zd3qhuZDJZBWa7cI+5c9ceGctwv8uQl2v+qFYRF01cqa0cB56x2tu0gPlYQ357ba4NyoiU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=mediatek.com; spf=pass smtp.mailfrom=mediatek.com; dkim=pass (1024-bit key) header.d=mediatek.com header.i=@mediatek.com header.b=cUr2IR/A; arc=none smtp.client-ip=210.61.82.184 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=mediatek.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=mediatek.com X-UUID: 9253d2facbea11eea2298b7352fd921d-20240215 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=k7GSG8F4GUsljl8fwatv0FWuLYxLL+lQMic2cNt5zmw=; b=cUr2IR/AI2XhKUQp3NztiNmT30zVtUKfyFLUNZLO1uvWpq48SzjarWUhQoCu+lSoDZMbasxNRVoWrfip+jtzGmW+lMLJ3vC+yAG5u9Rkl2pc2W/7FiyG33oYAUrJ+1jjXf72UefKy4+xHsSXsapnSBS1uPQaknjyJWBJZnyI9/k=; X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.37,REQID:a7bae21b-80ef-471b-9948-573bba0c30bf,IP:0,U RL:0,TC:0,Content:0,EDM:-25,RT:0,SF:0,FILE:0,BULK:0,RULE:Release_Ham,ACTIO N:release,TS:-25 X-CID-META: VersionHash:6f543d0,CLOUDID:b74d528f-e2c0-40b0-a8fe-7c7e47299109,B ulkID:nil,BulkQuantity:0,Recheck:0,SF:102,TC:nil,Content:0,EDM:1,IP:nil,UR L:11|1,File:nil,RT: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,TF_CID_SPAM_ULN X-UUID: 9253d2facbea11eea2298b7352fd921d-20240215 Received: from mtkmbs14n2.mediatek.inc [(172.21.101.76)] by mailgw02.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-GCM-SHA384 256/256) with ESMTP id 13096961; Thu, 15 Feb 2024 18:11:23 +0800 Received: from mtkmbs13n2.mediatek.inc (172.21.101.108) by MTKMBS14N1.mediatek.inc (172.21.101.75) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.26; Thu, 15 Feb 2024 18:11:22 +0800 Received: from mtksdccf07.mediatek.inc (172.21.84.99) by mtkmbs13n2.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.2.1118.26 via Frontend Transport; Thu, 15 Feb 2024 18:11:22 +0800 From: Hsiao Chien Sung To: AngeloGioacchino Del Regno , Chun-Kuang Hu CC: Philipp Zabel , David Airlie , Daniel Vetter , Matthias Brugger , Bibby Hsieh , CK Hu , Sean Paul , Fei Shao , Jason Chen , "Nancy . Lin" , , , , , Hsiao Chien Sung Subject: [PATCH v5 07/13] drm/mediatek: Support alpha blending in display driver Date: Thu, 15 Feb 2024 18:11:13 +0800 Message-ID: <20240215101119.12629-8-shawn.sung@mediatek.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20240215101119.12629-1-shawn.sung@mediatek.com> References: <20240215101119.12629-1-shawn.sung@mediatek.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: 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--8.987900-8.000000 X-TMASE-MatchedRID: x3Ubk3t+gcxo4JO2ZJOtUUKcYi5Qw/RVU+A7YkpDJ1haW2Ktn+I8/sz/ PYuNxvNIMWQ2vFVnCzvKeFqUCjYQAeRdshfO+/2p3y1ZMjVHx6my+WUX/nOlPQ2Y8xyy93kWkny 2PUPL6eBNbf7uoLznK8/PCmgLkWHoJS12kaJxXhED2WXLXdz+AQrefVId6fzVEvoxTu3fj1soEO 70Ha1CScb+TbMWrxk0gDLqnrRlXrYyF7rbsD7xod0H8LFZNFG7bkV4e2xSge55qDTYeZOJ41ARS 62TwUbAHZ5gm6COQK9P+VLujR8OVT6Qrn3xh/cy X-TM-AS-User-Approved-Sender: No X-TM-AS-User-Blocked-Sender: No X-TMASE-Result: 10--8.987900-8.000000 X-TMASE-Version: SMEX-14.0.0.3152-9.1.1006-23728.005 X-TM-SNTS-SMTP: 0CDCBDF2AFBA346F7A109E9699FAC315776E24D3610380DA250F2C3C7367766B2000:8 X-MTK: N Support "Pre-multiplied" and "None" blend mode on MediaTek's chips by adding correct blend mode property when the planes init. Before this patch, only the "Coverage" mode (default) is supported. For more information, there are three pixel blend modes in DRM driver: "None", "Pre-multiplied", and "Coverage". To understand the difference between these modes, let's take a look at the following two approaches to do alpha blending: 1. Straight: dst.RGB = src.RGB * src.A + dst.RGB * (1 - src.A) This is straightforward and easy to understand, when the source layer is compositing with the destination layer, it's alpha will affect the result. This is also known as "post-multiplied", or "Coverage" mode. 2. Pre-multiplied: dst.RGB = src.RGB + dst.RGB * (1 - src.A) Since the source RGB have already multiplied its alpha, only destination RGB need to multiply it. This is the "Pre-multiplied" mode in DRM. For the "None" blend mode in DRM, it means the pixel alpha is ignored when compositing the layers, only the constant alpha for the composited layer will take effects. Signed-off-by: Hsiao Chien Sung Reviewed-by: CK Hu --- 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 2dc28a79f7603..4e0206c45efd7 100644 --- a/drivers/gpu/drm/mediatek/mtk_drm_plane.c +++ b/drivers/gpu/drm/mediatek/mtk_drm_plane.c @@ -346,6 +346,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; -- 2.18.0