Skip to contentSkip to conversation

ASoC: Add support for machine specific trigger callback

PATCH Applied Stefan Roese 4 participants 12 messages Apr 28, 2014 – Apr 29, 2014

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/5 ASoC: Add support for machine specific trigger callback

From: Jarkko Nikula <[email protected]>

Machine specific trigger callback allows to do final stream start/stop related operations in a machine driver after setting up the codec, DMA and DAI.

One example could be clock management for linked streams case where machine driver can start/stop synchronously the linked streams.

---
 sound/soc/soc-pcm.c | 7 +++++++
 1 file changed, 7 insertions(+)
sound/soc/soc-pcm.c +7 -0
index 2cedf09..a3a7021 100644
@@ -819,6 +819,13 @@ static int soc_pcm_trigger(struct snd_pcm_substream *substream, int cmd)
 		if (ret < 0)
 			return ret;
 	}
+
+	if (rtd->dai_link->ops && rtd->dai_link->ops->trigger) {
+		ret = rtd->dai_link->ops->trigger(substream, cmd);
+		if (ret < 0)
+			return ret;
+	}
+
 	return 0;
 }
 
Signature · 1 line
1.9.1
#1 lore raw

PATCH 2/5 ASoC: Add HA (HEAD acoustics) DSP codec driver template

From: Jarkko Nikula <[email protected]>

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.

Updates from Stefan Roese, 2014-04-28:
Port the HA DSP codec driver to Linux v3.15-rc. This includes support for DT based probing. No platform-data code is needed any more, DT nodes are sufficient.

---
 sound/soc/codecs/Kconfig  |   4 +
 sound/soc/codecs/Makefile |   2 +
 sound/soc/codecs/ha-dsp.c | 419 ++++++++++++++++++++++++++++++++++++++++++++++
 sound/soc/codecs/ha-dsp.h |  50 ++++++
 4 files changed, 475 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
index f0e8401..f357988 100644
@@ -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
index 3c4d275..f296bec 100644
@@ -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 +419 -0

419 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.1
#5 lore raw

PATCH 3/5 ASoC: omap: Add HA (HEAD acoustics) DSP add-on card audio driver for TAO3530

In reply to Stefan Roese

From: Jarkko Nikula <[email protected]>

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.

Updates from Stefan Roese, 2014-04-28:
Port the HA DSP add-on card audio driver to Linux v3.15-rc. This includes support for DT based probing. No platform-data code is needed any more, DT nodes are sufficient.

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.

The slave mode #define was also moved to a DT configuration property (ha_dsp_codec_slave). If this property is set in the DT sound card device node, then this testing slave mode is used. Otherwise the "normal" operation is selected.

Also the now recommended card registration via snd_soc_register_card() is used instead of platform_device_add().

---
 sound/soc/omap/Kconfig       |  11 ++
 sound/soc/omap/Makefile      |   2 +
 sound/soc/omap/ha-dsp-card.c | 307 +++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 320 insertions(+)
 create mode 100644 sound/soc/omap/ha-dsp-card.c
sound/soc/omap/Kconfig +11 -0
index e006593..86cc869 100644
@@ -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
index a725905..02c0094 100644
@@ -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 +307 -0

307 lines not on this page · raw message

Signature · 1 line
1.9.1
#9 lore raw

PATCH 4/5 DT: Add vendor prefix for HEAD acoustics

In reply to Stefan Roese

Add "ha" for "HEAD acoustics" to the list of DT vendor prefixes.

Cc Thorsten Eisbein <[email protected]>
---
 Documentation/devicetree/bindings/vendor-prefixes.txt | 1 +
 1 file changed, 1 insertion(+)
Documentation/devicetree/bindings/vendor-prefixes.txt +1 -0
index abc3080..0cdca38 100644
@@ -53,6 +53,7 @@ globalscale	Globalscale Technologies, Inc.
 gmt	Global Mixed-mode Technology, Inc.
 google	Google, Inc.
 gumstix	Gumstix, Inc.
