Home | History | Annotate | Download | only in hal

Lines Matching refs:adev

178 static int set_voice_volume_l(struct audio_device *adev, float volume);
212 int enable_audio_route(struct audio_device *adev,
229 platform_add_backend_name(adev->platform, mixer_path, snd_device);
231 audio_route_apply_and_update_path(adev->audio_route, mixer_path);
237 int disable_audio_route(struct audio_device *adev,
252 platform_add_backend_name(adev->platform, mixer_path, snd_device);
254 audio_route_reset_and_update_path(adev->audio_route, mixer_path);
260 int enable_snd_device(struct audio_device *adev,
269 adev->snd_dev_ref_cnt[snd_device]++;
270 if (adev->snd_dev_ref_cnt[snd_device] > 1) {
276 if (platform_send_audio_calibration(adev->platform, snd_device) < 0) {
277 adev->snd_dev_ref_cnt[snd_device]--;
283 audio_route_apply_and_update_path(adev->audio_route, dev_path);
288 int disable_snd_device(struct audio_device *adev,
296 if (adev->snd_dev_ref_cnt[snd_device] <= 0) {
300 adev->snd_dev_ref_cnt[snd_device]--;
301 if (adev->snd_dev_ref_cnt[snd_device] == 0) {
304 audio_route_reset_and_update_path(adev->audio_route, dev_path);
309 static void check_usecases_codec_backend(struct audio_device *adev,
333 list_for_each(node, &adev->usecase_list) {
342 disable_audio_route(adev, usecase);
349 list_for_each(node, &adev->usecase_list) {
352 disable_snd_device(adev, usecase->out_snd_device);
356 list_for_each(node, &adev->usecase_list) {
359 enable_snd_device(adev, snd_device);
365 list_for_each(node, &adev->usecase_list) {
370 enable_audio_route(adev, usecase);
376 static void check_and_route_capture_usecases(struct audio_device *adev,
398 list_for_each(node, &adev->usecase_list) {
406 disable_audio_route(adev, usecase);
413 list_for_each(node, &adev->usecase_list) {
416 disable_snd_device(adev, usecase->in_snd_device);
420 list_for_each(node, &adev->usecase_list) {
423 enable_snd_device(adev, snd_device);
429 list_for_each(node, &adev->usecase_list) {
434 enable_audio_route(adev, usecase);
468 static audio_usecase_t get_voice_usecase_id_from_list(struct audio_device *adev)
473 list_for_each(node, &adev->usecase_list) {
483 adev,
489 list_for_each(node, &adev->usecase_list) {
497 int select_devices(struct audio_device *adev,
509 usecase = get_usecase_from_list(adev, uc_id);
517 out_snd_device = platform_get_output_snd_device(adev->platform,
519 in_snd_device = platform_get_input_snd_device(adev->platform, usecase->stream.out->devices);
529 if (voice_is_in_call(adev)) {
530 vc_usecase = get_usecase_from_list(adev,
531 get_voice_usecase_id_from_list(adev));
538 } else if (audio_extn_hfp_is_active(adev)) {
540 hfp_usecase = get_usecase_from_list(adev, hfp_ucid);
550 out_snd_device = platform_get_output_snd_device(adev->platform,
552 if (usecase->stream.out == adev->primary_output &&
553 adev->active_input &&
554 adev->active_input->source == AUDIO_SOURCE_VOICE_COMMUNICATION &&
556 select_devices(adev, adev->active_input->usecase);
564 if (adev->active_input->source == AUDIO_SOURCE_VOICE_COMMUNICATION &&
565 adev->primary_output && !adev->primary_output->standby) {
566 out_device = adev->primary_output->devices;
567 platform_set_echo_reference(adev, false, AUDIO_DEVICE_NONE);
571 in_snd_device = platform_get_input_snd_device(adev->platform, out_device);
593 status = platform_switch_voice_call_device_pre(adev->platform);
598 disable_audio_route(adev, usecase);
599 disable_snd_device(adev, usecase->out_snd_device);
603 disable_audio_route(adev, usecase);
604 disable_snd_device(adev, usecase->in_snd_device);
614 status = platform_switch_voice_call_enable_device_config(adev->platform,
622 check_usecases_codec_backend(adev, usecase, out_snd_device);
623 enable_snd_device(adev, out_snd_device);
627 check_and_route_capture_usecases(adev, usecase, in_snd_device);
628 enable_snd_device(adev, in_snd_device);
632 status = platform_switch_voice_call_device_post(adev->platform,
639 enable_audio_route(adev, usecase);
646 status = platform_switch_voice_call_usecase_route_post(adev->platform,
657 struct audio_device *adev = in->dev;
659 adev->active_input = NULL;
663 uc_info = get_usecase_from_list(adev, in->usecase);
671 disable_audio_route(adev, uc_info);
674 disable_snd_device(adev, uc_info->in_snd_device);
688 struct audio_device *adev = in->dev;
699 adev->active_input = in;
708 list_add_tail(&adev->usecase_list, &uc_info->list);
709 select_devices(adev, in->usecase);
712 __func__, adev->snd_card, in->pcm_device_id, in->config.channels);
723 in->pcm = pcm_open(adev->snd_card, in->pcm_device_id,
748 adev->active_input = NULL;
896 static bool allow_hdmi_channel_config(struct audio_device *adev)
902 list_for_each(node, &adev->usecase_list) {
927 static int check_and_set_hdmi_channels(struct audio_device *adev,
934 if (!allow_hdmi_channel_config(adev))
937 if (channels == adev->cur_hdmi_channels) {
942 platform_set_hdmi_channels(adev->platform, channels);
943 adev->cur_hdmi_channels = channels;
950 list_for_each(node, &adev->usecase_list) {
954 disable_audio_route(adev, usecase);
962 list_for_each(node, &adev->usecase_list) {
966 enable_audio_route(adev, usecase);
977 struct audio_device *adev = out->dev;
981 uc_info = get_usecase_from_list(adev, out->usecase);
989 if (adev->visualizer_stop_output != NULL)
990 adev->visualizer_stop_output(out->handle, out->pcm_device_id);
991 if (adev->offload_effects_stop_output != NULL)
992 adev->offload_effects_stop_output(out->handle, out->pcm_device_id);
996 disable_audio_route(adev, uc_info);
999 disable_snd_device(adev, uc_info->out_snd_device);
1004 audio_extn_extspk_update(adev->extspk);
1008 check_and_set_hdmi_channels(adev, DEFAULT_HDMI_OUT_CHANNELS);
1018 struct audio_device *adev = out->dev;
1040 check_and_set_hdmi_channels(adev, out->config.channels);
1042 list_add_tail(&adev->usecase_list, &uc_info->list);
1044 select_devices(adev, out->usecase);
1046 audio_extn_extspk_update(adev->extspk);
1049 __func__, adev->snd_card, out->pcm_device_id, out->config.format);
1060 out->pcm = pcm_open(adev->snd_card, out->pcm_device_id,
1079 out->compr = compress_open(adev->snd_card, out->pcm_device_id,
1091 if (adev->visualizer_start_output != NULL)
1092 adev->visualizer_start_output(out->handle, out->pcm_device_id);
1093 if (adev->offload_effects_start_output != NULL)
1094 adev->offload_effects_start_output(out->handle, out->pcm_device_id);
1203 struct audio_device *adev = out->dev;
1210 pthread_mutex_lock(&adev->lock);
1227 pthread_mutex_unlock(&adev->lock);
1271 static bool output_drives_call(struct audio_device *adev, struct stream_out *out)
1273 return out == adev->primary_output || out == adev->voice_tx_output;
1279 struct audio_device *adev = out->dev;
1295 pthread_mutex_lock(&adev->lock);
1331 select_devices(adev, out->usecase);
1333 if (output_drives_call(adev, out)) {
1334 if (!voice_is_in_call(adev)) {
1335 if (adev->mode == AUDIO_MODE_IN_CALL) {
1336 adev->current_call_output = out;
1337 ret = voice_start_call(adev);
1340 adev->current_call_output = out;
1341 voice_update_devices_for_all_voice_usecases(adev);
1346 pthread_mutex_unlock(&adev->lock);
1350 audio_extn_extspk_update(adev->extspk);
1424 struct audio_device *adev = out->dev;
1426 ctl = mixer_get_ctl_by_name(adev->mixer, mixer_ctl_name);
1434 ctl = mixer_get_ctl_by_name(adev->mixer, ctl_name);
1453 struct audio_device *adev = out->dev;
1459 pthread_mutex_lock(&adev->lock);
1461 pthread_mutex_unlock(&adev->lock);
1715 struct audio_device *adev = in->dev;
1720 pthread_mutex_lock(&adev->lock);
1726 adev->enable_voicerx = false;
1727 platform_set_echo_reference(adev, false, AUDIO_DEVICE_NONE );
1729 pthread_mutex_unlock(&adev->lock);
1744 struct audio_device *adev = in->dev;
1757 pthread_mutex_lock(&adev->lock);
1774 status = select_devices(adev, in->usecase);
1778 pthread_mutex_unlock(&adev->lock);
1801 struct audio_device *adev = in->dev;
1806 pthread_mutex_lock(&adev->lock);
1808 pthread_mutex_unlock(&adev->lock);
1825 * No need to acquire adev->lock to read mic_muted here as we don't change its state.
1827 if (ret == 0 && adev->mic_muted && in->usecase != USECASE_AUDIO_RECORD_AFE_PROXY)
1852 struct audio_device *adev = in->dev;
1868 adev->enable_voicerx = enable;
1871 list_for_each(node, &adev->usecase_list) {
1874 select_devices(adev, usecase->id);
1915 struct audio_device *adev = (struct audio_device *)dev;
1929 out->dev = adev;
1940 pthread_mutex_lock(&adev->lock);
1942 pthread_mutex_unlock(&adev->lock);
2028 adev->voice_tx_output = out;
2039 && pcm_params_format_test(adev->use_case_table[out->usecase],
2058 if (adev->primary_output == NULL)
2059 adev->primary_output = out;
2068 pthread_mutex_lock(&adev->lock);
2069 if (get_usecase_from_list(adev, out->usecase) != NULL) {
2071 pthread_mutex_unlock(&adev->lock);
2075 pthread_mutex_unlock(&adev->lock);
2122 struct audio_device *adev = out->dev;
2133 if (adev->voice_tx_output == out)
2134 adev->voice_tx_output = NULL;
2144 struct audio_device *adev = (struct audio_device *)dev;
2154 pthread_mutex_lock(&adev->lock);
2157 status = voice_set_parameters(adev, parms);
2168 adev->bluetooth_nrec = true;
2170 adev->bluetooth_nrec = false;
2176 adev->screen_off = false;
2178 adev->screen_off = true;
2200 if (adev->speaker_lr_swap != reverse_speakers) {
2201 adev->speaker_lr_swap = reverse_speakers;
2205 list_for_each(node, &adev->usecase_list) {
2208 select_devices(adev, usecase->id);
2218 adev->bt_wb_speech_enabled = !strcmp(value, AUDIO_PARAMETER_VALUE_ON);
2221 audio_extn_hfp_set_parameters(adev, parms);
2224 pthread_mutex_unlock(&adev->lock);
2232 struct audio_device *adev = (struct audio_device *)dev;
2237 pthread_mutex_lock(&adev->lock);
2239 voice_get_parameters(adev, query, reply);
2244 pthread_mutex_unlock(&adev->lock);
2257 struct audio_device *adev = (struct audio_device *)dev;
2259 audio_extn_extspk_set_voice_vol(adev->extspk, volume);
2261 pthread_mutex_lock(&adev->lock);
2262 ret = voice_set_volume(adev, volume);
2263 pthread_mutex_unlock(&adev->lock);
2291 struct audio_device *adev = (struct audio_device *)dev;
2293 pthread_mutex_lock(&adev->lock);
2294 if (adev->mode != mode) {
2296 adev->mode = mode;
2298 voice_is_in_call(adev)) {
2299 voice_stop_call(adev);
2300 adev->current_call_output = NULL;
2303 pthread_mutex_unlock(&adev->lock);
2305 audio_extn_extspk_set_mode(adev->extspk, mode);
2313 struct audio_device *adev = (struct audio_device *)dev;
2316 pthread_mutex_lock(&adev->lock);
2317 ret = voice_set_mic_mute(adev, state);
2318 adev->mic_muted = state;
2319 pthread_mutex_unlock(&adev->lock);
2348 struct audio_device *adev = (struct audio_device *)dev;
2381 in->dev = adev;
2466 static int adev_verify_devices(struct audio_device *adev)
2505 const unsigned card_id = adev->snd_card;
2528 pparams = &adev->use_case_table[audio_usecase];
2542 adev->active_input = &in;
2548 adev->active_input = NULL;
2556 list_add_tail(&adev->usecase_list, &uc_info.list);
2559 retval = select_devices(adev, audio_usecase);
2576 retval = disable_audio_route(adev, &uc_info);
2578 retval = disable_snd_device(adev,
2583 adev->active_input = NULL; /* restore adev state */
2590 struct audio_device *adev = (struct audio_device *)device;
2591 audio_route_free(adev->audio_route);
2592 free(adev->snd_dev_ref_cnt);
2593 platform_deinit(adev->platform);
2594 audio_extn_extspk_deinit(adev->extspk);
2595 for (i = 0; i < ARRAY_SIZE(adev->use_case_table); ++i) {
2596 pcm_params_free(adev->use_case_table[i]);
2622 struct audio_device *adev;
2628 adev = calloc(1, sizeof(struct audio_device));
2630 pthread_mutex_init(&adev->lock, (const pthread_mutexattr_t *) NULL);
2632 adev->device.common.tag = HARDWARE_DEVICE_TAG;
2633 adev->device.common.version = AUDIO_DEVICE_API_VERSION_2_0;
2634 adev->device.common.module = (struct hw_module_t *)module;
2635 adev->device.common.close = adev_close;
2637 adev->device.init_check = adev_init_check;
2638 adev->device.set_voice_volume = adev_set_voice_volume;
2639 adev->device.set_master_volume = adev_set_master_volume;
2640 adev->device.get_master_volume = adev_get_master_volume;
2641 adev->device.set_master_mute = adev_set_master_mute;
2642 adev->device.get_master_mute = adev_get_master_mute;
2643 adev->device.set_mode = adev_set_mode;
2644 adev->device.set_mic_mute = adev_set_mic_mute;
2645 adev->device.get_mic_mute = adev_get_mic_mute;
2646 adev->device.set_parameters = adev_set_parameters;
2647 adev->device.get_parameters = adev_get_parameters;
2648 adev->device.get_input_buffer_size = adev_get_input_buffer_size;
2649 adev->device.open_output_stream = adev_open_output_stream;
2650 adev->device.close_output_stream = adev_close_output_stream;
2651 adev->device.open_input_stream = adev_open_input_stream;
2652 adev->device.close_input_stream = adev_close_input_stream;
2653 adev->device.dump = adev_dump;
2656 pthread_mutex_lock(&adev->lock);
2657 adev->mode = AUDIO_MODE_NORMAL;
2658 adev->active_input = NULL;
2659 adev->primary_output = NULL;
2660 adev->bluetooth_nrec = true;
2661 adev->acdb_settings = TTY_MODE_OFF;
2662 /* adev->cur_hdmi_channels = 0; by calloc() */
2663 adev->snd_dev_ref_cnt = calloc(SND_DEVICE_MAX, sizeof(int));
2664 voice_init(adev);
2665 list_init(&adev->usecase_list);
2666 pthread_mutex_unlock(&adev->lock);
2669 adev->platform = platform_init(adev);
2670 if (!adev->platform) {
2671 free(adev->snd_dev_ref_cnt);
2672 free(adev);
2678 adev->extspk = audio_extn_extspk_init(adev);
2681 adev->visualizer_lib = dlopen(VISUALIZER_LIBRARY_PATH, RTLD_NOW);
2682 if (adev->visualizer_lib == NULL) {
2686 adev->visualizer_start_output =
2687 (int (*)(audio_io_handle_t, int))dlsym(adev->visualizer_lib,
2689 adev->visualizer_stop_output =
2690 (int (*)(audio_io_handle_t, int))dlsym(adev->visualizer_lib,
2696 adev->offload_effects_lib = dlopen(OFFLOAD_EFFECTS_BUNDLE_LIBRARY_PATH, RTLD_NOW);
2697 if (adev->offload_effects_lib == NULL) {
2703 adev->offload_effects_start_output =
2704 (int (*)(audio_io_handle_t, int))dlsym(adev->offload_effects_lib,
2706 adev->offload_effects_stop_output =
2707 (int (*)(audio_io_handle_t, int))dlsym(adev->offload_effects_lib,
2712 adev->bt_wb_speech_enabled = false;
2713 adev->enable_voicerx = false;
2715 *device = &adev->device.common;
2717 adev_verify_devices(adev);