aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/i915/i915_irq.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/gpu/drm/i915/i915_irq.c')
-rw-r--r--drivers/gpu/drm/i915/i915_irq.c62
1 files changed, 13 insertions, 49 deletions
diff --git a/drivers/gpu/drm/i915/i915_irq.c b/drivers/gpu/drm/i915/i915_irq.c
index fd97fe00cd0d..04493ef1d2f7 100644
--- a/drivers/gpu/drm/i915/i915_irq.c
+++ b/drivers/gpu/drm/i915/i915_irq.c
@@ -720,9 +720,7 @@ static u32 i915_get_vblank_counter(struct drm_device *dev, unsigned int pipe)
720 struct drm_i915_private *dev_priv = to_i915(dev); 720 struct drm_i915_private *dev_priv = to_i915(dev);
721 i915_reg_t high_frame, low_frame; 721 i915_reg_t high_frame, low_frame;
722 u32 high1, high2, low, pixel, vbl_start, hsync_start, htotal; 722 u32 high1, high2, low, pixel, vbl_start, hsync_start, htotal;
723 struct intel_crtc *intel_crtc = intel_get_crtc_for_pipe(dev_priv, 723 const struct drm_display_mode *mode = &dev->vblank[pipe].hwmode;
724 pipe);
725 const struct drm_display_mode *mode = &intel_crtc->base.hwmode;
726 unsigned long irqflags; 724 unsigned long irqflags;
727 725
728 htotal = mode->crtc_htotal; 726 htotal = mode->crtc_htotal;
@@ -779,13 +777,17 @@ static int __intel_get_crtc_scanline(struct intel_crtc *crtc)
779{ 777{
780 struct drm_device *dev = crtc->base.dev; 778 struct drm_device *dev = crtc->base.dev;
781 struct drm_i915_private *dev_priv = to_i915(dev); 779 struct drm_i915_private *dev_priv = to_i915(dev);
782 const struct drm_display_mode *mode = &crtc->base.hwmode; 780 const struct drm_display_mode *mode;
781 struct drm_vblank_crtc *vblank;
783 enum pipe pipe = crtc->pipe; 782 enum pipe pipe = crtc->pipe;
784 int position, vtotal; 783 int position, vtotal;
785 784
786 if (!crtc->active) 785 if (!crtc->active)
787 return -1; 786 return -1;
788 787
788 vblank = &crtc->base.dev->vblank[drm_crtc_index(&crtc->base)];
789 mode = &vblank->hwmode;
790
789 vtotal = mode->crtc_vtotal; 791 vtotal = mode->crtc_vtotal;
790 if (mode->flags & DRM_MODE_FLAG_INTERLACE) 792 if (mode->flags & DRM_MODE_FLAG_INTERLACE)
791 vtotal /= 2; 793 vtotal /= 2;
@@ -827,10 +829,10 @@ static int __intel_get_crtc_scanline(struct intel_crtc *crtc)
827 return (position + crtc->scanline_offset) % vtotal; 829 return (position + crtc->scanline_offset) % vtotal;
828} 830}
829 831
830static int i915_get_crtc_scanoutpos(struct drm_device *dev, unsigned int pipe, 832static bool i915_get_crtc_scanoutpos(struct drm_device *dev, unsigned int pipe,
831 unsigned int flags, int *vpos, int *hpos, 833 bool in_vblank_irq, int *vpos, int *hpos,
832 ktime_t *stime, ktime_t *etime, 834 ktime_t *stime, ktime_t *etime,
833 const struct drm_display_mode *mode) 835 const struct drm_display_mode *mode)
834{ 836{
835 struct drm_i915_private *dev_priv = to_i915(dev); 837 struct drm_i915_private *dev_priv = to_i915(dev);
836 struct intel_crtc *intel_crtc = intel_get_crtc_for_pipe(dev_priv, 838 struct intel_crtc *intel_crtc = intel_get_crtc_for_pipe(dev_priv,
@@ -838,13 +840,12 @@ static int i915_get_crtc_scanoutpos(struct drm_device *dev, unsigned int pipe,
838 int position; 840 int position;
839 int vbl_start, vbl_end, hsync_start, htotal, vtotal; 841 int vbl_start, vbl_end, hsync_start, htotal, vtotal;
840 bool in_vbl = true; 842 bool in_vbl = true;
841 int ret = 0;
842 unsigned long irqflags; 843 unsigned long irqflags;
843 844
844 if (WARN_ON(!mode->crtc_clock)) { 845 if (WARN_ON(!mode->crtc_clock)) {
845 DRM_DEBUG_DRIVER("trying to get scanoutpos for disabled " 846 DRM_DEBUG_DRIVER("trying to get scanoutpos for disabled "
846 "pipe %c\n", pipe_name(pipe)); 847 "pipe %c\n", pipe_name(pipe));
847 return 0; 848 return false;
848 } 849 }
849 850
850 htotal = mode->crtc_htotal; 851 htotal = mode->crtc_htotal;
@@ -859,8 +860,6 @@ static int i915_get_crtc_scanoutpos(struct drm_device *dev, unsigned int pipe,
859 vtotal /= 2; 860 vtotal /= 2;
860 } 861 }
861 862
862 ret |= DRM_SCANOUTPOS_VALID | DRM_SCANOUTPOS_ACCURATE;
863
864 /* 863 /*
865 * Lock uncore.lock, as we will do multiple timing critical raw 864 * Lock uncore.lock, as we will do multiple timing critical raw
866 * register reads, potentially with preemption disabled, so the 865 * register reads, potentially with preemption disabled, so the
@@ -944,11 +943,7 @@ static int i915_get_crtc_scanoutpos(struct drm_device *dev, unsigned int pipe,
944 *hpos = position - (*vpos * htotal); 943 *hpos = position - (*vpos * htotal);
945 } 944 }
946 945
947 /* In vblank? */ 946 return true;
948 if (in_vbl)
949 ret |= DRM_SCANOUTPOS_IN_VBLANK;
950
951 return ret;
952} 947}
953 948
954int intel_get_crtc_scanline(struct intel_crtc *crtc) 949int intel_get_crtc_scanline(struct intel_crtc *crtc)
@@ -964,37 +959,6 @@ int intel_get_crtc_scanline(struct intel_crtc *crtc)
964 return position; 959 return position;
965} 960}
966 961
967static int i915_get_vblank_timestamp(struct drm_device *dev, unsigned int pipe,
968 int *max_error,
969 struct timeval *vblank_time,
970 unsigned flags)
971{
972 struct drm_i915_private *dev_priv = to_i915(dev);
973 struct intel_crtc *crtc;
974
975 if (pipe >= INTEL_INFO(dev_priv)->num_pipes) {
976 DRM_ERROR("Invalid crtc %u\n", pipe);
977 return -EINVAL;
978 }
979
980 /* Get drm_crtc to timestamp: */
981 crtc = intel_get_crtc_for_pipe(dev_priv, pipe);
982 if (crtc == NULL) {
983 DRM_ERROR("Invalid crtc %u\n", pipe);
984 return -EINVAL;
985 }
986
987 if (!crtc->base.hwmode.crtc_clock) {
988 DRM_DEBUG_KMS("crtc %u is disabled\n", pipe);
989 return -EBUSY;
990 }
991
992 /* Helper routine in DRM core does all the work: */
993 return drm_calc_vbltimestamp_from_scanoutpos(dev, pipe, max_error,
994 vblank_time, flags,
995 &crtc->base.hwmode);
996}
997
998static void ironlake_rps_change_irq_handler(struct drm_i915_private *dev_priv) 962static void ironlake_rps_change_irq_handler(struct drm_i915_private *dev_priv)
999{ 963{
1000 u32 busy_up, busy_down, max_avg, min_avg; 964 u32 busy_up, busy_down, max_avg, min_avg;
@@ -4294,7 +4258,7 @@ void intel_irq_init(struct drm_i915_private *dev_priv)
4294 4258
4295 dev_priv->hotplug.hpd_storm_threshold = HPD_STORM_DEFAULT_THRESHOLD; 4259 dev_priv->hotplug.hpd_storm_threshold = HPD_STORM_DEFAULT_THRESHOLD;
4296 4260
4297 dev->driver->get_vblank_timestamp = i915_get_vblank_timestamp; 4261 dev->driver->get_vblank_timestamp = drm_calc_vbltimestamp_from_scanoutpos;
4298 dev->driver->get_scanout_position = i915_get_crtc_scanoutpos; 4262 dev->driver->get_scanout_position = i915_get_crtc_scanoutpos;
4299 4263
4300 if (IS_CHERRYVIEW(dev_priv)) { 4264 if (IS_CHERRYVIEW(dev_priv)) {