From mboxrd@z Thu Jan 1 00:00:00 1970 From: Eric Anholt 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 Message-ID: <878taxxgl9.fsf@anholt.net> References: <20180305142129.18352-1-maxime.ripard@bootlin.com> <20180305142129.18352-3-maxime.ripard@bootlin.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============1661937209==" Return-path: Received: from anholt.net (anholt.net [50.246.234.109]) by gabe.freedesktop.org (Postfix) with ESMTP id 9EDB66E1A9 for ; Mon, 12 Mar 2018 19:02:29 +0000 (UTC) In-Reply-To: <20180305142129.18352-3-maxime.ripard@bootlin.com> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" To: intel-gfx@lists.freedesktop.org Cc: Maxime Ripard , Thomas Petazzoni , eben@raspberrypi.org List-Id: intel-gfx@lists.freedesktop.org --===============1661937209== Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha512; protocol="application/pgp-signature" --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable 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 +=3D \ > kms_chamelium \ > + kms_chamelium_formats \ > $(NULL) > endif >=20=20 > 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 =3D \ > helpers_chamelium.h \ > helpers_chamelium.c >=20=20 > +kms_chamelium_formats_SOURCES =3D \ > + kms_chamelium_formats.c \ > + helpers_chamelium.h \ > + helpers_chamelium.c > + > testdisplay_SOURCES =3D \ > 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 =C2=A9 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 "Softwa= re"), > + * to deal in the Software without restriction, including without limita= tion > + * the rights to use, copy, modify, merge, publish, distribute, sublicen= se, > + * 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, EXPRE= SS OR > + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILI= TY, > + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SH= ALL > + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR = OTHER > + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISI= NG > + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER D= EALINGS > + * IN THE SOFTWARE. > + * > + * Authors: > + * Lyude Paul > + */ > + > +#include "config.h" > +#include "helpers_chamelium.h" > +#include "igt.h" > + > +#include > +#include > +#include > + > +struct formats { > + uint32_t drm_fmt; > + pixman_format_code_t pixman_fmt; > +} formats_map[] =3D { > + { 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[] =3D { 0xff000000, > + 0xffff0000, > + 0xff00ff00, > + 0xff0000ff, > + 0xffffffff }; > + unsigned i, j; > + uint32_t *data; > + > + data =3D malloc(width * height * sizeof(*data)); > + igt_assert(data); > + > + for (i =3D 0; i < height; i++) > + for (j =3D 0; j < width; j++) > + *(data + i * width + j) =3D 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 =3D 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 =3D kmstest_dumb_map_buffer(fb->fd, fb->gem_handle, fb->size, > + PROT_READ | PROT_WRITE); > + igt_assert(ptr); > + > + converted =3D pixman_image_create_bits(pixman_fmt, fb->width, fb->heigh= t, > + 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 =3D pixman_image_get_width(src); > + unsigned int h =3D pixman_image_get_height(src); > + void *data =3D malloc(w * h * 4); > + > + memset(data, 0, w * h * 4); > + converted =3D 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. --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAEBCgAdFiEE/JuuFDWp9/ZkuCBXtdYpNtH8nugFAlqmzsIACgkQtdYpNtH8 nujxqA/+L+OH8V87juDDhFxcItSNx0LF+Y5WPPfKc9n61dFaMJWC9/kUNXwlQNEA DJvX0pNLBDcjBKqcX6b7E1UsIqfzTMo5csmI+iPGysxKN6ZVpKWMD/J5MFrPo1Aj ye9095xS9rJ8TomMfeoLdsKUC112S2a/UOBUqNtkgaPHP0n/kYBF2mb+JAgBphKp sX+mwQleUo3TgRIQd4QYDqICib4nWX5TALgiYk5Q/AxqsrpjH/nAYT59CSzuFqQo RfAuqCNldq9ooctEU7GFSzd4P1tLNFtk+u46jqsm4R+e9kFegd03LvwH0qwpydCR bE3EwOhJfr3yUI3vOa4dgESl1RGy8KLBKrRJgSONBa57KREDZJHC3oM6lRvrzyNA w/4sQMK7Xv0UJJp8rs5b6ujRoxQ42+qHwjYiPs/p5J+IRJB7IQLs6cd0doVF1ROl RPccxKc2NuZYtzbNU/Mg0pCdrWBBnvsJPtGTf2AuqVXIO2x3kGK0lRaVunwyppNs c9WwKguUkYVyqBf8Zm0CE2H4EmAo6hZGNzdwuj9Vp1dNvKq5GF3DNQNtN65vGb9x gapY8imlUS67aytick3pcrMyZbDhe8+PxTl7HOPRseqctkaAzECXNETAlcT49f0i ICxXiRdfMtRHMYQ+XYjJPzPdARqjLGzyYIJA2D7OUeRPFkQtZFU= =ZGA3 -----END PGP SIGNATURE----- --=-=-=-- --===============1661937209== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: base64 Content-Disposition: inline X19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX18KSW50ZWwtZ2Z4 IG1haWxpbmcgbGlzdApJbnRlbC1nZnhAbGlzdHMuZnJlZWRlc2t0b3Aub3JnCmh0dHBzOi8vbGlz dHMuZnJlZWRlc2t0b3Aub3JnL21haWxtYW4vbGlzdGluZm8vaW50ZWwtZ2Z4Cg== --===============1661937209==--