]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - sound/soc/pxa/corgi.c
ASoC: Fix build for corgi and poodle
[linux-2.6-omap-h63xx.git] / sound / soc / pxa / corgi.c
index 1ba25a559524296217824f188ac8f4de081a72ec..146973ae0974d31ed46fd52d4174b93909196277 100644 (file)
@@ -16,6 +16,7 @@
 #include <linux/module.h>
 #include <linux/moduleparam.h>
 #include <linux/timer.h>
+#include <linux/i2c.h>
 #include <linux/interrupt.h>
 #include <linux/platform_device.h>
 #include <linux/gpio.h>
@@ -100,7 +101,7 @@ static void corgi_ext_control(struct snd_soc_codec *codec)
 static int corgi_startup(struct snd_pcm_substream *substream)
 {
        struct snd_soc_pcm_runtime *rtd = substream->private_data;
-       struct snd_soc_codec *codec = rtd->socdev->codec;
+       struct snd_soc_codec *codec = rtd->socdev->card->codec;
 
        /* check the jack status at stream startup */
        corgi_ext_control(codec);
@@ -317,19 +318,44 @@ static struct snd_soc_card snd_soc_corgi = {
        .num_links = 1,
 };
 
-/* corgi audio private data */
-static struct wm8731_setup_data corgi_wm8731_setup = {
-       .i2c_bus = 0,
-       .i2c_address = 0x1b,
-};
-
 /* corgi audio subsystem */
 static struct snd_soc_device corgi_snd_devdata = {
        .card = &snd_soc_corgi,
        .codec_dev = &soc_codec_dev_wm8731,
-       .codec_data = &corgi_wm8731_setup,
 };
 
+/*
+ * 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 platform_device *corgi_snd_device;
 
 static int __init corgi_init(void)
@@ -340,6 +366,10 @@ static int __init corgi_init(void)
              machine_is_husky()))
                return -ENODEV;
 
+       ret = wm8731_i2c_register();
+       if (ret != 0)
+               return ret;
+
        corgi_snd_device = platform_device_alloc("soc-audio", -1);
        if (!corgi_snd_device)
                return -ENOMEM;