+ha	HEAD acoustics
 haoyu	Haoyu Microelectronic Co. Ltd.
 hisilicon	Hisilicon Limited.
 honeywell	Honeywell
Signature · 1 line
1.9.1
#10 lore raw

PATCH 5/5 ASoC: omap: Add DT bindings documentation for HA DSP audio driver

In reply to Stefan Roese
Cc Thorsten Eisbein <[email protected]>
---
 .../devicetree/bindings/sound/omap3-ha.txt         | 27 ++++++++++++++++++++++
 1 file changed, 27 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/sound/omap3-ha.txt
Documentation/devicetree/bindings/sound/omap3-ha.txt new file +27 -0
new file mode 100644
index 0000000..09eccda
@@ -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
+
+Optional properties:
+- ha_dsp_codec_slave:
+  Add this property to test the codec in slave mode or without actual codec.
+  This makes it possible to test this driver by letting the OMAP be the DAI
+  link master.
+
+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 */
+};
Signature · 1 line
1.9.1
#2 lore raw

Re: [alsa-devel] [PATCH 2/5] ASoC: Add HA (HEAD acoustics) DSP codec driver template

In reply to Stefan Roese
Quoted 7 lines · Stefan Roese

From: Jarkko Nikula <[email protected]>

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.

Quoted 8 lines

Updates from Stefan Roese, 2014-04-28:
Port the HA DSP codec driver to Linux v3.15-rc. This includes support for DT based probing. No platform-data code is needed any more, DT nodes are sufficient.

Looks very good. Couple of bits inline.

[...]

Quoted 7 lines
sound/soc/codecs/ha-dsp.c new file +7 -0
+
+#include <linux/module.h>
+#include <linux/moduleparam.h>
+#include <linux/init.h>
+#include <linux/delay.h>
+#include <linux/pm.h>
+#include <linux/i2c.h>

sound/soc/codecs/ha-dsp.c line 28

Quoted 10 lines
sound/soc/codecs/ha-dsp.c new file +10 -0
+#include <linux/platform_device.h>
+#include <linux/regmap.h>
+#include <linux/slab.h>
+#include <sound/core.h>
+#include <sound/pcm.h>
+#include <sound/pcm_params.h>
+#include <sound/soc.h>
+#include <sound/soc-dapm.h>
+#include <sound/tlv.h>
+#include <sound/initval.h>

There seem to be a couple of includes here that are not really needed.

Quoted 2 lines
(quoted diff) +2 -0
+
+#include "ha-dsp.h"

[...]

Quoted 1 line

+static const char *ha_dsp_mode_texts[] = {"Mode 1", "Mode 2"};

const char *const

sound/soc/codecs/ha-dsp.c line 58

Quoted 5 lines
sound/soc/codecs/ha-dsp.c new file +5 -0
+static SOC_ENUM_SINGLE_DECL(ha_dsp_mode_enum, HA_DSP_CTRL, 0,
+			    ha_dsp_mode_texts);
+
+/* Monitor output mux selection */
+static const char *ha_dsp_monitor_texts[] = {"Off", "ADC", "DAC"};

const char *const

Quoted 3 lines
sound/soc/codecs/ha-dsp.c new file +3 -0
+static SOC_ENUM_SINGLE_DECL(ha_dsp_monitor_enum, HA_DSP_CTRL, 1,
+			    ha_dsp_monitor_texts);
+

[...]

sound/soc/codecs/ha-dsp.c line 119

