vmware/core: Update vmwgfx_drm.h
[mesa.git] / src / gallium / winsys / drm / vmware / core / vmwgfx_drm.h
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 #ifndef _VMWGFX_DRM_H_
29 #define _VMWGFX_DRM_H_
30
31 #define DRM_VMW_MAX_SURFACE_FACES 6
32 #define DRM_VMW_MAX_MIP_LEVELS 24
33
34 #define DRM_VMW_EXT_NAME_LEN 128
35
36 #define DRM_VMW_GET_PARAM 1
37 #define DRM_VMW_EXTENSION 2
38 #define DRM_VMW_CREATE_CONTEXT 3
39 #define DRM_VMW_UNREF_CONTEXT 4
40 #define DRM_VMW_CREATE_SURFACE 5
41 #define DRM_VMW_UNREF_SURFACE 6
42 #define DRM_VMW_REF_SURFACE 7
43 #define DRM_VMW_EXECBUF 8
44 #define DRM_VMW_ALLOC_DMABUF 9
45 #define DRM_VMW_UNREF_DMABUF 10
46 #define DRM_VMW_FIFO_DEBUG 11
47 #define DRM_VMW_FENCE_WAIT 12
48 #define DRM_VMW_OVERLAY 13
49 #define DRM_VMW_CURSOR_BYPASS 14
50
51 /*************************************************************************/
52 /**
53 * DRM_VMW_GET_PARAM - get device information.
54 *
55 * DRM_VMW_PARAM_FIFO_OFFSET:
56 * Offset to use to map the first page of the FIFO read-only.
57 * The fifo is mapped using the mmap() system call on the drm device.
58 *
59 * DRM_VMW_PARAM_OVERLAY_IOCTL:
60 * Does the driver support the overlay ioctl.
61 */
62
63 #define DRM_VMW_PARAM_FIFO_OFFSET 0
64 #define DRM_VMW_PARAM_OVERLAY_IOCTL 1
65
66 /**
67 * struct drm_vmw_getparam_arg
68 *
69 * @value: Returned value. //Out
70 * @param: Parameter to query. //In.
71 *
72 * Argument to the DRM_VMW_GET_PARAM Ioctl.
73 */
74
75 struct drm_vmw_getparam_arg {
76 uint64_t value;
77 uint32_t param;
78 uint32_t pad64;
79 };
80
81 /*************************************************************************/
82 /**
83 * DRM_VMW_EXTENSION - Query device extensions.
84 */
85
86 /**
87 * struct drm_vmw_extension_rep
88 *
89 * @exists: The queried extension exists.
90 * @driver_ioctl_offset: Ioctl number of the first ioctl in the extension.
91 * @driver_sarea_offset: Offset to any space in the DRI SAREA
92 * used by the extension.
93 * @major: Major version number of the extension.
94 * @minor: Minor version number of the extension.
95 * @pl: Patch level version number of the extension.
96 *
97 * Output argument to the DRM_VMW_EXTENSION Ioctl.
98 */
99
100 struct drm_vmw_extension_rep {
101 int32_t exists;
102 uint32_t driver_ioctl_offset;
103 uint32_t driver_sarea_offset;
104 uint32_t major;
105 uint32_t minor;
106 uint32_t pl;
107 uint32_t pad64;
108 };
109
110 /**
111 * union drm_vmw_extension_arg
112 *
113 * @extension - Ascii name of the extension to be queried. //In
114 * @rep - Reply as defined above. //Out
115 *
116 * Argument to the DRM_VMW_EXTENSION Ioctl.
117 */
118
119 union drm_vmw_extension_arg {
120 char extension[DRM_VMW_EXT_NAME_LEN];
121 struct drm_vmw_extension_rep rep;
122 };
123
124 /*************************************************************************/
125 /**
126 * DRM_VMW_CREATE_CONTEXT - Create a host context.
127 *
128 * Allocates a device unique context id, and queues a create context command
129 * for the host. Does not wait for host completion.
130 */
131
132 /**
133 * struct drm_vmw_context_arg
134 *
135 * @cid: Device unique context ID.
136 *
137 * Output argument to the DRM_VMW_CREATE_CONTEXT Ioctl.
138 * Input argument to the DRM_VMW_UNREF_CONTEXT Ioctl.
139 */
140
141 struct drm_vmw_context_arg {
142 int32_t cid;
143 uint32_t pad64;
144 };
145
146 /*************************************************************************/
147 /**
148 * DRM_VMW_UNREF_CONTEXT - Create a host context.
149 *
150 * Frees a global context id, and queues a destroy host command for the host.
151 * Does not wait for host completion. The context ID can be used directly
152 * in the command stream and shows up as the same context ID on the host.
153 */
154
155 /*************************************************************************/
156 /**
157 * DRM_VMW_CREATE_SURFACE - Create a host suface.
158 *
159 * Allocates a device unique surface id, and queues a create surface command
160 * for the host. Does not wait for host completion. The surface ID can be
161 * used directly in the command stream and shows up as the same surface
162 * ID on the host.
163 */
164
165 /**
166 * struct drm_wmv_surface_create_req
167 *
168 * @flags: Surface flags as understood by the host.
169 * @format: Surface format as understood by the host.
170 * @mip_levels: Number of mip levels for each face.
171 * An unused face should have 0 encoded.
172 * @size_addr: Address of a user-space array of sruct drm_vmw_size
173 * cast to an uint64_t for 32-64 bit compatibility.
174 * The size of the array should equal the total number of mipmap levels.
175 * @shareable: Boolean whether other clients (as identified by file descriptors)
176 * may reference this surface.
177 *
178 * Input data to the DRM_VMW_CREATE_SURFACE Ioctl.
179 * Output data from the DRM_VMW_REF_SURFACE Ioctl.
180 */
181
182 struct drm_vmw_surface_create_req {
183 uint32_t flags;
184 uint32_t format;
185 uint32_t mip_levels[DRM_VMW_MAX_SURFACE_FACES];
186 uint64_t size_addr;
187 int32_t shareable;
188 uint32_t pad64;
189 };
190
191 /**
192 * struct drm_wmv_surface_arg
193 *
194 * @sid: Surface id of created surface or surface to destroy or reference.
195 *
196 * Output data from the DRM_VMW_CREATE_SURFACE Ioctl.
197 * Input argument to the DRM_VMW_UNREF_SURFACE Ioctl.
198 * Input argument to the DRM_VMW_REF_SURFACE Ioctl.
199 */
200
201 struct drm_vmw_surface_arg {
202 int32_t sid;
203 uint32_t pad64;
204 };
205
206 /**
207 * struct drm_vmw_size ioctl.
208 *
209 * @width - mip level width
210 * @height - mip level height
211 * @depth - mip level depth
212 *
213 * Description of a mip level.
214 * Input data to the DRM_WMW_CREATE_SURFACE Ioctl.
215 */
216
217 struct drm_vmw_size {
218 uint32_t width;
219 uint32_t height;
220 uint32_t depth;
221 uint32_t pad64;
222 };
223
224 /**
225 * union drm_vmw_surface_create_arg
226 *
227 * @rep: Output data as described above.
228 * @req: Input data as described above.
229 *
230 * Argument to the DRM_VMW_CREATE_SURFACE Ioctl.
231 */
232
233 union drm_vmw_surface_create_arg {
234 struct drm_vmw_surface_arg rep;
235 struct drm_vmw_surface_create_req req;
236 };
237
238 /*************************************************************************/
239 /**
240 * DRM_VMW_REF_SURFACE - Reference a host surface.
241 *
242 * Puts a reference on a host surface with a give sid, as previously
243 * returned by the DRM_VMW_CREATE_SURFACE ioctl.
244 * A reference will make sure the surface isn't destroyed while we hold
245 * it and will allow the calling client to use the surface ID in the command
246 * stream.
247 *
248 * On successful return, the Ioctl returns the surface information given
249 * in the DRM_VMW_CREATE_SURFACE ioctl.
250 */
251
252 /**
253 * union drm_vmw_surface_reference_arg
254 *
255 * @rep: Output data as described above.
256 * @req: Input data as described above.
257 *
258 * Argument to the DRM_VMW_REF_SURFACE Ioctl.
259 */
260
261 union drm_vmw_surface_reference_arg {
262 struct drm_vmw_surface_create_req rep;
263 struct drm_vmw_surface_arg req;
264 };
265
266 /*************************************************************************/
267 /**
268 * DRM_VMW_UNREF_SURFACE - Unreference a host surface.
269 *
270 * Clear a reference previously put on a host surface.
271 * When all references are gone, including the one implicitly placed
272 * on creation,
273 * a destroy surface command will be queued for the host.
274 * Does not wait for completion.
275 */
276
277 /*************************************************************************/
278 /**
279 * DRM_VMW_EXECBUF
280 *
281 * Submit a command buffer for execution on the host, and return a
282 * fence sequence that when signaled, indicates that the command buffer has
283 * executed.
284 */
285
286 /**
287 * struct drm_vmw_execbuf_arg
288 *
289 * @commands: User-space address of a command buffer cast to an uint64_t.
290 * @command-size: Size in bytes of the command buffer.
291 * @fence_rep: User-space address of a struct drm_vmw_fence_rep cast to an
292 * uint64_t.
293 *
294 * Argument to the DRM_VMW_EXECBUF Ioctl.
295 */
296
297 struct drm_vmw_execbuf_arg {
298 uint64_t commands;
299 uint32_t command_size;
300 uint32_t pad64;
301 uint64_t fence_rep;
302 };
303
304 /**
305 * struct drm_vmw_fence_rep
306 *
307 * @fence_seq: Fence sequence associated with a command submission.
308 * @error: This member should've been set to -EFAULT on submission.
309 * The following actions should be take on completion:
310 * error == -EFAULT: Fence communication failed. The host is synchronized.
311 * Use the last fence id read from the FIFO fence register.
312 * error != 0 && error != -EFAULT:
313 * Fence submission failed. The host is synchronized. Use the fence_seq member.
314 * error == 0: All is OK, The host may not be synchronized.
315 * Use the fence_seq member.
316 *
317 * Input / Output data to the DRM_VMW_EXECBUF Ioctl.
318 */
319
320 struct drm_vmw_fence_rep {
321 uint64_t fence_seq;
322 int32_t error;
323 uint32_t pad64;
324 };
325
326 /*************************************************************************/
327 /**
328 * DRM_VMW_ALLOC_DMABUF
329 *
330 * Allocate a DMA buffer that is visible also to the host.
331 * NOTE: The buffer is
332 * identified by a handle and an offset, which are private to the guest, but
333 * useable in the command stream. The guest kernel may translate these
334 * and patch up the command stream accordingly. In the future, the offset may
335 * be zero at all times, or it may disappear from the interface before it is
336 * fixed.
337 *
338 * The DMA buffer may stay user-space mapped in the guest at all times,
339 * and is thus suitable for sub-allocation.
340 *
341 * DMA buffers are mapped using the mmap() syscall on the drm device.
342 */
343
344 /**
345 * struct drm_vmw_alloc_dmabuf_req
346 *
347 * @size: Required minimum size of the buffer.
348 *
349 * Input data to the DRM_VMW_ALLOC_DMABUF Ioctl.
350 */
351
352 struct drm_vmw_alloc_dmabuf_req {
353 uint32_t size;
354 uint32_t pad64;
355 };
356
357 /**
358 * struct drm_vmw_dmabuf_rep
359 *
360 * @map_handle: Offset to use in the mmap() call used to map the buffer.
361 * @handle: Handle unique to this buffer. Used for unreferencing.
362 * @cur_gmr_id: GMR id to use in the command stream when this buffer is
363 * referenced. See not above.
364 * @cur_gmr_offset: Offset to use in the command stream when this buffer is
365 * referenced. See note above.
366 *
367 * Output data from the DRM_VMW_ALLOC_DMABUF Ioctl.
368 */
369
370 struct drm_vmw_dmabuf_rep {
371 uint64_t map_handle;
372 uint32_t handle;
373 uint32_t cur_gmr_id;
374 uint32_t cur_gmr_offset;
375 uint32_t pad64;
376 };
377
378 /**
379 * union drm_vmw_dmabuf_arg
380 *
381 * @req: Input data as described above.
382 * @rep: Output data as described above.
383 *
384 * Argument to the DRM_VMW_ALLOC_DMABUF Ioctl.
385 */
386
387 union drm_vmw_alloc_dmabuf_arg {
388 struct drm_vmw_alloc_dmabuf_req req;
389 struct drm_vmw_dmabuf_rep rep;
390 };
391
392 /*************************************************************************/
393 /**
394 * DRM_VMW_UNREF_DMABUF - Free a DMA buffer.
395 *
396 */
397
398 /**
399 * struct drm_vmw_unref_dmabuf_arg
400 *
401 * @handle: Handle indicating what buffer to free. Obtained from the
402 * DRM_VMW_ALLOC_DMABUF Ioctl.
403 *
404 * Argument to the DRM_VMW_UNREF_DMABUF Ioctl.
405 */
406
407 struct drm_vmw_unref_dmabuf_arg {
408 uint32_t handle;
409 uint32_t pad64;
410 };
411
412 /*************************************************************************/
413 /**
414 * DRM_VMW_FIFO_DEBUG - Get last FIFO submission.
415 *
416 * This IOCTL copies the last FIFO submission directly out of the FIFO buffer.
417 */
418
419 /**
420 * struct drm_vmw_fifo_debug_arg
421 *
422 * @debug_buffer: User space address of a debug_buffer cast to an uint64_t //In
423 * @debug_buffer_size: Size in bytes of debug buffer //In
424 * @used_size: Number of bytes copied to the buffer // Out
425 * @did_not_fit: Boolean indicating that the fifo contents did not fit. //Out
426 *
427 * Argument to the DRM_VMW_FIFO_DEBUG Ioctl.
428 */
429
430 struct drm_vmw_fifo_debug_arg {
431 uint64_t debug_buffer;
432 uint32_t debug_buffer_size;
433 uint32_t used_size;
434 int32_t did_not_fit;
435 uint32_t pad64;
436 };
437
438 struct drm_vmw_fence_wait_arg {
439 uint64_t sequence;
440 uint64_t kernel_cookie;
441 int32_t cookie_valid;
442 int32_t pad64;
443 };
444
445 /*************************************************************************/
446 /**
447 * DRM_VMW_OVERLAY - Control overlays.
448 *
449 * This IOCTL controls the overlay units of the svga device.
450 * The SVGA overlay units does not work like regular hardware units in
451 * that they do not automaticaly read back the contents of the given dma
452 * buffer. But instead only read back for each call to this ioctl, and
453 * at any point between this call being made and a following call that
454 * either changes the buffer or disables the stream.
455 */
456
457 /**
458 * struct drm_vmw_rect
459 *
460 * Defines a rectangle. Used in the overlay ioctl to define
461 * source and destination rectangle.
462 */
463
464 struct drm_vmw_rect {
465 int32_t x;
466 int32_t y;
467 uint32_t w;
468 uint32_t h;
469 };
470
471 /**
472 * struct drm_vmw_overlay_arg
473 *
474 * @stream_id: Stearm to control
475 * @enabled: If false all following arguments are ignored.
476 * @handle: Handle to buffer for getting data from.
477 * @format: Format of the overlay as understood by the host.
478 * @width: Width of the overlay.
479 * @height: Height of the overlay.
480 * @size: Size of the overlay in bytes.
481 * @pitch: Array of pitches, the two last are only used for YUV12 formats.
482 * @offset: Offset from start of dma buffer to overlay.
483 * @src: Source rect, must be within the defined area above.
484 * @dst: Destination rect, x and y may be negative.
485 *
486 * Argument to the DRM_VMW_OVERLAY Ioctl.
487 */
488
489 struct drm_vmw_overlay_arg {
490 uint32_t stream_id;
491 uint32_t enabled;
492
493 uint32_t flags;
494 uint32_t color_key;
495
496 uint32_t handle;
497 uint32_t offset;
498 int32_t format;
499 uint32_t size;
500 uint32_t width;
501 uint32_t height;
502 uint32_t pitch[3];
503
504 uint32_t pad64;
505 struct drm_vmw_rect src;
506 struct drm_vmw_rect dst;
507 };
508
509 /*************************************************************************/
510 /**
511 * DRM_VMW_CURSOR_BYPASS - Give extra information about cursor bypass.
512 *
513 */
514
515 #define DRM_VMW_CURSOR_BYPASS_ALL (1 << 0)
516 #define DRM_VMW_CURSOR_BYPASS_FLAGS (1)
517
518 /**
519 * struct drm_vmw_cursor_bypass_arg
520 *
521 * @flags: Flags.
522 * @crtc_id: Crtc id, only used if DMR_CURSOR_BYPASS_ALL isn't passed.
523 * @xpos: X position of cursor.
524 * @ypos: Y position of cursor.
525 * @xhot: X hotspot.
526 * @yhot: Y hotspot.
527 *
528 * Argument to the DRM_VMW_CURSOR_BYPASS Ioctl.
529 */
530
531 struct drm_vmw_cursor_bypass_arg {
532 uint32_t flags;
533 uint32_t crtc_id;
534 int32_t xpos;
535 int32_t ypos;
536 int32_t xhot;
537 int32_t yhot;
538 };
539
540 #endif