Move the ReportRate into the profile

We don't have mice that can do report rates per resolutions, so let's not
commit to that.

This is a DBus API break but also a break in ratbagd, piper will need to
update to fetch the rate/rates from the profile object now.

It's a ratbagctl break as well, ratbagctl info changes slightly and the
resolution is not argument anymore for the rate.

Fixes #645

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
This commit is contained in:
Peter Hutterer
2019-02-26 08:00:19 +10:00
parent 9f9f6294c3
commit bf127d4c68
23 changed files with 379 additions and 420 deletions

View File

@@ -428,7 +428,7 @@ etekcity_read_profile(struct ratbag_profile *profile)
struct etekcity_settings_report *setting_report;
uint8_t *buf;
unsigned int report_rate;
int dpi_x, dpi_y, hz;
int dpi_x, dpi_y;
int rc;
unsigned int report_rates[] = { 125, 250, 500, 1000 };
@@ -456,24 +456,24 @@ etekcity_read_profile(struct ratbag_profile *profile)
report_rate = 0;
}
ratbag_profile_set_report_rate_list(profile, report_rates,
ARRAY_LENGTH(report_rates));
ratbag_profile_set_report_rate(profile, report_rate);
ratbag_profile_for_each_resolution(profile, resolution) {
dpi_x = setting_report->xres[resolution->index] * 50;
dpi_y = setting_report->yres[resolution->index] * 50;
hz = report_rate;
if (!(setting_report->dpi_mask & (1 << resolution->index))) {
/* the profile is disabled, overwrite it */
dpi_x = 0;
dpi_y = 0;
hz = 0;
}
ratbag_resolution_set_resolution(resolution, dpi_x, dpi_y, hz);
ratbag_resolution_set_resolution(resolution, dpi_x, dpi_y);
ratbag_resolution_set_cap(resolution,
RATBAG_RESOLUTION_CAP_SEPARATE_XY_RESOLUTION);
resolution->is_active = (resolution->index == setting_report->current_dpi);
ratbag_resolution_set_report_rate_list(resolution, report_rates,
ARRAY_LENGTH(report_rates));
}
ratbag_profile_for_each_button(profile, button)

View File

@@ -978,6 +978,7 @@ gskill_read_resolutions(struct ratbag_profile *profile,
struct gskill_profile_report *report)
{
struct gskill_profile_data *pdata = profile_to_pdata(profile);
unsigned int rates[] = { 500, 1000 }; /* let's assume that is true */
int dpi_x, dpi_y, hz, i;
log_debug(profile->device->ratbag,
@@ -985,16 +986,17 @@ gskill_read_resolutions(struct ratbag_profile *profile,
profile->index, report->dpi_num);
hz = GSKILL_MAX_POLLING_RATE / (report->polling_rate + 1);
ratbag_profile_set_report_rate_list(profile, rates, ARRAY_LENGTH(rates));
ratbag_profile_set_report_rate(profile, hz);
for (i = 0; i < report->dpi_num; i++) {
_cleanup_resolution_ struct ratbag_resolution *resolution = NULL;
unsigned int rates[] = { 500, 1000 }; /* let's assume that is true */
dpi_x = report->dpi_levels[i].x * GSKILL_DPI_UNIT;
dpi_y = report->dpi_levels[i].y * GSKILL_DPI_UNIT;
resolution = ratbag_profile_get_resolution(profile, i);
ratbag_resolution_set_resolution(resolution, dpi_x, dpi_y, hz);
ratbag_resolution_set_resolution(resolution, dpi_x, dpi_y);
resolution->is_active = (i == report->current_dpi_level);
pdata->res_idx_to_dev_idx[i] = i;
@@ -1003,8 +1005,6 @@ gskill_read_resolutions(struct ratbag_profile *profile,
ratbag_resolution_set_dpi_list_from_range(resolution,
GSKILL_MIN_DPI, GSKILL_MAX_DPI);
ratbag_resolution_set_report_rate_list(resolution, rates,
ARRAY_LENGTH(rates));
}
}

View File

@@ -429,8 +429,7 @@ hidpp10drv_read_profile(struct ratbag_profile *profile)
ratbag_resolution_set_resolution(res,
p.dpi_modes[res->index].xres,
p.dpi_modes[res->index].yres,
p.refresh_rate);
p.dpi_modes[res->index].yres);
ratbag_resolution_set_cap(res,
RATBAG_RESOLUTION_CAP_SEPARATE_XY_RESOLUTION);
if (profile->is_active &&
@@ -458,10 +457,11 @@ hidpp10drv_read_profile(struct ratbag_profile *profile)
ratbag_resolution_set_dpi_list(res, dpis, hidpp10->dpi_count);
}
ratbag_resolution_set_report_rate_list(res, rates,
ARRAY_LENGTH(rates));
}
ratbag_profile_set_report_rate_list(profile, rates, ARRAY_LENGTH(rates));
ratbag_profile_set_report_rate(profile, p.refresh_rate);
ratbag_profile_for_each_button(profile, button)
hidpp10drv_read_button(button);

