All of lore.kernel.org
 help / color / mirror / Atom feed
From: Max Krummenacher <max.oss.09@gmail.com>
To: Maxime Ripard <maxime@cerno.tech>
Cc: Marek Vasut <marex@denx.de>,
	Christoph Niedermaier <cniedermaier@dh-electronics.com>,
	Max Krummenacher <max.krummenacher@toradex.com>,
	Dave Stevenson <dave.stevenson@raspberrypi.com>,
	David Airlie <airlied@linux.ie>, Shawn Guo <shawnguo@kernel.org>,
	Sascha Hauer <s.hauer@pengutronix.de>,
	DRI Development <dri-devel@lists.freedesktop.org>,
	DenysDrozdov <denys.drozdov@toradex.com>,
	Laurent Pinchart <laurent.pinchart@ideasonboard.com>,
	Pengutronix Kernel Team <kernel@pengutronix.de>,
	Sam Ravnborg <sam@ravnborg.org>,
	Linux ARM <linux-arm-kernel@lists.infradead.org>,
	NXP Linux Team <linux-imx@nxp.com>
Subject: Re: [RFC PATCH] drm/panel: simple: panel-dpi: use bus-format to set bpc and bus_format
Date: Wed, 23 Mar 2022 21:06:18 +0100	[thread overview]
Message-ID: <ab2db55f6dedba76cd112e4bbc43cf8a7e4332a3.camel@gmail.com> (raw)
In-Reply-To: <20220323155817.xcsqxothziot7ba3@houat>

