Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3216321imu; Sat, 24 Nov 2018 00:18:59 -0800 (PST) X-Google-Smtp-Source: AFSGD/WSrgaxYdWMl6bv53fCTZp2k29lJuwzvW+0Wl6hkLgqqOfE2UZq5YiJH/e7Xi/xu7PBthde X-Received: by 2002:a17:902:2:: with SMTP id 2mr17052026pla.228.1543047538963; Sat, 24 Nov 2018 00:18:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543047538; cv=none; d=google.com; s=arc-20160816; b=XvaUYY3urJZOUnNdFY2dariakYO11m0WPjwtDOuGWIDWWGdMtDv7I65rWbxsyUqdO3 tpx5CU/kdaSRPw209T9DOsy34EYV14dONlxboipaUmQSF/i00XU08cZIr7drWtur+ybi OOVfKvaO7PAQdZKx91XgXWHsz4J70xV36REQUUOO6FCqusJ19SnyBd10KgGkf9K3wx95 u7+HG58GpBHfcvPuP9Vr5FgtxFe/mojbuSA7KaPPcGvWbjP1nI8r2Up9gTEcVvho/G06 n1Jb7XFkviULMqtMdZ3mb1YCFVdd+fatimBFYkvxn4bSC+0/ge/ldxVaO8+MAKhyR4Lt k4Uw== 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=ycZCn4+51nBSxP7V77ffrxe2te3sO2a64NCvpsbTQHs=; b=jVmC64O4kJQCAdi4koj7VLAatYDSWx9PTQSlF/bsi04+mhjp6Qkgi/3S5yJOrm0YV/ xT6PT1Ni+6KwWHoXU1EI3iQ7ZZoK6Jk1LVhmB3X8/ZFxBKYKNQu3atqXU0/I2QJ69H5A Gn674HzAu7Bljrwh7GztYYEs9C5BOtXmguRtA1RZeMUDFYg9Pg965rwZs/h4QMRHVJdY JbodJFuXvZG2xf29Ved29JoNjzpnbVNeKISKlkzBGSHaKUp+PctjLiH5i1mi9oBgJQFo 7s9El6WooUgERbdgYhG02/ex+998ArtdUulH5+vbzChIRpO+W6bX4mQV7TU7WfNlzgVt /vnQ== 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 u5si53268528pgi.146.2018.11.24.00.18.43; Sat, 24 Nov 2018 00:18:58 -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 S2394325AbeKWUNl (ORCPT + 99 others); Fri, 23 Nov 2018 15:13:41 -0500 Received: from mail.bootlin.com ([62.4.15.54]:49275 "EHLO mail.bootlin.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390514AbeKWUKQ (ORCPT ); Fri, 23 Nov 2018 15:10:16 -0500 Received: by mail.bootlin.com (Postfix, from userid 110) id 90BD920DD6; 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 7FA3420DD7; Fri, 23 Nov 2018 10:26:30 +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 12/43] drm/fourcc: Add format helpers for checking YUV sub-sampling Date: Fri, 23 Nov 2018 10:24:44 +0100 Message-Id: <20181123092515.2511-13-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 sub-sampling. 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 | 105 +++++++++++++++++++++++++++++++++++ include/drm/drm_fourcc.h | 5 ++ 2 files changed, 110 insertions(+) diff --git a/drivers/gpu/drm/drm_fourcc.c b/drivers/gpu/drm/drm_fourcc.c index b56e773f9f63..6d395c586ad5 100644 --- a/drivers/gpu/drm/drm_fourcc.c +++ b/drivers/gpu/drm/drm_fourcc.c @@ -492,6 +492,111 @@ bool drm_format_is_yuv_planar(uint32_t format) } EXPORT_SYMBOL(drm_format_is_yuv_planar); +/** + * drm_format_is_yuv_sampling_410 - check that the format is a YUV format with + * 4:1:0 sub-sampling + * @format: pixel format + * + * Returns: + * A boolean indicating whether the format is a YUV format with 4:1:0 + * sub-sampling. + */ +bool drm_format_is_yuv_sampling_410(uint32_t format) +{ + const struct drm_format_info *info; + + info = drm_format_info(format); + if (!info) + return false; + + return drm_format_info_is_yuv_sampling_410(info); +} +EXPORT_SYMBOL(drm_format_is_yuv_sampling_410); + +/** + * drm_format_is_yuv_sampling_411 - check that the format is a YUV format with + * 4:1:1 sub-sampling + * @format: pixel format + * + * Returns: + * A boolean indicating whether the format is a YUV format with 4:1:1 + * sub-sampling. + */ +bool drm_format_is_yuv_sampling_411(uint32_t format) +{ + const struct drm_format_info *info; + + info = drm_format_info(format); + if (!info) + return false; + + return drm_format_info_is_yuv_sampling_411(info); +} +EXPORT_SYMBOL(drm_format_is_yuv_sampling_411); + +/** + * drm_format_is_yuv_sampling_420 - check that the format is a YUV format with + * 4:2:0 sub-sampling + * @format: pixel format + * + * Returns: + * A boolean indicating whether the format is a YUV format with 4:2:0 + * sub-sampling. + */ +bool drm_format_is_yuv_sampling_420(uint32_t format) +{ + const struct drm_format_info *info; + + info = drm_format_info(format); + if (!info) + return false; + + return drm_format_info_is_yuv_sampling_420(info); +} +EXPORT_SYMBOL(drm_format_is_yuv_sampling_420); + +/** + * drm_format_is_yuv_sampling_422 - check that the format is a YUV format with + * 4:2:2 sub-sampling + * @format: pixel format + * + * Returns: + * A boolean indicating whether the format is a YUV format with 4:2:2 + * sub-sampling. + */ +bool drm_format_is_yuv_sampling_422(uint32_t format) +{ + const struct drm_format_info *info; + + info = drm_format_info(format); + if (!info) + return false; + + return drm_format_info_is_yuv_sampling_422(info); +} +EXPORT_SYMBOL(drm_format_is_yuv_sampling_422); + +/** + * drm_format_is_yuv_sampling_444 - check that the format is a YUV format with + * 4:4:4 sub-sampling + * @format: pixel format + * + * Returns: + * A boolean indicating whether the format is a YUV format with 4:4:4 + * sub-sampling. + */ +bool drm_format_is_yuv_sampling_444(uint32_t format) +{ + const struct drm_format_info *info; + + info = drm_format_info(format); + if (!info) + return false; + + return drm_format_info_is_yuv_sampling_444(info); +} +EXPORT_SYMBOL(drm_format_is_yuv_sampling_444); + /** * 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 d170b7b323f7..cf082d8b6ad4 100644 --- a/include/drm/drm_fourcc.h +++ b/include/drm/drm_fourcc.h @@ -278,6 +278,11 @@ 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); +bool drm_format_is_yuv_sampling_410(uint32_t format); +bool drm_format_is_yuv_sampling_411(uint32_t format); +bool drm_format_is_yuv_sampling_420(uint32_t format); +bool drm_format_is_yuv_sampling_422(uint32_t format); +bool drm_format_is_yuv_sampling_444(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