ASoC: Add HA (HEAD acoustics) DSP codec driver template
Subsystems (3)
PATCH v2 1/2 ASoC: Add HA (HEAD acoustics) DSP codec driver template
This codec driver template represents an I2C controlled multichannel audio codec that has many typical ASoC codec driver features like volume controls, mixer stages, mux selection, output power control, in-codec audio routings, codec bias management and DAI link configuration.
This driver is based on an early version provided by Jarkko Nikula.
---
v2:
- Added/changed copyright line
- Changed authorship (as suggested by Jarkko the original author)
- Added Thorsten as maintainer
- Remove ha_dsp_hw_params() and ha_dsp_set_dai_fmt() as its not used (only needed for CODEC as clock master which is currently not suported).
- Removed some unneeded include files
- "const char *const foo" used instead of "const char *foo"
- SOC_MIXER_ARRAY() helper macro used
- Removed ha_dsp_set_bias_level() and use default implementation
- Use codec->dev instead of codec->dev->parent in dev_get_regmap()
- Added CODEC reset to probe
- Remove "ret" in ha_dsp_i2c_probe()
sound/soc/codecs/Kconfig | 4 + sound/soc/codecs/Makefile | 2 + sound/soc/codecs/ha-dsp.c | 333 ++++++++++++++++++++++++++++++++++++++++++++++ sound/soc/codecs/ha-dsp.h | 50 +++++++ 4 files changed, 389 insertions(+) create mode 100644 sound/soc/codecs/ha-dsp.c create mode 100644 sound/soc/codecs/ha-dsp.h
sound/soc/codecs/Kconfig +4 -0
@@ -51,6 +51,7 @@ config SND_SOC_ALL_CODECS select SND_SOC_DA732X if I2C select SND_SOC_DA9055 if I2C select SND_SOC_BT_SCO + select SND_SOC_HA_DSP if I2C select SND_SOC_ISABELLE if I2C select SND_SOC_JZ4740_CODEC select SND_SOC_LM4857 if I2C
@@ -343,6 +344,9 @@ config SND_SOC_BT_SCO config SND_SOC_DMIC tristate +config SND_SOC_HA_DSP + tristate + config SND_SOC_HDMI_CODEC tristate "HDMI stub CODEC"
sound/soc/codecs/Makefile +2 -0
@@ -39,6 +39,7 @@ snd-soc-da732x-objs := da732x.o snd-soc-da9055-objs := da9055.o snd-soc-bt-sco-objs := bt-sco.o snd-soc-dmic-objs := dmic.o +snd-soc-ha-dsp-objs := ha-dsp.o snd-soc-isabelle-objs := isabelle.o snd-soc-jz4740-codec-objs := jz4740.o snd-soc-l3-objs := l3.o
@@ -190,6 +191,7 @@ obj-$(CONFIG_SND_SOC_DA732X) += snd-soc-da732x.o obj-$(CONFIG_SND_SOC_DA9055) += snd-soc-da9055.o obj-$(CONFIG_SND_SOC_BT_SCO) += snd-soc-bt-sco.o obj-$(CONFIG_SND_SOC_DMIC) += snd-soc-dmic.o +obj-$(CONFIG_SND_SOC_HA_DSP) += snd-soc-ha-dsp.o obj-$(CONFIG_SND_SOC_ISABELLE) += snd-soc-isabelle.o obj-$(CONFIG_SND_SOC_JZ4740_CODEC) += snd-soc-jz4740-codec.o obj-$(CONFIG_SND_SOC_L3) += snd-soc-l3.o
sound/soc/codecs/ha-dsp.c new file +333 -0
333 lines not on this page · raw message
sound/soc/codecs/ha-dsp.h new file +50 -0
50 lines not on this page · raw message
Signature · 1 line
1.9.2
PATCH v2 2/2 ASoC: omap: Add HA (HEAD acoustics) DSP add-on card audio driver for TAO3530
HA DSP card which features a HA DSP audio codec is intended to be connected to TAO-3530 (or BeagleBoard) using McBSP3 for digital audio and I2C bus for codec control. A GPIO signal from CPU to codec is used to request clock signals active.
This machine driver has a special feature to support linked streams where playback and capture can be triggered HW simultaneously. This is implemented for linked streams by activating/deactivating the clock request signal to codec only after both streams are ready to start/stop. For non-linked streams the request signal is active whenever there is a stream active.
The GPIO used to synchronize the clock for playback and record is now configured via the DT as well (no #define any more). When this GPIO is not configured in the DT, the sync clock feature is disabled.
Slave mode is not supported any more (was never really tested). So this version has the slave mode removed.
Also the now recommended card registration via devm_snd_soc_register_card() is used instead of platform_device_add().
This driver is based on an early version provided by Jarkko Nikula.
---
v2:
- Added/changed copyright line
- Changed authorship (as suggested by Jarkko the original author)
- Added Thorsten as maintainer
- Moved DT bindings documention into this patch
- ha_dsp_codec_slave removed as its currently not used
- devm_snd_soc_register_card() used
.../devicetree/bindings/sound/omap3-ha.txt | 27 +++ sound/soc/omap/Kconfig | 11 + sound/soc/omap/Makefile | 2 + sound/soc/omap/ha-dsp-card.c | 250 +++++++++++++++++++++ 4 files changed, 290 insertions(+) create mode 100644 Documentation/devicetree/bindings/sound/omap3-ha.txt create mode 100644 sound/soc/omap/ha-dsp-card.c
Documentation/devicetree/bindings/sound/omap3-ha.txt new file +21 -0
@@ -0,0 +1,27 @@ +OMAP3 HA (HEAD acoustics) audio controller + +Required properties: +- compatible: "ha,ha-dsp-card" for OMAP3-HA board (TAO3530 based) +- ti,model: Name of the sound card (for example "omap3-ha") +- ti,mcbsp: phandle for the McBSP node +- ti,codec: phandle for the twl4030 audio node +- gpios: GPIO used to sync the clock for playback and record + +Example: +sound2 { + compatible = "ha,ha-dsp-card"; + ti,model = "omap3-ha"; + + /* McBSP3 is used for HA-DSP */ + ti,mcbsp = <&mcbsp3>; + ti,codec = <&soc_audio>; + + /* GPIO to sync the clock for playback and record */ + gpios = <&gpio2 12 GPIO_ACTIVE_LOW>; /* GPIO 44 */ +};
sound/soc/omap/Kconfig +11 -0
@@ -117,3 +117,14 @@ config SND_OMAP_SOC_OMAP3_PANDORA select SND_SOC_TWL4030 help Say Y if you want to add support for SoC audio on the OMAP3 Pandora. + +config SND_OMAP_SOC_HA_DSP_CARD + tristate "SoC Audio support for HA DSP add-on card" + depends on TWL4030_CORE && SND_OMAP_SOC + depends on SND_OMAP_SOC_OMAP_TWL4030 + select SND_OMAP_SOC_MCBSP + select SND_SOC_TWL4030 + select SND_SOC_HA_DSP + help + Say Y if you want to add support for Soc audio on HA DSP add-on card + for TAO-3530/Thunder or BeagleBoard
sound/soc/omap/Makefile +2 -0
@@ -21,6 +21,7 @@ snd-soc-omap-abe-twl6040-objs := omap-abe-twl6040.o snd-soc-omap-twl4030-objs := omap-twl4030.o snd-soc-omap3pandora-objs := omap3pandora.o snd-soc-omap-hdmi-card-objs := omap-hdmi-card.o +snd-soc-ha-dsp-card-objs := ha-dsp-card.o obj-$(CONFIG_SND_OMAP_SOC_N810) += snd-soc-n810.o obj-$(CONFIG_SND_OMAP_SOC_RX51) += snd-soc-rx51.o
@@ -31,3 +32,4 @@ obj-$(CONFIG_SND_OMAP_SOC_OMAP_ABE_TWL6040) += snd-soc-omap-abe-twl6040.o obj-$(CONFIG_SND_OMAP_SOC_OMAP_TWL4030) += snd-soc-omap-twl4030.o obj-$(CONFIG_SND_OMAP_SOC_OMAP3_PANDORA) += snd-soc-omap3pandora.o obj-$(CONFIG_SND_OMAP_SOC_OMAP_HDMI) += snd-soc-omap-hdmi-card.o +obj-$(CONFIG_SND_OMAP_SOC_HA_DSP_CARD) += snd-soc-ha-dsp-card.o
sound/soc/omap/ha-dsp-card.c new file +250 -0
250 lines not on this page · raw message
Signature · 1 line
1.9.2
Mark Brown
maintainerRe: [PATCH 2/2 v2] ASoC: omap: Add HA (HEAD acoustics) DSP add-on card audio driver for TAO3530
Quoted 4 lines · Stefan Roese
HA DSP card which features a HA DSP audio codec is intended to be connected to TAO-3530 (or BeagleBoard) using McBSP3 for digital audio and I2C bus for codec control. A GPIO signal from CPU to codec is used to request clock signals active.
So, it's been a while. In part this is because I'm still really not happy with the exceptionally generic name here - there must be some kind of name that's more specific than the entire company here? It seems awfully generic.
Quoted 6 lines
sound/soc/omap/ha-dsp-card.c new file +6
-0+/* Set CODEC as master */ + fmt |=SND_SOC_DAIFMT_CBM_CFM ; + +/* Set codec DAI configuration */ + ret =snd_soc_dai_set_fmt (codec_dai, fmt); +if (ret <0 ) {
sound/soc/omap/ha-dsp-card.c line 72
Quoted 10 lines
sound/soc/omap/ha-dsp-card.c new file +10
-0+pr_err ("Can't set codec DAI configuration\n" ); +return ret; + } + +/* Set cpu DAI configuration */ + ret =snd_soc_dai_set_fmt (cpu_dai, fmt); +if (ret <0 ) { +pr_err ("Can't set cpu DAI configuration\n" ); +return ret; + }
Just initialise the format in the DAI link and leave the error checking for the number of channels as the only code here.
sound/soc/omap/ha-dsp-card.c line 194
Quoted 11 lines
sound/soc/omap/ha-dsp-card.c new file +11
-0+ ret =devm_gpio_request (&pdev->dev, priv->gpio,"HA-DSP clock request" ); +if (ret) { +dev_err (&pdev->dev,"Failed to request GPIO %u\n" , priv->gpio); +return ret; + } + + ret =gpio_direction_output (priv->gpio,0 ); +if (ret) { +dev_err (&pdev->dev,"failed to set pin direction\n" ); +return -EINVAL ; + }
devm_gpio_request_one()
Mark Brown
maintainerQuoted 1 line · Stefan Roese
This codec driver template represents an I2C controlled multichannel audio
It's not really a template, it's a driver for a specific device.
Again, naming is the biggest issue here - it's going to get confusing with a second product. While the code is pretty clean the template comment and the really generic name make this seem like it's more of a placeholder for something that people will hack on to deploy than an actual driver that someone can pick up and use.
I'm also missing any real management of the actual DSP, this appears to only control some analogue around the DSP and a single mode switch which is a bit odd.
Quoted 4 lines
codec that has many typical ASoC codec driver features like volume controls, mixer stages, mux selection, output power control, in-codec audio routings, codec bias management and DAI link configuration.
sound/soc/codecs/ha-dsp.c line 251
Quoted 10 lines
sound/soc/codecs/ha-dsp.c new file +10
-0+static int ha_dsp_probe (struct snd_soc_codec *codec) +{ +int ret; + + codec->control_data =dev_get_regmap (codec->dev,NULL ); + ret =snd_soc_codec_set_cache_io (codec, codec->control_data); +if (ret !=0 ) { +dev_err (codec->dev,"Failed to set cache I/O: %d\n" , ret); +return ret; + }
This will be done automatically by the core.
Review
Quoted 1 line
(quoted diff) +1
-0+ snd_soc_write(codec, HA_DSP_CTRL, HA_DSP_SW_RESET);
I'd expect this to be done in the I2C level probe.
sound/soc/codecs/ha-dsp.c line 317
Quoted 8 lines
sound/soc/codecs/ha-dsp.c new file +8
-0+/* +* This name/ID is neded to match the DT node for the codec +*/ +static const struct i2c_device_id ha_dsp_i2c_id[] = { + {"ha-dsp-audio" ,0 }, + { } +}; +MODULE_DEVICE_TABLE (i2c, ha_dsp_i2c_id);
For use with DT you should have an explicit compatible string. There's also no binding document here that I can see.