Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp295322imm; Wed, 18 Jul 2018 02:13:04 -0700 (PDT) X-Google-Smtp-Source: AAOMgpcWADSBV6F5/jCDDqvfqPbkyu9uoarP7ZBqS0fooBRyDbnB3Ty30EGEdUJXn7XXq5MCVQAH X-Received: by 2002:a63:9e0a:: with SMTP id s10-v6mr4993071pgd.326.1531905184201; Wed, 18 Jul 2018 02:13:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531905184; cv=none; d=google.com; s=arc-20160816; b=PmzeRWrtBU2uqzCYvEHfopumsrkqdmeD5TAWefYZFknnXwd9Y0W0O6ynmeP3vcu7Gq bblxhvFYBnxsNWpRL8tgYOY2QLRiixLm687svkC4QDGJYcpnY9jwElyohKtfYyAJTiFb WsStazKH+tAUO5VquGUSNMglDHIjHb5JKo2pbNX1ZMLXDYfj/+JQHJNyz3IdLRmRVaYZ NSgzfS5YfjOuyEJKWxpiR+psl1QgPpcCpUMimcOjqms3hZWwdLs/NcXAPt0Qx9o75byY 46qJpgxa+d2Z+0qW4QSJplqsaTlHH7FFiCPNopNUQcVlFUCnzA/L7pTfq6qo1wldHyb0 roXg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:arc-authentication-results; bh=z0Zx6oGlVaw2CRMNKb2luL+2QfMEn6fkmrfKdMw70yM=; b=M7+J8/WcevCj+f2rSuzi9GQp1IDHh/uUp1EYEEWGeNlh7BldNiu0BGL7jk6XUNV1CM CD69uMM17JdWO5+SIZUhO/ySJw8Y8L7nfjuNac2iP1URRWc2IDf7T7HDHWrILnpwSBq8 uCqlfH4VCHgtp4odnN6rz59k9sWKzin07Iy75J4ZWmjGegM9ZaxWlZbt1XUz3hXhpsnZ c8tlC8/vcM6vfRhmZYgTVMR/D4CGoV24zQ9DHmxTxe3+9aO17FMmTeqf0P/+mQ2FjqQq 6jQFkmmzJHIRVj2Nu21jYhGVQu8t4TNct1abrOs8qASLq76d06w0TSWYTQpcubHqdUyr k3cw== 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 f21-v6si3084341pgl.235.2018.07.18.02.12.49; Wed, 18 Jul 2018 02:13:04 -0700 (PDT) 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 S1730491AbeGRJtH (ORCPT + 99 others); Wed, 18 Jul 2018 05:49:07 -0400 Received: from foss.arm.com ([217.140.101.70]:57746 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730226AbeGRJtG (ORCPT ); Wed, 18 Jul 2018 05:49:06 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 96BE47A9; Wed, 18 Jul 2018 02:12:11 -0700 (PDT) Received: from DESKTOP-E1NTVVP.localdomain (desktop-e1ntvvp.cambridge.arm.com [10.1.34.170]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 6F6A23F318; Wed, 18 Jul 2018 02:12:07 -0700 (PDT) Date: Wed, 18 Jul 2018 10:12:02 +0100 From: Brian Starkey To: Ayan Kumar Halder Cc: liviu.dudau@arm.com, gustavo@padovan.org, maarten.lankhorst@linux.intel.com, seanpaul@chromium.org, airlied@linux.ie, jani.nikula@linux.intel.com, joonas.lahtinen@linux.intel.com, rodrigo.vivi@intel.com, intel-gfx@lists.freedesktop.org, hjc@rock-chips.com, heiko@sntech.de, linux-arm-kernel@lists.infradead.org, linux-rockchip@lists.infradead.org, linux-kernel@vger.kernel.org, tomi.valkeinen@ti.com, laurent.pinchart@ideasonboard.com, sre@kernel.org, bparrot@ti.com, peter.ujfalusi@ti.com, afd@ti.com, dri-devel@lists.freedesktop.org, maxime.ripard@bootlin.com, wens@csie.org, malidp@foss.arm.com, nd@arm.com Subject: Re: [PATCH 1/5] drm/fourcc: Add is_yuv field to drm_format_info to denote if the format is yuv Message-ID: <20180718091202.GA27151@DESKTOP-E1NTVVP.localdomain> References: <1531847626-22248-1-git-send-email-ayan.halder@arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline In-Reply-To: <1531847626-22248-1-git-send-email-ayan.halder@arm.com> User-Agent: Mutt/1.9.4 (2018-02-28) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Ayan, On Tue, Jul 17, 2018 at 06:13:42PM +0100, Ayan Kumar Halder wrote: >A lot of drivers duplicate the function to check if a format is yuv or not. >If we add a field (to denote whether the format is yuv or not) in the >drm_format_info table, all the drivers can use this field and it will >prevent duplication of similar logic. This looks like a good idea to me. I wonder if the two "has_alpha" and "is_yuv" bools should be bitfields to reduce the footprint (not sure what the general DRM attitude to bitfields is), but either way: Reviewed-by: Brian Starkey > >Signed-off-by: Ayan Kumar halder >--- > drivers/gpu/drm/drm_fourcc.c | 42 +++++++++++++++++++++--------------------- > include/drm/drm_fourcc.h | 2 ++ > 2 files changed, 23 insertions(+), 21 deletions(-) > >diff --git a/drivers/gpu/drm/drm_fourcc.c b/drivers/gpu/drm/drm_fourcc.c >index 5ca6395..35c1e27 100644 >--- a/drivers/gpu/drm/drm_fourcc.c >+++ b/drivers/gpu/drm/drm_fourcc.c >@@ -152,27 +152,27 @@ const struct drm_format_info *__drm_format_info(u32 format) > { .format = DRM_FORMAT_XBGR8888_A8, .depth = 32, .num_planes = 2, .cpp = { 4, 1, 0 }, .hsub = 1, .vsub = 1, .has_alpha = true }, > { .format = DRM_FORMAT_RGBX8888_A8, .depth = 32, .num_planes = 2, .cpp = { 4, 1, 0 }, .hsub = 1, .vsub = 1, .has_alpha = true }, > { .format = DRM_FORMAT_BGRX8888_A8, .depth = 32, .num_planes = 2, .cpp = { 4, 1, 0 }, .hsub = 1, .vsub = 1, .has_alpha = true }, >- { .format = DRM_FORMAT_YUV410, .depth = 0, .num_planes = 3, .cpp = { 1, 1, 1 }, .hsub = 4, .vsub = 4 }, >- { .format = DRM_FORMAT_YVU410, .depth = 0, .num_planes = 3, .cpp = { 1, 1, 1 }, .hsub = 4, .vsub = 4 }, >- { .format = DRM_FORMAT_YUV411, .depth = 0, .num_planes = 3, .cpp = { 1, 1, 1 }, .hsub = 4, .vsub = 1 }, >- { .format = DRM_FORMAT_YVU411, .depth = 0, .num_planes = 3, .cpp = { 1, 1, 1 }, .hsub = 4, .vsub = 1 }, >- { .format = DRM_FORMAT_YUV420, .depth = 0, .num_planes = 3, .cpp = { 1, 1, 1 }, .hsub = 2, .vsub = 2 }, >- { .format = DRM_FORMAT_YVU420, .depth = 0, .num_planes = 3, .cpp = { 1, 1, 1 }, .hsub = 2, .vsub = 2 }, >- { .format = DRM_FORMAT_YUV422, .depth = 0, .num_planes = 3, .cpp = { 1, 1, 1 }, .hsub = 2, .vsub = 1 }, >- { .format = DRM_FORMAT_YVU422, .depth = 0, .num_planes = 3, .cpp = { 1, 1, 1 }, .hsub = 2, .vsub = 1 }, >- { .format = DRM_FORMAT_YUV444, .depth = 0, .num_planes = 3, .cpp = { 1, 1, 1 }, .hsub = 1, .vsub = 1 }, >- { .format = DRM_FORMAT_YVU444, .depth = 0, .num_planes = 3, .cpp = { 1, 1, 1 }, .hsub = 1, .vsub = 1 }, >- { .format = DRM_FORMAT_NV12, .depth = 0, .num_planes = 2, .cpp = { 1, 2, 0 }, .hsub = 2, .vsub = 2 }, >- { .format = DRM_FORMAT_NV21, .depth = 0, .num_planes = 2, .cpp = { 1, 2, 0 }, .hsub = 2, .vsub = 2 }, >- { .format = DRM_FORMAT_NV16, .depth = 0, .num_planes = 2, .cpp = { 1, 2, 0 }, .hsub = 2, .vsub = 1 }, >- { .format = DRM_FORMAT_NV61, .depth = 0, .num_planes = 2, .cpp = { 1, 2, 0 }, .hsub = 2, .vsub = 1 }, >- { .format = DRM_FORMAT_NV24, .depth = 0, .num_planes = 2, .cpp = { 1, 2, 0 }, .hsub = 1, .vsub = 1 }, >- { .format = DRM_FORMAT_NV42, .depth = 0, .num_planes = 2, .cpp = { 1, 2, 0 }, .hsub = 1, .vsub = 1 }, >- { .format = DRM_FORMAT_YUYV, .depth = 0, .num_planes = 1, .cpp = { 2, 0, 0 }, .hsub = 2, .vsub = 1 }, >- { .format = DRM_FORMAT_YVYU, .depth = 0, .num_planes = 1, .cpp = { 2, 0, 0 }, .hsub = 2, .vsub = 1 }, >- { .format = DRM_FORMAT_UYVY, .depth = 0, .num_planes = 1, .cpp = { 2, 0, 0 }, .hsub = 2, .vsub = 1 }, >- { .format = DRM_FORMAT_VYUY, .depth = 0, .num_planes = 1, .cpp = { 2, 0, 0 }, .hsub = 2, .vsub = 1 }, >- { .format = DRM_FORMAT_AYUV, .depth = 0, .num_planes = 1, .cpp = { 4, 0, 0 }, .hsub = 1, .vsub = 1, .has_alpha = true }, >+ { .format = DRM_FORMAT_YUV410, .depth = 0, .num_planes = 3, .cpp = { 1, 1, 1 }, .hsub = 4, .vsub = 4, .is_yuv = true }, >+ { .format = DRM_FORMAT_YVU410, .depth = 0, .num_planes = 3, .cpp = { 1, 1, 1 }, .hsub = 4, .vsub = 4, .is_yuv = true }, >+ { .format = DRM_FORMAT_YUV411, .depth = 0, .num_planes = 3, .cpp = { 1, 1, 1 }, .hsub = 4, .vsub = 1, .is_yuv = true }, >+ { .format = DRM_FORMAT_YVU411, .depth = 0, .num_planes = 3, .cpp = { 1, 1, 1 }, .hsub = 4, .vsub = 1, .is_yuv = true }, >+ { .format = DRM_FORMAT_YUV420, .depth = 0, .num_planes = 3, .cpp = { 1, 1, 1 }, .hsub = 2, .vsub = 2, .is_yuv = true }, >+ { .format = DRM_FORMAT_YVU420, .depth = 0, .num_planes = 3, .cpp = { 1, 1, 1 }, .hsub = 2, .vsub = 2, .is_yuv = true }, >+ { .format = DRM_FORMAT_YUV422, .depth = 0, .num_planes = 3, .cpp = { 1, 1, 1 }, .hsub = 2, .vsub = 1, .is_yuv = true }, >+ { .format = DRM_FORMAT_YVU422, .depth = 0, .num_planes = 3, .cpp = { 1, 1, 1 }, .hsub = 2, .vsub = 1, .is_yuv = true }, >+ { .format = DRM_FORMAT_YUV444, .depth = 0, .num_planes = 3, .cpp = { 1, 1, 1 }, .hsub = 1, .vsub = 1, .is_yuv = true }, >+ { .format = DRM_FORMAT_YVU444, .depth = 0, .num_planes = 3, .cpp = { 1, 1, 1 }, .hsub = 1, .vsub = 1, .is_yuv = true }, >+ { .format = DRM_FORMAT_NV12, .depth = 0, .num_planes = 2, .cpp = { 1, 2, 0 }, .hsub = 2, .vsub = 2, .is_yuv = true }, >+ { .format = DRM_FORMAT_NV21, .depth = 0, .num_planes = 2, .cpp = { 1, 2, 0 }, .hsub = 2, .vsub = 2, .is_yuv = true }, >+ { .format = DRM_FORMAT_NV16, .depth = 0, .num_planes = 2, .cpp = { 1, 2, 0 }, .hsub = 2, .vsub = 1, .is_yuv = true }, >+ { .format = DRM_FORMAT_NV61, .depth = 0, .num_planes = 2, .cpp = { 1, 2, 0 }, .hsub = 2, .vsub = 1, .is_yuv = true }, >+ { .format = DRM_FORMAT_NV24, .depth = 0, .num_planes = 2, .cpp = { 1, 2, 0 }, .hsub = 1, .vsub = 1, .is_yuv = true }, >+ { .format = DRM_FORMAT_NV42, .depth = 0, .num_planes = 2, .cpp = { 1, 2, 0 }, .hsub = 1, .vsub = 1, .is_yuv = true }, >+ { .format = DRM_FORMAT_YUYV, .depth = 0, .num_planes = 1, .cpp = { 2, 0, 0 }, .hsub = 2, .vsub = 1, .is_yuv = true }, >+ { .format = DRM_FORMAT_YVYU, .depth = 0, .num_planes = 1, .cpp = { 2, 0, 0 }, .hsub = 2, .vsub = 1, .is_yuv = true }, >+ { .format = DRM_FORMAT_UYVY, .depth = 0, .num_planes = 1, .cpp = { 2, 0, 0 }, .hsub = 2, .vsub = 1, .is_yuv = true }, >+ { .format = DRM_FORMAT_VYUY, .depth = 0, .num_planes = 1, .cpp = { 2, 0, 0 }, .hsub = 2, .vsub = 1, .is_yuv = true }, >+ { .format = DRM_FORMAT_AYUV, .depth = 0, .num_planes = 1, .cpp = { 4, 0, 0 }, .hsub = 1, .vsub = 1, .has_alpha = true, .is_yuv = true }, > }; > > unsigned int i; >diff --git a/include/drm/drm_fourcc.h b/include/drm/drm_fourcc.h >index 3e86408..f9c1584 100644 >--- a/include/drm/drm_fourcc.h >+++ b/include/drm/drm_fourcc.h >@@ -39,6 +39,7 @@ struct drm_mode_fb_cmd2; > * @hsub: Horizontal chroma subsampling factor > * @vsub: Vertical chroma subsampling factor > * @has_alpha: Does the format embeds an alpha component? >+ * @is_yuv: Is it a YUV format? > */ > struct drm_format_info { > u32 format; >@@ -48,6 +49,7 @@ struct drm_format_info { > u8 hsub; > u8 vsub; > bool has_alpha; >+ bool is_yuv; > }; > > /** >-- >2.7.4 >