msm_stub.c 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. /* Copyright (c) 2011-2013, 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. /* A dummy driver useful only to advertise hardware parameters */
  20. static struct snd_soc_dai_driver msm_stub_dais[] = {
  21. {
  22. .name = "msm-stub-rx",
  23. .playback = { /* Support maximum range */
  24. .stream_name = "Playback",
  25. .channels_min = 1,
  26. .channels_max = 8,
  27. .rates = SNDRV_PCM_RATE_8000_48000,
  28. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  29. },
  30. },
  31. {
  32. .name = "msm-stub-tx",
  33. .capture = { /* Support maximum range */
  34. .stream_name = "Record",
  35. .channels_min = 1,
  36. .channels_max = 8,
  37. .rates = SNDRV_PCM_RATE_8000_48000,
  38. .formats = (SNDRV_PCM_FMTBIT_S16_LE |
  39. SNDRV_PCM_FMTBIT_S24_LE),
  40. },
  41. },
  42. };
  43. static struct snd_soc_codec_driver soc_msm_stub = {};
  44. static int __devinit msm_stub_dev_probe(struct platform_device *pdev)
  45. {
  46. if (pdev->dev.of_node)
  47. dev_set_name(&pdev->dev, "%s.%d", "msm-stub-codec", 1);
  48. dev_dbg(&pdev->dev, "dev name %s\n", dev_name(&pdev->dev));
  49. return snd_soc_register_codec(&pdev->dev,
  50. &soc_msm_stub, msm_stub_dais, ARRAY_SIZE(msm_stub_dais));
  51. }
  52. static int __devexit msm_stub_dev_remove(struct platform_device *pdev)
  53. {
  54. snd_soc_unregister_codec(&pdev->dev);
  55. return 0;
  56. }
  57. static const struct of_device_id msm_stub_codec_dt_match[] = {
  58. { .compatible = "qcom,msm-stub-codec", },
  59. {}
  60. };
  61. static struct platform_driver msm_stub_driver = {
  62. .driver = {
  63. .name = "msm-stub-codec",
  64. .owner = THIS_MODULE,
  65. .of_match_table = msm_stub_codec_dt_match,
  66. },
  67. .probe = msm_stub_dev_probe,
  68. .remove = __devexit_p(msm_stub_dev_remove),
  69. };
  70. static int __init msm_stub_init(void)
  71. {
  72. return platform_driver_register(&msm_stub_driver);
  73. }
  74. module_init(msm_stub_init);
  75. static void __exit msm_stub_exit(void)
  76. {
  77. platform_driver_unregister(&msm_stub_driver);
  78. }
  79. module_exit(msm_stub_exit);
  80. MODULE_DESCRIPTION("Generic MSM CODEC driver");
  81. MODULE_VERSION("1.0");
  82. MODULE_LICENSE("GPL v2");