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