All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH V3 0/4] Add support for STA529 codec, spdif_receiver and SPEAr spdif_out controller
@ 2012-06-28  7:01 Rajeev Kumar
  2012-06-28  7:01 ` [PATCH V3 1/4] ASoC: spdif_receiver: Add support for spdif in Audio Codec Rajeev Kumar
                   ` (3 more replies)
  0 siblings, 4 replies; 14+ messages in thread
From: Rajeev Kumar @ 2012-06-28  7:01 UTC (permalink / raw)
  To: tiwai, broonie, perex; +Cc: alsa-devel, Rajeev Kumar, lrg

Earlier I had circulated Patch set V2. Please find below the link for the same.

http://mailman.alsa-project.org/pipermail/alsa-devel/2012-June/052868.html.

Some of the patches got applied and for rest I am sending Version V3.

Patches that got applied(from V2 of patch set) are listed below:
1. [PATCH V2 3/9] sound:asoc: Add support for synopsys i2s controller as per ASoC framework.
2. [PATCH V2 4/9] sound:asoc: Add support for SPEAr ASoC pcm layer.
3. [PATCH V2 5/9] sound:asoc:spdif_in: Add spdif IN support

Changes since V2:
1. In-corporated review comments received on V2 

Rajeev Kumar (2):
  ASoC: STA529: Add support for STA529 Audio Codec
  ASoC: SPEAr: Add Kconfig and Makefile to support SPEAr audio driver

Vipin Kumar (2):
  ASoC: spdif_receiver: Add support for spdif in Audio Codec
  ASoC: SPEAr spdif_out: Add spdif out support

 sound/soc/codecs/Kconfig          |    4 +
 sound/soc/codecs/Makefile         |    4 +-
 sound/soc/codecs/spdif_receiver.c |   67 ++++++
 sound/soc/codecs/sta529.c         |  441 +++++++++++++++++++++++++++++++++++++
 sound/soc/spear/Kconfig           |   22 ++
 sound/soc/spear/Makefile          |    4 +
 sound/soc/spear/spdif_out.c       |  387 ++++++++++++++++++++++++++++++++
 sound/soc/spear/spdif_out_regs.h  |   79 +++++++
 8 files changed, 1007 insertions(+), 1 deletions(-)
 create mode 100644 sound/soc/codecs/spdif_receiver.c
 create mode 100644 sound/soc/codecs/sta529.c
 create mode 100644 sound/soc/spear/Kconfig
 create mode 100644 sound/soc/spear/Makefile
 create mode 100644 sound/soc/spear/spdif_out.c
 create mode 100644 sound/soc/spear/spdif_out_regs.h

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [PATCH V3 1/4] ASoC: spdif_receiver: Add support for spdif in Audio Codec
  2012-06-28  7:01 [PATCH V3 0/4] Add support for STA529 codec, spdif_receiver and SPEAr spdif_out controller Rajeev Kumar
@ 2012-06-28  7:01 ` Rajeev Kumar
  2012-06-28 12:15   ` Mark Brown
  2012-06-28  7:01 ` [PATCH V3 2/4] ASoC: STA529: Add support for STA529 " Rajeev Kumar
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 14+ messages in thread
From: Rajeev Kumar @ 2012-06-28  7:01 UTC (permalink / raw)
  To: tiwai, broonie, perex; +Cc: Vipin Kumar, alsa-devel, Rajeev Kumar, lrg

From: Vipin Kumar <vipin.kumar@st.com>

This patch adds the support for spdif in audio codec.

Signed-off-by: vipin Kumar <vipin.kumar@st.com>
Signed-off-by: Rajeev Kumar <rajeev-dlh.kumar@st.com>
---
 sound/soc/codecs/Makefile         |    2 +-
 sound/soc/codecs/spdif_receiver.c |   67 +++++++++++++++++++++++++++++++++++++
 2 files changed, 68 insertions(+), 1 deletions(-)
 create mode 100644 sound/soc/codecs/spdif_receiver.c

diff --git a/sound/soc/codecs/Makefile b/sound/soc/codecs/Makefile
index fc27fec..20b2d57 100644
--- a/sound/soc/codecs/Makefile
+++ b/sound/soc/codecs/Makefile
@@ -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
diff --git a/sound/soc/codecs/spdif_receiver.c b/sound/soc/codecs/spdif_receiver.c
new file mode 100644
index 0000000..dd8d856
--- /dev/null
+++ b/sound/soc/codecs/spdif_receiver.c
@@ -0,0 +1,67 @@
+/*
+ * ALSA SoC SPDIF DIR (Digital Interface Reciever) driver
+ *
+ * Based on ALSA SoC SPDIF DIT driver
+ *
+ *  This driver is used by controllers which can operate in DIR (SPDI/F) where
+ *  no codec is needed.  This file provides stub codec that can be used
+ *  in these configurations. SPEAr SPDIF IN Audio controller uses this driver.
+ *
+ * Author:      Vipin Kumar,  <vipin.kumar@st.com>
+ * Copyright:   (C) 2012  ST Microelectronics
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#include <linux/module.h>
+#include <linux/moduleparam.h>
+#include <linux/slab.h>
+#include <sound/soc.h>
+#include <sound/pcm.h>
+#include <sound/initval.h>
+
+#define STUB_RATES	SNDRV_PCM_RATE_8000_192000
+#define STUB_FORMATS	(SNDRV_PCM_FMTBIT_S16_LE | \
+			SNDRV_PCM_FMTBIT_IEC958_SUBFRAME_LE)
+
+static struct snd_soc_codec_driver soc_codec_spdif_dir;
+
+static struct snd_soc_dai_driver dir_stub_dai = {
+	.name		= "dir-hifi",
+	.capture	= {
+		.stream_name	= "Capture",
+		.channels_min	= 1,
+		.channels_max	= 384,
+		.rates		= STUB_RATES,
+		.formats	= STUB_FORMATS,
+	},
+};
+
+static int spdif_dir_probe(struct platform_device *pdev)
+{
+	return snd_soc_register_codec(&pdev->dev, &soc_codec_spdif_dir,
+			&dir_stub_dai, 1);
+}
+
+static int spdif_dir_remove(struct platform_device *pdev)
+{
+	snd_soc_unregister_codec(&pdev->dev);
+	return 0;
+}
+
+static struct platform_driver spdif_dir_driver = {
+	.probe		= spdif_dir_probe,
+	.remove		= spdif_dir_remove,
+	.driver		= {
+		.name	= "spdif-dir",
+		.owner	= THIS_MODULE,
+	},
+};
+
+module_platform_driver(spdif_dir_driver);
+
+MODULE_DESCRIPTION("ASoC SPDIF DIR driver");
+MODULE_AUTHOR("Vipin Kumar <vipin.kumar@st.com>");
+MODULE_LICENSE("GPL");
-- 
1.7.0.4

^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH V3 2/4] ASoC: STA529: Add support for STA529 Audio Codec
  2012-06-28  7:01 [PATCH V3 0/4] Add support for STA529 codec, spdif_receiver and SPEAr spdif_out controller Rajeev Kumar
  2012-06-28  7:01 ` [PATCH V3 1/4] ASoC: spdif_receiver: Add support for spdif in Audio Codec Rajeev Kumar
