Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3235381imu; Sat, 24 Nov 2018 00:45:04 -0800 (PST) X-Google-Smtp-Source: AJdET5cbLsypA2JhniyjPf+OOGoWTH7MLIhCDhz2rSLat+eHzkR3lHxfkm+hpBPkLEC6pPYS94No X-Received: by 2002:a62:35c2:: with SMTP id c185-v6mr19480406pfa.82.1543049104477; Sat, 24 Nov 2018 00:45:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543049104; cv=none; d=google.com; s=arc-20160816; b=mGiMTq8vIJHmqSTpCLuu49CSK1Yk9aDyghyocOPINessdILw1TpLCK2P5uhdzbqSoW BEKtfiobysjnrdYdw7wAYJ0QklP5k8cJAQ78pF5jn2yqSXQrvHVNR5gc48yGwBQ+F4FH KXHR4pR49BIuWm4OBN0gZQNEOtfpPgU38PgdCwnqe4uQi3u/Iu70nEFifL1h3rTOEZCB TuQHXJFfkTMSzZ68nqB1/fHrIBeXH1GZ9Tljg/zHKII5bDXOZfxSyMMc4T0sY7AjHozA Hw/PfG2iXPLtK47x3X47m2O4PaOdWU2CwRAlyY5XP7GD9SyJHw+uhQjBkER5ZwRVaixC X/jw== 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-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=d6US2/5v4a153VUcixusVSkY+2TGkQgwEH4A5mqKuGA=; b=mGtUO05B+H9lp+ocp+hHfZKX9rHM+PrvOM4vmrQqoNrBpoMbRCXrjf2Trif7CS8zlg ruvjJHJELBGYaH9tTQ1Pm8I5eGsANnrvi1KABc9vMBuCzQNivE5SXQpBovOQejEJBRFn ZFPJKrH1ywkKT6xvpPUT+Jb/r6QgDPe4RxHhowM34sQsyL0kDRxglq5a06eha65/BqSP oTrHaVKOusj5mUwqTPSAb4AIsBBGwsxGA+Ups0pTG6jDFrpuP7ymW25MMx5Y8ZquiRvA R10kzoylNxn9tIblNyIGQ0pMq3N08VrM1Ki8ZAzYOsvEk3A0wIm1fscTuR2gA6jw7C5Y 1hEA== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 1si30262397plk.296.2018.11.24.00.44.50; Sat, 24 Nov 2018 00:45:04 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2440841AbeKXEIW (ORCPT + 99 others); Fri, 23 Nov 2018 23:08:22 -0500 Received: from mga18.intel.com ([134.134.136.126]:35325 "EHLO mga18.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2391344AbeKXEIV (ORCPT ); Fri, 23 Nov 2018 23:08:21 -0500 X-Amp-Result: UNSCANNABLE X-Amp-File-Uploaded: False Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga106.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 23 Nov 2018 09:23:13 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.56,270,1539673200"; d="scan'208";a="107130010" Received: from stinkbox.fi.intel.com (HELO stinkbox) ([10.237.72.174]) by fmsmga002.fm.intel.com with SMTP; 23 Nov 2018 09:23:09 -0800 Received: by stinkbox (sSMTP sendmail emulation); Fri, 23 Nov 2018 19:23:08 +0200 Date: Fri, 23 Nov 2018 19:23:08 +0200 From: Ville =?iso-8859-1?Q?Syrj=E4l=E4?= To: Ayan Halder Cc: Paul Kocialkowski , nd , Maxime Ripard , "linux-kernel@vger.kernel.org" , "dri-devel@lists.freedesktop.org" , David Airlie , "linux-sunxi@googlegroups.com" , Thomas Petazzoni , Chen-Yu Tsai , Sean Paul , "linux-arm-kernel@lists.infradead.org" Subject: Re: [PATCH v2 12/43] drm/fourcc: Add format helpers for checking YUV sub-sampling Message-ID: <20181123172308.GR9144@intel.com> References: <20181123092515.2511-1-paul.kocialkowski@bootlin.com> <20181123092515.2511-13-paul.kocialkowski@bootlin.com> <20181123165532.GA22326@arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20181123165532.GA22326@arm.com> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Nov 23, 2018 at 04:55:33PM +0000, Ayan Halder wrote: > On Fri, Nov 23, 2018 at 10:24:44AM +0100, Paul Kocialkowski wrote: > > Hi Paul, > > > 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; Looks like you're doing a lot of drm_format_info(fb->format->format), which doesn't make sense. Not to mention that each lookup is a linear search so the costs may start to add up. Unless there's a really good reason I'd rather we try to remove all the current helpers that do these lookups, and not add any more. > > + > > + 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 > > > From patches [PATCH v2 08/43] till [PATCH v2 12/43], looks good to me. > > How about clubbing all the drm_format_helper functions together in a > separate file (call it drm_fourcc_helper.c)? This way, we could > keep the __drm_format_info[] only drm_fourcc.c. > > > _______________________________________________ > > dri-devel mailing list > > dri-devel@lists.freedesktop.org > > https://lists.freedesktop.org/mailman/listinfo/dri-devel > _______________________________________________ > dri-devel mailing list > dri-devel@lists.freedesktop.org > https://lists.freedesktop.org/mailman/listinfo/dri-devel -- Ville Syrj?l? Intel