bt-sco.c 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. // SPDX-License-Identifier: GPL-2.0-or-later
  2. /*
  3. * Driver for generic Bluetooth SCO link
  4. * Copyright 2011 Lars-Peter Clausen <[email protected]>
  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. SND_SOC_DAPM_AIF_IN("BT_SCO_RX", "Playback", 0,
  14. SND_SOC_NOPM, 0, 0),
  15. SND_SOC_DAPM_AIF_OUT("BT_SCO_TX", "Capture", 0,
  16. SND_SOC_NOPM, 0, 0),
  17. };
  18. static const struct snd_soc_dapm_route bt_sco_routes[] = {
  19. { "BT_SCO_TX", NULL, "RX" },
  20. { "TX", NULL, "BT_SCO_RX" },
  21. };
  22. static struct snd_soc_dai_driver bt_sco_dai[] = {
  23. {
  24. .name = "bt-sco-pcm",
  25. .playback = {
  26. .stream_name = "Playback",
  27. .channels_min = 1,
  28. .channels_max = 1,
  29. .rates = SNDRV_PCM_RATE_8000,
  30. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  31. },
  32. .capture = {
  33. .stream_name = "Capture",
  34. .channels_min = 1,
  35. .channels_max = 1,
  36. .rates = SNDRV_PCM_RATE_8000,
  37. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  38. },
  39. },
  40. {
  41. .name = "bt-sco-pcm-wb",
  42. .playback = {
  43. .stream_name = "Playback",
  44. .channels_min = 1,
  45. .channels_max = 1,
  46. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000,
  47. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  48. },
  49. .capture = {
  50. .stream_name = "Capture",
  51. .channels_min = 1,
  52. .channels_max = 1,
  53. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000,
  54. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  55. },
  56. }
  57. };
  58. static const struct snd_soc_component_driver soc_component_dev_bt_sco = {
  59. .dapm_widgets = bt_sco_widgets,
  60. .num_dapm_widgets = ARRAY_SIZE(bt_sco_widgets),
  61. .dapm_routes = bt_sco_routes,
  62. .num_dapm_routes = ARRAY_SIZE(bt_sco_routes),
  63. .idle_bias_on = 1,
  64. .use_pmdown_time = 1,
  65. .endianness = 1,
  66. };
  67. static int bt_sco_probe(struct platform_device *pdev)
  68. {
  69. return devm_snd_soc_register_component(&pdev->dev,
  70. &soc_component_dev_bt_sco,
  71. bt_sco_dai, ARRAY_SIZE(bt_sco_dai));
  72. }
  73. static int bt_sco_remove(struct platform_device *pdev)
  74. {
  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 <[email protected]>");
  106. MODULE_DESCRIPTION("ASoC generic bluetooth sco link driver");
  107. MODULE_LICENSE("GPL");