mirror of
https://github.com/brl/mutter.git
synced 2025-06-13 16:59:30 +00:00
backends/native: Add meta_calculate_drm_mode_vblank_duration_us()
Computes the vblank duration from mode timings. Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1762>
This commit is contained in:

committed by
Marge Bot

parent
63b9ac2724
commit
e40ff9d8b7
@ -47,6 +47,27 @@ meta_calculate_drm_mode_refresh_rate (const drmModeModeInfo *drm_mode)
|
||||
return numerator / denominator;
|
||||
}
|
||||
|
||||
int64_t
|
||||
meta_calculate_drm_mode_vblank_duration_us (const drmModeModeInfo *drm_mode)
|
||||
{
|
||||
int64_t value;
|
||||
|
||||
if (drm_mode->htotal <= 0 || drm_mode->vtotal <= 0)
|
||||
return 0;
|
||||
|
||||
/* Convert to int64_t early. */
|
||||
value = drm_mode->vtotal - drm_mode->vdisplay;
|
||||
value *= drm_mode->htotal;
|
||||
|
||||
if (drm_mode->flags & DRM_MODE_FLAG_DBLSCAN)
|
||||
value *= 2;
|
||||
|
||||
/* Round the duration up as it is used for buffer swap deadline computation. */
|
||||
value = (value * 1000 + drm_mode->clock - 1) / drm_mode->clock;
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
/**
|
||||
* meta_drm_format_to_string:
|
||||
* @tmp: temporary buffer
|
||||
|
@ -34,6 +34,9 @@ typedef struct _MetaDrmFormatBuf
|
||||
META_EXPORT_TEST
|
||||
float meta_calculate_drm_mode_refresh_rate (const drmModeModeInfo *drm_mode);
|
||||
|
||||
META_EXPORT_TEST
|
||||
int64_t meta_calculate_drm_mode_vblank_duration_us (const drmModeModeInfo *drm_mode);
|
||||
|
||||
const char * meta_drm_format_to_string (MetaDrmFormatBuf *tmp,
|
||||
uint32_t drm_format);
|
||||
|
||||
|
Reference in New Issue
Block a user