From patchwork Fri Nov 23 09:24:42 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Kocialkowski X-Patchwork-Id: 10695301 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 F1D04175A for ; Fri, 23 Nov 2018 09:27:09 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E31832C3EC for ; Fri, 23 Nov 2018 09:27:09 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D76C52C471; Fri, 23 Nov 2018 09:27:09 +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=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 3C0B62C3EC for ; Fri, 23 Nov 2018 09:27:08 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 971DA6E5FC; Fri, 23 Nov 2018 09:26:57 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail.bootlin.com (mail.bootlin.com [62.4.15.54]) by gabe.freedesktop.org (Postfix) with ESMTP id 648EF6E5EB for ; Fri, 23 Nov 2018 09:26:49 +0000 (UTC) Received: by mail.bootlin.com (Postfix, from userid 110) id 587DF20DCB; Fri, 23 Nov 2018 10:26:48 +0100 (CET) Received: from localhost.localdomain (aaubervilliers-681-1-94-205.w90-88.abo.wanadoo.fr [90.88.35.205]) by mail.bootlin.com (Postfix) with ESMTPSA id F166D20DD1; Fri, 23 Nov 2018 10:26:29 +0100 (CET) From: Paul Kocialkowski To: linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH v2 10/43] drm/fourcc: Add format helpers for checking YUV planes disposition Date: Fri, 23 Nov 2018 10:24:42 +0100 Message-Id: <20181123092515.2511-11-paul.kocialkowski@bootlin.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181123092515.2511-1-paul.kocialkowski@bootlin.com> References: <20181123092515.2511-1-paul.kocialkowski@bootlin.com> MIME-Version: 1.0 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: Maxime Ripard , linux-sunxi@googlegroups.com, Paul Kocialkowski , David Airlie , Chen-Yu Tsai , Thomas Petazzoni , Sean Paul Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP This introduces new format helpers that use the previously-introduced format info helpers for checking YUV planes disposition. Only the format fourcc is required by these helpers and the formats are iterated from the list. Signed-off-by: Paul Kocialkowski Reviewed-by: Maxime Ripard --- drivers/gpu/drm/drm_fourcc.c | 60 ++++++++++++++++++++++++++++++++++++ include/drm/drm_fourcc.h | 3 ++ 2 files changed, 63 insertions(+) diff --git a/drivers/gpu/drm/drm_fourcc.c b/drivers/gpu/drm/drm_fourcc.c index f85650c3463a..b56e773f9f63 100644 --- a/drivers/gpu/drm/drm_fourcc.c +++ b/drivers/gpu/drm/drm_fourcc.c @@ -432,6 +432,66 @@ bool drm_format_is_yuv(uint32_t format) } EXPORT_SYMBOL(drm_format_is_yuv); +/** + * drm_format_is_yuv_packed - check that the format is a YUV format with data + * laid in a single plane + * @format: pixel format + * + * Returns: + * A boolean indicating whether the format is a packed YUV format + */ +bool drm_format_is_yuv_packed(uint32_t format) +{ + const struct drm_format_info *info; + + info = drm_format_info(format); + if (!info) + return false; + + return drm_format_info_is_yuv_packed(info); +} +EXPORT_SYMBOL(drm_format_is_yuv_packed); + +/** + * drm_format_is_yuv_semiplanar - check that the format is a YUV format with + * data laid in two planes (luminance and chrominance) + * @format: pixel format + * + * Returns: + * A boolean indicating whether the format is a semiplanar YUV format + */ +bool drm_format_is_yuv_semiplanar(uint32_t format) +{ + const struct drm_format_info *info; + + info = drm_format_info(format); + if (!info) + return false; + + return drm_format_info_is_yuv_semiplanar(info); +} +EXPORT_SYMBOL(drm_format_is_yuv_semiplanar); + +/** + * drm_format_is_yuv_planar - check that the format is a YUV format with data + * laid in three planes (one for each YUV component) + * @format: pixel format + * + * Returns: + * A boolean indicating whether the format is a planar YUV format + */ +bool drm_format_is_yuv_planar(uint32_t format) +{ + const struct drm_format_info *info; + + info = drm_format_info(format); + if (!info) + return false; + + return drm_format_info_is_yuv_planar(info); +} +EXPORT_SYMBOL(drm_format_is_yuv_planar); + /** * drm_format_info_block_width - width in pixels of block. * @info: pixel format info diff --git a/include/drm/drm_fourcc.h b/include/drm/drm_fourcc.h index f43d5ba412fb..b652b711df1a 100644 --- a/include/drm/drm_fourcc.h +++ b/include/drm/drm_fourcc.h @@ -200,6 +200,9 @@ 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); bool drm_format_is_yuv(uint32_t format); +bool drm_format_is_yuv_packed(uint32_t format); +bool drm_format_is_yuv_semiplanar(uint32_t format); +bool drm_format_is_yuv_planar(uint32_t format); unsigned int drm_format_info_block_width(const struct drm_format_info *info, int plane); unsigned int drm_format_info_block_height(const struct drm_format_info *info,