summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorcodeworkx <codeworkx@cyanogenmod.org>2013-01-09 17:11:11 +0100
committercodeworkx <codeworkx@cyanogenmod.org>2013-01-09 21:24:23 +0100
commit926921690a1328216125f09b519066fd8c381684 (patch)
tree70fc8bac78cd5b7cacbba9044ffd281f96fed7d9
parent3296c9c2cf2d0dd75b892e3100e43e1438c0729a (diff)
downloaddevice_samsung_p5100-926921690a1328216125f09b519066fd8c381684.zip
device_samsung_p5100-926921690a1328216125f09b519066fd8c381684.tar.gz
device_samsung_p5100-926921690a1328216125f09b519066fd8c381684.tar.bz2
p5100: fix bluetooth incall audio
Change-Id: I6c288241611239cc326fb7dded8b3287c9ef1be3
-rwxr-xr-xaudio/audio_hw.c82
-rw-r--r--audio/audio_hw.h14
2 files changed, 83 insertions, 13 deletions
diff --git a/audio/audio_hw.c b/audio/audio_hw.c
index a6a8759..9bd054a 100755
--- a/audio/audio_hw.c
+++ b/audio/audio_hw.c
@@ -95,6 +95,8 @@ struct espresso_audio_device {
int in_device;
struct pcm *pcm_modem_dl;
struct pcm *pcm_modem_ul;
+ struct pcm *pcm_bt_dl;
+ struct pcm *pcm_bt_ul;
int in_call;
float voice_volume;
struct espresso_stream_in *active_input;
@@ -350,7 +352,7 @@ void select_devices(struct espresso_audio_device *adev)
static int start_call(struct espresso_audio_device *adev)
{
- ALOGE("Opening modem PCMs");
+ ALOGV("Opening modem PCMs");
int bt_on;
bt_on = adev->out_device & AUDIO_DEVICE_OUT_ALL_SCO;
@@ -358,10 +360,8 @@ static int start_call(struct espresso_audio_device *adev)
/* Open modem PCM channels */
if (adev->pcm_modem_dl == NULL) {
- if (bt_on)
- adev->pcm_modem_dl = pcm_open(CARD_DEFAULT, PORT_BT, PCM_OUT, &pcm_config_vx);
- else
- adev->pcm_modem_dl = pcm_open(CARD_DEFAULT, PORT_MODEM, PCM_OUT, &pcm_config_vx);
+ ALOGD("Opening PCM modem DL stream");
+ adev->pcm_modem_dl = pcm_open(CARD_DEFAULT, PORT_MODEM, PCM_OUT, &pcm_config_vx);
if (!pcm_is_ready(adev->pcm_modem_dl)) {
ALOGE("cannot open PCM modem DL stream: %s", pcm_get_error(adev->pcm_modem_dl));
goto err_open_dl;
@@ -369,6 +369,7 @@ static int start_call(struct espresso_audio_device *adev)
}
if (adev->pcm_modem_ul == NULL) {
+ ALOGD("Opening PCM modem UL stream");
adev->pcm_modem_ul = pcm_open(CARD_DEFAULT, PORT_MODEM, PCM_IN, &pcm_config_vx);
if (!pcm_is_ready(adev->pcm_modem_ul)) {
ALOGE("cannot open PCM modem UL stream: %s", pcm_get_error(adev->pcm_modem_ul));
@@ -376,31 +377,88 @@ static int start_call(struct espresso_audio_device *adev)
}
}
+ ALOGD("Starting PCM modem streams");
pcm_start(adev->pcm_modem_dl);
pcm_start(adev->pcm_modem_ul);
+ /* Open bluetooth PCM channels */
+ if (bt_on) {
+ ALOGV("Opening bluetooth PCMs");
+
+ if (adev->pcm_bt_dl == NULL) {
+ ALOGD("Opening PCM bluetooth DL stream");
+ adev->pcm_bt_dl = pcm_open(CARD_DEFAULT, PORT_BT, PCM_OUT, &pcm_config_vx);
+ if (!pcm_is_ready(adev->pcm_bt_dl)) {
+ ALOGE("cannot open PCM bluetooth DL stream: %s", pcm_get_error(adev->pcm_bt_dl));
+ goto err_open_dl;
+ }
+ }
+
+ if (adev->pcm_bt_ul == NULL) {
+ ALOGD("Opening PCM bluetooth UL stream");
+ adev->pcm_bt_ul = pcm_open(CARD_DEFAULT, PORT_BT, PCM_IN, &pcm_config_vx);
+ if (!pcm_is_ready(adev->pcm_bt_ul)) {
+ ALOGE("cannot open PCM bluetooth UL stream: %s", pcm_get_error(adev->pcm_bt_ul));
+ goto err_open_ul;
+ }
+ }
+ ALOGD("Starting PCM bluetooth streams");
+ pcm_start(adev->pcm_bt_dl);
+ pcm_start(adev->pcm_bt_ul);
+ }
+
return 0;
err_open_ul:
pcm_close(adev->pcm_modem_ul);
adev->pcm_modem_ul = NULL;
+ pcm_close(adev->pcm_bt_ul);
+ adev->pcm_bt_ul = NULL;
err_open_dl:
pcm_close(adev->pcm_modem_dl);
adev->pcm_modem_dl = NULL;
+ pcm_close(adev->pcm_bt_dl);
+ adev->pcm_bt_dl = NULL;
return -ENOMEM;
}
static void end_call(struct espresso_audio_device *adev)
{
- ALOGE("Closing modem PCMs");
+ int bt_on;
+ bt_on = adev->out_device & AUDIO_DEVICE_OUT_ALL_SCO;
- pcm_stop(adev->pcm_modem_dl);
- pcm_stop(adev->pcm_modem_ul);
- pcm_close(adev->pcm_modem_dl);
- pcm_close(adev->pcm_modem_ul);
+ if (adev->pcm_modem_dl != NULL) {
+ ALOGD("Stopping modem DL PCM");
+ pcm_stop(adev->pcm_modem_dl);
+ ALOGV("Closing modem DL PCM");
+ pcm_close(adev->pcm_modem_dl);
+ }
+ if (adev->pcm_modem_ul != NULL) {
+ ALOGD("Stopping modem UL PCM");
+ pcm_stop(adev->pcm_modem_ul);
+ ALOGV("Closing modem UL PCM");
+ pcm_close(adev->pcm_modem_ul);
+ }
adev->pcm_modem_dl = NULL;
adev->pcm_modem_ul = NULL;
+
+ if (bt_on) {
+ if (adev->pcm_bt_dl != NULL) {
+ ALOGD("Stopping bluetooth DL PCM");
+ pcm_stop(adev->pcm_bt_dl);
+ ALOGV("Closing bluetooth DL PCM");
+ pcm_close(adev->pcm_bt_dl);
+ }
+ if (adev->pcm_bt_ul != NULL) {
+ ALOGD("Stopping bluetooth UL PCM");
+ pcm_stop(adev->pcm_bt_ul);
+ ALOGV("Closing bluetooth UL PCM");
+ pcm_close(adev->pcm_bt_ul);
+ }
+ }
+ adev->pcm_bt_dl = NULL;
+ adev->pcm_bt_ul = NULL;
}
static void set_eq_filter(struct espresso_audio_device *adev)
@@ -2981,6 +3039,8 @@ static int adev_open(const hw_module_t* module, const char* name,
adev->pcm_modem_dl = NULL;
adev->pcm_modem_ul = NULL;
+ adev->pcm_bt_dl = NULL;
+ adev->pcm_bt_ul = NULL;
adev->voice_volume = 1.0f;
adev->tty_mode = TTY_MODE_OFF;
adev->bluetooth_nrec = true;
@@ -3012,7 +3072,7 @@ struct audio_module HAL_MODULE_INFO_SYM = {
.module_api_version = AUDIO_MODULE_API_VERSION_0_1,
.hal_api_version = HARDWARE_HAL_API_VERSION,
.id = AUDIO_HARDWARE_MODULE_ID,
- .name = "M0 audio HW HAL",
+ .name = "Piranha audio HW HAL",
.author = "The CyanogenMod Project",
.methods = &hal_module_methods,
},
diff --git a/audio/audio_hw.h b/audio/audio_hw.h
index 23bd893..3ef0e65 100644
--- a/audio/audio_hw.h
+++ b/audio/audio_hw.h
@@ -178,7 +178,17 @@ struct route_setting bt_output[] = {
};
struct route_setting bt_input[] = {
- { .ctl_name = "AIF1ADC1R Mixer AIF2 Switch", .intval = 1, },
- { .ctl_name = "AIF1ADC1L Mixer AIF2 Switch", .intval = 1, },
+ { .ctl_name = "AIF2ADC Mux", .intval = 1, },
+ { .ctl_name = "AIF2DACR Source", .intval = 1, },
+ { .ctl_name = "HP Switch", .intval = 0, },
+ { .ctl_name = "DAC1L Mixer AIF2 Switch", .intval = 1, },
+ { .ctl_name = "DAC1R Mixer AIF2 Switch", .intval = 1, },
+ { .ctl_name = "AIF1ADC1R Mixer AIF2 Switch", .intval = 0, },
+ { .ctl_name = "AIF1ADC1L Mixer AIF2 Switch", .intval = 0, },
+ { .ctl_name = "AIF2DAC2R Mixer Right Sidetone Switch", .intval = 0, },
+ { .ctl_name = "AIF2DAC2R Mixer Left Sidetone Switch", .intval = 1, },
+ { .ctl_name = "AIF1ADC1R Mixer AIF2 Switch", .intval = 0, },
+ { .ctl_name = "AIF1ADC1L Mixer AIF2 Switch", .intval = 0, },
+ { .ctl_name = "MIXINL IN1L Switch", .intval = 0, },
{ .ctl_name = NULL, },
};