aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaulo Zanoni <paulo.r.zanoni@intel.com>2016-01-18 12:56:58 -0500
committerPaulo Zanoni <paulo.r.zanoni@intel.com>2016-01-29 15:21:10 -0500
commite35be23f31c9bd42c342aca519bcedbc34b35da4 (patch)
treecc8c60d5e2dfa675ef06fe67ae142a9fddfccbc9
parent9b42281f9ddafe459e0b0d91ddf1939fbf84d832 (diff)
drm/i915/fbc: refactor some small functions called only once
The FBC fixes we've been doing in the last months required a lot of refactor, so functions that were once big and called from different spots are now small and called only once. IMHO now it's better to just move the contents of these functions to their only callers since this reduces the number of indirections while reading the code. While at it, also improve the related comments a little bit. Signed-off-by: Paulo Zanoni <paulo.r.zanoni@intel.com> Link: http://patchwork.freedesktop.org/patch/msgid/1453210558-7875-26-git-send-email-paulo.r.zanoni@intel.com
-rw-r--r--drivers/gpu/drm/i915/intel_fbc.c41
1 files changed, 14 insertions, 27 deletions
diff --git a/drivers/gpu/drm/i915/intel_fbc.c b/drivers/gpu/drm/i915/intel_fbc.c
index 2c896f95d2c3..5adf6d7620ad 100644
--- a/drivers/gpu/drm/i915/intel_fbc.c
+++ b/drivers/gpu/drm/i915/intel_fbc.c
@@ -414,14 +414,6 @@ out:
414 drm_crtc_vblank_put(&crtc->base); 414 drm_crtc_vblank_put(&crtc->base);
415} 415}
416 416
417static void intel_fbc_cancel_work(struct drm_i915_private *dev_priv)
418{
419 struct intel_fbc *fbc = &dev_priv->fbc;
420
421 WARN_ON(!mutex_is_locked(&fbc->lock));
422 fbc->work.scheduled = false;
423}
424
425static void intel_fbc_schedule_activation(struct intel_crtc *crtc) 417static void intel_fbc_schedule_activation(struct intel_crtc *crtc)
426{ 418{
427 struct drm_i915_private *dev_priv = crtc->base.dev->dev_private; 419 struct drm_i915_private *dev_priv = crtc->base.dev->dev_private;
@@ -436,10 +428,10 @@ static void intel_fbc_schedule_activation(struct intel_crtc *crtc)
436 return; 428 return;
437 } 429 }
438 430
439 /* It is useless to call intel_fbc_cancel_work() in this function since 431 /* It is useless to call intel_fbc_cancel_work() or cancel_work() in
440 * we're not releasing fbc.lock, so it won't have an opportunity to grab 432 * this function since we're not releasing fbc.lock, so it won't have an
441 * it to discover that it was cancelled. So we just update the expected 433 * opportunity to grab it to discover that it was cancelled. So we just
442 * jiffy count. */ 434 * update the expected jiffy count. */
443 work->scheduled = true; 435 work->scheduled = true;
444 work->scheduled_vblank = drm_crtc_vblank_count(&crtc->base); 436 work->scheduled_vblank = drm_crtc_vblank_count(&crtc->base);
445 drm_crtc_vblank_put(&crtc->base); 437 drm_crtc_vblank_put(&crtc->base);
@@ -453,25 +445,15 @@ static void intel_fbc_deactivate(struct drm_i915_private *dev_priv)
453 445
454 WARN_ON(!mutex_is_locked(&fbc->lock)); 446 WARN_ON(!mutex_is_locked(&fbc->lock));
455 447
456 intel_fbc_cancel_work(dev_priv); 448 /* Calling cancel_work() here won't help due to the fact that the work
449 * function grabs fbc->lock. Just set scheduled to false so the work
450 * function can know it was cancelled. */
451 fbc->work.scheduled = false;
457 452
458 if (fbc->active) 453 if (fbc->active)
459 fbc->deactivate(dev_priv); 454 fbc->deactivate(dev_priv);
460} 455}
461 456
462static bool crtc_can_fbc(struct intel_crtc *crtc)
463{
464 struct drm_i915_private *dev_priv = crtc->base.dev->dev_private;
465
466 if (fbc_on_pipe_a_only(dev_priv) && crtc->pipe != PIPE_A)
467 return false;
468
469 if (fbc_on_plane_a_only(dev_priv) && crtc->plane != PLANE_A)
470 return false;
471
472 return true;
473}
474
475static bool multiple_pipes_ok(struct intel_crtc *crtc) 457static bool multiple_pipes_ok(struct intel_crtc *crtc)
476{ 458{
477 struct drm_i915_private *dev_priv = crtc->base.dev->dev_private; 459 struct drm_i915_private *dev_priv = crtc->base.dev->dev_private;
@@ -831,11 +813,16 @@ static bool intel_fbc_can_choose(struct intel_crtc *crtc)
831 return false; 813 return false;
832 } 814 }
833 815
834 if (!crtc_can_fbc(crtc)) { 816 if (fbc_on_pipe_a_only(dev_priv) && crtc->pipe != PIPE_A) {
835 fbc->no_fbc_reason = "no enabled pipes can have FBC"; 817 fbc->no_fbc_reason = "no enabled pipes can have FBC";
836 return false; 818 return false;
837 } 819 }
838 820
821 if (fbc_on_plane_a_only(dev_priv) && crtc->plane != PLANE_A) {
822 fbc->no_fbc_reason = "no enabled planes can have FBC";
823 return false;
824 }
825
839 return true; 826 return true;
840} 827}
841 828