Thomas Gleixner | 2874c5f | 2019-05-27 08:55:01 +0200 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0-or-later |
Barry Song | 200ceb9 | 2013-05-18 20:25:00 +0800 | [diff] [blame] | 2 | /* |
| 3 | * Driver for generic Bluetooth SCO link |
| 4 | * Copyright 2011 Lars-Peter Clausen <lars@metafoo.de> |
Barry Song | 200ceb9 | 2013-05-18 20:25:00 +0800 | [diff] [blame] | 5 | */ |
| 6 | |
| 7 | #include <linux/init.h> |
| 8 | #include <linux/module.h> |
| 9 | #include <linux/platform_device.h> |
| 10 | |
| 11 | #include <sound/soc.h> |
| 12 | |
Mark Brown | 5195ca4 | 2013-08-19 12:16:19 +0100 | [diff] [blame] | 13 | static const struct snd_soc_dapm_widget bt_sco_widgets[] = { |
| 14 | SND_SOC_DAPM_INPUT("RX"), |
| 15 | SND_SOC_DAPM_OUTPUT("TX"), |
| 16 | }; |
| 17 | |
| 18 | static const struct snd_soc_dapm_route bt_sco_routes[] = { |
| 19 | { "Capture", NULL, "RX" }, |
| 20 | { "TX", NULL, "Playback" }, |
| 21 | }; |
| 22 | |
Garlic Tseng | 5947e1b | 2016-07-04 18:56:26 +0800 | [diff] [blame] | 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 | }, |
Barry Song | 200ceb9 | 2013-05-18 20:25:00 +0800 | [diff] [blame] | 40 | }, |
Garlic Tseng | 5947e1b | 2016-07-04 18:56:26 +0800 | [diff] [blame] | 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 | } |
Barry Song | 200ceb9 | 2013-05-18 20:25:00 +0800 | [diff] [blame] | 58 | }; |
| 59 | |
Kuninori Morimoto | 90e678d | 2018-01-29 04:34:42 +0000 | [diff] [blame] | 60 | static const struct snd_soc_component_driver soc_component_dev_bt_sco = { |
| 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 | .idle_bias_on = 1, |
| 66 | .use_pmdown_time = 1, |
| 67 | .endianness = 1, |
| 68 | .non_legacy_dai_naming = 1, |
Mark Brown | 5195ca4 | 2013-08-19 12:16:19 +0100 | [diff] [blame] | 69 | }; |
Barry Song | 200ceb9 | 2013-05-18 20:25:00 +0800 | [diff] [blame] | 70 | |
| 71 | static int bt_sco_probe(struct platform_device *pdev) |
| 72 | { |
Kuninori Morimoto | 90e678d | 2018-01-29 04:34:42 +0000 | [diff] [blame] | 73 | return devm_snd_soc_register_component(&pdev->dev, |
| 74 | &soc_component_dev_bt_sco, |
Garlic Tseng | 5947e1b | 2016-07-04 18:56:26 +0800 | [diff] [blame] | 75 | bt_sco_dai, ARRAY_SIZE(bt_sco_dai)); |
Barry Song | 200ceb9 | 2013-05-18 20:25:00 +0800 | [diff] [blame] | 76 | } |
| 77 | |
| 78 | static int bt_sco_remove(struct platform_device *pdev) |
| 79 | { |
Barry Song | 200ceb9 | 2013-05-18 20:25:00 +0800 | [diff] [blame] | 80 | return 0; |
| 81 | } |
| 82 | |
Krzysztof Kozlowski | c578743 | 2015-05-02 01:00:12 +0900 | [diff] [blame] | 83 | static const struct platform_device_id bt_sco_driver_ids[] = { |
Barry Song | 200ceb9 | 2013-05-18 20:25:00 +0800 | [diff] [blame] | 84 | { |
| 85 | .name = "dfbmcs320", |
| 86 | }, |
Mark Brown | b9dff9c | 2013-08-19 12:13:14 +0100 | [diff] [blame] | 87 | { |
| 88 | .name = "bt-sco", |
| 89 | }, |
Barry Song | 200ceb9 | 2013-05-18 20:25:00 +0800 | [diff] [blame] | 90 | {}, |
| 91 | }; |
| 92 | MODULE_DEVICE_TABLE(platform, bt_sco_driver_ids); |
| 93 | |
Marek Belisko | c778b47 | 2015-05-08 21:02:34 +0200 | [diff] [blame] | 94 | #if defined(CONFIG_OF) |
| 95 | static const struct of_device_id bt_sco_codec_of_match[] = { |
| 96 | { .compatible = "delta,dfbmcs320", }, |
Garlic Tseng | 5947e1b | 2016-07-04 18:56:26 +0800 | [diff] [blame] | 97 | { .compatible = "linux,bt-sco", }, |
Marek Belisko | c778b47 | 2015-05-08 21:02:34 +0200 | [diff] [blame] | 98 | {}, |
| 99 | }; |
| 100 | MODULE_DEVICE_TABLE(of, bt_sco_codec_of_match); |
| 101 | #endif |
| 102 | |
Barry Song | 200ceb9 | 2013-05-18 20:25:00 +0800 | [diff] [blame] | 103 | static struct platform_driver bt_sco_driver = { |
| 104 | .driver = { |
| 105 | .name = "bt-sco", |
Marek Belisko | c778b47 | 2015-05-08 21:02:34 +0200 | [diff] [blame] | 106 | .of_match_table = of_match_ptr(bt_sco_codec_of_match), |
Barry Song | 200ceb9 | 2013-05-18 20:25:00 +0800 | [diff] [blame] | 107 | }, |
| 108 | .probe = bt_sco_probe, |
| 109 | .remove = bt_sco_remove, |
| 110 | .id_table = bt_sco_driver_ids, |
| 111 | }; |
| 112 | |
| 113 | module_platform_driver(bt_sco_driver); |
| 114 | |
| 115 | MODULE_AUTHOR("Lars-Peter Clausen <lars@metafoo.de>"); |
Masanari Iida | a465122 | 2015-01-15 19:29:28 +0900 | [diff] [blame] | 116 | MODULE_DESCRIPTION("ASoC generic bluetooth sco link driver"); |
Barry Song | 200ceb9 | 2013-05-18 20:25:00 +0800 | [diff] [blame] | 117 | MODULE_LICENSE("GPL"); |