All of lore.kernel.org
 help / color / mirror / Atom feed
From: Daniel Vetter <daniel@ffwll.ch>
To: Tomeu Vizoso <tomeu.vizoso@collabora.com>
Cc: Micah Fedke <micah.fedke@collabora.com>,
	Intel GFX discussion <intel-gfx@lists.freedesktop.org>,
	Gustavo Padovan <gustavo.padovan@collabora.co.uk>,
	Daniel Stone <daniels@collabora.com>,
	Emil Velikov <emil.velikov@collabora.com>
Subject: Re: [i-g-t PATCH v1 06/14] lib: Add wrapper for DRM_IOCTL_MODE_CREATE_DUMB
Date: Sat, 5 Mar 2016 13:21:56 +0100	[thread overview]
Message-ID: <20160305122156.GD18536@phenom.ffwll.local> (raw)
In-Reply-To: <1456927221-32421-7-git-send-email-tomeu.vizoso@collabora.com>

On Wed, Mar 02, 2016 at 03:00:13PM +0100, Tomeu Vizoso wrote:
> In order to test drivers that don't have support for proper buffer
> objects, add a wrapper for creating dumb buffer objects that will be
> called from the lib code for those subtests that don't need to care.
> 
> Signed-off-by: Tomeu Vizoso <tomeu.vizoso@collabora.com>

Hm, in a way ioctl_wrappers.c is just i915 gem ioctl wrappers. I think
dumb makes much more sense as part of the kmstest_* set of functions in
igt_kms.c. Also maybe kmstest_dumb_create for consistency.
-Daniel

