From: Eric Anholt <eric@anholt.net>
To: intel-gfx@lists.freedesktop.org
Cc: Maxime Ripard <maxime.ripard@bootlin.com>,
Thomas Petazzoni <thomas.petazzoni@bootlin.com>,
eben@raspberrypi.org
Subject: Re: [RFC PATCH i-g-t 2/3] tests/chamelium: Add test case for plane formats
Date: Mon, 12 Mar 2018 12:02:26 -0700 [thread overview]
Message-ID: <878taxxgl9.fsf@anholt.net> (raw)
In-Reply-To: <20180305142129.18352-3-maxime.ripard@bootlin.com>
[-- Attachment #1.1: Type: text/plain, Size: 6060 bytes --]
Maxime Ripard <maxime.ripard@bootlin.com> 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@redhat.com>
> + */
> +
> +#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 #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 832 bytes --]
[-- Attachment #2: Type: text/plain, Size: 160 bytes --]
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
next prev parent reply other threads:[~2018-03-12 19:02 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-03-05 14:21 [RFC PATCH i-g-t 0/3] Test the plane formats on the Chamelium Maxime Ripard
2018-03-05 14:21 ` [RFC PATCH i-g-t 1/3] tests/chamelium: Move some functions and structures to a common place Maxime Ripard
2018-03-05 14:21 ` [RFC PATCH i-g-t 2/3] tests/chamelium: Add test case for plane formats Maxime Ripard
2018-03-12 19:02 ` Eric Anholt [this message]
2018-03-13 15:05 ` Maxime Ripard
2018-03-05 14:21 ` [RFC PATCH i-g-t 3/3] tests: Add vc4 test suite Maxime Ripard
2018-03-13 10:42 ` Petri Latvala
2018-03-13 15:18 ` Maxime Ripard
2018-03-14 10:44 ` Petri Latvala
2018-03-21 10:41 ` Maxime Ripard
2018-03-05 16:49 ` ✓ Fi.CI.BAT: success for Test the plane formats on the Chamelium Patchwork
2018-03-05 21:51 ` ✗ Fi.CI.IGT: warning " Patchwork
2018-03-21 11:25 ` [RFC PATCH i-g-t 0/3] " Maxime Ripard
2018-03-21 17:10 ` Eric Anholt
2018-03-28 8:30 ` Maxime Ripard
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=878taxxgl9.fsf@anholt.net \
--to=eric@anholt.net \
--cc=eben@raspberrypi.org \
--cc=intel-gfx@lists.freedesktop.org \
--cc=maxime.ripard@bootlin.com \
--cc=thomas.petazzoni@bootlin.com \
/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