Am Mittwoch, den 23.03.2022, 16:58 +0100 schrieb Maxime Ripard:
> On Wed, Mar 23, 2022 at 09:42:11AM +0100, Max Krummenacher wrote:
> > Am Freitag, den 18.03.2022, 17:53 +0000 schrieb Dave Stevenson:
> > > On Fri, 18 Mar 2022 at 17:16, Maxime Ripard <maxime@cerno.tech> wrote:
> > > > On Fri, Mar 18, 2022 at 05:05:11PM +0000, Dave Stevenson wrote:
> > > > > Hi Maxime
> > > > > 
> > > > > On Fri, 18 Mar 2022 at 16:35, Maxime Ripard <maxime@cerno.tech> wrote:
> > > > > > On Mon, Mar 07, 2022 at 04:26:56PM +0100, Max Krummenacher wrote:
> > > > > > > On Wed, Mar 2, 2022 at 5:22 PM Marek Vasut <marex@denx.de> wrote:
> > > > > > > > On 3/2/22 15:21, Maxime Ripard wrote:
> > > > > > > > > Hi,
> > > > > > > > 
> > > > > > > > Hi,
> > > > > > > > 
> > > > > > > > > Please try to avoid top posting
> > > > > > > Sorry.
> > > > > > > 
> > > > > > > > > On Wed, Feb 23, 2022 at 04:25:19PM +0100, Max Krummenacher wrote:
> > > > > > > > > > The goal here is to set the element bus_format in the struct
> > > > > > > > > > panel_desc. This is an enum with the possible values defined in
> > > > > > > > > > include/uapi/linux/media-bus-format.h.
> > > > > > > > > > 
> > > > > > > > > > The enum values are not constructed in a way that you could calculate
> > > > > > > > > > the value from color channel width/shift/mapping/whatever. You rather
> > > > > > > > > > would have to check if the combination of color channel
> > > > > > > > > > width/shift/mapping/whatever maps to an existing value and otherwise
> > > > > > > > > > EINVAL out.
> > > > > > > > > > 
> > > > > > > > > > I don't see the value in having yet another way of how this
> > > > > > > > > > information can be specified and then having to write a more
> > > > > > > > > > complicated parser which maps the dt data to bus_format.
> > > > > > > > > 
> > > > > > > > > Generally speaking, sending an RFC without explicitly stating what you
> > > > > > > > > want a comment on isn't very efficient.
> > > > > > > > 
> > > > > > > > Isn't that what RFC stands for -- Request For Comment ?
> > > > > > > 
> > > > > > > I hoped that the link to the original discussion was enough.
> > > > > > > 
> > > > > > > panel-simple used to have a finite number of hardcoded panels selected
> > > > > > > by their compatible.
> > > > > > > The following patchsets added a compatible 'panel-dpi' which should
> > > > > > > allow to specify the panel in the device tree with timing etc.
> > > > > > >   
> > > > > > > https://patchwork.kernel.org/project/dri-devel/patch/20200216181513.28109-6-sam@ravnborg.org/
> > > > > > > In the same release cycle part of it got reverted:
> > > > > > >   
> > > > > > > https://patchwork.kernel.org/project/dri-devel/patch/20200314153047.2486-3-sam@ravnborg.org/
> > > > > > > With this it is no longer possible to set bus_format.
> > > > > > > 
> > > > > > > The explanation what makes the use of a property "data-mapping" not a
> > > > > > > suitable way in that revert
> > > > > > > is a bit vague.
> > > > > > 
> > > > > > Indeed, but I can only guess. BGR666 in itself doesn't mean much for
> > > > > > example. Chances are the DPI interface will use a 24 bit bus, so where
> > > > > > is the padding?
> > > > > > 
> > > > > > I think that's what Sam and Laurent were talking about: there wasn't
> > > > > > enough information encoded in that property to properly describe the
> > > > > > format, hence the revert.
> > 
> > I agree that the strings used to set "data-mapping" weren't self explaining.
> > However, as there was a
> > clear 1:1 relation to the bus_format value the meaning
> > wasn't ambiguous at all.
> > 
> > > > > MEDIA_BUS_FMT_RGB666_1X18 defines an 18bit bus, therefore there is no
> > > > > padding. "bgr666" was selecting that media bus code (I won't ask about
> > > > > the rgb/bgr swap).
> > > > > 
> > > > > If there is padding on a 24 bit bus, then you'd use (for example)
> > > > > MEDIA_BUS_FMT_RGB666_1X24_CPADHI to denote that the top 2 bits of each
> > > > > colour are the padding. Define and use a PADLO variant if the padding
> > > > > is the low bits.
> > > > 
> > > > Yeah, that's kind of my point actually :)
> > > 
> > > Ah, OK :)
> > > 
> > > > Just having a rgb666 string won't allow to differentiate between
> > > > MEDIA_BUS_FMT_RGB666_1X18 and MEDIA_BUS_FMT_RGB666_1X24_CPADHI: both are
> > > > RGB666 formats. Or we could say that it's MEDIA_BUS_FMT_RGB666_1X18 and
> > > > then when we'll need MEDIA_BUS_FMT_RGB666_1X24_CPADHI we'll add a new
> > > > string but that usually leads to inconsistent or weird names, so this
> > > > isn't ideal.
> > 
> > We're on the same page that the strings that were used aren't self
> > explaining and do not follow a pattern which would make it easy to
> > extend. However that is something I addressed in my RFC proposal, not?
> > 
> > > > > The string matching would need to be extended to have some string to
> > > > > select those codes ("lvds666" is a weird choice from the original
> > > > > patch).
> > > > > 
> > > > > Taking those media bus codes and handling them appropriately is
> > > > > already done in vc4_dpi [1], and the vendor tree has gained
> > > > > BGR666_1X18 and BGR666_1X24_CPADHI [2] as they aren't defined in
> > > > > mainline.
> > > > > 
> > > > > Now this does potentially balloon out the number of MEDIA_BUS_FMT_xxx
> > > > > defines needed, but that's the downside of having defines for all
> > > > > formats.
> > > > > 
> > > > > (I will admit to having a similar change in the Pi vendor tree that
> > > > > allows the media bus code to be selected explicitly by hex value).
> > > > 
> > > > I think having an integer value is indeed better: it doesn't change much
> > > > in the device tree if we're using a header, it makes the driver simpler
> > > > since we don't have to parse a string, and we can easily extend it or
> > > > rename the define, it won't change the ABI.
> > 
> > Fine with me.
> > 
> > > > I'm not sure using the raw media bus format value is ideal though, since
> > > > that value could then be used by any OS, and it would effectively force
> > > > the mbus stuff down their throat.
> > 
> > I disagree here, this forces us to use code to map the device tree enum
> > to the kernel enum for Linux, i.e. adds complexity and maintenance work
> > if additional bus_formats are needed.
> > Assuming there is another OS which uses the device tree it would not
> > make a difference, that OS would still need to map the device tree enum
> > to the corresponding representation in their kernel.
> 
> So, you don't want to do something in Linux, but would expect someone
> else to be completely ok with that?

