Asish Bhattacharya | 8e2277f | 2017-07-20 18:31:55 +0530 | [diff] [blame] | 1 | /* Copyright (c) 2011-2014, 2017 The Linux Foundation. All rights reserved. |
| 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> |
| 14 | #include <linux/module.h> |
| 15 | #include <linux/of_device.h> |
| 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, |
| 37 | .channels_max = 8, |
| 38 | .rates = SNDRV_PCM_RATE_8000_48000, |
| 39 | .formats = (SNDRV_PCM_FMTBIT_S16_LE | |
| 40 | SNDRV_PCM_FMTBIT_S24_LE), |
| 41 | }, |
| 42 | }, |
| 43 | }; |
| 44 | |
| 45 | static struct snd_soc_codec_driver soc_msm_stub = {}; |
| 46 | |
| 47 | static int msm_stub_dev_probe(struct platform_device *pdev) |
| 48 | { |
| 49 | dev_dbg(&pdev->dev, "dev name %s\n", dev_name(&pdev->dev)); |
| 50 | |
| 51 | return snd_soc_register_codec(&pdev->dev, |
| 52 | &soc_msm_stub, msm_stub_dais, ARRAY_SIZE(msm_stub_dais)); |
| 53 | } |
| 54 | |
| 55 | static int msm_stub_dev_remove(struct platform_device *pdev) |
| 56 | { |
| 57 | snd_soc_unregister_codec(&pdev->dev); |
| 58 | return 0; |
| 59 | } |
| 60 | static const struct of_device_id msm_stub_codec_dt_match[] = { |
| 61 | { .compatible = "qcom,msm-stub-codec", }, |
| 62 | {} |
| 63 | }; |
| 64 | |
| 65 | static struct platform_driver msm_stub_driver = { |
| 66 | .driver = { |
| 67 | .name = "msm-stub-codec", |
| 68 | .owner = THIS_MODULE, |
| 69 | .of_match_table = msm_stub_codec_dt_match, |
| 70 | }, |
| 71 | .probe = msm_stub_dev_probe, |
| 72 | .remove = msm_stub_dev_remove, |
| 73 | }; |
| 74 | |
| 75 | static int __init msm_stub_init(void) |
| 76 | { |
| 77 | return platform_driver_register(&msm_stub_driver); |
| 78 | } |
| 79 | module_init(msm_stub_init); |
| 80 | |
| 81 | static void __exit msm_stub_exit(void) |
| 82 | { |
| 83 | platform_driver_unregister(&msm_stub_driver); |
| 84 | } |
| 85 | module_exit(msm_stub_exit); |
| 86 | |
| 87 | MODULE_DESCRIPTION("Generic MSM CODEC driver"); |
| 88 | MODULE_LICENSE("GPL v2"); |