@ 2012-06-28  7:01 ` Rajeev Kumar
  2012-06-28 12:21   ` Mark Brown
  2012-06-28  7:01 ` [PATCH V3 3/4] ASoC: SPEAr spdif_out: Add spdif out support Rajeev Kumar
  2012-06-28  7:01 ` [PATCH V3 4/4] ASoC: SPEAr: Add Kconfig and Makefile to support SPEAr audio driver Rajeev Kumar
  3 siblings, 1 reply; 14+ messages in thread
From: Rajeev Kumar @ 2012-06-28  7:01 UTC (permalink / raw)
  To: tiwai, broonie, perex; +Cc: alsa-devel, Rajeev Kumar, lrg

This patch adds the support for STA529 audio codec.

Signed-off-by: Rajeev Kumar <rajeev-dlh.kumar@st.com>
---
 sound/soc/codecs/Kconfig  |    4 +
 sound/soc/codecs/Makefile |    2 +
 sound/soc/codecs/sta529.c |  441 +++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 447 insertions(+), 0 deletions(-)
 create mode 100644 sound/soc/codecs/sta529.c

diff --git a/sound/soc/codecs/Kconfig b/sound/soc/codecs/Kconfig
index 1e1613a..f06600b 100644
--- a/sound/soc/codecs/Kconfig
+++ b/sound/soc/codecs/Kconfig
@@ -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
 