View File

@@ -805,7 +805,7 @@ hidpp20drv_read_resolution_dpi(struct ratbag_profile *profile)
sensor = &drv_data->sensors[0];
/* FIXME: retrieve the refresh rate */
ratbag_resolution_set_resolution(res, sensor->dpi, sensor->dpi, 0);
ratbag_resolution_set_resolution(res, sensor->dpi, sensor->dpi);
ratbag_resolution_set_dpi_list_from_range(res,
sensor->dpi_min,
sensor->dpi_max);
@@ -823,13 +823,11 @@ hidpp20drv_read_resolution_dpi(struct ratbag_profile *profile)
if (rc < 0)
return rc;
ratbag_profile_for_each_resolution(profile, res)
ratbag_resolution_set_report_rate_list(res,
drv_data->report_rates,
drv_data->num_report_rates);
ratbag_profile_set_report_rate_list(profile,
drv_data->report_rates,
drv_data->num_report_rates);
} else {
ratbag_profile_for_each_resolution(profile, res)
ratbag_resolution_set_report_rate_list(res, &default_rate, 1);
ratbag_profile_set_report_rate_list(profile, &default_rate, 1);
}
return 0;
@@ -1017,8 +1015,7 @@ hidpp20drv_read_profile_8100(struct ratbag_profile *profile)
ratbag_resolution_set_resolution(res,
p->dpi[res->index],
p->dpi[res->index],
p->report_rate);
p->dpi[res->index]);
if (profile->is_active &&
res->index == (unsigned int)dpi_index)
@@ -1032,10 +1029,12 @@ hidpp20drv_read_profile_8100(struct ratbag_profile *profile)
ratbag_resolution_set_dpi_list_from_range(res,
sensor->dpi_min,
sensor->dpi_max);
ratbag_resolution_set_report_rate_list(res,
drv_data->report_rates,
drv_data->num_report_rates);
}
ratbag_profile_set_report_rate_list(profile,
drv_data->report_rates,
drv_data->num_report_rates);
ratbag_profile_set_report_rate(profile, p->report_rate);
}
static void

View File

