summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTomi Valkeinen <tomi.valkeinen@ti.com>2018-10-16 11:35:44 +0300
committerTomi Valkeinen <tomi.valkeinen@ti.com>2018-10-17 11:09:49 +0300
commit47e808023f98f74673906ef7de34e774cd26f52b (patch)
tree61692a33768f49d508ac92f8b64af2f8c4e8c0dc
parentff9de1ab494ee5d48dba7aa84dfa1ce114464f09 (diff)
Add AR12 & AR15 support
Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
-rw-r--r--kms++/inc/kms++/pixelformats.h3
-rw-r--r--kms++/src/pixelformats.cpp3
-rw-r--r--kms++util/inc/kms++util/color.h2
-rw-r--r--kms++util/src/color.cpp10
-rw-r--r--kms++util/src/drawing.cpp16
-rw-r--r--kms++util/src/testpat.cpp2
6 files changed, 36 insertions, 0 deletions
diff --git a/kms++/inc/kms++/pixelformats.h b/kms++/inc/kms++/pixelformats.h
index 6392de1..1e273ef 100644
--- a/kms++/inc/kms++/pixelformats.h
+++ b/kms++/inc/kms++/pixelformats.h
@@ -32,6 +32,9 @@ enum class PixelFormat : uint32_t
RGB565 = MakeFourCC("RG16"),
BGR565 = MakeFourCC("BG16"),
+
+ ARGB4444 = MakeFourCC("AR12"),
+ ARGB1555 = MakeFourCC("AR15"),
};
static inline PixelFormat FourCCToPixelFormat(const std::string& fourcc)
diff --git a/kms++/src/pixelformats.cpp b/kms++/src/pixelformats.cpp
index 84ea924..819853b 100644
--- a/kms++/src/pixelformats.cpp
+++ b/kms++/src/pixelformats.cpp
@@ -26,6 +26,9 @@ static const map<PixelFormat, PixelFormatInfo> format_info_array = {
{ PixelFormat::XBGR8888, { 1, { { 32, 1, 1 } }, } },
{ PixelFormat::ARGB8888, { 1, { { 32, 1, 1 } }, } },
{ PixelFormat::ABGR8888, { 1, { { 32, 1, 1 } }, } },
+
+ { PixelFormat::ARGB4444, { 1, { { 16, 1, 1 } }, } },
+ { PixelFormat::ARGB1555, { 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 f378433..21eae66 100644
--- a/kms++util/inc/kms++util/color.h
+++ b/kms++util/inc/kms++util/color.h
@@ -27,6 +27,8 @@ struct RGB
uint32_t abgr8888() const;
uint16_t rgb565() const;
uint16_t bgr565() const;
+ uint16_t argb4444() const;
+ uint16_t argb1555() const;
YUV yuv(YUVType type = YUVType::BT601_Lim) const;
uint8_t b;
diff --git a/kms++util/src/color.cpp b/kms++util/src/color.cpp
index 2e6f217..2a41502 100644
--- a/kms++util/src/color.cpp
+++ b/kms++util/src/color.cpp
@@ -59,6 +59,16 @@ uint16_t RGB::bgr565() const
return ((b >> 3) << 11) | ((g >> 2) << 5) | ((r >> 3) << 0);
}
+uint16_t RGB::argb4444() const
+{
+ return ((a >> 4) << 12) | ((r >> 4) << 8) | ((g >> 4) << 4) | ((b >> 4) << 0);
+}
+
+uint16_t RGB::argb1555() const
+{
+ return ((!!a) << 15) | ((r >> 3) << 10) | ((g >> 3) << 5) | ((b >> 3) << 0);
+}
+
YUV RGB::yuv(YUVType type) const
{
return YUV(*this, type);
diff --git a/kms++util/src/drawing.cpp b/kms++util/src/drawing.cpp
index 8885112..9da7a77 100644
--- a/kms++util/src/drawing.cpp
+++ b/kms++util/src/drawing.cpp
@@ -56,6 +56,18 @@ void draw_rgb_pixel(IFramebuffer& buf, unsigned x, unsigned y, RGB color)
*p = color.bgr565();
break;
}
+ case PixelFormat::ARGB4444:
+ {
+ uint16_t *p = (uint16_t*)(buf.map(0) + buf.stride(0) * y + x * 2);
+ *p = color.argb4444();
+ break;
+ }
+ case PixelFormat::ARGB1555:
+ {
+ uint16_t *p = (uint16_t*)(buf.map(0) + buf.stride(0) * y + x * 2);
+ *p = color.argb1555();
+ break;
+ }
default:
throw std::invalid_argument("invalid pixelformat");
}
@@ -168,6 +180,8 @@ 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::ARGB4444:
+ case PixelFormat::ARGB1555:
for (j = 0; j < h; j++) {
for (i = 0; i < w; i++) {
draw_rgb_pixel(fb, x + i, y + j, color);
@@ -240,6 +254,8 @@ 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::ARGB4444:
+ case PixelFormat::ARGB1555:
for (y = 0; y < 8; y++) {
for (x = 0; x < 8; x++) {
bool b = get_char_pixel(c, x, y);
diff --git a/kms++util/src/testpat.cpp b/kms++util/src/testpat.cpp
index 8795cc6..ab197dc 100644
--- a/kms++util/src/testpat.cpp
+++ b/kms++util/src/testpat.cpp
@@ -114,6 +114,8 @@ static void draw_test_pattern_part(IFramebuffer& fb, unsigned start_y, unsigned
case PixelFormat::BGR888:
case PixelFormat::RGB565:
case PixelFormat::BGR565:
+ case PixelFormat::ARGB4444:
+ case PixelFormat::ARGB1555:
for (y = start_y; y < end_y; y++) {
for (x = 0; x < w; x++) {
RGB pixel = get_test_pattern_pixel(fb, x, y);