diff --git a/sound/soc/codecs/Makefile b/sound/soc/codecs/Makefile
index 20b2d57..09c2dd9 100644
--- a/sound/soc/codecs/Makefile
+++ b/sound/soc/codecs/Makefile
@@ -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
diff --git a/sound/soc/codecs/sta529.c b/sound/soc/codecs/sta529.c
new file mode 100644
index 0000000..5c47678
--- /dev/null
+++ b/sound/soc/codecs/sta529.c
@@ -0,0 +1,441 @@
+/*
+ * ASoC codec driver for spear platform
+ *
+ * sound/soc/codecs/sta529.c -- spear ALSA Soc codec driver
+ *
+ * Copyright (C) 2012 ST Microelectronics
+ * Rajeev Kumar <rajeev-dlh.kumar@st.com>
+ *
+ * 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/init.h>
+#include <linux/i2c.h>
+#include <linux/io.h>
+#include <linux/module.h>
+#include <linux/moduleparam.h>
+#include <linux/pm.h>
+#include <linux/regmap.h>
+#include <linux/slab.h>
+
+#include <sound/core.h>
+#include <sound/initval.h>
+#include <sound/pcm.h>
+#include <sound/pcm_params.h>
+#include <sound/soc.h>
+#include <sound/soc-dapm.h>
+#include <sound/tlv.h>
+
+/* STA529 Register offsets */
+#define	 STA529_FFXCFG0		0x00
+#define	 STA529_FFXCFG1		0x01
+#define	 STA529_MVOL		0x02
+#define	 STA529_LVOL		0x03
+#define	 STA529_RVOL		0x04
+#define	 STA529_TTF0		0x05
+#define	 STA529_TTF1		0x06
+#define	 STA529_TTP0		0x07
+#define	 STA529_TTP1		0x08
+#define	 STA529_S2PCFG0		0x0A
+#define	 STA529_S2PCFG1		0x0B
+#define	 STA529_P2SCFG0		0x0C
+#define	 STA529_P2SCFG1		0x0D
+#define	 STA529_PLLCFG0		0x14
+#define	 STA529_PLLCFG1		0x15
+#define	 STA529_PLLCFG2		0x16
+#define	 STA529_PLLCFG3		0x17
+#define	 STA529_PLLPFE		0x18
+#define	 STA529_PLLST		0x19
+#define	 STA529_ADCCFG		0x1E /*mic_select*/
+#define	 STA529_CKOCFG		0x1F
+#define	 STA529_MISC		0x20
+#define	 STA529_PADST0		0x21
+#define	 STA529_PADST1		0x22
+#define	 STA529_FFXST		0x23
+#define	 STA529_PWMIN1		0x2D
+#define	 STA529_PWMIN2		0x2E
+#define	 STA529_POWST		0x32
+
+#define STA529_MAX_REGISTER	0x32
+
+#define STA529_RATES		(SNDRV_PCM_RATE_8000 | \
+				SNDRV_PCM_RATE_11025 | \
+				SNDRV_PCM_RATE_16000 | \
+				SNDRV_PCM_RATE_22050 | \
+				SNDRV_PCM_RATE_32000 | \
+				SNDRV_PCM_RATE_44100 | \
+				SNDRV_PCM_RATE_48000)
+
+#define STA529_FORMAT		(SNDRV_PCM_FMTBIT_S16_LE | \
+				SNDRV_PCM_FMTBIT_S24_LE | \
+				SNDRV_PCM_FMTBIT_S32_LE)
+#define	S2PC_VALUE		0x98
+#define CLOCK_OUT		0x60
+#define LEFT_J_DATA_FORMAT	0x10
+#define I2S_DATA_FORMAT		0x12
+#define RIGHT_J_DATA_FORMAT	0x14
+#define CODEC_MUTE_VAL		0x80
+
+#define POWER_CNTLMSAK		0x40
+#define POWER_STDBY		0x40
+#define FFX_MASK		0x80
+#define FFX_OFF			0x80
+#define POWER_UP		0x00
+#define FFX_CLK_ENB		0x01
+#define FFX_CLK_DIS		0x00
+#define FFX_CLK_MSK		0x01
+#define FREQ_RANGE_MSK		0x7C
+#define PDATA_LEN_MSK		0xC0
+#define BCLK_TO_FS_MSK		0x30
+#define AUDIO_MUTE_MSK		0x80
+
+static const struct reg_default sta529_reg_defaults[] = {
+	{ 0,  0x35 },     /* R0   - FFX Configuration reg 0 */
+	{ 1,  0xc8 },     /* R1   - FFX Configuration reg 1 */
+	{ 2,  0x50 },     /* R2   - Master Volume */
+	{ 3,  0x00 },     /* R3   - Left Volume */
+	{ 4,  0x00 },     /* R4  -  Right Volume */
+	{ 10, 0xb2 },     /* R10  - S2P Config Reg 0 */
+	{ 11, 0x41 },     /* R11  - S2P Config Reg 1 */
+	{ 12, 0x92 },     /* R12  - P2S Config Reg 0 */
+	{ 13, 0x41 },     /* R13  - P2S Config Reg 1 */
+	{ 30, 0xd2 },     /* R30  - ADC Config Reg */
+	{ 31, 0x40 },     /* R31  - clock Out Reg */
+	{ 32, 0x21 },     /* R32  - Misc Register */
+};
+
+struct sta529 {
+	struct regmap *regmap;
+};
+
+static bool sta529_readable(struct device *dev, unsigned int reg)
+{
+	switch (reg) {
+
+	case STA529_FFXCFG0:
+	case STA529_FFXCFG1:
+	case STA529_MVOL:
+	case STA529_LVOL:
+	case STA529_RVOL:
+	case STA529_S2PCFG0:
+	case STA529_S2PCFG1:
+	case STA529_P2SCFG0:
+	case STA529_P2SCFG1:
+	case STA529_ADCCFG:
+	case STA529_CKOCFG:
+	case STA529_MISC:
+		return true;
+	default:
+		return false;
+	}
+}
+
+
+static const char *pwm_mode_text[] = { "Binary", "Headphone", "Ternary",
+	"Phase-shift"};
+
+static const DECLARE_TLV_DB_SCALE(out_gain_tlv, -9150, 50, 0);
+static const DECLARE_TLV_DB_SCALE(master_vol_tlv, -12750, 50, 0);
+static const SOC_ENUM_SINGLE_DECL(pwm_src, STA529_FFXCFG1, 4, pwm_mode_text);
+
+static const struct snd_kcontrol_new sta529_snd_controls[] = {
+	SOC_DOUBLE_R_TLV("Digital Playback Volume", STA529_LVOL, STA529_RVOL, 0,
+			127, 0, out_gain_tlv),
+	SOC_SINGLE_TLV("Master Playback Volume", STA529_MVOL, 0, 127, 1,
+			master_vol_tlv),
+	SOC_ENUM("PWM Select", pwm_src),
+};
+
+static int sta529_set_bias_level(struct snd_soc_codec *codec, enum
+		snd_soc_bias_level level)
+{
+	struct sta529 *sta529 = snd_soc_codec_get_drvdata(codec);
+
+	switch (level) {
+	case SND_SOC_BIAS_ON:
+	case SND_SOC_BIAS_PREPARE:
+		snd_soc_update_bits(codec, STA529_FFXCFG0, POWER_CNTLMSAK,
+				POWER_UP);
+		snd_soc_update_bits(codec, STA529_MISC,	FFX_CLK_MSK,
+				FFX_CLK_ENB);
+		break;
+	case SND_SOC_BIAS_STANDBY:
+		if (codec->dapm.bias_level == SND_SOC_BIAS_OFF)
+			regcache_sync(sta529->regmap);
+		snd_soc_update_bits(codec, STA529_FFXCFG0,
+					POWER_CNTLMSAK, POWER_STDBY);
+		/* Making FFX output to zero */
+		snd_soc_update_bits(codec, STA529_FFXCFG0, FFX_MASK,
+				FFX_OFF);
+		snd_soc_update_bits(codec, STA529_MISC, FFX_CLK_MSK,
+				FFX_CLK_DIS);
+		break;
+	case SND_SOC_BIAS_OFF:
+		break;
+	}
+
+	/*
+	 * store the label for powers down audio subsystem for suspend.This is
+	 * used by soc core layer
+	 */
+	codec->dapm.bias_level = level;
+
+	return 0;
+
+}
+
+static int sta529_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;
+	int pdata, play_freq_val, record_freq_val, val;
+	int bclk_to_fs_ratio;
+
+	switch (params_format(params)) {
+	case SNDRV_PCM_FORMAT_S16_LE:
+		pdata = 1;
+		bclk_to_fs_ratio = 0;
+		break;
+	case SNDRV_PCM_FORMAT_S24_LE:
+		pdata = 2;
+		bclk_to_fs_ratio = 1;
+		break;
+	case SNDRV_PCM_FORMAT_S32_LE:
+		pdata = 3;
+		bclk_to_fs_ratio = 2;
+		break;
+	default:
+		dev_err(codec->dev, "Unsupported format\n");
+		return -EINVAL;
+	}
+
+	switch (params_rate(params)) {
+	case 8000:
+	case 11025:
+		play_freq_val = 0;
+		record_freq_val = 2;
+		break;
+	case 16000:
+	case 22050:
+		play_freq_val = 1;
+		record_freq_val = 0;
+		break;
+
+	case 32000:
+	case 44100:
+	case 48000:
+		play_freq_val = 2;
+		record_freq_val = 0;
+		break;
+	default:
+		dev_err(codec->dev, "Unsupported rate\n");
+		return -EINVAL;
+	}
+
+	if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
+		snd_soc_update_bits(codec, STA529_S2PCFG1, PDATA_LEN_MSK,
+				pdata << 6);
+		snd_soc_update_bits(codec, STA529_S2PCFG1, BCLK_TO_FS_MSK,
+				bclk_to_fs_ratio << 4);
+	} else {
+		snd_soc_update_bits(codec, STA529_P2SCFG1, PDATA_LEN_MSK,
+				pdata << 6);
+		snd_soc_update_bits(codec, STA529_P2SCFG1, BCLK_TO_FS_MSK,
+				bclk_to_fs_ratio << 4);
+	}
+
+	val = snd_soc_read(codec, STA529_MISC);
+	/* set FFX audio frequency range */
+	val = (((val & 0x83) | (play_freq_val << 4)) | (record_freq_val << 2));
+	snd_soc_update_bits(codec, STA529_MISC, FREQ_RANGE_MSK, val);
+
+	return 0;
+}
+
+static int sta529_mute(struct snd_soc_dai *dai, int mute)
+{
+	u8 val = snd_soc_read(dai->codec, STA529_FFXCFG0);
+
+	if (mute)
+		val |= CODEC_MUTE_VAL;
+
+	snd_soc_update_bits(dai->codec, STA529_FFXCFG0, AUDIO_MUTE_MSK, val);
+
+	return 0;
+}
+
+static int sta529_set_dai_fmt(struct snd_soc_dai *codec_dai, u32 fmt)
+{
+	struct snd_soc_codec *codec = codec_dai->codec;
+	u8 mode = 0;
+
+	/* interface format */
+	switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) {
+	case SND_SOC_DAIFMT_LEFT_J:
+		mode = LEFT_J_DATA_FORMAT;
+		break;
+	case SND_SOC_DAIFMT_I2S:
+		mode = I2S_DATA_FORMAT;
+		break;
+	case SND_SOC_DAIFMT_RIGHT_J:
+		mode = RIGHT_J_DATA_FORMAT;
+		break;
+	default:
+		return -EINVAL;
+	}
+	mode |= 0x20;
+	snd_soc_update_bits(codec, STA529_S2PCFG0, 0xE0, mode);
+
+	return 0;
+}
+
+static const struct snd_soc_dai_ops sta529_dai_ops = {
+	.hw_params	=	sta529_hw_params,
+	.set_fmt	=	sta529_set_dai_fmt,
+	.digital_mute	=	sta529_mute,
+};
+
+static struct snd_soc_dai_driver sta529_dai = {
+	.name = "sta529-audio",
+	.playback = {
+		.stream_name = "Playback",
+		.channels_min = 2,
+		.channels_max = 2,
+		.rates = STA529_RATES,
+		.formats = STA529_FORMAT,
+	},
+	.capture = {
+		.stream_name = "Capture",
+		.channels_min = 2,
+		.channels_max = 2,
+		.rates = STA529_RATES,
+		.formats = STA529_FORMAT,
+	},
+	.ops	= &sta529_dai_ops,
+};
+
+static int sta529_probe(struct snd_soc_codec *codec)
+{
+	struct sta529 *sta529 = snd_soc_codec_get_drvdata(codec);
+	int ret;
+
+	codec->control_data = sta529->regmap;
+	ret = snd_soc_codec_set_cache_io(codec, 8, 8, SND_SOC_REGMAP);
+
+	if (ret < 0) {
+		dev_err(codec->dev, "Failed to set cache I/O: %d\n", ret);
+		return ret;
+	}
+	sta529_set_bias_level(codec, SND_SOC_BIAS_STANDBY);
+
+	return 0;
+}
+
+/* power down chip */
+static int sta529_remove(struct snd_soc_codec *codec)
+{
+	sta529_set_bias_level(codec, SND_SOC_BIAS_OFF);
+
+	return 0;
+}
+
+static int sta529_suspend(struct snd_soc_codec *codec)
+{
+	sta529_set_bias_level(codec, SND_SOC_BIAS_OFF);
+
+	return 0;
+}
+
+static int sta529_resume(struct snd_soc_codec *codec)
+{
+	sta529_set_bias_level(codec, SND_SOC_BIAS_STANDBY);
+
+	return 0;
+}
+
+struct snd_soc_codec_driver sta529_codec_driver = {
+	.probe = sta529_probe,
+	.remove = sta529_remove,
+	.set_bias_level = sta529_set_bias_level,
+	.suspend = sta529_suspend,
+	.resume = sta529_resume,
+	.controls = sta529_snd_controls,
+	.num_controls = ARRAY_SIZE(sta529_snd_controls),
+};
+
+static const struct regmap_config sta529_regmap = {
+	.reg_bits = 8,
+	.val_bits = 8,
+
+	.max_register = STA529_MAX_REGISTER,
+	.readable_reg = sta529_readable,
+
+	.cache_type = REGCACHE_RBTREE,
+	.reg_defaults = sta529_reg_defaults,
+	.num_reg_defaults = ARRAY_SIZE(sta529_reg_defaults),
+};
+
+static __devinit int sta529_i2c_probe(struct i2c_client *i2c,
+		const struct i2c_device_id *id)
+{
+	struct sta529 *sta529;
+	int ret;
+
+	if (!i2c_check_functionality(i2c->adapter, I2C_FUNC_SMBUS_BYTE_DATA))
+		return -EINVAL;
+
+	sta529 = devm_kzalloc(&i2c->dev, sizeof(struct sta529), GFP_KERNEL);
+	if (sta529 == NULL) {
+		dev_err(&i2c->dev, "Can not allocate memory\n");
+		return -ENOMEM;
+	}
+
+	sta529->regmap = devm_regmap_init_i2c(i2c, &sta529_regmap);
+	if (IS_ERR(sta529->regmap)) {
+		dev_err(&i2c->dev, "Failed to allocate regmap: %d\n", ret);
+		return PTR_ERR(sta529->regmap);
+	}
+
+	i2c_set_clientdata(i2c, sta529);
+
+	ret = snd_soc_register_codec(&i2c->dev,
+			&sta529_codec_driver, &sta529_dai, 1);
+	if (ret != 0)
+		dev_err(&i2c->dev, "Failed to register CODEC: %d\n", ret);
+
+	return ret;
+}
+
+static int __devexit sta529_i2c_remove(struct i2c_client *client)
+{
+	snd_soc_unregister_codec(&client->dev);
+
+	return 0;
+}
+
+static const struct i2c_device_id sta529_i2c_id[] = {
+	{ "sta529", 0 },
+	{ }
+};
+MODULE_DEVICE_TABLE(i2c, sta529_i2c_id);
+
+static struct i2c_driver sta529_i2c_driver = {
+	.driver = {
+		.name = "sta529",
+		.owner = THIS_MODULE,
+	},
+	.probe		= sta529_i2c_probe,
+	.remove		= __devexit_p(sta529_i2c_remove),
+	.id_table	= sta529_i2c_id,
+};
+
+module_i2c_driver(sta529_i2c_driver);
+
+MODULE_DESCRIPTION("ASoC STA529 codec driver");
+MODULE_AUTHOR("Rajeev Kumar <rajeev-dlh.kumar@st.com>");
+MODULE_LICENSE("GPL");
-- 
1.7.0.4

