Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame^] | 1 | /* sound/soc/msm/msm-dai.c |
| 2 | * |
| 3 | * Copyright (C) 2008 Google, Inc. |
| 4 | * Copyright (C) 2008 HTC Corporation |
| 5 | * Copyright (c) 2008-2010, Code Aurora Forum. All rights reserved. |
| 6 | * |
| 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> |
| 33 | #ifdef CONFIG_ARCH_MSM_ARM11 |
| 34 | #include "msm-pcm.h" |
| 35 | #else |
| 36 | #include "qsd-pcm.h" |
| 37 | #endif |
| 38 | |
| 39 | static struct snd_soc_dai_driver msm_pcm_codec_dais[] = { |
| 40 | { |
| 41 | .name = "msm-codec-dai", |
| 42 | .playback = { |
| 43 | .stream_name = "Playback", |
| 44 | .channels_max = USE_CHANNELS_MAX, |
| 45 | .rates = USE_RATE, |
| 46 | .rate_min = USE_RATE_MIN, |
| 47 | .rate_max = USE_RATE_MAX, |
| 48 | .formats = USE_FORMATS, |
| 49 | }, |
| 50 | .capture = { |
| 51 | .stream_name = "Capture", |
| 52 | .channels_max = USE_CHANNELS_MAX, |
| 53 | .rate_min = USE_RATE_MIN, |
| 54 | .rates = USE_RATE, |
| 55 | .formats = USE_FORMATS, |
| 56 | }, |
| 57 | }, |
| 58 | }; |
| 59 | |
| 60 | static struct snd_soc_dai_driver msm_pcm_cpu_dais[] = { |
| 61 | { |
| 62 | .name = "msm-cpu-dai", |
| 63 | .playback = { |
| 64 | .channels_min = USE_CHANNELS_MIN, |
| 65 | .channels_max = USE_CHANNELS_MAX, |
| 66 | .rates = USE_RATE, |
| 67 | .rate_min = USE_RATE_MIN, |
| 68 | .rate_max = USE_RATE_MAX, |
| 69 | .formats = USE_FORMATS, |
| 70 | }, |
| 71 | .capture = { |
| 72 | .channels_min = USE_CHANNELS_MIN, |
| 73 | .channels_max = USE_CHANNELS_MAX, |
| 74 | .rate_min = USE_RATE_MIN, |
| 75 | .rates = USE_RATE, |
| 76 | .formats = USE_FORMATS, |
| 77 | }, |
| 78 | }, |
| 79 | }; |
| 80 | |
| 81 | static struct snd_soc_codec_driver soc_codec_dev_msm = { |
| 82 | .compress_type = SND_SOC_FLAT_COMPRESSION, |
| 83 | }; |
| 84 | |
| 85 | static __devinit int asoc_msm_codec_probe(struct platform_device *pdev) |
| 86 | { |
| 87 | dev_info(&pdev->dev, "%s: dev name %s\n", __func__, dev_name(&pdev->dev)); |
| 88 | return snd_soc_register_codec(&pdev->dev, &soc_codec_dev_msm, |
| 89 | msm_pcm_codec_dais, ARRAY_SIZE(msm_pcm_codec_dais)); |
| 90 | } |
| 91 | |
| 92 | static int __devexit asoc_msm_codec_remove(struct platform_device *pdev) |
| 93 | { |
| 94 | snd_soc_unregister_dai(&pdev->dev); |
| 95 | return 0; |
| 96 | } |
| 97 | |
| 98 | static __devinit int asoc_pcm_cpu_probe(struct platform_device *pdev) |
| 99 | { |
| 100 | return snd_soc_register_dai(&pdev->dev, msm_pcm_cpu_dais); |
| 101 | } |
| 102 | |
| 103 | static int __devexit asoc_pcm_cpu_remove(struct platform_device *pdev) |
| 104 | { |
| 105 | snd_soc_unregister_dai(&pdev->dev); |
| 106 | return 0; |
| 107 | } |
| 108 | |
| 109 | static struct platform_driver asoc_codec_dai_driver = { |
| 110 | .probe = asoc_msm_codec_probe, |
| 111 | .remove = __devexit_p(asoc_msm_codec_remove), |
| 112 | .driver = { |
| 113 | .name = "msm-codec-dai", |
| 114 | .owner = THIS_MODULE, |
| 115 | }, |
| 116 | }; |
| 117 | |
| 118 | static struct platform_driver asoc_cpu_dai_driver = { |
| 119 | .probe = asoc_pcm_cpu_probe, |
| 120 | .remove = __devexit_p(asoc_pcm_cpu_remove), |
| 121 | .driver = { |
| 122 | .name = "msm-cpu-dai", |
| 123 | .owner = THIS_MODULE, |
| 124 | }, |
| 125 | }; |
| 126 | |
| 127 | static int __init msm_codec_dai_init(void) |
| 128 | { |
| 129 | return platform_driver_register(&asoc_codec_dai_driver); |
| 130 | } |
| 131 | |
| 132 | static void __exit msm_codec_dai_exit(void) |
| 133 | { |
| 134 | platform_driver_unregister(&asoc_codec_dai_driver); |
| 135 | } |
| 136 | |
| 137 | static int __init msm_cpu_dai_init(void) |
| 138 | { |
| 139 | return platform_driver_register(&asoc_cpu_dai_driver); |
| 140 | } |
| 141 | |
| 142 | static void __exit msm_cpu_dai_exit(void) |
| 143 | { |
| 144 | platform_driver_unregister(&asoc_cpu_dai_driver); |
| 145 | } |
| 146 | |
| 147 | module_init(msm_codec_dai_init); |
| 148 | module_exit(msm_codec_dai_exit); |
| 149 | module_init(msm_cpu_dai_init); |
| 150 | module_exit(msm_cpu_dai_exit); |
| 151 | |
| 152 | /* Module information */ |
| 153 | MODULE_DESCRIPTION("MSM Codec/Cpu Dai driver"); |
| 154 | MODULE_LICENSE("GPL v2"); |