Quoted 7 lines
sound/soc/codecs/ha-dsp.c new file +7 -0
+static const struct snd_soc_dapm_widget ha_dsp_widgets[] = {
+	SND_SOC_DAPM_ADC("ADC", "Capture", SND_SOC_NOPM, 0, 0),
+	SND_SOC_DAPM_DAC("DAC", "Playback", SND_SOC_NOPM, 0, 0),
+
+	SND_SOC_DAPM_MIXER("OUT1 Mixer", SND_SOC_NOPM, 0, 0,
+			   &ha_dsp_out1_mixer_controls[0],
+			   ARRAY_SIZE(ha_dsp_out1_mixer_controls)),

There is the SOC_MIXER_ARRAY() helper macro that you can use here and below.

Quoted 21 lines
sound/soc/codecs/ha-dsp.c new file +21 -0
+	SND_SOC_DAPM_MIXER("OUT2 Mixer", SND_SOC_NOPM, 0, 0,
+			   &ha_dsp_out2_mixer_controls[0],
+			   ARRAY_SIZE(ha_dsp_out2_mixer_controls)),
+	SND_SOC_DAPM_MIXER("OUT3 Mixer", SND_SOC_NOPM, 0, 0,
+			   &ha_dsp_out3_mixer_controls[0],
+			   ARRAY_SIZE(ha_dsp_out3_mixer_controls)),
+	SND_SOC_DAPM_MIXER("OUT4 Mixer", SND_SOC_NOPM, 0, 0,
+			   &ha_dsp_out4_mixer_controls[0],
+			   ARRAY_SIZE(ha_dsp_out4_mixer_controls)),
+	SND_SOC_DAPM_MIXER("OUT5 Mixer", SND_SOC_NOPM, 0, 0,
+			   &ha_dsp_out5_mixer_controls[0],
+			   ARRAY_SIZE(ha_dsp_out5_mixer_controls)),
+	SND_SOC_DAPM_MIXER("OUT6 Mixer", SND_SOC_NOPM, 0, 0,
+			   &ha_dsp_out6_mixer_controls[0],
+			   ARRAY_SIZE(ha_dsp_out6_mixer_controls)),
+	SND_SOC_DAPM_MIXER("OUT7 Mixer", SND_SOC_NOPM, 0, 0,
+			   &ha_dsp_out7_mixer_controls[0],
+			   ARRAY_SIZE(ha_dsp_out7_mixer_controls)),
+	SND_SOC_DAPM_MIXER("OUT8 Mixer", SND_SOC_NOPM, 0, 0,
+			   &ha_dsp_out8_mixer_controls[0],
+			   ARRAY_SIZE(ha_dsp_out8_mixer_controls)),

[...]

sound/soc/codecs/ha-dsp.c line 239

Quoted 6 lines
sound/soc/codecs/ha-dsp.c new file +6 -0
+static int ha_dsp_hw_params(struct snd_pcm_substream *substream,
+			    struct snd_pcm_hw_params *params,
+			    struct snd_soc_dai *dai)
+{
+	struct snd_soc_pcm_runtime *rtd = substream->private_data;
+	struct snd_soc_codec *codec = rtd->codec;

A codec should never look at the pcm_runtime. The proper way to get a pointer to the codec in dai callbacks is dai->codec. Or just use dai->dev below.

Quoted 7 lines
sound/soc/codecs/ha-dsp.c new file +7 -0
+
+	dev_dbg(codec->dev, "Sample format 0x%X\n", params_format(params));
+	dev_dbg(codec->dev, "Channels %d\n", params_channels(params));
+	dev_dbg(codec->dev, "Rate %d\n", params_rate(params));
+
+	return 0;
+}

[...]

Quoted 10 lines
sound/soc/codecs/ha-dsp.c new file +10 -0
+static int ha_dsp_set_bias_level(struct snd_soc_codec *codec,
+				 enum snd_soc_bias_level level)
+{
+	dev_dbg(codec->dev, "Changing bias from %d to %d\n",
+		codec->dapm.bias_level, level);
+
+	switch (level) {
+	case SND_SOC_BIAS_ON:
+		break;
+	case SND_SOC_BIAS_PREPARE:

sound/soc/codecs/ha-dsp.c line 295

Quoted 10 lines
sound/soc/codecs/ha-dsp.c new file +10 -0
+		/* Set PLL on */
+		break;
+	case SND_SOC_BIAS_STANDBY:
+		/* Set power on, Set PLL off */
+		break;
+	case SND_SOC_BIAS_OFF:
+		/* Set power down */
+		break;
+	}
+	codec->dapm.bias_level = level;

If you don't do anything in set_bias_level, just don't implement the function. The default implementation if no callback is specified is to set the bias_level to the requested level.

sound/soc/codecs/ha-dsp.c line 300

Quoted 5 lines
sound/soc/codecs/ha-dsp.c new file +5 -0
+
+	return 0;
+}
+
+static struct snd_soc_dai_ops ha_dsp_dai_ops = {

const

Quoted 20 lines
sound/soc/codecs/ha-dsp.c new file +20 -0
+	.hw_params	= ha_dsp_hw_params,
+	.set_fmt	= ha_dsp_set_dai_fmt,
+};
+
+static struct snd_soc_dai_driver ha_dsp_dai = {
+	.name = "ha-dsp-hifi",
+	.playback = {
+		.stream_name = "Playback",
+		.channels_min = 2,
+		.channels_max = 16,
+		.rates = SNDRV_PCM_RATE_8000_96000,
+		/* We use only 32 Bits for Audio */
+		.formats = SNDRV_PCM_FMTBIT_S32_LE,
+	},
+	.capture = {
+		.stream_name = "Capture",
+		.channels_min = 2,
+		.channels_max = 16,
+		.rates = SNDRV_PCM_RATE_8000_96000,
+		/* We use only 32 Bits for Audio */

sound/soc/codecs/ha-dsp.c line 330

Quoted 10 lines
sound/soc/codecs/ha-dsp.c new file +10 -0
+		.formats = SNDRV_PCM_FMTBIT_S32_LE,
+	},
+	.ops = &ha_dsp_dai_ops,
+};
+
+static int ha_dsp_probe(struct snd_soc_codec *codec)
+{
+	int ret;
+
+	codec->control_data = dev_get_regmap(codec->dev->parent, NULL);

Why do you want to use the regmap instance of the parent? That doesn't make sense given that you initialized a remgap instance for the device itself.

sound/soc/codecs/ha-dsp.c line 342

Quoted 12 lines
sound/soc/codecs/ha-dsp.c new file +12 -0
+	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;
+	}
+
+	return 0;
+}
+
+static int ha_dsp_remove(struct snd_soc_codec *codec)
+{
+	snd_soc_write(codec, HA_DSP_CTRL, HA_DSP_SW_RESET);

To get the codec into a well know state it is best practice to also reset it when probing the device.

Quoted 4 lines
sound/soc/codecs/ha-dsp.c new file +4 -0
+
+	return 0;
+}
+