^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH V3 3/4] ASoC: SPEAr spdif_out: Add spdif out support
  2012-06-28  7:01 [PATCH V3 0/4] Add support for STA529 codec, spdif_receiver and SPEAr spdif_out controller Rajeev Kumar
  2012-06-28  7:01 ` [PATCH V3 1/4] ASoC: spdif_receiver: Add support for spdif in Audio Codec Rajeev Kumar
  2012-06-28  7:01 ` [PATCH V3 2/4] ASoC: STA529: Add support for STA529 " Rajeev Kumar
@ 2012-06-28  7:01 ` Rajeev Kumar
  2012-06-28 12:27   ` Mark Brown
  2012-06-28  7:01 ` [PATCH V3 4/4] ASoC: SPEAr: Add Kconfig and Makefile to support SPEAr audio driver Rajeev Kumar
  3 siblings, 1 reply; 14+ messages in thread
From: Rajeev Kumar @ 2012-06-28  7:01 UTC (permalink / raw)
  To: tiwai, broonie, perex; +Cc: Vipin Kumar, alsa-devel, Rajeev Kumar, lrg

From: Vipin Kumar <vipin.kumar@st.com>

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

Signed-off-by: Vipin Kumar <vipin.kumar@st.com>
Signed-off-by: Rajeev Kumar <rajeev-dlh.kumar@st.com>
---
 sound/soc/spear/spdif_out.c      |  387 ++++++++++++++++++++++++++++++++++++++
 sound/soc/spear/spdif_out_regs.h |   79 ++++++++
 2 files changed, 466 insertions(+), 0 deletions(-)
 create mode 100644 sound/soc/spear/spdif_out.c
 create mode 100644 sound/soc/spear/spdif_out_regs.h

diff --git a/sound/soc/spear/spdif_out.c b/sound/soc/spear/spdif_out.c
new file mode 100644
index 0000000..25a74f2
--- /dev/null
+++ b/sound/soc/spear/spdif_out.c
@@ -0,0 +1,387 @@
+/*
+ * ALSA SoC SPDIF Out Audio Layer for spear processors
+ *
+ * Copyright (C) 2012 ST Microelectronics
+ * Vipin Kumar <vipin.kumar@st.com>
+ *
+ * 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,
+	},
+};
+
+module_platform_driver(spdif_out_driver);
+
+MODULE_AUTHOR("Vipin Kumar <vipin.kumar@st.com>");
+MODULE_DESCRIPTION("SPEAr SPDIF OUT SoC Interface");
+MODULE_LICENSE("GPL");
+MODULE_ALIAS("platform:spdif_out");
diff --git a/sound/soc/spear/spdif_out_regs.h b/sound/soc/spear/spdif_out_regs.h
new file mode 100644
index 0000000..a5e5332
--- /dev/null
+++ b/sound/soc/spear/spdif_out_regs.h
@@ -0,0 +1,79 @@
+/*
+ * SPEAr SPDIF OUT controller header file
+ *
+ * Copyright (ST) 2011 Vipin Kumar (vipin.kumar@st.com)
+ *
+ * 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 SPDIF_OUT_REGS_H
+#define SPDIF_OUT_REGS_H
+
+#define SPDIF_OUT_SOFT_RST	0x00
+	#define SPDIF_OUT_RESET		(1 << 0)
+#define SPDIF_OUT_FIFO_DATA	0x04
+#define SPDIF_OUT_INT_STA	0x08
+#define SPDIF_OUT_INT_STA_CLR	0x0C
+	#define SPDIF_INT_UNDERFLOW	(1 << 0)
+	#define SPDIF_INT_EODATA	(1 << 1)
+	#define SPDIF_INT_EOBLOCK	(1 << 2)
+	#define SPDIF_INT_EOLATENCY	(1 << 3)
+	#define SPDIF_INT_EOPD_DATA	(1 << 4)
+	#define SPDIF_INT_MEMFULLREAD	(1 << 5)
+	#define SPDIF_INT_EOPD_PAUSE	(1 << 6)
+
+#define SPDIF_OUT_INT_EN	0x10
+#define SPDIF_OUT_INT_EN_SET	0x14
+#define SPDIF_OUT_INT_EN_CLR	0x18
+#define SPDIF_OUT_CTRL		0x1C
+	#define SPDIF_OPMODE_MASK	(7 << 0)
+	#define SPDIF_OPMODE_OFF	(0 << 0)
+	#define SPDIF_OPMODE_MUTE_PCM	(1 << 0)
+	#define SPDIF_OPMODE_MUTE_PAUSE	(2 << 0)
+	#define SPDIF_OPMODE_AUD_DATA	(3 << 0)
+	#define SPDIF_OPMODE_ENCODE	(4 << 0)
+	#define SPDIF_STATE_NORMAL	(1 << 3)
+	#define SPDIF_DIVIDER_MASK	(0xff << 5)
+	#define SPDIF_DIVIDER_SHIFT	(5)
+	#define SPDIF_SAMPLEREAD_MASK	(0x1ffff << 15)
+	#define SPDIF_SAMPLEREAD_SHIFT	(15)
+#define SPDIF_OUT_STA		0x20
+#define SPDIF_OUT_PA_PB		0x24
+#define SPDIF_OUT_PC_PD		0x28
+#define SPDIF_OUT_CL1		0x2C
+#define SPDIF_OUT_CR1		0x30
+#define SPDIF_OUT_CL2_CR2_UV	0x34
+#define SPDIF_OUT_PAUSE_LAT	0x38
+#define SPDIF_OUT_FRMLEN_BRST	0x3C
+#define SPDIF_OUT_CFG		0x40
+	#define SPDIF_OUT_MEMFMT_16_0	(0 << 5)
+	#define SPDIF_OUT_MEMFMT_16_16	(1 << 5)
+	#define SPDIF_OUT_VALID_DMA	(0 << 3)
+	#define SPDIF_OUT_VALID_HW	(1 << 3)
+	#define SPDIF_OUT_USER_DMA	(0 << 2)
+	#define SPDIF_OUT_USER_HW	(1 << 2)
+	#define SPDIF_OUT_CHNLSTA_DMA	(0 << 1)
+	#define SPDIF_OUT_CHNLSTA_HW	(1 << 1)
+	#define SPDIF_OUT_PARITY_HW	(0 << 0)
+	#define SPDIF_OUT_PARITY_DMA	(1 << 0)
+	#define SPDIF_OUT_FDMA_TRIG_2	(2 << 8)
+	#define SPDIF_OUT_FDMA_TRIG_6	(6 << 8)
+	#define SPDIF_OUT_FDMA_TRIG_8	(8 << 8)
+	#define SPDIF_OUT_FDMA_TRIG_10	(10 << 8)
+	#define SPDIF_OUT_FDMA_TRIG_12	(12 << 8)
+	#define SPDIF_OUT_FDMA_TRIG_16	(16 << 8)
+	#define SPDIF_OUT_FDMA_TRIG_18	(18 << 8)
+
+#endif /* SPDIF_OUT_REGS_H */
-- 
1.7.0.4

^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH V3 4/4] ASoC: SPEAr: Add Kconfig and Makefile to support SPEAr audio driver
  2012-06-28  7:01 [PATCH V3 0/4] Add support for STA529 codec, spdif_receiver and SPEAr spdif_out controller Rajeev Kumar
                   ` (2 preceding siblings ...)
  2012-06-28  7:01 ` [PATCH V3 3/4] ASoC: SPEAr spdif_out: Add spdif out support Rajeev Kumar
@ 2012-06-28  7:01 ` Rajeev Kumar
  3 siblings, 0 replies; 14+ messages in thread
