]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - sound/soc/davinci/davinci-sffsdr.c
ASoC: Fix DaVinci module unload error
[linux-2.6-omap-h63xx.git] / sound / soc / davinci / davinci-sffsdr.c
index f67579d527655ad3fd84eb9a4e8f0c1bd23b5527..0bf81abba8c79048ef6f1be76129b68810ce6969 100644 (file)
 #include <sound/soc-dapm.h>
 
 #include <asm/dma.h>
+#include <asm/mach-types.h>
+#ifdef CONFIG_SFFSDR_FPGA
 #include <asm/plat-sffsdr/sffsdr-fpga.h>
+#endif
 
 #include <mach/mcbsp.h>
 #include <mach/edma.h>
@@ -42,6 +45,17 @@ static int sffsdr_hw_params(struct snd_pcm_substream *substream,
        int fs;
        int ret = 0;
 
+       /* Fsref can be 32000, 44100 or 48000. */
+       fs = params_rate(params);
+
+#ifndef CONFIG_SFFSDR_FPGA
+       /* Without the FPGA module, the Fs is fixed at 44100 Hz */
+       if (fs != 44100) {
+               pr_debug("warning: only 44.1 kHz is supported without SFFSDR FPGA module\n");
+               return -EINVAL;
+       }
+#endif
+
        /* Set cpu DAI configuration:
         * CLKX and CLKR are the inputs for the Sample Rate Generator.
         * FSX and FSR are outputs, driven by the sample Rate Generator. */
@@ -52,12 +66,13 @@ static int sffsdr_hw_params(struct snd_pcm_substream *substream,
        if (ret < 0)
                return ret;
 
-       /* Fsref can be 32000, 44100 or 48000. */
-       fs = params_rate(params);
-
        pr_debug("sffsdr_hw_params: rate = %d Hz\n", fs);
 
+#ifndef CONFIG_SFFSDR_FPGA
+       return 0;
+#else
        return sffsdr_fpga_set_codec_fs(fs);
+#endif
 }
 
 static struct snd_soc_ops sffsdr_ops = {
@@ -115,6 +130,9 @@ static int __init sffsdr_init(void)
 {
        int ret;
 
+       if (!machine_is_sffsdr())
+               return -EINVAL;
+
        sffsdr_snd_device = platform_device_alloc("soc-audio", 0);
        if (!sffsdr_snd_device) {
                printk(KERN_ERR "platform device allocation failed\n");
@@ -123,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,