Yes, sort of.
Recycling the values as used currently in the Linux kernel rather than
inventing a new numbering will make the Linux code a little easier to
write, read and maintain without any negative effect on how that other
OSs would have to map the DT representation to their internal representation.

Would you rather have something like:

<the common dt-bindings header file>
DT_BUS_FMT_RGB666_1X18	1
DT_BUS_FMT_RGB888_1X24	2
...

<panel-simple.c>
switch (bus-format) {
case DT_BUS_FMT_RGB666_1X18:
  bus_format = MEDIA_BUS_FMT_RGB666_1X18; break;
case DT_BUS_FMT_RGB888_1X24:
  bus_format = MEDIA_BUS_FMT_RGB888_1X24; break;
...

> 
> > I would copy the definitions of media-bus-format.h into a header in
> > include/dt-bindings similarly as it is done for
> > include/dt-bindings/display/sdtv-standards.h for TV standards.
> 
> That might not be an option: that header is licensed under the GPL,
> device trees are usually licensed under GPL+MIT, and we don't have any
> requirements on the license for other projects using a DT (hence the
> dual license).

That one I didn't consider. That would be solved by a newly invented
enum.

Max

> 
> Maxime


WARNING: multiple messages have this Message-ID (diff)
From: Max Krummenacher <max.oss.09@gmail.com>
To: Maxime Ripard <maxime@cerno.tech>
Cc: Dave Stevenson <dave.stevenson@raspberrypi.com>,
	Marek Vasut <marex@denx.de>,
	 Christoph Niedermaier <cniedermaier@dh-electronics.com>,
	Max Krummenacher <max.krummenacher@toradex.com>,
	Pengutronix Kernel Team <kernel@pengutronix.de>,
	David Airlie <airlied@linux.ie>, Sam Ravnborg <sam@ravnborg.org>,
	 Sascha Hauer <s.hauer@pengutronix.de>,
	DRI Development <dri-devel@lists.freedesktop.org>,
	DenysDrozdov <denys.drozdov@toradex.com>,
	Laurent Pinchart <laurent.pinchart@ideasonboard.com>,
	Shawn Guo <shawnguo@kernel.org>,
	Linux ARM <linux-arm-kernel@lists.infradead.org>,
	NXP Linux Team <linux-imx@nxp.com>
Subject: Re: [RFC PATCH] drm/panel: simple: panel-dpi: use bus-format to set bpc and bus_format
Date: Wed, 23 Mar 2022 21:06:18 +0100	[thread overview]
Message-ID: <ab2db55f6dedba76cd112e4bbc43cf8a7e4332a3.camel@gmail.com> (raw)
In-Reply-To: <20220323155817.xcsqxothziot7ba3@houat>

Am Mittwoch, den 23.03.2022, 16:58 +0100 schrieb Maxime Ripard:
> On Wed, Mar 23, 2022 at 09:42:11AM +0100, Max Krummenacher wrote:
> > Am Freitag, den 18.03.2022, 17:53 +0000 schrieb Dave Stevenson:
> > > On Fri, 18 Mar 2022 at 17:16, Maxime Ripard <maxime@cerno.tech> wrote:
> > > > On Fri, Mar 18, 2022 at 05:05:11PM +0000, Dave Stevenson wrote:
> > > > > Hi Maxime
> > > > > 
> > > > > On Fri, 18 Mar 2022 at 16:35, Maxime Ripard <maxime@cerno.tech> wrote:
> > > > > > On Mon, Mar 07, 2022 at 04:26:56PM +0100, Max Krummenacher wrote:
> > > > > > > On Wed, Mar 2, 2022 at 5:22 PM Marek Vasut <marex@denx.de> wrote:
> > > > > > > > On 3/2/22 15:21, Maxime Ripard wrote:
> > > > > > > > > Hi,
> > > > > > > > 
> > > > > > > > Hi,
> > > > > > > > 
> > > > > > > > > Please try to avoid top posting
> > > > > > > Sorry.
> > > > > > > 
> > > > > > > > > On Wed, Feb 23, 2022 at 04:25:19PM +0100, Max Krummenacher wrote:
> > > > > > > > > > The goal here is to set the element bus_format in the struct
> > > > > > > > > > panel_desc. This is an enum with the possible values defined in
> > > > > > > > > > include/uapi/linux/media-bus-format.h.
> > > > > > > > > > 
> > > > > > > > > > The enum values are not constructed in a way that you could calculate
> > > > > > > > > > the value from color channel width/shift/mapping/whatever. You rather
> > > > > > > > > > would have to check if the combination of color channel
> > > > > > > > > > width/shift/mapping/whatever maps to an existing value and otherwise
> > > > > > > > > > EINVAL out.
> > > > > > > > > > 
> > > > > > > > > > I don't see the value in having yet another way of how this
> > > > > > > > > > information can be specified and then having to write a more
> > > > > > > > > > complicated parser which maps the dt data to bus_format.
> > > > > > > > > 
> > > > > > > > > Generally speaking, sending an RFC without explicitly stating what you
> > > > > > > > > want a comment on isn't very efficient.
> > > > > > > > 
> > > > > > > > Isn't that what RFC stands for -- Request For Comment ?
> > > > > > > 
> > > > > > > I hoped that the link to the original discussion was enough.
> > > > > > > 
> > > > > > > panel-simple used to have a finite number of hardcoded panels selected
> > > > > > > by their compatible.
> > > > > > > The following patchsets added a compatible 'panel-dpi' which should
> > > > > > > allow to specify the panel in the device tree with timing etc.
> > > > > > >   
> > > > > > > https://patchwork.kernel.org/project/dri-devel/patch/20200216181513.28109-6-sam@ravnborg.org/
> > > > > > > In the same release cycle part of it got reverted:
> > > > > > >   
> > > > > > > https://patchwork.kernel.org/project/dri-devel/patch/20200314153047.2486-3-sam@ravnborg.org/
> > > > > > > With this it is no longer possible to set bus_format.
> > > > > > > 
> > > > > > > The explanation what makes the use of a property "data-mapping" not a
> > > > > > > suitable way in that revert
> > > > > > > is a bit vague.
> > > > > > 
> > > > > > Indeed, but I can only guess. BGR666 in itself doesn't mean much for
> > > > > > example. Chances are the DPI interface will use a 24 bit bus, so where
> > > > > > is the padding?
> > > > > > 
> > > > > > I think that's what Sam and Laurent were talking about: there wasn't
> > > > > > enough information encoded in that property to properly describe the
> > > > > > format, hence the revert.
> > 
> > I agree that the strings used to set "data-mapping" weren't self explaining.
> > However, as there was a
> > clear 1:1 relation to the bus_format value the meaning
> > wasn't ambiguous at all.
> > 
> > > > > MEDIA_BUS_FMT_RGB666_1X18 defines an 18bit bus, therefore there is no
> > > > > padding. "bgr666" was selecting that media bus code (I won't ask about
> > > > > the rgb/bgr swap).
> > > > > 
> > > > > If there is padding on a 24 bit bus, then you'd use (for example)
> > > > > MEDIA_BUS_FMT_RGB666_1X24_CPADHI to denote that the top 2 bits of each
> > > > > colour are the padding. Define and use a PADLO variant if the padding
> > > > > is the low bits.
> > > > 
> > > > Yeah, that's kind of my point actually :)
> > > 
> > > Ah, OK :)
> > > 
> > > > Just having a rgb666 string won't allow to differentiate between
> > > > MEDIA_BUS_FMT_RGB666_1X18 and MEDIA_BUS_FMT_RGB666_1X24_CPADHI: both are
> > > > RGB666 formats. Or we could say that it's MEDIA_BUS_FMT_RGB666_1X18 and
> > > > then when we'll need MEDIA_BUS_FMT_RGB666_1X24_CPADHI we'll add a new
> > > > string but that usually leads to inconsistent or weird names, so this
> > > > isn't ideal.
> > 
> > We're on the same page that the strings that were used aren't self
> > explaining and do not follow a pattern which would make it easy to
> > extend. However that is something I addressed in my RFC proposal, not?
> > 
> > > > > The string matching would need to be extended to have some string to
> > > > > select those codes ("lvds666" is a weird choice from the original
> > > > > patch).
> > > > > 
> > > > > Taking those media bus codes and handling them appropriately is
> > > > > already done in vc4_dpi [1], and the vendor tree has gained
> > > > > BGR666_1X18 and BGR666_1X24_CPADHI [2] as they aren't defined in
> > > > > mainline.
> > > > > 
> > > > > Now this does potentially balloon out the number of MEDIA_BUS_FMT_xxx
> > > > > defines needed, but that's the downside of having defines for all
> > > > > formats.
> > > > > 
> > > > > (I will admit to having a similar change in the Pi vendor tree that
> > > > > allows the media bus code to be selected explicitly by hex value).
> > > > 
> > > > I think having an integer value is indeed better: it doesn't change much
> > > > in the device tree if we're using a header, it makes the driver simpler
> > > > since we don't have to parse a string, and we can easily extend it or
> > > > rename the define, it won't change the ABI.
> > 
> > Fine with me.
> > 
> > > > I'm not sure using the raw media bus format value is ideal though, since
> > > > that value could then be used by any OS, and it would effectively force
> > > > the mbus stuff down their throat.
> > 
> > I disagree here, this forces us to use code to map the device tree enum
> > to the kernel enum for Linux, i.e. adds complexity and maintenance work
> > if additional bus_formats are needed.
> > Assuming there is another OS which uses the device tree it would not
> > make a difference, that OS would still need to map the device tree enum
> > to the corresponding representation in their kernel.
> 
> So, you don't want to do something in Linux, but would expect someone
> else to be completely ok with that?

