Skip to contentSkip to conversation

Blackfin supports for ALSA/ASOC

PATCH In review Bryan Wu 9 participants 27 messages Aug 27, 2008 – Sep 4, 2008

Subsystems (4)
lore
Share & tools
lore

Bryan Wu

author
#0 lore raw

cover Blackfin supports for ALSA/ASOC

Hi folks,

It's very happy to release this ASOC Blackfin ports. Please review our drivers and feel free to ask us update it.

In this patchset, we post ASOC Blackfin supports, SSM2602 audio codec driver and other 2 ALSA/ASOC patches.

Thanks a lot
-Bryan

author
#6 lore raw

PATCH 2/4 ASOC codec: add support for SSM2602 audio codec in ALSA SoC framework

From: Cliff Cai <[email protected]>

---
 include/linux/i2c-id.h     |    1 +
 sound/soc/codecs/Kconfig   |    3 +
 sound/soc/codecs/Makefile  |    2 +
 sound/soc/codecs/ssm2602.c |  837 ++++++++++++++++++++++++++++++++++++++++++++
 sound/soc/codecs/ssm2602.h |  132 +++++++
 5 files changed, 975 insertions(+), 0 deletions(-)
 create mode 100644 sound/soc/codecs/ssm2602.c
 create mode 100644 sound/soc/codecs/ssm2602.h
include/linux/i2c-id.h +1 -0
index e1b46bc..aeb221b 100644
@@ -82,6 +82,7 @@
 #define I2C_DRIVERID_CS4270	94	/* Cirrus Logic 4270 audio codec */
 #define I2C_DRIVERID_M52790 	95      /* Mitsubishi M52790SP/FP AV switch */
 #define I2C_DRIVERID_CS5345	96	/* cs5345 audio processor	*/
+#define I2C_DRIVERID_SSM2602	97	/* BF52xC built in audio codec */
 
 #define I2C_DRIVERID_OV7670 1048	/* Omnivision 7670 camera */
 #define I2C_DRIVERID_AD5252 1049
sound/soc/codecs/Kconfig +3 -0
index 221e1da..67ed3f2 100644
@@ -15,6 +15,9 @@ config SND_SOC_AD1980
 	tristate
 	depends on SND_SOC
 
+config SND_SOC_SSM2602
+	tristate
+
 config SND_SOC_WM8731
 	tristate
 
sound/soc/codecs/Makefile +2 -0
index 65e2a7d..29bcea6 100644
@@ -1,6 +1,7 @@
 snd-soc-ac97-objs := ac97.o
 snd-soc-ad1980-objs := ad1980.o
 snd-soc-ak4535-objs := ak4535.o
+snd-soc-ssm2602-objs := ssm2602.o
 snd-soc-uda1380-objs := uda1380.o
 snd-soc-wm8510-objs := wm8510.o
 snd-soc-wm8731-objs := wm8731.o
@@ -15,6 +16,7 @@ snd-soc-tlv320aic3x-objs := tlv320aic3x.o
 obj-$(CONFIG_SND_SOC_AC97_CODEC)	+= snd-soc-ac97.o
 obj-$(CONFIG_SND_SOC_AD1980)	+= snd-soc-ad1980.o
 obj-$(CONFIG_SND_SOC_AK4535)	+= snd-soc-ak4535.o
+obj-$(CONFIG_SND_SOC_SSM2602)	+= snd-soc-ssm2602.o
 obj-$(CONFIG_SND_SOC_UDA1380)	+= snd-soc-uda1380.o
 obj-$(CONFIG_SND_SOC_WM8510)	+= snd-soc-wm8510.o
 obj-$(CONFIG_SND_SOC_WM8731)	+= snd-soc-wm8731.o
sound/soc/codecs/ssm2602.c new file +837 -0

837 lines not on this page · raw message

sound/soc/codecs/ssm2602.h new file +132 -0

132 lines not on this page · raw message

Signature · 1 line
1.5.6
author
#11 lore raw

PATCH 3/4 ASOC: WM8731 codec: add SPI support as well as I2C

In reply to Bryan Wu

From: Cliff Cai <[email protected]>

---
 sound/soc/codecs/Kconfig  |    5 +++
 sound/soc/codecs/wm8731.c |   71 +++++++++++++++++++++++++++++++++++++++++++--
 2 files changed, 73 insertions(+), 3 deletions(-)
sound/soc/codecs/Kconfig +5 -0
index 67ed3f2..21bb277 100644
@@ -21,6 +21,11 @@ config SND_SOC_SSM2602
 config SND_SOC_WM8731
 	tristate
 
+config SND_SOC_WM8731_SPI
+	bool "Control interface: Use SPI instead of I2C"
+	depends on SND_SOC_WM8731
+	default n
+
 config SND_SOC_WM8750
 	tristate
 
sound/soc/codecs/wm8731.c +68 -3

110 lines not on this page · raw message

Signature · 1 line
1.5.6
author
#22 lore raw

PATCH 4/4 ALSA: add dummy function to support shared mmap in nommu Blackfin arch

In reply to Bryan Wu

From: Cliff Cai <[email protected]>

---
 sound/core/pcm_native.c |    8 ++++++++
 1 files changed, 8 insertions(+), 0 deletions(-)
sound/core/pcm_native.c +8 -0
index c49b9d9..cb202a1 100644
@@ -3391,6 +3391,12 @@ out:
 }
 #endif /* CONFIG_SND_SUPPORT_OLD_API */
 
+unsigned long dummy_get_unmapped_area(struct file *file, unsigned long addr,
+				      unsigned long len, unsigned long pgoff, unsigned long flags)
+{
+	return 0;
+}
+
 /*
  *  Register section
  */
@@ -3407,6 +3413,7 @@ const struct file_operations snd_pcm_f_ops[2] = {
 		.compat_ioctl = 	snd_pcm_ioctl_compat,
 		.mmap =			snd_pcm_mmap,
 		.fasync =		snd_pcm_fasync,
+		.get_unmapped_area =	dummy_get_unmapped_area,
 	},
 	{
 		.owner =		THIS_MODULE,
@@ -3419,5 +3426,6 @@ const struct file_operations snd_pcm_f_ops[2] = {
 		.compat_ioctl = 	snd_pcm_ioctl_compat,
 		.mmap =			snd_pcm_mmap,
 		.fasync =		snd_pcm_fasync,
+		.get_unmapped_area =	dummy_get_unmapped_area,
 	}
 };
Signature · 1 line
1.5.6
author
#1 lore raw

PATCH 1/4 ASOC: Blackfin driver for ALSA SoC framework

In reply to Bryan Wu

From: Cliff Cai <[email protected]>

---
 sound/soc/Kconfig                   |    1 +
 sound/soc/Makefile                  |    2 +-
 sound/soc/blackfin/Kconfig          |   85 +++
 sound/soc/blackfin/Makefile         |   20 +
 sound/soc/blackfin/bf5xx-ac97-pcm.c |  424 +++++++++++++++
 sound/soc/blackfin/bf5xx-ac97-pcm.h |   29 +
 sound/soc/blackfin/bf5xx-ac97.c     |  417 ++++++++++++++
 sound/soc/blackfin/bf5xx-ac97.h     |   36 ++
 sound/soc/blackfin/bf5xx-ad1980.c   |  116 ++++
 sound/soc/blackfin/bf5xx-i2s-pcm.c  |  293 ++++++++++
 sound/soc/blackfin/bf5xx-i2s-pcm.h  |   29 +
 sound/soc/blackfin/bf5xx-i2s.c      |  183 +++++++
 sound/soc/blackfin/bf5xx-i2s.h      |   14 +
 sound/soc/blackfin/bf5xx-sport.c    | 1018 +++++++++++++++++++++++++++++++++++
 sound/soc/blackfin/bf5xx-sport.h    |  192 +++++++
 sound/soc/blackfin/bf5xx-ssm2602.c  |  195 +++++++
 16 files changed, 3053 insertions(+), 1 deletions(-)
 create mode 100644 sound/soc/blackfin/Kconfig
 create mode 100644 sound/soc/blackfin/Makefile
 create mode 100644 sound/soc/blackfin/bf5xx-ac97-pcm.c
 create mode 100644 sound/soc/blackfin/bf5xx-ac97-pcm.h
 create mode 100644 sound/soc/blackfin/bf5xx-ac97.c
 create mode 100644 sound/soc/blackfin/bf5xx-ac97.h
 create mode 100644 sound/soc/blackfin/bf5xx-ad1980.c
 create mode 100644 sound/soc/blackfin/bf5xx-i2s-pcm.c
 create mode 100644 sound/soc/blackfin/bf5xx-i2s-pcm.h
 create mode 100644 sound/soc/blackfin/bf5xx-i2s.c
 create mode 100644 sound/soc/blackfin/bf5xx-i2s.h
 create mode 100644 sound/soc/blackfin/bf5xx-sport.c
 create mode 100644 sound/soc/blackfin/bf5xx-sport.h
 create mode 100644 sound/soc/blackfin/bf5xx-ssm2602.c
