From patchwork Thu Feb 15 10:11:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?U2hhd24gU3VuZyAo5a6L5a2d6KyZKQ==?= X-Patchwork-Id: 201334 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:b825:b0:106:860b:bbdd with SMTP id da37csp294743dyb; Thu, 15 Feb 2024 02:16:23 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWNDq5SO1e58UUlSJpDVUopkE7JWXtW5eoGyW4sg/aicc/Cins9iq0aKclqTTguyq4BeUUNyhWpTd7Ux2JD2D2kc79kXw== X-Google-Smtp-Source: AGHT+IEuiga4DXTnrKDz0YxgiZBCWBM5WTPD/7Zv4E/9Csps3IYwo7unwuxAj0h0NGsRZ6f6vv64 X-Received: by 2002:a17:903:1cb:b0:1db:6a6a:9966 with SMTP id e11-20020a17090301cb00b001db6a6a9966mr5297660plh.0.1707992183250; Thu, 15 Feb 2024 02:16:23 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707992183; cv=pass; d=google.com; s=arc-20160816; b=A2yLujOJY8OUTFmaASBVpq/gNJfqzWWgZMbjyBgdx4cFJrsBNFH/zTe6sXPeH71lB6 g8iqTkoighINVbCUzuPWnxveIlAICy/81EMMEk5+1GjK3cPuL+5sW/rHhRsMSvM1A+Rr vTs1YNfcaI3yGShEul6GEyGTVAKoTvGonfg0a4nd9MZgud1i+S2e91ENNwVlzySo59ud /9VRxZfiROii6Ob89p97Lp3NyTPnvkBLazbRIvIkvtOrNwMS8diYwTWU+K78yH/bUKU5 wnseW/gBw4ybcI+B/8H6miMBEYhTr+ZNK0UMy1QUZzqriqCHQjJgJcAGJ+5TP/B4oWgi zEMw== 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-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-66608-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=mediatek.com Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id y5-20020a170902700500b001d8ead4fbfesi897861plk.191.2024.02.15.02.16.23 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Feb 2024 02:16:23 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-66608-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; 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-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-66608-ouuuleilei=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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 20C1D287B53 for ; Thu, 15 Feb 2024 10:15:23 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B786C76900; Thu, 15 Feb 2024 10:11:37 +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 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 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790959611458368073 X-GMAIL-MSGID: 1790959611458368073 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 Reviewed-by: AngeloGioacchino Del Regno --- 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;