Skip to contentSkip to conversation

Add ASoC drivers for SPEAr platform & I2S driver for Designware module

PATCH Applied Rajeev Kumar 2 participants 27 messages Jun 21, 2012 – Jun 27, 2012

Subsystems (2)

v2 of 5 Applied Latest is v5 →

lore
Share & tools
lore
#0 lore raw

v2 cover Add ASoC drivers for SPEAr platform & I2S driver for Designware module

Changes since V1:
1. Move Synopsys i2s designware controller from 'spear' folder to a new folder 'dwc'
2. Implemented regmap in sta529 codec.
3. In-corporated review comments received on V1.

Rajeev Kumar (6):
sound:asoc: Add support for STA529 Audio Codec sound:asoc: Add support for synopsys i2s controller as per ASoC
framework.
sound:asoc: Add support for SPEAr ASoC pcm layer. sound:asoc: Add support for SPEAr ASoC machine driver. sound:asoc: Add Kconfig and Makefile to support SPEAr audio driver sound:asoc: Update Kconfig and Makefile(sound/soc/) to support SPEAr
audio

Vipin Kumar (3):
sound:asoc: Add support for spdif in Audio Codec sound:asoc:spdif_in: Add spdif IN support sound:asoc:spdif_out: Add spdif out support

 include/sound/designware_i2s.h    |   69 ++++++
 include/sound/spear_dma.h         |   35 +++
 include/sound/spear_spdif.h       |   29 +++
 sound/soc/Kconfig                 |    2 +
 sound/soc/Makefile                |    2 +
 sound/soc/codecs/Kconfig          |    4 +
 sound/soc/codecs/Makefile         |    4 +-
 sound/soc/codecs/spdif_receiver.c |   76 ++++++
 sound/soc/codecs/sta529.c         |  477 +++++++++++++++++++++++++++++++++++++
 sound/soc/dwc/Kconfig             |    8 +
 sound/soc/dwc/Makefile            |    3 +
 sound/soc/dwc/designware_i2s.c    |  454 +++++++++++++++++++++++++++++++++++
 sound/soc/spear/Kconfig           |   40 +++
 sound/soc/spear/Makefile          |    7 +
 sound/soc/spear/spdif_in.c        |  297 +++++++++++++++++++++++
 sound/soc/spear/spdif_in_regs.h   |   60 +++++
 sound/soc/spear/spdif_out.c       |  397 ++++++++++++++++++++++++++++++
 sound/soc/spear/spdif_out_regs.h  |   79 ++++++
 sound/soc/spear/spear_evb.c       |  206 ++++++++++++++++
 sound/soc/spear/spear_pcm.c       |  214 +++++++++++++++++
 20 files changed, 2462 insertions(+), 1 deletions(-)
 create mode 100644 include/sound/designware_i2s.h
 create mode 100644 include/sound/spear_dma.h
 create mode 100644 include/sound/spear_spdif.h
 create mode 100644 sound/soc/codecs/spdif_receiver.c
 create mode 100644 sound/soc/codecs/sta529.c
 create mode 100644 sound/soc/dwc/Kconfig
 create mode 100644 sound/soc/dwc/Makefile
 create mode 100644 sound/soc/dwc/designware_i2s.c
 create mode 100644 sound/soc/spear/Kconfig
 create mode 100644 sound/soc/spear/Makefile
 create mode 100644 sound/soc/spear/spdif_in.c
 create mode 100644 sound/soc/spear/spdif_in_regs.h
 create mode 100644 sound/soc/spear/spdif_out.c
 create mode 100644 sound/soc/spear/spdif_out_regs.h
 create mode 100644 sound/soc/spear/spear_evb.c
 create mode 100644 sound/soc/spear/spear_pcm.c
#1 lore raw

PATCH v2 1/9 sound:asoc: Add support for spdif in Audio Codec

From: Vipin Kumar <[email protected]>

This patch adds the support for spdif in audio codec.

---
 sound/soc/codecs/Makefile         |    2 +-
 sound/soc/codecs/spdif_receiver.c |   76 +++++++++++++++++++++++++++++++++++++
 2 files changed, 77 insertions(+), 1 deletions(-)
 create mode 100644 sound/soc/codecs/spdif_receiver.c
sound/soc/codecs/Makefile +1 -1
index fc27fec..20b2d57 100644
@@ -41,7 +41,7 @@ snd-soc-alc5623-objs := alc5623.o
 snd-soc-alc5632-objs := alc5632.o
 snd-soc-sigmadsp-objs := sigmadsp.o
 snd-soc-sn95031-objs := sn95031.o
-snd-soc-spdif-objs := spdif_transciever.o
+snd-soc-spdif-objs := spdif_transciever.o spdif_receiver.o
 snd-soc-ssm2602-objs := ssm2602.o
 snd-soc-sta32x-objs := sta32x.o
 snd-soc-stac9766-objs := stac9766.o
sound/soc/codecs/spdif_receiver.c new file +76 -0

76 lines not on this page · raw message

Signature · 1 line
1.7.0.4
#2 lore raw

Re: [PATCH V2 1/9] sound:asoc: Add support for spdif in Audio Codec

Quoted 3 lines · Rajeev Kumar

From: Vipin Kumar <[email protected]>

This patch adds the support for spdif in audio codec.

As ever do try to provide subject lines which are appropriate for the subsystem you're submitting against.

sound/soc/codecs/spdif_receiver.c line 76

Quoted 12 lines
sound/soc/codecs/spdif_receiver.c new file +12 -0
+static int __init dir_modinit(void)
+{
+	return platform_driver_register(&spdif_dir_driver);
+}
+
+static void __exit dir_exit(void)
+{
+	platform_driver_unregister(&spdif_dir_driver);
+}
+
+module_init(dir_modinit);
+module_exit(dir_exit);

module_platform_driver().

#3 lore raw

Re: [PATCH V2 1/9] sound:asoc: Add support for spdif in Audio Codec

Hello Mark,

Quoted 8 lines · Mark Brown
Quoted 3 lines · Rajeev Kumar

From: Vipin Kumar<[email protected]>

This patch adds the support for spdif in audio codec.

As ever do try to provide subject lines which are appropriate for the subsystem you're submitting against.

Ok , I will take care of these stuff.

It should be
ASoc: SPEAr: SPDIF

Quoted 6 lines
Quoted 6 lines
sound/soc/codecs/spdif_receiver.c new file +6 -0
+static int __init dir_modinit(void)
+{
+	return platform_driver_register(&spdif_dir_driver);
+}
+
+static void __exit dir_exit(void)
Quoted 8 lines

sound/soc/codecs/spdif_receiver.c line 76

Quoted 6 lines
sound/soc/codecs/spdif_receiver.c new file +6 -0
+{
+	platform_driver_unregister(&spdif_dir_driver);
+}
+
+module_init(dir_modinit);
+module_exit(dir_exit);

module_platform_driver().

Ok

Best Regards
Rajeev

#4 lore raw

Re: [PATCH V2 1/9] sound:asoc: Add support for spdif in Audio Codec

Quoted 2 lines · Rajeev kumar

It should be
ASoc: SPEAr: SPDIF

It should be "ASoC". Where have you seen "ASoc"?

#5 lore raw

Re: [PATCH V2 1/9] sound:asoc: Add support for spdif in Audio Codec

Hello Mark,

Quoted 6 lines · Mark Brown
Quoted 2 lines · Rajeev kumar

