2022-10-20 08:56:54

by Maxime Ripard

[permalink] [raw]
Subject: [PATCH v2 0/7] drm/vc4: dpi: Various improvements

Hi,

Those patches have been in the downstream RaspberryPi tree for a while and help
to support more DPI displays.

Let me know what you think,
Maxime

To: Emma Anholt <[email protected]>
To: Maxime Ripard <[email protected]>
To: David Airlie <[email protected]>
To: Daniel Vetter <[email protected]>
To: Eric Anholt <[email protected]>
To: Rob Herring <[email protected]>
Cc: [email protected]
Cc: [email protected]
Cc: Chris Morgan <[email protected]>
Cc: Joerg Quinten <[email protected]>
Cc: Laurent Pinchart <[email protected]>
Cc: Dave Stevenson <[email protected]>
Signed-off-by: Maxime Ripard <[email protected]>

---
Changes in v2:
- Documentation for the media bus formats
- Reword the commit log of patch 5
- Link to v1: https://lore.kernel.org/r/[email protected]

---
Chris Morgan (2):
media: uapi: add MEDIA_BUS_FMT_RGB565_1X24_CPADHI
drm/vc4: dpi: Support RGB565 format

Dave Stevenson (2):
drm/vc4: dpi: Change the default DPI format to being 18bpp, not 24.
drm/vc4: dpi: Fix format mapping for RGB565

Joerg Quinten (3):
media: uapi: add MEDIA_BUS_FMT_BGR666_1X18
media: uapi: add MEDIA_BUS_FMT_BGR666_1X24_CPADHI
drm/vc4: dpi: Support BGR666 formats

.../userspace-api/media/v4l/subdev-formats.rst | 111 +++++++++++++++++++++
drivers/gpu/drm/vc4/vc4_dpi.c | 16 ++-
include/uapi/linux/media-bus-format.h | 5 +-
3 files changed, 128 insertions(+), 4 deletions(-)
---
base-commit: 7c99616e3fe7f35fe25bf6f5797267da29b4751e
change-id: 20221013-rpi-dpi-improvements-c3d755531c39

Best regards,
--
Maxime Ripard <[email protected]>


2022-10-20 08:56:59

by Maxime Ripard

[permalink] [raw]
Subject: [PATCH v2 5/7] drm/vc4: dpi: Support BGR666 formats

From: Joerg Quinten <[email protected]>

The VC4 DPI output can support multiple BGR666 variants, but they were
never added to the driver. Let's add the the support for those formats.

Signed-off-by: Joerg Quinten <[email protected]>
Reviewed-by: Laurent Pinchart <[email protected]>
Signed-off-by: Maxime Ripard <[email protected]>
---
drivers/gpu/drm/vc4/vc4_dpi.c | 6 ++++++
1 file changed, 6 insertions(+)

diff --git a/drivers/gpu/drm/vc4/vc4_dpi.c b/drivers/gpu/drm/vc4/vc4_dpi.c
index 7da3dd1db50e..ecbe4cd87036 100644
--- a/drivers/gpu/drm/vc4/vc4_dpi.c
+++ b/drivers/gpu/drm/vc4/vc4_dpi.c
@@ -170,10 +170,16 @@ static void vc4_dpi_encoder_enable(struct drm_encoder *encoder)
dpi_c |= VC4_SET_FIELD(DPI_ORDER_BGR,
DPI_ORDER);
break;
+ case MEDIA_BUS_FMT_BGR666_1X24_CPADHI:
+ dpi_c |= VC4_SET_FIELD(DPI_ORDER_BGR, DPI_ORDER);
+ fallthrough;
case MEDIA_BUS_FMT_RGB666_1X24_CPADHI:
dpi_c |= VC4_SET_FIELD(DPI_FORMAT_18BIT_666_RGB_2,
DPI_FORMAT);
break;
+ case MEDIA_BUS_FMT_BGR666_1X18:
+ dpi_c |= VC4_SET_FIELD(DPI_ORDER_BGR, DPI_ORDER);
+ fallthrough;
case MEDIA_BUS_FMT_RGB666_1X18:
dpi_c |= VC4_SET_FIELD(DPI_FORMAT_18BIT_666_RGB_1,
DPI_FORMAT);

--
b4 0.10.1

2022-10-20 08:56:59

by Maxime Ripard

