示例#1
0
int mgag200_driver_load(struct drm_device *dev, unsigned long flags)
{
	struct mga_device *mdev;
	int r;

	mdev = devm_kzalloc(dev->dev, sizeof(struct mga_device), GFP_KERNEL);
	if (mdev == NULL)
		return -ENOMEM;
	dev->dev_private = (void *)mdev;
	mdev->dev = dev;

	r = mgag200_device_init(dev, flags);
	if (r) {
		dev_err(&dev->pdev->dev, "Fatal error during GPU init: %d\n", r);
		return r;
	}
	r = mgag200_mm_init(mdev);
	if (r)
		goto err_mm;

	drm_mode_config_init(dev);
	dev->mode_config.funcs = (void *)&mga_mode_funcs;
	if (IS_G200_SE(mdev) && mdev->mc.vram_size < (2048*1024))
		dev->mode_config.preferred_depth = 16;
	else
		dev->mode_config.preferred_depth = 24;
	dev->mode_config.prefer_shadow = 1;

	r = mgag200_modeset_init(mdev);
	if (r) {
		dev_err(&dev->pdev->dev, "Fatal error during modeset init: %d\n", r);
		goto err_modeset;
	}

	/* Make small buffers to store a hardware cursor (double buffered icon updates) */
	mgag200_bo_create(dev, roundup(48*64, PAGE_SIZE), 0, 0,
					  &mdev->cursor.pixels_1);
	mgag200_bo_create(dev, roundup(48*64, PAGE_SIZE), 0, 0,
					  &mdev->cursor.pixels_2);
	if (!mdev->cursor.pixels_2 || !mdev->cursor.pixels_1) {
		mdev->cursor.pixels_1 = NULL;
		mdev->cursor.pixels_2 = NULL;
		dev_warn(&dev->pdev->dev,
			"Could not allocate space for cursors. Not doing hardware cursors.\n");
	} else {
		mdev->cursor.pixels_current = mdev->cursor.pixels_1;
		mdev->cursor.pixels_prev = mdev->cursor.pixels_2;
	}

	return 0;

err_modeset:
	drm_mode_config_cleanup(dev);
	mgag200_mm_fini(mdev);
err_mm:
	dev->dev_private = NULL;

	return r;
}
int mgag200_gem_create(struct drm_device *dev,
		   u32 size, bool iskernel,
		   struct drm_gem_object **obj)
{
	struct mgag200_bo *astbo;
	int ret;

	*obj = NULL;

	size = roundup(size, PAGE_SIZE);
	if (size == 0)
		return -EINVAL;

	ret = mgag200_bo_create(dev, size, 0, 0, &astbo);
	if (ret) {
		if (ret != -ERESTARTSYS)
			DRM_ERROR("failed to allocate GEM object\n");
		return ret;
	}
	*obj = &astbo->gem;
	return 0;
}
示例#3
0
int mgag200_driver_load(struct drm_device *dev, unsigned long flags)
{
    struct mga_device *mdev;
    int r;

    mdev = devm_kzalloc(dev->dev, sizeof(struct mga_device), GFP_KERNEL);
    if (mdev == NULL)
        return -ENOMEM;
    dev->dev_private = (void *)mdev;
    mdev->dev = dev;

    r = mgag200_device_init(dev, flags);
    if (r) {
        dev_err(&dev->pdev->dev, "Fatal error during GPU init: %d\n", r);
        return r;
    }
    r = mgag200_mm_init(mdev);
    if (r)
        goto out;

    drm_mode_config_init(dev);
    dev->mode_config.funcs = (void *)&mga_mode_funcs;
    if (mgag200_preferred_depth == 0) {
        if (IS_G200_SE(mdev) && mdev->mc.vram_size <= (2048*1024)) {
            mdev->preferred_bpp =
                dev->mode_config.preferred_depth = 16;
        } else {
            /* prefer 16bpp on low end gpus with limited VRAM */
            mdev->preferred_bpp = 32;
            dev->mode_config.preferred_depth = 24;
        }
    } else {
        dev->mode_config.preferred_depth = mgag200_preferred_depth;
        switch (mgag200_preferred_depth) {
        case 16:
            mdev->preferred_bpp = 16;
            break;
        case 24:
            mdev->preferred_bpp = 32;
            break;
        default:
            goto out;
        }
    }
    dev->mode_config.prefer_shadow = 1;

    r = mgag200_modeset_init(mdev);
    if (r) {
        dev_err(&dev->pdev->dev, "Fatal error during modeset init: %d\n", r);
        goto out;
    }

    /* Make small buffers to store a hardware cursor (double buffered icon updates) */
    mgag200_bo_create(dev, roundup(48*64, PAGE_SIZE), 0, 0,
                      &mdev->cursor.pixels_1);
    mgag200_bo_create(dev, roundup(48*64, PAGE_SIZE), 0, 0,
                      &mdev->cursor.pixels_2);
    if (!mdev->cursor.pixels_2 || !mdev->cursor.pixels_1)
        goto cursor_nospace;
    mdev->cursor.pixels_current = mdev->cursor.pixels_1;
    mdev->cursor.pixels_prev = mdev->cursor.pixels_2;
    goto cursor_done;
cursor_nospace:
    mdev->cursor.pixels_1 = NULL;
    mdev->cursor.pixels_2 = NULL;
    dev_warn(&dev->pdev->dev, "Could not allocate space for cursors. Not doing hardware cursors.\n");
cursor_done:

out:
    if (r)
        mgag200_driver_unload(dev);
    return r;
}