summaryrefslogtreecommitdiffstats
path: root/audio
diff options
context:
space:
mode:
authorSergii Iegorov2012-11-26 09:35:25 -0600
committerDaniel Levin2012-12-04 08:06:02 -0600
commit12b48037881f67a07f52fec4cfd51151be43b1fb (patch)
treeaceda0ae20ee76373bfc9a2bc02ad99b3c09a510 /audio
parentdb182b788ed1b4b1e612389b764dc99df6341741 (diff)
downloaddevice-ti-common-open-12b48037881f67a07f52fec4cfd51151be43b1fb.tar.gz
device-ti-common-open-12b48037881f67a07f52fec4cfd51151be43b1fb.tar.xz
device-ti-common-open-12b48037881f67a07f52fec4cfd51151be43b1fb.zip
Porting Audio HAL to use Input device bit
Audio devices musks now intersects for output and input and contain special bit to identify an input device explicitely. Audio HAL should thus use different variables for input devices and output ones. Change-Id: I156fad5fe457780cfb7ba710ff75b319506cfb2b Signed-off-by: Sergii Iegorov <x0155539@ti.com>
Diffstat (limited to 'audio')
-rw-r--r--audio/audio_hw.c81
1 files changed, 44 insertions, 37 deletions
diff --git a/audio/audio_hw.c b/audio/audio_hw.c
index 05965e7..feeb240 100644
--- a/audio/audio_hw.c
+++ b/audio/audio_hw.c
@@ -836,6 +836,11 @@ struct mixer_ctls
836 836
837#define MAX_OUTPUTS 2 837#define MAX_OUTPUTS 2
838 838
839struct audio_devices {
840 int out_devices;
841 int in_devices;
842};
843
839struct selected_stream_output_device { 844struct selected_stream_output_device {
840 struct omap_stream_out* id; 845 struct omap_stream_out* id;
841 int device; 846 int device;
@@ -848,8 +853,8 @@ struct omap_audio_device {
848 struct mixer *mixer; 853 struct mixer *mixer;
849 struct mixer_ctls mixer_ctls; 854 struct mixer_ctls mixer_ctls;
850 int mode; 855 int mode;
851 int devices; 856 struct audio_devices devices;
852 int cur_devices; 857 struct audio_devices cur_devices;
853 struct selected_stream_output_device selected_device[MAX_OUTPUTS]; 858 struct selected_stream_output_device selected_device[MAX_OUTPUTS];
854 struct pcm *pcm_modem_dl; 859 struct pcm *pcm_modem_dl;
855 struct pcm *pcm_modem_ul; 860 struct pcm *pcm_modem_ul;
@@ -1146,17 +1151,17 @@ static void set_eq_filter(struct omap_audio_device *adev)
1146 LOGFUNC("%s(%p)", __FUNCTION__, adev); 1151 LOGFUNC("%s(%p)", __FUNCTION__, adev);
1147 1152
1148 /* DL1_EQ can't be used for bt */ 1153 /* DL1_EQ can't be used for bt */
1149 int dl1_eq_applicable = adev->devices & (AUDIO_DEVICE_OUT_WIRED_HEADSET | 1154 int dl1_eq_applicable = adev->devices.out_devices & (AUDIO_DEVICE_OUT_WIRED_HEADSET |
1150 AUDIO_DEVICE_OUT_WIRED_HEADPHONE | AUDIO_DEVICE_OUT_EARPIECE); 1155 AUDIO_DEVICE_OUT_WIRED_HEADPHONE | AUDIO_DEVICE_OUT_EARPIECE);
1151 1156
1152 if (!adev->dl2_support) 1157 if (!adev->dl2_support)
1153 dl1_eq_applicable |= adev->devices & AUDIO_DEVICE_OUT_SPEAKER; 1158 dl1_eq_applicable |= adev->devices.out_devices & AUDIO_DEVICE_OUT_SPEAKER;
1154 1159
1155 /* 4Khz LPF is used only in NB-AMR voicecall */ 1160 /* 4Khz LPF is used only in NB-AMR voicecall */
1156 if ((adev->mode == AUDIO_MODE_IN_CALL) && dl1_eq_applicable && 1161 if ((adev->mode == AUDIO_MODE_IN_CALL) && dl1_eq_applicable &&
1157 (adev->tty_mode == TTY_MODE_OFF) && !adev->wb_amr) 1162 (adev->tty_mode == TTY_MODE_OFF) && !adev->wb_amr)
1158 mixer_ctl_set_enum_by_string(adev->mixer_ctls.dl1_eq, MIXER_4KHZ_LPF_0DB); 1163 mixer_ctl_set_enum_by_string(adev->mixer_ctls.dl1_eq, MIXER_4KHZ_LPF_0DB);
1159 else if (!adev->dl2_support && (adev->devices & AUDIO_DEVICE_OUT_SPEAKER)) 1164 else if (!adev->dl2_support && (adev->devices.out_devices & AUDIO_DEVICE_OUT_SPEAKER))
1160 mixer_ctl_set_enum_by_string(adev->mixer_ctls.dl1_eq, MIXER_450HZ_HIGH_PASS); 1165 mixer_ctl_set_enum_by_string(adev->mixer_ctls.dl1_eq, MIXER_450HZ_HIGH_PASS);
1161 else 1166 else
1162 mixer_ctl_set_enum_by_string(adev->mixer_ctls.dl1_eq, MIXER_FLAT_RESPONSE); 1167 mixer_ctl_set_enum_by_string(adev->mixer_ctls.dl1_eq, MIXER_FLAT_RESPONSE);
@@ -1210,7 +1215,7 @@ static void set_incall_device(struct omap_audio_device *adev)
1210 * in call. In this case, an output stream device is not provided, but 1215 * in call. In this case, an output stream device is not provided, but
1211 * is instead provided in adev->devices. 1216 * is instead provided in adev->devices.
1212 */ 1217 */
1213 switch(adev->devices & AUDIO_DEVICE_OUT_ALL) { 1218 switch(adev->devices.out_devices & AUDIO_DEVICE_OUT_ALL) {
1214 case AUDIO_DEVICE_OUT_EARPIECE: 1219 case AUDIO_DEVICE_OUT_EARPIECE:
1215 device_type = SOUND_AUDIO_PATH_HANDSET; 1220 device_type = SOUND_AUDIO_PATH_HANDSET;
1216 break; 1221 break;
@@ -1330,7 +1335,7 @@ static void set_output_volumes(struct omap_audio_device *adev)
1330 1335
1331 speaker_volume = adev->mode == AUDIO_MODE_IN_CALL ? VOICE_CALL_SPEAKER_VOLUME : 1336 speaker_volume = adev->mode == AUDIO_MODE_IN_CALL ? VOICE_CALL_SPEAKER_VOLUME :
1332 NORMAL_SPEAKER_VOLUME; 1337 NORMAL_SPEAKER_VOLUME;
1333 headset_volume = adev->devices & AUDIO_DEVICE_OUT_WIRED_HEADSET ? 1338 headset_volume = adev->devices.out_devices & AUDIO_DEVICE_OUT_WIRED_HEADSET ?
1334 HEADSET_VOLUME : 1339 HEADSET_VOLUME :
1335 HEADPHONE_VOLUME; 1340 HEADPHONE_VOLUME;
1336 1341
@@ -1385,11 +1390,12 @@ static void select_mode(struct omap_audio_device *adev)
1385 a call. This works because we're sure that the audio policy 1390 a call. This works because we're sure that the audio policy
1386 manager will update the output device after the audio mode 1391 manager will update the output device after the audio mode
1387 change, even if the device selection did not change. */ 1392 change, even if the device selection did not change. */
1388 if ((adev->devices & AUDIO_DEVICE_OUT_ALL) == AUDIO_DEVICE_OUT_SPEAKER) 1393 if ((adev->devices.out_devices & AUDIO_DEVICE_OUT_ALL) == AUDIO_DEVICE_OUT_SPEAKER) {
1389 adev->devices = AUDIO_DEVICE_OUT_EARPIECE | 1394 adev->devices.out_devices = AUDIO_DEVICE_OUT_EARPIECE;
1390 AUDIO_DEVICE_IN_BUILTIN_MIC; 1395 adev->devices.in_devices = AUDIO_DEVICE_IN_BUILTIN_MIC & ~AUDIO_DEVICE_BIT_IN;
1391 else 1396 } else {
1392 adev->devices &= ~AUDIO_DEVICE_OUT_SPEAKER; 1397 adev->devices.out_devices &= ~AUDIO_DEVICE_OUT_SPEAKER;
1398 }
1393 select_output_device(adev, NULL); 1399 select_output_device(adev, NULL);
1394 if (adev->modem) { 1400 if (adev->modem) {
1395 ril_set_call_clock_sync(&adev->ril, SOUND_CLOCK_START); 1401 ril_set_call_clock_sync(&adev->ril, SOUND_CLOCK_START);
@@ -1502,18 +1508,18 @@ static void select_output_device(struct omap_audio_device *adev,
1502 adev->selected_device[i].device = out->device; 1508 adev->selected_device[i].device = out->device;
1503 } 1509 }
1504 } 1510 }
1505 adev->devices &= ~AUDIO_DEVICE_OUT_ALL; 1511 adev->devices.out_devices &= ~AUDIO_DEVICE_OUT_ALL;
1506 for(i = 0; i < MAX_OUTPUTS; i++) { 1512 for(i = 0; i < MAX_OUTPUTS; i++) {
1507 if (adev->selected_device[i].id) 1513 if (adev->selected_device[i].id)
1508 adev->devices |= adev->selected_device[i].device; 1514 adev->devices.out_devices |= adev->selected_device[i].device;
1509 } 1515 }
1510 } 1516 }
1511 headset_on |= adev->devices & AUDIO_DEVICE_OUT_WIRED_HEADSET; 1517 headset_on |= adev->devices.out_devices & AUDIO_DEVICE_OUT_WIRED_HEADSET;
1512 headphone_on |= adev->devices & AUDIO_DEVICE_OUT_WIRED_HEADPHONE; 1518 headphone_on |= adev->devices.out_devices & AUDIO_DEVICE_OUT_WIRED_HEADPHONE;
1513 speaker_on |= adev->devices & AUDIO_DEVICE_OUT_SPEAKER; 1519 speaker_on |= adev->devices.out_devices & AUDIO_DEVICE_OUT_SPEAKER;
1514 earpiece_on |= adev->devices & AUDIO_DEVICE_OUT_EARPIECE; 1520 earpiece_on |= adev->devices.out_devices & AUDIO_DEVICE_OUT_EARPIECE;
1515 bt_on |= adev->devices & AUDIO_DEVICE_OUT_ALL_SCO; 1521 bt_on |= adev->devices.out_devices & AUDIO_DEVICE_OUT_ALL_SCO;
1516 fmtx_on |= adev->devices & AUDIO_DEVICE_OUT_FM_RADIO_TX; 1522 fmtx_on |= adev->devices.out_devices & AUDIO_DEVICE_OUT_FM_RADIO_TX;
1517 1523
1518 /* force rx path according to TTY mode when in call */ 1524 /* force rx path according to TTY mode when in call */
1519 if (adev->mode == AUDIO_MODE_IN_CALL && !bt_on) { 1525 if (adev->mode == AUDIO_MODE_IN_CALL && !bt_on) {
@@ -1590,13 +1596,13 @@ static void select_output_device(struct omap_audio_device *adev,
1590 /* Automatic change of HSDAC power mode needed for earpiece 1596 /* Automatic change of HSDAC power mode needed for earpiece
1591 (which requires High-Perfomance mode) is not allowed 1597 (which requires High-Perfomance mode) is not allowed
1592 when DACs are active, disable DL1 outputs first */ 1598 when DACs are active, disable DL1 outputs first */
1593 if (((adev->cur_devices & AUDIO_DEVICE_OUT_WIRED_HEADSET) || 1599 if (((adev->cur_devices.out_devices & AUDIO_DEVICE_OUT_WIRED_HEADSET) ||
1594 (adev->cur_devices & AUDIO_DEVICE_OUT_WIRED_HEADPHONE)) 1600 (adev->cur_devices.out_devices & AUDIO_DEVICE_OUT_WIRED_HEADPHONE))
1595 && earpiece_on) { 1601 && earpiece_on) {
1596 set_route_by_array(adev->mixer, hs_output, 0); 1602 set_route_by_array(adev->mixer, hs_output, 0);
1597 } 1603 }
1598 1604
1599 if ((adev->cur_devices & AUDIO_DEVICE_OUT_EARPIECE) 1605 if ((adev->cur_devices.out_devices & AUDIO_DEVICE_OUT_EARPIECE)
1600 && (headset_on || headphone_on)) { 1606 && (headset_on || headphone_on)) {
1601 mixer_ctl_set_value(adev->mixer_ctls.earpiece_enable, 0, 0); 1607 mixer_ctl_set_value(adev->mixer_ctls.earpiece_enable, 0, 0);
1602 } 1608 }
@@ -1734,9 +1740,9 @@ static void select_input_device(struct omap_audio_device *adev)
1734 int headset_on = 0; 1740 int headset_on = 0;
1735 int main_mic_on = 0; 1741 int main_mic_on = 0;
1736 int sub_mic_on = 0; 1742 int sub_mic_on = 0;
1737 int bt_on = adev->devices & AUDIO_DEVICE_IN_ALL_SCO; 1743 int bt_on = adev->devices.in_devices & AUDIO_DEVICE_IN_ALL_SCO;
1738 int hw_is_stereo_only = 0; 1744 int hw_is_stereo_only = 0;
1739 int fm_rx_on = adev->devices & AUDIO_DEVICE_IN_FM_RADIO_RX; 1745 int fm_rx_on = adev->devices.in_devices & AUDIO_DEVICE_IN_FM_RADIO_RX;
1740 1746
1741 LOGFUNC("%s(%p)", __FUNCTION__, adev); 1747 LOGFUNC("%s(%p)", __FUNCTION__, adev);
1742 1748
@@ -1744,12 +1750,12 @@ static void select_input_device(struct omap_audio_device *adev)
1744 if ((adev->mode != AUDIO_MODE_IN_CALL) && (adev->active_input != 0)) { 1750 if ((adev->mode != AUDIO_MODE_IN_CALL) && (adev->active_input != 0)) {
1745 /* sub mic is used for camcorder or VoIP on speaker phone */ 1751 /* sub mic is used for camcorder or VoIP on speaker phone */
1746 sub_mic_on = (adev->active_input->source == AUDIO_SOURCE_CAMCORDER) || 1752 sub_mic_on = (adev->active_input->source == AUDIO_SOURCE_CAMCORDER) ||
1747 ((adev->devices & AUDIO_DEVICE_OUT_SPEAKER) && 1753 ((adev->devices.out_devices & AUDIO_DEVICE_OUT_SPEAKER) &&
1748 (adev->active_input->source == AUDIO_SOURCE_VOICE_COMMUNICATION)); 1754 (adev->active_input->source == AUDIO_SOURCE_VOICE_COMMUNICATION));
1749 } 1755 }
1750 if (!sub_mic_on) { 1756 if (!sub_mic_on) {
1751 headset_on = adev->devices & AUDIO_DEVICE_IN_WIRED_HEADSET; 1757 headset_on = adev->devices.in_devices & AUDIO_DEVICE_IN_WIRED_HEADSET;
1752 main_mic_on = adev->devices & AUDIO_DEVICE_IN_BUILTIN_MIC; 1758 main_mic_on = adev->devices.in_devices & AUDIO_DEVICE_IN_BUILTIN_MIC;
1753 } 1759 }
1754 } 1760 }
1755 1761
@@ -2493,8 +2499,8 @@ static int start_input_stream(struct omap_stream_in *in)
2493 adev->active_input = in; 2499 adev->active_input = in;
2494 2500
2495 if (adev->mode != AUDIO_MODE_IN_CALL) { 2501 if (adev->mode != AUDIO_MODE_IN_CALL) {
2496 adev->devices &= ~AUDIO_DEVICE_IN_ALL; 2502 adev->devices.in_devices &= ~AUDIO_DEVICE_IN_ALL;
2497 adev->devices |= in->device; 2503 adev->devices.in_devices |= in->device & ~AUDIO_DEVICE_BIT_IN;;
2498 select_input_device(adev); 2504 select_input_device(adev);
2499 adev->vx_rec_on = false; 2505 adev->vx_rec_on = false;
2500 } else { 2506 } else {
@@ -2506,7 +2512,7 @@ static int start_input_stream(struct omap_stream_in *in)
2506 adev->vx_rec_on = true; 2512 adev->vx_rec_on = true;
2507 } 2513 }
2508 2514
2509 if(adev->devices & AUDIO_DEVICE_IN_USB_HEADSET) { 2515 if(adev->devices.in_devices & AUDIO_DEVICE_IN_USB_HEADSET) {
2510 adev->input_requires_stereo = 0; 2516 adev->input_requires_stereo = 0;
2511 } 2517 }
2512 2518
@@ -2523,13 +2529,13 @@ static int start_input_stream(struct omap_stream_in *in)
2523 if (in->remix_at_driver) 2529 if (in->remix_at_driver)
2524 in->config.channels = in->remix_at_driver->in_chans; 2530 in->config.channels = in->remix_at_driver->in_chans;
2525 2531
2526 if(adev->devices & AUDIO_DEVICE_IN_USB_HEADSET) { 2532 if(adev->devices.in_devices & AUDIO_DEVICE_IN_USB_HEADSET) {
2527 card = CARD_OMAP_USB; 2533 card = CARD_OMAP_USB;
2528 /*device should be 0 for usb headset capture */ 2534 /*device should be 0 for usb headset capture */
2529 device = PORT_MM; 2535 device = PORT_MM;
2530 } 2536 }
2531 2537
2532 if(adev->devices & AUDIO_DEVICE_IN_FM_RADIO_RX) { 2538 if(adev->devices.in_devices & AUDIO_DEVICE_IN_FM_RADIO_RX) {
2533 card = CARD_OMAP_DEFAULT; 2539 card = CARD_OMAP_DEFAULT;
2534 /*device should be PORT_MM2_UL for FM capture */ 2540 /*device should be PORT_MM2_UL for FM capture */
2535 device = PORT_MM2_UL; 2541 device = PORT_MM2_UL;
@@ -2548,7 +2554,7 @@ static int start_input_stream(struct omap_stream_in *in)
2548 adev->active_input = NULL; 2554 adev->active_input = NULL;
2549 return -ENOMEM; 2555 return -ENOMEM;
2550 } 2556 }
2551 if (adev->devices & AUDIO_DEVICE_IN_FM_RADIO_RX) { 2557 if (adev->devices.in_devices & AUDIO_DEVICE_IN_FM_RADIO_RX) {
2552 ALOGI("FM:FM capture path opened successfully!!\nFM:Triggering loopback for FM capture path"); 2558 ALOGI("FM:FM capture path opened successfully!!\nFM:Triggering loopback for FM capture path");
2553 fm_enable = true; 2559 fm_enable = true;
2554 pcm_start(in->pcm); 2560 pcm_start(in->pcm);
@@ -2628,7 +2634,7 @@ static int do_input_standby(struct omap_stream_in *in)
2628 2634
2629 adev->active_input = 0; 2635 adev->active_input = 0;
2630 if (adev->mode != AUDIO_MODE_IN_CALL) { 2636 if (adev->mode != AUDIO_MODE_IN_CALL) {
2631 adev->devices &= ~AUDIO_DEVICE_IN_ALL; 2637 adev->devices.in_devices &= ~AUDIO_DEVICE_IN_ALL;
2632 select_input_device(adev); 2638 select_input_device(adev);
2633 } 2639 }
2634 2640
@@ -3467,7 +3473,7 @@ static int set_voice_volume(struct audio_hw_device *dev, float volume)
3467 3473
3468 /* in-call output devices are maintained in adev->devices */ 3474 /* in-call output devices are maintained in adev->devices */
3469 if (adev->mode == AUDIO_MODE_IN_CALL) { 3475 if (adev->mode == AUDIO_MODE_IN_CALL) {
3470 switch(adev->devices & AUDIO_DEVICE_OUT_ALL) { 3476 switch(adev->devices.out_devices & AUDIO_DEVICE_OUT_ALL) {
3471 case AUDIO_DEVICE_OUT_EARPIECE: 3477 case AUDIO_DEVICE_OUT_EARPIECE:
3472 default: 3478 default:
3473 sound_type = SOUND_TYPE_VOICE; 3479 sound_type = SOUND_TYPE_VOICE;
@@ -3921,7 +3927,8 @@ static int adev_open(const hw_module_t* module, const char* name,
3921 set_route_by_array(adev->mixer, hf_dl1, 1); 3927 set_route_by_array(adev->mixer, hf_dl1, 1);
3922 } 3928 }
3923 adev->mode = AUDIO_MODE_NORMAL; 3929 adev->mode = AUDIO_MODE_NORMAL;
3924 adev->devices = AUDIO_DEVICE_OUT_SPEAKER | AUDIO_DEVICE_IN_BUILTIN_MIC; 3930 adev->devices.out_devices = AUDIO_DEVICE_OUT_SPEAKER;
3931 adev->devices.in_devices = AUDIO_DEVICE_IN_BUILTIN_MIC & ~AUDIO_DEVICE_BIT_IN;
3925 3932
3926 adev->pcm_modem_dl = NULL; 3933 adev->pcm_modem_dl = NULL;
3927 adev->pcm_modem_ul = NULL; 3934 adev->pcm_modem_ul = NULL;