Lines Matching +full:dsp +full:- +full:ctrl
1 // SPDX-License-Identifier: GPL-2.0-only
3 * wm_adsp.c -- Wolfson ADSP support
35 dev_crit(_dsp->cs_dsp.dev, "%s: " fmt, _dsp->cs_dsp.name, ##__VA_ARGS__)
37 dev_err(_dsp->cs_dsp.dev, "%s: " fmt, _dsp->cs_dsp.name, ##__VA_ARGS__)
39 dev_warn(_dsp->cs_dsp.dev, "%s: " fmt, _dsp->cs_dsp.name, ##__VA_ARGS__)
41 dev_info(_dsp->cs_dsp.dev, "%s: " fmt, _dsp->cs_dsp.name, ##__VA_ARGS__)
43 dev_dbg(_dsp->cs_dsp.dev, "%s: " fmt, _dsp->cs_dsp.name, ##__VA_ARGS__)
46 adsp_err(_obj->dsp, "%s: " fmt, _obj->name ? _obj->name : "legacy", \
49 adsp_dbg(_obj->dsp, "%s: " fmt, _obj->name ? _obj->name : "legacy", \
80 [WM_ADSP_FW_CTRL] = "Voice Ctrl",
127 __be32 buf1_size; /* Size of buf1 area in DSP words */
129 __be32 buf1_buf2_size; /* Size of buf1+buf2 in DSP words */
131 __be32 buf_total_size; /* Size of buf1+buf2+buf3 in DSP words */
133 __be32 irq_count; /* bits 1-31 count IRQ assertions */
150 struct wm_adsp *dsp; member
167 struct wm_adsp *dsp; member
199 static int wm_adsp_buffer_init(struct wm_adsp *dsp);
200 static int wm_adsp_buffer_free(struct wm_adsp *dsp);
279 [WM_ADSP_FW_MBC_VSS] = { .file = "mbc-vss" },
282 [WM_ADSP_FW_TX_SPK] = { .file = "tx-spk" },
284 [WM_ADSP_FW_RX_ANC] = { .file = "rx-anc" },
286 .file = "ctrl",
300 .file = "spk-prot",
305 [WM_ADSP_FW_SPK_CALI] = { .file = "spk-cali" },
306 [WM_ADSP_FW_SPK_DIAG] = { .file = "spk-diag" },
321 struct soc_enum *e = (struct soc_enum *)kcontrol->private_value; in wm_adsp_fw_get()
322 struct wm_adsp *dsp = snd_soc_component_get_drvdata(component); in wm_adsp_fw_get() local
324 ucontrol->value.enumerated.item[0] = dsp[e->shift_l].fw; in wm_adsp_fw_get()
334 struct soc_enum *e = (struct soc_enum *)kcontrol->private_value; in wm_adsp_fw_put()
335 struct wm_adsp *dsp = snd_soc_component_get_drvdata(component); in wm_adsp_fw_put() local
338 if (ucontrol->value.enumerated.item[0] == dsp[e->shift_l].fw) in wm_adsp_fw_put()
341 if (ucontrol->value.enumerated.item[0] >= WM_ADSP_NUM_FW) in wm_adsp_fw_put()
342 return -EINVAL; in wm_adsp_fw_put()
344 mutex_lock(&dsp[e->shift_l].cs_dsp.pwr_lock); in wm_adsp_fw_put()
346 if (dsp[e->shift_l].cs_dsp.booted || !list_empty(&dsp[e->shift_l].compr_list)) in wm_adsp_fw_put()
347 ret = -EBUSY; in wm_adsp_fw_put()
349 dsp[e->shift_l].fw = ucontrol->value.enumerated.item[0]; in wm_adsp_fw_put()
351 mutex_unlock(&dsp[e->shift_l].cs_dsp.pwr_lock); in wm_adsp_fw_put()
377 (struct soc_bytes_ext *)kctl->private_value; in wm_coeff_info()
379 struct cs_dsp_coeff_ctl *cs_ctl = ctl->cs_ctl; in wm_coeff_info()
381 switch (cs_ctl->type) { in wm_coeff_info()
383 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; in wm_coeff_info()
384 uinfo->value.integer.min = CS_DSP_ACKED_CTL_MIN_VALUE; in wm_coeff_info()
385 uinfo->value.integer.max = CS_DSP_ACKED_CTL_MAX_VALUE; in wm_coeff_info()
386 uinfo->value.integer.step = 1; in wm_coeff_info()
387 uinfo->count = 1; in wm_coeff_info()
390 uinfo->type = SNDRV_CTL_ELEM_TYPE_BYTES; in wm_coeff_info()
391 uinfo->count = cs_ctl->len; in wm_coeff_info()
402 (struct soc_bytes_ext *)kctl->private_value; in wm_coeff_put()
404 struct cs_dsp_coeff_ctl *cs_ctl = ctl->cs_ctl; in wm_coeff_put()
405 char *p = ucontrol->value.bytes.data; in wm_coeff_put()
408 mutex_lock(&cs_ctl->dsp->pwr_lock); in wm_coeff_put()
409 ret = cs_dsp_coeff_write_ctrl(cs_ctl, 0, p, cs_ctl->len); in wm_coeff_put()
410 mutex_unlock(&cs_ctl->dsp->pwr_lock); in wm_coeff_put()
419 (struct soc_bytes_ext *)kctl->private_value; in wm_coeff_tlv_put()
421 struct cs_dsp_coeff_ctl *cs_ctl = ctl->cs_ctl; in wm_coeff_tlv_put()
427 return -ENOMEM; in wm_coeff_tlv_put()
430 ret = -EFAULT; in wm_coeff_tlv_put()
432 mutex_lock(&cs_ctl->dsp->pwr_lock); in wm_coeff_tlv_put()
434 mutex_unlock(&cs_ctl->dsp->pwr_lock); in wm_coeff_tlv_put()
445 (struct soc_bytes_ext *)kctl->private_value; in wm_coeff_put_acked()
447 struct cs_dsp_coeff_ctl *cs_ctl = ctl->cs_ctl; in wm_coeff_put_acked()
448 unsigned int val = ucontrol->value.integer.value[0]; in wm_coeff_put_acked()
454 mutex_lock(&cs_ctl->dsp->pwr_lock); in wm_coeff_put_acked()
456 if (cs_ctl->enabled) in wm_coeff_put_acked()
459 ret = -EPERM; in wm_coeff_put_acked()
461 mutex_unlock(&cs_ctl->dsp->pwr_lock); in wm_coeff_put_acked()
473 (struct soc_bytes_ext *)kctl->private_value; in wm_coeff_get()
475 struct cs_dsp_coeff_ctl *cs_ctl = ctl->cs_ctl; in wm_coeff_get()
476 char *p = ucontrol->value.bytes.data; in wm_coeff_get()
479 mutex_lock(&cs_ctl->dsp->pwr_lock); in wm_coeff_get()
480 ret = cs_dsp_coeff_read_ctrl(cs_ctl, 0, p, cs_ctl->len); in wm_coeff_get()
481 mutex_unlock(&cs_ctl->dsp->pwr_lock); in wm_coeff_get()
490 (struct soc_bytes_ext *)kctl->private_value; in wm_coeff_tlv_get()
492 struct cs_dsp_coeff_ctl *cs_ctl = ctl->cs_ctl; in wm_coeff_tlv_get()
495 mutex_lock(&cs_ctl->dsp->pwr_lock); in wm_coeff_tlv_get()
497 ret = cs_dsp_coeff_read_ctrl(cs_ctl, 0, cs_ctl->cache, size); in wm_coeff_tlv_get()
499 if (!ret && copy_to_user(bytes, cs_ctl->cache, size)) in wm_coeff_tlv_get()
500 ret = -EFAULT; in wm_coeff_tlv_get()
502 mutex_unlock(&cs_ctl->dsp->pwr_lock); in wm_coeff_tlv_get()
512 * user-side assumptions that all controls are readable and that a in wm_coeff_get_acked()
517 ucontrol->value.integer.value[0] = 0; in wm_coeff_get_acked()
558 struct cs_dsp_coeff_ctl *cs_ctl = ctl->cs_ctl; in wm_adsp_ctl_work()
559 struct wm_adsp *dsp = container_of(cs_ctl->dsp, in wm_adsp_ctl_work() local
568 kcontrol->name = ctl->name; in wm_adsp_ctl_work()
569 kcontrol->info = wm_coeff_info; in wm_adsp_ctl_work()
570 kcontrol->iface = SNDRV_CTL_ELEM_IFACE_MIXER; in wm_adsp_ctl_work()
571 kcontrol->tlv.c = snd_soc_bytes_tlv_callback; in wm_adsp_ctl_work()
572 kcontrol->private_value = (unsigned long)&ctl->bytes_ext; in wm_adsp_ctl_work()
573 kcontrol->access = wmfw_convert_flags(cs_ctl->flags, cs_ctl->len); in wm_adsp_ctl_work()
575 switch (cs_ctl->type) { in wm_adsp_ctl_work()
577 kcontrol->get = wm_coeff_get_acked; in wm_adsp_ctl_work()
578 kcontrol->put = wm_coeff_put_acked; in wm_adsp_ctl_work()
581 if (kcontrol->access & SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK) { in wm_adsp_ctl_work()
582 ctl->bytes_ext.max = cs_ctl->len; in wm_adsp_ctl_work()
583 ctl->bytes_ext.get = wm_coeff_tlv_get; in wm_adsp_ctl_work()
584 ctl->bytes_ext.put = wm_coeff_tlv_put; in wm_adsp_ctl_work()
586 kcontrol->get = wm_coeff_get; in wm_adsp_ctl_work()
587 kcontrol->put = wm_coeff_put; in wm_adsp_ctl_work()
592 snd_soc_add_component_controls(dsp->component, kcontrol, 1); in wm_adsp_ctl_work()
599 struct wm_adsp *dsp = container_of(cs_ctl->dsp, struct wm_adsp, cs_dsp); in wm_adsp_control_add() local
600 struct cs_dsp *cs_dsp = &dsp->cs_dsp; in wm_adsp_control_add()
606 if (cs_ctl->flags & WMFW_CTL_FLAG_SYS) in wm_adsp_control_add()
609 region_name = cs_dsp_mem_region_name(cs_ctl->alg_region.type); in wm_adsp_control_add()
611 adsp_err(dsp, "Unknown region type: %d\n", cs_ctl->alg_region.type); in wm_adsp_control_add()
612 return -EINVAL; in wm_adsp_control_add()
615 switch (cs_dsp->fw_ver) { in wm_adsp_control_add()
619 "%s %s %x", cs_dsp->name, region_name, in wm_adsp_control_add()
620 cs_ctl->alg_region.alg); in wm_adsp_control_add()
624 "%s%c %.12s %x", cs_dsp->name, *region_name, in wm_adsp_control_add()
625 wm_adsp_fw_text[dsp->fw], cs_ctl->alg_region.alg); in wm_adsp_control_add()
629 "%s %.12s %x", cs_dsp->name, in wm_adsp_control_add()
630 wm_adsp_fw_text[dsp->fw], cs_ctl->alg_region.alg); in wm_adsp_control_add()
634 if (cs_ctl->subname) { in wm_adsp_control_add()
635 int avail = SNDRV_CTL_ELEM_ID_NAME_MAXLEN - ret - 2; in wm_adsp_control_add()
638 if (dsp->component->name_prefix) in wm_adsp_control_add()
639 avail -= strlen(dsp->component->name_prefix) + 1; in wm_adsp_control_add()
642 if (cs_ctl->subname_len > avail) in wm_adsp_control_add()
643 skip = cs_ctl->subname_len - avail; in wm_adsp_control_add()
645 snprintf(name + ret, SNDRV_CTL_ELEM_ID_NAME_MAXLEN - ret, in wm_adsp_control_add()
646 " %.*s", cs_ctl->subname_len - skip, cs_ctl->subname + skip); in wm_adsp_control_add()
651 return -ENOMEM; in wm_adsp_control_add()
652 ctl->cs_ctl = cs_ctl; in wm_adsp_control_add()
654 ctl->name = kmemdup(name, strlen(name) + 1, GFP_KERNEL); in wm_adsp_control_add()
655 if (!ctl->name) { in wm_adsp_control_add()
656 ret = -ENOMEM; in wm_adsp_control_add()
660 cs_ctl->priv = ctl; in wm_adsp_control_add()
662 INIT_WORK(&ctl->work, wm_adsp_ctl_work); in wm_adsp_control_add()
663 schedule_work(&ctl->work); in wm_adsp_control_add()
675 struct wm_coeff_ctl *ctl = cs_ctl->priv; in wm_adsp_control_remove()
677 cancel_work_sync(&ctl->work); in wm_adsp_control_remove()
679 kfree(ctl->name); in wm_adsp_control_remove()
683 int wm_adsp_write_ctl(struct wm_adsp *dsp, const char *name, int type, in wm_adsp_write_ctl() argument
686 struct cs_dsp_coeff_ctl *cs_ctl = cs_dsp_get_ctl(&dsp->cs_dsp, name, type, alg); in wm_adsp_write_ctl()
690 mutex_lock(&dsp->cs_dsp.pwr_lock); in wm_adsp_write_ctl()
692 mutex_unlock(&dsp->cs_dsp.pwr_lock); in wm_adsp_write_ctl()
697 if (ret == 0 || (cs_ctl->flags & WMFW_CTL_FLAG_SYS)) in wm_adsp_write_ctl()
700 ctl = cs_ctl->priv; in wm_adsp_write_ctl()
702 return snd_soc_component_notify_control(dsp->component, ctl->name); in wm_adsp_write_ctl()
706 int wm_adsp_read_ctl(struct wm_adsp *dsp, const char *name, int type, in wm_adsp_read_ctl() argument
711 mutex_lock(&dsp->cs_dsp.pwr_lock); in wm_adsp_read_ctl()
712 ret = cs_dsp_coeff_read_ctrl(cs_dsp_get_ctl(&dsp->cs_dsp, name, type, alg), in wm_adsp_read_ctl()
714 mutex_unlock(&dsp->cs_dsp.pwr_lock); in wm_adsp_read_ctl()
720 static void wm_adsp_release_firmware_files(struct wm_adsp *dsp, in wm_adsp_release_firmware_files() argument
735 static int wm_adsp_request_firmware_file(struct wm_adsp *dsp, in wm_adsp_request_firmware_file() argument
741 struct cs_dsp *cs_dsp = &dsp->cs_dsp; in wm_adsp_request_firmware_file()
746 if (dsp->fwf_name) in wm_adsp_request_firmware_file()
747 fwf = dsp->fwf_name; in wm_adsp_request_firmware_file()
749 fwf = dsp->cs_dsp.name; in wm_adsp_request_firmware_file()
752 *filename = kasprintf(GFP_KERNEL, "%s%s-%s-%s-%s-%s.%s", dir, dsp->part, in wm_adsp_request_firmware_file()
753 fwf, wm_adsp_fw[dsp->fw].file, system_name, in wm_adsp_request_firmware_file()
756 *filename = kasprintf(GFP_KERNEL, "%s%s-%s-%s-%s.%s", dir, dsp->part, in wm_adsp_request_firmware_file()
757 fwf, wm_adsp_fw[dsp->fw].file, system_name, in wm_adsp_request_firmware_file()
760 *filename = kasprintf(GFP_KERNEL, "%s%s-%s-%s.%s", dir, dsp->part, fwf, in wm_adsp_request_firmware_file()
761 wm_adsp_fw[dsp->fw].file, filetype); in wm_adsp_request_firmware_file()
764 return -ENOMEM; in wm_adsp_request_firmware_file()
767 * Make sure that filename is lower-case and any non alpha-numeric in wm_adsp_request_firmware_file()
777 *s = '-'; in wm_adsp_request_firmware_file()
781 ret = firmware_request_nowarn(firmware, *filename, cs_dsp->dev); in wm_adsp_request_firmware_file()
783 adsp_dbg(dsp, "Failed to request '%s'\n", *filename); in wm_adsp_request_firmware_file()
787 adsp_dbg(dsp, "Found '%s'\n", *filename); in wm_adsp_request_firmware_file()
794 static int wm_adsp_request_firmware_files(struct wm_adsp *dsp, in wm_adsp_request_firmware_files() argument
800 const char *system_name = dsp->system_name; in wm_adsp_request_firmware_files()
801 const char *asoc_component_prefix = dsp->component->name_prefix; in wm_adsp_request_firmware_files()
805 if (!wm_adsp_request_firmware_file(dsp, wmfw_firmware, wmfw_filename, in wm_adsp_request_firmware_files()
808 wm_adsp_request_firmware_file(dsp, coeff_firmware, coeff_filename, in wm_adsp_request_firmware_files()
816 if (!wm_adsp_request_firmware_file(dsp, wmfw_firmware, wmfw_filename, in wm_adsp_request_firmware_files()
820 wm_adsp_request_firmware_file(dsp, coeff_firmware, coeff_filename, in wm_adsp_request_firmware_files()
825 wm_adsp_request_firmware_file(dsp, coeff_firmware, coeff_filename, in wm_adsp_request_firmware_files()
832 /* Check system-specific bin without wmfw before falling back to generic */ in wm_adsp_request_firmware_files()
833 if (dsp->wmfw_optional && system_name) { in wm_adsp_request_firmware_files()
835 wm_adsp_request_firmware_file(dsp, coeff_firmware, coeff_filename, in wm_adsp_request_firmware_files()
840 wm_adsp_request_firmware_file(dsp, coeff_firmware, coeff_filename, in wm_adsp_request_firmware_files()
849 if (!wm_adsp_request_firmware_file(dsp, wmfw_firmware, wmfw_filename, in wm_adsp_request_firmware_files()
851 wm_adsp_request_firmware_file(dsp, coeff_firmware, coeff_filename, in wm_adsp_request_firmware_files()
857 ret = wm_adsp_request_firmware_file(dsp, wmfw_firmware, wmfw_filename, in wm_adsp_request_firmware_files()
859 if (!ret || dsp->wmfw_optional) { in wm_adsp_request_firmware_files()
860 wm_adsp_request_firmware_file(dsp, coeff_firmware, coeff_filename, in wm_adsp_request_firmware_files()
865 adsp_err(dsp, "Failed to request firmware <%s>%s-%s-%s<-%s<%s>>.wmfw\n", in wm_adsp_request_firmware_files()
866 cirrus_dir, dsp->part, in wm_adsp_request_firmware_files()
867 dsp->fwf_name ? dsp->fwf_name : dsp->cs_dsp.name, in wm_adsp_request_firmware_files()
868 wm_adsp_fw[dsp->fw].file, system_name, asoc_component_prefix); in wm_adsp_request_firmware_files()
870 return -ENOENT; in wm_adsp_request_firmware_files()
873 static int wm_adsp_common_init(struct wm_adsp *dsp) in wm_adsp_common_init() argument
875 INIT_LIST_HEAD(&dsp->compr_list); in wm_adsp_common_init()
876 INIT_LIST_HEAD(&dsp->buffer_list); in wm_adsp_common_init()
881 int wm_adsp1_init(struct wm_adsp *dsp) in wm_adsp1_init() argument
885 dsp->cs_dsp.client_ops = &wm_adsp1_client_ops; in wm_adsp1_init()
887 ret = cs_dsp_adsp1_init(&dsp->cs_dsp); in wm_adsp1_init()
891 return wm_adsp_common_init(dsp); in wm_adsp1_init()
899 struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); in wm_adsp1_event()
901 struct wm_adsp *dsp = &dsps[w->shift]; in wm_adsp1_event() local
908 dsp->component = component; in wm_adsp1_event()
912 ret = wm_adsp_request_firmware_files(dsp, in wm_adsp1_event()
918 ret = cs_dsp_adsp1_power_up(&dsp->cs_dsp, in wm_adsp1_event()
921 wm_adsp_fw_text[dsp->fw]); in wm_adsp1_event()
923 wm_adsp_release_firmware_files(dsp, in wm_adsp1_event()
928 cs_dsp_adsp1_power_down(&dsp->cs_dsp); in wm_adsp1_event()
940 struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); in wm_adsp2_set_dspclk()
942 struct wm_adsp *dsp = &dsps[w->shift]; in wm_adsp2_set_dspclk() local
944 return cs_dsp_set_dspclk(&dsp->cs_dsp, freq); in wm_adsp2_set_dspclk()
954 (struct soc_mixer_control *)kcontrol->private_value; in wm_adsp2_preloader_get()
955 struct wm_adsp *dsp = &dsps[mc->shift - 1]; in wm_adsp2_preloader_get() local
957 ucontrol->value.integer.value[0] = dsp->preloaded; in wm_adsp2_preloader_get()
970 (struct soc_mixer_control *)kcontrol->private_value; in wm_adsp2_preloader_put()
971 struct wm_adsp *dsp = &dsps[mc->shift - 1]; in wm_adsp2_preloader_put() local
974 if (dsp->preloaded == ucontrol->value.integer.value[0]) in wm_adsp2_preloader_put()
977 snprintf(preload, ARRAY_SIZE(preload), "%s Preload", dsp->cs_dsp.name); in wm_adsp2_preloader_put()
979 if (ucontrol->value.integer.value[0] || dsp->toggle_preload) in wm_adsp2_preloader_put()
986 flush_work(&dsp->boot_work); in wm_adsp2_preloader_put()
988 dsp->preloaded = ucontrol->value.integer.value[0]; in wm_adsp2_preloader_put()
990 if (dsp->toggle_preload) { in wm_adsp2_preloader_put()
999 int wm_adsp_power_up(struct wm_adsp *dsp, bool load_firmware) in wm_adsp_power_up() argument
1008 ret = wm_adsp_request_firmware_files(dsp, in wm_adsp_power_up()
1015 ret = cs_dsp_power_up(&dsp->cs_dsp, in wm_adsp_power_up()
1018 wm_adsp_fw_text[dsp->fw]); in wm_adsp_power_up()
1020 wm_adsp_release_firmware_files(dsp, in wm_adsp_power_up()
1028 void wm_adsp_power_down(struct wm_adsp *dsp) in wm_adsp_power_down() argument
1030 cs_dsp_power_down(&dsp->cs_dsp); in wm_adsp_power_down()
1036 struct wm_adsp *dsp = container_of(work, in wm_adsp_boot_work() local
1040 wm_adsp_power_up(dsp, true); in wm_adsp_boot_work()
1046 struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); in wm_adsp_early_event()
1048 struct wm_adsp *dsp = &dsps[w->shift]; in wm_adsp_early_event() local
1052 queue_work(system_unbound_wq, &dsp->boot_work); in wm_adsp_early_event()
1055 wm_adsp_power_down(dsp); in wm_adsp_early_event()
1067 struct wm_adsp *dsp = container_of(cs_dsp, struct wm_adsp, cs_dsp); in wm_adsp_pre_run() local
1069 if (!dsp->pre_run) in wm_adsp_pre_run()
1072 return (*dsp->pre_run)(dsp); in wm_adsp_pre_run()
1077 struct wm_adsp *dsp = container_of(cs_dsp, struct wm_adsp, cs_dsp); in wm_adsp_event_post_run() local
1079 if (wm_adsp_fw[dsp->fw].num_caps != 0) in wm_adsp_event_post_run()
1080 return wm_adsp_buffer_init(dsp); in wm_adsp_event_post_run()
1087 struct wm_adsp *dsp = container_of(cs_dsp, struct wm_adsp, cs_dsp); in wm_adsp_event_post_stop() local
1089 if (wm_adsp_fw[dsp->fw].num_caps != 0) in wm_adsp_event_post_stop()
1090 wm_adsp_buffer_free(dsp); in wm_adsp_event_post_stop()
1092 dsp->fatal_error = false; in wm_adsp_event_post_stop()
1098 struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); in wm_adsp_event()
1100 struct wm_adsp *dsp = &dsps[w->shift]; in wm_adsp_event() local
1105 flush_work(&dsp->boot_work); in wm_adsp_event()
1106 ret = cs_dsp_run(&dsp->cs_dsp); in wm_adsp_event()
1109 cs_dsp_stop(&dsp->cs_dsp); in wm_adsp_event()
1119 int wm_adsp2_component_probe(struct wm_adsp *dsp, struct snd_soc_component *component) in wm_adsp2_component_probe() argument
1123 if (!dsp->cs_dsp.no_core_startstop) { in wm_adsp2_component_probe()
1124 snprintf(preload, ARRAY_SIZE(preload), "%s Preload", dsp->cs_dsp.name); in wm_adsp2_component_probe()
1128 cs_dsp_init_debugfs(&dsp->cs_dsp, component->debugfs_root); in wm_adsp2_component_probe()
1130 dsp->component = component; in wm_adsp2_component_probe()
1136 int wm_adsp2_component_remove(struct wm_adsp *dsp, struct snd_soc_component *component) in wm_adsp2_component_remove() argument
1138 cs_dsp_cleanup_debugfs(&dsp->cs_dsp); in wm_adsp2_component_remove()
1144 int wm_adsp2_init(struct wm_adsp *dsp) in wm_adsp2_init() argument
1148 INIT_WORK(&dsp->boot_work, wm_adsp_boot_work); in wm_adsp2_init()
1150 dsp->sys_config_size = sizeof(struct wm_adsp_system_config_xm_hdr); in wm_adsp2_init()
1151 dsp->cs_dsp.client_ops = &wm_adsp2_client_ops; in wm_adsp2_init()
1153 ret = cs_dsp_adsp2_init(&dsp->cs_dsp); in wm_adsp2_init()
1157 return wm_adsp_common_init(dsp); in wm_adsp2_init()
1161 int wm_halo_init(struct wm_adsp *dsp) in wm_halo_init() argument
1165 INIT_WORK(&dsp->boot_work, wm_adsp_boot_work); in wm_halo_init()
1167 dsp->sys_config_size = sizeof(struct wm_halo_system_config_xm_hdr); in wm_halo_init()
1168 dsp->cs_dsp.client_ops = &wm_adsp2_client_ops; in wm_halo_init()
1170 ret = cs_dsp_halo_init(&dsp->cs_dsp); in wm_halo_init()
1174 return wm_adsp_common_init(dsp); in wm_halo_init()
1178 void wm_adsp2_remove(struct wm_adsp *dsp) in wm_adsp2_remove() argument
1180 cs_dsp_remove(&dsp->cs_dsp); in wm_adsp2_remove()
1186 return compr->buf != NULL; in wm_adsp_compr_attached()
1193 if (compr->dsp->fatal_error) in wm_adsp_compr_attach()
1194 return -EINVAL; in wm_adsp_compr_attach()
1196 list_for_each_entry(tmp, &compr->dsp->buffer_list, list) { in wm_adsp_compr_attach()
1197 if (!tmp->name || !strcmp(compr->name, tmp->name)) { in wm_adsp_compr_attach()
1204 return -EINVAL; in wm_adsp_compr_attach()
1206 compr->buf = buf; in wm_adsp_compr_attach()
1207 buf->compr = compr; in wm_adsp_compr_attach()
1218 if (compr->stream) in wm_adsp_compr_detach()
1219 snd_compr_fragment_elapsed(compr->stream); in wm_adsp_compr_detach()
1222 compr->buf->compr = NULL; in wm_adsp_compr_detach()
1223 compr->buf = NULL; in wm_adsp_compr_detach()
1227 int wm_adsp_compr_open(struct wm_adsp *dsp, struct snd_compr_stream *stream) in wm_adsp_compr_open() argument
1230 struct snd_soc_pcm_runtime *rtd = stream->private_data; in wm_adsp_compr_open()
1233 mutex_lock(&dsp->cs_dsp.pwr_lock); in wm_adsp_compr_open()
1235 if (wm_adsp_fw[dsp->fw].num_caps == 0) { in wm_adsp_compr_open()
1236 adsp_err(dsp, "%s: Firmware does not support compressed API\n", in wm_adsp_compr_open()
1237 snd_soc_rtd_to_codec(rtd, 0)->name); in wm_adsp_compr_open()
1238 ret = -ENXIO; in wm_adsp_compr_open()
1242 if (wm_adsp_fw[dsp->fw].compr_direction != stream->direction) { in wm_adsp_compr_open()
1243 adsp_err(dsp, "%s: Firmware does not support stream direction\n", in wm_adsp_compr_open()
1244 snd_soc_rtd_to_codec(rtd, 0)->name); in wm_adsp_compr_open()
1245 ret = -EINVAL; in wm_adsp_compr_open()
1249 list_for_each_entry(tmp, &dsp->compr_list, list) { in wm_adsp_compr_open()
1250 if (!strcmp(tmp->name, snd_soc_rtd_to_codec(rtd, 0)->name)) { in wm_adsp_compr_open()
1251 adsp_err(dsp, "%s: Only a single stream supported per dai\n", in wm_adsp_compr_open()
1252 snd_soc_rtd_to_codec(rtd, 0)->name); in wm_adsp_compr_open()
1253 ret = -EBUSY; in wm_adsp_compr_open()
1260 ret = -ENOMEM; in wm_adsp_compr_open()
1264 compr->dsp = dsp; in wm_adsp_compr_open()
1265 compr->stream = stream; in wm_adsp_compr_open()
1266 compr->name = snd_soc_rtd_to_codec(rtd, 0)->name; in wm_adsp_compr_open()
1268 list_add_tail(&compr->list, &dsp->compr_list); in wm_adsp_compr_open()
1270 stream->runtime->private_data = compr; in wm_adsp_compr_open()
1273 mutex_unlock(&dsp->cs_dsp.pwr_lock); in wm_adsp_compr_open()
1282 struct wm_adsp_compr *compr = stream->runtime->private_data; in wm_adsp_compr_free()
1283 struct wm_adsp *dsp = compr->dsp; in wm_adsp_compr_free() local
1285 mutex_lock(&dsp->cs_dsp.pwr_lock); in wm_adsp_compr_free()
1288 list_del(&compr->list); in wm_adsp_compr_free()
1290 kfree(compr->raw_buf); in wm_adsp_compr_free()
1293 mutex_unlock(&dsp->cs_dsp.pwr_lock); in wm_adsp_compr_free()
1302 struct wm_adsp_compr *compr = stream->runtime->private_data; in wm_adsp_compr_check_params()
1303 struct wm_adsp *dsp = compr->dsp; in wm_adsp_compr_check_params() local
1308 if (params->buffer.fragment_size < WM_ADSP_MIN_FRAGMENT_SIZE || in wm_adsp_compr_check_params()
1309 params->buffer.fragment_size > WM_ADSP_MAX_FRAGMENT_SIZE || in wm_adsp_compr_check_params()
1310 params->buffer.fragments < WM_ADSP_MIN_FRAGMENTS || in wm_adsp_compr_check_params()
1311 params->buffer.fragments > WM_ADSP_MAX_FRAGMENTS || in wm_adsp_compr_check_params()
1312 params->buffer.fragment_size % CS_DSP_DATA_WORD_SIZE) { in wm_adsp_compr_check_params()
1314 params->buffer.fragment_size, in wm_adsp_compr_check_params()
1315 params->buffer.fragments); in wm_adsp_compr_check_params()
1317 return -EINVAL; in wm_adsp_compr_check_params()
1320 for (i = 0; i < wm_adsp_fw[dsp->fw].num_caps; i++) { in wm_adsp_compr_check_params()
1321 caps = &wm_adsp_fw[dsp->fw].caps[i]; in wm_adsp_compr_check_params()
1322 desc = &caps->desc; in wm_adsp_compr_check_params()
1324 if (caps->id != params->codec.id) in wm_adsp_compr_check_params()
1327 if (stream->direction == SND_COMPRESS_PLAYBACK) { in wm_adsp_compr_check_params()
1328 if (desc->max_ch < params->codec.ch_out) in wm_adsp_compr_check_params()
1331 if (desc->max_ch < params->codec.ch_in) in wm_adsp_compr_check_params()
1335 if (!(desc->formats & (1 << params->codec.format))) in wm_adsp_compr_check_params()
1338 for (j = 0; j < desc->num_sample_rates; ++j) in wm_adsp_compr_check_params()
1339 if (desc->sample_rates[j] == params->codec.sample_rate) in wm_adsp_compr_check_params()
1344 params->codec.id, params->codec.ch_in, params->codec.ch_out, in wm_adsp_compr_check_params()
1345 params->codec.sample_rate, params->codec.format); in wm_adsp_compr_check_params()
1346 return -EINVAL; in wm_adsp_compr_check_params()
1351 return compr->size.fragment_size / CS_DSP_DATA_WORD_SIZE; in wm_adsp_compr_frag_words()
1358 struct wm_adsp_compr *compr = stream->runtime->private_data; in wm_adsp_compr_set_params()
1366 compr->size = params->buffer; in wm_adsp_compr_set_params()
1369 compr->size.fragment_size, compr->size.fragments); in wm_adsp_compr_set_params()
1371 size = wm_adsp_compr_frag_words(compr) * sizeof(*compr->raw_buf); in wm_adsp_compr_set_params()
1372 compr->raw_buf = kmalloc(size, GFP_DMA | GFP_KERNEL); in wm_adsp_compr_set_params()
1373 if (!compr->raw_buf) in wm_adsp_compr_set_params()
1374 return -ENOMEM; in wm_adsp_compr_set_params()
1376 compr->sample_rate = params->codec.sample_rate; in wm_adsp_compr_set_params()
1386 struct wm_adsp_compr *compr = stream->runtime->private_data; in wm_adsp_compr_get_caps()
1387 int fw = compr->dsp->fw; in wm_adsp_compr_get_caps()
1392 caps->codecs[i] = wm_adsp_fw[fw].caps[i].id; in wm_adsp_compr_get_caps()
1394 caps->num_codecs = i; in wm_adsp_compr_get_caps()
1395 caps->direction = wm_adsp_fw[fw].compr_direction; in wm_adsp_compr_get_caps()
1397 caps->min_fragment_size = WM_ADSP_MIN_FRAGMENT_SIZE; in wm_adsp_compr_get_caps()
1398 caps->max_fragment_size = WM_ADSP_MAX_FRAGMENT_SIZE; in wm_adsp_compr_get_caps()
1399 caps->min_fragments = WM_ADSP_MIN_FRAGMENTS; in wm_adsp_compr_get_caps()
1400 caps->max_fragments = WM_ADSP_MAX_FRAGMENTS; in wm_adsp_compr_get_caps()
1410 return cs_dsp_read_data_word(&buf->dsp->cs_dsp, buf->host_buf_mem_type, in wm_adsp_buffer_read()
1411 buf->host_buf_ptr + field_offset, data); in wm_adsp_buffer_read()
1417 return cs_dsp_write_data_word(&buf->dsp->cs_dsp, buf->host_buf_mem_type, in wm_adsp_buffer_write()
1418 buf->host_buf_ptr + field_offset, in wm_adsp_buffer_write()
1424 const struct wm_adsp_fw_caps *caps = wm_adsp_fw[buf->dsp->fw].caps; in wm_adsp_buffer_populate()
1429 buf->regions = kcalloc(caps->num_regions, sizeof(*buf->regions), in wm_adsp_buffer_populate()
1431 if (!buf->regions) in wm_adsp_buffer_populate()
1432 return -ENOMEM; in wm_adsp_buffer_populate()
1434 for (i = 0; i < caps->num_regions; ++i) { in wm_adsp_buffer_populate()
1435 region = &buf->regions[i]; in wm_adsp_buffer_populate()
1437 region->offset = offset; in wm_adsp_buffer_populate()
1438 region->mem_type = caps->region_defs[i].mem_type; in wm_adsp_buffer_populate()
1440 ret = wm_adsp_buffer_read(buf, caps->region_defs[i].base_offset, in wm_adsp_buffer_populate()
1441 ®ion->base_addr); in wm_adsp_buffer_populate()
1445 ret = wm_adsp_buffer_read(buf, caps->region_defs[i].size_offset, in wm_adsp_buffer_populate()
1450 region->cumulative_size = offset; in wm_adsp_buffer_populate()
1454 i, region->mem_type, region->base_addr, in wm_adsp_buffer_populate()
1455 region->offset, region->cumulative_size); in wm_adsp_buffer_populate()
1461 kfree(buf->regions); in wm_adsp_buffer_populate()
1467 buf->irq_count = 0xFFFFFFFF; in wm_adsp_buffer_clear()
1468 buf->read_index = -1; in wm_adsp_buffer_clear()
1469 buf->avail = 0; in wm_adsp_buffer_clear()
1472 static struct wm_adsp_compr_buf *wm_adsp_buffer_alloc(struct wm_adsp *dsp) in wm_adsp_buffer_alloc() argument
1480 buf->dsp = dsp; in wm_adsp_buffer_alloc()
1487 static int wm_adsp_buffer_parse_legacy(struct wm_adsp *dsp) in wm_adsp_buffer_parse_legacy() argument
1494 alg_region = cs_dsp_find_alg_region(&dsp->cs_dsp, WMFW_ADSP2_XM, dsp->cs_dsp.fw_id); in wm_adsp_buffer_parse_legacy()
1496 adsp_err(dsp, "No algorithm region found\n"); in wm_adsp_buffer_parse_legacy()
1497 return -EINVAL; in wm_adsp_buffer_parse_legacy()
1500 xmalg = dsp->sys_config_size / sizeof(__be32); in wm_adsp_buffer_parse_legacy()
1502 addr = alg_region->base + xmalg + ALG_XM_FIELD(magic); in wm_adsp_buffer_parse_legacy()
1503 ret = cs_dsp_read_data_word(&dsp->cs_dsp, WMFW_ADSP2_XM, addr, &magic); in wm_adsp_buffer_parse_legacy()
1508 return -ENODEV; in wm_adsp_buffer_parse_legacy()
1510 buf = wm_adsp_buffer_alloc(dsp); in wm_adsp_buffer_parse_legacy()
1512 return -ENOMEM; in wm_adsp_buffer_parse_legacy()
1514 addr = alg_region->base + xmalg + ALG_XM_FIELD(host_buf_ptr); in wm_adsp_buffer_parse_legacy()
1516 ret = cs_dsp_read_data_word(&dsp->cs_dsp, WMFW_ADSP2_XM, addr, in wm_adsp_buffer_parse_legacy()
1517 &buf->host_buf_ptr); in wm_adsp_buffer_parse_legacy()
1521 if (buf->host_buf_ptr) in wm_adsp_buffer_parse_legacy()
1527 if (!buf->host_buf_ptr) { in wm_adsp_buffer_parse_legacy()
1528 ret = -EIO; in wm_adsp_buffer_parse_legacy()
1532 buf->host_buf_mem_type = WMFW_ADSP2_XM; in wm_adsp_buffer_parse_legacy()
1538 list_add_tail(&buf->list, &dsp->buffer_list); in wm_adsp_buffer_parse_legacy()
1540 compr_dbg(buf, "legacy host_buf_ptr=%x\n", buf->host_buf_ptr); in wm_adsp_buffer_parse_legacy()
1554 struct wm_adsp *dsp = container_of(cs_ctl->dsp, struct wm_adsp, cs_dsp); in wm_adsp_buffer_parse_coeff() local
1560 min(cs_ctl->len, sizeof(coeff_v1))); in wm_adsp_buffer_parse_coeff()
1571 adsp_err(dsp, "Failed to acquire host buffer\n"); in wm_adsp_buffer_parse_coeff()
1572 return -EIO; in wm_adsp_buffer_parse_coeff()
1575 buf = wm_adsp_buffer_alloc(dsp); in wm_adsp_buffer_parse_coeff()
1577 return -ENOMEM; in wm_adsp_buffer_parse_coeff()
1579 buf->host_buf_mem_type = cs_ctl->alg_region.type; in wm_adsp_buffer_parse_coeff()
1580 buf->host_buf_ptr = be32_to_cpu(coeff_v1.host_buf_ptr); in wm_adsp_buffer_parse_coeff()
1590 if (cs_ctl->len == 4) in wm_adsp_buffer_parse_coeff()
1597 adsp_err(dsp, in wm_adsp_buffer_parse_coeff()
1600 ret = -EINVAL; in wm_adsp_buffer_parse_coeff()
1606 buf->name = kasprintf(GFP_KERNEL, "%s-dsp-%s", dsp->part, in wm_adsp_buffer_parse_coeff()
1610 list_add_tail(&buf->list, &dsp->buffer_list); in wm_adsp_buffer_parse_coeff()
1613 buf->host_buf_ptr, version); in wm_adsp_buffer_parse_coeff()
1623 static int wm_adsp_buffer_init(struct wm_adsp *dsp) in wm_adsp_buffer_init() argument
1628 list_for_each_entry(cs_ctl, &dsp->cs_dsp.ctl_list, list) { in wm_adsp_buffer_init()
1629 if (cs_ctl->type != WMFW_CTL_TYPE_HOST_BUFFER) in wm_adsp_buffer_init()
1632 if (!cs_ctl->enabled) in wm_adsp_buffer_init()
1637 adsp_err(dsp, "Failed to parse coeff: %d\n", ret); in wm_adsp_buffer_init()
1645 if (list_empty(&dsp->buffer_list)) { in wm_adsp_buffer_init()
1647 ret = wm_adsp_buffer_parse_legacy(dsp); in wm_adsp_buffer_init()
1648 if (ret == -ENODEV) in wm_adsp_buffer_init()
1649 adsp_info(dsp, "Legacy support not available\n"); in wm_adsp_buffer_init()
1651 adsp_warn(dsp, "Failed to parse legacy: %d\n", ret); in wm_adsp_buffer_init()
1657 wm_adsp_buffer_free(dsp); in wm_adsp_buffer_init()
1661 static int wm_adsp_buffer_free(struct wm_adsp *dsp) in wm_adsp_buffer_free() argument
1665 list_for_each_entry_safe(buf, tmp, &dsp->buffer_list, list) { in wm_adsp_buffer_free()
1666 wm_adsp_compr_detach(buf->compr); in wm_adsp_buffer_free()
1668 kfree(buf->name); in wm_adsp_buffer_free()
1669 kfree(buf->regions); in wm_adsp_buffer_free()
1670 list_del(&buf->list); in wm_adsp_buffer_free()
1681 ret = wm_adsp_buffer_read(buf, HOST_BUFFER_FIELD(error), &buf->error); in wm_adsp_buffer_get_error()
1686 if (buf->error != 0) { in wm_adsp_buffer_get_error()
1687 compr_err(buf, "Buffer error occurred: %d\n", buf->error); in wm_adsp_buffer_get_error()
1688 return -EIO; in wm_adsp_buffer_get_error()
1697 struct wm_adsp_compr *compr = stream->runtime->private_data; in wm_adsp_compr_trigger()
1698 struct wm_adsp *dsp = compr->dsp; in wm_adsp_compr_trigger() local
1703 mutex_lock(&dsp->cs_dsp.pwr_lock); in wm_adsp_compr_trigger()
1716 ret = wm_adsp_buffer_get_error(compr->buf); in wm_adsp_compr_trigger()
1721 ret = wm_adsp_buffer_write(compr->buf, in wm_adsp_compr_trigger()
1732 wm_adsp_buffer_clear(compr->buf); in wm_adsp_compr_trigger()
1735 ret = -EINVAL; in wm_adsp_compr_trigger()
1739 mutex_unlock(&dsp->cs_dsp.pwr_lock); in wm_adsp_compr_trigger()
1747 int last_region = wm_adsp_fw[buf->dsp->fw].caps->num_regions - 1; in wm_adsp_buffer_size()
1749 return buf->regions[last_region].cumulative_size; in wm_adsp_buffer_size()
1759 if (buf->read_index < 0) { in wm_adsp_buffer_update_avail()
1773 buf->read_index = read_index; in wm_adsp_buffer_update_avail()
1783 avail = write_index - buf->read_index; in wm_adsp_buffer_update_avail()
1788 buf->read_index, write_index, avail * CS_DSP_DATA_WORD_SIZE); in wm_adsp_buffer_update_avail()
1790 buf->avail = avail; in wm_adsp_buffer_update_avail()
1795 int wm_adsp_compr_handle_irq(struct wm_adsp *dsp) in wm_adsp_compr_handle_irq() argument
1801 mutex_lock(&dsp->cs_dsp.pwr_lock); in wm_adsp_compr_handle_irq()
1803 if (list_empty(&dsp->buffer_list)) { in wm_adsp_compr_handle_irq()
1804 ret = -ENODEV; in wm_adsp_compr_handle_irq()
1808 adsp_dbg(dsp, "Handling buffer IRQ\n"); in wm_adsp_compr_handle_irq()
1810 list_for_each_entry(buf, &dsp->buffer_list, list) { in wm_adsp_compr_handle_irq()
1811 compr = buf->compr; in wm_adsp_compr_handle_irq()
1818 &buf->irq_count); in wm_adsp_compr_handle_irq()
1830 if (wm_adsp_fw[dsp->fw].voice_trigger && buf->irq_count == 2) in wm_adsp_compr_handle_irq()
1834 if (compr && compr->stream) in wm_adsp_compr_handle_irq()
1835 snd_compr_fragment_elapsed(compr->stream); in wm_adsp_compr_handle_irq()
1839 mutex_unlock(&dsp->cs_dsp.pwr_lock); in wm_adsp_compr_handle_irq()
1847 if (buf->irq_count & 0x01) in wm_adsp_buffer_reenable_irq()
1850 compr_dbg(buf, "Enable IRQ(0x%x) for next fragment\n", buf->irq_count); in wm_adsp_buffer_reenable_irq()
1852 buf->irq_count |= 0x01; in wm_adsp_buffer_reenable_irq()
1855 buf->irq_count); in wm_adsp_buffer_reenable_irq()
1862 struct wm_adsp_compr *compr = stream->runtime->private_data; in wm_adsp_compr_pointer()
1863 struct wm_adsp *dsp = compr->dsp; in wm_adsp_compr_pointer() local
1869 mutex_lock(&dsp->cs_dsp.pwr_lock); in wm_adsp_compr_pointer()
1871 buf = compr->buf; in wm_adsp_compr_pointer()
1873 if (dsp->fatal_error || !buf || buf->error) { in wm_adsp_compr_pointer()
1875 ret = -EIO; in wm_adsp_compr_pointer()
1879 if (buf->avail < wm_adsp_compr_frag_words(compr)) { in wm_adsp_compr_pointer()
1888 * DSP to inform us once a whole fragment is available. in wm_adsp_compr_pointer()
1890 if (buf->avail < wm_adsp_compr_frag_words(compr)) { in wm_adsp_compr_pointer()
1893 if (buf->error) in wm_adsp_compr_pointer()
1901 compr_err(compr, "Failed to re-enable buffer IRQ: %d\n", in wm_adsp_compr_pointer()
1908 tstamp->copied_total = compr->copied_total; in wm_adsp_compr_pointer()
1909 tstamp->copied_total += buf->avail * CS_DSP_DATA_WORD_SIZE; in wm_adsp_compr_pointer()
1910 tstamp->sampling_rate = compr->sample_rate; in wm_adsp_compr_pointer()
1913 mutex_unlock(&dsp->cs_dsp.pwr_lock); in wm_adsp_compr_pointer()
1921 struct wm_adsp_compr_buf *buf = compr->buf; in wm_adsp_buffer_capture_block()
1927 for (i = 0; i < wm_adsp_fw[buf->dsp->fw].caps->num_regions; ++i) in wm_adsp_buffer_capture_block()
1928 if (buf->read_index < buf->regions[i].cumulative_size) in wm_adsp_buffer_capture_block()
1931 if (i == wm_adsp_fw[buf->dsp->fw].caps->num_regions) in wm_adsp_buffer_capture_block()
1932 return -EINVAL; in wm_adsp_buffer_capture_block()
1934 mem_type = buf->regions[i].mem_type; in wm_adsp_buffer_capture_block()
1935 adsp_addr = buf->regions[i].base_addr + in wm_adsp_buffer_capture_block()
1936 (buf->read_index - buf->regions[i].offset); in wm_adsp_buffer_capture_block()
1939 nwords = buf->regions[i].cumulative_size - buf->read_index; in wm_adsp_buffer_capture_block()
1943 if (nwords > buf->avail) in wm_adsp_buffer_capture_block()
1944 nwords = buf->avail; in wm_adsp_buffer_capture_block()
1950 /* Read data from DSP */ in wm_adsp_buffer_capture_block()
1951 ret = cs_dsp_read_raw_data_block(&buf->dsp->cs_dsp, mem_type, adsp_addr, in wm_adsp_buffer_capture_block()
1952 nwords, (__be32 *)compr->raw_buf); in wm_adsp_buffer_capture_block()
1956 cs_dsp_remove_padding(compr->raw_buf, nwords); in wm_adsp_buffer_capture_block()
1959 buf->read_index += nwords; in wm_adsp_buffer_capture_block()
1960 if (buf->read_index == wm_adsp_buffer_size(buf)) in wm_adsp_buffer_capture_block()
1961 buf->read_index = 0; in wm_adsp_buffer_capture_block()
1964 buf->read_index); in wm_adsp_buffer_capture_block()
1969 buf->avail -= nwords; in wm_adsp_buffer_capture_block()
1977 struct wm_adsp *dsp = compr->dsp; in wm_adsp_compr_read() local
1983 if (dsp->fatal_error || !compr->buf || compr->buf->error) { in wm_adsp_compr_read()
1984 snd_compr_stop_error(compr->stream, SNDRV_PCM_STATE_XRUN); in wm_adsp_compr_read()
1985 return -EIO; in wm_adsp_compr_read()
2002 if (copy_to_user(buf + ntotal, compr->raw_buf, nbytes)) { in wm_adsp_compr_read()
2005 return -EFAULT; in wm_adsp_compr_read()
2008 count -= nwords; in wm_adsp_compr_read()
2012 compr->copied_total += ntotal; in wm_adsp_compr_read()
2021 struct wm_adsp_compr *compr = stream->runtime->private_data; in wm_adsp_compr_copy()
2022 struct wm_adsp *dsp = compr->dsp; in wm_adsp_compr_copy() local
2025 mutex_lock(&dsp->cs_dsp.pwr_lock); in wm_adsp_compr_copy()
2027 if (stream->direction == SND_COMPRESS_CAPTURE) in wm_adsp_compr_copy()
2030 ret = -ENOTSUPP; in wm_adsp_compr_copy()
2032 mutex_unlock(&dsp->cs_dsp.pwr_lock); in wm_adsp_compr_copy()
2040 struct wm_adsp *dsp = container_of(cs_dsp, struct wm_adsp, cs_dsp); in wm_adsp_fatal_error() local
2043 dsp->fatal_error = true; in wm_adsp_fatal_error()
2045 list_for_each_entry(compr, &dsp->compr_list, list) { in wm_adsp_fatal_error()
2046 if (compr->stream) in wm_adsp_fatal_error()
2047 snd_compr_fragment_elapsed(compr->stream); in wm_adsp_fatal_error()
2053 struct wm_adsp *dsp = (struct wm_adsp *)data; in wm_adsp2_bus_error() local
2055 cs_dsp_adsp2_bus_error(&dsp->cs_dsp); in wm_adsp2_bus_error()
2063 struct wm_adsp *dsp = (struct wm_adsp *)data; in wm_halo_bus_error() local
2065 cs_dsp_halo_bus_error(&dsp->cs_dsp); in wm_halo_bus_error()
2073 struct wm_adsp *dsp = data; in wm_halo_wdt_expire() local
2075 cs_dsp_halo_wdt_expire(&dsp->cs_dsp); in wm_halo_wdt_expire()