Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
drm.h
Go to the documentation of this file.
1 
11 /*
12  * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
13  * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
14  * All rights reserved.
15  *
16  * Permission is hereby granted, free of charge, to any person obtaining a
17  * copy of this software and associated documentation files (the "Software"),
18  * to deal in the Software without restriction, including without limitation
19  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
20  * and/or sell copies of the Software, and to permit persons to whom the
21  * Software is furnished to do so, subject to the following conditions:
22  *
23  * The above copyright notice and this permission notice (including the next
24  * paragraph) shall be included in all copies or substantial portions of the
25  * Software.
26  *
27  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
28  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
29  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
30  * VA LINUX SYSTEMS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
31  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
32  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
33  * OTHER DEALINGS IN THE SOFTWARE.
34  */
35 
36 #ifndef _DRM_H_
37 #define _DRM_H_
38 
39 #if defined(__linux__)
40 
41 #include <linux/types.h>
42 #include <asm/ioctl.h>
43 typedef unsigned int drm_handle_t;
44 
45 #else /* One of the BSDs */
46 
47 #include <sys/ioccom.h>
48 #include <sys/types.h>
49 typedef int8_t __s8;
50 typedef uint8_t __u8;
51 typedef int16_t __s16;
52 typedef uint16_t __u16;
53 typedef int32_t __s32;
54 typedef uint32_t __u32;
55 typedef int64_t __s64;
56 typedef uint64_t __u64;
57 typedef unsigned long drm_handle_t;
58 
59 #endif
60 
61 #define DRM_NAME "drm"
62 #define DRM_MIN_ORDER 5
63 #define DRM_MAX_ORDER 22
64 #define DRM_RAM_PERCENT 10
66 #define _DRM_LOCK_HELD 0x80000000U
67 #define _DRM_LOCK_CONT 0x40000000U
68 #define _DRM_LOCK_IS_HELD(lock) ((lock) & _DRM_LOCK_HELD)
69 #define _DRM_LOCK_IS_CONT(lock) ((lock) & _DRM_LOCK_CONT)
70 #define _DRM_LOCKING_CONTEXT(lock) ((lock) & ~(_DRM_LOCK_HELD|_DRM_LOCK_CONT))
71 
72 typedef unsigned int drm_context_t;
73 typedef unsigned int drm_drawable_t;
74 typedef unsigned int drm_magic_t;
75 
85 struct drm_clip_rect {
86  unsigned short x1;
87  unsigned short y1;
88  unsigned short x2;
89  unsigned short y2;
90 };
91 
96  unsigned int num_rects;
98 };
99 
104  unsigned char next;
105  unsigned char prev;
106  unsigned char in_use;
107  unsigned char padding;
108  unsigned int age;
109 };
110 
118 struct drm_hw_lock {
119  __volatile__ unsigned int lock;
120  char padding[60];
121 };
122 
128 struct drm_version {
132  size_t name_len;
133  char __user *name;
134  size_t date_len;
135  char __user *date;
136  size_t desc_len;
137  char __user *desc;
138 };
139 
145 struct drm_unique {
146  size_t unique_len;
147  char __user *unique;
148 };
149 
150 struct drm_list {
151  int count;
153 };
154 
155 struct drm_block {
156  int unused;
157 };
158 
164 struct drm_control {
165  enum {
170  } func;
171  int irq;
172 };
173 
180  _DRM_SHM = 2,
181  _DRM_AGP = 3,
184  _DRM_GEM = 6,
185 };
186 
193  _DRM_LOCKED = 0x04,
194  _DRM_KERNEL = 0x08,
197  _DRM_REMOVABLE = 0x40,
198  _DRM_DRIVER = 0x80
199 };
200 
202  unsigned int ctx_id;
203  void *handle;
204 };
205 
212 struct drm_map {
213  unsigned long offset;
214  unsigned long size;
217  void *handle;
219  int mtrr;
220  /* Private data */
221 };
222 
226 struct drm_client {
227  int idx;
228  int auth;
229  unsigned long pid;
230  unsigned long uid;
231  unsigned long magic;
232  unsigned long iocs;
233 };
234 
252  /* Add to the *END* of the list */
253 };
254 
258 struct drm_stats {
259  unsigned long count;
260  struct {
261  unsigned long value;
263  } data[15];
264 };
265 
274  /* These *HALT* flags aren't supported yet
275  -- they will be used to support the
276  full-screen DGA-like mode. */
279 };
280 
286 struct drm_lock {
287  int context;
289 };
290 
300  /* Flags for DMA buffer dispatch */
301  _DRM_DMA_BLOCK = 0x01,
314  /* Flags for DMA buffer request */
315  _DRM_DMA_WAIT = 0x10,
318 };
319 
325 struct drm_buf_desc {
326  int count;
327  int size;
328  int low_mark;
329  int high_mark;
330  enum {
333  _DRM_SG_BUFFER = 0x04,
334  _DRM_FB_BUFFER = 0x08,
336  } flags;
337  unsigned long agp_start;
341 };
342 
346 struct drm_buf_info {
347  int count;
349 };
350 
354 struct drm_buf_free {
355  int count;
356  int __user *list;
357 };
358 
364 struct drm_buf_pub {
365  int idx;
366  int total;
367  int used;
368  void __user *address;
369 };
370 
374 struct drm_buf_map {
375  int count;
376  void __user *virtual;
378 };
379 
387 struct drm_dma {
388  int context;
398 };
399 
403 };
404 
410 struct drm_ctx {
413 };
414 
418 struct drm_ctx_res {
419  int count;
421 };
422 
426 struct drm_draw {
428 };
429 
433 typedef enum {
436 
439  unsigned int type;
440  unsigned int num;
441  unsigned long long data;
442 };
443 
447 struct drm_auth {
449 };
450 
457  int irq;
458  int busnum;
459  int devnum;
460  int funcnum;
461 };
462 
466  /* bits 1-6 are reserved for high crtcs */
468  _DRM_VBLANK_EVENT = 0x4000000,
469  _DRM_VBLANK_FLIP = 0x8000000,
470  _DRM_VBLANK_NEXTONMISS = 0x10000000,
471  _DRM_VBLANK_SECONDARY = 0x20000000,
472  _DRM_VBLANK_SIGNAL = 0x40000000
473 };
474 #define _DRM_VBLANK_HIGH_CRTC_SHIFT 1
475 
476 #define _DRM_VBLANK_TYPES_MASK (_DRM_VBLANK_ABSOLUTE | _DRM_VBLANK_RELATIVE)
477 #define _DRM_VBLANK_FLAGS_MASK (_DRM_VBLANK_EVENT | _DRM_VBLANK_SIGNAL | \
478  _DRM_VBLANK_SECONDARY | _DRM_VBLANK_NEXTONMISS)
479 
482  unsigned int sequence;
483  unsigned long signal;
484 };
485 
488  unsigned int sequence;
489  long tval_sec;
490  long tval_usec;
491 };
492 
501 };
502 
503 #define _DRM_PRE_MODESET 1
504 #define _DRM_POST_MODESET 2
505 
514 };
515 
521 struct drm_agp_mode {
522  unsigned long mode;
523 };
524 
531  unsigned long size;
532  unsigned long handle;
533  unsigned long type;
534  unsigned long physical;
535 };
536 
543  unsigned long handle;
544  unsigned long offset;
545 };
546 
554 struct drm_agp_info {
557  unsigned long mode;
558  unsigned long aperture_base; /* physical address */
559  unsigned long aperture_size; /* bytes */
560  unsigned long memory_allowed; /* bytes */
561  unsigned long memory_used;
562 
563  /* PCI information */
564  unsigned short id_vendor;
565  unsigned short id_device;
566 };
567 
572  unsigned long size;
573  unsigned long handle;
574 };
575 
584 };
585 
591 };
592 
597 
600 };
601 
603 struct drm_gem_open {
606 
609 
612 };
613 
615 struct drm_get_cap {
618 };
619 
620 #define DRM_CLOEXEC O_CLOEXEC
623 
626 
629 };
630 
631 #include <drm/drm_mode.h>
632 
633 #define DRM_IOCTL_BASE 'd'
634 #define DRM_IO(nr) _IO(DRM_IOCTL_BASE,nr)
635 #define DRM_IOR(nr,type) _IOR(DRM_IOCTL_BASE,nr,type)
636 #define DRM_IOW(nr,type) _IOW(DRM_IOCTL_BASE,nr,type)
637 #define DRM_IOWR(nr,type) _IOWR(DRM_IOCTL_BASE,nr,type)
638 
639 #define DRM_IOCTL_VERSION DRM_IOWR(0x00, struct drm_version)
640 #define DRM_IOCTL_GET_UNIQUE DRM_IOWR(0x01, struct drm_unique)
641 #define DRM_IOCTL_GET_MAGIC DRM_IOR( 0x02, struct drm_auth)
642 #define DRM_IOCTL_IRQ_BUSID DRM_IOWR(0x03, struct drm_irq_busid)
643 #define DRM_IOCTL_GET_MAP DRM_IOWR(0x04, struct drm_map)
644 #define DRM_IOCTL_GET_CLIENT DRM_IOWR(0x05, struct drm_client)
645 #define DRM_IOCTL_GET_STATS DRM_IOR( 0x06, struct drm_stats)
646 #define DRM_IOCTL_SET_VERSION DRM_IOWR(0x07, struct drm_set_version)
647 #define DRM_IOCTL_MODESET_CTL DRM_IOW(0x08, struct drm_modeset_ctl)
648 #define DRM_IOCTL_GEM_CLOSE DRM_IOW (0x09, struct drm_gem_close)
649 #define DRM_IOCTL_GEM_FLINK DRM_IOWR(0x0a, struct drm_gem_flink)
650 #define DRM_IOCTL_GEM_OPEN DRM_IOWR(0x0b, struct drm_gem_open)
651 #define DRM_IOCTL_GET_CAP DRM_IOWR(0x0c, struct drm_get_cap)
652 
653 #define DRM_IOCTL_SET_UNIQUE DRM_IOW( 0x10, struct drm_unique)
654 #define DRM_IOCTL_AUTH_MAGIC DRM_IOW( 0x11, struct drm_auth)
655 #define DRM_IOCTL_BLOCK DRM_IOWR(0x12, struct drm_block)
656 #define DRM_IOCTL_UNBLOCK DRM_IOWR(0x13, struct drm_block)
657 #define DRM_IOCTL_CONTROL DRM_IOW( 0x14, struct drm_control)
658 #define DRM_IOCTL_ADD_MAP DRM_IOWR(0x15, struct drm_map)
659 #define DRM_IOCTL_ADD_BUFS DRM_IOWR(0x16, struct drm_buf_desc)
660 #define DRM_IOCTL_MARK_BUFS DRM_IOW( 0x17, struct drm_buf_desc)
661 #define DRM_IOCTL_INFO_BUFS DRM_IOWR(0x18, struct drm_buf_info)
662 #define DRM_IOCTL_MAP_BUFS DRM_IOWR(0x19, struct drm_buf_map)
663 #define DRM_IOCTL_FREE_BUFS DRM_IOW( 0x1a, struct drm_buf_free)
664 
665 #define DRM_IOCTL_RM_MAP DRM_IOW( 0x1b, struct drm_map)
666 
667 #define DRM_IOCTL_SET_SAREA_CTX DRM_IOW( 0x1c, struct drm_ctx_priv_map)
668 #define DRM_IOCTL_GET_SAREA_CTX DRM_IOWR(0x1d, struct drm_ctx_priv_map)
669 
670 #define DRM_IOCTL_SET_MASTER DRM_IO(0x1e)
671 #define DRM_IOCTL_DROP_MASTER DRM_IO(0x1f)
672 
673 #define DRM_IOCTL_ADD_CTX DRM_IOWR(0x20, struct drm_ctx)
674 #define DRM_IOCTL_RM_CTX DRM_IOWR(0x21, struct drm_ctx)
675 #define DRM_IOCTL_MOD_CTX DRM_IOW( 0x22, struct drm_ctx)
676 #define DRM_IOCTL_GET_CTX DRM_IOWR(0x23, struct drm_ctx)
677 #define DRM_IOCTL_SWITCH_CTX DRM_IOW( 0x24, struct drm_ctx)
678 #define DRM_IOCTL_NEW_CTX DRM_IOW( 0x25, struct drm_ctx)
679 #define DRM_IOCTL_RES_CTX DRM_IOWR(0x26, struct drm_ctx_res)
680 #define DRM_IOCTL_ADD_DRAW DRM_IOWR(0x27, struct drm_draw)
681 #define DRM_IOCTL_RM_DRAW DRM_IOWR(0x28, struct drm_draw)
682 #define DRM_IOCTL_DMA DRM_IOWR(0x29, struct drm_dma)
683 #define DRM_IOCTL_LOCK DRM_IOW( 0x2a, struct drm_lock)
684 #define DRM_IOCTL_UNLOCK DRM_IOW( 0x2b, struct drm_lock)
685 #define DRM_IOCTL_FINISH DRM_IOW( 0x2c, struct drm_lock)
686 
687 #define DRM_IOCTL_PRIME_HANDLE_TO_FD DRM_IOWR(0x2d, struct drm_prime_handle)
688 #define DRM_IOCTL_PRIME_FD_TO_HANDLE DRM_IOWR(0x2e, struct drm_prime_handle)
689 
690 #define DRM_IOCTL_AGP_ACQUIRE DRM_IO( 0x30)
691 #define DRM_IOCTL_AGP_RELEASE DRM_IO( 0x31)
692 #define DRM_IOCTL_AGP_ENABLE DRM_IOW( 0x32, struct drm_agp_mode)
693 #define DRM_IOCTL_AGP_INFO DRM_IOR( 0x33, struct drm_agp_info)
694 #define DRM_IOCTL_AGP_ALLOC DRM_IOWR(0x34, struct drm_agp_buffer)
695 #define DRM_IOCTL_AGP_FREE DRM_IOW( 0x35, struct drm_agp_buffer)
696 #define DRM_IOCTL_AGP_BIND DRM_IOW( 0x36, struct drm_agp_binding)
697 #define DRM_IOCTL_AGP_UNBIND DRM_IOW( 0x37, struct drm_agp_binding)
698 
699 #define DRM_IOCTL_SG_ALLOC DRM_IOWR(0x38, struct drm_scatter_gather)
700 #define DRM_IOCTL_SG_FREE DRM_IOW( 0x39, struct drm_scatter_gather)
701 
702 #define DRM_IOCTL_WAIT_VBLANK DRM_IOWR(0x3a, union drm_wait_vblank)
703 
704 #define DRM_IOCTL_UPDATE_DRAW DRM_IOW(0x3f, struct drm_update_draw)
705 
706 #define DRM_IOCTL_MODE_GETRESOURCES DRM_IOWR(0xA0, struct drm_mode_card_res)
707 #define DRM_IOCTL_MODE_GETCRTC DRM_IOWR(0xA1, struct drm_mode_crtc)
708 #define DRM_IOCTL_MODE_SETCRTC DRM_IOWR(0xA2, struct drm_mode_crtc)
709 #define DRM_IOCTL_MODE_CURSOR DRM_IOWR(0xA3, struct drm_mode_cursor)
710 #define DRM_IOCTL_MODE_GETGAMMA DRM_IOWR(0xA4, struct drm_mode_crtc_lut)
711 #define DRM_IOCTL_MODE_SETGAMMA DRM_IOWR(0xA5, struct drm_mode_crtc_lut)
712 #define DRM_IOCTL_MODE_GETENCODER DRM_IOWR(0xA6, struct drm_mode_get_encoder)
713 #define DRM_IOCTL_MODE_GETCONNECTOR DRM_IOWR(0xA7, struct drm_mode_get_connector)
714 #define DRM_IOCTL_MODE_ATTACHMODE DRM_IOWR(0xA8, struct drm_mode_mode_cmd)
715 #define DRM_IOCTL_MODE_DETACHMODE DRM_IOWR(0xA9, struct drm_mode_mode_cmd)
716 
717 #define DRM_IOCTL_MODE_GETPROPERTY DRM_IOWR(0xAA, struct drm_mode_get_property)
718 #define DRM_IOCTL_MODE_SETPROPERTY DRM_IOWR(0xAB, struct drm_mode_connector_set_property)
719 #define DRM_IOCTL_MODE_GETPROPBLOB DRM_IOWR(0xAC, struct drm_mode_get_blob)
720 #define DRM_IOCTL_MODE_GETFB DRM_IOWR(0xAD, struct drm_mode_fb_cmd)
721 #define DRM_IOCTL_MODE_ADDFB DRM_IOWR(0xAE, struct drm_mode_fb_cmd)
722 #define DRM_IOCTL_MODE_RMFB DRM_IOWR(0xAF, unsigned int)
723 #define DRM_IOCTL_MODE_PAGE_FLIP DRM_IOWR(0xB0, struct drm_mode_crtc_page_flip)
724 #define DRM_IOCTL_MODE_DIRTYFB DRM_IOWR(0xB1, struct drm_mode_fb_dirty_cmd)
725 
726 #define DRM_IOCTL_MODE_CREATE_DUMB DRM_IOWR(0xB2, struct drm_mode_create_dumb)
727 #define DRM_IOCTL_MODE_MAP_DUMB DRM_IOWR(0xB3, struct drm_mode_map_dumb)
728 #define DRM_IOCTL_MODE_DESTROY_DUMB DRM_IOWR(0xB4, struct drm_mode_destroy_dumb)
729 #define DRM_IOCTL_MODE_GETPLANERESOURCES DRM_IOWR(0xB5, struct drm_mode_get_plane_res)
730 #define DRM_IOCTL_MODE_GETPLANE DRM_IOWR(0xB6, struct drm_mode_get_plane)
731 #define DRM_IOCTL_MODE_SETPLANE DRM_IOWR(0xB7, struct drm_mode_set_plane)
732 #define DRM_IOCTL_MODE_ADDFB2 DRM_IOWR(0xB8, struct drm_mode_fb_cmd2)
733 #define DRM_IOCTL_MODE_OBJ_GETPROPERTIES DRM_IOWR(0xB9, struct drm_mode_obj_get_properties)
734 #define DRM_IOCTL_MODE_OBJ_SETPROPERTY DRM_IOWR(0xBA, struct drm_mode_obj_set_property)
735 
744 #define DRM_COMMAND_BASE 0x40
745 #define DRM_COMMAND_END 0xA0
746 
759 struct drm_event {
762 };
763 
764 #define DRM_EVENT_VBLANK 0x01
765 #define DRM_EVENT_FLIP_COMPLETE 0x02
766 
768  struct drm_event base;
774 };
775 
776 #define DRM_CAP_DUMB_BUFFER 0x1
777 #define DRM_CAP_VBLANK_HIGH_CRTC 0x2
778 #define DRM_CAP_DUMB_PREFERRED_DEPTH 0x3
779 #define DRM_CAP_DUMB_PREFER_SHADOW 0x4
780 #define DRM_CAP_PRIME 0x5
781 
782 #define DRM_PRIME_CAP_IMPORT 0x1
783 #define DRM_PRIME_CAP_EXPORT 0x2
784 
785 /* typedef area */
786 #ifndef __KERNEL__
790 typedef struct drm_hw_lock drm_hw_lock_t;
791 typedef struct drm_version drm_version_t;
792 typedef struct drm_unique drm_unique_t;
793 typedef struct drm_list drm_list_t;
794 typedef struct drm_block drm_block_t;
795 typedef struct drm_control drm_control_t;
799 typedef struct drm_map drm_map_t;
800 typedef struct drm_client drm_client_t;
802 typedef struct drm_stats drm_stats_t;
804 typedef struct drm_lock drm_lock_t;
809 typedef struct drm_buf_pub drm_buf_pub_t;
810 typedef struct drm_buf_map drm_buf_map_t;
811 typedef struct drm_dma drm_dma_t;
815 typedef struct drm_ctx drm_ctx_t;
816 typedef struct drm_ctx_res drm_ctx_res_t;
817 typedef struct drm_draw drm_draw_t;
819 typedef struct drm_auth drm_auth_t;
822 
828 #endif
829 
830 #endif