diff options
-rw-r--r-- | linux-core/drmP.h | 2 | ||||
-rw-r--r-- | linux-core/drm_stub.c | 7 | ||||
-rw-r--r-- | linux-core/drm_sysfs.c | 34 | ||||
-rw-r--r-- | linux-core/i810_drv.c | 6 | ||||
-rw-r--r-- | linux-core/radeon_drv.c | 12 | ||||
-rw-r--r-- | shared-core/via_drv.c | 6 |
6 files changed, 57 insertions, 10 deletions
diff --git a/linux-core/drmP.h b/linux-core/drmP.h index 5ada94ef..99e66597 100644 --- a/linux-core/drmP.h +++ b/linux-core/drmP.h @@ -544,6 +544,7 @@ struct drm_driver { int new); int (*kernel_context_switch_unlock) (struct drm_device * dev); int (*vblank_wait) (struct drm_device * dev, unsigned int *sequence); + int (*dri_library_name) (struct drm_device * dev, char * buf); /** * Called by \c drm_device_is_agp. Typically used to determine if a @@ -987,6 +988,7 @@ extern struct drm_sysfs_class *drm_sysfs_create(struct module *owner, char *name); extern void drm_sysfs_destroy(struct drm_sysfs_class *cs); extern struct class_device *drm_sysfs_device_add(struct drm_sysfs_class *cs, + drm_head_t * head, dev_t dev, struct device *device, const char *fmt, ...); diff --git a/linux-core/drm_stub.c b/linux-core/drm_stub.c index 7d0e075a..25af18ba 100644 --- a/linux-core/drm_stub.c +++ b/linux-core/drm_stub.c @@ -166,10 +166,9 @@ static int drm_get_head(drm_device_t * dev, drm_head_t * head) } head->dev_class = drm_sysfs_device_add(drm_class, - MKDEV(DRM_MAJOR, - minor), - DRM_PCI_DEV(dev->pdev), - "card%d", minor); + head, MKDEV(DRM_MAJOR, minor), + DRM_PCI_DEV(dev->pdev), + "card%d", minor); if (IS_ERR(head->dev_class)) { printk(KERN_ERR "DRM: Error sysfs_device_add.\n"); diff --git a/linux-core/drm_sysfs.c b/linux-core/drm_sysfs.c index 405ba44c..229b2132 100644 --- a/linux-core/drm_sysfs.c +++ b/linux-core/drm_sysfs.c @@ -16,6 +16,7 @@ #include <linux/kdev_t.h> #include <linux/err.h> +#include "drmP.h" #include "drm_core.h" struct drm_sysfs_class { @@ -121,6 +122,18 @@ void drm_sysfs_destroy(struct drm_sysfs_class *cs) class_unregister(&cs->class); } +static ssize_t show_dri(struct class_device *class_device, char *buf) +{ + drm_device_t * dev = ((drm_head_t *)class_get_devdata(class_device))->dev; + if (dev->driver->dri_library_name) + return dev->driver->dri_library_name(dev, buf); + return snprintf(buf, PAGE_SIZE, "%s\n", dev->driver->pci_driver.name); +} + +static struct class_device_attribute class_device_attrs[] = { + __ATTR(dri_library_name, S_IRUGO, show_dri, NULL), +}; + /** * drm_sysfs_device_add - adds a class device to sysfs for a character driver * @cs: pointer to the struct drm_sysfs_class that this device should be registered to. @@ -135,13 +148,13 @@ void drm_sysfs_destroy(struct drm_sysfs_class *cs) * Note: the struct drm_sysfs_class passed to this function must have previously been * created with a call to drm_sysfs_create(). */ -struct class_device *drm_sysfs_device_add(struct drm_sysfs_class *cs, dev_t dev, - struct device *device, - const char *fmt, ...) +struct class_device *drm_sysfs_device_add(struct drm_sysfs_class *cs, + drm_head_t * head, dev_t dev, + struct device *device, const char *fmt, ...) { va_list args; struct simple_dev *s_dev = NULL; - int retval; + int i, retval; if ((cs == NULL) || (IS_ERR(cs))) { retval = -ENODEV; @@ -172,9 +185,14 @@ struct class_device *drm_sysfs_device_add(struct drm_sysfs_class *cs, dev_t dev, list_add(&s_dev->node, &simple_dev_list); spin_unlock(&simple_dev_list_lock); + class_set_devdata(&s_dev->class_dev, head); + + for (i = 0; i < ARRAY_SIZE(class_device_attrs); i++) + class_device_create_file(&s_dev->class_dev, &class_device_attrs[i]); + return &s_dev->class_dev; - error: +error: kfree(s_dev); return ERR_PTR(retval); } @@ -189,7 +207,7 @@ struct class_device *drm_sysfs_device_add(struct drm_sysfs_class *cs, dev_t dev, void drm_sysfs_device_remove(dev_t dev) { struct simple_dev *s_dev = NULL; - int found = 0; + int i, found = 0; spin_lock(&simple_dev_list_lock); list_for_each_entry(s_dev, &simple_dev_list, node) { @@ -201,6 +219,10 @@ void drm_sysfs_device_remove(dev_t dev) if (found) { list_del(&s_dev->node); spin_unlock(&simple_dev_list_lock); + + for (i = 0; i < ARRAY_SIZE(class_device_attrs); i++) + class_device_remove_file(&s_dev->class_dev, &class_device_attrs[i]); + class_device_unregister(&s_dev->class_dev); } else { spin_unlock(&simple_dev_list_lock); diff --git a/linux-core/i810_drv.c b/linux-core/i810_drv.c index 128452c0..f043041b 100644 --- a/linux-core/i810_drv.c +++ b/linux-core/i810_drv.c @@ -70,6 +70,11 @@ static int version(drm_version_t * version) return 0; } +static int dri_library_name(struct drm_device * dev, char * buf) +{ + return snprintf(buf, PAGE_SIZE, "i830\n"); +} + static struct pci_device_id pciidlist[] = { i810_PCI_IDS }; @@ -90,6 +95,7 @@ static struct drm_driver driver = { .dma_quiescent = i810_driver_dma_quiescent, .get_map_ofs = drm_core_get_map_ofs, .get_reg_ofs = drm_core_get_reg_ofs, + .dri_library_name = dri_library_name, .postinit = postinit, .version = version, .ioctls = i810_ioctls, diff --git a/linux-core/radeon_drv.c b/linux-core/radeon_drv.c index c26d887d..a79bdf38 100644 --- a/linux-core/radeon_drv.c +++ b/linux-core/radeon_drv.c @@ -62,6 +62,17 @@ static int version(drm_version_t * version) return 0; } +static int dri_library_name(struct drm_device * dev, char * buf) +{ + drm_radeon_private_t *dev_priv = dev->dev_private; + int family = dev_priv->flags & CHIP_FAMILY_MASK; + + return snprintf(buf, PAGE_SIZE, "%s\n", + (family < CHIP_R200) ? "radeon" : + ((family < CHIP_R300) ? "r200" : + "r300")); +} + static struct pci_device_id pciidlist[] = { radeon_PCI_IDS }; @@ -83,6 +94,7 @@ static struct drm_driver driver = { .pretakedown = radeon_driver_pretakedown, .open_helper = radeon_driver_open_helper, .vblank_wait = radeon_driver_vblank_wait, + .dri_library_name = dri_library_name, .irq_preinstall = radeon_driver_irq_preinstall, .irq_postinstall = radeon_driver_irq_postinstall, .irq_uninstall = radeon_driver_irq_uninstall, diff --git a/shared-core/via_drv.c b/shared-core/via_drv.c index 21f28a63..5e542c76 100644 --- a/shared-core/via_drv.c +++ b/shared-core/via_drv.c @@ -54,6 +54,11 @@ static int version(drm_version_t * version) return 0; } +static int dri_library_name(struct drm_device * dev, char * buf) +{ + return snprintf(buf, PAGE_SIZE, "unichrome\n"); +} + static struct pci_device_id pciidlist[] = { viadrv_PCI_IDS }; @@ -86,6 +91,7 @@ static struct drm_driver driver = { .irq_uninstall = via_driver_irq_uninstall, .irq_handler = via_driver_irq_handler, .dma_quiescent = via_driver_dma_quiescent, + .dri_library_name = dri_library_name, .reclaim_buffers = drm_core_reclaim_buffers, .get_map_ofs = drm_core_get_map_ofs, .get_reg_ofs = drm_core_get_reg_ofs, |