[...]

Quoted 5 lines
sound/soc/codecs/ha-dsp.c new file +5 -0
+static int ha_dsp_i2c_probe(struct i2c_client *client,
+			    const struct i2c_device_id *id)
+{
+	struct regmap *regmap;
+	int ret;

sound/soc/codecs/ha-dsp.c line 384

Quoted 10 lines
sound/soc/codecs/ha-dsp.c new file +10 -0
+
+	regmap = devm_regmap_init_i2c(client, &ha_dsp_regmap);
+	if (IS_ERR(regmap)) {
+		ret = PTR_ERR(regmap);
+		dev_err(&client->dev, "Failed to create regmap: %d\n", ret);
+		return ret;
+	}
+
+	ret = snd_soc_register_codec(&client->dev, &soc_codec_dev_ha_dsp,
+				     &ha_dsp_dai, 1);

Just return snd_soc_register_codec(...)

Quoted 3 lines
sound/soc/codecs/ha-dsp.c new file +3 -0
+
+	return ret;
+}

[...]

#3 lore raw

Re: [PATCH 2/5] ASoC: Add HA (HEAD acoustics) DSP codec driver template

In reply to Stefan Roese

Hi Stefan

Quoted 7 lines · Stefan Roese

From: Jarkko Nikula <[email protected]>

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.

I think it's fair to change authorship to you or Thorsten as this is now more a real codec driver than implementation template I developed originally a few years back and you have done porting to newer kernel and API. Plus taking review commits too :-)

Quoted 9 lines

Updates from Stefan Roese, 2014-04-28:
Port the HA DSP codec driver to Linux v3.15-rc. This includes support for DT based probing. No platform-data code is needed any more, DT nodes are sufficient.

