Lines Matching +full:dsp +full:- +full:config +full:- +full:name
1 // SPDX-License-Identifier: GPL-2.0
5 // Copyright (C) 2022 - 2024 Texas Instruments Incorporated
12 // Author: Shenghao Ding <shenghao-ding@ti.com>
13 // Author: Kevin Lu <kevin-lu@ti.com>
32 #include <sound/tas2781-tlv.h>
49 * tas2781_digital_getvol - get the volum control
54 * tas2781 contains book and page two-level register map, especially
65 (struct soc_mixer_control *)kcontrol->private_value; in tas2781_digital_getvol()
76 (struct soc_mixer_control *)kcontrol->private_value; in tas2781_digital_putvol()
87 (struct soc_mixer_control *)kcontrol->private_value; in tas2781_amp_getvol()
99 (struct soc_mixer_control *)kcontrol->private_value; in tas2781_amp_putvol()
112 ucontrol->value.integer.value[0] = (int)tas_priv->force_fwload_status; in tas2781_force_fwload_get()
113 dev_dbg(tas_priv->dev, "%s : Force FWload %s\n", __func__, in tas2781_force_fwload_get()
114 tas_priv->force_fwload_status ? "ON" : "OFF"); in tas2781_force_fwload_get()
126 bool change, val = (bool)ucontrol->value.integer.value[0]; in tas2781_force_fwload_put()
128 if (tas_priv->force_fwload_status == val) in tas2781_force_fwload_put()
132 tas_priv->force_fwload_status = val; in tas2781_force_fwload_put()
134 dev_dbg(tas_priv->dev, "%s : Force FWload %s\n", __func__, in tas2781_force_fwload_put()
135 tas_priv->force_fwload_status ? "ON" : "OFF"); in tas2781_force_fwload_put()
158 if (tas_priv->rcabin.profile_cfg_id != in tasdevice_set_profile_id()
159 ucontrol->value.integer.value[0]) { in tasdevice_set_profile_id()
160 tas_priv->rcabin.profile_cfg_id = in tasdevice_set_profile_id()
161 ucontrol->value.integer.value[0]; in tasdevice_set_profile_id()
173 struct tasdevice_fw *tas_fw = tas_priv->fmw; in tasdevice_info_programs()
175 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; in tasdevice_info_programs()
176 uinfo->count = 1; in tasdevice_info_programs()
177 uinfo->value.integer.min = 0; in tasdevice_info_programs()
178 uinfo->value.integer.max = (int)tas_fw->nr_programs; in tasdevice_info_programs()
189 struct tasdevice_fw *tas_fw = tas_priv->fmw; in tasdevice_info_configurations()
191 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; in tasdevice_info_configurations()
192 uinfo->count = 1; in tasdevice_info_configurations()
193 uinfo->value.integer.min = 0; in tasdevice_info_configurations()
194 uinfo->value.integer.max = (int)tas_fw->nr_configurations - 1; in tasdevice_info_configurations()
205 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; in tasdevice_info_profile()
206 uinfo->count = 1; in tasdevice_info_profile()
207 uinfo->value.integer.min = 0; in tasdevice_info_profile()
208 uinfo->value.integer.max = tas_priv->rcabin.ncfgs - 1; in tasdevice_info_profile()
219 ucontrol->value.integer.value[0] = tas_priv->rcabin.profile_cfg_id; in tasdevice_get_profile_id()
230 char *name; in tasdevice_create_control() local
232 prof_ctrls = devm_kcalloc(tas_priv->dev, nr_controls, in tasdevice_create_control()
235 ret = -ENOMEM; in tasdevice_create_control()
240 name = devm_kzalloc(tas_priv->dev, SNDRV_CTL_ELEM_ID_NAME_MAXLEN, in tasdevice_create_control()
242 if (!name) { in tasdevice_create_control()
243 ret = -ENOMEM; in tasdevice_create_control()
246 scnprintf(name, SNDRV_CTL_ELEM_ID_NAME_MAXLEN, "Speaker Profile Id"); in tasdevice_create_control()
247 prof_ctrls[mix_index].name = name; in tasdevice_create_control()
254 ret = snd_soc_add_component_controls(tas_priv->codec, in tasdevice_create_control()
267 ucontrol->value.integer.value[0] = tas_priv->cur_prog; in tasdevice_program_get()
277 unsigned int nr_program = ucontrol->value.integer.value[0]; in tasdevice_program_put()
280 if (tas_priv->cur_prog != nr_program) { in tasdevice_program_put()
281 tas_priv->cur_prog = nr_program; in tasdevice_program_put()
295 ucontrol->value.integer.value[0] = tas_priv->cur_conf; in tasdevice_configuration_get()
306 unsigned int nr_configuration = ucontrol->value.integer.value[0]; in tasdevice_configuration_put()
309 if (tas_priv->cur_conf != nr_configuration) { in tasdevice_configuration_put()
310 tas_priv->cur_conf = nr_configuration; in tasdevice_configuration_put()
329 dsp_ctrls = devm_kcalloc(tas_priv->dev, nr_controls, in tasdevice_dsp_create_ctrls()
332 ret = -ENOMEM; in tasdevice_dsp_create_ctrls()
337 prog_name = devm_kzalloc(tas_priv->dev, in tasdevice_dsp_create_ctrls()
339 conf_name = devm_kzalloc(tas_priv->dev, SNDRV_CTL_ELEM_ID_NAME_MAXLEN, in tasdevice_dsp_create_ctrls()
342 ret = -ENOMEM; in tasdevice_dsp_create_ctrls()
348 dsp_ctrls[mix_index].name = prog_name; in tasdevice_dsp_create_ctrls()
356 "Speaker Config Id"); in tasdevice_dsp_create_ctrls()
357 dsp_ctrls[mix_index].name = conf_name; in tasdevice_dsp_create_ctrls()
364 ret = snd_soc_add_component_controls(tas_priv->codec, dsp_ctrls, in tasdevice_dsp_create_ctrls()
378 mutex_lock(&tas_priv->codec_lock); in tasdevice_fw_ready()
390 * The baseline is the RCA-only case, and then the code attempts to in tasdevice_fw_ready()
391 * load DSP firmware but in case of failures just keep going, i.e. in tasdevice_fw_ready()
392 * failing to load DSP firmware is NOT an error. in tasdevice_fw_ready()
394 tas_priv->fw_state = TASDEVICE_RCA_FW_OK; in tasdevice_fw_ready()
395 scnprintf(tas_priv->coef_binaryname, 64, "%s_coef.bin", in tasdevice_fw_ready()
396 tas_priv->dev_name); in tasdevice_fw_ready()
399 dev_err(tas_priv->dev, "dspfw load %s error\n", in tasdevice_fw_ready()
400 tas_priv->coef_binaryname); in tasdevice_fw_ready()
405 * If no dsp-related kcontrol created, the dsp resource will be freed. in tasdevice_fw_ready()
409 dev_err(tas_priv->dev, "dsp controls error\n"); in tasdevice_fw_ready()
413 tas_priv->fw_state = TASDEVICE_DSP_FW_ALL_OK; in tasdevice_fw_ready()
415 /* If calibrated data occurs error, dsp will still works with default in tasdevice_fw_ready()
418 for (i = 0; i < tas_priv->ndev; i++) { in tasdevice_fw_ready()
419 scnprintf(tas_priv->cal_binaryname[i], 64, "%s_cal_0x%02x.bin", in tasdevice_fw_ready()
420 tas_priv->dev_name, tas_priv->tasdevice[i].dev_addr); in tasdevice_fw_ready()
422 tas_priv->cal_binaryname[i], i); in tasdevice_fw_ready()
424 dev_err(tas_priv->dev, in tasdevice_fw_ready()
426 __func__, tas_priv->cal_binaryname[i]); in tasdevice_fw_ready()
430 tas_priv->cur_prog = 0; in tasdevice_fw_ready()
432 if (tas_priv->fw_state == TASDEVICE_RCA_FW_OK) { in tasdevice_fw_ready()
433 /* If DSP FW fail, DSP kcontrol won't be created. */ in tasdevice_fw_ready()
436 mutex_unlock(&tas_priv->codec_lock); in tasdevice_fw_ready()
444 struct snd_soc_component *codec = snd_soc_dapm_to_component(w->dapm); in tasdevice_dapm_event()
449 mutex_lock(&tas_priv->codec_lock); in tasdevice_dapm_event()
454 mutex_unlock(&tas_priv->codec_lock); in tasdevice_dapm_event()
478 struct snd_soc_component *codec = dai->component; in tasdevice_startup()
481 switch (tas_priv->fw_state) { in tasdevice_startup()
486 return -EINVAL; in tasdevice_startup()
505 dev_err(tas_priv->dev, "%s: incorrect sample rate = %u\n", in tasdevice_hw_params()
507 rc = -EINVAL; in tasdevice_hw_params()
519 dev_err(tas_priv->dev, "%s: incorrect slot width = %u\n", in tasdevice_hw_params()
521 rc = -EINVAL; in tasdevice_hw_params()
527 dev_err(tas_priv->dev, "%s: incorrect bclk rate = %d\n", in tasdevice_hw_params()
542 tas_priv->sysclk = freq; in tasdevice_set_dai_sysclk()
555 .name = "tas2781_codec",
590 tas_priv->fw_state = TASDEVICE_DSP_FW_PENDING; in tasdevice_deinit()
617 struct i2c_client *client = (struct i2c_client *)tas_priv->client; in tasdevice_parse_dt()
621 if (tas_priv->isacpi) { in tasdevice_parse_dt()
622 ndev = device_property_read_u32_array(&client->dev, in tasdevice_parse_dt()
623 "ti,audio-slots", NULL, 0); in tasdevice_parse_dt()
626 dev_addrs[0] = client->addr; in tasdevice_parse_dt()
630 ndev = device_property_read_u32_array(&client->dev, in tasdevice_parse_dt()
631 "ti,audio-slots", dev_addrs, ndev); in tasdevice_parse_dt()
634 tas_priv->irq = in tasdevice_parse_dt()
635 acpi_dev_gpio_irq_get(ACPI_COMPANION(&client->dev), 0); in tasdevice_parse_dt()
637 struct device_node *np = tas_priv->dev->of_node; in tasdevice_parse_dt()
646 tas_priv->irq = of_irq_get(np, 0); in tasdevice_parse_dt()
649 dev_addrs[0] = client->addr; in tasdevice_parse_dt()
651 tas_priv->ndev = ndev; in tasdevice_parse_dt()
653 tas_priv->tasdevice[i].dev_addr = dev_addrs[i]; in tasdevice_parse_dt()
655 tas_priv->reset = devm_gpiod_get_optional(&client->dev, in tasdevice_parse_dt()
657 if (IS_ERR(tas_priv->reset)) in tasdevice_parse_dt()
658 dev_err(tas_priv->dev, "%s Can't get reset GPIO\n", in tasdevice_parse_dt()
661 strcpy(tas_priv->dev_name, tasdevice_id[tas_priv->chip_id].name); in tasdevice_parse_dt()
673 return -ENOMEM; in tasdevice_i2c_probe()
675 dev_set_drvdata(&i2c->dev, tas_priv); in tasdevice_i2c_probe()
677 if (ACPI_HANDLE(&i2c->dev)) { in tasdevice_i2c_probe()
678 acpi_id = acpi_match_device(i2c->dev.driver->acpi_match_table, in tasdevice_i2c_probe()
679 &i2c->dev); in tasdevice_i2c_probe()
681 dev_err(&i2c->dev, "No driver data\n"); in tasdevice_i2c_probe()
682 ret = -EINVAL; in tasdevice_i2c_probe()
685 tas_priv->chip_id = acpi_id->driver_data; in tasdevice_i2c_probe()
686 tas_priv->isacpi = true; in tasdevice_i2c_probe()
688 tas_priv->chip_id = id ? id->driver_data : 0; in tasdevice_i2c_probe()
689 tas_priv->isacpi = false; in tasdevice_i2c_probe()
698 ret = devm_snd_soc_register_component(tas_priv->dev, in tasdevice_i2c_probe()
702 dev_err(tas_priv->dev, "%s: codec register error:0x%08x\n", in tasdevice_i2c_probe()
730 .name = "tas2781-codec",
743 MODULE_AUTHOR("Shenghao Ding <shenghao-ding@ti.com>");
744 MODULE_AUTHOR("Kevin Lu <kevin-lu@ti.com>");