Home | History | Annotate | Download | only in hal

Lines Matching refs:adev

273 struct mixer_card *adev_get_mixer_for_card(struct audio_device *adev, int card)
278 list_for_each(node, &adev->mixer_list) {
299 void free_mixer_list(struct audio_device *adev)
305 list_for_each_safe(node, next, &adev->mixer_list) {
313 int mixer_init(struct audio_device *adev)
324 list_init(&adev->mixer_list);
328 if (adev_get_mixer_for_card(adev, card) == NULL) {
353 list_add_tail(&adev->mixer_list, &mixer_card->adev_list_node);
360 free_mixer_list(adev);
404 static struct audio_usecase *get_usecase_from_id(struct audio_device *adev,
410 list_for_each(node, &adev->usecase_list) {
418 static struct audio_usecase *get_usecase_from_type(struct audio_device *adev,
424 list_for_each(node, &adev->usecase_list) {
432 /* always called with adev lock held */
433 static int set_voice_volume_l(struct audio_device *adev, float volume)
438 if (adev->mode == AUDIO_MODE_IN_CALL) {
445 snd_device_t get_output_snd_device(struct audio_device *adev, audio_devices_t devices)
448 audio_mode_t mode = adev->mode;
461 if (adev->tty_mode == TTY_MODE_FULL)
463 else if (adev->tty_mode == TTY_MODE_VCO)
465 else if (adev->tty_mode == TTY_MODE_HCO)
515 snd_device_t get_input_snd_device(struct audio_device *adev, audio_devices_t out_device)
518 audio_mode_t mode = adev->mode;
525 usecase = get_usecase_from_type(adev, PCM_CAPTURE|VOICE_CALL);
545 if (adev->tty_mode != TTY_MODE_OFF) {
548 switch (adev->tty_mode) {
559 ALOGE("%s: Invalid TTY mode (%#x)", __func__, adev->tty_mode);
579 if (adev->dualmic_config == DUALMIC_CONFIG_1) {
582 else if (adev->ns_in_voice_rec)
656 int set_hdmi_channels(struct audio_device *adev, int channel_count)
660 (void)adev;
667 int edid_get_max_channels(struct audio_device *adev)
671 (void)adev;
685 static int enable_snd_device(struct audio_device *adev,
697 adev->snd_dev_ref_cnt[snd_device]++;
698 if (adev->snd_dev_ref_cnt[snd_device] > 1) {
717 static int disable_snd_device(struct audio_device *adev,
729 if (adev->snd_dev_ref_cnt[snd_device] <= 0) {
733 adev->snd_dev_ref_cnt[snd_device]--;
734 if (adev->snd_dev_ref_cnt[snd_device] == 0) {
747 static int select_devices(struct audio_device *adev,
764 usecase = get_usecase_from_type(adev, PCM_CAPTURE|VOICE_CALL);
769 usecase = get_usecase_from_id(adev, uc_id);
777 out_snd_device = get_output_snd_device(adev, active_out->devices);
778 in_snd_device = get_input_snd_device(adev, active_out->devices);
787 if (adev->in_call) {
788 vc_usecase = get_usecase_from_id(adev, USECASE_VOICE_CALL);
800 out_snd_device = get_output_snd_device(adev, active_out->devices);
801 if (active_out == adev->primary_output &&
804 select_devices(adev, active_input->usecase);
812 adev->primary_output && !adev->primary_output->standby) {
813 in_snd_device = get_input_snd_device(adev, adev->primary_output->devices);
815 in_snd_device = get_input_snd_device(adev, AUDIO_DEVICE_NONE);
833 disable_snd_device(adev, usecase, usecase->out_snd_device, false);
837 disable_snd_device(adev, usecase, usecase->in_snd_device, false);
842 enable_snd_device(adev, usecase, out_snd_device, false);
846 enable_snd_device(adev, usecase, in_snd_device, false);
1279 struct audio_device *adev = in->dev;
1281 adev->active_input = NULL;
1284 uc_info = get_usecase_from_id(adev, in->usecase);
1292 disable_snd_device(adev, uc_info, uc_info->in_snd_device, true);
1314 struct audio_device *adev = in->dev;
1319 adev->active_input = in;
1349 &adev_get_mixer_for_card(adev,
1352 list_add_tail(&adev->usecase_list, &uc_info->adev_list_node);
1354 select_devices(adev, in->usecase);
1401 if (!adev->sound_trigger_open_for_streaming) {
1408 adev->sound_trigger_open_for_streaming();
1456 adev->active_input = NULL;
1526 struct audio_device *adev = out->dev;
1531 adev->sound_trigger_close_for_streaming(
1560 struct audio_device *adev = out->dev;
1570 (adev->mode == AUDIO_MODE_IN_CALL || adev->mode == AUDIO_MODE_IN_COMMUNICATION)
1616 struct audio_device *adev = out->dev;
1619 uc_info = get_usecase_from_id(adev, out->usecase);
1625 disable_snd_device(adev, uc_info, uc_info->out_snd_device, true);
1635 struct audio_device *adev = out->dev;
1647 list_add_tail(&adev->usecase_list, &uc_info->adev_list_node);
1649 select_devices(adev, out->usecase);
1655 struct audio_device *adev = out->dev;
1670 struct audio_device *adev = out->dev;
1687 static int stop_voice_call(struct audio_device *adev)
1692 adev->in_call = false;
1696 uc_info = get_usecase_from_id(adev, USECASE_VOICE_CALL);
1703 disable_snd_device(adev, uc_info, uc_info->out_snd_device, false);
1704 disable_snd_device(adev, uc_info, uc_info->in_snd_device, true);
1714 /* always called with adev lock held */
1715 static int start_voice_call(struct audio_device *adev)
1724 uc_info->stream = (struct audio_stream *)adev->primary_output;
1725 uc_info->devices = adev->primary_output->devices;
1731 list_add_tail(&adev->usecase_list, &uc_info->adev_list_node);
1733 select_devices(adev, USECASE_VOICE_CALL);
1739 set_voice_volume_l(adev, adev->voice_volume);
1741 adev->in_call = true;
1845 struct audio_device *adev = out->dev;
1858 struct audio_device *adev = out->dev;
1864 pthread_mutex_lock(&adev->lock);
1866 pthread_mutex_unlock(&adev->lock);
1884 struct audio_device *adev = out->dev;
1897 ALOGV("%s: enter: usecase(%d: %s) kvpairs: %s out->devices(%d) adev->mode(%d)",
1898 __func__, out->usecase, use_case_table[out->usecase], kvpairs, out->devices, adev->mode);
1903 pthread_mutex_lock(&adev->lock_inputs);
1905 pthread_mutex_lock(&adev->lock);
1912 if (adev->active_input && (adev->active_input->source == AUDIO_SOURCE_VOICE_COMMUNICATION ||
1913 adev->active_input->source == AUDIO_SOURCE_MIC)) {
1914 in = adev->active_input;
1926 select_devices(adev, out->usecase);
1929 if ((adev->mode == AUDIO_MODE_IN_CALL) && !adev->in_call &&
1930 (out == adev->primary_output)) {
1931 start_voice_call(adev);
1932 } else if ((adev->mode == AUDIO_MODE_IN_CALL) && adev->in_call &&
1933 (out == adev->primary_output)) {
1934 select_devices(adev, USECASE_VOICE_CALL);
1938 if ((adev->mode == AUDIO_MODE_NORMAL) && adev->in_call &&
1939 (out == adev->primary_output)) {
1940 stop_voice_call(adev);
1942 pthread_mutex_unlock(&adev->lock);
1946 /* The lock on adev->lock_inputs prevents input stream from being closed */
1948 pthread_mutex_lock(&adev->lock);
1949 LOG_ALWAYS_FATAL_IF(in != adev->active_input);
1951 pthread_mutex_unlock(&adev->lock);
1955 pthread_mutex_unlock(&adev->lock_inputs);
2014 struct audio_device *adev = out->dev;
2051 struct audio_device *adev = out->dev;
2070 pthread_mutex_lock(&adev->lock_inputs);
2073 pthread_mutex_unlock(&adev->lock_inputs);
2077 pthread_mutex_lock(&adev->lock);
2080 pthread_mutex_unlock(&adev->lock);
2082 pthread_mutex_unlock(&adev->lock_inputs);
2090 if (adev->active_input &&
2091 (adev->active_input->source == AUDIO_SOURCE_VOICE_COMMUNICATION ||
2092 adev->active_input->source == AUDIO_SOURCE_MIC)) {
2093 in = adev->active_input;
2097 pthread_mutex_unlock(&adev->lock);
2101 pthread_mutex_unlock(&adev->lock_inputs);
2195 /* The lock on adev->lock_inputs prevents input stream from being closed */
2197 pthread_mutex_lock(&adev->lock);
2198 LOG_ALWAYS_FATAL_IF(in != adev->active_input);
2200 pthread_mutex_unlock(&adev->lock);
2203 pthread_mutex_unlock(&adev->lock_inputs);
2327 struct audio_device *adev = in->dev;
2336 adev->sound_trigger_close_for_streaming(
2366 // called with adev->lock_inputs locked
2369 struct audio_device *adev = in->dev;
2373 pthread_mutex_lock(&adev->lock);
2375 pthread_mutex_unlock(&adev->lock);
2384 struct audio_device *adev = in->dev;
2387 pthread_mutex_lock(&adev->lock_inputs);
2389 pthread_mutex_unlock(&adev->lock_inputs);
2405 struct audio_device *adev = in->dev;
2421 pthread_mutex_lock(&adev->lock_inputs);
2423 pthread_mutex_lock(&adev->lock);
2439 uc_info = get_usecase_from_id(adev, in->usecase);
2457 ret = select_devices(adev, in->usecase);
2461 pthread_mutex_unlock(&adev->lock);
2463 pthread_mutex_unlock(&adev->lock_inputs);
2493 struct audio_device *adev = in->dev;
2499 return adev->sound_trigger_read_samples(
2509 struct audio_device *adev = in->dev;
2516 /* no need to acquire adev->lock_inputs because API contract prevents a close */
2520 pthread_mutex_lock(&adev->lock_inputs);
2523 pthread_mutex_unlock(&adev->lock_inputs);
2526 pthread_mutex_lock(&adev->lock);
2528 pthread_mutex_unlock(&adev->lock);
2529 pthread_mutex_unlock(&adev->lock_inputs);
2559 if (read_and_process_successful == true && adev->mic_mute)
2586 struct audio_device *adev = in->dev;
2598 pthread_mutex_lock(&adev->lock_inputs);
2654 pthread_mutex_unlock(&adev->lock_inputs);
2680 struct audio_device *adev = (struct audio_device *)dev;
2695 out->dev = adev;
2721 if (adev->primary_output == NULL)
2722 adev->primary_output = out;
2731 pthread_mutex_lock(&adev->lock);
2732 if (get_usecase_from_id(adev, out->usecase) != NULL) {
2734 pthread_mutex_unlock(&adev->lock);
2738 pthread_mutex_unlock(&adev->lock);
2786 struct audio_device *adev = out->dev;
2801 struct audio_device *adev = (struct audio_device *)dev;
2826 pthread_mutex_lock(&adev->lock);
2827 if (tty_mode != adev->tty_mode) {
2828 adev->tty_mode = tty_mode;
2829 if (adev->in_call)
2830 select_devices(adev, USECASE_VOICE_CALL);
2832 pthread_mutex_unlock(&adev->lock);
2841 adev->bluetooth_nrec = true;
2843 adev->bluetooth_nrec = false;
2849 adev->screen_off = false;
2851 adev->screen_off = true;
2872 pthread_mutex_lock(&adev->lock);
2873 if (adev->speaker_lr_swap != reverse_speakers) {
2874 adev->speaker_lr_swap = reverse_speakers;
2876 mixer_card = adev_get_mixer_for_card(adev, SOUND_CARD);
2882 pthread_mutex_unlock(&adev->lock);
2909 struct audio_device *adev = (struct audio_device *)dev;
2910 pthread_mutex_lock(&adev->lock);
2912 adev->voice_volume = volume;
2913 ret = set_voice_volume_l(adev, adev->voice_volume);
2914 pthread_mutex_unlock(&adev->lock);
2953 struct audio_device *adev = (struct audio_device *)dev;
2955 pthread_mutex_lock(&adev->lock);
2956 if (adev->mode != mode) {
2958 adev->mode = mode;
2960 pthread_mutex_unlock(&adev->lock);
2966 struct audio_device *adev = (struct audio_device *)dev;
2969 pthread_mutex_lock(&adev->lock);
2970 adev->mic_mute = state;
2972 if (adev->mode == AUDIO_MODE_IN_CALL) {
2976 pthread_mutex_unlock(&adev->lock);
2982 struct audio_device *adev = (struct audio_device *)dev;
2984 *state = adev->mic_mute;
3013 struct audio_device *adev = (struct audio_device *)dev;
3050 in->dev = adev;
3080 struct audio_device *adev = (struct audio_device *)dev;
3085 pthread_mutex_lock(&adev->lock_inputs);
3114 pthread_mutex_unlock(&adev->lock_inputs);
3129 struct audio_device *adev = (struct audio_device *)device;
3130 free(adev->snd_dev_ref_cnt);
3131 free_mixer_list(adev);
3139 struct audio_device *adev;
3145 adev = calloc(1, sizeof(struct audio_device));
3147 adev->device.common.tag = HARDWARE_DEVICE_TAG;
3148 adev->device.common.version = AUDIO_DEVICE_API_VERSION_2_0;
3149 adev->device.common.module = (struct hw_module_t *)module;
3150 adev->device.common.close = adev_close;
3152 adev->device.init_check = adev_init_check;
3153 adev->device.set_voice_volume = adev_set_voice_volume;
3154 adev->device.set_master_volume = adev_set_master_volume;
3155 adev->device.get_master_volume = adev_get_master_volume;
3156 adev->device.set_master_mute = adev_set_master_mute;
3157 adev->device.get_master_mute = adev_get_master_mute;
3158 adev->device.set_mode = adev_set_mode;
3159 adev->device.set_mic_mute = adev_set_mic_mute;
3160 adev->device.get_mic_mute = adev_get_mic_mute;
3161 adev->device.set_parameters = adev_set_parameters;
3162 adev->device.get_parameters = adev_get_parameters;
3163 adev->device.get_input_buffer_size = adev_get_input_buffer_size;
3164 adev->device.open_output_stream = adev_open_output_stream;
3165 adev->device.close_output_stream = adev_close_output_stream;
3166 adev->device.open_input_stream = adev_open_input_stream;
3167 adev->device.close_input_stream = adev_close_input_stream;
3168 adev->device.dump = adev_dump;
3171 adev->mode = AUDIO_MODE_NORMAL;
3172 adev->active_input = NULL;
3173 adev->primary_output = NULL;
3174 adev->voice_volume = 1.0f;
3175 adev->tty_mode = TTY_MODE_OFF;
3176 adev->bluetooth_nrec = true;
3177 adev->in_call = false;
3178 /* adev->cur_hdmi_channels = 0; by calloc() */
3179 adev->snd_dev_ref_cnt = calloc(SND_DEVICE_MAX, sizeof(int));
3181 adev->dualmic_config = DUALMIC_CONFIG_NONE;
3182 adev->ns_in_voice_rec = false;
3184 list_init(&adev->usecase_list);
3186 if (mixer_init(adev) != 0) {
3187 free(adev->snd_dev_ref_cnt);
3188 free(adev);
3196 adev->sound_trigger_lib = dlopen(SOUND_TRIGGER_HAL_LIBRARY_PATH,
3198 if (adev->sound_trigger_lib == NULL) {
3204 adev->sound_trigger_open_for_streaming =
3205 (int (*)(void))dlsym(adev->sound_trigger_lib,
3207 adev->sound_trigger_read_samples =
3209 adev->sound_trigger_lib,
3211 adev->sound_trigger_close_for_streaming =
3213 adev->sound_trigger_lib,
3215 if (!adev->sound_trigger_open_for_streaming ||
3216 !adev->sound_trigger_read_samples ||
3217 !adev->sound_trigger_close_for_streaming) {
3221 adev->sound_trigger_open_for_streaming = 0;
3222 adev->sound_trigger_read_samples = 0;
3223 adev->sound_trigger_close_for_streaming = 0;
3228 *device = &adev->device.common;