blob: 490db458d5dbffe7344f12ace8da7ebfd81fc961 [file] [log] [blame]
Jakob Bornecrantzfb1d9732009-12-10 00:19:58 +00001/**************************************************************************
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
Thomas Hellstrom781b8bd2011-09-01 20:18:38 +000051#define DRM_VMW_FENCE_WAIT 13
Jakob Bornecrantzfb1d9732009-12-10 00:19:58 +000052
53/*************************************************************************/
54/**
55 * DRM_VMW_GET_PARAM - get device information.
56 *
57 * DRM_VMW_PARAM_FIFO_OFFSET:
58 * Offset to use to map the first page of the FIFO read-only.
59 * The fifo is mapped using the mmap() system call on the drm device.
60 *
61 * DRM_VMW_PARAM_OVERLAY_IOCTL:
62 * Does the driver support the overlay ioctl.
63 */
64
65#define DRM_VMW_PARAM_NUM_STREAMS 0
66#define DRM_VMW_PARAM_NUM_FREE_STREAMS 1
67#define DRM_VMW_PARAM_3D 2
Thomas Hellstrom07999a72011-09-01 20:18:40 +000068#define DRM_VMW_PARAM_HW_CAPS 3
69#define DRM_VMW_PARAM_FIFO_CAPS 4
70#define DRM_VMW_PARAM_MAX_FB_SIZE 5
Jakob Bornecrantzfb1d9732009-12-10 00:19:58 +000071
72/**
73 * struct drm_vmw_getparam_arg
74 *
75 * @value: Returned value. //Out
76 * @param: Parameter to query. //In.
77 *
78 * Argument to the DRM_VMW_GET_PARAM Ioctl.
79 */
80
81struct drm_vmw_getparam_arg {
82 uint64_t value;
83 uint32_t param;
84 uint32_t pad64;
85};
86
87/*************************************************************************/
88/**
89 * DRM_VMW_EXTENSION - Query device extensions.
90 */
91
92/**
93 * struct drm_vmw_extension_rep
94 *
95 * @exists: The queried extension exists.
96 * @driver_ioctl_offset: Ioctl number of the first ioctl in the extension.
97 * @driver_sarea_offset: Offset to any space in the DRI SAREA
98 * used by the extension.
99 * @major: Major version number of the extension.
100 * @minor: Minor version number of the extension.
101 * @pl: Patch level version number of the extension.
102 *
103 * Output argument to the DRM_VMW_EXTENSION Ioctl.
104 */
105
106struct drm_vmw_extension_rep {
107 int32_t exists;
108 uint32_t driver_ioctl_offset;
109 uint32_t driver_sarea_offset;
110 uint32_t major;
111 uint32_t minor;
112 uint32_t pl;
113 uint32_t pad64;
114};
115
116/**
117 * union drm_vmw_extension_arg
118 *
119 * @extension - Ascii name of the extension to be queried. //In
120 * @rep - Reply as defined above. //Out
121 *
122 * Argument to the DRM_VMW_EXTENSION Ioctl.
123 */
124
125union drm_vmw_extension_arg {
126 char extension[DRM_VMW_EXT_NAME_LEN];
127 struct drm_vmw_extension_rep rep;
128};
129
130/*************************************************************************/
131/**
132 * DRM_VMW_CREATE_CONTEXT - Create a host context.
133 *
134 * Allocates a device unique context id, and queues a create context command
135 * for the host. Does not wait for host completion.
136 */
137
138/**
139 * struct drm_vmw_context_arg
140 *
141 * @cid: Device unique context ID.
142 *
143 * Output argument to the DRM_VMW_CREATE_CONTEXT Ioctl.
144 * Input argument to the DRM_VMW_UNREF_CONTEXT Ioctl.
145 */
146
147struct drm_vmw_context_arg {
148 int32_t cid;
149 uint32_t pad64;
150};
151
152/*************************************************************************/
153/**
154 * DRM_VMW_UNREF_CONTEXT - Create a host context.
155 *
156 * Frees a global context id, and queues a destroy host command for the host.
157 * Does not wait for host completion. The context ID can be used directly
158 * in the command stream and shows up as the same context ID on the host.
159 */
160
161/*************************************************************************/
162/**
163 * DRM_VMW_CREATE_SURFACE - Create a host suface.
164 *
165 * Allocates a device unique surface id, and queues a create surface command
166 * for the host. Does not wait for host completion. The surface ID can be
167 * used directly in the command stream and shows up as the same surface
168 * ID on the host.
169 */
170
171/**
172 * struct drm_wmv_surface_create_req
173 *
174 * @flags: Surface flags as understood by the host.
175 * @format: Surface format as understood by the host.
176 * @mip_levels: Number of mip levels for each face.
177 * An unused face should have 0 encoded.
178 * @size_addr: Address of a user-space array of sruct drm_vmw_size
179 * cast to an uint64_t for 32-64 bit compatibility.
180 * The size of the array should equal the total number of mipmap levels.
181 * @shareable: Boolean whether other clients (as identified by file descriptors)
182 * may reference this surface.
Thomas Hellstromf77cef32010-02-09 19:41:55 +0000183 * @scanout: Boolean whether the surface is intended to be used as a
184 * scanout.
Jakob Bornecrantzfb1d9732009-12-10 00:19:58 +0000185 *
186 * Input data to the DRM_VMW_CREATE_SURFACE Ioctl.
187 * Output data from the DRM_VMW_REF_SURFACE Ioctl.
188 */
189
190struct drm_vmw_surface_create_req {
191 uint32_t flags;
192 uint32_t format;
193 uint32_t mip_levels[DRM_VMW_MAX_SURFACE_FACES];
194 uint64_t size_addr;
195 int32_t shareable;
Thomas Hellstromf77cef32010-02-09 19:41:55 +0000196 int32_t scanout;
Jakob Bornecrantzfb1d9732009-12-10 00:19:58 +0000197};
198
199/**
200 * struct drm_wmv_surface_arg
201 *
202 * @sid: Surface id of created surface or surface to destroy or reference.
203 *
204 * Output data from the DRM_VMW_CREATE_SURFACE Ioctl.
205 * Input argument to the DRM_VMW_UNREF_SURFACE Ioctl.
206 * Input argument to the DRM_VMW_REF_SURFACE Ioctl.
207 */
208
209struct drm_vmw_surface_arg {
210 int32_t sid;
211 uint32_t pad64;
212};
213
214/**
215 * struct drm_vmw_size ioctl.
216 *
217 * @width - mip level width
218 * @height - mip level height
219 * @depth - mip level depth
220 *
221 * Description of a mip level.
222 * Input data to the DRM_WMW_CREATE_SURFACE Ioctl.
223 */
224
225struct drm_vmw_size {
226 uint32_t width;
227 uint32_t height;
228 uint32_t depth;
229 uint32_t pad64;
230};
231
232/**
233 * union drm_vmw_surface_create_arg
234 *
235 * @rep: Output data as described above.
236 * @req: Input data as described above.
237 *
238 * Argument to the DRM_VMW_CREATE_SURFACE Ioctl.
239 */
240
241union drm_vmw_surface_create_arg {
242 struct drm_vmw_surface_arg rep;
243 struct drm_vmw_surface_create_req req;
244};
245
246/*************************************************************************/
247/**
248 * DRM_VMW_REF_SURFACE - Reference a host surface.
249 *
250 * Puts a reference on a host surface with a give sid, as previously
251 * returned by the DRM_VMW_CREATE_SURFACE ioctl.
252 * A reference will make sure the surface isn't destroyed while we hold
253 * it and will allow the calling client to use the surface ID in the command
254 * stream.
255 *
256 * On successful return, the Ioctl returns the surface information given
257 * in the DRM_VMW_CREATE_SURFACE ioctl.
258 */
259
260/**
261 * union drm_vmw_surface_reference_arg
262 *
263 * @rep: Output data as described above.
264 * @req: Input data as described above.
265 *
266 * Argument to the DRM_VMW_REF_SURFACE Ioctl.
267 */
268
269union drm_vmw_surface_reference_arg {
270 struct drm_vmw_surface_create_req rep;
271 struct drm_vmw_surface_arg req;
272};
273
274/*************************************************************************/
275/**
276 * DRM_VMW_UNREF_SURFACE - Unreference a host surface.
277 *
278 * Clear a reference previously put on a host surface.
279 * When all references are gone, including the one implicitly placed
280 * on creation,
281 * a destroy surface command will be queued for the host.
282 * Does not wait for completion.
283 */
284
285/*************************************************************************/
286/**
287 * DRM_VMW_EXECBUF
288 *
289 * Submit a command buffer for execution on the host, and return a
290 * fence sequence that when signaled, indicates that the command buffer has
291 * executed.
292 */
293
294/**
295 * struct drm_vmw_execbuf_arg
296 *
297 * @commands: User-space address of a command buffer cast to an uint64_t.
298 * @command-size: Size in bytes of the command buffer.
Thomas Hellstromf77cef32010-02-09 19:41:55 +0000299 * @throttle-us: Sleep until software is less than @throttle_us
300 * microseconds ahead of hardware. The driver may round this value
301 * to the nearest kernel tick.
Jakob Bornecrantzfb1d9732009-12-10 00:19:58 +0000302 * @fence_rep: User-space address of a struct drm_vmw_fence_rep cast to an
303 * uint64_t.
Jakob Bornecrantza87897e2010-02-09 21:29:47 +0000304 * @version: Allows expanding the execbuf ioctl parameters without breaking
305 * backwards compatibility, since user-space will always tell the kernel
306 * which version it uses.
307 * @flags: Execbuf flags. None currently.
Jakob Bornecrantzfb1d9732009-12-10 00:19:58 +0000308 *
309 * Argument to the DRM_VMW_EXECBUF Ioctl.
310 */
311
Jakob Bornecrantza87897e2010-02-09 21:29:47 +0000312#define DRM_VMW_EXECBUF_VERSION 0
313
Jakob Bornecrantzfb1d9732009-12-10 00:19:58 +0000314struct drm_vmw_execbuf_arg {
315 uint64_t commands;
316 uint32_t command_size;
Thomas Hellstromf77cef32010-02-09 19:41:55 +0000317 uint32_t throttle_us;
Jakob Bornecrantzfb1d9732009-12-10 00:19:58 +0000318 uint64_t fence_rep;
Jakob Bornecrantza87897e2010-02-09 21:29:47 +0000319 uint32_t version;
320 uint32_t flags;
Jakob Bornecrantzfb1d9732009-12-10 00:19:58 +0000321};
322
323/**
324 * struct drm_vmw_fence_rep
325 *
326 * @fence_seq: Fence sequence associated with a command submission.
327 * @error: This member should've been set to -EFAULT on submission.
328 * The following actions should be take on completion:
329 * error == -EFAULT: Fence communication failed. The host is synchronized.
330 * Use the last fence id read from the FIFO fence register.
331 * error != 0 && error != -EFAULT:
332 * Fence submission failed. The host is synchronized. Use the fence_seq member.
333 * error == 0: All is OK, The host may not be synchronized.
334 * Use the fence_seq member.
335 *
336 * Input / Output data to the DRM_VMW_EXECBUF Ioctl.
337 */
338
339struct drm_vmw_fence_rep {
340 uint64_t fence_seq;
341 int32_t error;
342 uint32_t pad64;
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
371struct 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
389struct 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
406union 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
426struct drm_vmw_unref_dmabuf_arg {
427 uint32_t handle;
428 uint32_t pad64;
429};
430
Jakob Bornecrantzfb1d9732009-12-10 00:19:58 +0000431
432struct drm_vmw_fence_wait_arg {
433 uint64_t sequence;
434 uint64_t kernel_cookie;
435 int32_t cookie_valid;
436 int32_t pad64;
437};
438
439/*************************************************************************/
440/**
441 * DRM_VMW_CONTROL_STREAM - Control overlays, aka streams.
442 *
443 * This IOCTL controls the overlay units of the svga device.
444 * The SVGA overlay units does not work like regular hardware units in
445 * that they do not automaticaly read back the contents of the given dma
446 * buffer. But instead only read back for each call to this ioctl, and
447 * at any point between this call being made and a following call that
448 * either changes the buffer or disables the stream.
449 */
450
451/**
452 * struct drm_vmw_rect
453 *
454 * Defines a rectangle. Used in the overlay ioctl to define
455 * source and destination rectangle.
456 */
457
458struct drm_vmw_rect {
459 int32_t x;
460 int32_t y;
461 uint32_t w;
462 uint32_t h;
463};
464
465/**
466 * struct drm_vmw_control_stream_arg
467 *
468 * @stream_id: Stearm to control
469 * @enabled: If false all following arguments are ignored.
470 * @handle: Handle to buffer for getting data from.
471 * @format: Format of the overlay as understood by the host.
472 * @width: Width of the overlay.
473 * @height: Height of the overlay.
474 * @size: Size of the overlay in bytes.
475 * @pitch: Array of pitches, the two last are only used for YUV12 formats.
476 * @offset: Offset from start of dma buffer to overlay.
477 * @src: Source rect, must be within the defined area above.
478 * @dst: Destination rect, x and y may be negative.
479 *
480 * Argument to the DRM_VMW_CONTROL_STREAM Ioctl.
481 */
482
483struct drm_vmw_control_stream_arg {
484 uint32_t stream_id;
485 uint32_t enabled;
486
487 uint32_t flags;
488 uint32_t color_key;
489
490 uint32_t handle;
491 uint32_t offset;
492 int32_t format;
493 uint32_t size;
494 uint32_t width;
495 uint32_t height;
496 uint32_t pitch[3];
497
498 uint32_t pad64;
499 struct drm_vmw_rect src;
500 struct drm_vmw_rect dst;
501};
502
503/*************************************************************************/
504/**
505 * DRM_VMW_CURSOR_BYPASS - Give extra information about cursor bypass.
506 *
507 */
508
509#define DRM_VMW_CURSOR_BYPASS_ALL (1 << 0)
510#define DRM_VMW_CURSOR_BYPASS_FLAGS (1)
511
512/**
513 * struct drm_vmw_cursor_bypass_arg
514 *
515 * @flags: Flags.
516 * @crtc_id: Crtc id, only used if DMR_CURSOR_BYPASS_ALL isn't passed.
517 * @xpos: X position of cursor.
518 * @ypos: Y position of cursor.
519 * @xhot: X hotspot.
520 * @yhot: Y hotspot.
521 *
522 * Argument to the DRM_VMW_CURSOR_BYPASS Ioctl.
523 */
524
525struct drm_vmw_cursor_bypass_arg {
526 uint32_t flags;
527 uint32_t crtc_id;
528 int32_t xpos;
529 int32_t ypos;
530 int32_t xhot;
531 int32_t yhot;
532};
533
534/*************************************************************************/
535/**
536 * DRM_VMW_CLAIM_STREAM - Claim a single stream.
537 */
538
539/**
540 * struct drm_vmw_context_arg
541 *
542 * @stream_id: Device unique context ID.
543 *
544 * Output argument to the DRM_VMW_CREATE_CONTEXT Ioctl.
545 * Input argument to the DRM_VMW_UNREF_CONTEXT Ioctl.
546 */
547
548struct drm_vmw_stream_arg {
549 uint32_t stream_id;
550 uint32_t pad64;
551};
552
553/*************************************************************************/
554/**
555 * DRM_VMW_UNREF_STREAM - Unclaim a stream.
556 *
557 * Return a single stream that was claimed by this process. Also makes
558 * sure that the stream has been stopped.
559 */
560
Jakob Bornecrantzd8bd19d2010-06-01 11:54:20 +0200561/*************************************************************************/
562/**
563 * DRM_VMW_UPDATE_LAYOUT - Update layout
564 *
Lucas De Marchi25985ed2011-03-30 22:57:33 -0300565 * Updates the preferred modes and connection status for connectors. The
Jakob Bornecrantzd8bd19d2010-06-01 11:54:20 +0200566 * command conisits of one drm_vmw_update_layout_arg pointing out a array
567 * of num_outputs drm_vmw_rect's.
568 */
569
570/**
571 * struct drm_vmw_update_layout_arg
572 *
573 * @num_outputs: number of active
574 * @rects: pointer to array of drm_vmw_rect
575 *
576 * Input argument to the DRM_VMW_UPDATE_LAYOUT Ioctl.
577 */
578
579struct drm_vmw_update_layout_arg {
580 uint32_t num_outputs;
581 uint32_t pad64;
582 uint64_t rects;
583};
584
Jakob Bornecrantzfb1d9732009-12-10 00:19:58 +0000585#endif