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: 123876 Delivered-To: patch@linaro.org Received: by 10.80.140.226 with SMTP id r31csp305807edr; Tue, 9 Jan 2018 02:57:23 -0800 (PST) X-Google-Smtp-Source: ACJfBou29Dz7as4h3FAcGNp/CdW7rHUJ+bT7QWyvmecxHDXl1j2/YgKxB7xklc2RP4+ua1E7aSKJ X-Received: by 10.98.36.69 with SMTP id r66mr13194092pfj.96.1515495442941; Tue, 09 Jan 2018 02:57:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1515495442; cv=none; d=google.com; s=arc-20160816; b=fLm56DZtcjJ7W1yZHDn8u4yPTcCAnqhors5Pl/dYlTeJEhaLM4F83PcfrAM+2TOcwn 5gA+owKwcEe3G77we0ApwbRdFM5pV+1ODcs/WLRCic/QsgXxv17CxFLxobTzKFnN+qOD x20MGKS1m1TM6A3xCFU1MtDg21vRi83ZkMYBaDH/kRB60I95K41Ru/T9JEuqb75mp8cP XTUGJQSol1CoVThEoPHIR6abk1WXjZhlJXYvfPgQ1cK2xeMqhrGT1dZ0BV+9Rn05pKEM kOJWiq5r/QjcMP4zzAy9d4R+LCZNc/iPaJPpIzbCzZ91hs7ZeX45edhHFmzO4a+11Jyp 5auQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:cc:references:in-reply-to:references:in-reply-to :message-id:date:subject:to:from:delivered-to :arc-authentication-results; bh=ThvE27PGy3mCZJLQmm59BmsX/6P8cGhjKKs0wS/Nryc=; b=YhbbadbDBPUXzPCZ8MAXUTvT0dXGFGoiL1eab5d8s7ynCw3JeIPK0dlsTPar1VqGTM qx73pmmiyTeSehhmC2lRU3VbYGjaNARb5PR8AQyR2NUrlSGZisq76nAZsYFPKetLFBpG e82+uJR+ftfWg3d53d6EP40i3Vlth+F6MILNIVqM79R89bPNoUyfG7h4VIxGkb9efZIN Ah9X8q8hYnCIJ+oz+zzGaSGU7zTBDinynfcnPNlIvQzttJZUPA5HQrneKYCX+m0NNAFE xxhQpltG6w6ndEc8k3BQoIKwsFY0hSh7LochlCvOC6vvurRp/EBU2RdgHTHcUqP+UgN1 Gx7w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 131.252.210.177 as permitted sender) smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Return-Path: Received: from gabe.freedesktop.org (gabe.freedesktop.org. [131.252.210.177]) by mx.google.com with ESMTPS id q7si10264115plk.225.2018.01.09.02.57.22 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 09 Jan 2018 02:57:22 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 131.252.210.177 as permitted sender) client-ip=131.252.210.177; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 131.252.210.177 as permitted sender) smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 330E26E067; Tue, 9 Jan 2018 10:57:05 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail.free-electrons.com (mail.free-electrons.com [62.4.15.54]) by gabe.freedesktop.org (Postfix) with ESMTP id B765E6E04A for ; Tue, 9 Jan 2018 10:57:02 +0000 (UTC) Received: by mail.free-electrons.com (Postfix, from userid 110) id 3D91F20725; Tue, 9 Jan 2018 11:57:01 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on mail.free-electrons.com X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=ALL_TRUSTED,SHORTCIRCUIT, URIBL_BLOCKED shortcircuit=ham autolearn=disabled version=3.4.0 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: Cc: Thomas Petazzoni , Boris Brezillon , Seung-Woo Kim , linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, Kyungmin Park , Laurent Pinchart , Mark Yao , linux-arm-kernel@lists.infradead.org, thomas@vitsch.nl X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" 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); 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__ */