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