VirtualBox

Changeset 74864 in vbox for trunk


Ignore:
Timestamp:
Oct 16, 2018 11:48:44 AM (6 years ago)
Author:
vboxsync
Message:

Additions/linux/vboxvideo: Use fbdev helpers where possible
bugref:8282: Additions/linux: track kernel changes to vboxvideo in our own tree

This results in a nice cleanup, and fixes link errors when fbdev support
is disabled.


Signed-off-by: Hans de Goede <hdegoede@…>
Signed-off-by: Greg Kroah-Hartman <gregkh@…>

Adjusted by the VirtualBox team to make it build on older kernels too.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Additions/linux/drm/vbox_fb.c

    r74773 r74864  
    5151#include <VBoxVideo.h>
    5252
    53 #define VBOX_DIRTY_DELAY (HZ / 30)
     53#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 7, 0) && !defined(RHEL_74)
    5454/**
    5555 * Tell the host about dirty rectangles to update.
     
    124124        vbox_bo_unreserve(bo);
    125125}
     126#endif
    126127
    127128#ifdef CONFIG_FB_DEFERRED_IO
    128 static void vbox_deferred_io(struct fb_info *info, struct list_head *pagelist)
     129# if LINUX_VERSION_CODE < KERNEL_VERSION(4, 7, 0) && !defined(RHEL_74)
     130static void drm_fb_helper_deferred_io(struct fb_info *info, struct list_head *pagelist)
    129131{
    130132        struct vbox_fbdev *fbdev = info->par;
     
    150152        }
    151153}
     154# endif
    152155
    153156static struct fb_deferred_io vbox_defio = {
    154         .delay = VBOX_DIRTY_DELAY,
    155         .deferred_io = vbox_deferred_io,
     157        .delay = HZ / 30,
     158        .deferred_io = drm_fb_helper_deferred_io,
    156159};
    157160#endif
    158161
    159 static void vbox_fillrect(struct fb_info *info, const struct fb_fillrect *rect)
     162#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 3, 0) && !defined(RHEL_73)
     163static void drm_fb_helper_sys_fillrect(struct fb_info *info, const struct fb_fillrect *rect)
    160164{
    161165        struct vbox_fbdev *fbdev = info->par;
     
    165169}
    166170
    167 static void vbox_copyarea(struct fb_info *info, const struct fb_copyarea *area)
     171static void drm_fb_helper_sys_copyarea(struct fb_info *info, const struct fb_copyarea *area)
    168172{
    169173        struct vbox_fbdev *fbdev = info->par;
     
    173177}
    174178
    175 static void vbox_imageblit(struct fb_info *info, const struct fb_image *image)
     179static void drm_fb_helper_sys_imageblit(struct fb_info *info, const struct fb_image *image)
    176180{
    177181        struct vbox_fbdev *fbdev = info->par;
     
    181185                          image->height);
    182186}
     187#endif
    183188
    184189static struct fb_ops vboxfb_ops = {
     
    186191        .fb_check_var = drm_fb_helper_check_var,
    187192        .fb_set_par = drm_fb_helper_set_par,
    188         .fb_fillrect = vbox_fillrect,
    189         .fb_copyarea = vbox_copyarea,
    190         .fb_imageblit = vbox_imageblit,
     193        .fb_fillrect = drm_fb_helper_sys_fillrect,
     194        .fb_copyarea = drm_fb_helper_sys_copyarea,
     195        .fb_imageblit = drm_fb_helper_sys_imageblit,
    191196        .fb_pan_display = drm_fb_helper_pan_display,
    192197        .fb_blank = drm_fb_helper_blank,
     
    221226}
    222227
     228#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 3, 0) && !defined(RHEL_73)
     229static struct fb_info *drm_fb_helper_alloc_fbi(struct drm_fb_helper *helper)
     230{
     231        struct fb_info *info;
     232        struct vbox_fbdev *fbdev =
     233            container_of(helper, struct vbox_fbdev, helper);
     234        struct drm_device *dev = fbdev->helper.dev;
     235        struct device *device = &dev->pdev->dev;
     236
     237        info = framebuffer_alloc(0, device);
     238        if (!info)
     239                return ERR_PTR(-ENOMEM);
     240        fbdev->helper.fbdev = info;
     241
     242        if (fb_alloc_cmap(&info->cmap, 256, 0))
     243                return ERR_PTR(-ENOMEM);
     244
     245        info->apertures = alloc_apertures(1);
     246        if (!info->apertures)
     247                return ERR_PTR(-ENOMEM);
     248
     249        return info;
     250}
     251#endif
     252
    223253static int vboxfb_create(struct drm_fb_helper *helper,
    224254                         struct drm_fb_helper_surface_size *sizes)
     
    230260        struct drm_framebuffer *fb;
    231261        struct fb_info *info;
    232         struct device *device = &dev->pdev->dev;
    233262        struct drm_gem_object *gobj;
    234263        struct vbox_bo *bo;
     
    280309        }
    281310
    282         info = framebuffer_alloc(0, device);
    283         if (!info)
    284                 return -ENOMEM;
     311        info = drm_fb_helper_alloc_fbi(helper);
     312        if (IS_ERR(info))
     313                return -PTR_ERR(info);
     314
    285315        info->par = fbdev;
    286316
     
    289319        fb = &fbdev->afb.base;
    290320        fbdev->helper.fb = fb;
    291         fbdev->helper.fbdev = info;
    292321
    293322        strcpy(info->fix.id, "vboxdrmfb");
     
    301330        info->fbops = &vboxfb_ops;
    302331
    303         ret = fb_alloc_cmap(&info->cmap, 256, 0);
    304         if (ret)
    305                 return -ENOMEM;
    306 
    307332        /*
    308333         * This seems to be done for safety checking that the framebuffer
    309334         * is not registered twice by different drivers.
    310335         */
    311         info->apertures = alloc_apertures(1);
    312         if (!info->apertures)
    313                 return -ENOMEM;
    314336        info->apertures->ranges[0].base = pci_resource_start(dev->pdev, 0);
    315337        info->apertures->ranges[0].size = pci_resource_len(dev->pdev, 0);
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette