dri-devel.lists.freedesktop.org archive mirror
 help / color / mirror / Atom feed
From: Hyun Kwon <hyun.kwon@xilinx.com>
To: dri-devel@lists.freedesktop.org
Cc: Hyun Kwon <hyun.kwon@xilinx.com>
Subject: [PATCH libdrm 1/3] tests: util: pattern: Use 64bit RGB samples
Date: Sat, 7 Jul 2018 19:35:31 -0700	[thread overview]
Message-ID: <1531017333-1483-2-git-send-email-hyun.kwon@xilinx.com> (raw)
In-Reply-To: <1531017333-1483-1-git-send-email-hyun.kwon@xilinx.com>

Use of 32bit RGB samples, where each component is 8bit, cannot
support formats with components greater than 8bit (ex, XRGB2101010).
Introduce MAKE_RGBA_64() which creates pixels from a 64bit sample.
Each component in a 64bit sample is 16bit long, thus a pixel with 10bit
components can be generated correctly.

MAKE_RGBA() can use MAKE_RGBA_64() by scaling each 8bit component
to 16bit, for compatilbity.

Signed-off-by: Hyun Kwon <hyun.kwon@xilinx.com>
---
 tests/util/pattern.c | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/tests/util/pattern.c b/tests/util/pattern.c
index 9fa0a41..aa067c9 100644
--- a/tests/util/pattern.c
+++ b/tests/util/pattern.c
@@ -60,11 +60,17 @@ struct color_yuv {
 	  .u = MAKE_YUV_601_U(r, g, b), \
 	  .v = MAKE_YUV_601_V(r, g, b) }
 
+#define COLOR_MASK(value, color) \
+	((value & ((1 << (color).length) - 1)) << (color).offset)
+
+#define MAKE_RGBA_64(rgb, r, g, b, a) \
+	(COLOR_MASK(((r) >> (16 - (rgb)->red.length)), (rgb)->red) | \
+	 COLOR_MASK(((g) >> (16 - (rgb)->green.length)), (rgb)->green) | \
+	 COLOR_MASK(((b) >> (16 - (rgb)->blue.length)), (rgb)->blue) | \
+	 COLOR_MASK(((a) >> (16 - (rgb)->alpha.length)), (rgb)->alpha))
+
 #define MAKE_RGBA(rgb, r, g, b, a) \
-	((((r) >> (8 - (rgb)->red.length)) << (rgb)->red.offset) | \
-	 (((g) >> (8 - (rgb)->green.length)) << (rgb)->green.offset) | \
-	 (((b) >> (8 - (rgb)->blue.length)) << (rgb)->blue.offset) | \
-	 (((a) >> (8 - (rgb)->alpha.length)) << (rgb)->alpha.offset))
+	MAKE_RGBA_64(rgb, (r) * 0x101, (g) * 0x101, (b) * 0x101, (a) * 0x101)
 
 #define MAKE_RGB24(rgb, r, g, b) \
 	{ .value = MAKE_RGBA(rgb, r, g, b, 0) }
-- 
2.7.4

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

  reply	other threads:[~2018-07-08  2:37 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-07-08  2:35 [PATCH libdrm 0/3] Enable more formats in modetest Hyun Kwon
2018-07-08  2:35 ` Hyun Kwon [this message]
2018-07-08  2:35 ` [PATCH libdrm 2/3] modetest: Add support for YUV422 and YUV444 Hyun Kwon
2018-07-08  2:35 ` [PATCH libdrm 3/3] tests: util: " Hyun Kwon
  -- strict thread matches above, loose matches on Subject: below --
2018-05-04 23:40 [PATCH LIBDRM 0/3] Enable more formats in modetest Hyun Kwon
2018-05-04 23:40 ` [PATCH LIBDRM 1/3] tests: util: pattern: Use 64bit RGB samples Hyun Kwon

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=1531017333-1483-2-git-send-email-hyun.kwon@xilinx.com \
    --to=hyun.kwon@xilinx.com \
    --cc=dri-devel@lists.freedesktop.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).