bt-sco.c 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. // SPDX-License-Identifier: GPL-2.0-or-later
  2. /*
  3. * Driver for generic Bluetooth SCO link
  4. * Copyright 2011 Lars-Peter Clausen <lars@metafoo.de>
  5. */
  6. #include <linux/init.h>
  7. #include <linux/module.h>
  8. #include <linux/platform_device.h>
  9. #include <sound/soc.h>
  10. static const struct snd_soc_dapm_widget bt_sco_widgets[] = {
  11. SND_SOC_DAPM_INPUT("RX"),
  12. SND_SOC_DAPM_OUTPUT("TX"),
  13. };
  14. static const struct snd_soc_dapm_route bt_sco_routes[] = {
  15. { "Capture", NULL, "RX" },
  16. { "TX", NULL, "Playback" },
  17. };
  18. static struct snd_soc_dai_driver bt_sco_dai[] = {
  19. {
  20. .name = "bt-sco-pcm",
  21. .playback = {
  22. .stream_name = "Playback",
  23. .channels_min = 1,
  24. .channels_max = 1,
  25. .rates = SNDRV_PCM_RATE_8000,
  26. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  27. },
  28. .capture = {
  29. .stream_name = "Capture",
  30. .channels_min = 1,
  31. .channels_max = 1,
  32. .rates = SNDRV_PCM_RATE_8000,
  33. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  34. },
  35. },
  36. {
  37. .name = "bt-sco-pcm-wb",
  38. .playback = {
  39. .stream_name = "Playback",
  40. .channels_min = 1,
  41. .channels_max = 1,
  42. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000,
  43. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  44. },
  45. .capture = {
  46. .stream_name = "Capture",
  47. .channels_min = 1,
  48. .channels_max = 1,
  49. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000,
  50. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  51. },
  52. },
  53. {
  54. .name = "dummy-pcm",
  55. .playback = {
  56. .stream_name = "Playback",
  57. .channels_min = 2,
  58. .channels_max = 2,
  59. .rates = SNDRV_PCM_RATE_8000_48000,
  60. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  61. },
  62. .capture = {
  63. .stream_name = "Capture",
  64. .channels_min = 1,
  65. .channels_max = 2,
  66. .rates = SNDRV_PCM_RATE_8000_48000,
  67. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  68. },
  69. },
  70. };
  71. static const struct snd_soc_component_driver soc_component_dev_bt_sco = {
  72. .dapm_widgets = bt_sco_widgets,
  73. .num_dapm_widgets = ARRAY_SIZE(bt_sco_widgets),
  74. .dapm_routes = bt_sco_routes,
  75. .num_dapm_routes = ARRAY_SIZE(bt_sco_routes),
  76. .idle_bias_on = 1,
  77. .use_pmdown_time = 1,
  78. .endianness = 1,
  79. .non_legacy_dai_naming = 1,
  80. };
  81. static int bt_sco_probe(struct platform_device *pdev)
  82. {
  83. return devm_snd_soc_register_component(&pdev->dev,
  84. &soc_component_dev_bt_sco,
  85. bt_sco_dai, ARRAY_SIZE(bt_sco_dai));
  86. }
  87. static int bt_sco_remove(struct platform_device *pdev)
  88. {
  89. return 0;
  90. }
  91. static const struct platform_device_id bt_sco_driver_ids[] = {
  92. {
  93. .name = "dfbmcs320",
  94. },
  95. {
  96. .name = "bt-sco",
  97. },
  98. {},
  99. };
  100. MODULE_DEVICE_TABLE(platform, bt_sco_driver_ids);
  101. #if defined(CONFIG_OF)
  102. static const struct of_device_id bt_sco_codec_of_match[] = {
  103. { .compatible = "delta,dfbmcs320", },
  104. { .compatible = "linux,bt-sco", },
  105. {},
  106. };
  107. MODULE_DEVICE_TABLE(of, bt_sco_codec_of_match);
  108. #endif
  109. static struct platform_driver bt_sco_driver = {
  110. .driver = {
  111. .name = "bt-sco",
  112. .of_match_table = of_match_ptr(bt_sco_codec_of_match),
  113. },
  114. .probe = bt_sco_probe,
  115. .remove = bt_sco_remove,
  116. .id_table = bt_sco_driver_ids,
  117. };
  118. module_platform_driver(bt_sco_driver);
  119. MODULE_AUTHOR("Lars-Peter Clausen <lars@metafoo.de>");
  120. MODULE_DESCRIPTION("ASoC generic bluetooth sco link driver");
  121. MODULE_LICENSE("GPL");