diff mbox

[09/11] drm/i915: extract intel_fbc_find_crtc()

Message ID 1418054960-1403-10-git-send-email-przanoni@gmail.com (mailing list archive)
State New, archived
Headers show

Commit Message

Paulo Zanoni Dec. 8, 2014, 4:09 p.m. UTC
From: Paulo Zanoni <paulo.r.zanoni@intel.com>

I want to make this code a little more complicated, so let's extract
the function first.

Signed-off-by: Paulo Zanoni <paulo.r.zanoni@intel.com>
---
 drivers/gpu/drm/i915/intel_fbc.c | 46 +++++++++++++++++++++++++---------------
 1 file changed, 29 insertions(+), 17 deletions(-)

Comments

Rodrigo Vivi Dec. 13, 2014, 1:20 a.m. UTC | #1
Reviewed-by: Rodrigo Vivi <rodrigo.vivi@intel.com>

On Mon, Dec 8, 2014 at 8:09 AM, Paulo Zanoni <przanoni@gmail.com> wrote:
> From: Paulo Zanoni <paulo.r.zanoni@intel.com>
>
> I want to make this code a little more complicated, so let's extract
> the function first.
>
> Signed-off-by: Paulo Zanoni <paulo.r.zanoni@intel.com>
> ---
>  drivers/gpu/drm/i915/intel_fbc.c | 46 +++++++++++++++++++++++++---------------
>  1 file changed, 29 insertions(+), 17 deletions(-)
>
> diff --git a/drivers/gpu/drm/i915/intel_fbc.c b/drivers/gpu/drm/i915/intel_fbc.c
> index 03ba43d..450d0be 100644
> --- a/drivers/gpu/drm/i915/intel_fbc.c
> +++ b/drivers/gpu/drm/i915/intel_fbc.c
> @@ -444,6 +444,32 @@ static bool set_no_fbc_reason(struct drm_i915_private *dev_priv,
>         return true;
>  }
>
> +static struct drm_crtc *intel_fbc_find_crtc(struct drm_i915_private *dev_priv)
> +{
> +       struct drm_device *dev = dev_priv->dev;
> +       struct drm_crtc *crtc = NULL, *tmp_crtc;
> +
> +       for_each_crtc(dev, tmp_crtc) {
> +               if (intel_crtc_active(tmp_crtc) &&
> +                   to_intel_crtc(tmp_crtc)->primary_enabled) {
> +                       if (crtc) {
> +                               if (set_no_fbc_reason(dev_priv, FBC_MULTIPLE_PIPES))
> +                                       DRM_DEBUG_KMS("more than one pipe active, disabling compression\n");
> +                               return NULL;
> +                       }
> +                       crtc = tmp_crtc;
> +               }
> +       }
> +
> +       if (!crtc || crtc->primary->fb == NULL) {
> +               if (set_no_fbc_reason(dev_priv, FBC_NO_OUTPUT))
> +                       DRM_DEBUG_KMS("no output, disabling\n");
> +               return NULL;
> +       }
> +
> +       return crtc;
> +}
> +
>  /**
>   * intel_fbc_update - enable/disable FBC as needed
>   * @dev: the drm_device
> @@ -466,7 +492,7 @@ static bool set_no_fbc_reason(struct drm_i915_private *dev_priv,
>  void intel_fbc_update(struct drm_device *dev)
>  {
>         struct drm_i915_private *dev_priv = dev->dev_private;
> -       struct drm_crtc *crtc = NULL, *tmp_crtc;
> +       struct drm_crtc *crtc = NULL;
>         struct intel_crtc *intel_crtc;
>         struct drm_framebuffer *fb;
>         struct drm_i915_gem_object *obj;
> @@ -497,23 +523,9 @@ void intel_fbc_update(struct drm_device *dev)
>          *   - new fb is too large to fit in compressed buffer
>          *   - going to an unsupported config (interlace, pixel multiply, etc.)
>          */
> -       for_each_crtc(dev, tmp_crtc) {
> -               if (intel_crtc_active(tmp_crtc) &&
> -                   to_intel_crtc(tmp_crtc)->primary_enabled) {
> -                       if (crtc) {
> -                               if (set_no_fbc_reason(dev_priv, FBC_MULTIPLE_PIPES))
> -                                       DRM_DEBUG_KMS("more than one pipe active, disabling compression\n");
> -                               goto out_disable;
> -                       }
> -                       crtc = tmp_crtc;
> -               }
> -       }
> -
> -       if (!crtc || crtc->primary->fb == NULL) {
> -               if (set_no_fbc_reason(dev_priv, FBC_NO_OUTPUT))
> -                       DRM_DEBUG_KMS("no output, disabling\n");
> +       crtc = intel_fbc_find_crtc(dev_priv);
> +       if (!crtc)
>                 goto out_disable;
> -       }
>
>         intel_crtc = to_intel_crtc(crtc);
>         fb = crtc->primary->fb;
> --
> 2.1.3
>
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/intel-gfx
diff mbox

