blob: 61e46753890832edfe3d8dbe36577ccd01a6785d [file] [log] [blame]
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001/* sound/soc/msm/msm-dai.c
2 *
3 * Copyright (C) 2008 Google, Inc.
4 * Copyright (C) 2008 HTC Corporation
Manish Dewangan3a260992011-06-24 18:01:34 +05305 * Copyright (c) 2008-2011, Code Aurora Forum. All rights reserved.
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006 *
7 * Derived from msm-pcm.c and msm7201.c.
8 *
9 * This software is licensed under the terms of the GNU General Public
10 * License version 2, as published by the Free Software Foundation, and
11 * may be copied, distributed, and modified under those terms.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
16 *
17 * See the GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, you can find it at http://www.fsf.org.
20 */
21
22#include <linux/init.h>
23#include <linux/module.h>
24#include <linux/device.h>
25#include <linux/delay.h>
26#include <linux/clk.h>
27#include <linux/platform_device.h>
28#include <linux/slab.h>
29#include <sound/core.h>
30#include <sound/pcm.h>
31#include <sound/initval.h>
32#include <sound/soc.h>
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070033#include "msm-pcm.h"
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070034
35static struct snd_soc_dai_driver msm_pcm_codec_dais[] = {
36{
37 .name = "msm-codec-dai",
38 .playback = {
39 .stream_name = "Playback",
40 .channels_max = USE_CHANNELS_MAX,
41 .rates = USE_RATE,
42 .rate_min = USE_RATE_MIN,
43 .rate_max = USE_RATE_MAX,
44 .formats = USE_FORMATS,
45 },
46 .capture = {
47 .stream_name = "Capture",
48 .channels_max = USE_CHANNELS_MAX,
49 .rate_min = USE_RATE_MIN,
50 .rates = USE_RATE,
51 .formats = USE_FORMATS,
52 },
53},
54};
55
56static struct snd_soc_dai_driver msm_pcm_cpu_dais[] = {
57{
58 .name = "msm-cpu-dai",
59 .playback = {
60 .channels_min = USE_CHANNELS_MIN,
61 .channels_max = USE_CHANNELS_MAX,
62 .rates = USE_RATE,
63 .rate_min = USE_RATE_MIN,
64 .rate_max = USE_RATE_MAX,
65 .formats = USE_FORMATS,
66 },
67 .capture = {
68 .channels_min = USE_CHANNELS_MIN,
69 .channels_max = USE_CHANNELS_MAX,
70 .rate_min = USE_RATE_MIN,
71 .rates = USE_RATE,
72 .formats = USE_FORMATS,
73 },
74},
75};
76
77static struct snd_soc_codec_driver soc_codec_dev_msm = {
78 .compress_type = SND_SOC_FLAT_COMPRESSION,
79};
80
81static __devinit int asoc_msm_codec_probe(struct platform_device *pdev)
82{
83 dev_info(&pdev->dev, "%s: dev name %s\n", __func__, dev_name(&pdev->dev));
84 return snd_soc_register_codec(&pdev->dev, &soc_codec_dev_msm,
85 msm_pcm_codec_dais, ARRAY_SIZE(msm_pcm_codec_dais));
86}
87
88static int __devexit asoc_msm_codec_remove(struct platform_device *pdev)
89{
90 snd_soc_unregister_dai(&pdev->dev);
91 return 0;
92}
93
94static __devinit int asoc_pcm_cpu_probe(struct platform_device *pdev)
95{
96 return snd_soc_register_dai(&pdev->dev, msm_pcm_cpu_dais);
97}
98
99static int __devexit asoc_pcm_cpu_remove(struct platform_device *pdev)
100{
101 snd_soc_unregister_dai(&pdev->dev);
102 return 0;
103}
104
105static struct platform_driver asoc_codec_dai_driver = {
106 .probe = asoc_msm_codec_probe,
107 .remove = __devexit_p(asoc_msm_codec_remove),
108 .driver = {
109 .name = "msm-codec-dai",
110 .owner = THIS_MODULE,
111 },
112};
113
114static struct platform_driver asoc_cpu_dai_driver = {
115 .probe = asoc_pcm_cpu_probe,
116 .remove = __devexit_p(asoc_pcm_cpu_remove),
117 .driver = {
118 .name = "msm-cpu-dai",
119 .owner = THIS_MODULE,
120 },
121};
122
123static int __init msm_codec_dai_init(void)
124{
125 return platform_driver_register(&asoc_codec_dai_driver);
126}
127
128static void __exit msm_codec_dai_exit(void)
129{
130 platform_driver_unregister(&asoc_codec_dai_driver);
131}
132
133static int __init msm_cpu_dai_init(void)
134{
135 return platform_driver_register(&asoc_cpu_dai_driver);
136}
137
138static void __exit msm_cpu_dai_exit(void)
139{
140 platform_driver_unregister(&asoc_cpu_dai_driver);
141}
142
143module_init(msm_codec_dai_init);
144module_exit(msm_codec_dai_exit);
145module_init(msm_cpu_dai_init);
146module_exit(msm_cpu_dai_exit);
147
148/* Module information */
149MODULE_DESCRIPTION("MSM Codec/Cpu Dai driver");
150MODULE_LICENSE("GPL v2");