.. | .. |
---|
37 | 37 | #include <linux/vga_switcheroo.h> |
---|
38 | 38 | #include <linux/console.h> |
---|
39 | 39 | |
---|
40 | | -#include <drm/drmP.h> |
---|
41 | 40 | #include <drm/drm_crtc.h> |
---|
42 | 41 | #include <drm/drm_crtc_helper.h> |
---|
43 | 42 | #include <drm/drm_fb_helper.h> |
---|
| 43 | +#include <drm/drm_fourcc.h> |
---|
44 | 44 | #include <drm/drm_atomic.h> |
---|
45 | 45 | |
---|
46 | 46 | #include "nouveau_drv.h" |
---|
.. | .. |
---|
205 | 205 | return 0; |
---|
206 | 206 | } |
---|
207 | 207 | |
---|
208 | | -static struct fb_ops nouveau_fbcon_ops = { |
---|
| 208 | +static const struct fb_ops nouveau_fbcon_ops = { |
---|
209 | 209 | .owner = THIS_MODULE, |
---|
210 | 210 | DRM_FB_HELPER_DEFAULT_OPS, |
---|
211 | 211 | .fb_open = nouveau_fbcon_open, |
---|
.. | .. |
---|
216 | 216 | .fb_sync = nouveau_fbcon_sync, |
---|
217 | 217 | }; |
---|
218 | 218 | |
---|
219 | | -static struct fb_ops nouveau_fbcon_sw_ops = { |
---|
| 219 | +static const struct fb_ops nouveau_fbcon_sw_ops = { |
---|
220 | 220 | .owner = THIS_MODULE, |
---|
221 | 221 | DRM_FB_HELPER_DEFAULT_OPS, |
---|
222 | 222 | .fb_open = nouveau_fbcon_open, |
---|
.. | .. |
---|
256 | 256 | fbcon->helper.fbdev->flags |= FBINFO_HWACCEL_DISABLED; |
---|
257 | 257 | console_unlock(); |
---|
258 | 258 | nouveau_channel_idle(drm->channel); |
---|
259 | | - nvif_object_fini(&fbcon->twod); |
---|
260 | | - nvif_object_fini(&fbcon->blit); |
---|
261 | | - nvif_object_fini(&fbcon->gdi); |
---|
262 | | - nvif_object_fini(&fbcon->patt); |
---|
263 | | - nvif_object_fini(&fbcon->rop); |
---|
264 | | - nvif_object_fini(&fbcon->clip); |
---|
265 | | - nvif_object_fini(&fbcon->surf2d); |
---|
| 259 | + nvif_object_dtor(&fbcon->twod); |
---|
| 260 | + nvif_object_dtor(&fbcon->blit); |
---|
| 261 | + nvif_object_dtor(&fbcon->gdi); |
---|
| 262 | + nvif_object_dtor(&fbcon->patt); |
---|
| 263 | + nvif_object_dtor(&fbcon->rop); |
---|
| 264 | + nvif_object_dtor(&fbcon->clip); |
---|
| 265 | + nvif_object_dtor(&fbcon->surf2d); |
---|
266 | 266 | } |
---|
267 | 267 | } |
---|
268 | 268 | |
---|
.. | .. |
---|
314 | 314 | struct nouveau_drm *drm = nouveau_drm(dev); |
---|
315 | 315 | struct nvif_device *device = &drm->client.device; |
---|
316 | 316 | struct fb_info *info; |
---|
317 | | - struct nouveau_framebuffer *fb; |
---|
| 317 | + struct drm_framebuffer *fb; |
---|
318 | 318 | struct nouveau_channel *chan; |
---|
319 | 319 | struct nouveau_bo *nvbo; |
---|
320 | 320 | struct drm_mode_fb_cmd2 mode_cmd = {}; |
---|
.. | .. |
---|
337 | 337 | goto out; |
---|
338 | 338 | } |
---|
339 | 339 | |
---|
340 | | - ret = nouveau_framebuffer_new(dev, &mode_cmd, nvbo, &fb); |
---|
| 340 | + ret = nouveau_framebuffer_new(dev, &mode_cmd, &nvbo->bo.base, &fb); |
---|
341 | 341 | if (ret) |
---|
342 | 342 | goto out_unref; |
---|
343 | 343 | |
---|
344 | | - ret = nouveau_bo_pin(nvbo, TTM_PL_FLAG_VRAM, false); |
---|
| 344 | + ret = nouveau_bo_pin(nvbo, NOUVEAU_GEM_DOMAIN_VRAM, false); |
---|
345 | 345 | if (ret) { |
---|
346 | 346 | NV_ERROR(drm, "failed to pin fb: %d\n", ret); |
---|
347 | 347 | goto out_unref; |
---|
.. | .. |
---|
355 | 355 | |
---|
356 | 356 | chan = nouveau_nofbaccel ? NULL : drm->channel; |
---|
357 | 357 | if (chan && device->info.family >= NV_DEVICE_INFO_V0_TESLA) { |
---|
358 | | - ret = nouveau_vma_new(nvbo, &drm->client.vmm, &fb->vma); |
---|
| 358 | + ret = nouveau_vma_new(nvbo, chan->vmm, &fbcon->vma); |
---|
359 | 359 | if (ret) { |
---|
360 | 360 | NV_ERROR(drm, "failed to map fb into chan: %d\n", ret); |
---|
361 | 361 | chan = NULL; |
---|
.. | .. |
---|
367 | 367 | ret = PTR_ERR(info); |
---|
368 | 368 | goto out_unlock; |
---|
369 | 369 | } |
---|
370 | | - info->skip_vt_switch = 1; |
---|
371 | | - |
---|
372 | | - info->par = fbcon; |
---|
373 | 370 | |
---|
374 | 371 | /* setup helper */ |
---|
375 | | - fbcon->helper.fb = &fb->base; |
---|
| 372 | + fbcon->helper.fb = fb; |
---|
376 | 373 | |
---|
377 | | - strcpy(info->fix.id, "nouveaufb"); |
---|
378 | 374 | if (!chan) |
---|
379 | | - info->flags = FBINFO_DEFAULT | FBINFO_HWACCEL_DISABLED; |
---|
| 375 | + info->flags = FBINFO_HWACCEL_DISABLED; |
---|
380 | 376 | else |
---|
381 | | - info->flags = FBINFO_DEFAULT | FBINFO_HWACCEL_COPYAREA | |
---|
| 377 | + info->flags = FBINFO_HWACCEL_COPYAREA | |
---|
382 | 378 | FBINFO_HWACCEL_FILLRECT | |
---|
383 | 379 | FBINFO_HWACCEL_IMAGEBLIT; |
---|
384 | | - info->flags |= FBINFO_CAN_FORCE_OUTPUT; |
---|
385 | 380 | info->fbops = &nouveau_fbcon_sw_ops; |
---|
386 | | - info->fix.smem_start = fb->nvbo->bo.mem.bus.base + |
---|
387 | | - fb->nvbo->bo.mem.bus.offset; |
---|
388 | | - info->fix.smem_len = fb->nvbo->bo.mem.num_pages << PAGE_SHIFT; |
---|
| 381 | + info->fix.smem_start = nvbo->bo.mem.bus.offset; |
---|
| 382 | + info->fix.smem_len = nvbo->bo.mem.num_pages << PAGE_SHIFT; |
---|
389 | 383 | |
---|
390 | | - info->screen_base = nvbo_kmap_obj_iovirtual(fb->nvbo); |
---|
391 | | - info->screen_size = fb->nvbo->bo.mem.num_pages << PAGE_SHIFT; |
---|
| 384 | + info->screen_base = nvbo_kmap_obj_iovirtual(nvbo); |
---|
| 385 | + info->screen_size = nvbo->bo.mem.num_pages << PAGE_SHIFT; |
---|
392 | 386 | |
---|
393 | | - drm_fb_helper_fill_fix(info, fb->base.pitches[0], |
---|
394 | | - fb->base.format->depth); |
---|
395 | | - drm_fb_helper_fill_var(info, &fbcon->helper, sizes->fb_width, sizes->fb_height); |
---|
| 387 | + drm_fb_helper_fill_info(info, &fbcon->helper, sizes); |
---|
396 | 388 | |
---|
397 | 389 | /* Use default scratch pixmap (info->pixmap.flags = FB_PIXMAP_SYSTEM) */ |
---|
398 | 390 | |
---|
.. | .. |
---|
402 | 394 | |
---|
403 | 395 | /* To allow resizeing without swapping buffers */ |
---|
404 | 396 | NV_INFO(drm, "allocated %dx%d fb: 0x%llx, bo %p\n", |
---|
405 | | - fb->base.width, fb->base.height, fb->nvbo->bo.offset, nvbo); |
---|
| 397 | + fb->width, fb->height, nvbo->offset, nvbo); |
---|
406 | 398 | |
---|
407 | 399 | vga_switcheroo_client_fb_set(dev->pdev, info); |
---|
408 | 400 | return 0; |
---|
409 | 401 | |
---|
410 | 402 | out_unlock: |
---|
411 | 403 | if (chan) |
---|
412 | | - nouveau_vma_del(&fb->vma); |
---|
413 | | - nouveau_bo_unmap(fb->nvbo); |
---|
| 404 | + nouveau_vma_del(&fbcon->vma); |
---|
| 405 | + nouveau_bo_unmap(nvbo); |
---|
414 | 406 | out_unpin: |
---|
415 | | - nouveau_bo_unpin(fb->nvbo); |
---|
| 407 | + nouveau_bo_unpin(nvbo); |
---|
416 | 408 | out_unref: |
---|
417 | | - nouveau_bo_ref(NULL, &fb->nvbo); |
---|
| 409 | + nouveau_bo_ref(NULL, &nvbo); |
---|
418 | 410 | out: |
---|
419 | 411 | return ret; |
---|
420 | 412 | } |
---|
.. | .. |
---|
422 | 414 | static int |
---|
423 | 415 | nouveau_fbcon_destroy(struct drm_device *dev, struct nouveau_fbdev *fbcon) |
---|
424 | 416 | { |
---|
425 | | - struct nouveau_framebuffer *nouveau_fb = nouveau_framebuffer(fbcon->helper.fb); |
---|
| 417 | + struct drm_framebuffer *fb = fbcon->helper.fb; |
---|
| 418 | + struct nouveau_bo *nvbo; |
---|
426 | 419 | |
---|
427 | 420 | drm_fb_helper_unregister_fbi(&fbcon->helper); |
---|
428 | 421 | drm_fb_helper_fini(&fbcon->helper); |
---|
429 | 422 | |
---|
430 | | - if (nouveau_fb && nouveau_fb->nvbo) { |
---|
431 | | - nouveau_vma_del(&nouveau_fb->vma); |
---|
432 | | - nouveau_bo_unmap(nouveau_fb->nvbo); |
---|
433 | | - nouveau_bo_unpin(nouveau_fb->nvbo); |
---|
434 | | - drm_framebuffer_put(&nouveau_fb->base); |
---|
| 423 | + if (fb && fb->obj[0]) { |
---|
| 424 | + nvbo = nouveau_gem_object(fb->obj[0]); |
---|
| 425 | + nouveau_vma_del(&fbcon->vma); |
---|
| 426 | + nouveau_bo_unmap(nvbo); |
---|
| 427 | + nouveau_bo_unpin(nvbo); |
---|
| 428 | + drm_framebuffer_put(fb); |
---|
435 | 429 | } |
---|
436 | 430 | |
---|
437 | 431 | return 0; |
---|
.. | .. |
---|
470 | 464 | if (state == FBINFO_STATE_RUNNING) { |
---|
471 | 465 | nouveau_fbcon_hotplug_resume(drm->fbcon); |
---|
472 | 466 | pm_runtime_mark_last_busy(drm->dev->dev); |
---|
473 | | - pm_runtime_put_sync(drm->dev->dev); |
---|
| 467 | + pm_runtime_put_autosuspend(drm->dev->dev); |
---|
474 | 468 | } |
---|
475 | 469 | } |
---|
476 | 470 | |
---|
.. | .. |
---|
567 | 561 | |
---|
568 | 562 | drm_fb_helper_prepare(dev, &fbcon->helper, &nouveau_fbcon_helper_funcs); |
---|
569 | 563 | |
---|
570 | | - ret = drm_fb_helper_init(dev, &fbcon->helper, 4); |
---|
| 564 | + ret = drm_fb_helper_init(dev, &fbcon->helper); |
---|
571 | 565 | if (ret) |
---|
572 | 566 | goto free; |
---|
573 | | - |
---|
574 | | - ret = drm_fb_helper_single_add_all_connectors(&fbcon->helper); |
---|
575 | | - if (ret) |
---|
576 | | - goto fini; |
---|
577 | 567 | |
---|
578 | 568 | if (preferred_bpp != 8 && preferred_bpp != 16 && preferred_bpp != 32) { |
---|
579 | 569 | if (drm->client.device.info.ram_size <= 32 * 1024 * 1024) |
---|