Lines Matching refs:adev
234 static void dummybuf_thread_close(struct audio_device *adev);
305 static struct mixer_card *adev_get_mixer_for_card(struct audio_device *adev, int card) in adev_get_mixer_for_card() argument
310 list_for_each(node, &adev->mixer_list) { in adev_get_mixer_for_card()
331 static void free_mixer_list(struct audio_device *adev) in free_mixer_list() argument
337 list_for_each_safe(node, next, &adev->mixer_list) { in free_mixer_list()
345 static int mixer_init(struct audio_device *adev) in mixer_init() argument
356 list_init(&adev->mixer_list); in mixer_init()
360 if (adev_get_mixer_for_card(adev, card) == NULL) { in mixer_init()
385 list_add_tail(&adev->mixer_list, &mixer_card->adev_list_node); in mixer_init()
392 free_mixer_list(adev); in mixer_init()
431 static struct audio_usecase *get_usecase_from_id(struct audio_device *adev, in get_usecase_from_id() argument
437 list_for_each(node, &adev->usecase_list) { in get_usecase_from_id()
445 static struct audio_usecase *get_usecase_from_type(struct audio_device *adev, in get_usecase_from_type() argument
451 list_for_each(node, &adev->usecase_list) { in get_usecase_from_type()
460 static int set_voice_volume_l(struct audio_device *adev, float volume) in set_voice_volume_l() argument
465 if (adev->mode == AUDIO_MODE_IN_CALL) { in set_voice_volume_l()
472 static snd_device_t get_output_snd_device(struct audio_device *adev, audio_devices_t devices) in get_output_snd_device() argument
475 audio_mode_t mode = adev->mode; in get_output_snd_device()
488 if (adev->tty_mode == TTY_MODE_FULL) in get_output_snd_device()
490 else if (adev->tty_mode == TTY_MODE_VCO) in get_output_snd_device()
492 else if (adev->tty_mode == TTY_MODE_HCO) in get_output_snd_device()
546 static snd_device_t get_input_snd_device(struct audio_device *adev, audio_devices_t out_device) in get_input_snd_device() argument
549 audio_mode_t mode = adev->mode; in get_input_snd_device()
556 usecase = get_usecase_from_type(adev, PCM_CAPTURE|VOICE_CALL); in get_input_snd_device()
576 if (adev->tty_mode != TTY_MODE_OFF) { in get_input_snd_device()
579 switch (adev->tty_mode) { in get_input_snd_device()
590 ALOGE("%s: Invalid TTY mode (%#x)", __func__, adev->tty_mode); in get_input_snd_device()
612 if (adev->dualmic_config == DUALMIC_CONFIG_1) { in get_input_snd_device()
615 else if (adev->ns_in_voice_rec) in get_input_snd_device()
693 static int set_hdmi_channels(struct audio_device *adev, int channel_count) in set_hdmi_channels() argument
697 (void)adev; in set_hdmi_channels()
704 static int edid_get_max_channels(struct audio_device *adev) in edid_get_max_channels() argument
708 (void)adev; in edid_get_max_channels()
722 static int enable_snd_device(struct audio_device *adev, in enable_snd_device() argument
736 enable_snd_device(adev, uc_info, SND_DEVICE_OUT_SPEAKER, update_mixer); in enable_snd_device()
737 enable_snd_device(adev, uc_info, SND_DEVICE_OUT_HEADPHONES, update_mixer); in enable_snd_device()
740 adev->snd_dev_ref_cnt[snd_device]++; in enable_snd_device()
741 if (adev->snd_dev_ref_cnt[snd_device] > 1) { in enable_snd_device()
760 static int disable_snd_device(struct audio_device *adev, in disable_snd_device() argument
774 disable_snd_device(adev, uc_info, SND_DEVICE_OUT_SPEAKER, update_mixer); in disable_snd_device()
775 disable_snd_device(adev, uc_info, SND_DEVICE_OUT_HEADPHONES, update_mixer); in disable_snd_device()
779 if (adev->snd_dev_ref_cnt[snd_device] <= 0) { in disable_snd_device()
783 adev->snd_dev_ref_cnt[snd_device]--; in disable_snd_device()
784 if (adev->snd_dev_ref_cnt[snd_device] == 0) { in disable_snd_device()
797 static int select_devices(struct audio_device *adev, in select_devices() argument
814 usecase = get_usecase_from_type(adev, PCM_CAPTURE|VOICE_CALL); in select_devices()
819 usecase = get_usecase_from_id(adev, uc_id); in select_devices()
827 out_snd_device = get_output_snd_device(adev, active_out->devices); in select_devices()
828 in_snd_device = get_input_snd_device(adev, active_out->devices); in select_devices()
837 if (adev->in_call) { in select_devices()
838 vc_usecase = get_usecase_from_id(adev, USECASE_VOICE_CALL); in select_devices()
850 out_snd_device = get_output_snd_device(adev, active_out->devices); in select_devices()
851 if (active_out == adev->primary_output && in select_devices()
854 select_devices(adev, active_input->usecase); in select_devices()
862 adev->primary_output && !adev->primary_output->standby) { in select_devices()
863 in_snd_device = get_input_snd_device(adev, adev->primary_output->devices); in select_devices()
865 in_snd_device = get_input_snd_device(adev, AUDIO_DEVICE_NONE); in select_devices()
883 pthread_mutex_lock(&adev->tfa9895_lock); in select_devices()
884 disable_snd_device(adev, usecase, usecase->out_snd_device, false); in select_devices()
885 pthread_mutex_unlock(&adev->tfa9895_lock); in select_devices()
889 disable_snd_device(adev, usecase, usecase->in_snd_device, false); in select_devices()
894 enable_snd_device(adev, usecase, out_snd_device, false); in select_devices()
898 enable_snd_device(adev, usecase, in_snd_device, false); in select_devices()
911 if (adev->htc_acoustic_set_rt5506_amp != NULL) in select_devices()
912 adev->htc_acoustic_set_rt5506_amp(adev->mode, usecase->devices); in select_devices()
1128 static void put_echo_reference(struct audio_device *adev, in put_echo_reference() argument
1132 int32_t prev_generation = adev->echo_reference_generation; in put_echo_reference()
1133 struct stream_out *out = adev->primary_output; in put_echo_reference()
1135 if (adev->echo_reference != NULL && in put_echo_reference()
1136 reference == adev->echo_reference) { in put_echo_reference()
1139 adev->echo_reference = NULL; in put_echo_reference()
1140 android_atomic_inc(&adev->echo_reference_generation); in put_echo_reference()
1155 static struct echo_reference_itfe *get_echo_reference(struct audio_device *adev, in get_echo_reference() argument
1161 put_echo_reference(adev, adev->echo_reference); in get_echo_reference()
1164 if (adev->primary_output!= NULL && adev->primary_output->usecase == USECASE_AUDIO_PLAYBACK && in get_echo_reference()
1165 !adev->primary_output->standby) { in get_echo_reference()
1167 &adev->primary_output->stream.common; in get_echo_reference()
1177 &adev->echo_reference); in get_echo_reference()
1179 android_atomic_inc(&adev->echo_reference_generation); in get_echo_reference()
1181 return adev->echo_reference; in get_echo_reference()
1189 struct audio_device *adev = in->dev; in get_hw_echo_reference() local
1193 if (adev->primary_output!= NULL && in get_hw_echo_reference()
1194 !adev->primary_output->standby && in get_hw_echo_reference()
1195 adev->primary_output->usecase == USECASE_AUDIO_PLAYBACK && in get_hw_echo_reference()
1196 adev->primary_output->devices == AUDIO_DEVICE_OUT_SPEAKER) { in get_hw_echo_reference()
1197 struct audio_stream *stream = &adev->primary_output->stream.common; in get_hw_echo_reference()
1904 struct audio_device *adev = in->dev; in stop_input_stream() local
1906 adev->active_input = NULL; in stop_input_stream()
1909 uc_info = get_usecase_from_id(adev, in->usecase); in stop_input_stream()
1917 disable_snd_device(adev, uc_info, uc_info->in_snd_device, true); in stop_input_stream()
1947 struct audio_device *adev = in->dev; in start_input_stream() local
1952 adev->active_input = in; in start_input_stream()
1976 &adev_get_mixer_for_card(adev, in start_input_stream()
1979 list_add_tail(&adev->usecase_list, &uc_info->adev_list_node); in start_input_stream()
1981 select_devices(adev, in->usecase); in start_input_stream()
2020 in->echo_reference = get_echo_reference(adev, in start_input_stream()
2049 if (!adev->sound_trigger_open_for_streaming) { in start_input_stream()
2055 pcm_device->sound_trigger_handle = adev->sound_trigger_open_for_streaming(); in start_input_stream()
2100 adev->active_input = NULL; in start_input_stream()
2300 struct audio_device *adev = out->dev; in out_close_pcm_devices() local
2305 adev->sound_trigger_close_for_streaming(pcm_device->sound_trigger_handle); in out_close_pcm_devices()
2373 struct audio_device *adev = out->dev; in disable_output_path_l() local
2376 uc_info = get_usecase_from_id(adev, out->usecase); in disable_output_path_l()
2382 disable_snd_device(adev, uc_info, uc_info->out_snd_device, true); in disable_output_path_l()
2392 struct audio_device *adev = out->dev; in enable_output_path_l() local
2404 list_add_tail(&adev->usecase_list, &uc_info->adev_list_node); in enable_output_path_l()
2405 select_devices(adev, out->usecase); in enable_output_path_l()
2411 struct audio_device *adev = out->dev; in stop_output_stream() local
2418 adev->offload_fx_stop_output != NULL) { in stop_output_stream()
2419 adev->offload_fx_stop_output(out->handle); in stop_output_stream()
2436 struct audio_device *adev = out->dev; in start_output_stream() local
2450 out->echo_reference_generation = adev->echo_reference_generation; in start_output_stream()
2451 if (adev->echo_reference != NULL) in start_output_stream()
2452 out->echo_reference = adev->echo_reference; in start_output_stream()
2467 if (adev->offload_fx_start_output != NULL) in start_output_stream()
2468 adev->offload_fx_start_output(out->handle); in start_output_stream()
2478 static int stop_voice_call(struct audio_device *adev) in stop_voice_call() argument
2483 adev->in_call = false; in stop_voice_call()
2487 uc_info = get_usecase_from_id(adev, USECASE_VOICE_CALL); in stop_voice_call()
2494 disable_snd_device(adev, uc_info, uc_info->out_snd_device, false); in stop_voice_call()
2495 disable_snd_device(adev, uc_info, uc_info->in_snd_device, true); in stop_voice_call()
2506 static int start_voice_call(struct audio_device *adev) in start_voice_call() argument
2515 uc_info->stream = (struct audio_stream *)adev->primary_output; in start_voice_call()
2516 uc_info->devices = adev->primary_output->devices; in start_voice_call()
2522 list_add_tail(&adev->usecase_list, &uc_info->adev_list_node); in start_voice_call()
2524 select_devices(adev, USECASE_VOICE_CALL); in start_voice_call()
2530 set_voice_volume_l(adev, adev->voice_volume); in start_voice_call()
2532 adev->in_call = true; in start_voice_call()
2640 struct audio_device *adev = out->dev; in do_out_standby_l() local
2650 if (out->echo_reference_generation != adev->echo_reference_generation) { in do_out_standby_l()
2653 out->echo_reference_generation = adev->echo_reference_generation; in do_out_standby_l()
2675 struct audio_device *adev = out->dev; in out_standby() local
2681 pthread_mutex_lock(&adev->lock); in out_standby()
2683 pthread_mutex_unlock(&adev->lock); in out_standby()
2734 struct audio_device *adev = out->dev; in out_set_parameters() local
2749 __func__, out->usecase, use_case_table[out->usecase], kvpairs, out->devices, adev->mode); in out_set_parameters()
2754 pthread_mutex_lock(&adev->lock_inputs); in out_set_parameters()
2756 pthread_mutex_lock(&adev->lock); in out_set_parameters()
2763 … if (adev->active_input && (adev->active_input->source == AUDIO_SOURCE_VOICE_COMMUNICATION || in out_set_parameters()
2764 adev->active_input->source == AUDIO_SOURCE_MIC)) { in out_set_parameters()
2765 in = adev->active_input; in out_set_parameters()
2773 uc_info = get_usecase_from_id(adev, out->usecase); in out_set_parameters()
2791 uc_info = get_usecase_from_id(adev, USECASE_AUDIO_PLAYBACK); in out_set_parameters()
2798 disable_snd_device(adev, uc_info, SND_DEVICE_OUT_SPEAKER, true); in out_set_parameters()
2802 select_devices(adev, out->usecase); in out_set_parameters()
2806 if ((adev->mode == AUDIO_MODE_IN_CALL) && !adev->in_call && in out_set_parameters()
2807 (out == adev->primary_output)) { in out_set_parameters()
2808 start_voice_call(adev); in out_set_parameters()
2809 } else if ((adev->mode == AUDIO_MODE_IN_CALL) && adev->in_call && in out_set_parameters()
2810 (out == adev->primary_output)) { in out_set_parameters()
2811 select_devices(adev, USECASE_VOICE_CALL); in out_set_parameters()
2815 if ((adev->mode == AUDIO_MODE_NORMAL) && adev->in_call && in out_set_parameters()
2816 (out == adev->primary_output)) { in out_set_parameters()
2817 stop_voice_call(adev); in out_set_parameters()
2819 pthread_mutex_unlock(&adev->lock); in out_set_parameters()
2825 pthread_mutex_lock(&adev->lock); in out_set_parameters()
2826 LOG_ALWAYS_FATAL_IF(in != adev->active_input); in out_set_parameters()
2828 pthread_mutex_unlock(&adev->lock); in out_set_parameters()
2832 pthread_mutex_unlock(&adev->lock_inputs); in out_set_parameters()
2901 struct audio_device *adev = out->dev; in out_set_volume() local
2942 struct audio_device *adev = (struct audio_device *)context; in tfa9895_config_thread() local
2943 pthread_mutex_lock(&adev->tfa9895_lock); in tfa9895_config_thread()
2944 adev->tfa9895_init = in tfa9895_config_thread()
2945 adev->htc_acoustic_set_amp_mode(adev->mode, AUDIO_DEVICE_OUT_SPEAKER, 0, 0, false); in tfa9895_config_thread()
2946 if (!adev->tfa9895_init) { in tfa9895_config_thread()
2948 adev->tfa9895_mode_change |= 0x1; in tfa9895_config_thread()
2950 ALOGI("@@##tfa9895_config_thread Done!! tfa9895_mode_change=%d", adev->tfa9895_mode_change); in tfa9895_config_thread()
2951 pthread_mutex_unlock(&adev->tfa9895_lock); in tfa9895_config_thread()
2952 dummybuf_thread_close(adev); in tfa9895_config_thread()
2983 struct audio_device *adev = out->dev; in out_write() local
3014 pthread_mutex_lock(&adev->lock_inputs); in out_write()
3017 pthread_mutex_unlock(&adev->lock_inputs); in out_write()
3021 pthread_mutex_lock(&adev->lock); in out_write()
3025 pthread_mutex_unlock(&adev->lock); in out_write()
3027 pthread_mutex_unlock(&adev->lock_inputs); in out_write()
3035 if (adev->active_input && in out_write()
3036 (adev->active_input->source == AUDIO_SOURCE_VOICE_COMMUNICATION || in out_write()
3037 adev->active_input->source == AUDIO_SOURCE_MIC)) { in out_write()
3038 in = adev->active_input; in out_write()
3042 pthread_mutex_unlock(&adev->lock); in out_write()
3046 pthread_mutex_unlock(&adev->lock_inputs); in out_write()
3057 pthread_mutex_lock(&adev->lock); in out_write()
3059 pthread_mutex_unlock(&adev->lock); in out_write()
3081 pthread_mutex_unlock(&adev->lock_inputs); in out_write()
3087 if (android_atomic_acquire_load(&adev->echo_reference_generation) in out_write()
3089 pthread_mutex_lock(&adev->lock); in out_write()
3097 out->echo_reference_generation = adev->echo_reference_generation; in out_write()
3098 out->echo_reference = adev->echo_reference; in out_write()
3101 pthread_mutex_unlock(&adev->lock); in out_write()
3138 if (adev->tfa9895_mode_change == 0x1) { in out_write()
3140 pthread_mutex_lock(&adev->tfa9895_lock); in out_write()
3175 adev->tfa9895_mode_change &= ~0x1; in out_write()
3177 "adev->tfa9895_mode_change=%d", adev->tfa9895_mode_change); in out_write()
3178 adev->tfa9895_init = in out_write()
3179 adev->htc_acoustic_set_amp_mode( in out_write()
3180 adev->mode, AUDIO_DEVICE_OUT_SPEAKER, 0, 0, false); in out_write()
3199 pthread_mutex_unlock(&adev->tfa9895_lock); in out_write()
3205 pthread_mutex_unlock(&adev->tfa9895_lock); in out_write()
3240 pthread_mutex_lock(&adev->lock); in out_write()
3241 LOG_ALWAYS_FATAL_IF(in != adev->active_input); in out_write()
3243 pthread_mutex_unlock(&adev->lock); in out_write()
3246 pthread_mutex_unlock(&adev->lock_inputs); in out_write()
3483 struct audio_device *adev = in->dev; in in_close_pcm_devices() local
3492 adev->sound_trigger_close_for_streaming(pcm_device->sound_trigger_handle); in in_close_pcm_devices()
3506 struct audio_device *adev = in->dev; in do_in_standby_l() local
3516 put_echo_reference(adev, in->echo_reference); in do_in_standby_l()
3545 struct audio_device *adev = in->dev; in in_standby_l() local
3549 pthread_mutex_lock(&adev->lock); in in_standby_l()
3551 pthread_mutex_unlock(&adev->lock); in in_standby_l()
3560 struct audio_device *adev = in->dev; in in_standby() local
3563 pthread_mutex_lock(&adev->lock_inputs); in in_standby()
3565 pthread_mutex_unlock(&adev->lock_inputs); in in_standby()
3581 struct audio_device *adev = in->dev; in in_set_parameters() local
3597 pthread_mutex_lock(&adev->lock_inputs); in in_set_parameters()
3599 pthread_mutex_lock(&adev->lock); in in_set_parameters()
3615 uc_info = get_usecase_from_id(adev, in->usecase); in in_set_parameters()
3633 ret = select_devices(adev, in->usecase); in in_set_parameters()
3637 pthread_mutex_unlock(&adev->lock); in in_set_parameters()
3639 pthread_mutex_unlock(&adev->lock_inputs); in in_set_parameters()
3670 struct audio_device *adev = in->dev; in read_bytes_from_dsp() local
3676 return adev->sound_trigger_read_samples(pcm_device->sound_trigger_handle, buffer, bytes); in read_bytes_from_dsp()
3685 struct audio_device *adev = in->dev; in in_read() local
3708 pthread_mutex_lock(&adev->lock_inputs); in in_read()
3711 pthread_mutex_unlock(&adev->lock_inputs); in in_read()
3714 pthread_mutex_lock(&adev->lock); in in_read()
3716 pthread_mutex_unlock(&adev->lock); in in_read()
3717 pthread_mutex_unlock(&adev->lock_inputs); in in_read()
3747 if (read_and_process_successful == true && adev->mic_mute) in in_read()
3774 struct audio_device *adev = in->dev; in add_remove_audio_effect() local
3786 pthread_mutex_lock(&adev->lock_inputs); in add_remove_audio_effect()
3860 pthread_mutex_unlock(&adev->lock_inputs); in add_remove_audio_effect()
3886 struct audio_device *adev = (struct audio_device *)dev; in adev_open_output_stream() local
3901 out->dev = adev; in adev_open_output_stream()
3978 if (adev->primary_output == NULL) in adev_open_output_stream()
3979 adev->primary_output = out; in adev_open_output_stream()
3988 pthread_mutex_lock(&adev->lock); in adev_open_output_stream()
3989 if (get_usecase_from_id(adev, out->usecase) != NULL) { in adev_open_output_stream()
3991 pthread_mutex_unlock(&adev->lock); in adev_open_output_stream()
3995 pthread_mutex_unlock(&adev->lock); in adev_open_output_stream()
4045 struct audio_device *adev = out->dev; in adev_close_output_stream() local
4064 struct audio_device *adev = (struct audio_device *)dev; in adev_set_parameters() local
4089 pthread_mutex_lock(&adev->lock); in adev_set_parameters()
4090 if (tty_mode != adev->tty_mode) { in adev_set_parameters()
4091 adev->tty_mode = tty_mode; in adev_set_parameters()
4092 if (adev->in_call) in adev_set_parameters()
4093 select_devices(adev, USECASE_VOICE_CALL); in adev_set_parameters()
4095 pthread_mutex_unlock(&adev->lock); in adev_set_parameters()
4104 adev->bluetooth_nrec = true; in adev_set_parameters()
4106 adev->bluetooth_nrec = false; in adev_set_parameters()
4112 adev->screen_off = false; in adev_set_parameters()
4114 adev->screen_off = true; in adev_set_parameters()
4134 pthread_mutex_lock(&adev->lock); in adev_set_parameters()
4135 if (adev->speaker_lr_swap != reverse_speakers) { in adev_set_parameters()
4136 adev->speaker_lr_swap = reverse_speakers; in adev_set_parameters()
4140 list_for_each(node, &adev->usecase_list) { in adev_set_parameters()
4143 select_devices(adev, usecase->id); in adev_set_parameters()
4144 if (adev->htc_acoustic_spk_reverse) in adev_set_parameters()
4145 adev->htc_acoustic_spk_reverse(adev->speaker_lr_swap); in adev_set_parameters()
4150 pthread_mutex_unlock(&adev->lock); in adev_set_parameters()
4181 struct audio_device *adev = (struct audio_device *)dev; in adev_set_voice_volume() local
4182 pthread_mutex_lock(&adev->lock); in adev_set_voice_volume()
4184 adev->voice_volume = volume; in adev_set_voice_volume()
4185 ret = set_voice_volume_l(adev, adev->voice_volume); in adev_set_voice_volume()
4186 pthread_mutex_unlock(&adev->lock); in adev_set_voice_volume()
4225 struct audio_device *adev = (struct audio_device *)dev; in adev_set_mode() local
4227 pthread_mutex_lock(&adev->lock); in adev_set_mode()
4228 if (adev->mode != mode) { in adev_set_mode()
4230 adev->mode = mode; in adev_set_mode()
4231 pthread_mutex_lock(&adev->tfa9895_lock); in adev_set_mode()
4232 adev->tfa9895_mode_change |= 0x1; in adev_set_mode()
4233 pthread_mutex_unlock(&adev->tfa9895_lock); in adev_set_mode()
4235 pthread_mutex_unlock(&adev->lock); in adev_set_mode()
4241 struct audio_device *adev = (struct audio_device *)dev; in adev_set_mic_mute() local
4244 pthread_mutex_lock(&adev->lock); in adev_set_mic_mute()
4245 adev->mic_mute = state; in adev_set_mic_mute()
4247 if (adev->mode == AUDIO_MODE_IN_CALL) { in adev_set_mic_mute()
4251 pthread_mutex_unlock(&adev->lock); in adev_set_mic_mute()
4257 struct audio_device *adev = (struct audio_device *)dev; in adev_get_mic_mute() local
4259 *state = adev->mic_mute; in adev_get_mic_mute()
4288 struct audio_device *adev = (struct audio_device *)dev; in adev_open_input_stream() local
4334 in->dev = adev; in adev_open_input_stream()
4366 struct audio_device *adev = (struct audio_device *)dev; in adev_close_input_stream() local
4371 pthread_mutex_lock(&adev->lock_inputs); in adev_close_input_stream()
4409 pthread_mutex_unlock(&adev->lock_inputs); in adev_close_input_stream()
4424 struct audio_device *adev = (struct audio_device *)device; in adev_close() local
4426 free(adev->snd_dev_ref_cnt); in adev_close()
4427 free_mixer_list(adev); in adev_close()
4436 struct audio_device *adev = (struct audio_device *)context; in dummybuf_thread() local
4443 audio_devices_t dummybuf_thread_devices = adev->dummybuf_thread_devices; in dummybuf_thread()
4445 pthread_mutex_lock(&adev->dummybuf_thread_lock); in dummybuf_thread()
4501 adev->dummybuf_thread_active = 1; in dummybuf_thread()
4518 if (adev->dummybuf_thread_cancel || adev->dummybuf_thread_timeout-- <= 0) { in dummybuf_thread()
4519 adev->dummybuf_thread_cancel = 0; in dummybuf_thread()
4523 pthread_mutex_unlock(&adev->dummybuf_thread_lock); in dummybuf_thread()
4525 pthread_mutex_lock(&adev->dummybuf_thread_lock); in dummybuf_thread()
4529 adev->dummybuf_thread_active = 0; in dummybuf_thread()
4549 pthread_mutex_unlock(&adev->dummybuf_thread_lock); in dummybuf_thread()
4557 static void dummybuf_thread_open(struct audio_device *adev) in dummybuf_thread_open() argument
4559 adev->dummybuf_thread_timeout = 6000; /* in 18 sec */ in dummybuf_thread_open()
4560 adev->dummybuf_thread_cancel = 0; in dummybuf_thread_open()
4561 adev->dummybuf_thread_active = 0; in dummybuf_thread_open()
4562 pthread_mutex_init(&adev->dummybuf_thread_lock, (const pthread_mutexattr_t *) NULL); in dummybuf_thread_open()
4563 if (!adev->dummybuf_thread) in dummybuf_thread_open()
4564 … pthread_create(&adev->dummybuf_thread, (const pthread_attr_t *) NULL, dummybuf_thread, adev); in dummybuf_thread_open()
4567 static void dummybuf_thread_close(struct audio_device *adev) in dummybuf_thread_close() argument
4572 if (adev->dummybuf_thread == 0) in dummybuf_thread_close()
4575 pthread_mutex_lock(&adev->dummybuf_thread_lock); in dummybuf_thread_close()
4576 adev->dummybuf_thread_cancel = 1; in dummybuf_thread_close()
4577 pthread_mutex_unlock(&adev->dummybuf_thread_lock); in dummybuf_thread_close()
4580 pthread_mutex_lock(&adev->dummybuf_thread_lock); in dummybuf_thread_close()
4581 if (adev->dummybuf_thread_active == 0) { in dummybuf_thread_close()
4582 pthread_mutex_unlock(&adev->dummybuf_thread_lock); in dummybuf_thread_close()
4585 pthread_mutex_unlock(&adev->dummybuf_thread_lock); in dummybuf_thread_close()
4590 pthread_join(adev->dummybuf_thread, (void **) NULL); in dummybuf_thread_close()
4591 pthread_mutex_destroy(&adev->dummybuf_thread_lock); in dummybuf_thread_close()
4592 adev->dummybuf_thread = 0; in dummybuf_thread_close()
4616 struct audio_device *adev; in adev_open() local
4622 adev = calloc(1, sizeof(struct audio_device)); in adev_open()
4624 adev->device.common.tag = HARDWARE_DEVICE_TAG; in adev_open()
4625 adev->device.common.version = AUDIO_DEVICE_API_VERSION_2_0; in adev_open()
4626 adev->device.common.module = (struct hw_module_t *)module; in adev_open()
4627 adev->device.common.close = adev_close; in adev_open()
4629 adev->device.init_check = adev_init_check; in adev_open()
4630 adev->device.set_voice_volume = adev_set_voice_volume; in adev_open()
4631 adev->device.set_master_volume = adev_set_master_volume; in adev_open()
4632 adev->device.get_master_volume = adev_get_master_volume; in adev_open()
4633 adev->device.set_master_mute = adev_set_master_mute; in adev_open()
4634 adev->device.get_master_mute = adev_get_master_mute; in adev_open()
4635 adev->device.set_mode = adev_set_mode; in adev_open()
4636 adev->device.set_mic_mute = adev_set_mic_mute; in adev_open()
4637 adev->device.get_mic_mute = adev_get_mic_mute; in adev_open()
4638 adev->device.set_parameters = adev_set_parameters; in adev_open()
4639 adev->device.get_parameters = adev_get_parameters; in adev_open()
4640 adev->device.get_input_buffer_size = adev_get_input_buffer_size; in adev_open()
4641 adev->device.open_output_stream = adev_open_output_stream; in adev_open()
4642 adev->device.close_output_stream = adev_close_output_stream; in adev_open()
4643 adev->device.open_input_stream = adev_open_input_stream; in adev_open()
4644 adev->device.close_input_stream = adev_close_input_stream; in adev_open()
4645 adev->device.dump = adev_dump; in adev_open()
4648 adev->mode = AUDIO_MODE_NORMAL; in adev_open()
4649 adev->active_input = NULL; in adev_open()
4650 adev->primary_output = NULL; in adev_open()
4651 adev->voice_volume = 1.0f; in adev_open()
4652 adev->tty_mode = TTY_MODE_OFF; in adev_open()
4653 adev->bluetooth_nrec = true; in adev_open()
4654 adev->in_call = false; in adev_open()
4656 adev->snd_dev_ref_cnt = calloc(SND_DEVICE_MAX, sizeof(int)); in adev_open()
4658 adev->dualmic_config = DUALMIC_CONFIG_NONE; in adev_open()
4659 adev->ns_in_voice_rec = false; in adev_open()
4661 list_init(&adev->usecase_list); in adev_open()
4663 if (mixer_init(adev) != 0) { in adev_open()
4664 free(adev->snd_dev_ref_cnt); in adev_open()
4665 free(adev); in adev_open()
4672 adev->offload_fx_lib = dlopen(OFFLOAD_FX_LIBRARY_PATH, RTLD_NOW); in adev_open()
4673 if (adev->offload_fx_lib == NULL) { in adev_open()
4677 adev->offload_fx_start_output = in adev_open()
4678 (int (*)(audio_io_handle_t))dlsym(adev->offload_fx_lib, in adev_open()
4680 adev->offload_fx_stop_output = in adev_open()
4681 (int (*)(audio_io_handle_t))dlsym(adev->offload_fx_lib, in adev_open()
4687 adev->htc_acoustic_lib = dlopen(HTC_ACOUSTIC_LIBRARY_PATH, RTLD_NOW); in adev_open()
4688 if (adev->htc_acoustic_lib == NULL) { in adev_open()
4692 adev->htc_acoustic_init_rt5506 = in adev_open()
4693 (int (*)())dlsym(adev->htc_acoustic_lib, in adev_open()
4695 adev->htc_acoustic_set_rt5506_amp = in adev_open()
4696 (int (*)(int, int))dlsym(adev->htc_acoustic_lib, in adev_open()
4698 adev->htc_acoustic_set_amp_mode = in adev_open()
4699 (int (*)(int , int, int, int, bool))dlsym(adev->htc_acoustic_lib, in adev_open()
4701 adev->htc_acoustic_spk_reverse = in adev_open()
4702 (int (*)(bool))dlsym(adev->htc_acoustic_lib, in adev_open()
4704 if (adev->htc_acoustic_spk_reverse) in adev_open()
4705 adev->htc_acoustic_spk_reverse(adev->speaker_lr_swap); in adev_open()
4710 adev->sound_trigger_lib = dlopen(SOUND_TRIGGER_HAL_LIBRARY_PATH, RTLD_NOW); in adev_open()
4711 if (adev->sound_trigger_lib == NULL) { in adev_open()
4715 adev->sound_trigger_open_for_streaming = in adev_open()
4716 (int (*)(void))dlsym(adev->sound_trigger_lib, in adev_open()
4718 adev->sound_trigger_read_samples = in adev_open()
4719 (size_t (*)(int, void *, size_t))dlsym(adev->sound_trigger_lib, in adev_open()
4721 adev->sound_trigger_close_for_streaming = in adev_open()
4722 (int (*)(int))dlsym(adev->sound_trigger_lib, in adev_open()
4724 if (!adev->sound_trigger_open_for_streaming || in adev_open()
4725 !adev->sound_trigger_read_samples || in adev_open()
4726 !adev->sound_trigger_close_for_streaming) { in adev_open()
4729 adev->sound_trigger_open_for_streaming = 0; in adev_open()
4730 adev->sound_trigger_read_samples = 0; in adev_open()
4731 adev->sound_trigger_close_for_streaming = 0; in adev_open()
4737 *device = &adev->device.common; in adev_open()
4739 if (adev->htc_acoustic_init_rt5506 != NULL) in adev_open()
4740 adev->htc_acoustic_init_rt5506(); in adev_open()
4744 adev->dummybuf_thread_devices = AUDIO_DEVICE_OUT_WIRED_HEADPHONE; in adev_open()
4745 dummybuf_thread_open(adev); in adev_open()
4748 pthread_mutex_lock(&adev->dummybuf_thread_lock); in adev_open()
4749 if (adev->dummybuf_thread_active != 0) { in adev_open()
4750 pthread_mutex_unlock(&adev->dummybuf_thread_lock); in adev_open()
4753 pthread_mutex_unlock(&adev->dummybuf_thread_lock); in adev_open()
4756 dummybuf_thread_close(adev); in adev_open()
4759 if (adev->htc_acoustic_set_amp_mode) { in adev_open()
4761 adev->dummybuf_thread_devices = AUDIO_DEVICE_OUT_SPEAKER; in adev_open()
4762 dummybuf_thread_open(adev); in adev_open()
4763 pthread_mutex_lock(&adev->dummybuf_thread_lock); in adev_open()
4766 if (adev->dummybuf_thread_active) { in adev_open()
4769 pthread_mutex_unlock(&adev->dummybuf_thread_lock); in adev_open()
4771 pthread_mutex_lock(&adev->dummybuf_thread_lock); in adev_open()
4773 if (adev->dummybuf_thread_active) { in adev_open()
4775 if (pthread_create(&th, NULL, tfa9895_config_thread, (void* )adev) != 0) { in adev_open()
4779 pthread_mutex_unlock(&adev->dummybuf_thread_lock); in adev_open()