diff options
author | Ville Syrjälä <ville.syrjala@linux.intel.com> | 2018-11-06 17:46:23 +0200 |
---|---|---|
committer | Ville Syrjälä <ville.syrjala@linux.intel.com> | 2019-03-11 22:02:35 +0200 |
commit | 0cf3d67a5a96f0a913acd73034672b1f474922eb (patch) | |
tree | 5f480d26ff06cb1eeb49b72997514cc0b8b9cc1b /lib/igt_kms.h | |
parent | 34b87e110fbe0d33273a1669c8b5fc6c3a891218 (diff) |
lib/debugfs: Fix wraparound handling for crc frame counter check
Deal with frame counter wraparound correcrtly.
v2: Make the comparison functions available for everyone (Chris)
Add some docs (gtk-doc seems obtuse so not 100% warning free)
Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch> #v1
Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
Diffstat (limited to 'lib/igt_kms.h')
-rw-r--r-- | lib/igt_kms.h | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/lib/igt_kms.h b/lib/igt_kms.h index a29ad783..3c602576 100644 --- a/lib/igt_kms.h +++ b/lib/igt_kms.h @@ -767,4 +767,64 @@ void igt_cleanup_hotplug(struct udev_monitor *mon); bool igt_display_has_format_mod(igt_display_t *display, uint32_t format, uint64_t modifier); bool igt_plane_has_format_mod(igt_plane_t *plane, uint32_t format, uint64_t modifier); +/** + * igt_vblank_after_eq: + * @a: First vblank sequence number. + * @b: Second vblank sequence number. + * + * Compare vblank sequence numbers, + * handling wraparound correctly. + * + * Returns: @a >= @b + */ +static inline bool igt_vblank_after_eq(uint32_t a, uint32_t b) +{ + return (int32_t)(a - b) >= 0; +} + +/** + * igt_vblank_before_eq: + * @a: First vblank sequence number. + * @b: Second vblank sequence number. + * + * Compare vblank sequence numbers, + * handling wraparound correctly. + * + * Returns: @a <= @b + */ +static inline bool igt_vblank_before_eq(uint32_t a, uint32_t b) +{ + return igt_vblank_after_eq(b, a); +} + +/** + * igt_vblank_after: + * @a: First vblank sequence number. + * @b: Second vblank sequence number. + * + * Compare vblank sequence numbers, + * handling wraparound correctly. + * + * Returns: @a > @b + */ +static inline bool igt_vblank_after(uint32_t a, uint32_t b) +{ + return (int32_t)(b - a) < 0; +} + +/** + * igt_vblank_before: + * @a: First vblank sequence number. + * @b: Second vblank sequence number. + * + * Compare vblank sequence numbers, + * handling wraparound correctly. + * + * Returns: @a < @b + */ +static inline bool igt_vblank_before(uint32_t a, uint32_t b) +{ + return igt_vblank_after(b, a); +} + #endif /* __IGT_KMS_H__ */ |