Lines Matching refs:ctl

931 static int wm_coeff_base_reg(struct wm_coeff_ctl *ctl, unsigned int *reg)  in wm_coeff_base_reg()  argument
933 const struct wm_adsp_alg_region *alg_region = &ctl->alg_region; in wm_coeff_base_reg()
934 struct wm_adsp *dsp = ctl->dsp; in wm_coeff_base_reg()
944 *reg = dsp->ops->region_to_reg(mem, ctl->alg_region.base + ctl->offset); in wm_coeff_base_reg()
954 struct wm_coeff_ctl *ctl = bytes_ext_to_ctl(bytes_ext); in wm_coeff_info() local
956 switch (ctl->type) { in wm_coeff_info()
966 uinfo->count = ctl->len; in wm_coeff_info()
973 static int wm_coeff_write_acked_control(struct wm_coeff_ctl *ctl, in wm_coeff_write_acked_control() argument
976 struct wm_adsp *dsp = ctl->dsp; in wm_coeff_write_acked_control()
981 ret = wm_coeff_base_reg(ctl, &reg); in wm_coeff_write_acked_control()
986 event_id, ctl->alg_region.alg, in wm_coeff_write_acked_control()
987 wm_adsp_mem_region_name(ctl->alg_region.type), ctl->offset); in wm_coeff_write_acked_control()
1026 reg, ctl->alg_region.alg, in wm_coeff_write_acked_control()
1027 wm_adsp_mem_region_name(ctl->alg_region.type), in wm_coeff_write_acked_control()
1028 ctl->offset); in wm_coeff_write_acked_control()
1033 static int wm_coeff_write_ctrl_raw(struct wm_coeff_ctl *ctl, in wm_coeff_write_ctrl_raw() argument
1036 struct wm_adsp *dsp = ctl->dsp; in wm_coeff_write_ctrl_raw()
1041 ret = wm_coeff_base_reg(ctl, &reg); in wm_coeff_write_ctrl_raw()
1064 static int wm_coeff_write_ctrl(struct wm_coeff_ctl *ctl, in wm_coeff_write_ctrl() argument
1069 if (ctl->flags & WMFW_CTL_FLAG_VOLATILE) in wm_coeff_write_ctrl()
1071 else if (buf != ctl->cache) in wm_coeff_write_ctrl()
1072 memcpy(ctl->cache, buf, len); in wm_coeff_write_ctrl()
1074 ctl->set = 1; in wm_coeff_write_ctrl()
1075 if (ctl->enabled && ctl->dsp->running) in wm_coeff_write_ctrl()
1076 ret = wm_coeff_write_ctrl_raw(ctl, buf, len); in wm_coeff_write_ctrl()
1086 struct wm_coeff_ctl *ctl = bytes_ext_to_ctl(bytes_ext); in wm_coeff_put() local
1090 mutex_lock(&ctl->dsp->pwr_lock); in wm_coeff_put()
1091 ret = wm_coeff_write_ctrl(ctl, p, ctl->len); in wm_coeff_put()
1092 mutex_unlock(&ctl->dsp->pwr_lock); in wm_coeff_put()
1102 struct wm_coeff_ctl *ctl = bytes_ext_to_ctl(bytes_ext); in wm_coeff_tlv_put() local
1105 mutex_lock(&ctl->dsp->pwr_lock); in wm_coeff_tlv_put()
1107 if (copy_from_user(ctl->cache, bytes, size)) in wm_coeff_tlv_put()
1110 ret = wm_coeff_write_ctrl(ctl, ctl->cache, size); in wm_coeff_tlv_put()
1112 mutex_unlock(&ctl->dsp->pwr_lock); in wm_coeff_tlv_put()
1122 struct wm_coeff_ctl *ctl = bytes_ext_to_ctl(bytes_ext); in wm_coeff_put_acked() local
1129 mutex_lock(&ctl->dsp->pwr_lock); in wm_coeff_put_acked()
1131 if (ctl->enabled && ctl->dsp->running) in wm_coeff_put_acked()
1132 ret = wm_coeff_write_acked_control(ctl, val); in wm_coeff_put_acked()
1136 mutex_unlock(&ctl->dsp->pwr_lock); in wm_coeff_put_acked()
1141 static int wm_coeff_read_ctrl_raw(struct wm_coeff_ctl *ctl, in wm_coeff_read_ctrl_raw() argument
1144 struct wm_adsp *dsp = ctl->dsp; in wm_coeff_read_ctrl_raw()
1149 ret = wm_coeff_base_reg(ctl, &reg); in wm_coeff_read_ctrl_raw()
1172 static int wm_coeff_read_ctrl(struct wm_coeff_ctl *ctl, void *buf, size_t len) in wm_coeff_read_ctrl() argument
1176 if (ctl->flags & WMFW_CTL_FLAG_VOLATILE) { in wm_coeff_read_ctrl()
1177 if (ctl->enabled && ctl->dsp->running) in wm_coeff_read_ctrl()
1178 return wm_coeff_read_ctrl_raw(ctl, buf, len); in wm_coeff_read_ctrl()
1182 if (!ctl->flags && ctl->enabled && ctl->dsp->running) in wm_coeff_read_ctrl()
1183 ret = wm_coeff_read_ctrl_raw(ctl, ctl->cache, ctl->len); in wm_coeff_read_ctrl()
1185 if (buf != ctl->cache) in wm_coeff_read_ctrl()
1186 memcpy(buf, ctl->cache, len); in wm_coeff_read_ctrl()
1197 struct wm_coeff_ctl *ctl = bytes_ext_to_ctl(bytes_ext); in wm_coeff_get() local
1201 mutex_lock(&ctl->dsp->pwr_lock); in wm_coeff_get()
1202 ret = wm_coeff_read_ctrl(ctl, p, ctl->len); in wm_coeff_get()
1203 mutex_unlock(&ctl->dsp->pwr_lock); in wm_coeff_get()
1213 struct wm_coeff_ctl *ctl = bytes_ext_to_ctl(bytes_ext); in wm_coeff_tlv_get() local
1216 mutex_lock(&ctl->dsp->pwr_lock); in wm_coeff_tlv_get()
1218 ret = wm_coeff_read_ctrl(ctl, ctl->cache, size); in wm_coeff_tlv_get()
1220 if (!ret && copy_to_user(bytes, ctl->cache, size)) in wm_coeff_tlv_get()
1223 mutex_unlock(&ctl->dsp->pwr_lock); in wm_coeff_tlv_get()
1245 struct wm_coeff_ctl *ctl; member
1280 static int wmfw_add_ctl(struct wm_adsp *dsp, struct wm_coeff_ctl *ctl) in wmfw_add_ctl() argument
1285 if (!ctl || !ctl->name) in wmfw_add_ctl()
1292 kcontrol->name = ctl->name; in wmfw_add_ctl()
1296 kcontrol->private_value = (unsigned long)&ctl->bytes_ext; in wmfw_add_ctl()
1297 kcontrol->access = wmfw_convert_flags(ctl->flags, ctl->len); in wmfw_add_ctl()
1299 switch (ctl->type) { in wmfw_add_ctl()
1306 ctl->bytes_ext.max = ctl->len; in wmfw_add_ctl()
1307 ctl->bytes_ext.get = wm_coeff_tlv_get; in wmfw_add_ctl()
1308 ctl->bytes_ext.put = wm_coeff_tlv_put; in wmfw_add_ctl()
1331 struct wm_coeff_ctl *ctl; in wm_coeff_init_control_caches() local
1334 list_for_each_entry(ctl, &dsp->ctl_list, list) { in wm_coeff_init_control_caches()
1335 if (!ctl->enabled || ctl->set) in wm_coeff_init_control_caches()
1337 if (ctl->flags & WMFW_CTL_FLAG_VOLATILE) in wm_coeff_init_control_caches()
1345 if (!ctl->flags || (ctl->flags & WMFW_CTL_FLAG_READABLE)) { in wm_coeff_init_control_caches()
1346 ret = wm_coeff_read_ctrl_raw(ctl, ctl->cache, ctl->len); in wm_coeff_init_control_caches()
1357 struct wm_coeff_ctl *ctl; in wm_coeff_sync_controls() local
1360 list_for_each_entry(ctl, &dsp->ctl_list, list) { in wm_coeff_sync_controls()
1361 if (!ctl->enabled) in wm_coeff_sync_controls()
1363 if (ctl->set && !(ctl->flags & WMFW_CTL_FLAG_VOLATILE)) { in wm_coeff_sync_controls()
1364 ret = wm_coeff_write_ctrl_raw(ctl, ctl->cache, in wm_coeff_sync_controls()
1365 ctl->len); in wm_coeff_sync_controls()
1377 struct wm_coeff_ctl *ctl; in wm_adsp_signal_event_controls() local
1380 list_for_each_entry(ctl, &dsp->ctl_list, list) { in wm_adsp_signal_event_controls()
1381 if (ctl->type != WMFW_CTL_TYPE_HOSTEVENT) in wm_adsp_signal_event_controls()
1384 if (!ctl->enabled) in wm_adsp_signal_event_controls()
1387 ret = wm_coeff_write_acked_control(ctl, event); in wm_adsp_signal_event_controls()
1391 event, ctl->alg_region.alg, ret); in wm_adsp_signal_event_controls()
1401 wmfw_add_ctl(ctl_work->dsp, ctl_work->ctl); in wm_adsp_ctl_work()
1405 static void wm_adsp_free_ctl_blk(struct wm_coeff_ctl *ctl) in wm_adsp_free_ctl_blk() argument
1407 kfree(ctl->cache); in wm_adsp_free_ctl_blk()
1408 kfree(ctl->name); in wm_adsp_free_ctl_blk()
1409 kfree(ctl->subname); in wm_adsp_free_ctl_blk()
1410 kfree(ctl); in wm_adsp_free_ctl_blk()
1419 struct wm_coeff_ctl *ctl; in wm_adsp_create_control() local
1465 list_for_each_entry(ctl, &dsp->ctl_list, list) { in wm_adsp_create_control()
1466 if (!strcmp(ctl->name, name)) { in wm_adsp_create_control()
1467 if (!ctl->enabled) in wm_adsp_create_control()
1468 ctl->enabled = 1; in wm_adsp_create_control()
1473 ctl = kzalloc(sizeof(*ctl), GFP_KERNEL); in wm_adsp_create_control()
1474 if (!ctl) in wm_adsp_create_control()
1476 ctl->fw_name = wm_adsp_fw_text[dsp->fw]; in wm_adsp_create_control()
1477 ctl->alg_region = *alg_region; in wm_adsp_create_control()
1478 ctl->name = kmemdup(name, strlen(name) + 1, GFP_KERNEL); in wm_adsp_create_control()
1479 if (!ctl->name) { in wm_adsp_create_control()
1484 ctl->subname_len = subname_len; in wm_adsp_create_control()
1485 ctl->subname = kmemdup(subname, in wm_adsp_create_control()
1487 if (!ctl->subname) { in wm_adsp_create_control()
1492 ctl->enabled = 1; in wm_adsp_create_control()
1493 ctl->set = 0; in wm_adsp_create_control()
1494 ctl->dsp = dsp; in wm_adsp_create_control()
1496 ctl->flags = flags; in wm_adsp_create_control()
1497 ctl->type = type; in wm_adsp_create_control()
1498 ctl->offset = offset; in wm_adsp_create_control()
1499 ctl->len = len; in wm_adsp_create_control()
1500 ctl->cache = kzalloc(ctl->len, GFP_KERNEL); in wm_adsp_create_control()
1501 if (!ctl->cache) { in wm_adsp_create_control()
1506 list_add(&ctl->list, &dsp->ctl_list); in wm_adsp_create_control()
1518 ctl_work->ctl = ctl; in wm_adsp_create_control()
1525 list_del(&ctl->list); in wm_adsp_create_control()
1526 kfree(ctl->cache); in wm_adsp_create_control()
1528 kfree(ctl->subname); in wm_adsp_create_control()
1530 kfree(ctl->name); in wm_adsp_create_control()
1532 kfree(ctl); in wm_adsp_create_control()
2048 struct wm_coeff_ctl *ctl; in wm_adsp_write_ctl() local
2053 ctl = wm_adsp_get_ctl(dsp, name, type, alg); in wm_adsp_write_ctl()
2054 if (!ctl) in wm_adsp_write_ctl()
2057 if (len > ctl->len) in wm_adsp_write_ctl()
2060 ret = wm_coeff_write_ctrl(ctl, buf, len); in wm_adsp_write_ctl()
2064 if (ctl->flags & WMFW_CTL_FLAG_SYS) in wm_adsp_write_ctl()
2069 dsp->component->name_prefix, ctl->name); in wm_adsp_write_ctl()
2072 ctl->name); in wm_adsp_write_ctl()
2090 struct wm_coeff_ctl *ctl; in wm_adsp_read_ctl() local
2092 ctl = wm_adsp_get_ctl(dsp, name, type, alg); in wm_adsp_read_ctl()
2093 if (!ctl) in wm_adsp_read_ctl()
2096 if (len > ctl->len) in wm_adsp_read_ctl()
2099 return wm_coeff_read_ctrl(ctl, buf, len); in wm_adsp_read_ctl()
2106 struct wm_coeff_ctl *ctl; in wm_adsp_ctl_fixup_base() local
2108 list_for_each_entry(ctl, &dsp->ctl_list, list) { in wm_adsp_ctl_fixup_base()
2109 if (ctl->fw_name == wm_adsp_fw_text[dsp->fw] && in wm_adsp_ctl_fixup_base()
2110 alg_region->alg == ctl->alg_region.alg && in wm_adsp_ctl_fixup_base()
2111 alg_region->type == ctl->alg_region.type) { in wm_adsp_ctl_fixup_base()
2112 ctl->alg_region.base = alg_region->base; in wm_adsp_ctl_fixup_base()
2811 struct wm_coeff_ctl *ctl; in wm_adsp1_event() local
2894 list_for_each_entry(ctl, &dsp->ctl_list, list) in wm_adsp1_event()
2895 ctl->enabled = 0; in wm_adsp1_event()
3183 struct wm_coeff_ctl *ctl; in wm_adsp_early_event() local
3202 list_for_each_entry(ctl, &dsp->ctl_list, list) in wm_adsp_early_event()
3203 ctl->enabled = 0; in wm_adsp_early_event()
3430 struct wm_coeff_ctl *ctl; in wm_adsp2_remove() local
3433 ctl = list_first_entry(&dsp->ctl_list, struct wm_coeff_ctl, in wm_adsp2_remove()
3435 list_del(&ctl->list); in wm_adsp2_remove()
3436 wm_adsp_free_ctl_blk(ctl); in wm_adsp2_remove()
3865 static int wm_adsp_buffer_parse_coeff(struct wm_coeff_ctl *ctl) in wm_adsp_buffer_parse_coeff() argument
3873 ret = wm_coeff_base_reg(ctl, &reg); in wm_adsp_buffer_parse_coeff()
3878 ret = regmap_raw_read(ctl->dsp->regmap, reg, &bufp, sizeof(bufp)); in wm_adsp_buffer_parse_coeff()
3889 adsp_err(ctl->dsp, "Failed to acquire host buffer\n"); in wm_adsp_buffer_parse_coeff()
3893 buf = wm_adsp_buffer_alloc(ctl->dsp); in wm_adsp_buffer_parse_coeff()
3897 buf->host_buf_mem_type = ctl->alg_region.type; in wm_adsp_buffer_parse_coeff()
3908 if (ctl->len == 4) { in wm_adsp_buffer_parse_coeff()
3913 ret = regmap_raw_read(ctl->dsp->regmap, reg, &coeff_v1, in wm_adsp_buffer_parse_coeff()
3922 adsp_err(ctl->dsp, in wm_adsp_buffer_parse_coeff()
3930 buf->name = kasprintf(GFP_KERNEL, "%s-dsp-%s", ctl->dsp->part, in wm_adsp_buffer_parse_coeff()
3941 struct wm_coeff_ctl *ctl; in wm_adsp_buffer_init() local
3944 list_for_each_entry(ctl, &dsp->ctl_list, list) { in wm_adsp_buffer_init()
3945 if (ctl->type != WMFW_CTL_TYPE_HOST_BUFFER) in wm_adsp_buffer_init()
3948 if (!ctl->enabled) in wm_adsp_buffer_init()
3951 ret = wm_adsp_buffer_parse_coeff(ctl); in wm_adsp_buffer_init()