Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3216231imu; Sat, 24 Nov 2018 00:18:50 -0800 (PST) X-Google-Smtp-Source: AFSGD/WTfSrWAY5bACT6/Hk/PPPWL37OLLwh8Rw4EHP2MV9W1tYtooL+LLESApTAC68dLOR1lWr9 X-Received: by 2002:a62:5182:: with SMTP id f124mr17015192pfb.238.1543047530427; Sat, 24 Nov 2018 00:18:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543047530; cv=none; d=google.com; s=arc-20160816; b=0AVKVuBnJIPmkyqrob9PhggiKEQiSuyGh/zj4E8qo9yIwbO6Ml5TBYOwYUHNqGdEs5 LmjfUwHPlHYFCVtp1PkJM/D9R5ttGjsJOPWkB9PCppx9LBa3RtgWkK0zVqh7n8FFv2eu Lekujkc8j5DEsj009LiFTyPY/MgJjX2bPFcYN6joOTd5dmygNE/az5v97Qf38/CcPlzf xzB4I2/SVf8thrOfDw6ZhM9exzY6R+sxYPlsoXIvV/bcqIJYEybs+Vh8TN6YE+4tHGfY +FXf/O8MHsd8Isp1kIosJZbxVlaJ7UJJz0H1PMxgERLGc3GidT14y3LplzLbygS5qY9m RfbA== 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=Z6dJQ/UV/uZfjyukw7Jhxgci2ZAWEj6mXNyHZuVvOrg=; b=x9k6FAprEP1GIYHN9yMobYoKQWQfuKVj5HGxmXx6U3VGhIkchRTMwceQT8nkAsWlJY HTKew6eWbWOBjf+ktmMH7ekzMavjzkBCo5sFjjYmSBO0aJFJ6kog7LCCoq725v4sForP pcYLmbV2ujc3iaUYIuV4DAj9rk5xVg0ojLKnPXAI6krg6EiL8QnFuqep5dw8DhF1I2a5 aYfnkgKEMKRn1ulPlKy93GF28zzcQMxSNa1H75OISbDTv61l1inmnU1zhwP9kagGjyOr 3na7QTn/PXJp4VBNiExEvr4VNRXkgbbWOBqLX0992xijHsyY4lWSlPs5tiNiJg3QL4e9 Vl5w== 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 f184-v6si44434674pfc.224.2018.11.24.00.18.36; Sat, 24 Nov 2018 00:18:50 -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 S2394371AbeKWUNY (ORCPT + 99 others); Fri, 23 Nov 2018 15:13:24 -0500 Received: from mail.bootlin.com ([62.4.15.54]:49271 "EHLO mail.bootlin.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388036AbeKWUKQ (ORCPT ); Fri, 23 Nov 2018 15:10:16 -0500 Received: by mail.bootlin.com (Postfix, from userid 110) id 889E620DD1; 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 3DDED20DD6; 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 11/43] drm/fourcc: Add format info helpers for checking YUV sub-sampling Date: Fri, 23 Nov 2018 10:24:43 +0100 Message-Id: <20181123092515.2511-12-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 Display engine drivers often need to distinguish between different types of YUV sub-sampling. This introduces helpers to check for common sub-sampling ratios in their commonly-used denomination from the DRM format info. Signed-off-by: Paul Kocialkowski --- include/drm/drm_fourcc.h | 75 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 75 insertions(+) diff --git a/include/drm/drm_fourcc.h b/include/drm/drm_fourcc.h index b652b711df1a..d170b7b323f7 100644 --- a/include/drm/drm_fourcc.h +++ b/include/drm/drm_fourcc.h @@ -185,6 +185,81 @@ drm_format_info_is_yuv_planar(const struct drm_format_info *info) return info->is_yuv && info->num_planes == 3; } +/** + * drm_format_info_is_yuv_sampling_410 - check that the format info matches a + * YUV format with 4:1:0 sub-sampling + * @info: format info + * + * Returns: + * A boolean indicating whether the format info matches a YUV format with 4:1:0 + * sub-sampling. + */ +static inline bool +drm_format_info_is_yuv_sampling_410(const struct drm_format_info *info) +{ + return info->is_yuv && info->hsub == 4 && info->vsub == 4; +} + +/** + * drm_format_info_is_yuv_sampling_411 - check that the format info matches a + * YUV format with 4:1:1 sub-sampling + * @info: format info + * + * Returns: + * A boolean indicating whether the format info matches a YUV format with 4:1:1 + * sub-sampling. + */ +static inline bool +drm_format_info_is_yuv_sampling_411(const struct drm_format_info *info) +{ + return info->is_yuv && info->hsub == 4 && info->vsub == 1; +} + +/** + * drm_format_info_is_yuv_sampling_420 - check that the format info matches a + * YUV format with 4:2:0 sub-sampling + * @info: format info + * + * Returns: + * A boolean indicating whether the format info matches a YUV format with 4:2:0 + * sub-sampling. + */ +static inline bool +drm_format_info_is_yuv_sampling_420(const struct drm_format_info *info) +{ + return info->is_yuv && info->hsub == 2 && info->vsub == 2; +} + +/** + * drm_format_info_is_yuv_sampling_422 - check that the format info matches a + * YUV format with 4:2:2 sub-sampling + * @info: format info + * + * Returns: + * A boolean indicating whether the format info matches a YUV format with 4:2:2 + * sub-sampling. + */ +static inline bool +drm_format_info_is_yuv_sampling_422(const struct drm_format_info *info) +{ + return info->is_yuv && info->hsub == 2 && info->vsub == 1; +} + +/** + * drm_format_info_is_yuv_sampling_444 - check that the format info matches a + * YUV format with 4:4:4 sub-sampling + * @info: format info + * + * Returns: + * A boolean indicating whether the format info matches a YUV format with 4:4:4 + * sub-sampling. + */ +static inline bool +drm_format_info_is_yuv_sampling_444(const struct drm_format_info *info) +{ + return info->is_yuv && info->hsub == 1 && info->vsub == 1; +} + 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