Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755365AbeAOPrv (ORCPT + 1 other); Mon, 15 Jan 2018 10:47:51 -0500 Received: from mail-db5eur01on0081.outbound.protection.outlook.com ([104.47.2.81]:3774 "EHLO EUR01-DB5-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751407AbeAOPrt (ORCPT ); Mon, 15 Jan 2018 10:47:49 -0500 Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Ayan.Halder@arm.com; Date: Mon, 15 Jan 2018 15:47:44 +0000 From: Ayan Halder To: Maxime Ripard Cc: Laurent Pinchart , Thomas Petazzoni , Boris Brezillon , Seung-Woo Kim , linux-kernel@vger.kernel.org, Kyungmin Park , Chen-Yu Tsai , dri-devel@lists.freedesktop.org, Daniel Vetter , thomas@vitsch.nl, linux-arm-kernel@lists.infradead.org, Mark Yao Subject: Re: [PATCH 01/19] drm/fourcc: Add a function to tell if the format embeds alpha Message-ID: <20180115154744.GA28269@arm.com> References: <1796930.sWoKI78acY@avalon> <20180109132833.petfgnh3fvbbvosv@flea> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180109132833.petfgnh3fvbbvosv@flea> User-Agent: Mutt/1.5.24 (2015-08-30) X-Originating-IP: [217.140.96.140] X-ClientProxiedBy: DB6PR07CA0172.eurprd07.prod.outlook.com (2603:10a6:6:43::26) To AM5PR0802MB2404.eurprd08.prod.outlook.com (2603:10a6:203:9f::9) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 529972c9-8a24-44f5-67ee-08d55c2f52e5 X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(7020095)(4652020)(5600026)(4604075)(48565401081)(2017052603307)(7153060)(7193020);SRVR:AM5PR0802MB2404; X-Microsoft-Exchange-Diagnostics: 1;AM5PR0802MB2404;3:78x/tZN4YJic4D60t0kms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hkyPXwfY0Royl3VWAhgbEV9CEtI74uN4iLf6kghOK/ZOiQdbN/C7vVznUlhyp3ZSHkoVeB0MVNEPnJriqw3SXyX4JHzkAqgHTvgGt5HGWvUS5k9DaCOzHGo/tW3yZ5YmRJiHlXMU+UeLkd9rzb+2maJObKPBwO+OqjgDd6GD/qtUJHFgU5ogKC/zZLgfumG4dMNsX4SFyi/QxoYebCzxraUDMgmn46dNB9sQAvBzo59xx3t782eRkP7/q4xpl+be4cCcXdzcAXzQtwwYHuc+I6ryYN0kuBCO0toXMZREl15t5qGsWxPJBvdphddbpujaoZbRt3yU/S/xky3vs/sehNxq/;4:c1ZdeW0suRdkaJZO5tI3fnUbc87w2trR8oY63E49Ce9FpJnrZ/Lvgnv/+fIYS17anbwLzj3IZJZblQMP02lfnUr//IWfbZwk0r32LF5QWnRJAyTpW0dLA2cggrtTKVXSF0phFu0QowxY8QmL4ib+R5WO+5qrSZ7zTaOtrJ4kjBwaQaKojJKdXMe05nU1sumllnz7tHta0qZ10Xv5vdn+4NQi12OyI3ccYMI6S9nXkxAfiQGPCblbP9pNbF6yXG2XmLNrfWjUtY7OTuncBrpqC/acumxgoolqM1tnkLQsLNZjR0JK5EhQYS4d1xr37keg5GKG0EfSv+EYkFHH9RxWF0SIMOY59VcNxvJmzkl8T5AVtJKoVJwVHcqmH4kRwlpT X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(58145275503218)(217544274631240)(7411616537696); X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(6040470)(2401047)(5005006)(8121501046)(93006095)(93001095)(10201501046)(3231023)(944501161)(3002001)(6055026)(6041268)(20161123558120)(20161123560045)(20161123562045)(20161123564045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(6072148)(201708071742011);SRVR:AM5PR0802MB2404;BCL:0;PCL:0;RULEID:(100000803101)(100110400095);SRVR:AM5PR0802MB2404; X-Forefront-PRVS: 0553CBB77A X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10009020)(6069001)(346002)(376002)(366004)(39860400002)(396003)(39380400002)(189003)(199004)(40434004)(24454002)(6116002)(72206003)(3846002)(86362001)(6496006)(386003)(105586002)(966005)(52116002)(305945005)(93886005)(25786009)(7736002)(1076002)(50466002)(16526018)(58126008)(54906003)(23726003)(83506002)(229853002)(478600001)(76176011)(316002)(97736004)(59450400001)(6246003)(6486002)(7416002)(2950100002)(8936002)(66066001)(6916009)(106356001)(81156014)(81166006)(47776003)(33656002)(53936002)(8676002)(76506005)(2906002)(8746002)(53386004)(36756003)(68736007)(5890100001)(6306002)(4326008)(5660300001)(18370500001);DIR:OUT;SFP:1101;SCL:1;SRVR:AM5PR0802MB2404;H:localhost;FPR:;SPF:None;PTR:InfoNoRecords;MX:1;A:1;LANG:en; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;AM5PR0802MB2404;23:DLsp40YXnN0xUPhnVa2AuPIoG0K+FZzuvI1bl1F?= =?us-ascii?Q?5mWHk268pRWQjaLeUc9f7imSjWFFdwukWgRoajs2KN8peHpvDCluDfG7FzWo?= =?us-ascii?Q?nhBRmKw5SHui1umrDnbAq9sJ9ToxDF8KbHJAf+i1/3Fs6okY5YEF83Yb8hBp?= =?us-ascii?Q?wQfHrLtLqHp9sdCZANrPfzTm9w+WvtrplG8F/ARJ67h7pM8KhpLOcWobXqcl?= =?us-ascii?Q?adKOn6GXJ91Y9bgzHliZc/pRpKdQpKKWed50YjZv8WQd14E27X5v6diP5QVP?= =?us-ascii?Q?isYtijVm6M+wNMnOCizzkynl5E/HIC4fARxBJ6z/XhBVL1wRKfkQuG5zzmS2?= =?us-ascii?Q?/oDdZ87LT/Org4PHQWDP5DY3aIT2csaxc/egQRv4oNadkm6Lf8VcoMXsf6SC?= =?us-ascii?Q?khk1AZKXEPOlziMg+lmWTeviL9cJGYc5rGR0bM/Cuh5f4Zt3zM5wdtVJzIii?= =?us-ascii?Q?QYv+xMXQvBI/utKxAfcsHj+c+88oJUv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enVBKAFyUIL4ZpaH7c63jSHH5Qd0itFujMukAzz0dD2+JsBt4P?= =?us-ascii?Q?iVrjKIAX2mg=3D=3D?= X-Microsoft-Exchange-Diagnostics: 1;AM5PR0802MB2404;6:vnybyGv3Z5DPWncZflicXxbAErHmj+HCbHy4dWQBMzHdUeBB4i/FvYoTsgO1NH383rlcj7qRldHyklWAQzd6MsWFOyjgeboXrkF23yMabzVLvSztS4Gb55U2g1zIv5Ldl/MKHOUaeiHJt1krUcv+uCcBuJOi9wI01335EkuqtsuCCYPoyFPVvcTq/mQved14B00ps5e9+tdYw5WO/Jv8gpa2Jiq+DSDXmdgnUb4vMbj6iLg9ZyKvx48vBStui3ADSqs16GQX7AqzeluTn+fXwYxm9FVW05y01syyG4Rtb8CoDaOxy4vxnGN5O6QoVMAGGydmld1ds9FllSy10RBM2e9wiN99VQr8+8dU81c8GpE=;5:owI61vh92TW90da4TExkefDoziFNKEWuRWT2BcMn/7VPZGj4HhD2mL/bouTWWUWOoxUp7NO4yyqjbGMu9lGJSgADtcscZSqdfElHSGoDRpZdrVfve6u5zhRAc+Xw0tSUVzPyqdIh7HHdh9dGbY66w5w/H1uBJJj/U/FtRJE1TBs=;24:bvlEeO+BO69LDyOX3JuHrPonuH47bEphp0kLhiTzo0Xat4iKBVUupgobTqWBX5jqEJz0ePwvnG/CHZ47w/xuWV7SMG7aIYqyS6PN6KILcUA=;7:N+l+im5QkwywNlzqHOhxO1wKm5PAp0pjKwXbUH0mN2wABQjuW9n8ixiglvSIx3NnWbkSiMm3iUU6WmwY1ffUs2ec5mdEdR9U10TiqBGlYU9I8xClDTkxI8CqmLx0I/sIViOrJCRPgeRZSmJfrq6pt+NpXiYx48qA7+2NbnKhNLQwbQ3DMa4tZ7tWTTidMG35eebZxPXtHZn/kBjJ/zC1hRKy7ynISB6mV57mrJooJspOsYBa2FD07qmLoUTf6CHm SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Jan 2018 15:47:46.5840 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 529972c9-8a24-44f5-67ee-08d55c2f52e5 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM5PR0802MB2404 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Return-Path: On Tue, Jan 09, 2018 at 02:28:33PM +0100, Maxime Ripard wrote: > Hi Laurent, > > On Tue, Jan 09, 2018 at 02:29:58PM +0200, Laurent Pinchart wrote: > > On Tuesday, 9 January 2018 12:56:20 EET Maxime Ripard wrote: > > > There's a bunch of drivers that duplicate the same function to know if a > > > particular format embeds an alpha component or not. > > > > > > Let's create a helper to avoid duplicating that logic. > > > > > > Cc: Boris Brezillon > > > Cc: Eric Anholt > > > Cc: Inki Dae > > > Cc: Joonyoung Shim > > > Cc: Kyungmin Park > > > Cc: Laurent Pinchart > > > Cc: Mark Yao > > > Cc: Seung-Woo Kim > > > Signed-off-by: Maxime Ripard > > > --- > > > drivers/gpu/drm/drm_fourcc.c | 43 +++++++++++++++++++++++++++++++++++++- > > > include/drm/drm_fourcc.h | 1 +- > > > 2 files changed, 44 insertions(+) > > > > > > diff --git a/drivers/gpu/drm/drm_fourcc.c b/drivers/gpu/drm/drm_fourcc.c > > > index 9c0152df45ad..6e6227d6a46b 100644 > > > --- a/drivers/gpu/drm/drm_fourcc.c > > > +++ b/drivers/gpu/drm/drm_fourcc.c > > > @@ -348,3 +348,46 @@ int drm_format_plane_height(int height, uint32_t > > > format, int plane) return height / info->vsub; > > > } > > > EXPORT_SYMBOL(drm_format_plane_height); > > > + > > > +/** > > > + * drm_format_has_alpha - get whether the format embeds an alpha component > > > + * @format: pixel format (DRM_FORMAT_*) > > > + * > > > + * Returns: > > > + * true if the format embeds an alpha component, false otherwise. > > > + */ > > > +bool drm_format_has_alpha(uint32_t format) > > > +{ > > > + switch (format) { > > > + case DRM_FORMAT_ARGB4444: > > > + case DRM_FORMAT_ABGR4444: > > > + case DRM_FORMAT_RGBA4444: > > > + case DRM_FORMAT_BGRA4444: > > > + case DRM_FORMAT_ARGB1555: > > > + case DRM_FORMAT_ABGR1555: > > > + case DRM_FORMAT_RGBA5551: > > > + case DRM_FORMAT_BGRA5551: > > > + case DRM_FORMAT_ARGB8888: > > > + case DRM_FORMAT_ABGR8888: > > > + case DRM_FORMAT_RGBA8888: > > > + case DRM_FORMAT_BGRA8888: > > > + case DRM_FORMAT_ARGB2101010: > > > + case DRM_FORMAT_ABGR2101010: > > > + case DRM_FORMAT_RGBA1010102: > > > + case DRM_FORMAT_BGRA1010102: > > > + case DRM_FORMAT_AYUV: > > > + case DRM_FORMAT_XRGB8888_A8: > > > + case DRM_FORMAT_XBGR8888_A8: > > > + case DRM_FORMAT_RGBX8888_A8: > > > + case DRM_FORMAT_BGRX8888_A8: > > > + case DRM_FORMAT_RGB888_A8: > > > + case DRM_FORMAT_BGR888_A8: > > > + case DRM_FORMAT_RGB565_A8: > > > + case DRM_FORMAT_BGR565_A8: > > > + return true; > > > + > > > + default: > > > + return false; > > > + } > > > +} > > > +EXPORT_SYMBOL(drm_format_has_alpha); > > > > How about adding the information to struct drm_format_info instead ? > > drm_format_has_alpha() could then be implemented as > > > > bool drm_format_has_alpha(uint32_t format) > > { > > const struct drm_format_info *info; > > > > info = drm_format_info(format); > > return info ? info->has_alpha : false; > > } > > I considered it, and wasn't too sure about if adding more fields to > drm_format_info was ok. I can definitely do it that way. Are you going to send an updated patch with the change mentioned here. Or should I update my patch (https://patchwork.kernel.org/patch/10161023/) and change the type of '.alpha' to boolean to denote if the color format has an alpha channel or not. > > although drivers should really use the drm_framebuffer::format field directly > > in most cases, so the helper might not be needed at all. > > The drivers converted in my serie shouldn't be too hard to convert to > use drm_format_info directly, so that can be removed as well. > > Maxime > > -- > Maxime Ripard, Free Electrons > Embedded Linux and Kernel engineering > http://free-electrons.com > _______________________________________________ > dri-devel mailing list > dri-devel@lists.freedesktop.org > https://lists.freedesktop.org/mailman/listinfo/dri-devel IMPORTANT NOTICE: The contents of this email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please notify the sender immediately and do not disclose the contents to any other person, use it for any purpose, or store or copy the information in any medium. Thank you.