Patch

diff --git a/drivers/gpu/drm/i915/intel_fbc.c b/drivers/gpu/drm/i915/intel_fbc.c
index 03ba43d..450d0be 100644
--- a/drivers/gpu/drm/i915/intel_fbc.c
+++ b/drivers/gpu/drm/i915/intel_fbc.c
@@ -444,6 +444,32 @@  static bool set_no_fbc_reason(struct drm_i915_private *dev_priv,
 	return true;
 }
 
+static struct drm_crtc *intel_fbc_find_crtc(struct drm_i915_private *dev_priv)
+{
+	struct drm_device *dev = dev_priv->dev;
+	struct drm_crtc *crtc = NULL, *tmp_crtc;
+
+	for_each_crtc(dev, tmp_crtc) {
+		if (intel_crtc_active(tmp_crtc) &&
+		    to_intel_crtc(tmp_crtc)->primary_enabled) {
+			if (crtc) {
+				if (set_no_fbc_reason(dev_priv, FBC_MULTIPLE_PIPES))
+					DRM_DEBUG_KMS("more than one pipe active, disabling compression\n");
+				return NULL;
+			}
+			crtc = tmp_crtc;
+		}
+	}
+
+	if (!crtc || crtc->primary->fb == NULL) {
+		if (set_no_fbc_reason(dev_priv, FBC_NO_OUTPUT))
+			DRM_DEBUG_KMS("no output, disabling\n");
+		return NULL;
+	}
+
+	return crtc;
+}
+
 /**
  * intel_fbc_update - enable/disable FBC as needed
  * @dev: the drm_device
@@ -466,7 +492,7 @@  static bool set_no_fbc_reason(struct drm_i915_private *dev_priv,
 void intel_fbc_update(struct drm_device *dev)
 {
 	struct drm_i915_private *dev_priv = dev->dev_private;
-	struct drm_crtc *crtc = NULL, *tmp_crtc;
+	struct drm_crtc *crtc = NULL;
 	struct intel_crtc *intel_crtc;
 	struct drm_framebuffer *fb;
 	struct drm_i915_gem_object *obj;
@@ -497,23 +523,9 @@  void intel_fbc_update(struct drm_device *dev)
 	 *   - new fb is too large to fit in compressed buffer
 	 *   - going to an unsupported config (interlace, pixel multiply, etc.)
 	 */
-	for_each_crtc(dev, tmp_crtc) {
-		if (intel_crtc_active(tmp_crtc) &&
-		    to_intel_crtc(tmp_crtc)->primary_enabled) {
-			if (crtc) {
-				if (set_no_fbc_reason(dev_priv, FBC_MULTIPLE_PIPES))
-					DRM_DEBUG_KMS("more than one pipe active, disabling compression\n");
-				goto out_disable;
-			}
-			crtc = tmp_crtc;
-		}
-	}
-
-	if (!crtc || crtc->primary->fb == NULL) {
-		if (set_no_fbc_reason(dev_priv, FBC_NO_OUTPUT))
-			DRM_DEBUG_KMS("no output, disabling\n");
+	crtc = intel_fbc_find_crtc(dev_priv);
+	if (!crtc)
 		goto out_disable;
-	}
 
 	intel_crtc = to_intel_crtc(crtc);
 	fb = crtc->primary->fb;