winsys/radeon: test the userptr ioctl to see if it's present
authorMarek Olšák <marek.olsak@amd.com>
Wed, 11 Feb 2015 19:25:16 +0000 (20:25 +0100)
committerMarek Olšák <marek.olsak@amd.com>
Tue, 17 Feb 2015 16:31:48 +0000 (17:31 +0100)
There is no other way to check for support.

Reviewed-by: Christian König <christian.koenig@amd.com>
src/gallium/winsys/radeon/drm/radeon_drm_bo.c
src/gallium/winsys/radeon/drm/radeon_drm_cs.h
src/gallium/winsys/radeon/drm/radeon_drm_winsys.c
src/gallium/winsys/radeon/drm/radeon_drm_winsys.h
src/gallium/winsys/radeon/drm/radeon_winsys.h

index e3b2c228378ef90da74e8e776da4f7ec706eac22..e609d6868370daa7e6c995d58614caf8132a8f2d 100644 (file)
 #include <fcntl.h>
 #include <stdio.h>
 
-#ifndef DRM_RADEON_GEM_USERPTR
-
-#define DRM_RADEON_GEM_USERPTR         0x2d
-
-#define RADEON_GEM_USERPTR_READONLY    (1 << 0)
-#define RADEON_GEM_USERPTR_ANONONLY    (1 << 1)
-#define RADEON_GEM_USERPTR_VALIDATE    (1 << 2)
-#define RADEON_GEM_USERPTR_REGISTER    (1 << 3)
-
-struct drm_radeon_gem_userptr {
-       uint64_t                addr;
-       uint64_t                size;
-       uint32_t                flags;
-       uint32_t                handle;
-};
-
-#endif
-
 extern const struct pb_vtbl radeon_bo_vtbl;
 
 static INLINE struct radeon_bo *radeon_bo(struct pb_buffer *bo)
index 089494eac23daf881b836003361f43bf59439fac..fcc29fe948009e025f57a80ac2e2209306fe9fe2 100644 (file)
@@ -28,7 +28,6 @@
 #define RADEON_DRM_CS_H
 
 #include "radeon_drm_bo.h"
-#include <radeon_drm.h>
 
 struct radeon_cs_context {
     uint32_t                    buf[RADEON_MAX_CMDBUF_DWORDS];
index 72b7931936a7b1766c9139ccca29bae976f1bdd7..2b12f4da46676a94a783ec27cdbd91365c752413 100644 (file)
@@ -309,6 +309,21 @@ static boolean do_winsys_init(struct radeon_drm_winsys *ws)
        }
     }
 
+    /* Check for userptr support. */
+    {
+        struct drm_radeon_gem_userptr args = {0};
+
+        /* If the ioctl doesn't exist, -EINVAL is returned.
+         *
+         * If the ioctl exists, it should return -EACCES
+         * if RADEON_GEM_USERPTR_READONLY or RADEON_GEM_USERPTR_REGISTER
+         * aren't set.
+         */
+        ws->info.has_userptr =
+            drmCommandWriteRead(ws->fd, DRM_RADEON_GEM_USERPTR,
+                                &args, sizeof(args)) == -EACCES;
+    }
+
     /* Get GEM info. */
     retval = drmCommandWriteRead(ws->fd, DRM_RADEON_GEM_INFO,
             &gem_info, sizeof(gem_info));
index 1e0c632be9914016e3047a91ca9e059326dda8d2..5711ffa8e53c80657be7c9d346d01d676d14c394 100644 (file)
 
 #include "radeon_winsys.h"
 #include "os/os_thread.h"
+#include <radeon_drm.h>
+
+#ifndef DRM_RADEON_GEM_USERPTR
+
+#define DRM_RADEON_GEM_USERPTR         0x2d
+
+#define RADEON_GEM_USERPTR_READONLY    (1 << 0)
+#define RADEON_GEM_USERPTR_ANONONLY    (1 << 1)
+#define RADEON_GEM_USERPTR_VALIDATE    (1 << 2)
+#define RADEON_GEM_USERPTR_REGISTER    (1 << 3)
+
+struct drm_radeon_gem_userptr {
+       uint64_t                addr;
+       uint64_t                size;
+       uint32_t                flags;
+       uint32_t                handle;
+};
+
+#endif
 
 struct radeon_drm_cs;
 
index 3a6037c05421464653ce4435162b1f2dddf66580..a8cc60a33e40c751f7fc348b6ab2c108f0f6f222 100644 (file)
@@ -214,6 +214,7 @@ struct radeon_info {
 
     boolean                     has_uvd;
     uint32_t                    vce_fw_version;
+    boolean                     has_userptr;
 
     uint32_t                    r300_num_gb_pipes;
     uint32_t                    r300_num_z_pipes;