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