Received: by 2002:a89:413:0:b0:1fd:dba5:e537 with SMTP id m19csp544525lqs; Thu, 13 Jun 2024 19:48:15 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCX7sEkb1YzHGClBBoXaZJDDE52e1ewLLVb6AyQa0KKsO5S6MOQvs/uyfoA+7gyVcv4osonHH7Aw5gnBeyLMbxCvsM39TxL48mojZA81xw== X-Google-Smtp-Source: AGHT+IGmtJWwIAJ3Q93OVe6KvBOWkHrm4+41Xdjo6+65TBRfOuLE5qyAWc3ooxJUbWtyJuZ+SyY8 X-Received: by 2002:a17:902:e88a:b0:1f6:d368:7dd7 with SMTP id d9443c01a7336-1f862b155e2mr17016885ad.45.1718333295161; Thu, 13 Jun 2024 19:48:15 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1718333295; cv=pass; d=google.com; s=arc-20160816; b=uHMRxwyAQP34h+VWSr7zi+WeBOwan4CeW64GM+X+83FhsQPIGaGriXNJPBI5QpmrLj E/pmTJMK14EB8TuEAZGzTh4ubBoOWSvdtw/HVFSoMlAf0rFSZTC2+x5ferTYYo11o2N4 Jp2QygBdnkm+QBOFn7yDdDSOz9xsnKNqbCTOMEGS41knJcdIDd5sHMRlyZ4ziMZ9IgLY LynzpT/u0ZXU7XS4Kv+vB647Q8D0O77/C0l/lofLopECGCRMUhYw/Rsqd9kzKhuuraz5 Wu7s0PA4mFRa+UfC0CHrHWLtd5ADWy2tq8MNRhFMNWeNnl53eOdJjuvjAKXd6eWRlZhb Ss2Q== 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=vWmVzfOJfIWdePj1eWvkP+831hHcoQ7rXvnybC61XOo=; fh=q/Ppq8/frEfcA3kotGB0IrpJr8gO0uNs3CtN4uoBAAY=; b=rAniH7CtFjiiNBP/J2HMK9BGCoGccdwDw5ipx5CtfUlQwTEMKzYFTM6s/7LUcU4OF5 2qK4fakcmQPFCT1UCx0sCz8CN0JxxNEAuXX3Qbc8i55oa31GvYT2loEU6PRWIW0VuH5B PWYTlOh2sz2RPvK45X8Tuek1oH7t45n+ul6fK0yoDz+I6ZQjthw5qQ5xyVj1ifYYy21s P/wKaOZ6j8KJD5WhrMgg9WF0XBYJjlu6vCHcqDA8Co7wYUFOHK3PbCcYxz1oQkl/ilPp sYSvgrL2Xy+Nzdjf6Tsq6uF2oahkZR8/JMHTFpGw6Jg2GjO7e4gEOod+74l71lbfTKNg 0BSQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@mediatek.com header.s=dk header.b="qNDk/dm5"; 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-214253-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-214253-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=mediatek.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id d9443c01a7336-1f855ee6971si26222875ad.418.2024.06.13.19.48.14 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 13 Jun 2024 19:48:15 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-214253-linux.lists.archive=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="qNDk/dm5"; 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-214253-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-214253-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 91C6228475D for ; Fri, 14 Jun 2024 02:47:51 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 07FDE186E33; Fri, 14 Jun 2024 02:46:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=mediatek.com header.i=@mediatek.com header.b="qNDk/dm5" 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 1CD0418410A for ; Fri, 14 Jun 2024 02:46:29 +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=1718333191; cv=none; b=AcyIyNvuvRzggsrMXsaEiDCfpbbwlFKsuw7DcdNk2Dziid57S/twG7nM7v1Oz9t056cesfKgH2XaJ2txd07pFfbw72kWJLcMcBviQF+0h/3bt3geP3cYMG6AU3BV4DV8oA2s48MYUFWUNsxwt+CvPwxob7PEcVC8xNZmqIitZsk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718333191; c=relaxed/simple; bh=ke4iFgPqY/JOg9VDatLm32LPTA+JgSC9vh/gHLk4+sw=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=iKPjF6IE4soTduULNsPXHc7uTFSw7qJ020XjNOQty9ULRHdJiXELgp/5Wcva5dO96zbw5qHCn8ZDeMgOWRIpiWK48Z2PYQNwKo9UD4WBhVGyQX1MV/rdPFXq3aQgBMDBNc293Q83Wh/9f60Te/QYKoPJKZRZay9ZKHV7gdEYVvM= 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=qNDk/dm5; 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: 4adce8fa29f811efa22eafcdcd04c131-20240614 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=vWmVzfOJfIWdePj1eWvkP+831hHcoQ7rXvnybC61XOo=; b=qNDk/dm5YhIv5G+q8WKC/Ql3qsGwpbE+M7GHFYPVsbcsIWw2eSXHQPkf7rJMO3tkRUOkm0ZT52s9FxQRfHt6piaqJjFz6FZX/vJLxS8JxvtznGeuDIj5NC5vuip1vo1bCavnCzTA+C2p3U+AGj0YPYIqp1ZoneHrsTslPiau/n8=; X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.39,REQID:b44a9200-5344-4830-bac3-b921c02bed55,IP:0,U RL:0,TC:0,Content:0,EDM:-30,RT:0,SF:0,FILE:0,BULK:0,RULE:Release_Ham,ACTIO N:release,TS:-30 X-CID-META: VersionHash:393d96e,CLOUDID:e4fe1185-4f93-4875-95e7-8c66ea833d57,B ulkID:nil,BulkQuantity:0,Recheck:0,SF:102,TC:nil,Content:0,EDM:2,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,ARC:0 X-CID-BVR: 0 X-CID-BAS: 0,_,0,_ X-CID-FACTOR: TF_CID_SPAM_SNR,TF_CID_SPAM_ULN X-UUID: 4adce8fa29f811efa22eafcdcd04c131-20240614 Received: from mtkmbs11n1.mediatek.inc [(172.21.101.185)] by mailgw02.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-GCM-SHA384 256/256) with ESMTP id 1590546119; Fri, 14 Jun 2024 10:46:25 +0800 Received: from mtkmbs11n2.mediatek.inc (172.21.101.187) by MTKMBS09N2.mediatek.inc (172.21.101.94) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.26; Thu, 13 Jun 2024 19:46:24 -0700 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; Fri, 14 Jun 2024 10:46:24 +0800 From: Shawn Sung To: Chun-Kuang Hu CC: Philipp Zabel , David Airlie , Daniel Vetter , Matthias Brugger , AngeloGioacchino Del Regno , Bibby Hsieh , CK Hu , "Nancy . Lin" , Sean Paul , Jason Chen , Fei Shao , , , , , Hsiao Chien Sung Subject: [PATCH v9 18/21] drm/mediatek: Support alpha blending in display driver Date: Fri, 14 Jun 2024 10:46:17 +0800 Message-ID: <20240614024620.19011-19-shawn.sung@mediatek.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20240614024620.19011-1-shawn.sung@mediatek.com> References: <20240614024620.19011-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-MTK: N From: Hsiao Chien Sung 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. Reviewed-by: CK Hu Reviewed-by: AngeloGioacchino Del Regno Signed-off-by: Hsiao Chien Sung --- drivers/gpu/drm/mediatek/mtk_plane.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/drivers/gpu/drm/mediatek/mtk_plane.c b/drivers/gpu/drm/mediatek/mtk_plane.c index 713e17473930..9762bba23273 100644 --- a/drivers/gpu/drm/mediatek/mtk_plane.c +++ b/drivers/gpu/drm/mediatek/mtk_plane.c @@ -354,6 +354,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