Lines Matching +full:spk +full:- +full:mute

1 // SPDX-License-Identifier: GPL-2.0
13 // Author: Kevin Lu <kevin-lu@ti.com>
33 #include <sound/tas2781-tlv.h>
609 dev_err(tas_dev->dev, "cal data magic number mismatch"); in tas2783_validate_calibdata()
610 return -EINVAL; in tas2783_validate_calibdata()
615 dev_err(tas_dev->dev, "cal data spk_count too large"); in tas2783_validate_calibdata()
616 return -EINVAL; in tas2783_validate_calibdata()
621 dev_dbg(tas_dev->dev, "cal data timestamp: %ld-%d-%d %d:%d:%d", in tas2783_validate_calibdata()
629 dev_err(tas_dev->dev, "cali data sz too large"); in tas2783_validate_calibdata()
630 return -EINVAL; in tas2783_validate_calibdata()
632 dev_err(tas_dev->dev, "cali data size mismatch calc=%u vs %d\n", in tas2783_validate_calibdata()
634 return -EINVAL; in tas2783_validate_calibdata()
638 size_calculated - TAS2783_CALIB_CRC_SZ) ^ ~0; in tas2783_validate_calibdata()
639 crc_read = tmp_val[(size_calculated - TAS2783_CALIB_CRC_SZ) / sizeof(u32)]; in tas2783_validate_calibdata()
641 dev_err(tas_dev->dev, in tas2783_validate_calibdata()
644 return -EINVAL; in tas2783_validate_calibdata()
660 if (cali_data[offset] != tas_dev->sdw_peripheral->id.unique_id) { in tas2783_set_calib_params_to_device()
672 regmap_bulk_write(tas_dev->regmap, tas2783_cali_reg[i], in tas2783_set_calib_params_to_device()
679 dev_err(tas_dev->dev, "device not found\n"); in tas2783_set_calib_params_to_device()
681 dev_dbg(tas_dev->dev, "calib data update done\n"); in tas2783_set_calib_params_to_device()
694 tmp_val = (u32 *)tas_dev->cali_data.data; in tas2783_update_calibdata()
707 dev_err(tas_dev->dev, "cali data too large\n"); in tas2783_update_calibdata()
711 tas_dev->cali_data.read_sz = size; in tas2783_update_calibdata()
714 &tas_dev->cali_data.read_sz, in tas2783_update_calibdata()
715 tas_dev->cali_data.data); in tas2783_update_calibdata()
716 dev_dbg(tas_dev->dev, "cali get %lu bytes result:%ld\n", in tas2783_update_calibdata()
717 tas_dev->cali_data.read_sz, status); in tas2783_update_calibdata()
725 dev_dbg(tas_dev->dev, "No calibration data in UEFI."); in tas2783_update_calibdata()
729 mutex_lock(&tas_dev->calib_lock); in tas2783_update_calibdata()
730 ret = tas2783_validate_calibdata(tas_dev, tas_dev->cali_data.data, in tas2783_update_calibdata()
731 tas_dev->cali_data.read_sz); in tas2783_update_calibdata()
734 mutex_unlock(&tas_dev->calib_lock); in tas2783_update_calibdata()
741 hdr->vendor_id = get_unaligned_le16(&data[0]); in read_header()
742 hdr->file_id = get_unaligned_le32(&data[2]); in read_header()
743 hdr->version = get_unaligned_le16(&data[6]); in read_header()
744 hdr->length = get_unaligned_le32(&data[8]); in read_header()
756 if (!fmw || !fmw->data) { in tas2783_fw_ready()
758 dev_err(tas_dev->dev, in tas2783_fw_ready()
759 "Failed to read %s, no side-effect on driver running\n", in tas2783_fw_ready()
760 tas_dev->rca_binaryname); in tas2783_fw_ready()
761 ret = -EINVAL; in tas2783_fw_ready()
765 img_sz = fmw->size; in tas2783_fw_ready()
766 buf = fmw->data; in tas2783_fw_ready()
768 if (offset >= (img_sz - FW_FL_HDR)) { in tas2783_fw_ready()
769 dev_err(tas_dev->dev, in tas2783_fw_ready()
771 ret = -EINVAL; in tas2783_fw_ready()
775 mutex_lock(&tas_dev->pde_lock); in tas2783_fw_ready()
776 while (offset < (img_sz - FW_FL_HDR)) { in tas2783_fw_ready()
779 dev_dbg(tas_dev->dev, in tas2783_fw_ready()
784 file_blk_size = hdr.length - FW_FL_HDR; in tas2783_fw_ready()
788 ret = -EINVAL; in tas2783_fw_ready()
789 dev_err(tas_dev->dev, in tas2783_fw_ready()
796 ret = sdw_nwrite_no_pm(tas_dev->sdw_peripheral, in tas2783_fw_ready()
800 dev_err(tas_dev->dev, in tas2783_fw_ready()
805 ret = sdw_nwrite_no_pm(tas_dev->sdw_peripheral, in tas2783_fw_ready()
809 dev_err(tas_dev->dev, in tas2783_fw_ready()
815 ret = -EINVAL; in tas2783_fw_ready()
816 dev_err(tas_dev->dev, "Unsupported file"); in tas2783_fw_ready()
825 mutex_unlock(&tas_dev->pde_lock); in tas2783_fw_ready()
831 tas_dev->fw_dl_success = true; in tas2783_fw_ready()
832 tas_dev->fw_dl_task_done = true; in tas2783_fw_ready()
833 wake_up(&tas_dev->fw_wait); in tas2783_fw_ready()
840 return regmap_update_bits(priv->regmap, in tas_clear_latch()
848 struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); in tas_fu21_event()
850 s32 mute; in tas_fu21_event() local
854 mute = 0; in tas_fu21_event()
858 mute = 1; in tas_fu21_event()
862 return sdw_write_no_pm(tas_dev->sdw_peripheral, in tas_fu21_event()
864 TAS2783_SDCA_CTL_FU_MUTE, 1), mute); in tas_fu21_event()
870 struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); in tas_fu23_event()
872 s32 mute; in tas_fu23_event() local
876 mute = 0; in tas_fu23_event()
880 mute = 1; in tas_fu23_event()
884 return sdw_write_no_pm(tas_dev->sdw_peripheral, in tas_fu23_event()
886 TAS2783_SDCA_CTL_FU_MUTE, 1), mute); in tas_fu23_event()
897 SND_SOC_DAPM_OUTPUT("SPK"),
903 {"SPK", NULL, "FU21"},
905 {"SPK", NULL, "FU23"},
930 struct snd_soc_component *component = dai->component; in tas_sdw_hw_params()
936 struct sdw_slave *sdw_peripheral = tas_dev->sdw_peripheral; in tas_sdw_hw_params()
939 if (!tas_dev->fw_dl_success) { in tas_sdw_hw_params()
940 dev_err(tas_dev->dev, "error playback without fw download"); in tas_sdw_hw_params()
941 return -EINVAL; in tas_sdw_hw_params()
946 return -EINVAL; in tas_sdw_hw_params()
950 dev_err(tas_dev->dev, in tas_sdw_hw_params()
953 mutex_lock(&tas_dev->pde_lock); in tas_sdw_hw_params()
960 ret = regmap_write(tas_dev->regmap, in tas_sdw_hw_params()
967 } while (retry--); in tas_sdw_hw_params()
968 mutex_unlock(&tas_dev->pde_lock); in tas_sdw_hw_params()
976 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) in tas_sdw_hw_params()
984 dev_err(dai->dev, "Unable to configure port\n"); in tas_sdw_hw_params()
993 struct snd_soc_component *component = dai->component; in tas_sdw_pcm_hw_free()
999 sdw_stream_remove_slave(tas_dev->sdw_peripheral, sdw_stream); in tas_sdw_pcm_hw_free()
1001 mutex_lock(&tas_dev->pde_lock); in tas_sdw_pcm_hw_free()
1002 ret = regmap_write(tas_dev->regmap, in tas_sdw_pcm_hw_free()
1006 mutex_unlock(&tas_dev->pde_lock); in tas_sdw_pcm_hw_free()
1020 .name = "tas2783-codec",
1046 tas_dev->component = component; in tas_component_probe()
1047 tas25xx_register_misc(tas_dev->sdw_peripheral); in tas_component_probe()
1057 tas_dev->component = NULL; in tas_component_remove()
1077 dev_set_drvdata(tas_dev->dev, tas_dev); in tas_init()
1078 ret = devm_snd_soc_register_component(tas_dev->dev, in tas_init()
1083 dev_err(tas_dev->dev, "%s: codec register error:%d.\n", in tas_init()
1089 pm_runtime_set_autosuspend_delay(tas_dev->dev, 3000); in tas_init()
1090 pm_runtime_use_autosuspend(tas_dev->dev); in tas_init()
1092 pm_runtime_mark_last_busy(tas_dev->dev); in tas_init()
1093 pm_runtime_enable(tas_dev->dev); in tas_init()
1100 struct sdw_slave_prop *prop = &slave->prop; in tas_read_prop()
1107 prop->scp_int1_mask = in tas_read_prop()
1109 prop->quirks = SDW_SLAVE_QUIRKS_INVALID_INITIAL_PARITY; in tas_read_prop()
1111 prop->paging_support = true; in tas_read_prop()
1114 prop->source_ports = 0x04; /* BITMAP: 00000100 */ in tas_read_prop()
1115 prop->sink_ports = 0x2; /* BITMAP: 00000010 */ in tas_read_prop()
1117 nval = hweight32(prop->source_ports); in tas_read_prop()
1118 prop->src_dpn_prop = devm_kcalloc(&slave->dev, nval, in tas_read_prop()
1119 sizeof(*prop->src_dpn_prop), GFP_KERNEL); in tas_read_prop()
1120 if (!prop->src_dpn_prop) in tas_read_prop()
1121 return -ENOMEM; in tas_read_prop()
1124 dpn = prop->src_dpn_prop; in tas_read_prop()
1125 addr = prop->source_ports; in tas_read_prop()
1135 nval = hweight32(prop->sink_ports); in tas_read_prop()
1136 prop->sink_dpn_prop = devm_kcalloc(&slave->dev, nval, in tas_read_prop()
1137 sizeof(*prop->sink_dpn_prop), GFP_KERNEL); in tas_read_prop()
1138 if (!prop->sink_dpn_prop) in tas_read_prop()
1139 return -ENOMEM; in tas_read_prop()
1142 dpn = prop->sink_dpn_prop; in tas_read_prop()
1143 addr = prop->sink_ports; in tas_read_prop()
1153 prop->clk_stop_timeout = 200; in tas_read_prop()
1162 if (!tas_dev->hw_init) in tas2783_sdca_dev_suspend()
1165 regcache_cache_only(tas_dev->regmap, true); in tas2783_sdca_dev_suspend()
1180 if (!slave->unattach_request) in tas2783_sdca_dev_resume()
1183 t = wait_for_completion_timeout(&slave->initialization_complete, in tas2783_sdca_dev_resume()
1186 dev_err(&slave->dev, "resume: initialization timed out\n"); in tas2783_sdca_dev_resume()
1187 sdw_show_ping_status(slave->bus, true); in tas2783_sdca_dev_resume()
1188 return -ETIMEDOUT; in tas2783_sdca_dev_resume()
1191 slave->unattach_request = 0; in tas2783_sdca_dev_resume()
1194 regcache_cache_only(tas_dev->regmap, false); in tas2783_sdca_dev_resume()
1195 regcache_sync(tas_dev->regmap); in tas2783_sdca_dev_resume()
1208 u8 unique_id = tas_dev->sdw_peripheral->id.unique_id; in tas_io_init()
1210 if (tas_dev->hw_init) in tas_io_init()
1213 tas_dev->fw_dl_task_done = false; in tas_io_init()
1214 tas_dev->fw_dl_success = false; in tas_io_init()
1215 scnprintf(tas_dev->rca_binaryname, sizeof(tas_dev->rca_binaryname), in tas_io_init()
1216 "tas2783-%01x.bin", unique_id); in tas_io_init()
1219 tas_dev->rca_binaryname, tas_dev->dev, in tas_io_init()
1222 dev_err(tas_dev->dev, in tas_io_init()
1228 ret = wait_event_timeout(tas_dev->fw_wait, tas_dev->fw_dl_task_done, in tas_io_init()
1231 dev_err(tas_dev->dev, "fw request, wait_event timeout\n"); in tas_io_init()
1232 ret = -EAGAIN; in tas_io_init()
1234 ret = regmap_multi_reg_write(tas_dev->regmap, tas2783_init_seq, in tas_io_init()
1236 tas_dev->hw_init = true; in tas_io_init()
1245 struct tas2783_prv *tas_dev = dev_get_drvdata(&slave->dev); in tas_update_status()
1246 struct device *dev = &slave->dev; in tas_update_status()
1252 tas_dev->status = status; in tas_update_status()
1254 tas_dev->hw_init = false; in tas_update_status()
1259 if (tas_dev->hw_init || tas_dev->status != SDW_SLAVE_ATTACHED) in tas_update_status()
1263 regcache_cache_only(tas_dev->regmap, false); in tas_update_status()
1264 regcache_sync(tas_dev->regmap); in tas_update_status()
1267 return tas_io_init(&slave->dev, slave); in tas_update_status()
1277 snd_soc_unregister_component(tas_dev->dev); in tas_remove()
1284 struct device *dev = &peripheral->dev; in tas_sdw_probe()
1289 return dev_err_probe(dev, -ENOMEM, in tas_sdw_probe()
1292 tas_dev->dev = dev; in tas_sdw_probe()
1293 tas_dev->sdw_peripheral = peripheral; in tas_sdw_probe()
1294 tas_dev->hw_init = false; in tas_sdw_probe()
1295 mutex_init(&tas_dev->calib_lock); in tas_sdw_probe()
1296 mutex_init(&tas_dev->pde_lock); in tas_sdw_probe()
1298 init_waitqueue_head(&tas_dev->fw_wait); in tas_sdw_probe()
1309 tas_dev->regmap = regmap; in tas_sdw_probe()
1315 struct tas2783_prv *tas_dev = dev_get_drvdata(&peripheral->dev); in tas_sdw_remove()
1317 pm_runtime_disable(tas_dev->dev); in tas_sdw_remove()
1319 mutex_destroy(&tas_dev->calib_lock); in tas_sdw_remove()
1320 mutex_destroy(&tas_dev->pde_lock); in tas_sdw_remove()
1321 dev_set_drvdata(&peripheral->dev, NULL); in tas_sdw_remove()
1335 .name = "slave-tas2783",