> ---
> 
>  lib/ioctl_wrappers.c | 36 ++++++++++++++++++++++++++++++++++++
>  lib/ioctl_wrappers.h |  1 +
>  tests/drm_read.c     | 16 +---------------
>  tests/gem_exec_blt.c | 18 +-----------------
>  4 files changed, 39 insertions(+), 32 deletions(-)
> 
> diff --git a/lib/ioctl_wrappers.c b/lib/ioctl_wrappers.c
> index 0221b7fef3a1..d842d860ba65 100644
> --- a/lib/ioctl_wrappers.c
> +++ b/lib/ioctl_wrappers.c
> @@ -531,6 +531,42 @@ uint32_t gem_create(int fd, uint64_t size)
>  }
>  
>  /**
> + * dumb_create:
> + * @fd: open drm file descriptor
> + * @width: width of the buffer in pixels
> + * @height: height of the buffer in pixels
> + * @bpp: bytes per pixel of the buffer
> + *
> + * This wraps the CREATE_DUMB ioctl, which allocates a new dumb buffer object
> + * for the specified dimensions.
> + *
> + * Returns: The file-private handle of the created buffer object
> + */
> +uint32_t dumb_create(int fd, int width, int height, int bpp, unsigned *stride,
> +		     unsigned *size)
> +{
> +	struct drm_mode_create_dumb create;
> +
> +	memset(&create, 0, sizeof(create));
> +	create.width = width;
> +	create.height = height;
> +	create.bpp = bpp;
> +
> +	create.handle = 0;
> +	do_ioctl(fd, DRM_IOCTL_MODE_CREATE_DUMB, &create);
> +	igt_assert(create.handle);
> +	igt_assert(create.size >= width * height * bpp / 8);
> +
> +	if (stride)
> +		*stride = create.pitch;
> +
> +	if (size)
> +		*size = create.size;
> +
> +	return create.handle;
> +}
> +
> +/**
>   * __gem_execbuf:
>   * @fd: open i915 drm file descriptor
>   * @execbuf: execbuffer data structure
> diff --git a/lib/ioctl_wrappers.h b/lib/ioctl_wrappers.h
> index f59eafba4bdd..9282ffdd8520 100644
> --- a/lib/ioctl_wrappers.h
> +++ b/lib/ioctl_wrappers.h
> @@ -62,6 +62,7 @@ uint32_t __gem_create_stolen(int fd, uint64_t size);
>  uint32_t gem_create_stolen(int fd, uint64_t size);
>  uint32_t __gem_create(int fd, int size);
>  uint32_t gem_create(int fd, uint64_t size);
> +uint32_t dumb_create(int fd, int width, int height, int bpp, unsigned *stride, unsigned *size);
>  void gem_execbuf(int fd, struct drm_i915_gem_execbuffer2 *execbuf);
>  int __gem_execbuf(int fd, struct drm_i915_gem_execbuffer2 *execbuf);
>  
> diff --git a/tests/drm_read.c b/tests/drm_read.c
> index faa3df862ea6..a27e5522daa0 100644
> --- a/tests/drm_read.c
> +++ b/tests/drm_read.c
> @@ -120,20 +120,6 @@ static void test_invalid_buffer(int in)
>  	teardown(fd);
>  }
>  
> -static uint32_t dumb_create(int fd)
> -{
> -	struct drm_mode_create_dumb arg;
> -
> -	arg.bpp = 32;
> -	arg.width = 32;
> -	arg.height = 32;
> -
> -	do_ioctl(fd, DRM_IOCTL_MODE_CREATE_DUMB, &arg);
> -	igt_assert(arg.size >= 4096);
> -
> -	return arg.handle;
> -}
> -
>  static void test_fault_buffer(int in)
>  {
>  	int fd = setup(in, 0);
> @@ -141,7 +127,7 @@ static void test_fault_buffer(int in)
>  	char *buf;
>  
>  	memset(&arg, 0, sizeof(arg));
> -	arg.handle = dumb_create(fd);
> +	arg.handle = dumb_create(fd, 32, 32, 32, NULL, NULL);
>  
>  	do_ioctl(fd, DRM_IOCTL_MODE_MAP_DUMB, &arg);
>  
> diff --git a/tests/gem_exec_blt.c b/tests/gem_exec_blt.c
> index 74f5c2ba87ad..42a030fb4f57 100644
> --- a/tests/gem_exec_blt.c
> +++ b/tests/gem_exec_blt.c
> @@ -170,22 +170,6 @@ static const char *bytes_per_sec(char *buf, double v)
>  	return buf;
>  }
>  
> -static uint32_t dumb_create(int fd)
> -{
> -	struct drm_mode_create_dumb arg;
> -	int ret;
> -
> -	arg.bpp = 32;
> -	arg.width = 32;
> -	arg.height = 32;
> -
> -	ret = drmIoctl(fd, DRM_IOCTL_MODE_CREATE_DUMB, &arg);
> -	igt_assert_eq(ret, 0);
> -	igt_assert(arg.size >= 4096);
> -
> -	return arg.handle;
> -}
> -
>  static int dcmp(const void *A, const void *B)
>  {
>  	const double *a = A, *b = B;
> @@ -209,7 +193,7 @@ static void run(int object_size, bool dumb)
>  
>  	fd = drm_open_driver(DRIVER_INTEL);
>  	if (dumb)
> -		handle = dumb_create(fd);
> +		handle = dumb_create(fd, 32, 32, 32, NULL, NULL);
>  	else
>  		handle = gem_create(fd, 4096);
>  
> -- 
> 2.5.0
> 
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/intel-gfx

-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

  reply	other threads:[~2016-03-05 12:21 UTC|newest]

Thread overview: 39+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-03-02 14:00 [i-g-t PATCH v1 00/14] Get a few more tests to run on !i915 Tomeu Vizoso
2016-03-02 14:00 ` [i-g-t PATCH v1 01/14] lib: add igt_require_intel Tomeu Vizoso
2016-03-02 14:18   ` Chris Wilson
2016-03-02 14:00 ` [i-g-t PATCH v1 02/14] lib: Have gem_set_tiling require intel Tomeu Vizoso
2016-03-02 14:00 ` [i-g-t PATCH v1 03/14] lib: Expose is_i915_device Tomeu Vizoso
2016-03-02 14:00 ` [i-g-t PATCH v1 04/14] lib: Have intel_get_drm_devid call igt_require_intel Tomeu Vizoso
2016-03-02 14:00 ` [i-g-t PATCH v1 05/14] lib: Call intel_get_drm_devid only from intel code Tomeu Vizoso
2016-03-02 14:00 ` [i-g-t PATCH v1 06/14] lib: Add wrapper for DRM_IOCTL_MODE_CREATE_DUMB Tomeu Vizoso
2016-03-05 12:21   ` Daniel Vetter [this message]
2016-03-02 14:00 ` [i-g-t PATCH v1 07/14] lib: Map dumb buffers Tomeu Vizoso
2016-03-02 14:21   ` Chris Wilson
2016-03-02 14:22     ` Daniel Stone
2016-03-02 14:39       ` Chris Wilson
2016-03-02 14:40         ` Daniel Stone
2016-03-02 14:54           ` Chris Wilson
2016-03-02 15:41             ` Daniel Stone
2016-03-05 12:24             ` Daniel Vetter
2016-03-05 12:27               ` Daniel Vetter
2016-03-02 14:00 ` [i-g-t PATCH v1 08/14] lib: Add igt_create_bo_with_dimensions Tomeu Vizoso
2016-03-05 12:30   ` Daniel Vetter
2016-03-07 16:19     ` Tomeu Vizoso
2016-03-07 16:25     ` Ville Syrjälä
2016-03-08 11:45     ` Daniel Stone
2016-11-01 15:44   ` Tvrtko Ursulin
2016-11-10 13:17     ` Tomeu Vizoso
2016-11-10 16:23       ` Tvrtko Ursulin
2016-11-11 11:23         ` Tomeu Vizoso
2016-11-11 11:33           ` Tvrtko Ursulin
2016-11-11 13:14             ` Tomeu Vizoso
2016-03-02 14:00 ` [i-g-t PATCH v1 09/14] tests: Open any driver Tomeu Vizoso
2016-03-02 14:00 ` [i-g-t PATCH v1 10/14] kms_addfb_basic: call igt_create_bo_with_dimensions Tomeu Vizoso
2016-03-02 14:00 ` [i-g-t PATCH v1 11/14] kms_addfb_basic: move tiling functionality into each subtest Tomeu Vizoso
2016-03-02 14:00 ` [i-g-t PATCH v1 12/14] kms_addfb_basic: Split tiling_tests off Tomeu Vizoso
2016-03-05 12:33   ` Daniel Vetter
2016-03-07 16:08     ` Tomeu Vizoso
2016-03-02 14:00 ` [i-g-t PATCH v1 13/14] kms_addfb_basic: Move calls to gem_set_tiling to the subtests Tomeu Vizoso
2016-03-02 14:00 ` [i-g-t PATCH v1 14/14] kms_addfb_basic: Get intel gen from within subtest Tomeu Vizoso
2016-03-05 12:34 ` [i-g-t PATCH v1 00/14] Get a few more tests to run on !i915 Daniel Vetter
2016-04-14 12:56   ` Daniel Stone

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=20160305122156.GD18536@phenom.ffwll.local \
    --to=daniel@ffwll.ch \
    --cc=daniels@collabora.com \
    --cc=emil.velikov@collabora.com \
    --cc=gustavo.padovan@collabora.co.uk \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=micah.fedke@collabora.com \
    --cc=tomeu.vizoso@collabora.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.