From: Rajeev Kumar @ 2012-06-28  7:01 UTC (permalink / raw)
  To: tiwai, broonie, perex; +Cc: alsa-devel, Rajeev Kumar, lrg

This patch add Kconfig and Makefile to support SPEAr Audio driver

Signed-off-by: Rajeev Kumar <rajeev-dlh.kumar@st.com>
---
 sound/soc/spear/Kconfig  |   22 ++++++++++++++++++++++
 sound/soc/spear/Makefile |    4 ++++
 2 files changed, 26 insertions(+), 0 deletions(-)
 create mode 100644 sound/soc/spear/Kconfig
 create mode 100644 sound/soc/spear/Makefile

diff --git a/sound/soc/spear/Kconfig b/sound/soc/spear/Kconfig
new file mode 100644
index 0000000..6ff9460
--- /dev/null
+++ b/sound/soc/spear/Kconfig
@@ -0,0 +1,22 @@
+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
+	select SND_SOC_STA529
+	select SND_SOC_SPDIF
+	select SND_SIMPLE_CARD
+	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.
diff --git a/sound/soc/spear/Makefile b/sound/soc/spear/Makefile
new file mode 100644
index 0000000..9f47bb4
--- /dev/null
+++ b/sound/soc/spear/Makefile
@@ -0,0 +1,4 @@
+# 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
-- 
1.7.0.4

