ASoC: tas2783-sdw: add firmware download status check
Subsystems (3)
Baojun Xu
maintainerPATCH v4 1/1 ASoC: tas2783-sdw: add firmware download status check
Currently, the firmware download is unnecessarily triggered on every system resume from suspend, causing significant wake-up latency. However, this step is redundant if the AMP remains powered on.
---
v4:
- Since first_hw_init is only required for download reduction, remove it when this feature is not enabled.
v3:
- Updated description about memory page download reduce.
- Removed the logic that skips memory page downloads.
v2:
- Update register address from 0x07 to 7 and keep the line within the 80-character limit.
- Remove stray/unnecessary changes.
- Change variable type to unsigned int to comply with API requirements.
- Replace usleep_range() with fsleep().
- Set idle_bias_on to 0 to enable low-power mode.
- Reactivate the AMP after resume.
--- sound/soc/codecs/tas2783-sdw.c | 33 ++++++++++++++++++++------------- 1 file changed, 20 insertions(+), 13 deletions(-)
sound/soc/codecs/tas2783-sdw.c +20 -13
@@ -857,6 +857,7 @@ static void tas2783_fw_ready(const struct firmware *fmw, void *context) ret = -EINVAL ; }else {tas2783_update_calibdata (tas_dev); +regmap_write (tas_dev->regmap,TASDEV_REG_SDW (0 ,0 ,7 ),0x22 ); } out:
@@ -996,7 +997,7 @@ static s32 tas_sdw_hw_params(struct snd_pcm_substream *substream, TAS2783_SDCA_POW_STATE_ON);if (!ret)break ; -usleep_range (2000 ,2200 ); +fsleep (2200 ); }while (retry--); }
@@ -1119,7 +1120,7 @@ static const struct snd_soc_component_driver soc_codec_driver_tasdevice = { .num_dapm_widgets = ARRAY_SIZE(tas_dapm_widgets), .dapm_routes = tas_audio_map, .num_dapm_routes = ARRAY_SIZE(tas_audio_map), - .idle_bias_on = 1, + .idle_bias_on = 0, .endianness = 1, };
@@ -1252,25 +1253,29 @@ static s32 tas_fw_load(struct tas2783_prv *tas_dev, struct sdw_slave *slave)static s32 tas_io_init (struct device *dev,struct sdw_slave *slave) {struct tas2783_prv *tas_dev =dev_get_drvdata (dev); +unsigned int val;s32 ret;if (tas_dev->hw_init)return 0 ; - tas_dev->fw_dl_success = false; +regmap_read (tas_dev->regmap,TASDEV_REG_SDW (0 ,0 ,7 ), &val); +/* Check if the AMP is in reset status. */ +if (val ==0x20 ) { + tas_dev->fw_dl_success = false; - ret =regmap_write (tas_dev->regmap,TAS2783_SW_RESET ,0x1 ); -if (ret) { -dev_err (dev,"sw reset failed, err=%d" , ret); -return ret; - } -usleep_range (2000 ,2200 ); + ret =regmap_write (tas_dev->regmap,TAS2783_SW_RESET ,0x1 ); +if (ret) { +dev_err (dev,"sw reset failed, err=%d" , ret); +return ret; + } +fsleep (2200 ); - tas_dev->fw_use_fallback = false; - ret =tas_fw_load (tas_dev, slave); -if (!ret && tas_dev->fw_use_fallback) + tas_dev->fw_use_fallback = false; ret =tas_fw_load (tas_dev, slave); - +if (!ret && tas_dev->fw_use_fallback) + ret =tas_fw_load (tas_dev, slave); + }if (!ret) {if (tas_dev->sa_func_data) ret = sdca_regmap_write_init(dev, tas_dev->regmap,
@@ -1279,6 +1284,8 @@ static s32 tas_io_init(struct device *dev, struct sdw_slave *slave) ret =regmap_multi_reg_write (tas_dev->regmap, tas2783_init_seq,ARRAY_SIZE (tas2783_init_seq)); +/* Re-active AMP after resume. */ +regmap_write (tas_dev->regmap,TASDEV_REG_SDW (0 ,0 ,2 ),0 );if (ret)dev_err (tas_dev->dev,"init writes failed, err=%d" , ret);
Signature · 1 line
2.25.1
Mark Brown
maintainersound/soc/codecs/tas2783-sdw.c static s32 tas_fw_load(struct tas2783_prv *tas_dev, struct sdw_slave *slave) · line 1265
Quoted 9 lines · Baojun Xu
Currently, the firmware download is unnecessarily triggered on every system resume from suspend, causing significant wake-up latency. However, this step is redundant if the AMP remains powered on.
sound/soc/codecs/tas2783-sdw.c +4
-1- tas_dev->fw_dl_success = false; +regmap_read (tas_dev->regmap,TASDEV_REG_SDW (0 ,0 ,7 ), &val); +/* Check if the AMP is in reset status. */ +if (val ==0x20 ) { + tas_dev->fw_dl_success = false;
Don't we also need to set the flag to true if we're skipping download, what'll happen if we get here if the firmware was downloaded prior to the driver starting (eg, you can probably trigger that with a bind/unbind)?
Quoted 3 lines · Baojun Xu
Currently, the firmware download is unnecessarily triggered on every system resume from suspend, causing significant wake-up latency. However, this step is redundant if the AMP remains powered on.
Either drop 'unnecessarily' in the first sentence or shorten the second sentence to 'The step is redundant (...)'.
sound/soc/codecs/tas2783-sdw.c static s32 tas_sdw_hw_params(struct snd_pcm_substream *substream, · line 1000
Quoted 6 lines
sound/soc/codecs/tas2783-sdw.c +1
-1@@ -996,7 +997,7 @@ static s32 tas_sdw_hw_params(struct snd_pcm_substream *substream, TAS2783_SDCA_POW_STATE_ON);if (!ret)break ; -usleep_range (2000 ,2200 ); +fsleep (2200 );
Is this a crucial part of the patch? Looks out of scope and if so, please move it to a separate patch.
Quoted 6 lines
sound/soc/codecs/tas2783-sdw.c +0
-0}while (retry--); }@@ -1252,25 +1253,29 @@ static s32 tas_fw_load(struct tas2783_prv *tas_dev, struct sdw_slave *slave)static s32 tas_io_init (struct device *dev,struct sdw_slave *slave) {
sound/soc/codecs/tas2783-sdw.c static s32 tas_fw_load(struct tas2783_prv *tas_dev, struct sdw_slave *slave) · line 1263
Quoted 10 lines
sound/soc/codecs/tas2783-sdw.c +3
-1struct tas2783_prv *tas_dev =dev_get_drvdata (dev); +unsigned int val;s32 ret;if (tas_dev->hw_init)return 0 ; - tas_dev->fw_dl_success = false; +regmap_read (tas_dev->regmap,TASDEV_REG_SDW (0 ,0 ,7 ), &val); +/* Check if the AMP is in reset status. */
Please add a newline between regmap_read() and the comment.
Quoted 3 lines
sound/soc/codecs/tas2783-sdw.c +2
-0+if (val ==0x20 ) { + tas_dev->fw_dl_success = false;