Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751882AbeAPKiK (ORCPT + 1 other); Tue, 16 Jan 2018 05:38:10 -0500 Received: from mail-he1eur01on0043.outbound.protection.outlook.com ([104.47.0.43]:63227 "EHLO EUR01-HE1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751826AbeAPKiH (ORCPT ); Tue, 16 Jan 2018 05:38:07 -0500 Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Ayan.Halder@arm.com; Date: Tue, 16 Jan 2018 10:37:59 +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 , nd@arm.com Subject: Re: [PATCH 01/19] drm/fourcc: Add a function to tell if the format embeds alpha Message-ID: <20180116103759.GB28269@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: DB6P189CA0020.EURP189.PROD.OUTLOOK.COM (2603:10a6:6:2e::33) To HE1PR0802MB2412.eurprd08.prod.outlook.com (2603:10a6:3:dd::22) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: a34b97da-6936-4383-3686-08d55ccd3815 X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(7020095)(4652020)(5600026)(4604075)(48565401081)(2017052603307)(7153060)(7193020);SRVR:HE1PR0802MB2412; X-Microsoft-Exchange-Diagnostics: 1;HE1PR0802MB2412;3:tzhmTQOdB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hijlk=;4:qTEaODKRQcI1rftt1+IsOXR1YTm09j1xxvq1AcPeT0Md4OL4gw3ofX6gImICSqYYaZtcZvpI8pwavQYNqKVgnuPEOL1YxyBJ6cB2wMZvlZaYOznUUx8C7O9d9Vqg1lfCEu/Sa4J1EW74IWF7A3I1qwj1m5UF6ZRSUoLqVGt7218iS9YLyCdLw/43Eg9XjbH6a0ix3+8cABF1pHWziRijPJb06CfD0KuH5/WiwMQb+Bdb76aCPS8J4KQCLyvDlaDMX0wZgjHdIDQCceyI1LDVR0iJsbCTRjQ6hL3i7vXbCdKZvDjejoW0Or6zdgKB79OjoEUj4WQ+sU8PB+40m7iRvIRDpupsk7QIUrXIYmHK5VpgJzCD600UTH1FE8Dabfvm 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)(8121501046)(5005006)(3002001)(10201501046)(93006095)(93001095)(3231023)(944501161)(6055026)(6041268)(20161123564045)(20161123562045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123560045)(20161123558120)(6072148)(201708071742011);SRVR:HE1PR0802MB2412;BCL:0;PCL:0;RULEID:(100000803101)(100110400095);SRVR:HE1PR0802MB2412; X-Forefront-PRVS: 0554B1F54F X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10009020)(6069001)(366004)(39380400002)(376002)(346002)(39860400002)(396003)(24454002)(199004)(189003)(16586007)(47776003)(86362001)(25786009)(54906003)(58126008)(6496006)(76176011)(50466002)(72206003)(52116002)(966005)(5660300001)(6916009)(6246003)(83506002)(6666003)(26005)(316002)(16526018)(4326008)(93886005)(53386004)(66066001)(97736004)(2950100002)(7736002)(7416002)(229853002)(2906002)(53936002)(3846002)(36756003)(33656002)(386003)(6116002)(76506005)(6486002)(106356001)(8936002)(305945005)(478600001)(81166006)(6306002)(23726003)(68736007)(59450400001)(8676002)(81156014)(105586002)(1076002)(18370500001);DIR:OUT;SFP:1101;SCL:1;SRVR:HE1PR0802MB2412;H:localhost;FPR:;SPF:None;PTR:InfoNoRecords;A:1;MX:1;LANG:en; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;HE1PR0802MB2412;23:jS+0oyeW5tdgjgGHpKnYK1d0mkLLOtUUJuHDuNo?= =?us-ascii?Q?izZ5S83DS0I1ngNNmj4CGUPTHWKCDmOZhfwGlm9zceWSie3gcyYmer8VA83R?= =?us-ascii?Q?fF7OaCuvlCgwrLRfEJm+lOnJ7c7p0qLLu+a6YfEvICHfE1wvRRn1VWh4a6tG?= =?us-ascii?Q?V5IP4CF8YFArxfsSMq9mQuPhxEg3yU+PbAdu9SGC7gC13yGT28S5IDxPWHhG?= =?us-ascii?Q?oL/dVQCXuCWj2zY4CRpF3XePVWt/72cmXkdwofzQhHl5afc5Jdnwd1YjJqvH?= =?us-ascii?Q?XYr4DM4xL4ncsqZlJ5hFsN9zroSXC+J/DgoeYcI8rpvBAaLgpNX6IWQX8jvO?= =?us-ascii?Q?PJI0H+6mkFbTBxByDYxJRr0cHsUSZ+qfLlpQqIMrgVnSF2SjeZtaLE9asi0r?= =?us-ascii?Q?1mrI6RywgEuCXFKW8LOFF0sSIuquxR/XLWKYONdCXVx0cOgwVe+0/c2i1haT?= =?us-ascii?Q?IFbeFVI30Sa69Ovh8RTni4qLkoPy/NbFndWdo76cLivziaTQ6QKOEAlv4Smn?= =?us-ascii?Q?6CyMdz0/EJUILIZohWwjg368xv0RYihlJ3jSXZqGHorURyCYS2EwnI+w14pY?= =?us-ascii?Q?9sa13cgRxbCL4xMzjBktP6ZklX4YAYJ2UbBg00eoQ0VDIGQwg7TqbysePBRn?= =?us-ascii?Q?c2Arb35OMiE9EZqItRvjPxNg9b+O4ZMhd4S8HA4Ec2i6pwi4mptChoP+Ss10?= =?us-ascii?Q?iG7FQisDYlYoUDln5AY386Gu28u2R4N32tZAgO9AnIu00vimR35RY38/kt6X?= =?us-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3Iah9YqT3bvfKmFcYEi+0xGHKfxS3WKoQ7dka4T7QGeyGz5vxmz2znw3+oyT+6wiWlCjsAwzxfxpbGpW2MwAwC7OB1D0cxsT5FziGT97462NS8w8ICZG9gU=;5:F7/c1d3XcH4C9tS9FlLgeqQyZIs2ZgTM1OgRhf09oXSrc72tvx2sOMlpdQwQmvr25gsLnrZqrel7Uz0XaGZUUwavYSGjEta12B8EzqsFEkyNu493sjjNBovXD4NA+cYIUYO58wO2RY02/O8fHlbNpWtJu3kLRe8g7SLngJGF0RE=;24:fR/O1CDmkVy+s6C4393X3avAwGmPF9YzEEJ52Zdn+Ie/AOhQ0x1VbvNnM+lxOgHDgfnFYC3oLTMn1NV2br1xMfMFuWU1/sH5aUcjCnXIyTg=;7:GF/+hm1i3AOdnoPfAtdFEwJEsoZTiL+KPAmxbjnRCIqBIz2eeEyKdc1gD+DOilf0rm8k8Tdj+xMpmBZJSoHzd4N2xq3TyPtVuLPgDDDgeN5ELelFsXSk5l3eUfQmUbM+e+qT3L0jkAabizxj/DudBzcXy8bUYRLopYW6RQ300MEHsXcaMaOIT55s8+zBlNHNHbAJoSni/hytYFV5Xg2wBv7+E+cVTBaS+8FmAMUG65u+gj2Z/RohqI0egte3KeUW SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Jan 2018 10:38:02.0196 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: a34b97da-6936-4383-3686-08d55ccd3815 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-Transport-CrossTenantHeadersStamped: HE1PR0802MB2412 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