summaryrefslogtreecommitdiffstats
path: root/audio
diff options
context:
space:
mode:
authorMisael Lopez Cruz2014-11-26 01:37:21 -0600
committerMisael Lopez Cruz2014-11-26 03:06:17 -0600
commit523b963f5c7b354a5656f32e422a3eeeae7578ff (patch)
tree222bbda2e61e005f1a41bcc65a33943ba67f0018 /audio
parent989e6a8edfff8e7966b25428dd5fb1ed585f34be (diff)
downloaddevice-ti-jacinto6evm-523b963f5c7b354a5656f32e422a3eeeae7578ff.tar.gz
device-ti-jacinto6evm-523b963f5c7b354a5656f32e422a3eeeae7578ff.tar.xz
device-ti-jacinto6evm-523b963f5c7b354a5656f32e422a3eeeae7578ff.zip
audio: Legacy: Use BT sound card
Starting in kernel-3.14, Bluetooth SCO audio has a separate sound card. Previously, BT SCO was a PCM device of the primary card. The index of the BT SCO card is found dynamically when present in the system. Change-Id: I5c24e07df48b836473ce56170f9b12e5aac9f975 Signed-off-by: Misael Lopez Cruz <misael.lopez@ti.com>
Diffstat (limited to 'audio')
-rw-r--r--audio/legacy/audio_hw.c34
1 files changed, 25 insertions, 9 deletions
diff --git a/audio/legacy/audio_hw.c b/audio/legacy/audio_hw.c
index 8aa28ab..1cd9e80 100644
--- a/audio/legacy/audio_hw.c
+++ b/audio/legacy/audio_hw.c
@@ -97,6 +97,7 @@ struct j6_audio_device {
97 unsigned int card; 97 unsigned int card;
98 unsigned int in_port; 98 unsigned int in_port;
99 unsigned int out_port; 99 unsigned int out_port;
100 unsigned int bt_card;
100 unsigned int bt_port; 101 unsigned int bt_port;
101 bool mic_mute; 102 bool mic_mute;
102 bool in_call; 103 bool in_call;
@@ -133,12 +134,16 @@ struct j6_stream_out {
133}; 134};
134 135
135 136
136static const char *supported_cards[] = { 137static const char *supported_media_cards[] = {
137 "dra7evm", 138 "dra7evm",
138 "VayuEVM", 139 "VayuEVM",
139 "DRA7xxEVM", 140 "DRA7xxEVM",
140}; 141};
141 142
143static const char *supported_bt_cards[] = {
144 "DRA7xxWiLink",
145};
146
142#define SUPPORTED_IN_DEVICES (AUDIO_DEVICE_IN_BUILTIN_MIC | \ 147#define SUPPORTED_IN_DEVICES (AUDIO_DEVICE_IN_BUILTIN_MIC | \
143 AUDIO_DEVICE_IN_WIRED_HEADSET | \ 148 AUDIO_DEVICE_IN_WIRED_HEADSET | \
144 AUDIO_DEVICE_IN_DEFAULT) 149 AUDIO_DEVICE_IN_DEFAULT)
@@ -204,7 +209,7 @@ struct pcm_config pcm_config_bt_out = {
204 .avail_min = BT_PERIOD_SIZE, 209 .avail_min = BT_PERIOD_SIZE,
205}; 210};
206 211
207static int find_supported_card(void) 212static int find_card_index(const char *supported_cards[], int num_supported)
208{ 213{
209 char name[256] = ""; 214 char name[256] = "";
210 int card = 0; 215 int card = 0;
@@ -218,7 +223,7 @@ static int find_supported_card(void)
218 if (ret) 223 if (ret)
219 break; 224 break;
220 225
221 for (i = 0; i < ARRAY_SIZE(supported_cards); ++i) { 226 for (i = 0; i < num_supported; ++i) {
222 if (supported_cards[i] && !strcmp(name, supported_cards[i])) { 227 if (supported_cards[i] && !strcmp(name, supported_cards[i])) {
223 ALOGV("Supported card '%s' found at %d", name, card); 228 ALOGV("Supported card '%s' found at %d", name, card);
224 found = 1; 229 found = 1;
@@ -498,7 +503,9 @@ static void voice_stream_exit(struct j6_voice_stream *stream)
498} 503}
499 504
500static int voice_stream_init(struct j6_voice_stream *stream, 505static int voice_stream_init(struct j6_voice_stream *stream,
506 unsigned int in_card,
501 unsigned int in_port, 507 unsigned int in_port,
508 unsigned int out_card,
502 unsigned int out_port, 509 unsigned int out_port,
503 bool needs_mono_remix) 510 bool needs_mono_remix)
504{ 511{
@@ -518,8 +525,8 @@ static int voice_stream_init(struct j6_voice_stream *stream,
518 return ret; 525 return ret;
519 } 526 }
520 527
521 stream->pcm_in = pcm_open(adev->card, in_port, PCM_IN, &stream->in_config); 528 stream->pcm_in = pcm_open(in_card, in_port, PCM_IN, &stream->in_config);
522 stream->pcm_out = pcm_open(adev->card, out_port, PCM_OUT, &stream->out_config); 529 stream->pcm_out = pcm_open(out_card, out_port, PCM_OUT, &stream->out_config);
523 530
524 if (!pcm_is_ready(stream->pcm_in) || !pcm_is_ready(stream->pcm_out)) { 531 if (!pcm_is_ready(stream->pcm_in) || !pcm_is_ready(stream->pcm_out)) {
525 ALOGE("voice_stream_init() failed to open pcm %s devices", stream->name); 532 ALOGE("voice_stream_init() failed to open pcm %s devices", stream->name);
@@ -574,7 +581,8 @@ static int enter_voice_call(struct j6_audio_device *adev)
574 voice->ul.in_config = pcm_config_capture; 581 voice->ul.in_config = pcm_config_capture;
575 voice->ul.out_config = pcm_config_bt_out; 582 voice->ul.out_config = pcm_config_bt_out;
576 voice->ul.dev = adev; 583 voice->ul.dev = adev;
577 ret = voice_stream_init(&voice->ul, adev->in_port, adev->bt_port, false); 584 ret = voice_stream_init(&voice->ul, adev->card, adev->in_port,
585 adev->bt_card, adev->bt_port, false);
578 if (ret) { 586 if (ret) {
579 ALOGE("enter_voice_call() failed to init uplink %d", ret); 587 ALOGE("enter_voice_call() failed to init uplink %d", ret);
580 return ret; 588 return ret;
@@ -585,7 +593,8 @@ static int enter_voice_call(struct j6_audio_device *adev)
585 voice->dl.in_config = pcm_config_bt_in; 593 voice->dl.in_config = pcm_config_bt_in;
586 voice->dl.out_config = pcm_config_playback; 594 voice->dl.out_config = pcm_config_playback;
587 voice->dl.dev = adev; 595 voice->dl.dev = adev;
588 ret = voice_stream_init(&voice->dl, adev->bt_port, adev->out_port, true); 596 ret = voice_stream_init(&voice->dl, adev->bt_card, adev->bt_port,
597 adev->card, adev->out_port, true);
589 if (ret) { 598 if (ret) {
590 ALOGE("enter_voice_call() failed to init downlink %d", ret); 599 ALOGE("enter_voice_call() failed to init downlink %d", ret);
591 goto err_dl_init; 600 goto err_dl_init;
@@ -1613,10 +1622,17 @@ static int adev_open(const hw_module_t* module, const char* name,
1613 1622
1614 adev->in_device = AUDIO_DEVICE_IN_BUILTIN_MIC; 1623 adev->in_device = AUDIO_DEVICE_IN_BUILTIN_MIC;
1615 adev->out_device = AUDIO_DEVICE_OUT_SPEAKER; 1624 adev->out_device = AUDIO_DEVICE_OUT_SPEAKER;
1616 adev->card = find_supported_card(); 1625 adev->card = find_card_index(supported_media_cards,
1626 ARRAY_SIZE(supported_media_cards));
1617 adev->in_port = 0; 1627 adev->in_port = 0;
1618 adev->out_port = 0; 1628 adev->out_port = 0;
1619 adev->bt_port = 2; 1629 ALOGI("Media card is hw:%d\n", adev->card);
1630
1631 adev->bt_card = find_card_index(supported_bt_cards,
1632 ARRAY_SIZE(supported_bt_cards));
1633 adev->bt_port = 0;
1634 ALOGI("Bluetooth SCO card is hw:%d\n", adev->bt_card);
1635
1620 adev->mic_mute = false; 1636 adev->mic_mute = false;
1621 adev->in_call = false; 1637 adev->in_call = false;
1622 adev->mode = AUDIO_MODE_NORMAL; 1638 adev->mode = AUDIO_MODE_NORMAL;