[permalink] [raw]
Subject: [PATCH v2 6/7] drm/vc4: dpi: Change the default DPI format to being 18bpp, not 24.

From: Dave Stevenson <[email protected]>

DPI hasn't really been used up until now, so the default has
been meaningless.
In theory we should be able to pass the desired format for the
adjacent bridge chip through, but framework seems to be missing
for that.

As the main device to use DPI is the VGA666 or Adafruit Kippah,
both of which use RGB666, change the default to being RGB666 instead
of RGB888.

Signed-off-by: Dave Stevenson <[email protected]>
Reviewed-by: Laurent Pinchart <[email protected]>
Signed-off-by: Maxime Ripard <[email protected]>
---
drivers/gpu/drm/vc4/vc4_dpi.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/vc4/vc4_dpi.c b/drivers/gpu/drm/vc4/vc4_dpi.c
index ecbe4cd87036..fdae02760b6d 100644
--- a/drivers/gpu/drm/vc4/vc4_dpi.c
+++ b/drivers/gpu/drm/vc4/vc4_dpi.c
@@ -150,8 +150,8 @@ static void vc4_dpi_encoder_enable(struct drm_encoder *encoder)
}
drm_connector_list_iter_end(&conn_iter);

- /* Default to 24bit if no connector or format found. */
- dpi_c |= VC4_SET_FIELD(DPI_FORMAT_24BIT_888_RGB, DPI_FORMAT);
+ /* Default to 18bit if no connector or format found. */
+ dpi_c |= VC4_SET_FIELD(DPI_FORMAT_18BIT_666_RGB_1, DPI_FORMAT);

