Lines Matching refs:pipe
93 drm_get_last_vbltimestamp(struct drm_device *dev, unsigned int pipe,
105 static void store_vblank(struct drm_device *dev, unsigned int pipe,
109 struct drm_vblank_crtc *vblank = &dev->vblank[pipe];
121 static u32 drm_max_vblank_count(struct drm_device *dev, unsigned int pipe)
123 struct drm_vblank_crtc *vblank = &dev->vblank[pipe];
132 static u32 drm_vblank_no_hw_counter(struct drm_device *dev, unsigned int pipe)
134 WARN_ON_ONCE(drm_max_vblank_count(dev, pipe) != 0);
138 static u32 __get_vblank_counter(struct drm_device *dev, unsigned int pipe)
141 struct drm_crtc *crtc = drm_crtc_from_index(dev, pipe);
151 return dev->driver->get_vblank_counter(dev, pipe);
153 return drm_vblank_no_hw_counter(dev, pipe);
165 static void drm_reset_vblank_timestamp(struct drm_device *dev, unsigned int pipe)
181 cur_vblank = __get_vblank_counter(dev, pipe);
182 rc = drm_get_last_vbltimestamp(dev, pipe, &t_vblank, false);
183 } while (cur_vblank != __get_vblank_counter(dev, pipe) && --count > 0);
197 store_vblank(dev, pipe, 1, t_vblank, cur_vblank);
204 * (specified by @pipe). Deal with wraparound, if it occurred, and
214 static void drm_update_vblank_count(struct drm_device *dev, unsigned int pipe,
217 struct drm_vblank_crtc *vblank = &dev->vblank[pipe];
223 u32 max_vblank_count = drm_max_vblank_count(dev, pipe);
240 cur_vblank = __get_vblank_counter(dev, pipe);
241 rc = drm_get_last_vbltimestamp(dev, pipe, &t_vblank, in_vblank_irq);
242 } while (cur_vblank != __get_vblank_counter(dev, pipe) && --count > 0);
258 pipe, (long long) diff_ns, framedur_ns);
264 pipe);
281 " due to pre-modeset.\n", pipe, diff);
287 pipe, atomic64_read(&vblank->count), diff,
304 store_vblank(dev, pipe, diff, t_vblank, cur_vblank);
307 static u64 drm_vblank_count(struct drm_device *dev, unsigned int pipe)
309 struct drm_vblank_crtc *vblank = &dev->vblank[pipe];
312 if (WARN_ON(pipe >= dev->num_crtcs))
343 unsigned int pipe = drm_crtc_index(crtc);
354 drm_update_vblank_count(dev, pipe, false);
355 vblank = drm_vblank_count(dev, pipe);
363 static void __disable_vblank(struct drm_device *dev, unsigned int pipe)
366 struct drm_crtc *crtc = drm_crtc_from_index(dev, pipe);
377 dev->driver->disable_vblank(dev, pipe);
386 void drm_vblank_disable_and_save(struct drm_device *dev, unsigned int pipe)
388 struct drm_vblank_crtc *vblank = &dev->vblank[pipe];
414 drm_update_vblank_count(dev, pipe, false);
415 __disable_vblank(dev, pipe);
424 unsigned int pipe)
427 BUG_ON(vblank != &dev->vblank[pipe]);
431 DRM_DEBUG("disabling vblank on crtc %u\n", pipe);
432 drm_vblank_disable_and_save(dev, pipe);
440 unsigned int pipe = vblank->pipe;
445 DRM_DEBUG("disabling vblank on crtc %u\n", pipe);
446 drm_vblank_disable_and_save(dev, pipe);
453 unsigned int pipe;
459 for (pipe = 0; pipe < dev->num_crtcs; pipe++) {
460 struct drm_vblank_crtc *vblank = &dev->vblank[pipe];
505 vblank->pipe = i;
564 unsigned int pipe = drm_crtc_index(crtc);
565 struct drm_vblank_crtc *vblank = &dev->vblank[pipe];
572 if (WARN_ON(pipe >= dev->num_crtcs))
611 * @pipe: index of CRTC whose vblank timestamp to retrieve
640 unsigned int pipe,
650 struct drm_vblank_crtc *vblank = &dev->vblank[pipe];
657 crtc = drm_crtc_from_index(dev, pipe);
659 if (pipe >= dev->num_crtcs || !crtc) {
660 DRM_ERROR("Invalid crtc %u\n", pipe);
679 DRM_DEBUG("crtc %u: Noop due to uninitialized mode.\n", pipe);
697 vbl_status = dev->driver->get_scanout_position(dev, pipe,
706 pipe);
721 pipe, duration_ns/1000, *max_error/1000, i);
746 pipe, hpos, vpos,
759 * @pipe: index of CRTC whose vblank timestamp to retrieve
777 drm_get_last_vbltimestamp(struct drm_device *dev, unsigned int pipe,
787 ret = dev->driver->get_vblank_timestamp(dev, pipe, &max_error,
830 * @pipe: index of CRTC whose counter to retrieve
840 static u64 drm_vblank_count_and_time(struct drm_device *dev, unsigned int pipe,
843 struct drm_vblank_crtc *vblank = &dev->vblank[pipe];
847 if (WARN_ON(pipe >= dev->num_crtcs)) {
913 trace_drm_vblank_event_delivered(e->base.file_priv, e->pipe, seq);
959 unsigned int pipe = drm_crtc_index(crtc);
963 e->pipe = pipe;
985 unsigned int pipe = drm_crtc_index(crtc);
989 seq = drm_vblank_count_and_time(dev, pipe, &now);
995 e->pipe = pipe;
1000 static int __enable_vblank(struct drm_device *dev, unsigned int pipe)
1003 struct drm_crtc *crtc = drm_crtc_from_index(dev, pipe);
1012 return dev->driver->enable_vblank(dev, pipe);
1015 static int drm_vblank_enable(struct drm_device *dev, unsigned int pipe)
1017 struct drm_vblank_crtc *vblank = &dev->vblank[pipe];
1032 ret = __enable_vblank(dev, pipe);
1033 DRM_DEBUG("enabling vblank on crtc %u, ret: %d\n", pipe, ret);
1037 drm_update_vblank_count(dev, pipe, 0);
1052 static int drm_vblank_get_locked(struct drm_device *dev, unsigned int pipe)
1054 struct drm_vblank_crtc *vblank = &dev->vblank[pipe];
1062 if (WARN_ON(pipe >= dev->num_crtcs))
1067 ret = drm_vblank_enable(dev, pipe);
1078 static int drm_vblank_get(struct drm_device *dev, unsigned int pipe)
1083 ret = drm_vblank_get_locked(dev, pipe);
1111 static void drm_vblank_put_locked(struct drm_device *dev, unsigned int pipe)
1113 struct drm_vblank_crtc *vblank = &dev->vblank[pipe];
1117 if (WARN_ON(pipe >= dev->num_crtcs))
1128 vblank_disable_locked(vblank, dev, pipe);
1135 static void drm_vblank_put(struct drm_device *dev, unsigned int pipe)
1137 struct drm_vblank_crtc *vblank = &dev->vblank[pipe];
1139 if (WARN_ON(pipe >= dev->num_crtcs))
1178 * @pipe: CRTC index
1180 * This waits for one vblank to pass on @pipe, using the irq driver interfaces.
1181 * It is a failure to call this when the vblank irq for @pipe is disabled, e.g.
1186 void drm_wait_one_vblank(struct drm_device *dev, unsigned int pipe)
1188 struct drm_vblank_crtc *vblank = &dev->vblank[pipe];
1192 if (WARN_ON(pipe >= dev->num_crtcs))
1197 ret = drm_vblank_get_locked(dev, pipe);
1198 if (WARN(ret, "vblank not available on crtc %i, ret=%i\n", pipe, ret))
1201 last = drm_vblank_count(dev, pipe);
1204 last != drm_vblank_count(dev, pipe));
1206 WARN(ret == 0, "vblank wait timed out on crtc %i\n", pipe);
1208 drm_vblank_put_locked(dev, pipe);
1241 unsigned int pipe = drm_crtc_index(crtc);
1242 struct drm_vblank_crtc *vblank = &dev->vblank[pipe];
1249 if (WARN_ON(pipe >= dev->num_crtcs))
1255 pipe, vblank->enabled, vblank->inmodeset);
1260 drm_vblank_disable_and_save(dev, pipe);
1274 seq = drm_vblank_count_and_time(dev, pipe, &now);
1277 if (e->pipe != pipe)
1283 drm_vblank_put(dev, pipe);
1310 unsigned int pipe = drm_crtc_index(crtc);
1311 struct drm_vblank_crtc *vblank = &dev->vblank[pipe];
1348 unsigned int pipe = drm_crtc_index(crtc);
1349 struct drm_vblank_crtc *vblank = &dev->vblank[pipe];
1371 unsigned int pipe = drm_crtc_index(crtc);
1372 struct drm_vblank_crtc *vblank = &dev->vblank[pipe];
1375 if (WARN_ON(pipe >= dev->num_crtcs))
1380 pipe, vblank->enabled, vblank->inmodeset);
1388 drm_reset_vblank_timestamp(dev, pipe);
1395 WARN_ON(drm_vblank_enable(dev, pipe));
1403 * @pipe: CRTC index
1413 void drm_vblank_restore(struct drm_device *dev, unsigned int pipe)
1422 if (WARN_ON(pipe >= dev->num_crtcs))
1428 vblank = &dev->vblank[pipe];
1434 cur_vblank = __get_vblank_counter(dev, pipe);
1435 drm_get_last_vbltimestamp(dev, pipe, &t_vblank, false);
1436 } while (cur_vblank != __get_vblank_counter(dev, pipe) && --count > 0);
1445 store_vblank(dev, pipe, diff, t_vblank, cur_vblank);
1466 unsigned int pipe)
1468 struct drm_vblank_crtc *vblank = &dev->vblank[pipe];
1474 if (WARN_ON(pipe >= dev->num_crtcs))
1486 if (drm_vblank_get(dev, pipe) == 0)
1492 unsigned int pipe)
1494 struct drm_vblank_crtc *vblank = &dev->vblank[pipe];
1501 if (WARN_ON(pipe >= dev->num_crtcs))
1506 drm_reset_vblank_timestamp(dev, pipe);
1510 drm_vblank_put(dev, pipe);
1520 unsigned int pipe;
1530 pipe = modeset->crtc;
1531 if (pipe >= dev->num_crtcs)
1536 drm_legacy_vblank_pre_modeset(dev, pipe);
1539 drm_legacy_vblank_post_modeset(dev, pipe);
1553 static int drm_queue_vblank_event(struct drm_device *dev, unsigned int pipe,
1558 struct drm_vblank_crtc *vblank = &dev->vblank[pipe];
1571 e->pipe = pipe;
1577 struct drm_crtc *crtc = drm_crtc_from_index(dev, pipe);
1601 seq = drm_vblank_count_and_time(dev, pipe, &now);
1604 req_seq, seq, pipe);
1606 trace_drm_vblank_event_queued(file_priv, pipe, req_seq);
1610 drm_vblank_put(dev, pipe);
1627 drm_vblank_put(dev, pipe);
1658 static void drm_wait_vblank_reply(struct drm_device *dev, unsigned int pipe,
1669 reply->sequence = drm_vblank_count_and_time(dev, pipe, &now);
1684 unsigned int flags, pipe, high_pipe;
1711 pipe = 0;
1718 pipe++;
1721 pipe = pipe_index;
1724 if (pipe >= dev->num_crtcs)
1727 vblank = &dev->vblank[pipe];
1735 drm_wait_vblank_reply(dev, pipe, &vblwait->reply);
1739 ret = drm_vblank_get(dev, pipe);
1741 DRM_DEBUG("crtc %d failed to acquire vblank counter, %d\n", pipe, ret);
1744 seq = drm_vblank_count(dev, pipe);
1771 return drm_queue_vblank_event(dev, pipe, req_seq, vblwait, file_priv);
1778 req_seq, pipe);
1782 (vblank_passed(drm_vblank_count(dev, pipe), req_seq) ||
1802 drm_wait_vblank_reply(dev, pipe, &vblwait->reply);
1805 pipe, vblwait->reply.sequence);
1807 DRM_DEBUG("crtc %d vblank wait interrupted by signal\n", pipe);
1811 drm_vblank_put(dev, pipe);
1815 static void drm_handle_vblank_events(struct drm_device *dev, unsigned int pipe)
1823 seq = drm_vblank_count_and_time(dev, pipe, &now);
1826 if (e->pipe != pipe)
1835 drm_vblank_put(dev, pipe);
1839 trace_drm_vblank_event(pipe, seq, now,
1846 * @pipe: index of CRTC where this event occurred
1853 bool drm_handle_vblank(struct drm_device *dev, unsigned int pipe)
1855 struct drm_vblank_crtc *vblank = &dev->vblank[pipe];
1862 if (WARN_ON(pipe >= dev->num_crtcs))
1880 drm_update_vblank_count(dev, pipe, true);
1895 drm_handle_vblank_events(dev, pipe);
1945 int pipe;
1961 pipe = drm_crtc_index(crtc);
1963 vblank = &dev->vblank[pipe];
1969 DRM_DEBUG("crtc %d failed to acquire vblank counter, %d\n", pipe, ret);
1979 get_seq->sequence = drm_vblank_count_and_time(dev, pipe, &now);
1999 int pipe;
2025 pipe = drm_crtc_index(crtc);
2027 vblank = &dev->vblank[pipe];
2035 DRM_DEBUG("crtc %d failed to acquire vblank counter, %d\n", pipe, ret);
2039 seq = drm_vblank_count_and_time(dev, pipe, &now);
2048 e->pipe = pipe;