Duy Truong | 790f06d | 2013-02-13 16:38:12 -0800 | [diff] [blame^] | 1 | /* Copyright (c) 2011-2012, The Linux Foundation. All rights reserved. |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 2 | * |
| 3 | * This program is free software; you can redistribute it and/or modify |
| 4 | * it under the terms of the GNU General Public License version 2 and |
| 5 | * only version 2 as published by the Free Software Foundation. |
| 6 | * |
| 7 | * This program is distributed in the hope that it will be useful, |
| 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 10 | * GNU General Public License for more details. |
| 11 | */ |
| 12 | #include <linux/platform_device.h> |
| 13 | #include <linux/slab.h> |
Steve Muckle | f132c6c | 2012-06-06 18:30:57 -0700 | [diff] [blame] | 14 | #include <linux/module.h> |
Phani Kumar Uppalapati | 87841c8 | 2012-06-14 21:28:43 -0700 | [diff] [blame] | 15 | #include <linux/of_device.h> |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 16 | #include <sound/core.h> |
| 17 | #include <sound/pcm.h> |
| 18 | #include <sound/soc.h> |
| 19 | |
| 20 | /* A dummy driver useful only to advertise hardware parameters */ |
| 21 | static struct snd_soc_dai_driver msm_stub_dais[] = { |
| 22 | { |
| 23 | .name = "msm-stub-rx", |
| 24 | .playback = { /* Support maximum range */ |
| 25 | .stream_name = "Playback", |
| 26 | .channels_min = 1, |
| 27 | .channels_max = 8, |
| 28 | .rates = SNDRV_PCM_RATE_8000_48000, |
| 29 | .formats = SNDRV_PCM_FMTBIT_S16_LE, |
| 30 | }, |
| 31 | }, |
| 32 | { |
| 33 | .name = "msm-stub-tx", |
| 34 | .capture = { /* Support maximum range */ |
| 35 | .stream_name = "Record", |
| 36 | .channels_min = 1, |
Phani Kumar Uppalapati | 5d26c9f | 2012-11-12 19:43:24 -0800 | [diff] [blame] | 37 | .channels_max = 8, |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 38 | .rates = SNDRV_PCM_RATE_8000_48000, |
| 39 | .formats = SNDRV_PCM_FMTBIT_S16_LE, |
| 40 | }, |
Steve Muckle | f132c6c | 2012-06-06 18:30:57 -0700 | [diff] [blame] | 41 | }, |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 42 | }; |
| 43 | |
| 44 | static struct snd_soc_codec_driver soc_msm_stub = {}; |
| 45 | |
| 46 | static int __devinit msm_stub_dev_probe(struct platform_device *pdev) |
| 47 | { |
Phani Kumar Uppalapati | 87841c8 | 2012-06-14 21:28:43 -0700 | [diff] [blame] | 48 | if (pdev->dev.of_node) |
| 49 | dev_set_name(&pdev->dev, "%s.%d", "msm-stub-codec", 1); |
| 50 | |
| 51 | dev_dbg(&pdev->dev, "dev name %s\n", dev_name(&pdev->dev)); |
| 52 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 53 | return snd_soc_register_codec(&pdev->dev, |
| 54 | &soc_msm_stub, msm_stub_dais, ARRAY_SIZE(msm_stub_dais)); |
| 55 | } |
| 56 | |
| 57 | static int __devexit msm_stub_dev_remove(struct platform_device *pdev) |
| 58 | { |
| 59 | snd_soc_unregister_codec(&pdev->dev); |
| 60 | return 0; |
| 61 | } |
Phani Kumar Uppalapati | 87841c8 | 2012-06-14 21:28:43 -0700 | [diff] [blame] | 62 | static const struct of_device_id msm_stub_codec_dt_match[] = { |
| 63 | { .compatible = "qcom,msm-stub-codec", }, |
| 64 | {} |
| 65 | }; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 66 | |
| 67 | static struct platform_driver msm_stub_driver = { |
| 68 | .driver = { |
| 69 | .name = "msm-stub-codec", |
| 70 | .owner = THIS_MODULE, |
Phani Kumar Uppalapati | 87841c8 | 2012-06-14 21:28:43 -0700 | [diff] [blame] | 71 | .of_match_table = msm_stub_codec_dt_match, |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 72 | }, |
| 73 | .probe = msm_stub_dev_probe, |
| 74 | .remove = __devexit_p(msm_stub_dev_remove), |
| 75 | }; |
| 76 | |
| 77 | static int __init msm_stub_init(void) |
| 78 | { |
| 79 | return platform_driver_register(&msm_stub_driver); |
| 80 | } |
| 81 | module_init(msm_stub_init); |
| 82 | |
| 83 | static void __exit msm_stub_exit(void) |
| 84 | { |
| 85 | platform_driver_unregister(&msm_stub_driver); |
| 86 | } |
| 87 | module_exit(msm_stub_exit); |
| 88 | |
| 89 | MODULE_DESCRIPTION("Generic MSM CODEC driver"); |
| 90 | MODULE_VERSION("1.0"); |
| 91 | MODULE_LICENSE("GPL v2"); |