Changeset 64830 in vbox for trunk/src/VBox/Additions
- Timestamp:
- Dec 12, 2016 9:55:37 AM (8 years ago)
- Location:
- trunk/src/VBox/Additions/linux/drm
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/linux/drm/vbox_drv.h
r64172 r64830 183 183 struct drm_fb_helper helper; 184 184 struct vbox_framebuffer afb; 185 void *sysram;186 185 int size; 187 186 struct ttm_bo_kmap_obj mapping; -
trunk/src/VBox/Additions/linux/drm/vbox_fb.c
r64337 r64830 75 75 int x, int y, int width, int height) 76 76 { 77 int i;78 79 77 struct drm_gem_object *obj; 80 78 struct vbox_bo *bo; 81 int src_offset, dst_offset;82 int bpp = (fbdev->afb.base.bits_per_pixel + 7)/8;83 79 int ret = -EBUSY; 84 bool unmap = false;85 80 bool store_for_later = false; 86 81 int x2, y2; … … 131 126 spin_unlock_irqrestore(&fbdev->dirty_lock, flags); 132 127 133 if (!bo->kmap.virtual) {134 ret = ttm_bo_kmap(&bo->bo, 0, bo->bo.num_pages, &bo->kmap);135 if (ret) {136 DRM_ERROR("failed to kmap fb updates\n");137 vbox_bo_unreserve(bo);138 return;139 }140 unmap = true;141 }142 for (i = y; i <= y2; i++) {143 /* assume equal stride for now */144 src_offset = dst_offset = i * fbdev->afb.base.pitches[0] + (x * bpp);145 memcpy_toio(bo->kmap.virtual + src_offset, (char *)fbdev->sysram + src_offset, (x2 - x + 1) * bpp);146 }147 128 /* Not sure why the original code subtracted 1 here, but I will keep it that 148 129 * way to avoid unnecessary differences. */ … … 152 133 rect.y2 = y2 + 1; 153 134 vbox_framebuffer_dirty_rectangles(&fbdev->afb.base, &rect, 1); 154 if (unmap)155 ttm_bo_kunmap(&bo->kmap);156 135 157 136 vbox_bo_unreserve(bo); … … 271 250 int size, ret; 272 251 struct device *device = &dev->pdev->dev; 273 void *sysram;274 252 struct drm_gem_object *gobj = NULL; 275 253 struct vbox_bo *bo = NULL; … … 294 272 return ret; 295 273 } 274 275 ret = vbox_framebuffer_init(dev, &fbdev->afb, &mode_cmd, gobj); 276 if (ret) 277 return ret; 278 296 279 bo = gem_to_vbox_bo(gobj); 297 280 298 sysram = vmalloc(size); 299 if (!sysram) 281 ret = vbox_bo_reserve(bo, false); 282 if (ret) 283 return ret; 284 285 ret = vbox_bo_pin(bo, TTM_PL_FLAG_VRAM, NULL); 286 if (ret) { 287 vbox_bo_unreserve(bo); 288 return ret; 289 } 290 291 ret = ttm_bo_kmap(&bo->bo, 0, bo->bo.num_pages, &bo->kmap); 292 vbox_bo_unreserve(bo); 293 if (ret) { 294 DRM_ERROR("failed to kmap fbcon\n"); 295 return ret; 296 } 297 298 info = framebuffer_alloc(0, device); 299 if (!info) 300 300 return -ENOMEM; 301 302 info = framebuffer_alloc(0, device);303 if (!info) {304 ret = -ENOMEM;305 goto out;306 }307 301 info->par = fbdev; 308 302 309 ret = vbox_framebuffer_init(dev, &fbdev->afb, &mode_cmd, gobj);310 if (ret)311 goto out;312 313 fbdev->sysram = sysram;314 303 fbdev->size = size; 315 304 … … 327 316 328 317 ret = fb_alloc_cmap(&info->cmap, 256, 0); 329 if (ret) { 330 ret = -ENOMEM; 331 goto out; 332 } 318 if (ret) 319 return -ENOMEM; 333 320 334 321 /* This seems to be done for safety checking that the framebuffer is not 335 322 * registered twice by different drivers. */ 336 323 info->apertures = alloc_apertures(1); 337 if (!info->apertures) { 338 ret = -ENOMEM; 339 goto out; 340 } 324 if (!info->apertures) 325 return -ENOMEM; 341 326 info->apertures->ranges[0].base = pci_resource_start(dev->pdev, 0); 342 327 info->apertures->ranges[0].size = pci_resource_len(dev->pdev, 0); … … 345 330 drm_fb_helper_fill_var(info, &fbdev->helper, sizes->fb_width, sizes->fb_height); 346 331 347 info->screen_base = sysram;332 info->screen_base = bo->kmap.virtual; 348 333 info->screen_size = size; 349 334 … … 359 344 360 345 return 0; 361 out:362 return ret;363 346 } 364 347 … … 397 380 398 381 if (afb->obj) { 382 struct vbox_bo *bo = gem_to_vbox_bo(afb->obj); 383 if (!vbox_bo_reserve(bo, false)) { 384 if (bo->kmap.virtual) 385 ttm_bo_kunmap(&bo->kmap); 386 /* QXL does this, but is it really needed before freeing? */ 387 if (bo->pin_count) 388 vbox_bo_unpin(bo); 389 vbox_bo_unreserve(bo); 390 } 399 391 drm_gem_object_unreference_unlocked(afb->obj); 400 392 afb->obj = NULL; … … 402 394 drm_fb_helper_fini(&fbdev->helper); 403 395 404 vfree(fbdev->sysram);405 396 #if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 9, 0) 406 397 drm_framebuffer_unregister_private(&afb->base); -
trunk/src/VBox/Additions/linux/drm/vbox_mode.c
r64400 r64830 171 171 } 172 172 173 /* We move buffers which are not in active use out of VRAM to save memory. */174 173 static int vbox_crtc_do_set_base(struct drm_crtc *crtc, 175 struct drm_framebuffer * fb,176 int x, int y , int atomic)174 struct drm_framebuffer *old_fb, 175 int x, int y) 177 176 { 178 177 struct vbox_private *vbox = crtc->dev->dev_private; … … 184 183 u64 gpu_addr; 185 184 186 /* push the previous fb to system ram*/187 if ( !atomic &&fb) {188 vbox_fb = to_vbox_framebuffer( fb);185 /* Unpin the previous fb. */ 186 if (old_fb) { 187 vbox_fb = to_vbox_framebuffer(old_fb); 189 188 obj = vbox_fb->obj; 190 189 bo = gem_to_vbox_bo(obj); … … 192 191 if (ret) 193 192 return ret; 194 vbox_bo_ push_sysram(bo);193 vbox_bo_unpin(bo); 195 194 vbox_bo_unreserve(bo); 196 195 } … … 210 209 } 211 210 212 if (&vbox->fbdev->afb == vbox_fb) { 213 /* if pushing console in kmap it */ 214 ret = ttm_bo_kmap(&bo->bo, 0, bo->bo.num_pages, &bo->kmap); 215 if (ret) 216 DRM_ERROR("failed to kmap fbcon\n"); 217 else 218 vbox_fbdev_set_base(vbox, gpu_addr); 219 } 211 if (&vbox->fbdev->afb == vbox_fb) 212 vbox_fbdev_set_base(vbox, gpu_addr); 220 213 vbox_bo_unreserve(bo); 221 214 … … 232 225 struct drm_framebuffer *old_fb) 233 226 { 234 return vbox_crtc_do_set_base(crtc, old_fb, x, y , 0);227 return vbox_crtc_do_set_base(crtc, old_fb, x, y); 235 228 } 236 229
Note:
See TracChangeset
for help on using the changeset viewer.