sound/soc/Kconfig +1 -0
index f743530..82e4d79 100644
@@ -25,6 +25,7 @@ config SND_SOC_AC97_BUS
 source "sound/soc/at32/Kconfig"
 source "sound/soc/at91/Kconfig"
 source "sound/soc/au1x/Kconfig"
+source "sound/soc/blackfin/Kconfig"
 source "sound/soc/pxa/Kconfig"
 source "sound/soc/s3c24xx/Kconfig"
 source "sound/soc/sh/Kconfig"
sound/soc/Makefile +1 -1
index 933a66d..d849349 100644
@@ -2,4 +2,4 @@ snd-soc-core-objs := soc-core.o soc-dapm.o
 
 obj-$(CONFIG_SND_SOC)	+= snd-soc-core.o
 obj-$(CONFIG_SND_SOC)	+= codecs/ at32/ at91/ pxa/ s3c24xx/ sh/ fsl/ davinci/
-obj-$(CONFIG_SND_SOC)	+= omap/ au1x/
+obj-$(CONFIG_SND_SOC)	+= omap/ au1x/ blackfin/
sound/soc/blackfin/Kconfig new file +85 -0

85 lines not on this page · raw message

sound/soc/blackfin/Makefile new file +20 -0
new file mode 100644
index 0000000..9ea8bd9
@@ -0,0 +1,20 @@
+# Blackfin Platform Support
+snd-bf5xx-ac97-objs := bf5xx-ac97-pcm.o
+snd-bf5xx-i2s-objs := bf5xx-i2s-pcm.o
+snd-soc-bf5xx-sport-objs := bf5xx-sport.o
+snd-soc-bf5xx-ac97-objs := bf5xx-ac97.o
+snd-soc-bf5xx-i2s-objs := bf5xx-i2s.o
+
+obj-$(CONFIG_SND_BF5XX_AC97) += snd-bf5xx-ac97.o
+obj-$(CONFIG_SND_BF5XX_I2S) += snd-bf5xx-i2s.o
+obj-$(CONFIG_SND_BF5XX_SOC_SPORT) += snd-soc-bf5xx-sport.o
+obj-$(CONFIG_SND_BF5XX_SOC_AC97) += snd-soc-bf5xx-ac97.o
+obj-$(CONFIG_SND_BF5XX_SOC_I2S) += snd-soc-bf5xx-i2s.o
+
+# Blackfin Machine Support
+snd-ad1980-objs := bf5xx-ad1980.o
+snd-ssm2602-objs := bf5xx-ssm2602.o
+
+
+obj-$(CONFIG_SND_BF5XX_SOC_AD1980) += snd-ad1980.o
+obj-$(CONFIG_SND_BF5XX_SOC_SSM2602) += snd-ssm2602.o
sound/soc/blackfin/bf5xx-ac97-pcm.c new file +424 -0

424 lines not on this page · raw message

sound/soc/blackfin/bf5xx-ac97-pcm.h new file +29 -0
new file mode 100644
index 0000000..5831300
@@ -0,0 +1,29 @@
+/*
+ * linux/sound/arm/bf5xx-ac97-pcm.h -- ALSA PCM interface for the Blackfin
+ *
+ * Copyright 2007 Analog Device Inc.
+ *
+ * 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.
+ */
+
+#ifndef _BF5XX_AC97_PCM_H
+#define _BF5XX_AC97_PCM_H
+
+struct bf5xx_pcm_dma_params {
+	char *name;			/* stream identifier */
+};
+
+struct bf5xx_gpio {
+	u32 sys;
+	u32	rx;
+	u32 tx;
+	u32 clk;
+	u32 frm;
+};
+
+/* platform data */
+extern struct snd_soc_platform bf5xx_ac97_soc_platform;
+
+#endif
sound/soc/blackfin/bf5xx-ac97.c new file +417 -0

417 lines not on this page · raw message

sound/soc/blackfin/bf5xx-ac97.h new file +36 -0
new file mode 100644
index 0000000..725ede8
@@ -0,0 +1,36 @@
+/*
+ * linux/sound/arm/bf5xx-ac97.h
+ *
+ * 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.
+ */
+
+#ifndef _BF5XX_AC97_H
+#define _BF5XX_AC97_H
+
+extern struct snd_ac97_bus_ops bf5xx_ac97_ops;
+extern struct snd_ac97 *ac97;
+/* Frame format in memory, only support stereo currently */
+struct ac97_frame {
+	u16 ac97_tag;		/* slot 0 */
+	u16 ac97_addr;		/* slot 1 */
+	u16 ac97_data;		/* slot 2 */
+	u32 ac97_pcm;		/* slot 3 and 4: left and right pcm data */
+} __attribute__ ((packed));
+
+#define TAG_VALID		0x8000
+#define TAG_CMD			0x6000
+#define TAG_PCM_LEFT		0x1000
+#define TAG_PCM_RIGHT		0x0800
+#define TAG_PCM			(TAG_PCM_LEFT | TAG_PCM_RIGHT)
+
+extern struct snd_soc_cpu_dai bfin_ac97_dai;
+
+void bf5xx_pcm_to_ac97(struct ac97_frame *dst, const __u32 *src, \
+		size_t count);
+
+void bf5xx_ac97_to_pcm(const struct ac97_frame *src, __u32 *dst, \
+		size_t count);
+
+#endif
sound/soc/blackfin/bf5xx-ad1980.c new file +116 -0

116 lines not on this page · raw message

sound/soc/blackfin/bf5xx-i2s-pcm.c new file +293 -0

293 lines not on this page · raw message

sound/soc/blackfin/bf5xx-i2s-pcm.h new file +29 -0
new file mode 100644
index 0000000..5ab26e1
@@ -0,0 +1,29 @@
+/*
+ * linux/sound/arm/bf5xx-i2s-pcm.h -- ALSA PCM interface for the Blackfin
+ *
+ * Copyright 2007 Analog Device Inc.
+ *
+ * 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.
+ */
+
+#ifndef _BF5XX_I2S_PCM_H
+#define _BF5XX_I2S_PCM_H
+
+struct bf5xx_pcm_dma_params {
+	char *name;			/* stream identifier */
+};
+
+struct bf5xx_gpio {
+	u32 sys;
+	u32	rx;
+	u32 tx;
+	u32 clk;
+	u32 frm;
+};
+
+/* platform data */
+extern struct snd_soc_platform bf5xx_i2s_soc_platform;
+
+#endif
sound/soc/blackfin/bf5xx-i2s.c new file +183 -0

183 lines not on this page · raw message

sound/soc/blackfin/bf5xx-i2s.h new file +14 -0
new file mode 100644
index 0000000..3731273
@@ -0,0 +1,14 @@
+/*
+ * linux/sound/arm/bf5xx-i2s.h
+ *
+ * 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.
+ */
+
+#ifndef _BF5XX_I2S_H
+#define _BF5XX_I2S_H
+
+extern struct snd_soc_cpu_dai bf5xx_i2s_dai;
+
+#endif
sound/soc/blackfin/bf5xx-sport.c new file +1018 -0

1,018 lines not on this page · raw message

sound/soc/blackfin/bf5xx-sport.h new file +192 -0

192 lines not on this page · raw message

sound/soc/blackfin/bf5xx-ssm2602.c new file +195 -0

132 lines not on this page · raw message

The rest of this diff is not shown. View the raw message.

Signature · 1 line
1.5.6

Part of the diff is not shown here. View the raw message.

#7 lore raw

Re: [alsa-devel] [PATCH 2/4] ASOC codec: add support for SSM2602 audio codec in ALSA SoC framework

In reply to Bryan Wu

On Wed, Aug 27, 2008 at 05:39:26PM +0800, Bryan Wu wrote:

This looks basically good, thanks - I've picked up a few things below but they are mostly either minor or reflect the fact that the patch looks like it's been developed against current release kernels but there's been some churn recently in the ASoC APIs which need updates.

Quoted 2 lines

#define I2C_DRIVERID_CS5345 96 /* cs5345 audio processor */
+#define I2C_DRIVERID_SSM2602 97 /* BF52xC built in audio codec */

It should be possible to just remove this - it shouldn't be needed.

sound/soc/codecs/Kconfig

Quoted 2 lines
sound/soc/codecs/Kconfig +0 -0

Current kernels have a Kconfig option SND_SOC_ALL_CODECS which should have your codec added - this allows codec drivers to be built without boards for test purposes.

Quoted 4 lines
sound/soc/codecs/Kconfig +4 -0
+#define SSM2602_DEBUG 0
+
+#ifdef SSM2602_DEBUG
+#define dbg(format, arg...) \

sound/soc/codecs/Kconfig

