Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3216341imu; Sat, 24 Nov 2018 00:19:00 -0800 (PST) X-Google-Smtp-Source: AJdET5eOABOEduaJN/fORQDZntN+khh8NAfpSY8fdelo9tFbWAkoxjPnrYw/U2Fxojnfxkdw0GAA X-Received: by 2002:a62:f5da:: with SMTP id b87mr19704128pfm.253.1543047540911; Sat, 24 Nov 2018 00:19:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543047540; cv=none; d=google.com; s=arc-20160816; b=btLd1X+itaIzwjs+djoGsJjAhOEXpQNH3F3d1dktxl+pxoaO6AFwP7ebFPiyYbCTfB JBo8Dmvfimpd/9vzwx2i92shQli19Cz94R1ZJxAayMjiOuJHiaYmgZ5cYSQjNBimvi/E ts6NX6F/6duj4Pvup3iv8Hs5XXW96MU0sCcAfh9yfwIiDFh0awIolLZ1L0wQmCFMI63H SNlOzGdPiAlJ8+unrnYxIO60lUo1zPK2g/J4RUHGfk1Wc1QcmfOOKS/c91oEVe37u7Xd 0tzDjol/+VbRppFcIwRkdZS8GNK7yj75UATPGFXKcprtfK8qsFOHPX4Yg3mUhr1fld1H hTdQ== 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=VvcJJhTJ2hcP92AIKK0OrNNStXk5otlBWf2kWks+T8c=; b=zcRRD9cFPBV/BBPw8I94wM+Lz5nmoTkvNOPnza5qc5HHy6z6riPtTGl3Bbm0R03qwS ihzCiD3fmNX1MrQZxgzcWEmVW+bpNSACtCr2TYQFiWaAyB2xdmbBpE5GHgGxhvwYNOSr +RvQy0/Mvghscf0X/HgzjXG2aaYxXxIY0TSi5xzVlsk02SEakwoI150FqrWqV3Im1aY7 54+oI1vJT8imeYeEXHlB/nj5hD8HZZ3gVyf7OpgT/fD6Bg7BFP9GpxhOc6C4Nmet/vN3 yJEhHKPE5tMWaWWC9pnt0XY3WqydXx/p008YVoRpvafHhFv12EOaCkwr4j2ncQPXj4iL Qkrw== 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 j10si38391175pll.179.2018.11.24.00.18.46; Sat, 24 Nov 2018 00:19:00 -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 S2409100AbeKWUN6 (ORCPT + 99 others); Fri, 23 Nov 2018 15:13:58 -0500 Received: from mail.bootlin.com ([62.4.15.54]:49214 "EHLO mail.bootlin.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2502645AbeKWUKP (ORCPT ); Fri, 23 Nov 2018 15:10:15 -0500 Received: by mail.bootlin.com (Postfix, from userid 110) id 12B1B20DC1; 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 6E7BB20DC4; 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 08/43] drm/fourcc: Add helper to check if a format uses a YUV colorspace Date: Fri, 23 Nov 2018 10:24:40 +0100 Message-Id: <20181123092515.2511-9-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 adds a new helper to check whether the format described by its fourcc code uses a YUV colorspace, by returning the is_yuv entry for the DRM info entry matching that format. Signed-off-by: Paul Kocialkowski --- drivers/gpu/drm/drm_fourcc.c | 19 +++++++++++++++++++ include/drm/drm_fourcc.h | 1 + 2 files changed, 20 insertions(+) diff --git a/drivers/gpu/drm/drm_fourcc.c b/drivers/gpu/drm/drm_fourcc.c index f523948c82b1..f85650c3463a 100644 --- a/drivers/gpu/drm/drm_fourcc.c +++ b/drivers/gpu/drm/drm_fourcc.c @@ -413,6 +413,25 @@ int drm_format_plane_height(int height, uint32_t format, int plane) } EXPORT_SYMBOL(drm_format_plane_height); +/** + * drm_format_is_yuv - check that the format uses a YUV colorspace + * @format: pixel format + * + * Returns: + * A boolean indicating whether the format uses a YUV colorspace. + */ +bool drm_format_is_yuv(uint32_t format) +{ + const struct drm_format_info *info; + + info = drm_format_info(format); + if (!info) + return false; + + return info->is_yuv; +} +EXPORT_SYMBOL(drm_format_is_yuv); + /** * 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 bcb389f04618..569b70483505 100644 --- a/include/drm/drm_fourcc.h +++ b/include/drm/drm_fourcc.h @@ -157,6 +157,7 @@ int drm_format_horz_chroma_subsampling(uint32_t format); 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); 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