ASoC: tas2781: add capture_profile_id field and update the tuning_switch function
Subsystems (3)
Shenghao Ding
maintainerPATCH v2 1/1 ASoC: tas2781: add capture_profile_id field and update the tuning_switch function
Currently, the TAS2781 SmartAMP driver uses the same profile ID for both playback and capture scenarios (e.g., PDM microphone recording or IV data capture). This makes it impossible to apply different DSP configurations for capture and playback, which is required in real-world tuning and production use cases. With these changes, capture and playback paths now use their own DSP profiles, improving tuning flexibility and avoiding unintended profile conflicts between SmartAMP capture and playback scenarios.
---
v2:
- Update the git commit diff to include changes for both the header file and all modified source C files, instead of only touching the header.
- Add missing userspace input validation for profile control.
--- include/sound/tas2781-dsp.h | 7 +- .../hda/codecs/side-codecs/tas2781_hda_i2c.c | 10 +- .../hda/codecs/side-codecs/tas2781_hda_spi.c | 12 +- sound/soc/codecs/tas2781-fmwlib.c | 6 +- sound/soc/codecs/tas2781-i2c.c | 133 +++++++++++++++++- 5 files changed, 151 insertions(+), 17 deletions(-)
include/sound/tas2781-dsp.h +6 -1
@@ -201,6 +201,11 @@ struct tasdevice_rca {int ncfgs;struct tasdevice_config_info **cfg_info;int profile_cfg_id; +/* +* Used among SmartAMP for PDM microphone recording or IV data +* capture. +*/ +int capture_profile_id;/* * Since version 0x105, the keyword 'init' was introduced into the * profile, which is used for chip initialization, particularly to
@@ -222,7 +227,7 @@ void tasdevice_calbin_remove(void *context);int tasdevice_select_tuningprm_cfg (void *context,int prm,int cfg_no,int rca_conf_no);int tasdevice_prmg_load (void *context,int prm_no); -void tasdevice_tuning_switch (void *context,int state); +void tasdevice_tuning_switch (void *context,int state,bool is_cap);int tas2781_load_calibration (void *context,char *file_name,unsigned short i);
sound/hda/codecs/side-codecs/tas2781_hda_i2c.c +5 -5
@@ -173,13 +173,13 @@ static void tas2781_hda_playback_hook(struct device *dev, int action)case HDA_GEN_PCM_ACT_OPEN :pm_runtime_get_sync (dev); scoped_guard(mutex, &tas_hda->priv->codec_lock) { -tasdevice_tuning_switch (tas_hda->priv,0 ); +tasdevice_tuning_switch (tas_hda->priv,0 , false); tas_hda->priv->playback_started = true; }break ;case HDA_GEN_PCM_ACT_CLOSE : scoped_guard(mutex, &tas_hda->priv->codec_lock) { -tasdevice_tuning_switch (tas_hda->priv,1 ); +tasdevice_tuning_switch (tas_hda->priv,1 , false); tas_hda->priv->playback_started = false; }
@@ -722,7 +722,7 @@ static int tas2781_runtime_suspend(struct device *dev)* Stop the playback if it's unused. */ if (tas_hda->priv->playback_started) { -tasdevice_tuning_switch (tas_hda->priv,1 ); +tasdevice_tuning_switch (tas_hda->priv,1 , false); tas_hda->priv->playback_started = false; }
@@ -752,7 +752,7 @@ static int tas2781_system_suspend(struct device *dev)/* Shutdown chip before system suspend */ if (tas_hda->priv->playback_started) -tasdevice_tuning_switch (tas_hda->priv,1 ); +tasdevice_tuning_switch (tas_hda->priv,1 , false);/* * Reset GPIO may be shared, so cannot reset here.
@@ -785,7 +785,7 @@ static int tas2781_system_resume(struct device *dev) TASDEVICE_BIN_BLK_PRE_POWER_UP);if (tas_hda->priv->playback_started) -tasdevice_tuning_switch (tas_hda->priv,0 ); +tasdevice_tuning_switch (tas_hda->priv,0 , false);return 0 ; }
sound/hda/codecs/side-codecs/tas2781_hda_spi.c +6 -6
@@ -399,11 +399,11 @@ static void tas2781_hda_playback_hook(struct device *dev, int action)pm_runtime_get_sync (dev);guard (mutex)(&tas_priv->codec_lock);if (tas_priv->fw_state ==TASDEVICE_DSP_FW_ALL_OK ) -tasdevice_tuning_switch (tas_hda->priv,0 ); +tasdevice_tuning_switch (tas_hda->priv,0 , false); }else if (action ==HDA_GEN_PCM_ACT_CLOSE ) {guard (mutex)(&tas_priv->codec_lock);if (tas_priv->fw_state ==TASDEVICE_DSP_FW_ALL_OK ) -tasdevice_tuning_switch (tas_priv,1 ); +tasdevice_tuning_switch (tas_priv,1 , false);pm_runtime_put_autosuspend (dev); } }
@@ -847,7 +847,7 @@ static int tas2781_runtime_suspend(struct device *dev)if (tas_priv->fw_state ==TASDEVICE_DSP_FW_ALL_OK && tas_priv->playback_started) -tasdevice_tuning_switch (tas_priv,1 ); +tasdevice_tuning_switch (tas_priv,1 , false); tas_priv->tasdevice[tas_priv->index].cur_book =-1 ; tas_priv->tasdevice[tas_priv->index].cur_conf =-1 ;
@@ -864,7 +864,7 @@ static int tas2781_runtime_resume(struct device *dev)if (tas_priv->fw_state ==TASDEVICE_DSP_FW_ALL_OK && tas_priv->playback_started) -tasdevice_tuning_switch (tas_priv,0 ); +tasdevice_tuning_switch (tas_priv,0 , false);return 0 ; }
@@ -882,7 +882,7 @@ static int tas2781_system_suspend(struct device *dev)/* Shutdown chip before system suspend */ if (tas_priv->fw_state ==TASDEVICE_DSP_FW_ALL_OK && tas_priv->playback_started) -tasdevice_tuning_switch (tas_priv,1 ); +tasdevice_tuning_switch (tas_priv,1 , false);return 0 ; }
@@ -917,7 +917,7 @@ static int tas2781_system_resume(struct device *dev) tas_priv->fw_state =TASDEVICE_DSP_FW_ALL_OK ;if (tas_priv->playback_started) -tasdevice_tuning_switch (tas_priv,0 ); +tasdevice_tuning_switch (tas_priv,0 , false); }return ret;
sound/soc/codecs/tas2781-fmwlib.c +3 -3
@@ -2797,11 +2797,12 @@ int tasdevice_prmg_load(void *context, int prm_no) }EXPORT_SYMBOL_NS_GPL (tasdevice_prmg_load,"SND_SOC_TAS2781_FMWLIB" ); -void tasdevice_tuning_switch (void *context,int state) +void tasdevice_tuning_switch (void *context,int state,bool is_cap) {struct tasdevice_priv *tas_priv = (struct tasdevice_priv *) context;struct tasdevice_fw *tas_fmw = tas_priv->fmw; -int profile_cfg_id = tas_priv->rcabin.profile_cfg_id; +int profile_cfg_id = is_cap ? tas_priv->rcabin.capture_profile_id : + tas_priv->rcabin.profile_cfg_id;/* * Only RCA-based Playback can still work with no dsp program running
@@ -2818,7 +2819,6 @@ void tasdevice_tuning_switch(void *context, int state)if (state ==0 ) {if (tas_fmw && tas_priv->cur_prog < tas_fmw->nr_programs) {/* dsp mode or tuning mode */ - profile_cfg_id = tas_priv->rcabin.profile_cfg_id;tasdevice_select_tuningprm_cfg (tas_priv, tas_priv->cur_prog, tas_priv->cur_conf, profile_cfg_id);
sound/soc/codecs/tas2781-i2c.c +131 -2
163 lines not on this page · raw message
Signature · 1 line
2.43.0
Mark Brown
maintainerQuoted 1 line · Shenghao Ding
ASoC: tas2781: add
capture_profile_idfield and update thetuning_switchfunction
Applied to
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-7.3
Thanks!
[1/1] ASoC: tas2781: add capture_profile_id field and update the tuning_switch function
https://git.kernel.org/broonie/sound/c/431c15610d01
All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.
You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.
If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.
Please add any relevant lists and maintainers to the CCs when replying to this mail.
Thanks,
Mark