diff options
author | Dave Airlie <airlied@gmail.com> | 2010-12-14 12:16:38 -0500 |
---|---|---|
committer | Dave Airlie <airlied@redhat.com> | 2011-02-06 22:09:36 -0500 |
commit | 8410ea3b95d105a5be5db501656f44bbb91197c1 (patch) | |
tree | 6cd27f207e50c13ba2f4a78d6323bc23f751e380 | |
parent | ff72145badb834e8051719ea66e024784d000cb4 (diff) |
drm: rework PCI/platform driver interface.
This abstracts the pci/platform interface out a step further,
we can go further but this is far enough for now to allow USB
to be plugged in.
The drivers now just call the init code directly for their
device type.
Signed-off-by: Dave Airlie <airlied@redhat.com>
24 files changed, 456 insertions, 359 deletions
diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c index 3e991980cee2..0d04914eb058 100644 --- a/drivers/gpu/drm/drm_drv.c +++ b/drivers/gpu/drm/drm_drv.c | |||
@@ -237,49 +237,6 @@ int drm_lastclose(struct drm_device * dev) | |||
237 | return 0; | 237 | return 0; |
238 | } | 238 | } |
239 | 239 | ||
240 | /** | ||
241 | * Module initialization. Called via init_module at module load time, or via | ||
242 | * linux/init/main.c (this is not currently supported). | ||
243 | * | ||
244 | * \return zero on success or a negative number on failure. | ||
245 | * | ||
246 | * Initializes an array of drm_device structures, and attempts to | ||
247 | * initialize all available devices, using consecutive minors, registering the | ||
248 | * stubs and initializing the device. | ||
249 | * | ||
250 | * Expands the \c DRIVER_PREINIT and \c DRIVER_POST_INIT macros before and | ||
251 | * after the initialization for driver customization. | ||
252 | */ | ||
253 | int drm_init(struct drm_driver *driver) | ||
254 | { | ||
255 | DRM_DEBUG("\n"); | ||
256 | INIT_LIST_HEAD(&driver->device_list); | ||
257 | |||
258 | if (driver->driver_features & DRIVER_USE_PLATFORM_DEVICE) | ||
259 | return drm_platform_init(driver); | ||
260 | else | ||
261 | return drm_pci_init(driver); | ||
262 | } | ||
263 | |||
264 | EXPORT_SYMBOL(drm_init); | ||
265 | |||
266 | void drm_exit(struct drm_driver *driver) | ||
267 | { | ||
268 | struct drm_device *dev, *tmp; | ||
269 | DRM_DEBUG("\n"); | ||
270 | |||
271 | if (driver->driver_features & DRIVER_MODESET) { | ||
272 | pci_unregister_driver(&driver->pci_driver); | ||
273 | } else { | ||
274 | list_for_each_entry_safe(dev, tmp, &driver->device_list, driver_item) | ||
275 | drm_put_dev(dev); | ||
276 | } | ||
277 | |||
278 | DRM_INFO("Module unloaded\n"); | ||
279 | } | ||
280 | |||
281 | EXPORT_SYMBOL(drm_exit); | ||
282 | |||
283 | /** File operations structure */ | 240 | /** File operations structure */ |
284 | static const struct file_operations drm_stub_fops = { | 241 | static const struct file_operations drm_stub_fops = { |
285 | .owner = THIS_MODULE, | 242 | .owner = THIS_MODULE, |
diff --git a/drivers/gpu/drm/drm_info.c b/drivers/gpu/drm/drm_info.c index 3cdbaf379bb5..812aaac4438a 100644 --- a/drivers/gpu/drm/drm_info.c +++ b/drivers/gpu/drm/drm_info.c | |||
@@ -47,30 +47,19 @@ int drm_name_info(struct seq_file *m, void *data) | |||
47 | struct drm_minor *minor = node->minor; | 47 | struct drm_minor *minor = node->minor; |
48 | struct drm_device *dev = minor->dev; | 48 | struct drm_device *dev = minor->dev; |
49 | struct drm_master *master = minor->master; | 49 | struct drm_master *master = minor->master; |
50 | 50 | const char *bus_name; | |
51 | if (!master) | 51 | if (!master) |
52 | return 0; | 52 | return 0; |
53 | 53 | ||
54 | if (drm_core_check_feature(dev, DRIVER_USE_PLATFORM_DEVICE)) { | 54 | bus_name = dev->driver->bus->get_name(dev); |
55 | if (master->unique) { | 55 | if (master->unique) { |
56 | seq_printf(m, "%s %s %s\n", | 56 | seq_printf(m, "%s %s %s\n", |
57 | dev->driver->platform_device->name, | 57 | bus_name, |
58 | dev_name(dev->dev), master->unique); | 58 | dev_name(dev->dev), master->unique); |
59 | } else { | ||
60 | seq_printf(m, "%s\n", | ||
61 | dev->driver->platform_device->name); | ||
62 | } | ||
63 | } else { | 59 | } else { |
64 | if (master->unique) { | 60 | seq_printf(m, "%s %s\n", |
65 | seq_printf(m, "%s %s %s\n", | 61 | bus_name, dev_name(dev->dev)); |
66 | dev->driver->pci_driver.name, | ||
67 | dev_name(dev->dev), master->unique); | ||
68 | } else { | ||
69 | seq_printf(m, "%s %s\n", dev->driver->pci_driver.name, | ||
70 | dev_name(dev->dev)); | ||
71 | } | ||
72 | } | 62 | } |
73 | |||
74 | return 0; | 63 | return 0; |
75 | } | 64 | } |
76 | 65 | ||
diff --git a/drivers/gpu/drm/drm_ioctl.c b/drivers/gpu/drm/drm_ioctl.c index 47db4df37a69..117490590f56 100644 --- a/drivers/gpu/drm/drm_ioctl.c +++ b/drivers/gpu/drm/drm_ioctl.c | |||
@@ -96,7 +96,7 @@ int drm_setunique(struct drm_device *dev, void *data, | |||
96 | { | 96 | { |
97 | struct drm_unique *u = data; | 97 | struct drm_unique *u = data; |
98 | struct drm_master *master = file_priv->master; | 98 | struct drm_master *master = file_priv->master; |
99 | int domain, bus, slot, func, ret; | 99 | int ret; |
100 | 100 | ||
101 | if (master->unique_len || master->unique) | 101 | if (master->unique_len || master->unique) |
102 | return -EBUSY; | 102 | return -EBUSY; |
@@ -104,50 +104,12 @@ int drm_setunique(struct drm_device *dev, void *data, | |||
104 | if (!u->unique_len || u->unique_len > 1024) | 104 | if (!u->unique_len || u->unique_len > 1024) |
105 | return -EINVAL; | 105 | return -EINVAL; |
106 | 106 | ||
107 | master->unique_len = u->unique_len; | 107 | if (!dev->driver->bus->set_unique) |
108 | master->unique_size = u->unique_len + 1; | 108 | return -EINVAL; |
109 | master->unique = kmalloc(master->unique_size, GFP_KERNEL); | ||
110 | if (!master->unique) { | ||
111 | ret = -ENOMEM; | ||
112 | goto err; | ||
113 | } | ||
114 | |||
115 | if (copy_from_user(master->unique, u->unique, master->unique_len)) { | ||
116 | ret = -EFAULT; | ||
117 | goto err; | ||
118 | } | ||
119 | |||
120 | master->unique[master->unique_len] = '\0'; | ||
121 | |||
122 | dev->devname = kmalloc(strlen(dev->driver->pci_driver.name) + | ||
123 | strlen(master->unique) + 2, GFP_KERNEL); | ||
124 | if (!dev->devname) { | ||
125 | ret = -ENOMEM; | ||
126 | goto err; | ||
127 | } | ||
128 | |||
129 | sprintf(dev->devname, "%s@%s", dev->driver->pci_driver.name, | ||
130 | master->unique); | ||
131 | |||
132 | /* Return error if the busid submitted doesn't match the device's actual | ||
133 | * busid. | ||
134 | */ | ||
135 | ret = sscanf(master->unique, "PCI:%d:%d:%d", &bus, &slot, &func); | ||
136 | if (ret != 3) { | ||
137 | ret = -EINVAL; | ||
138 | goto err; | ||
139 | } | ||
140 | |||
141 | domain = bus >> 8; | ||
142 | bus &= 0xff; | ||
143 | 109 | ||
144 | if ((domain != drm_get_pci_domain(dev)) || | 110 | ret = dev->driver->bus->set_unique(dev, master, u); |
145 | (bus != dev->pdev->bus->number) || | 111 | if (ret) |
146 | (slot != PCI_SLOT(dev->pdev->devfn)) || | ||
147 | (func != PCI_FUNC(dev->pdev->devfn))) { | ||
148 | ret = -EINVAL; | ||
149 | goto err; | 112 | goto err; |
150 | } | ||
151 | 113 | ||
152 | return 0; | 114 | return 0; |
153 | 115 | ||
@@ -159,74 +121,15 @@ err: | |||
159 | static int drm_set_busid(struct drm_device *dev, struct drm_file *file_priv) | 121 | static int drm_set_busid(struct drm_device *dev, struct drm_file *file_priv) |
160 | { | 122 | { |
161 | struct drm_master *master = file_priv->master; | 123 | struct drm_master *master = file_priv->master; |
162 | int len, ret; | 124 | int ret; |
163 | 125 | ||
164 | if (master->unique != NULL) | 126 | if (master->unique != NULL) |
165 | drm_unset_busid(dev, master); | 127 | drm_unset_busid(dev, master); |
166 | 128 | ||
167 | if (drm_core_check_feature(dev, DRIVER_USE_PLATFORM_DEVICE)) { | 129 | ret = dev->driver->bus->set_busid(dev, master); |
168 | master->unique_len = 10 + strlen(dev->platformdev->name); | 130 | if (ret) |
169 | master->unique = kmalloc(master->unique_len + 1, GFP_KERNEL); | 131 | goto err; |
170 | |||
171 | if (master->unique == NULL) | ||
172 | return -ENOMEM; | ||
173 | |||
174 | len = snprintf(master->unique, master->unique_len, | ||
175 | "platform:%s", dev->platformdev->name); | ||
176 | |||
177 | if (len > master->unique_len) { | ||
178 | DRM_ERROR("Unique buffer overflowed\n"); | ||
179 | ret = -EINVAL; | ||
180 | goto err; | ||
181 | } | ||
182 | |||
183 | dev->devname = | ||
184 | kmalloc(strlen(dev->platformdev->name) + | ||
185 | master->unique_len + 2, GFP_KERNEL); | ||
186 | |||
187 | if (dev->devname == NULL) { | ||
188 | ret = -ENOMEM; | ||
189 | goto err; | ||
190 | } | ||
191 | |||
192 | sprintf(dev->devname, "%s@%s", dev->platformdev->name, | ||
193 | master->unique); | ||
194 | |||
195 | } else { | ||
196 | master->unique_len = 40; | ||
197 | master->unique_size = master->unique_len; | ||
198 | master->unique = kmalloc(master->unique_size, GFP_KERNEL); | ||
199 | if (master->unique == NULL) | ||
200 | return -ENOMEM; | ||
201 | |||
202 | len = snprintf(master->unique, master->unique_len, | ||
203 | "pci:%04x:%02x:%02x.%d", | ||
204 | drm_get_pci_domain(dev), | ||
205 | dev->pdev->bus->number, | ||
206 | PCI_SLOT(dev->pdev->devfn), | ||
207 | PCI_FUNC(dev->pdev->devfn)); | ||
208 | if (len >= master->unique_len) { | ||
209 | DRM_ERROR("buffer overflow"); | ||
210 | ret = -EINVAL; | ||
211 | goto err; | ||
212 | } else | ||
213 | master->unique_len = len; | ||
214 | |||
215 | dev->devname = | ||
216 | kmalloc(strlen(dev->driver->pci_driver.name) + | ||
217 | master->unique_len + 2, GFP_KERNEL); | ||
218 | |||
219 | if (dev->devname == NULL) { | ||
220 | ret = -ENOMEM; | ||
221 | goto err; | ||
222 | } | ||
223 | |||
224 | sprintf(dev->devname, "%s@%s", dev->driver->pci_driver.name, | ||
225 | master->unique); | ||
226 | } | ||
227 | |||
228 | return 0; | 132 | return 0; |
229 | |||
230 | err: | 133 | err: |
231 | drm_unset_busid(dev, master); | 134 | drm_unset_busid(dev, master); |
232 | return ret; | 135 | return ret; |
diff --git a/drivers/gpu/drm/drm_irq.c b/drivers/gpu/drm/drm_irq.c index 3dadfa2a8528..cb49685bde01 100644 --- a/drivers/gpu/drm/drm_irq.c +++ b/drivers/gpu/drm/drm_irq.c | |||
@@ -74,23 +74,13 @@ int drm_irq_by_busid(struct drm_device *dev, void *data, | |||
74 | { | 74 | { |
75 | struct drm_irq_busid *p = data; | 75 | struct drm_irq_busid *p = data; |
76 | 76 | ||
77 | if (drm_core_check_feature(dev, DRIVER_USE_PLATFORM_DEVICE)) | 77 | if (!dev->driver->bus->irq_by_busid) |
78 | return -EINVAL; | 78 | return -EINVAL; |
79 | 79 | ||
80 | if (!drm_core_check_feature(dev, DRIVER_HAVE_IRQ)) | 80 | if (!drm_core_check_feature(dev, DRIVER_HAVE_IRQ)) |
81 | return -EINVAL; | 81 | return -EINVAL; |
82 | 82 | ||
83 | if ((p->busnum >> 8) != drm_get_pci_domain(dev) || | 83 | return dev->driver->bus->irq_by_busid(dev, p); |
84 | (p->busnum & 0xff) != dev->pdev->bus->number || | ||
85 | p->devnum != PCI_SLOT(dev->pdev->devfn) || p->funcnum != PCI_FUNC(dev->pdev->devfn)) | ||
86 | return -EINVAL; | ||
87 | |||
88 | p->irq = dev->pdev->irq; | ||
89 | |||
90 | DRM_DEBUG("%d:%d:%d => IRQ %d\n", p->busnum, p->devnum, p->funcnum, | ||
91 | p->irq); | ||
92 | |||
93 | return 0; | ||
94 | } | 84 | } |
95 | 85 | ||
96 | /* | 86 | /* |
diff --git a/drivers/gpu/drm/drm_pci.c b/drivers/gpu/drm/drm_pci.c index f5bd9e590c80..e1aee4f6a7c6 100644 --- a/drivers/gpu/drm/drm_pci.c +++ b/drivers/gpu/drm/drm_pci.c | |||
@@ -125,6 +125,176 @@ void drm_pci_free(struct drm_device * dev, drm_dma_handle_t * dmah) | |||
125 | EXPORT_SYMBOL(drm_pci_free); | 125 | EXPORT_SYMBOL(drm_pci_free); |
126 | 126 | ||
127 | #ifdef CONFIG_PCI | 127 | #ifdef CONFIG_PCI |
128 | |||
129 | static int drm_get_pci_domain(struct drm_device *dev) | ||
130 | { | ||
131 | #ifndef __alpha__ | ||
132 | /* For historical reasons, drm_get_pci_domain() is busticated | ||
133 | * on most archs and has to remain so for userspace interface | ||
134 | * < 1.4, except on alpha which was right from the beginning | ||
135 | */ | ||
136 | if (dev->if_version < 0x10004) | ||
137 | return 0; | ||
138 | #endif /* __alpha__ */ | ||
139 | |||
140 | return pci_domain_nr(dev->pdev->bus); | ||
141 | } | ||
142 | |||
143 | static int drm_pci_get_irq(struct drm_device *dev) | ||
144 | { | ||
145 | return dev->pdev->irq; | ||
146 | } | ||
147 | |||
148 | static const char *drm_pci_get_name(struct drm_device *dev) | ||
149 | { | ||
150 | struct pci_driver *pdriver = dev->driver->kdriver.pci; | ||
151 | return pdriver->name; | ||
152 | } | ||
153 | |||
154 | int drm_pci_set_busid(struct drm_device *dev, struct drm_master *master) | ||
155 | { | ||
156 | int len, ret; | ||
157 | struct pci_driver *pdriver = dev->driver->kdriver.pci; | ||
158 | master->unique_len = 40; | ||
159 | master->unique_size = master->unique_len; | ||
160 | master->unique = kmalloc(master->unique_size, GFP_KERNEL); | ||
161 | if (master->unique == NULL) | ||
162 | return -ENOMEM; | ||
163 | |||
164 | |||
165 | len = snprintf(master->unique, master->unique_len, | ||
166 | "pci:%04x:%02x:%02x.%d", | ||
167 | drm_get_pci_domain(dev), | ||
168 | dev->pdev->bus->number, | ||
169 | PCI_SLOT(dev->pdev->devfn), | ||
170 | PCI_FUNC(dev->pdev->devfn)); | ||
171 | |||
172 | if (len >= master->unique_len) { | ||
173 | DRM_ERROR("buffer overflow"); | ||
174 | ret = -EINVAL; | ||
175 | goto err; | ||
176 | } else | ||
177 | master->unique_len = len; | ||
178 | |||
179 | dev->devname = | ||
180 | kmalloc(strlen(pdriver->name) + | ||
181 | master->unique_len + 2, GFP_KERNEL); | ||
182 | |||
183 | if (dev->devname == NULL) { | ||
184 | ret = -ENOMEM; | ||
185 | goto err; | ||
186 | } | ||
187 | |||
188 | sprintf(dev->devname, "%s@%s", pdriver->name, | ||
189 | master->unique); | ||
190 | |||
191 | return 0; | ||
192 | err: | ||
193 | return ret; | ||
194 | } | ||
195 | |||
196 | int drm_pci_set_unique(struct drm_device *dev, | ||
197 | struct drm_master *master, | ||
198 | struct drm_unique *u) | ||
199 | { | ||
200 | int domain, bus, slot, func, ret; | ||
201 | const char *bus_name; | ||
202 | |||
203 | master->unique_len = u->unique_len; | ||
204 | master->unique_size = u->unique_len + 1; | ||
205 | master->unique = kmalloc(master->unique_size, GFP_KERNEL); | ||
206 | if (!master->unique) { | ||
207 | ret = -ENOMEM; | ||
208 | goto err; | ||
209 | } | ||
210 | |||
211 | if (copy_from_user(master->unique, u->unique, master->unique_len)) { | ||
212 | ret = -EFAULT; | ||
213 | goto err; | ||
214 | } | ||
215 | |||
216 | master->unique[master->unique_len] = '\0'; | ||
217 | |||
218 | bus_name = dev->driver->bus->get_name(dev); | ||
219 | dev->devname = kmalloc(strlen(bus_name) + | ||
220 | strlen(master->unique) + 2, GFP_KERNEL); | ||
221 | if (!dev->devname) { | ||
222 | ret = -ENOMEM; | ||
223 | goto err; | ||
224 | } | ||
225 | |||
226 | sprintf(dev->devname, "%s@%s", bus_name, | ||
227 | master->unique); | ||
228 | |||
229 | /* Return error if the busid submitted doesn't match the device's actual | ||
230 | * busid. | ||
231 | */ | ||
232 | ret = sscanf(master->unique, "PCI:%d:%d:%d", &bus, &slot, &func); | ||
233 | if (ret != 3) { | ||
234 | ret = -EINVAL; | ||
235 | goto err; | ||
236 | } | ||
237 | |||
238 | domain = bus >> 8; | ||
239 | bus &= 0xff; | ||
240 | |||
241 | if ((domain != drm_get_pci_domain(dev)) || | ||
242 | (bus != dev->pdev->bus->number) || | ||
243 | (slot != PCI_SLOT(dev->pdev->devfn)) || | ||
244 | (func != PCI_FUNC(dev->pdev->devfn))) { | ||
245 | ret = -EINVAL; | ||
246 | goto err; | ||
247 | } | ||
248 | return 0; | ||
249 | err: | ||
250 | return ret; | ||
251 | } | ||
252 | |||
253 | |||
254 | int drm_pci_irq_by_busid(struct drm_device *dev, struct drm_irq_busid *p) | ||
255 | { | ||
256 | if ((p->busnum >> 8) != drm_get_pci_domain(dev) || | ||
257 | (p->busnum & 0xff) != dev->pdev->bus->number || | ||
258 | p->devnum != PCI_SLOT(dev->pdev->devfn) || p->funcnum != PCI_FUNC(dev->pdev->devfn)) | ||
259 | return -EINVAL; | ||
260 | |||
261 | p->irq = dev->pdev->irq; | ||
262 | |||
263 | DRM_DEBUG("%d:%d:%d => IRQ %d\n", p->busnum, p->devnum, p->funcnum, | ||
264 | p->irq); | ||
265 | return 0; | ||
266 | } | ||
267 | |||
268 | int drm_pci_agp_init(struct drm_device *dev) | ||
269 | { | ||
270 | if (drm_core_has_AGP(dev)) { | ||
271 | if (drm_pci_device_is_agp(dev)) | ||
272 | dev->agp = drm_agp_init(dev); | ||
273 | if (drm_core_check_feature(dev, DRIVER_REQUIRE_AGP) | ||
274 | && (dev->agp == NULL)) { | ||
275 | DRM_ERROR("Cannot initialize the agpgart module.\n"); | ||
276 | return -EINVAL; | ||
277 | } | ||
278 | if (drm_core_has_MTRR(dev)) { | ||
279 | if (dev->agp) | ||
280 | dev->agp->agp_mtrr = | ||
281 | mtrr_add(dev->agp->agp_info.aper_base, | ||
282 | dev->agp->agp_info.aper_size * | ||
283 | 1024 * 1024, MTRR_TYPE_WRCOMB, 1); | ||
284 | } | ||
285 | } | ||
286 | return 0; | ||
287 | } | ||
288 | |||
289 | static struct drm_bus drm_pci_bus = { | ||
290 | .bus_type = DRIVER_BUS_PCI, | ||
291 | .get_irq = drm_pci_get_irq, | ||
292 | .get_name = drm_pci_get_name, | ||
293 | .set_busid = drm_pci_set_busid, | ||
294 | .set_unique = drm_pci_set_unique, | ||
295 | .agp_init = drm_pci_agp_init, | ||
296 | }; | ||
297 | |||
128 | /** | 298 | /** |
129 | * Register. | 299 | * Register. |
130 | * | 300 | * |
@@ -219,7 +389,7 @@ err_g1: | |||
219 | EXPORT_SYMBOL(drm_get_pci_dev); | 389 | EXPORT_SYMBOL(drm_get_pci_dev); |
220 | 390 | ||
221 | /** | 391 | /** |
222 | * PCI device initialization. Called via drm_init at module load time, | 392 | * PCI device initialization. Called direct from modules at load time. |
223 | * | 393 | * |
224 | * \return zero on success or a negative number on failure. | 394 | * \return zero on success or a negative number on failure. |
225 | * | 395 | * |
@@ -229,18 +399,24 @@ EXPORT_SYMBOL(drm_get_pci_dev); | |||
229 | * Expands the \c DRIVER_PREINIT and \c DRIVER_POST_INIT macros before and | 399 | * Expands the \c DRIVER_PREINIT and \c DRIVER_POST_INIT macros before and |
230 | * after the initialization for driver customization. | 400 | * after the initialization for driver customization. |
231 | */ | 401 | */ |
232 | int drm_pci_init(struct drm_driver *driver) | 402 | int drm_pci_init(struct drm_driver *driver, struct pci_driver *pdriver) |
233 | { | 403 | { |
234 | struct pci_dev *pdev = NULL; | 404 | struct pci_dev *pdev = NULL; |
235 | const struct pci_device_id *pid; | 405 | const struct pci_device_id *pid; |
236 | int i; | 406 | int i; |
237 | 407 | ||
408 | DRM_DEBUG("\n"); | ||
409 | |||
410 | INIT_LIST_HEAD(&driver->device_list); | ||
411 | driver->kdriver.pci = pdriver; | ||
412 | driver->bus = &drm_pci_bus; | ||
413 | |||
238 | if (driver->driver_features & DRIVER_MODESET) | 414 | if (driver->driver_features & DRIVER_MODESET) |
239 | return pci_register_driver(&driver->pci_driver); | 415 | return pci_register_driver(pdriver); |
240 | 416 | ||
241 | /* If not using KMS, fall back to stealth mode manual scanning. */ | 417 | /* If not using KMS, fall back to stealth mode manual scanning. */ |
242 | for (i = 0; driver->pci_driver.id_table[i].vendor != 0; i++) { | 418 | for (i = 0; pdriver->id_table[i].vendor != 0; i++) { |
243 | pid = &driver->pci_driver.id_table[i]; | 419 | pid = &pdriver->id_table[i]; |
244 | 420 | ||
245 | /* Loop around setting up a DRM device for each PCI device | 421 | /* Loop around setting up a DRM device for each PCI device |
246 | * matching our ID and device class. If we had the internal | 422 | * matching our ID and device class. If we had the internal |
@@ -265,10 +441,27 @@ int drm_pci_init(struct drm_driver *driver) | |||
265 | 441 | ||
266 | #else | 442 | #else |
267 | 443 | ||
268 | int drm_pci_init(struct drm_driver *driver) | 444 | int drm_pci_init(struct drm_driver *driver, struct pci_driver *pdriver) |
269 | { | 445 | { |
270 | return -1; | 446 | return -1; |
271 | } | 447 | } |
272 | 448 | ||
273 | #endif | 449 | #endif |
450 | |||
451 | EXPORT_SYMBOL(drm_pci_init); | ||
452 | |||
274 | /*@}*/ | 453 | /*@}*/ |
454 | void drm_pci_exit(struct drm_driver *driver, struct pci_driver *pdriver) | ||
455 | { | ||
456 | struct drm_device *dev, *tmp; | ||
457 | DRM_DEBUG("\n"); | ||
458 | |||
459 | if (driver->driver_features & DRIVER_MODESET) { | ||
460 | pci_unregister_driver(pdriver); | ||
461 | } else { | ||
462 | list_for_each_entry_safe(dev, tmp, &driver->device_list, driver_item) | ||
463 | drm_put_dev(dev); | ||
464 | } | ||
465 | DRM_INFO("Module unloaded\n"); | ||
466 | } | ||
467 | EXPORT_SYMBOL(drm_pci_exit); | ||
diff --git a/drivers/gpu/drm/drm_platform.c b/drivers/gpu/drm/drm_platform.c index 92d1d0fb7b75..7223f06d8e58 100644 --- a/drivers/gpu/drm/drm_platform.c +++ b/drivers/gpu/drm/drm_platform.c | |||
@@ -109,8 +109,60 @@ err_g1: | |||
109 | } | 109 | } |
110 | EXPORT_SYMBOL(drm_get_platform_dev); | 110 | EXPORT_SYMBOL(drm_get_platform_dev); |
111 | 111 | ||
112 | static int drm_platform_get_irq(struct drm_device *dev) | ||
113 | { | ||
114 | return platform_get_irq(dev->platformdev, 0); | ||
115 | } | ||
116 | |||
117 | static const char *drm_platform_get_name(struct drm_device *dev) | ||
118 | { | ||
119 | return dev->platformdev->name; | ||
120 | } | ||
121 | |||
122 | static int drm_platform_set_busid(struct drm_device *dev, struct drm_master *master) | ||
123 | { | ||
124 | int len, ret; | ||
125 | |||
126 | master->unique_len = 10 + strlen(dev->platformdev->name); | ||
127 | master->unique = kmalloc(master->unique_len + 1, GFP_KERNEL); | ||
128 | |||
129 | if (master->unique == NULL) | ||
130 | return -ENOMEM; | ||
131 | |||
132 | len = snprintf(master->unique, master->unique_len, | ||
133 | "platform:%s", dev->platformdev->name); | ||
134 | |||
135 | if (len > master->unique_len) { | ||
136 | DRM_ERROR("Unique buffer overflowed\n"); | ||
137 | ret = -EINVAL; | ||
138 | goto err; | ||
139 | } | ||
140 | |||
141 | dev->devname = | ||
142 | kmalloc(strlen(dev->platformdev->name) + | ||
143 | master->unique_len + 2, GFP_KERNEL); | ||
144 | |||
145 | if (dev->devname == NULL) { | ||
146 | ret = -ENOMEM; | ||
147 | goto err; | ||
148 | } | ||
149 | |||
150 | sprintf(dev->devname, "%s@%s", dev->platformdev->name, | ||
151 | master->unique); | ||
152 | return 0; | ||
153 | err: | ||
154 | return ret; | ||
155 | } | ||
156 | |||
157 | static struct drm_bus drm_platform_bus = { | ||
158 | .bus_type = DRIVER_BUS_PLATFORM, | ||
159 | .get_irq = drm_platform_get_irq, | ||
160 | .get_name = drm_platform_get_name, | ||
161 | .set_busid = drm_platform_set_busid, | ||
162 | }; | ||
163 | |||
112 | /** | 164 | /** |
113 | * Platform device initialization. Called via drm_init at module load time, | 165 | * Platform device initialization. Called direct from modules. |
114 | * | 166 | * |
115 | * \return zero on success or a negative number on failure. | 167 | * \return zero on success or a negative number on failure. |
116 | * | 168 | * |
@@ -121,7 +173,24 @@ EXPORT_SYMBOL(drm_get_platform_dev); | |||
121 | * after the initialization for driver customization. | 173 | * after the initialization for driver customization. |
122 | */ | 174 | */ |
123 | 175 | ||
124 | int drm_platform_init(struct drm_driver *driver) | 176 | int drm_platform_init(struct drm_driver *driver, struct platform_device *platform_device) |
125 | { | 177 | { |
126 | return drm_get_platform_dev(driver->platform_device, driver); | 178 | DRM_DEBUG("\n"); |
179 | |||
180 | driver->kdriver.platform_device = platform_device; | ||
181 | driver->bus = &drm_platform_bus; | ||
182 | INIT_LIST_HEAD(&driver->device_list); | ||
183 | return drm_get_platform_dev(platform_device, driver); | ||
184 | } | ||
185 | EXPORT_SYMBOL(drm_platform_init); | ||
186 | |||
187 | void drm_platform_exit(struct drm_driver *driver, struct platform_device *platform_device) | ||
188 | { | ||
189 | struct drm_device *dev, *tmp; | ||
190 | DRM_DEBUG("\n"); | ||
191 | |||
192 | list_for_each_entry_safe(dev, tmp, &driver->device_list, driver_item) | ||
193 | drm_put_dev(dev); | ||
194 | DRM_INFO("Module unloaded\n"); | ||
127 | } | 195 | } |
196 | EXPORT_SYMBOL(drm_platform_exit); | ||
diff --git a/drivers/gpu/drm/drm_stub.c b/drivers/gpu/drm/drm_stub.c index d59edc18301f..0bf2c773c6c5 100644 --- a/drivers/gpu/drm/drm_stub.c +++ b/drivers/gpu/drm/drm_stub.c | |||
@@ -269,25 +269,14 @@ int drm_fill_in_dev(struct drm_device *dev, | |||
269 | 269 | ||
270 | dev->driver = driver; | 270 | dev->driver = driver; |
271 | 271 | ||
272 | if (drm_core_has_AGP(dev)) { | 272 | if (dev->driver->bus->agp_init) { |
273 | if (drm_device_is_agp(dev)) | 273 | retcode = dev->driver->bus->agp_init(dev); |
274 | dev->agp = drm_agp_init(dev); | 274 | if (retcode) |
275 | if (drm_core_check_feature(dev, DRIVER_REQUIRE_AGP) | ||
276 | && (dev->agp == NULL)) { | ||
277 | DRM_ERROR("Cannot initialize the agpgart module.\n"); | ||
278 | retcode = -EINVAL; | ||
279 | goto error_out_unreg; | 275 | goto error_out_unreg; |
280 | } | ||
281 | if (drm_core_has_MTRR(dev)) { | ||
282 | if (dev->agp) | ||
283 | dev->agp->agp_mtrr = | ||
284 | mtrr_add(dev->agp->agp_info.aper_base, | ||
285 | dev->agp->agp_info.aper_size * | ||
286 | 1024 * 1024, MTRR_TYPE_WRCOMB, 1); | ||
287 | } | ||
288 | } | 276 | } |
289 | 277 | ||
290 | 278 | ||
279 | |||
291 | retcode = drm_ctxbitmap_init(dev); | 280 | retcode = drm_ctxbitmap_init(dev); |
292 | if (retcode) { | 281 | if (retcode) { |
293 | DRM_ERROR("Cannot allocate memory for context bitmap.\n"); | 282 | DRM_ERROR("Cannot allocate memory for context bitmap.\n"); |
@@ -425,7 +414,6 @@ int drm_put_minor(struct drm_minor **minor_p) | |||
425 | * | 414 | * |
426 | * Cleans up all DRM device, calling drm_lastclose(). | 415 | * Cleans up all DRM device, calling drm_lastclose(). |
427 | * | 416 | * |
428 | * \sa drm_init | ||
429 | */ | 417 | */ |
430 | void drm_put_dev(struct drm_device *dev) | 418 | void drm_put_dev(struct drm_device *dev) |
431 | { | 419 | { |
diff --git a/drivers/gpu/drm/i810/i810_drv.c b/drivers/gpu/drm/i810/i810_drv.c index 0152fa27e616..6f98d059f68a 100644 --- a/drivers/gpu/drm/i810/i810_drv.c +++ b/drivers/gpu/drm/i810/i810_drv.c | |||
@@ -64,11 +64,6 @@ static struct drm_driver driver = { | |||
64 | .llseek = noop_llseek, | 64 | .llseek = noop_llseek, |
65 | }, | 65 | }, |
66 | 66 | ||
67 | .pci_driver = { | ||
68 | .name = DRIVER_NAME, | ||
69 | .id_table = pciidlist, | ||
70 | }, | ||
71 | |||
72 | .name = DRIVER_NAME, | 67 | .name = DRIVER_NAME, |
73 | .desc = DRIVER_DESC, | 68 | .desc = DRIVER_DESC, |
74 | .date = DRIVER_DATE, | 69 | .date = DRIVER_DATE, |
@@ -77,6 +72,11 @@ static struct drm_driver driver = { | |||
77 | .patchlevel = DRIVER_PATCHLEVEL, | 72 | .patchlevel = DRIVER_PATCHLEVEL, |
78 | }; | 73 | }; |
79 | 74 | ||
75 | static struct pci_driver i810_pci_driver = { | ||
76 | .name = DRIVER_NAME, | ||
77 | .id_table = pciidlist, | ||
78 | }; | ||
79 | |||
80 | static int __init i810_init(void) | 80 | static int __init i810_init(void) |
81 | { | 81 | { |
82 | if (num_possible_cpus() > 1) { | 82 | if (num_possible_cpus() > 1) { |
@@ -84,12 +84,12 @@ static int __init i810_init(void) | |||
84 | return -EINVAL; | 84 | return -EINVAL; |
85 | } | 85 | } |
86 | driver.num_ioctls = i810_max_ioctl; | 86 | driver.num_ioctls = i810_max_ioctl; |
87 | return drm_init(&driver); | 87 | return drm_pci_init(&driver, &i810_pci_driver); |
88 | } | 88 | } |
89 | 89 | ||
90 | static void __exit i810_exit(void) | 90 | static void __exit i810_exit(void) |
91 | { | 91 | { |
92 | drm_exit(&driver); | 92 | drm_pci_exit(&driver, &i810_pci_driver); |
93 | } | 93 | } |
94 | 94 | ||
95 | module_init(i810_init); | 95 | module_init(i810_init); |
diff --git a/drivers/gpu/drm/i915/i915_drv.c b/drivers/gpu/drm/i915/i915_drv.c index 17fde2f27418..9ad42d583493 100644 --- a/drivers/gpu/drm/i915/i915_drv.c +++ b/drivers/gpu/drm/i915/i915_drv.c | |||
@@ -719,14 +719,6 @@ static struct drm_driver driver = { | |||
719 | .llseek = noop_llseek, | 719 | .llseek = noop_llseek, |
720 | }, | 720 | }, |
721 | 721 | ||
722 | .pci_driver = { | ||
723 | .name = DRIVER_NAME, | ||
724 | .id_table = pciidlist, | ||
725 | .probe = i915_pci_probe, | ||
726 | .remove = i915_pci_remove, | ||
727 | .driver.pm = &i915_pm_ops, | ||
728 | }, | ||
729 | |||
730 | .name = DRIVER_NAME, | 722 | .name = DRIVER_NAME, |
731 | .desc = DRIVER_DESC, | 723 | .desc = DRIVER_DESC, |
732 | .date = DRIVER_DATE, | 724 | .date = DRIVER_DATE, |
@@ -735,6 +727,14 @@ static struct drm_driver driver = { | |||
735 | .patchlevel = DRIVER_PATCHLEVEL, | 727 | .patchlevel = DRIVER_PATCHLEVEL, |
736 | }; | 728 | }; |
737 | 729 | ||
730 | static struct pci_driver i915_pci_driver = { | ||
731 | .name = DRIVER_NAME, | ||
732 | .id_table = pciidlist, | ||
733 | .probe = i915_pci_probe, | ||
734 | .remove = i915_pci_remove, | ||
735 | .driver.pm = &i915_pm_ops, | ||
736 | }; | ||
737 | |||
738 | static int __init i915_init(void) | 738 | static int __init i915_init(void) |
739 | { | 739 | { |
740 | if (!intel_agp_enabled) { | 740 | if (!intel_agp_enabled) { |
@@ -768,12 +768,12 @@ static int __init i915_init(void) | |||
768 | if (!(driver.driver_features & DRIVER_MODESET)) | 768 | if (!(driver.driver_features & DRIVER_MODESET)) |
769 | driver.get_vblank_timestamp = NULL; | 769 | driver.get_vblank_timestamp = NULL; |
770 | 770 | ||
771 | return drm_init(&driver); | 771 | return drm_pci_init(&driver, &i915_pci_driver); |
772 | } | 772 | } |
773 | 773 | ||
774 | static void __exit i915_exit(void) | 774 | static void __exit i915_exit(void) |
775 | { | 775 | { |
776 | drm_exit(&driver); | 776 | drm_pci_exit(&driver, &i915_pci_driver); |
777 | } | 777 | } |
778 | 778 | ||
779 | module_init(i915_init); | 779 | module_init(i915_init); |
diff --git a/drivers/gpu/drm/mga/mga_dma.c b/drivers/gpu/drm/mga/mga_dma.c index 08868ac3048a..1e1eb1d7e971 100644 --- a/drivers/gpu/drm/mga/mga_dma.c +++ b/drivers/gpu/drm/mga/mga_dma.c | |||
@@ -703,7 +703,7 @@ static int mga_do_pci_dma_bootstrap(struct drm_device *dev, | |||
703 | static int mga_do_dma_bootstrap(struct drm_device *dev, | 703 | static int mga_do_dma_bootstrap(struct drm_device *dev, |
704 | drm_mga_dma_bootstrap_t *dma_bs) | 704 | drm_mga_dma_bootstrap_t *dma_bs) |
705 | { | 705 | { |
706 | const int is_agp = (dma_bs->agp_mode != 0) && drm_device_is_agp(dev); | 706 | const int is_agp = (dma_bs->agp_mode != 0) && drm_pci_device_is_agp(dev); |
707 | int err; | 707 | int err; |
708 | drm_mga_private_t *const dev_priv = | 708 | drm_mga_private_t *const dev_priv = |
709 | (drm_mga_private_t *) dev->dev_private; | 709 | (drm_mga_private_t *) dev->dev_private; |
diff --git a/drivers/gpu/drm/mga/mga_drv.c b/drivers/gpu/drm/mga/mga_drv.c index 0aaf5f67a436..42d31874edf2 100644 --- a/drivers/gpu/drm/mga/mga_drv.c +++ b/drivers/gpu/drm/mga/mga_drv.c | |||
@@ -75,10 +75,6 @@ static struct drm_driver driver = { | |||
75 | #endif | 75 | #endif |
76 | .llseek = noop_llseek, | 76 | .llseek = noop_llseek, |
77 | }, | 77 | }, |
78 | .pci_driver = { | ||
79 | .name = DRIVER_NAME, | ||
80 | .id_table = pciidlist, | ||
81 | }, | ||
82 | 78 | ||
83 | .name = DRIVER_NAME, | 79 | .name = DRIVER_NAME, |
84 | .desc = DRIVER_DESC, | 80 | .desc = DRIVER_DESC, |
@@ -88,15 +84,20 @@ static struct drm_driver driver = { | |||
88 | .patchlevel = DRIVER_PATCHLEVEL, | 84 | .patchlevel = DRIVER_PATCHLEVEL, |
89 | }; | 85 | }; |
90 | 86 | ||
87 | static struct pci_driver mga_pci_driver = { | ||
88 | .name = DRIVER_NAME, | ||
89 | .id_table = pciidlist, | ||
90 | }; | ||
91 | |||
91 | static int __init mga_init(void) | 92 | static int __init mga_init(void) |
92 | { | 93 | { |
93 | driver.num_ioctls = mga_max_ioctl; | 94 | driver.num_ioctls = mga_max_ioctl; |
94 | return drm_init(&driver); | 95 | return drm_pci_init(&driver, &mga_pci_driver); |
95 | } | 96 | } |
96 | 97 | ||
97 | static void __exit mga_exit(void) | 98 | static void __exit mga_exit(void) |
98 | { | 99 | { |
99 | drm_exit(&driver); | 100 | drm_pci_exit(&driver, &mga_pci_driver); |
100 | } | 101 | } |
101 | 102 | ||
102 | module_init(mga_init); | 103 | module_init(mga_init); |
diff --git a/drivers/gpu/drm/nouveau/nouveau_drv.c b/drivers/gpu/drm/nouveau/nouveau_drv.c index f658a04eecf9..155ebdcbf06f 100644 --- a/drivers/gpu/drm/nouveau/nouveau_drv.c +++ b/drivers/gpu/drm/nouveau/nouveau_drv.c | |||
@@ -408,14 +408,6 @@ static struct drm_driver driver = { | |||
408 | #endif | 408 | #endif |
409 | .llseek = noop_llseek, | 409 | .llseek = noop_llseek, |
410 | }, | 410 | }, |
411 | .pci_driver = { | ||
412 | .name = DRIVER_NAME, | ||
413 | .id_table = pciidlist, | ||
414 | .probe = nouveau_pci_probe, | ||
415 | .remove = nouveau_pci_remove, | ||
416 | .suspend = nouveau_pci_suspend, | ||
417 | .resume = nouveau_pci_resume | ||
418 | }, | ||
419 | 411 | ||
420 | .gem_init_object = nouveau_gem_object_new, | 412 | .gem_init_object = nouveau_gem_object_new, |
421 | .gem_free_object = nouveau_gem_object_del, | 413 | .gem_free_object = nouveau_gem_object_del, |
@@ -432,6 +424,15 @@ static struct drm_driver driver = { | |||
432 | .patchlevel = DRIVER_PATCHLEVEL, | 424 | .patchlevel = DRIVER_PATCHLEVEL, |
433 | }; | 425 | }; |
434 | 426 | ||
427 | static struct pci_driver nouveau_pci_driver = { | ||
428 | .name = DRIVER_NAME, | ||
429 | .id_table = pciidlist, | ||
430 | .probe = nouveau_pci_probe, | ||
431 | .remove = nouveau_pci_remove, | ||
432 | .suspend = nouveau_pci_suspend, | ||
433 | .resume = nouveau_pci_resume | ||
434 | }; | ||
435 | |||
435 | static int __init nouveau_init(void) | 436 | static int __init nouveau_init(void) |
436 | { | 437 | { |
437 | driver.num_ioctls = nouveau_max_ioctl; | 438 | driver.num_ioctls = nouveau_max_ioctl; |
@@ -449,7 +450,7 @@ static int __init nouveau_init(void) | |||
449 | return 0; | 450 | return 0; |
450 | 451 | ||
451 | nouveau_register_dsm_handler(); | 452 | nouveau_register_dsm_handler(); |
452 | return drm_init(&driver); | 453 | return drm_pci_init(&driver, &nouveau_pci_driver); |
453 | } | 454 | } |
454 | 455 | ||
455 | static void __exit nouveau_exit(void) | 456 | static void __exit nouveau_exit(void) |
@@ -457,7 +458,7 @@ static void __exit nouveau_exit(void) | |||
457 | if (!nouveau_modeset) | 458 | if (!nouveau_modeset) |
458 | return; | 459 | return; |
459 | 460 | ||
460 | drm_exit(&driver); | 461 | drm_pci_exit(&driver, &nouveau_pci_driver); |
461 | nouveau_unregister_dsm_handler(); | 462 | nouveau_unregister_dsm_handler(); |
462 | } | 463 | } |
463 | 464 | ||
diff --git a/drivers/gpu/drm/nouveau/nouveau_mem.c b/drivers/gpu/drm/nouveau/nouveau_mem.c index 26347b7cd872..123969dd4f56 100644 --- a/drivers/gpu/drm/nouveau/nouveau_mem.c +++ b/drivers/gpu/drm/nouveau/nouveau_mem.c | |||
@@ -480,7 +480,7 @@ nouveau_mem_gart_init(struct drm_device *dev) | |||
480 | dev_priv->gart_info.type = NOUVEAU_GART_NONE; | 480 | dev_priv->gart_info.type = NOUVEAU_GART_NONE; |
481 | 481 | ||
482 | #if !defined(__powerpc__) && !defined(__ia64__) | 482 | #if !defined(__powerpc__) && !defined(__ia64__) |
483 | if (drm_device_is_agp(dev) && dev->agp && nouveau_agpmode) { | 483 | if (drm_pci_device_is_agp(dev) && dev->agp && nouveau_agpmode) { |
484 | ret = nouveau_mem_init_agp(dev); | 484 | ret = nouveau_mem_init_agp(dev); |
485 | if (ret) | 485 | if (ret) |
486 | NV_ERROR(dev, "Error initialising AGP: %d\n", ret); | 486 | NV_ERROR(dev, "Error initialising AGP: %d\n", ret); |
diff --git a/drivers/gpu/drm/nouveau/nouveau_state.c b/drivers/gpu/drm/nouveau/nouveau_state.c index a54fc431fe98..2148d01354da 100644 --- a/drivers/gpu/drm/nouveau/nouveau_state.c +++ b/drivers/gpu/drm/nouveau/nouveau_state.c | |||
@@ -1103,9 +1103,9 @@ int nouveau_ioctl_getparam(struct drm_device *dev, void *data, | |||
1103 | getparam->value = dev->pci_device; | 1103 | getparam->value = dev->pci_device; |
1104 | break; | 1104 | break; |
1105 | case NOUVEAU_GETPARAM_BUS_TYPE: | 1105 | case NOUVEAU_GETPARAM_BUS_TYPE: |
1106 | if (drm_device_is_agp(dev)) | 1106 | if (drm_pci_device_is_agp(dev)) |
1107 | getparam->value = NV_AGP; | 1107 | getparam->value = NV_AGP; |
1108 | else if (drm_device_is_pcie(dev)) | 1108 | else if (drm_pci_device_is_pcie(dev)) |
1109 | getparam->value = NV_PCIE; | 1109 | getparam->value = NV_PCIE; |
1110 | else | 1110 | else |
1111 | getparam->value = NV_PCI; | 1111 | getparam->value = NV_PCI; |
diff --git a/drivers/gpu/drm/r128/r128_drv.c b/drivers/gpu/drm/r128/r128_drv.c index 18c3c71e41b1..b9e8efd2b754 100644 --- a/drivers/gpu/drm/r128/r128_drv.c +++ b/drivers/gpu/drm/r128/r128_drv.c | |||
@@ -71,10 +71,7 @@ static struct drm_driver driver = { | |||
71 | #endif | 71 | #endif |
72 | .llseek = noop_llseek, | 72 | .llseek = noop_llseek, |
73 | }, | 73 | }, |
74 | .pci_driver = { | 74 | |
75 | .name = DRIVER_NAME, | ||
76 | .id_table = pciidlist, | ||
77 | }, | ||
78 | 75 | ||
79 | .name = DRIVER_NAME, | 76 | .name = DRIVER_NAME, |
80 | .desc = DRIVER_DESC, | 77 | .desc = DRIVER_DESC, |
@@ -89,16 +86,21 @@ int r128_driver_load(struct drm_device *dev, unsigned long flags) | |||
89 | return drm_vblank_init(dev, 1); | 86 | return drm_vblank_init(dev, 1); |
90 | } | 87 | } |
91 | 88 | ||
89 | static struct pci_driver r128_pci_driver = { | ||
90 | .name = DRIVER_NAME, | ||
91 | .id_table = pciidlist, | ||
92 | }; | ||
93 | |||
92 | static int __init r128_init(void) | 94 | static int __init r128_init(void) |
93 | { | 95 | { |
94 | driver.num_ioctls = r128_max_ioctl; | 96 | driver.num_ioctls = r128_max_ioctl; |
95 | 97 | ||
96 | return drm_init(&driver); | 98 | return drm_pci_init(&driver, &r128_pci_driver); |
97 | } | 99 | } |
98 | 100 | ||
99 | static void __exit r128_exit(void) | 101 | static void __exit r128_exit(void) |
100 | { | 102 | { |
101 | drm_exit(&driver); | 103 | drm_pci_exit(&driver, &r128_pci_driver); |
102 | } | 104 | } |
103 | 105 | ||
104 | module_init(r128_init); | 106 | module_init(r128_init); |
diff --git a/drivers/gpu/drm/radeon/radeon_cp.c b/drivers/gpu/drm/radeon/radeon_cp.c index eb6b9eed7349..3d599e33b9cc 100644 --- a/drivers/gpu/drm/radeon/radeon_cp.c +++ b/drivers/gpu/drm/radeon/radeon_cp.c | |||
@@ -2113,9 +2113,9 @@ int radeon_driver_load(struct drm_device *dev, unsigned long flags) | |||
2113 | break; | 2113 | break; |
2114 | } | 2114 | } |
2115 | 2115 | ||
2116 | if (drm_device_is_agp(dev)) | 2116 | if (drm_pci_device_is_agp(dev)) |
2117 | dev_priv->flags |= RADEON_IS_AGP; | 2117 | dev_priv->flags |= RADEON_IS_AGP; |
2118 | else if (drm_device_is_pcie(dev)) | 2118 | else if (drm_pci_device_is_pcie(dev)) |
2119 | dev_priv->flags |= RADEON_IS_PCIE; | 2119 | dev_priv->flags |= RADEON_IS_PCIE; |
2120 | else | 2120 | else |
2121 | dev_priv->flags |= RADEON_IS_PCI; | 2121 | dev_priv->flags |= RADEON_IS_PCI; |
diff --git a/drivers/gpu/drm/radeon/radeon_drv.c b/drivers/gpu/drm/radeon/radeon_drv.c index ca1b7d4c1d83..8a0df3d2a4c3 100644 --- a/drivers/gpu/drm/radeon/radeon_drv.c +++ b/drivers/gpu/drm/radeon/radeon_drv.c | |||
@@ -238,11 +238,6 @@ static struct drm_driver driver_old = { | |||
238 | .llseek = noop_llseek, | 238 | .llseek = noop_llseek, |
239 | }, | 239 | }, |
240 | 240 | ||
241 | .pci_driver = { | ||
242 | .name = DRIVER_NAME, | ||
243 | .id_table = pciidlist, | ||
244 | }, | ||
245 | |||
246 | .name = DRIVER_NAME, | 241 | .name = DRIVER_NAME, |
247 | .desc = DRIVER_DESC, | 242 | .desc = DRIVER_DESC, |
248 | .date = DRIVER_DATE, | 243 | .date = DRIVER_DATE, |
@@ -349,15 +344,6 @@ static struct drm_driver kms_driver = { | |||
349 | #endif | 344 | #endif |
350 | }, | 345 | }, |
351 | 346 | ||
352 | .pci_driver = { | ||
353 | .name = DRIVER_NAME, | ||
354 | .id_table = pciidlist, | ||
355 | .probe = radeon_pci_probe, | ||
356 | .remove = radeon_pci_remove, | ||
357 | .suspend = radeon_pci_suspend, | ||
358 | .resume = radeon_pci_resume, | ||
359 | }, | ||
360 | |||
361 | .name = DRIVER_NAME, | 347 | .name = DRIVER_NAME, |
362 | .desc = DRIVER_DESC, | 348 | .desc = DRIVER_DESC, |
363 | .date = DRIVER_DATE, | 349 | .date = DRIVER_DATE, |
@@ -367,15 +353,32 @@ static struct drm_driver kms_driver = { | |||
367 | }; | 353 | }; |
368 | 354 | ||
369 | static struct drm_driver *driver; | 355 | static struct drm_driver *driver; |
356 | static struct pci_driver *pdriver; | ||
357 | |||
358 | static struct pci_driver radeon_pci_driver = { | ||
359 | .name = DRIVER_NAME, | ||
360 | .id_table = pciidlist, | ||
361 | }; | ||
362 | |||
363 | static struct pci_driver radeon_kms_pci_driver = { | ||
364 | .name = DRIVER_NAME, | ||
365 | .id_table = pciidlist, | ||
366 | .probe = radeon_pci_probe, | ||
367 | .remove = radeon_pci_remove, | ||
368 | .suspend = radeon_pci_suspend, | ||
369 | .resume = radeon_pci_resume, | ||
370 | }; | ||
370 | 371 | ||
371 | static int __init radeon_init(void) | 372 | static int __init radeon_init(void) |
372 | { | 373 | { |
373 | driver = &driver_old; | 374 | driver = &driver_old; |
375 | pdriver = &radeon_pci_driver; | ||
374 | driver->num_ioctls = radeon_max_ioctl; | 376 | driver->num_ioctls = radeon_max_ioctl; |
375 | #ifdef CONFIG_VGA_CONSOLE | 377 | #ifdef CONFIG_VGA_CONSOLE |
376 | if (vgacon_text_force() && radeon_modeset == -1) { | 378 | if (vgacon_text_force() && radeon_modeset == -1) { |
377 | DRM_INFO("VGACON disable radeon kernel modesetting.\n"); | 379 | DRM_INFO("VGACON disable radeon kernel modesetting.\n"); |
378 | driver = &driver_old; | 380 | driver = &driver_old; |
381 | pdriver = &radeon_pci_driver; | ||
379 | driver->driver_features &= ~DRIVER_MODESET; | 382 | driver->driver_features &= ~DRIVER_MODESET; |
380 | radeon_modeset = 0; | 383 | radeon_modeset = 0; |
381 | } | 384 | } |
@@ -393,18 +396,19 @@ static int __init radeon_init(void) | |||
393 | if (radeon_modeset == 1) { | 396 | if (radeon_modeset == 1) { |
394 | DRM_INFO("radeon kernel modesetting enabled.\n"); | 397 | DRM_INFO("radeon kernel modesetting enabled.\n"); |
395 | driver = &kms_driver; | 398 | driver = &kms_driver; |
399 | pdriver = &radeon_kms_pci_driver; | ||
396 | driver->driver_features |= DRIVER_MODESET; | 400 | driver->driver_features |= DRIVER_MODESET; |
397 | driver->num_ioctls = radeon_max_kms_ioctl; | 401 | driver->num_ioctls = radeon_max_kms_ioctl; |
398 | radeon_register_atpx_handler(); | 402 | radeon_register_atpx_handler(); |
399 | } | 403 | } |
400 | /* if the vga console setting is enabled still | 404 | /* if the vga console setting is enabled still |
401 | * let modprobe override it */ | 405 | * let modprobe override it */ |
402 | return drm_init(driver); | 406 | return drm_pci_init(driver, pdriver); |
403 | } | 407 | } |
404 | 408 | ||
405 | static void __exit radeon_exit(void) | 409 | static void __exit radeon_exit(void) |
406 | { | 410 | { |
407 | drm_exit(driver); | 411 | drm_pci_exit(driver, pdriver); |
408 | radeon_unregister_atpx_handler(); | 412 | radeon_unregister_atpx_handler(); |
409 | } | 413 | } |
410 | 414 | ||
diff --git a/drivers/gpu/drm/radeon/radeon_kms.c b/drivers/gpu/drm/radeon/radeon_kms.c index 8387d32caaa7..4057ebf5195d 100644 --- a/drivers/gpu/drm/radeon/radeon_kms.c +++ b/drivers/gpu/drm/radeon/radeon_kms.c | |||
@@ -58,9 +58,9 @@ int radeon_driver_load_kms(struct drm_device *dev, unsigned long flags) | |||
58 | dev->dev_private = (void *)rdev; | 58 | dev->dev_private = (void *)rdev; |
59 | 59 | ||
60 | /* update BUS flag */ | 60 | /* update BUS flag */ |
61 | if (drm_device_is_agp(dev)) { | 61 | if (drm_pci_device_is_agp(dev)) { |
62 | flags |= RADEON_IS_AGP; | 62 | flags |= RADEON_IS_AGP; |
63 | } else if (drm_device_is_pcie(dev)) { | 63 | } else if (drm_pci_device_is_pcie(dev)) { |
64 | flags |= RADEON_IS_PCIE; | 64 | flags |= RADEON_IS_PCIE; |
65 | } else { | 65 | } else { |
66 | flags |= RADEON_IS_PCI; | 66 | flags |= RADEON_IS_PCI; |
diff --git a/drivers/gpu/drm/savage/savage_drv.c b/drivers/gpu/drm/savage/savage_drv.c index fa64d25d4248..6464490b240b 100644 --- a/drivers/gpu/drm/savage/savage_drv.c +++ b/drivers/gpu/drm/savage/savage_drv.c | |||
@@ -55,11 +55,6 @@ static struct drm_driver driver = { | |||
55 | .llseek = noop_llseek, | 55 | .llseek = noop_llseek, |
56 | }, | 56 | }, |
57 | 57 | ||
58 | .pci_driver = { | ||
59 | .name = DRIVER_NAME, | ||
60 | .id_table = pciidlist, | ||
61 | }, | ||
62 | |||
63 | .name = DRIVER_NAME, | 58 | .name = DRIVER_NAME, |
64 | .desc = DRIVER_DESC, | 59 | .desc = DRIVER_DESC, |
65 | .date = DRIVER_DATE, | 60 | .date = DRIVER_DATE, |
@@ -68,15 +63,20 @@ static struct drm_driver driver = { | |||
68 | .patchlevel = DRIVER_PATCHLEVEL, | 63 | .patchlevel = DRIVER_PATCHLEVEL, |
69 | }; | 64 | }; |
70 | 65 | ||
66 | static struct pci_driver savage_pci_driver = { | ||
67 | .name = DRIVER_NAME, | ||
68 | .id_table = pciidlist, | ||
69 | }; | ||
70 | |||
71 | static int __init savage_init(void) | 71 | static int __init savage_init(void) |
72 | { | 72 | { |
73 | driver.num_ioctls = savage_max_ioctl; | 73 | driver.num_ioctls = savage_max_ioctl; |
74 | return drm_init(&driver); | 74 | return drm_pci_init(&driver, &savage_pci_driver); |
75 | } | 75 | } |
76 | 76 | ||
77 | static void __exit savage_exit(void) | 77 | static void __exit savage_exit(void) |
78 | { | 78 | { |
79 | drm_exit(&driver); | 79 | drm_pci_exit(&driver, &savage_pci_driver); |
80 | } | 80 | } |
81 | 81 | ||
82 | module_init(savage_init); | 82 | module_init(savage_init); |
diff --git a/drivers/gpu/drm/sis/sis_drv.c b/drivers/gpu/drm/sis/sis_drv.c index 4caf5d01cfd3..46d5be6e97e5 100644 --- a/drivers/gpu/drm/sis/sis_drv.c +++ b/drivers/gpu/drm/sis/sis_drv.c | |||
@@ -82,10 +82,6 @@ static struct drm_driver driver = { | |||
82 | .fasync = drm_fasync, | 82 | .fasync = drm_fasync, |
83 | .llseek = noop_llseek, | 83 | .llseek = noop_llseek, |
84 | }, | 84 | }, |
85 | .pci_driver = { | ||
86 | .name = DRIVER_NAME, | ||
87 | .id_table = pciidlist, | ||
88 | }, | ||
89 | 85 | ||
90 | .name = DRIVER_NAME, | 86 | .name = DRIVER_NAME, |
91 | .desc = DRIVER_DESC, | 87 | .desc = DRIVER_DESC, |
@@ -95,15 +91,20 @@ static struct drm_driver driver = { | |||
95 | .patchlevel = DRIVER_PATCHLEVEL, | 91 | .patchlevel = DRIVER_PATCHLEVEL, |
96 | }; | 92 | }; |
97 | 93 | ||
94 | static struct pci_driver sis_pci_driver = { | ||
95 | .name = DRIVER_NAME, | ||
96 | .id_table = pciidlist, | ||
97 | }; | ||
98 | |||
98 | static int __init sis_init(void) | 99 | static int __init sis_init(void) |
99 | { | 100 | { |
100 | driver.num_ioctls = sis_max_ioctl; | 101 | driver.num_ioctls = sis_max_ioctl; |
101 | return drm_init(&driver); | 102 | return drm_pci_init(&driver, &sis_pci_driver); |
102 | } | 103 | } |
103 | 104 | ||
104 | static void __exit sis_exit(void) | 105 | static void __exit sis_exit(void) |
105 | { | 106 | { |
106 | drm_exit(&driver); | 107 | drm_pci_exit(&driver, &sis_pci_driver); |
107 | } | 108 | } |
108 | 109 | ||
109 | module_init(sis_init); | 110 | module_init(sis_init); |
diff --git a/drivers/gpu/drm/tdfx/tdfx_drv.c b/drivers/gpu/drm/tdfx/tdfx_drv.c index b70fa91d761a..8bf98810a8d6 100644 --- a/drivers/gpu/drm/tdfx/tdfx_drv.c +++ b/drivers/gpu/drm/tdfx/tdfx_drv.c | |||
@@ -52,10 +52,6 @@ static struct drm_driver driver = { | |||
52 | .fasync = drm_fasync, | 52 | .fasync = drm_fasync, |
53 | .llseek = noop_llseek, | 53 | .llseek = noop_llseek, |
54 | }, | 54 | }, |
55 | .pci_driver = { | ||
56 | .name = DRIVER_NAME, | ||
57 | .id_table = pciidlist, | ||
58 | }, | ||
59 | 55 | ||
60 | .name = DRIVER_NAME, | 56 | .name = DRIVER_NAME, |
61 | .desc = DRIVER_DESC, | 57 | .desc = DRIVER_DESC, |
@@ -65,14 +61,19 @@ static struct drm_driver driver = { | |||
65 | .patchlevel = DRIVER_PATCHLEVEL, | 61 | .patchlevel = DRIVER_PATCHLEVEL, |
66 | }; | 62 | }; |
67 | 63 | ||
64 | static struct pci_driver tdfx_pci_driver = { | ||
65 | .name = DRIVER_NAME, | ||
66 | .id_table = pciidlist, | ||
67 | }; | ||
68 | |||
68 | static int __init tdfx_init(void) | 69 | static int __init tdfx_init(void) |
69 | { | 70 | { |
70 | return drm_init(&driver); | 71 | return drm_pci_init(&driver, &tdfx_pci_driver); |
71 | } | 72 | } |
72 | 73 | ||
73 | static void __exit tdfx_exit(void) | 74 | static void __exit tdfx_exit(void) |
74 | { | 75 | { |
75 | drm_exit(&driver); | 76 | drm_pci_exit(&driver, &tdfx_pci_driver); |
76 | } | 77 | } |
77 | 78 | ||
78 | module_init(tdfx_init); | 79 | module_init(tdfx_init); |
diff --git a/drivers/gpu/drm/via/via_drv.c b/drivers/gpu/drm/via/via_drv.c index e1ff4e7a6eb0..920a55214bcf 100644 --- a/drivers/gpu/drm/via/via_drv.c +++ b/drivers/gpu/drm/via/via_drv.c | |||
@@ -62,10 +62,6 @@ static struct drm_driver driver = { | |||
62 | .fasync = drm_fasync, | 62 | .fasync = drm_fasync, |
63 | .llseek = noop_llseek, | 63 | .llseek = noop_llseek, |
64 | }, | 64 | }, |
65 | .pci_driver = { | ||
66 | .name = DRIVER_NAME, | ||
67 | .id_table = pciidlist, | ||
68 | }, | ||
69 | 65 | ||
70 | .name = DRIVER_NAME, | 66 | .name = DRIVER_NAME, |
71 | .desc = DRIVER_DESC, | 67 | .desc = DRIVER_DESC, |
@@ -75,16 +71,21 @@ static struct drm_driver driver = { | |||
75 | .patchlevel = DRIVER_PATCHLEVEL, | 71 | .patchlevel = DRIVER_PATCHLEVEL, |
76 | }; | 72 | }; |
77 | 73 | ||
74 | static struct pci_driver via_pci_driver = { | ||
75 | .name = DRIVER_NAME, | ||
76 | .id_table = pciidlist, | ||
77 | }; | ||
78 | |||
78 | static int __init via_init(void) | 79 | static int __init via_init(void) |
79 | { | 80 | { |
80 | driver.num_ioctls = via_max_ioctl; | 81 | driver.num_ioctls = via_max_ioctl; |
81 | via_init_command_verifier(); | 82 | via_init_command_verifier(); |
82 | return drm_init(&driver); | 83 | return drm_pci_init(&driver, &via_pci_driver); |
83 | } | 84 | } |
84 | 85 | ||
85 | static void __exit via_exit(void) | 86 | static void __exit via_exit(void) |
86 | { | 87 | { |
87 | drm_exit(&driver); | 88 | drm_pci_exit(&driver, &via_pci_driver); |
88 | } | 89 | } |
89 | 90 | ||
90 | module_init(via_init); | 91 | module_init(via_init); |
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c index 10ca97ee0206..96949b93d920 100644 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c | |||
@@ -909,15 +909,6 @@ static struct drm_driver driver = { | |||
909 | #endif | 909 | #endif |
910 | .llseek = noop_llseek, | 910 | .llseek = noop_llseek, |
911 | }, | 911 | }, |
912 | .pci_driver = { | ||
913 | .name = VMWGFX_DRIVER_NAME, | ||
914 | .id_table = vmw_pci_id_list, | ||
915 | .probe = vmw_probe, | ||
916 | .remove = vmw_remove, | ||
917 | .driver = { | ||
918 | .pm = &vmw_pm_ops | ||
919 | } | ||
920 | }, | ||
921 | .name = VMWGFX_DRIVER_NAME, | 912 | .name = VMWGFX_DRIVER_NAME, |
922 | .desc = VMWGFX_DRIVER_DESC, | 913 | .desc = VMWGFX_DRIVER_DESC, |
923 | .date = VMWGFX_DRIVER_DATE, | 914 | .date = VMWGFX_DRIVER_DATE, |
@@ -926,6 +917,16 @@ static struct drm_driver driver = { | |||
926 | .patchlevel = VMWGFX_DRIVER_PATCHLEVEL | 917 | .patchlevel = VMWGFX_DRIVER_PATCHLEVEL |
927 | }; | 918 | }; |
928 | 919 | ||
920 | static struct pci_driver vmw_pci_driver = { | ||
921 | .name = VMWGFX_DRIVER_NAME, | ||
922 | .id_table = vmw_pci_id_list, | ||
923 | .probe = vmw_probe, | ||
924 | .remove = vmw_remove, | ||
925 | .driver = { | ||
926 | .pm = &vmw_pm_ops | ||
927 | } | ||
928 | }; | ||
929 | |||
929 | static int vmw_probe(struct pci_dev *pdev, const struct pci_device_id *ent) | 930 | static int vmw_probe(struct pci_dev *pdev, const struct pci_device_id *ent) |
930 | { | 931 | { |
931 | return drm_get_pci_dev(pdev, ent, &driver); | 932 | return drm_get_pci_dev(pdev, ent, &driver); |
@@ -934,7 +935,7 @@ static int vmw_probe(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
934 | static int __init vmwgfx_init(void) | 935 | static int __init vmwgfx_init(void) |
935 | { | 936 | { |
936 | int ret; | 937 | int ret; |
937 | ret = drm_init(&driver); | 938 | ret = drm_pci_init(&driver, &vmw_pci_driver); |
938 | if (ret) | 939 | if (ret) |
939 | DRM_ERROR("Failed initializing DRM.\n"); | 940 | DRM_ERROR("Failed initializing DRM.\n"); |
940 | return ret; | 941 | return ret; |
@@ -942,7 +943,7 @@ static int __init vmwgfx_init(void) | |||
942 | 943 | ||
943 | static void __exit vmwgfx_exit(void) | 944 | static void __exit vmwgfx_exit(void) |
944 | { | 945 | { |
945 | drm_exit(&driver); | 946 | drm_pci_exit(&driver, &vmw_pci_driver); |
946 | } | 947 | } |
947 | 948 | ||
948 | module_init(vmwgfx_init); | 949 | module_init(vmwgfx_init); |
diff --git a/include/drm/drmP.h b/include/drm/drmP.h index 3cbe7a02d2aa..a99aefb9537c 100644 --- a/include/drm/drmP.h +++ b/include/drm/drmP.h | |||
@@ -145,7 +145,10 @@ extern void drm_ut_debug_printk(unsigned int request_level, | |||
145 | #define DRIVER_IRQ_VBL2 0x800 | 145 | #define DRIVER_IRQ_VBL2 0x800 |
146 | #define DRIVER_GEM 0x1000 | 146 | #define DRIVER_GEM 0x1000 |
147 | #define DRIVER_MODESET 0x2000 | 147 | #define DRIVER_MODESET 0x2000 |
148 | #define DRIVER_USE_PLATFORM_DEVICE 0x4000 | 148 | |
149 | #define DRIVER_BUS_PCI 0x1 | ||
150 | #define DRIVER_BUS_PLATFORM 0x2 | ||
151 | #define DRIVER_BUS_USB 0x3 | ||
149 | 152 | ||
150 | /***********************************************************************/ | 153 | /***********************************************************************/ |
151 | /** \name Begin the DRM... */ | 154 | /** \name Begin the DRM... */ |
@@ -698,6 +701,19 @@ struct drm_master { | |||
698 | #define DRM_SCANOUTPOS_INVBL (1 << 1) | 701 | #define DRM_SCANOUTPOS_INVBL (1 << 1) |
699 | #define DRM_SCANOUTPOS_ACCURATE (1 << 2) | 702 | #define DRM_SCANOUTPOS_ACCURATE (1 << 2) |
700 | 703 | ||
704 | struct drm_bus { | ||
705 | int bus_type; | ||
706 | int (*get_irq)(struct drm_device *dev); | ||
707 | const char *(*get_name)(struct drm_device *dev); | ||
708 | int (*set_busid)(struct drm_device *dev, struct drm_master *master); | ||
709 | int (*set_unique)(struct drm_device *dev, struct drm_master *master, | ||
710 | struct drm_unique *unique); | ||
711 | int (*irq_by_busid)(struct drm_device *dev, struct drm_irq_busid *p); | ||
712 | /* hooks that are for PCI */ | ||
713 | int (*agp_init)(struct drm_device *dev); | ||
714 | |||
715 | }; | ||
716 | |||
701 | /** | 717 | /** |
702 | * DRM driver structure. This structure represent the common code for | 718 | * DRM driver structure. This structure represent the common code for |
703 | * a family of cards. There will one drm_device for each card present | 719 | * a family of cards. There will one drm_device for each card present |
@@ -906,8 +922,12 @@ struct drm_driver { | |||
906 | struct drm_ioctl_desc *ioctls; | 922 | struct drm_ioctl_desc *ioctls; |
907 | int num_ioctls; | 923 | int num_ioctls; |
908 | struct file_operations fops; | 924 | struct file_operations fops; |
909 | struct pci_driver pci_driver; | 925 | union { |
910 | struct platform_device *platform_device; | 926 | struct pci_driver *pci; |
927 | struct platform_device *platform_device; | ||
928 | } kdriver; | ||
929 | struct drm_bus *bus; | ||
930 | |||
911 | /* List of devices hanging off this driver */ | 931 | /* List of devices hanging off this driver */ |
912 | struct list_head device_list; | 932 | struct list_head device_list; |
913 | }; | 933 | }; |
@@ -1147,28 +1167,9 @@ static __inline__ int drm_core_check_feature(struct drm_device *dev, | |||
1147 | 1167 | ||
1148 | static inline int drm_dev_to_irq(struct drm_device *dev) | 1168 | static inline int drm_dev_to_irq(struct drm_device *dev) |
1149 | { | 1169 | { |
1150 | if (drm_core_check_feature(dev, DRIVER_USE_PLATFORM_DEVICE)) | 1170 | return dev->driver->bus->get_irq(dev); |
1151 | return platform_get_irq(dev->platformdev, 0); | ||
1152 | else | ||
1153 | return dev->pdev->irq; | ||
1154 | } | 1171 | } |
1155 | 1172 | ||
1156 | static inline int drm_get_pci_domain(struct drm_device *dev) | ||
1157 | { | ||
1158 | if (drm_core_check_feature(dev, DRIVER_USE_PLATFORM_DEVICE)) | ||
1159 | return 0; | ||
1160 | |||
1161 | #ifndef __alpha__ | ||
1162 | /* For historical reasons, drm_get_pci_domain() is busticated | ||
1163 | * on most archs and has to remain so for userspace interface | ||
1164 | * < 1.4, except on alpha which was right from the beginning | ||
1165 | */ | ||
1166 | if (dev->if_version < 0x10004) | ||
1167 | return 0; | ||
1168 | #endif /* __alpha__ */ | ||
1169 | |||
1170 | return pci_domain_nr(dev->pdev->bus); | ||
1171 | } | ||
1172 | 1173 | ||
1173 | #if __OS_HAS_AGP | 1174 | #if __OS_HAS_AGP |
1174 | static inline int drm_core_has_AGP(struct drm_device *dev) | 1175 | static inline int drm_core_has_AGP(struct drm_device *dev) |
@@ -1222,8 +1223,6 @@ static inline int drm_mtrr_del(int handle, unsigned long offset, | |||
1222 | /*@{*/ | 1223 | /*@{*/ |
1223 | 1224 | ||
1224 | /* Driver support (drm_drv.h) */ | 1225 | /* Driver support (drm_drv.h) */ |
1225 | extern int drm_init(struct drm_driver *driver); | ||
1226 | extern void drm_exit(struct drm_driver *driver); | ||
1227 | extern long drm_ioctl(struct file *filp, | 1226 | extern long drm_ioctl(struct file *filp, |
1228 | unsigned int cmd, unsigned long arg); | 1227 | unsigned int cmd, unsigned long arg); |
1229 | extern long drm_compat_ioctl(struct file *filp, | 1228 | extern long drm_compat_ioctl(struct file *filp, |
@@ -1433,11 +1432,7 @@ extern int drm_dropmaster_ioctl(struct drm_device *dev, void *data, | |||
1433 | struct drm_master *drm_master_create(struct drm_minor *minor); | 1432 | struct drm_master *drm_master_create(struct drm_minor *minor); |
1434 | extern struct drm_master *drm_master_get(struct drm_master *master); | 1433 | extern struct drm_master *drm_master_get(struct drm_master *master); |
1435 | extern void drm_master_put(struct drm_master **master); | 1434 | extern void drm_master_put(struct drm_master **master); |
1436 | extern int drm_get_pci_dev(struct pci_dev *pdev, | 1435 | |
1437 | const struct pci_device_id *ent, | ||
1438 | struct drm_driver *driver); | ||
1439 | extern int drm_get_platform_dev(struct platform_device *pdev, | ||
1440 | struct drm_driver *driver); | ||
1441 | extern void drm_put_dev(struct drm_device *dev); | 1436 | extern void drm_put_dev(struct drm_device *dev); |
1442 | extern int drm_put_minor(struct drm_minor **minor); | 1437 | extern int drm_put_minor(struct drm_minor **minor); |
1443 | extern unsigned int drm_debug; | 1438 | extern unsigned int drm_debug; |
@@ -1628,11 +1623,21 @@ static __inline__ struct drm_local_map *drm_core_findmap(struct drm_device *dev, | |||
1628 | return NULL; | 1623 | return NULL; |
1629 | } | 1624 | } |
1630 | 1625 | ||
1631 | static __inline__ int drm_device_is_agp(struct drm_device *dev) | 1626 | static __inline__ void drm_core_dropmap(struct drm_local_map *map) |
1632 | { | 1627 | { |
1633 | if (drm_core_check_feature(dev, DRIVER_USE_PLATFORM_DEVICE)) | 1628 | } |
1634 | return 0; | 1629 | |
1630 | #include "drm_mem_util.h" | ||
1635 | 1631 | ||
1632 | extern int drm_fill_in_dev(struct drm_device *dev, | ||
1633 | const struct pci_device_id *ent, | ||
1634 | struct drm_driver *driver); | ||
1635 | int drm_get_minor(struct drm_device *dev, struct drm_minor **minor, int type); | ||
1636 | /*@}*/ | ||
1637 | |||
1638 | /* PCI section */ | ||
1639 | static __inline__ int drm_pci_device_is_agp(struct drm_device *dev) | ||
1640 | { | ||
1636 | if (dev->driver->device_is_agp != NULL) { | 1641 | if (dev->driver->device_is_agp != NULL) { |
1637 | int err = (*dev->driver->device_is_agp) (dev); | 1642 | int err = (*dev->driver->device_is_agp) (dev); |
1638 | 1643 | ||
@@ -1644,35 +1649,26 @@ static __inline__ int drm_device_is_agp(struct drm_device *dev) | |||
1644 | return pci_find_capability(dev->pdev, PCI_CAP_ID_AGP); | 1649 | return pci_find_capability(dev->pdev, PCI_CAP_ID_AGP); |
1645 | } | 1650 | } |
1646 | 1651 | ||
1647 | static __inline__ int drm_device_is_pcie(struct drm_device *dev) | ||
1648 | { | ||
1649 | if (drm_core_check_feature(dev, DRIVER_USE_PLATFORM_DEVICE)) | ||
1650 | return 0; | ||
1651 | else | ||
1652 | return pci_find_capability(dev->pdev, PCI_CAP_ID_EXP); | ||
1653 | } | ||
1654 | 1652 | ||
1655 | static __inline__ void drm_core_dropmap(struct drm_local_map *map) | 1653 | static __inline__ int drm_pci_device_is_pcie(struct drm_device *dev) |
1656 | { | 1654 | { |
1655 | return pci_find_capability(dev->pdev, PCI_CAP_ID_EXP); | ||
1657 | } | 1656 | } |
1658 | 1657 | ||
1659 | #include "drm_mem_util.h" | ||
1660 | 1658 | ||
1661 | static inline void *drm_get_device(struct drm_device *dev) | 1659 | extern int drm_pci_init(struct drm_driver *driver, struct pci_driver *pdriver); |
1662 | { | 1660 | extern void drm_pci_exit(struct drm_driver *driver, struct pci_driver *pdriver); |
1663 | if (drm_core_check_feature(dev, DRIVER_USE_PLATFORM_DEVICE)) | 1661 | extern int drm_get_pci_dev(struct pci_dev *pdev, |
1664 | return dev->platformdev; | ||
1665 | else | ||
1666 | return dev->pdev; | ||
1667 | } | ||
1668 | |||
1669 | extern int drm_platform_init(struct drm_driver *driver); | ||
1670 | extern int drm_pci_init(struct drm_driver *driver); | ||
1671 | extern int drm_fill_in_dev(struct drm_device *dev, | ||
1672 | const struct pci_device_id *ent, | 1662 | const struct pci_device_id *ent, |
1673 | struct drm_driver *driver); | 1663 | struct drm_driver *driver); |
1674 | int drm_get_minor(struct drm_device *dev, struct drm_minor **minor, int type); | 1664 | |
1675 | /*@}*/ | 1665 | |
1666 | /* platform section */ | ||
1667 | extern int drm_platform_init(struct drm_driver *driver, struct platform_device *platform_device); | ||
1668 | extern void drm_platform_exit(struct drm_driver *driver, struct platform_device *platform_device); | ||
1669 | |||
1670 | extern int drm_get_platform_dev(struct platform_device *pdev, | ||
1671 | struct drm_driver *driver); | ||
1676 | 1672 | ||
1677 | #endif /* __KERNEL__ */ | 1673 | #endif /* __KERNEL__ */ |
1678 | #endif | 1674 | #endif |