All of lore.kernel.org
 help / color / mirror / Atom feed
From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
To: Tomi Valkeinen <tomi.valkeinen@ti.com>
Cc: linux-renesas-soc@vger.kernel.org
Subject: [PATCH 8/8] kms++: Add support for missing 8 -and 16-bit RGB formats
Date: Thu,  6 Aug 2020 05:18:06 +0300	[thread overview]
Message-ID: <20200806021807.21863-9-laurent.pinchart@ideasonboard.com> (raw)
In-Reply-To: <20200806021807.21863-1-laurent.pinchart@ideasonboard.com>

Add support for the RGB332, XRGB1555 and XRGB4444 formats to the
PixelFormat class, the Python API, and the drawing utilities.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
 kms++/inc/kms++/pixelformats.h  |  5 +++++
 kms++/src/pixelformats.cpp      |  9 ++++++---
 kms++util/inc/kms++util/color.h |  1 +
 kms++util/src/color.cpp         |  5 +++++
 kms++util/src/drawing.cpp       | 14 ++++++++++++++
 py/pykms/pykmsbase.cpp          |  5 +++++
 6 files changed, 36 insertions(+), 3 deletions(-)

diff --git a/kms++/inc/kms++/pixelformats.h b/kms++/inc/kms++/pixelformats.h
index 746f9e2b8c5a..4e453a2f594d 100644
--- a/kms++/inc/kms++/pixelformats.h
+++ b/kms++/inc/kms++/pixelformats.h
@@ -45,9 +45,14 @@ enum class PixelFormat : uint32_t
 	RGB888 = MakeFourCC("RG24"),
 	BGR888 = MakeFourCC("BG24"),
 
+	RGB332 = MakeFourCC("RGB8"),
+
 	RGB565 = MakeFourCC("RG16"),
 	BGR565 = MakeFourCC("BG16"),
 
+	XRGB4444 = MakeFourCC("XR12"),
+	XRGB1555 = MakeFourCC("XR15"),
+
 	ARGB4444 = MakeFourCC("AR12"),
 	ARGB1555 = MakeFourCC("AR15"),
 
