c8a86318017446918d54380900b28c9d60df8eb0
[linux-2.6-block.git] / include / uapi / drm / 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 #ifndef __KERNEL__
32 #include <drm/drm.h>
33 #endif
34
35 #define DRM_VMW_MAX_SURFACE_FACES 6
36 #define DRM_VMW_MAX_MIP_LEVELS 24
37
38
39 #define DRM_VMW_GET_PARAM            0
40 #define DRM_VMW_ALLOC_DMABUF         1
41 #define DRM_VMW_UNREF_DMABUF         2
42 #define DRM_VMW_CURSOR_BYPASS        3
43 /* guarded by DRM_VMW_PARAM_NUM_STREAMS != 0*/
44 #define DRM_VMW_CONTROL_STREAM       4
45 #define DRM_VMW_CLAIM_STREAM         5
46 #define DRM_VMW_UNREF_STREAM         6
47 /* guarded by DRM_VMW_PARAM_3D == 1 */
48 #define DRM_VMW_CREATE_CONTEXT       7
49 #define DRM_VMW_UNREF_CONTEXT        8
50 #define DRM_VMW_CREATE_SURFACE       9
51 #define DRM_VMW_UNREF_SURFACE        10
52 #define DRM_VMW_REF_SURFACE          11
53 #define DRM_VMW_EXECBUF              12
54 #define DRM_VMW_GET_3D_CAP           13
55 #define DRM_VMW_FENCE_WAIT           14
56 #define DRM_VMW_FENCE_SIGNALED       15
57 #define DRM_VMW_FENCE_UNREF          16
58 #define DRM_VMW_FENCE_EVENT          17
59 #define DRM_VMW_PRESENT              18
60 #define DRM_VMW_PRESENT_READBACK     19
61 #define DRM_VMW_UPDATE_LAYOUT        20
62 #define DRM_VMW_CREATE_SHADER        21
63 #define DRM_VMW_UNREF_SHADER         22
64 #define DRM_VMW_GB_SURFACE_CREATE    23
65 #define DRM_VMW_GB_SURFACE_REF       24
66 #define DRM_VMW_SYNCCPU              25
67
68 /*************************************************************************/
69 /**
70  * DRM_VMW_GET_PARAM - get device information.
71  *
72  * DRM_VMW_PARAM_FIFO_OFFSET:
73  * Offset to use to map the first page of the FIFO read-only.
74  * The fifo is mapped using the mmap() system call on the drm device.
75  *
76  * DRM_VMW_PARAM_OVERLAY_IOCTL:
77  * Does the driver support the overlay ioctl.
78  */
79
80 #define DRM_VMW_PARAM_NUM_STREAMS      0
81 #define DRM_VMW_PARAM_NUM_FREE_STREAMS 1
82 #define DRM_VMW_PARAM_3D               2
83 #define DRM_VMW_PARAM_HW_CAPS          3
84 #define DRM_VMW_PARAM_FIFO_CAPS        4
85 #define DRM_VMW_PARAM_MAX_FB_SIZE      5
86 #define DRM_VMW_PARAM_FIFO_HW_VERSION  6
87 #define DRM_VMW_PARAM_MAX_SURF_MEMORY  7
88 #define DRM_VMW_PARAM_3D_CAPS_SIZE     8
89 #define DRM_VMW_PARAM_MAX_MOB_MEMORY   9
90 #define DRM_VMW_PARAM_MAX_MOB_SIZE     10
91 #define DRM_VMW_PARAM_SCREEN_TARGET    11
92
93 /**
94  * enum drm_vmw_handle_type - handle type for ref ioctls
95  *
96  */
97 enum drm_vmw_handle_type {
98         DRM_VMW_HANDLE_LEGACY = 0,
99         DRM_VMW_HANDLE_PRIME = 1
100 };
101
102 /**
103  * struct drm_vmw_getparam_arg
104  *
105  * @value: Returned value. //Out
106  * @param: Parameter to query. //In.
107  *
108  * Argument to the DRM_VMW_GET_PARAM Ioctl.
109  */
110
111 struct drm_vmw_getparam_arg {
112         uint64_t value;
113         uint32_t param;
114         uint32_t pad64;
115 };
116
117 /*************************************************************************/
118 /**
119  * DRM_VMW_CREATE_CONTEXT - Create a host context.
120  *
121  * Allocates a device unique context id, and queues a create context command
122  * for the host. Does not wait for host completion.
123  */
124
125 /**
126  * struct drm_vmw_context_arg
127  *
128  * @cid: Device unique context ID.
129  *
130  * Output argument to the DRM_VMW_CREATE_CONTEXT Ioctl.
131  * Input argument to the DRM_VMW_UNREF_CONTEXT Ioctl.
132  */
133
134 struct drm_vmw_context_arg {
135         int32_t cid;
136         uint32_t pad64;
137 };
138
139 /*************************************************************************/
140 /**
141  * DRM_VMW_UNREF_CONTEXT - Create a host context.
142  *
143  * Frees a global context id, and queues a destroy host command for the host.
144  * Does not wait for host completion. The context ID can be used directly
145  * in the command stream and shows up as the same context ID on the host.
146  */
147
148 /*************************************************************************/
149 /**
150  * DRM_VMW_CREATE_SURFACE - Create a host suface.
151  *
152  * Allocates a device unique surface id, and queues a create surface command
153  * for the host. Does not wait for host completion. The surface ID can be
154  * used directly in the command stream and shows up as the same surface
155  * ID on the host.
156  */
157
158 /**
159  * struct drm_wmv_surface_create_req
160  *
161  * @flags: Surface flags as understood by the host.
162  * @format: Surface format as understood by the host.
163  * @mip_levels: Number of mip levels for each face.
164  * An unused face should have 0 encoded.
165  * @size_addr: Address of a user-space array of sruct drm_vmw_size
166  * cast to an uint64_t for 32-64 bit compatibility.
167  * The size of the array should equal the total number of mipmap levels.
168  * @shareable: Boolean whether other clients (as identified by file descriptors)
169  * may reference this surface.
170  * @scanout: Boolean whether the surface is intended to be used as a
171  * scanout.
172  *
173  * Input data to the DRM_VMW_CREATE_SURFACE Ioctl.
174  * Output data from the DRM_VMW_REF_SURFACE Ioctl.
175  */
176
177 struct drm_vmw_surface_create_req {
178         uint32_t flags;
179         uint32_t format;
180         uint32_t mip_levels[DRM_VMW_MAX_SURFACE_FACES];
181         uint64_t size_addr;
182         int32_t shareable;
183         int32_t scanout;
184 };
185
186 /**
187  * struct drm_wmv_surface_arg
188  *
189  * @sid: Surface id of created surface or surface to destroy or reference.
190  * @handle_type: Handle type for DRM_VMW_REF_SURFACE Ioctl.
191  *
192  * Output data from the DRM_VMW_CREATE_SURFACE Ioctl.
193  * Input argument to the DRM_VMW_UNREF_SURFACE Ioctl.
194  * Input argument to the DRM_VMW_REF_SURFACE Ioctl.
195  */
196
197 struct drm_vmw_surface_arg {
198         int32_t sid;
199         enum drm_vmw_handle_type handle_type;
200 };
201
202 /**
203  * struct drm_vmw_size ioctl.
204  *
205  * @width - mip level width
206  * @height - mip level height
207  * @depth - mip level depth
208  *
209  * Description of a mip level.
210  * Input data to the DRM_WMW_CREATE_SURFACE Ioctl.
211  */
212
213 struct drm_vmw_size {
214         uint32_t width;
215         uint32_t height;
216         uint32_t depth;
217         uint32_t pad64;
218 };
219
220 /**
221  * union drm_vmw_surface_create_arg
222  *
223  * @rep: Output data as described above.
224  * @req: Input data as described above.
225  *
226  * Argument to the DRM_VMW_CREATE_SURFACE Ioctl.
227  */
228
229 union drm_vmw_surface_create_arg {
230         struct drm_vmw_surface_arg rep;
231         struct drm_vmw_surface_create_req req;
232 };
233
234 /*************************************************************************/
235 /**
236  * DRM_VMW_REF_SURFACE - Reference a host surface.
237  *
238  * Puts a reference on a host surface with a give sid, as previously
239  * returned by the DRM_VMW_CREATE_SURFACE ioctl.
240  * A reference will make sure the surface isn't destroyed while we hold
241  * it and will allow the calling client to use the surface ID in the command
242  * stream.
243  *
244  * On successful return, the Ioctl returns the surface information given
245  * in the DRM_VMW_CREATE_SURFACE ioctl.
246  */
247
248 /**
249  * union drm_vmw_surface_reference_arg
250  *
251  * @rep: Output data as described above.
252  * @req: Input data as described above.
253  *
254  * Argument to the DRM_VMW_REF_SURFACE Ioctl.
255  */
256
257 union drm_vmw_surface_reference_arg {
258         struct drm_vmw_surface_create_req rep;
259         struct drm_vmw_surface_arg req;
260 };
261
262 /*************************************************************************/
263 /**
264  * DRM_VMW_UNREF_SURFACE - Unreference a host surface.
265  *
266  * Clear a reference previously put on a host surface.
267  * When all references are gone, including the one implicitly placed
268  * on creation,
269  * a destroy surface command will be queued for the host.
270  * Does not wait for completion.
271  */
272
273 /*************************************************************************/
274 /**
275  * DRM_VMW_EXECBUF
276  *
277  * Submit a command buffer for execution on the host, and return a
278  * fence seqno that when signaled, indicates that the command buffer has
279  * executed.
280  */
281
282 /**
283  * struct drm_vmw_execbuf_arg
284  *
285  * @commands: User-space address of a command buffer cast to an uint64_t.
286  * @command-size: Size in bytes of the command buffer.
287  * @throttle-us: Sleep until software is less than @throttle_us
288  * microseconds ahead of hardware. The driver may round this value
289  * to the nearest kernel tick.
290  * @fence_rep: User-space address of a struct drm_vmw_fence_rep cast to an
291  * uint64_t.
292  * @version: Allows expanding the execbuf ioctl parameters without breaking
293  * backwards compatibility, since user-space will always tell the kernel
294  * which version it uses.
295  * @flags: Execbuf flags. None currently.
296  *
297  * Argument to the DRM_VMW_EXECBUF Ioctl.
298  */
299
300 #define DRM_VMW_EXECBUF_VERSION 1
301
302 struct drm_vmw_execbuf_arg {
303         uint64_t commands;
304         uint32_t command_size;
305         uint32_t throttle_us;
306         uint64_t fence_rep;
307         uint32_t version;
308         uint32_t flags;
309 };
310
311 /**
312  * struct drm_vmw_fence_rep
313  *
314  * @handle: Fence object handle for fence associated with a command submission.
315  * @mask: Fence flags relevant for this fence object.
316  * @seqno: Fence sequence number in fifo. A fence object with a lower
317  * seqno will signal the EXEC flag before a fence object with a higher
318  * seqno. This can be used by user-space to avoid kernel calls to determine
319  * whether a fence has signaled the EXEC flag. Note that @seqno will
320  * wrap at 32-bit.
321  * @passed_seqno: The highest seqno number processed by the hardware
322  * so far. This can be used to mark user-space fence objects as signaled, and
323  * to determine whether a fence seqno might be stale.
324  * @error: This member should've been set to -EFAULT on submission.
325  * The following actions should be take on completion:
326  * error == -EFAULT: Fence communication failed. The host is synchronized.
327  * Use the last fence id read from the FIFO fence register.
328  * error != 0 && error != -EFAULT:
329  * Fence submission failed. The host is synchronized. Use the fence_seq member.
330  * error == 0: All is OK, The host may not be synchronized.
331  * Use the fence_seq member.
332  *
333  * Input / Output data to the DRM_VMW_EXECBUF Ioctl.
334  */
335
336 struct drm_vmw_fence_rep {
337         uint32_t handle;
338         uint32_t mask;
339         uint32_t seqno;
340         uint32_t passed_seqno;
341         uint32_t pad64;
342         int32_t error;
343 };
344
345 /*************************************************************************/
346 /**
347  * DRM_VMW_ALLOC_DMABUF
348  *
349  * Allocate a DMA buffer that is visible also to the host.
350  * NOTE: The buffer is
351  * identified by a handle and an offset, which are private to the guest, but
352  * useable in the command stream. The guest kernel may translate these
353  * and patch up the command stream accordingly. In the future, the offset may
354  * be zero at all times, or it may disappear from the interface before it is
355  * fixed.
356  *
357  * The DMA buffer may stay user-space mapped in the guest at all times,
358  * and is thus suitable for sub-allocation.
359  *
360  * DMA buffers are mapped using the mmap() syscall on the drm device.
361  */
362
363 /**
364  * struct drm_vmw_alloc_dmabuf_req
365  *
366  * @size: Required minimum size of the buffer.
367  *
368  * Input data to the DRM_VMW_ALLOC_DMABUF Ioctl.
369  */
370
371 struct drm_vmw_alloc_dmabuf_req {
372         uint32_t size;
373         uint32_t pad64;
374 };
375
376 /**
377  * struct drm_vmw_dmabuf_rep
378  *
379  * @map_handle: Offset to use in the mmap() call used to map the buffer.
380  * @handle: Handle unique to this buffer. Used for unreferencing.
381  * @cur_gmr_id: GMR id to use in the command stream when this buffer is
382  * referenced. See not above.
383  * @cur_gmr_offset: Offset to use in the command stream when this buffer is
384  * referenced. See note above.
385  *
386  * Output data from the DRM_VMW_ALLOC_DMABUF Ioctl.
387  */
388
389 struct drm_vmw_dmabuf_rep {
390         uint64_t map_handle;
391         uint32_t handle;
392         uint32_t cur_gmr_id;
393         uint32_t cur_gmr_offset;
394         uint32_t pad64;
395 };
396
397 /**
398  * union drm_vmw_dmabuf_arg
399  *
400  * @req: Input data as described above.
401  * @rep: Output data as described above.
402  *
403  * Argument to the DRM_VMW_ALLOC_DMABUF Ioctl.
404  */
405
406 union drm_vmw_alloc_dmabuf_arg {
407         struct drm_vmw_alloc_dmabuf_req req;
408         struct drm_vmw_dmabuf_rep rep;
409 };
410
411 /*************************************************************************/
412 /**
413  * DRM_VMW_UNREF_DMABUF - Free a DMA buffer.
414  *
415  */
416
417 /**
418  * struct drm_vmw_unref_dmabuf_arg
419  *
420  * @handle: Handle indicating what buffer to free. Obtained from the
421  * DRM_VMW_ALLOC_DMABUF Ioctl.
422  *
423  * Argument to the DRM_VMW_UNREF_DMABUF Ioctl.
424  */
425
426 struct drm_vmw_unref_dmabuf_arg {
427         uint32_t handle;
428         uint32_t pad64;
429 };
430
431 /*************************************************************************/
432 /**
433  * DRM_VMW_CONTROL_STREAM - Control overlays, aka streams.
434  *
435  * This IOCTL controls the overlay units of the svga device.
436  * The SVGA overlay units does not work like regular hardware units in
437  * that they do not automaticaly read back the contents of the given dma
438  * buffer. But instead only read back for each call to this ioctl, and
439  * at any point between this call being made and a following call that
440  * either changes the buffer or disables the stream.
441  */
442
443 /**
444  * struct drm_vmw_rect
445  *
446  * Defines a rectangle. Used in the overlay ioctl to define
447  * source and destination rectangle.
448  */
449
450 struct drm_vmw_rect {
451         int32_t x;
452         int32_t y;
453         uint32_t w;
454         uint32_t h;
455 };
456
457 /**
458  * struct drm_vmw_control_stream_arg
459  *
460  * @stream_id: Stearm to control
461  * @enabled: If false all following arguments are ignored.
462  * @handle: Handle to buffer for getting data from.
463  * @format: Format of the overlay as understood by the host.
464  * @width: Width of the overlay.
465  * @height: Height of the overlay.
466  * @size: Size of the overlay in bytes.
467  * @pitch: Array of pitches, the two last are only used for YUV12 formats.
468  * @offset: Offset from start of dma buffer to overlay.
469  * @src: Source rect, must be within the defined area above.
470  * @dst: Destination rect, x and y may be negative.
471  *
472  * Argument to the DRM_VMW_CONTROL_STREAM Ioctl.
473  */
474
475 struct drm_vmw_control_stream_arg {
476         uint32_t stream_id;
477         uint32_t enabled;
478
479         uint32_t flags;
480         uint32_t color_key;
481
482         uint32_t handle;
483         uint32_t offset;
484         int32_t format;
485         uint32_t size;
486         uint32_t width;
487         uint32_t height;
488         uint32_t pitch[3];
489
490         uint32_t pad64;
491         struct drm_vmw_rect src;
492         struct drm_vmw_rect dst;
493 };
494
495 /*************************************************************************/
496 /**
497  * DRM_VMW_CURSOR_BYPASS - Give extra information about cursor bypass.
498  *
499  */
500
501 #define DRM_VMW_CURSOR_BYPASS_ALL    (1 << 0)
502 #define DRM_VMW_CURSOR_BYPASS_FLAGS       (1)
503
504 /**
505  * struct drm_vmw_cursor_bypass_arg
506  *
507  * @flags: Flags.
508  * @crtc_id: Crtc id, only used if DMR_CURSOR_BYPASS_ALL isn't passed.
509  * @xpos: X position of cursor.
510  * @ypos: Y position of cursor.
511  * @xhot: X hotspot.
512  * @yhot: Y hotspot.
513  *
514  * Argument to the DRM_VMW_CURSOR_BYPASS Ioctl.
515  */
516
517 struct drm_vmw_cursor_bypass_arg {
518         uint32_t flags;
519         uint32_t crtc_id;
520         int32_t xpos;
521         int32_t ypos;
522         int32_t xhot;
523         int32_t yhot;
524 };
525
526 /*************************************************************************/
527 /**
528  * DRM_VMW_CLAIM_STREAM - Claim a single stream.
529  */
530
531 /**
532  * struct drm_vmw_context_arg
533  *
534  * @stream_id: Device unique context ID.
535  *
536  * Output argument to the DRM_VMW_CREATE_CONTEXT Ioctl.
537  * Input argument to the DRM_VMW_UNREF_CONTEXT Ioctl.
538  */
539
540 struct drm_vmw_stream_arg {
541         uint32_t stream_id;
542         uint32_t pad64;
543 };
544
545 /*************************************************************************/
546 /**
547  * DRM_VMW_UNREF_STREAM - Unclaim a stream.
548  *
549  * Return a single stream that was claimed by this process. Also makes
550  * sure that the stream has been stopped.
551  */
552
553 /*************************************************************************/
554 /**
555  * DRM_VMW_GET_3D_CAP
556  *
557  * Read 3D capabilities from the FIFO
558  *
559  */
560
561 /**
562  * struct drm_vmw_get_3d_cap_arg
563  *
564  * @buffer: Pointer to a buffer for capability data, cast to an uint64_t
565  * @size: Max size to copy
566  *
567  * Input argument to the DRM_VMW_GET_3D_CAP_IOCTL
568  * ioctls.
569  */
570
571 struct drm_vmw_get_3d_cap_arg {
572         uint64_t buffer;
573         uint32_t max_size;
574         uint32_t pad64;
575 };
576
577 /*************************************************************************/
578 /**
579  * DRM_VMW_FENCE_WAIT
580  *
581  * Waits for a fence object to signal. The wait is interruptible, so that
582  * signals may be delivered during the interrupt. The wait may timeout,
583  * in which case the calls returns -EBUSY. If the wait is restarted,
584  * that is restarting without resetting @cookie_valid to zero,
585  * the timeout is computed from the first call.
586  *
587  * The flags argument to the DRM_VMW_FENCE_WAIT ioctl indicates what to wait
588  * on:
589  * DRM_VMW_FENCE_FLAG_EXEC: All commands ahead of the fence in the command
590  * stream
591  * have executed.
592  * DRM_VMW_FENCE_FLAG_QUERY: All query results resulting from query finish
593  * commands
594  * in the buffer given to the EXECBUF ioctl returning the fence object handle
595  * are available to user-space.
596  *
597  * DRM_VMW_WAIT_OPTION_UNREF: If this wait option is given, and the
598  * fenc wait ioctl returns 0, the fence object has been unreferenced after
599  * the wait.
600  */
601
602 #define DRM_VMW_FENCE_FLAG_EXEC   (1 << 0)
603 #define DRM_VMW_FENCE_FLAG_QUERY  (1 << 1)
604
605 #define DRM_VMW_WAIT_OPTION_UNREF (1 << 0)
606
607 /**
608  * struct drm_vmw_fence_wait_arg
609  *
610  * @handle: Fence object handle as returned by the DRM_VMW_EXECBUF ioctl.
611  * @cookie_valid: Must be reset to 0 on first call. Left alone on restart.
612  * @kernel_cookie: Set to 0 on first call. Left alone on restart.
613  * @timeout_us: Wait timeout in microseconds. 0 for indefinite timeout.
614  * @lazy: Set to 1 if timing is not critical. Allow more than a kernel tick
615  * before returning.
616  * @flags: Fence flags to wait on.
617  * @wait_options: Options that control the behaviour of the wait ioctl.
618  *
619  * Input argument to the DRM_VMW_FENCE_WAIT ioctl.
620  */
621
622 struct drm_vmw_fence_wait_arg {
623         uint32_t handle;
624         int32_t  cookie_valid;
625         uint64_t kernel_cookie;
626         uint64_t timeout_us;
627         int32_t lazy;
628         int32_t flags;
629         int32_t wait_options;
630         int32_t pad64;
631 };
632
633 /*************************************************************************/
634 /**
635  * DRM_VMW_FENCE_SIGNALED
636  *
637  * Checks if a fence object is signaled..
638  */
639
640 /**
641  * struct drm_vmw_fence_signaled_arg
642  *
643  * @handle: Fence object handle as returned by the DRM_VMW_EXECBUF ioctl.
644  * @flags: Fence object flags input to DRM_VMW_FENCE_SIGNALED ioctl
645  * @signaled: Out: Flags signaled.
646  * @sequence: Out: Highest sequence passed so far. Can be used to signal the
647  * EXEC flag of user-space fence objects.
648  *
649  * Input/Output argument to the DRM_VMW_FENCE_SIGNALED and DRM_VMW_FENCE_UNREF
650  * ioctls.
651  */
652
653 struct drm_vmw_fence_signaled_arg {
654          uint32_t handle;
655          uint32_t flags;
656          int32_t signaled;
657          uint32_t passed_seqno;
658          uint32_t signaled_flags;
659          uint32_t pad64;
660 };
661
662 /*************************************************************************/
663 /**
664  * DRM_VMW_FENCE_UNREF
665  *
666  * Unreferences a fence object, and causes it to be destroyed if there are no
667  * other references to it.
668  *
669  */
670
671 /**
672  * struct drm_vmw_fence_arg
673  *
674  * @handle: Fence object handle as returned by the DRM_VMW_EXECBUF ioctl.
675  *
676  * Input/Output argument to the DRM_VMW_FENCE_UNREF ioctl..
677  */
678
679 struct drm_vmw_fence_arg {
680          uint32_t handle;
681          uint32_t pad64;
682 };
683
684
685 /*************************************************************************/
686 /**
687  * DRM_VMW_FENCE_EVENT
688  *
689  * Queues an event on a fence to be delivered on the drm character device
690  * when the fence has signaled the DRM_VMW_FENCE_FLAG_EXEC flag.
691  * Optionally the approximate time when the fence signaled is
692  * given by the event.
693  */
694
695 /*
696  * The event type
697  */
698 #define DRM_VMW_EVENT_FENCE_SIGNALED 0x80000000
699
700 struct drm_vmw_event_fence {
701         struct drm_event base;
702         uint64_t user_data;
703         uint32_t tv_sec;
704         uint32_t tv_usec;
705 };
706
707 /*
708  * Flags that may be given to the command.
709  */
710 /* Request fence signaled time on the event. */
711 #define DRM_VMW_FE_FLAG_REQ_TIME (1 << 0)
712
713 /**
714  * struct drm_vmw_fence_event_arg
715  *
716  * @fence_rep: Pointer to fence_rep structure cast to uint64_t or 0 if
717  * the fence is not supposed to be referenced by user-space.
718  * @user_info: Info to be delivered with the event.
719  * @handle: Attach the event to this fence only.
720  * @flags: A set of flags as defined above.
721  */
722 struct drm_vmw_fence_event_arg {
723         uint64_t fence_rep;
724         uint64_t user_data;
725         uint32_t handle;
726         uint32_t flags;
727 };
728
729
730 /*************************************************************************/
731 /**
732  * DRM_VMW_PRESENT
733  *
734  * Executes an SVGA present on a given fb for a given surface. The surface
735  * is placed on the framebuffer. Cliprects are given relative to the given
736  * point (the point disignated by dest_{x|y}).
737  *
738  */
739
740 /**
741  * struct drm_vmw_present_arg
742  * @fb_id: framebuffer id to present / read back from.
743  * @sid: Surface id to present from.
744  * @dest_x: X placement coordinate for surface.
745  * @dest_y: Y placement coordinate for surface.
746  * @clips_ptr: Pointer to an array of clip rects cast to an uint64_t.
747  * @num_clips: Number of cliprects given relative to the framebuffer origin,
748  * in the same coordinate space as the frame buffer.
749  * @pad64: Unused 64-bit padding.
750  *
751  * Input argument to the DRM_VMW_PRESENT ioctl.
752  */
753
754 struct drm_vmw_present_arg {
755         uint32_t fb_id;
756         uint32_t sid;
757         int32_t dest_x;
758         int32_t dest_y;
759         uint64_t clips_ptr;
760         uint32_t num_clips;
761         uint32_t pad64;
762 };
763
764
765 /*************************************************************************/
766 /**
767  * DRM_VMW_PRESENT_READBACK
768  *
769  * Executes an SVGA present readback from a given fb to the dma buffer
770  * currently bound as the fb. If there is no dma buffer bound to the fb,
771  * an error will be returned.
772  *
773  */
774
775 /**
776  * struct drm_vmw_present_arg
777  * @fb_id: fb_id to present / read back from.
778  * @num_clips: Number of cliprects.
779  * @clips_ptr: Pointer to an array of clip rects cast to an uint64_t.
780  * @fence_rep: Pointer to a struct drm_vmw_fence_rep, cast to an uint64_t.
781  * If this member is NULL, then the ioctl should not return a fence.
782  */
783
784 struct drm_vmw_present_readback_arg {
785          uint32_t fb_id;
786          uint32_t num_clips;
787          uint64_t clips_ptr;
788          uint64_t fence_rep;
789 };
790
791 /*************************************************************************/
792 /**
793  * DRM_VMW_UPDATE_LAYOUT - Update layout
794  *
795  * Updates the preferred modes and connection status for connectors. The
796  * command consists of one drm_vmw_update_layout_arg pointing to an array
797  * of num_outputs drm_vmw_rect's.
798  */
799
800 /**
801  * struct drm_vmw_update_layout_arg
802  *
803  * @num_outputs: number of active connectors
804  * @rects: pointer to array of drm_vmw_rect cast to an uint64_t
805  *
806  * Input argument to the DRM_VMW_UPDATE_LAYOUT Ioctl.
807  */
808 struct drm_vmw_update_layout_arg {
809         uint32_t num_outputs;
810         uint32_t pad64;
811         uint64_t rects;
812 };
813
814
815 /*************************************************************************/
816 /**
817  * DRM_VMW_CREATE_SHADER - Create shader
818  *
819  * Creates a shader and optionally binds it to a dma buffer containing
820  * the shader byte-code.
821  */
822
823 /**
824  * enum drm_vmw_shader_type - Shader types
825  */
826 enum drm_vmw_shader_type {
827         drm_vmw_shader_type_vs = 0,
828         drm_vmw_shader_type_ps,
829         drm_vmw_shader_type_gs
830 };
831
832
833 /**
834  * struct drm_vmw_shader_create_arg
835  *
836  * @shader_type: Shader type of the shader to create.
837  * @size: Size of the byte-code in bytes.
838  * where the shader byte-code starts
839  * @buffer_handle: Buffer handle identifying the buffer containing the
840  * shader byte-code
841  * @shader_handle: On successful completion contains a handle that
842  * can be used to subsequently identify the shader.
843  * @offset: Offset in bytes into the buffer given by @buffer_handle,
844  *
845  * Input / Output argument to the DRM_VMW_CREATE_SHADER Ioctl.
846  */
847 struct drm_vmw_shader_create_arg {
848         enum drm_vmw_shader_type shader_type;
849         uint32_t size;
850         uint32_t buffer_handle;
851         uint32_t shader_handle;
852         uint64_t offset;
853 };
854
855 /*************************************************************************/
856 /**
857  * DRM_VMW_UNREF_SHADER - Unreferences a shader
858  *
859  * Destroys a user-space reference to a shader, optionally destroying
860  * it.
861  */
862
863 /**
864  * struct drm_vmw_shader_arg
865  *
866  * @handle: Handle identifying the shader to destroy.
867  *
868  * Input argument to the DRM_VMW_UNREF_SHADER ioctl.
869  */
870 struct drm_vmw_shader_arg {
871         uint32_t handle;
872         uint32_t pad64;
873 };
874
875 /*************************************************************************/
876 /**
877  * DRM_VMW_GB_SURFACE_CREATE - Create a host guest-backed surface.
878  *
879  * Allocates a surface handle and queues a create surface command
880  * for the host on the first use of the surface. The surface ID can
881  * be used as the surface ID in commands referencing the surface.
882  */
883
884 /**
885  * enum drm_vmw_surface_flags
886  *
887  * @drm_vmw_surface_flag_shareable:     Whether the surface is shareable
888  * @drm_vmw_surface_flag_scanout:       Whether the surface is a scanout
889  *                                      surface.
890  * @drm_vmw_surface_flag_create_buffer: Create a backup buffer if none is
891  *                                      given.
892  */
893 enum drm_vmw_surface_flags {
894         drm_vmw_surface_flag_shareable = (1 << 0),
895         drm_vmw_surface_flag_scanout = (1 << 1),
896         drm_vmw_surface_flag_create_buffer = (1 << 2)
897 };
898
899 /**
900  * struct drm_vmw_gb_surface_create_req
901  *
902  * @svga3d_flags:     SVGA3d surface flags for the device.
903  * @format:           SVGA3d format.
904  * @mip_level:        Number of mip levels for all faces.
905  * @drm_surface_flags Flags as described above.
906  * @multisample_count Future use. Set to 0.
907  * @autogen_filter    Future use. Set to 0.
908  * @buffer_handle     Buffer handle of backup buffer. SVGA3D_INVALID_ID
909  *                    if none.
910  * @base_size         Size of the base mip level for all faces.
911  *
912  * Input argument to the  DRM_VMW_GB_SURFACE_CREATE Ioctl.
913  * Part of output argument for the DRM_VMW_GB_SURFACE_REF Ioctl.
914  */
915 struct drm_vmw_gb_surface_create_req {
916         uint32_t svga3d_flags;
917         uint32_t format;
918         uint32_t mip_levels;
919         enum drm_vmw_surface_flags drm_surface_flags;
920         uint32_t multisample_count;
921         uint32_t autogen_filter;
922         uint32_t buffer_handle;
923         uint32_t pad64;
924         struct drm_vmw_size base_size;
925 };
926
927 /**
928  * struct drm_vmw_gb_surface_create_rep
929  *
930  * @handle:            Surface handle.
931  * @backup_size:       Size of backup buffers for this surface.
932  * @buffer_handle:     Handle of backup buffer. SVGA3D_INVALID_ID if none.
933  * @buffer_size:       Actual size of the buffer identified by
934  *                     @buffer_handle
935  * @buffer_map_handle: Offset into device address space for the buffer
936  *                     identified by @buffer_handle.
937  *
938  * Part of output argument for the DRM_VMW_GB_SURFACE_REF ioctl.
939  * Output argument for the DRM_VMW_GB_SURFACE_CREATE ioctl.
940  */
941 struct drm_vmw_gb_surface_create_rep {
942         uint32_t handle;
943         uint32_t backup_size;
944         uint32_t buffer_handle;
945         uint32_t buffer_size;
946         uint64_t buffer_map_handle;
947 };
948
949 /**
950  * union drm_vmw_gb_surface_create_arg
951  *
952  * @req: Input argument as described above.
953  * @rep: Output argument as described above.
954  *
955  * Argument to the DRM_VMW_GB_SURFACE_CREATE ioctl.
956  */
957 union drm_vmw_gb_surface_create_arg {
958         struct drm_vmw_gb_surface_create_rep rep;
959         struct drm_vmw_gb_surface_create_req req;
960 };
961
962 /*************************************************************************/
963 /**
964  * DRM_VMW_GB_SURFACE_REF - Reference a host surface.
965  *
966  * Puts a reference on a host surface with a given handle, as previously
967  * returned by the DRM_VMW_GB_SURFACE_CREATE ioctl.
968  * A reference will make sure the surface isn't destroyed while we hold
969  * it and will allow the calling client to use the surface handle in
970  * the command stream.
971  *
972  * On successful return, the Ioctl returns the surface information given
973  * to and returned from the DRM_VMW_GB_SURFACE_CREATE ioctl.
974  */
975
976 /**
977  * struct drm_vmw_gb_surface_reference_arg
978  *
979  * @creq: The data used as input when the surface was created, as described
980  *        above at "struct drm_vmw_gb_surface_create_req"
981  * @crep: Additional data output when the surface was created, as described
982  *        above at "struct drm_vmw_gb_surface_create_rep"
983  *
984  * Output Argument to the DRM_VMW_GB_SURFACE_REF ioctl.
985  */
986 struct drm_vmw_gb_surface_ref_rep {
987         struct drm_vmw_gb_surface_create_req creq;
988         struct drm_vmw_gb_surface_create_rep crep;
989 };
990
991 /**
992  * union drm_vmw_gb_surface_reference_arg
993  *
994  * @req: Input data as described above at "struct drm_vmw_surface_arg"
995  * @rep: Output data as described above at "struct drm_vmw_gb_surface_ref_rep"
996  *
997  * Argument to the DRM_VMW_GB_SURFACE_REF Ioctl.
998  */
999 union drm_vmw_gb_surface_reference_arg {
1000         struct drm_vmw_gb_surface_ref_rep rep;
1001         struct drm_vmw_surface_arg req;
1002 };
1003
1004
1005 /*************************************************************************/
1006 /**
1007  * DRM_VMW_SYNCCPU - Sync a DMA buffer / MOB for CPU access.
1008  *
1009  * Idles any previously submitted GPU operations on the buffer and
1010  * by default blocks command submissions that reference the buffer.
1011  * If the file descriptor used to grab a blocking CPU sync is closed, the
1012  * cpu sync is released.
1013  * The flags argument indicates how the grab / release operation should be
1014  * performed:
1015  */
1016
1017 /**
1018  * enum drm_vmw_synccpu_flags - Synccpu flags:
1019  *
1020  * @drm_vmw_synccpu_read: Sync for read. If sync is done for read only, it's a
1021  * hint to the kernel to allow command submissions that references the buffer
1022  * for read-only.
1023  * @drm_vmw_synccpu_write: Sync for write. Block all command submissions
1024  * referencing this buffer.
1025  * @drm_vmw_synccpu_dontblock: Dont wait for GPU idle, but rather return
1026  * -EBUSY should the buffer be busy.
1027  * @drm_vmw_synccpu_allow_cs: Allow command submission that touches the buffer
1028  * while the buffer is synced for CPU. This is similar to the GEM bo idle
1029  * behavior.
1030  */
1031 enum drm_vmw_synccpu_flags {
1032         drm_vmw_synccpu_read = (1 << 0),
1033         drm_vmw_synccpu_write = (1 << 1),
1034         drm_vmw_synccpu_dontblock = (1 << 2),
1035         drm_vmw_synccpu_allow_cs = (1 << 3)
1036 };
1037
1038 /**
1039  * enum drm_vmw_synccpu_op - Synccpu operations:
1040  *
1041  * @drm_vmw_synccpu_grab:    Grab the buffer for CPU operations
1042  * @drm_vmw_synccpu_release: Release a previous grab.
1043  */
1044 enum drm_vmw_synccpu_op {
1045         drm_vmw_synccpu_grab,
1046         drm_vmw_synccpu_release
1047 };
1048
1049 /**
1050  * struct drm_vmw_synccpu_arg
1051  *
1052  * @op:                      The synccpu operation as described above.
1053  * @handle:                  Handle identifying the buffer object.
1054  * @flags:                   Flags as described above.
1055  */
1056 struct drm_vmw_synccpu_arg {
1057         enum drm_vmw_synccpu_op op;
1058         enum drm_vmw_synccpu_flags flags;
1059         uint32_t handle;
1060         uint32_t pad64;
1061 };
1062
1063 #endif