Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp5501053imu; Mon, 26 Nov 2018 01:05:56 -0800 (PST) X-Google-Smtp-Source: AFSGD/UXjTImsmFroI/0XSCiViyXVyqWZ2oibttcKdDihOQlv/L34pVs17U+gEVSTULJzgBxqqj4 X-Received: by 2002:a17:902:be0c:: with SMTP id r12mr13844709pls.299.1543223156853; Mon, 26 Nov 2018 01:05:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543223156; cv=none; d=google.com; s=arc-20160816; b=xPL/7yJPbNz4gHNsyo0xBJnlGv4Lz/LebQClLgkkyOC0rdRWOQpZn3o/BgIn0KpckP IVm0eHk4tnInNbOEUDunG+V5QfD8+BBYexXNphQhiHEkoP5QW1it/pO1IhfvEgCIC3YS kDJSO1keoV7OYHeUFDc9G+GYyzcXlLDwur9rUoQDWqZ6Le4c372cTajAf3Q4bSf84c8i dn/CUY0YI2KOojW4yYHITDHD8A4/tKJm/alAE2msUyhrs/ofMdXdjRmKfeuyOvsGEK4e MHRnmLy34R/UahHKvWwyLCH+fQpuWYYEBvXSNDH+LwRfGwTOf20cYz2AlzR1BHQPv+Su ukAA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:organization :references:in-reply-to:date:cc:to:from:subject:message-id; bh=Me3DgUJl3FgFGShKNuY9PGEkKg5IR9TPdMGRl27LflE=; b=gvlBHEXc5I65neMwxQldTlkmE6suXcmVxdiEpcQwGAdrkZr48GQbWWMRNDGBJO/Xxj uxXCchXU8xGt0WLP916JTNBoGDWIIR5lLYsb6av7qnmUH14AzEksZ7XMdYGB733c3M+n lIUlpI4P4MZGty6f8YZerkRoJsmmpq5CaJxM9MBnMcLxmBlwewk7O8PHLwG2VH+ssf5s TyapMppbHqCMYZik5EG1VsC4iE5F6a3pTu5DnCwSpTxIMkpkuwLeiY7Lm0kf0u2IAhSc 2u2vC0/fhKz+bQic9D5Lxy+Oz0UWmpYbt1Dx1QUsY0LDAk00PgIGBp7hyy13ncMjjvgW N5rQ== 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 s5si24763376pfi.134.2018.11.26.01.05.39; Mon, 26 Nov 2018 01:05:56 -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 S1726354AbeKZT47 (ORCPT + 99 others); Mon, 26 Nov 2018 14:56:59 -0500 Received: from mail.bootlin.com ([62.4.15.54]:45269 "EHLO mail.bootlin.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726200AbeKZT47 (ORCPT ); Mon, 26 Nov 2018 14:56:59 -0500 Received: by mail.bootlin.com (Postfix, from userid 110) id BFA9520D31; Mon, 26 Nov 2018 10:03:28 +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 aptenodytes (aaubervilliers-681-1-94-205.w90-88.abo.wanadoo.fr [90.88.35.205]) by mail.bootlin.com (Postfix) with ESMTPSA id 5FB7320701; Mon, 26 Nov 2018 10:03:18 +0100 (CET) Message-ID: <8598fbb06768c0701571d43f4148a3891ad8ff12.camel@bootlin.com> Subject: Re: [PATCH v2 12/43] drm/fourcc: Add format helpers for checking YUV sub-sampling From: Paul Kocialkowski To: Ville =?ISO-8859-1?Q?Syrj=E4l=E4?= , Ayan Halder Cc: 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" Date: Mon, 26 Nov 2018 10:03:17 +0100 In-Reply-To: <20181123172308.GR9144@intel.com> References: <20181123092515.2511-1-paul.kocialkowski@bootlin.com> <20181123092515.2511-13-paul.kocialkowski@bootlin.com> <20181123165532.GA22326@arm.com> <20181123172308.GR9144@intel.com> Organization: Bootlin Content-Type: multipart/signed; micalg="pgp-sha256"; protocol="application/pgp-signature"; boundary="=-bKXIetVKq/YjlhcXtyi8" User-Agent: Evolution 3.30.2 Mime-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --=-bKXIetVKq/YjlhcXtyi8 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hi, On Fri, 2018-11-23 at 19:23 +0200, Ville Syrj=C3=A4l=C3=A4 wrote: > 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: > >=20 > > Hi Paul, > >=20 > > > This introduces new format helpers that use the previously-introduced > > > format info helpers for checking YUV sub-sampling. > > >=20 > > > Only the format fourcc is required by these helpers and the formats a= re > > > iterated from the list. > > >=20 > > > Signed-off-by: Paul Kocialkowski > > > --- > > > drivers/gpu/drm/drm_fourcc.c | 105 +++++++++++++++++++++++++++++++++= ++ > > > include/drm/drm_fourcc.h | 5 ++ > > > 2 files changed, 110 insertions(+) > > >=20 > > > diff --git a/drivers/gpu/drm/drm_fourcc.c b/drivers/gpu/drm/drm_fourc= c.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); > > > =20 > > > +/** > > > + * drm_format_is_yuv_sampling_410 - check that the format is a YUV f= ormat 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 =3D drm_format_info(format); > > > + if (!info) > > > + return false; >=20 > 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. >=20 > 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. I totally agree that we should be passing the drm_format_info structure onwards to all the driver helpers so we don't have to do the lookup each time. I thought it was still somewhat acceptable to have lookup fashions of these format helpers, but I am totally in favor of getting rid of them (and other lookup helpers eventually). I'll remove the lookup YUV format helpers and convert this series to passing the full drm_format_info everywhere needed. Cheers, Paul > > > + > > > + 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 f= ormat 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 =3D 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 f= ormat 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 =3D 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 f= ormat 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 =3D 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 f= ormat 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 =3D 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_inf= o *info, > > > int plane); > > > unsigned int drm_format_info_block_height(const struct drm_format_in= fo *info, > > > --=20 > > > 2.19.1 > > >=20 > > From patches [PATCH v2 08/43] till [PATCH v2 12/43], looks good to me. > >=20 > > 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. > >=20 > > > _______________________________________________ > > > 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 --=20 Paul Kocialkowski, Bootlin (formerly Free Electrons) Embedded Linux and kernel engineering https://bootlin.com --=-bKXIetVKq/YjlhcXtyi8 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: This is a digitally signed message part Content-Transfer-Encoding: 7bit -----BEGIN PGP SIGNATURE----- iQEzBAABCAAdFiEEJZpWjZeIetVBefti3cLmz3+fv9EFAlv7ttUACgkQ3cLmz3+f v9HsNQf+Ify8eWnG0z5Uj7O1DH0NRASlhAaJofz2laZpSVEix1IRM0QVHv825Rdu BnYCYAo11Z1OM6zFXJtQcyp0kXnlTv/Vtf/UT2c5/BKYRI2uWrzCNMqz9IJGJzXG QbaDQRReN6ylkl+r/wSSW0Ny6aXSUUit/5WO2BeATZ6nywzmIMCBLwsR5m9Ngb/L 1cB1QpKlyKGZhGxhTE3ks24SE2QfL7b8QX5bOuInZFvVZWEHy0KhFex1crbxUgZp 9tB9L7FJiksLJSF3rZh7tBbzZHQLPNEmu/VWOPzFhyuRUNBmnD21RVuhxh0nQV6D bvJ3azrrONmyAZhO1M01vSB2Qrh5iw== =PKmP -----END PGP SIGNATURE----- --=-bKXIetVKq/YjlhcXtyi8--