aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/char/drm/drm_stub.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/char/drm/drm_stub.c')
-rw-r--r--drivers/char/drm/drm_stub.c112
1 files changed, 59 insertions, 53 deletions
diff --git a/drivers/char/drm/drm_stub.c b/drivers/char/drm/drm_stub.c
index 95a976c96eb8..7cb7234d6288 100644
--- a/drivers/char/drm/drm_stub.c
+++ b/drivers/char/drm/drm_stub.c
@@ -37,11 +37,11 @@
37#include "drm_core.h" 37#include "drm_core.h"
38 38
39unsigned int drm_cards_limit = 16; /* Enough for one machine */ 39unsigned int drm_cards_limit = 16; /* Enough for one machine */
40unsigned int drm_debug = 0; /* 1 to enable debug output */ 40unsigned int drm_debug = 0; /* 1 to enable debug output */
41EXPORT_SYMBOL(drm_debug); 41EXPORT_SYMBOL(drm_debug);
42 42
43MODULE_AUTHOR( CORE_AUTHOR ); 43MODULE_AUTHOR(CORE_AUTHOR);
44MODULE_DESCRIPTION( CORE_DESC ); 44MODULE_DESCRIPTION(CORE_DESC);
45MODULE_LICENSE("GPL and additional rights"); 45MODULE_LICENSE("GPL and additional rights");
46MODULE_PARM_DESC(cards_limit, "Maximum number of graphics cards"); 46MODULE_PARM_DESC(cards_limit, "Maximum number of graphics cards");
47MODULE_PARM_DESC(debug, "Enable debug output"); 47MODULE_PARM_DESC(debug, "Enable debug output");
@@ -53,19 +53,21 @@ drm_head_t **drm_heads;
53struct drm_sysfs_class *drm_class; 53struct drm_sysfs_class *drm_class;
54struct proc_dir_entry *drm_proc_root; 54struct proc_dir_entry *drm_proc_root;
55 55
56static int drm_fill_in_dev(drm_device_t *dev, struct pci_dev *pdev, const struct pci_device_id *ent, struct drm_driver *driver) 56static int drm_fill_in_dev(drm_device_t * dev, struct pci_dev *pdev,
57 const struct pci_device_id *ent,
58 struct drm_driver *driver)
57{ 59{
58 int retcode; 60 int retcode;
59 61
60 spin_lock_init(&dev->count_lock); 62 spin_lock_init(&dev->count_lock);
61 init_timer( &dev->timer ); 63 init_timer(&dev->timer);
62 sema_init( &dev->struct_sem, 1 ); 64 sema_init(&dev->struct_sem, 1);
63 sema_init( &dev->ctxlist_sem, 1 ); 65 sema_init(&dev->ctxlist_sem, 1);
64 66
65 dev->pdev = pdev; 67 dev->pdev = pdev;
66 68
67#ifdef __alpha__ 69#ifdef __alpha__
68 dev->hose = pdev->sysdata; 70 dev->hose = pdev->sysdata;
69 dev->pci_domain = dev->hose->bus->number; 71 dev->pci_domain = dev->hose->bus->number;
70#else 72#else
71 dev->pci_domain = 0; 73 dev->pci_domain = 0;
@@ -82,15 +84,15 @@ static int drm_fill_in_dev(drm_device_t *dev, struct pci_dev *pdev, const struct
82 84
83 /* the DRM has 6 basic counters */ 85 /* the DRM has 6 basic counters */
84 dev->counters = 6; 86 dev->counters = 6;
85 dev->types[0] = _DRM_STAT_LOCK; 87 dev->types[0] = _DRM_STAT_LOCK;
86 dev->types[1] = _DRM_STAT_OPENS; 88 dev->types[1] = _DRM_STAT_OPENS;
87 dev->types[2] = _DRM_STAT_CLOSES; 89 dev->types[2] = _DRM_STAT_CLOSES;
88 dev->types[3] = _DRM_STAT_IOCTLS; 90 dev->types[3] = _DRM_STAT_IOCTLS;
89 dev->types[4] = _DRM_STAT_LOCKS; 91 dev->types[4] = _DRM_STAT_LOCKS;
90 dev->types[5] = _DRM_STAT_UNLOCKS; 92 dev->types[5] = _DRM_STAT_UNLOCKS;
91 93
92 dev->driver = driver; 94 dev->driver = driver;
93 95
94 if (dev->driver->preinit) 96 if (dev->driver->preinit)
95 if ((retcode = dev->driver->preinit(dev, ent->driver_data))) 97 if ((retcode = dev->driver->preinit(dev, ent->driver_data)))
96 goto error_out_unreg; 98 goto error_out_unreg;
@@ -98,29 +100,30 @@ static int drm_fill_in_dev(drm_device_t *dev, struct pci_dev *pdev, const struct
98 if (drm_core_has_AGP(dev)) { 100 if (drm_core_has_AGP(dev)) {
99 if (drm_device_is_agp(dev)) 101 if (drm_device_is_agp(dev))
100 dev->agp = drm_agp_init(dev); 102 dev->agp = drm_agp_init(dev);
101 if (drm_core_check_feature(dev, DRIVER_REQUIRE_AGP) && (dev->agp == NULL)) { 103 if (drm_core_check_feature(dev, DRIVER_REQUIRE_AGP)
102 DRM_ERROR( "Cannot initialize the agpgart module.\n" ); 104 && (dev->agp == NULL)) {
105 DRM_ERROR("Cannot initialize the agpgart module.\n");
103 retcode = -EINVAL; 106 retcode = -EINVAL;
104 goto error_out_unreg; 107 goto error_out_unreg;
105 } 108 }
106 if (drm_core_has_MTRR(dev)) { 109 if (drm_core_has_MTRR(dev)) {
107 if (dev->agp) 110 if (dev->agp)
108 dev->agp->agp_mtrr = mtrr_add( dev->agp->agp_info.aper_base, 111 dev->agp->agp_mtrr =
109 dev->agp->agp_info.aper_size*1024*1024, 112 mtrr_add(dev->agp->agp_info.aper_base,
110 MTRR_TYPE_WRCOMB, 113 dev->agp->agp_info.aper_size *
111 1 ); 114 1024 * 1024, MTRR_TYPE_WRCOMB, 1);
112 } 115 }
113 } 116 }
114 117
115 retcode = drm_ctxbitmap_init( dev ); 118 retcode = drm_ctxbitmap_init(dev);
116 if( retcode ) { 119 if (retcode) {
117 DRM_ERROR( "Cannot allocate memory for context bitmap.\n" ); 120 DRM_ERROR("Cannot allocate memory for context bitmap.\n");
118 goto error_out_unreg; 121 goto error_out_unreg;
119 } 122 }
120 123
121 return 0; 124 return 0;
122 125
123error_out_unreg: 126 error_out_unreg:
124 drm_takedown(dev); 127 drm_takedown(dev);
125 return retcode; 128 return retcode;
126} 129}
@@ -140,7 +143,7 @@ int drm_stub_open(struct inode *inode, struct file *filp)
140 int minor = iminor(inode); 143 int minor = iminor(inode);
141 int err = -ENODEV; 144 int err = -ENODEV;
142 struct file_operations *old_fops; 145 struct file_operations *old_fops;
143 146
144 DRM_DEBUG("\n"); 147 DRM_DEBUG("\n");
145 148
146 if (!((minor >= 0) && (minor < drm_cards_limit))) 149 if (!((minor >= 0) && (minor < drm_cards_limit)))
@@ -148,7 +151,7 @@ int drm_stub_open(struct inode *inode, struct file *filp)
148 151
149 if (!drm_heads[minor]) 152 if (!drm_heads[minor])
150 return -ENODEV; 153 return -ENODEV;
151 154
152 if (!(dev = drm_heads[minor]->dev)) 155 if (!(dev = drm_heads[minor]->dev))
153 return -ENODEV; 156 return -ENODEV;
154 157
@@ -174,7 +177,7 @@ int drm_stub_open(struct inode *inode, struct file *filp)
174 * create the proc init entry via proc_init(). This routines assigns 177 * create the proc init entry via proc_init(). This routines assigns
175 * minor numbers to secondary heads of multi-headed cards 178 * minor numbers to secondary heads of multi-headed cards
176 */ 179 */
177static int drm_get_head(drm_device_t *dev, drm_head_t *head) 180static int drm_get_head(drm_device_t * dev, drm_head_t * head)
178{ 181{
179 drm_head_t **heads = drm_heads; 182 drm_head_t **heads = drm_heads;
180 int ret; 183 int ret;
@@ -184,26 +187,27 @@ static int drm_get_head(drm_device_t *dev, drm_head_t *head)
184 187
185 for (minor = 0; minor < drm_cards_limit; minor++, heads++) { 188 for (minor = 0; minor < drm_cards_limit; minor++, heads++) {
186 if (!*heads) { 189 if (!*heads) {
187 190
188 *head = (drm_head_t) { 191 *head = (drm_head_t) {
189 .dev = dev, 192 .dev = dev,.device =
190 .device = MKDEV(DRM_MAJOR, minor), 193 MKDEV(DRM_MAJOR, minor),.minor = minor,};
191 .minor = minor, 194
192 }; 195 if ((ret =
193 196 drm_proc_init(dev, minor, drm_proc_root,
194 if ((ret = drm_proc_init(dev, minor, drm_proc_root, &head->dev_root))) { 197 &head->dev_root))) {
195 printk (KERN_ERR "DRM: Failed to initialize /proc/dri.\n"); 198 printk(KERN_ERR
199 "DRM: Failed to initialize /proc/dri.\n");
196 goto err_g1; 200 goto err_g1;
197 } 201 }
198 202
199
200 head->dev_class = drm_sysfs_device_add(drm_class, 203 head->dev_class = drm_sysfs_device_add(drm_class,
201 MKDEV(DRM_MAJOR, 204 MKDEV(DRM_MAJOR,
202 minor), 205 minor),
203 &dev->pdev->dev, 206 &dev->pdev->dev,
204 "card%d", minor); 207 "card%d", minor);
205 if (IS_ERR(head->dev_class)) { 208 if (IS_ERR(head->dev_class)) {
206 printk(KERN_ERR "DRM: Error sysfs_device_add.\n"); 209 printk(KERN_ERR
210 "DRM: Error sysfs_device_add.\n");
207 ret = PTR_ERR(head->dev_class); 211 ret = PTR_ERR(head->dev_class);
208 goto err_g2; 212 goto err_g2;
209 } 213 }
@@ -215,13 +219,14 @@ static int drm_get_head(drm_device_t *dev, drm_head_t *head)
215 } 219 }
216 DRM_ERROR("out of minors\n"); 220 DRM_ERROR("out of minors\n");
217 return -ENOMEM; 221 return -ENOMEM;
218err_g2: 222 err_g2:
219 drm_proc_cleanup(minor, drm_proc_root, head->dev_root); 223 drm_proc_cleanup(minor, drm_proc_root, head->dev_root);
220err_g1: 224 err_g1:
221 *head = (drm_head_t) {.dev = NULL}; 225 *head = (drm_head_t) {
226 .dev = NULL};
222 return ret; 227 return ret;
223} 228}
224 229
225/** 230/**
226 * Register. 231 * Register.
227 * 232 *
@@ -234,7 +239,7 @@ err_g1:
234 * Try and register, if we fail to register, backout previous work. 239 * Try and register, if we fail to register, backout previous work.
235 */ 240 */
236int drm_get_dev(struct pci_dev *pdev, const struct pci_device_id *ent, 241int drm_get_dev(struct pci_dev *pdev, const struct pci_device_id *ent,
237 struct drm_driver *driver) 242 struct drm_driver *driver)
238{ 243{
239 drm_device_t *dev; 244 drm_device_t *dev;
240 int ret; 245 int ret;
@@ -261,10 +266,11 @@ int drm_get_dev(struct pci_dev *pdev, const struct pci_device_id *ent,
261 266
262 return 0; 267 return 0;
263 268
264err_g1: 269 err_g1:
265 drm_free(dev, sizeof(*dev), DRM_MEM_STUB); 270 drm_free(dev, sizeof(*dev), DRM_MEM_STUB);
266 return ret; 271 return ret;
267} 272}
273
268EXPORT_SYMBOL(drm_get_dev); 274EXPORT_SYMBOL(drm_get_dev);
269 275
270/** 276/**
@@ -305,19 +311,19 @@ int drm_put_dev(drm_device_t * dev)
305 * last minor released. 311 * last minor released.
306 * 312 *
307 */ 313 */
308int drm_put_head(drm_head_t *head) 314int drm_put_head(drm_head_t * head)
309{ 315{
310 int minor = head->minor; 316 int minor = head->minor;
311 317
312 DRM_DEBUG("release secondary minor %d\n", minor); 318 DRM_DEBUG("release secondary minor %d\n", minor);
313 319
314 drm_proc_cleanup(minor, drm_proc_root, head->dev_root); 320 drm_proc_cleanup(minor, drm_proc_root, head->dev_root);
315 drm_sysfs_device_remove(MKDEV(DRM_MAJOR, head->minor)); 321 drm_sysfs_device_remove(MKDEV(DRM_MAJOR, head->minor));
316 322
317 *head = (drm_head_t){.dev = NULL}; 323 *head = (drm_head_t) {
324 .dev = NULL};
318 325
319 drm_heads[minor] = NULL; 326 drm_heads[minor] = NULL;
320 327
321 return 0; 328 return 0;
322} 329}
323