1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
// SPDX-FileCopyrightText: (c) 2026 Joel Winarske
// SPDX-License-Identifier: MIT
//! The CRTC's vblank counter, as `drmCrtcGetSequence` reads it.
//!
//! The `drm` crate binds `DRM_IOCTL_WAIT_VBLANK`, whose sequence is 32 bits,
//! but not `DRM_IOCTL_CRTC_GET_SEQUENCE`, which is what upstream reads. The
//! wider counter is the one to compare against: a 32-bit one wraps in a little
//! over two years at 60 Hz, and a comparison across the wrap goes backwards.
use AsFd;
use drm_crtc_get_sequence;
use crate;
/// `DRM_IOCTL_CRTC_GET_SEQUENCE`, i.e. `DRM_IOWR(0x3b, struct
/// drm_crtc_get_sequence)` with `DRM_IOCTL_BASE == 'd'`.
const CRTC_GET_SEQUENCE: Opcode =
;
/// The CRTC's current vblank sequence.
///
/// Port of `drmCrtcGetSequence` without the timestamp. The count moves once per
/// vblank while the CRTC is active, so a flip committed when it read `n` has
/// landed once it reads more than `n`.
///
/// # Errors
///
/// [`CoreError::Io`] if the ioctl fails: `EINVAL` for a CRTC id the device
/// does not have, `EOPNOTSUPP` on a driver without vblank support.
/// Whether an event -- a page-flip completion, a vblank -- is queued on the
/// device, without reading it.
///
/// A zero-timeout `poll`, so the event stays for whoever dispatches it. The
/// kernel queues a flip event only once the flip has landed, which makes this
/// the second sign of a landed flip beside [`crtc_sequence`]: a driver that
/// completes the flip inside the commit (the SA8155P) moves the sequence
/// before the caller can read it, and not again until the next commit
/// (drm-cxx `42287bd`). `false` if the poll fails.