Quoted 10 lines
sound/soc/codecs/Kconfig +10 -0
+	printk(KERN_DEBUG AUDIO_NAME ": " format "\n" , ## arg)
+#else
+#define dbg(format, arg...) do {} while (0)
+#endif
+#define err(format, arg...) \
+	printk(KERN_ERR AUDIO_NAME ": " format "\n" , ## arg)
+#define info(format, arg...) \
+	printk(KERN_INFO AUDIO_NAME ": " format "\n" , ## arg)
+#define warn(format, arg...) \
+	printk(KERN_WARNING AUDIO_NAME ": " format "\n" , ## arg)

Please convert these to use the standard pr_ macros (or ideally the dev_ ones where possible) for debug prints.

sound/soc/codecs/Kconfig

Quoted 6 lines
sound/soc/codecs/Kconfig +6 -0
+
+#define ssm2602_reset(c)	ssm2602_write(c, SSM2602_RESET, 0)
+/*Appending several "None"s just for OSS mixer use*/
+static const char *ssm2602_input_select[] = {"Line", "Mic", "None", "None", "None",
+		"None", "None", "None"};
+static const char *ssm2602_deemph[] = {"None", "32Khz", "44.1Khz", "48Khz"};

Please keep the lines under 80 characters where reasonable. A little more while space (blank lines and at the start and end of comments) would be nice too.

Quoted 1 line

+static const char *intercon[][3] = {

This should be converted to an array of struct snd_soc_dapm_route - there's a new bulk registration API been added which saves everything open coding all these and improves the error checking.

sound/soc/codecs/Kconfig

Quoted 6 lines
sound/soc/codecs/Kconfig +6 -0
+static int ssm2602_add_widgets(struct snd_soc_codec *codec)
+{
+	int i;
+
+	for (i = 0; i < ARRAY_SIZE(ssm2602_dapm_widgets); i++)
+		snd_soc_dapm_new_control(codec, &ssm2602_dapm_widgets[i]);

There's now a snd_soc_dapm_new_controls() for registering DAPM controls en masse as well.

sound/soc/codecs/Kconfig

Quoted 5 lines
sound/soc/codecs/Kconfig +5 -0
+	/* set up audio path interconnects */
+	for (i = 0; intercon[i][0] != NULL; i++) {
+		snd_soc_dapm_connect_input(codec, intercon[i][0],
+			intercon[i][1], intercon[i][2]);
+	}

This can be replaced with snd_soc_dapm_add_routes().

sound/soc/codecs/Kconfig

Quoted 10 lines
sound/soc/codecs/Kconfig +10 -0
+static int ssm2602_mute(struct snd_soc_codec_dai *dai, int mute)
+{
+	struct snd_soc_codec *codec = dai->codec;
+	u16 mute_reg = ssm2602_read_reg_cache(codec, SSM2602_APDIGI) & 0xfff7;
+	if (mute)
+		ssm2602_write(codec, SSM2602_APDIGI, mute_reg | ENABLE_DAC_MUTE);
+	else
+		ssm2602_write(codec, SSM2602_APDIGI, mute_reg);
+	return 0;
+}

More blank lines would be nice here and elsewhere but it's not critical.

sound/soc/codecs/Kconfig

Quoted 6 lines
sound/soc/codecs/Kconfig +6 -0
+static int ssm2602_dapm_event(struct snd_soc_codec *codec, int event)
+{
+	u16 reg = ssm2602_read_reg_cache(codec, SSM2602_PWR) & 0xff7f;
+
+	switch (event) {
+	case SNDRV_CTL_POWER_D0: /* full On */

This won't compile with current kernels. The dapm_event() interface has been replaced by the very similar but hopefully clearer set_bias_level() interface which use a different set of constants.

sound/soc/codecs/Kconfig

Quoted 6 lines
sound/soc/codecs/Kconfig +6 -0
+static int ssm2602_suspend(struct platform_device *pdev, pm_message_t state)
+{
+	struct snd_soc_device *socdev = platform_get_drvdata(pdev);
+	struct snd_soc_codec *codec = socdev->codec;
+
+	ssm2602_write(codec, SSM2602_ACTIVE, 0);

That *should* be redundant - ALSA should stop the playback streams before suspending - but equally well it shouldn't hurt.

Quoted 1 line

+#if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE) && !defined(CONFIG_SND_SOC_SSM2602_SPI)

Hrm. Why does the SPI support disable the I2C support? I'd expect to be able to build a kernel with the chip supported on both (for use on multiple boards).

sound/soc/codecs/Kconfig

Quoted 11 lines
sound/soc/codecs/Kconfig +11 -0
+
+/*
+ * ssm2602 2 wire address is determined by GPIO5
+ * state during powerup.
+ *    low  = 0x1a
+ *    high = 0x1b
+ */
+static unsigned short normal_i2c[] = { 0, I2C_CLIENT_END };
+
+/* Magic definition of all other variables and things */
+I2C_CLIENT_INSMOD;

Jean Delvare is currently in the process of convering all the ASoC codec drivers to new style I2C drivers so we probably shouldn't add any more old style I2C codec drivers. The update is fairly straightforward - see his patches yesterday for WM8731 and WM8750 for example conversions.

sound/soc/codecs/Kconfig

Quoted 5 lines
sound/soc/codecs/Kconfig +5 -0
+#elif defined(CONFIG_SPI_MASTER) && defined(CONFIG_SND_SOC_SSM2602_SPI)
+	codec->hw_write = (hw_write_t)ssm2602_spi_write;
+	ret = spi_register_driver(&ssm2602_spi_driver);
+	if (ret != 0)
+		printk(KERN_ERR "can't add spi driver");

You could add a flag in the device data to identify if the device is on SPI here (that's what the check for i2c_address is intended for).

#12 lore raw

Re: [alsa-devel] [PATCH 3/4] ASOC: WM8731 codec: add SPI support as well as I2C

In reply to Bryan Wu

On Wed, Aug 27, 2008 at 05:39:27PM +0800, Bryan Wu wrote:

This looks good, thanks but...

Quoted 6 lines
sound/soc/codecs/wm8731.c +1 -1
-#if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE)
+#if defined (CONFIG_I2C) || defined (CONFIG_I2C_MODULE) && !defined (CONFIG_SND_SOC_WM8731_SPI)
 	if (setup->i2c_address) {
 		normal_i2c[0] = setup->i2c_address;
 		codec->hw_write = (hw_write_t)i2c_master_send;

sound/soc/codecs/wm8731.c static int wm8731_probe(struct platform_device *pdev) · line 752

Quoted 8 lines
sound/soc/codecs/wm8731.c +5 -0
@@ -688,8 +745,14 @@ static int wm8731_probe(struct platform_device *pdev)
 		if (ret != 0)
 			printk(KERN_ERR "can't add i2c driver");
 	}
+#elif defined (CONFIG_SPI_MASTER) && defined (CONFIG_SND_SOC_WM8731_SPI)
+	codec->hw_write = (hw_write_t)wm8731_spi_write;
+	ret = spi_register_driver(&wm8731_spi_driver);
+	if (ret != 0)
+		printk(KERN_ERR "can't add spi driver");

...as for the SSM2602 it'd be good if it were possible to build a kernel which supports both I2C and SPI. If you like I could do this for you - there's likely to be merge issues due to the update to the new I2C API anyway?

#2 lore raw

Re: [PATCH 1/4] ASOC: Blackfin driver for ALSA SoC framework

In reply to Bryan Wu
Quoted 4 lines · Bryan Wu

From: Cliff Cai <[email protected]>

As with the other patches in the series this looks good but it has been affected by changes in the ASoC APIs and needs to be updated to reflect current ALSA. The topic/asoc branch of Takashi's tree:

    git://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound-2.6.git

is what's currently queued for 2.6.28.

Other than that, checkpatch-style things and a few more minor issues the main things are the register write interface in /proc and the hardware parameters for the I2S driver. I've not flagged all the checkpatch stuff here.

Can I also suggest splitting this up into a series of patches for easier review - for example, adding the SPORT support first, followed by the AC97 and I2S drivers and then the machine drivers? I'd certainly have appreciated having seen the SPORT support (which appears at the end of the patch) before looking at the AC97 and I2S stuff.

sound/soc/blackfin/Kconfig line 32

Quoted 11 lines
sound/soc/blackfin/Kconfig new file +11 -0
+	depends on BLACKFIN && SND_SOC
+	help
+	  Say Y or M if you want to add support for codecs attached to
+	  the Blackfin SPORT (synchronous serial ports) interface in slot 16 
+	  mode (pseudo AC97 interface).
+	  You will also need to select the audio interfaces to support below.
+
+	  Note:
+	  AC'97 codecs which do not implment the slot-16 mode will not function
+	  properly with this driver. This driver is known to work with the
+	  Analog Devices line of AC97 codecs.

Your spelling of AC97 isn't consistent here. The kernel seems to prefer AC97, as do you.

Quoted 5 lines

+ * File: sound/soc/blackfin/bf5xx-ac97-pcm.c
+ * Author: Cliff Cai <[email protected]>
+ *
+ * Created: Tue June 06 2008
+ * Description: Driver for SSM2602 sound chip built in ADSP-BF52xC

Hopefully the driver is more generic than that?

sound/soc/blackfin/bf5xx-ac97-pcm.c line 110

Quoted 4 lines
sound/soc/blackfin/bf5xx-ac97-pcm.c new file +4 -0
+static int bf5xx_pcm_hw_params(struct snd_pcm_substream *substream,
+	struct snd_pcm_hw_params *params)
+{
+	size_t size = bf5xx_pcm_hardware.buffer_bytes_max * sizeof(struct ac97_frame)/4;

Checkpatch picks up on this and quite a few other places being over 80 columns.

sound/soc/blackfin/bf5xx-ac97-pcm.c line 165

Quoted 8 lines
sound/soc/blackfin/bf5xx-ac97-pcm.c new file +8 -0
+static int bf5xx_pcm_trigger(struct snd_pcm_substream *substream, int cmd)
+{
+	struct snd_pcm_runtime *runtime = substream->runtime;
+	struct sport_device *sport = runtime->private_data;
+	int ret = 0;
+
+	pr_debug("%s %s\n", substream->stream?"Capture":"Playback", \
+			cmd?" start":" stop");

This looks wrong - there's rather more options for cmd, for example, and you're making assumptions about the value of SNDRV_PMC_STREAM_PLAYBACK.

Quoted 1 line

+/*Need to allocate local buffer when enable MMAP for SPORT working in TMD mode(include AC97).*/

Indentation?

sound/soc/blackfin/bf5xx-ac97-pcm.h line 24

Quoted 13 lines
sound/soc/blackfin/bf5xx-ac97-pcm.h new file +7 -0
new file mode 100644
index 0000000..5831300
 
+struct bf5xx_gpio {
+	u32 sys;
+	u32	rx;
+	u32 tx;
+	u32 clk;
+	u32 frm;
+};

That should be a space before rx, not a tab.

sound/soc/blackfin/bf5xx-ac97.c

Quoted 7 lines
sound/soc/blackfin/bf5xx-ac97.c new file +1 -0
new file mode 100644
index 0000000..685a494
 
+#include <sound/driver.h>

This header is obsolte and should be removed.

sound/soc/blackfin/bf5xx-ac97.c line 160

Quoted 13 lines
sound/soc/blackfin/bf5xx-ac97.c new file +13 -0
+static unsigned short bf5xx_ac97_read(struct snd_ac97 *ac97,
+	unsigned short reg)
+{
+	struct ac97_frame out_frame[2], in_frame[2];
+
+	pr_debug("%s enter 0x%x\n", __func__, reg);
+
+	/* When dma descriptor is enabled, the register should not be read */
+	if (sport_handle->tx_run || sport_handle->rx_run) {
+		printk(KERN_ERR "Could you send a mail to author "
+				"to report this?\n");
+		return -EFAULT;
+	}

Might be nice to say what to report and who the author is - by itself the printout is going to be rather obscure :)

sound/soc/blackfin/bf5xx-ac97.c line 258

Quoted 2 lines
sound/soc/blackfin/bf5xx-ac97.c new file +2 -0
+static int bf5xx_ac97_resume(struct platform_device *pdev,
+	struct snd_soc_cpu_dai *dai)

struct snd_soc_cpu_dai and struct snd_soc_codec_dai have been merged into a single struct snd_soc_dai in current versions.

sound/soc/blackfin/bf5xx-ac97.c line 284

Quoted 12 lines
sound/soc/blackfin/bf5xx-ac97.c new file +12 -0
+	ret = sport_config_rx(sport_handle, IRFS, 0xF, 0, (16*16-1));
+
+	if (ret) {
+		printk(KERN_ERR "SPORT is busy!\n");
+		return -EBUSY;
+	}
+	ret = sport_config_tx(sport_handle, ITFS, 0xF, 0, (16*16-1));
+
+	if (ret) {
+		printk(KERN_ERR "SPORT is busy!\n");
+		return -EBUSY;
+	}

Shouldn't this undo the previous sport_confix_rx() on error?

Also, the use of blank lines is a bit funny here - I'd expect the blank before rather than after the function calls.

sound/soc/blackfin/bf5xx-ac97.c line 303

Quoted 6 lines
sound/soc/blackfin/bf5xx-ac97.c new file +6 -0
+static struct proc_dir_entry *ac_entry;
+
+/* For test purpose, read a register from codec */
+static int proc_write(struct file *file, const char __user *buffer,
+		unsigned long count, void *data)
+{

I think it's probably better to drop this from mainline - it doesn't seem like something that we should be supporting long term and obviously it could do damage if used.

If you do want to put it in mainline then it ought to go in debugfs rather than proc.

sound/soc/blackfin/bf5xx-ac97.c line 368

Quoted 13 lines
sound/soc/blackfin/bf5xx-ac97.c new file +13 -0
+	/*SPORT works in TDM mode to simulate AC97 transfers*/
+	ret = sport_set_multichannel(sport_handle, 16, 0x1F, 1);
+
+	if (ret) {
+		printk(KERN_ERR "SPORT is busy!\n");
+		return -EBUSY;
+	}
+	ret = sport_config_rx(sport_handle, IRFS, 0xF, 0, (16*16-1));
+
+	if (ret) {
+		printk(KERN_ERR "SPORT is busy!\n");
+		return -EBUSY;
+	}

Again, odd blank lines and presumably there needs to be something to undo things on error?

Quoted 4 lines

+ * File: sound/soc/blackfin/bf5xx-ad1980.c
+ * Author: Cliff Cai <[email protected]>
+ *
+ * Created: Tue June 06 2008

o> + * Description: Driver for SSM2602 sound chip built in ADSP-BF52xC

This comment is wrong - it's for the AD1980.

Quoted 13 lines
sound/soc/blackfin/bf5xx-ac97.c new file +9 -0
+static int bf5xx_board_startup(struct snd_pcm_substream *substream)
+{
+	struct snd_soc_pcm_runtime *rtd = substream->private_data;
+	struct snd_soc_cpu_dai *cpu_dai = rtd->dai->cpu_dai;
+
+	pr_debug("%s enter\n", __func__);
+	cpu_dai->private_data = sport_handle;
+	return 0;
+}

sound/soc/blackfin/bf5xx-i2s-pcm.c line 6

Quoted 6 lines
sound/soc/blackfin/bf5xx-i2s-pcm.c new file +6 -0
@@ -0,0 +1,293 @@
+/*
+ * File:         sound/soc/blackfin/bf5xx-i2s-pcm.c
+ * Author:       Cliff Cai <[email protected]>
+ *
+ * Created:      Tue June 06 2008
+ * Description:  Driver for SSM2602 sound chip built in ADSP-BF52xC

This comment is wrong too :)

sound/soc/blackfin/bf5xx-i2s-pcm.c line 7

Quoted 1 line
sound/soc/blackfin/bf5xx-i2s-pcm.c new file +1 -0
+#include <sound/driver.h>

Obsolete.

sound/soc/blackfin/bf5xx-i2s-pcm.c line 9

Quoted 2 lines
sound/soc/blackfin/bf5xx-i2s-pcm.c new file +2 -0
+	pr_debug("%s %s\n", substream->stream?"Capture":"Playback", \
+			cmd?" start":" stop");

Same comment as for AC97. Shouldn't more of this code be shared with the AC97 DMA driver?

sound/soc/blackfin/bf5xx-i2s-pcm.c line 16

Quoted 7 lines
sound/soc/blackfin/bf5xx-i2s-pcm.c new file +7 -0
+static int bf5xx_pcm_close(struct snd_pcm_substream *substream)
+{
+	pr_debug("%s enter\n", __func__);
+	/*Nothing need to be cleared here*/
+
+	return 0;
+}

You should just be able to remove this if it's empty.

sound/soc/blackfin/bf5xx-i2s-pcm.c line 17

Quoted 1 line
sound/soc/blackfin/bf5xx-i2s-pcm.c new file +1 -0
+#include <sound/driver.h>

Obsolete.

sound/soc/blackfin/bf5xx-i2s-pcm.c line 21

Quoted 4 lines
sound/soc/blackfin/bf5xx-i2s-pcm.c new file +4 -0
+	/*  TX and RX are not independent,they are enabled at the same time,
+	 *  even if only one side is running.So,we need to configure both of them in advance.
+	 *  CPU DAI format:I2S,word length:32 bit,slave mode.
+	 */

Are the RX and TX clocks independant? If not you should probably tell user space about the constraint in startup(), forcing the second stream that's opened to use the same configuration as the first - take a look at the fsl_ssi driver or the wm8903 driver for examples of how to do this.

I'm also not seeing the code that configures the sample rate anywhere - but then it looks like the driver only support slave mode ATM? That's what the machine driver is using. There should still be a set_fmt() to document what's supported if nothing else.

sound/soc/blackfin/bf5xx-i2s-pcm.c line 31

Quoted 10 lines
sound/soc/blackfin/bf5xx-i2s-pcm.c new file +10 -0
+void decfrag(struct sport_device *sport, int *frag, int tx)
+{
+	--(*frag);
+	if (tx == 1 && *frag == 0)
+		*frag = sport->tx_frags;
+
+	if (tx == 0 && *frag == 0)
+		*frag = sport->rx_frags;
+}
+EXPORT_SYMBOL(decfrag);

This symbol should be namespaced.

sound/soc/blackfin/bf5xx-ssm2602.c

Quoted 5 lines
sound/soc/blackfin/bf5xx-ssm2602.c new file +0 -0
new file mode 100644
index 0000000..41e161f

This driver needs to follow the ssm2602 codec driver so either the series needs reordering or at least this bit needs to be split out into another patch.

Quoted 1 line

+#include <sound/driver.h>

Obsolete.

Quoted 13 lines
sound/soc/blackfin/bf5xx-ssm2602.c new file +13 -0
+	 * WARNING - TODO
+	 *
+	 * This code assumes there is a variable clocksource for the SSM2602.
+	 * i.e. it supplies MCLK depending on rate.
+	 *
+	 * If you are using a crystal source then modify the below case
+	 * statement with a static frequency.
+	 *
+	 * If you are using the SPORT to generate clocking then this is
+	 * where to do it.
+	 */
+
+	switch (params_rate(params)) {

sound/soc/blackfin/bf5xx-ssm2602.c line 95

Quoted 10 lines
sound/soc/blackfin/bf5xx-ssm2602.c new file +10 -0
+	case 8000:
+	case 16000:
+	case 48000:
+	case 96000:
+	case 11025:
+	case 22050:
+	case 44100:
+		clk = 12000000;
+		break;
+	}

I'm not sure that comment quite agrees with the code here...

author
#13 lore raw

Re: [alsa-devel] [PATCH 3/4] ASOC: WM8731 codec: add SPI support as well as I2C

In reply to Mark Brown
Quoted 15 lines · Mark Brown

On Wed, Aug 27, 2008 at 05:39:27PM +0800, Bryan Wu wrote:

This looks good, thanks but...

Quoted 11 lines
sound/soc/codecs/wm8731.c +3 -1
-#if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE)
+#if defined (CONFIG_I2C) || defined (CONFIG_I2C_MODULE) && !defined (CONFIG_SND_SOC_WM8731_SPI)
      if (setup->i2c_address) {
              normal_i2c[0] = setup->i2c_address;
              codec->hw_write = (hw_write_t)i2c_master_send;
@@ -688,8 +745,14 @@ static int wm8731_probe(struct platform_device *pdev)
              if (ret != 0)
                      printk(KERN_ERR "can't add i2c driver");
      }
+#elif defined (CONFIG_SPI_MASTER) && defined (CONFIG_SND_SOC_WM8731_SPI)
+     codec->hw_write = (hw_write_t)wm8731_spi_write;
Quoted 9 lines

sound/soc/codecs/wm8731.c static int wm8731_probe(struct platform_device *pdev) · line 752

Quoted 3 lines
sound/soc/codecs/wm8731.c +3 -0
+     ret = spi_register_driver(&wm8731_spi_driver);
+     if (ret != 0)
+             printk(KERN_ERR "can't add spi driver");

...as for the SSM2602 it'd be good if it were possible to build a kernel which supports both I2C and SPI. If you like I could do this for you - there's likely to be merge issues due to the update to the new I2C API anyway?

Oh, do you mean SSM2602 or WM8731? I also noticed the i2c API updates patch from Jean and I'd like to use the new one

Thanks
-Bryan

author
#8 lore raw

Re: [alsa-devel] [PATCH 2/4] ASOC codec: add support for SSM2602 audio codec in ALSA SoC framework

In reply to Mark Brown
Quoted 7 lines · Mark Brown

On Wed, Aug 27, 2008 at 05:39:26PM +0800, Bryan Wu wrote:

This looks basically good, thanks - I've picked up a few things below but they are mostly either minor or reflect the fact that the patch looks like it's been developed against current release kernels but there's been some churn recently in the ASoC APIs which need updates.

Quoted 5 lines
Quoted 2 lines

#define I2C_DRIVERID_CS5345 96 /* cs5345 audio processor */
+#define I2C_DRIVERID_SSM2602 97 /* BF52xC built in audio codec */

It should be possible to just remove this - it shouldn't be needed.

OK, I'll take care of this i2c stuff here.

Quoted 7 lines

sound/soc/codecs/Kconfig

Quoted 2 lines
sound/soc/codecs/Kconfig +0 -0

Current kernels have a Kconfig option SND_SOC_ALL_CODECS which should have your codec added - this allows codec drivers to be built without boards for test purposes.

Is this option in alsa git tree or in the mainline? I fail to find it in upstream mainline.
And do you mean I don't need to add SND_SOC_SSM2602 at all?

Quoted 9 lines
Quoted 9 lines
sound/soc/codecs/Kconfig +9 -0
+#define SSM2602_DEBUG 0
+
+#ifdef SSM2602_DEBUG
+#define dbg(format, arg...) \
+     printk(KERN_DEBUG AUDIO_NAME ": " format "\n" , ## arg)
+#else
+#define dbg(format, arg...) do {} while (0)
+#endif
+#define err(format, arg...) \
Quoted 9 lines

sound/soc/codecs/Kconfig

Quoted 5 lines
sound/soc/codecs/Kconfig +5 -0
+     printk(KERN_ERR AUDIO_NAME ": " format "\n" , ## arg)
+#define info(format, arg...) \
+     printk(KERN_INFO AUDIO_NAME ": " format "\n" , ## arg)
+#define warn(format, arg...) \
+     printk(KERN_WARNING AUDIO_NAME ": " format "\n" , ## arg)

Please convert these to use the standard pr_ macros (or ideally the dev_ ones where possible) for debug prints.

Right, I killed this local definition and replaced them to pr_xxxx.

Quoted 11 lines

sound/soc/codecs/Kconfig

Quoted 6 lines
sound/soc/codecs/Kconfig +6 -0
+
+#define ssm2602_reset(c)     ssm2602_write(c, SSM2602_RESET, 0)
+/*Appending several "None"s just for OSS mixer use*/
+static const char *ssm2602_input_select[] = {"Line", "Mic", "None", "None", "None",
+             "None", "None", "None"};
+static const char *ssm2602_deemph[] = {"None", "32Khz", "44.1Khz", "48Khz"};

Please keep the lines under 80 characters where reasonable. A little more while space (blank lines and at the start and end of comments) would be nice too.

Yes, I will fix this issue by running checkpatch.pl. And for other API conflicts and I2C interface upgrading stuffs,
I will leave them to Cliff.

Thanks
-Bryan

#9 lore raw

Re: [alsa-devel] [PATCH 2/4] ASOC codec: add support for SSM2602 audio codec in ALSA SoC framework

Quoted 9 lines · Bryan Wu
Quoted 3 lines · Mark Brown

Current kernels have a Kconfig option SND_SOC_ALL_CODECS which should have your codec added - this allows codec drivers to be built without boards for test purposes.

Is this option in alsa git tree or in the mainline? I fail to find it in upstream mainline.
And do you mean I don't need to add SND_SOC_SSM2602 at all?

It's in ALSA git, queued for the 2.6.28 merge window. See the topic/asoc branch of:

        git://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound-2.6.git

for the current ASoC merge queue. The other API changes will all be queued there too.

There's quite a bit of churn in ASoC at the minute but additional API changes will be taken care of by whoever does them once your driver is merged so it should save you some work if you're able to get this in soon.

Quoted 3 lines

Yes, I will fix this issue by running checkpatch.pl. And for other API conflicts and I2C interface upgrading stuffs,
I will leave them to Cliff.

OK. Jean might be willing to do the I2C API conversion for you (I've CCed him in).

#14 lore raw

Re: [alsa-devel] [PATCH 3/4] ASOC: WM8731 codec: add SPI support as well as I2C

In reply to Bryan Wu
Quoted 9 lines · Bryan Wu
Quoted 4 lines · Mark Brown

...as for the SSM2602 it'd be good if it were possible to build a kernel which supports both I2C and SPI. If you like I could do this for you - there's likely to be merge issues due to the update to the new I2C API anyway?

Oh, do you mean SSM2602 or WM8731? I also noticed the i2c API updates patch from Jean and I'd like to use the new one

Sorry, that could've been clearer - I meant wm8731. Obviously if you want to update that too then that would be great but I figured it'd make life easier for you if I were to ensure that one gets merged OK. Which way do you prefer?

#10 lore raw

Re: [alsa-devel] [PATCH 2/4] ASOC codec: add support for SSM2602 audio codec in ALSA SoC framework

In reply to Mark Brown

Hi Bryan, Mark,

Quoted 7 lines · Mark Brown
Quoted 3 lines · Bryan Wu

Yes, I will fix this issue by running checkpatch.pl. And for other API conflicts and I2C interface upgrading stuffs,
I will leave them to Cliff.

OK. Jean might be willing to do the I2C API conversion for you (I've CCed him in).

Sure, I can help with that if needed. OTOH, I've posted patches converting 2 drivers already [1] [2], and apparently all the codec drivers follow the same model so it shouldn't be too difficult for driver authors to do the same on their code. But anyway I'll convert the remaining drivers as my time permits. The plan is to have everything converted for kernel 2.6.28 (at which point the old I2C API will be deprecated.)

[1] http://mailman.alsa-project.org/pipermail/alsa-devel/2008-August/010198.html
[2] http://mailman.alsa-project.org/pipermail/alsa-devel/2008-August/010199.html

Signature · 1 line
Jean Delvare
#23 lore raw

Re: [PATCH 4/4] ALSA: add dummy function to support shared mmap in nommu Blackfin arch

In reply to Bryan Wu

At Wed, 27 Aug 2008 17:39:28 +0800,

Quoted 14 lines · Bryan Wu

From: Cliff Cai <[email protected]>

---
 sound/core/pcm_native.c |    8 ++++++++
 1 files changed, 8 insertions(+), 0 deletions(-)
sound/core/pcm_native.c +0 -0
index c49b9d9..cb202a1 100644

sound/core/pcm_native.c out: · line 3398

Quoted 8 lines
sound/core/pcm_native.c +5 -0
@@ -3391,6 +3391,12 @@ out:
 }
 #endif /* CONFIG_SND_SUPPORT_OLD_API */
 
+unsigned long dummy_get_unmapped_area(struct file *file, unsigned long addr,
+				      unsigned long len, unsigned long pgoff, unsigned long flags)
+{
+	return 0;
+}

Always zero is confirmed to work for other architectures, too?

Quoted 12 lines
sound/core/pcm_native.c +1 -0
 /*
  *  Register section
  */
@@ -3407,6 +3413,7 @@ const struct file_operations snd_pcm_f_ops[2] = {
 		.compat_ioctl = 	snd_pcm_ioctl_compat,
 		.mmap =			snd_pcm_mmap,
 		.fasync =		snd_pcm_fasync,
+		.get_unmapped_area =	dummy_get_unmapped_area,
 	},
 	{
 		.owner =		THIS_MODULE,

sound/core/pcm_native.c const struct file_operations snd_pcm_f_ops[2] = { · line 3431

Quoted 6 lines
sound/core/pcm_native.c +1 -0
@@ -3419,5 +3426,6 @@ const struct file_operations snd_pcm_f_ops[2] = {
 		.compat_ioctl = 	snd_pcm_ioctl_compat,
 		.mmap =			snd_pcm_mmap,
 		.fasync =		snd_pcm_fasync,
+		.get_unmapped_area =	dummy_get_unmapped_area,
 	}
 };

I don't think adding this dummy get_unmapped_area unconditionally for every driver is good. This overrides the default mm->get_unmaped_area.

Takashi

#15 lore raw

Re: [alsa-devel] [PATCH 3/4] ASOC: WM8731 codec: add SPI support as well as I2C

In reply to Mark Brown

At Thu, 28 Aug 2008 11:14:35 +0100,

Quoted 9 lines · Mark Brown
Quoted 6 lines · Bryan Wu
Quoted 4 lines · Mark Brown

...as for the SSM2602 it'd be good if it were possible to build a kernel which supports both I2C and SPI. If you like I could do this for you - there's likely to be merge issues due to the update to the new I2C API anyway?

Quoted 7 lines
Quoted 2 lines

Oh, do you mean SSM2602 or WM8731? I also noticed the i2c API updates patch from Jean and I'd like to use the new one

Sorry, that could've been clearer - I meant wm8731. Obviously if you want to update that too then that would be great but I figured it'd make life easier for you if I were to ensure that one gets merged OK. Which way do you prefer?

For me, it's easier when they come from you all together ;)

I still postponed to merge Jean's latest patches. Care to check that don't conflict your work and send them together?

thanks,

Takashi

#16 lore raw

Re: [alsa-devel] [PATCH 3/4] ASOC: WM8731 codec: add SPI support as well as I2C

Quoted 2 lines · Takashi Iwai

I still postponed to merge Jean's latest patches. Care to check that don't conflict your work and send them together?

No problem from my point of view, though all I'll do is construct a patch series with Jean's changes at the start so from that point of view you may as well merge them directly - it doesn't change the work that needs to be done.

#17 lore raw

Re: [alsa-devel] [PATCH 3/4] ASOC: WM8731 codec: add SPI support as well as I2C

In reply to Bryan Wu

We have just started trying this out as an alternative to i2c, and picked out the following:

Quoted 3 lines · Bryan Wu
(quoted diff) +1 -1
-#if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE)
+#if defined (CONFIG_I2C) || defined (CONFIG_I2C_MODULE) && !defined

(CONFIG_SND_SOC_WM8731_SPI)

I think this needs extra brackets round the ||'s before the && thus:

Quoted 2 lines

+#if (defined (CONFIG_I2C) || defined (CONFIG_I2C_MODULE)) && !defined (CONFIG_SND_SOC_WM8731_SPI)

in order to force use of SPI when (CONFIG_SND_SOC_WM8731_SPI) and (CONFIG_I2C) are both defined. Or have we misunderstood the intention? This is in 2 other places also in the patch.

Alan

#18 lore raw

Re: [alsa-devel] [PATCH 3/4] ASOC: WM8731 codec: add SPI support as well as I2C

Quoted 10 lines · Alan Horstmann

We have just started trying this out as an alternative to i2c, and picked out the following:

Quoted 3 lines · Bryan Wu
(quoted diff) +1 -1
-#if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE)
+#if defined (CONFIG_I2C) || defined (CONFIG_I2C_MODULE) && !defined

(CONFIG_SND_SOC_WM8731_SPI)

I think this needs extra brackets round the ||'s before the && thus:

Quoted 7 lines
Quoted 2 lines

+#if (defined (CONFIG_I2C) || defined (CONFIG_I2C_MODULE)) && !defined (CONFIG_SND_SOC_WM8731_SPI)

in order to force use of SPI when (CONFIG_SND_SOC_WM8731_SPI) and (CONFIG_I2C) are both defined. Or have we misunderstood the intention? This is in 2 other places also in the patch.

It may be simpler to only have CONFIG_SND_SOC_WM8731_SPI and CONFIG_SND_SOC_WM8731_I2C definitions for all the codec drivers. These would be set by machine Kconfig.

Liam

#19 lore raw

Re: [alsa-devel] [PATCH 3/4] ASOC: WM8731 codec: add SPI support as well as I2C

In reply to Alan Horstmann
Quoted 3 lines · Alan Horstmann

in order to force use of SPI when (CONFIG_SND_SOC_WM8731_SPI) and (CONFIG_I2C) are both defined. Or have we misunderstood the intention? This is in 2 other places also in the patch.

I've reworked the patch to allow a single kernel image to support both I2C and SPI which sidesteps this problem. I'll post this later today.

#24 lore raw

RE: [PATCH 4/4] ALSA: add dummy function to support shared mmap in nommu Blackfin arch

In reply to Takashi Iwai

-----Original Message-----
From: Takashi Iwai [mailto:[email protected]]
Sent: Thursday, August 28, 2008 8:45 PM
To: Bryan Wu
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Cliff Cai
Subject: Re: [PATCH 4/4] ALSA: add dummy function to support shared mmap in nommu Blackfin arch

At Wed, 27 Aug 2008 17:39:28 +0800,

Quoted 14 lines · Bryan Wu

From: Cliff Cai <[email protected]>

---
 sound/core/pcm_native.c |    8 ++++++++
 1 files changed, 8 insertions(+), 0 deletions(-)
sound/core/pcm_native.c index renamed from sound/core/pcm_native.c +0 -0

c49b9d9..cb202a1 100644

sound/core/pcm_native.c out: · line 3394

Quoted 4 lines
sound/core/pcm_native.c +1 -0
@@ -3391,6 +3391,12 @@ out:
 }
 #endif /* CONFIG_SND_SUPPORT_OLD_API */
 
+unsigned long dummy_get_unmapped_area(struct file *file, unsigned

long addr,

sound/core/pcm_native.c out: · line 3395

Quoted 1 line
sound/core/pcm_native.c +1 -0
+				      unsigned long len, unsigned long

pgoff, unsigned long

Quoted 5 lines
sound/core/pcm_native.c +3 -0
+flags) {
+	return 0;
+}
 

Always zero is confirmed to work for other architectures, too?

I'm not sure about this but for non-mmu arch it's enough and harmless.

sound/core/pcm_native.c const struct file_operations snd_pcm_f_ops[2] =

Quoted 4 lines

/*
* Register section
*/

sound/core/pcm_native.c +0 -0
@@ -3407,6 +3413,7 @@ const struct file_operations snd_pcm_f_ops[2] =

{

sound/core/pcm_native.c const struct file_operations snd_pcm_f_ops[2] =

Quoted 8 lines
sound/core/pcm_native.c +1 -0
 		.compat_ioctl = 	snd_pcm_ioctl_compat,
 		.mmap =			snd_pcm_mmap,
 		.fasync =		snd_pcm_fasync,
+		.get_unmapped_area =	dummy_get_unmapped_area,
 	},
 	{
 		.owner =		THIS_MODULE,
@@ -3419,5 +3426,6 @@ const struct file_operations snd_pcm_f_ops[2] =

{

Quoted 8 lines
sound/core/pcm_native.c +1 -0
 		.compat_ioctl = 	snd_pcm_ioctl_compat,
 		.mmap =			snd_pcm_mmap,
 		.fasync =		snd_pcm_fasync,
+		.get_unmapped_area =	dummy_get_unmapped_area,
 	}
 };

I don't think adding this dummy get_unmapped_area unconditionally for

every driver is good. This overrides the default

Quoted 1 line

mm->get_unmaped_area.

But without this dummy function,shared mmap on nommu arch would fail,refer to validate_mmap_request() in mm/nommu.c.
May be we can add a kernel config item to include or not include this function depending on non-mmu or mmu arch.

Cliff

#25 lore raw

Re: [PATCH 4/4] ALSA: add dummy function to support shared mmap in nommu Blackfin arch

At Tue, 2 Sep 2008 11:16:37 +0800,

Quoted 11 lines · Cliff

Review const struct file_operations snd_pcm_f_ops[2] =

Quoted 3 lines
(quoted diff) +0 -0
@@ -3419,5 +3426,6 @@ const struct file_operations snd_pcm_f_ops[2] =

{

Quoted 6 lines
sound/core/pcm_native.c +1 -0
 		.compat_ioctl = 	snd_pcm_ioctl_compat,
 		.mmap =			snd_pcm_mmap,
 		.fasync =		snd_pcm_fasync,
+		.get_unmapped_area =	dummy_get_unmapped_area,
 	}
 };
Quoted 5 lines
Quoted 1 line

I don't think adding this dummy get_unmapped_area unconditionally for

every driver is good. This overrides the default

Quoted 1 line

mm->get_unmaped_area.

But without this dummy function,shared mmap on nommu arch would fail,refer to validate_mmap_request() in mm/nommu.c.

Yes, I know it's needed for nommu. That's why I wrote "unconditionally" in the above.

Quoted 2 lines

May be we can add a kernel config item to include or not include this function depending on non-mmu or mmu arch.

Checking CONFIG_MMU may suffice?

Takashi

author
#26 lore raw

Re: [PATCH 4/4] ALSA: add dummy function to support shared mmap in nommu Blackfin arch

Quoted 19 lines · Takashi Iwai

At Tue, 2 Sep 2008 11:16:37 +0800,

Quoted 11 lines · Cliff

Review const struct file_operations snd_pcm_f_ops[2] =

Quoted 3 lines
(quoted diff) +0 -0
@@ -3419,5 +3426,6 @@ const struct file_operations snd_pcm_f_ops[2] =

{

Quoted 6 lines
sound/core/pcm_native.c +1 -0
            .compat_ioctl =         snd_pcm_ioctl_compat,
            .mmap =                 snd_pcm_mmap,
            .fasync =               snd_pcm_fasync,
+           .get_unmapped_area =    dummy_get_unmapped_area,
    }
 };
Quoted 5 lines
Quoted 1 line

I don't think adding this dummy get_unmapped_area unconditionally for

every driver is good. This overrides the default

Quoted 1 line

mm->get_unmaped_area.

But without this dummy function,shared mmap on nommu arch would fail,refer to validate_mmap_request() in mm/nommu.c.

Quoted 8 lines

Yes, I know it's needed for nommu. That's why I wrote "unconditionally" in the above.

Quoted 2 lines

May be we can add a kernel config item to include or not include this function depending on non-mmu or mmu arch.

Checking CONFIG_MMU may suffice?

Right, I post a v2 patch including this checking.

Thanks
-Bryan

#20 lore raw

Re: [PATCH 3/4] ASOC: WM8731 codec: add SPI support as well as I2C

In reply to Mark Brown
Quoted 7 lines · you
Quoted 3 lines · Alan Horstmann

in order to force use of SPI when (CONFIG_SND_SOC_WM8731_SPI) and (CONFIG_I2C) are both defined. Or have we misunderstood the intention? This is in 2 other places also in the patch.

I've reworked the patch to allow a single kernel image to support both I2C and SPI which sidesteps this problem. I'll post this later today.

I am aware am new to the asoc stuff, and hesitate to comment, but it would seem to me that Liams suggestion:

Quoted 5 lines

It may be simpler to only have CONFIG_SND_SOC_WM8731_SPI and CONFIG_SND_SOC_WM8731_I2C definitions for all the codec drivers. These would be set by machine Kconfig.

Liam

is better, since it means one or the other, or both sets of code can be built. Since in most applications the hardware is always wired up on a known bus, it avoids unused code built in. Otherwise we would have to hand edit out sections of code. (CONFIG_I2C) may be set because of other devices on that bus. Does the codec ONLY work in spi master?

Then (CONFIG_SND_SOC_WM8731) is not really needed since it is

CONFIG_SND_SOC_WM8731_I2C || CONFIG_SND_SOC_WM8731_SPI

Essentially, where a hardware device can be connected in different ways needing different code, a config option for each way is needed, rather than being guessed from bus config options.

Alan

#21 lore raw

Re: [PATCH 3/4] ASOC: WM8731 codec: add SPI support as well as I2C

Quoted 8 lines · Alan Horstmann
Quoted 2 lines · you

I've reworked the patch to allow a single kernel image to support both I2C and SPI which sidesteps this problem. I'll post this later today.

I am aware am new to the asoc stuff, and hesitate to comment, but it would seem to me that Liams suggestion:

Quoted 8 lines
Quoted 3 lines

It may be simpler to only have CONFIG_SND_SOC_WM8731_SPI and CONFIG_SND_SOC_WM8731_I2C definitions for all the codec drivers. These would be set by machine Kconfig.

is better, since it means one or the other, or both sets of code can be built. Since in most applications the hardware is always wired up on a known bus, it avoids unused code built in. Otherwise we would have to hand edit out sections of code. (CONFIG_I2C) may be set because of other devices on that

Given the very small amount of code involved in attaching the codec to SPI or I2C I wasn't too worried about the additional cost in the driver itself if the kernel already contains all the bus code. That said, I do agree that it could be useful to have ths level of control and I'd certainly ack a patch which added it.

Note that the drivers will still need to support both simultaneously in order to allow support for multiple boards in a single kernel image (which was the main problem with the original patch). There's quite a push to reduce the number of builds required to get coverage on ARM at the minute partly since it is useful for distributions and partly because it facilitates architecture wide development.

Quoted 1 line

bus. Does the codec ONLY work in spi master?

The SPI_MASTER config option refers to the controller rather than the target - if there is nothing able to act as a SPI master then nothing will be able to control the codec.

Quoted 7 lines

Then (CONFIG_SND_SOC_WM8731) is not really needed since it is

CONFIG_SND_SOC_WM8731_I2C || CONFIG_SND_SOC_WM8731_SPI

Essentially, where a hardware device can be connected in different ways needing different code, a config option for each way is needed, rather than being guessed from bus config options.

I'm not sure I'd go so far as *needed* - it's useful for modular kernels where both I2C and SPI are availaible but one or the other is not loaded in some configurations so you end up pulling the bus core in.

#3 lore raw

RE: [PATCH 1/4] ASOC: Blackfin driver for ALSA SoC framework

In reply to Mark Brown

-----Original Message-----
From: Mark Brown [mailto:[email protected]]
Sent: Wednesday, August 27, 2008 9:49 PM
To: Bryan Wu
Cc: [email protected]; [email protected]; [email protected]; [email protected]; Cliff Cai
Subject: Re: [PATCH 1/4] ASOC: Blackfin driver for ALSA SoC framework

Quoted 4 lines · Bryan Wu

From: Cliff Cai <[email protected]>

As with the other patches in the series this looks good but it has been affected by changes in the ASoC APIs and needs to be updated to reflect current ALSA. The topic/asoc branch of Takashi's tree:

    git://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound-2.6.git

is what's currently queued for 2.6.28.

Other than that, checkpatch-style things and a few more minor issues the main things are the register write interface in /proc and the hardware parameters for the I2S driver. I've not flagged all the checkpatch stuff here.

Can I also suggest splitting this up into a series of patches for easier review - for example, adding the SPORT support first, followed by the AC97 and I2S drivers and then the machine drivers? I'd certainly have appreciated having seen the SPORT support (which appears at the end of the patch) before looking at the AC97 and I2S stuff.

sound/soc/blackfin/Kconfig

Quoted 4 lines
sound/soc/blackfin/Kconfig new file +4 -0
+	depends on BLACKFIN && SND_SOC
+	help
+	  Say Y or M if you want to add support for codecs attached to
+	  the Blackfin SPORT (synchronous serial ports) interface in

slot 16

Review

Quoted 2 lines
(quoted diff) +2 -0
+	  mode (pseudo AC97 interface).
+	  You will also need to select the audio interfaces to support

below.

sound/soc/blackfin/Kconfig

Quoted 3 lines
sound/soc/blackfin/Kconfig new file +3 -0
+
+	  Note:
+	  AC'97 codecs which do not implment the slot-16 mode will not

function

Review

Quoted 1 line
(quoted diff) +1 -0
+	  properly with this driver. This driver is known to work with

the

sound/soc/blackfin/Kconfig line 32

Quoted 1 line
sound/soc/blackfin/Kconfig new file +1 -0
+	  Analog Devices line of AC97 codecs.

Your spelling of AC97 isn't consistent here. The kernel seems to prefer AC97, as do you.

Quoted 5 lines

+ * File: sound/soc/blackfin/bf5xx-ac97-pcm.c
+ * Author: Cliff Cai <[email protected]>
+ *
+ * Created: Tue June 06 2008
+ * Description: Driver for SSM2602 sound chip built in ADSP-BF52xC

Hopefully the driver is more generic than that?

sound/soc/blackfin/bf5xx-ac97-pcm.c

Quoted 4 lines
sound/soc/blackfin/bf5xx-ac97-pcm.c new file +4 -0
+static int bf5xx_pcm_hw_params(struct snd_pcm_substream *substream,
+	struct snd_pcm_hw_params *params)
+{
+	size_t size = bf5xx_pcm_hardware.buffer_bytes_max *

sizeof(struct

Quoted 1 line

+ac97_frame)/4;

Checkpatch picks up on this and quite a few other places being over 80 columns.

sound/soc/blackfin/bf5xx-ac97-pcm.c line 165

Quoted 9 lines
sound/soc/blackfin/bf5xx-ac97-pcm.c new file +8 -0
+static int bf5xx_pcm_trigger(struct snd_pcm_substream *substream, int
 
+cmd) {
+	struct snd_pcm_runtime *runtime = substream->runtime;
+	struct sport_device *sport = runtime->private_data;
+	int ret = 0;
+
+	pr_debug("%s %s\n", substream->stream?"Capture":"Playback", \
+			cmd?" start":" stop");

This looks wrong - there's rather more options for cmd, for example, and you're making assumptions about the value of SNDRV_PMC_STREAM_PLAYBACK.

Review

Quoted 3 lines
(quoted diff) +2 -0
+/*Need to allocate local buffer when enable MMAP for SPORT working in
 
+TMD mode(include AC97).*/

Indentation?

Quoted 13 lines
sound/soc/blackfin/bf5xx-ac97.c new file +12 -0
+	ret = sport_config_rx(sport_handle, IRFS, 0xF, 0, (16*16-1));
+
+	if (ret) {
+		printk(KERN_ERR "SPORT is busy!\n");
+		return -EBUSY;
+	}
+	ret = sport_config_tx(sport_handle, ITFS, 0xF, 0, (16*16-1));
+
+	if (ret) {
+		printk(KERN_ERR "SPORT is busy!\n");
+		return -EBUSY;
+	}
Quoted 3 lines

Shouldn't this undo the previous sport_confix_rx() on error?

Also, the use of blank lines is a bit funny here - I'd expect the blank

before rather than after the function calls.

Quoted 14 lines
sound/soc/blackfin/bf5xx-ac97.c new file +13 -0
+	/*SPORT works in TDM mode to simulate AC97 transfers*/
+	ret = sport_set_multichannel(sport_handle, 16, 0x1F, 1);
+
+	if (ret) {
+		printk(KERN_ERR "SPORT is busy!\n");
+		return -EBUSY;
+	}
+	ret = sport_config_rx(sport_handle, IRFS, 0xF, 0, (16*16-1));
+
+	if (ret) {
+		printk(KERN_ERR "SPORT is busy!\n");
+		return -EBUSY;
+	}
Quoted 1 line

Again, odd blank lines and presumably there needs to be something to

undo things on error?

t's not necessary to do anything else on error, these functions only set registers.

Review

Quoted 1 line
(quoted diff) +1 -0
+	/*  TX and RX are not independent,they are enabled at the same

time,

Review

Quoted 1 line
(quoted diff) +1 -0
+	 *  even if only one side is running.So,we need to configure

both of them in advance.

Quoted 4 lines
sound/soc/blackfin/bf5xx-i2s.c new file +2 -0
+	 *  CPU DAI format:I2S,word length:32 bit,slave mode.
+	 */

Are the RX and TX clocks independant? If not you should probably tell

user space about the constraint in startup(), forcing the second stream that's opened to use the

Quoted 1 line

same configuration as the first - take a look at the fsl_ssi driver or

the wm8903 driver for examples of how to do this.

TX and RX Clocks are also not independent,currently,in order to implement full duplex,we have to enable both RX and TX side even if there is only a steam is opened,
And make the other side running on a dummy buffer,so all registers cann't be configured any more. when the second stream is opened we just switch the DMA form dummy buffer to the normal data buffer.

Quoted 1 line

I'm also not seeing the code that configures the sample rate anywhere -

but then it looks like the driver only support slave mode ATM? That's what the machine driver is

Quoted 1 line

using. There should still be a set_fmt() to document what's supported

if nothing else.

Yes ,the codec runs in master mode and provides bit clock..Do you mean just implement a dummy set_fmt() with comments for CPU DAI, Refer to my description above,it's not possible to configure anything for CPU DAI after a stream is opened ,that why we have to configure CPU DAI before any stream is opened.

Cliff

#4 lore raw

Re: [PATCH 1/4] ASOC: Blackfin driver for ALSA SoC framework

On Wed, Sep 03, 2008 at 12:09:49PM +0800, Cai, Cliff wrote:

Cliff, please fix your mail client configuration - the formatting of your reply makes little (if any) distinction between the text of my original mail which makes your message difficult to read.

Quoted 8 lines

-----Original Message-----
From: Mark Brown [mailto:[email protected]]
Sent: Wednesday, August 27, 2008 9:49 PM
To: Bryan Wu
Cc: [email protected]; [email protected]; [email protected]; [email protected]; Cliff Cai
Subject: Re: [PATCH 1/4] ASOC: Blackfin driver for ALSA SoC framework

Quoted 8 lines
Quoted 3 lines · Bryan Wu

From: Cliff Cai <[email protected]>

Again, odd blank lines and presumably there needs to be something to

undo things on error?

t's not necessary to do anything else on error, these functions only set registers.

And none of these settings will leave things so that the port looks busy or anything like that?

Quoted 6 lines

TX and RX Clocks are also not independent,currently,in order to implement full duplex,we have to enable both RX and TX side even if there is only a steam is opened,
And make the other side running on a dummy buffer,so all registers cann't be configured any more. when the second stream is opened we just switch the DMA form dummy buffer to the normal data buffer.

Right, in that case your driver should use constraints to stop applications trying to configure the capture and playback sides differently.

Quoted 8 lines
Quoted 1 line

I'm also not seeing the code that configures the sample rate anywhere -

but then it looks like the driver only support slave mode ATM? That's what the machine driver is

Quoted 1 line

using. There should still be a set_fmt() to document what's supported

if nothing else.

Yes ,the codec runs in master mode and provides bit clock..Do you mean just implement a dummy set_fmt() with comments for CPU DAI,

It shouldn't just be a dummy - it should reject DAI formats other than CBS_CFM if that is the only configuration that's supported.

Quoted 3 lines

Refer to my description above,it's not possible to configure anything for CPU DAI after a stream is opened ,that why we have to configure CPU DAI before any stream is opened.

This is normal (and generally trying would result in audio artifacts if you try), but normally there is at least some configuration that can be done before the stream actually starts running.

#5 lore raw

RE: [alsa-devel] [PATCH 1/4] ASOC: Blackfin driver for ALSA SoC framework

Quoted 27 lines

Date: Wed, 3 Sep 2008 11:38:52 +0100
From: [email protected]
To: [email protected]
CC: [email protected]; [email protected]; [email protected]; [email protected]
Subject: Re: [alsa-devel] [PATCH 1/4] ASOC: Blackfin driver for ALSA SoC framework

On Wed, Sep 03, 2008 at 12:09:49PM +0800, Cai, Cliff wrote:

Cliff, please fix your mail client configuration - the formatting of your reply makes little (if any) distinction between the text of my original mail which makes your message difficult to read.

Quoted 10 lines

-----Original Message-----
From: Mark Brown [mailto:[email protected]]
Sent: Wednesday, August 27, 2008 9:49 PM
To: Bryan Wu
Cc: [email protected]; [email protected]; [email protected]; [email protected]; Cliff Cai
Subject: Re: [PATCH 1/4] ASOC: Blackfin driver for ALSA SoC framework

Quoted 1 line · Bryan Wu

From: Cliff Cai

Quoted 8 lines
Quoted 5 lines
Quoted 1 line

Again, odd blank lines and presumably there needs to be something to

undo things on error?

t's not necessary to do anything else on error, these functions only set registers.

And none of these settings will leave things so that the port looks busy or anything like that?

No,they are called just to configure somthing but won't start it,it only fails when the port is busy.

Quoted 28 lines
Quoted 7 lines

TX and RX Clocks are also not independent,currently,in order to implement full duplex,we have to enable both RX and TX side even if there is only a steam is opened,
And make the other side running on a dummy buffer,so all registers cann't be configured any more. when the second stream is opened we just switch the DMA form dummy buffer to the normal data buffer.

Right, in that case your driver should use constraints to stop applications trying to configure the capture and playback sides differently.

Quoted 8 lines
Quoted 1 line

I'm also not seeing the code that configures the sample rate anywhere -

but then it looks like the driver only support slave mode ATM? That's what the machine driver is

Quoted 1 line

using. There should still be a set_fmt() to document what's supported

if nothing else.

Yes ,the codec runs in master mode and provides bit clock..Do you mean just implement a dummy set_fmt() with comments for CPU DAI,

It shouldn't just be a dummy - it should reject DAI formats other than CBS_CFM if that is the only configuration that's supported.

Quoted 3 lines

Refer to my description above,it's not possible to configure anything for CPU DAI after a stream is opened ,that why we have to configure CPU DAI before any stream is opened.

Quoted 7 lines

This is normal (and generally trying would result in audio artifacts if you try), but normally there is at least some configuration that can be done before the stream actually starts running.
_______________________________________________
Alsa-devel mailing list
[email protected]
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel

_________________________________________________________________
一边聊天一边快速搜索,并把结果共享给好友,立刻试试!
http://im.live.cn/Share/18.htm