---

To me it's fine if you write commit log like it was done by you and say it's based on early implementation template from me. Or something like that.

sound/soc/codecs/ha-dsp.c line 7

Quoted 13 lines
sound/soc/codecs/ha-dsp.c new file +7 -0
new file mode 100644
index 0000000..7cf24dc
@@ -0,0 +1,419 @@
+/*
+ * ha-dsp.c  --  HA DSP ALSA SoC Audio driver
+ *
+ * Copyright 2011 Head acoustics GmbH
+ *
+ * Author: Jarkko Nikula <[email protected]>
+ *

List here also other authors in order to get kudos to you too.

Signature · 1 line
Jarkko
#6 lore raw

Re: [PATCH 3/5] ASoC: omap: Add HA (HEAD acoustics) DSP add-on card audio driver for TAO3530

In reply to Stefan Roese
Quoted 2 lines · Stefan Roese

From: Jarkko Nikula <[email protected]>

Same authorship and commit log notes here than to 2/5. One important comment below.

sound/soc/omap/ha-dsp-card.c line 8

Quoted 11 lines
sound/soc/omap/ha-dsp-card.c new file +8 -0
@@ -0,0 +1,307 @@
+/*
+ * ha-dsp-card.c  --  SoC audio HA-DSP add-on card for TAO-3530
+ *
+ * Author: Jarkko Nikula <[email protected]>
+ *
+ * Additional changes by:
+ *   Thorsten Eisbein <[email protected]>
+ *   Stefan Roese <[email protected]>

Put here Copyright 2011 Head acoustics GmbH.

Signature · 1 line
Jarkko
#7 lore raw

Re: [PATCH 3/5] ASoC: omap: Add HA (HEAD acoustics) DSP add-on card audio driver for TAO3530

In reply to Stefan Roese
Quoted 2 lines · Stefan Roese

From: Jarkko Nikula <[email protected]>

Same authorship and commit log notes here than to 2/5. One important note below.

sound/soc/omap/ha-dsp-card.c line 9

Quoted 12 lines
sound/soc/omap/ha-dsp-card.c new file +9 -0
@@ -0,0 +1,307 @@
+/*
+ * ha-dsp-card.c  --  SoC audio HA-DSP add-on card for TAO-3530
+ *
+ * Author: Jarkko Nikula <[email protected]>
+ *
+ * Additional changes by:
+ *   Thorsten Eisbein <[email protected]>
+ *   Stefan Roese <[email protected]>
+ *

Put here Copyright 2011 Head acoustics GmbH.

Signature · 1 line
Jarkko
maintainer
#4 lore raw

Re: [PATCH 2/5] ASoC: Add HA (HEAD acoustics) DSP codec driver template

In reply to Stefan Roese

sound/soc/codecs/ha-dsp.c line 246

Quoted 13 lines · Stefan Roese
sound/soc/codecs/ha-dsp.c new file +13 -0
+static int ha_dsp_hw_params(struct snd_pcm_substream *substream,
+			    struct snd_pcm_hw_params *params,
+			    struct snd_soc_dai *dai)
+{
+	struct snd_soc_pcm_runtime *rtd = substream->private_data;
+	struct snd_soc_codec *codec = rtd->codec;
+
+	dev_dbg(codec->dev, "Sample format 0x%X\n", params_format(params));
+	dev_dbg(codec->dev, "Channels %d\n", params_channels(params));
+	dev_dbg(codec->dev, "Rate %d\n", params_rate(params));
+
+	return 0;
+}

This doesn't do anything, you should either implement active code here or remove it (I note that a range of sample rates are supported and the CODEC can be clock master so I'd expect to see code here).

sound/soc/codecs/ha-dsp.c line 263

Quoted 11 lines
sound/soc/codecs/ha-dsp.c new file +11 -0
+	/* codec role */
+	switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) {
+	case SND_SOC_DAIFMT_CBM_CFM:
+		dev_dbg(codec->dev, "Codec is master\n");
+		break;
+	case SND_SOC_DAIFMT_CBS_CFS:
+		dev_dbg(codec->dev, "Codec is slave\n");
+		break;
+	default:
+		return -EINVAL;
+	}

