diff options
author | Jakob Bornecrantz <jakob@vmware.com> | 2011-11-28 07:19:10 -0500 |
---|---|---|
committer | Dave Airlie <airlied@redhat.com> | 2011-12-19 09:06:02 -0500 |
commit | 6a91d97e02d7efde955c25a5b0fbf950cd2a6efa (patch) | |
tree | 91f51a8bcc64a160e98a703a9a73b6167dde4386 /drivers | |
parent | ef5ab24bd3373941bd27e371512c0009eb11581c (diff) |
vmwgfx: Refactor cursor update
Signed-off-by: Jakob Bornecrantz <jakob@vmware.com>
Reviewed-by: Thomas Hellstrom <thellstrom@vmware.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/gpu/drm/vmwgfx/vmwgfx_kms.c | 66 |
1 files changed, 39 insertions, 27 deletions
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c b/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c index 37d40545ed77..bee671624a98 100644 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c | |||
@@ -82,6 +82,43 @@ int vmw_cursor_update_image(struct vmw_private *dev_priv, | |||
82 | return 0; | 82 | return 0; |
83 | } | 83 | } |
84 | 84 | ||
85 | int vmw_cursor_update_dmabuf(struct vmw_private *dev_priv, | ||
86 | struct vmw_dma_buffer *dmabuf, | ||
87 | u32 width, u32 height, | ||
88 | u32 hotspotX, u32 hotspotY) | ||
89 | { | ||
90 | struct ttm_bo_kmap_obj map; | ||
91 | unsigned long kmap_offset; | ||
92 | unsigned long kmap_num; | ||
93 | void *virtual; | ||
94 | bool dummy; | ||
95 | int ret; | ||
96 | |||
97 | kmap_offset = 0; | ||
98 | kmap_num = (width*height*4 + PAGE_SIZE - 1) >> PAGE_SHIFT; | ||
99 | |||
100 | ret = ttm_bo_reserve(&dmabuf->base, true, false, false, 0); | ||
101 | if (unlikely(ret != 0)) { | ||
102 | DRM_ERROR("reserve failed\n"); | ||
103 | return -EINVAL; | ||
104 | } | ||
105 | |||
106 | ret = ttm_bo_kmap(&dmabuf->base, kmap_offset, kmap_num, &map); | ||
107 | if (unlikely(ret != 0)) | ||
108 | goto err_unreserve; | ||
109 | |||
110 | virtual = ttm_kmap_obj_virtual(&map, &dummy); | ||
111 | ret = vmw_cursor_update_image(dev_priv, virtual, width, height, | ||
112 | hotspotX, hotspotY); | ||
113 | |||
114 | ttm_bo_kunmap(&map); | ||
115 | err_unreserve: | ||
116 | ttm_bo_unreserve(&dmabuf->base); | ||
117 | |||
118 | return ret; | ||
119 | } | ||
120 | |||
121 | |||
85 | void vmw_cursor_update_position(struct vmw_private *dev_priv, | 122 | void vmw_cursor_update_position(struct vmw_private *dev_priv, |
86 | bool show, int x, int y) | 123 | bool show, int x, int y) |
87 | { | 124 | { |
@@ -146,36 +183,11 @@ int vmw_du_crtc_cursor_set(struct drm_crtc *crtc, struct drm_file *file_priv, | |||
146 | vmw_cursor_update_image(dev_priv, surface->snooper.image, | 183 | vmw_cursor_update_image(dev_priv, surface->snooper.image, |
147 | 64, 64, du->hotspot_x, du->hotspot_y); | 184 | 64, 64, du->hotspot_x, du->hotspot_y); |
148 | } else if (dmabuf) { | 185 | } else if (dmabuf) { |
149 | struct ttm_bo_kmap_obj map; | ||
150 | unsigned long kmap_offset; | ||
151 | unsigned long kmap_num; | ||
152 | void *virtual; | ||
153 | bool dummy; | ||
154 | |||
155 | /* vmw_user_surface_lookup takes one reference */ | 186 | /* vmw_user_surface_lookup takes one reference */ |
156 | du->cursor_dmabuf = dmabuf; | 187 | du->cursor_dmabuf = dmabuf; |
157 | 188 | ||
158 | kmap_offset = 0; | 189 | ret = vmw_cursor_update_dmabuf(dev_priv, dmabuf, width, height, |
159 | kmap_num = (64*64*4) >> PAGE_SHIFT; | 190 | du->hotspot_x, du->hotspot_y); |
160 | |||
161 | ret = ttm_bo_reserve(&dmabuf->base, true, false, false, 0); | ||
162 | if (unlikely(ret != 0)) { | ||
163 | DRM_ERROR("reserve failed\n"); | ||
164 | return -EINVAL; | ||
165 | } | ||
166 | |||
167 | ret = ttm_bo_kmap(&dmabuf->base, kmap_offset, kmap_num, &map); | ||
168 | if (unlikely(ret != 0)) | ||
169 | goto err_unreserve; | ||
170 | |||
171 | virtual = ttm_kmap_obj_virtual(&map, &dummy); | ||
172 | vmw_cursor_update_image(dev_priv, virtual, 64, 64, | ||
173 | du->hotspot_x, du->hotspot_y); | ||
174 | |||
175 | ttm_bo_kunmap(&map); | ||
176 | err_unreserve: | ||
177 | ttm_bo_unreserve(&dmabuf->base); | ||
178 | |||
179 | } else { | 191 | } else { |
180 | vmw_cursor_update_position(dev_priv, false, 0, 0); | 192 | vmw_cursor_update_position(dev_priv, false, 0, 0); |
181 | return 0; | 193 | return 0; |