aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/i915/intel_fbdev.c
diff options
context:
space:
mode:
authorJesse Barnes <jbarnes@virtuousgeek.org>2014-03-07 11:57:55 -0500
committerDaniel Vetter <daniel.vetter@ffwll.ch>2014-03-08 05:31:58 -0500
commit484b41dd70a9fbea894632d8926bbb93f05021c7 (patch)
tree3ea2683f50180ebe0bca779fda0d60d19d846aa9 /drivers/gpu/drm/i915/intel_fbdev.c
parentd978ef14456a38034f6c0e94a794129501f89200 (diff)
drm/i915: remove early fb allocation dependency on CONFIG_FB v2
By stuffing the fb allocation into the crtc, we get mode set lifetime refcounting for free, but have to handle the initial pin & fence slightly differently. It also means we can move the shared fb handling into the core rather than leaving it out in the fbdev code. v2: null out crtc->fb on error (Daniel) take fbdev fb ref and remove unused error path (Daniel) Requested-by: Daniel Vetter <daniel@ffwll.ch> Signed-off-by: Jesse Barnes <jbarnes@virtuousgeek.org> Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Diffstat (limited to 'drivers/gpu/drm/i915/intel_fbdev.c')
-rw-r--r--drivers/gpu/drm/i915/intel_fbdev.c38
1 files changed, 4 insertions, 34 deletions
diff --git a/drivers/gpu/drm/i915/intel_fbdev.c b/drivers/gpu/drm/i915/intel_fbdev.c
index 32a05edc517c..d6d78c86c232 100644
--- a/drivers/gpu/drm/i915/intel_fbdev.c
+++ b/drivers/gpu/drm/i915/intel_fbdev.c
@@ -481,7 +481,7 @@ static bool intel_fbdev_init_bios(struct drm_device *dev,
481 list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) { 481 list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) {
482 intel_crtc = to_intel_crtc(crtc); 482 intel_crtc = to_intel_crtc(crtc);
483 483
484 if (!intel_crtc->active || !intel_crtc->plane_config.fb) { 484 if (!intel_crtc->active || !crtc->fb) {
485 DRM_DEBUG_KMS("pipe %c not active or no fb, skipping\n", 485 DRM_DEBUG_KMS("pipe %c not active or no fb, skipping\n",
486 pipe_name(intel_crtc->pipe)); 486 pipe_name(intel_crtc->pipe));
487 continue; 487 continue;
@@ -491,7 +491,7 @@ static bool intel_fbdev_init_bios(struct drm_device *dev,
491 DRM_DEBUG_KMS("found possible fb from plane %c\n", 491 DRM_DEBUG_KMS("found possible fb from plane %c\n",
492 pipe_name(intel_crtc->pipe)); 492 pipe_name(intel_crtc->pipe));
493 plane_config = &intel_crtc->plane_config; 493 plane_config = &intel_crtc->plane_config;
494 fb = plane_config->fb; 494 fb = to_intel_framebuffer(crtc->fb);
495 max_size = plane_config->size; 495 max_size = plane_config->size;
496 } 496 }
497 } 497 }
@@ -543,43 +543,15 @@ static bool intel_fbdev_init_bios(struct drm_device *dev,
543 max_size, cur_size); 543 max_size, cur_size);
544 } 544 }
545 545
546 /* Free unused fbs */
547 list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) {
548 struct intel_framebuffer *cur_fb;
549
550 intel_crtc = to_intel_crtc(crtc);
551 cur_fb = intel_crtc->plane_config.fb;
552
553 if (cur_fb && cur_fb != fb)
554 drm_framebuffer_unreference(&cur_fb->base);
555 }
556
557 if (!fb) { 546 if (!fb) {
558 DRM_DEBUG_KMS("BIOS fb not suitable for all pipes, not using\n"); 547 DRM_DEBUG_KMS("BIOS fb not suitable for all pipes, not using\n");
559 goto out; 548 goto out;
560 } 549 }
561 550
562 ifbdev->preferred_bpp = plane_config->fb->base.bits_per_pixel; 551 ifbdev->preferred_bpp = fb->base.bits_per_pixel;
563 ifbdev->fb = fb; 552 ifbdev->fb = fb;
564 553
565 /* Assuming a single fb across all pipes here */ 554 drm_framebuffer_reference(&ifbdev->fb->base);
566 list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) {
567 intel_crtc = to_intel_crtc(crtc);
568
569 if (!intel_crtc->active)
570 continue;
571
572 /*
573 * This should only fail on the first one so we don't need
574 * to cleanup any secondary crtc->fbs
575 */
576 if (intel_pin_and_fence_fb_obj(dev, fb->obj, NULL))
577 goto out_unref_obj;
578
579 crtc->fb = &fb->base;
580 drm_gem_object_reference(&fb->obj->base);
581 drm_framebuffer_reference(&fb->base);
582 }
583 555
584 /* Final pass to check if any active pipes don't have fbs */ 556 /* Final pass to check if any active pipes don't have fbs */
585 list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) { 557 list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) {
@@ -597,8 +569,6 @@ static bool intel_fbdev_init_bios(struct drm_device *dev,
597 DRM_DEBUG_KMS("using BIOS fb for initial console\n"); 569 DRM_DEBUG_KMS("using BIOS fb for initial console\n");
598 return true; 570 return true;
599 571
600out_unref_obj:
601 drm_framebuffer_unreference(&fb->base);
602out: 572out:
603 573
604 return false; 574 return false;