mirror of
https://github.com/hyprwm/wlroots-hyprland.git
synced 2024-11-26 06:35:58 +01:00
More accurate refresh rates (mHz)
This commit is contained in:
parent
c436e76240
commit
3000b8615f
2 changed files with 19 additions and 7 deletions
|
@ -249,6 +249,20 @@ static struct wlr_output_impl output_impl = {
|
||||||
.destroy = wlr_drm_output_destroy,
|
.destroy = wlr_drm_output_destroy,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static uint32_t calculate_refresh_rate(drmModeModeInfo *mode) {
|
||||||
|
uint32_t refresh = (mode->clock * 1000000LL / mode->htotal +
|
||||||
|
mode->vtotal / 2) / mode->vtotal;
|
||||||
|
|
||||||
|
if (mode->flags & DRM_MODE_FLAG_INTERLACE)
|
||||||
|
refresh *= 2;
|
||||||
|
if (mode->flags & DRM_MODE_FLAG_DBLSCAN)
|
||||||
|
refresh /= 2;
|
||||||
|
if (mode->vscan > 1)
|
||||||
|
refresh /= mode->vscan;
|
||||||
|
|
||||||
|
return refresh;
|
||||||
|
}
|
||||||
|
|
||||||
void wlr_drm_scan_connectors(struct wlr_backend_state *state) {
|
void wlr_drm_scan_connectors(struct wlr_backend_state *state) {
|
||||||
wlr_log(L_INFO, "Scanning DRM connectors");
|
wlr_log(L_INFO, "Scanning DRM connectors");
|
||||||
|
|
||||||
|
@ -321,14 +335,12 @@ void wlr_drm_scan_connectors(struct wlr_backend_state *state) {
|
||||||
struct wlr_output_mode *mode = calloc(1,
|
struct wlr_output_mode *mode = calloc(1,
|
||||||
sizeof(struct wlr_output_mode));
|
sizeof(struct wlr_output_mode));
|
||||||
mode->width = _state->mode.hdisplay;
|
mode->width = _state->mode.hdisplay;
|
||||||
// TODO: Calculate more accurate refresh rate
|
|
||||||
// TODO: Check that this refresh rate is mHz
|
|
||||||
mode->height = _state->mode.vdisplay;
|
mode->height = _state->mode.vdisplay;
|
||||||
|
mode->refresh = calculate_refresh_rate(&_state->mode);
|
||||||
mode->state = _state;
|
mode->state = _state;
|
||||||
|
|
||||||
wlr_log(L_INFO, " %"PRIu16"@%"PRIu16"@%"PRIu32,
|
wlr_log(L_INFO, " %"PRIu32"@%"PRIu32"@%"PRIu32,
|
||||||
_state->mode.hdisplay, _state->mode.vdisplay,
|
mode->width, mode->height, mode->refresh);
|
||||||
_state->mode.vrefresh);
|
|
||||||
|
|
||||||
list_add(wlr_output->modes, mode);
|
list_add(wlr_output->modes, mode);
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,8 +10,8 @@ struct wlr_output_mode_state;
|
||||||
struct wlr_output_mode {
|
struct wlr_output_mode {
|
||||||
struct wlr_output_mode_state *state;
|
struct wlr_output_mode_state *state;
|
||||||
uint32_t flags; // enum wl_output_mode
|
uint32_t flags; // enum wl_output_mode
|
||||||
int32_t width, height;
|
uint32_t width, height;
|
||||||
int32_t refresh; // mHz
|
uint32_t refresh; // mHz
|
||||||
};
|
};
|
||||||
|
|
||||||
struct wlr_output_impl;
|
struct wlr_output_impl;
|
||||||
|
|
Loading…
Reference in a new issue