};
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;
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;
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,
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;
/** Array of structures for receiving mode hints. */
struct vbva_modehint *last_mode_hints;
- struct vbox_fbdev *fbdev;
-
int fb_mtrr;
struct {
#undef CURSOR_PIXEL_COUNT
#undef CURSOR_DATA_SIZE
-void vbox_driver_lastclose(struct drm_device *dev);
-
struct vbox_gem_object;
struct vbox_connector {
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)
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 {
.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;
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;
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");
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);
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);
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;
-}