From mboxrd@z Thu Jan 1 00:00:00 1970 From: Thierry Reding Subject: Re: [RFC libdrm 6/6] tegra: Add gr2d-fill test Date: Wed, 19 Feb 2014 22:49:00 +0100 Message-ID: <20140219214859.GA2638@ulmo.nvidia.com> References: <1392825893-7380-1-git-send-email-thierry.reding@gmail.com> <1392825893-7380-7-git-send-email-thierry.reding@gmail.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============1361332389==" Return-path: Received: from mail-bk0-f44.google.com (mail-bk0-f44.google.com [209.85.214.44]) by gabe.freedesktop.org (Postfix) with ESMTP id BEF1BFAF28 for ; Wed, 19 Feb 2014 13:49:03 -0800 (PST) Received: by mail-bk0-f44.google.com with SMTP id r7so391757bkg.31 for ; Wed, 19 Feb 2014 13:49:02 -0800 (PST) In-Reply-To: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: dri-devel-bounces@lists.freedesktop.org Errors-To: dri-devel-bounces@lists.freedesktop.org To: Erik Faye-Lund Cc: dri-devel@lists.freedesktop.org List-Id: dri-devel@lists.freedesktop.org --===============1361332389== Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="EVF5PPMfhYS0aIcm" Content-Disposition: inline --EVF5PPMfhYS0aIcm Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Wed, Feb 19, 2014 at 10:03:31PM +0100, Erik Faye-Lund wrote: > On Wed, Feb 19, 2014 at 5:04 PM, Thierry Reding > wrote: > > From: Thierry Reding > > > > This test uses the IOCTLs for job submission and fences to fill a sub- > > region of the screen to a specific color using gr2d. > > > > Signed-off-by: Thierry Reding > > --- > > tests/tegra/Makefile.am | 1 + > > tests/tegra/gr2d-fill.c | 145 ++++++++++++++++++++++++++++++++++++++++= ++++++++ > > 2 files changed, 146 insertions(+) > > create mode 100644 tests/tegra/gr2d-fill.c > > > > diff --git a/tests/tegra/Makefile.am b/tests/tegra/Makefile.am > > index 90b11b278a42..9e9e75e91ad4 100644 > > --- a/tests/tegra/Makefile.am > > +++ b/tests/tegra/Makefile.am > > @@ -17,6 +17,7 @@ LDADD =3D \ > > > > TESTS =3D \ > > openclose \ > > + gr2d-fill > > > > if HAVE_INSTALL_TESTS > > testdir =3D $(libexecdir)/libdrm/tests/tegra > > diff --git a/tests/tegra/gr2d-fill.c b/tests/tegra/gr2d-fill.c > > new file mode 100644 > > index 000000000000..7ffe6f0b0848 > > --- /dev/null > > +++ b/tests/tegra/gr2d-fill.c > > @@ -0,0 +1,145 @@ > > +/* > > + * Copyright =C2=A9 2014 NVIDIA Corporation > > + * > > + * Permission is hereby granted, free of charge, to any person obtaini= ng a > > + * copy of this software and associated documentation files (the "Soft= ware"), > > + * to deal in the Software without restriction, including without limi= tation > > + * the rights to use, copy, modify, merge, publish, distribute, sublic= ense, > > + * and/or sell copies of the Software, and to permit persons to whom t= he > > + * Software is furnished to do so, subject to the following conditions: > > + * > > + * The above copyright notice and this permission notice shall be incl= uded in > > + * all copies or substantial portions of the Software. > > + * > > + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXP= RESS OR > > + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABI= LITY, > > + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT = SHALL > > + * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAG= ES OR > > + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWIS= E, > > + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE = OR > > + * OTHER DEALINGS IN THE SOFTWARE. > > + */ > > + > > +#ifdef HAVE_CONFIG_H > > +# include "config.h" > > +#endif > > + > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > + > > +#include > > + > > +#include "xf86drm.h" > > +#include "xf86drmMode.h" > > +#include "drm_fourcc.h" > > + > > +#include "drm-test-tegra.h" > > +#include "tegra.h" > > + > > +int main(int argc, char *argv[]) > > +{ > > + uint32_t format =3D DRM_FORMAT_XRGB8888; > > + struct drm_tegra_gr2d *gr2d; > > + struct drm_framebuffer *fb; > > + struct drm_screen *screen; > > + unsigned int pitch, size; > > + struct drm_tegra_bo *bo; > > + struct drm_tegra *drm; > > + uint32_t handle; > > + int fd, err; > > + void *ptr; > > + > > + fd =3D drm_open(argv[1]); > > + if (fd < 0) { > > + fprintf(stderr, "failed to open DRM device %s: %s\n", a= rgv[1], > > + strerror(errno)); > > + return 1; > > + } > > + > > + err =3D drm_screen_open(&screen, fd); > > + if (err < 0) { > > + fprintf(stderr, "failed to open screen: %s\n", strerror= (-err)); > > + return 1; > > + } > > + > > + err =3D drm_tegra_new(&drm, fd); > > + if (err < 0) { > > + fprintf(stderr, "failed to create Tegra DRM context: %s= \n", > > + strerror(-err)); > > + return 1; > > + } > > + > > + err =3D drm_tegra_gr2d_open(&gr2d, drm); > > + if (err < 0) { > > + fprintf(stderr, "failed to open gr2d channel: %s\n", > > + strerror(-err)); > > + return 1; > > + } > > + > > + pitch =3D screen->width * screen->bpp / 8; > > + size =3D pitch * screen->height; > > + > > + err =3D drm_tegra_bo_new(&bo, drm, 0, size); > > + if (err < 0) { > > + fprintf(stderr, "failed to create buffer object: %s\n", > > + strerror(-err)); > > + return 1; > > + } > > + > > + err =3D drm_tegra_bo_get_handle(bo, &handle); > > + if (err < 0) { > > + fprintf(stderr, "failed to get handle to buffer object:= %s\n", > > + strerror(-err)); > > + return 1; > > + } > > + > > + err =3D drm_tegra_bo_map(bo, &ptr); > > + if (err < 0) { > > + fprintf(stderr, "failed to map buffer object: %s\n", > > + strerror(-err)); > > + return 1; > > + } > > + > > + memset(ptr, 0xff, size); > > + > > + err =3D drm_framebuffer_new(&fb, screen, handle, screen->width, > > + screen->height, pitch, format, bo); > > + if (err < 0) { > > + fprintf(stderr, "failed to create framebuffer: %s\n", > > + strerror(-err)); > > + return 1; > > + } > > + > > + err =3D drm_screen_set_framebuffer(screen, fb); > > + if (err < 0) { > > + fprintf(stderr, "failed to display framebuffer: %s\n", > > + strerror(-err)); > > + return 1; > > + } > > + > > + sleep(1); > > + > > + err =3D drm_tegra_gr2d_fill(gr2d, fb, fb->width / 4, fb->height= / 4, > > + fb->width / 2, fb->height / 2, 0x0000= 0000); > > + if (err < 0) { > > + fprintf(stderr, "failed to fill rectangle: %s\n", > > + strerror(-err)); > > + return 1; > > + } > > + > > + sleep(1); >=20 > Oh, I see. You don't validate the result from the code, but visually inst= ead? >=20 > IMO, we should allow automated test to verify the result > automatically. GR2D doesn't care about modesetting. >=20 > We could of course have a switch that lets the test-result be > inspected visually when specified. But I don't think that should be > the default, as it's more error prone, and requires master-rights. Yes, I think we should support both. Offscreen tests for automatic validation and onscreen tests for me because I like looking at the output. One of the things also on my TODO list, and with these patches getting ready that moves more towards the top, is render node support. It should be relatively easy to support that. Thierry --EVF5PPMfhYS0aIcm Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.22 (GNU/Linux) iQIcBAEBAgAGBQJTBSbLAAoJEN0jrNd/PrOhJbYQALIQq2XtxO1WghEPp4v1Rhiy Kp1i3gCjk15IRkWXJwQJq1z7jh9P6Ll9NTa8hlDkf7oc4etKUFJhb7bdYJQfyrlW mMnU+sRVndX/OGn2KKzsabmuMVOHkXF2VAM8VEAKuQQePAzZm2wIm/1utuXztLR9 p5uIXToeCzRaP7doYfT8dDrau70JheQjJBuF2CYyAICKpexoUUmeOL5bGQ/i+Y25 SrPr+Vl6sqvvcXqMrk+jXCMla/NSwx6jnLmPcYd4PXJDB2LJFCVOc1Tofg0KZpIs EVEQQsEQ7Sfl4CnOl7SgKBh8jbtaCGxElQw4dpgNKk4SdTs0dFSTMKXiUK3jWoPc 6ba6zA2GVwAwgZ/hp/HqPlR4iK15VbTQKnQ4DusgprLR8qXQfK5qILACs0mX/Ctq Ixnq/QqP4ei93ujTxsZY9BqFXvuBAB5BRL1qFiN1UYQr7NRfTQxKlILcq0ZDGugu vLXqsCIhtdDnwhJrijixN54q+iX8NFA7gOUFqM5kveH7I/Z0sZrE9xhjjW1kGgb8 wAzsU4qO+OoO3iV6tluMY1w/9jBlVOrpd+aVG7unvyYxoPCq2C5yE2yFOQmAKoY1 SKnNIB6pI5Tf1EPc1G7LUraRWkX9RZmYxxPCodVl8sl6EqCPNSDTaT5pl7LMSHCO 1cSd/n6ll8HHulhojjuu =M4mB -----END PGP SIGNATURE----- --EVF5PPMfhYS0aIcm-- --===============1361332389== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ dri-devel mailing list dri-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/dri-devel --===============1361332389==--