Re: [Intel-gfx] [RFC PATCH i-g-t 2/3] tests/chamelium: Add test case for plane formats

2018-03-13 Thread Maxime Ripard
Hi Eric,

On Mon, Mar 12, 2018 at 12:02:26PM -0700, Eric Anholt wrote:
> > +static pixman_image_t *convert_frame_format(pixman_image_t *src,
> > +   int format)
> > +{
> > +   pixman_image_t *converted;
> > +   unsigned int w = pixman_image_get_width(src);
> > +   unsigned int h = pixman_image_get_height(src);
> > +   void *data = malloc(w * h * 4);
> > +
> > +   memset(data, 0, w * h * 4);
> > +   converted = pixman_image_create_bits(format, w, h, data,
> > +PIXMAN_FORMAT_BPP(format) / 8 * w);
> > +   pixman_image_composite(PIXMAN_OP_ADD, src, NULL, converted,
> > +  0, 0, 0, 0, 0, 0, w, h);
> > +   return converted;
> > +}
> 
> Instead of the memset, you could just use PIXMAN_OP_SRC.

I guess PIXMAN_OP_ADD will do a composition between the existing
buffer content and the new one, while PIXMAN_OP_SRC will just take
whatever comes from the buffer and overwrite the previous content?

> Also, instead of "* 4", probably want "* PIXMAN_FORMAT_BPP(format) / 8"
> there too.

Ah, yes, definitely.

> > +#define PIXEL_MASK 0x00f8f8f8
> 
> If we're going to have some tolerance, the tolerance should probably
> depend on the lowest depth of the channel involved.

Indeed, yes.

> However, I'm not sure this is needed -- we should be able to get
> bit-exact from VC4 by filling in the size-extension bits in the HVS.

I guess it really depends on what we're aiming for here. While it
would probably work with VC4, I think this part is rather generic, so
I guess we could end up in scenarios where the CRTC will not fill the
bits to our expected value and where it wouldn't be something we can
change.

I just looked at the Allwinner display engine for example, and it
didn't have such configuration (documented, at least).

That's why I went with this approach here (but I can definitely change
it if we want to deal with that theorical case later).

Maxime

-- 
Maxime Ripard, Bootlin (formerly Free Electrons)
Embedded Linux and Kernel engineering
https://bootlin.com


signature.asc
Description: PGP signature
___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx


Re: [Intel-gfx] [RFC PATCH i-g-t 2/3] tests/chamelium: Add test case for plane formats

2018-03-12 Thread Eric Anholt
Maxime Ripard  writes:

> KMS can support a lot of different plane formats that are not being tested
> by the current chamelium tests.
>
> Add some preliminary tests to exert the RGB formats exposed by the KMS
> planes.

I'm really excited for this test.  A few comments...

