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