Commit e2c3860b authored by Hans de Goede's avatar Hans de Goede Committed by Greg Kroah-Hartman

staging: vboxvideo: Use more drm_fb_helper functions

Store fbhelper and afb struct directly in vbox_private and use
drm_fb_helper_fbdev_setup to replace vbox_fbdev_init, note we cannot use
drm_fb_helper_fbdev_teardown since we use a private framebuffer for the
fbdev.

And replace vbox_driver_lastclose with drm_fb_helper_lastclose.
Signed-off-by: default avatarHans de Goede <hdegoede@redhat.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 0c762dda
......@@ -49,6 +49,10 @@ static const struct pci_device_id pciidlist[] = {
};
MODULE_DEVICE_TABLE(pci, pciidlist);
static struct drm_fb_helper_funcs vbox_fb_helper_funcs = {
.fb_probe = vboxfb_create,
};
static int vbox_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
{
struct vbox_private *vbox;
......@@ -92,7 +96,9 @@ static int vbox_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
if (ret)
goto err_mode_fini;
ret = vbox_fbdev_init(vbox);
ret = drm_fb_helper_fbdev_setup(&vbox->ddev, &vbox->fb_helper,
&vbox_fb_helper_funcs, 32,
vbox->num_crtcs);
if (ret)
goto err_irq_fini;
......@@ -257,7 +263,7 @@ static struct drm_driver driver = {
DRIVER_PRIME | DRIVER_ATOMIC,
.dev_priv_size = 0,
.lastclose = vbox_driver_lastclose,
.lastclose = drm_fb_helper_lastclose,
.master_set = vbox_master_set,
.master_drop = vbox_master_drop,
......
......@@ -72,11 +72,16 @@
sizeof(struct hgsmi_host_flags))
#define HOST_FLAGS_OFFSET GUEST_HEAP_USABLE_SIZE
struct vbox_fbdev;
struct vbox_framebuffer {
struct drm_framebuffer base;
struct drm_gem_object *obj;
};
struct vbox_private {
/* Must be first; or we must define our own release callback */
struct drm_device ddev;
struct drm_fb_helper fb_helper;
struct vbox_framebuffer afb;
u8 __iomem *guest_heap;
u8 __iomem *vbva_buffers;
......@@ -91,8 +96,6 @@ struct vbox_private {
/** Array of structures for receiving mode hints. */
struct vbva_modehint *last_mode_hints;
struct vbox_fbdev *fbdev;
int fb_mtrr;
struct {
......@@ -122,8 +125,6 @@ struct vbox_private {
#undef CURSOR_PIXEL_COUNT
#undef CURSOR_DATA_SIZE
void vbox_driver_lastclose(struct drm_device *dev);
struct vbox_gem_object;
struct vbox_connector {
......@@ -171,20 +172,6 @@ struct vbox_encoder {
struct drm_encoder base;
};
struct vbox_framebuffer {
struct drm_framebuffer base;
struct drm_gem_object *obj;
};
struct vbox_fbdev {
struct drm_fb_helper helper;
struct vbox_framebuffer afb;
int size;
struct ttm_bo_kmap_obj mapping;
int x1, y1, x2, y2; /* dirty rect */
spinlock_t dirty_lock;
};
#define to_vbox_crtc(x) container_of(x, struct vbox_crtc, base)
#define to_vbox_connector(x) container_of(x, struct vbox_connector, base)
#define to_vbox_encoder(x) container_of(x, struct vbox_encoder, base)
......@@ -212,7 +199,8 @@ int vbox_framebuffer_init(struct vbox_private *vbox,
const struct DRM_MODE_FB_CMD *mode_cmd,
struct drm_gem_object *obj);
int vbox_fbdev_init(struct vbox_private *vbox);
int vboxfb_create(struct drm_fb_helper *helper,
struct drm_fb_helper_surface_size *sizes);
void vbox_fbdev_fini(struct vbox_private *vbox);
struct vbox_bo {
......
......@@ -66,13 +66,11 @@ static struct fb_ops vboxfb_ops = {
.fb_debug_leave = drm_fb_helper_debug_leave,
};
static int vboxfb_create(struct drm_fb_helper *helper,
struct drm_fb_helper_surface_size *sizes)
int vboxfb_create(struct drm_fb_helper *helper,
struct drm_fb_helper_surface_size *sizes)
{
struct vbox_fbdev *fbdev =
container_of(helper, struct vbox_fbdev, helper);
struct vbox_private *vbox = container_of(fbdev->helper.dev,
struct vbox_private, ddev);
struct vbox_private *vbox =
container_of(helper, struct vbox_private, fb_helper);
struct pci_dev *pdev = vbox->ddev.pdev;
struct DRM_MODE_FB_CMD mode_cmd;
struct drm_framebuffer *fb;
......@@ -98,7 +96,7 @@ static int vboxfb_create(struct drm_fb_helper *helper,
return ret;
}
ret = vbox_framebuffer_init(vbox, &fbdev->afb, &mode_cmd, gobj);
ret = vbox_framebuffer_init(vbox, &vbox->afb, &mode_cmd, gobj);
if (ret)
return ret;
......@@ -117,12 +115,10 @@ static int vboxfb_create(struct drm_fb_helper *helper,
if (IS_ERR(info->screen_base))
return PTR_ERR(info->screen_base);
info->par = fbdev;
info->par = helper;
fbdev->size = size;
fb = &fbdev->afb.base;
fbdev->helper.fb = fb;
fb = &vbox->afb.base;
helper->fb = fb;
strcpy(info->fix.id, "vboxdrmfb");
......@@ -142,7 +138,7 @@ static int vboxfb_create(struct drm_fb_helper *helper,
info->apertures->ranges[0].size = pci_resource_len(pdev, 0);
drm_fb_helper_fill_fix(info, fb->pitches[0], fb->format->depth);
drm_fb_helper_fill_var(info, &fbdev->helper, sizes->fb_width,
drm_fb_helper_fill_var(info, helper, sizes->fb_width,
sizes->fb_height);
gpu_addr = vbox_bo_gpu_offset(bo);
......@@ -161,21 +157,16 @@ static int vboxfb_create(struct drm_fb_helper *helper,
return 0;
}
static struct drm_fb_helper_funcs vbox_fb_helper_funcs = {
.fb_probe = vboxfb_create,
};
void vbox_fbdev_fini(struct vbox_private *vbox)
{
struct vbox_fbdev *fbdev = vbox->fbdev;
struct vbox_framebuffer *afb = &fbdev->afb;
struct vbox_framebuffer *afb = &vbox->afb;
#ifdef CONFIG_DRM_KMS_FB_HELPER
if (fbdev->helper.fbdev && fbdev->helper.fbdev->fbdefio)
fb_deferred_io_cleanup(fbdev->helper.fbdev);
if (vbox->fb_helper.fbdev && vbox->fb_helper.fbdev->fbdefio)
fb_deferred_io_cleanup(vbox->fb_helper.fbdev);
#endif
drm_fb_helper_unregister_fbi(&fbdev->helper);
drm_fb_helper_unregister_fbi(&vbox->fb_helper);
if (afb->obj) {
struct vbox_bo *bo = gem_to_vbox_bo(afb->obj);
......@@ -188,41 +179,8 @@ void vbox_fbdev_fini(struct vbox_private *vbox)
drm_gem_object_put_unlocked(afb->obj);
afb->obj = NULL;
}
drm_fb_helper_fini(&fbdev->helper);
drm_fb_helper_fini(&vbox->fb_helper);
drm_framebuffer_unregister_private(&afb->base);
drm_framebuffer_cleanup(&afb->base);
}
int vbox_fbdev_init(struct vbox_private *vbox)
{
struct drm_device *dev = &vbox->ddev;
struct vbox_fbdev *fbdev;
int ret;
fbdev = devm_kzalloc(dev->dev, sizeof(*fbdev), GFP_KERNEL);
if (!fbdev)
return -ENOMEM;
vbox->fbdev = fbdev;
spin_lock_init(&fbdev->dirty_lock);
drm_fb_helper_prepare(dev, &fbdev->helper, &vbox_fb_helper_funcs);
ret = drm_fb_helper_init(dev, &fbdev->helper, vbox->num_crtcs);
if (ret)
return ret;
ret = drm_fb_helper_single_add_all_connectors(&fbdev->helper);
if (ret)
goto err_fini;
ret = drm_fb_helper_initial_config(&fbdev->helper, 32);
if (ret)
goto err_fini;
return 0;
err_fini:
drm_fb_helper_fini(&fbdev->helper);
return ret;
}
......@@ -322,18 +322,6 @@ void vbox_hw_fini(struct vbox_private *vbox)
pci_iounmap(vbox->ddev.pdev, vbox->guest_heap);
}
/**
* @note this is described in the DRM framework documentation. AST does not
* have it, but we get an oops on driver unload if it is not present.
*/
void vbox_driver_lastclose(struct drm_device *dev)
{
struct vbox_private *vbox = dev->dev_private;
if (vbox->fbdev)
drm_fb_helper_restore_fbdev_mode_unlocked(&vbox->fbdev->helper);
}
int vbox_gem_create(struct vbox_private *vbox,
u32 size, bool iskernel, struct drm_gem_object **obj)
{
......
......@@ -153,7 +153,7 @@ static bool vbox_set_up_input_mapping(struct vbox_private *vbox)
if (!fb1) {
fb1 = fb;
if (to_vbox_framebuffer(fb1) == &vbox->fbdev->afb)
if (to_vbox_framebuffer(fb1) == &vbox->afb)
break;
} else if (fb != fb1) {
single_framebuffer = false;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment