Lines Matching refs:ctl

928 static int wm_coeff_base_reg(struct wm_coeff_ctl *ctl, unsigned int *reg)  in wm_coeff_base_reg()  argument
930 const struct wm_adsp_alg_region *alg_region = &ctl->alg_region; in wm_coeff_base_reg()
931 struct wm_adsp *dsp = ctl->dsp; in wm_coeff_base_reg()
941 *reg = dsp->ops->region_to_reg(mem, ctl->alg_region.base + ctl->offset); in wm_coeff_base_reg()
951 struct wm_coeff_ctl *ctl = bytes_ext_to_ctl(bytes_ext); in wm_coeff_info() local
953 switch (ctl->type) { in wm_coeff_info()
963 uinfo->count = ctl->len; in wm_coeff_info()
970 static int wm_coeff_write_acked_control(struct wm_coeff_ctl *ctl, in wm_coeff_write_acked_control() argument
973 struct wm_adsp *dsp = ctl->dsp; in wm_coeff_write_acked_control()
978 ret = wm_coeff_base_reg(ctl, &reg); in wm_coeff_write_acked_control()
983 event_id, ctl->alg_region.alg, in wm_coeff_write_acked_control()
984 wm_adsp_mem_region_name(ctl->alg_region.type), ctl->offset); in wm_coeff_write_acked_control()
1023 reg, ctl->alg_region.alg, in wm_coeff_write_acked_control()
1024 wm_adsp_mem_region_name(ctl->alg_region.type), in wm_coeff_write_acked_control()
1025 ctl->offset); in wm_coeff_write_acked_control()
1030 static int wm_coeff_write_control(struct wm_coeff_ctl *ctl, in wm_coeff_write_control() argument
1033 struct wm_adsp *dsp = ctl->dsp; in wm_coeff_write_control()
1038 ret = wm_coeff_base_reg(ctl, &reg); in wm_coeff_write_control()
1066 struct wm_coeff_ctl *ctl = bytes_ext_to_ctl(bytes_ext); in wm_coeff_put() local
1070 mutex_lock(&ctl->dsp->pwr_lock); in wm_coeff_put()
1072 if (ctl->flags & WMFW_CTL_FLAG_VOLATILE) in wm_coeff_put()
1075 memcpy(ctl->cache, p, ctl->len); in wm_coeff_put()
1077 ctl->set = 1; in wm_coeff_put()
1078 if (ctl->enabled && ctl->dsp->running) in wm_coeff_put()
1079 ret = wm_coeff_write_control(ctl, p, ctl->len); in wm_coeff_put()
1081 mutex_unlock(&ctl->dsp->pwr_lock); in wm_coeff_put()
1091 struct wm_coeff_ctl *ctl = bytes_ext_to_ctl(bytes_ext); in wm_coeff_tlv_put() local
1094 mutex_lock(&ctl->dsp->pwr_lock); in wm_coeff_tlv_put()
1096 if (copy_from_user(ctl->cache, bytes, size)) { in wm_coeff_tlv_put()
1099 ctl->set = 1; in wm_coeff_tlv_put()
1100 if (ctl->enabled && ctl->dsp->running) in wm_coeff_tlv_put()
1101 ret = wm_coeff_write_control(ctl, ctl->cache, size); in wm_coeff_tlv_put()
1102 else if (ctl->flags & WMFW_CTL_FLAG_VOLATILE) in wm_coeff_tlv_put()
1106 mutex_unlock(&ctl->dsp->pwr_lock); in wm_coeff_tlv_put()
1116 struct wm_coeff_ctl *ctl = bytes_ext_to_ctl(bytes_ext); in wm_coeff_put_acked() local
1123 mutex_lock(&ctl->dsp->pwr_lock); in wm_coeff_put_acked()
1125 if (ctl->enabled && ctl->dsp->running) in wm_coeff_put_acked()
1126 ret = wm_coeff_write_acked_control(ctl, val); in wm_coeff_put_acked()
1130 mutex_unlock(&ctl->dsp->pwr_lock); in wm_coeff_put_acked()
1135 static int wm_coeff_read_control(struct wm_coeff_ctl *ctl, in wm_coeff_read_control() argument
1138 struct wm_adsp *dsp = ctl->dsp; in wm_coeff_read_control()
1143 ret = wm_coeff_base_reg(ctl, &reg); in wm_coeff_read_control()
1171 struct wm_coeff_ctl *ctl = bytes_ext_to_ctl(bytes_ext); in wm_coeff_get() local
1175 mutex_lock(&ctl->dsp->pwr_lock); in wm_coeff_get()
1177 if (ctl->flags & WMFW_CTL_FLAG_VOLATILE) { in wm_coeff_get()
1178 if (ctl->enabled && ctl->dsp->running) in wm_coeff_get()
1179 ret = wm_coeff_read_control(ctl, p, ctl->len); in wm_coeff_get()
1183 if (!ctl->flags && ctl->enabled && ctl->dsp->running) in wm_coeff_get()
1184 ret = wm_coeff_read_control(ctl, ctl->cache, ctl->len); in wm_coeff_get()
1186 memcpy(p, ctl->cache, ctl->len); in wm_coeff_get()
1189 mutex_unlock(&ctl->dsp->pwr_lock); in wm_coeff_get()
1199 struct wm_coeff_ctl *ctl = bytes_ext_to_ctl(bytes_ext); in wm_coeff_tlv_get() local
1202 mutex_lock(&ctl->dsp->pwr_lock); in wm_coeff_tlv_get()
1204 if (ctl->flags & WMFW_CTL_FLAG_VOLATILE) { in wm_coeff_tlv_get()
1205 if (ctl->enabled && ctl->dsp->running) in wm_coeff_tlv_get()
1206 ret = wm_coeff_read_control(ctl, ctl->cache, size); in wm_coeff_tlv_get()
1210 if (!ctl->flags && ctl->enabled && ctl->dsp->running) in wm_coeff_tlv_get()
1211 ret = wm_coeff_read_control(ctl, ctl->cache, size); in wm_coeff_tlv_get()
1214 if (!ret && copy_to_user(bytes, ctl->cache, size)) in wm_coeff_tlv_get()
1217 mutex_unlock(&ctl->dsp->pwr_lock); in wm_coeff_tlv_get()
1239 struct wm_coeff_ctl *ctl; member
1274 static int wmfw_add_ctl(struct wm_adsp *dsp, struct wm_coeff_ctl *ctl) in wmfw_add_ctl() argument
1279 if (!ctl || !ctl->name) in wmfw_add_ctl()
1286 kcontrol->name = ctl->name; in wmfw_add_ctl()
1290 kcontrol->private_value = (unsigned long)&ctl->bytes_ext; in wmfw_add_ctl()
1291 kcontrol->access = wmfw_convert_flags(ctl->flags, ctl->len); in wmfw_add_ctl()
1293 switch (ctl->type) { in wmfw_add_ctl()
1300 ctl->bytes_ext.max = ctl->len; in wmfw_add_ctl()
1301 ctl->bytes_ext.get = wm_coeff_tlv_get; in wmfw_add_ctl()
1302 ctl->bytes_ext.put = wm_coeff_tlv_put; in wmfw_add_ctl()
1325 struct wm_coeff_ctl *ctl; in wm_coeff_init_control_caches() local
1328 list_for_each_entry(ctl, &dsp->ctl_list, list) { in wm_coeff_init_control_caches()
1329 if (!ctl->enabled || ctl->set) in wm_coeff_init_control_caches()
1331 if (ctl->flags & WMFW_CTL_FLAG_VOLATILE) in wm_coeff_init_control_caches()
1339 if (!ctl->flags || (ctl->flags & WMFW_CTL_FLAG_READABLE)) { in wm_coeff_init_control_caches()
1340 ret = wm_coeff_read_control(ctl, ctl->cache, ctl->len); in wm_coeff_init_control_caches()
1351 struct wm_coeff_ctl *ctl; in wm_coeff_sync_controls() local
1354 list_for_each_entry(ctl, &dsp->ctl_list, list) { in wm_coeff_sync_controls()
1355 if (!ctl->enabled) in wm_coeff_sync_controls()
1357 if (ctl->set && !(ctl->flags & WMFW_CTL_FLAG_VOLATILE)) { in wm_coeff_sync_controls()
1358 ret = wm_coeff_write_control(ctl, ctl->cache, ctl->len); in wm_coeff_sync_controls()
1370 struct wm_coeff_ctl *ctl; in wm_adsp_signal_event_controls() local
1373 list_for_each_entry(ctl, &dsp->ctl_list, list) { in wm_adsp_signal_event_controls()
1374 if (ctl->type != WMFW_CTL_TYPE_HOSTEVENT) in wm_adsp_signal_event_controls()
1377 if (!ctl->enabled) in wm_adsp_signal_event_controls()
1380 ret = wm_coeff_write_acked_control(ctl, event); in wm_adsp_signal_event_controls()
1384 event, ctl->alg_region.alg, ret); in wm_adsp_signal_event_controls()
1394 wmfw_add_ctl(ctl_work->dsp, ctl_work->ctl); in wm_adsp_ctl_work()
1398 static void wm_adsp_free_ctl_blk(struct wm_coeff_ctl *ctl) in wm_adsp_free_ctl_blk() argument
1400 kfree(ctl->cache); in wm_adsp_free_ctl_blk()
1401 kfree(ctl->name); in wm_adsp_free_ctl_blk()
1402 kfree(ctl); in wm_adsp_free_ctl_blk()
1411 struct wm_coeff_ctl *ctl; in wm_adsp_create_control() local
1457 list_for_each_entry(ctl, &dsp->ctl_list, list) { in wm_adsp_create_control()
1458 if (!strcmp(ctl->name, name)) { in wm_adsp_create_control()
1459 if (!ctl->enabled) in wm_adsp_create_control()
1460 ctl->enabled = 1; in wm_adsp_create_control()
1465 ctl = kzalloc(sizeof(*ctl), GFP_KERNEL); in wm_adsp_create_control()
1466 if (!ctl) in wm_adsp_create_control()
1468 ctl->fw_name = wm_adsp_fw_text[dsp->fw]; in wm_adsp_create_control()
1469 ctl->alg_region = *alg_region; in wm_adsp_create_control()
1470 ctl->name = kmemdup(name, strlen(name) + 1, GFP_KERNEL); in wm_adsp_create_control()
1471 if (!ctl->name) { in wm_adsp_create_control()
1475 ctl->enabled = 1; in wm_adsp_create_control()
1476 ctl->set = 0; in wm_adsp_create_control()
1477 ctl->ops.xget = wm_coeff_get; in wm_adsp_create_control()
1478 ctl->ops.xput = wm_coeff_put; in wm_adsp_create_control()
1479 ctl->dsp = dsp; in wm_adsp_create_control()
1481 ctl->flags = flags; in wm_adsp_create_control()
1482 ctl->type = type; in wm_adsp_create_control()
1483 ctl->offset = offset; in wm_adsp_create_control()
1484 ctl->len = len; in wm_adsp_create_control()
1485 ctl->cache = kzalloc(ctl->len, GFP_KERNEL); in wm_adsp_create_control()
1486 if (!ctl->cache) { in wm_adsp_create_control()
1491 list_add(&ctl->list, &dsp->ctl_list); in wm_adsp_create_control()
1503 ctl_work->ctl = ctl; in wm_adsp_create_control()
1510 kfree(ctl->cache); in wm_adsp_create_control()
1512 kfree(ctl->name); in wm_adsp_create_control()
1514 kfree(ctl); in wm_adsp_create_control()
2001 struct wm_coeff_ctl *ctl; in wm_adsp_ctl_fixup_base() local
2003 list_for_each_entry(ctl, &dsp->ctl_list, list) { in wm_adsp_ctl_fixup_base()
2004 if (ctl->fw_name == wm_adsp_fw_text[dsp->fw] && in wm_adsp_ctl_fixup_base()
2005 alg_region->alg == ctl->alg_region.alg && in wm_adsp_ctl_fixup_base()
2006 alg_region->type == ctl->alg_region.type) { in wm_adsp_ctl_fixup_base()
2007 ctl->alg_region.base = alg_region->base; in wm_adsp_ctl_fixup_base()
2705 struct wm_coeff_ctl *ctl; in wm_adsp1_event() local
2788 list_for_each_entry(ctl, &dsp->ctl_list, list) in wm_adsp1_event()
2789 ctl->enabled = 0; in wm_adsp1_event()
3077 struct wm_coeff_ctl *ctl; in wm_adsp_early_event() local
3096 list_for_each_entry(ctl, &dsp->ctl_list, list) in wm_adsp_early_event()
3097 ctl->enabled = 0; in wm_adsp_early_event()
3323 struct wm_coeff_ctl *ctl; in wm_adsp2_remove() local
3326 ctl = list_first_entry(&dsp->ctl_list, struct wm_coeff_ctl, in wm_adsp2_remove()
3328 list_del(&ctl->list); in wm_adsp2_remove()
3329 wm_adsp_free_ctl_blk(ctl); in wm_adsp2_remove()
3746 static int wm_adsp_buffer_parse_coeff(struct wm_coeff_ctl *ctl) in wm_adsp_buffer_parse_coeff() argument
3753 ret = wm_coeff_base_reg(ctl, &reg); in wm_adsp_buffer_parse_coeff()
3758 ret = regmap_raw_read(ctl->dsp->regmap, reg, &val, sizeof(val)); in wm_adsp_buffer_parse_coeff()
3769 adsp_err(ctl->dsp, "Failed to acquire host buffer\n"); in wm_adsp_buffer_parse_coeff()
3773 buf = wm_adsp_buffer_alloc(ctl->dsp); in wm_adsp_buffer_parse_coeff()
3777 buf->host_buf_mem_type = ctl->alg_region.type; in wm_adsp_buffer_parse_coeff()
3788 if (ctl->len == 4) { in wm_adsp_buffer_parse_coeff()
3793 ret = regmap_raw_read(ctl->dsp->regmap, reg, &coeff_v1, in wm_adsp_buffer_parse_coeff()
3803 adsp_err(ctl->dsp, in wm_adsp_buffer_parse_coeff()
3816 buf->name = kasprintf(GFP_KERNEL, "%s-dsp-%s", ctl->dsp->part, in wm_adsp_buffer_parse_coeff()
3827 struct wm_coeff_ctl *ctl; in wm_adsp_buffer_init() local
3830 list_for_each_entry(ctl, &dsp->ctl_list, list) { in wm_adsp_buffer_init()
3831 if (ctl->type != WMFW_CTL_TYPE_HOST_BUFFER) in wm_adsp_buffer_init()
3834 if (!ctl->enabled) in wm_adsp_buffer_init()
3837 ret = wm_adsp_buffer_parse_coeff(ctl); in wm_adsp_buffer_init()