Re: [PATCH v3 6/8] drm/format-helper: Support the XB24 format

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 





Am 17.11.22 um 19:40 schrieb Thierry Reding:
From: Thierry Reding <treding@xxxxxxxxxx>

Add a conversion helper for the XB24 format to use in drm_fb_blit().

Signed-off-by: Thierry Reding <treding@xxxxxxxxxx>

Reviewed-by: Thomas Zimmermann <tzimmermann@xxxxxxx>

---
Changes in v3:
- rebase onto latest drm-next

Changes in v2:
- support XB24 format instead of AB24

  drivers/gpu/drm/drm_format_helper.c | 39 +++++++++++++++++++++++++++++
  1 file changed, 39 insertions(+)

diff --git a/drivers/gpu/drm/drm_format_helper.c b/drivers/gpu/drm/drm_format_helper.c
index 74ff33c2ddaa..c8764cc61e87 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_xbgr8888_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 & 0x00ff0000) >> 16) <<  0 |
+		      ((pix & 0x0000ff00) >>  8) <<  8 |
+		      ((pix & 0x000000ff) >>  0) << 16 |
+		      0xff << 24;
+		*dbuf32++ = cpu_to_le32(pix);
+	}
+}
+
+static void drm_fb_xrgb8888_to_xbgr8888(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_xbgr8888_line);
+}
+
  static void drm_fb_xrgb8888_to_xrgb2101010_line(void *dbuf, const void *sbuf, unsigned int pixels)
  {
  	__le32 *dbuf32 = dbuf;
@@ -646,6 +676,8 @@ int drm_fb_blit(struct iosys_map *dst, const unsigned int *dst_pitch, uint32_t d
  		fb_format = DRM_FORMAT_XRGB8888;
  	if (dst_format == DRM_FORMAT_ARGB8888)
  		dst_format = DRM_FORMAT_XRGB8888;
+	if (dst_format == DRM_FORMAT_ABGR8888)
+		dst_format = DRM_FORMAT_XBGR8888;
  	if (fb_format == DRM_FORMAT_ARGB2101010)
  		fb_format = DRM_FORMAT_XRGB2101010;
  	if (dst_format == DRM_FORMAT_ARGB2101010)
@@ -678,6 +710,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_XBGR8888) {
+		if (fb_format == DRM_FORMAT_XRGB8888) {
+			drm_fb_xrgb8888_to_xbgr8888(dst, dst_pitch, src, fb, clip);
+			return 0;
+		}
  	} else if (dst_format == DRM_FORMAT_XRGB2101010) {
  		if (fb_format == DRM_FORMAT_XRGB8888) {
  			drm_fb_xrgb8888_to_xrgb2101010(dst, dst_pitch, src, fb, clip);
@@ -820,6 +857,8 @@ static bool is_listed_fourcc(const uint32_t *fourccs, size_t nfourccs, uint32_t
  static const uint32_t conv_from_xrgb8888[] = {
  	DRM_FORMAT_XRGB8888,
  	DRM_FORMAT_ARGB8888,
+	DRM_FORMAT_ABGR8888,
+	DRM_FORMAT_XBGR8888,
  	DRM_FORMAT_XRGB2101010,
  	DRM_FORMAT_ARGB2101010,
  	DRM_FORMAT_RGB565,

--
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Maxfeldstr. 5, 90409 Nürnberg, Germany
(HRB 36809, AG Nürnberg)
Geschäftsführer: Ivo Totev

Attachment: OpenPGP_signature
Description: OpenPGP digital signature


[Index of Archives]     [Device Tree Compilter]     [Device Tree Spec]     [Linux Driver Backports]     [Video for Linux]     [Linux USB Devel]     [Linux PCI Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Yosemite Backpacking]


  Powered by Linux