コード例 #1
0
ファイル: i810_drv.c プロジェクト: dmgerman/linux-pre-history
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;
}
コード例 #2
0
/**
 * Get a secondary minor number.
 *
 * \param dev device data structure
 * \param sec-minor structure to hold the assigned minor
 * \return negative number on failure.
 *
 * Search an empty entry and initialize it to the given parameters, and
 * create the proc init entry via proc_init(). This routines assigns
 * minor numbers to secondary heads of multi-headed cards
 */
static int drm_get_minor(struct drm_device *dev, struct drm_minor **minor, int type)
{
	struct drm_minor *new_minor;
	int ret;
	int minor_id;

	DRM_DEBUG("\n");

	minor_id = drm_minor_get_id(dev, type);
	if (minor_id < 0)
		return minor_id;

	new_minor = kzalloc(sizeof(struct drm_minor), GFP_KERNEL);
	if (!new_minor) {
		ret = -ENOMEM;
		goto err_idr;
	}

	new_minor->type = type;
	new_minor->device = MKDEV(DRM_MAJOR, minor_id);
	new_minor->dev = dev;
	new_minor->index = minor_id;

	idr_replace(&drm_minors_idr, new_minor, minor_id);

	if (type == DRM_MINOR_LEGACY) {
		ret = drm_proc_init(new_minor, minor_id, drm_proc_root);
		if (ret) {
			DRM_ERROR("DRM: Failed to initialize /proc/dri.\n");
			goto err_mem;
		}
	} else
		new_minor->dev_root = NULL;

	ret = drm_sysfs_device_add(new_minor);
	if (ret) {
		printk(KERN_ERR
		       "DRM: Error sysfs_device_add.\n");
		goto err_g2;
	}
	*minor = new_minor;

	DRM_DEBUG("new minor assigned %d\n", minor_id);
	return 0;


err_g2:
	if (new_minor->type == DRM_MINOR_LEGACY)
		drm_proc_cleanup(new_minor, drm_proc_root);
err_mem:
	kfree(new_minor);
err_idr:
	idr_remove(&drm_minors_idr, minor_id);
	*minor = NULL;
	return ret;
}
コード例 #3
0
ファイル: drm_stub.c プロジェクト: narenas/nx-libs
/**
 * Get a secondary minor number.
 *
 * \param dev device data structure
 * \param sec-minor structure to hold the assigned minor
 * \return negative number on failure.
 *
 * Search an empty entry and initialize it to the given parameters, and
 * create the proc init entry via proc_init(). This routines assigns
 * minor numbers to secondary heads of multi-headed cards
 */
static int drm_get_head(drm_device_t * dev, drm_head_t * head)
{
    drm_head_t **heads = drm_heads;
    int ret;
    int minor;

    DRM_DEBUG("\n");

    for (minor = 0; minor < cards_limit; minor++, heads++) {
        if (!*heads) {

            *head = (drm_head_t) {
                .dev = dev,
                 .device = MKDEV(DRM_MAJOR, minor),
                  .minor = minor,
            };
            if ((ret =
                        drm_proc_init(dev, minor, drm_proc_root,
                                      &head->dev_root))) {
                printk(KERN_ERR
                       "DRM: Failed to initialize /proc/dri.\n");
                goto err_g1;
            }

            head->dev_class = drm_sysfs_device_add(drm_class, head);
            if (IS_ERR(head->dev_class)) {
                printk(KERN_ERR
                       "DRM: Error sysfs_device_add.\n");
                ret = PTR_ERR(head->dev_class);
                goto err_g2;
            }
            *heads = head;

            DRM_DEBUG("new minor assigned %d\n", minor);
            return 0;
        }
    }
    DRM_ERROR("out of minors\n");
    return -ENOMEM;
err_g2:
    drm_proc_cleanup(minor, drm_proc_root, head->dev_root);
err_g1:
    *head = (drm_head_t) {
        .dev = NULL
    };
    return ret;
}
コード例 #4
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;
}