aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVille Syrjälä <ville.syrjala@linux.intel.com>2014-08-06 07:49:47 -0400
committerDaniel Vetter <daniel.vetter@ffwll.ch>2014-08-06 16:39:24 -0400
commit13b030af54a5e307cbcccdf5479873fbc4b7f185 (patch)
tree49da5aca207c7ba9a6f4a6533cd84009eb474a8b
parent844b03f27739135fe1fed2fef06da0ffc4c7a081 (diff)
drm: Move drm_update_vblank_count()
Move drm_update_vblank_count() to avoid forward a declaration. No functional change. Reviewed-by: Matt Roper <matthew.d.roper@intel.com> Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com> Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
-rw-r--r--drivers/gpu/drm/drm_irq.c128
1 files changed, 64 insertions, 64 deletions
diff --git a/drivers/gpu/drm/drm_irq.c b/drivers/gpu/drm/drm_irq.c
index 65d2da9b604b..af965174b083 100644
--- a/drivers/gpu/drm/drm_irq.c
+++ b/drivers/gpu/drm/drm_irq.c
@@ -55,6 +55,70 @@
55 */ 55 */
56#define DRM_REDUNDANT_VBLIRQ_THRESH_NS 1000000 56#define DRM_REDUNDANT_VBLIRQ_THRESH_NS 1000000
57 57
58/**
59 * drm_update_vblank_count - update the master vblank counter
60 * @dev: DRM device
61 * @crtc: counter to update
62 *
63 * Call back into the driver to update the appropriate vblank counter
64 * (specified by @crtc). Deal with wraparound, if it occurred, and
65 * update the last read value so we can deal with wraparound on the next
66 * call if necessary.
67 *
68 * Only necessary when going from off->on, to account for frames we
69 * didn't get an interrupt for.
70 *
71 * Note: caller must hold dev->vbl_lock since this reads & writes
72 * device vblank fields.
73 */
74static void drm_update_vblank_count(struct drm_device *dev, int crtc)
75{
76 u32 cur_vblank, diff, tslot, rc;
77 struct timeval t_vblank;
78
79 /*
80 * Interrupts were disabled prior to this call, so deal with counter
81 * wrap if needed.
82 * NOTE! It's possible we lost a full dev->max_vblank_count events
83 * here if the register is small or we had vblank interrupts off for
84 * a long time.
85 *
86 * We repeat the hardware vblank counter & timestamp query until
87 * we get consistent results. This to prevent races between gpu
88 * updating its hardware counter while we are retrieving the
89 * corresponding vblank timestamp.
90 */
91 do {
92 cur_vblank = dev->driver->get_vblank_counter(dev, crtc);
93 rc = drm_get_last_vbltimestamp(dev, crtc, &t_vblank, 0);
94 } while (cur_vblank != dev->driver->get_vblank_counter(dev, crtc));
95
96 /* Deal with counter wrap */
97 diff = cur_vblank - dev->vblank[crtc].last;
98 if (cur_vblank < dev->vblank[crtc].last) {
99 diff += dev->max_vblank_count;
100
101 DRM_DEBUG("last_vblank[%d]=0x%x, cur_vblank=0x%x => diff=0x%x\n",
102 crtc, dev->vblank[crtc].last, cur_vblank, diff);
103 }
104
105 DRM_DEBUG("enabling vblank interrupts on crtc %d, missed %d\n",
106 crtc, diff);
107
108 /* Reinitialize corresponding vblank timestamp if high-precision query
109 * available. Skip this step if query unsupported or failed. Will
110 * reinitialize delayed at next vblank interrupt in that case.
111 */
112 if (rc) {
113 tslot = atomic_read(&dev->vblank[crtc].count) + diff;
114 vblanktimestamp(dev, crtc, tslot) = t_vblank;
115 }
116
117 smp_mb__before_atomic();
118 atomic_add(diff, &dev->vblank[crtc].count);
119 smp_mb__after_atomic();
120}
121
58/* 122/*
59 * Disable vblank irq's on crtc, make sure that last vblank count 123 * Disable vblank irq's on crtc, make sure that last vblank count
60 * of hardware and corresponding consistent software vblank counter 124 * of hardware and corresponding consistent software vblank counter
@@ -799,70 +863,6 @@ void drm_send_vblank_event(struct drm_device *dev, int crtc,
799EXPORT_SYMBOL(drm_send_vblank_event); 863EXPORT_SYMBOL(drm_send_vblank_event);
800 864
801/** 865/**
802 * drm_update_vblank_count - update the master vblank counter
803 * @dev: DRM device
804 * @crtc: counter to update
805 *
806 * Call back into the driver to update the appropriate vblank counter
807 * (specified by @crtc). Deal with wraparound, if it occurred, and
808 * update the last read value so we can deal with wraparound on the next
809 * call if necessary.
810 *
811 * Only necessary when going from off->on, to account for frames we
812 * didn't get an interrupt for.
813 *
814 * Note: caller must hold dev->vbl_lock since this reads & writes
815 * device vblank fields.
816 */
817static void drm_update_vblank_count(struct drm_device *dev, int crtc)
818{
819 u32 cur_vblank, diff, tslot, rc;
820 struct timeval t_vblank;
821
822 /*
823 * Interrupts were disabled prior to this call, so deal with counter
824 * wrap if needed.
825 * NOTE! It's possible we lost a full dev->max_vblank_count events
826 * here if the register is small or we had vblank interrupts off for
827 * a long time.
828 *
829 * We repeat the hardware vblank counter & timestamp query until
830 * we get consistent results. This to prevent races between gpu
831 * updating its hardware counter while we are retrieving the
832 * corresponding vblank timestamp.
833 */
834 do {
835 cur_vblank = dev->driver->get_vblank_counter(dev, crtc);
836 rc = drm_get_last_vbltimestamp(dev, crtc, &t_vblank, 0);
837 } while (cur_vblank != dev->driver->get_vblank_counter(dev, crtc));
838
839 /* Deal with counter wrap */
840 diff = cur_vblank - dev->vblank[crtc].last;
841 if (cur_vblank < dev->vblank[crtc].last) {
842 diff += dev->max_vblank_count;
843
844 DRM_DEBUG("last_vblank[%d]=0x%x, cur_vblank=0x%x => diff=0x%x\n",
845 crtc, dev->vblank[crtc].last, cur_vblank, diff);
846 }
847
848 DRM_DEBUG("enabling vblank interrupts on crtc %d, missed %d\n",
849 crtc, diff);
850
851 /* Reinitialize corresponding vblank timestamp if high-precision query
852 * available. Skip this step if query unsupported or failed. Will
853 * reinitialize delayed at next vblank interrupt in that case.
854 */
855 if (rc) {
856 tslot = atomic_read(&dev->vblank[crtc].count) + diff;
857 vblanktimestamp(dev, crtc, tslot) = t_vblank;
858 }
859
860 smp_mb__before_atomic();
861 atomic_add(diff, &dev->vblank[crtc].count);
862 smp_mb__after_atomic();
863}
864
865/**
866 * drm_vblank_enable - enable the vblank interrupt on a CRTC 866 * drm_vblank_enable - enable the vblank interrupt on a CRTC
867 * @dev: DRM device 867 * @dev: DRM device
868 * @crtc: CRTC in question 868 * @crtc: CRTC in question