Yes, sort of.
Recycling the values as used currently in the Linux kernel rather than
inventing a new numbering will make the Linux code a little easier to
write, read and maintain without any negative effect on how that other
OSs would have to map the DT representation to their internal representation.

Would you rather have something like:

<the common dt-bindings header file>
DT_BUS_FMT_RGB666_1X18	1
DT_BUS_FMT_RGB888_1X24	2
...

<panel-simple.c>
switch (bus-format) {
case DT_BUS_FMT_RGB666_1X18:
  bus_format = MEDIA_BUS_FMT_RGB666_1X18; break;
case DT_BUS_FMT_RGB888_1X24:
  bus_format = MEDIA_BUS_FMT_RGB888_1X24; break;
...

> 
> > I would copy the definitions of media-bus-format.h into a header in
> > include/dt-bindings similarly as it is done for
> > include/dt-bindings/display/sdtv-standards.h for TV standards.
> 
> That might not be an option: that header is licensed under the GPL,
> device trees are usually licensed under GPL+MIT, and we don't have any
> requirements on the license for other projects using a DT (hence the
> dual license).

That one I didn't consider. That would be solved by a newly invented
enum.

Max

> 
> Maxime


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  reply	other threads:[~2022-03-23 20:06 UTC|newest]

Thread overview: 48+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-22  8:47 [RFC PATCH] drm/panel: simple: panel-dpi: use bus-format to set bpc and bus_format Max Krummenacher
2022-02-22  8:47 ` Max Krummenacher
2022-02-23 13:41 ` Maxime Ripard
2022-02-23 13:41   ` Maxime Ripard
2022-02-23 13:45   ` Marek Vasut
2022-02-23 13:45     ` Marek Vasut
2022-02-23 13:47     ` Maxime Ripard
2022-02-23 13:47       ` Maxime Ripard
2022-02-23 14:09       ` Marek Vasut
2022-02-23 14:09         ` Marek Vasut
2022-02-23 14:37         ` Maxime Ripard
2022-02-23 14:37           ` Maxime Ripard
2022-02-23 14:38           ` Marek Vasut
2022-02-23 14:38             ` Marek Vasut
2022-02-23 16:39             ` Maxime Ripard
2022-02-23 16:39               ` Maxime Ripard
2022-02-23 16:57               ` Marek Vasut
2022-02-23 16:57                 ` Marek Vasut
2022-02-23 15:25     ` Max Krummenacher
2022-02-23 15:25       ` Max Krummenacher
2022-03-02 14:21       ` Maxime Ripard
2022-03-02 14:21         ` Maxime Ripard
2022-03-02 16:22         ` Marek Vasut
2022-03-02 16:22           ` Marek Vasut
2022-03-07 15:26           ` Max Krummenacher
2022-03-07 15:26             ` Max Krummenacher
2022-03-18 16:35             ` Maxime Ripard
2022-03-18 16:35               ` Maxime Ripard
2022-03-18 17:05               ` Dave Stevenson
2022-03-18 17:05                 ` Dave Stevenson
2022-03-18 17:16                 ` Maxime Ripard
2022-03-18 17:16                   ` Maxime Ripard
2022-03-18 17:53                   ` Dave Stevenson
2022-03-18 17:53                     ` Dave Stevenson
2022-03-23  8:42                     ` Max Krummenacher
2022-03-23  8:42                       ` Max Krummenacher
2022-03-23 15:58                       ` Maxime Ripard
2022-03-23 15:58                         ` Maxime Ripard
2022-03-23 20:06                         ` Max Krummenacher [this message]
2022-03-23 20:06                           ` Max Krummenacher
2022-03-24  8:15                           ` Francesco Dolcini
2022-03-24  8:15                             ` Francesco Dolcini
2022-04-08 18:01                             ` Laurent Pinchart
2022-04-08 18:01                               ` Laurent Pinchart
2022-04-08 18:15                           ` Laurent Pinchart
2022-04-08 18:15                             ` Laurent Pinchart
2022-04-19 11:50                             ` Max Krummenacher
2022-04-19 11:50                               ` Max Krummenacher

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ab2db55f6dedba76cd112e4bbc43cf8a7e4332a3.camel@gmail.com \
    --to=max.oss.09@gmail.com \
    --cc=airlied@linux.ie \
    --cc=cniedermaier@dh-electronics.com \
    --cc=dave.stevenson@raspberrypi.com \
    --cc=denys.drozdov@toradex.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=kernel@pengutronix.de \
    --cc=laurent.pinchart@ideasonboard.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-imx@nxp.com \
    --cc=marex@denx.de \
    --cc=max.krummenacher@toradex.com \
    --cc=maxime@cerno.tech \
    --cc=s.hauer@pengutronix.de \
    --cc=sam@ravnborg.org \
    --cc=shawnguo@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.