Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3213876imu; Sat, 24 Nov 2018 00:15:33 -0800 (PST) X-Google-Smtp-Source: AFSGD/U1v05xDTM2JP9jDAlbBaVMPUHKwF9YnY8Czf+50X2ZQ2WpzDX94gRUwgjjx041VaYkg4do X-Received: by 2002:a63:111c:: with SMTP id g28mr16951246pgl.85.1543047333194; Sat, 24 Nov 2018 00:15:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543047333; cv=none; d=google.com; s=arc-20160816; b=ks6LQXYSNDlQD0vlp3BwQUuXERXzR8DJAGteqfhSW5ginMym1ZScoReuudiaTINQdr McxtMn2OvC6ytB2hosagrXIonAfqU/OkC3e71btJH46MrrQH80ALEKkBILX9Lz1HQq0M J1EKBYuTcqFNsQ+zGIWAAB/GSAq2+B1OsplGsEv5at2U3W8KYV1yUxIsDKen4f4pwIG2 UtUoa8/DinkmGEPPewIVo3q1O84P6pW84klScjE7J32MMZ800qC0mxR6MATK7MQmMEs9 VEnKAheI9OaSOt/IuZfSXdd2a853yqnxRMmFxa/o6MSrQbAlyBf04byZVfW1iX6gxV1M xOPQ== 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=eMqXtMeFCi0RPrt8ojHEExXjwMAmQMAggHwX+FMfDzs=; b=hadkiiRA//qSwo9F4ehQlDR1/K7xJOSJMSKSSEYOPur3eBgt1G8Q8qfYRfDiPAdBOR NeNegG2fE47aicaNl3zbwW3685i8iE57Z6MU91Xoe/qbhf735MrKcFfE5XQVaPra1WU6 PNUqMR9Dd40ZSn02/JlHi/ucFnR4qa/GNoB4v4SCEY6TZTxOGveIifKQH4ZQdHx/5Kx3 P5aGQ6hf+dlrVI2DbjHu1sPyLQU+VeFMuH354EZNMZsrQTsJHAIdYbpl6WTmzO2NBfYs Tktx6N6abKwU5OGx/QTl8NrvsTQTca+Mpt+0zrKont+zU3xEsbVj2uZ4Qe9giumpjHFQ +P/g== 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 p14si24289839pgf.52.2018.11.24.00.15.18; Sat, 24 Nov 2018 00:15:33 -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 S2502679AbeKWUKQ (ORCPT + 99 others); Fri, 23 Nov 2018 15:10:16 -0500 Received: from mail.bootlin.com ([62.4.15.54]:49224 "EHLO mail.bootlin.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2502646AbeKWUKP (ORCPT ); Fri, 23 Nov 2018 15:10:15 -0500 Received: by mail.bootlin.com (Postfix, from userid 110) id 4CFB920DC4; 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 AF7F920DCB; 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 09/43] drm/fourcc: Add format info helpers for checking YUV planes disposition Date: Fri, 23 Nov 2018 10:24:41 +0100 Message-Id: <20181123092515.2511-10-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 It is often useful to check whether the DRM format info retrieved from the DRM framebuffer matches a specific YUV planes disposition. This introduces helpers to quickly check that a provided format info matches a YUV format with a specific disposition, in commonly-used terminology. The intent of providing helpers taking the format info instead of the fourcc alone is to avoid the overhead of iterating through all formats when the whole format info structure is available. As a result, these helpers are very simple so they are made inline. Signed-off-by: Paul Kocialkowski --- include/drm/drm_fourcc.h | 42 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/include/drm/drm_fourcc.h b/include/drm/drm_fourcc.h index 569b70483505..f43d5ba412fb 100644 --- a/include/drm/drm_fourcc.h +++ b/include/drm/drm_fourcc.h @@ -143,6 +143,48 @@ struct drm_format_name_buf { char str[32]; }; +/** + * drm_format_info_is_yuv_packed - check that the format info matches a YUV + * format with data laid in a single plane + * @info: format info + * + * Returns: + * A boolean indicating whether the format info matches a packed YUV format. + */ +static inline bool +drm_format_info_is_yuv_packed(const struct drm_format_info *info) +{ + return info->is_yuv && info->num_planes == 1; +} + +/** + * drm_format_info_is_yuv_semiplanar - check that the format info matches a YUV + * format with data laid in two planes (luminance and chrominance) + * @info: format info + * + * Returns: + * A boolean indicating whether the format info matches a semiplanar YUV format. + */ +static inline bool +drm_format_info_is_yuv_semiplanar(const struct drm_format_info *info) +{ + return info->is_yuv && info->num_planes == 2; +} + +/** + * drm_format_info_is_yuv_planar - check that the format info matches a YUV + * format with data laid in three planes (one for each YUV component) + * @info: format info + * + * Returns: + * A boolean indicating whether the format info matches a planar YUV format. + */ +static inline bool +drm_format_info_is_yuv_planar(const struct drm_format_info *info) +{ + return info->is_yuv && info->num_planes == 3; +} + const struct drm_format_info *__drm_format_info(u32 format); const struct drm_format_info *drm_format_info(u32 format); const struct drm_format_info * -- 2.19.1