diff options
author | Thomas Hellstrom <thellstrom@vmware.com> | 2011-09-01 16:18:41 -0400 |
---|---|---|
committer | Dave Airlie <airlied@redhat.com> | 2011-09-06 06:48:35 -0400 |
commit | f63f6a59d3905ac73aeeb617b27ac31516549ed9 (patch) | |
tree | 051927c6b2b8a1ff0816ea9e58aa462e55d884f4 | |
parent | 07999a7e0e409891cb27f34fa1da851d8484a5c5 (diff) |
vmwgfx: Add functionality to get 3D caps
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>
-rw-r--r-- | drivers/gpu/drm/vmwgfx/vmwgfx_drv.c | 5 | ||||
-rw-r--r-- | drivers/gpu/drm/vmwgfx/vmwgfx_drv.h | 2 | ||||
-rw-r--r-- | drivers/gpu/drm/vmwgfx/vmwgfx_ioctl.c | 48 | ||||
-rw-r--r-- | include/drm/vmwgfx_drm.h | 25 |
4 files changed, 80 insertions, 0 deletions
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c index 9819d0d048db..8010254e9cf9 100644 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c | |||
@@ -85,6 +85,9 @@ | |||
85 | #define DRM_IOCTL_VMW_FENCE_WAIT \ | 85 | #define DRM_IOCTL_VMW_FENCE_WAIT \ |
86 | DRM_IOWR(DRM_COMMAND_BASE + DRM_VMW_FENCE_WAIT, \ | 86 | DRM_IOWR(DRM_COMMAND_BASE + DRM_VMW_FENCE_WAIT, \ |
87 | struct drm_vmw_fence_wait_arg) | 87 | struct drm_vmw_fence_wait_arg) |
88 | #define DRM_IOCTL_VMW_GET_3D_CAP \ | ||
89 | DRM_IOW(DRM_COMMAND_BASE + DRM_VMW_GET_3D_CAP, \ | ||
90 | struct drm_vmw_get_3d_cap_arg) | ||
88 | 91 | ||
89 | /** | 92 | /** |
90 | * The core DRM version of this macro doesn't account for | 93 | * The core DRM version of this macro doesn't account for |
@@ -130,6 +133,8 @@ static struct drm_ioctl_desc vmw_ioctls[] = { | |||
130 | DRM_AUTH | DRM_UNLOCKED), | 133 | DRM_AUTH | DRM_UNLOCKED), |
131 | VMW_IOCTL_DEF(VMW_FENCE_WAIT, vmw_fence_wait_ioctl, | 134 | VMW_IOCTL_DEF(VMW_FENCE_WAIT, vmw_fence_wait_ioctl, |
132 | DRM_AUTH | DRM_UNLOCKED), | 135 | DRM_AUTH | DRM_UNLOCKED), |
136 | VMW_IOCTL_DEF(VMW_GET_3D_CAP, vmw_get_cap_3d_ioctl, | ||
137 | DRM_AUTH | DRM_UNLOCKED), | ||
133 | }; | 138 | }; |
134 | 139 | ||
135 | static struct pci_device_id vmw_pci_id_list[] = { | 140 | static struct pci_device_id vmw_pci_id_list[] = { |
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h index 39be79619068..2374a5c495f2 100644 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h | |||
@@ -397,6 +397,8 @@ extern int vmw_user_stream_lookup(struct vmw_private *dev_priv, | |||
397 | 397 | ||
398 | extern int vmw_getparam_ioctl(struct drm_device *dev, void *data, | 398 | extern int vmw_getparam_ioctl(struct drm_device *dev, void *data, |
399 | struct drm_file *file_priv); | 399 | struct drm_file *file_priv); |
400 | extern int vmw_get_cap_3d_ioctl(struct drm_device *dev, void *data, | ||
401 | struct drm_file *file_priv); | ||
400 | 402 | ||
401 | /** | 403 | /** |
402 | * Fifo utilities - vmwgfx_fifo.c | 404 | * Fifo utilities - vmwgfx_fifo.c |
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_ioctl.c b/drivers/gpu/drm/vmwgfx/vmwgfx_ioctl.c index 74b1dc8a7cdd..5ecf96660644 100644 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_ioctl.c +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_ioctl.c | |||
@@ -54,6 +54,13 @@ int vmw_getparam_ioctl(struct drm_device *dev, void *data, | |||
54 | case DRM_VMW_PARAM_MAX_FB_SIZE: | 54 | case DRM_VMW_PARAM_MAX_FB_SIZE: |
55 | param->value = dev_priv->vram_size; | 55 | param->value = dev_priv->vram_size; |
56 | break; | 56 | break; |
57 | case DRM_VMW_PARAM_FIFO_HW_VERSION: | ||
58 | { | ||
59 | __le32 __iomem *fifo_mem = dev_priv->mmio_virt; | ||
60 | |||
61 | param->value = ioread32(fifo_mem + SVGA_FIFO_3D_HWVERSION); | ||
62 | break; | ||
63 | } | ||
57 | default: | 64 | default: |
58 | DRM_ERROR("Illegal vmwgfx get param request: %d\n", | 65 | DRM_ERROR("Illegal vmwgfx get param request: %d\n", |
59 | param->param); | 66 | param->param); |
@@ -62,3 +69,44 @@ int vmw_getparam_ioctl(struct drm_device *dev, void *data, | |||
62 | 69 | ||
63 | return 0; | 70 | return 0; |
64 | } | 71 | } |
72 | |||
73 | |||
74 | int vmw_get_cap_3d_ioctl(struct drm_device *dev, void *data, | ||
75 | struct drm_file *file_priv) | ||
76 | { | ||
77 | struct drm_vmw_get_3d_cap_arg *arg = | ||
78 | (struct drm_vmw_get_3d_cap_arg *) data; | ||
79 | struct vmw_private *dev_priv = vmw_priv(dev); | ||
80 | uint32_t size; | ||
81 | __le32 __iomem *fifo_mem; | ||
82 | void __user *buffer = (void __user *)((unsigned long)(arg->buffer)); | ||
83 | void *bounce; | ||
84 | int ret; | ||
85 | |||
86 | if (unlikely(arg->pad64 != 0)) { | ||
87 | DRM_ERROR("Illegal GET_3D_CAP argument.\n"); | ||
88 | return -EINVAL; | ||
89 | } | ||
90 | |||
91 | size = (SVGA_FIFO_3D_CAPS_LAST - SVGA_FIFO_3D_CAPS + 1) << 2; | ||
92 | |||
93 | if (arg->max_size < size) | ||
94 | size = arg->max_size; | ||
95 | |||
96 | bounce = vmalloc(size); | ||
97 | if (unlikely(bounce == NULL)) { | ||
98 | DRM_ERROR("Failed to allocate bounce buffer for 3D caps.\n"); | ||
99 | return -ENOMEM; | ||
100 | } | ||
101 | |||
102 | fifo_mem = dev_priv->mmio_virt; | ||
103 | memcpy_fromio(bounce, &fifo_mem[SVGA_FIFO_3D_CAPS], size); | ||
104 | |||
105 | ret = copy_to_user(buffer, bounce, size); | ||
106 | vfree(bounce); | ||
107 | |||
108 | if (unlikely(ret != 0)) | ||
109 | DRM_ERROR("Failed to report 3D caps info.\n"); | ||
110 | |||
111 | return ret; | ||
112 | } | ||
diff --git a/include/drm/vmwgfx_drm.h b/include/drm/vmwgfx_drm.h index 490db458d5db..467b80c7485d 100644 --- a/include/drm/vmwgfx_drm.h +++ b/include/drm/vmwgfx_drm.h | |||
@@ -49,6 +49,7 @@ | |||
49 | #define DRM_VMW_REF_SURFACE 11 | 49 | #define DRM_VMW_REF_SURFACE 11 |
50 | #define DRM_VMW_EXECBUF 12 | 50 | #define DRM_VMW_EXECBUF 12 |
51 | #define DRM_VMW_FENCE_WAIT 13 | 51 | #define DRM_VMW_FENCE_WAIT 13 |
52 | #define DRM_VMW_GET_3D_CAP 14 | ||
52 | 53 | ||
53 | /*************************************************************************/ | 54 | /*************************************************************************/ |
54 | /** | 55 | /** |
@@ -68,6 +69,7 @@ | |||
68 | #define DRM_VMW_PARAM_HW_CAPS 3 | 69 | #define DRM_VMW_PARAM_HW_CAPS 3 |
69 | #define DRM_VMW_PARAM_FIFO_CAPS 4 | 70 | #define DRM_VMW_PARAM_FIFO_CAPS 4 |
70 | #define DRM_VMW_PARAM_MAX_FB_SIZE 5 | 71 | #define DRM_VMW_PARAM_MAX_FB_SIZE 5 |
72 | #define DRM_VMW_PARAM_FIFO_HW_VERSION 6 | ||
71 | 73 | ||
72 | /** | 74 | /** |
73 | * struct drm_vmw_getparam_arg | 75 | * struct drm_vmw_getparam_arg |
@@ -557,6 +559,29 @@ struct drm_vmw_stream_arg { | |||
557 | * Return a single stream that was claimed by this process. Also makes | 559 | * Return a single stream that was claimed by this process. Also makes |
558 | * sure that the stream has been stopped. | 560 | * sure that the stream has been stopped. |
559 | */ | 561 | */ |
562 | /*************************************************************************/ | ||
563 | /** | ||
564 | * DRM_VMW_GET_3D_CAP | ||
565 | * | ||
566 | * Read 3D capabilities from the FIFO | ||
567 | * | ||
568 | */ | ||
569 | |||
570 | /** | ||
571 | * struct drm_vmw_get_3d_cap_arg | ||
572 | * | ||
573 | * @buffer: Pointer to a buffer for capability data, cast to an uint64_t | ||
574 | * @size: Max size to copy | ||
575 | * | ||
576 | * Input argument to the DRM_VMW_GET_3D_CAP_IOCTL | ||
577 | * ioctls. | ||
578 | */ | ||
579 | |||
580 | struct drm_vmw_get_3d_cap_arg { | ||
581 | uint64_t buffer; | ||
582 | uint32_t max_size; | ||
583 | uint32_t pad64; | ||
584 | }; | ||
560 | 585 | ||
561 | /*************************************************************************/ | 586 | /*************************************************************************/ |
562 | /** | 587 | /** |