diff options
author | Paul Moore <pmoore@redhat.com> | 2013-11-08 13:56:38 -0500 |
---|---|---|
committer | Paul Moore <pmoore@redhat.com> | 2013-11-08 13:56:38 -0500 |
commit | 94851b18d4eb94f8bbf0d9176f7429bd8e371f62 (patch) | |
tree | c3c743ac6323e1caf9e987d6946cc4b2333a8256 /include/drm/drmP.h | |
parent | 42d64e1add3a1ce8a787116036163b8724362145 (diff) | |
parent | 5e01dc7b26d9f24f39abace5da98ccbd6a5ceb52 (diff) |
Merge tag 'v3.12'
Linux 3.12
Diffstat (limited to 'include/drm/drmP.h')
-rw-r--r-- | include/drm/drmP.h | 247 |
1 files changed, 78 insertions, 169 deletions
diff --git a/include/drm/drmP.h b/include/drm/drmP.h index 12083dc862a9..b46fb45f2cca 100644 --- a/include/drm/drmP.h +++ b/include/drm/drmP.h | |||
@@ -45,7 +45,6 @@ | |||
45 | #include <linux/kernel.h> | 45 | #include <linux/kernel.h> |
46 | #include <linux/miscdevice.h> | 46 | #include <linux/miscdevice.h> |
47 | #include <linux/fs.h> | 47 | #include <linux/fs.h> |
48 | #include <linux/proc_fs.h> | ||
49 | #include <linux/init.h> | 48 | #include <linux/init.h> |
50 | #include <linux/file.h> | 49 | #include <linux/file.h> |
51 | #include <linux/platform_device.h> | 50 | #include <linux/platform_device.h> |
@@ -62,20 +61,18 @@ | |||
62 | #endif | 61 | #endif |
63 | #include <asm/mman.h> | 62 | #include <asm/mman.h> |
64 | #include <asm/uaccess.h> | 63 | #include <asm/uaccess.h> |
65 | #if defined(CONFIG_AGP) || defined(CONFIG_AGP_MODULE) | ||
66 | #include <linux/types.h> | 64 | #include <linux/types.h> |
67 | #include <linux/agp_backend.h> | 65 | #include <linux/agp_backend.h> |
68 | #endif | ||
69 | #include <linux/workqueue.h> | 66 | #include <linux/workqueue.h> |
70 | #include <linux/poll.h> | 67 | #include <linux/poll.h> |
71 | #include <asm/pgalloc.h> | 68 | #include <asm/pgalloc.h> |
72 | #include <drm/drm.h> | 69 | #include <drm/drm.h> |
73 | #include <drm/drm_sarea.h> | 70 | #include <drm/drm_sarea.h> |
71 | #include <drm/drm_vma_manager.h> | ||
74 | 72 | ||
75 | #include <linux/idr.h> | 73 | #include <linux/idr.h> |
76 | 74 | ||
77 | #define __OS_HAS_AGP (defined(CONFIG_AGP) || (defined(CONFIG_AGP_MODULE) && defined(MODULE))) | 75 | #define __OS_HAS_AGP (defined(CONFIG_AGP) || (defined(CONFIG_AGP_MODULE) && defined(MODULE))) |
78 | #define __OS_HAS_MTRR (defined(CONFIG_MTRR)) | ||
79 | 76 | ||
80 | struct module; | 77 | struct module; |
81 | 78 | ||
@@ -140,19 +137,15 @@ int drm_err(const char *func, const char *format, ...); | |||
140 | /* driver capabilities and requirements mask */ | 137 | /* driver capabilities and requirements mask */ |
141 | #define DRIVER_USE_AGP 0x1 | 138 | #define DRIVER_USE_AGP 0x1 |
142 | #define DRIVER_REQUIRE_AGP 0x2 | 139 | #define DRIVER_REQUIRE_AGP 0x2 |
143 | #define DRIVER_USE_MTRR 0x4 | ||
144 | #define DRIVER_PCI_DMA 0x8 | 140 | #define DRIVER_PCI_DMA 0x8 |
145 | #define DRIVER_SG 0x10 | 141 | #define DRIVER_SG 0x10 |
146 | #define DRIVER_HAVE_DMA 0x20 | 142 | #define DRIVER_HAVE_DMA 0x20 |
147 | #define DRIVER_HAVE_IRQ 0x40 | 143 | #define DRIVER_HAVE_IRQ 0x40 |
148 | #define DRIVER_IRQ_SHARED 0x80 | 144 | #define DRIVER_IRQ_SHARED 0x80 |
149 | #define DRIVER_IRQ_VBL 0x100 | ||
150 | #define DRIVER_DMA_QUEUE 0x200 | ||
151 | #define DRIVER_FB_DMA 0x400 | ||
152 | #define DRIVER_IRQ_VBL2 0x800 | ||
153 | #define DRIVER_GEM 0x1000 | 145 | #define DRIVER_GEM 0x1000 |
154 | #define DRIVER_MODESET 0x2000 | 146 | #define DRIVER_MODESET 0x2000 |
155 | #define DRIVER_PRIME 0x4000 | 147 | #define DRIVER_PRIME 0x4000 |
148 | #define DRIVER_RENDER 0x8000 | ||
156 | 149 | ||
157 | #define DRIVER_BUS_PCI 0x1 | 150 | #define DRIVER_BUS_PCI 0x1 |
158 | #define DRIVER_BUS_PLATFORM 0x2 | 151 | #define DRIVER_BUS_PLATFORM 0x2 |
@@ -168,13 +161,7 @@ int drm_err(const char *func, const char *format, ...); | |||
168 | #define DRM_MAGIC_HASH_ORDER 4 /**< Size of key hash table. Must be power of 2. */ | 161 | #define DRM_MAGIC_HASH_ORDER 4 /**< Size of key hash table. Must be power of 2. */ |
169 | #define DRM_KERNEL_CONTEXT 0 /**< Change drm_resctx if changed */ | 162 | #define DRM_KERNEL_CONTEXT 0 /**< Change drm_resctx if changed */ |
170 | #define DRM_RESERVED_CONTEXTS 1 /**< Change drm_resctx if changed */ | 163 | #define DRM_RESERVED_CONTEXTS 1 /**< Change drm_resctx if changed */ |
171 | #define DRM_LOOPING_LIMIT 5000000 | ||
172 | #define DRM_TIME_SLICE (HZ/20) /**< Time slice for GLXContexts */ | ||
173 | #define DRM_LOCK_SLICE 1 /**< Time slice for lock, in jiffies */ | ||
174 | |||
175 | #define DRM_FLAG_DEBUG 0x01 | ||
176 | 164 | ||
177 | #define DRM_MAX_CTXBITMAP (PAGE_SIZE * 8) | ||
178 | #define DRM_MAP_HASH_OFFSET 0x10000000 | 165 | #define DRM_MAP_HASH_OFFSET 0x10000000 |
179 | 166 | ||
180 | /*@}*/ | 167 | /*@}*/ |
@@ -263,9 +250,6 @@ int drm_err(const char *func, const char *format, ...); | |||
263 | 250 | ||
264 | #define DRM_ARRAY_SIZE(x) ARRAY_SIZE(x) | 251 | #define DRM_ARRAY_SIZE(x) ARRAY_SIZE(x) |
265 | 252 | ||
266 | #define DRM_LEFTCOUNT(x) (((x)->rp + (x)->count - (x)->wp) % ((x)->count + 1)) | ||
267 | #define DRM_BUFCOUNT(x) ((x)->count - DRM_LEFTCOUNT(x)) | ||
268 | |||
269 | #define DRM_IF_VERSION(maj, min) (maj << 16 | min) | 253 | #define DRM_IF_VERSION(maj, min) (maj << 16 | min) |
270 | 254 | ||
271 | /** | 255 | /** |
@@ -307,6 +291,7 @@ typedef int drm_ioctl_compat_t(struct file *filp, unsigned int cmd, | |||
307 | #define DRM_ROOT_ONLY 0x4 | 291 | #define DRM_ROOT_ONLY 0x4 |
308 | #define DRM_CONTROL_ALLOW 0x8 | 292 | #define DRM_CONTROL_ALLOW 0x8 |
309 | #define DRM_UNLOCKED 0x10 | 293 | #define DRM_UNLOCKED 0x10 |
294 | #define DRM_RENDER_ALLOW 0x20 | ||
310 | 295 | ||
311 | struct drm_ioctl_desc { | 296 | struct drm_ioctl_desc { |
312 | unsigned int cmd; | 297 | unsigned int cmd; |
@@ -587,7 +572,6 @@ struct drm_map_list { | |||
587 | struct drm_local_map *map; /**< mapping */ | 572 | struct drm_local_map *map; /**< mapping */ |
588 | uint64_t user_token; | 573 | uint64_t user_token; |
589 | struct drm_master *master; | 574 | struct drm_master *master; |
590 | struct drm_mm_node *file_offset_node; /**< fake offset */ | ||
591 | }; | 575 | }; |
592 | 576 | ||
593 | /** | 577 | /** |
@@ -622,8 +606,7 @@ struct drm_ati_pcigart_info { | |||
622 | * GEM specific mm private for tracking GEM objects | 606 | * GEM specific mm private for tracking GEM objects |
623 | */ | 607 | */ |
624 | struct drm_gem_mm { | 608 | struct drm_gem_mm { |
625 | struct drm_mm offset_manager; /**< Offset mgmt for buffer objects */ | 609 | struct drm_vma_offset_manager vma_manager; |
626 | struct drm_open_hash offset_hash; /**< User token hash table for maps */ | ||
627 | }; | 610 | }; |
628 | 611 | ||
629 | /** | 612 | /** |
@@ -634,8 +617,16 @@ struct drm_gem_object { | |||
634 | /** Reference count of this object */ | 617 | /** Reference count of this object */ |
635 | struct kref refcount; | 618 | struct kref refcount; |
636 | 619 | ||
637 | /** Handle count of this object. Each handle also holds a reference */ | 620 | /** |
638 | atomic_t handle_count; /* number of handles on this object */ | 621 | * handle_count - gem file_priv handle count of this object |
622 | * | ||
623 | * Each handle also holds a reference. Note that when the handle_count | ||
624 | * drops to 0 any global names (e.g. the id in the flink namespace) will | ||
625 | * be cleared. | ||
626 | * | ||
627 | * Protected by dev->object_name_lock. | ||
628 | * */ | ||
629 | unsigned handle_count; | ||
639 | 630 | ||
640 | /** Related drm device */ | 631 | /** Related drm device */ |
641 | struct drm_device *dev; | 632 | struct drm_device *dev; |
@@ -644,7 +635,7 @@ struct drm_gem_object { | |||
644 | struct file *filp; | 635 | struct file *filp; |
645 | 636 | ||
646 | /* Mapping info for this object */ | 637 | /* Mapping info for this object */ |
647 | struct drm_map_list map_list; | 638 | struct drm_vma_offset_node vma_node; |
648 | 639 | ||
649 | /** | 640 | /** |
650 | * Size of the object, in bytes. Immutable over the object's | 641 | * Size of the object, in bytes. Immutable over the object's |
@@ -678,10 +669,32 @@ struct drm_gem_object { | |||
678 | 669 | ||
679 | void *driver_private; | 670 | void *driver_private; |
680 | 671 | ||
681 | /* dma buf exported from this GEM object */ | 672 | /** |
682 | struct dma_buf *export_dma_buf; | 673 | * dma_buf - dma buf associated with this GEM object |
674 | * | ||
675 | * Pointer to the dma-buf associated with this gem object (either | ||
676 | * through importing or exporting). We break the resulting reference | ||
677 | * loop when the last gem handle for this object is released. | ||
678 | * | ||
679 | * Protected by obj->object_name_lock | ||
680 | */ | ||
681 | struct dma_buf *dma_buf; | ||
683 | 682 | ||
684 | /* dma buf attachment backing this object */ | 683 | /** |
684 | * import_attach - dma buf attachment backing this object | ||
685 | * | ||
686 | * Any foreign dma_buf imported as a gem object has this set to the | ||
687 | * attachment point for the device. This is invariant over the lifetime | ||
688 | * of a gem object. | ||
689 | * | ||
690 | * The driver's ->gem_free_object callback is responsible for cleaning | ||
691 | * up the dma_buf attachment and references acquired at import time. | ||
692 | * | ||
693 | * Note that the drm gem/prime core does not depend upon drivers setting | ||
694 | * this field any more. So for drivers where this doesn't make sense | ||
695 | * (e.g. virtual devices or a displaylink behind an usb bus) they can | ||
696 | * simply leave it as NULL. | ||
697 | */ | ||
685 | struct dma_buf_attachment *import_attach; | 698 | struct dma_buf_attachment *import_attach; |
686 | }; | 699 | }; |
687 | 700 | ||
@@ -737,6 +750,7 @@ struct drm_bus { | |||
737 | int (*irq_by_busid)(struct drm_device *dev, struct drm_irq_busid *p); | 750 | int (*irq_by_busid)(struct drm_device *dev, struct drm_irq_busid *p); |
738 | /* hooks that are for PCI */ | 751 | /* hooks that are for PCI */ |
739 | int (*agp_init)(struct drm_device *dev); | 752 | int (*agp_init)(struct drm_device *dev); |
753 | void (*agp_destroy)(struct drm_device *dev); | ||
740 | 754 | ||
741 | }; | 755 | }; |
742 | 756 | ||
@@ -885,8 +899,6 @@ struct drm_driver { | |||
885 | void (*irq_preinstall) (struct drm_device *dev); | 899 | void (*irq_preinstall) (struct drm_device *dev); |
886 | int (*irq_postinstall) (struct drm_device *dev); | 900 | int (*irq_postinstall) (struct drm_device *dev); |
887 | void (*irq_uninstall) (struct drm_device *dev); | 901 | void (*irq_uninstall) (struct drm_device *dev); |
888 | void (*set_version) (struct drm_device *dev, | ||
889 | struct drm_set_version *sv); | ||
890 | 902 | ||
891 | /* Master routines */ | 903 | /* Master routines */ |
892 | int (*master_create)(struct drm_device *dev, struct drm_master *master); | 904 | int (*master_create)(struct drm_device *dev, struct drm_master *master); |
@@ -966,7 +978,7 @@ struct drm_driver { | |||
966 | 978 | ||
967 | u32 driver_features; | 979 | u32 driver_features; |
968 | int dev_priv_size; | 980 | int dev_priv_size; |
969 | struct drm_ioctl_desc *ioctls; | 981 | const struct drm_ioctl_desc *ioctls; |
970 | int num_ioctls; | 982 | int num_ioctls; |
971 | const struct file_operations *fops; | 983 | const struct file_operations *fops; |
972 | union { | 984 | union { |
@@ -1037,8 +1049,6 @@ struct drm_minor { | |||
1037 | struct device kdev; /**< Linux device */ | 1049 | struct device kdev; /**< Linux device */ |
1038 | struct drm_device *dev; | 1050 | struct drm_device *dev; |
1039 | 1051 | ||
1040 | struct proc_dir_entry *proc_root; /**< proc directory entry */ | ||
1041 | struct drm_info_node proc_nodes; | ||
1042 | struct dentry *debugfs_root; | 1052 | struct dentry *debugfs_root; |
1043 | 1053 | ||
1044 | struct list_head debugfs_list; | 1054 | struct list_head debugfs_list; |
@@ -1131,12 +1141,7 @@ struct drm_device { | |||
1131 | /*@{ */ | 1141 | /*@{ */ |
1132 | int irq_enabled; /**< True if irq handler is enabled */ | 1142 | int irq_enabled; /**< True if irq handler is enabled */ |
1133 | __volatile__ long context_flag; /**< Context swapping flag */ | 1143 | __volatile__ long context_flag; /**< Context swapping flag */ |
1134 | __volatile__ long interrupt_flag; /**< Interruption handler flag */ | ||
1135 | __volatile__ long dma_flag; /**< DMA dispatch flag */ | ||
1136 | wait_queue_head_t context_wait; /**< Processes waiting on ctx switch */ | ||
1137 | int last_checked; /**< Last context checked for DMA */ | ||
1138 | int last_context; /**< Last current context */ | 1144 | int last_context; /**< Last current context */ |
1139 | unsigned long last_switch; /**< jiffies at last context switch */ | ||
1140 | /*@} */ | 1145 | /*@} */ |
1141 | 1146 | ||
1142 | struct work_struct work; | 1147 | struct work_struct work; |
@@ -1174,12 +1179,6 @@ struct drm_device { | |||
1174 | spinlock_t event_lock; | 1179 | spinlock_t event_lock; |
1175 | 1180 | ||
1176 | /*@} */ | 1181 | /*@} */ |
1177 | cycles_t ctx_start; | ||
1178 | cycles_t lck_start; | ||
1179 | |||
1180 | struct fasync_struct *buf_async;/**< Processes waiting for SIGIO */ | ||
1181 | wait_queue_head_t buf_readers; /**< Processes waiting to read */ | ||
1182 | wait_queue_head_t buf_writers; /**< Processes waiting to ctx switch */ | ||
1183 | 1182 | ||
1184 | struct drm_agp_head *agp; /**< AGP data */ | 1183 | struct drm_agp_head *agp; /**< AGP data */ |
1185 | 1184 | ||
@@ -1207,12 +1206,13 @@ struct drm_device { | |||
1207 | unsigned int agp_buffer_token; | 1206 | unsigned int agp_buffer_token; |
1208 | struct drm_minor *control; /**< Control node for card */ | 1207 | struct drm_minor *control; /**< Control node for card */ |
1209 | struct drm_minor *primary; /**< render type primary screen head */ | 1208 | struct drm_minor *primary; /**< render type primary screen head */ |
1209 | struct drm_minor *render; /**< render node for card */ | ||
1210 | 1210 | ||
1211 | struct drm_mode_config mode_config; /**< Current mode config */ | 1211 | struct drm_mode_config mode_config; /**< Current mode config */ |
1212 | 1212 | ||
1213 | /** \name GEM information */ | 1213 | /** \name GEM information */ |
1214 | /*@{ */ | 1214 | /*@{ */ |
1215 | spinlock_t object_name_lock; | 1215 | struct mutex object_name_lock; |
1216 | struct idr object_name_idr; | 1216 | struct idr object_name_idr; |
1217 | /*@} */ | 1217 | /*@} */ |
1218 | int switch_power_state; | 1218 | int switch_power_state; |
@@ -1223,6 +1223,7 @@ struct drm_device { | |||
1223 | #define DRM_SWITCH_POWER_ON 0 | 1223 | #define DRM_SWITCH_POWER_ON 0 |
1224 | #define DRM_SWITCH_POWER_OFF 1 | 1224 | #define DRM_SWITCH_POWER_OFF 1 |
1225 | #define DRM_SWITCH_POWER_CHANGING 2 | 1225 | #define DRM_SWITCH_POWER_CHANGING 2 |
1226 | #define DRM_SWITCH_POWER_DYNAMIC_OFF 3 | ||
1226 | 1227 | ||
1227 | static __inline__ int drm_core_check_feature(struct drm_device *dev, | 1228 | static __inline__ int drm_core_check_feature(struct drm_device *dev, |
1228 | int feature) | 1229 | int feature) |
@@ -1235,25 +1236,6 @@ static inline int drm_dev_to_irq(struct drm_device *dev) | |||
1235 | return dev->driver->bus->get_irq(dev); | 1236 | return dev->driver->bus->get_irq(dev); |
1236 | } | 1237 | } |
1237 | 1238 | ||
1238 | |||
1239 | #if __OS_HAS_AGP | ||
1240 | static inline int drm_core_has_AGP(struct drm_device *dev) | ||
1241 | { | ||
1242 | return drm_core_check_feature(dev, DRIVER_USE_AGP); | ||
1243 | } | ||
1244 | #else | ||
1245 | #define drm_core_has_AGP(dev) (0) | ||
1246 | #endif | ||
1247 | |||
1248 | #if __OS_HAS_MTRR | ||
1249 | static inline int drm_core_has_MTRR(struct drm_device *dev) | ||
1250 | { | ||
1251 | return drm_core_check_feature(dev, DRIVER_USE_MTRR); | ||
1252 | } | ||
1253 | #else | ||
1254 | #define drm_core_has_MTRR(dev) (0) | ||
1255 | #endif | ||
1256 | |||
1257 | static inline void drm_device_set_unplugged(struct drm_device *dev) | 1239 | static inline void drm_device_set_unplugged(struct drm_device *dev) |
1258 | { | 1240 | { |
1259 | smp_wmb(); | 1241 | smp_wmb(); |
@@ -1272,6 +1254,11 @@ static inline bool drm_modeset_is_locked(struct drm_device *dev) | |||
1272 | return mutex_is_locked(&dev->mode_config.mutex); | 1254 | return mutex_is_locked(&dev->mode_config.mutex); |
1273 | } | 1255 | } |
1274 | 1256 | ||
1257 | static inline bool drm_is_render_client(struct drm_file *file_priv) | ||
1258 | { | ||
1259 | return file_priv->minor->type == DRM_MINOR_RENDER; | ||
1260 | } | ||
1261 | |||
1275 | /******************************************************************/ | 1262 | /******************************************************************/ |
1276 | /** \name Internal function definitions */ | 1263 | /** \name Internal function definitions */ |
1277 | /*@{*/ | 1264 | /*@{*/ |
@@ -1287,7 +1274,6 @@ extern int drm_lastclose(struct drm_device *dev); | |||
1287 | extern struct mutex drm_global_mutex; | 1274 | extern struct mutex drm_global_mutex; |
1288 | extern int drm_open(struct inode *inode, struct file *filp); | 1275 | extern int drm_open(struct inode *inode, struct file *filp); |
1289 | extern int drm_stub_open(struct inode *inode, struct file *filp); | 1276 | extern int drm_stub_open(struct inode *inode, struct file *filp); |
1290 | extern int drm_fasync(int fd, struct file *filp, int on); | ||
1291 | extern ssize_t drm_read(struct file *filp, char __user *buffer, | 1277 | extern ssize_t drm_read(struct file *filp, char __user *buffer, |
1292 | size_t count, loff_t *offset); | 1278 | size_t count, loff_t *offset); |
1293 | extern int drm_release(struct inode *inode, struct file *filp); | 1279 | extern int drm_release(struct inode *inode, struct file *filp); |
@@ -1301,14 +1287,6 @@ extern unsigned int drm_poll(struct file *filp, struct poll_table_struct *wait); | |||
1301 | 1287 | ||
1302 | /* Memory management support (drm_memory.h) */ | 1288 | /* Memory management support (drm_memory.h) */ |
1303 | #include <drm/drm_memory.h> | 1289 | #include <drm/drm_memory.h> |
1304 | extern void drm_free_agp(DRM_AGP_MEM * handle, int pages); | ||
1305 | extern int drm_bind_agp(DRM_AGP_MEM * handle, unsigned int start); | ||
1306 | extern DRM_AGP_MEM *drm_agp_bind_pages(struct drm_device *dev, | ||
1307 | struct page **pages, | ||
1308 | unsigned long num_pages, | ||
1309 | uint32_t gtt_offset, | ||
1310 | uint32_t type); | ||
1311 | extern int drm_unbind_agp(DRM_AGP_MEM * handle); | ||
1312 | 1290 | ||
1313 | /* Misc. IOCTL support (drm_ioctl.h) */ | 1291 | /* Misc. IOCTL support (drm_ioctl.h) */ |
1314 | extern int drm_irq_by_busid(struct drm_device *dev, void *data, | 1292 | extern int drm_irq_by_busid(struct drm_device *dev, void *data, |
@@ -1335,8 +1313,6 @@ extern int drm_resctx(struct drm_device *dev, void *data, | |||
1335 | struct drm_file *file_priv); | 1313 | struct drm_file *file_priv); |
1336 | extern int drm_addctx(struct drm_device *dev, void *data, | 1314 | extern int drm_addctx(struct drm_device *dev, void *data, |
1337 | struct drm_file *file_priv); | 1315 | struct drm_file *file_priv); |
1338 | extern int drm_modctx(struct drm_device *dev, void *data, | ||
1339 | struct drm_file *file_priv); | ||
1340 | extern int drm_getctx(struct drm_device *dev, void *data, | 1316 | extern int drm_getctx(struct drm_device *dev, void *data, |
1341 | struct drm_file *file_priv); | 1317 | struct drm_file *file_priv); |
1342 | extern int drm_switchctx(struct drm_device *dev, void *data, | 1318 | extern int drm_switchctx(struct drm_device *dev, void *data, |
@@ -1405,11 +1381,12 @@ extern int drm_freebufs(struct drm_device *dev, void *data, | |||
1405 | struct drm_file *file_priv); | 1381 | struct drm_file *file_priv); |
1406 | extern int drm_mapbufs(struct drm_device *dev, void *data, | 1382 | extern int drm_mapbufs(struct drm_device *dev, void *data, |
1407 | struct drm_file *file_priv); | 1383 | struct drm_file *file_priv); |
1408 | extern int drm_order(unsigned long size); | 1384 | extern int drm_dma_ioctl(struct drm_device *dev, void *data, |
1385 | struct drm_file *file_priv); | ||
1409 | 1386 | ||
1410 | /* DMA support (drm_dma.h) */ | 1387 | /* DMA support (drm_dma.h) */ |
1411 | extern int drm_dma_setup(struct drm_device *dev); | 1388 | extern int drm_legacy_dma_setup(struct drm_device *dev); |
1412 | extern void drm_dma_takedown(struct drm_device *dev); | 1389 | extern void drm_legacy_dma_takedown(struct drm_device *dev); |
1413 | extern void drm_free_buffer(struct drm_device *dev, struct drm_buf * buf); | 1390 | extern void drm_free_buffer(struct drm_device *dev, struct drm_buf * buf); |
1414 | extern void drm_core_reclaim_buffers(struct drm_device *dev, | 1391 | extern void drm_core_reclaim_buffers(struct drm_device *dev, |
1415 | struct drm_file *filp); | 1392 | struct drm_file *filp); |
@@ -1423,7 +1400,6 @@ extern int drm_irq_uninstall(struct drm_device *dev); | |||
1423 | extern int drm_vblank_init(struct drm_device *dev, int num_crtcs); | 1400 | extern int drm_vblank_init(struct drm_device *dev, int num_crtcs); |
1424 | extern int drm_wait_vblank(struct drm_device *dev, void *data, | 1401 | extern int drm_wait_vblank(struct drm_device *dev, void *data, |
1425 | struct drm_file *filp); | 1402 | struct drm_file *filp); |
1426 | extern int drm_vblank_wait(struct drm_device *dev, unsigned int *vbl_seq); | ||
1427 | extern u32 drm_vblank_count(struct drm_device *dev, int crtc); | 1403 | extern u32 drm_vblank_count(struct drm_device *dev, int crtc); |
1428 | extern u32 drm_vblank_count_and_time(struct drm_device *dev, int crtc, | 1404 | extern u32 drm_vblank_count_and_time(struct drm_device *dev, int crtc, |
1429 | struct timeval *vblanktime); | 1405 | struct timeval *vblanktime); |
@@ -1465,31 +1441,8 @@ extern int drm_modeset_ctl(struct drm_device *dev, void *data, | |||
1465 | struct drm_file *file_priv); | 1441 | struct drm_file *file_priv); |
1466 | 1442 | ||
1467 | /* AGP/GART support (drm_agpsupport.h) */ | 1443 | /* AGP/GART support (drm_agpsupport.h) */ |
1468 | extern struct drm_agp_head *drm_agp_init(struct drm_device *dev); | 1444 | |
1469 | extern int drm_agp_acquire(struct drm_device *dev); | 1445 | #include <drm/drm_agpsupport.h> |
1470 | extern int drm_agp_acquire_ioctl(struct drm_device *dev, void *data, | ||
1471 | struct drm_file *file_priv); | ||
1472 | extern int drm_agp_release(struct drm_device *dev); | ||
1473 | extern int drm_agp_release_ioctl(struct drm_device *dev, void *data, | ||
1474 | struct drm_file *file_priv); | ||
1475 | extern int drm_agp_enable(struct drm_device *dev, struct drm_agp_mode mode); | ||
1476 | extern int drm_agp_enable_ioctl(struct drm_device *dev, void *data, | ||
1477 | struct drm_file *file_priv); | ||
1478 | extern int drm_agp_info(struct drm_device *dev, struct drm_agp_info *info); | ||
1479 | extern int drm_agp_info_ioctl(struct drm_device *dev, void *data, | ||
1480 | struct drm_file *file_priv); | ||
1481 | extern int drm_agp_alloc(struct drm_device *dev, struct drm_agp_buffer *request); | ||
1482 | extern int drm_agp_alloc_ioctl(struct drm_device *dev, void *data, | ||
1483 | struct drm_file *file_priv); | ||
1484 | extern int drm_agp_free(struct drm_device *dev, struct drm_agp_buffer *request); | ||
1485 | extern int drm_agp_free_ioctl(struct drm_device *dev, void *data, | ||
1486 | struct drm_file *file_priv); | ||
1487 | extern int drm_agp_unbind(struct drm_device *dev, struct drm_agp_binding *request); | ||
1488 | extern int drm_agp_unbind_ioctl(struct drm_device *dev, void *data, | ||
1489 | struct drm_file *file_priv); | ||
1490 | extern int drm_agp_bind(struct drm_device *dev, struct drm_agp_binding *request); | ||
1491 | extern int drm_agp_bind_ioctl(struct drm_device *dev, void *data, | ||
1492 | struct drm_file *file_priv); | ||
1493 | 1446 | ||
1494 | /* Stub support (drm_stub.h) */ | 1447 | /* Stub support (drm_stub.h) */ |
1495 | extern int drm_setmaster_ioctl(struct drm_device *dev, void *data, | 1448 | extern int drm_setmaster_ioctl(struct drm_device *dev, void *data, |
@@ -1504,23 +1457,19 @@ extern void drm_put_dev(struct drm_device *dev); | |||
1504 | extern int drm_put_minor(struct drm_minor **minor); | 1457 | extern int drm_put_minor(struct drm_minor **minor); |
1505 | extern void drm_unplug_dev(struct drm_device *dev); | 1458 | extern void drm_unplug_dev(struct drm_device *dev); |
1506 | extern unsigned int drm_debug; | 1459 | extern unsigned int drm_debug; |
1460 | extern unsigned int drm_rnodes; | ||
1507 | 1461 | ||
1508 | extern unsigned int drm_vblank_offdelay; | 1462 | extern unsigned int drm_vblank_offdelay; |
1509 | extern unsigned int drm_timestamp_precision; | 1463 | extern unsigned int drm_timestamp_precision; |
1510 | extern unsigned int drm_timestamp_monotonic; | 1464 | extern unsigned int drm_timestamp_monotonic; |
1511 | 1465 | ||
1512 | extern struct class *drm_class; | 1466 | extern struct class *drm_class; |
1513 | extern struct proc_dir_entry *drm_proc_root; | ||
1514 | extern struct dentry *drm_debugfs_root; | 1467 | extern struct dentry *drm_debugfs_root; |
1515 | 1468 | ||
1516 | extern struct idr drm_minors_idr; | 1469 | extern struct idr drm_minors_idr; |
1517 | 1470 | ||
1518 | extern struct drm_local_map *drm_getsarea(struct drm_device *dev); | 1471 | extern struct drm_local_map *drm_getsarea(struct drm_device *dev); |
1519 | 1472 | ||
1520 | /* Proc support (drm_proc.h) */ | ||
1521 | extern int drm_proc_init(struct drm_minor *minor, struct proc_dir_entry *root); | ||
1522 | extern int drm_proc_cleanup(struct drm_minor *minor, struct proc_dir_entry *root); | ||
1523 | |||
1524 | /* Debugfs support */ | 1473 | /* Debugfs support */ |
1525 | #if defined(CONFIG_DEBUG_FS) | 1474 | #if defined(CONFIG_DEBUG_FS) |
1526 | extern int drm_debugfs_init(struct drm_minor *minor, int minor_id, | 1475 | extern int drm_debugfs_init(struct drm_minor *minor, int minor_id, |
@@ -1550,6 +1499,7 @@ extern struct drm_gem_object *drm_gem_prime_import(struct drm_device *dev, | |||
1550 | struct dma_buf *dma_buf); | 1499 | struct dma_buf *dma_buf); |
1551 | extern int drm_gem_prime_fd_to_handle(struct drm_device *dev, | 1500 | extern int drm_gem_prime_fd_to_handle(struct drm_device *dev, |
1552 | struct drm_file *file_priv, int prime_fd, uint32_t *handle); | 1501 | struct drm_file *file_priv, int prime_fd, uint32_t *handle); |
1502 | extern void drm_gem_dmabuf_release(struct dma_buf *dma_buf); | ||
1553 | 1503 | ||
1554 | extern int drm_prime_handle_to_fd_ioctl(struct drm_device *dev, void *data, | 1504 | extern int drm_prime_handle_to_fd_ioctl(struct drm_device *dev, void *data, |
1555 | struct drm_file *file_priv); | 1505 | struct drm_file *file_priv); |
@@ -1561,25 +1511,22 @@ extern int drm_prime_sg_to_page_addr_arrays(struct sg_table *sgt, struct page ** | |||
1561 | extern struct sg_table *drm_prime_pages_to_sg(struct page **pages, int nr_pages); | 1511 | extern struct sg_table *drm_prime_pages_to_sg(struct page **pages, int nr_pages); |
1562 | extern void drm_prime_gem_destroy(struct drm_gem_object *obj, struct sg_table *sg); | 1512 | extern void drm_prime_gem_destroy(struct drm_gem_object *obj, struct sg_table *sg); |
1563 | 1513 | ||
1514 | int drm_gem_dumb_destroy(struct drm_file *file, | ||
1515 | struct drm_device *dev, | ||
1516 | uint32_t handle); | ||
1564 | 1517 | ||
1565 | void drm_prime_init_file_private(struct drm_prime_file_private *prime_fpriv); | 1518 | void drm_prime_init_file_private(struct drm_prime_file_private *prime_fpriv); |
1566 | void drm_prime_destroy_file_private(struct drm_prime_file_private *prime_fpriv); | 1519 | void drm_prime_destroy_file_private(struct drm_prime_file_private *prime_fpriv); |
1567 | int drm_prime_lookup_buf_handle(struct drm_prime_file_private *prime_fpriv, struct dma_buf *dma_buf, uint32_t *handle); | 1520 | void drm_prime_remove_buf_handle_locked(struct drm_prime_file_private *prime_fpriv, struct dma_buf *dma_buf); |
1568 | void drm_prime_remove_buf_handle(struct drm_prime_file_private *prime_fpriv, struct dma_buf *dma_buf); | ||
1569 | |||
1570 | int drm_prime_add_dma_buf(struct drm_device *dev, struct drm_gem_object *obj); | ||
1571 | int drm_prime_lookup_obj(struct drm_device *dev, struct dma_buf *buf, | ||
1572 | struct drm_gem_object **obj); | ||
1573 | 1521 | ||
1574 | #if DRM_DEBUG_CODE | 1522 | #if DRM_DEBUG_CODE |
1575 | extern int drm_vma_info(struct seq_file *m, void *data); | 1523 | extern int drm_vma_info(struct seq_file *m, void *data); |
1576 | #endif | 1524 | #endif |
1577 | 1525 | ||
1578 | /* Scatter Gather Support (drm_scatter.h) */ | 1526 | /* Scatter Gather Support (drm_scatter.h) */ |
1579 | extern void drm_sg_cleanup(struct drm_sg_mem * entry); | 1527 | extern void drm_legacy_sg_cleanup(struct drm_device *dev); |
1580 | extern int drm_sg_alloc_ioctl(struct drm_device *dev, void *data, | 1528 | extern int drm_sg_alloc(struct drm_device *dev, void *data, |
1581 | struct drm_file *file_priv); | 1529 | struct drm_file *file_priv); |
1582 | extern int drm_sg_alloc(struct drm_device *dev, struct drm_scatter_gather * request); | ||
1583 | extern int drm_sg_free(struct drm_device *dev, void *data, | 1530 | extern int drm_sg_free(struct drm_device *dev, void *data, |
1584 | struct drm_file *file_priv); | 1531 | struct drm_file *file_priv); |
1585 | 1532 | ||
@@ -1613,9 +1560,8 @@ struct drm_gem_object *drm_gem_object_alloc(struct drm_device *dev, | |||
1613 | size_t size); | 1560 | size_t size); |
1614 | int drm_gem_object_init(struct drm_device *dev, | 1561 | int drm_gem_object_init(struct drm_device *dev, |
1615 | struct drm_gem_object *obj, size_t size); | 1562 | struct drm_gem_object *obj, size_t size); |
1616 | int drm_gem_private_object_init(struct drm_device *dev, | 1563 | void drm_gem_private_object_init(struct drm_device *dev, |
1617 | struct drm_gem_object *obj, size_t size); | 1564 | struct drm_gem_object *obj, size_t size); |
1618 | void drm_gem_object_handle_free(struct drm_gem_object *obj); | ||
1619 | void drm_gem_vm_open(struct vm_area_struct *vma); | 1565 | void drm_gem_vm_open(struct vm_area_struct *vma); |
1620 | void drm_gem_vm_close(struct vm_area_struct *vma); | 1566 | void drm_gem_vm_close(struct vm_area_struct *vma); |
1621 | int drm_gem_mmap_obj(struct drm_gem_object *obj, unsigned long obj_size, | 1567 | int drm_gem_mmap_obj(struct drm_gem_object *obj, unsigned long obj_size, |
@@ -1640,66 +1586,32 @@ drm_gem_object_unreference(struct drm_gem_object *obj) | |||
1640 | static inline void | 1586 | static inline void |
1641 | drm_gem_object_unreference_unlocked(struct drm_gem_object *obj) | 1587 | drm_gem_object_unreference_unlocked(struct drm_gem_object *obj) |
1642 | { | 1588 | { |
1643 | if (obj != NULL) { | 1589 | if (obj && !atomic_add_unless(&obj->refcount.refcount, -1, 1)) { |
1644 | struct drm_device *dev = obj->dev; | 1590 | struct drm_device *dev = obj->dev; |
1591 | |||
1645 | mutex_lock(&dev->struct_mutex); | 1592 | mutex_lock(&dev->struct_mutex); |
1646 | kref_put(&obj->refcount, drm_gem_object_free); | 1593 | if (likely(atomic_dec_and_test(&obj->refcount.refcount))) |
1594 | drm_gem_object_free(&obj->refcount); | ||
1647 | mutex_unlock(&dev->struct_mutex); | 1595 | mutex_unlock(&dev->struct_mutex); |
1648 | } | 1596 | } |
1649 | } | 1597 | } |
1650 | 1598 | ||
1599 | int drm_gem_handle_create_tail(struct drm_file *file_priv, | ||
1600 | struct drm_gem_object *obj, | ||
1601 | u32 *handlep); | ||
1651 | int drm_gem_handle_create(struct drm_file *file_priv, | 1602 | int drm_gem_handle_create(struct drm_file *file_priv, |
1652 | struct drm_gem_object *obj, | 1603 | struct drm_gem_object *obj, |
1653 | u32 *handlep); | 1604 | u32 *handlep); |
1654 | int drm_gem_handle_delete(struct drm_file *filp, u32 handle); | 1605 | int drm_gem_handle_delete(struct drm_file *filp, u32 handle); |
1655 | 1606 | ||
1656 | static inline void | ||
1657 | drm_gem_object_handle_reference(struct drm_gem_object *obj) | ||
1658 | { | ||
1659 | drm_gem_object_reference(obj); | ||
1660 | atomic_inc(&obj->handle_count); | ||
1661 | } | ||
1662 | |||
1663 | static inline void | ||
1664 | drm_gem_object_handle_unreference(struct drm_gem_object *obj) | ||
1665 | { | ||
1666 | if (obj == NULL) | ||
1667 | return; | ||
1668 | |||
1669 | if (atomic_read(&obj->handle_count) == 0) | ||
1670 | return; | ||
1671 | /* | ||
1672 | * Must bump handle count first as this may be the last | ||
1673 | * ref, in which case the object would disappear before we | ||
1674 | * checked for a name | ||
1675 | */ | ||
1676 | if (atomic_dec_and_test(&obj->handle_count)) | ||
1677 | drm_gem_object_handle_free(obj); | ||
1678 | drm_gem_object_unreference(obj); | ||
1679 | } | ||
1680 | |||
1681 | static inline void | ||
1682 | drm_gem_object_handle_unreference_unlocked(struct drm_gem_object *obj) | ||
1683 | { | ||
1684 | if (obj == NULL) | ||
1685 | return; | ||
1686 | |||
1687 | if (atomic_read(&obj->handle_count) == 0) | ||
1688 | return; | ||
1689 | |||
1690 | /* | ||
1691 | * Must bump handle count first as this may be the last | ||
1692 | * ref, in which case the object would disappear before we | ||
1693 | * checked for a name | ||
1694 | */ | ||
1695 | |||
1696 | if (atomic_dec_and_test(&obj->handle_count)) | ||
1697 | drm_gem_object_handle_free(obj); | ||
1698 | drm_gem_object_unreference_unlocked(obj); | ||
1699 | } | ||
1700 | 1607 | ||
1701 | void drm_gem_free_mmap_offset(struct drm_gem_object *obj); | 1608 | void drm_gem_free_mmap_offset(struct drm_gem_object *obj); |
1702 | int drm_gem_create_mmap_offset(struct drm_gem_object *obj); | 1609 | int drm_gem_create_mmap_offset(struct drm_gem_object *obj); |
1610 | int drm_gem_create_mmap_offset_size(struct drm_gem_object *obj, size_t size); | ||
1611 | |||
1612 | struct page **drm_gem_get_pages(struct drm_gem_object *obj, gfp_t gfpmask); | ||
1613 | void drm_gem_put_pages(struct drm_gem_object *obj, struct page **pages, | ||
1614 | bool dirty, bool accessed); | ||
1703 | 1615 | ||
1704 | struct drm_gem_object *drm_gem_object_lookup(struct drm_device *dev, | 1616 | struct drm_gem_object *drm_gem_object_lookup(struct drm_device *dev, |
1705 | struct drm_file *filp, | 1617 | struct drm_file *filp, |
@@ -1769,9 +1681,6 @@ extern int drm_pcie_get_speed_cap_mask(struct drm_device *dev, u32 *speed_mask); | |||
1769 | extern int drm_platform_init(struct drm_driver *driver, struct platform_device *platform_device); | 1681 | extern int drm_platform_init(struct drm_driver *driver, struct platform_device *platform_device); |
1770 | extern void drm_platform_exit(struct drm_driver *driver, struct platform_device *platform_device); | 1682 | extern void drm_platform_exit(struct drm_driver *driver, struct platform_device *platform_device); |
1771 | 1683 | ||
1772 | extern int drm_get_platform_dev(struct platform_device *pdev, | ||
1773 | struct drm_driver *driver); | ||
1774 | |||
1775 | /* returns true if currently okay to sleep */ | 1684 | /* returns true if currently okay to sleep */ |
1776 | static __inline__ bool drm_can_sleep(void) | 1685 | static __inline__ bool drm_can_sleep(void) |
1777 | { | 1686 | { |