diff options
Diffstat (limited to 'sound/soc/omap/omap-mcbsp.c')
-rw-r--r-- | sound/soc/omap/omap-mcbsp.c | 125 |
1 files changed, 62 insertions, 63 deletions
diff --git a/sound/soc/omap/omap-mcbsp.c b/sound/soc/omap/omap-mcbsp.c index 86f213905e2c..99696187b55a 100644 --- a/sound/soc/omap/omap-mcbsp.c +++ b/sound/soc/omap/omap-mcbsp.c | |||
@@ -62,8 +62,6 @@ struct omap_mcbsp_data { | |||
62 | int wlen; | 62 | int wlen; |
63 | }; | 63 | }; |
64 | 64 | ||
65 | #define to_mcbsp(priv) container_of((priv), struct omap_mcbsp_data, bus_id) | ||
66 | |||
67 | static struct omap_mcbsp_data mcbsp_data[NUM_LINKS]; | 65 | static struct omap_mcbsp_data mcbsp_data[NUM_LINKS]; |
68 | 66 | ||
69 | /* | 67 | /* |
@@ -153,13 +151,13 @@ static const unsigned long omap34xx_mcbsp_port[][2] = {}; | |||
153 | static void omap_mcbsp_set_threshold(struct snd_pcm_substream *substream) | 151 | static void omap_mcbsp_set_threshold(struct snd_pcm_substream *substream) |
154 | { | 152 | { |
155 | struct snd_soc_pcm_runtime *rtd = substream->private_data; | 153 | struct snd_soc_pcm_runtime *rtd = substream->private_data; |
156 | struct snd_soc_dai *cpu_dai = rtd->dai->cpu_dai; | 154 | struct snd_soc_dai *cpu_dai = rtd->cpu_dai; |
157 | struct omap_mcbsp_data *mcbsp_data = to_mcbsp(cpu_dai->private_data); | 155 | struct omap_mcbsp_data *mcbsp_data = snd_soc_dai_get_drvdata(cpu_dai); |
158 | struct omap_pcm_dma_data *dma_data; | 156 | struct omap_pcm_dma_data *dma_data; |
159 | int dma_op_mode = omap_mcbsp_get_dma_op_mode(mcbsp_data->bus_id); | 157 | int dma_op_mode = omap_mcbsp_get_dma_op_mode(mcbsp_data->bus_id); |
160 | int words; | 158 | int words; |
161 | 159 | ||
162 | dma_data = snd_soc_dai_get_dma_data(rtd->dai->cpu_dai, substream); | 160 | dma_data = snd_soc_dai_get_dma_data(rtd->cpu_dai, substream); |
163 | 161 | ||
164 | /* TODO: Currently, MODE_ELEMENT == MODE_FRAME */ | 162 | /* TODO: Currently, MODE_ELEMENT == MODE_FRAME */ |
165 | if (dma_op_mode == MCBSP_DMA_MODE_THRESHOLD) | 163 | if (dma_op_mode == MCBSP_DMA_MODE_THRESHOLD) |
@@ -203,11 +201,9 @@ static int omap_mcbsp_hwrule_min_buffersize(struct snd_pcm_hw_params *params, | |||
203 | } | 201 | } |
204 | 202 | ||
205 | static int omap_mcbsp_dai_startup(struct snd_pcm_substream *substream, | 203 | static int omap_mcbsp_dai_startup(struct snd_pcm_substream *substream, |
206 | struct snd_soc_dai *dai) | 204 | struct snd_soc_dai *cpu_dai) |
207 | { | 205 | { |
208 | struct snd_soc_pcm_runtime *rtd = substream->private_data; | 206 | struct omap_mcbsp_data *mcbsp_data = snd_soc_dai_get_drvdata(cpu_dai); |
209 | struct snd_soc_dai *cpu_dai = rtd->dai->cpu_dai; | ||
210 | struct omap_mcbsp_data *mcbsp_data = to_mcbsp(cpu_dai->private_data); | ||
211 | int bus_id = mcbsp_data->bus_id; | 207 | int bus_id = mcbsp_data->bus_id; |
212 | int err = 0; | 208 | int err = 0; |
213 | 209 | ||
@@ -249,11 +245,9 @@ static int omap_mcbsp_dai_startup(struct snd_pcm_substream *substream, | |||
249 | } | 245 | } |
250 | 246 | ||
251 | static void omap_mcbsp_dai_shutdown(struct snd_pcm_substream *substream, | 247 | static void omap_mcbsp_dai_shutdown(struct snd_pcm_substream *substream, |
252 | struct snd_soc_dai *dai) | 248 | struct snd_soc_dai *cpu_dai) |
253 | { | 249 | { |
254 | struct snd_soc_pcm_runtime *rtd = substream->private_data; | 250 | struct omap_mcbsp_data *mcbsp_data = snd_soc_dai_get_drvdata(cpu_dai); |
255 | struct snd_soc_dai *cpu_dai = rtd->dai->cpu_dai; | ||
256 | struct omap_mcbsp_data *mcbsp_data = to_mcbsp(cpu_dai->private_data); | ||
257 | 251 | ||
258 | if (!cpu_dai->active) { | 252 | if (!cpu_dai->active) { |
259 | omap_mcbsp_free(mcbsp_data->bus_id); | 253 | omap_mcbsp_free(mcbsp_data->bus_id); |
@@ -262,11 +256,9 @@ static void omap_mcbsp_dai_shutdown(struct snd_pcm_substream *substream, | |||
262 | } | 256 | } |
263 | 257 | ||
264 | static int omap_mcbsp_dai_trigger(struct snd_pcm_substream *substream, int cmd, | 258 | static int omap_mcbsp_dai_trigger(struct snd_pcm_substream *substream, int cmd, |
265 | struct snd_soc_dai *dai) | 259 | struct snd_soc_dai *cpu_dai) |
266 | { | 260 | { |
267 | struct snd_soc_pcm_runtime *rtd = substream->private_data; | 261 | struct omap_mcbsp_data *mcbsp_data = snd_soc_dai_get_drvdata(cpu_dai); |
268 | struct snd_soc_dai *cpu_dai = rtd->dai->cpu_dai; | ||
269 | struct omap_mcbsp_data *mcbsp_data = to_mcbsp(cpu_dai->private_data); | ||
270 | int err = 0, play = (substream->stream == SNDRV_PCM_STREAM_PLAYBACK); | 262 | int err = 0, play = (substream->stream == SNDRV_PCM_STREAM_PLAYBACK); |
271 | 263 | ||
272 | switch (cmd) { | 264 | switch (cmd) { |
@@ -295,8 +287,8 @@ static snd_pcm_sframes_t omap_mcbsp_dai_delay( | |||
295 | struct snd_soc_dai *dai) | 287 | struct snd_soc_dai *dai) |
296 | { | 288 | { |
297 | struct snd_soc_pcm_runtime *rtd = substream->private_data; | 289 | struct snd_soc_pcm_runtime *rtd = substream->private_data; |
298 | struct snd_soc_dai *cpu_dai = rtd->dai->cpu_dai; | 290 | struct snd_soc_dai *cpu_dai = rtd->cpu_dai; |
299 | struct omap_mcbsp_data *mcbsp_data = to_mcbsp(cpu_dai->private_data); | 291 | struct omap_mcbsp_data *mcbsp_data = snd_soc_dai_get_drvdata(cpu_dai); |
300 | u16 fifo_use; | 292 | u16 fifo_use; |
301 | snd_pcm_sframes_t delay; | 293 | snd_pcm_sframes_t delay; |
302 | 294 | ||
@@ -317,11 +309,9 @@ static snd_pcm_sframes_t omap_mcbsp_dai_delay( | |||
317 | 309 | ||
318 | static int omap_mcbsp_dai_hw_params(struct snd_pcm_substream *substream, | 310 | static int omap_mcbsp_dai_hw_params(struct snd_pcm_substream *substream, |
319 | struct snd_pcm_hw_params *params, | 311 | struct snd_pcm_hw_params *params, |
320 | struct snd_soc_dai *dai) | 312 | struct snd_soc_dai *cpu_dai) |
321 | { | 313 | { |
322 | struct snd_soc_pcm_runtime *rtd = substream->private_data; | 314 | struct omap_mcbsp_data *mcbsp_data = snd_soc_dai_get_drvdata(cpu_dai); |
323 | struct snd_soc_dai *cpu_dai = rtd->dai->cpu_dai; | ||
324 | struct omap_mcbsp_data *mcbsp_data = to_mcbsp(cpu_dai->private_data); | ||
325 | struct omap_mcbsp_reg_cfg *regs = &mcbsp_data->regs; | 315 | struct omap_mcbsp_reg_cfg *regs = &mcbsp_data->regs; |
326 | struct omap_pcm_dma_data *dma_data; | 316 | struct omap_pcm_dma_data *dma_data; |
327 | int dma, bus_id = mcbsp_data->bus_id; | 317 | int dma, bus_id = mcbsp_data->bus_id; |
@@ -496,7 +486,7 @@ static int omap_mcbsp_dai_hw_params(struct snd_pcm_substream *substream, | |||
496 | static int omap_mcbsp_dai_set_dai_fmt(struct snd_soc_dai *cpu_dai, | 486 | static int omap_mcbsp_dai_set_dai_fmt(struct snd_soc_dai *cpu_dai, |
497 | unsigned int fmt) | 487 | unsigned int fmt) |
498 | { | 488 | { |
499 | struct omap_mcbsp_data *mcbsp_data = to_mcbsp(cpu_dai->private_data); | 489 | struct omap_mcbsp_data *mcbsp_data = snd_soc_dai_get_drvdata(cpu_dai); |
500 | struct omap_mcbsp_reg_cfg *regs = &mcbsp_data->regs; | 490 | struct omap_mcbsp_reg_cfg *regs = &mcbsp_data->regs; |
501 | unsigned int temp_fmt = fmt; | 491 | unsigned int temp_fmt = fmt; |
502 | 492 | ||
@@ -596,7 +586,7 @@ static int omap_mcbsp_dai_set_dai_fmt(struct snd_soc_dai *cpu_dai, | |||
596 | static int omap_mcbsp_dai_set_clkdiv(struct snd_soc_dai *cpu_dai, | 586 | static int omap_mcbsp_dai_set_clkdiv(struct snd_soc_dai *cpu_dai, |
597 | int div_id, int div) | 587 | int div_id, int div) |
598 | { | 588 | { |
599 | struct omap_mcbsp_data *mcbsp_data = to_mcbsp(cpu_dai->private_data); | 589 | struct omap_mcbsp_data *mcbsp_data = snd_soc_dai_get_drvdata(cpu_dai); |
600 | struct omap_mcbsp_reg_cfg *regs = &mcbsp_data->regs; | 590 | struct omap_mcbsp_reg_cfg *regs = &mcbsp_data->regs; |
601 | 591 | ||
602 | if (div_id != OMAP_MCBSP_CLKGDV) | 592 | if (div_id != OMAP_MCBSP_CLKGDV) |
@@ -699,7 +689,7 @@ static int omap_mcbsp_dai_set_dai_sysclk(struct snd_soc_dai *cpu_dai, | |||
699 | int clk_id, unsigned int freq, | 689 | int clk_id, unsigned int freq, |
700 | int dir) | 690 | int dir) |
701 | { | 691 | { |
702 | struct omap_mcbsp_data *mcbsp_data = to_mcbsp(cpu_dai->private_data); | 692 | struct omap_mcbsp_data *mcbsp_data = snd_soc_dai_get_drvdata(cpu_dai); |
703 | struct omap_mcbsp_reg_cfg *regs = &mcbsp_data->regs; | 693 | struct omap_mcbsp_reg_cfg *regs = &mcbsp_data->regs; |
704 | int err = 0; | 694 | int err = 0; |
705 | 695 | ||
@@ -733,7 +723,7 @@ static int omap_mcbsp_dai_set_dai_sysclk(struct snd_soc_dai *cpu_dai, | |||
733 | return err; | 723 | return err; |
734 | } | 724 | } |
735 | 725 | ||
736 | static struct snd_soc_dai_ops omap_mcbsp_dai_ops = { | 726 | static struct snd_soc_dai_ops mcbsp_dai_ops = { |
737 | .startup = omap_mcbsp_dai_startup, | 727 | .startup = omap_mcbsp_dai_startup, |
738 | .shutdown = omap_mcbsp_dai_shutdown, | 728 | .shutdown = omap_mcbsp_dai_shutdown, |
739 | .trigger = omap_mcbsp_dai_trigger, | 729 | .trigger = omap_mcbsp_dai_trigger, |
@@ -744,43 +734,32 @@ static struct snd_soc_dai_ops omap_mcbsp_dai_ops = { | |||
744 | .set_sysclk = omap_mcbsp_dai_set_dai_sysclk, | 734 | .set_sysclk = omap_mcbsp_dai_set_dai_sysclk, |
745 | }; | 735 | }; |
746 | 736 | ||
747 | #define OMAP_MCBSP_DAI_BUILDER(link_id) \ | 737 | static int mcbsp_dai_probe(struct snd_soc_dai *dai) |
748 | { \ | 738 | { |
749 | .name = "omap-mcbsp-dai-"#link_id, \ | 739 | mcbsp_data[dai->id].bus_id = dai->id; |
750 | .id = (link_id), \ | 740 | snd_soc_dai_set_drvdata(dai, &mcbsp_data[dai->id].bus_id); |
751 | .playback = { \ | 741 | return 0; |
752 | .channels_min = 1, \ | ||
753 | .channels_max = 16, \ | ||
754 | .rates = OMAP_MCBSP_RATES, \ | ||
755 | .formats = SNDRV_PCM_FMTBIT_S16_LE | \ | ||
756 | SNDRV_PCM_FMTBIT_S32_LE, \ | ||
757 | }, \ | ||
758 | .capture = { \ | ||
759 | .channels_min = 1, \ | ||
760 | .channels_max = 16, \ | ||
761 | .rates = OMAP_MCBSP_RATES, \ | ||
762 | .formats = SNDRV_PCM_FMTBIT_S16_LE | \ | ||
763 | SNDRV_PCM_FMTBIT_S32_LE, \ | ||
764 | }, \ | ||
765 | .ops = &omap_mcbsp_dai_ops, \ | ||
766 | .private_data = &mcbsp_data[(link_id)].bus_id, \ | ||
767 | } | 742 | } |
768 | 743 | ||
769 | struct snd_soc_dai omap_mcbsp_dai[] = { | 744 | static struct snd_soc_dai_driver omap_mcbsp_dai = |
770 | OMAP_MCBSP_DAI_BUILDER(0), | 745 | { |
771 | OMAP_MCBSP_DAI_BUILDER(1), | 746 | .probe = mcbsp_dai_probe, |
772 | #if NUM_LINKS >= 3 | 747 | .playback = { |
773 | OMAP_MCBSP_DAI_BUILDER(2), | 748 | .channels_min = 1, |
774 | #endif | 749 | .channels_max = 16, |
775 | #if NUM_LINKS == 5 | 750 | .rates = OMAP_MCBSP_RATES, |
776 | OMAP_MCBSP_DAI_BUILDER(3), | 751 | .formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S32_LE, |
777 | OMAP_MCBSP_DAI_BUILDER(4), | 752 | }, |
778 | #endif | 753 | .capture = { |
754 | .channels_min = 1, | ||
755 | .channels_max = 16, | ||
756 | .rates = OMAP_MCBSP_RATES, | ||
757 | .formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S32_LE, | ||
758 | }, | ||
759 | .ops = &mcbsp_dai_ops, | ||
779 | }; | 760 | }; |
780 | 761 | ||
781 | EXPORT_SYMBOL_GPL(omap_mcbsp_dai); | 762 | static int omap_mcbsp_st_info_volsw(struct snd_kcontrol *kcontrol, |
782 | |||
783 | int omap_mcbsp_st_info_volsw(struct snd_kcontrol *kcontrol, | ||
784 | struct snd_ctl_elem_info *uinfo) | 763 | struct snd_ctl_elem_info *uinfo) |
785 | { | 764 | { |
786 | struct soc_mixer_control *mc = | 765 | struct soc_mixer_control *mc = |
@@ -910,16 +889,36 @@ int omap_mcbsp_st_add_controls(struct snd_soc_codec *codec, int mcbsp_id) | |||
910 | } | 889 | } |
911 | EXPORT_SYMBOL_GPL(omap_mcbsp_st_add_controls); | 890 | EXPORT_SYMBOL_GPL(omap_mcbsp_st_add_controls); |
912 | 891 | ||
892 | static __devinit int asoc_mcbsp_probe(struct platform_device *pdev) | ||
893 | { | ||
894 | return snd_soc_register_dai(&pdev->dev, &omap_mcbsp_dai); | ||
895 | } | ||
896 | |||
897 | static int __devexit asoc_mcbsp_remove(struct platform_device *pdev) | ||
898 | { | ||
899 | snd_soc_unregister_dai(&pdev->dev); | ||
900 | return 0; | ||
901 | } | ||
902 | |||
903 | static struct platform_driver asoc_mcbsp_driver = { | ||
904 | .driver = { | ||
905 | .name = "omap-mcbsp-dai", | ||
906 | .owner = THIS_MODULE, | ||
907 | }, | ||
908 | |||
909 | .probe = asoc_mcbsp_probe, | ||
910 | .remove = __devexit_p(asoc_mcbsp_remove), | ||
911 | }; | ||
912 | |||
913 | static int __init snd_omap_mcbsp_init(void) | 913 | static int __init snd_omap_mcbsp_init(void) |
914 | { | 914 | { |
915 | return snd_soc_register_dais(omap_mcbsp_dai, | 915 | return platform_driver_register(&asoc_mcbsp_driver); |
916 | ARRAY_SIZE(omap_mcbsp_dai)); | ||
917 | } | 916 | } |
918 | module_init(snd_omap_mcbsp_init); | 917 | module_init(snd_omap_mcbsp_init); |
919 | 918 | ||
920 | static void __exit snd_omap_mcbsp_exit(void) | 919 | static void __exit snd_omap_mcbsp_exit(void) |
921 | { | 920 | { |
922 | snd_soc_unregister_dais(omap_mcbsp_dai, ARRAY_SIZE(omap_mcbsp_dai)); | 921 | platform_driver_unregister(&asoc_mcbsp_driver); |
923 | } | 922 | } |
924 | module_exit(snd_omap_mcbsp_exit); | 923 | module_exit(snd_omap_mcbsp_exit); |
925 | 924 | ||