Jakob Bornecrantz | fb1d973 | 2009-12-10 00:19:58 +0000 | [diff] [blame] | 1 | /************************************************************************** |
| 2 | * |
| 3 | * Copyright © 2009 VMware, Inc., Palo Alto, CA., USA |
| 4 | * All Rights Reserved. |
| 5 | * |
| 6 | * Permission is hereby granted, free of charge, to any person obtaining a |
| 7 | * copy of this software and associated documentation files (the |
| 8 | * "Software"), to deal in the Software without restriction, including |
| 9 | * without limitation the rights to use, copy, modify, merge, publish, |
| 10 | * distribute, sub license, and/or sell copies of the Software, and to |
| 11 | * permit persons to whom the Software is furnished to do so, subject to |
| 12 | * the following conditions: |
| 13 | * |
| 14 | * The above copyright notice and this permission notice (including the |
| 15 | * next paragraph) shall be included in all copies or substantial portions |
| 16 | * of the Software. |
| 17 | * |
| 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 20 | * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL |
| 21 | * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, |
| 22 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR |
| 23 | * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE |
| 24 | * USE OR OTHER DEALINGS IN THE SOFTWARE. |
| 25 | * |
| 26 | **************************************************************************/ |
| 27 | |
| 28 | #include "vmwgfx_drv.h" |
| 29 | #include "vmwgfx_drm.h" |
| 30 | |
| 31 | int vmw_getparam_ioctl(struct drm_device *dev, void *data, |
| 32 | struct drm_file *file_priv) |
| 33 | { |
| 34 | struct vmw_private *dev_priv = vmw_priv(dev); |
| 35 | struct drm_vmw_getparam_arg *param = |
| 36 | (struct drm_vmw_getparam_arg *)data; |
| 37 | |
| 38 | switch (param->param) { |
| 39 | case DRM_VMW_PARAM_NUM_STREAMS: |
| 40 | param->value = vmw_overlay_num_overlays(dev_priv); |
| 41 | break; |
| 42 | case DRM_VMW_PARAM_NUM_FREE_STREAMS: |
| 43 | param->value = vmw_overlay_num_free_overlays(dev_priv); |
| 44 | break; |
| 45 | case DRM_VMW_PARAM_3D: |
| 46 | param->value = dev_priv->capabilities & SVGA_CAP_3D ? 1 : 0; |
| 47 | break; |
| 48 | case DRM_VMW_PARAM_FIFO_OFFSET: |
| 49 | param->value = dev_priv->mmio_start; |
| 50 | break; |
| 51 | default: |
| 52 | DRM_ERROR("Illegal vmwgfx get param request: %d\n", |
| 53 | param->param); |
| 54 | return -EINVAL; |
| 55 | } |
| 56 | |
| 57 | return 0; |
| 58 | } |
| 59 | |
| 60 | int vmw_fifo_debug_ioctl(struct drm_device *dev, void *data, |
| 61 | struct drm_file *file_priv) |
| 62 | { |
| 63 | struct vmw_private *dev_priv = vmw_priv(dev); |
| 64 | struct vmw_fifo_state *fifo_state = &dev_priv->fifo; |
| 65 | struct drm_vmw_fifo_debug_arg *arg = |
| 66 | (struct drm_vmw_fifo_debug_arg *)data; |
| 67 | __le32 __user *buffer = (__le32 __user *) |
| 68 | (unsigned long)arg->debug_buffer; |
| 69 | |
| 70 | if (unlikely(fifo_state->last_buffer == NULL)) |
| 71 | return -EINVAL; |
| 72 | |
| 73 | if (arg->debug_buffer_size < fifo_state->last_data_size) { |
| 74 | arg->used_size = arg->debug_buffer_size; |
| 75 | arg->did_not_fit = 1; |
| 76 | } else { |
| 77 | arg->used_size = fifo_state->last_data_size; |
| 78 | arg->did_not_fit = 0; |
| 79 | } |
| 80 | return copy_to_user(buffer, fifo_state->last_buffer, arg->used_size); |
| 81 | } |