^ permalink raw reply related	[flat|nested] 14+ messages in thread

* Re: [PATCH V3 1/4] ASoC: spdif_receiver: Add support for spdif in Audio Codec
  2012-06-28  7:01 ` [PATCH V3 1/4] ASoC: spdif_receiver: Add support for spdif in Audio Codec Rajeev Kumar
@ 2012-06-28 12:15   ` Mark Brown
  0 siblings, 0 replies; 14+ messages in thread
From: Mark Brown @ 2012-06-28 12:15 UTC (permalink / raw)
  To: Rajeev Kumar; +Cc: tiwai, Vipin Kumar, alsa-devel, lrg


[-- Attachment #1.1: Type: text/plain, Size: 186 bytes --]

On Thu, Jun 28, 2012 at 12:31:37PM +0530, Rajeev Kumar wrote:
> From: Vipin Kumar <vipin.kumar@st.com>
> 
> This patch adds the support for spdif in audio codec.

Applied, thanks.

[-- Attachment #1.2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

[-- Attachment #2: Type: text/plain, Size: 0 bytes --]



^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH V3 2/4] ASoC: STA529: Add support for STA529 Audio Codec
  2012-06-28  7:01 ` [PATCH V3 2/4] ASoC: STA529: Add support for STA529 " Rajeev Kumar
@ 2012-06-28 12:21   ` Mark Brown
  0 siblings, 0 replies; 14+ messages in thread
From: Mark Brown @ 2012-06-28 12:21 UTC (permalink / raw)
  To: Rajeev Kumar; +Cc: tiwai, alsa-devel, lrg


[-- Attachment #1.1: Type: text/plain, Size: 967 bytes --]

On Thu, Jun 28, 2012 at 12:31:38PM +0530, Rajeev Kumar wrote:

> +	val = snd_soc_read(codec, STA529_MISC);
> +	/* set FFX audio frequency range */
> +	val = (((val & 0x83) | (play_freq_val << 4)) | (record_freq_val << 2));
> +	snd_soc_update_bits(codec, STA529_MISC, FREQ_RANGE_MSK, val);

This is really odd, you're using update_bits() like write() - half the
point of update_bits() is that you don't need to do the read to get the
initial value.  It also looks like the frequency range set should be
being done in your playback/capture cases so that instead of 

> +	u8 val = snd_soc_read(dai->codec, STA529_FFXCFG0);
> +
> +	if (mute)
> +		val |= CODEC_MUTE_VAL;
> +
> +	snd_soc_update_bits(dai->codec, STA529_FFXCFG0, AUDIO_MUTE_MSK, val);

This will never disable mute since you're using update_bits() badly
again - once mute has been set then the read will have the bit set and
nothing ever clears it.  You shouldn't have the read at all.

[-- Attachment #1.2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

[-- Attachment #2: Type: text/plain, Size: 0 bytes --]



^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH V3 3/4] ASoC: SPEAr spdif_out: Add spdif out support
  2012-06-28  7:01 ` [PATCH V3 3/4] ASoC: SPEAr spdif_out: Add spdif out support Rajeev Kumar
@ 2012-06-28 12:27   ` Mark Brown
  2012-06-29  7:35     ` Vipin Kumar
  2012-07-02  5:00     ` Rajeev kumar
  0 siblings, 2 replies; 14+ messages in thread
From: Mark Brown @ 2012-06-28 12:27 UTC (permalink / raw)
  To: Rajeev Kumar; +Cc: tiwai, Vipin Kumar, alsa-devel, lrg


[-- Attachment #1.1: Type: text/plain, Size: 929 bytes --]

On Thu, Jun 28, 2012 at 12:31:39PM +0530, Rajeev Kumar wrote:

> +	void *io_base;

Should be __iomem.  Looking at the code I suspect this might benefit
from using regmap like Tegra, you'd save having to open code your mute
control if nothing else.

> +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),

Should be "IEC958 Playback Switch".

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

We should add a framework thing for this...

> +	.ops = (struct snd_soc_dai_ops *)&spdif_out_dai_ops,

Why do you need this cast?

[-- Attachment #1.2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

[-- Attachment #2: Type: text/plain, Size: 0 bytes --]



^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH V3 3/4] ASoC: SPEAr spdif_out: Add spdif out support
  2012-06-28 12:27   ` Mark Brown
@ 2012-06-29  7:35     ` Vipin Kumar
  2012-06-30 18:35       ` Mark Brown
  2012-07-02  5:00     ` Rajeev kumar
  1 sibling, 1 reply; 14+ messages in thread
From: Vipin Kumar @ 2012-06-29  7:35 UTC (permalink / raw)
  To: Mark Brown; +Cc: alsa-devel, Rajeev KUMAR, tiwai, spear-devel, lrg

On 6/28/2012 5:57 PM, Mark Brown wrote:
> On Thu, Jun 28, 2012 at 12:31:39PM +0530, Rajeev Kumar wrote:
>
>> +	void *io_base;
>
> Should be __iomem.  Looking at the code I suspect this might benefit
> from using regmap like Tegra, you'd save having to open code your mute
> control if nothing else.
>

OK

>> +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),
>
> Should be "IEC958 Playback Switch".
>

OK

>> +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));
>
> We should add a framework thing for this...
>
>> +	.ops = (struct snd_soc_dai_ops *)&spdif_out_dai_ops,
>
> Why do you need this cast?

It was a const I think

Regards
Vipin

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH V3 3/4] ASoC: SPEAr spdif_out: Add spdif out support
  2012-06-29  7:35     ` Vipin Kumar
@ 2012-06-30 18:35       ` Mark Brown
  2012-07-01  6:32         ` Vipin Kumar
  0 siblings, 1 reply; 14+ messages in thread
From: Mark Brown @ 2012-06-30 18:35 UTC (permalink / raw)
  To: Vipin Kumar; +Cc: alsa-devel, Rajeev KUMAR, tiwai, spear-devel, lrg


[-- Attachment #1.1: Type: text/plain, Size: 422 bytes --]

On Fri, Jun 29, 2012 at 01:05:13PM +0530, Vipin Kumar wrote:
> On 6/28/2012 5:57 PM, Mark Brown wrote:

> >>+	.ops = (struct snd_soc_dai_ops *)&spdif_out_dai_ops,

> >Why do you need this cast?

> It was a const I think

So you've just introduced a bug, then - you're using a const variable in
a non-const context.  Don't cast away the const, either arrange for the
ops pointer in the dai to be const or remove the const.

[-- Attachment #1.2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

[-- Attachment #2: Type: text/plain, Size: 0 bytes --]



^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH V3 3/4] ASoC: SPEAr spdif_out: Add spdif out support
  2012-06-30 18:35       ` Mark Brown
@ 2012-07-01  6:32         ` Vipin Kumar
  0 siblings, 0 replies; 14+ messages in thread
From: Vipin Kumar @ 2012-07-01  6:32 UTC (permalink / raw)
  To: Mark Brown; +Cc: alsa-devel, Rajeev KUMAR, tiwai, spear-devel, lrg

On 7/1/2012 12:05 AM, Mark Brown wrote:
> On Fri, Jun 29, 2012 at 01:05:13PM +0530, Vipin Kumar wrote:
>> On 6/28/2012 5:57 PM, Mark Brown wrote:
>
>>>> +	.ops = (struct snd_soc_dai_ops *)&spdif_out_dai_ops,
>
>>> Why do you need this cast?
>
>> It was a const I think
>
> So you've just introduced a bug, then - you're using a const variable in
> a non-const context.  Don't cast away the const, either arrange for the
> ops pointer in the dai to be const or remove the const.

sure, i will do that...got it :)

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH V3 3/4] ASoC: SPEAr spdif_out: Add spdif out support
  2012-06-28 12:27   ` Mark Brown
  2012-06-29  7:35     ` Vipin Kumar
@ 2012-07-02  5:00     ` Rajeev kumar
  2012-07-03  4:20       ` Rajeev kumar
  2012-07-03 19:09       ` Mark Brown
  1 sibling, 2 replies; 14+ messages in thread
From: Rajeev kumar @ 2012-07-02  5:00 UTC (permalink / raw)
  To: Mark Brown; +Cc: tiwai, Vipin KUMAR, alsa-devel, lrg

Hello Mark,

On 6/28/2012 5:57 PM, Mark Brown wrote:
>> +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));
> We should add a framework thing for this...
>

