[Pixman] [PATCH] Add support for 18bpp X14R6G6B6 format.

Marek Vasut marek.vasut at gmail.com
Fri Jul 30 01:11:49 PDT 2010


This format is used on PXA framebuffer with some boards.

Signed-off-by: Marek Vasut <marek.vasut at gmail.com>
---
 pixman/pixman-access.c |   68 +++++++++++++++++++++++++++++++++++++++++++++++-
 pixman/pixman.h        |    1 +
 2 files changed, 68 insertions(+), 1 deletions(-)

diff --git a/pixman/pixman-access.c b/pixman/pixman-access.c
index 80fa9e8..82a28de 100644
--- a/pixman/pixman-access.c
+++ b/pixman/pixman-access.c
@@ -397,6 +397,31 @@ fetch_scanline_b8g8r8 (pixman_image_t *image,
 }
 
 static void
+fetch_scanline_x14r6g6b6 (pixman_image_t *image,
+                       int             x,
+                       int             y,
+                       int             width,
+                       uint32_t *      buffer,
+                       const uint32_t *mask,
+                       uint32_t        mask_bits)
+{
+    const uint32_t *bits = image->bits.bits + y * image->bits.rowstride;
+    const uint32_t *pixel = (const uint32_t *)bits + x;
+    const uint32_t *end = pixel + width;
+
+    while (pixel < end) {
+	uint32_t p = READ (image, pixel++);
+	uint32_t r, g, b;
+
+	r = ((p & 0x3f000) << 6) | ((p & 0x30000));
+	g = ((p & 0x00fc0) << 4) | ((p & 0x00c00) >> 2);
+	b = ((p & 0x0003f) << 2) | ((p & 0x00030) >> 4);
+
+	*buffer++ = 0xff000000 | r | g | b;
+    }
+}
+
+static void
 fetch_scanline_r5g6b5 (pixman_image_t *image,
                        int             x,
                        int             y,
@@ -1308,6 +1333,22 @@ fetch_pixel_b8g8r8 (bits_image_t *image,
 }
 
 static uint32_t
+fetch_pixel_x14r6g6b6 (bits_image_t *image,
+		    int           offset,
+		    int           line)
+{
+    uint32_t *bits = image->bits + line * image->rowstride;
+    uint32_t pixel = READ (image, (uint32_t *) bits + offset);
+    uint32_t r, g, b;
+
+    r = ((pixel & 0x3f000) << 6) | ((pixel & 0x30000));
+    g = ((pixel & 0x00fc0) << 4) | ((pixel & 0x00c00) >> 2);
+    b = ((pixel & 0x0003f) << 2) | ((pixel & 0x00030) >> 4);
+
+    return 0xff000000 | r | g | b;
+}
+
+static uint32_t
 fetch_pixel_r5g6b5 (bits_image_t *image,
 		    int           offset,
 		    int           line)
@@ -2041,6 +2082,30 @@ store_scanline_b8g8r8 (bits_image_t *  image,
 }
 
 static void
+store_scanline_x14r6g6b6 (bits_image_t *  image,
+                       int             x,
+                       int             y,
+                       int             width,
+                       const uint32_t *values)
+{
+    uint32_t *bits = image->bits + image->rowstride * y;
+    uint32_t *pixel = ((uint32_t *) bits) + x;
+    int i;
+
+    for (i = 0; i < width; ++i)
+    {
+	uint32_t s = values[i];
+	uint32_t r, g, b;
+
+	r = (s & 0xfc0000) >> 6;
+	g = (s & 0x00fc00) >> 4;
+	b = (s & 0x0000fc) >> 2;
+
+	WRITE (image, pixel++, r | g | b);
+    }
+}
+
+static void
 store_scanline_r5g6b5 (bits_image_t *  image,
                        int             x,
                        int             y,
@@ -2780,7 +2845,8 @@ static const format_info_t accessors[] =
     FORMAT_INFO (x8b8g8r8),
     FORMAT_INFO (b8g8r8a8),
     FORMAT_INFO (b8g8r8x8),
-    
+    FORMAT_INFO (x14r6g6b6),
+
 /* 24bpp formats */
     FORMAT_INFO (r8g8b8),
     FORMAT_INFO (b8g8r8),
diff --git a/pixman/pixman.h b/pixman/pixman.h
index 9981f0d..d0f0475 100644
--- a/pixman/pixman.h
+++ b/pixman/pixman.h
@@ -668,6 +668,7 @@ typedef enum {
     PIXMAN_a2r10g10b10 = PIXMAN_FORMAT(32,PIXMAN_TYPE_ARGB,2,10,10,10),
     PIXMAN_x2b10g10r10 = PIXMAN_FORMAT(32,PIXMAN_TYPE_ABGR,0,10,10,10),
     PIXMAN_a2b10g10r10 = PIXMAN_FORMAT(32,PIXMAN_TYPE_ABGR,2,10,10,10),
+    PIXMAN_x14r6g6b6 =	 PIXMAN_FORMAT(32,PIXMAN_TYPE_ARGB,0,6,6,6),
 
 /* 24bpp formats */
     PIXMAN_r8g8b8 =	 PIXMAN_FORMAT(24,PIXMAN_TYPE_ARGB,0,8,8,8),
-- 
1.7.1



More information about the Pixman mailing list