aboutsummaryrefslogtreecommitdiffstats
path: root/sound/soc/blackfin/bf5xx-ad193x.c
diff options
context:
space:
mode:
Diffstat (limited to 'sound/soc/blackfin/bf5xx-ad193x.c')
-rw-r--r--sound/soc/blackfin/bf5xx-ad193x.c68
1 files changed, 38 insertions, 30 deletions
diff --git a/sound/soc/blackfin/bf5xx-ad193x.c b/sound/soc/blackfin/bf5xx-ad193x.c
index b8c9060cfd8e..d6651c033cb7 100644
--- a/sound/soc/blackfin/bf5xx-ad193x.c
+++ b/sound/soc/blackfin/bf5xx-ad193x.c
@@ -29,7 +29,6 @@
29#include <sound/core.h> 29#include <sound/core.h>
30#include <sound/pcm.h> 30#include <sound/pcm.h>
31#include <sound/soc.h> 31#include <sound/soc.h>
32#include <sound/soc-dapm.h>
33#include <sound/pcm_params.h> 32#include <sound/pcm_params.h>
34 33
35#include <asm/blackfin.h> 34#include <asm/blackfin.h>
@@ -39,30 +38,28 @@
39#include <asm/portmux.h> 38#include <asm/portmux.h>
40 39
41#include "../codecs/ad193x.h" 40#include "../codecs/ad193x.h"
42#include "bf5xx-sport.h"
43 41
44#include "bf5xx-tdm-pcm.h" 42#include "bf5xx-tdm-pcm.h"
45#include "bf5xx-tdm.h" 43#include "bf5xx-tdm.h"
46 44
47static struct snd_soc_card bf5xx_ad193x; 45static struct snd_soc_card bf5xx_ad193x;
48 46
49static int bf5xx_ad193x_startup(struct snd_pcm_substream *substream)
50{
51 struct snd_soc_pcm_runtime *rtd = substream->private_data;
52 struct snd_soc_dai *cpu_dai = rtd->dai->cpu_dai;
53
54 cpu_dai->private_data = sport_handle;
55 return 0;
56}
57
58static int bf5xx_ad193x_hw_params(struct snd_pcm_substream *substream, 47static int bf5xx_ad193x_hw_params(struct snd_pcm_substream *substream,
59 struct snd_pcm_hw_params *params) 48 struct snd_pcm_hw_params *params)
60{ 49{
61 struct snd_soc_pcm_runtime *rtd = substream->private_data; 50 struct snd_soc_pcm_runtime *rtd = substream->private_data;
62 struct snd_soc_dai *cpu_dai = rtd->dai->cpu_dai; 51 struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
63 struct snd_soc_dai *codec_dai = rtd->dai->codec_dai; 52 struct snd_soc_dai *codec_dai = rtd->codec_dai;
53 unsigned int clk = 0;
64 unsigned int channel_map[] = {0, 1, 2, 3, 4, 5, 6, 7}; 54 unsigned int channel_map[] = {0, 1, 2, 3, 4, 5, 6, 7};
65 int ret = 0; 55 int ret = 0;
56
57 switch (params_rate(params)) {
58 case 48000:
59 clk = 12288000;
60 break;
61 }
62
66 /* set cpu DAI configuration */ 63 /* set cpu DAI configuration */
67 ret = snd_soc_dai_set_fmt(cpu_dai, SND_SOC_DAIFMT_DSP_A | 64 ret = snd_soc_dai_set_fmt(cpu_dai, SND_SOC_DAIFMT_DSP_A |
68 SND_SOC_DAIFMT_IB_IF | SND_SOC_DAIFMT_CBM_CFM); 65 SND_SOC_DAIFMT_IB_IF | SND_SOC_DAIFMT_CBM_CFM);
@@ -75,6 +72,12 @@ static int bf5xx_ad193x_hw_params(struct snd_pcm_substream *substream,
75 if (ret < 0) 72 if (ret < 0)
76 return ret; 73 return ret;
77 74
75 /* set the codec system clock for DAC and ADC */
76 ret = snd_soc_dai_set_sysclk(codec_dai, 0, clk,
77 SND_SOC_CLOCK_IN);
78 if (ret < 0)
79 return ret;
80
78 /* set codec DAI slots, 8 channels, all channels are enabled */ 81 /* set codec DAI slots, 8 channels, all channels are enabled */
79 ret = snd_soc_dai_set_tdm_slot(codec_dai, 0xFF, 0xFF, 8, 32); 82 ret = snd_soc_dai_set_tdm_slot(codec_dai, 0xFF, 0xFF, 8, 32);
80 if (ret < 0) 83 if (ret < 0)
@@ -90,30 +93,36 @@ static int bf5xx_ad193x_hw_params(struct snd_pcm_substream *substream,
90} 93}
91 94
92static struct snd_soc_ops bf5xx_ad193x_ops = { 95static struct snd_soc_ops bf5xx_ad193x_ops = {
93 .startup = bf5xx_ad193x_startup,
94 .hw_params = bf5xx_ad193x_hw_params, 96 .hw_params = bf5xx_ad193x_hw_params,
95}; 97};
96 98
97static struct snd_soc_dai_link bf5xx_ad193x_dai = { 99static struct snd_soc_dai_link bf5xx_ad193x_dai[] = {
98 .name = "ad193x", 100 {
99 .stream_name = "AD193X", 101 .name = "ad193x",
100 .cpu_dai = &bf5xx_tdm_dai, 102 .stream_name = "AD193X",
101 .codec_dai = &ad193x_dai, 103 .cpu_dai_name = "bfin-tdm.0",
102 .ops = &bf5xx_ad193x_ops, 104 .codec_dai_name ="ad193x-hifi",
105 .platform_name = "bfin-tdm-pcm-audio",
106 .codec_name = "ad193x.5",
107 .ops = &bf5xx_ad193x_ops,
108 },
109 {
110 .name = "ad193x",
111 .stream_name = "AD193X",
112 .cpu_dai_name = "bfin-tdm.1",
113 .codec_dai_name ="ad193x-hifi",
114 .platform_name = "bfin-tdm-pcm-audio",
115 .codec_name = "ad193x.5",
116 .ops = &bf5xx_ad193x_ops,
117 },
103}; 118};
104 119
105static struct snd_soc_card bf5xx_ad193x = { 120static struct snd_soc_card bf5xx_ad193x = {
106 .name = "bf5xx_ad193x", 121 .name = "bfin-ad193x",
107 .platform = &bf5xx_tdm_soc_platform, 122 .dai_link = &bf5xx_ad193x_dai[CONFIG_SND_BF5XX_SPORT_NUM],
108 .dai_link = &bf5xx_ad193x_dai,
109 .num_links = 1, 123 .num_links = 1,
110}; 124};
111 125
112static struct snd_soc_device bf5xx_ad193x_snd_devdata = {
113 .card = &bf5xx_ad193x,
114 .codec_dev = &soc_codec_dev_ad193x,
115};
116
117static struct platform_device *bfxx_ad193x_snd_device; 126static struct platform_device *bfxx_ad193x_snd_device;
118 127
119static int __init bf5xx_ad193x_init(void) 128static int __init bf5xx_ad193x_init(void)
@@ -124,8 +133,7 @@ static int __init bf5xx_ad193x_init(void)
124 if (!bfxx_ad193x_snd_device) 133 if (!bfxx_ad193x_snd_device)
125 return -ENOMEM; 134 return -ENOMEM;
126 135
127 platform_set_drvdata(bfxx_ad193x_snd_device, &bf5xx_ad193x_snd_devdata); 136 platform_set_drvdata(bfxx_ad193x_snd_device, &bf5xx_ad193x);
128 bf5xx_ad193x_snd_devdata.dev = &bfxx_ad193x_snd_device->dev;
129 ret = platform_device_add(bfxx_ad193x_snd_device); 137 ret = platform_device_add(bfxx_ad193x_snd_device);
130 138
131 if (ret) 139 if (ret)