From mboxrd@z Thu Jan 1 00:00:00 1970 From: Thierry Reding Subject: Re: [PATCH v2 libdrm 6/7] tegra: Add gr2d-fill test Date: Fri, 2 May 2014 16:25:55 +0200 Message-ID: <20140502142554.GD21515@ulmo> References: <1397043630-13972-1-git-send-email-thierry.reding@gmail.com> <1397043630-13972-7-git-send-email-thierry.reding@gmail.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============1795470090==" Return-path: Received: from mail-ee0-f46.google.com (mail-ee0-f46.google.com [74.125.83.46]) by gabe.freedesktop.org (Postfix) with ESMTP id 6EE3B6E540 for ; Fri, 2 May 2014 07:27:38 -0700 (PDT) Received: by mail-ee0-f46.google.com with SMTP id d49so466307eek.5 for ; Fri, 02 May 2014 07:27:37 -0700 (PDT) In-Reply-To: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" To: Erik Faye-Lund Cc: "dri-devel@lists.freedesktop.org" List-Id: dri-devel@lists.freedesktop.org --===============1795470090== Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="+B+y8wtTXqdUj1xM" Content-Disposition: inline --+B+y8wtTXqdUj1xM Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Thu, Apr 10, 2014 at 07:28:16PM +0200, Erik Faye-Lund wrote: > On Wed, Apr 9, 2014 at 1:40 PM, Thierry Reding = wrote: > > diff --git a/tests/tegra/gr2d-fill.c b/tests/tegra/gr2d-fill.c > > new file mode 100644 > > index 000000000000..b6ba35a9d668 > > --- /dev/null > > +++ b/tests/tegra/gr2d-fill.c > > @@ -0,0 +1,146 @@ > > +/* > > + * 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; > > + } >=20 > I'm not quite sure I understand this part. Why would argv[1] be > anything else than NULL? Is this useful for manual debugging, perhaps? Yes. On newer Tegra generations the nouveau driver can create its own device files in /dev/dri and depending on device probe order, the card0 device can be the wrong one. For such cases these test programs can be passed the path to the correct device via the command-line. Probably a better approach would be to search for a compatible device via udev matching or iterating over /dev/dri/card* and querying the driver name (which is what drm_tegra_new() already does). But that seems overkill currently. Perhaps when this turns into a more fully-fledged test suite that could be implemented more cleverly. For now I've addressed this by making the tests fallback to a default device (/dev/dri/card0) if no argument has been specified. > > + 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 > Why do we need to sleep here? This is a visual test, so that one second gives me some time to see if the result looks as expected. I have tentative plans to implement a set of more automated tests, where an image is rendered and the checksum computed over the content can be compared with a known good reference checksum, but for now this is better than nothing. Thierry --+B+y8wtTXqdUj1xM Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.22 (GNU/Linux) iQIcBAEBAgAGBQJTY6ryAAoJEN0jrNd/PrOhRekP/3Wc8QrP7IATbNpv3oSah/5z hsTn2phzw1GMExzolRG+Qf3Q/lMR/LtYCKTd+O8DM/seASZ6oPDSkGus+KJl1xR9 tg+BlAPDuY/YowxAWfIX8Q302WJESvTDkEPXzRps56+5yNFfCwkctXFfOTrLfCJt 3+Jt4LGqL/TFzeImrUhb4RCQTa9KtziGx9+V/1lV8ooDKmdxc23Y1ZIaiRdxXr8r 8j19fxCBCANf8RWHusTj/wqRELIk3MbhAlZLn4I8J5FLDXabDwKfhYuFYQ0uqYtd 2INle8OzpEST1ZjK7ufweXIZz9BHUm49W+AGLxyvpmV8sKWwdQf4sc3A7JNEG8cy wWg4GLc/oAsjl+vcrNglY8LoxhxPPKV+r0Iz049JdN3yRWUJNezW+hiI5IUyzytU OD65zkCk9Myfe+Oz+vocBdui3tT6fWEaBS/UsRukNhQZBx4n4SjYCh/7auUNhU9i SZUdnPVfD2IMvqMi5FBf5gUP8ICHs0No4O/WPthw6jEmkX1Y5eaPL1Z3Pj0Fx38K CFzCWlXcu8kcYLAMOjil/BWNFb2McbMp60D5THYPyOxuBET9YVv6foOsnFcKNcHC WJGC/IaQQck16ZIae/yK3nyYx2gAJRedfJmpCIH2W1v6eDEEGe8fbq4A8NICpbg/ yA2wQx8v+nGi2G5N2C+l =i8qy -----END PGP SIGNATURE----- --+B+y8wtTXqdUj1xM-- --===============1795470090== 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 --===============1795470090==--