diff options
author | Jorge Zapata <turran@openmoko.com> | 2009-02-17 17:48:14 +0100 |
---|---|---|
committer | Thomas White <taw@bitwiz.org.uk> | 2009-03-26 21:34:09 +0000 |
commit | d78d95efdfec5a39e470e8e866b864c8fc096c7a (patch) | |
tree | 4bc96b4ecfc1031d49df588ae477bd4e414aa939 /drivers/gpu/drm/drm_stub.c | |
parent | bd3253cdafb13969a3a52e38ec591d8c7df4b5dc (diff) |
Platform's DRM driver loading, unloading and sysfs interface support.
Diffstat (limited to 'drivers/gpu/drm/drm_stub.c')
-rw-r--r-- | drivers/gpu/drm/drm_stub.c | 57 |
1 files changed, 54 insertions, 3 deletions
diff --git a/drivers/gpu/drm/drm_stub.c b/drivers/gpu/drm/drm_stub.c index 46bb923b097..e8aa423bd9b 100644 --- a/drivers/gpu/drm/drm_stub.c +++ b/drivers/gpu/drm/drm_stub.c @@ -213,12 +213,13 @@ static int drm_fill_in_dev(struct drm_device * dev, struct pci_dev *pdev, idr_init(&dev->drw_idr); dev->pdev = pdev; - dev->pci_device = pdev->device; - dev->pci_vendor = pdev->vendor; - + if (pdev) { + dev->pci_device = pdev->device; + dev->pci_vendor = pdev->vendor; #ifdef __alpha__ dev->hose = pdev->sysdata; #endif + } if (drm_ht_create(&dev->map_hash, 12)) { return -ENOMEM; @@ -418,6 +419,56 @@ err_g1: return ret; } + /** + * + * Register a platform device as a DRM device + * + * \param pdev - platform device structure + * \param driver - the matching drm_driver structure + * \return zero on success or a negative number on failure. + * + * Attempt to gets inter module "drm" information. If we are first + * then register the character device and inter module information. + * Try and register, if we fail to register, backout previous work. + * + * \sa drm_get_dev + */ +int drm_get_platform_dev(struct platform_device *pdev, + struct drm_driver *driver) +{ + struct drm_device *dev; + int ret; +#if 0 + int len; +#endif + DRM_DEBUG("\n"); + + dev = drm_calloc(1, sizeof(*dev), DRM_MEM_STUB); + if (!dev) + return -ENOMEM; + + if ((ret = drm_fill_in_dev(dev, NULL, NULL, driver))) { + printk(KERN_ERR "DRM: Fill_in_dev failed.\n"); + goto err_g1; + } + + dev->platform_dev = pdev; + if ((ret = drm_get_minor(dev, &dev->primary, DRM_MINOR_LEGACY))) + goto err_g1; + + list_add_tail(&dev->driver_item, &driver->device_list); + + DRM_INFO("Initialized %s %d.%d.%d %s on minor %d\n", + driver->name, driver->major, driver->minor, driver->patchlevel, + driver->date, dev->primary->index); + + return 0; + +err_g1: + drm_free(dev, sizeof(*dev), DRM_MEM_STUB); + return ret; +} + /** * Put a device minor number. * |