From 0a2635f3a5e79c5438e2afaedbbb5e3ac5595f3d Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Sun, 24 Feb 2013 08:46:40 +0100 Subject: v4l2-drm-example: Use dumb GEM buffers The GEM buffers we allocate will only be used as backing memory for the frame buffer. Dumb GEM buffers can fullfill that task and remove dependencies on the Exynos driver. Use them. Signed-off-by: Laurent Pinchart --- v4l2-drm-example/dmabuf-sharing.c | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/v4l2-drm-example/dmabuf-sharing.c b/v4l2-drm-example/dmabuf-sharing.c index d5739f8..d19d219 100644 --- a/v4l2-drm-example/dmabuf-sharing.c +++ b/v4l2-drm-example/dmabuf-sharing.c @@ -20,7 +20,6 @@ #include #include -#include #include #include #include @@ -33,9 +32,13 @@ #include #include +#include +#include + +#include + #include #include -#include #define ERRSTR strerror(errno) @@ -192,17 +195,17 @@ static int parse_args(int argc, char *argv[], struct setup *s) static int buffer_create(struct buffer *b, int drmfd, struct setup *s, uint64_t size, uint32_t pitch) { - int ret = strncmp(s->module, "exynos", 6); - if (WARN_ON(ret, "drm: only exynos GEM is supported\n")) - return -1; - - struct drm_exynos_gem_create gem; - struct drm_gem_close gem_close; + struct drm_mode_create_dumb gem; + struct drm_mode_destroy_dumb gem_destroy; + int ret; memset(&gem, 0, sizeof gem); + gem.width = s->w; + gem.height = s->h; + gem.bpp = pitch / s->w * 8; gem.size = size; - ret = ioctl(drmfd, DRM_IOCTL_EXYNOS_GEM_CREATE, &gem); - if (WARN_ON(ret, "EXYNOS_GEM_CREATE failed: %s\n", ERRSTR)) + ret = ioctl(drmfd, DRM_IOCTL_MODE_CREATE_DUMB, &gem); + if (WARN_ON(ret, "CREATE_DUMB failed: %s\n", ERRSTR)) return -1; b->bo_handle = gem.handle; @@ -233,10 +236,10 @@ fail_prime: close(b->dbuf_fd); fail_gem: - memset(&gem_close, 0, sizeof gem_close); - gem_close.handle = b->bo_handle, - ret = ioctl(drmfd, DRM_IOCTL_GEM_CLOSE, gem_close); - WARN_ON(ret, "GEM_CLOSE failed: %s\n", ERRSTR); + memset(&gem_destroy, 0, sizeof gem_destroy); + gem_destroy.handle = b->bo_handle, + ret = ioctl(drmfd, DRM_IOCTL_MODE_DESTROY_DUMB, &gem_destroy); + WARN_ON(ret, "DESTROY_DUMB failed: %s\n", ERRSTR); return -1; } -- cgit v1.2.3