driver-hidpp20: implement disabled resolutions
@@ -1008,6 +1008,13 @@ hidpp20drv_update_resolution_dpi(struct ratbag_resolution *resolution,
int i;
int dpi = dpi_x; /* dpi_x == dpi_y if we don't have the individual resolution cap */
+ if (resolution->is_disabled) {
+ if (!ratbag_resolution_has_capability(resolution, RATBAG_RESOLUTION_CAP_DISABLE))
+ return -ENOTSUP;
+
+ dpi = dpi_x = dpi_y = 0;
+ }
+
if (drv_data->capabilities & HIDPP_CAP_ONBOARD_PROFILES_8100)
return hidpp20drv_update_resolution_dpi_8100(resolution, dpi_x, dpi_y);
@@ -1020,6 +1027,7 @@ hidpp20drv_update_resolution_dpi(struct ratbag_resolution *resolution,
/* just for clarity, we use the first available sensor only */
sensor = &drv_data->sensors[0];
+ if (!resolution->is_disabled) {
/* validate that the sensor accepts the given DPI */
if (dpi < sensor->dpi_min || dpi > sensor->dpi_max)
return -EINVAL;
@@ -1037,6 +1045,7 @@ hidpp20drv_update_resolution_dpi(struct ratbag_resolution *resolution,
if (sensor->dpi_list[i] != dpi)
return -EINVAL;
}
+ }
return hidpp20_adjustable_dpi_set_sensor_dpi(drv_data->dev, sensor, dpi);
}
@@ -1214,6 +1223,7 @@ hidpp20drv_read_profile_8100(struct ratbag_profile *profile)
struct ratbag_resolution *res;
struct hidpp20_profile *p;
int dpi_index = 0xff;
+ int dpi;
profile->is_enabled = drv_data->profiles->profiles[profile->index].enabled;
@@ -1234,9 +1244,15 @@ hidpp20drv_read_profile_8100(struct ratbag_profile *profile)
* sensors is too niche to care about right now */
sensor = &drv_data->sensors[0];
- ratbag_resolution_set_resolution(res,
- p->dpi[res->index],
- p->dpi[res->index]);
+ dpi = p->dpi[res->index];
+
+ /* If the resolution is zero dpi it is disabled,
+ * but internally we set the minimum value */
+ if (dpi == 0) {
+ res->is_disabled = true;
+ dpi = sensor->dpi_min;
+ }
+ ratbag_resolution_set_resolution(res, dpi, dpi);
if (profile->is_active &&
res->index == (unsigned int)dpi_index)
@@ -1317,12 +1333,17 @@ hidpp20drv_read_profile(struct ratbag_profile *profile)
{
struct ratbag_device *device = profile->device;
struct hidpp20drv_data *drv_data = ratbag_get_drv_data(device);
+ struct ratbag_resolution *resolution;
struct ratbag_led *led;
struct ratbag_button *button;
if (drv_data->capabilities & HIDPP_CAP_ONBOARD_PROFILES_8100) {
hidpp20drv_read_profile_8100(profile);
ratbag_profile_set_cap(profile, RATBAG_PROFILE_CAP_DISABLE);
+
+ ratbag_profile_for_each_resolution(profile, resolution) {
+ ratbag_resolution_set_cap(resolution, RATBAG_RESOLUTION_CAP_DISABLE);
+ }
} else {
hidpp20drv_read_resolution_dpi(profile);
hidpp20drv_read_special_key_mouse(device);
