All of lore.kernel.org
 help / color / mirror / Atom feed
From: Thierry Reding <thierry.reding@gmail.com>
To: Erik Faye-Lund <kusmabite@gmail.com>
Cc: dri-devel@lists.freedesktop.org
Subject: Re: [RFC libdrm 6/6] tegra: Add gr2d-fill test
Date: Wed, 19 Feb 2014 22:49:00 +0100	[thread overview]
Message-ID: <20140219214859.GA2638@ulmo.nvidia.com> (raw)
In-Reply-To: <CABPQNSYUF0LZ+fwneExrV8CdGCy6oP3hKWsrJo5HvfUt01GZKQ@mail.gmail.com>


[-- Attachment #1.1: Type: text/plain, Size: 7049 bytes --]

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
> <thierry.reding@gmail.com> wrote:
> > From: Thierry Reding <treding@nvidia.com>
> >
> > 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 <treding@nvidia.com>
> > ---
> >  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 = \
> >
> >  TESTS = \
> >         openclose \
> > +       gr2d-fill
> >
> >  if HAVE_INSTALL_TESTS
> >  testdir = $(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 © 2014 NVIDIA Corporation
> > + *
> > + * 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 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 COPYRIGHT HOLDER(S) OR AUTHOR(S) 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.
> > + */
> > +
> > +#ifdef HAVE_CONFIG_H
> > +#  include "config.h"
> > +#endif
> > +
> > +#include <errno.h>
> > +#include <fcntl.h>
> > +#include <stdbool.h>
> > +#include <stdint.h>
> > +#include <stdio.h>
> > +#include <stdlib.h>
> > +#include <string.h>
> > +#include <unistd.h>
> > +
> > +#include <sys/ioctl.h>
> > +
> > +#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 = 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 = drm_open(argv[1]);
> > +       if (fd < 0) {
> > +               fprintf(stderr, "failed to open DRM device %s: %s\n", argv[1],
> > +                       strerror(errno));
> > +               return 1;
> > +       }
> > +
> > +       err = drm_screen_open(&screen, fd);
> > +       if (err < 0) {
> > +               fprintf(stderr, "failed to open screen: %s\n", strerror(-err));
> > +               return 1;
> > +       }
> > +
> > +       err = drm_tegra_new(&drm, fd);
> > +       if (err < 0) {
> > +               fprintf(stderr, "failed to create Tegra DRM context: %s\n",
> > +                       strerror(-err));
> > +               return 1;
> > +       }
> > +
> > +       err = drm_tegra_gr2d_open(&gr2d, drm);
> > +       if (err < 0) {
> > +               fprintf(stderr, "failed to open gr2d channel: %s\n",
> > +                       strerror(-err));
> > +               return 1;
> > +       }
> > +
> > +       pitch = screen->width * screen->bpp / 8;
> > +       size = pitch * screen->height;
> > +
> > +       err = 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 = 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 = 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 = 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 = drm_screen_set_framebuffer(screen, fb);
> > +       if (err < 0) {
> > +               fprintf(stderr, "failed to display framebuffer: %s\n",
> > +                       strerror(-err));
> > +               return 1;
> > +       }
> > +
> > +       sleep(1);
> > +
> > +       err = drm_tegra_gr2d_fill(gr2d, fb, fb->width / 4, fb->height / 4,
> > +                                 fb->width / 2, fb->height / 2, 0x00000000);
> > +       if (err < 0) {
> > +               fprintf(stderr, "failed to fill rectangle: %s\n",
> > +                       strerror(-err));
> > +               return 1;
> > +       }
> > +
> > +       sleep(1);
> 
> Oh, I see. You don't validate the result from the code, but visually instead?
> 
> IMO, we should allow automated test to verify the result
> automatically. GR2D doesn't care about modesetting.
> 
> 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

[-- Attachment #1.2: Type: application/pgp-signature, Size: 836 bytes --]

[-- Attachment #2: Type: text/plain, Size: 159 bytes --]

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel

  reply	other threads:[~2014-02-19 21:49 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-02-19 16:04 [RFC libdrm 0/6] Add NVIDIA Tegra support Thierry Reding
2014-02-19 16:04 ` [RFC libdrm 1/6] configure: Support symbol visibility when available Thierry Reding
2014-02-19 21:05   ` Erik Faye-Lund
2014-02-19 21:50     ` Thierry Reding
2014-02-19 16:04 ` [RFC libdrm 2/6] libdrm: Add NVIDIA Tegra support Thierry Reding
2014-02-19 19:59   ` Rémi Cardona
2014-02-19 20:03   ` Erik Faye-Lund
2014-02-19 21:33     ` Thierry Reding
2014-02-19 20:13   ` Erik Faye-Lund
2014-02-19 21:32     ` Thierry Reding
2014-02-19 16:04 ` [RFC libdrm 3/6] tegra: Add simple test for drm_tegra_open() Thierry Reding
2014-02-19 20:19   ` Erik Faye-Lund
2014-02-19 20:50     ` Erik Faye-Lund
2014-02-19 21:34   ` Erik Faye-Lund
2014-02-19 16:04 ` [RFC libdrm 4/6] tegra: Add channel, job, pushbuf and fence APIs Thierry Reding
2014-02-19 19:57   ` Erik Faye-Lund
2014-02-19 21:11     ` Thierry Reding
2014-02-19 16:04 ` [RFC libdrm 5/6] tegra: Add helper library for tests Thierry Reding
2014-02-19 20:54   ` Erik Faye-Lund
2014-02-19 16:04 ` [RFC libdrm 6/6] tegra: Add gr2d-fill test Thierry Reding
2014-02-19 21:03   ` Erik Faye-Lund
2014-02-19 21:49     ` Thierry Reding [this message]
2014-03-20 15:23 ` [RFC libdrm 0/6] Add NVIDIA Tegra support Erik Faye-Lund
2014-04-08 12:58   ` Erik Faye-Lund

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=20140219214859.GA2638@ulmo.nvidia.com \
    --to=thierry.reding@gmail.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=kusmabite@gmail.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.