Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp444779img; Thu, 21 Mar 2019 01:21:51 -0700 (PDT) X-Google-Smtp-Source: APXvYqw43uLnVJ0hqXS4Ha6x+nyFMEb+ddLvUrTbDCfDvWmm3Sdg8xWpo2v3b8KoAjZ4uXp51HL1 X-Received: by 2002:a63:f802:: with SMTP id n2mr2080660pgh.83.1553156511192; Thu, 21 Mar 2019 01:21:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553156511; cv=none; d=google.com; s=arc-20160816; b=O96OITMH/GJJRbPB8oMVolVL48jmwghJ4hSn5rajLkE1D4J9/3eLH2WiXna7yiTfwS dC7LRCo3NOfWfRvPSXWPMpCBn5DlfuYCtyyL03wgRPQONUvSXGlYlVpweL6pffHPo4RO oDqCYjarBespVXDX9ujq0kKP0syJfRq9Gx/GybKlCvI9aoOuhQTrPJ70nxT0Uddy1BeS 6JwnnEOdZpI8q70q9upR+xFLmhbIB4xZEpj8A0DVRkL343kHom7P4VpWlynrFUhcpo/o 83thZSqIhqvs7JslcmhxKHO/5/KqV+Ces/DkFnCm3njbFcOyXKYkQ+v5mLoIoi3oSFea Ojfw== 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; bh=5rjh6gz7ZY8dUEch/r4FnsAVqZ8Tja5ykkR/BfEQfxo=; b=rNbH25g0E2Wj/Z+1nEWSxZswSsPnjs4wHKrlJnvvovMsHo2U90y1Xx91wSvLyFL/wj ur/VbnGco8RFRWVmQJy2gCAjpilhiqnyTmSCzkFD6C4z0TZMbuZYoYhQ+Ro7XrEQ6uLZ UKlnL/8UJFP/GznmyzfAv1hXGffs9SYsIGUHq8+qFtkPtk8RmluMwYiNGmFqUbB6Cxp7 5yJ1JgUxVOkAaRRphVel6bkRE5R0pCxvM1ammr2zSz4b8S2NWV4ab7PrJwjl9a0hai3b 1bhqSbUTVZQ74cEM/i4MYrAKuSiihuSK73rIY4ABj544u00NqK8QQR2UrOgWvFod6Enk dJWA== 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 f124si3716745pfb.38.2019.03.21.01.21.35; Thu, 21 Mar 2019 01:21:51 -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 S1727934AbfCUIUr (ORCPT + 99 others); Thu, 21 Mar 2019 04:20:47 -0400 Received: from relay3-d.mail.gandi.net ([217.70.183.195]:42511 "EHLO relay3-d.mail.gandi.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727915AbfCUIUr (ORCPT ); Thu, 21 Mar 2019 04:20:47 -0400 X-Originating-IP: 90.88.33.153 Received: from localhost (aaubervilliers-681-1-92-153.w90-88.abo.wanadoo.fr [90.88.33.153]) (Authenticated sender: maxime.ripard@bootlin.com) by relay3-d.mail.gandi.net (Postfix) with ESMTPSA id 71FF660009; Thu, 21 Mar 2019 08:20:42 +0000 (UTC) Date: Thu, 21 Mar 2019 09:20:41 +0100 From: Maxime Ripard To: Boris Brezillon Cc: Daniel Vetter , David Airlie , Maarten Lankhorst , Sean Paul , Mauro Carvalho Chehab , Sakari Ailus , linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, Paul Kocialkowski , Hans Verkuil , Laurent Pinchart , Thomas Petazzoni , linux-media@vger.kernel.org Subject: Re: [RFC PATCH 06/20] lib: Add video format information library Message-ID: <20190321082041.aswin5sgpejnx76t@flea> References: <20190320143944.10454b3b@collabora.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="e2jb2zt3fdhdz6iq" Content-Disposition: inline In-Reply-To: <20190320143944.10454b3b@collabora.com> User-Agent: NeoMutt/20180716 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --e2jb2zt3fdhdz6iq Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Hi Boris, On Wed, Mar 20, 2019 at 02:39:44PM +0100, Boris Brezillon wrote: > On Tue, 19 Mar 2019 22:57:11 +0100 > Maxime Ripard wrote: > > > Move the DRM formats API to turn this into a more generic image formats API > > to be able to leverage it into some other places of the kernel, such as > > v4l2 drivers. > > > > Signed-off-by: Maxime Ripard > > --- > > include/linux/image-formats.h | 240 +++++++++++- > > lib/Kconfig | 7 +- > > lib/Makefile | 3 +- > > lib/image-formats-selftests.c | 326 +++++++++++++++- > > lib/image-formats.c | 760 +++++++++++++++++++++++++++++++++++- > > 5 files changed, 1336 insertions(+) > > create mode 100644 include/linux/image-formats.h > > create mode 100644 lib/image-formats-selftests.c > > create mode 100644 lib/image-formats.c > > > > [...] > > > --- /dev/null > > +++ b/lib/image-formats.c > > @@ -0,0 +1,760 @@ > > +#include > > +#include > > +#include > > +#include > > + > > +#include > > + > > +static const struct image_format_info formats[] = { > > + { > > ... > > > + }, > > +}; > > + > > +#define __image_format_lookup(_field, _fmt) \ > > + ({ \ > > + const struct image_format_info *format = NULL; \ > > + unsigned i; \ > > + \ > > + for (i = 0; i < ARRAY_SIZE(formats); i++) \ > > + if (formats[i]._field == _fmt) \ > > + format = &formats[i]; \ > > + \ > > + format; \ > > + }) > > + > > +/** > > + * __image_format_drm_lookup - query information for a given format > > + * @drm: DRM fourcc pixel format (DRM_FORMAT_*) > > + * > > + * The caller should only pass a supported pixel format to this function. > > + * > > + * Returns: > > + * The instance of struct image_format_info that describes the pixel format, or > > + * NULL if the format is unsupported. > > + */ > > +const struct image_format_info *__image_format_drm_lookup(u32 drm) > > +{ > > + return __image_format_lookup(drm_fmt, drm); > > +} > > +EXPORT_SYMBOL(__image_format_drm_lookup); > > + > > +/** > > + * image_format_drm_lookup - query information for a given format > > + * @drm: DRM fourcc pixel format (DRM_FORMAT_*) > > + * > > + * The caller should only pass a supported pixel format to this function. > > + * Unsupported pixel formats will generate a warning in the kernel log. > > + * > > + * Returns: > > + * The instance of struct image_format_info that describes the pixel format, or > > + * NULL if the format is unsupported. > > + */ > > +const struct image_format_info *image_format_drm_lookup(u32 drm) > > +{ > > + const struct image_format_info *format; > > + > > + format = __image_format_drm_lookup(drm); > > + > > + WARN_ON(!format); > > + return format; > > +} > > +EXPORT_SYMBOL(image_format_drm_lookup); > > I think this function and the DRM formats table should be moved in > drivers/gpu/drm/drm_image_format.c since they are DRM specific. The > remaining functions can IMHO be placed in include/linux/image-formats.h > as static inline funcs. This way you can get rid of lib/image-formats.c > and the associated Kconfig entry. I'm not quite sure what you mean. The whole point of the series is to split out that table out of DRM so that we can use it in other places, so surely putting it back into DRM defeats the purpose? Maxime -- Maxime Ripard, Bootlin Embedded Linux and Kernel engineering https://bootlin.com --e2jb2zt3fdhdz6iq Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iHUEABYIAB0WIQRcEzekXsqa64kGDp7j7w1vZxhRxQUCXJNJWQAKCRDj7w1vZxhR xTILAQDHHRBU77XsVzzXciL/8qvCrPNaAQuh6xVBpCgHVWb1+gD/SbS0s6OYIshv X8tkZEQEoreInmyKBXKuaUjwfXXgQgE= =zZ6Q -----END PGP SIGNATURE----- --e2jb2zt3fdhdz6iq--