sinowealth: use the detected LED count
I put this in a separate commit as 99% of this is just a change of
indentation levels, which doesn't look nice in git.
@@ -350,6 +350,7 @@ sinowealth_update_profile(struct ratbag_profile *profile)
}
/* Body lighting */
+ if (drv_data->led_count > 0) {
led = ratbag_profile_get_led(profile, 0);
switch (config->rgb_effect) {
case RGB_OFF:
@@ -376,6 +377,7 @@ sinowealth_update_profile(struct ratbag_profile *profile)
break;
}
ratbag_led_unref(led);
+ }
profile->is_active = true;
@@ -417,7 +419,7 @@ sinowealth_init_profile(struct ratbag_device *device)
unsigned int dpis[num_dpis];
/* TODO: Button remapping */
- ratbag_device_init_profiles(device, 1, SINOWEALTH_NUM_DPIS, 0, 1);
+ ratbag_device_init_profiles(device, 1, SINOWEALTH_NUM_DPIS, 0, drv_data->led_count);
profile = ratbag_device_get_profile(device, 0);
@@ -437,6 +439,7 @@ sinowealth_init_profile(struct ratbag_device *device)
ratbag_profile_set_report_rate_list(profile, report_rates, ARRAY_LENGTH(report_rates));
/* Set up LED capabilities */
+ if (drv_data->led_count > 0) {
led = ratbag_profile_get_led(profile, 0);
led->type = RATBAG_LED_TYPE_SIDE;
led->colordepth = RATBAG_LED_COLORDEPTH_RGB_888;
@@ -445,6 +448,7 @@ sinowealth_init_profile(struct ratbag_device *device)
ratbag_led_set_mode_capability(led, RATBAG_LED_CYCLE);
ratbag_led_set_mode_capability(led, RATBAG_LED_BREATHING);
ratbag_led_unref(led);
+ }
ratbag_profile_unref(profile);
@@ -563,6 +567,7 @@ sinowealth_commit(struct ratbag_device *device)
config->dpi_enabled = ~dpi_enabled; /* config->dpi_enabled is inverted */
/* Body lighting */
+ if (drv_data->led_count > 0) {
led = ratbag_profile_get_led(profile, 0);
switch(led->mode) {
case RATBAG_LED_OFF:
@@ -583,6 +588,7 @@ sinowealth_commit(struct ratbag_device *device)
break;
}
ratbag_led_unref(led);
+ }
config->config_write = drv_data->config_size - 8;
