vmwgfx: Add functionality to get 3D caps
authorThomas Hellstrom <thellstrom@vmware.com>
Thu, 1 Sep 2011 20:18:41 +0000 (20:18 +0000)
committerDave Airlie <airlied@redhat.com>
Tue, 6 Sep 2011 10:48:35 +0000 (11:48 +0100)
Since we don't allow user-space to map the fifo anymore,
add a parameter to get fifo hw version and
an ioctl to copy the 3D capabilities.

Signed-off-by: Thomas Hellstrom <thellstrom@vmware.com>
Reviewed-by: Jakob Bornecranz <jakob@vmware.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
drivers/gpu/drm/vmwgfx/vmwgfx_ioctl.c
include/drm/vmwgfx_drm.h

index 9819d0d048db9964528d640284fd01e02e2731c0..8010254e9cf931776fdd80db8e5cb2b78433f004 100644 (file)
@@ -85,6 +85,9 @@
 #define DRM_IOCTL_VMW_FENCE_WAIT                               \
        DRM_IOWR(DRM_COMMAND_BASE + DRM_VMW_FENCE_WAIT,         \
                 struct drm_vmw_fence_wait_arg)
+#define DRM_IOCTL_VMW_GET_3D_CAP                               \
+       DRM_IOW(DRM_COMMAND_BASE + DRM_VMW_GET_3D_CAP,          \
+               struct drm_vmw_get_3d_cap_arg)
 
 /**
  * The core DRM version of this macro doesn't account for
@@ -130,6 +133,8 @@ static struct drm_ioctl_desc vmw_ioctls[] = {
                      DRM_AUTH | DRM_UNLOCKED),
        VMW_IOCTL_DEF(VMW_FENCE_WAIT, vmw_fence_wait_ioctl,
                      DRM_AUTH | DRM_UNLOCKED),
+       VMW_IOCTL_DEF(VMW_GET_3D_CAP, vmw_get_cap_3d_ioctl,
+                     DRM_AUTH | DRM_UNLOCKED),
 };
 
 static struct pci_device_id vmw_pci_id_list[] = {
index 39be7961906831a0c7322dfbe6b867ad179f216b..2374a5c495f246c4841901a6e9f476eaa39f13a2 100644 (file)
@@ -397,6 +397,8 @@ extern int vmw_user_stream_lookup(struct vmw_private *dev_priv,
 
 extern int vmw_getparam_ioctl(struct drm_device *dev, void *data,
                              struct drm_file *file_priv);
+extern int vmw_get_cap_3d_ioctl(struct drm_device *dev, void *data,
+                               struct drm_file *file_priv);
 
 /**
  * Fifo utilities - vmwgfx_fifo.c
index 74b1dc8a7cdd8c7f17eb602baf627faad77fe661..5ecf966606447bf06913af811bd72f98ccd89b9e 100644 (file)
@@ -54,6 +54,13 @@ int vmw_getparam_ioctl(struct drm_device *dev, void *data,
        case DRM_VMW_PARAM_MAX_FB_SIZE:
                param->value = dev_priv->vram_size;
                break;
+       case DRM_VMW_PARAM_FIFO_HW_VERSION:
+       {
+               __le32 __iomem *fifo_mem = dev_priv->mmio_virt;
+
+               param->value = ioread32(fifo_mem + SVGA_FIFO_3D_HWVERSION);
+               break;
+       }
        default:
                DRM_ERROR("Illegal vmwgfx get param request: %d\n",
                          param->param);
@@ -62,3 +69,44 @@ int vmw_getparam_ioctl(struct drm_device *dev, void *data,
 
        return 0;
 }
+
+
+int vmw_get_cap_3d_ioctl(struct drm_device *dev, void *data,
+                        struct drm_file *file_priv)
+{
+       struct drm_vmw_get_3d_cap_arg *arg =
+               (struct drm_vmw_get_3d_cap_arg *) data;
+       struct vmw_private *dev_priv = vmw_priv(dev);
+       uint32_t size;
+       __le32 __iomem *fifo_mem;
+       void __user *buffer = (void __user *)((unsigned long)(arg->buffer));
+       void *bounce;
+       int ret;
+
+       if (unlikely(arg->pad64 != 0)) {
+               DRM_ERROR("Illegal GET_3D_CAP argument.\n");
+               return -EINVAL;
+       }
+
+       size = (SVGA_FIFO_3D_CAPS_LAST - SVGA_FIFO_3D_CAPS + 1) << 2;
+
+       if (arg->max_size < size)
+               size = arg->max_size;
+
+       bounce = vmalloc(size);
+       if (unlikely(bounce == NULL)) {
+               DRM_ERROR("Failed to allocate bounce buffer for 3D caps.\n");
+               return -ENOMEM;
+       }
+
+       fifo_mem = dev_priv->mmio_virt;
+       memcpy_fromio(bounce, &fifo_mem[SVGA_FIFO_3D_CAPS], size);
+
+       ret = copy_to_user(buffer, bounce, size);
+       vfree(bounce);
+
+       if (unlikely(ret != 0))
+               DRM_ERROR("Failed to report 3D caps info.\n");
+
+       return ret;
+}
index 490db458d5dbffe7344f12ace8da7ebfd81fc961..467b80c7485d6cfb240c6e3134a2556b37e01ebb 100644 (file)
@@ -49,6 +49,7 @@
 #define DRM_VMW_REF_SURFACE          11
 #define DRM_VMW_EXECBUF              12
 #define DRM_VMW_FENCE_WAIT           13
+#define DRM_VMW_GET_3D_CAP           14
 
 /*************************************************************************/
 /**
@@ -68,6 +69,7 @@
 #define DRM_VMW_PARAM_HW_CAPS          3
 #define DRM_VMW_PARAM_FIFO_CAPS        4
 #define DRM_VMW_PARAM_MAX_FB_SIZE      5
+#define DRM_VMW_PARAM_FIFO_HW_VERSION  6
 
 /**
  * struct drm_vmw_getparam_arg
@@ -557,6 +559,29 @@ struct drm_vmw_stream_arg {
  * Return a single stream that was claimed by this process. Also makes
  * sure that the stream has been stopped.
  */
+/*************************************************************************/
+/**
+ * DRM_VMW_GET_3D_CAP
+ *
+ * Read 3D capabilities from the FIFO
+ *
+ */
+
+/**
+ * struct drm_vmw_get_3d_cap_arg
+ *
+ * @buffer: Pointer to a buffer for capability data, cast to an uint64_t
+ * @size: Max size to copy
+ *
+ * Input argument to the DRM_VMW_GET_3D_CAP_IOCTL
+ * ioctls.
+ */
+
+struct drm_vmw_get_3d_cap_arg {
+       uint64_t buffer;
+       uint32_t max_size;
+       uint32_t pad64;
+};
 
 /*************************************************************************/
 /**