Lines Matching refs:ctl
813 static int wm_coeff_base_reg(struct wm_coeff_ctl *ctl, unsigned int *reg) in wm_coeff_base_reg() argument
815 const struct wm_adsp_alg_region *alg_region = &ctl->alg_region; in wm_coeff_base_reg()
816 struct wm_adsp *dsp = ctl->dsp; in wm_coeff_base_reg()
826 *reg = wm_adsp_region_to_reg(mem, ctl->alg_region.base + ctl->offset); in wm_coeff_base_reg()
836 struct wm_coeff_ctl *ctl = bytes_ext_to_ctl(bytes_ext); in wm_coeff_info() local
838 switch (ctl->type) { in wm_coeff_info()
848 uinfo->count = ctl->len; in wm_coeff_info()
855 static int wm_coeff_write_acked_control(struct wm_coeff_ctl *ctl, in wm_coeff_write_acked_control() argument
858 struct wm_adsp *dsp = ctl->dsp; in wm_coeff_write_acked_control()
863 ret = wm_coeff_base_reg(ctl, ®); in wm_coeff_write_acked_control()
868 event_id, ctl->alg_region.alg, in wm_coeff_write_acked_control()
869 wm_adsp_mem_region_name(ctl->alg_region.type), ctl->offset); in wm_coeff_write_acked_control()
908 reg, ctl->alg_region.alg, in wm_coeff_write_acked_control()
909 wm_adsp_mem_region_name(ctl->alg_region.type), in wm_coeff_write_acked_control()
910 ctl->offset); in wm_coeff_write_acked_control()
915 static int wm_coeff_write_control(struct wm_coeff_ctl *ctl, in wm_coeff_write_control() argument
918 struct wm_adsp *dsp = ctl->dsp; in wm_coeff_write_control()
923 ret = wm_coeff_base_reg(ctl, ®); in wm_coeff_write_control()
951 struct wm_coeff_ctl *ctl = bytes_ext_to_ctl(bytes_ext); in wm_coeff_put() local
955 mutex_lock(&ctl->dsp->pwr_lock); in wm_coeff_put()
957 if (ctl->flags & WMFW_CTL_FLAG_VOLATILE) in wm_coeff_put()
960 memcpy(ctl->cache, p, ctl->len); in wm_coeff_put()
962 ctl->set = 1; in wm_coeff_put()
963 if (ctl->enabled && ctl->dsp->running) in wm_coeff_put()
964 ret = wm_coeff_write_control(ctl, p, ctl->len); in wm_coeff_put()
966 mutex_unlock(&ctl->dsp->pwr_lock); in wm_coeff_put()
976 struct wm_coeff_ctl *ctl = bytes_ext_to_ctl(bytes_ext); in wm_coeff_tlv_put() local
979 mutex_lock(&ctl->dsp->pwr_lock); in wm_coeff_tlv_put()
981 if (copy_from_user(ctl->cache, bytes, size)) { in wm_coeff_tlv_put()
984 ctl->set = 1; in wm_coeff_tlv_put()
985 if (ctl->enabled && ctl->dsp->running) in wm_coeff_tlv_put()
986 ret = wm_coeff_write_control(ctl, ctl->cache, size); in wm_coeff_tlv_put()
987 else if (ctl->flags & WMFW_CTL_FLAG_VOLATILE) in wm_coeff_tlv_put()
991 mutex_unlock(&ctl->dsp->pwr_lock); in wm_coeff_tlv_put()
1001 struct wm_coeff_ctl *ctl = bytes_ext_to_ctl(bytes_ext); in wm_coeff_put_acked() local
1008 mutex_lock(&ctl->dsp->pwr_lock); in wm_coeff_put_acked()
1010 if (ctl->enabled && ctl->dsp->running) in wm_coeff_put_acked()
1011 ret = wm_coeff_write_acked_control(ctl, val); in wm_coeff_put_acked()
1015 mutex_unlock(&ctl->dsp->pwr_lock); in wm_coeff_put_acked()
1020 static int wm_coeff_read_control(struct wm_coeff_ctl *ctl, in wm_coeff_read_control() argument
1023 struct wm_adsp *dsp = ctl->dsp; in wm_coeff_read_control()
1028 ret = wm_coeff_base_reg(ctl, ®); in wm_coeff_read_control()
1056 struct wm_coeff_ctl *ctl = bytes_ext_to_ctl(bytes_ext); in wm_coeff_get() local
1060 mutex_lock(&ctl->dsp->pwr_lock); in wm_coeff_get()
1062 if (ctl->flags & WMFW_CTL_FLAG_VOLATILE) { in wm_coeff_get()
1063 if (ctl->enabled && ctl->dsp->running) in wm_coeff_get()
1064 ret = wm_coeff_read_control(ctl, p, ctl->len); in wm_coeff_get()
1068 if (!ctl->flags && ctl->enabled && ctl->dsp->running) in wm_coeff_get()
1069 ret = wm_coeff_read_control(ctl, ctl->cache, ctl->len); in wm_coeff_get()
1071 memcpy(p, ctl->cache, ctl->len); in wm_coeff_get()
1074 mutex_unlock(&ctl->dsp->pwr_lock); in wm_coeff_get()
1084 struct wm_coeff_ctl *ctl = bytes_ext_to_ctl(bytes_ext); in wm_coeff_tlv_get() local
1087 mutex_lock(&ctl->dsp->pwr_lock); in wm_coeff_tlv_get()
1089 if (ctl->flags & WMFW_CTL_FLAG_VOLATILE) { in wm_coeff_tlv_get()
1090 if (ctl->enabled && ctl->dsp->running) in wm_coeff_tlv_get()
1091 ret = wm_coeff_read_control(ctl, ctl->cache, size); in wm_coeff_tlv_get()
1095 if (!ctl->flags && ctl->enabled && ctl->dsp->running) in wm_coeff_tlv_get()
1096 ret = wm_coeff_read_control(ctl, ctl->cache, size); in wm_coeff_tlv_get()
1099 if (!ret && copy_to_user(bytes, ctl->cache, size)) in wm_coeff_tlv_get()
1102 mutex_unlock(&ctl->dsp->pwr_lock); in wm_coeff_tlv_get()
1124 struct wm_coeff_ctl *ctl; member
1160 static int wmfw_add_ctl(struct wm_adsp *dsp, struct wm_coeff_ctl *ctl) in wmfw_add_ctl() argument
1165 if (!ctl || !ctl->name) in wmfw_add_ctl()
1172 kcontrol->name = ctl->name; in wmfw_add_ctl()
1176 kcontrol->private_value = (unsigned long)&ctl->bytes_ext; in wmfw_add_ctl()
1177 kcontrol->access = wmfw_convert_flags(ctl->flags, ctl->len); in wmfw_add_ctl()
1179 switch (ctl->type) { in wmfw_add_ctl()
1186 ctl->bytes_ext.max = ctl->len; in wmfw_add_ctl()
1187 ctl->bytes_ext.get = wm_coeff_tlv_get; in wmfw_add_ctl()
1188 ctl->bytes_ext.put = wm_coeff_tlv_put; in wmfw_add_ctl()
1211 struct wm_coeff_ctl *ctl; in wm_coeff_init_control_caches() local
1214 list_for_each_entry(ctl, &dsp->ctl_list, list) { in wm_coeff_init_control_caches()
1215 if (!ctl->enabled || ctl->set) in wm_coeff_init_control_caches()
1217 if (ctl->flags & WMFW_CTL_FLAG_VOLATILE) in wm_coeff_init_control_caches()
1225 if (!ctl->flags || (ctl->flags & WMFW_CTL_FLAG_READABLE)) { in wm_coeff_init_control_caches()
1226 ret = wm_coeff_read_control(ctl, ctl->cache, ctl->len); in wm_coeff_init_control_caches()
1237 struct wm_coeff_ctl *ctl; in wm_coeff_sync_controls() local
1240 list_for_each_entry(ctl, &dsp->ctl_list, list) { in wm_coeff_sync_controls()
1241 if (!ctl->enabled) in wm_coeff_sync_controls()
1243 if (ctl->set && !(ctl->flags & WMFW_CTL_FLAG_VOLATILE)) { in wm_coeff_sync_controls()
1244 ret = wm_coeff_write_control(ctl, ctl->cache, ctl->len); in wm_coeff_sync_controls()
1256 struct wm_coeff_ctl *ctl; in wm_adsp_signal_event_controls() local
1259 list_for_each_entry(ctl, &dsp->ctl_list, list) { in wm_adsp_signal_event_controls()
1260 if (ctl->type != WMFW_CTL_TYPE_HOSTEVENT) in wm_adsp_signal_event_controls()
1263 if (!ctl->enabled) in wm_adsp_signal_event_controls()
1266 ret = wm_coeff_write_acked_control(ctl, event); in wm_adsp_signal_event_controls()
1270 event, ctl->alg_region.alg, ret); in wm_adsp_signal_event_controls()
1280 wmfw_add_ctl(ctl_work->dsp, ctl_work->ctl); in wm_adsp_ctl_work()
1284 static void wm_adsp_free_ctl_blk(struct wm_coeff_ctl *ctl) in wm_adsp_free_ctl_blk() argument
1286 kfree(ctl->cache); in wm_adsp_free_ctl_blk()
1287 kfree(ctl->name); in wm_adsp_free_ctl_blk()
1288 kfree(ctl); in wm_adsp_free_ctl_blk()
1297 struct wm_coeff_ctl *ctl; in wm_adsp_create_control() local
1338 list_for_each_entry(ctl, &dsp->ctl_list, list) { in wm_adsp_create_control()
1339 if (!strcmp(ctl->name, name)) { in wm_adsp_create_control()
1340 if (!ctl->enabled) in wm_adsp_create_control()
1341 ctl->enabled = 1; in wm_adsp_create_control()
1346 ctl = kzalloc(sizeof(*ctl), GFP_KERNEL); in wm_adsp_create_control()
1347 if (!ctl) in wm_adsp_create_control()
1349 ctl->fw_name = wm_adsp_fw_text[dsp->fw]; in wm_adsp_create_control()
1350 ctl->alg_region = *alg_region; in wm_adsp_create_control()
1351 ctl->name = kmemdup(name, strlen(name) + 1, GFP_KERNEL); in wm_adsp_create_control()
1352 if (!ctl->name) { in wm_adsp_create_control()
1356 ctl->enabled = 1; in wm_adsp_create_control()
1357 ctl->set = 0; in wm_adsp_create_control()
1358 ctl->ops.xget = wm_coeff_get; in wm_adsp_create_control()
1359 ctl->ops.xput = wm_coeff_put; in wm_adsp_create_control()
1360 ctl->dsp = dsp; in wm_adsp_create_control()
1362 ctl->flags = flags; in wm_adsp_create_control()
1363 ctl->type = type; in wm_adsp_create_control()
1364 ctl->offset = offset; in wm_adsp_create_control()
1365 ctl->len = len; in wm_adsp_create_control()
1366 ctl->cache = kzalloc(ctl->len, GFP_KERNEL); in wm_adsp_create_control()
1367 if (!ctl->cache) { in wm_adsp_create_control()
1372 list_add(&ctl->list, &dsp->ctl_list); in wm_adsp_create_control()
1384 ctl_work->ctl = ctl; in wm_adsp_create_control()
1391 kfree(ctl->cache); in wm_adsp_create_control()
1393 kfree(ctl->name); in wm_adsp_create_control()
1395 kfree(ctl); in wm_adsp_create_control()
1853 struct wm_coeff_ctl *ctl; in wm_adsp_ctl_fixup_base() local
1855 list_for_each_entry(ctl, &dsp->ctl_list, list) { in wm_adsp_ctl_fixup_base()
1856 if (ctl->fw_name == wm_adsp_fw_text[dsp->fw] && in wm_adsp_ctl_fixup_base()
1857 alg_region->alg == ctl->alg_region.alg && in wm_adsp_ctl_fixup_base()
1858 alg_region->type == ctl->alg_region.type) { in wm_adsp_ctl_fixup_base()
1859 ctl->alg_region.base = alg_region->base; in wm_adsp_ctl_fixup_base()
2442 struct wm_coeff_ctl *ctl; in wm_adsp1_event() local
2525 list_for_each_entry(ctl, &dsp->ctl_list, list) in wm_adsp1_event()
2526 ctl->enabled = 0; in wm_adsp1_event()
2735 struct wm_coeff_ctl *ctl; in wm_adsp2_early_event() local
2755 list_for_each_entry(ctl, &dsp->ctl_list, list) in wm_adsp2_early_event()
2756 ctl->enabled = 0; in wm_adsp2_early_event()
2951 struct wm_coeff_ctl *ctl; in wm_adsp2_remove() local
2954 ctl = list_first_entry(&dsp->ctl_list, struct wm_coeff_ctl, in wm_adsp2_remove()
2956 list_del(&ctl->list); in wm_adsp2_remove()
2957 wm_adsp_free_ctl_blk(ctl); in wm_adsp2_remove()
3271 struct wm_coeff_ctl *ctl; in wm_adsp_find_host_buffer_ctrl() local
3273 list_for_each_entry(ctl, &dsp->ctl_list, list) { in wm_adsp_find_host_buffer_ctrl()
3274 if (ctl->type != WMFW_CTL_TYPE_HOST_BUFFER) in wm_adsp_find_host_buffer_ctrl()
3277 if (!ctl->enabled) in wm_adsp_find_host_buffer_ctrl()
3280 return ctl; in wm_adsp_find_host_buffer_ctrl()
3289 struct wm_coeff_ctl *ctl; in wm_adsp_buffer_locate() local
3294 ctl = wm_adsp_find_host_buffer_ctrl(buf); in wm_adsp_buffer_locate()
3295 if (!ctl) in wm_adsp_buffer_locate()
3298 ret = wm_coeff_base_reg(ctl, ®); in wm_adsp_buffer_locate()