> ---
>  tests/Makefile.am |   1 +
>  tests/Makefile.sources|   5 +
>  tests/kms_chamelium_formats.c | 305 
> ++
>  tests/meson.build |   1 +
>  4 files changed, 312 insertions(+)
>  create mode 100644 tests/kms_chamelium_formats.c
>
> diff --git a/tests/Makefile.am b/tests/Makefile.am
> index 8472a6bf0a73..becc23de895b 100644
> --- a/tests/Makefile.am
> +++ b/tests/Makefile.am
> @@ -17,6 +17,7 @@ endif
>  if HAVE_CHAMELIUM
>  TESTS_progs += \
>   kms_chamelium \
> + kms_chamelium_formats \
>   $(NULL)
>  endif
>  
> diff --git a/tests/Makefile.sources b/tests/Makefile.sources
> index c27226fc96c9..8476b63a245c 100644
> --- a/tests/Makefile.sources
> +++ b/tests/Makefile.sources
> @@ -280,6 +280,11 @@ kms_chamelium_SOURCES = \
>   helpers_chamelium.h \
>   helpers_chamelium.c
>  
> +kms_chamelium_formats_SOURCES = \
> + kms_chamelium_formats.c \
> + helpers_chamelium.h \
> + helpers_chamelium.c
> +
>  testdisplay_SOURCES = \
>   testdisplay.c \
>   testdisplay.h \
> diff --git a/tests/kms_chamelium_formats.c b/tests/kms_chamelium_formats.c
> new file mode 100644
> index ..6d61f2fa34d8
> --- /dev/null
> +++ b/tests/kms_chamelium_formats.c
> @@ -0,0 +1,305 @@
> +/*
> + * Copyright © 2016 Red Hat Inc.
> + *
> + * Permission is hereby granted, free of charge, to any person obtaining a
> + * copy of this software and associated documentation files (the "Software"),
> + * to deal in the Software without restriction, including without limitation
> + * the rights to use, copy, modify, merge, publish, distribute, sublicense,
> + * and/or sell copies of the Software, and to permit persons to whom the
> + * Software is furnished to do so, subject to the following conditions:
> + *
> + * The above copyright notice and this permission notice (including the next
> + * paragraph) shall be included in all copies or substantial portions of the
> + * Software.
> + *
> + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
> + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
> + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
> + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
> + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
> + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 
> DEALINGS
> + * IN THE SOFTWARE.
> + *
> + * Authors:
> + *Lyude Paul 
> + */
> +
> +#include "config.h"
> +#include "helpers_chamelium.h"
> +#include "igt.h"
> +
> +#include 
> +#include 
> +#include 
> +
> +struct formats {
> + uint32_tdrm_fmt;
> + pixman_format_code_tpixman_fmt;
> +} formats_map[] = {
> + { DRM_FORMAT_XRGB, PIXMAN_x8r8g8b8 },
> + { DRM_FORMAT_ARGB, PIXMAN_a8r8g8b8 },
> + { DRM_FORMAT_ABGR, PIXMAN_a8b8g8r8 },
> + { DRM_FORMAT_RGB565, PIXMAN_r5g6b5 },
> + { DRM_FORMAT_BGR565, PIXMAN_b5g6r5 },
> + { DRM_FORMAT_ARGB1555, PIXMAN_a1r5g5b5 },
> + { DRM_FORMAT_XRGB1555, PIXMAN_x1r5g5b5 },
> +};
> +
> +static pixman_image_t *paint_ar24_pattern(size_t width, size_t height)
> +{
> + uint32_t colors[] = { 0xff00,
> +   0x,
> +   0xff00ff00,
> +   0xffff,
> +   0x };
> + unsigned i, j;
> + uint32_t *data;
> +
> + data = malloc(width * height * sizeof(*data));
> + igt_assert(data);
> +
> + for (i = 0; i < height; i++)
> + for (j = 0; j < width; j++)
> + *(data + i * width + j) = colors[((j / 64) + (i / 64)) 
> % 5];
> +
> + return pixman_image_create_bits(PIXMAN_a8r8g8b8, width, height,
> + data, width * 4);
> +}
> +
> +static void free_pattern(pixman_image_t *pattern)
> +{
> + void *data = pixman_image_get_data(pattern);
> +
> + pixman_image_unref(pattern);
> + free(data);
> +}
> +
> +static pixman_image_t *pattern_to_fb(pixman_image_t *pattern, struct igt_fb 
> *fb,
> +  pixman_format_code_t pixman_fmt)
> +{
> + pixman_image_t *converted;
> + void *ptr;
> +
> + igt_assert(fb->is_dumb);
> +
> + ptr = kmstest_dumb_map_buffer(fb->fd, fb->gem_handle, fb->size,
> +   PROT_READ | PROT_WRITE);
> + igt_assert(ptr);
> +
> + converted = pixman_image_create_bits(pixman_fmt, fb->width, fb->height,
> +  ptr, fb->stride);
> + 

[Intel-gfx] [RFC PATCH i-g-t 2/3] tests/chamelium: Add test case for plane formats

2018-03-05 Thread Maxime Ripard
KMS can support a lot of different plane formats that are not being tested
by the current chamelium tests.

Add some preliminary tests to exert the RGB formats exposed by the KMS
planes.

Signed-off-by: Maxime Ripard 
---
 tests/Makefile.am |   1 +
 tests/Makefile.sources|   5 +
 tests/kms_chamelium_formats.c | 305 ++
 tests/meson.build |   1 +
 4 files changed, 312 insertions(+)
 create mode 100644 tests/kms_chamelium_formats.c

diff --git a/tests/Makefile.am b/tests/Makefile.am
index 8472a6bf0a73..becc23de895b 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -17,6 +17,7 @@ endif
 if HAVE_CHAMELIUM
 TESTS_progs += \
kms_chamelium \
+   kms_chamelium_formats \
$(NULL)
 endif
 
diff --git a/tests/Makefile.sources b/tests/Makefile.sources
index c27226fc96c9..8476b63a245c 100644
--- a/tests/Makefile.sources
+++ b/tests/Makefile.sources
@@ -280,6 +280,11 @@ kms_chamelium_SOURCES = \
helpers_chamelium.h \
helpers_chamelium.c
 
+kms_chamelium_formats_SOURCES = \
+   kms_chamelium_formats.c \
+   helpers_chamelium.h \
+   helpers_chamelium.c
+
 testdisplay_SOURCES = \
testdisplay.c \
testdisplay.h \
diff --git a/tests/kms_chamelium_formats.c b/tests/kms_chamelium_formats.c
new file mode 100644
index ..6d61f2fa34d8
--- /dev/null
+++ b/tests/kms_chamelium_formats.c
@@ -0,0 +1,305 @@
+/*
+ * Copyright © 2016 Red Hat Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ *
+ * Authors:
+ *Lyude Paul 
+ */
+
+#include "config.h"
+#include "helpers_chamelium.h"
+#include "igt.h"
+
+#include 
+#include 
+#include 
+
+struct formats {
+   uint32_tdrm_fmt;
+   pixman_format_code_tpixman_fmt;
+} formats_map[] = {
+   { DRM_FORMAT_XRGB, PIXMAN_x8r8g8b8 },
+   { DRM_FORMAT_ARGB, PIXMAN_a8r8g8b8 },
+   { DRM_FORMAT_ABGR, PIXMAN_a8b8g8r8 },
+   { DRM_FORMAT_RGB565, PIXMAN_r5g6b5 },
+   { DRM_FORMAT_BGR565, PIXMAN_b5g6r5 },
+   { DRM_FORMAT_ARGB1555, PIXMAN_a1r5g5b5 },
+   { DRM_FORMAT_XRGB1555, PIXMAN_x1r5g5b5 },
+};
+
+static pixman_image_t *paint_ar24_pattern(size_t width, size_t height)
+{
+   uint32_t colors[] = { 0xff00,
+ 0x,
+ 0xff00ff00,
+ 0xffff,
+ 0x };
+   unsigned i, j;
+   uint32_t *data;
+
+   data = malloc(width * height * sizeof(*data));
+   igt_assert(data);
+
+   for (i = 0; i < height; i++)
+   for (j = 0; j < width; j++)
+   *(data + i * width + j) = colors[((j / 64) + (i / 64)) 
% 5];
+
+   return pixman_image_create_bits(PIXMAN_a8r8g8b8, width, height,
+   data, width * 4);
+}
+
+static void free_pattern(pixman_image_t *pattern)
+{
+   void *data = pixman_image_get_data(pattern);
+
+   pixman_image_unref(pattern);
+   free(data);
+}
+
+static pixman_image_t *pattern_to_fb(pixman_image_t *pattern, struct igt_fb 
*fb,
+pixman_format_code_t pixman_fmt)
+{
+   pixman_image_t *converted;
+   void *ptr;
+
+   igt_assert(fb->is_dumb);
+
+   ptr = kmstest_dumb_map_buffer(fb->fd, fb->gem_handle, fb->size,
+ PROT_READ | PROT_WRITE);
+   igt_assert(ptr);
+
+   converted = pixman_image_create_bits(pixman_fmt, fb->width, fb->height,
+ptr, fb->stride);
+   pixman_image_composite(PIXMAN_OP_ADD, pattern, NULL, converted,
+  0, 0, 0, 0, 0, 0, fb->width, fb->height);
+
+   return converted;
+}
+
+static pixman_image_t *convert_frame_format(pixman_image_t *src,
+