if (connector) {
if (connector->display_info.num_bus_formats) {

--
b4 0.10.1

2022-10-20 08:57:04

by Maxime Ripard

[permalink] [raw]
Subject: [PATCH v2 7/7] drm/vc4: dpi: Fix format mapping for RGB565

From: Dave Stevenson <[email protected]>

The mapping is incorrect for RGB565_1X16 as it should be
DPI_FORMAT_18BIT_666_RGB_1 instead of DPI_FORMAT_18BIT_666_RGB_3.

Fixes: 08302c35b59d ("drm/vc4: Add DPI driver")
Signed-off-by: Dave Stevenson <[email protected]>
Reviewed-by: Laurent Pinchart <[email protected]>
Signed-off-by: Maxime Ripard <[email protected]>
---
drivers/gpu/drm/vc4/vc4_dpi.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/vc4/vc4_dpi.c b/drivers/gpu/drm/vc4/vc4_dpi.c
index fdae02760b6d..a7bebfa5d5b0 100644
--- a/drivers/gpu/drm/vc4/vc4_dpi.c
+++ b/drivers/gpu/drm/vc4/vc4_dpi.c
@@ -185,7 +185,7 @@ static void vc4_dpi_encoder_enable(struct drm_encoder *encoder)
DPI_FORMAT);
break;
case MEDIA_BUS_FMT_RGB565_1X16:
- dpi_c |= VC4_SET_FIELD(DPI_FORMAT_16BIT_565_RGB_3,
+ dpi_c |= VC4_SET_FIELD(DPI_FORMAT_16BIT_565_RGB_1,
DPI_FORMAT);
break;
case MEDIA_BUS_FMT_RGB565_1X24_CPADHI:

--
b4 0.10.1

2022-10-20 09:35:19

by Maxime Ripard

[permalink] [raw]
Subject: [PATCH v2 3/7] media: uapi: add MEDIA_BUS_FMT_BGR666_1X24_CPADHI

From: Joerg Quinten <[email protected]>

Add the BGR666 format MEDIA_BUS_FMT_BGR666_1X24_CPADHI supported by the
RaspberryPi.

Signed-off-by: Joerg Quinten <[email protected]>
Signed-off-by: Maxime Ripard <[email protected]>
---
.../userspace-api/media/v4l/subdev-formats.rst | 37 ++++++++++++++++++++++
include/uapi/linux/media-bus-format.h | 3 +-
2 files changed, 39 insertions(+), 1 deletion(-)

diff --git a/Documentation/userspace-api/media/v4l/subdev-formats.rst b/Documentation/userspace-api/media/v4l/subdev-formats.rst
index 68f8d7d37984..604a30e2f890 100644
--- a/Documentation/userspace-api/media/v4l/subdev-formats.rst
+++ b/Documentation/userspace-api/media/v4l/subdev-formats.rst
@@ -1023,6 +1023,43 @@ The following tables list existing packed RGB formats.
- g\ :sub:`2`
- g\ :sub:`1`
- g\ :sub:`0`
+ * .. _MEDIA-BUS-FMT-BGR666-1X24_CPADHI:
+
+ - MEDIA_BUS_FMT_BGR666_1X24_CPADHI
+ - 0x1024
+ -
+ -
+ -
+ -
+ -
+ -
+ -
+ -
+ -
+ - 0
+ - 0
+ - b\ :sub:`5`
+ - b\ :sub:`4`
+ - b\ :sub:`3`
+ - b\ :sub:`2`
+ - b\ :sub:`1`
+ - b\ :sub:`0`
+ - 0
+ - 0
+ - g\ :sub:`5`
+ - g\ :sub:`4`
+ - g\ :sub:`3`
+ - g\ :sub:`2`
+ - g\ :sub:`1`
+ - g\ :sub:`0`
+ - 0
+ - 0
+ - r\ :sub:`5`
+ - r\ :sub:`4`
+ - r\ :sub:`3`
+ - r\ :sub:`2`
+ - r\ :sub:`1`
+ - r\ :sub:`0`
* .. _MEDIA-BUS-FMT-RGB565-1X24_CPADHI:

- MEDIA_BUS_FMT_RGB565_1X24_CPADHI
diff --git a/include/uapi/linux/media-bus-format.h b/include/uapi/linux/media-bus-format.h
index 2ee0b38c0a71..d4228d038b54 100644
--- a/include/uapi/linux/media-bus-format.h
+++ b/include/uapi/linux/media-bus-format.h
@@ -34,7 +34,7 @@

#define MEDIA_BUS_FMT_FIXED 0x0001

-/* RGB - next is 0x1024 */
+/* RGB - next is 0x1025 */
#define MEDIA_BUS_FMT_RGB444_1X12 0x1016
#define MEDIA_BUS_FMT_RGB444_2X8_PADHI_BE 0x1001
#define MEDIA_BUS_FMT_RGB444_2X8_PADHI_LE 0x1002
@@ -49,6 +49,7 @@
#define MEDIA_BUS_FMT_BGR666_1X18 0x1023
#define MEDIA_BUS_FMT_RGB666_1X18 0x1009
#define MEDIA_BUS_FMT_RBG888_1X24 0x100e
+#define MEDIA_BUS_FMT_BGR666_1X24_CPADHI 0x1024
#define MEDIA_BUS_FMT_RGB666_1X24_CPADHI 0x1015
#define MEDIA_BUS_FMT_RGB666_1X7X3_SPWG 0x1010
#define MEDIA_BUS_FMT_BGR888_1X24 0x1013

--
b4 0.10.1

2022-11-29 12:58:49

by Laurent Pinchart

[permalink] [raw]
Subject: Re: [PATCH v2 3/7] media: uapi: add MEDIA_BUS_FMT_BGR666_1X24_CPADHI

Hi Maxime and Joerg,

Thank you for the patch.

On Thu, Oct 20, 2022 at 10:30:47AM +0200, Maxime Ripard wrote:
> From: Joerg Quinten <[email protected]>
>
> Add the BGR666 format MEDIA_BUS_FMT_BGR666_1X24_CPADHI supported by the
> RaspberryPi.
>
> Signed-off-by: Joerg Quinten <[email protected]>
> Signed-off-by: Maxime Ripard <[email protected]>
> ---
> .../userspace-api/media/v4l/subdev-formats.rst | 37 ++++++++++++++++++++++
> include/uapi/linux/media-bus-format.h | 3 +-
> 2 files changed, 39 insertions(+), 1 deletion(-)
>
> diff --git a/Documentation/userspace-api/media/v4l/subdev-formats.rst b/Documentation/userspace-api/media/v4l/subdev-formats.rst
> index 68f8d7d37984..604a30e2f890 100644
> --- a/Documentation/userspace-api/media/v4l/subdev-formats.rst
> +++ b/Documentation/userspace-api/media/v4l/subdev-formats.rst
> @@ -1023,6 +1023,43 @@ The following tables list existing packed RGB formats.
> - g\ :sub:`2`
> - g\ :sub:`1`
> - g\ :sub:`0`
> + * .. _MEDIA-BUS-FMT-BGR666-1X24_CPADHI:

I would move this just below MEDIA_BUS_FMT_RGB565_1X24_CPADHI. Actually,
could you check 1/7 and 2/7 to make sure the formats are sorted in the
documentation in the same order as in the header ?

> +
> + - MEDIA_BUS_FMT_BGR666_1X24_CPADHI
> + - 0x1024
> + -
> + -
> + -
> + -
> + -
> + -
> + -
> + -
> + -
> + - 0
> + - 0
> + - b\ :sub:`5`
> + - b\ :sub:`4`
> + - b\ :sub:`3`
> + - b\ :sub:`2`
> + - b\ :sub:`1`
> + - b\ :sub:`0`
> + - 0
> + - 0
> + - g\ :sub:`5`
> + - g\ :sub:`4`
> + - g\ :sub:`3`
> + - g\ :sub:`2`
> + - g\ :sub:`1`
> + - g\ :sub:`0`
> + - 0
> + - 0
> + - r\ :sub:`5`
> + - r\ :sub:`4`
> + - r\ :sub:`3`
> + - r\ :sub:`2`
> + - r\ :sub:`1`
> + - r\ :sub:`0`
> * .. _MEDIA-BUS-FMT-RGB565-1X24_CPADHI:
>
> - MEDIA_BUS_FMT_RGB565_1X24_CPADHI
> diff --git a/include/uapi/linux/media-bus-format.h b/include/uapi/linux/media-bus-format.h
> index 2ee0b38c0a71..d4228d038b54 100644
> --- a/include/uapi/linux/media-bus-format.h
> +++ b/include/uapi/linux/media-bus-format.h
> @@ -34,7 +34,7 @@
>
> #define MEDIA_BUS_FMT_FIXED 0x0001
>
> -/* RGB - next is 0x1024 */
> +/* RGB - next is 0x1025 */
> #define MEDIA_BUS_FMT_RGB444_1X12 0x1016
> #define MEDIA_BUS_FMT_RGB444_2X8_PADHI_BE 0x1001
> #define MEDIA_BUS_FMT_RGB444_2X8_PADHI_LE 0x1002
> @@ -49,6 +49,7 @@
> #define MEDIA_BUS_FMT_BGR666_1X18 0x1023
> #define MEDIA_BUS_FMT_RGB666_1X18 0x1009
> #define MEDIA_BUS_FMT_RBG888_1X24 0x100e
> +#define MEDIA_BUS_FMT_BGR666_1X24_CPADHI 0x1024
> #define MEDIA_BUS_FMT_RGB666_1X24_CPADHI 0x1015
> #define MEDIA_BUS_FMT_RGB666_1X7X3_SPWG 0x1010
> #define MEDIA_BUS_FMT_BGR888_1X24 0x1013
>

--
Regards,

Laurent Pinchart

2022-11-29 18:55:29

by Laurent Pinchart

[permalink] [raw]
Subject: Re: [PATCH v2 3/7] media: uapi: add MEDIA_BUS_FMT_BGR666_1X24_CPADHI

Hi Jörg,

On Tue, Nov 29, 2022 at 03:52:45PM +0100, Jörg Quinten wrote:
> Hi Laurent,
>
> looks like linux/Documentation/userspace-api/media/v4l/subdev-formats.rst
> doesn't correlate at all to the arrangement and numbering in
> linux/include/uapi/linux/media-bus-format.h .

Looking at the RGB group in include/uapi/linux/media-bus-format.h in the
mainline kernel, if you exclude the LVDS formats that are documented
separately, and the MEDIA_BUS_FMT_RGB888_3X8_DELTA format that appears
to be undocumented, the formats are ordered in the same way as in
subdev-formats.rst (see
https://linuxtv.org/downloads/v4l-dvb-apis/userspace-api/v4l/subdev-formats.html#v4l2-mbus-pixelcode for an HTML version).

> Which sources do you want me to check?
>
> Looking at https://github.com/raspberrypi/linux/tree/rpi-6.1.y btw.
>
> Rgds
> Joerg
>
>
>
>
> Am Di., 29. Nov. 2022 um 13:38 Uhr schrieb Laurent Pinchart <
> [email protected]>:
>
> > Hi Maxime and Joerg,
> >
> > Thank you for the patch.
> >
> > On Thu, Oct 20, 2022 at 10:30:47AM +0200, Maxime Ripard wrote:
> > > From: Joerg Quinten <[email protected]>
> > >
> > > Add the BGR666 format MEDIA_BUS_FMT_BGR666_1X24_CPADHI supported by the
> > > RaspberryPi.
> > >
> > > Signed-off-by: Joerg Quinten <[email protected]>
> > > Signed-off-by: Maxime Ripard <[email protected]>
> > > ---
> > > .../userspace-api/media/v4l/subdev-formats.rst | 37
> > ++++++++++++++++++++++
> > > include/uapi/linux/media-bus-format.h | 3 +-
> > > 2 files changed, 39 insertions(+), 1 deletion(-)
> > >
> > > diff --git a/Documentation/userspace-api/media/v4l/subdev-formats.rst
> > b/Documentation/userspace-api/media/v4l/subdev-formats.rst
> > > index 68f8d7d37984..604a30e2f890 100644
> > > --- a/Documentation/userspace-api/media/v4l/subdev-formats.rst
> > > +++ b/Documentation/userspace-api/media/v4l/subdev-formats.rst
> > > @@ -1023,6 +1023,43 @@ The following tables list existing packed RGB
> > formats.
> > > - g\ :sub:`2`
> > > - g\ :sub:`1`
> > > - g\ :sub:`0`
> > > + * .. _MEDIA-BUS-FMT-BGR666-1X24_CPADHI:
> >
> > I would move this just below MEDIA_BUS_FMT_RGB565_1X24_CPADHI. Actually,
> > could you check 1/7 and 2/7 to make sure the formats are sorted in the
> > documentation in the same order as in the header ?
> >
> > > +
> > > + - MEDIA_BUS_FMT_BGR666_1X24_CPADHI
> > > + - 0x1024
> > > + -
> > > + -
> > > + -
> > > + -
> > > + -
> > > + -
> > > + -
> > > + -
> > > + -
> > > + - 0
> > > + - 0
> > > + - b\ :sub:`5`
> > > + - b\ :sub:`4`
> > > + - b\ :sub:`3`
> > > + - b\ :sub:`2`
> > > + - b\ :sub:`1`
> > > + - b\ :sub:`0`
> > > + - 0
> > > + - 0
> > > + - g\ :sub:`5`
> > > + - g\ :sub:`4`
> > > + - g\ :sub:`3`
> > > + - g\ :sub:`2`
> > > + - g\ :sub:`1`
> > > + - g\ :sub:`0`
> > > + - 0
> > > + - 0
> > > + - r\ :sub:`5`
> > > + - r\ :sub:`4`
> > > + - r\ :sub:`3`
> > > + - r\ :sub:`2`
> > > + - r\ :sub:`1`
> > > + - r\ :sub:`0`
> > > * .. _MEDIA-BUS-FMT-RGB565-1X24_CPADHI:
> > >
> > > - MEDIA_BUS_FMT_RGB565_1X24_CPADHI
> > > diff --git a/include/uapi/linux/media-bus-format.h
> > b/include/uapi/linux/media-bus-format.h
> > > index 2ee0b38c0a71..d4228d038b54 100644
> > > --- a/include/uapi/linux/media-bus-format.h
> > > +++ b/include/uapi/linux/media-bus-format.h
> > > @@ -34,7 +34,7 @@
> > >
> > > #define MEDIA_BUS_FMT_FIXED 0x0001
> > >
> > > -/* RGB - next is 0x1024 */
> > > +/* RGB - next is 0x1025 */
> > > #define MEDIA_BUS_FMT_RGB444_1X12 0x1016
> > > #define MEDIA_BUS_FMT_RGB444_2X8_PADHI_BE 0x1001
> > > #define MEDIA_BUS_FMT_RGB444_2X8_PADHI_LE 0x1002
> > > @@ -49,6 +49,7 @@
> > > #define MEDIA_BUS_FMT_BGR666_1X18 0x1023
> > > #define MEDIA_BUS_FMT_RGB666_1X18 0x1009
> > > #define MEDIA_BUS_FMT_RBG888_1X24 0x100e
> > > +#define MEDIA_BUS_FMT_BGR666_1X24_CPADHI 0x1024
> > > #define MEDIA_BUS_FMT_RGB666_1X24_CPADHI 0x1015
> > > #define MEDIA_BUS_FMT_RGB666_1X7X3_SPWG 0x1010
> > > #define MEDIA_BUS_FMT_BGR888_1X24 0x1013
> > >

--
Regards,

Laurent Pinchart