• Home
  • Raw
  • Download

Lines Matching refs:dsp

279 	struct wm_adsp *dsp;  member
292 struct wm_adsp *dsp; member
319 static int wm_adsp_buffer_init(struct wm_adsp *dsp);
320 static int wm_adsp_buffer_free(struct wm_adsp *dsp);
437 struct wm_adsp *dsp; member
450 static void wm_adsp_debugfs_save_wmfwname(struct wm_adsp *dsp, const char *s) in wm_adsp_debugfs_save_wmfwname() argument
454 kfree(dsp->wmfw_file_name); in wm_adsp_debugfs_save_wmfwname()
455 dsp->wmfw_file_name = tmp; in wm_adsp_debugfs_save_wmfwname()
458 static void wm_adsp_debugfs_save_binname(struct wm_adsp *dsp, const char *s) in wm_adsp_debugfs_save_binname() argument
462 kfree(dsp->bin_file_name); in wm_adsp_debugfs_save_binname()
463 dsp->bin_file_name = tmp; in wm_adsp_debugfs_save_binname()
466 static void wm_adsp_debugfs_clear(struct wm_adsp *dsp) in wm_adsp_debugfs_clear() argument
468 kfree(dsp->wmfw_file_name); in wm_adsp_debugfs_clear()
469 kfree(dsp->bin_file_name); in wm_adsp_debugfs_clear()
470 dsp->wmfw_file_name = NULL; in wm_adsp_debugfs_clear()
471 dsp->bin_file_name = NULL; in wm_adsp_debugfs_clear()
478 struct wm_adsp *dsp = file->private_data; in wm_adsp_debugfs_wmfw_read() local
481 mutex_lock(&dsp->pwr_lock); in wm_adsp_debugfs_wmfw_read()
483 if (!dsp->wmfw_file_name || !dsp->booted) in wm_adsp_debugfs_wmfw_read()
487 dsp->wmfw_file_name, in wm_adsp_debugfs_wmfw_read()
488 strlen(dsp->wmfw_file_name)); in wm_adsp_debugfs_wmfw_read()
490 mutex_unlock(&dsp->pwr_lock); in wm_adsp_debugfs_wmfw_read()
498 struct wm_adsp *dsp = file->private_data; in wm_adsp_debugfs_bin_read() local
501 mutex_lock(&dsp->pwr_lock); in wm_adsp_debugfs_bin_read()
503 if (!dsp->bin_file_name || !dsp->booted) in wm_adsp_debugfs_bin_read()
507 dsp->bin_file_name, in wm_adsp_debugfs_bin_read()
508 strlen(dsp->bin_file_name)); in wm_adsp_debugfs_bin_read()
510 mutex_unlock(&dsp->pwr_lock); in wm_adsp_debugfs_bin_read()
534 static void wm_adsp2_init_debugfs(struct wm_adsp *dsp, in wm_adsp2_init_debugfs() argument
542 adsp_err(dsp, "No codec debugfs root\n"); in wm_adsp2_init_debugfs()
550 snprintf(root_name, PAGE_SIZE, "dsp%d", dsp->num); in wm_adsp2_init_debugfs()
557 if (!debugfs_create_bool("booted", S_IRUGO, root, &dsp->booted)) in wm_adsp2_init_debugfs()
560 if (!debugfs_create_bool("running", S_IRUGO, root, &dsp->running)) in wm_adsp2_init_debugfs()
563 if (!debugfs_create_x32("fw_id", S_IRUGO, root, &dsp->fw_id)) in wm_adsp2_init_debugfs()
567 &dsp->fw_id_version)) in wm_adsp2_init_debugfs()
572 S_IRUGO, root, dsp, in wm_adsp2_init_debugfs()
577 dsp->debugfs_root = root; in wm_adsp2_init_debugfs()
582 adsp_err(dsp, "Failed to create debugfs\n"); in wm_adsp2_init_debugfs()
585 static void wm_adsp2_cleanup_debugfs(struct wm_adsp *dsp) in wm_adsp2_cleanup_debugfs() argument
587 wm_adsp_debugfs_clear(dsp); in wm_adsp2_cleanup_debugfs()
588 debugfs_remove_recursive(dsp->debugfs_root); in wm_adsp2_cleanup_debugfs()
591 static inline void wm_adsp2_init_debugfs(struct wm_adsp *dsp, in wm_adsp2_init_debugfs() argument
596 static inline void wm_adsp2_cleanup_debugfs(struct wm_adsp *dsp) in wm_adsp2_cleanup_debugfs() argument
600 static inline void wm_adsp_debugfs_save_wmfwname(struct wm_adsp *dsp, in wm_adsp_debugfs_save_wmfwname() argument
605 static inline void wm_adsp_debugfs_save_binname(struct wm_adsp *dsp, in wm_adsp_debugfs_save_binname() argument
610 static inline void wm_adsp_debugfs_clear(struct wm_adsp *dsp) in wm_adsp_debugfs_clear() argument
620 struct wm_adsp *dsp = snd_soc_codec_get_drvdata(codec); in wm_adsp_fw_get() local
622 ucontrol->value.enumerated.item[0] = dsp[e->shift_l].fw; in wm_adsp_fw_get()
632 struct wm_adsp *dsp = snd_soc_codec_get_drvdata(codec); in wm_adsp_fw_put() local
635 if (ucontrol->value.enumerated.item[0] == dsp[e->shift_l].fw) in wm_adsp_fw_put()
641 mutex_lock(&dsp[e->shift_l].pwr_lock); in wm_adsp_fw_put()
643 if (dsp[e->shift_l].booted || dsp[e->shift_l].compr) in wm_adsp_fw_put()
646 dsp[e->shift_l].fw = ucontrol->value.enumerated.item[0]; in wm_adsp_fw_put()
648 mutex_unlock(&dsp[e->shift_l].pwr_lock); in wm_adsp_fw_put()
672 static struct wm_adsp_region const *wm_adsp_find_region(struct wm_adsp *dsp, in wm_adsp_find_region() argument
677 for (i = 0; i < dsp->num_mems; i++) in wm_adsp_find_region()
678 if (dsp->mem[i].type == type) in wm_adsp_find_region()
679 return &dsp->mem[i]; in wm_adsp_find_region()
706 static void wm_adsp2_show_fw_status(struct wm_adsp *dsp) in wm_adsp2_show_fw_status() argument
711 ret = regmap_raw_read(dsp->regmap, dsp->base + ADSP2_SCRATCH0, in wm_adsp2_show_fw_status()
714 adsp_err(dsp, "Failed to read SCRATCH regs: %d\n", ret); in wm_adsp2_show_fw_status()
718 adsp_dbg(dsp, "FW SCRATCH 0:0x%x 1:0x%x 2:0x%x 3:0x%x\n", in wm_adsp2_show_fw_status()
747 struct wm_adsp *dsp = ctl->dsp; in wm_coeff_write_control() local
752 mem = wm_adsp_find_region(dsp, alg_region->type); in wm_coeff_write_control()
754 adsp_err(dsp, "No base for region %x\n", in wm_coeff_write_control()
766 ret = regmap_raw_write(dsp->regmap, reg, scratch, in wm_coeff_write_control()
769 adsp_err(dsp, "Failed to write %zu bytes to %x: %d\n", in wm_coeff_write_control()
774 adsp_dbg(dsp, "Wrote %zu bytes to %x\n", len, reg); in wm_coeff_write_control()
790 mutex_lock(&ctl->dsp->pwr_lock); in wm_coeff_put()
798 if (ctl->enabled && ctl->dsp->running) in wm_coeff_put()
801 mutex_unlock(&ctl->dsp->pwr_lock); in wm_coeff_put()
814 mutex_lock(&ctl->dsp->pwr_lock); in wm_coeff_tlv_put()
820 if (ctl->enabled && ctl->dsp->running) in wm_coeff_tlv_put()
826 mutex_unlock(&ctl->dsp->pwr_lock); in wm_coeff_tlv_put()
836 struct wm_adsp *dsp = ctl->dsp; in wm_coeff_read_control() local
841 mem = wm_adsp_find_region(dsp, alg_region->type); in wm_coeff_read_control()
843 adsp_err(dsp, "No base for region %x\n", in wm_coeff_read_control()
855 ret = regmap_raw_read(dsp->regmap, reg, scratch, len); in wm_coeff_read_control()
857 adsp_err(dsp, "Failed to read %zu bytes from %x: %d\n", in wm_coeff_read_control()
862 adsp_dbg(dsp, "Read %zu bytes from %x\n", len, reg); in wm_coeff_read_control()
879 mutex_lock(&ctl->dsp->pwr_lock); in wm_coeff_get()
882 if (ctl->enabled && ctl->dsp->running) in wm_coeff_get()
887 if (!ctl->flags && ctl->enabled && ctl->dsp->running) in wm_coeff_get()
893 mutex_unlock(&ctl->dsp->pwr_lock); in wm_coeff_get()
906 mutex_lock(&ctl->dsp->pwr_lock); in wm_coeff_tlv_get()
909 if (ctl->enabled && ctl->dsp->running) in wm_coeff_tlv_get()
914 if (!ctl->flags && ctl->enabled && ctl->dsp->running) in wm_coeff_tlv_get()
921 mutex_unlock(&ctl->dsp->pwr_lock); in wm_coeff_tlv_get()
927 struct wm_adsp *dsp; member
964 static int wmfw_add_ctl(struct wm_adsp *dsp, struct wm_coeff_ctl *ctl) in wmfw_add_ctl() argument
991 ret = snd_soc_add_card_controls(dsp->card, kcontrol, 1); in wmfw_add_ctl()
997 ctl->kcontrol = snd_soc_card_get_kcontrol(dsp->card, ctl->name); in wmfw_add_ctl()
1006 static int wm_coeff_init_control_caches(struct wm_adsp *dsp) in wm_coeff_init_control_caches() argument
1011 list_for_each_entry(ctl, &dsp->ctl_list, list) { in wm_coeff_init_control_caches()
1025 static int wm_coeff_sync_controls(struct wm_adsp *dsp) in wm_coeff_sync_controls() argument
1030 list_for_each_entry(ctl, &dsp->ctl_list, list) { in wm_coeff_sync_controls()
1049 wmfw_add_ctl(ctl_work->dsp, ctl_work->ctl); in wm_adsp_ctl_work()
1060 static int wm_adsp_create_control(struct wm_adsp *dsp, in wm_adsp_create_control() argument
1092 adsp_err(dsp, "Unknown region type: %d\n", alg_region->type); in wm_adsp_create_control()
1096 switch (dsp->fw_ver) { in wm_adsp_create_control()
1100 dsp->num, region_name, alg_region->alg); in wm_adsp_create_control()
1104 "DSP%d%c %.12s %x", dsp->num, *region_name, in wm_adsp_create_control()
1105 wm_adsp_fw_text[dsp->fw], alg_region->alg); in wm_adsp_create_control()
1122 list_for_each_entry(ctl, &dsp->ctl_list, list) { in wm_adsp_create_control()
1133 ctl->fw_name = wm_adsp_fw_text[dsp->fw]; in wm_adsp_create_control()
1144 ctl->dsp = dsp; in wm_adsp_create_control()
1155 list_add(&ctl->list, &dsp->ctl_list); in wm_adsp_create_control()
1163 ctl_work->dsp = dsp; in wm_adsp_create_control()
1240 static inline void wm_coeff_parse_alg(struct wm_adsp *dsp, const u8 **data, in wm_coeff_parse_alg() argument
1245 switch (dsp->fw_ver) { in wm_coeff_parse_alg()
1265 adsp_dbg(dsp, "Algorithm ID: %#x\n", blk->id); in wm_coeff_parse_alg()
1266 adsp_dbg(dsp, "Algorithm name: %.*s\n", blk->name_len, blk->name); in wm_coeff_parse_alg()
1267 adsp_dbg(dsp, "# of coefficient descriptors: %#x\n", blk->ncoeff); in wm_coeff_parse_alg()
1270 static inline void wm_coeff_parse_coeff(struct wm_adsp *dsp, const u8 **data, in wm_coeff_parse_coeff() argument
1277 switch (dsp->fw_ver) { in wm_coeff_parse_coeff()
1308 adsp_dbg(dsp, "\tCoefficient type: %#x\n", blk->mem_type); in wm_coeff_parse_coeff()
1309 adsp_dbg(dsp, "\tCoefficient offset: %#x\n", blk->offset); in wm_coeff_parse_coeff()
1310 adsp_dbg(dsp, "\tCoefficient name: %.*s\n", blk->name_len, blk->name); in wm_coeff_parse_coeff()
1311 adsp_dbg(dsp, "\tCoefficient flags: %#x\n", blk->flags); in wm_coeff_parse_coeff()
1312 adsp_dbg(dsp, "\tALSA control type: %#x\n", blk->ctl_type); in wm_coeff_parse_coeff()
1313 adsp_dbg(dsp, "\tALSA control len: %#x\n", blk->len); in wm_coeff_parse_coeff()
1316 static int wm_adsp_parse_coeff(struct wm_adsp *dsp, in wm_adsp_parse_coeff() argument
1325 wm_coeff_parse_alg(dsp, &data, &alg_blk); in wm_adsp_parse_coeff()
1327 wm_coeff_parse_coeff(dsp, &data, &coeff_blk); in wm_adsp_parse_coeff()
1333 adsp_err(dsp, "Unknown control type: %d\n", in wm_adsp_parse_coeff()
1341 ret = wm_adsp_create_control(dsp, &alg_region, in wm_adsp_parse_coeff()
1348 adsp_err(dsp, "Failed to create control: %.*s, %d\n", in wm_adsp_parse_coeff()
1355 static int wm_adsp_load(struct wm_adsp *dsp) in wm_adsp_load() argument
1359 struct regmap *regmap = dsp->regmap; in wm_adsp_load()
1378 snprintf(file, PAGE_SIZE, "%s-dsp%d-%s.wmfw", dsp->part, dsp->num, in wm_adsp_load()
1379 wm_adsp_fw[dsp->fw].file); in wm_adsp_load()
1382 ret = request_firmware(&firmware, file, dsp->dev); in wm_adsp_load()
1384 adsp_err(dsp, "Failed to request '%s'\n", file); in wm_adsp_load()
1391 adsp_err(dsp, "%s: file too short, %zu bytes\n", in wm_adsp_load()
1399 adsp_err(dsp, "%s: invalid magic\n", file); in wm_adsp_load()
1405 adsp_warn(dsp, "%s: Depreciated file format %d\n", in wm_adsp_load()
1412 adsp_err(dsp, "%s: unknown file format %d\n", in wm_adsp_load()
1417 adsp_info(dsp, "Firmware version: %d\n", header->ver); in wm_adsp_load()
1418 dsp->fw_ver = header->ver; in wm_adsp_load()
1420 if (header->core != dsp->type) { in wm_adsp_load()
1421 adsp_err(dsp, "%s: invalid core %d != %d\n", in wm_adsp_load()
1422 file, header->core, dsp->type); in wm_adsp_load()
1426 switch (dsp->type) { in wm_adsp_load()
1433 adsp_dbg(dsp, "%s: %d DM, %d PM, %d ZM\n", in wm_adsp_load()
1445 adsp_dbg(dsp, "%s: %d XM, %d YM %d PM, %d ZM\n", in wm_adsp_load()
1459 adsp_err(dsp, "%s: unexpected header length %d\n", in wm_adsp_load()
1464 adsp_dbg(dsp, "%s: timestamp %llu\n", file, in wm_adsp_load()
1475 mem = wm_adsp_find_region(dsp, type); in wm_adsp_load()
1485 ret = wm_adsp_parse_coeff(dsp, region); in wm_adsp_load()
1519 adsp_warn(dsp, in wm_adsp_load()
1525 adsp_dbg(dsp, "%s.%d: %d bytes at %d in %s\n", file, in wm_adsp_load()
1531 adsp_err(dsp, in wm_adsp_load()
1541 adsp_info(dsp, "%s: %s\n", file, text); in wm_adsp_load()
1551 adsp_err(dsp, "Out of memory\n"); in wm_adsp_load()
1559 adsp_err(dsp, in wm_adsp_load()
1574 adsp_err(dsp, "Failed to complete async write: %d\n", ret); in wm_adsp_load()
1579 adsp_warn(dsp, "%s.%d: %zu bytes at end of file\n", in wm_adsp_load()
1582 wm_adsp_debugfs_save_wmfwname(dsp, file); in wm_adsp_load()
1595 static void wm_adsp_ctl_fixup_base(struct wm_adsp *dsp, in wm_adsp_ctl_fixup_base() argument
1600 list_for_each_entry(ctl, &dsp->ctl_list, list) { in wm_adsp_ctl_fixup_base()
1601 if (ctl->fw_name == wm_adsp_fw_text[dsp->fw] && in wm_adsp_ctl_fixup_base()
1609 static void *wm_adsp_read_algs(struct wm_adsp *dsp, size_t n_algs, in wm_adsp_read_algs() argument
1617 adsp_err(dsp, "No algorithms\n"); in wm_adsp_read_algs()
1622 adsp_err(dsp, "Algorithm count %zx excessive\n", n_algs); in wm_adsp_read_algs()
1627 ret = regmap_raw_read(dsp->regmap, pos + len, &val, sizeof(val)); in wm_adsp_read_algs()
1629 adsp_err(dsp, "Failed to read algorithm list end: %d\n", in wm_adsp_read_algs()
1635 adsp_warn(dsp, "Algorithm list end %x 0x%x != 0xbeadead\n", in wm_adsp_read_algs()
1642 ret = regmap_raw_read(dsp->regmap, pos, alg, len * 2); in wm_adsp_read_algs()
1644 adsp_err(dsp, "Failed to read algorithm list: %d\n", ret); in wm_adsp_read_algs()
1653 wm_adsp_find_alg_region(struct wm_adsp *dsp, int type, unsigned int id) in wm_adsp_find_alg_region() argument
1657 list_for_each_entry(alg_region, &dsp->alg_regions, list) { in wm_adsp_find_alg_region()
1665 static struct wm_adsp_alg_region *wm_adsp_create_region(struct wm_adsp *dsp, in wm_adsp_create_region() argument
1679 list_add_tail(&alg_region->list, &dsp->alg_regions); in wm_adsp_create_region()
1681 if (dsp->fw_ver > 0) in wm_adsp_create_region()
1682 wm_adsp_ctl_fixup_base(dsp, alg_region); in wm_adsp_create_region()
1687 static void wm_adsp_free_alg_regions(struct wm_adsp *dsp) in wm_adsp_free_alg_regions() argument
1691 while (!list_empty(&dsp->alg_regions)) { in wm_adsp_free_alg_regions()
1692 alg_region = list_first_entry(&dsp->alg_regions, in wm_adsp_free_alg_regions()
1700 static int wm_adsp1_setup_algs(struct wm_adsp *dsp) in wm_adsp1_setup_algs() argument
1710 mem = wm_adsp_find_region(dsp, WMFW_ADSP1_DM); in wm_adsp1_setup_algs()
1714 ret = regmap_raw_read(dsp->regmap, mem->base, &adsp1_id, in wm_adsp1_setup_algs()
1717 adsp_err(dsp, "Failed to read algorithm info: %d\n", in wm_adsp1_setup_algs()
1723 dsp->fw_id = be32_to_cpu(adsp1_id.fw.id); in wm_adsp1_setup_algs()
1724 adsp_info(dsp, "Firmware: %x v%d.%d.%d, %zu algorithms\n", in wm_adsp1_setup_algs()
1725 dsp->fw_id, in wm_adsp1_setup_algs()
1731 alg_region = wm_adsp_create_region(dsp, WMFW_ADSP1_ZM, in wm_adsp1_setup_algs()
1736 alg_region = wm_adsp_create_region(dsp, WMFW_ADSP1_DM, in wm_adsp1_setup_algs()
1744 adsp1_alg = wm_adsp_read_algs(dsp, n_algs, mem->base + pos, len); in wm_adsp1_setup_algs()
1749 adsp_info(dsp, "%d: ID %x v%d.%d.%d DM@%x ZM@%x\n", in wm_adsp1_setup_algs()
1757 alg_region = wm_adsp_create_region(dsp, WMFW_ADSP1_DM, in wm_adsp1_setup_algs()
1764 if (dsp->fw_ver == 0) { in wm_adsp1_setup_algs()
1769 wm_adsp_create_control(dsp, alg_region, 0, in wm_adsp1_setup_algs()
1772 adsp_warn(dsp, "Missing length info for region DM with ID %x\n", in wm_adsp1_setup_algs()
1777 alg_region = wm_adsp_create_region(dsp, WMFW_ADSP1_ZM, in wm_adsp1_setup_algs()
1784 if (dsp->fw_ver == 0) { in wm_adsp1_setup_algs()
1789 wm_adsp_create_control(dsp, alg_region, 0, in wm_adsp1_setup_algs()
1792 adsp_warn(dsp, "Missing length info for region ZM with ID %x\n", in wm_adsp1_setup_algs()
1803 static int wm_adsp2_setup_algs(struct wm_adsp *dsp) in wm_adsp2_setup_algs() argument
1813 mem = wm_adsp_find_region(dsp, WMFW_ADSP2_XM); in wm_adsp2_setup_algs()
1817 ret = regmap_raw_read(dsp->regmap, mem->base, &adsp2_id, in wm_adsp2_setup_algs()
1820 adsp_err(dsp, "Failed to read algorithm info: %d\n", in wm_adsp2_setup_algs()
1826 dsp->fw_id = be32_to_cpu(adsp2_id.fw.id); in wm_adsp2_setup_algs()
1827 dsp->fw_id_version = be32_to_cpu(adsp2_id.fw.ver); in wm_adsp2_setup_algs()
1828 adsp_info(dsp, "Firmware: %x v%d.%d.%d, %zu algorithms\n", in wm_adsp2_setup_algs()
1829 dsp->fw_id, in wm_adsp2_setup_algs()
1830 (dsp->fw_id_version & 0xff0000) >> 16, in wm_adsp2_setup_algs()
1831 (dsp->fw_id_version & 0xff00) >> 8, in wm_adsp2_setup_algs()
1832 dsp->fw_id_version & 0xff, in wm_adsp2_setup_algs()
1835 alg_region = wm_adsp_create_region(dsp, WMFW_ADSP2_XM, in wm_adsp2_setup_algs()
1840 alg_region = wm_adsp_create_region(dsp, WMFW_ADSP2_YM, in wm_adsp2_setup_algs()
1845 alg_region = wm_adsp_create_region(dsp, WMFW_ADSP2_ZM, in wm_adsp2_setup_algs()
1853 adsp2_alg = wm_adsp_read_algs(dsp, n_algs, mem->base + pos, len); in wm_adsp2_setup_algs()
1858 adsp_info(dsp, in wm_adsp2_setup_algs()
1868 alg_region = wm_adsp_create_region(dsp, WMFW_ADSP2_XM, in wm_adsp2_setup_algs()
1875 if (dsp->fw_ver == 0) { in wm_adsp2_setup_algs()
1880 wm_adsp_create_control(dsp, alg_region, 0, in wm_adsp2_setup_algs()
1883 adsp_warn(dsp, "Missing length info for region XM with ID %x\n", in wm_adsp2_setup_algs()
1888 alg_region = wm_adsp_create_region(dsp, WMFW_ADSP2_YM, in wm_adsp2_setup_algs()
1895 if (dsp->fw_ver == 0) { in wm_adsp2_setup_algs()
1900 wm_adsp_create_control(dsp, alg_region, 0, in wm_adsp2_setup_algs()
1903 adsp_warn(dsp, "Missing length info for region YM with ID %x\n", in wm_adsp2_setup_algs()
1908 alg_region = wm_adsp_create_region(dsp, WMFW_ADSP2_ZM, in wm_adsp2_setup_algs()
1915 if (dsp->fw_ver == 0) { in wm_adsp2_setup_algs()
1920 wm_adsp_create_control(dsp, alg_region, 0, in wm_adsp2_setup_algs()
1923 adsp_warn(dsp, "Missing length info for region ZM with ID %x\n", in wm_adsp2_setup_algs()
1934 static int wm_adsp_load_coeff(struct wm_adsp *dsp) in wm_adsp_load_coeff() argument
1937 struct regmap *regmap = dsp->regmap; in wm_adsp_load_coeff()
1952 snprintf(file, PAGE_SIZE, "%s-dsp%d-%s.bin", dsp->part, dsp->num, in wm_adsp_load_coeff()
1953 wm_adsp_fw[dsp->fw].file); in wm_adsp_load_coeff()
1956 ret = request_firmware(&firmware, file, dsp->dev); in wm_adsp_load_coeff()
1958 adsp_warn(dsp, "Failed to request '%s'\n", file); in wm_adsp_load_coeff()
1965 adsp_err(dsp, "%s: file too short, %zu bytes\n", in wm_adsp_load_coeff()
1972 adsp_err(dsp, "%s: invalid magic\n", file); in wm_adsp_load_coeff()
1980 adsp_err(dsp, "%s: Unsupported coefficient file format %d\n", in wm_adsp_load_coeff()
1986 adsp_dbg(dsp, "%s: v%d.%d.%d\n", file, in wm_adsp_load_coeff()
2001 adsp_dbg(dsp, "%s.%d: %x v%d.%d.%d\n", in wm_adsp_load_coeff()
2006 adsp_dbg(dsp, "%s.%d: %d bytes at 0x%x in %x\n", in wm_adsp_load_coeff()
2020 if (le32_to_cpu(blk->id) == dsp->fw_id && in wm_adsp_load_coeff()
2023 mem = wm_adsp_find_region(dsp, type); in wm_adsp_load_coeff()
2025 adsp_err(dsp, "No ZM\n"); in wm_adsp_load_coeff()
2040 adsp_dbg(dsp, "%s.%d: %d bytes in %x for %x\n", in wm_adsp_load_coeff()
2044 mem = wm_adsp_find_region(dsp, type); in wm_adsp_load_coeff()
2046 adsp_err(dsp, "No base for region %x\n", type); in wm_adsp_load_coeff()
2050 alg_region = wm_adsp_find_alg_region(dsp, type, in wm_adsp_load_coeff()
2057 adsp_err(dsp, "No %x for algorithm %x\n", in wm_adsp_load_coeff()
2063 adsp_err(dsp, "%s.%d: Unknown region type %x at %d\n", in wm_adsp_load_coeff()
2071 adsp_err(dsp, in wm_adsp_load_coeff()
2084 adsp_err(dsp, "Out of memory\n"); in wm_adsp_load_coeff()
2089 adsp_dbg(dsp, "%s.%d: Writing %d bytes at %x\n", in wm_adsp_load_coeff()
2095 adsp_err(dsp, in wm_adsp_load_coeff()
2107 adsp_err(dsp, "Failed to complete async write: %d\n", ret); in wm_adsp_load_coeff()
2110 adsp_warn(dsp, "%s.%d: %zu bytes at end of file\n", in wm_adsp_load_coeff()
2113 wm_adsp_debugfs_save_binname(dsp, file); in wm_adsp_load_coeff()
2124 int wm_adsp1_init(struct wm_adsp *dsp) in wm_adsp1_init() argument
2126 INIT_LIST_HEAD(&dsp->alg_regions); in wm_adsp1_init()
2128 mutex_init(&dsp->pwr_lock); in wm_adsp1_init()
2140 struct wm_adsp *dsp = &dsps[w->shift]; in wm_adsp1_event() local
2145 dsp->card = codec->component.card; in wm_adsp1_event()
2147 mutex_lock(&dsp->pwr_lock); in wm_adsp1_event()
2151 regmap_update_bits(dsp->regmap, dsp->base + ADSP1_CONTROL_30, in wm_adsp1_event()
2158 if (dsp->sysclk_reg) { in wm_adsp1_event()
2159 ret = regmap_read(dsp->regmap, dsp->sysclk_reg, &val); in wm_adsp1_event()
2161 adsp_err(dsp, "Failed to read SYSCLK state: %d\n", in wm_adsp1_event()
2166 val = (val & dsp->sysclk_mask) >> dsp->sysclk_shift; in wm_adsp1_event()
2168 ret = regmap_update_bits(dsp->regmap, in wm_adsp1_event()
2169 dsp->base + ADSP1_CONTROL_31, in wm_adsp1_event()
2172 adsp_err(dsp, "Failed to set clock rate: %d\n", in wm_adsp1_event()
2178 ret = wm_adsp_load(dsp); in wm_adsp1_event()
2182 ret = wm_adsp1_setup_algs(dsp); in wm_adsp1_event()
2186 ret = wm_adsp_load_coeff(dsp); in wm_adsp1_event()
2191 ret = wm_coeff_init_control_caches(dsp); in wm_adsp1_event()
2196 ret = wm_coeff_sync_controls(dsp); in wm_adsp1_event()
2200 dsp->booted = true; in wm_adsp1_event()
2203 regmap_update_bits(dsp->regmap, dsp->base + ADSP1_CONTROL_30, in wm_adsp1_event()
2207 dsp->running = true; in wm_adsp1_event()
2211 dsp->running = false; in wm_adsp1_event()
2212 dsp->booted = false; in wm_adsp1_event()
2215 regmap_update_bits(dsp->regmap, dsp->base + ADSP1_CONTROL_30, in wm_adsp1_event()
2218 regmap_update_bits(dsp->regmap, dsp->base + ADSP1_CONTROL_19, in wm_adsp1_event()
2221 regmap_update_bits(dsp->regmap, dsp->base + ADSP1_CONTROL_30, in wm_adsp1_event()
2224 list_for_each_entry(ctl, &dsp->ctl_list, list) in wm_adsp1_event()
2228 wm_adsp_free_alg_regions(dsp); in wm_adsp1_event()
2235 mutex_unlock(&dsp->pwr_lock); in wm_adsp1_event()
2240 regmap_update_bits(dsp->regmap, dsp->base + ADSP1_CONTROL_30, in wm_adsp1_event()
2243 mutex_unlock(&dsp->pwr_lock); in wm_adsp1_event()
2249 static int wm_adsp2_ena(struct wm_adsp *dsp) in wm_adsp2_ena() argument
2254 ret = regmap_update_bits_async(dsp->regmap, dsp->base + ADSP2_CONTROL, in wm_adsp2_ena()
2261 ret = regmap_read(dsp->regmap, dsp->base + ADSP2_STATUS1, &val); in wm_adsp2_ena()
2272 adsp_err(dsp, "Failed to start DSP RAM\n"); in wm_adsp2_ena()
2276 adsp_dbg(dsp, "RAM ready after %d polls\n", count); in wm_adsp2_ena()
2283 struct wm_adsp *dsp = container_of(work, in wm_adsp2_boot_work() local
2288 mutex_lock(&dsp->pwr_lock); in wm_adsp2_boot_work()
2290 ret = regmap_update_bits(dsp->regmap, dsp->base + ADSP2_CONTROL, in wm_adsp2_boot_work()
2295 ret = wm_adsp2_ena(dsp); in wm_adsp2_boot_work()
2299 ret = wm_adsp_load(dsp); in wm_adsp2_boot_work()
2303 ret = wm_adsp2_setup_algs(dsp); in wm_adsp2_boot_work()
2307 ret = wm_adsp_load_coeff(dsp); in wm_adsp2_boot_work()
2312 ret = wm_coeff_init_control_caches(dsp); in wm_adsp2_boot_work()
2316 dsp->booted = true; in wm_adsp2_boot_work()
2319 ret = regmap_update_bits(dsp->regmap, dsp->base + ADSP2_CONTROL, in wm_adsp2_boot_work()
2324 mutex_unlock(&dsp->pwr_lock); in wm_adsp2_boot_work()
2329 regmap_update_bits(dsp->regmap, dsp->base + ADSP2_CONTROL, in wm_adsp2_boot_work()
2332 mutex_unlock(&dsp->pwr_lock); in wm_adsp2_boot_work()
2335 static void wm_adsp2_set_dspclk(struct wm_adsp *dsp, unsigned int freq) in wm_adsp2_set_dspclk() argument
2339 ret = regmap_update_bits_async(dsp->regmap, in wm_adsp2_set_dspclk()
2340 dsp->base + ADSP2_CLOCKING, in wm_adsp2_set_dspclk()
2344 adsp_err(dsp, "Failed to set clock rate: %d\n", ret); in wm_adsp2_set_dspclk()
2353 struct wm_adsp *dsp = &dsps[w->shift]; in wm_adsp2_early_event() local
2356 dsp->card = codec->component.card; in wm_adsp2_early_event()
2360 wm_adsp2_set_dspclk(dsp, freq); in wm_adsp2_early_event()
2361 queue_work(system_unbound_wq, &dsp->boot_work); in wm_adsp2_early_event()
2364 wm_adsp_debugfs_clear(dsp); in wm_adsp2_early_event()
2366 dsp->fw_id = 0; in wm_adsp2_early_event()
2367 dsp->fw_id_version = 0; in wm_adsp2_early_event()
2369 dsp->booted = false; in wm_adsp2_early_event()
2371 regmap_update_bits(dsp->regmap, dsp->base + ADSP2_CONTROL, in wm_adsp2_early_event()
2374 list_for_each_entry(ctl, &dsp->ctl_list, list) in wm_adsp2_early_event()
2377 wm_adsp_free_alg_regions(dsp); in wm_adsp2_early_event()
2379 adsp_dbg(dsp, "Shutdown complete\n"); in wm_adsp2_early_event()
2394 struct wm_adsp *dsp = &dsps[w->shift]; in wm_adsp2_event() local
2399 flush_work(&dsp->boot_work); in wm_adsp2_event()
2401 if (!dsp->booted) in wm_adsp2_event()
2404 ret = wm_adsp2_ena(dsp); in wm_adsp2_event()
2409 ret = wm_coeff_sync_controls(dsp); in wm_adsp2_event()
2413 ret = regmap_update_bits(dsp->regmap, in wm_adsp2_event()
2414 dsp->base + ADSP2_CONTROL, in wm_adsp2_event()
2420 dsp->running = true; in wm_adsp2_event()
2422 mutex_lock(&dsp->pwr_lock); in wm_adsp2_event()
2424 if (wm_adsp_fw[dsp->fw].num_caps != 0) in wm_adsp2_event()
2425 ret = wm_adsp_buffer_init(dsp); in wm_adsp2_event()
2427 mutex_unlock(&dsp->pwr_lock); in wm_adsp2_event()
2433 wm_adsp2_show_fw_status(dsp); in wm_adsp2_event()
2435 mutex_lock(&dsp->pwr_lock); in wm_adsp2_event()
2437 dsp->running = false; in wm_adsp2_event()
2439 regmap_update_bits(dsp->regmap, dsp->base + ADSP2_CONTROL, in wm_adsp2_event()
2443 regmap_write(dsp->regmap, dsp->base + ADSP2_RDMA_CONFIG_1, 0); in wm_adsp2_event()
2444 regmap_write(dsp->regmap, dsp->base + ADSP2_WDMA_CONFIG_1, 0); in wm_adsp2_event()
2445 regmap_write(dsp->regmap, dsp->base + ADSP2_WDMA_CONFIG_2, 0); in wm_adsp2_event()
2447 regmap_update_bits(dsp->regmap, dsp->base + ADSP2_CONTROL, in wm_adsp2_event()
2450 if (wm_adsp_fw[dsp->fw].num_caps != 0) in wm_adsp2_event()
2451 wm_adsp_buffer_free(dsp); in wm_adsp2_event()
2453 mutex_unlock(&dsp->pwr_lock); in wm_adsp2_event()
2455 adsp_dbg(dsp, "Execution stopped\n"); in wm_adsp2_event()
2464 regmap_update_bits(dsp->regmap, dsp->base + ADSP2_CONTROL, in wm_adsp2_event()
2470 int wm_adsp2_codec_probe(struct wm_adsp *dsp, struct snd_soc_codec *codec) in wm_adsp2_codec_probe() argument
2472 wm_adsp2_init_debugfs(dsp, codec); in wm_adsp2_codec_probe()
2475 &wm_adsp_fw_controls[dsp->num - 1], in wm_adsp2_codec_probe()
2480 int wm_adsp2_codec_remove(struct wm_adsp *dsp, struct snd_soc_codec *codec) in wm_adsp2_codec_remove() argument
2482 wm_adsp2_cleanup_debugfs(dsp); in wm_adsp2_codec_remove()
2488 int wm_adsp2_init(struct wm_adsp *dsp) in wm_adsp2_init() argument
2496 ret = regmap_update_bits(dsp->regmap, dsp->base + ADSP2_CONTROL, in wm_adsp2_init()
2499 adsp_err(dsp, "Failed to clear memory retention: %d\n", ret); in wm_adsp2_init()
2503 INIT_LIST_HEAD(&dsp->alg_regions); in wm_adsp2_init()
2504 INIT_LIST_HEAD(&dsp->ctl_list); in wm_adsp2_init()
2505 INIT_WORK(&dsp->boot_work, wm_adsp2_boot_work); in wm_adsp2_init()
2507 mutex_init(&dsp->pwr_lock); in wm_adsp2_init()
2513 void wm_adsp2_remove(struct wm_adsp *dsp) in wm_adsp2_remove() argument
2517 while (!list_empty(&dsp->ctl_list)) { in wm_adsp2_remove()
2518 ctl = list_first_entry(&dsp->ctl_list, struct wm_coeff_ctl, in wm_adsp2_remove()
2537 if (!compr->dsp->buffer) in wm_adsp_compr_attach()
2540 compr->buf = compr->dsp->buffer; in wm_adsp_compr_attach()
2561 int wm_adsp_compr_open(struct wm_adsp *dsp, struct snd_compr_stream *stream) in wm_adsp_compr_open() argument
2566 mutex_lock(&dsp->pwr_lock); in wm_adsp_compr_open()
2568 if (wm_adsp_fw[dsp->fw].num_caps == 0) { in wm_adsp_compr_open()
2569 adsp_err(dsp, "Firmware does not support compressed API\n"); in wm_adsp_compr_open()
2574 if (wm_adsp_fw[dsp->fw].compr_direction != stream->direction) { in wm_adsp_compr_open()
2575 adsp_err(dsp, "Firmware does not support stream direction\n"); in wm_adsp_compr_open()
2580 if (dsp->compr) { in wm_adsp_compr_open()
2582 adsp_err(dsp, "Only a single stream supported per DSP\n"); in wm_adsp_compr_open()
2593 compr->dsp = dsp; in wm_adsp_compr_open()
2596 dsp->compr = compr; in wm_adsp_compr_open()
2601 mutex_unlock(&dsp->pwr_lock); in wm_adsp_compr_open()
2610 struct wm_adsp *dsp = compr->dsp; in wm_adsp_compr_free() local
2612 mutex_lock(&dsp->pwr_lock); in wm_adsp_compr_free()
2615 dsp->compr = NULL; in wm_adsp_compr_free()
2620 mutex_unlock(&dsp->pwr_lock); in wm_adsp_compr_free()
2630 struct wm_adsp *dsp = compr->dsp; in wm_adsp_compr_check_params() local
2640 adsp_err(dsp, "Invalid buffer fragsize=%d fragments=%d\n", in wm_adsp_compr_check_params()
2647 for (i = 0; i < wm_adsp_fw[dsp->fw].num_caps; i++) { in wm_adsp_compr_check_params()
2648 caps = &wm_adsp_fw[dsp->fw].caps[i]; in wm_adsp_compr_check_params()
2670 adsp_err(dsp, "Invalid params id=%u ch=%u,%u rate=%u fmt=%u\n", in wm_adsp_compr_check_params()
2694 adsp_dbg(compr->dsp, "fragment_size=%d fragments=%d\n", in wm_adsp_compr_set_params()
2712 int fw = compr->dsp->fw; in wm_adsp_compr_get_caps()
2732 static int wm_adsp_read_data_block(struct wm_adsp *dsp, int mem_type, in wm_adsp_read_data_block() argument
2736 struct wm_adsp_region const *mem = wm_adsp_find_region(dsp, mem_type); in wm_adsp_read_data_block()
2745 ret = regmap_raw_read(dsp->regmap, reg, data, in wm_adsp_read_data_block()
2756 static inline int wm_adsp_read_data_word(struct wm_adsp *dsp, int mem_type, in wm_adsp_read_data_word() argument
2759 return wm_adsp_read_data_block(dsp, mem_type, mem_addr, 1, data); in wm_adsp_read_data_word()
2762 static int wm_adsp_write_data_word(struct wm_adsp *dsp, int mem_type, in wm_adsp_write_data_word() argument
2765 struct wm_adsp_region const *mem = wm_adsp_find_region(dsp, mem_type); in wm_adsp_write_data_word()
2775 return regmap_raw_write(dsp->regmap, reg, &data, sizeof(data)); in wm_adsp_write_data_word()
2781 return wm_adsp_read_data_word(buf->dsp, WMFW_ADSP2_XM, in wm_adsp_buffer_read()
2788 return wm_adsp_write_data_word(buf->dsp, WMFW_ADSP2_XM, in wm_adsp_buffer_write()
2795 struct wm_adsp *dsp = buf->dsp; in wm_adsp_buffer_locate() local
2799 alg_region = wm_adsp_find_alg_region(dsp, WMFW_ADSP2_XM, dsp->fw_id); in wm_adsp_buffer_locate()
2803 ret = wm_adsp_read_data_word(dsp, WMFW_ADSP2_XM, addr, &magic); in wm_adsp_buffer_locate()
2812 ret = wm_adsp_read_data_word(dsp, WMFW_ADSP2_XM, addr, in wm_adsp_buffer_locate()
2826 adsp_dbg(dsp, "host_buf_ptr=%x\n", buf->host_buf_ptr); in wm_adsp_buffer_locate()
2833 const struct wm_adsp_fw_caps *caps = wm_adsp_fw[buf->dsp->fw].caps; in wm_adsp_buffer_populate()
2856 adsp_dbg(buf->dsp, in wm_adsp_buffer_populate()
2865 static int wm_adsp_buffer_init(struct wm_adsp *dsp) in wm_adsp_buffer_init() argument
2874 buf->dsp = dsp; in wm_adsp_buffer_init()
2880 adsp_err(dsp, "Failed to acquire host buffer: %d\n", ret); in wm_adsp_buffer_init()
2884 buf->regions = kcalloc(wm_adsp_fw[dsp->fw].caps->num_regions, in wm_adsp_buffer_init()
2893 adsp_err(dsp, "Failed to populate host buffer: %d\n", ret); in wm_adsp_buffer_init()
2897 dsp->buffer = buf; in wm_adsp_buffer_init()
2908 static int wm_adsp_buffer_free(struct wm_adsp *dsp) in wm_adsp_buffer_free() argument
2910 if (dsp->buffer) { in wm_adsp_buffer_free()
2911 wm_adsp_compr_detach(dsp->buffer->compr); in wm_adsp_buffer_free()
2913 kfree(dsp->buffer->regions); in wm_adsp_buffer_free()
2914 kfree(dsp->buffer); in wm_adsp_buffer_free()
2916 dsp->buffer = NULL; in wm_adsp_buffer_free()
2925 struct wm_adsp *dsp = compr->dsp; in wm_adsp_compr_trigger() local
2928 adsp_dbg(dsp, "Trigger: %d\n", cmd); in wm_adsp_compr_trigger()
2930 mutex_lock(&dsp->pwr_lock); in wm_adsp_compr_trigger()
2939 adsp_err(dsp, "Failed to link buffer and stream: %d\n", in wm_adsp_compr_trigger()
2949 adsp_err(dsp, "Failed to set high water mark: %d\n", in wm_adsp_compr_trigger()
2961 mutex_unlock(&dsp->pwr_lock); in wm_adsp_compr_trigger()
2969 int last_region = wm_adsp_fw[buf->dsp->fw].caps->num_regions - 1; in wm_adsp_buffer_size()
2991 adsp_dbg(buf->dsp, "Avail check on unstarted stream\n"); in wm_adsp_buffer_update_avail()
3009 adsp_dbg(buf->dsp, "readindex=0x%x, writeindex=0x%x, avail=%d\n", in wm_adsp_buffer_update_avail()
3023 adsp_err(buf->dsp, "Failed to check buffer error: %d\n", ret); in wm_adsp_buffer_get_error()
3027 adsp_err(buf->dsp, "Buffer error occurred: %d\n", buf->error); in wm_adsp_buffer_get_error()
3034 int wm_adsp_compr_handle_irq(struct wm_adsp *dsp) in wm_adsp_compr_handle_irq() argument
3040 mutex_lock(&dsp->pwr_lock); in wm_adsp_compr_handle_irq()
3042 buf = dsp->buffer; in wm_adsp_compr_handle_irq()
3043 compr = dsp->compr; in wm_adsp_compr_handle_irq()
3050 adsp_dbg(dsp, "Handling buffer IRQ\n"); in wm_adsp_compr_handle_irq()
3059 adsp_err(dsp, "Failed to get irq_count: %d\n", ret); in wm_adsp_compr_handle_irq()
3065 adsp_err(dsp, "Error reading avail: %d\n", ret); in wm_adsp_compr_handle_irq()
3069 if (wm_adsp_fw[dsp->fw].voice_trigger && buf->irq_count == 2) in wm_adsp_compr_handle_irq()
3077 mutex_unlock(&dsp->pwr_lock); in wm_adsp_compr_handle_irq()
3088 adsp_dbg(buf->dsp, "Enable IRQ(0x%x) for next fragment\n", in wm_adsp_buffer_reenable_irq()
3101 struct wm_adsp *dsp = compr->dsp; in wm_adsp_compr_pointer() local
3105 adsp_dbg(dsp, "Pointer request\n"); in wm_adsp_compr_pointer()
3107 mutex_lock(&dsp->pwr_lock); in wm_adsp_compr_pointer()
3120 adsp_err(dsp, "Error reading avail: %d\n", ret); in wm_adsp_compr_pointer()
3139 adsp_err(dsp, in wm_adsp_compr_pointer()
3152 mutex_unlock(&dsp->pwr_lock); in wm_adsp_compr_pointer()
3168 for (i = 0; i < wm_adsp_fw[buf->dsp->fw].caps->num_regions; ++i) in wm_adsp_buffer_capture_block()
3172 if (i == wm_adsp_fw[buf->dsp->fw].caps->num_regions) in wm_adsp_buffer_capture_block()
3192 ret = wm_adsp_read_data_block(buf->dsp, mem_type, adsp_addr, in wm_adsp_buffer_capture_block()
3224 struct wm_adsp *dsp = compr->dsp; in wm_adsp_compr_read() local
3228 adsp_dbg(dsp, "Requested read of %zu bytes\n", count); in wm_adsp_compr_read()
3240 adsp_err(dsp, "Failed to capture block: %d\n", nwords); in wm_adsp_compr_read()
3246 adsp_dbg(dsp, "Read %d bytes\n", nbytes); in wm_adsp_compr_read()
3249 adsp_err(dsp, "Failed to copy data to user: %d, %d\n", in wm_adsp_compr_read()
3267 struct wm_adsp *dsp = compr->dsp; in wm_adsp_compr_copy() local
3270 mutex_lock(&dsp->pwr_lock); in wm_adsp_compr_copy()
3277 mutex_unlock(&dsp->pwr_lock); in wm_adsp_compr_copy()