ASoC: SDCA: make q78_get_volsw and q78_put_volsw extern
Subsystems (4)
PATCH v2 1/4 ASoC: SDCA: make q78_get_volsw and q78_put_volsw extern
q78_get_volsw and q78_put_volsw are get and set functions
in sdca library to handle 16bit signed Q7.8 values for Volume control. Make them extern so that ASoC drivers can reuse them.
---
v2:
- newly added patch
--- include/sound/sdca_asoc.h | 6 ++++++ sound/soc/sdca/sdca_asoc.c | 10 ++++++---- 2 files changed, 12 insertions(+), 4 deletions(-)
include/sound/sdca_asoc.h +6 -0
@@ -13,6 +13,8 @@struct device ;struct regmap ;struct sdca_function_data ; +struct snd_ctl_elem_value ; +struct snd_kcontrol ;struct snd_kcontrol_new ;struct snd_pcm_hw_params ;struct snd_pcm_substream ;
@@ -57,5 +59,9 @@ int sdca_asoc_hw_params(struct device *dev, struct regmap *regmap,struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params, struct snd_soc_dai *dai); +int q78_put_volsw (struct snd_kcontrol *kcontrol, +struct snd_ctl_elem_value *ucontrol); +int q78_get_volsw (struct snd_kcontrol *kcontrol, +struct snd_ctl_elem_value *ucontrol);#endif // __SDCA_ASOC_H__
sound/soc/sdca/sdca_asoc.c +6 -4
@@ -820,8 +820,8 @@ static int q78_write(struct snd_soc_component *component,return snd_soc_component_update_bits (component, reg, mask, reg_val); } -static int q78_put_volsw (struct snd_kcontrol *kcontrol, -struct snd_ctl_elem_value *ucontrol) +int q78_put_volsw (struct snd_kcontrol *kcontrol, +struct snd_ctl_elem_value *ucontrol) {struct soc_mixer_control *mc = (struct soc_mixer_control *)kcontrol->private_value;struct snd_soc_component *component =snd_kcontrol_chip (kcontrol);
@@ -841,6 +841,7 @@ static int q78_put_volsw(struct snd_kcontrol *kcontrol,return ret; } +EXPORT_SYMBOL_NS (q78_put_volsw,"SND_SOC_SDCA" );static int q78_read (struct snd_soc_component *component,struct soc_mixer_control *mc,unsigned int reg)
@@ -855,8 +856,8 @@ static int q78_read(struct snd_soc_component *component,return val &GENMASK (mc->sign_bit,0 ); } -static int q78_get_volsw (struct snd_kcontrol *kcontrol, -struct snd_ctl_elem_value *ucontrol) +int q78_get_volsw (struct snd_kcontrol *kcontrol, +struct snd_ctl_elem_value *ucontrol) {struct soc_mixer_control *mc = (struct soc_mixer_control *)kcontrol->private_value;struct snd_soc_component *component =snd_kcontrol_chip (kcontrol);
@@ -868,6 +869,7 @@ static int q78_get_volsw(struct snd_kcontrol *kcontrol,return 0 ; } +EXPORT_SYMBOL_NS (q78_get_volsw,"SND_SOC_SDCA" ); static int control_limit_kctl(struct device *dev, struct sdca_entity *entity,
Signature · 1 line
2.34.1
PATCH v2 2/4 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.
---
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 | 2151 ++++++++++++++++++++++++++++++++ sound/soc/codecs/tac5xx2.h | 259 ++++ 4 files changed, 2423 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, + TAC568 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 +2151 -0
2,151 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
Charles Keepax
maintainerRe: [PATCH v2 2/4] ASoC: tac5xx2-sdw: add soundwire based codec driver
Quoted 9 lines · Niranjan H Y
sound/soc/codecs/tac5xx2-sdw.c new file +9
-0+/* TLV for volume control */ +static const DECLARE_TLV_DB_SCALE(tac5xx2_amp_tlv, 0, 50, 0); +static const DECLARE_TLV_DB_SCALE(tac5xx2_dvc_tlv, -7200, 50, 0); + +/* Q7.8 volume control parameters: range -72dB to +6dB, step 0.5dB */ +#define TAC_DVC_STEP 128/* 0.5 dB in Q7.8 format */ +#define TAC_DVC_MIN (-144)/* -72 dB / 0.5 dB step */ +#define TAC_DVC_MAX 12/* +6 dB / 0.5 dB step */ +
sound/soc/codecs/tac5xx2-sdw.c line 126
Quoted 10 lines
sound/soc/codecs/tac5xx2-sdw.c new file +10
-0+#define SOC_SINGLE_Q78_TLV (xname, xreg, tlv_array) { \ + .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ + .name = xname, \ + .access = SNDRV_CTL_ELEM_ACCESS_TLV_READ | SNDRV_CTL_ELEM_ACCESS_READWRITE, \ + .tlv.p = (tlv_array), \ + .info = snd_soc_info_volsw, .get = q78_get_volsw, .put = q78_put_volsw, \ + .private_value = (unsigned long)&(struct soc_mixer_control) { \ + .reg = (xreg), .rreg = (xreg), \ + .min = TAC_DVC_MIN, .max = TAC_DVC_MAX, \ + .platform_max = TAC_DVC_MAX - TAC_DVC_MIN, .shift = TAC_DVC_STEP, \
What is the purpose of the platform_max here? Doesn't feel like we should be setting that from the driver.
sound/soc/codecs/tac5xx2-sdw.c line 129
Quoted 3 lines
sound/soc/codecs/tac5xx2-sdw.c new file +3
-0+ .sign_bit = 15 \ + } \ +}
Probably makes sense to parameterise min,max,step here and then put this macro in the sdca_asoc.h header, perhaps rename to something like SDCA_SINGLE_Q78_TLV as well. That way if others are creating these controls directly they can just reuse that.
Quoted 6 lines
sound/soc/codecs/tac5xx2-sdw.c new file +6
-0+static int tac5xx2_sdca_button_detect (struct tac5xx2_prv *tac_dev) +{ +unsigned int btn_type, offset, idx; +int ret, value, owner; +u8 buf[2 ]; +
sound/soc/codecs/tac5xx2-sdw.c line 1057
Quoted 10 lines
sound/soc/codecs/tac5xx2-sdw.c new file +10
-0+ ret =regmap_read (tac_dev->regmap, +SDW_SDCA_CTL (TAC_FUNCTION_ID_HID ,TAC_SDCA_ENT_HID1 , +TAC_SDCA_CTL_HIDTX_CURRENT_OWNER ,0 ), &owner); +if (ret) { +dev_err (tac_dev->dev, +"Failed to read current UMP message owner 0x%x" , ret); +return ret; + } + +if (owner ==1 ) {
Would be nice to use the SDCA_UMP_OWNER_DEVICE define here.
sound/soc/codecs/tac5xx2-sdw.c line 1058
Quoted 1 line
sound/soc/codecs/tac5xx2-sdw.c new file +1
-0+dev_dbg (tac_dev->dev,"current owner is host, skipping.." );
I think this message should read either "current owner is device" or "current owner is not host", as a value of 1 is device and it makes more sense in the context.
Quoted 23 lines
sound/soc/codecs/tac5xx2-sdw.c new file +23
-0+return 0 ; + } + + ret =regmap_read (tac_dev->regmap, +SDW_SDCA_CTL (TAC_FUNCTION_ID_HID ,TAC_SDCA_ENT_HID1 , +TAC_SDCA_CTL_HIDTX_MESSAGE_OFFSET ,0 ), &value); +if (ret) { +dev_err (tac_dev->dev, +"Failed to read current UMP message offset: %d" , ret); + goto end_btn_det; + } + +dev_dbg (tac_dev->dev,"btn_ message offset = %x" , value); + offset = value; + +for (idx =0 ; idx <sizeof (buf); idx++) { + ret =regmap_read (tac_dev->regmap, +TAC_BUF_ADDR_HID1 + offset + idx, &value); +if (ret) { +dev_err (tac_dev->dev, +"Failed to read HID buffer: %d" , ret); + goto end_btn_det; + }
sound/soc/codecs/tac5xx2-sdw.c line 1091
Quoted 10 lines
sound/soc/codecs/tac5xx2-sdw.c new file +10
-0+ buf[idx] = value &0xff ; + } + +if (buf[0 ] ==0x1 ) { + btn_type =tac5xx2_sdca_btn_type (&buf[1 ], tac_dev); + ret = btn_type; + } + +end_btn_det: +if (!owner)
Does this if actually make sense? owner can only be 0,1 by the spec and you check for 1 earlier in the function, so isn't this always true?
Quoted 4 lines
sound/soc/codecs/tac5xx2-sdw.c new file +4
-0+regmap_write (tac_dev->regmap, +SDW_SDCA_CTL (TAC_FUNCTION_ID_HID ,TAC_SDCA_ENT_HID1 , +TAC_SDCA_CTL_HIDTX_CURRENT_OWNER ,0 ),0x01 ); +
sound/soc/codecs/tac5xx2-sdw.c line 2133
Quoted 10 lines
sound/soc/codecs/tac5xx2-sdw.c new file +9
-0+return ret; +} +static const struct sdw_device_id tac_sdw_id[] = { +SDW_SLAVE_ENTRY (0x0102 ,0x5572 ,0 ), +SDW_SLAVE_ENTRY (0x0102 ,0x5672 ,0 ), +SDW_SLAVE_ENTRY (0x0102 ,0x5682 ,0 ), +SDW_SLAVE_ENTRY (0x0102 ,0x2883 ,0 ), + {}, +};
Not that I am pushing for this now on this driver but would be good for you guys to perhaps poke what happens binding your parts with the class driver itself (sdca_class.c). The hope would be in time we can support all new SDCA parts out of there by just adding the slave entry. So good to start finding out what does and doesn't work for you guys. At the moment the class driver is still in active development and a lot of shipping products have dodgy DisCo or hardware issues that make use difficult, so this is more of a long term goal. From scanning the driver here I am guessing perhaps the firmware download might not work so well with your current parts. But a lot of the rest looks like it would assuming the DisCo is all correct.
Thanks,
Charles
RE: [EXTERNAL] Re: [PATCH v2 2/4] ASoC: tac5xx2-sdw: add soundwire based codec driver
Quoted 9 lines · Charles Keepax
Subject: : [PATCH v2 2/4] ASoC: tac5xx2-sdw: add soundwire based codec driver
Quoted 3 lines · Niranjan H Y
sound/soc/codecs/tac5xx2-sdw.c new file +3
-0+ SDW_SLAVE_ENTRY(0x0102, 0x2883, 0), + {}, +};
..
Quoted 5 lines
dodgy DisCo or hardware issues that make use difficult, so this is more of a long term goal. From scanning the driver here I am guessing perhaps the firmware download might not work so well with your current parts. But a lot of the rest looks like it would assuming the DisCo is all correct.
Thanks for the suggestion. I will start testing the class driver Implementation for the current devices to identify any gaps and start contributing. The plan is to go with class driver for next HW version.
Regards
Niranjan
PATCH v2 3/4 ASoC: sdw_utils: TI amp utility for tac5xx2 family
In reply to Niranjan H Y Add TI amp utility for supporting the tac5xx2 family
of devices to support tac5572, tac5672, tac5682 and tas2883
---
v2:
- 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
@@ -270,7 +270,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 v2 4/4 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.
---
v2:
- 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
Charles Keepax
maintainerQuoted 8 lines · Niranjan H Y
q78_get_volswandq78_put_volsware get and set functions
in sdca library to handle 16bit signed Q7.8 values for Volume control. Make them extern so that ASoC drivers can reuse them.Signed-off-by Niranjan H Y <[email protected]>---
include/sound/sdca_asoc.h int sdca_asoc_hw_params(struct device *dev, struct regmap *regmap, · line 65
Quoted 7 lines
include/sound/sdca_asoc.h +4
-0@@ -57,5 +59,9 @@ int sdca_asoc_hw_params(struct device *dev, struct regmap *regmap,struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params, struct snd_soc_dai *dai); +int q78_put_volsw (struct snd_kcontrol *kcontrol, +struct snd_ctl_elem_value *ucontrol); +int q78_get_volsw (struct snd_kcontrol *kcontrol, +struct snd_ctl_elem_value *ucontrol);
Lets rename these to sdca_asoc_q78_put_volsw and sdca_asoc_q78_get_volsw to be more consistent with the other exported functions. Otherwise this looks good to me.
Thanks,
Charles