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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Maxime Ripard <maxime.ripard@xxxxxxxxxxx> 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 000000000000..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 <lyude@xxxxxxxxxx>
> + */
> +
> +#include "config.h"
> +#include "helpers_chamelium.h"
> +#include "igt.h"
> +
> +#include <fcntl.h>
> +#include <pixman.h>
> +#include <string.h>
> +
> +struct formats {
> +	uint32_t		drm_fmt;
> +	pixman_format_code_t	pixman_fmt;
> +} formats_map[] = {
> +	{ DRM_FORMAT_XRGB8888, PIXMAN_x8r8g8b8 },
> +	{ DRM_FORMAT_ARGB8888, PIXMAN_a8r8g8b8 },
> +	{ DRM_FORMAT_ABGR8888, 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[] = { 0xff000000,
> +			      0xffff0000,
> +			      0xff00ff00,
> +			      0xff0000ff,
> +			      0xffffffff };
> +	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);

If you're trying to fill the FB with the incoming pattern, then
PIXMAN_OP_SRC is the thing you want (and will be *much* faster).

> +
> +	return converted;
> +}
> +
> +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.

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

> +#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.  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.

Attachment: signature.asc
Description: PGP signature

_______________________________________________
Intel-gfx mailing list
Intel-gfx@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]
  Powered by Linux