forked from drath/libratbag
hidpp20: fetch active profile index only once
currently the active profile index is fetched for each profile, this adds unnecessary overhead. change the behavior to fetch the active profile only once during the driver data initialization.
This commit is contained in:
committed by
Peter Hutterer
parent
3ea0d44176
commit
48bccf4c98
@@ -1209,9 +1209,7 @@ hidpp20drv_read_profile_8100(struct ratbag_profile *profile)
|
||||
|
||||
profile->is_enabled = drv_data->profiles->profiles[profile->index].enabled;
|
||||
|
||||
profile->is_active = false;
|
||||
if ((int)profile->index == hidpp20drv_current_profile(device))
|
||||
profile->is_active = true;
|
||||
profile->is_active = (profile->index == drv_data->profiles->active_profile_index);
|
||||
|
||||
if (profile->is_active)
|
||||
dpi_index = hidpp20_onboard_profiles_get_current_dpi_index(drv_data->dev);
|
||||
|
||||
@@ -2244,8 +2244,7 @@ hidpp20_onboard_profiles_allocate(struct hidpp20_device *device,
|
||||
{
|
||||
struct hidpp20_onboard_profiles_info info = { 0 };
|
||||
struct hidpp20_profiles *profiles;
|
||||
int onboard_mode;
|
||||
int rc;
|
||||
int onboard_mode, active_profile_index, rc;
|
||||
|
||||
rc = hidpp20_onboard_profiles_get_profiles_desc(device, &info);
|
||||
if (rc)
|
||||
@@ -2269,6 +2268,12 @@ hidpp20_onboard_profiles_allocate(struct hidpp20_device *device,
|
||||
return rc;
|
||||
}
|
||||
|
||||
rc = hidpp20_onboard_profiles_get_current_profile(device);
|
||||
if (rc < 0)
|
||||
return rc;
|
||||
|
||||
active_profile_index = rc;
|
||||
|
||||
profiles = zalloc(sizeof(struct hidpp20_profiles));
|
||||
profiles->profiles = zalloc(info.profile_count * sizeof(struct hidpp20_profile));
|
||||
profiles->sector_size = info.sector_size;
|
||||
@@ -2280,6 +2285,7 @@ hidpp20_onboard_profiles_allocate(struct hidpp20_device *device,
|
||||
profiles->num_leds = HIDPP20_LED_COUNT;
|
||||
profiles->has_g_shift = (info.mechanical_layout & 0x03) == 0x02;
|
||||
profiles->has_dpi_shift = ((info.mechanical_layout & 0x0c) >> 2) == 0x02;
|
||||
profiles->active_profile_index = active_profile_index;
|
||||
switch(info.various_info & 0x07) {
|
||||
case 1:
|
||||
profiles->corded = 1;
|
||||
|
||||
@@ -915,6 +915,7 @@ struct hidpp20_profiles {
|
||||
uint8_t wireless;
|
||||
uint8_t sector_count;
|
||||
uint16_t sector_size;
|
||||
uint8_t active_profile_index;
|
||||
struct hidpp20_profile *profiles;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user