From patchwork Tue Jan 9 10:56:20 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Ripard X-Patchwork-Id: 10151747 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 95F5A603ED for ; Tue, 9 Jan 2018 11:01:48 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 993C81FF62 for ; Tue, 9 Jan 2018 11:01:48 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8D9EC26E97; Tue, 9 Jan 2018 11:01:48 +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=-4.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_MED autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 08AAA1FF62 for ; Tue, 9 Jan 2018 11:01:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=JLpOelfQDBMhuAzbf7E5VMgyF/VdtFH3MPXvas8n8Uc=; b=WNBQUKUijOmeU1clehpkfeo7u1 RcOCHNhWDhLlrcLbHKkGEkFpHcC+vty6ehlO8wwvKBbif8pj3czqbECMprQZwa00Owyfr0Jr0K+ai vi9o4skRIVRte0nujYDBB9XXatWlLosTy7U4UGc0CZyp849RkovRQloYX+GqP4tDLxvZsZAUPZheT h+atAXGpHalbDhI7imu4tqylxrxO180v7FqHHH71MkiS+WP1tMIm7q9Vy429YmEjnrRY+CJyO5uYU Dz59RgR/2mxGUENfPXoMZwtuqQ3Mpn3tvYKqUWEk5PQMzg6RUcJi9OS8Jr1Dk7Vrh+Wd/JWTNnLC4 D0jfbYmQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.89 #1 (Red Hat Linux)) id 1eYrf5-0001I4-MD; Tue, 09 Jan 2018 11:01:43 +0000 Received: from mail.free-electrons.com ([62.4.15.54]) by bombadil.infradead.org with esmtp (Exim 4.89 #1 (Red Hat Linux)) id 1eYral-0005hd-Kx for linux-arm-kernel@lists.infradead.org; Tue, 09 Jan 2018 10:59:17 +0000 Received: by mail.free-electrons.com (Postfix, from userid 110) id 3D91F20725; Tue, 9 Jan 2018 11:57:01 +0100 (CET) Received: from localhost (LStLambert-657-1-97-87.w90-63.abo.wanadoo.fr [90.63.216.87]) by mail.free-electrons.com (Postfix) with ESMTPSA id 59BDB20741; Tue, 9 Jan 2018 11:56:42 +0100 (CET) From: Maxime Ripard To: Chen-Yu Tsai , Maxime Ripard , Daniel Vetter , Jani Nikula , Sean Paul Subject: [PATCH 01/19] drm/fourcc: Add a function to tell if the format embeds alpha Date: Tue, 9 Jan 2018 11:56:20 +0100 Message-Id: X-Mailer: git-send-email 2.14.3 In-Reply-To: References: In-Reply-To: References: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180109_025716_648292_47827076 X-CRM114-Status: GOOD ( 11.01 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Thomas Petazzoni , Boris Brezillon , Joonyoung Shim , Seung-Woo Kim , linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, Inki Dae , Eric Anholt , Kyungmin Park , Laurent Pinchart , Mark Yao , linux-arm-kernel@lists.infradead.org, thomas@vitsch.nl MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP 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 Reviewed-by: Boris Brezillon --- 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); diff --git a/include/drm/drm_fourcc.h b/include/drm/drm_fourcc.h index 6942e84b6edd..e08fc22c5f78 100644 --- a/include/drm/drm_fourcc.h +++ b/include/drm/drm_fourcc.h @@ -69,5 +69,6 @@ int drm_format_vert_chroma_subsampling(uint32_t format); int drm_format_plane_width(int width, uint32_t format, int plane); int drm_format_plane_height(int height, uint32_t format, int plane); const char *drm_get_format_name(uint32_t format, struct drm_format_name_buf *buf); +bool drm_format_has_alpha(uint32_t format); #endif /* __DRM_FOURCC_H__ */