I was going through the simaple-card.c file and I think that the above 
is possible if we have a pointer of "snd_kcontrol_new" in 
asoc_simple_card_info structure. In this case we can pass all the 
controls from board file (arch/arm/mach-*). Please share your opinion.

or,

Is there any other way to do this ?

Best Regards
Rajeev

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH V3 3/4] ASoC: SPEAr spdif_out: Add spdif out support
  2012-07-02  5:00     ` Rajeev kumar
@ 2012-07-03  4:20       ` Rajeev kumar
  2012-07-03 19:09       ` Mark Brown
  1 sibling, 0 replies; 14+ messages in thread
From: Rajeev kumar @ 2012-07-03  4:20 UTC (permalink / raw)
  To: Mark Brown; +Cc: alsa-devel, Rajeev kumar, tiwai, Vipin KUMAR, lrg

Hello Mark,

On 7/2/2012 10:30 AM, Rajeev kumar wrote:
> Hello Mark,
>
> On 6/28/2012 5:57 PM, Mark Brown wrote:
>>> +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));
>> We should add a framework thing for this...
>>
>
> I was going through the simaple-card.c file and I think that the above
> is possible if we have a pointer of "snd_kcontrol_new" in
> asoc_simple_card_info structure. In this case we can pass all the
> controls from board file (arch/arm/mach-*). Please share your opinion.
>
> or,
>
> Is there any other way to do this ?
>

Waiting for your reply,

Best Regards
Rajeev

> Best Regards
> Rajeev
>

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH V3 3/4] ASoC: SPEAr spdif_out: Add spdif out support
  2012-07-02  5:00     ` Rajeev kumar
  2012-07-03  4:20       ` Rajeev kumar
@ 2012-07-03 19:09       ` Mark Brown
  1 sibling, 0 replies; 14+ messages in thread
