diff options
author | Wolfgang Wiedmeyer <wolfgit@wiedmeyer.de> | 2015-10-23 01:34:08 +0200 |
---|---|---|
committer | Wolfgang Wiedmeyer <wolfgit@wiedmeyer.de> | 2015-10-23 01:34:08 +0200 |
commit | 5864eaf2f7f0ec3366be0efe9e7a5fd0476e25cc (patch) | |
tree | fd05a3a313d92c74af3854cca137797d76ebad71 /drivers/gpu/drm/vmwgfx/vmwgfx_ioctl.c | |
parent | 786208aedd8f75b0720e36b2ca66b3a411417301 (diff) | |
download | kernel_samsung_smdk4412-5864eaf2f7f0ec3366be0efe9e7a5fd0476e25cc.zip kernel_samsung_smdk4412-5864eaf2f7f0ec3366be0efe9e7a5fd0476e25cc.tar.gz kernel_samsung_smdk4412-5864eaf2f7f0ec3366be0efe9e7a5fd0476e25cc.tar.bz2 |
remove firmware files, merge more uncritical stuff from 3.0.101
Diffstat (limited to 'drivers/gpu/drm/vmwgfx/vmwgfx_ioctl.c')
-rw-r--r-- | drivers/gpu/drm/vmwgfx/vmwgfx_ioctl.c | 273 |
1 files changed, 17 insertions, 256 deletions
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_ioctl.c b/drivers/gpu/drm/vmwgfx/vmwgfx_ioctl.c index 66917c6..570d577 100644 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_ioctl.c +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_ioctl.c @@ -27,7 +27,6 @@ #include "vmwgfx_drv.h" #include "vmwgfx_drm.h" -#include "vmwgfx_kms.h" int vmw_getparam_ioctl(struct drm_device *dev, void *data, struct drm_file *file_priv) @@ -46,6 +45,9 @@ int vmw_getparam_ioctl(struct drm_device *dev, void *data, case DRM_VMW_PARAM_3D: param->value = vmw_fifo_have_3d(dev_priv) ? 1 : 0; break; + case DRM_VMW_PARAM_FIFO_OFFSET: + param->value = dev_priv->mmio_start; + break; case DRM_VMW_PARAM_HW_CAPS: param->value = dev_priv->capabilities; break; @@ -55,19 +57,6 @@ 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; - const struct vmw_fifo_state *fifo = &dev_priv->fifo; - - param->value = - ioread32(fifo_mem + - ((fifo->capabilities & - SVGA_FIFO_CAP_3D_HWVERSION_REVISED) ? - SVGA_FIFO_3D_HWVERSION_REVISED : - SVGA_FIFO_3D_HWVERSION)); - break; - } default: DRM_ERROR("Illegal vmwgfx get param request: %d\n", param->param); @@ -77,253 +66,25 @@ int vmw_getparam_ioctl(struct drm_device *dev, void *data, return 0; } - -int vmw_get_cap_3d_ioctl(struct drm_device *dev, void *data, +int vmw_fifo_debug_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; + struct vmw_fifo_state *fifo_state = &dev_priv->fifo; + struct drm_vmw_fifo_debug_arg *arg = + (struct drm_vmw_fifo_debug_arg *)data; + __le32 __user *buffer = (__le32 __user *) + (unsigned long)arg->debug_buffer; - if (unlikely(arg->pad64 != 0)) { - DRM_ERROR("Illegal GET_3D_CAP argument.\n"); + if (unlikely(fifo_state->last_buffer == NULL)) 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; -} - -int vmw_present_ioctl(struct drm_device *dev, void *data, - struct drm_file *file_priv) -{ - struct ttm_object_file *tfile = vmw_fpriv(file_priv)->tfile; - struct vmw_private *dev_priv = vmw_priv(dev); - struct drm_vmw_present_arg *arg = - (struct drm_vmw_present_arg *)data; - struct vmw_surface *surface; - struct vmw_master *vmaster = vmw_master(file_priv->master); - struct drm_vmw_rect __user *clips_ptr; - struct drm_vmw_rect *clips = NULL; - struct drm_mode_object *obj; - struct vmw_framebuffer *vfb; - uint32_t num_clips; - int ret; - - num_clips = arg->num_clips; - clips_ptr = (struct drm_vmw_rect *)(unsigned long)arg->clips_ptr; - - if (unlikely(num_clips == 0)) - return 0; - - if (clips_ptr == NULL) { - DRM_ERROR("Variable clips_ptr must be specified.\n"); - ret = -EINVAL; - goto out_clips; - } - - clips = kcalloc(num_clips, sizeof(*clips), GFP_KERNEL); - if (clips == NULL) { - DRM_ERROR("Failed to allocate clip rect list.\n"); - ret = -ENOMEM; - goto out_clips; - } - - ret = copy_from_user(clips, clips_ptr, num_clips * sizeof(*clips)); - if (ret) { - DRM_ERROR("Failed to copy clip rects from userspace.\n"); - ret = -EFAULT; - goto out_no_copy; - } - - ret = mutex_lock_interruptible(&dev->mode_config.mutex); - if (unlikely(ret != 0)) { - ret = -ERESTARTSYS; - goto out_no_mode_mutex; - } - - obj = drm_mode_object_find(dev, arg->fb_id, DRM_MODE_OBJECT_FB); - if (!obj) { - DRM_ERROR("Invalid framebuffer id.\n"); - ret = -EINVAL; - goto out_no_fb; - } - vfb = vmw_framebuffer_to_vfb(obj_to_fb(obj)); - - ret = ttm_read_lock(&vmaster->lock, true); - if (unlikely(ret != 0)) - goto out_no_ttm_lock; - - ret = vmw_user_surface_lookup_handle(dev_priv, tfile, arg->sid, - &surface); - if (ret) - goto out_no_surface; - - ret = vmw_kms_present(dev_priv, file_priv, - vfb, surface, arg->sid, - arg->dest_x, arg->dest_y, - clips, num_clips); - - /* vmw_user_surface_lookup takes one ref so does new_fb */ - vmw_surface_unreference(&surface); -out_no_surface: - ttm_read_unlock(&vmaster->lock); -out_no_ttm_lock: -out_no_fb: - mutex_unlock(&dev->mode_config.mutex); -out_no_mode_mutex: -out_no_copy: - kfree(clips); -out_clips: - return ret; -} - -int vmw_present_readback_ioctl(struct drm_device *dev, void *data, - struct drm_file *file_priv) -{ - struct vmw_private *dev_priv = vmw_priv(dev); - struct drm_vmw_present_readback_arg *arg = - (struct drm_vmw_present_readback_arg *)data; - struct drm_vmw_fence_rep __user *user_fence_rep = - (struct drm_vmw_fence_rep __user *) - (unsigned long)arg->fence_rep; - struct vmw_master *vmaster = vmw_master(file_priv->master); - struct drm_vmw_rect __user *clips_ptr; - struct drm_vmw_rect *clips = NULL; - struct drm_mode_object *obj; - struct vmw_framebuffer *vfb; - uint32_t num_clips; - int ret; - - num_clips = arg->num_clips; - clips_ptr = (struct drm_vmw_rect *)(unsigned long)arg->clips_ptr; - - if (unlikely(num_clips == 0)) - return 0; - - if (clips_ptr == NULL) { - DRM_ERROR("Argument clips_ptr must be specified.\n"); - ret = -EINVAL; - goto out_clips; - } - - clips = kcalloc(num_clips, sizeof(*clips), GFP_KERNEL); - if (clips == NULL) { - DRM_ERROR("Failed to allocate clip rect list.\n"); - ret = -ENOMEM; - goto out_clips; - } - - ret = copy_from_user(clips, clips_ptr, num_clips * sizeof(*clips)); - if (ret) { - DRM_ERROR("Failed to copy clip rects from userspace.\n"); - ret = -EFAULT; - goto out_no_copy; - } - - ret = mutex_lock_interruptible(&dev->mode_config.mutex); - if (unlikely(ret != 0)) { - ret = -ERESTARTSYS; - goto out_no_mode_mutex; - } - - obj = drm_mode_object_find(dev, arg->fb_id, DRM_MODE_OBJECT_FB); - if (!obj) { - DRM_ERROR("Invalid framebuffer id.\n"); - ret = -EINVAL; - goto out_no_fb; - } - - vfb = vmw_framebuffer_to_vfb(obj_to_fb(obj)); - if (!vfb->dmabuf) { - DRM_ERROR("Framebuffer not dmabuf backed.\n"); - ret = -EINVAL; - goto out_no_fb; + if (arg->debug_buffer_size < fifo_state->last_data_size) { + arg->used_size = arg->debug_buffer_size; + arg->did_not_fit = 1; + } else { + arg->used_size = fifo_state->last_data_size; + arg->did_not_fit = 0; } - - ret = ttm_read_lock(&vmaster->lock, true); - if (unlikely(ret != 0)) - goto out_no_ttm_lock; - - ret = vmw_kms_readback(dev_priv, file_priv, - vfb, user_fence_rep, - clips, num_clips); - - ttm_read_unlock(&vmaster->lock); -out_no_ttm_lock: -out_no_fb: - mutex_unlock(&dev->mode_config.mutex); -out_no_mode_mutex: -out_no_copy: - kfree(clips); -out_clips: - return ret; -} - - -/** - * vmw_fops_poll - wrapper around the drm_poll function - * - * @filp: See the linux fops poll documentation. - * @wait: See the linux fops poll documentation. - * - * Wrapper around the drm_poll function that makes sure the device is - * processing the fifo if drm_poll decides to wait. - */ -unsigned int vmw_fops_poll(struct file *filp, struct poll_table_struct *wait) -{ - struct drm_file *file_priv = filp->private_data; - struct vmw_private *dev_priv = - vmw_priv(file_priv->minor->dev); - - vmw_fifo_ping_host(dev_priv, SVGA_SYNC_GENERIC); - return drm_poll(filp, wait); -} - - -/** - * vmw_fops_read - wrapper around the drm_read function - * - * @filp: See the linux fops read documentation. - * @buffer: See the linux fops read documentation. - * @count: See the linux fops read documentation. - * offset: See the linux fops read documentation. - * - * Wrapper around the drm_read function that makes sure the device is - * processing the fifo if drm_read decides to wait. - */ -ssize_t vmw_fops_read(struct file *filp, char __user *buffer, - size_t count, loff_t *offset) -{ - struct drm_file *file_priv = filp->private_data; - struct vmw_private *dev_priv = - vmw_priv(file_priv->minor->dev); - - vmw_fifo_ping_host(dev_priv, SVGA_SYNC_GENERIC); - return drm_read(filp, buffer, count, offset); + return copy_to_user(buffer, fifo_state->last_buffer, arg->used_size); } |