Igt-dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [igt-dev] [PATCH i-g-t 01/10] lib: Add clamp() to igt_aux and use it for ycbcr<->rgb conversion
@ 2018-05-17 19:51 Ville Syrjala
  2018-05-17 19:51 ` [igt-dev] [PATCH i-g-t 02/10] lib: Clear packed YUV formats to black Ville Syrjala
                   ` (13 more replies)
  0 siblings, 14 replies; 27+ messages in thread
From: Ville Syrjala @ 2018-05-17 19:51 UTC (permalink / raw)
  To: igt-dev

From: Ville Syrjälä <ville.syrjala@linux.intel.com>

Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
---
 lib/igt_aux.h |  7 +++++++
 lib/igt_fb.c  | 11 ++++-------
 2 files changed, 11 insertions(+), 7 deletions(-)

diff --git a/lib/igt_aux.h b/lib/igt_aux.h
index 9bb03b77ed46..0eb96e442a7e 100644
--- a/lib/igt_aux.h
+++ b/lib/igt_aux.h
@@ -228,6 +228,13 @@ void intel_require_files(uint64_t count);
 	_a > _b ? _a : _b;		\
 })
 
+#define clamp(x, min, max) ({		\
+	typeof(min) _min = (min);	\
+	typeof(max) _max = (max);	\
+	typeof(x) _x = (x);		\
+	_x < _min ? _min : _x > _max ? _max : _x;	\
+})
+
 #define igt_swap(a, b) do {	\
 	typeof(a) _tmp = (a);	\
 	(a) = (b);		\
diff --git a/lib/igt_fb.c b/lib/igt_fb.c
index 34b1a261b95c..ac3792f4c0db 100644
--- a/lib/igt_fb.c
+++ b/lib/igt_fb.c
@@ -30,6 +30,7 @@
 #include <inttypes.h>
 
 #include "drmtest.h"
+#include "igt_aux.h"
 #include "igt_fb.h"
 #include "igt_kms.h"
 #include "igt_x86.h"
@@ -1320,13 +1321,9 @@ struct fb_convert_blit_upload {
 	struct fb_blit_linear linear;
 };
 
-static uint8_t clamprgb(float val) {
-	if (val < 0)
-		return 0;
-	if (val > 255)
-		return 255;
-
-	return (uint8_t)val;
+static uint8_t clamprgb(float val)
+{
+	return clamp(val, 0.0f, 255.0f);
 }
 
 static void convert_nv12_to_rgb24(struct igt_fb *fb, struct fb_convert_blit_upload *blit)
-- 
2.16.1

_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev

^ permalink raw reply related	[flat|nested] 27+ messages in thread

end of thread, other threads:[~2018-05-19  6:30 UTC | newest]

Thread overview: 27+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-05-17 19:51 [igt-dev] [PATCH i-g-t 01/10] lib: Add clamp() to igt_aux and use it for ycbcr<->rgb conversion Ville Syrjala
2018-05-17 19:51 ` [igt-dev] [PATCH i-g-t 02/10] lib: Clear packed YUV formats to black Ville Syrjala
2018-05-17 19:51 ` [igt-dev] [PATCH i-g-t 03/10] lib: Don't use dumb buffers for YCbCr Ville Syrjala
2018-05-17 19:51 ` [igt-dev] [PATCH i-g-t 04/10] lib: Clean up format_desc Ville Syrjala
2018-05-17 20:13   ` Chris Wilson
2018-05-18 12:42     ` Ville Syrjälä
2018-05-17 19:51 ` [igt-dev] [PATCH i-g-t 05/10] lib: Add igt_matrix Ville Syrjala
2018-05-17 20:16   ` Chris Wilson
2018-05-17 19:51 ` [igt-dev] [PATCH i-g-t 06/10] lib: Add igt_color_encoding Ville Syrjala
2018-05-17 20:48   ` Chris Wilson
2018-05-17 19:51 ` [igt-dev] [PATCH i-g-t 07/10] lib: Use igt_matrix for ycbcr<->rgb conversion Ville Syrjala
2018-05-17 21:49   ` Chris Wilson
2018-05-18 12:41     ` Ville Syrjälä
2018-05-18 19:56   ` [igt-dev] [PATCH i-g-t v4 " Ville Syrjala
2018-05-17 19:51 ` [igt-dev] [PATCH i-g-t 08/10] lib: Add support for rendering into packed YCbCr framebuffers Ville Syrjala
2018-05-17 22:41   ` Chris Wilson
2018-05-18 13:00     ` Ville Syrjälä
2018-05-18 13:17       ` Chris Wilson
2018-05-18 19:57   ` [igt-dev] [PATCH i-g-t v5 " Ville Syrjala
2018-05-17 19:51 ` [igt-dev] [PATCH i-g-t 09/10] lib/fb: Add color_encoding/color_range to igt_fb Ville Syrjala
2018-05-17 21:42   ` Chris Wilson
2018-05-17 19:51 ` [igt-dev] [PATCH i-g-t 10/10] lib/kms: Respect fb color_encoding/color_range Ville Syrjala
2018-05-17 20:09 ` [igt-dev] [PATCH i-g-t 01/10] lib: Add clamp() to igt_aux and use it for ycbcr<->rgb conversion Chris Wilson
2018-05-17 20:29 ` [igt-dev] ✓ Fi.CI.BAT: success for series starting with [i-g-t,01/10] " Patchwork
2018-05-17 23:38 ` [igt-dev] ✗ Fi.CI.IGT: failure " Patchwork
2018-05-18 20:30 ` [igt-dev] ✓ Fi.CI.BAT: success for series starting with [i-g-t,01/10] lib: Add clamp() to igt_aux and use it for ycbcr<->rgb conversion (rev3) Patchwork
2018-05-19  6:30 ` [igt-dev] ✗ Fi.CI.IGT: failure " Patchwork

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox