From patchwork Tue Aug 14 11:32:56 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Lowry Li (Arm Technology China)" X-Patchwork-Id: 10565375 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 5AA7D17E1 for ; Tue, 14 Aug 2018 11:33:31 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 488B928D6C for ; Tue, 14 Aug 2018 11:33:31 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3C1AA28DBA; Tue, 14 Aug 2018 11:33:31 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAD_ENC_HEADER,BAYES_00, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 9BF6228D6C for ; Tue, 14 Aug 2018 11:33:30 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 4DBF289D8D; Tue, 14 Aug 2018 11:33:29 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from EUR01-DB5-obe.outbound.protection.outlook.com (mail-db5eur01on0604.outbound.protection.outlook.com [IPv6:2a01:111:f400:fe02::604]) by gabe.freedesktop.org (Postfix) with ESMTPS id D0FF089D8D for ; Tue, 14 Aug 2018 11:33:27 +0000 (UTC) Received: from lowry-ThinkStation-P300.shanghai.arm.com (113.29.88.7) by VI1PR08MB3533.eurprd08.prod.outlook.com (2603:10a6:803:84::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1017.22; Tue, 14 Aug 2018 11:33:21 +0000 From: Lowry Li To: liviu.dudau@arm.com Subject: [PATCH v4 1/2] drm: Add per-plane pixel blend mode property Date: Tue, 14 Aug 2018 19:32:56 +0800 Message-Id: <1534246377-31346-2-git-send-email-lowry.li@arm.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1534246377-31346-1-git-send-email-lowry.li@arm.com> References: <1534246377-31346-1-git-send-email-lowry.li@arm.com> MIME-Version: 1.0 X-Originating-IP: [113.29.88.7] X-ClientProxiedBy: SG2PR0302CA0016.apcprd03.prod.outlook.com (2603:1096:3:2::26) To VI1PR08MB3533.eurprd08.prod.outlook.com (2603:10a6:803:84::16) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 48e41f7a-dcd0-461a-875b-08d601d9bf96 X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: BCL:0; PCL:0; RULEID:(7020095)(4652040)(8989117)(5600074)(711020)(4618075)(2017052603328)(7153060)(7193020); SRVR:VI1PR08MB3533; X-Microsoft-Exchange-Diagnostics: 1; VI1PR08MB3533; 3:iZUvD1X/MUy6Mt1BERv9+WV3qwp0zNH8M/FiWAsNjE+ddJGecdYMhc3DAEb+ONZJSf380jHsYf7/mJyJigwVVcvaSuWjDLSSssEMovNkVWpl1ptQQwEHc4QDhqBEeB11fTpd1JW+vXrAZyqCt9dWxSh0LIGeVzdLXqOVYXWg4LliOj246AxjhtPNSNlWz8Z9etS6g9V7GgObjrWnq6Z2ZYpk5sA8L1TJ1WwGjfHq5l3yo1bNmneEFnR2X4aoRK9l; 25:9kaic7lnZmlZ6yKT3Hf96oDxrxrxUOYlHWSpW4xXQCnNijBh3MgGcE1zJ8aovaRcLuQWYBhr03rqUZo8fGoT0rgmgbBAt3LQgNmKVSuOSDV65N097kkfI4Nr/wUw7yUY8B8p+AlNDgTxJ41idFHFo0quNEdp1e/C8g2KKVDOiheRH2pgHqowfwY28e1rXoOQNE82fB/ih9F8NUPe41Tx8BJvdHymqHWAWhgaWjAnluCl58uXghB/FY4PplM9eq7tR42OQrlzstGX2248eZGJM9pUNEMFMdls+7w9HlKuZDnLxQWmum+LG2xubOyOyUq27IwD1xsU9zWq/T+u3zEyDA==; 31:jThUgTSojje3qPYann833qH1WWTOM2Lb0XlsVpb2fvMmwa0ifSuLY+7jSgoILzQjUVcDp9yDtt7PDU0rqnGB+WcWTg5C65WOna/2AuKKe2KsjdEUbgnKNmEo8yWbNM2hoJHJpAX/4mfLBwyW63UdFn8A82qTo9K6g17Cce/qQjhd3zFijHn0GGvYi3xb/ne2dkSDYmQePM5ki9ZuHPDwuIXDQoMV99BQZbo+i44V/rk= X-MS-TrafficTypeDiagnostic: VI1PR08MB3533: NoDisclaimer: True X-Microsoft-Exchange-Diagnostics: 1; VI1PR08MB3533; 20:gh1UIUMRXAlpXQ/10aVvK21n38xgdy4Q4mWSRmOPeXKan3KXI9ZEop2Nu6oUvsai1iNBLy/WDBXp0shBg0FMv2C75nK/Qg0XoX2/eMPeoQ60w6erwHrncIylAfhNa/Z7D0hZAF+lft0RHQgf8BPldhMf0xCkc/817YFnDNVYnc5cp29tdP9TachHos6ev9aKdUvSIJtCt2/L4Jy92NKqGReI+by5UVawY9A3RhZuFuYjyEWOVXRHoaRhJugnMfaJMfpsxMmHmTOIj1hvH3Hpb9/wI06qMTToQsCylPLa1YB690kx9N1iAlCCI7RnhdRcUq/CUjRTCYXIjZLscDSL1w==; 4:tnjNIthPWSOsc8PLfyNvjku3H2s1gDhXKTlT0THN96YhjhJBToWGRwIbFzyQuQEGbvb5x1EqcUdC/0C6v4OSsR0PP3H3oI8w309iawnp8vxJnkAk+S+4QCw9BrCS03onZDAF9Wi3W+BKXHnv4NOEkF7IUwMeFOZ3ZQbUY2Fc3SYxW7C96ZNhkJnzLIDK5hRaZbJm3el+acC2bLgIGs+iEyQUpMXpOmUiUhNAaP/k7k1QeW4vsn/RKmOyuKn5X2y5OuSIHhKuGFV1wfC8oYUzbvuiWa6XVCBNn4ou+UgDoBkmaPCf9M5LqYYJWXRFuDOa X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(180628864354917); X-MS-Exchange-SenderADCheck: 1 X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(5005006)(8121501046)(3002001)(10201501046)(3231311)(944501410)(52105095)(93006095)(93001095)(6055026)(149027)(150027)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123558120)(20161123562045)(20161123564045)(20161123560045)(6072148)(201708071742011)(7699016); SRVR:VI1PR08MB3533; BCL:0; PCL:0; RULEID:; SRVR:VI1PR08MB3533; X-Forefront-PRVS: 0764C4A8CD X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(39860400002)(396003)(136003)(346002)(376002)(366004)(189003)(199004)(8676002)(6486002)(25786009)(386003)(68736007)(2351001)(2361001)(2906002)(36756003)(316002)(53936002)(34206002)(39060400002)(50226002)(8936002)(44832011)(16526019)(81156014)(6636002)(81166006)(4326008)(6666003)(105586002)(106356001)(26005)(7696005)(51416003)(446003)(5660300001)(76176011)(52116002)(305945005)(7736002)(11346002)(476003)(66066001)(3846002)(37006003)(956004)(16586007)(486006)(5024004)(478600001)(72206003)(6116002)(97736004)(50466002)(47776003)(2616005)(86362001)(48376002); DIR:OUT; SFP:1101; SCL:1; SRVR:VI1PR08MB3533; H:lowry-ThinkStation-P300.shanghai.arm.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; Received-SPF: None (protection.outlook.com: arm.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; VI1PR08MB3533; 23:TcgcAn03vDZWmU2TXP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UYrpJzRUfE7eWwKwHHQiQ==; 5:oxYZp4dUUma0TQNiBybVG6/TbVIUU988r7Tnpz4mvTTLViu3C/M5JFFEw+N1g8bdNaz5dqAiZNq1hsGeqkoekEC5wd/tiBYBHMg6VDlHcCZh9S+X7pV+wjFsDgfGFfWRmHk6gDQv33bTYti9ro8q1gc8F3nYFd2+T5G3ge922Tg=; 7:kAF8Bsgg+oWI1CeNQrICOpJOHVjFyaohdRFd1KrIL+gQ/A02iU2ZEc1IWNKTeydsIzCC8QiqO+xtyibsAeXNycFRZ5cufVcz+lvfKwmmzLI4Yeg+bElXmxfVZPkdk3fp6FtTHxcYNijsUGwq6tMyugZJtHbtpiO7irjhVgAgadOWKVhbqmnY028nZ+y2KvcDVtxNDnQ7pzejcYuOKpy3cBbvoeGnuQbcQOcqr5OL4Mfp7wnA11CTaQJUYl30P2uD SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Aug 2018 11:33:21.1315 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 48e41f7a-dcd0-461a-875b-08d601d9bf96 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR08MB3533 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: airlied@linux.ie, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, emil.l.velikov@gmail.com, malidp@foss.arm.com, daniel.vetter@intel.com, nd@arm.com Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP Pixel blend modes represent the alpha blending equation selection, describing how the pixels from the current plane are composited with the background. Adds a pixel_blend_mode to drm_plane_state and a blend_mode_property to drm_plane, and related support functions. Defines three blend modes in drm_blend.h. Signed-off-by: Lowry Li --- drivers/gpu/drm/drm_atomic.c | 4 ++ drivers/gpu/drm/drm_atomic_helper.c | 1 + drivers/gpu/drm/drm_blend.c | 126 ++++++++++++++++++++++++++++++++++++ include/drm/drm_blend.h | 6 ++ include/drm/drm_plane.h | 2 + 5 files changed, 139 insertions(+) diff --git a/drivers/gpu/drm/drm_atomic.c b/drivers/gpu/drm/drm_atomic.c index 3eb061e..d0478ab 100644 --- a/drivers/gpu/drm/drm_atomic.c +++ b/drivers/gpu/drm/drm_atomic.c @@ -895,6 +895,8 @@ static int drm_atomic_plane_set_property(struct drm_plane *plane, state->src_h = val; } else if (property == plane->alpha_property) { state->alpha = val; + } else if (property == plane->blend_mode_property) { + state->pixel_blend_mode = val; } else if (property == plane->rotation_property) { if (!is_power_of_2(val & DRM_MODE_ROTATE_MASK)) { DRM_DEBUG_ATOMIC("[PLANE:%d:%s] bad rotation bitmask: 0x%llx\n", @@ -968,6 +970,8 @@ static int drm_atomic_plane_set_property(struct drm_plane *plane, *val = state->src_h; } else if (property == plane->alpha_property) { *val = state->alpha; + } else if (property == plane->blend_mode_property) { + *val = state->pixel_blend_mode; } else if (property == plane->rotation_property) { *val = state->rotation; } else if (property == plane->zpos_property) { diff --git a/drivers/gpu/drm/drm_atomic_helper.c b/drivers/gpu/drm/drm_atomic_helper.c index 6dd5036..563af09 100644 --- a/drivers/gpu/drm/drm_atomic_helper.c +++ b/drivers/gpu/drm/drm_atomic_helper.c @@ -3569,6 +3569,7 @@ void __drm_atomic_helper_plane_reset(struct drm_plane *plane, /* Reset the alpha value to fully opaque if it matters */ if (plane->alpha_property) state->alpha = plane->alpha_property->values[1]; + plane->state->pixel_blend_mode = DRM_MODE_BLEND_PREMULTI; plane->state = state; } diff --git a/drivers/gpu/drm/drm_blend.c b/drivers/gpu/drm/drm_blend.c index a16a74d..24016c9 100644 --- a/drivers/gpu/drm/drm_blend.c +++ b/drivers/gpu/drm/drm_blend.c @@ -107,6 +107,52 @@ * planes. Without this property the primary plane is always below the cursor * plane, and ordering between all other planes is undefined. * + * pixel blend mode: + * Pixel blend mode is set up with drm_plane_create_blend_mode_property(). + * It adds a blend mode for alpha blending equation selection, describing + * how the pixels from the current plane are composited with the + * background. + * + * Three alpha blending equations are defined: + * + * "None": + * Blend formula that ignores the pixel alpha:: + * + * out.rgb = plane_alpha * fg.rgb + + * (1 - plane_alpha) * bg.rgb + * + * "Pre-multiplied": + * Blend formula that assumes the pixel color values + * have been already pre-multiplied with the alpha + * channel values:: + * + * out.rgb = plane_alpha * fg.rgb + + * (1 - (plane_alpha * fg.alpha)) * bg.rgb + * + * "Coverage": + * Blend formula that assumes the pixel color values have not + * been pre-multiplied and will do so when blending them to the + * background color values:: + * + * out.rgb = plane_alpha * fg.alpha * fg.rgb + + * (1 - (plane_alpha * fg.alpha)) * bg.rgb + * + * Using the following symbols: + * + * "fg.rgb": + * Each of the RGB component values from the plane's pixel + * "fg.alpha": + * Alpha component value from the plane's pixel. If the plane's + * pixel format has no alpha component, then this is assumed to be + * 1.0. In these cases, this property has no effect, as all three + * equations become equivalent. + * "bg.rgb": + * Each of the RGB component values from the background + * "plane_alpha": + * Plane alpha value set by the plane "alpha" property. If the + * plane does not expose the "alpha" property, then this is + * assumed to be 1.0 + * * Note that all the property extensions described here apply either to the * plane or the CRTC (e.g. for the background color, which currently is not * exposed and assumed to be black). @@ -448,3 +494,83 @@ int drm_atomic_normalize_zpos(struct drm_device *dev, return 0; } EXPORT_SYMBOL(drm_atomic_normalize_zpos); + +/** + * drm_plane_create_blend_mode_property - create a new blend mode property + * @plane: drm plane + * @supported_modes: bitmask of supported modes, must include + * BIT(DRM_MODE_BLEND_PREMULTI). Current DRM assumption is + * that alpha is premultiplied, and old userspace can break if + * the property defaults to anything else. + * + * This creates a new property describing the blend mode. + * + * The property exposed to userspace is an enumeration property (see + * drm_property_create_enum()) called "pixel blend mode" and has the + * following enumeration values: + * + * "None": + * Blend formula that ignores the pixel alpha. + * + * "Pre-multiplied": + * Blend formula that assumes the pixel color values have been already + * pre-multiplied with the alpha channel values. + * + * "Coverage": + * Blend formula that assumes the pixel color values have not been + * pre-multiplied and will do so when blending them to the background color + * values. + * + * RETURNS: + * Zero for success or -errno + */ +int drm_plane_create_blend_mode_property(struct drm_plane *plane, + unsigned int supported_modes) +{ + struct drm_device *dev = plane->dev; + struct drm_property *prop; + static const struct drm_prop_enum_list props[] = { + { DRM_MODE_BLEND_PIXEL_NONE, "None" }, + { DRM_MODE_BLEND_PREMULTI, "Pre-multiplied" }, + { DRM_MODE_BLEND_COVERAGE, "Coverage" }, + }; + unsigned int valid_mode_mask = BIT(DRM_MODE_BLEND_PIXEL_NONE) | + BIT(DRM_MODE_BLEND_PREMULTI) | + BIT(DRM_MODE_BLEND_COVERAGE); + int i; + + if (WARN_ON((supported_modes & ~valid_mode_mask) || + ((supported_modes & BIT(DRM_MODE_BLEND_PREMULTI)) == 0))) + return -EINVAL; + + prop = drm_property_create(dev, DRM_MODE_PROP_ENUM, + "pixel blend mode", + hweight32(supported_modes)); + if (!prop) + return -ENOMEM; + + for (i = 0; i < ARRAY_SIZE(props); i++) { + int ret; + + if (!(BIT(props[i].type) & supported_modes)) + continue; + + ret = drm_property_add_enum(prop, props[i].type, + props[i].name); + + if (ret) { + drm_property_destroy(dev, prop); + + return ret; + } + } + + drm_object_attach_property(&plane->base, prop, DRM_MODE_BLEND_PREMULTI); + plane->blend_mode_property = prop; + + if (plane->state) + plane->state->pixel_blend_mode = DRM_MODE_BLEND_PREMULTI; + + return 0; +} +EXPORT_SYMBOL(drm_plane_create_blend_mode_property); diff --git a/include/drm/drm_blend.h b/include/drm/drm_blend.h index 330c561..88bdfec 100644 --- a/include/drm/drm_blend.h +++ b/include/drm/drm_blend.h @@ -27,6 +27,10 @@ #include #include +#define DRM_MODE_BLEND_PREMULTI 0 +#define DRM_MODE_BLEND_COVERAGE 1 +#define DRM_MODE_BLEND_PIXEL_NONE 2 + struct drm_device; struct drm_atomic_state; struct drm_plane; @@ -52,4 +56,6 @@ int drm_plane_create_zpos_immutable_property(struct drm_plane *plane, unsigned int zpos); int drm_atomic_normalize_zpos(struct drm_device *dev, struct drm_atomic_state *state); +int drm_plane_create_blend_mode_property(struct drm_plane *plane, + unsigned int supported_modes); #endif diff --git a/include/drm/drm_plane.h b/include/drm/drm_plane.h index 8a152dc..c52614a 100644 --- a/include/drm/drm_plane.h +++ b/include/drm/drm_plane.h @@ -117,6 +117,7 @@ struct drm_plane_state { * details. */ u16 alpha; + uint16_t pixel_blend_mode; /** * @rotation: @@ -659,6 +660,7 @@ struct drm_plane { * drm_plane_create_rotation_property(). */ struct drm_property *rotation_property; + struct drm_property *blend_mode_property; /** * @color_encoding_property: From patchwork Tue Aug 14 11:32:57 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Lowry Li (Arm Technology China)" X-Patchwork-Id: 10565377 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 44D1A17E1 for ; Tue, 14 Aug 2018 11:33:36 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 330AE28D6C for ; Tue, 14 Aug 2018 11:33:36 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 26FCC28DBA; Tue, 14 Aug 2018 11:33:36 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAD_ENC_HEADER,BAYES_00, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 98A9728D6C for ; Tue, 14 Aug 2018 11:33:35 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 609076E1C8; Tue, 14 Aug 2018 11:33:34 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from EUR04-DB3-obe.outbound.protection.outlook.com (mail-eopbgr60078.outbound.protection.outlook.com [40.107.6.78]) by gabe.freedesktop.org (Postfix) with ESMTPS id C6DF96E1C2 for ; Tue, 14 Aug 2018 11:33:32 +0000 (UTC) Received: from lowry-ThinkStation-P300.shanghai.arm.com (113.29.88.7) by VI1PR08MB3533.eurprd08.prod.outlook.com (2603:10a6:803:84::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1017.22; Tue, 14 Aug 2018 11:33:25 +0000 From: Lowry Li To: liviu.dudau@arm.com Subject: [PATCH v4 2/2] drm/mali-dp: Implement plane alpha and pixel blend on malidp Date: Tue, 14 Aug 2018 19:32:57 +0800 Message-Id: <1534246377-31346-3-git-send-email-lowry.li@arm.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1534246377-31346-1-git-send-email-lowry.li@arm.com> References: <1534246377-31346-1-git-send-email-lowry.li@arm.com> MIME-Version: 1.0 X-Originating-IP: [113.29.88.7] X-ClientProxiedBy: SG2PR0302CA0016.apcprd03.prod.outlook.com (2603:1096:3:2::26) To VI1PR08MB3533.eurprd08.prod.outlook.com (2603:10a6:803:84::16) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 3fab10f3-394d-4554-6a02-08d601d9c27e X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: BCL:0; PCL:0; RULEID:(7020095)(4652040)(8989117)(5600074)(711020)(4618075)(2017052603328)(7153060)(7193020); SRVR:VI1PR08MB3533; X-Microsoft-Exchange-Diagnostics: 1; VI1PR08MB3533; 3:Zv20y0gJYnvEo9whPJ2yfuIGiWNTGqDagJqCwGf3HOl6KI8TFEOf9e0a+ElLFq4mWx2zoXgkJYXSE8Un4uEbZsW/71jcjFASLcOyRLWpI3fW+gJ4nKCB3FMpJiC60kTjn/R3ZZ/YmxYenY016Uw4jVPVDKN7UpQXeuBuZZocduaoRsxTrkWDiFdAhqV71YnGF7ME57vWGecMhg9SVxLzcNSuvTXZA8AcdBOu/poOaWT0StuX/AKABOAyrrzd+5gd; 25:xaPSRR3QXTbrB6u4hRZjXKzpgJFGGJBCC7Nvcf7XZCtCI0h9ChiYxmGgoI23711NpiqszIh5yUWiVLpc2u/WcH6FcTYGy6K/6kAZ+doJx9ocBC7c2WLHl1Ms+W/7tvEvMniL5pDzCkp92x0fNav3VE8IT7ZD5Btmrhx6iMk4qUq6CnXQqeGJIkD6edsEC9pRKQu6vLCwZPymKDk25T+kCUVFYSMkxPdo/8VeDJr+uWUol0MI3JUumu/15RQ2vtTD/Z6Qe/zuNpuQPVVVOdMPdZmo35LwQeaDOxsp4nukIZxvRBA9qpYw/sT2f0OODKX6aeKpCSLdIZR3B/+N9gU28w==; 31:YMi+YP+2Mvd+ES63UM0ObK7ylCSCtj7CPQ7GpgdIT37KtCjGZQ+GlUdRSEwj2xaS5YV2/xnw7x8qoTT2vMauZ6rykn1sJ/uIrGOUAAgrFk6h3prQ/dvhRnjnQzlFYWlTyHqrppu06TRmBwB7qCn2W6Q7iHfQD6smQtDWHw43Dz3ixYzUHDr9MiTmNYFMp+T/nEk9uRzaAWiKjRUDlBI0Qrwxyy/Qz6KvYK+t9lQa9ew= X-MS-TrafficTypeDiagnostic: VI1PR08MB3533: NoDisclaimer: True X-Microsoft-Exchange-Diagnostics: 1; VI1PR08MB3533; 20:3jhJpxxq+yGQRJ9MVyCUs2nEKmPjJSBy/hLBblyEDN6Ud0bDJvG8Kr681sWN1tRKj19/3PrTsbK1vUEycPfbgy7lSkA5eXQ6V9RTHZkFhoWNOMu10sa8b1iI3RFruqDd2lOWmfQSb3mvdgLAxyivQ5TMTcGUQ8fh0a8sdlXBJQ5mQaW5aoiwZuY8vsZtZOjZppQlNOOr7/4Y0XvhLgPGDR3YdHzwweicgYkFLtZVkl88qXMmzLQevlcMtjq+q6bd1Za2PKSXVL8soOw4gZiVOMRVNp94fZm09wzntms8Vi7EQ4WM0tYBpohYhyjpvfo3U0Y+BQzfYAkzO+YPYAmL7w==; 4:Atlj8hGtUWd41HrkCCjVFq7oobc6tP3/mOo8H7O/RjJ+n7UGsdnZSs65JCYPd8tnf2ewDhchLNPnAFnDiaQCs6+Y8nnGarEUj9lARvLTXdglEvHLRbt6OYXn4t87LABSxl5hevdhewNKH+tDyCuzbB+3Q8BmyVrn8kYUicgQbLrSkNmDLM8kDWMbq0PcQ1Ij6pphyOW04ZuIUN+lhCvXhhY+Nga9fJY/tsq+VQ8L8S3JImbz2goV/o99QnClHcsJ+wUviyTmi2KlWXLgtj2rBm8QfPUH8zRHxOe+e0rdnBPmommrGqlm+7k6kOe8BI8m X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(180628864354917); X-MS-Exchange-SenderADCheck: 1 X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(5005006)(8121501046)(3002001)(10201501046)(3231311)(944501410)(52105095)(93006095)(93001095)(6055026)(149027)(150027)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123558120)(20161123562045)(20161123564045)(20161123560045)(6072148)(201708071742011)(7699016); SRVR:VI1PR08MB3533; BCL:0; PCL:0; RULEID:; SRVR:VI1PR08MB3533; X-Forefront-PRVS: 0764C4A8CD X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(39860400002)(396003)(136003)(346002)(376002)(366004)(189003)(199004)(8676002)(6486002)(25786009)(386003)(68736007)(2351001)(2361001)(2906002)(36756003)(316002)(53936002)(34206002)(39060400002)(50226002)(8936002)(44832011)(16526019)(81156014)(6636002)(81166006)(4326008)(6666003)(105586002)(106356001)(26005)(7696005)(51416003)(446003)(5660300001)(76176011)(52116002)(305945005)(7736002)(11346002)(476003)(66066001)(45080400002)(3846002)(37006003)(956004)(16586007)(486006)(14444005)(5024004)(478600001)(72206003)(6116002)(97736004)(50466002)(47776003)(2616005)(86362001)(48376002); DIR:OUT; SFP:1101; SCL:1; SRVR:VI1PR08MB3533; H:lowry-ThinkStation-P300.shanghai.arm.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; Received-SPF: None (protection.outlook.com: arm.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; VI1PR08MB3533; 23:GApA5PqmCxDrOj5ytDvG+9CC9i/sSjXe9bzWwNAzZ?= pPcrw4NTvC/C1mtyNyKRCnGtXCERuZCL5bmsB7fhzIA3gQdtmpA5BxOIZWdAsc+qr81PCcVF01eyOtoiqoapY0jLO21qdh8WnZbkyebqZu805cf2B3DLdYRUmR3q5aQUP+q06tXL1sqpkGvL4JtNWxUO45XVlvXp+qYm+1hbe3my1PxFnJ6tifLzn9nfM0gQvc58Smpjio2N+MUgpxvlW6DLpWfa+fZMzeql6nO+qmqGropQ1OxUVRrRqEb9skcNRnCQgKEhB3O65yQxgRdCK3I07Qj3FRRhPhCprKWIxQFn5dDjETeMPppOoj7jelgafR5HI40GcCq1tY00wgUB2TPAM7w+EYAt0oPgGjYeevs2I+4UEGcf/LqWQBBpcYIH7q8tuvEqkSiZTXj4JoBzXWOEaaTsWJcshPlIShMyrAzWErThd384pb7l+fHOKDgH8WNaEBNvBEcsxJ+yE+9pPC0ZbW09Fori2R5vRW0EXkzelITWnOFJPNXTLq3t3oUNiJ8lsDJ8s6Dvg2QfQpKKtRUiG7xZ93NvEKGBzxIY0+rM5kKjQyqwSNzRndWtm1RnMUgOfPD63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10ZQeiKdOToOrHmFcQ5Dg/RmObd98zLhADrDM= X-Microsoft-Exchange-Diagnostics: 1; VI1PR08MB3533; 6:tnszzjUZ2ZI31TDFi4Q+F4hC0tX1GAOoOE1xHooLeA+kj6AY5loCgArL0ijL9Ui/akHEppVJWRO87aAX8vNXHguSepg76O62rGsW8PZDWl9FEtQOEnw6JxXYLDIQpOWeUVqUUkolPDfxahCui1X/Uo6fNJcH3nVq2o/YIyHnnXj0yETzSMEqqrLDF4AJAeUoTcqjjndNUGXvO6gGkEr4PYSHt48ZaiPcKqNNh2BIYTXo00HH/8UuC1E28W6PmfcMEjsdxzkBbzZ4WBHk31fSzEV4OnhueBD6Lx3ZQO6q22Gad9ajr2BJkw/GHx3TQ8T/rixKSp1GpOqDGvt9VV3BdfpAhv9s1v6bSNtcipvd1txDgVSOY3GqTM5nRNC1nKKBuMuWZszulVK0d3s901/OGjosuyzVKmGrpy8/bX0umFRSMIwCcyc4e79HNfxMXIUFKHZgpP8OSWRdia7aAx8hMA==; 5:DmvNKlGex9HvavlVS5fTWwk6uBWq/BpKlI6aVsUW0IgiLOjCFedqmWDSKUPICxc+uVS5ikyPch5s0cU1AihS9nWh8KqJavgxFagJydInrkSlwCuiz2gAPK5hu+fJqczRkEwXPz9vfGYsGT5mSUR1oWj7ZNhhAvGpmezdCU68jXw=; 7:sQ/PqepeNJ0h4lxh1s6iml6DlP4qbEJiPWOr/oomFwTpYGlsEVDc4N4hSN+t8bywRcRv7zIAszFpSvAb/aJ9y7k5Qj9e4N65ACSED8zNBVRJpvzaUviu4n+JtIzs1iWzrAWd8ihGwAiyvIVEE5fQK1XAECO09SEC/8JsTgZJbOzYo9wsCPTM3gBQtAcxtzTwnizGdSVN/gRHPHd5dugvn+jkPDj2NLtGUeLkIcyMeaa/I1ad9fvnLaMUdZT3TKPx SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Aug 2018 11:33:25.9754 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 3fab10f3-394d-4554-6a02-08d601d9c27e X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR08MB3533 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: airlied@linux.ie, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, emil.l.velikov@gmail.com, malidp@foss.arm.com, daniel.vetter@intel.com, nd@arm.com Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP Checks the pixel blending mode and plane alpha value when do the plane_check. Mali DP supports blending the current plane with the background either based on the pixel alpha blending mode or by using the layer's alpha value, but not both at the same time. If both case, plane_check will return failed. Sets the HW when doing plane_update accordingly. If plane alpha is the 0xffff, set the pixel blending bits accordingly. If not we'd set ALPHA bit as zero and layer alpha value. Signed-off-by: Lowry Li --- drivers/gpu/drm/arm/malidp_planes.c | 74 +++++++++++++++++++++---------------- 1 file changed, 43 insertions(+), 31 deletions(-) diff --git a/drivers/gpu/drm/arm/malidp_planes.c b/drivers/gpu/drm/arm/malidp_planes.c index 49c37f6..17be123 100644 --- a/drivers/gpu/drm/arm/malidp_planes.c +++ b/drivers/gpu/drm/arm/malidp_planes.c @@ -36,6 +36,7 @@ #define LAYER_COMP_MASK (0x3 << 12) #define LAYER_COMP_PIXEL (0x3 << 12) #define LAYER_COMP_PLANE (0x2 << 12) +#define LAYER_PMUL_ENABLE (0x1 << 14) #define LAYER_ALPHA_OFFSET (16) #define LAYER_ALPHA_MASK (0xff) #define LAYER_ALPHA(x) (((x) & LAYER_ALPHA_MASK) << LAYER_ALPHA_OFFSET) @@ -180,6 +181,7 @@ static int malidp_de_plane_check(struct drm_plane *plane, struct malidp_plane_state *ms = to_malidp_plane_state(state); bool rotated = state->rotation & MALIDP_ROTATED_MASK; struct drm_framebuffer *fb; + u16 pixel_alpha = state->pixel_blend_mode; int i, ret; if (!state->crtc || !state->fb) @@ -242,6 +244,11 @@ static int malidp_de_plane_check(struct drm_plane *plane, ms->rotmem_size = val; } + /* HW can't support plane + pixel blending */ + if ((state->alpha != DRM_BLEND_ALPHA_OPAQUE) && + (pixel_alpha != DRM_MODE_BLEND_PIXEL_NONE)) + return -EINVAL; + return 0; } @@ -323,17 +330,19 @@ static void malidp_de_plane_update(struct drm_plane *plane, { struct malidp_plane *mp; struct malidp_plane_state *ms = to_malidp_plane_state(plane->state); + struct drm_plane_state *state = plane->state; + u16 pixel_alpha = state->pixel_blend_mode; + u8 plane_alpha = state->alpha >> 8; u32 src_w, src_h, dest_w, dest_h, val; int i; - bool format_has_alpha = plane->state->fb->format->has_alpha; mp = to_malidp_plane(plane); /* convert src values from Q16 fixed point to integer */ - src_w = plane->state->src_w >> 16; - src_h = plane->state->src_h >> 16; - dest_w = plane->state->crtc_w; - dest_h = plane->state->crtc_h; + src_w = state->src_w >> 16; + src_h = state->src_h >> 16; + dest_w = state->crtc_w; + dest_h = state->crtc_h; val = malidp_hw_read(mp->hwdev, mp->layer->base); val = (val & ~LAYER_FORMAT_MASK) | ms->format; @@ -342,14 +351,14 @@ static void malidp_de_plane_update(struct drm_plane *plane, for (i = 0; i < ms->n_planes; i++) { /* calculate the offset for the layer's plane registers */ u16 ptr = mp->layer->ptr + (i << 4); - dma_addr_t fb_addr = drm_fb_cma_get_gem_addr(plane->state->fb, - plane->state, i); + dma_addr_t fb_addr = drm_fb_cma_get_gem_addr(state->fb, + state, i); malidp_hw_write(mp->hwdev, lower_32_bits(fb_addr), ptr); malidp_hw_write(mp->hwdev, upper_32_bits(fb_addr), ptr + 4); } malidp_de_set_plane_pitches(mp, ms->n_planes, - plane->state->fb->pitches); + state->fb->pitches); if ((plane->state->color_encoding != old_state->color_encoding) || (plane->state->color_range != old_state->color_range)) @@ -362,8 +371,8 @@ static void malidp_de_plane_update(struct drm_plane *plane, malidp_hw_write(mp->hwdev, LAYER_H_VAL(dest_w) | LAYER_V_VAL(dest_h), mp->layer->base + MALIDP_LAYER_COMP_SIZE); - malidp_hw_write(mp->hwdev, LAYER_H_VAL(plane->state->crtc_x) | - LAYER_V_VAL(plane->state->crtc_y), + malidp_hw_write(mp->hwdev, LAYER_H_VAL(state->crtc_x) | + LAYER_V_VAL(state->crtc_y), mp->layer->base + MALIDP_LAYER_OFFSET); if (mp->layer->id == DE_SMART) @@ -376,38 +385,35 @@ static void malidp_de_plane_update(struct drm_plane *plane, val &= ~LAYER_ROT_MASK; /* setup the rotation and axis flip bits */ - if (plane->state->rotation & DRM_MODE_ROTATE_MASK) + if (state->rotation & DRM_MODE_ROTATE_MASK) val |= ilog2(plane->state->rotation & DRM_MODE_ROTATE_MASK) << LAYER_ROT_OFFSET; - if (plane->state->rotation & DRM_MODE_REFLECT_X) + if (state->rotation & DRM_MODE_REFLECT_X) val |= LAYER_H_FLIP; - if (plane->state->rotation & DRM_MODE_REFLECT_Y) + if (state->rotation & DRM_MODE_REFLECT_Y) val |= LAYER_V_FLIP; - val &= ~LAYER_COMP_MASK; - if (format_has_alpha) { - - /* - * always enable pixel alpha blending until we have a way - * to change blend modes - */ - val |= LAYER_COMP_PIXEL; - } else { + val &= ~(LAYER_COMP_MASK | LAYER_PMUL_ENABLE | LAYER_ALPHA(0xff)); - /* - * do not enable pixel alpha blending as the color channel - * does not have any alpha information - */ + if (state->alpha != DRM_BLEND_ALPHA_OPAQUE) { val |= LAYER_COMP_PLANE; - - /* Set layer alpha coefficient to 0xff ie fully opaque */ - val |= LAYER_ALPHA(0xff); + } else if (state->fb->format->has_alpha) { + /* We only care about blend mode if the format has alpha */ + switch (pixel_alpha) { + case DRM_MODE_BLEND_PREMULTI: + val |= LAYER_COMP_PIXEL | LAYER_PMUL_ENABLE; + break; + case DRM_MODE_BLEND_COVERAGE: + val |= LAYER_COMP_PIXEL; + break; + } } + val |= LAYER_ALPHA(plane_alpha); val &= ~LAYER_FLOWCFG(LAYER_FLOWCFG_MASK); - if (plane->state->crtc) { + if (state->crtc) { struct malidp_crtc_state *m = - to_malidp_crtc_state(plane->state->crtc->state); + to_malidp_crtc_state(state->crtc->state); if (m->scaler_config.scale_enable && m->scaler_config.plane_src_id == mp->layer->id) @@ -446,6 +452,9 @@ int malidp_de_planes_init(struct drm_device *drm) unsigned long crtcs = 1 << drm->mode_config.num_crtc; unsigned long flags = DRM_MODE_ROTATE_0 | DRM_MODE_ROTATE_90 | DRM_MODE_ROTATE_180 | DRM_MODE_ROTATE_270 | DRM_MODE_REFLECT_X | DRM_MODE_REFLECT_Y; + unsigned int blend_caps = BIT(DRM_MODE_BLEND_PIXEL_NONE) | + BIT(DRM_MODE_BLEND_PREMULTI) | + BIT(DRM_MODE_BLEND_COVERAGE); u32 *formats; int ret, i, j, n; @@ -498,6 +507,9 @@ int malidp_de_planes_init(struct drm_device *drm) malidp_hw_write(malidp->dev, MALIDP_ALPHA_LUT, plane->layer->base + MALIDP_LAYER_COMPOSE); + drm_plane_create_alpha_property(&plane->base); + drm_plane_create_blend_mode_property(&plane->base, blend_caps); + /* Attach the YUV->RGB property only to video layers */ if (id & (DE_VIDEO1 | DE_VIDEO2)) { /* default encoding for YUV->RGB is BT601 NARROW */