From 3cfda944d00e6711f1cf9c2df00fcdf93ab9795f Mon Sep 17 00:00:00 2001 From: Thomas Hindoe Paaboel Andersen Date: Fri, 28 Oct 2016 00:25:47 +0200 Subject: [PATCH] Update report rate on all resolutions if needed For drivers without the capability RATBAG_RESOLUTION_CAP_INDIVIDUAL_REPORT_RATE we should update the report rate on all resolutions. --- src/libratbag.c | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/src/libratbag.c b/src/libratbag.c index 6aa74076..4e93f070 100644 --- a/src/libratbag.c +++ b/src/libratbag.c @@ -955,9 +955,25 @@ LIBRATBAG_EXPORT enum ratbag_error_code ratbag_resolution_set_report_rate(struct ratbag_resolution *resolution, unsigned int hz) { - if (resolution->hz != hz) { - resolution->hz = hz; - resolution->profile->dirty = true; + if (ratbag_resolution_has_capability(resolution, + RATBAG_RESOLUTION_CAP_INDIVIDUAL_REPORT_RATE)) { + if (resolution->hz != hz) { + resolution->hz = hz; + resolution->profile->dirty = true; + } + } else { + struct ratbag_profile *profile = resolution->profile; + unsigned int i; + + /* No indvidual report rate per resolution. Loop through all of + * them and update. */ + for (i = 0; i < profile->resolution.num_modes; i++) { + struct ratbag_resolution *res = &profile->resolution.modes[i]; + if (res->hz != hz) { + res->hz = hz; + profile->dirty = true; + } + } } return RATBAG_SUCCESS;