static int __init i810_init(void) { int retcode; drm_device_t *dev = &i810_device; DRM_DEBUG("\n"); memset((void *)dev, 0, sizeof(*dev)); dev->count_lock = SPIN_LOCK_UNLOCKED; sema_init(&dev->struct_sem, 1); #ifdef MODULE drm_parse_options(i810); #endif DRM_DEBUG("doing misc_register\n"); if ((retcode = misc_register(&i810_misc))) { DRM_ERROR("Cannot register \"%s\"\n", I810_NAME); return retcode; } dev->device = MKDEV(MISC_MAJOR, i810_misc.minor); dev->name = I810_NAME; DRM_DEBUG("doing mem init\n"); drm_mem_init(); DRM_DEBUG("doing proc init\n"); drm_proc_init(dev); DRM_DEBUG("doing agp init\n"); dev->agp = drm_agp_init(); if(dev->agp == NULL) { DRM_INFO("The i810 drm module requires the agpgart module" " to function correctly\nPlease load the agpgart" " module before you load the i810 module\n"); drm_proc_cleanup(); misc_deregister(&i810_misc); i810_takedown(dev); return -ENOMEM; } DRM_DEBUG("doing ctxbitmap init\n"); if((retcode = drm_ctxbitmap_init(dev))) { DRM_ERROR("Cannot allocate memory for context bitmap.\n"); drm_proc_cleanup(); misc_deregister(&i810_misc); i810_takedown(dev); return retcode; } DRM_INFO("Initialized %s %d.%d.%d %s on minor %d\n", I810_NAME, I810_MAJOR, I810_MINOR, I810_PATCHLEVEL, I810_DATE, i810_misc.minor); return 0; }
static int __init tdfx_init(void) { int retcode; drm_device_t *dev = &tdfx_device; DRM_DEBUG("\n"); memset((void *)dev, 0, sizeof(*dev)); dev->count_lock = SPIN_LOCK_UNLOCKED; sema_init(&dev->struct_sem, 1); #ifdef MODULE drm_parse_options(tdfx); #endif if ((retcode = misc_register(&tdfx_misc))) { DRM_ERROR("Cannot register \"%s\"\n", TDFX_NAME); return retcode; } dev->device = MKDEV(MISC_MAJOR, tdfx_misc.minor); dev->name = TDFX_NAME; drm_mem_init(); drm_proc_init(dev); #if defined(CONFIG_AGP) || defined(CONFIG_AGP_MODULE) dev->agp = drm_agp_init(); #endif if((retcode = drm_ctxbitmap_init(dev))) { DRM_ERROR("Cannot allocate memory for context bitmap.\n"); drm_proc_cleanup(); misc_deregister(&tdfx_misc); tdfx_takedown(dev); return retcode; } DRM_INFO("Initialized %s %d.%d.%d %s on minor %d\n", TDFX_NAME, TDFX_MAJOR, TDFX_MINOR, TDFX_PATCHLEVEL, TDFX_DATE, tdfx_misc.minor); return 0; }
static int fill_in_dev(drm_device_t * dev, struct pci_dev *pdev, const struct pci_device_id *ent, struct drm_driver *driver) { int retcode; spin_lock_init(&dev->count_lock); init_timer(&dev->timer); sema_init(&dev->struct_sem, 1); sema_init(&dev->ctxlist_sem, 1); dev->pdev = pdev; #ifdef __alpha__ dev->hose = pdev->sysdata; dev->pci_domain = dev->hose->bus->number; #else dev->pci_domain = 0; #endif dev->pci_bus = pdev->bus->number; dev->pci_slot = PCI_SLOT(pdev->devfn); dev->pci_func = PCI_FUNC(pdev->devfn); dev->irq = pdev->irq; dev->maplist = drm_calloc(1, sizeof(*dev->maplist), DRM_MEM_MAPS); if (dev->maplist == NULL) return -ENOMEM; INIT_LIST_HEAD(&dev->maplist->head); /* the DRM has 6 counters */ dev->counters = 6; dev->types[0] = _DRM_STAT_LOCK; dev->types[1] = _DRM_STAT_OPENS; dev->types[2] = _DRM_STAT_CLOSES; dev->types[3] = _DRM_STAT_IOCTLS; dev->types[4] = _DRM_STAT_LOCKS; dev->types[5] = _DRM_STAT_UNLOCKS; dev->driver = driver; if (dev->driver->load) if ((retcode = dev->driver->load(dev, ent->driver_data))) goto error_out_unreg; if (drm_core_has_AGP(dev)) { if (drm_device_is_agp(dev)) dev->agp = drm_agp_init(dev); if (drm_core_check_feature(dev, DRIVER_REQUIRE_AGP) && (dev->agp == NULL)) { DRM_ERROR("Cannot initialize the agpgart module.\n"); retcode = -EINVAL; goto error_out_unreg; } if (drm_core_has_MTRR(dev)) { if (dev->agp) dev->agp->agp_mtrr = mtrr_add(dev->agp->agp_info.aper_base, dev->agp->agp_info.aper_size * 1024 * 1024, MTRR_TYPE_WRCOMB, 1); } } retcode = drm_ctxbitmap_init(dev); if (retcode) { DRM_ERROR("Cannot allocate memory for context bitmap.\n"); goto error_out_unreg; } return 0; error_out_unreg: drm_lastclose(dev); return retcode; }
static int drm_fill_in_dev(struct drm_device * dev, struct pci_dev *pdev, const struct pci_device_id *ent, struct drm_driver *driver) { int retcode; INIT_LIST_HEAD(&dev->filelist); INIT_LIST_HEAD(&dev->ctxlist); INIT_LIST_HEAD(&dev->vmalist); INIT_LIST_HEAD(&dev->maplist); spin_lock_init(&dev->count_lock); spin_lock_init(&dev->drw_lock); spin_lock_init(&dev->tasklet_lock); spin_lock_init(&dev->lock.spinlock); init_timer(&dev->timer); mutex_init(&dev->struct_mutex); mutex_init(&dev->ctxlist_mutex); idr_init(&dev->drw_idr); dev->pdev = pdev; dev->pci_device = pdev->device; dev->pci_vendor = pdev->vendor; #ifdef __alpha__ dev->hose = pdev->sysdata; #endif dev->irq = pdev->irq; if (drm_ht_create(&dev->map_hash, 12)) { return -ENOMEM; } /* the DRM has 6 basic counters */ dev->counters = 6; dev->types[0] = _DRM_STAT_LOCK; dev->types[1] = _DRM_STAT_OPENS; dev->types[2] = _DRM_STAT_CLOSES; dev->types[3] = _DRM_STAT_IOCTLS; dev->types[4] = _DRM_STAT_LOCKS; dev->types[5] = _DRM_STAT_UNLOCKS; dev->driver = driver; if (drm_core_has_AGP(dev)) { if (drm_device_is_agp(dev)) dev->agp = drm_agp_init(dev); if (drm_core_check_feature(dev, DRIVER_REQUIRE_AGP) && (dev->agp == NULL)) { DRM_ERROR("Cannot initialize the agpgart module.\n"); retcode = -EINVAL; goto error_out_unreg; } if (drm_core_has_MTRR(dev)) { if (dev->agp) dev->agp->agp_mtrr = mtrr_add(dev->agp->agp_info.aper_base, dev->agp->agp_info.aper_size * 1024 * 1024, MTRR_TYPE_WRCOMB, 1); } } if (dev->driver->load) if ((retcode = dev->driver->load(dev, ent->driver_data))) goto error_out_unreg; retcode = drm_ctxbitmap_init(dev); if (retcode) { DRM_ERROR("Cannot allocate memory for context bitmap.\n"); goto error_out_unreg; } return 0; error_out_unreg: drm_lastclose(dev); return retcode; }