diff options
author | Jordan Crouse <jcrouse@codeaurora.org> | 2010-05-27 15:40:25 -0400 |
---|---|---|
committer | Dave Airlie <airlied@redhat.com> | 2010-05-31 20:07:39 -0400 |
commit | dcdb167402cbdca1d021bdfa5f63995ee0a79317 (patch) | |
tree | 3cd0ab1189d972b59daaaf863f518d7b94d2de7a /drivers/gpu/drm/drm_stub.c | |
parent | 01d73a6967f12fe6c4bbde1834a9fe662264a2eb (diff) |
drm: Add support for platform devices to register as DRM devices
Allow platform devices without PCI resources to be DRM devices.
[airlied: fixup warnings with dev pointers]
Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>
Signed-off-by: Dave Airlie <airlied@redhat.com>
Diffstat (limited to 'drivers/gpu/drm/drm_stub.c')
-rw-r--r-- | drivers/gpu/drm/drm_stub.c | 89 |
1 files changed, 2 insertions, 87 deletions
diff --git a/drivers/gpu/drm/drm_stub.c b/drivers/gpu/drm/drm_stub.c index a0c365f2e521..63575e2fa882 100644 --- a/drivers/gpu/drm/drm_stub.c +++ b/drivers/gpu/drm/drm_stub.c | |||
@@ -224,7 +224,7 @@ int drm_dropmaster_ioctl(struct drm_device *dev, void *data, | |||
224 | return 0; | 224 | return 0; |
225 | } | 225 | } |
226 | 226 | ||
227 | static int drm_fill_in_dev(struct drm_device * dev, struct pci_dev *pdev, | 227 | int drm_fill_in_dev(struct drm_device *dev, |
228 | const struct pci_device_id *ent, | 228 | const struct pci_device_id *ent, |
229 | struct drm_driver *driver) | 229 | struct drm_driver *driver) |
230 | { | 230 | { |
@@ -245,14 +245,6 @@ static int drm_fill_in_dev(struct drm_device * dev, struct pci_dev *pdev, | |||
245 | 245 | ||
246 | idr_init(&dev->drw_idr); | 246 | idr_init(&dev->drw_idr); |
247 | 247 | ||
248 | dev->pdev = pdev; | ||
249 | dev->pci_device = pdev->device; | ||
250 | dev->pci_vendor = pdev->vendor; | ||
251 | |||
252 | #ifdef __alpha__ | ||
253 | dev->hose = pdev->sysdata; | ||
254 | #endif | ||
255 | |||
256 | if (drm_ht_create(&dev->map_hash, 12)) { | 248 | if (drm_ht_create(&dev->map_hash, 12)) { |
257 | return -ENOMEM; | 249 | return -ENOMEM; |
258 | } | 250 | } |
@@ -321,7 +313,7 @@ static int drm_fill_in_dev(struct drm_device * dev, struct pci_dev *pdev, | |||
321 | * create the proc init entry via proc_init(). This routines assigns | 313 | * create the proc init entry via proc_init(). This routines assigns |
322 | * minor numbers to secondary heads of multi-headed cards | 314 | * minor numbers to secondary heads of multi-headed cards |
323 | */ | 315 | */ |
324 | static int drm_get_minor(struct drm_device *dev, struct drm_minor **minor, int type) | 316 | int drm_get_minor(struct drm_device *dev, struct drm_minor **minor, int type) |
325 | { | 317 | { |
326 | struct drm_minor *new_minor; | 318 | struct drm_minor *new_minor; |
327 | int ret; | 319 | int ret; |
@@ -388,83 +380,6 @@ err_idr: | |||
388 | } | 380 | } |
389 | 381 | ||
390 | /** | 382 | /** |
391 | * Register. | ||
392 | * | ||
393 | * \param pdev - PCI device structure | ||
394 | * \param ent entry from the PCI ID table with device type flags | ||
395 | * \return zero on success or a negative number on failure. | ||
396 | * | ||
397 | * Attempt to gets inter module "drm" information. If we are first | ||
398 | * then register the character device and inter module information. | ||
399 | * Try and register, if we fail to register, backout previous work. | ||
400 | */ | ||
401 | int drm_get_dev(struct pci_dev *pdev, const struct pci_device_id *ent, | ||
402 | struct drm_driver *driver) | ||
403 | { | ||
404 | struct drm_device *dev; | ||
405 | int ret; | ||
406 | |||
407 | DRM_DEBUG("\n"); | ||
408 | |||
409 | dev = kzalloc(sizeof(*dev), GFP_KERNEL); | ||
410 | if (!dev) | ||
411 | return -ENOMEM; | ||
412 | |||
413 | ret = pci_enable_device(pdev); | ||
414 | if (ret) | ||
415 | goto err_g1; | ||
416 | |||
417 | pci_set_master(pdev); | ||
418 | if ((ret = drm_fill_in_dev(dev, pdev, ent, driver))) { | ||
419 | printk(KERN_ERR "DRM: Fill_in_dev failed.\n"); | ||
420 | goto err_g2; | ||
421 | } | ||
422 | |||
423 | if (drm_core_check_feature(dev, DRIVER_MODESET)) { | ||
424 | pci_set_drvdata(pdev, dev); | ||
425 | ret = drm_get_minor(dev, &dev->control, DRM_MINOR_CONTROL); | ||
426 | if (ret) | ||
427 | goto err_g2; | ||
428 | } | ||
429 | |||
430 | if ((ret = drm_get_minor(dev, &dev->primary, DRM_MINOR_LEGACY))) | ||
431 | goto err_g3; | ||
432 | |||
433 | if (dev->driver->load) { | ||
434 | ret = dev->driver->load(dev, ent->driver_data); | ||
435 | if (ret) | ||
436 | goto err_g4; | ||
437 | } | ||
438 | |||
439 | /* setup the grouping for the legacy output */ | ||
440 | if (drm_core_check_feature(dev, DRIVER_MODESET)) { | ||
441 | ret = drm_mode_group_init_legacy_group(dev, &dev->primary->mode_group); | ||
442 | if (ret) | ||
443 | goto err_g4; | ||
444 | } | ||
445 | |||
446 | list_add_tail(&dev->driver_item, &driver->device_list); | ||
447 | |||
448 | DRM_INFO("Initialized %s %d.%d.%d %s for %s on minor %d\n", | ||
449 | driver->name, driver->major, driver->minor, driver->patchlevel, | ||
450 | driver->date, pci_name(pdev), dev->primary->index); | ||
451 | |||
452 | return 0; | ||
453 | |||
454 | err_g4: | ||
455 | drm_put_minor(&dev->primary); | ||
456 | err_g3: | ||
457 | if (drm_core_check_feature(dev, DRIVER_MODESET)) | ||
458 | drm_put_minor(&dev->control); | ||
459 | err_g2: | ||
460 | pci_disable_device(pdev); | ||
461 | err_g1: | ||
462 | kfree(dev); | ||
463 | return ret; | ||
464 | } | ||
465 | EXPORT_SYMBOL(drm_get_dev); | ||
466 | |||
467 | /** | ||
468 | * Put a secondary minor number. | 383 | * Put a secondary minor number. |
469 | * | 384 | * |
470 | * \param sec_minor - structure to be released | 385 | * \param sec_minor - structure to be released |