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