Hi Hans, On Tue, Dec 20, 2022 at 10:22 AM Hans Verkuil <hverkuil-cisco@xxxxxxxxx> wrote: > On 20/12/2022 10:09, Geert Uytterhoeven wrote: > > On Tue, Dec 20, 2022 at 10:01 AM Hans Verkuil <hverkuil-cisco@xxxxxxxxx> wrote: > >> On 19/12/2022 22:47, Laurent Pinchart wrote: > >>> (CC'ing Sakari and Hans) > >>> > >>> Thank you for the patch. > >>> > >>> On Mon, Dec 19, 2022 at 04:01:39PM +0200, Tomi Valkeinen wrote: > >>>> Add new pixel formats: RGBX1010102, RGBA1010102, ARGB2101010 and Y210. > >>>> > >>>> Signed-off-by: Tomi Valkeinen <tomi.valkeinen+renesas@xxxxxxxxxxxxxxxx> > >>>> --- > >>>> drivers/gpu/drm/rcar-du/rcar_du_kms.c | 24 +++++++++++++ > >>>> drivers/gpu/drm/rcar-du/rcar_du_vsp.c | 49 +++++++++++++++++++++++++-- > >>>> 2 files changed, 71 insertions(+), 2 deletions(-) > >>>> > >>>> diff --git a/drivers/gpu/drm/rcar-du/rcar_du_kms.c b/drivers/gpu/drm/rcar-du/rcar_du_kms.c > >>>> index 8c2719efda2a..8ccabf5a30c4 100644 > >>>> --- a/drivers/gpu/drm/rcar-du/rcar_du_kms.c > >>>> +++ b/drivers/gpu/drm/rcar-du/rcar_du_kms.c > >>>> @@ -259,6 +259,24 @@ static const struct rcar_du_format_info rcar_du_format_infos[] = { > >>>> .bpp = 32, > >>>> .planes = 1, > >>>> .hsub = 1, > >>>> + }, { > >>>> + .fourcc = DRM_FORMAT_RGBX1010102, > >>> > >>> Ah, here the format makes sense. > >>> > >>>> + .v4l2 = V4L2_PIX_FMT_XBGR2101010, > >>> > >>> But this is horrible :-( Could we use the same names as DRM for new > >>> formats, when there is no conflict with existing V4L2 formats ? > >>> > >>> Sakari, Hans, what do you think ? Please see patch 1/7 in the series for > >>> the format definitions. > >> > >> V4L2 describes pixel formats based on how they appear in memory from the > >> lowest to highest memory address. > > > > So that means big endian? > > Yes. > > >> If I am not mistaken, DRM uses the CPU order. So that explains the difference > >> in naming. I don't think we should hide that difference. And V4L2 has been > >> quite consistent in following memory ordering in the naming (except possibly > >> for some of the really old pixelformats). > > > > DRM uses little endian. > > So not CPU order, but always little endian order? I.e., on a big endian system > a given DRM_FORMAT_ would have the same memory layout as on a little endian > system? Indeed. Big-endian formats must set the DRM_FORMAT_BIG_ENDIAN flag: #define DRM_FORMAT_BIG_ENDIAN (1U<<31) /* format is big endian instead of little endian */ unless the big-endian format has a standard (little-endian) equivalent: Old PPC drivers may violate that, so there is some quirk handling... /* * DRM formats are little endian. Define host endian variants for the * most common formats here, to reduce the #ifdefs needed in drivers. * * Note that the DRM_FORMAT_BIG_ENDIAN flag should only be used in * case the format can't be specified otherwise, so we don't end up * with two values describing the same format. */ #ifdef __BIG_ENDIAN # define DRM_FORMAT_HOST_XRGB1555 (DRM_FORMAT_XRGB1555 | \ DRM_FORMAT_BIG_ENDIAN) # define DRM_FORMAT_HOST_RGB565 (DRM_FORMAT_RGB565 | \ DRM_FORMAT_BIG_ENDIAN) # define DRM_FORMAT_HOST_XRGB8888 DRM_FORMAT_BGRX8888 # define DRM_FORMAT_HOST_ARGB8888 DRM_FORMAT_BGRA8888 #else # define DRM_FORMAT_HOST_XRGB1555 DRM_FORMAT_XRGB1555 # define DRM_FORMAT_HOST_RGB565 DRM_FORMAT_RGB565 # define DRM_FORMAT_HOST_XRGB8888 DRM_FORMAT_XRGB8888 # define DRM_FORMAT_HOST_ARGB8888 DRM_FORMAT_ARGB8888 #endif However, given the number of bugs related to big-endian formats, I doubt DRM has any real use on big-endian hardware (i.e. not counting hobbyists trying to migrate from fbdev to DRM ;-) Gr{oetje,eeting}s, Geert -- Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@xxxxxxxxxxxxxx In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. -- Linus Torvalds