aboutsummaryrefslogtreecommitdiffstats
path: root/sound/soc/davinci/davinci-sffsdr.c
diff options
context:
space:
mode:
Diffstat (limited to 'sound/soc/davinci/davinci-sffsdr.c')
-rw-r--r--sound/soc/davinci/davinci-sffsdr.c43
1 files changed, 30 insertions, 13 deletions
diff --git a/sound/soc/davinci/davinci-sffsdr.c b/sound/soc/davinci/davinci-sffsdr.c
index 4935d1bcbd8d..40eccfe9e358 100644
--- a/sound/soc/davinci/davinci-sffsdr.c
+++ b/sound/soc/davinci/davinci-sffsdr.c
@@ -25,7 +25,9 @@
25 25
26#include <asm/dma.h> 26#include <asm/dma.h>
27#include <asm/mach-types.h> 27#include <asm/mach-types.h>
28#ifdef CONFIG_SFFSDR_FPGA
28#include <asm/plat-sffsdr/sffsdr-fpga.h> 29#include <asm/plat-sffsdr/sffsdr-fpga.h>
30#endif
29 31
30#include <mach/mcbsp.h> 32#include <mach/mcbsp.h>
31#include <mach/edma.h> 33#include <mach/edma.h>
@@ -34,31 +36,45 @@
34#include "davinci-pcm.h" 36#include "davinci-pcm.h"
35#include "davinci-i2s.h" 37#include "davinci-i2s.h"
36 38
39/*
40 * CLKX and CLKR are the inputs for the Sample Rate Generator.
41 * FSX and FSR are outputs, driven by the sample Rate Generator.
42 */
43#define AUDIO_FORMAT (SND_SOC_DAIFMT_DSP_B | \
44 SND_SOC_DAIFMT_CBM_CFS | \
45 SND_SOC_DAIFMT_IB_NF)
46
37static int sffsdr_hw_params(struct snd_pcm_substream *substream, 47static int sffsdr_hw_params(struct snd_pcm_substream *substream,
38 struct snd_pcm_hw_params *params, 48 struct snd_pcm_hw_params *params)
39 struct snd_soc_dai *dai)
40{ 49{
41 struct snd_soc_pcm_runtime *rtd = substream->private_data; 50 struct snd_soc_pcm_runtime *rtd = substream->private_data;
42 struct snd_soc_dai *cpu_dai = rtd->dai->cpu_dai; 51 struct snd_soc_dai *cpu_dai = rtd->dai->cpu_dai;
43 int fs; 52 int fs;
44 int ret = 0; 53 int ret = 0;
45 54
46 /* Set cpu DAI configuration:
47 * CLKX and CLKR are the inputs for the Sample Rate Generator.
48 * FSX and FSR are outputs, driven by the sample Rate Generator. */
49 ret = snd_soc_dai_set_fmt(cpu_dai,
50 SND_SOC_DAIFMT_RIGHT_J |
51 SND_SOC_DAIFMT_CBM_CFS |
52 SND_SOC_DAIFMT_IB_NF);
53 if (ret < 0)
54 return ret;
55
56 /* Fsref can be 32000, 44100 or 48000. */ 55 /* Fsref can be 32000, 44100 or 48000. */
57 fs = params_rate(params); 56 fs = params_rate(params);
58 57
58#ifndef CONFIG_SFFSDR_FPGA
59 /* Without the FPGA module, the Fs is fixed at 44100 Hz */
60 if (fs != 44100) {
61 pr_debug("warning: only 44.1 kHz is supported without SFFSDR FPGA module\n");
62 return -EINVAL;
63 }
64#endif
65
66 /* set cpu DAI configuration */
67 ret = snd_soc_dai_set_fmt(cpu_dai, AUDIO_FORMAT);
68 if (ret < 0)
69 return ret;
70
59 pr_debug("sffsdr_hw_params: rate = %d Hz\n", fs); 71 pr_debug("sffsdr_hw_params: rate = %d Hz\n", fs);
60 72
73#ifndef CONFIG_SFFSDR_FPGA
74 return 0;
75#else
61 return sffsdr_fpga_set_codec_fs(fs); 76 return sffsdr_fpga_set_codec_fs(fs);
77#endif
62} 78}
63 79
64static struct snd_soc_ops sffsdr_ops = { 80static struct snd_soc_ops sffsdr_ops = {
@@ -127,7 +143,8 @@ static int __init sffsdr_init(void)
127 143
128 platform_set_drvdata(sffsdr_snd_device, &sffsdr_snd_devdata); 144 platform_set_drvdata(sffsdr_snd_device, &sffsdr_snd_devdata);
129 sffsdr_snd_devdata.dev = &sffsdr_snd_device->dev; 145 sffsdr_snd_devdata.dev = &sffsdr_snd_device->dev;
130 sffsdr_snd_device->dev.platform_data = &sffsdr_snd_data; 146 platform_device_add_data(sffsdr_snd_device, &sffsdr_snd_data,
147 sizeof(sffsdr_snd_data));
131 148
132 ret = platform_device_add_resources(sffsdr_snd_device, 149 ret = platform_device_add_resources(sffsdr_snd_device,
133 sffsdr_snd_resources, 150 sffsdr_snd_resources,