It should be
ASoc: SPEAr: SPDIF

It should be "ASoC". Where have you seen "ASoc"?

Oops, Yes it should be "ASoC".

Best Regards,
Rajeev

#6 lore raw

PATCH v2 2/9 sound:asoc: Add support for STA529 Audio Codec

In reply to Rajeev Kumar

This patch adds the support for STA529 audio codec.

---
 sound/soc/codecs/Kconfig  |    4 +
 sound/soc/codecs/Makefile |    2 +
 sound/soc/codecs/sta529.c |  477 +++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 483 insertions(+), 0 deletions(-)
 create mode 100644 sound/soc/codecs/sta529.c
sound/soc/codecs/Kconfig +4 -0
index 1e1613a..f06600b 100644
@@ -54,6 +54,7 @@ config SND_SOC_ALL_CODECS
 	select SND_SOC_SPDIF
 	select SND_SOC_SSM2602 if SND_SOC_I2C_AND_SPI
 	select SND_SOC_STA32X if I2C
+	select SND_SOC_STA529 if I2C
 	select SND_SOC_STAC9766 if SND_SOC_AC97_BUS
 	select SND_SOC_TLV320AIC23 if I2C
 	select SND_SOC_TLV320AIC26 if SPI_MASTER
@@ -266,6 +267,9 @@ config SND_SOC_SSM2602
 config SND_SOC_STA32X
 	tristate
 
+config SND_SOC_STA529
+	tristate
+
 config SND_SOC_STAC9766
 	tristate
 
sound/soc/codecs/Makefile +2 -0
index 20b2d57..09c2dd9 100644
@@ -44,6 +44,7 @@ snd-soc-sn95031-objs := sn95031.o
 snd-soc-spdif-objs := spdif_transciever.o spdif_receiver.o
 snd-soc-ssm2602-objs := ssm2602.o
 snd-soc-sta32x-objs := sta32x.o
+snd-soc-sta529-objs := sta529.o
 snd-soc-stac9766-objs := stac9766.o
 snd-soc-tlv320aic23-objs := tlv320aic23.o
 snd-soc-tlv320aic26-objs := tlv320aic26.o
@@ -153,6 +154,7 @@ obj-$(CONFIG_SND_SOC_SN95031)	+=snd-soc-sn95031.o
 obj-$(CONFIG_SND_SOC_SPDIF)	+= snd-soc-spdif.o
 obj-$(CONFIG_SND_SOC_SSM2602)	+= snd-soc-ssm2602.o
 obj-$(CONFIG_SND_SOC_STA32X)   += snd-soc-sta32x.o
+obj-$(CONFIG_SND_SOC_STA529)   += snd-soc-sta529.o
 obj-$(CONFIG_SND_SOC_STAC9766)	+= snd-soc-stac9766.o
 obj-$(CONFIG_SND_SOC_TLV320AIC23)	+= snd-soc-tlv320aic23.o
 obj-$(CONFIG_SND_SOC_TLV320AIC26)	+= snd-soc-tlv320aic26.o
sound/soc/codecs/sta529.c new file +477 -0

477 lines not on this page · raw message

Signature · 1 line
1.7.0.4
#7 lore raw

Re: [PATCH V2 2/9] sound:asoc: Add support for STA529 Audio Codec

Quoted 1 line · Rajeev Kumar

This patch adds the support for STA529 audio codec.

As I said last time always use subject lines corresponding to the style of the subsystem, don't make up your own style.

This is mostly OK, a few things below but nothing terribly major.

sound/soc/codecs/sta529.c line 269

