summaryrefslogtreecommitdiff
path: root/vmwgfx_kms.c
diff options
context:
space:
mode:
authorThomas Hellstrom <thellstrom@vmware.com>2017-03-23 11:37:51 +0100
committerThomas Hellstrom <thellstrom@vmware.com>2017-03-27 10:41:36 +0200
commite6d4e6afab55b2554c5aa8a33bc9270b92116dc7 (patch)
tree4f8200dfc50d8292375fadd5936751d34b2db249 /vmwgfx_kms.c
parente69062e1a6d27aba62ce0bd58d191745a7d32a7a (diff)
vmwgfx: Strip legacy cursor code
Use the atomic code only. Also clean up the locking by taking a spinlock around the position update. Signed-off-by: Thomas Hellstrom <thellstrom@vmware.com> Reviewed-by: Sinclair yeh <syeh@vmware.com>
Diffstat (limited to 'vmwgfx_kms.c')
-rw-r--r--vmwgfx_kms.c164
1 files changed, 13 insertions, 151 deletions
diff --git a/vmwgfx_kms.c b/vmwgfx_kms.c
index 2da0ac3..c9c2bfa 100644
--- a/vmwgfx_kms.c
+++ b/vmwgfx_kms.c
@@ -59,9 +59,9 @@ void vmw_du_cleanup(struct vmw_display_unit *du)
* Display Unit Cursor functions
*/
-int vmw_cursor_update_image(struct vmw_private *dev_priv,
- u32 *image, u32 width, u32 height,
- u32 hotspotX, u32 hotspotY)
+static int vmw_cursor_update_image(struct vmw_private *dev_priv,
+ u32 *image, u32 width, u32 height,
+ u32 hotspotX, u32 hotspotY)
{
struct {
u32 cmd;
@@ -95,10 +95,10 @@ int vmw_cursor_update_image(struct vmw_private *dev_priv,
return 0;
}
-int vmw_cursor_update_dmabuf(struct vmw_private *dev_priv,
- struct vmw_dma_buffer *dmabuf,
- u32 width, u32 height,
- u32 hotspotX, u32 hotspotY)
+static int vmw_cursor_update_dmabuf(struct vmw_private *dev_priv,
+ struct vmw_dma_buffer *dmabuf,
+ u32 width, u32 height,
+ u32 hotspotX, u32 hotspotY)
{
struct ttm_bo_kmap_obj map;
unsigned long kmap_offset;
@@ -132,145 +132,22 @@ err_unreserve:
}
-void vmw_cursor_update_position(struct vmw_private *dev_priv,
- bool show, int x, int y)
+static void vmw_cursor_update_position(struct vmw_private *dev_priv,
+ bool show, int x, int y)
{
u32 *fifo_mem = dev_priv->mmio_virt;
uint32_t count;
+ spin_lock(&dev_priv->cursor_lock);
vmw_mmio_write(show ? 1 : 0, fifo_mem + SVGA_FIFO_CURSOR_ON);
vmw_mmio_write(x, fifo_mem + SVGA_FIFO_CURSOR_X);
vmw_mmio_write(y, fifo_mem + SVGA_FIFO_CURSOR_Y);
count = vmw_mmio_read(fifo_mem + SVGA_FIFO_CURSOR_COUNT);
vmw_mmio_write(++count, fifo_mem + SVGA_FIFO_CURSOR_COUNT);
+ spin_unlock(&dev_priv->cursor_lock);
}
-/*
- * vmw_du_crtc_cursor_set2 - Driver cursor_set2 callback.
- */
-int vmw_du_crtc_cursor_set2(struct drm_crtc *crtc, struct drm_file *file_priv,
- uint32_t handle, uint32_t width, uint32_t height,
- int32_t hot_x, int32_t hot_y)
-{
- struct vmw_private *dev_priv = vmw_priv(crtc->dev);
- struct vmw_display_unit *du = vmw_crtc_to_du(crtc);
- struct vmw_surface *surface = NULL;
- struct vmw_dma_buffer *dmabuf = NULL;
- s32 hotspot_x, hotspot_y;
- int ret;
-
- /*
- * FIXME: Unclear whether there's any global state touched by the
- * cursor_set function, especially vmw_cursor_update_position looks
- * suspicious. For now take the easy route and reacquire all locks. We
- * can do this since the caller in the drm core doesn't check anything
- * which is protected by any looks.
- */
- drm_modeset_unlock_crtc(crtc);
- drm_modeset_lock_all(dev_priv->dev);
- hotspot_x = hot_x + du->hotspot_x;
- hotspot_y = hot_y + du->hotspot_y;
-
- /* A lot of the code assumes this */
- if (handle && (width != 64 || height != 64)) {
- ret = -EINVAL;
- goto out;
- }
-
- if (handle) {
- struct ttm_object_file *tfile = vmw_fpriv(file_priv)->tfile;
-
- ret = vmw_user_lookup_handle(dev_priv, tfile,
- handle, &surface, &dmabuf);
- if (ret) {
- DRM_ERROR("failed to find surface or dmabuf: %i\n", ret);
- ret = -EINVAL;
- goto out;
- }
- }
-
- /* need to do this before taking down old image */
- if (surface && !surface->snooper.image) {
- DRM_ERROR("surface not suitable for cursor\n");
- vmw_surface_unreference(&surface);
- ret = -EINVAL;
- goto out;
- }
-
- /* takedown old cursor */
- if (du->cursor_surface) {
- vmw_surface_unreference(&du->cursor_surface);
- }
- if (du->cursor_dmabuf)
- vmw_dmabuf_unreference(&du->cursor_dmabuf);
-
- /* setup new image */
- ret = 0;
- if (surface) {
- /* vmw_user_surface_lookup takes one reference */
- du->cursor_surface = surface;
-
- du->cursor_age = du->cursor_surface->snooper.age;
- ret = vmw_cursor_update_image(dev_priv, surface->snooper.image,
- 64, 64, hotspot_x, hotspot_y);
- } else if (dmabuf) {
- /* vmw_user_surface_lookup takes one reference */
- du->cursor_dmabuf = dmabuf;
-
- ret = vmw_cursor_update_dmabuf(dev_priv, dmabuf, width, height,
- hotspot_x, hotspot_y);
- } else {
- vmw_cursor_update_position(dev_priv, false, 0, 0);
- goto out;
- }
-
- if (!ret) {
- vmw_cursor_update_position(dev_priv, true,
- du->cursor_x + hotspot_x,
- du->cursor_y + hotspot_y);
- du->core_hotspot_x = hot_x;
- du->core_hotspot_y = hot_y;
- }
-
-out:
- drm_modeset_unlock_all(dev_priv->dev);
- drm_modeset_lock_crtc(crtc, crtc->cursor);
-
- return ret;
-}
-
-int vmw_du_crtc_cursor_move(struct drm_crtc *crtc, int x, int y)
-{
- struct vmw_private *dev_priv = vmw_priv(crtc->dev);
- struct vmw_display_unit *du = vmw_crtc_to_du(crtc);
- bool shown = du->cursor_surface || du->cursor_dmabuf ? true : false;
-
- du->cursor_x = x + du->set_gui_x;
- du->cursor_y = y + du->set_gui_y;
-
- /*
- * FIXME: Unclear whether there's any global state touched by the
- * cursor_set function, especially vmw_cursor_update_position looks
- * suspicious. For now take the easy route and reacquire all locks. We
- * can do this since the caller in the drm core doesn't check anything
- * which is protected by any looks.
- */
- drm_modeset_unlock_crtc(crtc);
- drm_modeset_lock_all(dev_priv->dev);
-
- vmw_cursor_update_position(dev_priv, shown,
- du->cursor_x + du->hotspot_x +
- du->core_hotspot_x,
- du->cursor_y + du->hotspot_y +
- du->core_hotspot_y);
-
- drm_modeset_unlock_all(dev_priv->dev);
- drm_modeset_lock_crtc(crtc, crtc->cursor);
-
- return 0;
-}
-
void vmw_kms_cursor_snoop(struct vmw_surface *srf,
struct ttm_object_file *tfile,
struct ttm_buffer_object *bo,
@@ -422,9 +299,6 @@ void vmw_kms_cursor_post_execbuf(struct vmw_private *dev_priv)
* @src_w: Not used
* @src_h: Not used
*
- * This function currently does not support hotspot from the legacy
- * cursor_set2 API because hot_x and hot_y fields have not been
- * added to drm_framebuffer.
*
* RETURNS:
* Zero on success, error code on failure
@@ -445,17 +319,8 @@ int vmw_du_cursor_plane_update(struct drm_plane *plane,
s32 hotspot_x, hotspot_y;
int ret;
- /*
- * FIXME: Unclear whether there's any global state touched by the
- * cursor_set function, especially vmw_cursor_update_position looks
- * suspicious. For now take the easy route and reacquire all locks. We
- * can do this since the caller in the drm core doesn't check anything
- * which is protected by any locks.
- */
- drm_modeset_unlock_crtc(crtc);
- drm_modeset_lock_all(dev_priv->dev);
- hotspot_x = du->hotspot_x;
- hotspot_y = du->hotspot_y;
+ hotspot_x = du->hotspot_x + fb->hot_x;
+ hotspot_y = du->hotspot_y + fb->hot_y;
/* A lot of the code assumes this */
if (crtc_w != 64 || crtc_h != 64) {
@@ -505,9 +370,6 @@ int vmw_du_cursor_plane_update(struct drm_plane *plane,
}
out:
- drm_modeset_unlock_all(dev_priv->dev);
- drm_modeset_lock_crtc(crtc, crtc->cursor);
-
return ret;
}