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