Skip to contentSkip to conversation

ASoC updates for 2.6.30

PATCH New Mark Brown 2 participants 19 messages Feb 18, 2009

Subsystems (6)
lore
Share & tools
lore

Mark Brown

author
#0 lore raw

The following changes since commit f1464ede550b8fda75086cb9bacf8d60fc9f6780:
Takashi Iwai (1):

        Merge branch 'for-2.6.30' of git://git.kernel.org/.../broonie/sound-2.6 into topic/asoc

are available in the git repository at:

git://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound-2.6.git for-2.6.30

Kevin Hilman (1):
ASoC: Fix DaVinci module unload error

Mark Brown (9):
ASoC: Remove version display from the WM8731 driver
ASoC: Clean up WM8731 bias level configuration
ASoC: Improve diagnostics for AT91SAM9G20-EK probe
ASoC: Check machine type before loading on AT91SAM9G20-EK
ASoC: Actively manage MCLK for AT91SAM9G20-EK
ASoC: Rename AT91SAMG20-EK for applications
ASoC: Shuffle WM8731 SPI and I2C device registration
ASoC: Refactor WM8731 device registration
ASoC: Remove version display from the WM8753 driver

Paul Fertser (1):
ASoC: Fix WM8753 DAIs unregistering

 sound/soc/atmel/sam9g20_wm8731.c   |  124 +++++++++++--
 sound/soc/codecs/wm8731.c          |  377 ++++++++++++++++--------------------
 sound/soc/codecs/wm8731.h          |    6 -
 sound/soc/codecs/wm8753.c          |    9 +-
 sound/soc/davinci/davinci-evm.c    |    3 +-
 sound/soc/davinci/davinci-sffsdr.c |    3 +-
 sound/soc/pxa/corgi.c              |   43 ++++-
 sound/soc/pxa/poodle.c             |   41 ++++-
 8 files changed, 361 insertions(+), 245 deletions(-)
author
#1 lore raw

PATCH 1/11 ASoC: Fix DaVinci module unload error

From: Kevin Hilman <[email protected]>

Fix for the error when the audio module is unloaded. On unregistering the platform_device, platform_device_release will free the platform data.If platform data is static the kernel panics when it is freed. Instead use the platform device helper function to add data.

This change has been tested on DM644x EVM, DM644x SFFSDR and DM355 EVM.

---
 sound/soc/davinci/davinci-evm.c    |    3 ++-
 sound/soc/davinci/davinci-sffsdr.c |    3 ++-
 2 files changed, 4 insertions(+), 2 deletions(-)
sound/soc/davinci/davinci-evm.c +2 -1
index 54851f3..9b90b34 100644
@@ -186,7 +186,8 @@ static int __init evm_init(void)
 
 	platform_set_drvdata(evm_snd_device, &evm_snd_devdata);
 	evm_snd_devdata.dev = &evm_snd_device->dev;
-	evm_snd_device->dev.platform_data = &evm_snd_data;
+	platform_device_add_data(evm_snd_device, &evm_snd_data,
+				 sizeof(evm_snd_data));
 
 	ret = platform_device_add_resources(evm_snd_device, evm_snd_resources,
 					    ARRAY_SIZE(evm_snd_resources));
sound/soc/davinci/davinci-sffsdr.c +2 -1
index 50baef1..0bf81ab 100644
@@ -141,7 +141,8 @@ static int __init sffsdr_init(void)
 
 	platform_set_drvdata(sffsdr_snd_device, &sffsdr_snd_devdata);
 	sffsdr_snd_devdata.dev = &sffsdr_snd_device->dev;
-	sffsdr_snd_device->dev.platform_data = &sffsdr_snd_data;
+	platform_device_add_data(sffsdr_snd_device, &sffsdr_snd_data,
+				 sizeof(sffsdr_snd_data));
 
 	ret = platform_device_add_resources(sffsdr_snd_device,
 					    sffsdr_snd_resources,
Signature · 1 line
1.5.6.3
author
#2 lore raw

PATCH 2/11 ASoC: Fix WM8753 DAIs unregistering

In reply to Mark Brown

From: Paul Fertser <[email protected]>

WM8753 uses a tricky way to switch DAIs "on the fly", for that it registers 2 dummy DAIs and substitutes them depending on mixer control.

List element of registered dummy DAIs should be preserved to allow unregistering of DAIs on module unload.

---
 sound/soc/codecs/wm8753.c |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)