diff --git a/kms++/src/pixelformats.cpp b/kms++/src/pixelformats.cpp
index fe86fca04cd8..2c60c1e673f3 100644
--- a/kms++/src/pixelformats.cpp
+++ b/kms++/src/pixelformats.cpp
@@ -24,9 +24,15 @@ static const map<PixelFormat, PixelFormatInfo> format_info_array = {
 	{ PixelFormat::YVU422, { PixelColorType::YUV, 3, { { 8, 1, 1, }, { 8, 2, 1 }, { 8, 2, 1 } }, } },
 	{ PixelFormat::YUV444, { PixelColorType::YUV, 3, { { 8, 1, 1, }, { 8, 1, 1 }, { 8, 1, 1 } }, } },
 	{ PixelFormat::YVU444, { PixelColorType::YUV, 3, { { 8, 1, 1, }, { 8, 1, 1 }, { 8, 1, 1 } }, } },
+	/* RGB8 */
+	{ PixelFormat::RGB332, { PixelColorType::RGB, 1, { { 8, 1, 1 } }, } },
 	/* RGB16 */
 	{ PixelFormat::RGB565, { PixelColorType::RGB, 1, { { 16, 1, 1 } }, } },
 	{ PixelFormat::BGR565, { PixelColorType::RGB, 1, { { 16, 1, 1 } }, } },
+	{ PixelFormat::XRGB4444, { PixelColorType::RGB, 1, { { 16, 1, 1 } }, } },
+	{ PixelFormat::XRGB1555, { PixelColorType::RGB, 1, { { 16, 1, 1 } }, } },
+	{ PixelFormat::ARGB4444, { PixelColorType::RGB, 1, { { 16, 1, 1 } }, } },
+	{ PixelFormat::ARGB1555, { PixelColorType::RGB, 1, { { 16, 1, 1 } }, } },
 	/* RGB24 */
 	{ PixelFormat::RGB888, { PixelColorType::RGB, 1, { { 24, 1, 1 } }, } },
 	{ PixelFormat::BGR888, { PixelColorType::RGB, 1, { { 24, 1, 1 } }, } },
@@ -50,9 +56,6 @@ static const map<PixelFormat, PixelFormatInfo> format_info_array = {
 	{ PixelFormat::ABGR2101010, { PixelColorType::RGB, 1, { { 32, 1, 1 } }, } },
 	{ PixelFormat::RGBA1010102, { PixelColorType::RGB, 1, { { 32, 1, 1 } }, } },
 	{ PixelFormat::BGRA1010102, { PixelColorType::RGB, 1, { { 32, 1, 1 } }, } },
-
-	{ PixelFormat::ARGB4444, { PixelColorType::RGB, 1, { { 16, 1, 1 } }, } },
-	{ PixelFormat::ARGB1555, { PixelColorType::RGB, 1, { { 16, 1, 1 } }, } },
 };
 
 const struct PixelFormatInfo& get_pixel_format_info(PixelFormat format)
diff --git a/kms++util/inc/kms++util/color.h b/kms++util/inc/kms++util/color.h
index 2bf6e66315a4..fa05fbcc1982 100644
--- a/kms++util/inc/kms++util/color.h
+++ b/kms++util/inc/kms++util/color.h
@@ -34,6 +34,7 @@ struct RGB
 	uint32_t rgba1010102() const;
 	uint32_t bgra1010102() const;
 
+	uint8_t rgb332() const;
 	uint16_t rgb565() const;
 	uint16_t bgr565() const;
 	uint16_t argb4444() const;
diff --git a/kms++util/src/color.cpp b/kms++util/src/color.cpp
index 80e486668298..2d45eff5d70b 100644
--- a/kms++util/src/color.cpp
+++ b/kms++util/src/color.cpp
@@ -79,6 +79,11 @@ uint32_t RGB::bgra1010102() const
 	return (b << 24) | (g << 14) | (r << 4) | (a >> 6);
 }
 
+uint8_t RGB::rgb332() const
+{
+	return ((r >> 5) << 5) | ((g >> 5) << 2) | ((b >> 6) << 0);
+}
+
 uint16_t RGB::rgb565() const
 {
 	return ((r >> 3) << 11) | ((g >> 2) << 5) | ((b >> 3) << 0);
diff --git a/kms++util/src/drawing.cpp b/kms++util/src/drawing.cpp
index c1c639a8b3a5..3752f94695e0 100644
--- a/kms++util/src/drawing.cpp
+++ b/kms++util/src/drawing.cpp
@@ -86,6 +86,12 @@ void draw_rgb_pixel(IFramebuffer& buf, unsigned x, unsigned y, RGB color)
 		p[2] = color.b;
 		break;
 	}
+	case PixelFormat::RGB332:
+	{
+		uint8_t *p = (uint8_t*)(buf.map(0) + buf.stride(0) * y + x);
+		*p = color.rgb332();
+		break;
+	}
 	case PixelFormat::RGB565:
 	{
 		uint16_t *p = (uint16_t*)(buf.map(0) + buf.stride(0) * y + x * 2);
@@ -98,12 +104,14 @@ void draw_rgb_pixel(IFramebuffer& buf, unsigned x, unsigned y, RGB color)
 		*p = color.bgr565();
 		break;
 	}
+	case PixelFormat::XRGB4444:
 	case PixelFormat::ARGB4444:
 	{
 		uint16_t *p = (uint16_t*)(buf.map(0) + buf.stride(0) * y + x * 2);
 		*p = color.argb4444();
 		break;
 	}
