drm/i915: DRRS calls based on frontbuffer
authorVandana Kannan <vandana.kannan@intel.com>
Fri, 9 Jan 2015 20:55:59 +0000 (02:25 +0530)
committerDaniel Vetter <daniel.vetter@ffwll.ch>
Tue, 27 Jan 2015 08:51:15 +0000 (09:51 +0100)
Calls have been added to invalidate/flush DRRS whenever invalidate/flush is
called as part of frontbuffer tracking.
Apart from calls as a result of GEM tracking to fb invalidate/flush, a
call has been added to invalidate fb obj from crtc_page_flip as well. This
is to track busyness through flip calls.
The call to fb_obj_invalidate (in flip) is placed before queuing flip for this
obj.

drrs_invalidate() and drrs_flush() check for drrs.dp which would be NULL if
it was setup in drrs_enable(). This covers for the condition when DRRS is
not supported.

v2: Removing the call to invalidate_drrs from page_flip.
This has not been tested on Android yet, but, in case DRRS transtions do not
work as expected, check by adding back this call in page_flip.

Signed-off-by: Vandana Kannan <vandana.kannan@intel.com>
Reviewed-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
drivers/gpu/drm/i915/intel_dp.c
drivers/gpu/drm/i915/intel_drv.h
drivers/gpu/drm/i915/intel_frontbuffer.c

index 4ecc47468a9eeae132486fde7fef3ba0f8a3c8b2..a2adfa36d83bd175df12b6a6209da1f6f1acd50a 100644 (file)
@@ -4908,6 +4908,57 @@ unlock:
        mutex_unlock(&dev_priv->drrs.mutex);
 }
 
+void intel_edp_drrs_invalidate(struct drm_device *dev,
+               unsigned frontbuffer_bits)
+{
+       struct drm_i915_private *dev_priv = dev->dev_private;
+       struct drm_crtc *crtc;
+       enum pipe pipe;
+
+       if (!dev_priv->drrs.dp)
+               return;
+
+       mutex_lock(&dev_priv->drrs.mutex);
+       crtc = dp_to_dig_port(dev_priv->drrs.dp)->base.base.crtc;
+       pipe = to_intel_crtc(crtc)->pipe;
+
+       if (dev_priv->drrs.refresh_rate_type == DRRS_LOW_RR) {
+               cancel_delayed_work_sync(&dev_priv->drrs.work);
+               intel_dp_set_drrs_state(dev_priv->dev,
+                               dev_priv->drrs.dp->attached_connector->panel.
+                               fixed_mode->vrefresh);
+       }
+
+       frontbuffer_bits &= INTEL_FRONTBUFFER_ALL_MASK(pipe);
+
+       dev_priv->drrs.busy_frontbuffer_bits |= frontbuffer_bits;
+       mutex_unlock(&dev_priv->drrs.mutex);
+}
+
+void intel_edp_drrs_flush(struct drm_device *dev,
+               unsigned frontbuffer_bits)
+{
+       struct drm_i915_private *dev_priv = dev->dev_private;
+       struct drm_crtc *crtc;
+       enum pipe pipe;
+
+       if (!dev_priv->drrs.dp)
+               return;
+
+       mutex_lock(&dev_priv->drrs.mutex);
+       crtc = dp_to_dig_port(dev_priv->drrs.dp)->base.base.crtc;
+       pipe = to_intel_crtc(crtc)->pipe;
+       dev_priv->drrs.busy_frontbuffer_bits &= ~frontbuffer_bits;
+
+       cancel_delayed_work_sync(&dev_priv->drrs.work);
+
+       if (dev_priv->drrs.refresh_rate_type != DRRS_LOW_RR &&
+                       !dev_priv->drrs.busy_frontbuffer_bits)
+               schedule_delayed_work(&dev_priv->drrs.work,
+                               msecs_to_jiffies(1000));
+       mutex_unlock(&dev_priv->drrs.mutex);
+}
+
 static struct drm_display_mode *
 intel_dp_drrs_init(struct intel_connector *intel_connector,
                struct drm_display_mode *fixed_mode)
index bae20af646c06c62dd01220d8b3276d555cebba3..59a7b82cb9d745ad59d2512fb689b413a5ac24f0 100644 (file)
@@ -1032,6 +1032,9 @@ int intel_disable_plane(struct drm_plane *plane);
 void intel_plane_destroy(struct drm_plane *plane);
 void intel_edp_drrs_enable(struct intel_dp *intel_dp);
 void intel_edp_drrs_disable(struct intel_dp *intel_dp);
+void intel_edp_drrs_invalidate(struct drm_device *dev,
+               unsigned frontbuffer_bits);
+void intel_edp_drrs_flush(struct drm_device *dev, unsigned frontbuffer_bits);
 
 /* intel_dp_mst.c */
 int intel_dp_mst_encoder_init(struct intel_digital_port *intel_dig_port, int conn_id);
index 79f6d72179c51a280724b0245821ac75997fdbb6..73cb6e036445dd38f50503191db16d9fbf7a11b6 100644 (file)
@@ -157,6 +157,7 @@ void intel_fb_obj_invalidate(struct drm_i915_gem_object *obj,
        intel_mark_fb_busy(dev, obj->frontbuffer_bits, ring);
 
        intel_psr_invalidate(dev, obj->frontbuffer_bits);
+       intel_edp_drrs_invalidate(dev, obj->frontbuffer_bits);
 }
 
 /**
@@ -182,6 +183,7 @@ void intel_frontbuffer_flush(struct drm_device *dev,
 
        intel_mark_fb_busy(dev, frontbuffer_bits, NULL);
 
+       intel_edp_drrs_flush(dev, frontbuffer_bits);
        intel_psr_flush(dev, frontbuffer_bits);
 
        /*