sound/soc/codecs/wm8753.c +5 -0
index 6f9e6be..dc6042c 100644
@@ -1451,30 +1451,35 @@ static void wm8753_set_dai_mode(struct snd_soc_codec *codec, unsigned int mode)
 	if (mode < 4) {
 		int playback_active, capture_active, codec_active, pop_wait;
 		void *private_data;
+		struct list_head list;
 
 		playback_active = wm8753_dai[0].playback.active;
 		capture_active = wm8753_dai[0].capture.active;
 		codec_active = wm8753_dai[0].active;
 		private_data = wm8753_dai[0].private_data;
 		pop_wait = wm8753_dai[0].pop_wait;
+		list = wm8753_dai[0].list;
 		wm8753_dai[0] = wm8753_all_dai[mode << 1];
 		wm8753_dai[0].playback.active = playback_active;
 		wm8753_dai[0].capture.active = capture_active;
 		wm8753_dai[0].active = codec_active;
 		wm8753_dai[0].private_data = private_data;
 		wm8753_dai[0].pop_wait = pop_wait;
+		wm8753_dai[0].list = list;
 
 		playback_active = wm8753_dai[1].playback.active;
 		capture_active = wm8753_dai[1].capture.active;
 		codec_active = wm8753_dai[1].active;
 		private_data = wm8753_dai[1].private_data;
 		pop_wait = wm8753_dai[1].pop_wait;
+		list = wm8753_dai[1].list;
 		wm8753_dai[1] = wm8753_all_dai[(mode << 1) + 1];
 		wm8753_dai[1].playback.active = playback_active;
 		wm8753_dai[1].capture.active = capture_active;
 		wm8753_dai[1].active = codec_active;
 		wm8753_dai[1].private_data = private_data;
 		wm8753_dai[1].pop_wait = pop_wait;
+		wm8753_dai[1].list = list;
 	}
 	wm8753_dai[0].codec = codec;
 	wm8753_dai[1].codec = codec;
Signature · 1 line
1.5.6.3
author
#3 lore raw

PATCH 3/11 ASoC: Remove version display from the WM8731 driver

In reply to Mark Brown

It makes boot a bit more noisy and I never remember to update it.

---
 sound/soc/codecs/wm8731.c |    4 ----
 1 files changed, 0 insertions(+), 4 deletions(-)
sound/soc/codecs/wm8731.c +0 -4
index 0150fe5..816e5bf 100644
@@ -29,8 +29,6 @@
 
 #include "wm8731.h"
 
-#define WM8731_VERSION "0.13"
-
 struct snd_soc_codec_device soc_codec_dev_wm8731;
 
 /* codec private data */
@@ -702,8 +700,6 @@ static int wm8731_probe(struct platform_device *pdev)
 	struct wm8731_priv *wm8731;
 	int ret = 0;
 
-	pr_info("WM8731 Audio Codec %s", WM8731_VERSION);
-
 	setup = socdev->codec_data;
 	codec = kzalloc(sizeof(struct snd_soc_codec), GFP_KERNEL);
 	if (codec == NULL)
Signature · 1 line
1.5.6.3
author
#4 lore raw

PATCH 4/11 ASoC: Clean up WM8731 bias level configuration

In reply to Mark Brown

The WM8731 bias level configuration function was written slightly obscurely - streamline the code a little and refresh the comments.

---
 sound/soc/codecs/wm8731.c |    8 +++-----
 1 files changed, 3 insertions(+), 5 deletions(-)