+	case PixelFormat::XRGB1555:
 	case PixelFormat::ARGB1555:
 	{
 		uint16_t *p = (uint16_t*)(buf.map(0) + buf.stride(0) * y + x * 2);
@@ -397,8 +405,11 @@ void draw_rect(IFramebuffer &fb, uint32_t x, uint32_t y, uint32_t w, uint32_t h,
 	case PixelFormat::BGR888:
 	case PixelFormat::RGB565:
 	case PixelFormat::BGR565:
+	case PixelFormat::XRGB4444:
+	case PixelFormat::XRGB1555:
 	case PixelFormat::ARGB4444:
 	case PixelFormat::ARGB1555:
+	case PixelFormat::RGB332:
 		for (j = 0; j < h; j++) {
 			for (i = 0; i < w; i++) {
 				draw_rgb_pixel(fb, x + i, y + j, color);
@@ -486,8 +497,11 @@ static void draw_char(IFramebuffer& buf, uint32_t xpos, uint32_t ypos, char c, R
 	case PixelFormat::BGR888:
 	case PixelFormat::RGB565:
 	case PixelFormat::BGR565:
+	case PixelFormat::XRGB4444:
+	case PixelFormat::XRGB1555:
 	case PixelFormat::ARGB4444:
 	case PixelFormat::ARGB1555:
+	case PixelFormat::RGB332:
 		for (y = 0; y < 8; y++) {
 			for (x = 0; x < 8; x++) {
 				bool b = get_char_pixel(c, x, y);
diff --git a/py/pykms/pykmsbase.cpp b/py/pykms/pykmsbase.cpp
index 3e6defc88def..0448e0264ded 100644
--- a/py/pykms/pykmsbase.cpp
+++ b/py/pykms/pykmsbase.cpp
@@ -206,9 +206,14 @@ void init_pykmsbase(py::module &m)
 			.value("RGB888", PixelFormat::RGB888)
 			.value("BGR888", PixelFormat::BGR888)
 
+			.value("RGB332", PixelFormat::RGB332)
+
 			.value("RGB565", PixelFormat::RGB565)
 			.value("BGR565", PixelFormat::BGR565)
 
+			.value("XRGB4444", PixelFormat::XRGB4444)
+			.value("XRGB1555", PixelFormat::XRGB1555)
+
 			.value("ARGB4444", PixelFormat::ARGB4444)
 			.value("ARGB1555", PixelFormat::ARGB1555)
 
-- 
Regards,

Laurent Pinchart


  parent reply	other threads:[~2020-08-06  2:18 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-08-06  2:17 [PATCH 0/8] kmsxx: Various fixes and improvements Laurent Pinchart
2020-08-06  2:17 ` [PATCH 1/8] card: Add a method to retrieve the device minor Laurent Pinchart
2020-08-06  7:46   ` Tomi Valkeinen
2020-08-10  5:54     ` Laurent Pinchart
2020-08-10  6:48       ` Tomi Valkeinen
2020-08-06  9:55   ` Sergei Shtylyov
2020-08-06  2:18 ` [PATCH 2/8] card: Rename has_has_universal_planes to has_universal_planes Laurent Pinchart
2020-08-06  2:18 ` [PATCH 3/8] dumbfb: Add support tri- or quadri-planar buffers Laurent Pinchart
2020-08-06  2:18 ` [PATCH 4/8] dumbfb: Fix pitch for tri-planar formats Laurent Pinchart
2020-08-06  9:21   ` Tomi Valkeinen
2020-08-08 22:14     ` Laurent Pinchart
2020-08-10  6:16       ` Tomi Valkeinen
2020-08-10  6:28         ` Tomi Valkeinen
2020-08-06  2:18 ` [PATCH 5/8] pykmsbase: Add missing pixel formats Laurent Pinchart
2020-08-06  2:18 ` [PATCH 6/8] kms++: Add support for semiplanar YUV422 formats (NV16 and NV61) Laurent Pinchart
2020-08-06  2:18 ` [PATCH 7/8] kms++: Add support for the planar YUV formats Laurent Pinchart
2020-08-06  2:18 ` Laurent Pinchart [this message]
2020-08-06  9:33 ` [PATCH 0/8] kmsxx: Various fixes and improvements Tomi Valkeinen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200806021807.21863-9-laurent.pinchart@ideasonboard.com \
    --to=laurent.pinchart@ideasonboard.com \
    --cc=linux-renesas-soc@vger.kernel.org \
    --cc=tomi.valkeinen@ti.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.