Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3216204imu; Sat, 24 Nov 2018 00:18:48 -0800 (PST) X-Google-Smtp-Source: AFSGD/UD6vUeLKVFeqiIq4FYYu9OlpthUzxk2Gweu2Y4RobToOjw1uosTF1CNdyy7BSKGs7VdLGz X-Received: by 2002:a63:504d:: with SMTP id q13mr17277267pgl.319.1543047528287; Sat, 24 Nov 2018 00:18:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543047528; cv=none; d=google.com; s=arc-20160816; b=XaBbOvIhsR0VOrdoyAwktanEaUGitwsAtRPUmTOCPdgDUhkUG/z3QJTeEcI4E13oPJ JPGO9kGmBRcKtPg9+G6Lm0XG+iMb1VIVXbOliUQFEFcAxH0g+0RFOzR7dQC3cTuMdo6K dxFJ9uUUjizVOHjU6xwqForlt/aWaKbwQpxhup+pv6gN/ZwmKkUitkBYGjaqTCqMkHZw AfpyNEfl4EnY3raMxTdWb1+SxoYLHFR+WTiv7ukPG6/312r0Zd+FTq8EaEADAzPr7zNY TxL3XyZdN5nrzXHKRMVuV9YpZDUAxuZSH0QW1BMUEjsorvvinfjCwoyJZ644P86A/VHa 3TQg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=f3k0oUU1MaJSi8rhXApCwt4u0ohZA+cVVf2OkR/nKe8=; b=M6i8X8XUgqSNEAprprB2EEoTNgXwO/XYnFcep9TEftQDY2qoa6u1KMOqUncJqzn7Qc ZOozbmDPmx6Wt3j5396tS21pW/0a6qAW2mX5iIgE4dA5X1r7L4Qea6SxEhz8lgfdrUxK NgeITrhTtIXMONLKwSGDELtgqGRU83qRcmTIIF9X6P52hQfpXFaRGzQnwzXsMk9v0/qo S8bNeuu9iyfJuZIZmzyH8g8OLoF//k54FJjIIBiKEMsPC8PVN6POfscbiVy+IkyFBmxM z/a+rFR7rWOPtcvCks6+JpEK0Q0lvckh7evwgjKe723D3Q67oqApGRutgfUqs6KblZih 9oow== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r23si59106108pgu.359.2018.11.24.00.18.33; Sat, 24 Nov 2018 00:18:48 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2502852AbeKWUNY (ORCPT + 99 others); Fri, 23 Nov 2018 15:13:24 -0500 Received: from mail.bootlin.com ([62.4.15.54]:49270 "EHLO mail.bootlin.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388038AbeKWUKQ (ORCPT ); Fri, 23 Nov 2018 15:10:16 -0500 Received: by mail.bootlin.com (Postfix, from userid 110) id 587DF20DCB; Fri, 23 Nov 2018 10:26:48 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on mail.bootlin.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.2 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 Cc: Maarten Lankhorst , Maxime Ripard , Sean Paul , David Airlie , Chen-Yu Tsai , Thomas Petazzoni , linux-sunxi@googlegroups.com, Daniel Vetter , Paul Kocialkowski 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 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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, -- 2.19.1