@@ -443,6 +443,9 @@ logitech_g300_read_profile(struct ratbag_profile *profile)
hz = logitech_g300_raw_to_frequency(report->frequency);
ratbag_profile_set_report_rate_list(profile, &hz, 1);
ratbag_profile_set_report_rate(profile, hz);
ratbag_profile_for_each_resolution(profile, resolution) {
struct logitech_g300_resolution *res =
&report->dpi_levels[resolution->index];
@@ -451,13 +454,11 @@ logitech_g300_read_profile(struct ratbag_profile *profile)
resolution->dpi_x = res->dpi * 250;
resolution->dpi_y = res->dpi * 250;
resolution->hz = hz;
resolution->is_default = res->is_default;
resolution->is_active = res->is_default;
ratbag_resolution_set_dpi_list(resolution, dpis,
ARRAY_LENGTH(dpis));
ratbag_resolution_set_report_rate_list(resolution, &hz, 1);
}
ratbag_profile_for_each_button(profile, button)
@@ -534,12 +535,13 @@ logitech_g300_write_profile(struct ratbag_profile *profile)
struct ratbag_led *led;
uint8_t *buf;
unsigned int hz;
int rc;
pdata = &drv_data->profile_data[profile->index];
report = &pdata->report;
report->frequency = logitech_g300_frequency_to_raw(profile->hz);
ratbag_profile_for_each_resolution(profile, resolution) {
struct logitech_g300_resolution *res =
&report->dpi_levels[resolution->index];
@@ -550,12 +552,6 @@ logitech_g300_write_profile(struct ratbag_profile *profile)
if (profile->is_active && resolution->is_active)
logitech_g300_set_current_resolution(device,
resolution->index);
/* The same hz is used for all resolutions */
if (resolution->index == 0) {
hz = resolution->hz;
report->frequency = logitech_g300_frequency_to_raw(hz);
}
}
list_for_each(button, &profile->buttons, link) {

View File

@@ -438,19 +438,19 @@ logitech_g600_read_profile(struct ratbag_profile *profile)
return;
}
ratbag_profile_set_report_rate_list(profile, report_rates,
ARRAY_LENGTH(report_rates));
ratbag_profile_set_report_rate(profile, 1000 / (report->frequency + 1));
ratbag_profile_for_each_resolution(profile, resolution) {
resolution->dpi_x = report->dpi[resolution->index] * 50;
resolution->dpi_y = report->dpi[resolution->index] * 50;
resolution->hz = 1000 / (report->frequency + 1);
resolution->is_default = report->dpi_default - 1U == resolution->index;
resolution->is_active = resolution->is_default;
ratbag_resolution_set_dpi_list_from_range(resolution,
LOGITECH_G600_DPI_MIN,
LOGITECH_G600_DPI_MAX);
ratbag_resolution_set_report_rate_list(resolution, report_rates,
ARRAY_LENGTH(report_rates));
}
ratbag_profile_for_each_button(profile, button)
@@ -531,6 +531,8 @@ logitech_g600_write_profile(struct ratbag_profile *profile)
pdata = &drv_data->profile_data[profile->index];
report = &pdata->report;
report->frequency = (1000 / profile->hz) - 1;
ratbag_profile_for_each_resolution(profile, resolution) {
report->dpi[resolution->index] = resolution->dpi_x / 50;
@@ -539,10 +541,6 @@ logitech_g600_write_profile(struct ratbag_profile *profile)
if (profile->is_active && resolution->is_active)
active_resolution = resolution->index;
/* The same hz is used for all resolutions */
if (resolution->index == 0)
report->frequency = (1000 / resolution->hz) - 1;
}
list_for_each(button, &profile->buttons, link) {

View File

@@ -702,7 +702,7 @@ roccat_read_profile(struct ratbag_profile *profile)
struct roccat_settings_report *setting_report;
uint8_t *buf;
unsigned int report_rate;
int dpi_x, dpi_y, hz;
int dpi_x, dpi_y;
int rc;
unsigned int report_rates[] = { 125, 250, 500, 1000 };
@@ -730,24 +730,24 @@ roccat_read_profile(struct ratbag_profile *profile)
report_rate = 0;
}
ratbag_profile_set_report_rate_list(profile, report_rates,
ARRAY_LENGTH(report_rates));
ratbag_profile_set_report_rate(profile, report_rate);
ratbag_profile_for_each_resolution(profile, resolution) {
dpi_x = setting_report->xres[resolution->index] * 50;
dpi_y = setting_report->yres[resolution->index] * 50;
hz = report_rate;
if (!(setting_report->dpi_mask & (1 << resolution->index))) {
/* the profile is disabled, overwrite it */
dpi_x = 0;
dpi_y = 0;
hz = 0;
}
ratbag_resolution_set_resolution(resolution, dpi_x, dpi_y, hz);
ratbag_resolution_set_resolution(resolution, dpi_x, dpi_y);
ratbag_resolution_set_cap(resolution,
RATBAG_RESOLUTION_CAP_SEPARATE_XY_RESOLUTION);
resolution->is_active = (resolution->index == setting_report->current_dpi);
ratbag_resolution_set_report_rate_list(resolution, report_rates,
ARRAY_LENGTH(report_rates));
ratbag_resolution_set_dpi_list_from_range(resolution, 200, 8200);
}