Quoted 6 lines
sound/soc/codecs/sta529.c new file +6 -0
+static int sta529_mute(struct snd_soc_dai *dai, int mute)
+{
+	u8 val;
+
+	if (mute)
+		val |= CODEC_MUTE_VAL;

You need to initialise val otherwise it's going to have an undefined value when you're not muting.

sound/soc/codecs/sta529.c line 332

Quoted 2 lines
sound/soc/codecs/sta529.c new file +2 -0
+	codec->control_data = sta529->regmap;
+	ret = snd_soc_codec_set_cache_io(codec, 8, 8, SND_SOC_I2C);

You've got a regmap, you should be using SND_SOC_REGMAP as the control mode.

sound/soc/codecs/sta529.c line 343

Quoted 5 lines
sound/soc/codecs/sta529.c new file +5 -0
+	snd_soc_add_codec_controls(codec, sta529_snd_controls,
+			ARRAY_SIZE(sta529_snd_controls));
+
+	snd_soc_add_codec_controls(codec, sta529_new_snd_controls,
+			ARRAY_SIZE(sta529_new_snd_controls));

Set these in the CODEC driver structure and merge the two arrays, no point in having code for this.

sound/soc/codecs/sta529.c line 364

Quoted 3 lines
sound/soc/codecs/sta529.c new file +3 -0
+static int sta529_resume(struct snd_soc_codec *codec)
+{
+	snd_soc_cache_sync(codec);

You're not using the ASoC cache code.

Review

Quoted 2 lines
(quoted diff) +2 -0
+	sta529_set_bias_level(codec, SND_SOC_BIAS_STANDBY);
+	sta529_set_bias_level(codec, codec->dapm.suspend_bias_level);

The second of these isn't needed, the core will ensure the device is in standby before suspend.

sound/soc/codecs/sta529.c line 407

Quoted 2 lines
sound/soc/codecs/sta529.c new file +2 -0
+	sta529->regmap = regmap_init_i2c(i2c, &sta529_regmap);
+	if (IS_ERR(sta529->regmap)) {

devm_regmap_init_i2c() then you don't need any cleanup code for it.

sound/soc/codecs/sta529.c line 458

Quoted 3 lines
sound/soc/codecs/sta529.c new file +3 -0
+static int __init sta529_modinit(void)
+{
+	int ret = 0;

module_i2c_driver.

#8 lore raw

Re: [PATCH V2 2/9] sound:asoc: Add support for STA529 Audio Codec

Hello Mark

Quoted 5 lines · Mark Brown
Quoted 3 lines

+static int sta529_resume(struct snd_soc_codec *codec)

Quoted 2 lines

+{
+ snd_soc_cache_sync(codec);

You're not using the ASoC cache code.

Point is not clear to me, you mean to say I need to use regcache_sync(sta529->regmap), please confirm.

Best Regards
Rajeev

#9 lore raw

Re: [PATCH V2 2/9] sound:asoc: Add support for STA529 Audio Codec

Quoted 9 lines · Rajeev kumar
Quoted 4 lines · Mark Brown
Quoted 3 lines

+static int sta529_resume(struct snd_soc_codec *codec)

Quoted 2 lines

+{
+ snd_soc_cache_sync(codec);

You're not using the ASoC cache code.

Point is not clear to me, you mean to say I need to use regcache_sync(sta529->regmap), please confirm.

You shouldn't be calling ASoC cache functions at all since you're not using an ASoC cache. There's no point in doing anything here as you're doing your cache management in set_bias_level() but if you were then yes you should be using regcache_sync().

#10 lore raw

PATCH v2 3/9 sound:asoc: Add support for synopsys i2s controller as per ASoC framework.

In reply to Rajeev Kumar

This patch add support for synopsys I2S controller as per the ASoC framework.

---
 include/sound/designware_i2s.h |   69 ++++++
 sound/soc/Kconfig              |    1 +
 sound/soc/Makefile             |    1 +
 sound/soc/dwc/Kconfig          |    8 +
 sound/soc/dwc/Makefile         |    3 +
 sound/soc/dwc/designware_i2s.c |  454 ++++++++++++++++++++++++++++++++++++++++
 6 files changed, 536 insertions(+), 0 deletions(-)
 create mode 100644 include/sound/designware_i2s.h
 create mode 100644 sound/soc/dwc/Kconfig
 create mode 100644 sound/soc/dwc/Makefile
 create mode 100644 sound/soc/dwc/designware_i2s.c
include/sound/designware_i2s.h new file +69 -0
new file mode 100644
index 0000000..26f406e
@@ -0,0 +1,69 @@
+/*
+ * Copyright (ST) 2012 Rajeev Kumar ([email protected])
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ */
+
+#ifndef __SOUND_DESIGNWARE_I2S_H
+#define __SOUND_DESIGNWARE_I2S_H
+
+#include <linux/dmaengine.h>
+#include <linux/types.h>
+
+/*
+ * struct i2s_clk_config_data - represent i2s clk configuration data
+ * @chan_nr: number of channel
+ * @data_width: number of bits per sample (8/16/24/32 bit)
+ * @sample_rate: sampling frequency (8Khz, 16Khz, 32Khz, 44Khz, 48Khz)
+ */
+struct i2s_clk_config_data {
+	int chan_nr;
+	u32 data_width;
+	u32 sample_rate;
+};
+
+struct i2s_platform_data {
+	#define DWC_I2S_PLAY	(1 << 0)
+	#define DWC_I2S_RECORD	(1 << 1)
+	unsigned int cap;
+	int channel;
+	u32 snd_fmts;
+	u32 snd_rates;
+
+	void *play_dma_data;
+	void *capture_dma_data;
+	bool (*filter)(struct dma_chan *chan, void *slave);
+	int (*i2s_clk_cfg)(struct i2s_clk_config_data *config);
+};
+
+struct i2s_dma_data {
+	void *data;
+	dma_addr_t addr;
+	u32 max_burst;
+	enum dma_slave_buswidth addr_width;
+	bool (*filter)(struct dma_chan *chan, void *slave);
+};
+
+/* I2S DMA registers */
+#define I2S_RXDMA		0x01C0
+#define I2S_TXDMA		0x01C8
+
+#define TWO_CHANNEL_SUPPORT	2	/* up to 2.0 */
+#define FOUR_CHANNEL_SUPPORT	4	/* up to 3.1 */
+#define SIX_CHANNEL_SUPPORT	6	/* up to 5.1 */
+#define EIGHT_CHANNEL_SUPPORT	8	/* up to 7.1 */
+
+#endif /*  __SOUND_DESIGNWARE_I2S_H */
sound/soc/Kconfig +1 -0
index 40b2ad1..c5de0a8 100644
@@ -33,6 +33,7 @@ source "sound/soc/atmel/Kconfig"
 source "sound/soc/au1x/Kconfig"
 source "sound/soc/blackfin/Kconfig"
 source "sound/soc/davinci/Kconfig"
+source "sound/soc/dwc/Kconfig"
 source "sound/soc/ep93xx/Kconfig"
 source "sound/soc/fsl/Kconfig"
 source "sound/soc/jz4740/Kconfig"
sound/soc/Makefile +1 -0
index 70990f4..00a555a 100644
@@ -11,6 +11,7 @@ obj-$(CONFIG_SND_SOC)	+= atmel/
 obj-$(CONFIG_SND_SOC)	+= au1x/
 obj-$(CONFIG_SND_SOC)	+= blackfin/
 obj-$(CONFIG_SND_SOC)	+= davinci/
+obj-$(CONFIG_SND_SOC)	+= dwc/
 obj-$(CONFIG_SND_SOC)	+= ep93xx/
 obj-$(CONFIG_SND_SOC)	+= fsl/
 obj-$(CONFIG_SND_SOC)	+= jz4740/
sound/soc/dwc/Kconfig new file +8 -0
new file mode 100644
index 0000000..93e9fc3
@@ -0,0 +1,8 @@
+config SND_DESIGNWARE_I2S
+	tristate "Synopsys I2S Device Driver"
+	help
+	 Say Y or M if you want to add support for I2S driver for
+	 Synopsys desigwnware I2S device. The device supports upto
+	 maximum of 8 channels each for play and record.
+
+
sound/soc/dwc/Makefile new file +3 -0
new file mode 100644
index 0000000..319371f
@@ -0,0 +1,3 @@
+# SYNOPSYS Platform Support
+obj-$(CONFIG_SND_DESIGNWARE_I2S) += designware_i2s.o
+
sound/soc/dwc/designware_i2s.c new file +454 -0

454 lines not on this page · raw message

Signature · 1 line
1.7.0.4
Applied
#11 lore raw

Re: [PATCH V2 3/9] sound:asoc: Add support for synopsys i2s controller as per ASoC framework.

Quoted 2 lines · Rajeev Kumar

This patch add support for synopsys I2S controller as per the ASoC framework.

I've applied this but I had to rewrite the subject line.

sound/soc/dwc/designware_i2s.c line 303

Quoted 7 lines
sound/soc/dwc/designware_i2s.c new file +7 -0
+static int dw_i2s_suspend(struct snd_soc_dai *dai)
+{
+	struct dw_i2s_dev *dev = snd_soc_dai_get_drvdata(dai);
+
+	clk_disable(dev->clk);
+	return 0;
+}

It seems a bit sad that we can't disable the clock when the device is idle. If you need the clock for register I/O then something like the Tegra approach of using regmap to provide a cached copy of the register map when the device is idle should work well.

#12 lore raw

Re: [PATCH V2 3/9] sound:asoc: Add support for synopsys i2s controller as per ASoC framework.

Hello Mark,

Quoted 6 lines · Mark Brown
Quoted 2 lines · Rajeev Kumar

This patch add support for synopsys I2S controller as per the ASoC framework.

I've applied this but I had to rewrite the subject line.

Thanks,

Quoted 4 lines
Quoted 4 lines
sound/soc/dwc/designware_i2s.c new file +4 -0
+static int dw_i2s_suspend(struct snd_soc_dai *dai)
+{
+	struct dw_i2s_dev *dev = snd_soc_dai_get_drvdata(dai);
+
Quoted 8 lines

sound/soc/dwc/designware_i2s.c line 303

Quoted 3 lines
sound/soc/dwc/designware_i2s.c new file +3 -0
+	clk_disable(dev->clk);
+	return 0;
+}

It seems a bit sad that we can't disable the clock when the device is idle. If you need the clock for register I/O then something like the Tegra approach of using regmap to provide a cached copy of the register map when the device is idle should work well.

I will keep this in my TODO list and will circulate a separate patch for this later.

Best Regards
Rajeev

#13 lore raw

PATCH v2 4/9 sound:asoc: Add support for SPEAr ASoC pcm layer.

In reply to Rajeev Kumar

This patch add support for the SPEAr ASoC pcm layer in ASoC framework. The pcm layer uses common snd_dmaengine framework.

---
 include/sound/spear_dma.h   |   35 +++++++
 sound/soc/spear/spear_pcm.c |  214 +++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 249 insertions(+), 0 deletions(-)
 create mode 100644 include/sound/spear_dma.h
 create mode 100644 sound/soc/spear/spear_pcm.c
include/sound/spear_dma.h new file +35 -0
new file mode 100644
index 0000000..1b365bf
@@ -0,0 +1,35 @@
+/*
+* linux/spear_dma.h
+*
+* Copyright (ST) 2012 Rajeev Kumar ([email protected])
+*
+* This program is free software; you can redistribute it and/or modify
+* it under the terms of the GNU General Public License as published by
+* the Free Software Foundation; either version 2 of the License, or
+* (at your option) any later version.
+*
+* This program is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU General Public License for more details.
+*
+* You should have received a copy of the GNU General Public License
+* along with this program; if not, write to the Free Software
+* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+*
+*/
+
+#ifndef SPEAR_DMA_H
+#define SPEAR_DMA_H
+
+#include <linux/dmaengine.h>
+
+struct spear_dma_data {
+	void *data;
+	dma_addr_t addr;
+	u32 max_burst;
+	enum dma_slave_buswidth addr_width;
+	bool (*filter)(struct dma_chan *chan, void *slave);
+};
+
+#endif /* SPEAR_DMA_H */
sound/soc/spear/spear_pcm.c new file +214 -0

214 lines not on this page · raw message

Signature · 1 line
1.7.0.4
Applied
#14 lore raw

Re: [PATCH V2 4/9] sound:asoc: Add support for SPEAr ASoC pcm layer.

Quoted 2 lines · Rajeev Kumar

This patch add support for the SPEAr ASoC pcm layer in ASoC framework. The pcm layer uses common snd_dmaengine framework.

Applied, thanks (again with rewritten subject).

#15 lore raw

Re: [PATCH V2 4/9] sound:asoc: Add support for SPEAr ASoC pcm layer.

Quoted 5 lines · Mark Brown
Quoted 2 lines · Rajeev Kumar

This patch add support for the SPEAr ASoC pcm layer in ASoC framework. The pcm layer uses common snd_dmaengine framework.

Applied, thanks (again with rewritten subject).

Thanks,

Best Regards
Rajeev

#16 lore raw

PATCH v2 5/9 sound:asoc:spdif_in: Add spdif IN support

In reply to Rajeev Kumar

From: Vipin Kumar <[email protected]>

This patch implements the spdif IN driver for ST peripheral

---
 include/sound/spear_spdif.h     |   29 ++++
 sound/soc/spear/spdif_in.c      |  297 +++++++++++++++++++++++++++++++++++++++
 sound/soc/spear/spdif_in_regs.h |   60 ++++++++
 3 files changed, 386 insertions(+), 0 deletions(-)
 create mode 100644 include/sound/spear_spdif.h
 create mode 100644 sound/soc/spear/spdif_in.c
 create mode 100644 sound/soc/spear/spdif_in_regs.h
include/sound/spear_spdif.h new file +29 -0
new file mode 100644
index 0000000..a12f396
@@ -0,0 +1,29 @@
+/*
+ * Copyright (ST) 2012 Vipin Kumar ([email protected])
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#ifndef __SOUND_SPDIF_H
+#define __SOUND_SPDIF_H
+
+struct spear_spdif_platform_data {
+	/* DMA params */
+	void *dma_params;
+	bool (*filter)(struct dma_chan *chan, void *slave);
+	void (*reset_perip)(void);
+};
+
+#endif /* SOUND_SPDIF_H */
sound/soc/spear/spdif_in.c new file +297 -0

297 lines not on this page · raw message

sound/soc/spear/spdif_in_regs.h new file +60 -0

60 lines not on this page · raw message

Signature · 1 line
1.7.0.4
Applied
#17 lore raw

Re: [PATCH V2 5/9] sound:asoc:spdif_in: Add spdif IN support

Quoted 3 lines · Rajeev Kumar

From: Vipin Kumar <[email protected]>

This patch implements the spdif IN driver for ST peripheral

Applied, thanks, with the usual comment about subject lines.

#18 lore raw

PATCH v2 6/9 sound:asoc:spdif_out: Add spdif out support

In reply to Rajeev Kumar

From: Vipin Kumar <[email protected]>

This patch implements the spdif out driver for ST peripheral. This peripheral implements IEC60958 standard

---
 sound/soc/spear/spdif_out.c      |  397 ++++++++++++++++++++++++++++++++++++++
 sound/soc/spear/spdif_out_regs.h |   79 ++++++++
 2 files changed, 476 insertions(+), 0 deletions(-)
 create mode 100644 sound/soc/spear/spdif_out.c
 create mode 100644 sound/soc/spear/spdif_out_regs.h
sound/soc/spear/spdif_out.c new file +397 -0
new file mode 100644
index 0000000..cb1969a
@@ -0,0 +1,397 @@
+/*
+ * ALSA SoC SPDIF Out Audio Layer for spear processors
+ *
+ * Copyright (C) 2012 ST Microelectronics
+ * Vipin Kumar <[email protected]>
+ *
+ * This file is licensed under the terms of the GNU General Public
+ * License version 2. This program is licensed "as is" without any
+ * warranty of any kind, whether express or implied.
+ */
+
+#include <linux/clk.h>
+#include <linux/delay.h>
+#include <linux/device.h>
+#include <linux/kernel.h>
+#include <linux/init.h>
+#include <linux/io.h>
+#include <linux/ioport.h>
+#include <linux/module.h>
+#include <linux/platform_device.h>
+#include <sound/soc.h>
+#include <sound/spear_dma.h>
+#include <sound/spear_spdif.h>
+#include "spdif_out_regs.h"
+
+static int spdif_out_mute;
+
+struct spdif_out_params {
+	u32 rate;
+	u32 core_freq;
+};
+
+struct spdif_out_dev {
+	struct clk *clk;
+	struct spear_dma_data dma_params;
+	struct spdif_out_params saved_params;
+	u32 running;
+	void *io_base;
+};
+
+static void spdif_out_configure(struct spdif_out_dev *host)
+{
+	writel(SPDIF_OUT_RESET, host->io_base + SPDIF_OUT_SOFT_RST);
+	mdelay(1);
+	writel(readl(host->io_base + SPDIF_OUT_SOFT_RST) & ~SPDIF_OUT_RESET,
+			host->io_base + SPDIF_OUT_SOFT_RST);
+
+	writel(SPDIF_OUT_FDMA_TRIG_16 | SPDIF_OUT_MEMFMT_16_16 |
+			SPDIF_OUT_VALID_HW | SPDIF_OUT_USER_HW |
+			SPDIF_OUT_CHNLSTA_HW | SPDIF_OUT_PARITY_HW,
+			host->io_base + SPDIF_OUT_CFG);
+
+	writel(0x7F, host->io_base + SPDIF_OUT_INT_STA_CLR);
+	writel(0x7F, host->io_base + SPDIF_OUT_INT_EN_CLR);
+}
+
+static int spdif_out_startup(struct snd_pcm_substream *substream,
+		struct snd_soc_dai *cpu_dai)
+{
+	struct spdif_out_dev *host = snd_soc_dai_get_drvdata(cpu_dai);
+	int ret;
+
+	if (substream->stream != SNDRV_PCM_STREAM_PLAYBACK)
+		return -EINVAL;
+
+	snd_soc_dai_set_dma_data(cpu_dai, substream, (void *)&host->dma_params);
+
+	ret = clk_enable(host->clk);
+	if (ret)
+		return ret;
+
+	host->running = true;
+	spdif_out_configure(host);
+
+	return 0;
+}
+
+static void spdif_out_shutdown(struct snd_pcm_substream *substream,
+		struct snd_soc_dai *dai)
+{
+	struct spdif_out_dev *host = snd_soc_dai_get_drvdata(dai);
+
+	if (substream->stream != SNDRV_PCM_STREAM_PLAYBACK)
+		return;
+
+	clk_disable(host->clk);
+	host->running = false;
+	snd_soc_dai_set_dma_data(dai, substream, NULL);
+}
+
+static void spdif_out_clock(struct spdif_out_dev *host, u32 core_freq,
+		u32 rate)
+{
+	u32 divider, ctrl;
+
+	clk_set_rate(host->clk, core_freq);
+	divider = DIV_ROUND_CLOSEST(clk_get_rate(host->clk), (rate * 128));
+
+	ctrl = readl(host->io_base + SPDIF_OUT_CTRL);
+	ctrl &= ~SPDIF_DIVIDER_MASK;
+	ctrl |= (divider << SPDIF_DIVIDER_SHIFT) & SPDIF_DIVIDER_MASK;
+	writel(ctrl, host->io_base + SPDIF_OUT_CTRL);
+}
+
+static int spdif_out_hw_params(struct snd_pcm_substream *substream,
+		struct snd_pcm_hw_params *params,
+		struct snd_soc_dai *dai)
+{
+	struct spdif_out_dev *host = snd_soc_dai_get_drvdata(dai);
+	u32 rate, core_freq;
+
+	if (substream->stream != SNDRV_PCM_STREAM_PLAYBACK)
+		return -EINVAL;
+
+	rate = params_rate(params);
+
+	switch (rate) {
+	case 8000:
+	case 16000:
+	case 32000:
+	case 64000:
+		/*
+		 * The clock is multiplied by 10 to bring it to feasible range
+		 * of frequencies for sscg
+		 */
+		core_freq = 64000 * 128 * 10;	/* 81.92 MHz */
+		break;
+	case 5512:
+	case 11025:
+	case 22050:
+	case 44100:
+	case 88200:
+	case 176400:
+		core_freq = 176400 * 128;	/* 22.5792 MHz */
+		break;
+	case 48000:
+	case 96000:
+	case 192000:
+	default:
+		core_freq = 192000 * 128;	/* 24.576 MHz */
+		break;
+	}
+
+	spdif_out_clock(host, core_freq, rate);
+	host->saved_params.core_freq = core_freq;
+	host->saved_params.rate = rate;
+
+	return 0;
+}
+
+static int spdif_out_trigger(struct snd_pcm_substream *substream, int cmd,
+		struct snd_soc_dai *dai)
+{
+	struct spdif_out_dev *host = snd_soc_dai_get_drvdata(dai);
+	u32 ctrl;
+	int ret = 0;
+
+	if (substream->stream != SNDRV_PCM_STREAM_PLAYBACK)
+		return -EINVAL;
+
+	switch (cmd) {
+	case SNDRV_PCM_TRIGGER_START:
+	case SNDRV_PCM_TRIGGER_RESUME:
+	case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
+			ctrl = readl(host->io_base + SPDIF_OUT_CTRL);
+			ctrl &= ~SPDIF_OPMODE_MASK;
+			if (!spdif_out_mute)
+				ctrl |= SPDIF_OPMODE_AUD_DATA |
+					SPDIF_STATE_NORMAL;
+			else
+				ctrl |= SPDIF_OPMODE_MUTE_PCM;
+			writel(ctrl, host->io_base + SPDIF_OUT_CTRL);
+		break;
+
+	case SNDRV_PCM_TRIGGER_STOP:
+	case SNDRV_PCM_TRIGGER_SUSPEND:
+	case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
+		ctrl = readl(host->io_base + SPDIF_OUT_CTRL);
+		ctrl &= ~SPDIF_OPMODE_MASK;
+		ctrl |= SPDIF_OPMODE_OFF;
+		writel(ctrl, host->io_base + SPDIF_OUT_CTRL);
+		break;
+
+	default:
+		ret = -EINVAL;
+		break;
+	}
+	return ret;
+}
+
+static int spdif_digital_mute(struct snd_soc_dai *dai, int mute)
+{
+	struct spdif_out_dev *host = snd_soc_dai_get_drvdata(dai);
+	u32 val;
+
+	spdif_out_mute = mute;
+	val = readl(host->io_base + SPDIF_OUT_CTRL);
+	val &= ~SPDIF_OPMODE_MASK;
+
+	if (mute)
+		val |= SPDIF_OPMODE_MUTE_PCM;
+	else {
+		if (host->running)
+			val |= SPDIF_OPMODE_AUD_DATA | SPDIF_STATE_NORMAL;
+		else
+			val |= SPDIF_OPMODE_OFF;
+	}
+
+	writel(val, host->io_base + SPDIF_OUT_CTRL);
+	return 0;
+}
+
+static int spdif_mute_get(struct snd_kcontrol *kcontrol,
+		struct snd_ctl_elem_value *ucontrol)
+{
+	ucontrol->value.integer.value[0] = spdif_out_mute;
+	return 0;
+}
+
+static int spdif_mute_put(struct snd_kcontrol *kcontrol,
+		struct snd_ctl_elem_value *ucontrol)
+{
+	struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
+	struct snd_soc_card *card = codec->card;
+	struct snd_soc_pcm_runtime *rtd = card->rtd;
+	struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
+
+	if (spdif_out_mute == ucontrol->value.integer.value[0])
+		return 0;
+
+	spdif_digital_mute(cpu_dai, ucontrol->value.integer.value[0]);
+
+	return 1;
+}
+static const struct snd_kcontrol_new spdif_out_controls[] = {
+	SOC_SINGLE_BOOL_EXT("SPDIF Play Mute", (unsigned long)&spdif_out_mute,
+			spdif_mute_get, spdif_mute_put),
+};
+
+int spdif_soc_dai_probe(struct snd_soc_dai *dai)
+{
+	struct snd_soc_card *card = dai->card;
+	struct snd_soc_pcm_runtime *rtd = card->rtd;
+	struct snd_soc_codec *codec = rtd->codec;
+
+	return snd_soc_add_codec_controls(codec, spdif_out_controls,
+				ARRAY_SIZE(spdif_out_controls));
+}
+
+static struct snd_soc_dai_ops spdif_out_dai_ops = {
+	.digital_mute	= spdif_digital_mute,
+	.startup	= spdif_out_startup,
+	.shutdown	= spdif_out_shutdown,
+	.trigger	= spdif_out_trigger,
+	.hw_params	= spdif_out_hw_params,
+};
+
+struct snd_soc_dai_driver spdif_out_dai = {
+	.playback = {
+		.channels_min = 2,
+		.channels_max = 2,
+		.rates = (SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 | \
+				 SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_96000 | \
+				 SNDRV_PCM_RATE_192000),
+		.formats = SNDRV_PCM_FMTBIT_S16_LE,
+	},
+	.probe = spdif_soc_dai_probe,
+	.ops = (struct snd_soc_dai_ops *)&spdif_out_dai_ops,
+};
+
+static int spdif_out_probe(struct platform_device *pdev)
+{
+	struct spdif_out_dev *host;
+	struct spear_spdif_platform_data *pdata;
+	struct resource *res;
+	int ret;
+
+	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+	if (!res)
+		return -EINVAL;
+
+	if (!devm_request_mem_region(&pdev->dev, res->start,
+				resource_size(res), pdev->name)) {
+		dev_warn(&pdev->dev, "Failed to get memory resourse\n");
+		return -ENOENT;
+	}
+
+	host = devm_kzalloc(&pdev->dev, sizeof(*host), GFP_KERNEL);
+	if (!host) {
+		dev_warn(&pdev->dev, "kzalloc fail\n");
+		return -ENOMEM;
+	}
+
+	host->io_base = devm_ioremap(&pdev->dev, res->start,
+				resource_size(res));
+	if (!host->io_base) {
+		dev_warn(&pdev->dev, "ioremap failed\n");
+		return -ENOMEM;
+	}
+
+	host->clk = clk_get(&pdev->dev, NULL);
+	if (IS_ERR(host->clk))
+		return PTR_ERR(host->clk);
+
+	pdata = dev_get_platdata(&pdev->dev);
+
+	host->dma_params.data = pdata->dma_params;
+	host->dma_params.addr = res->start + SPDIF_OUT_FIFO_DATA;
+	host->dma_params.max_burst = 16;
+	host->dma_params.addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES;
+	host->dma_params.filter = pdata->filter;
+
+	dev_set_drvdata(&pdev->dev, host);
+
+	ret = snd_soc_register_dai(&pdev->dev, &spdif_out_dai);
+	if (ret != 0) {
+		clk_put(host->clk);
+		return ret;
+	}
+
+	return 0;
+}
+
+static int spdif_out_remove(struct platform_device *pdev)
+{
+	struct spdif_out_dev *host = dev_get_drvdata(&pdev->dev);
+
+	snd_soc_unregister_dai(&pdev->dev);
+	dev_set_drvdata(&pdev->dev, NULL);
+
+	clk_put(host->clk);
+
+	return 0;
+}
+
+#ifdef CONFIG_PM
+static int spdif_out_suspend(struct device *dev)
+{
+	struct platform_device *pdev = to_platform_device(dev);
+	struct spdif_out_dev *host = dev_get_drvdata(&pdev->dev);
+
+	if (host->running)
+		clk_disable(host->clk);
+
+	return 0;
+}
+
+static int spdif_out_resume(struct device *dev)
+{
+	struct platform_device *pdev = to_platform_device(dev);
+	struct spdif_out_dev *host = dev_get_drvdata(&pdev->dev);
+
+	if (host->running) {
+		clk_enable(host->clk);
+		spdif_out_configure(host);
+		spdif_out_clock(host, host->saved_params.core_freq,
+				host->saved_params.rate);
+	}
+	return 0;
+}
+
+static SIMPLE_DEV_PM_OPS(spdif_out_dev_pm_ops, spdif_out_suspend, \
+		spdif_out_resume);
+
+#define SPDIF_OUT_DEV_PM_OPS (&spdif_out_dev_pm_ops)
+
+#else
+#define SPDIF_OUT_DEV_PM_OPS NULL
+
+#endif
+
+static struct platform_driver spdif_out_driver = {
+	.probe		= spdif_out_probe,
+	.remove		= spdif_out_remove,
+	.driver		= {
+		.name	= "spdif-out",
+		.owner	= THIS_MODULE,
+		.pm	= SPDIF_OUT_DEV_PM_OPS,
+	},
+};
+
+static int __init spdif_out_init(void)
+{
+	return platform_driver_register(&spdif_out_driver);
+}
+module_init(spdif_out_init);
+
+static void __exit spdif_out_exit(void)
+{
+	platform_driver_unregister(&spdif_out_driver);
+}
+module_exit(spdif_out_exit);
+
+MODULE_AUTHOR("Vipin Kumar <[email protected]>");
+MODULE_DESCRIPTION("SPEAr SPDIF OUT SoC Interface");
+MODULE_LICENSE("GPL");
+MODULE_ALIAS("platform:spdif_out");
sound/soc/spear/spdif_out_regs.h new file +79 -0

79 lines not on this page · raw message

Signature · 1 line
1.7.0.4
#19 lore raw

Re: [PATCH V2 6/9] sound:asoc:spdif_out: Add spdif out support

Quoted 4 lines · Rajeev Kumar

From: Vipin Kumar <[email protected]>

This patch implements the spdif out driver for ST peripheral. This peripheral implements IEC60958 standard

This is fine but it should use module_platform_driver(), please resend with the other patches.

#20 lore raw

PATCH v2 7/9 sound:asoc: Add support for SPEAr ASoC machine driver.

In reply to Rajeev Kumar

The patch add support for SPEAr ASoC machine driver.

---
 sound/soc/spear/spear_evb.c |  206 +++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 206 insertions(+), 0 deletions(-)
 create mode 100644 sound/soc/spear/spear_evb.c
sound/soc/spear/spear_evb.c new file +206 -0
new file mode 100644
index 0000000..fcde033
@@ -0,0 +1,206 @@
+/*
+ * ASoC machine driver for SPEAr evaluation boards
+ *
+ * sound/soc/spear/spear_evb.c
+ *
+ * Copyright (C) 2010 ST Microelectronics
+ * Rajeev Kumar<[email protected]>
+ *
+ * This file is licensed under the terms of the GNU General Public
+ * License version 2. This program is licensed "as is" without any
+ * warranty of any kind, whether express or implied.
+ */
+
+#include <linux/io.h>
+#include <linux/of.h>
+#include <linux/platform_device.h>
+#include <linux/module.h>
+
+#include <sound/pcm.h>
+#include <sound/pcm_params.h>
+#include <sound/soc.h>
+#include <mach/hardware.h>
+
+static int sta529_hw_params(struct snd_pcm_substream *substream,
+		struct snd_pcm_hw_params *params)
+{
+	struct snd_soc_pcm_runtime *rtd = substream->private_data;
+	struct snd_soc_dai *codec_dai = rtd->codec_dai;
+	int ret = 0;
+
+	/* set codec DAI configuration */
+	ret = snd_soc_dai_set_fmt(codec_dai, SND_SOC_DAIFMT_I2S |
+			SND_SOC_DAIFMT_CBS_CFM);
+	if (ret < 0)
+		return ret;
+
+	return 0;
+}
+
+/* Audio machine driver for SPEAr evb */
+static struct snd_soc_ops sta529_ops = {
+	.hw_params	= sta529_hw_params,
+};
+
+/* SPEAr audio interface glue - connects codec <--> CPU <--> platform */
+static struct snd_soc_dai_link spear_evb_dai[] = {
+	{
+		.name		= "sta529-pcm",
+		.stream_name	= "pcm",
+		.cpu_dai_name	= "designware-i2s.0",
+		.platform_name	= "spear-pcm-audio",
+		.codec_dai_name	= "sta529-audio",
+		.codec_name	= "sta529-codec.0-001a",
+		.ops		= &sta529_ops,
+	},
+};
+
+/* SPEAr audio machine driver */
+static struct snd_soc_card spear_snd_card = {
+	.name		= "spear-evb",
+	.dai_link	= spear_evb_dai,
+	.num_links	= ARRAY_SIZE(spear_evb_dai),
+};
+
+/* SPEAr320s audio interface glue - connects codec <--> CPU <--> platform */
+static struct snd_soc_dai_link spear320s_evb_dai[] = {
+	{
+		.name		= "sta529-pcm",
+		.stream_name	= "pcm",
+		.cpu_dai_name	= "designware-i2s",
+		.platform_name	= "spear-pcm-audio",
+		.codec_dai_name	= "sta529-audio",
+		.codec_name	= "sta529-codec.0-001a",
+		.ops		= &sta529_ops,
+	},
+};
+
+/* SPEAr320s audio machine driver */
+static struct snd_soc_card spear320s_snd_card = {
+	.name		= "spear320s-evb",
+	.dai_link	= spear320s_evb_dai,
+	.num_links	= ARRAY_SIZE(spear320s_evb_dai),
+};
+
+/* LCAD audio interface glue - connects codec <--> CPU <--> platform */
+static struct snd_soc_dai_link lcad_evb_dai[] = {
+	{
+		.name		= "sta529-pcm0",
+		.stream_name	= "I2S Playback",
+		.cpu_dai_name	= "designware-i2s.0",
+		.platform_name	= "spear-pcm-audio",
+		.codec_dai_name	= "sta529-audio",
+		.codec_name	= "sta529-codec.0-001a",
+		.ops		= &sta529_ops,
+	}, {
+		.name		= "sta529-pcm1",
+		.stream_name	= "I2S Capture",
+		.cpu_dai_name	= "designware-i2s.1",
+		.platform_name	= "spear-pcm-audio",
+		.codec_dai_name	= "sta529-audio",
+		.codec_name	= "sta529-codec.0-001a",
+		.ops		= &sta529_ops,
+	},
+};
+
+static struct snd_soc_card lcad_snd_card = {
+	.name		= "lcad-evb",
+	.dai_link	= lcad_evb_dai,
+	.num_links	= ARRAY_SIZE(lcad_evb_dai),
+};
+
+/* Audio machine driver for SPEAr1340 evb */
+
+/* SPEAr1340 audio interface glue - connects codec <--> CPU <--> platform */
+static struct snd_soc_dai_link spear1340_evb_dai[] = {
+	{
+		.name		= "spdif-pcm0",
+		.stream_name	= "SPDIF Playback",
+		.cpu_dai_name	= "spdif-out",
+		.platform_name	= "spear-pcm-audio",
+		.codec_dai_name	= "dit-hifi",
+		.codec_name	= "spdif-dit",
+		.ops		= NULL,
+	}, {
+		.name		= "spdif-pcm1",
+		.stream_name	= "SPDIF Capture",
+		.cpu_dai_name	= "spdif-in",
+		.platform_name	= "spear-pcm-audio",
+		.codec_dai_name	= "dir-hifi",
+		.codec_name	= "spdif-dir",
+		.ops		= NULL,
+	}, {
+		.name		= "sta529-pcm0",
+		.stream_name	= "I2S Playback",
+		.cpu_dai_name	= "designware-i2s.0",
+		.platform_name	= "spear-pcm-audio",
+		.codec_dai_name	= "sta529-audio",
+		.codec_name	= "sta529-codec.0-001a",
+		.ops		= &sta529_ops,
+	}, {
+		.name		= "sta529-pcm1",
+		.stream_name	= "I2S Capture",
+		.cpu_dai_name	= "designware-i2s.1",
+		.platform_name	= "spear-pcm-audio",
+		.codec_dai_name	= "sta529-audio",
+		.codec_name	= "sta529-codec.0-001a",
+		.ops		= &sta529_ops,
+	},
+};
+
+static struct snd_soc_card spear1340_snd_card = {
+	.name		= "spear1340-evb",
+	.dai_link	= spear1340_evb_dai,
+	.num_links	= ARRAY_SIZE(spear1340_evb_dai),
+};
+
+static __devinit int spear_evb_probe(struct platform_device *pdev)
+{
+	struct snd_soc_card *spear_soc_card;
+	int ret;
+
+	if (of_machine_is_compatible("st,spear_lcad"))
+		spear_soc_card = &lcad_snd_card;
+	else if (of_machine_is_compatible("st,spear1340"))
+		spear_soc_card = &spear1340_snd_card;
+	else if (of_machine_is_compatible("st,spear320"))
+		spear_soc_card = &spear320s_snd_card;
+	else
+		spear_soc_card = &spear_snd_card;
+
+	spear_soc_card->dev = &pdev->dev;
+
+	ret = snd_soc_register_card(spear_soc_card);
+	if (ret) {
+		dev_err(&pdev->dev, "snd_soc_register_card failed: %d\n", ret);
+		return ret;
+	}
+
+	return 0;
+}
+
+static int __devexit spear_evb_remove(struct platform_device *pdev)
+{
+	struct snd_soc_card *spear_soc_card = platform_get_drvdata(pdev);
+
+	snd_soc_unregister_card(spear_soc_card);
+
+	return 0;
+}
+
+static struct platform_driver spear_evb_driver = {
+	.driver = {
+		.name = "spear-evb",
+		.owner = THIS_MODULE,
+		.pm = &snd_soc_pm_ops,
+	},
+	.probe = spear_evb_probe,
+	.remove = __devexit_p(spear_evb_remove),
+};
+
+module_platform_driver(spear_evb_driver);
+
+MODULE_AUTHOR("Rajeev Kumar <[email protected]>");
+MODULE_DESCRIPTION("ST SPEAr EVB ASoC driver");
+MODULE_LICENSE("GPL");
+MODULE_ALIAS("platform:spear evb");
Signature · 1 line
1.7.0.4
#21 lore raw

Re: [PATCH V2 7/9] sound:asoc: Add support for SPEAr ASoC machine driver.

sound/soc/spear/spear_evb.c line 33

Quoted 3 lines · Rajeev Kumar
sound/soc/spear/spear_evb.c new file +3 -0
+	/* set codec DAI configuration */
+	ret = snd_soc_dai_set_fmt(codec_dai, SND_SOC_DAIFMT_I2S |
+			SND_SOC_DAIFMT_CBS_CFM);

You can se this in the dai_link structure rather than having to set it in hw_params() every time.

sound/soc/spear/spear_evb.c line 199

Quoted 9 lines
sound/soc/spear/spear_evb.c new file +9 -0
+static struct platform_driver spear_evb_driver = {
+       .driver = {
+               .name = "spear-evb",
+               .owner = THIS_MODULE,
+               .pm = &snd_soc_pm_ops,
+       },
+       .probe = spear_evb_probe,
+       .remove = __devexit_p(spear_evb_remove),
+};

I'd expect to see an of_match_table in the device too given that you're parsing OF compatible data. Given how simple this is I wonder if you can instead add DT support to the simple-card driver which Morimoto-san recently contributed rather than adding a new driver?

Quoted 1 line

+MODULE_ALIAS("platform:spear evb");

This won't match against anything in the driver.

#22 lore raw

Re: [PATCH V2 7/9] sound:asoc: Add support for SPEAr ASoC machine driver.

Hello Mark,

Quoted 9 lines · Mark Brown

sound/soc/spear/spear_evb.c line 33

Quoted 3 lines · Rajeev Kumar
sound/soc/spear/spear_evb.c new file +3 -0
+	/* set codec DAI configuration */
+	ret = snd_soc_dai_set_fmt(codec_dai, SND_SOC_DAIFMT_I2S |
+			SND_SOC_DAIFMT_CBS_CFM);

You can se this in the dai_link structure rather than having to set it in hw_params() every time.

Ok, I will do that.

Quoted 6 lines
Quoted 6 lines
sound/soc/spear/spear_evb.c new file +6 -0
+static struct platform_driver spear_evb_driver = {
+       .driver = {
+               .name = "spear-evb",
+               .owner = THIS_MODULE,
+               .pm =&snd_soc_pm_ops,
+       },
Quoted 9 lines

sound/soc/spear/spear_evb.c line 199

Quoted 3 lines
sound/soc/spear/spear_evb.c new file +3 -0
+       .probe = spear_evb_probe,
+       .remove = __devexit_p(spear_evb_remove),
+};

I'd expect to see an of_match_table in the device too given that you're parsing OF compatible data. Given how simple this is I wonder if you can instead add DT support to the simple-card driver which Morimoto-san recently contributed rather than adding a new driver?

I am not well-versed with device-tree framework. It will take me some time to study and incorporate the changes. I will get back on this point as soon as I finish the same.

In the meanwhile can I send the V3 of rest patches which is not applied, namely

1. [PATCH V2 1/9] sound:asoc: Add support for spdif in Audio Codec.
2. [PATCH V2 2/9] sound:asoc: Add support for STA529 Audio Codec.
3. [PATCH V2 6/9] sound:asoc:spdif_out: Add spdif out support

Quoted 3 lines
Quoted 1 line

+MODULE_ALIAS("platform:spear evb");

This won't match against anything in the driver.

OK.

Best Regards
Rajeev

#23 lore raw

Re: [PATCH V2 7/9] sound:asoc: Add support for SPEAr ASoC machine driver.

Hello Mark,

Quoted 5 lines · Rajeev kumar
Quoted 5 lines

I'd expect to see an of_match_table in the device too given that you're parsing OF compatible data. Given how simple this is I wonder if you can instead add DT support to the simple-card driver which Morimoto-san recently contributed rather than adding a new driver?

This will completely eliminate m/c driver. Am I correct ?

Quoted 7 lines

I am not well-versed with device-tree framework. It will take me some time to study and incorporate the changes. I will get back on this point as soon as I finish the same.

Quoted 6 lines

In the meanwhile can I send the V3 of rest patches which is not applied, namely

1. [PATCH V2 1/9] sound:asoc: Add support for spdif in Audio Codec.
2. [PATCH V2 2/9] sound:asoc: Add support for STA529 Audio Codec.
3. [PATCH V2 6/9] sound:asoc:spdif_out: Add spdif out support

Can I send above patches.

Best Regards
Rajeev

#24 lore raw

Re: [PATCH V2 7/9] sound:asoc: Add support for SPEAr ASoC machine driver.

Quoted 9 lines · Rajeev kumar

Hello Mark,

Quoted 4 lines · Rajeev kumar
Quoted 4 lines

I'd expect to see an of_match_table in the device too given that you're parsing OF compatible data. Given how simple this is I wonder if you can instead add DT support to the simple-card driver which Morimoto-san recently contributed rather than adding a new driver?

This will completely eliminate m/c driver. Am I correct ?

Well, it'll mean that you don't need to write a custom one.

#25 lore raw

PATCH v2 8/9 sound:asoc: Add Kconfig and Makefile to support SPEAr audio driver

In reply to Rajeev Kumar

This patch add Kconfig and Makefile to support SPEAr Audio driver

---
 sound/soc/spear/Kconfig  |   40 ++++++++++++++++++++++++++++++++++++++++
 sound/soc/spear/Makefile |    7 +++++++
 2 files changed, 47 insertions(+), 0 deletions(-)
 create mode 100644 sound/soc/spear/Kconfig
 create mode 100644 sound/soc/spear/Makefile
sound/soc/spear/Kconfig new file +40 -0
new file mode 100644
index 0000000..23529a2
@@ -0,0 +1,40 @@
+config SND_SPEAR_EVM
+	tristate "SoC Audio support for SPEAr EVM"
+	select SND_DESIGNWARE_I2S
+	select SND_SOC_STA529
+	select SND_SPEAR_SOC
+	help
+	 Say Y if you want to add support for SoC audio on SPEAr
+	 platform
+
+config SND_SPEAR1340_EVM
+	tristate "SoC Audio support for SPEAr1340 EVM"
+	select SND_DESIGNWARE_I2S
+	select SND_SOC_STA529
+	select SND_SPEAR_SPDIF_OUT
+	select SND_SPEAR_SPDIF_IN
+	select SND_SOC_SPDIF
+	select SND_SPEAR_SOC
+	help
+	 Say Y if you want to add support for SoC audio on SPEAr1340
+	 platform
+
+config SND_SPEAR_SOC
+	tristate "SoC Audio for the ST chip"
+	depends on SND_DESIGNWARE_I2S || SND_SPEAR_SPDIF_OUT || \
+		SND_SPEAR_SPDIF_IN
+	select SND_SOC_DMAENGINE_PCM
+	help
+	 Say Y or M if you want to add support for any of the audio
+	 controllers (I2S/SPDIF). You will also need to select
+	 the audio interface codecs to support below.
+
+config SND_SPEAR_SPDIF_OUT
+	tristate "SPEAr SPDIF Out Device Driver"
+	help
+	 Say Y or M if you want to add support for SPDIF OUT driver.
+
+config SND_SPEAR_SPDIF_IN
+	tristate "SPEAr SPDIF IN Device Driver"
+	help
+	 Say Y or M if you want to add support for SPDIF IN driver.
sound/soc/spear/Makefile new file +7 -0
new file mode 100644
index 0000000..b365126
@@ -0,0 +1,7 @@
+# SPEAR Platform Support
+obj-$(CONFIG_SND_SPEAR_SOC) += spear_pcm.o
+obj-$(CONFIG_SND_SPEAR_SPDIF_IN) += spdif_in.o
+obj-$(CONFIG_SND_SPEAR_SPDIF_OUT) += spdif_out.o
+
+# SPEAR Machine Support
+obj-$(CONFIG_SND_SPEAR_EVM) += spear_evb.o
Signature · 1 line
1.7.0.4
#26 lore raw

PATCH v2 9/9 sound:asoc: Update Kconfig and Makefile(sound/soc/) to support SPEAr audio

In reply to Rajeev Kumar

This patch update Kconfig and Makefile present in soc directory to support SPEAr

---
 sound/soc/Kconfig  |    1 +
 sound/soc/Makefile |    1 +
 2 files changed, 2 insertions(+), 0 deletions(-)
sound/soc/Kconfig +1 -0
index c5de0a8..8309589 100644
@@ -46,6 +46,7 @@ source "sound/soc/pxa/Kconfig"
 source "sound/soc/samsung/Kconfig"
 source "sound/soc/s6000/Kconfig"
 source "sound/soc/sh/Kconfig"
+source "sound/soc/spear/Kconfig"
 source "sound/soc/tegra/Kconfig"
 source "sound/soc/txx9/Kconfig"
 source "sound/soc/ux500/Kconfig"
sound/soc/Makefile +1 -0
index 00a555a..4a8c886 100644
@@ -24,6 +24,7 @@ obj-$(CONFIG_SND_SOC)	+= pxa/
 obj-$(CONFIG_SND_SOC)	+= samsung/
 obj-$(CONFIG_SND_SOC)	+= s6000/
 obj-$(CONFIG_SND_SOC)	+= sh/
+obj-$(CONFIG_SND_SOC)	+= spear/
 obj-$(CONFIG_SND_SOC)	+= tegra/
 obj-$(CONFIG_SND_SOC)	+= txx9/
 obj-$(CONFIG_SND_SOC)	+= ux500/
Signature · 1 line
1.7.0.4