bt-sco.c 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. /*
  2. * Driver for generic Bluetooth SCO link
  3. * Copyright 2011 Lars-Peter Clausen <lars@metafoo.de>
  4. *
  5. * This program is free software; you can redistribute it and/or modify it
  6. * under the terms of the GNU General Public License as published by the
  7. * Free Software Foundation; either version 2 of the License, or (at your
  8. * option) any later version.
  9. *
  10. */
  11. #include <linux/init.h>
  12. #include <linux/module.h>
  13. #include <linux/platform_device.h>
  14. #include <sound/soc.h>
  15. static const struct snd_soc_dapm_widget bt_sco_widgets[] = {
  16. SND_SOC_DAPM_INPUT("RX"),
  17. SND_SOC_DAPM_OUTPUT("TX"),
  18. };
  19. static const struct snd_soc_dapm_route bt_sco_routes[] = {
  20. { "Capture", NULL, "RX" },
  21. { "TX", NULL, "Playback" },
  22. };
  23. static struct snd_soc_dai_driver bt_sco_dai[] = {
  24. {
  25. .name = "bt-sco-pcm",
  26. .playback = {
  27. .stream_name = "Playback",
  28. .channels_min = 1,
  29. .channels_max = 1,
  30. .rates = SNDRV_PCM_RATE_8000,
  31. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  32. },
  33. .capture = {
  34. .stream_name = "Capture",
  35. .channels_min = 1,
  36. .channels_max = 1,
  37. .rates = SNDRV_PCM_RATE_8000,
  38. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  39. },
  40. },
  41. {
  42. .name = "bt-sco-pcm-wb",
  43. .playback = {
  44. .stream_name = "Playback",
  45. .channels_min = 1,
  46. .channels_max = 1,
  47. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000,
  48. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  49. },
  50. .capture = {
  51. .stream_name = "Capture",
  52. .channels_min = 1,
  53. .channels_max = 1,
  54. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000,
  55. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  56. },
  57. }
  58. };
  59. static struct snd_soc_codec_driver soc_codec_dev_bt_sco = {
  60. .component_driver = {
  61. .dapm_widgets = bt_sco_widgets,
  62. .num_dapm_widgets = ARRAY_SIZE(bt_sco_widgets),
  63. .dapm_routes = bt_sco_routes,
  64. .num_dapm_routes = ARRAY_SIZE(bt_sco_routes),
  65. },
  66. };
  67. static int bt_sco_probe(struct platform_device *pdev)
  68. {
  69. return snd_soc_register_codec(&pdev->dev, &soc_codec_dev_bt_sco,
  70. bt_sco_dai, ARRAY_SIZE(bt_sco_dai));
  71. }
  72. static int bt_sco_remove(struct platform_device *pdev)
  73. {
  74. snd_soc_unregister_codec(&pdev->dev);
  75. return 0;
  76. }
  77. static const struct platform_device_id bt_sco_driver_ids[] = {
  78. {
  79. .name = "dfbmcs320",
  80. },
  81. {
  82. .name = "bt-sco",
  83. },
  84. {},
  85. };
  86. MODULE_DEVICE_TABLE(platform, bt_sco_driver_ids);
  87. #if defined(CONFIG_OF)
  88. static const struct of_device_id bt_sco_codec_of_match[] = {
  89. { .compatible = "delta,dfbmcs320", },
  90. { .compatible = "linux,bt-sco", },
  91. {},
  92. };
  93. MODULE_DEVICE_TABLE(of, bt_sco_codec_of_match);
  94. #endif
  95. static struct platform_driver bt_sco_driver = {
  96. .driver = {
  97. .name = "bt-sco",
  98. .of_match_table = of_match_ptr(bt_sco_codec_of_match),
  99. },
  100. .probe = bt_sco_probe,
  101. .remove = bt_sco_remove,
  102. .id_table = bt_sco_driver_ids,
  103. };
  104. module_platform_driver(bt_sco_driver);
  105. MODULE_AUTHOR("Lars-Peter Clausen <lars@metafoo.de>");
  106. MODULE_DESCRIPTION("ASoC generic bluetooth sco link driver");
  107. MODULE_LICENSE("GPL");