From: Mark Brown @ 2012-07-03 19:09 UTC (permalink / raw)
  To: Rajeev kumar; +Cc: tiwai, Vipin KUMAR, alsa-devel, lrg


[-- Attachment #1.1: Type: text/plain, Size: 879 bytes --]

On Mon, Jul 02, 2012 at 10:30:25AM +0530, Rajeev kumar wrote:
> On 6/28/2012 5:57 PM, Mark Brown wrote:

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

> >We should add a framework thing for this...

> I was going through the simaple-card.c file and I think that the
> above is possible if we have a pointer of "snd_kcontrol_new" in
> asoc_simple_card_info structure. In this case we can pass all the
> controls from board file (arch/arm/mach-*). Please share your
> opinion.

Why would we want to do that?  These controls are part of the CPU DAI,
the CPU DAI driver should add them.

[-- Attachment #1.2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

[-- Attachment #2: Type: text/plain, Size: 0 bytes --]



^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2012-07-03 19:09 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-06-28  7:01 [PATCH V3 0/4] Add support for STA529 codec, spdif_receiver and SPEAr spdif_out controller Rajeev Kumar
2012-06-28  7:01 ` [PATCH V3 1/4] ASoC: spdif_receiver: Add support for spdif in Audio Codec Rajeev Kumar
2012-06-28 12:15   ` Mark Brown
2012-06-28  7:01 ` [PATCH V3 2/4] ASoC: STA529: Add support for STA529 " Rajeev Kumar
2012-06-28 12:21   ` Mark Brown
2012-06-28  7:01 ` [PATCH V3 3/4] ASoC: SPEAr spdif_out: Add spdif out support Rajeev Kumar
2012-06-28 12:27   ` Mark Brown
2012-06-29  7:35     ` Vipin Kumar
2012-06-30 18:35       ` Mark Brown
2012-07-01  6:32         ` Vipin Kumar
2012-07-02  5:00     ` Rajeev kumar
2012-07-03  4:20       ` Rajeev kumar
2012-07-03 19:09       ` Mark Brown
2012-06-28  7:01 ` [PATCH V3 4/4] ASoC: SPEAr: Add Kconfig and Makefile to support SPEAr audio driver Rajeev Kumar

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.