ASoC: tac5xx2-sdw: add soundwire based codec driver
Subsystems (3)
PATCH v8 1/3 ASoC: tac5xx2-sdw: add soundwire based codec driver
Add codec driver for tac5xx2 family of devices. This includes the support for
1. tac5572 - DAC, PDM, UAJ and HID
2. tas2883 - Amplifier with DSP
3. tac5672 - Similar to tac5572 with feedback
4. tac5682 - Similar to tac5672 with Amplifier DSP.
---
v8:
- disable interrupts in .set_jack if jack is set to NULL
- hold uaj_lock in .set_jack
- keep interrupt registration only in .set_jack
v7:
- refactor remove the cx11, cs18 and cs11 they are not required to be configured for mic
- fix error handling and interrupt cleanup in .set_jack
- fix typo in Kconfig
v6:
- move firmware caching trigger from soundwire bus callback to soundwire probe and make it asynchronous
- validate the firmware fully before starting firmware.
- drop mixer control for cx11 configuration
- check the actual power state in .hw_free after requesting power state transition to power off
- use dev_is_pci() and remove CONFIG_PCI
v5:
- add missing pde_lock while accessing the current power state.
- add uaj_lock to serialize uaj detection update
- return error, if any, returned by sdw_stream_add_slave in hw_parms
- drop snd_soc_unregister_component as we are using devm_snd_soc_register_component
- fix issue in error handling for invalid firmware
- remove unsupported line in/out detection in jack detection
- refactor the jack and button detection logic to be based on their respective interrupt
v4:
- make volume controls as stereo controls for amp gain, playback, dmic and uaj playback.
- better error handling for "CX11 CS Select" mixer control.
- use switch statement for scalability in hw_params and hw_free
- remove unnecessary else in tac_io_init
- change error log for unsupported sample rates to debug logs
- make firmware binary parsing robust by checking the fw size during caching and parsing
v3:
- use macro SDCA_SINGLE_Q78_TLV for the volume mixer controls
- replace magic number with macro for current owner
- fix debug log message about the current owner for hid event
v2:
- Define and use consistent macros for register access to improve code readability and maintainability
- Replace complex event handlers with simpler DAPM widget implementations using direct register control for muting/unmuting and enabling/disabling components
- Replace custom volume controls with standard Q7.8 controls from the SDCA framework
- Fix PDE power state transitions with proper verification of actual power state
- Combine separate locks into a single ops\_lock to protect both firmware operations and power state transitions
- Clean up interrupt handling by removing unnecessary register accesses
- Fix headset microphone control by using the correct mono channel value
- Add comments to clarify firmware handling and critical sections
--- sound/soc/codecs/Kconfig | 11 + sound/soc/codecs/Makefile | 2 + sound/soc/codecs/tac5xx2-sdw.c | 2067 ++++++++++++++++++++++++++++++++ sound/soc/codecs/tac5xx2.h | 259 ++++ 4 files changed, 2339 insertions(+) create mode 100644 sound/soc/codecs/tac5xx2-sdw.c create mode 100644 sound/soc/codecs/tac5xx2.h
sound/soc/codecs/Kconfig +11 -0
@@ -264,6 +264,7 @@ config SND_SOC_ALL_CODECS imply SND_SOC_STA529 imply SND_SOC_STAC9766 imply SND_SOC_STI_SAS + imply SND_SOC_TAC5XX2_SDW imply SND_SOC_TAS2552 imply SND_SOC_TAS2562 imply SND_SOC_TAS2764
@@ -2139,6 +2140,16 @@ config SND_SOC_STAC9766 config SND_SOC_STI_SAS tristate "codec Audio support for STI SAS codec" +config SND_SOC_TAC5XX2_SDW + tristate "Texas Instruments TAC5XX2 SoundWire Smart Amplifier" + depends on SOUNDWIRE + depends on SND_SOC_SDCA + help + This option enables support for Texas Instruments TAC5XX2 family + of SoundWire Smart Amplifiers. This includes TAC5572, TAC5672, + TAC5682 and TAS2883. To compile this driver as a module, choose + M here: the module will be called snd-soc-tac5xx2. + config SND_SOC_TAS2552 tristate "Texas Instruments TAS2552 Mono Audio amplifier" depends on I2C
sound/soc/codecs/Makefile +2 -0
@@ -313,6 +313,7 @@ snd-soc-sta350-y := sta350.o snd-soc-sta529-y := sta529.o snd-soc-stac9766-y := stac9766.o snd-soc-sti-sas-y := sti-sas.o +snd-soc-tac5xx2-sdw-y := tac5xx2-sdw.o snd-soc-tas5086-y := tas5086.o snd-soc-tas571x-y := tas571x.o snd-soc-tas5720-y := tas5720.o
@@ -746,6 +747,7 @@ obj-$(CONFIG_SND_SOC_STA350) += snd-soc-sta350.o obj-$(CONFIG_SND_SOC_STA529) += snd-soc-sta529.o obj-$(CONFIG_SND_SOC_STAC9766) += snd-soc-stac9766.o obj-$(CONFIG_SND_SOC_STI_SAS) += snd-soc-sti-sas.o +obj-$(CONFIG_SND_SOC_TAC5XX2_SDW) += snd-soc-tac5xx2-sdw.o obj-$(CONFIG_SND_SOC_TAS2552) += snd-soc-tas2552.o obj-$(CONFIG_SND_SOC_TAS2562) += snd-soc-tas2562.o obj-$(CONFIG_SND_SOC_TAS2764) += snd-soc-tas2764.o
sound/soc/codecs/tac5xx2-sdw.c new file +2067 -0
2,067 lines not on this page · raw message
sound/soc/codecs/tac5xx2.h new file +259 -0
259 lines not on this page · raw message
Signature · 1 line
2.34.1
PATCH v8 2/3 ASoC: sdw_utils: TI amp utility for tac5xx2 family
Add TI amp utility for supporting the tac5xx2 family
of devices to support tac5572, tac5672, tac5682 and tas2883
---
v8:
- no change
v7:
- no change
--- include/sound/soc_sdw_utils.h | 4 + sound/soc/sdw_utils/soc_sdw_ti_amp.c | 144 ++++++++++++++++++++++++- sound/soc/sdw_utils/soc_sdw_utils.c | 151 +++++++++++++++++++++++++++ 3 files changed, 298 insertions(+), 1 deletion(-)
include/sound/soc_sdw_utils.h +4 -0
@@ -272,7 +272,11 @@ int asoc_sdw_ti_amp_init(struct snd_soc_card *card,struct asoc_sdw_codec_info *info, bool playback);int asoc_sdw_ti_spk_rtd_init (struct snd_soc_pcm_runtime *rtd,struct snd_soc_dai *dai); +int asoc_sdw_ti_tac5xx2_spk_rtd_init (struct snd_soc_pcm_runtime *rtd, +struct snd_soc_dai *dai);int asoc_sdw_ti_amp_initial_settings (struct snd_soc_card *card,const char *name_prefix); +int asoc_sdw_ti_dmic_rtd_init (struct snd_soc_pcm_runtime *rtd,struct snd_soc_dai *dai); +int asoc_sdw_ti_sdca_jack_rtd_init (struct snd_soc_pcm_runtime *rtd,struct snd_soc_dai *dai);#endif
sound/soc/sdw_utils/soc_sdw_ti_amp.c +143 -1
158 lines not on this page · raw message
sound/soc/sdw_utils/soc_sdw_utils.c +151 -0
157 lines not on this page · raw message
Signature · 1 line
2.34.1
PATCH v8 3/3 ASoC: tac5xx2-sdw: ACPI match for intel mtl platform
In reply to Niranjan H Y Add acpi match entries to support TI's tac5572,
tas2883, tac5672 and tac5682 on link 0 on MTL machine.
---
v8:
- no change
v7:
- no change
--- .../intel/common/soc-acpi-intel-mtl-match.c | 132 ++++++++++++++++++ 1 file changed, 132 insertions(+)
sound/soc/intel/common/soc-acpi-intel-mtl-match.c +132 -0
@@ -122,6 +122,42 @@ static const struct snd_soc_acpi_endpoint spk_r_endpoint = { .group_id = 1, }; +static const struct snd_soc_acpi_endpoint tac5xx2_endpoints[] = { + {/* Playback Endpoint */ + .num =0 , + .aggregated =0 , + .group_position =0 , + .group_id =0 , + }, + {/* Mic Capture Endpoint */ + .num =1 , + .aggregated =0 , + .group_position =0 , + .group_id =0 , + }, + {/* UAJ-HP with Mic Endpoint */ + .num =2 , + .aggregated =0 , + .group_position =0 , + .group_id =0 , + }, +}; + +static const struct snd_soc_acpi_endpoint tas2883_endpoints[] = { + {/* Playback Endpoint */ + .num =0 , + .aggregated =0 , + .group_position =0 , + .group_id =0 , + }, + {/* Mic Capture Endpoint */ + .num =1 , + .aggregated =0 , + .group_position =0 , + .group_id =0 , + }, +}; +static const struct snd_soc_acpi_endpoint rt712_endpoints[] = { { .num =0 ,
@@ -1011,6 +1047,33 @@ static const struct snd_soc_acpi_adr_device cs42l42_0_adr[] = { } }; +static const struct snd_soc_acpi_adr_device tac5572_0_adr[] = { + { + .adr =0x0000300102557201ull , + .num_endpoints =ARRAY_SIZE (tac5xx2_endpoints), + .endpoints = tac5xx2_endpoints, + .name_prefix ="tac5572" + } +}; + +static const struct snd_soc_acpi_adr_device tac5672_0_adr[] = { + { + .adr =0x0000300102567201ull , + .num_endpoints =ARRAY_SIZE (tac5xx2_endpoints), + .endpoints = tac5xx2_endpoints, + .name_prefix ="tac5672" + } +}; + +static const struct snd_soc_acpi_adr_device tac5682_0_adr[] = { + { + .adr =0x0000300102568201ull , + .num_endpoints =ARRAY_SIZE (tac5xx2_endpoints), + .endpoints = tac5xx2_endpoints, + .name_prefix ="tac5682" + } +}; +static const struct snd_soc_acpi_adr_device tas2783_0_adr[] = { { .adr =0x00003c0102000001ull ,
@@ -1035,9 +1098,45 @@ static const struct snd_soc_acpi_adr_device tas2783_0_adr[] = { .num_endpoints = 1, .endpoints = &spk_r_endpoint, .name_prefix ="tas2783-4" + }, +}; + +static const struct snd_soc_acpi_adr_device tas2883_0_adr[] = { + { + .adr =0x0000300102288301ull , + .num_endpoints =ARRAY_SIZE (tas2883_endpoints), + .endpoints = tas2883_endpoints, + .name_prefix ="tas2883" } }; +static const struct snd_soc_acpi_link_adr tac5572_l0[] = { + { + .mask =BIT (0 ), + .num_adr =ARRAY_SIZE (tac5572_0_adr), + .adr_d = tac5572_0_adr, + }, + {} +}; + +static const struct snd_soc_acpi_link_adr tac5672_l0[] = { + { + .mask =BIT (0 ), + .num_adr =ARRAY_SIZE (tac5672_0_adr), + .adr_d = tac5672_0_adr, + }, + {} +}; + +static const struct snd_soc_acpi_link_adr tac5682_l0[] = { + { + .mask =BIT (0 ), + .num_adr =ARRAY_SIZE (tac5682_0_adr), + .adr_d = tac5682_0_adr, + }, + {} +}; +static const struct snd_soc_acpi_link_adr tas2783_link0[] = { { .mask =BIT (0 ),
@@ -1047,6 +1146,15 @@ static const struct snd_soc_acpi_link_adr tas2783_link0[] = { {} }; +static const struct snd_soc_acpi_link_adr tas2883_l0[] = { + { + .mask =BIT (0 ), + .num_adr =ARRAY_SIZE (tas2883_0_adr), + .adr_d = tas2883_0_adr, + }, + {} +}; +static const struct snd_soc_acpi_link_adr cs42l42_link0_max98363_link2[] = {/* Expected order: jack -> amp */ {
@@ -1208,12 +1316,36 @@ struct snd_soc_acpi_mach snd_soc_acpi_intel_mtl_sdw_machines[] = { .drv_name = "sof_sdw", .sof_tplg_filename = "sof-mtl-rt715-rt711-rt1308-mono.tplg", }, + { + .link_mask = BIT(0), + .links = tac5572_l0, + .drv_name = "sof_sdw", + .sof_tplg_filename = "sof-mtl-tac5572.tplg", + }, + { + .link_mask = BIT(0), + .links = tac5672_l0, + .drv_name = "sof_sdw", + .sof_tplg_filename = "sof-mtl-tac5672.tplg", + }, + { + .link_mask = BIT(0), + .links = tac5682_l0, + .drv_name = "sof_sdw", + .sof_tplg_filename = "sof-mtl-tac5682.tplg", + }, { .link_mask = BIT(0), .links = tas2783_link0, .drv_name = "sof_sdw", .sof_tplg_filename = "sof-mtl-tas2783.tplg", }, + { + .link_mask = BIT(0), + .links = tas2883_l0, + .drv_name = "sof_sdw", + .sof_tplg_filename = "sof-mtl-tas2883.tplg", + }, { .link_mask = GENMASK(3, 0), .links = mtl_rt713_l0_rt1316_l12_rt1713_l3,
Signature · 1 line
2.34.1
Pierre-Louis Bossart
reviewerQuoted 6 lines
sound/soc/codecs/tac5xx2-sdw.c new file +5
-0+static int tac_clear_latch (struct tac5xx2_prv *priv) +{ +int ret; + + ret =regmap_write (priv->regmap,TAC_INT_CFG ,0X00 );
sound/soc/codecs/tac5xx2-sdw.c line 684
Quoted 10 lines
sound/soc/codecs/tac5xx2-sdw.c new file +10
-0+if (ret) +return ret; + + ret =regmap_update_bits (priv->regmap,TAC_INT_CFG , +TAC_INT_CFG_CLR_REG ,TAC_INT_CFG_CLR_REG ); +if (ret) +return ret; + + ret =regmap_write (priv->regmap,TAC_INT_CFG ,0X00 ); +return ret;
nit-pick: it wouldn't hurt to describe what this sequence does.
Quoted 49 lines
sound/soc/codecs/tac5xx2-sdw.c new file +49
-0+} + +static int tac_sdw_hw_params (struct snd_pcm_substream *substream, +struct snd_pcm_hw_params *params, +struct snd_soc_dai *dai) +{ +struct snd_soc_component *component = dai->component; +struct tac5xx2_prv *tac_dev =snd_soc_component_get_drvdata (component); +struct sdw_stream_config stream_config = {0 }; +struct sdw_port_config port_config = {0 }; +struct sdw_stream_runtime *sdw_stream; +struct sdw_slave *sdw_peripheral = tac_dev->sdw_peripheral; +unsigned long time; +int ret, retry; +int function_id; +int pde_entity; +int port_num; +unsigned int actual_ps =3 ;/* off */ +u8 sample_rate_idx =0 ; + + time =wait_for_completion_timeout (&sdw_peripheral->initialization_complete, +msecs_to_jiffies (TAC5XX2_PROBE_TIMEOUT_MS )); +if (!time) { +dev_warn (tac_dev->dev,"%s: hw initialization timeout\n" , __func__); +return -ETIMEDOUT ; + } +if (!tac_dev->hw_init) { +dev_err (tac_dev->dev, +"error: operation without hw initialization" ); +return -EINVAL ; + } + + sdw_stream =snd_soc_dai_get_dma_data (dai, substream); +if (!sdw_stream) { +dev_err (tac_dev->dev,"failed to get dma data" ); +return -EINVAL ; + } + + ret =tac_clear_latch (tac_dev); +if (ret) +dev_warn (tac_dev->dev,"clear latch failed, err=%d" , ret); + +switch (dai->id) { +case TAC5XX2_DMIC : + function_id =TAC_FUNCTION_ID_SM ; + pde_entity =TAC_SDCA_ENT_PDE11 ; + port_num =TAC_SDW_PORT_NUM_DMIC ; +break ; +case TAC5XX2_UAJ :
sound/soc/codecs/tac5xx2-sdw.c line 743
Quoted 10 lines
sound/soc/codecs/tac5xx2-sdw.c new file +10
-0+ function_id =TAC_FUNCTION_ID_UAJ ; + pde_entity = substream->stream ==SNDRV_PCM_STREAM_PLAYBACK ? +TAC_SDCA_ENT_PDE47 :TAC_SDCA_ENT_PDE34 ; + port_num = substream->stream ==SNDRV_PCM_STREAM_PLAYBACK ? +TAC_SDW_PORT_NUM_UAJ_PLAYBACK : +TAC_SDW_PORT_NUM_UAJ_CAPTURE ; +/* Detect and set jack type for UAJ path before playback. +* This is required as jack is not triggering interrupt +* when the device is in suspended mode. +*/
presumably in runtime_pm suspend with the bus in clock stop mode, the jack should be able to trigger a bus wake. You may want to update this comment, 'suspended mode' is a rather overloaded term.
Quoted 11 lines
sound/soc/codecs/tac5xx2-sdw.c new file +11
-0+mutex_lock (&tac_dev->uaj_lock); +tac5xx2_sdca_headset_detect (tac_dev); +mutex_unlock (&tac_dev->uaj_lock); +break ; +case TAC5XX2_SPK : + function_id =TAC_FUNCTION_ID_SA ; + pde_entity =TAC_SDCA_ENT_PDE23 ; + port_num = substream->stream ==SNDRV_PCM_STREAM_PLAYBACK ? +TAC_SDW_PORT_NUM_SPK_PLAYBACK : +TAC_SDW_PORT_NUM_SPK_CAPTURE ; +break ;
sound/soc/codecs/tac5xx2-sdw.c line 764
Quoted 10 lines
sound/soc/codecs/tac5xx2-sdw.c new file +10
-0+default : +dev_err (tac_dev->dev,"Invalid dai id: %d" , dai->id); +return -EINVAL ; + } + +mutex_lock (&tac_dev->pde_lock); +regmap_write (tac_dev->regmap,SDW_SDCA_CTL (function_id, pde_entity, +TAC_SDCA_REQUESTED_PS ,0 ), +0x03 ); +mutex_unlock (&tac_dev->pde_lock);
I think I provided the feedback several times that the "SDCA way" is to write REQUESTED_PS but then wait for ACTUAL_PS to reflect the intended power state. If this is not required for these devices, you absolutely want to comment on this non-standard device-specific sequences.
Edit: you have a loop to wait on ACTUAL_PS below when you write REQUESTED_PS a second time. This does require more comments or a code simplification...
Quoted 30 lines
sound/soc/codecs/tac5xx2-sdw.c new file +30
-0+ +snd_sdw_params_to_config (substream, params, &stream_config, &port_config); + port_config.num = port_num; + ret =sdw_stream_add_slave (sdw_peripheral, &stream_config, + &port_config,1 , sdw_stream); +if (ret) { +dev_err (dai->dev, +"Unable to configure port %d: %d\n" , port_num, ret); +return ret; + } + +switch (params_rate (params)) { +case 48000 : + sample_rate_idx =0x01 ; +break ; +case 44100 : + sample_rate_idx =0x02 ; +break ; +case 96000 : + sample_rate_idx =0x03 ; +break ; +case 88200 : + sample_rate_idx =0x04 ; +break ; +default : +dev_dbg (tac_dev->dev,"Unsupported sample rate: %d Hz" , +params_rate (params)); +return -EINVAL ; + } +
sound/soc/codecs/tac5xx2-sdw.c line 804
Quoted 10 lines
sound/soc/codecs/tac5xx2-sdw.c new file +10
-0+switch (function_id) { +case TAC_FUNCTION_ID_SM : + ret =regmap_write (tac_dev->regmap, +SDW_SDCA_CTL (function_id,TAC_SDCA_ENT_PPU11 , +TAC_SDCA_CTL_PPU_POSTURE_NUM ,0 ), +0 ); +if (ret) { +dev_err (tac_dev->dev,"Failed to set PPU11: %d" , ret); +return ret; + }
Can this register be initialized once on startup? This doesn't look dependent on any stream-specific hw params, and we have no hook to select the 'posture' (SDCA generalized orientation concept) at the moment.
Quoted 35 lines
sound/soc/codecs/tac5xx2-sdw.c new file +35
-0+ + ret =regmap_write (tac_dev->regmap, +SDW_SDCA_CTL (function_id,TAC_SDCA_ENT_CS113 , +TAC_SDCA_CTL_CS_SAMP_RATE_IDX ,0 ), + sample_rate_idx); +if (ret) { +dev_err (tac_dev->dev,"Failed to set CS113 sample rate: %d" , ret); +return ret; + } + +break ; +case TAC_FUNCTION_ID_UAJ : +if (substream->stream ==SNDRV_PCM_STREAM_PLAYBACK ) { + ret =regmap_write (tac_dev->regmap, +SDW_SDCA_CTL (function_id,TAC_SDCA_ENT_CS41 , +TAC_SDCA_CTL_CS_SAMP_RATE_IDX ,0 ), + sample_rate_idx); +if (ret) { +dev_err (tac_dev->dev,"Failed to set CS41 sample rate: %d" , ret); +return ret; + } + }else { + ret =regmap_write (tac_dev->regmap, +SDW_SDCA_CTL (function_id,TAC_SDCA_ENT_CS36 , +TAC_SDCA_CTL_CS_SAMP_RATE_IDX ,0 ), + sample_rate_idx); +if (ret) { +dev_err (tac_dev->dev,"Failed to set CS36 sample rate: %d" , ret); +return ret; + } + } +break ; +case TAC_FUNCTION_ID_SA : +/* SmartAmp: no additional sample rate configuration needed */ +break ;
sound/soc/codecs/tac5xx2-sdw.c line 849
Quoted 10 lines
sound/soc/codecs/tac5xx2-sdw.c new file +10
-0+ } + +guard (mutex)(&tac_dev->pde_lock); + ret =regmap_write (tac_dev->regmap, +SDW_SDCA_CTL (function_id, pde_entity, +TAC_SDCA_REQUESTED_PS ,0 ),0 ); +if (ret) { +dev_err (tac_dev->dev,"failed to set PS to 0: %d\n" , ret); +return ret; + }
humm, why do you need to write REQUESTED_PS again?
Quoted 44 lines
sound/soc/codecs/tac5xx2-sdw.c new file +44
-0+ + retry =3 ; +do { + ret =regmap_read (tac_dev->regmap, +SDW_SDCA_CTL (function_id, pde_entity, +TAC_SDCA_ACTUAL_PS ,0 ), + &actual_ps); +if (ret) +continue ; +if (!actual_ps) +break ; +if (retry) +usleep_range (1000 ,1200 ); + }while (retry--); + +if (ret) +dev_err (tac_dev->dev, +"failed to read PS 0 transition, err=%d\n" , ret); + +return ret; +} + +static s32 tac_sdw_pcm_hw_free (struct snd_pcm_substream *substream, +struct snd_soc_dai *dai) +{ +s32 ret; +struct snd_soc_component *component = dai->component; +struct tac5xx2_prv *tac_dev = +snd_soc_component_get_drvdata (component); +struct sdw_stream_runtime *sdw_stream = +snd_soc_dai_get_dma_data (dai, substream); +int pde_entity, function_id, actual_ps, retry; + +sdw_stream_remove_slave (tac_dev->sdw_peripheral, sdw_stream); + +switch (dai->id) { +case TAC5XX2_DMIC : + pde_entity =TAC_SDCA_ENT_PDE11 ; + function_id =TAC_FUNCTION_ID_SM ; +break ; +case TAC5XX2_UAJ : + function_id =TAC_FUNCTION_ID_UAJ ; + pde_entity = substream->stream ==SNDRV_PCM_STREAM_PLAYBACK ? +TAC_SDCA_ENT_PDE47 :TAC_SDCA_ENT_PDE34 ;
sound/soc/codecs/tac5xx2-sdw.c line 903
Quoted 10 lines
sound/soc/codecs/tac5xx2-sdw.c new file +10
-0+break ; +default : + function_id =TAC_FUNCTION_ID_SA ; + pde_entity =TAC_SDCA_ENT_PDE23 ; +break ; + } + +guard (mutex)(&tac_dev->pde_lock); + ret = regmap_write(tac_dev->regmap, + SDW_SDCA_CTL(function_id, pde_entity, 0x01, 0),
TAC_SDCA_REQUESTED_PS?
Quoted 6 lines
sound/soc/codecs/tac5xx2-sdw.c new file +6
-0+ 0x03); +if (ret) +return ret; + + retry =3 ; + do {
sound/soc/codecs/tac5xx2-sdw.c line 919
Quoted 10 lines
sound/soc/codecs/tac5xx2-sdw.c new file +10
-0+ ret =regmap_read (tac_dev->regmap,SDW_SDCA_CTL (function_id, pde_entity, +TAC_SDCA_ACTUAL_PS ,0 ), + &actual_ps); +if (ret) +continue ; +if (actual_ps ==0x03 ) +break ; +if (retry) +usleep_range (1000 ,1200 ); + }while (retry--);
this sequence should be a generic SDCA helper really to avoid code duplication.
Quoted 3 lines
sound/soc/codecs/tac5xx2-sdw.c new file +3
-0+ +return ret; +}
Quoted 22 lines · Pierre-Louis Bossart
Subject: Re: [PATCH v8 1/3] ASoC: tac5xx2-sdw: add soundwire based codec driver
sound/soc/codecs/tac5xx2-sdw.c
Quoted 7 lines
sound/soc/codecs/tac5xx2-sdw.c new file +6
-0+static int tac_sdw_hw_params(struct snd_pcm_substream *substream, + struct snd_pcm_hw_params *params, + struct snd_soc_dai *dai) + + mutex_lock(&tac_dev->pde_lock); + regmap_write(tac_dev->regmap, SDW_SDCA_CTL(function_id,
pde_entity,Review
Quoted 1 line
(quoted diff) +1
-0+ TAC_SDCA_REQUESTED_PS,0),
sound/soc/codecs/tac5xx2-sdw.c line 764
Quoted 2 lines
sound/soc/codecs/tac5xx2-sdw.c new file +2
-0+ 0x03); +mutex_unlock (&tac_dev->pde_lock);I think I provided the feedback several times that the "SDCA way" is to write
REQUESTED_PSbut then wait forACTUAL_PSto reflect the intended power state.
If this is not required for these devices, you absolutely want to comment on this non-standard device-specific sequences.
Quoted 3 lines
Edit: you have a loop to wait on
ACTUAL_PSbelow when you writeREQUESTED_PSa second time.
This does require more comments or a code simplification...
This is to ensure D3, so that other writes will happen with device powered down ...
Quoted 11 lines
sound/soc/codecs/tac5xx2-sdw.c line 849
Quoted 9 lines
sound/soc/codecs/tac5xx2-sdw.c new file +9
-0+ +guard (mutex)(&tac_dev->pde_lock); + ret =regmap_write (tac_dev->regmap, +SDW_SDCA_CTL (function_id, pde_entity, +TAC_SDCA_REQUESTED_PS ,0 ),0 ); +if (ret) { +dev_err (tac_dev->dev,"failed to set PS to 0: %d\n" , ret); +return ret; + }humm, why do you need to write
REQUESTED_PSagain?
... and this is D3 -> D0 transition. I will see if I can improve this logic in the next patch. Thanks
Regards
Niranjan