View File

@@ -307,6 +307,9 @@ steelseries_probe(struct ratbag_device *device)
profile->is_active = true;
ratbag_profile_set_cap(profile, RATBAG_PROFILE_CAP_WRITE_ONLY);
ratbag_profile_set_report_rate_list(profile, report_rates,
ARRAY_LENGTH(report_rates));
ratbag_profile_set_report_rate(profile, 1000);
ratbag_profile_for_each_resolution(profile, resolution) {
if (resolution->index == 0) {
@@ -327,10 +330,6 @@ steelseries_probe(struct ratbag_device *device)
* by all known devices. */
resolution->dpi_x = 800 * (resolution->index + 1);
resolution->dpi_y = 800 * (resolution->index + 1);
ratbag_resolution_set_report_rate_list(resolution, report_rates,
ARRAY_LENGTH(report_rates));
resolution->hz = 1000;
}
ratbag_profile_for_each_button(profile, button) {
@@ -434,9 +433,9 @@ steelseries_write_dpi(struct ratbag_resolution *resolution)
}
static int
steelseries_write_report_rate(struct ratbag_resolution *resolution)
steelseries_write_report_rate(struct ratbag_profile *profile)
{
struct ratbag_device *device = resolution->profile->device;
struct ratbag_device *device = profile->device;
int device_version = ratbag_device_data_steelseries_get_device_version(device->data);
int ret;
size_t buf_len;
@@ -445,15 +444,15 @@ steelseries_write_report_rate(struct ratbag_resolution *resolution)
if (device_version == 1) {
buf_len = STEELSERIES_REPORT_SIZE_SHORT;
buf[0] = STEELSERIES_ID_REPORT_RATE_SHORT;
buf[2] = 1000 / resolution->hz;
buf[2] = 1000 / profile->hz;
} else if (device_version == 2) {
buf_len = STEELSERIES_REPORT_SIZE;
buf[0] = STEELSERIES_ID_REPORT_RATE;
buf[2] = 1000 / resolution->hz;
buf[2] = 1000 / profile->hz;
} else if (device_version == 3) {
buf_len = STEELSERIES_REPORT_SIZE;
buf[0] = STEELSERIES_ID_REPORT_RATE_PROTOCOL3;
buf[2] = 1000 / resolution->hz;
buf[2] = 1000 / profile->hz;
} else {
return -ENOTSUP;
}
@@ -882,6 +881,10 @@ steelseries_write_profile(struct ratbag_profile *profile)
int rc;
bool buttons_dirty = false;
rc = steelseries_write_report_rate(profile);
if (rc != 0)
return rc;
ratbag_profile_for_each_resolution(profile, resolution) {
if (!resolution->dirty)
continue;
@@ -894,9 +897,6 @@ steelseries_write_profile(struct ratbag_profile *profile)
if (resolution->index > 0)
continue;
rc = steelseries_write_report_rate(resolution);
if (rc != 0)
return rc;
}
ratbag_profile_for_each_button(profile, button) {

View File

@@ -175,6 +175,7 @@ test_read_profile(struct ratbag_profile *profile)
unsigned int i;
bool active_set = false;
bool default_set = false;
size_t nrates = 0;
assert(profile->index < d->num_profiles);
@@ -182,29 +183,30 @@ test_read_profile(struct ratbag_profile *profile)
p0 = &d->profiles[0];
r0 = &p0->resolutions[0];
for (size_t r = 0; r < ARRAY_LENGTH(p0->report_rates); r++) {
if (p0->report_rates[r] > 0)
nrates++;
}
if (nrates > 0)
ratbag_profile_set_report_rate_list(profile,
p0->report_rates,
nrates);
ratbag_profile_set_report_rate(profile, p->hz);
for (i = 0; i < d->num_resolutions; i++) {
_cleanup_resolution_ struct ratbag_resolution *res = NULL;
size_t nrates = 0;
r = &p->resolutions[i];
res = ratbag_profile_get_resolution(profile, i);
assert(res);
ratbag_resolution_set_resolution(res, r->xres, r->yres, r->hz);
ratbag_resolution_set_resolution(res, r->xres, r->yres);
if (r0->dpi_min != 0 && r0->dpi_max != 0)
ratbag_resolution_set_dpi_list_from_range(res,
r0->dpi_min,
r0->dpi_max);
for (size_t r = 0; r < ARRAY_LENGTH(r0->report_rates); r++) {
if (r0->report_rates[r] > 0)
nrates++;
}
if (nrates > 0)
ratbag_resolution_set_report_rate_list(res,
r0->report_rates,
nrates);
res->is_active = r->active;
if (r->active)
@@ -213,7 +215,6 @@ test_read_profile(struct ratbag_profile *profile)
if (r->dflt)
default_set = true;
ratbag_resolution_set_cap(res, r->caps);
res->hz = r->hz;
}
/* special case triggered by the test suite when num_resolutions is 0 */

View File

@@ -125,17 +125,10 @@ enum ratbag_profile_capability {
* @ingroup enums
*/
enum ratbag_resolution_capability {
/**
* The report rate can be set per resolution mode. If this property
* is not available, all resolutions within the same profile have
* the same report rate and changing one changes the others.
*/
RATBAG_RESOLUTION_CAP_INDIVIDUAL_REPORT_RATE = 1,
/**
* The resolution can be set for x and y separately.
*/
RATBAG_RESOLUTION_CAP_SEPARATE_XY_RESOLUTION,
RATBAG_RESOLUTION_CAP_SEPARATE_XY_RESOLUTION = 1,
};
/**

View File

@@ -250,10 +250,7 @@ struct ratbag_resolution {
unsigned int dpi_x; /**< x resolution in dpi */
unsigned int dpi_y; /**< y resolution in dpi */
unsigned int hz; /**< report rate in Hz */
unsigned int rates[8];
size_t nrates;
bool is_active;
bool is_default;
@@ -291,6 +288,10 @@ struct ratbag_profile {
struct list resolutions;
struct list leds;
unsigned int hz; /**< report rate in Hz */
unsigned int rates[8]; /**< report rates available */
size_t nrates; /**< number of entries in rates */
unsigned int num_resolutions;
bool is_active; /**< profile is the currently active one */
@@ -485,11 +486,10 @@ ratbag_action_keycode_from_macro(struct ratbag_button_action *action,
static inline void
ratbag_resolution_set_resolution(struct ratbag_resolution *res,
int dpi_x, int dpi_y, int hz)
int dpi_x, int dpi_y)
{
res->dpi_x = dpi_x;
res->dpi_y = dpi_y;
res->hz = hz;
}
static inline void
@@ -546,19 +546,19 @@ ratbag_resolution_set_dpi_list(struct ratbag_resolution *res,
}
static inline void
ratbag_resolution_set_report_rate_list(struct ratbag_resolution *res,
unsigned int *rates,
size_t nrates)
ratbag_profile_set_report_rate_list(struct ratbag_profile *profile,
unsigned int *rates,
size_t nrates)
{
assert(nrates <= ARRAY_LENGTH(res->rates));
_Static_assert(sizeof(*rates) == sizeof(*res->rates), "Mismatching size");
assert(nrates <= ARRAY_LENGTH(profile->rates));
_Static_assert(sizeof(*rates) == sizeof(*profile->rates), "Mismatching size");
for (size_t i = 0; i < nrates; i++) {
res->rates[i] = rates[i];
profile->rates[i] = rates[i];
if (i > 0)
assert(rates[i] > rates[i - 1]);
}
res->nrates = nrates;
profile->nrates = nrates;
}
static inline void

View File

@@ -51,13 +51,11 @@ struct ratbag_test_button {
struct ratbag_test_resolution {
int xres, yres;
int hz;
bool active;
bool dflt;
uint32_t caps;
int dpi_min, dpi_max;
unsigned int report_rates[5];
};
struct ratbag_test_color {
@@ -83,6 +81,9 @@ struct ratbag_test_profile {
bool dflt;
bool disabled;
uint32_t caps[10];
int hz;
unsigned int report_rates[5];
};
struct ratbag_test_device {

View File

@@ -241,6 +241,8 @@ ratbag_sanity_check_device(struct ratbag_device *device)
ratbag_device_for_each_profile(device, profile) {
struct ratbag_resolution *resolution;
unsigned int vals[300];
unsigned int nvals = ARRAY_LENGTH(vals);
/* Allow max 1 active profile */
if (profile->is_active) {
@@ -263,9 +265,6 @@ ratbag_sanity_check_device(struct ratbag_device *device)
}
ratbag_profile_for_each_resolution(profile, resolution) {
unsigned int vals[300];
unsigned int nvals = ARRAY_LENGTH(vals);
nvals = ratbag_resolution_get_dpi_list(resolution, vals, nvals);
if (nvals == 0) {
log_bug_libratbag(ratbag,
@@ -274,13 +273,14 @@ ratbag_sanity_check_device(struct ratbag_device *device)
goto out;
}
nvals = ratbag_resolution_get_report_rate_list(resolution, vals, nvals);
if (nvals == 0) {
log_bug_libratbag(ratbag,
"%s: invalid report rate list\n",
device->name);
goto out;
}
}
nvals = ratbag_profile_get_report_rate_list(profile, vals, nvals);
if (nvals == 0) {
log_bug_libratbag(ratbag,
"%s: invalid report rate list\n",
device->name);
goto out;
}
}
@@ -1028,7 +1028,6 @@ ratbag_resolution_has_capability(struct ratbag_resolution *resolution,
enum ratbag_resolution_capability cap)
{
switch (cap) {
case RATBAG_RESOLUTION_CAP_INDIVIDUAL_REPORT_RATE:
case RATBAG_RESOLUTION_CAP_SEPARATE_XY_RESOLUTION:
break;
default:
@@ -1096,29 +1095,12 @@ ratbag_resolution_set_dpi_xy(struct ratbag_resolution *resolution,
}
LIBRATBAG_EXPORT enum ratbag_error_code
ratbag_resolution_set_report_rate(struct ratbag_resolution *resolution,
unsigned int hz)
ratbag_profile_set_report_rate(struct ratbag_profile *profile,
unsigned int hz)
{
if (ratbag_resolution_has_capability(resolution,
RATBAG_RESOLUTION_CAP_INDIVIDUAL_REPORT_RATE)) {
if (resolution->hz != hz) {
resolution->hz = hz;
resolution->dirty = true;
resolution->profile->dirty = true;
}
} else {
struct ratbag_profile *profile = resolution->profile;
struct ratbag_resolution *res;
/* No indvidual report rate per resolution. Loop through all of
* them and update. */
ratbag_profile_for_each_resolution(profile, res) {
if (res->hz != hz) {
res->hz = hz;
res->dirty = true;
profile->dirty = true;
}
}
if (profile->hz != hz) {
profile->hz = hz;
profile->dirty = true;
}
return RATBAG_SUCCESS;
@@ -1161,27 +1143,27 @@ ratbag_resolution_get_dpi_y(struct ratbag_resolution *resolution)
}
LIBRATBAG_EXPORT int
ratbag_resolution_get_report_rate(struct ratbag_resolution *resolution)
ratbag_profile_get_report_rate(struct ratbag_profile *profile)
{
return resolution->hz;
return profile->hz;
}
LIBRATBAG_EXPORT size_t
ratbag_resolution_get_report_rate_list(struct ratbag_resolution *resolution,
unsigned int *rates,
size_t nrates)
ratbag_profile_get_report_rate_list(struct ratbag_profile *profile,
unsigned int *rates,
size_t nrates)
{
_Static_assert(sizeof(*rates) == sizeof(*resolution->rates), "type mismatch");
_Static_assert(sizeof(*rates) == sizeof(*profile->rates), "type mismatch");
assert(nrates > 0);
if (resolution->nrates == 0)
if (profile->nrates == 0)
return 0;
memcpy(rates, resolution->rates,
sizeof(unsigned int) * min(nrates, resolution->nrates));
memcpy(rates, profile->rates,
sizeof(unsigned int) * min(nrates, profile->nrates));
return resolution->nrates;
return profile->nrates;
}
LIBRATBAG_EXPORT bool

View File

@@ -685,6 +685,61 @@ ratbag_profile_is_active(struct ratbag_profile *profile);
enum ratbag_error_code
ratbag_profile_set_active(struct ratbag_profile *profile);
/**
* @ingroup profile
*
* Set the report rate in Hz for the profile.
*
* A value of 0 hz disables the mode.
*
* If the profile mode is the currently active profile,
* the change takes effect immediately.
*
* @param profile A previously initialized ratbag profile
* @param hz Set to the report rate in Hz, may be 0
*
* @return zero on success or an error code on failure
*/
enum ratbag_error_code
ratbag_profile_set_report_rate(struct ratbag_profile *profile,
unsigned int hz);
/**
* @ingroup profile
*
* Get the report rate in Hz for the profile.
*
* @param profile A previously initialized ratbag profile
*
* @return The report rate for this profile in Hz
*/
int
ratbag_profile_get_report_rate(struct ratbag_profile *profile);
/**
* @ingroup profile
*
* Get the number of report rates in Hz available for this profile.
* The list of report rates is sorted in ascending order but may be filtered
* by libratbag and does not necessarily reflect all report rates supported by
* the physical device.
*
* This function writes at most nrates values but returns the number of
* report rates available on this resolution. In other words, if it returns a
* number larger than nrates, call it again with an array the size of the
* return value.
*
* @param[out] rates Set to the supported report rates in ascending order
* @param[in] nrates The number of elements in resolutions
*
* @return The number of valid items in rates. If the returned value
* is larger than nrates, the list was truncated.
*/
size_t
ratbag_profile_get_report_rate_list(struct ratbag_profile *profile,
unsigned int *rates,
size_t nrates);
/**
* @ingroup profile
*
@@ -913,67 +968,6 @@ ratbag_resolution_get_dpi_x(struct ratbag_resolution *resolution);
int
ratbag_resolution_get_dpi_y(struct ratbag_resolution *resolution);
/**
* @ingroup resolution
*
* Set the report rate in Hz for the resolution mode.
*
* A value of 0 hz disables the mode.
*
* If the resolution mode is the currently active mode and the profile is
* the currently active profile, the change takes effect immediately.
*
* If the resolution does not have the @ref
* RATBAG_RESOLUTION_CAP_INDIVIDUAL_REPORT_RATE capability, changing the
* report rate on one resolution changes the report rate for all resolutions
* in this profile.
*
* @param resolution A previously initialized ratbag resolution
* @param hz Set to the report rate in Hz, may be 0
*
* @return zero on success or an error code on failure
*/
enum ratbag_error_code
ratbag_resolution_set_report_rate(struct ratbag_resolution *resolution,
unsigned int hz);
/**
* @ingroup resolution
*
* Get the report rate in Hz for the resolution mode.
*
* A value of 0 hz indicates the mode is disabled.
*
* @param resolution A previously initialized ratbag resolution
*
* @return The report rate for this resolution in Hz
*/
int
ratbag_resolution_get_report_rate(struct ratbag_resolution *resolution);
/**
* @ingroup resolution
*
* Get the number of report rates in Hz available for this resolution.
* The list of report rates is sorted in ascending order but may be filtered
* by libratbag and does not necessarily reflect all report rates supported by
* the physical device.
*
* This function writes at most nrates values but returns the number of
* report rates available on this resolution. In other words, if it returns a
* number larger than nrates, call it again with an array the size of the
* return value.
*
* @param[out] rates Set to the supported report rates in ascending order
* @param[in] nrates The number of elements in resolutions
*
* @return The number of valid items in rates. If the returned value
* is larger than nrates, the list was truncated.
*/
size_t
ratbag_resolution_get_report_rate_list(struct ratbag_resolution *resolution,
unsigned int *rates,
size_t nrates);
/**
* @ingroup resolution
*