This isn't doing anything with what it parsed, how does that work?

sound/soc/codecs/ha-dsp.c line 403

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);

This doesn't have any actual part numbers?

maintainer
#8 lore raw

Re: [PATCH 3/5] ASoC: omap: Add HA (HEAD acoustics) DSP add-on card audio driver for TAO3530

In reply to Stefan Roese

sound/soc/omap/ha-dsp-card.c line 59

Quoted 10 lines · Stefan Roese
sound/soc/omap/ha-dsp-card.c new file +10 -0
+	switch (params_channels(params)) {
+	case 2:
+	case 4:
+	case 8:
+	case 16:
+		fmt = SND_SOC_DAIFMT_DSP_B | SND_SOC_DAIFMT_IB_NF;
+		break;
+	default:
+		return -EINVAL;
+	}

Why is this "conditional" on the number of channels (though the same value is always chosen)?

sound/soc/omap/ha-dsp-card.c line 101

Quoted 13 lines
sound/soc/omap/ha-dsp-card.c new file +13 -0
+		/*
+		 * Calculate McBSP SRG divisor in McBSP master mode
+		 */
+		div = 96000000 / params_rate(params) / params_channels(params);
+		switch (params_format(params)) {
+		case SNDRV_PCM_FORMAT_S16_LE:
+			div /= 16;
+			break;
+		case SNDRV_PCM_FORMAT_S24_LE:
+		case SNDRV_PCM_FORMAT_S32_LE:
+			div /= 32;
+			break;
+		};

params_width().

sound/soc/omap/ha-dsp-card.c line 115

Quoted 5 lines
sound/soc/omap/ha-dsp-card.c new file +5 -0
+		ret = snd_soc_dai_set_clkdiv(cpu_dai, OMAP_MCBSP_CLKGDV, div);
+		if (ret < 0) {
+			pr_err("can't set SRG clock divider\n");
+			return ret;
+		}

Why not put this code into the DAI driver for the SoC - what's board specific about the calcuation? I'd expect this to be handlable by set_sysclk().

sound/soc/omap/ha-dsp-card.c line 210

Quoted 4 lines
sound/soc/omap/ha-dsp-card.c new file +4 -0
+	if (!node) {
+		dev_err(&pdev->dev, "No DT node provided\n");
+		return -ENODEV;
+	}

You've got something with a DT binding here but no binding document, documentation is mandatory for new DT bindings.

sound/soc/omap/ha-dsp-card.c line 244

Quoted 3 lines
sound/soc/omap/ha-dsp-card.c new file +3 -0
+	priv->slave = of_property_read_bool(node, "ha_dsp_codec_slave");
+	if (priv->slave)
+		dev_info(&pdev->dev, "Using slave mode for testing!\n");

This seems like something that shouldn't be in production code, or perhaps a build time option if the testing is valuable?

sound/soc/omap/ha-dsp-card.c line 250

Quoted 5 lines
sound/soc/omap/ha-dsp-card.c new file +5 -0
+	if (snd_soc_of_parse_card_name(card, "ti,model")) {
+		dev_err(&pdev->dev, "Card name is not provided\n");
+		ret = -ENODEV;
+		goto err;
+	}

Why not have a default?

sound/soc/omap/ha-dsp-card.c line 268

Quoted 6 lines
sound/soc/omap/ha-dsp-card.c new file +6 -0
+	ret = snd_soc_register_card(card);
+	if (ret) {
+		dev_err(&pdev->dev, "snd_soc_register_card() failed: %d\n",
+			ret);
+		goto err;
+	}

devm_snd_soc_register_card().

maintainer Applied
#11 lore raw
In reply to Stefan Roese
Quoted 5 lines · Stefan Roese

From: Jarkko Nikula <[email protected]>

Machine specific trigger callback allows to do final stream start/stop related operations in a machine driver after setting up the codec, DMA and DAI.

Applied, thanks.