sound/soc/codecs/wm8731.c +3 -5
index 816e5bf..c6db677 100644
@@ -396,21 +396,19 @@ static int wm8731_set_dai_fmt(struct snd_soc_dai *codec_dai,
 static int wm8731_set_bias_level(struct snd_soc_codec *codec,
 				 enum snd_soc_bias_level level)
 {
-	u16 reg = wm8731_read_reg_cache(codec, WM8731_PWR) & 0xff7f;
+	u16 reg;
 
 	switch (level) {
 	case SND_SOC_BIAS_ON:
-		/* vref/mid, osc on, dac unmute */
-		wm8731_write(codec, WM8731_PWR, reg);
 		break;
 	case SND_SOC_BIAS_PREPARE:
 		break;
 	case SND_SOC_BIAS_STANDBY:
-		/* everything off except vref/vmid, */
+		/* Clear PWROFF, gate CLKOUT, everything else as-is */
+		reg = wm8731_read_reg_cache(codec, WM8731_PWR) & 0xff7f;
 		wm8731_write(codec, WM8731_PWR, reg | 0x0040);
 		break;
 	case SND_SOC_BIAS_OFF:
-		/* everything off, dac mute, inactive */
 		wm8731_write(codec, WM8731_ACTIVE, 0x0);
 		wm8731_write(codec, WM8731_PWR, 0xffff);
 		break;
Signature · 1 line
1.5.6.3
author
#5 lore raw

PATCH 5/11 ASoC: Improve diagnostics for AT91SAM9G20-EK probe

In reply to Mark Brown

We should display an error by default if we fail to register.

---
 sound/soc/atmel/sam9g20_wm8731.c |    7 +++----
 1 files changed, 3 insertions(+), 4 deletions(-)
sound/soc/atmel/sam9g20_wm8731.c +3 -4
index 6ea04be..be3f923 100644
@@ -273,6 +273,7 @@ static int __init at91sam9g20ek_init(void)
 	 */
 	ssc = ssc_request(0);
 	if (IS_ERR(ssc)) {
+		printk(KERN_ERR "ASoC: Failed to request SSC 0\n");
 		ret = PTR_ERR(ssc);
 		ssc = NULL;
 		goto err_ssc;
@@ -281,8 +282,7 @@ static int __init at91sam9g20ek_init(void)
 
 	at91sam9g20ek_snd_device = platform_device_alloc("soc-audio", -1);
 	if (!at91sam9g20ek_snd_device) {
-		printk(KERN_DEBUG
-				"platform device allocation failed\n");
+		printk(KERN_ERR "ASoC: Platform device allocation failed\n");
 		ret = -ENOMEM;
 	}
 
@@ -292,8 +292,7 @@ static int __init at91sam9g20ek_init(void)
 
 	ret = platform_device_add(at91sam9g20ek_snd_device);
 	if (ret) {
-		printk(KERN_DEBUG
-				"platform device allocation failed\n");
+		printk(KERN_ERR "ASoC: Platform device allocation failed\n");
 		platform_device_put(at91sam9g20ek_snd_device);
 	}
 
Signature · 1 line
1.5.6.3
author
#6 lore raw

PATCH 6/11 ASoC: Check machine type before loading on AT91SAM9G20-EK

In reply to Mark Brown
---
 sound/soc/atmel/sam9g20_wm8731.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)
sound/soc/atmel/sam9g20_wm8731.c +4 -0
index be3f923..b7efdc8 100644
@@ -45,6 +45,7 @@
 #include <sound/soc.h>
 #include <sound/soc-dapm.h>
 
+#include <asm/mach-types.h>
 #include <mach/hardware.h>
 #include <mach/gpio.h>
 
@@ -268,6 +269,9 @@ static int __init at91sam9g20ek_init(void)
 	struct ssc_device *ssc = NULL;
 	int ret;
 
+	if (!machine_is_at91sam9g20ek())
+		return -ENODEV;
+
 	/*
 	 * Request SSC device
 	 */
Signature · 1 line
1.5.6.3
author
#7 lore raw

PATCH 7/11 ASoC: Actively manage MCLK for AT91SAM9G20-EK

In reply to Mark Brown

We have software control of the MCLK for the WM8731 so save a bit of power by actively managing it within the machine driver, enabling it only while the codec is active.

Once ASoC supports multiple boards and doesn't require the soc-audio device the initial clock setup should be pushed down into the arch/arm code but for now this reduces merge issues.

---
 sound/soc/atmel/sam9g20_wm8731.c |   68 ++++++++++++++++++++++++++++++++++++--
 1 files changed, 65 insertions(+), 3 deletions(-)
sound/soc/atmel/sam9g20_wm8731.c +65 -3
index b7efdc8..ab32514 100644
@@ -53,6 +53,9 @@
 #include "atmel-pcm.h"
 #include "atmel_ssc_dai.h"
 
+#define MCLK_RATE 12000000
+
+static struct clk *mclk;
 
 static int at91sam9g20ek_startup(struct snd_pcm_substream *substream)
 {
@@ -60,11 +63,12 @@ static int at91sam9g20ek_startup(struct snd_pcm_substream *substream)
 	struct snd_soc_dai *codec_dai = rtd->dai->codec_dai;
 	int ret;
 
-	/* codec system clock is supplied by PCK0, set to 12MHz */
 	ret = snd_soc_dai_set_sysclk(codec_dai, WM8731_SYSCLK,
-		12000000, SND_SOC_CLOCK_IN);
-	if (ret < 0)
+		MCLK_RATE, SND_SOC_CLOCK_IN);
+	if (ret < 0) {
+		clk_disable(mclk);
 		return ret;
+	}
 
 	return 0;
 }
@@ -190,6 +194,31 @@ static struct snd_soc_ops at91sam9g20ek_ops = {
 	.shutdown = at91sam9g20ek_shutdown,
 };
 
+static int at91sam9g20ek_set_bias_level(struct snd_soc_card *card,
+					enum snd_soc_bias_level level)
+{
+	static int mclk_on;
+	int ret = 0;
+
+	switch (level) {
+	case SND_SOC_BIAS_ON:
+	case SND_SOC_BIAS_PREPARE:
+		if (!mclk_on)
+			ret = clk_enable(mclk);
+		if (ret == 0)
+			mclk_on = 1;
+		break;
+
+	case SND_SOC_BIAS_OFF:
+	case SND_SOC_BIAS_STANDBY:
+		if (mclk_on)
+			clk_disable(mclk);
+		mclk_on = 0;
+		break;
+	}
+
+	return ret;
+}
 
 static const struct snd_soc_dapm_widget at91sam9g20ek_dapm_widgets[] = {
 	SND_SOC_DAPM_MIC("Int Mic", NULL),
@@ -248,6 +277,7 @@ static struct snd_soc_card snd_soc_at91sam9g20ek = {
 	.platform = &atmel_soc_platform,
 	.dai_link = &at91sam9g20ek_dai,
 	.num_links = 1,
+	.set_bias_level = at91sam9g20ek_set_bias_level,
 };
 
 static struct wm8731_setup_data at91sam9g20ek_wm8731_setup = {
@@ -267,12 +297,38 @@ static int __init at91sam9g20ek_init(void)
 {
 	struct atmel_ssc_info *ssc_p = at91sam9g20ek_dai.cpu_dai->private_data;
 	struct ssc_device *ssc = NULL;
+	struct clk *pllb;
 	int ret;
 
 	if (!machine_is_at91sam9g20ek())
 		return -ENODEV;
 
 	/*
+	 * Codec MCLK is supplied by PCK0 - set it up.
+	 */
+	mclk = clk_get(NULL, "pck0");
+	if (IS_ERR(mclk)) {
+		printk(KERN_ERR "ASoC: Failed to get MCLK\n");
+		ret = PTR_ERR(mclk);
+		goto err;
+	}
+
+	pllb = clk_get(NULL, "pllb");
+	if (IS_ERR(mclk)) {
+		printk(KERN_ERR "ASoC: Failed to get PLLB\n");
+		ret = PTR_ERR(mclk);
+		goto err_mclk;
+	}
+	ret = clk_set_parent(mclk, pllb);
+	clk_put(pllb);
+	if (ret != 0) {
+		printk(KERN_ERR "ASoC: Failed to set MCLK parent\n");
+		goto err_mclk;
+	}
+
+	clk_set_rate(mclk, MCLK_RATE);
+
+	/*
 	 * Request SSC device
 	 */
 	ssc = ssc_request(0);
@@ -303,6 +359,10 @@ static int __init at91sam9g20ek_init(void)
 	return ret;
 
 err_ssc:
+err_mclk:
+	clk_put(mclk);
+	mclk = NULL;
+err:
 	return ret;
 }
 
@@ -320,6 +380,8 @@ static void __exit at91sam9g20ek_exit(void)
 
 	platform_device_unregister(at91sam9g20ek_snd_device);
 	at91sam9g20ek_snd_device = NULL;
+	clk_put(mclk);
+	mclk = NULL;
 }
 
 module_init(at91sam9g20ek_init);
Signature · 1 line
1.5.6.3
author
#8 lore raw

PATCH 8/11 ASoC: Rename AT91SAMG20-EK for applications

In reply to Mark Brown

This is a bit more idiomatic and makes identifying a configuration based on the board type work better.

---
 sound/soc/atmel/sam9g20_wm8731.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
sound/soc/atmel/sam9g20_wm8731.c +1 -1
index ab32514..aa52423 100644
@@ -273,7 +273,7 @@ static struct snd_soc_dai_link at91sam9g20ek_dai = {
 };
 
 static struct snd_soc_card snd_soc_at91sam9g20ek = {
-	.name = "WM8731",
+	.name = "AT91SAMG20-EK",
 	.platform = &atmel_soc_platform,
 	.dai_link = &at91sam9g20ek_dai,
 	.num_links = 1,
Signature · 1 line
1.5.6.3
author
#9 lore raw

PATCH 9/11 ASoC: Shuffle WM8731 SPI and I2C device registration

In reply to Mark Brown

This is a pure code motion patch intended to improve reviewability of a following patch moving WM8731 to use more standard device registration.

---
 sound/soc/codecs/wm8731.c |  215 +++++++++++++++++++++++---------------------
 1 files changed, 112 insertions(+), 103 deletions(-)
sound/soc/codecs/wm8731.c +112 -103
index c6db677..3ff971a 100644
@@ -36,6 +36,11 @@ struct wm8731_priv {
 	unsigned int sysclk;
 };
 
+#ifdef CONFIG_SPI_MASTER
+static int wm8731_spi_write(struct spi_device *spi, const char *data, int len);
+static struct spi_driver wm8731_spi_driver;
+#endif
+
 /*
  * wm8731 register cache
  * We can't read the WM8731 register space when we are
@@ -544,54 +549,9 @@ pcm_err:
 
 static struct snd_soc_device *wm8731_socdev;
 
-#if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE)
-
-/*
- * WM8731 2 wire address is determined by GPIO5
- * state during powerup.
- *    low  = 0x1a
- *    high = 0x1b
- */
-
-static int wm8731_i2c_probe(struct i2c_client *i2c,
-			    const struct i2c_device_id *id)
-{
-	struct snd_soc_device *socdev = wm8731_socdev;
-	struct snd_soc_codec *codec = socdev->card->codec;
-	int ret;
-
-	i2c_set_clientdata(i2c, codec);
-	codec->control_data = i2c;
-
-	ret = wm8731_init(socdev);
-	if (ret < 0)
-		pr_err("failed to initialise WM8731\n");
-
-	return ret;
-}
 
-static int wm8731_i2c_remove(struct i2c_client *client)
-{
-	struct snd_soc_codec *codec = i2c_get_clientdata(client);
-	kfree(codec->reg_cache);
-	return 0;
-}
-
-static const struct i2c_device_id wm8731_i2c_id[] = {
-	{ "wm8731", 0 },
-	{ }
-};
-MODULE_DEVICE_TABLE(i2c, wm8731_i2c_id);
-
-static struct i2c_driver wm8731_i2c_driver = {
-	.driver = {
-		.name = "WM8731 I2C Codec",
-		.owner = THIS_MODULE,
-	},
-	.probe =    wm8731_i2c_probe,
-	.remove =   wm8731_i2c_remove,
-	.id_table = wm8731_i2c_id,
-};
+#if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE)
+static struct i2c_driver wm8731_i2c_driver;
 
 static int wm8731_add_i2c_device(struct platform_device *pdev,
 				 const struct wm8731_setup_data *setup)
@@ -634,62 +594,6 @@ err_driver:
 }
 #endif
 
-#if defined(CONFIG_SPI_MASTER)
-static int __devinit wm8731_spi_probe(struct spi_device *spi)
-{
-	struct snd_soc_device *socdev = wm8731_socdev;
-	struct snd_soc_codec *codec = socdev->card->codec;
-	int ret;
-
-	codec->control_data = spi;
-
-	ret = wm8731_init(socdev);
-	if (ret < 0)
-		dev_err(&spi->dev, "failed to initialise WM8731\n");
-
-	return ret;
-}
-
-static int __devexit wm8731_spi_remove(struct spi_device *spi)
-{
-	return 0;
-}
-
-static struct spi_driver wm8731_spi_driver = {
-	.driver = {
-		.name	= "wm8731",
-		.bus	= &spi_bus_type,
-		.owner	= THIS_MODULE,
-	},
-	.probe		= wm8731_spi_probe,
-	.remove		= __devexit_p(wm8731_spi_remove),
-};
-
-static int wm8731_spi_write(struct spi_device *spi, const char *data, int len)
-{
-	struct spi_transfer t;
-	struct spi_message m;
-	u8 msg[2];
-
-	if (len <= 0)
-		return 0;
-
-	msg[0] = data[0];
-	msg[1] = data[1];
-
-	spi_message_init(&m);
-	memset(&t, 0, (sizeof t));
-
-	t.tx_buf = &msg[0];
-	t.len = len;
-
-	spi_message_add_tail(&t, &m);
-	spi_sync(spi, &m);
-
-	return len;
-}
-#endif /* CONFIG_SPI_MASTER */
-
 static int wm8731_probe(struct platform_device *pdev)
 {
 	struct snd_soc_device *socdev = platform_get_drvdata(pdev);
@@ -772,6 +676,111 @@ struct snd_soc_codec_device soc_codec_dev_wm8731 = {
 };
 EXPORT_SYMBOL_GPL(soc_codec_dev_wm8731);
 
+#if defined(CONFIG_SPI_MASTER)
+static int __devinit wm8731_spi_probe(struct spi_device *spi)
+{
+	struct snd_soc_device *socdev = wm8731_socdev;
+	struct snd_soc_codec *codec = socdev->card->codec;
+	int ret;
+
+	codec->control_data = spi;
+
+	ret = wm8731_init(socdev);
+	if (ret < 0)
+		dev_err(&spi->dev, "failed to initialise WM8731\n");
+
+	return ret;
+}
+
+static int __devexit wm8731_spi_remove(struct spi_device *spi)
+{
+	return 0;
+}
+
+static struct spi_driver wm8731_spi_driver = {
+	.driver = {
+		.name	= "wm8731",
+		.bus	= &spi_bus_type,
+		.owner	= THIS_MODULE,
+	},
+	.probe		= wm8731_spi_probe,
+	.remove		= __devexit_p(wm8731_spi_remove),
+};
+
+static int wm8731_spi_write(struct spi_device *spi, const char *data, int len)
+{
+	struct spi_transfer t;
+	struct spi_message m;
+	u8 msg[2];
+
+	if (len <= 0)
+		return 0;
+
+	msg[0] = data[0];
+	msg[1] = data[1];
+
+	spi_message_init(&m);
+	memset(&t, 0, (sizeof t));
+
+	t.tx_buf = &msg[0];
+	t.len = len;
+
+	spi_message_add_tail(&t, &m);
+	spi_sync(spi, &m);
+
+	return len;
+}
+#endif /* CONFIG_SPI_MASTER */
+
+#if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE)
+/*
+ * WM8731 2 wire address is determined by GPIO5
+ * state during powerup.
+ *    low  = 0x1a
+ *    high = 0x1b
+ */
+
+static int wm8731_i2c_probe(struct i2c_client *i2c,
+			    const struct i2c_device_id *id)
+{
+	struct snd_soc_device *socdev = wm8731_socdev;
+	struct snd_soc_codec *codec = socdev->card->codec;
+	int ret;
+
+	i2c_set_clientdata(i2c, codec);
+	codec->control_data = i2c;
+
+	ret = wm8731_init(socdev);
+	if (ret < 0)
+		pr_err("failed to initialise WM8731\n");
+
+	return ret;
+}
+
+static int wm8731_i2c_remove(struct i2c_client *client)
+{
+	struct snd_soc_codec *codec = i2c_get_clientdata(client);
+	kfree(codec->reg_cache);
+	return 0;
+}
+
+static const struct i2c_device_id wm8731_i2c_id[] = {
+	{ "wm8731", 0 },
+	{ }
+};
+MODULE_DEVICE_TABLE(i2c, wm8731_i2c_id);
+
+static struct i2c_driver wm8731_i2c_driver = {
+	.driver = {
+		.name = "WM8731 I2C Codec",
+		.owner = THIS_MODULE,
+	},
+	.probe =    wm8731_i2c_probe,
+	.remove =   wm8731_i2c_remove,
+	.id_table = wm8731_i2c_id,
+};
+#endif
+
 static int __init wm8731_modinit(void)
 {
 	return snd_soc_register_dai(&wm8731_dai);
Signature · 1 line
1.5.6.3
author
#10 lore raw

PATCH 10/11 ASoC: Refactor WM8731 device registration

In reply to Mark Brown

Move the WM8731 driver to use a more standard device registration scheme where the device can be registered independantly of the ASoC probe.

As a transition measure push the current manual code for registering the WM8731 into the individual machine driver probes. This allows separate patches to update the relevant architecture files with less risk of merge issues.

---
 sound/soc/atmel/sam9g20_wm8731.c |   43 +++++-
 sound/soc/codecs/wm8731.c        |  334 +++++++++++++++++---------------------
 sound/soc/codecs/wm8731.h        |    6 -
 sound/soc/pxa/corgi.c            |   43 ++++-
 sound/soc/pxa/poodle.c           |   41 ++++-
 5 files changed, 256 insertions(+), 211 deletions(-)
sound/soc/atmel/sam9g20_wm8731.c +38 -5
index aa52423..173a239 100644
@@ -36,6 +36,7 @@
 #include <linux/timer.h>
 #include <linux/interrupt.h>
 #include <linux/platform_device.h>
+#include <linux/i2c.h>
 
 #include <linux/atmel-ssc.h>
 
@@ -280,15 +281,41 @@ static struct snd_soc_card snd_soc_at91sam9g20ek = {
 	.set_bias_level = at91sam9g20ek_set_bias_level,
 };
 
-static struct wm8731_setup_data at91sam9g20ek_wm8731_setup = {
-	.i2c_bus = 0,
-	.i2c_address = 0x1b,
-};
+/*
+ * FIXME: This is a temporary bodge to avoid cross-tree merge issues.
+ * New drivers should register the wm8731 I2C device in the machine
+ * setup code (under arch/arm for ARM systems).
+ */
+static int wm8731_i2c_register(void)
+{
+	struct i2c_board_info info;
+	struct i2c_adapter *adapter;
+	struct i2c_client *client;
+
+	memset(&info, 0, sizeof(struct i2c_board_info));
+	info.addr = 0x1b;
+	strlcpy(info.type, "wm8731", I2C_NAME_SIZE);
+
+	adapter = i2c_get_adapter(0);
+	if (!adapter) {
+		printk(KERN_ERR "can't get i2c adapter 0\n");
+		return -ENODEV;
+	}
+
+	client = i2c_new_device(adapter, &info);
+	i2c_put_adapter(adapter);
+	if (!client) {
+		printk(KERN_ERR "can't add i2c device at 0x%x\n",
+			(unsigned int)info.addr);
+		return -ENODEV;
+	}
+
+	return 0;
+}
 
 static struct snd_soc_device at91sam9g20ek_snd_devdata = {
 	.card = &snd_soc_at91sam9g20ek,
 	.codec_dev = &soc_codec_dev_wm8731,
-	.codec_data = &at91sam9g20ek_wm8731_setup,
 };
 
 static struct platform_device *at91sam9g20ek_snd_device;
@@ -340,6 +367,10 @@ static int __init at91sam9g20ek_init(void)
 	}
 	ssc_p->ssc = ssc;
 
+	ret = wm8731_i2c_register();
+	if (ret != 0)
+		goto err_ssc;
+
 	at91sam9g20ek_snd_device = platform_device_alloc("soc-audio", -1);
 	if (!at91sam9g20ek_snd_device) {
 		printk(KERN_ERR "ASoC: Platform device allocation failed\n");
@@ -359,6 +390,8 @@ static int __init at91sam9g20ek_init(void)
 	return ret;
 
 err_ssc:
+	ssc_free(ssc);
+	ssc_p->ssc = NULL;
 err_mclk:
 	clk_put(mclk);
 	mclk = NULL;
sound/soc/codecs/wm8731.c +147 -187

431 lines not on this page · raw message

sound/soc/codecs/wm8731.h +0 -6
index 95190e9..cd7b806 100644
@@ -34,12 +34,6 @@
 #define WM8731_SYSCLK	0
 #define WM8731_DAI		0
 
-struct wm8731_setup_data {
-	int            spi;
-	int            i2c_bus;
-	unsigned short i2c_address;
-};
-
 extern struct snd_soc_dai wm8731_dai;
 extern struct snd_soc_codec_device soc_codec_dev_wm8731;
 
sound/soc/pxa/corgi.c +36 -7

61 lines not on this page · raw message

sound/soc/pxa/poodle.c +35 -6

58 lines not on this page · raw message

Signature · 1 line
1.5.6.3
author
#11 lore raw

PATCH 11/11 ASoC: Remove version display from the WM8753 driver

In reply to Mark Brown
---
 sound/soc/codecs/wm8753.c |    4 ----
 1 files changed, 0 insertions(+), 4 deletions(-)
sound/soc/codecs/wm8753.c +0 -4
index dc6042c..31ff337 100644
@@ -51,8 +51,6 @@
 
 #include "wm8753.h"
 
-#define WM8753_VERSION "0.16"
-
 static int caps_charge = 2000;
 module_param(caps_charge, int, 0);
 MODULE_PARM_DESC(caps_charge, "WM8753 cap charge time (msecs)");
@@ -1778,8 +1776,6 @@ static int wm8753_probe(struct platform_device *pdev)
 	struct wm8753_priv *wm8753;
 	int ret = 0;
 
-	pr_info("WM8753 Audio Codec %s", WM8753_VERSION);
-
 	setup = socdev->codec_data;
 	codec = kzalloc(sizeof(struct snd_soc_codec), GFP_KERNEL);
 	if (codec == NULL)
Signature · 1 line
1.5.6.3
#12 lore raw
In reply to Mark Brown

At Wed, 18 Feb 2009 12:01:37 +0000,

Quoted 8 lines · Mark Brown

The following changes since commit f1464ede550b8fda75086cb9bacf8d60fc9f6780:
Takashi Iwai (1):

        Merge branch 'for-2.6.30' of git://git.kernel.org/.../broonie/sound-2.6 into topic/asoc

are available in the git repository at:

git://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound-2.6.git for-2.6.30

Pulled now. Thanks.

Takashi

#13 lore raw

At Wed, 18 Feb 2009 13:18:23 +0100,

Quoted 8 lines · I wrote:

At Wed, 18 Feb 2009 12:01:37 +0000,

Quoted 5 lines · Mark Brown

The following changes since commit f1464ede550b8fda75086cb9bacf8d60fc9f6780:
Takashi Iwai (1):

        Merge branch 'for-2.6.30' of git://git.kernel.org/.../broonie/sound-2.6 into topic/asoc
Quoted 5 lines
Quoted 3 lines

are available in the git repository at:

git://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound-2.6.git for-2.6.30

Pulled now. Thanks.

I get the following warning with my build test:

    sound/soc/codecs/wm8731.c:611: warning: 'wm8731_unregister' defined but not used

Could you fix it?

thanks,

Takashi

#14 lore raw

At Wed, 18 Feb 2009 13:22:08 +0100,

Quoted 13 lines · I wrote:

At Wed, 18 Feb 2009 13:18:23 +0100,

Quoted 10 lines · I wrote:

At Wed, 18 Feb 2009 12:01:37 +0000,

Quoted 7 lines · Mark Brown

The following changes since commit f1464ede550b8fda75086cb9bacf8d60fc9f6780:
Takashi Iwai (1):

        Merge branch 'for-2.6.30' of git://git.kernel.org/.../broonie/sound-2.6 into topic/asoc

are available in the git repository at:

Quoted 8 lines
Quoted 3 lines
Quoted 1 line

git://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound-2.6.git for-2.6.30

Pulled now. Thanks.

I get the following warning with my build test:

    sound/soc/codecs/wm8731.c:611: warning: 'wm8731_unregister' defined but not used

Could you fix it?

... and pxa/* drivers don't build. Missing i2c updates?

sound/soc/pxa/corgi.c: In function 'wm8731_i2c_register':
sound/soc/pxa/corgi.c:333: error: storage size of 'info' isn't known sound/soc/pxa/corgi.c:337: error: invalid application of 'sizeof' to incomplete type 'struct i2c_board_info' sound/soc/pxa/corgi.c:339: error: 'I2C_NAME_SIZE' undeclared (first use in this function) sound/soc/pxa/corgi.c:339: error: (Each undeclared identifier is reported only once sound/soc/pxa/corgi.c:339: error: for each function it appears in.) sound/soc/pxa/corgi.c:341: error: implicit declaration of function 'i2c_get_adapter' sound/soc/pxa/corgi.c:341: warning: assignment makes pointer from integer without a cast sound/soc/pxa/corgi.c:347: error: implicit declaration of function 'i2c_new_device' sound/soc/pxa/corgi.c:347: warning: assignment makes pointer from integer without a cast sound/soc/pxa/corgi.c:348: error: implicit declaration of function 'i2c_put_adapter' sound/soc/pxa/corgi.c:333: warning: unused variable 'info'
sound/soc/pxa/corgi.c: In function 'corgi_init':
sound/soc/pxa/corgi.c:368: error: implicit declaration of function 'wm8731_i2c_setup'

Takashi

author
#15 lore raw
Quoted 1 line · Takashi Iwai

... and pxa/* drivers don't build. Missing i2c updates?

Yes, I'll send a patch shortly.

I've never been able to get the underlying platform support for those machines to build, could you send me the .config you're using for testing, please? It's possible that they've been fixed since I last tried, I know people have been working on them a bit.

#16 lore raw

At Wed, 18 Feb 2009 12:37:20 +0000,

Quoted 11 lines · Mark Brown
Quoted 1 line · Takashi Iwai

... and pxa/* drivers don't build. Missing i2c updates?

Yes, I'll send a patch shortly.

I've never been able to get the underlying platform support for those machines to build, could you send me the .config you're using for testing, please? It's possible that they've been fixed since I last tried, I know people have been working on them a bit.

Attached below for corgi. It was generated by
KCONFIG_ALLCONFIG=arch/arm/configs/corgi_defconfig make allyesconfig

Takashi

_______________________________________________
Alsa-devel mailing list
[email protected]
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel

author
#17 lore raw
In reply to Takashi Iwai
Quoted 4 lines · Takashi Iwai

I get the following warning with my build test:

    sound/soc/codecs/wm8731.c:611: warning: 'wm8731_unregister' defined but not used

Could you fix it?

What config are you running - is CONFIG_I2C undefined?

#18 lore raw

At Wed, 18 Feb 2009 12:29:54 +0000,

Quoted 9 lines · Mark Brown
Quoted 4 lines · Takashi Iwai

I get the following warning with my build test:

    sound/soc/codecs/wm8731.c:611: warning: 'wm8731_unregister' defined but not used

Could you fix it?

What config are you running - is CONFIG_I2C undefined?

Yes. Only CONFIG_SPI=y.

Takashi