aboutsummaryrefslogtreecommitdiffstats
path: root/include/drm/drmP.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/drm/drmP.h')
-rw-r--r--include/drm/drmP.h108
1 files changed, 92 insertions, 16 deletions
diff --git a/include/drm/drmP.h b/include/drm/drmP.h
index d5e8e5c89548..afb7858c068d 100644
--- a/include/drm/drmP.h
+++ b/include/drm/drmP.h
@@ -105,6 +105,7 @@ struct drm_device;
105#define DRIVER_FB_DMA 0x400 105#define DRIVER_FB_DMA 0x400
106#define DRIVER_IRQ_VBL2 0x800 106#define DRIVER_IRQ_VBL2 0x800
107#define DRIVER_GEM 0x1000 107#define DRIVER_GEM 0x1000
108#define DRIVER_MODESET 0x2000
108 109
109/***********************************************************************/ 110/***********************************************************************/
110/** \name Begin the DRM... */ 111/** \name Begin the DRM... */
@@ -238,11 +239,11 @@ struct drm_device;
238 */ 239 */
239#define LOCK_TEST_WITH_RETURN( dev, file_priv ) \ 240#define LOCK_TEST_WITH_RETURN( dev, file_priv ) \
240do { \ 241do { \
241 if ( !_DRM_LOCK_IS_HELD( dev->lock.hw_lock->lock ) || \ 242 if (!_DRM_LOCK_IS_HELD(file_priv->master->lock.hw_lock->lock) || \
242 dev->lock.file_priv != file_priv ) { \ 243 file_priv->master->lock.file_priv != file_priv) { \
243 DRM_ERROR( "%s called without lock held, held %d owner %p %p\n",\ 244 DRM_ERROR( "%s called without lock held, held %d owner %p %p\n",\
244 __func__, _DRM_LOCK_IS_HELD( dev->lock.hw_lock->lock ),\ 245 __func__, _DRM_LOCK_IS_HELD(file_priv->master->lock.hw_lock->lock),\
245 dev->lock.file_priv, file_priv ); \ 246 file_priv->master->lock.file_priv, file_priv); \
246 return -EINVAL; \ 247 return -EINVAL; \
247 } \ 248 } \
248} while (0) 249} while (0)
@@ -276,6 +277,7 @@ typedef int drm_ioctl_compat_t(struct file *filp, unsigned int cmd,
276#define DRM_AUTH 0x1 277#define DRM_AUTH 0x1
277#define DRM_MASTER 0x2 278#define DRM_MASTER 0x2
278#define DRM_ROOT_ONLY 0x4 279#define DRM_ROOT_ONLY 0x4
280#define DRM_CONTROL_ALLOW 0x8
279 281
280struct drm_ioctl_desc { 282struct drm_ioctl_desc {
281 unsigned int cmd; 283 unsigned int cmd;
@@ -379,21 +381,26 @@ struct drm_buf_entry {
379/** File private data */ 381/** File private data */
380struct drm_file { 382struct drm_file {
381 int authenticated; 383 int authenticated;
382 int master;
383 pid_t pid; 384 pid_t pid;
384 uid_t uid; 385 uid_t uid;
385 drm_magic_t magic; 386 drm_magic_t magic;
386 unsigned long ioctl_count; 387 unsigned long ioctl_count;
387 struct list_head lhead; 388 struct list_head lhead;
388 struct drm_minor *minor; 389 struct drm_minor *minor;
389 int remove_auth_on_close;
390 unsigned long lock_count; 390 unsigned long lock_count;
391
391 /** Mapping of mm object handles to object pointers. */ 392 /** Mapping of mm object handles to object pointers. */
392 struct idr object_idr; 393 struct idr object_idr;
393 /** Lock for synchronization of access to object_idr. */ 394 /** Lock for synchronization of access to object_idr. */
394 spinlock_t table_lock; 395 spinlock_t table_lock;
396
395 struct file *filp; 397 struct file *filp;
396 void *driver_priv; 398 void *driver_priv;
399
400 int is_master; /* this file private is a master for a minor */
401 struct drm_master *master; /* master this node is currently associated with
402 N.B. not always minor->master */
403 struct list_head fbs;
397}; 404};
398 405
399/** Wait queue */ 406/** Wait queue */
@@ -523,6 +530,8 @@ struct drm_map_list {
523 struct drm_hash_item hash; 530 struct drm_hash_item hash;
524 struct drm_map *map; /**< mapping */ 531 struct drm_map *map; /**< mapping */
525 uint64_t user_token; 532 uint64_t user_token;
533 struct drm_master *master;
534 struct drm_mm_node *file_offset_node; /**< fake offset */
526}; 535};
527 536
528typedef struct drm_map drm_local_map_t; 537typedef struct drm_map drm_local_map_t;
@@ -563,6 +572,14 @@ struct drm_ati_pcigart_info {
563}; 572};
564 573
565/** 574/**
575 * GEM specific mm private for tracking GEM objects
576 */
577struct drm_gem_mm {
578 struct drm_mm offset_manager; /**< Offset mgmt for buffer objects */
579 struct drm_open_hash offset_hash; /**< User token hash table for maps */
580};
581
582/**
566 * This structure defines the drm_mm memory object, which will be used by the 583 * This structure defines the drm_mm memory object, which will be used by the
567 * DRM for its buffer objects. 584 * DRM for its buffer objects.
568 */ 585 */
@@ -579,6 +596,9 @@ struct drm_gem_object {
579 /** File representing the shmem storage */ 596 /** File representing the shmem storage */
580 struct file *filp; 597 struct file *filp;
581 598
599 /* Mapping info for this object */
600 struct drm_map_list map_list;
601
582 /** 602 /**
583 * Size of the object, in bytes. Immutable over the object's 603 * Size of the object, in bytes. Immutable over the object's
584 * lifetime. 604 * lifetime.
@@ -612,6 +632,33 @@ struct drm_gem_object {
612 void *driver_private; 632 void *driver_private;
613}; 633};
614 634
635#include "drm_crtc.h"
636
637/* per-master structure */
638struct drm_master {
639
640 struct kref refcount; /* refcount for this master */
641
642 struct list_head head; /**< each minor contains a list of masters */
643 struct drm_minor *minor; /**< link back to minor we are a master for */
644
645 char *unique; /**< Unique identifier: e.g., busid */
646 int unique_len; /**< Length of unique field */
647 int unique_size; /**< amount allocated */
648
649 int blocked; /**< Blocked due to VC switch? */
650
651 /** \name Authentication */
652 /*@{ */
653 struct drm_open_hash magiclist;
654 struct list_head magicfree;
655 /*@} */
656
657 struct drm_lock_data lock; /**< Information on hardware lock */
658
659 void *driver_priv; /**< Private structure for driver to use */
660};
661
615/** 662/**
616 * DRM driver structure. This structure represent the common code for 663 * DRM driver structure. This structure represent the common code for
617 * a family of cards. There will one drm_device for each card present 664 * a family of cards. There will one drm_device for each card present
@@ -712,6 +759,10 @@ struct drm_driver {
712 void (*set_version) (struct drm_device *dev, 759 void (*set_version) (struct drm_device *dev,
713 struct drm_set_version *sv); 760 struct drm_set_version *sv);
714 761
762 /* Master routines */
763 int (*master_create)(struct drm_device *dev, struct drm_master *master);
764 void (*master_destroy)(struct drm_device *dev, struct drm_master *master);
765
715 int (*proc_init)(struct drm_minor *minor); 766 int (*proc_init)(struct drm_minor *minor);
716 void (*proc_cleanup)(struct drm_minor *minor); 767 void (*proc_cleanup)(struct drm_minor *minor);
717 768
@@ -724,6 +775,9 @@ struct drm_driver {
724 int (*gem_init_object) (struct drm_gem_object *obj); 775 int (*gem_init_object) (struct drm_gem_object *obj);
725 void (*gem_free_object) (struct drm_gem_object *obj); 776 void (*gem_free_object) (struct drm_gem_object *obj);
726 777
778 /* Driver private ops for this object */
779 struct vm_operations_struct *gem_vm_ops;
780
727 int major; 781 int major;
728 int minor; 782 int minor;
729 int patchlevel; 783 int patchlevel;
@@ -737,10 +791,14 @@ struct drm_driver {
737 int num_ioctls; 791 int num_ioctls;
738 struct file_operations fops; 792 struct file_operations fops;
739 struct pci_driver pci_driver; 793 struct pci_driver pci_driver;
794 /* List of devices hanging off this driver */
795 struct list_head device_list;
740}; 796};
741 797
742#define DRM_MINOR_UNASSIGNED 0 798#define DRM_MINOR_UNASSIGNED 0
743#define DRM_MINOR_LEGACY 1 799#define DRM_MINOR_LEGACY 1
800#define DRM_MINOR_CONTROL 2
801#define DRM_MINOR_RENDER 3
744 802
745/** 803/**
746 * DRM minor structure. This structure represents a drm minor number. 804 * DRM minor structure. This structure represents a drm minor number.
@@ -752,6 +810,9 @@ struct drm_minor {
752 struct device kdev; /**< Linux device */ 810 struct device kdev; /**< Linux device */
753 struct drm_device *dev; 811 struct drm_device *dev;
754 struct proc_dir_entry *dev_root; /**< proc directory entry */ 812 struct proc_dir_entry *dev_root; /**< proc directory entry */
813 struct drm_master *master; /* currently active master for this node */
814 struct list_head master_list;
815 struct drm_mode_group mode_group;
755}; 816};
756 817
757/** 818/**
@@ -759,13 +820,10 @@ struct drm_minor {
759 * may contain multiple heads. 820 * may contain multiple heads.
760 */ 821 */
761struct drm_device { 822struct drm_device {
762 char *unique; /**< Unique identifier: e.g., busid */ 823 struct list_head driver_item; /**< list of devices per driver */
763 int unique_len; /**< Length of unique field */
764 char *devname; /**< For /proc/interrupts */ 824 char *devname; /**< For /proc/interrupts */
765 int if_version; /**< Highest interface version set */ 825 int if_version; /**< Highest interface version set */
766 826
767 int blocked; /**< Blocked due to VC switch? */
768
769 /** \name Locks */ 827 /** \name Locks */
770 /*@{ */ 828 /*@{ */
771 spinlock_t count_lock; /**< For inuse, drm_device::open_count, drm_device::buf_use */ 829 spinlock_t count_lock; /**< For inuse, drm_device::open_count, drm_device::buf_use */
@@ -788,12 +846,7 @@ struct drm_device {
788 atomic_t counts[15]; 846 atomic_t counts[15];
789 /*@} */ 847 /*@} */
790 848
791 /** \name Authentication */
792 /*@{ */
793 struct list_head filelist; 849 struct list_head filelist;
794 struct drm_open_hash magiclist; /**< magic hash table */
795 struct list_head magicfree;
796 /*@} */
797 850
798 /** \name Memory management */ 851 /** \name Memory management */
799 /*@{ */ 852 /*@{ */
@@ -810,7 +863,7 @@ struct drm_device {
810 struct idr ctx_idr; 863 struct idr ctx_idr;
811 864
812 struct list_head vmalist; /**< List of vmas (for debugging) */ 865 struct list_head vmalist; /**< List of vmas (for debugging) */
813 struct drm_lock_data lock; /**< Information on hardware lock */ 866
814 /*@} */ 867 /*@} */
815 868
816 /** \name DMA queues (contexts) */ 869 /** \name DMA queues (contexts) */
@@ -858,6 +911,7 @@ struct drm_device {
858 int *vblank_enabled; /* so we don't call enable more than 911 int *vblank_enabled; /* so we don't call enable more than
859 once per disable */ 912 once per disable */
860 int *vblank_inmodeset; /* Display driver is setting mode */ 913 int *vblank_inmodeset; /* Display driver is setting mode */
914 u32 *last_vblank_wait; /* Last vblank seqno waited per CRTC */
861 struct timer_list vblank_disable_timer; 915 struct timer_list vblank_disable_timer;
862 916
863 u32 max_vblank_count; /**< size of vblank counter register */ 917 u32 max_vblank_count; /**< size of vblank counter register */
@@ -881,12 +935,15 @@ struct drm_device {
881 struct drm_sg_mem *sg; /**< Scatter gather memory */ 935 struct drm_sg_mem *sg; /**< Scatter gather memory */
882 int num_crtcs; /**< Number of CRTCs on this device */ 936 int num_crtcs; /**< Number of CRTCs on this device */
883 void *dev_private; /**< device private data */ 937 void *dev_private; /**< device private data */
938 void *mm_private;
939 struct address_space *dev_mapping;
884 struct drm_sigdata sigdata; /**< For block_all_signals */ 940 struct drm_sigdata sigdata; /**< For block_all_signals */
885 sigset_t sigmask; 941 sigset_t sigmask;
886 942
887 struct drm_driver *driver; 943 struct drm_driver *driver;
888 drm_local_map_t *agp_buffer_map; 944 drm_local_map_t *agp_buffer_map;
889 unsigned int agp_buffer_token; 945 unsigned int agp_buffer_token;
946 struct drm_minor *control; /**< Control node for card */
890 struct drm_minor *primary; /**< render type primary screen head */ 947 struct drm_minor *primary; /**< render type primary screen head */
891 948
892 /** \name Drawable information */ 949 /** \name Drawable information */
@@ -895,6 +952,8 @@ struct drm_device {
895 struct idr drw_idr; 952 struct idr drw_idr;
896 /*@} */ 953 /*@} */
897 954
955 struct drm_mode_config mode_config; /**< Current mode config */
956
898 /** \name GEM information */ 957 /** \name GEM information */
899 /*@{ */ 958 /*@{ */
900 spinlock_t object_name_lock; 959 spinlock_t object_name_lock;
@@ -997,6 +1056,8 @@ extern int drm_release(struct inode *inode, struct file *filp);
997 1056
998 /* Mapping support (drm_vm.h) */ 1057 /* Mapping support (drm_vm.h) */
999extern int drm_mmap(struct file *filp, struct vm_area_struct *vma); 1058extern int drm_mmap(struct file *filp, struct vm_area_struct *vma);
1059extern int drm_mmap_locked(struct file *filp, struct vm_area_struct *vma);
1060extern void drm_vm_open_locked(struct vm_area_struct *vma);
1000extern unsigned long drm_core_get_map_ofs(struct drm_map * map); 1061extern unsigned long drm_core_get_map_ofs(struct drm_map * map);
1001extern unsigned long drm_core_get_reg_ofs(struct drm_device *dev); 1062extern unsigned long drm_core_get_reg_ofs(struct drm_device *dev);
1002extern unsigned int drm_poll(struct file *filp, struct poll_table_struct *wait); 1063extern unsigned int drm_poll(struct file *filp, struct poll_table_struct *wait);
@@ -1153,6 +1214,8 @@ extern int drm_vblank_get(struct drm_device *dev, int crtc);
1153extern void drm_vblank_put(struct drm_device *dev, int crtc); 1214extern void drm_vblank_put(struct drm_device *dev, int crtc);
1154extern void drm_vblank_cleanup(struct drm_device *dev); 1215extern void drm_vblank_cleanup(struct drm_device *dev);
1155/* Modesetting support */ 1216/* Modesetting support */
1217extern void drm_vblank_pre_modeset(struct drm_device *dev, int crtc);
1218extern void drm_vblank_post_modeset(struct drm_device *dev, int crtc);
1156extern int drm_modeset_ctl(struct drm_device *dev, void *data, 1219extern int drm_modeset_ctl(struct drm_device *dev, void *data,
1157 struct drm_file *file_priv); 1220 struct drm_file *file_priv);
1158 1221
@@ -1189,6 +1252,13 @@ extern int drm_agp_unbind_memory(DRM_AGP_MEM * handle);
1189extern void drm_agp_chipset_flush(struct drm_device *dev); 1252extern void drm_agp_chipset_flush(struct drm_device *dev);
1190 1253
1191 /* Stub support (drm_stub.h) */ 1254 /* Stub support (drm_stub.h) */
1255extern int drm_setmaster_ioctl(struct drm_device *dev, void *data,
1256 struct drm_file *file_priv);
1257extern int drm_dropmaster_ioctl(struct drm_device *dev, void *data,
1258 struct drm_file *file_priv);
1259struct drm_master *drm_master_create(struct drm_minor *minor);
1260extern struct drm_master *drm_master_get(struct drm_master *master);
1261extern void drm_master_put(struct drm_master **master);
1192extern int drm_get_dev(struct pci_dev *pdev, const struct pci_device_id *ent, 1262extern int drm_get_dev(struct pci_dev *pdev, const struct pci_device_id *ent,
1193 struct drm_driver *driver); 1263 struct drm_driver *driver);
1194extern int drm_put_dev(struct drm_device *dev); 1264extern int drm_put_dev(struct drm_device *dev);
@@ -1231,7 +1301,11 @@ struct drm_sysfs_class;
1231extern struct class *drm_sysfs_create(struct module *owner, char *name); 1301extern struct class *drm_sysfs_create(struct module *owner, char *name);
1232extern void drm_sysfs_destroy(void); 1302extern void drm_sysfs_destroy(void);
1233extern int drm_sysfs_device_add(struct drm_minor *minor); 1303extern int drm_sysfs_device_add(struct drm_minor *minor);
1304extern void drm_sysfs_hotplug_event(struct drm_device *dev);
1234extern void drm_sysfs_device_remove(struct drm_minor *minor); 1305extern void drm_sysfs_device_remove(struct drm_minor *minor);
1306extern char *drm_get_connector_status_name(enum drm_connector_status status);
1307extern int drm_sysfs_connector_add(struct drm_connector *connector);
1308extern void drm_sysfs_connector_remove(struct drm_connector *connector);
1235 1309
1236/* 1310/*
1237 * Basic memory manager support (drm_mm.c) 1311 * Basic memory manager support (drm_mm.c)
@@ -1251,10 +1325,12 @@ extern int drm_mm_add_space_to_tail(struct drm_mm *mm, unsigned long size);
1251 1325
1252/* Graphics Execution Manager library functions (drm_gem.c) */ 1326/* Graphics Execution Manager library functions (drm_gem.c) */
1253int drm_gem_init(struct drm_device *dev); 1327int drm_gem_init(struct drm_device *dev);
1328void drm_gem_destroy(struct drm_device *dev);
1254void drm_gem_object_free(struct kref *kref); 1329void drm_gem_object_free(struct kref *kref);
1255struct drm_gem_object *drm_gem_object_alloc(struct drm_device *dev, 1330struct drm_gem_object *drm_gem_object_alloc(struct drm_device *dev,
1256 size_t size); 1331 size_t size);
1257void drm_gem_object_handle_free(struct kref *kref); 1332void drm_gem_object_handle_free(struct kref *kref);
1333int drm_gem_mmap(struct file *filp, struct vm_area_struct *vma);
1258 1334
1259static inline void 1335static inline void
1260drm_gem_object_reference(struct drm_gem_object *obj) 1336drm_gem_object_reference(struct drm_gem_object *obj)