On Wed, Sep 07, 2022 at 09:23:01AM +0200, Thomas Zimmermann wrote: > Hi > > Am 05.09.22 um 18:32 schrieb Thierry Reding: > > From: Thierry Reding > > > > Add a conversion helper for the AB24 format to use in drm_fb_blit(). > > > > Signed-off-by: Thierry Reding > > --- > > drivers/gpu/drm/drm_format_helper.c | 35 +++++++++++++++++++++++++++++ > > 1 file changed, 35 insertions(+) > > > > diff --git a/drivers/gpu/drm/drm_format_helper.c b/drivers/gpu/drm/drm_format_helper.c > > index 56642816fdff..d564412a816b 100644 > > --- a/drivers/gpu/drm/drm_format_helper.c > > +++ b/drivers/gpu/drm/drm_format_helper.c > > @@ -503,6 +503,36 @@ static void drm_fb_rgb888_to_xrgb8888(struct iosys_map *dst, const unsigned int > > drm_fb_rgb888_to_xrgb8888_line); > > } > > +static void drm_fb_xrgb8888_to_abgr8888_line(void *dbuf, const void *sbuf, unsigned int pixels) > > +{ > > + __le32 *dbuf32 = dbuf; > > + const __le32 *sbuf32 = sbuf; > > + unsigned int x; > > + u32 pix; > > + > > + for (x = 0; x < pixels; x++) { > > + pix = le32_to_cpu(sbuf32[x]); > > + pix = ((pix & 0xff000000) >> 24) << 24 | > > + ((pix & 0x00ff0000) >> 16) << 0 | > > + ((pix & 0x0000ff00) >> 8) << 8 | > > + ((pix & 0x000000ff) >> 0) << 16; > > + *dbuf32++ = cpu_to_le32(pix); > > + } > > +} > > What does the Jetson device do with these alpha bits? > > AFAIK the X channel's content is undefined. Shifting the bits into the A > channel might result in wrong results in the general case. Better just set > the alpha to 0xff unconditionally. I'm not exactly sure, so I'd have to do some digging. I suspect that perhaps this might actually be XBGR rather than ABGR, so this may end up doing nothing. EFI FB reports this as ABGR, at least if I read the output right, so that's what I went with for the DT implementation. > > + > > +static void drm_fb_xrgb8888_to_abgr8888(struct iosys_map *dst, const unsigned int *dst_pitch, > > + const struct iosys_map *src, > > + const struct drm_framebuffer *fb, > > + const struct drm_rect *clip) > > +{ > > + static const u8 dst_pixsize[DRM_FORMAT_MAX_PLANES] = { > > + 4, > > + }; > > + > > + drm_fb_xfrm(dst, dst_pitch, dst_pixsize, src, fb, clip, false, > > + drm_fb_xrgb8888_to_abgr8888_line); > > +} > > + > > static void drm_fb_xrgb8888_to_xrgb2101010_line(void *dbuf, const void *sbuf, unsigned int pixels) > > { > > __le32 *dbuf32 = dbuf; > > @@ -672,6 +702,11 @@ int drm_fb_blit(struct iosys_map *dst, const unsigned int *dst_pitch, uint32_t d > > drm_fb_rgb565_to_xrgb8888(dst, dst_pitch, src, fb, clip); > > return 0; > > } > > + } else if (dst_format == DRM_FORMAT_ABGR8888) { > > + if (fb_format == DRM_FORMAT_XRGB8888) { > > + drm_fb_xrgb8888_to_abgr8888(dst, dst_pitch, src, fb, clip); > > + return 0; > > + } > > For the other alpha-containing formats, we treat them like non-alpha formats > (see the top of this function). Maybe just do the same here and then > implement the conversion as drm_fb_xrgb8888_to_xbgr8888() helpers? Yeah, that's probably for the best. None of the boot splash uses alpha as far as I can tell and neither does the kernel framebuffer console, so there's really little point in trying to support it. Thierry