Lines Matching full:adev
129 static int set_voice_volume_l(struct audio_device *adev, float volume);
158 static int enable_audio_route(struct audio_device *adev,
178 audio_route_apply_path(adev->audio_route, mixer_path);
180 audio_route_update_mixer(adev->audio_route);
186 static int disable_audio_route(struct audio_device *adev,
204 audio_route_reset_path(adev->audio_route, mixer_path);
206 audio_route_update_mixer(adev->audio_route);
212 static int enable_snd_device(struct audio_device *adev,
222 adev->snd_dev_ref_cnt[snd_device]++;
223 if (adev->snd_dev_ref_cnt[snd_device] > 1) {
229 if (platform_send_audio_calibration(adev->platform, snd_device) < 0) {
230 adev->snd_dev_ref_cnt[snd_device]--;
236 audio_route_apply_path(adev->audio_route, platform_get_snd_device_name(snd_device));
238 audio_route_update_mixer(adev->audio_route);
243 static int disable_snd_device(struct audio_device *adev,
252 if (adev->snd_dev_ref_cnt[snd_device] <= 0) {
256 adev->snd_dev_ref_cnt[snd_device]--;
257 if (adev->snd_dev_ref_cnt[snd_device] == 0) {
260 audio_route_reset_path(adev->audio_route, platform_get_snd_device_name(snd_device));
262 audio_route_update_mixer(adev->audio_route);
267 static void check_usecases_codec_backend(struct audio_device *adev,
291 list_for_each(node, &adev->usecase_list) {
300 disable_audio_route(adev, usecase, false);
308 audio_route_update_mixer(adev->audio_route);
310 list_for_each(node, &adev->usecase_list) {
313 disable_snd_device(adev, usecase->out_snd_device, false);
317 list_for_each(node, &adev->usecase_list) {
320 enable_snd_device(adev, snd_device, false);
325 audio_route_update_mixer(adev->audio_route);
329 list_for_each(node, &adev->usecase_list) {
334 enable_audio_route(adev, usecase, false);
338 audio_route_update_mixer(adev->audio_route);
342 static void check_and_route_capture_usecases(struct audio_device *adev,
364 list_for_each(node, &adev->usecase_list) {
372 disable_audio_route(adev, usecase, false);
380 audio_route_update_mixer(adev->audio_route);
382 list_for_each(node, &adev->usecase_list) {
385 disable_snd_device(adev, usecase->in_snd_device, false);
386 enable_snd_device(adev, snd_device, false);
391 audio_route_update_mixer(adev->audio_route);
395 list_for_each(node, &adev->usecase_list) {
400 enable_audio_route(adev, usecase, false);
404 audio_route_update_mixer(adev->audio_route);
437 static struct audio_usecase *get_usecase_from_list(struct audio_device *adev,
443 list_for_each(node, &adev->usecase_list) {
451 static int select_devices(struct audio_device *adev,
461 usecase = get_usecase_from_list(adev, uc_id);
468 out_snd_device = platform_get_output_snd_device(adev->platform,
470 in_snd_device = platform_get_input_snd_device(adev->platform, usecase->stream.out->devices);
480 if (adev->in_call) {
481 vc_usecase = get_usecase_from_list(adev, USECASE_VOICE_CALL);
491 out_snd_device = platform_get_output_snd_device(adev->platform,
493 if (usecase->stream.out == adev->primary_output &&
494 adev->active_input &&
495 adev->active_input->source == AUDIO_SOURCE_VOICE_COMMUNICATION) {
496 select_devices(adev, adev->active_input->usecase);
503 if (adev->active_input->source == AUDIO_SOURCE_VOICE_COMMUNICATION &&
504 adev->primary_output && !adev->primary_output->standby) {
505 in_snd_device = platform_get_input_snd_device(adev->platform,
506 adev->primary_output->devices);
508 in_snd_device = platform_get_input_snd_device(adev->platform,
530 status = platform_switch_voice_call_device_pre(adev->platform);
535 disable_audio_route(adev, usecase, true);
536 disable_snd_device(adev, usecase->out_snd_device, false);
540 disable_audio_route(adev, usecase, true);
541 disable_snd_device(adev, usecase->in_snd_device, false);
547 check_usecases_codec_backend(adev, usecase, out_snd_device);
548 enable_snd_device(adev, out_snd_device, false);
552 check_and_route_capture_usecases(adev, usecase, in_snd_device);
553 enable_snd_device(adev, in_snd_device, false);
557 status = platform_switch_voice_call_device_post(adev->platform,
561 audio_route_update_mixer(adev->audio_route);
566 enable_audio_route(adev, usecase, true);
575 struct audio_device *adev = in->dev;
577 adev->active_input = NULL;
581 uc_info = get_usecase_from_list(adev, in->usecase);
589 disable_audio_route(adev, uc_info, true);
592 disable_snd_device(adev, uc_info->in_snd_device, true);
606 struct audio_device *adev = in->dev;
617 adev->active_input = in;
626 list_add_tail(&adev->usecase_list, &uc_info->list);
627 select_devices(adev, in->usecase);
647 adev->active_input = NULL;
792 static bool allow_hdmi_channel_config(struct audio_device *adev)
798 list_for_each(node, &adev->usecase_list) {
823 static int check_and_set_hdmi_channels(struct audio_device *adev,
830 if (!allow_hdmi_channel_config(adev))
833 if (channels == adev->cur_hdmi_channels) {
838 platform_set_hdmi_channels(adev->platform, channels);
839 adev->cur_hdmi_channels = channels;
846 list_for_each(node, &adev->usecase_list) {
850 disable_audio_route(adev, usecase, true);
858 list_for_each(node, &adev->usecase_list) {
862 enable_audio_route(adev, usecase, true);
873 struct audio_device *adev = out->dev;
877 uc_info = get_usecase_from_list(adev, out->usecase);
885 adev->visualizer_stop_output != NULL)
886 adev->visualizer_stop_output(out->handle);
889 disable_audio_route(adev, uc_info, true);
892 disable_snd_device(adev, uc_info->out_snd_device, true);
899 check_and_set_hdmi_channels(adev, DEFAULT_HDMI_OUT_CHANNELS);
909 struct audio_device *adev = out->dev;
931 check_and_set_hdmi_channels(adev, out->config.channels);
933 list_add_tail(&adev->usecase_list, &uc_info->list);
935 select_devices(adev, out->usecase);
963 if (adev->visualizer_start_output != NULL)
964 adev->visualizer_start_output(out->handle);
974 static int stop_voice_call(struct audio_device *adev)
980 adev->in_call = false;
982 ret = platform_stop_voice_call(adev->platform);
985 if (adev->voice_call_rx) {
986 pcm_close(adev->voice_call_rx);
987 adev->voice_call_rx = NULL;
989 if (adev->voice_call_tx) {
990 pcm_close(adev->voice_call_tx);
991 adev->voice_call_tx = NULL;
994 uc_info = get_usecase_from_list(adev, USECASE_VOICE_CALL);
1002 disable_audio_route(adev, uc_info, true);
1005 disable_snd_device(adev, uc_info->out_snd_device, false);
1006 disable_snd_device(adev, uc_info->in_snd_device, true);
1015 static int start_voice_call(struct audio_device *adev)
1026 uc_info->stream.out = adev->primary_output;
1027 uc_info->devices = adev->primary_output->devices;
1031 list_add_tail(&adev->usecase_list, &uc_info->list);
1033 select_devices(adev, USECASE_VOICE_CALL);
1047 adev->voice_call_rx = pcm_open(SOUND_CARD,
1050 if (adev->voice_call_rx && !pcm_is_ready(adev->voice_call_rx)) {
1051 ALOGE("%s: %s", __func__, pcm_get_error(adev->voice_call_rx));
1058 adev->voice_call_tx = pcm_open(SOUND_CARD,
1061 if (adev->voice_call_tx && !pcm_is_ready(adev->voice_call_tx)) {
1062 ALOGE("%s: %s", __func__, pcm_get_error(adev->voice_call_tx));
1068 set_voice_volume_l(adev, adev->voice_volume);
1070 pcm_start(adev->voice_call_rx);
1071 pcm_start(adev->voice_call_tx);
1073 ret = platform_start_voice_call(adev->platform);
1078 adev->in_call = true;
1082 stop_voice_call(adev);
1180 struct audio_device *adev = out->dev;
1187 pthread_mutex_lock(&adev->lock);
1204 pthread_mutex_unlock(&adev->lock);
1252 struct audio_device *adev = out->dev;
1267 pthread_mutex_lock(&adev->lock);
1303 select_devices(adev, out->usecase);
1305 if ((adev->mode == AUDIO_MODE_IN_CALL) && !adev->in_call &&
1306 (out == adev->primary_output)) {
1307 start_voice_call(adev);
1308 } else if ((adev->mode == AUDIO_MODE_IN_CALL) && adev->in_call &&
1309 (out == adev->primary_output)) {
1310 select_devices(adev, USECASE_VOICE_CALL);
1314 if ((adev->mode == AUDIO_MODE_NORMAL) && adev->in_call &&
1315 (out == adev->primary_output)) {
1316 stop_voice_call(adev);
1319 pthread_mutex_unlock(&adev->lock);
1394 struct audio_device *adev = out->dev;
1397 ctl = mixer_get_ctl_by_name(adev->mixer, mixer_ctl_name);
1416 struct audio_device *adev = out->dev;
1422 pthread_mutex_lock(&adev->lock);
1424 pthread_mutex_unlock(&adev->lock);
1671 struct audio_device *adev = in->dev;
1676 pthread_mutex_lock(&adev->lock);
1683 pthread_mutex_unlock(&adev->lock);
1698 struct audio_device *adev = in->dev;
1710 pthread_mutex_lock(&adev->lock);
1726 ret = select_devices(adev, in->usecase);
1730 pthread_mutex_unlock(&adev->lock);
1753 struct audio_device *adev = in->dev;
1758 pthread_mutex_lock(&adev->lock);
1760 pthread_mutex_unlock(&adev->lock);
1775 if (ret == 0 && adev->mic_mute)
1843 struct audio_device *adev = (struct audio_device *)dev;
1857 out->dev = adev;
1868 pthread_mutex_lock(&adev->lock);
1870 pthread_mutex_unlock(&adev->lock);
1947 if(adev->primary_output == NULL)
1948 adev->primary_output = out;
1957 pthread_mutex_lock(&adev->lock);
1958 if (get_usecase_from_list(adev, out->usecase) != NULL) {
1960 pthread_mutex_unlock(&adev->lock);
1964 pthread_mutex_unlock(&adev->lock);
2011 struct audio_device *adev = out->dev;
2029 struct audio_device *adev = (struct audio_device *)dev;
2054 pthread_mutex_lock(&adev->lock);
2055 if (tty_mode != adev->tty_mode) {
2056 adev->tty_mode = tty_mode;
2057 adev->acdb_settings = (adev->acdb_settings & TTY_MODE_CLEAR) | tty_mode;
2058 if (adev->in_call)
2059 select_devices(adev, USECASE_VOICE_CALL);
2061 pthread_mutex_unlock(&adev->lock);
2070 adev->bluetooth_nrec = true;
2072 adev->bluetooth_nrec = false;
2078 adev->screen_off = false;
2080 adev->screen_off = true;
2100 pthread_mutex_lock(&adev->lock);
2101 if (adev->speaker_lr_swap != reverse_speakers) {
2102 adev->speaker_lr_swap = reverse_speakers;
2106 list_for_each(node, &adev->usecase_list) {
2109 select_devices(adev, usecase->id);
2114 pthread_mutex_unlock(&adev->lock);
2133 /* always called with adev lock held */
2134 static int set_voice_volume_l(struct audio_device *adev, float volume)
2138 if (adev->mode == AUDIO_MODE_IN_CALL) {
2152 err = platform_set_voice_volume(adev->platform, vol);
2160 struct audio_device *adev = (struct audio_device *)dev;
2161 pthread_mutex_lock(&adev->lock);
2163 adev->voice_volume = volume;
2164 ret = set_voice_volume_l(adev, adev->voice_volume);
2165 pthread_mutex_unlock(&adev->lock);
2192 struct audio_device *adev = (struct audio_device *)dev;
2194 pthread_mutex_lock(&adev->lock);
2195 if (adev->mode != mode) {
2196 adev->mode = mode;
2198 pthread_mutex_unlock(&adev->lock);
2204 struct audio_device *adev = (struct audio_device *)dev;
2207 pthread_mutex_lock(&adev->lock);
2208 adev->mic_mute = state;
2210 err = platform_set_mic_mute(adev->platform, state);
2211 pthread_mutex_unlock(&adev->lock);
2217 struct audio_device *adev = (struct audio_device *)dev;
2219 *state = adev->mic_mute;
2238 struct audio_device *adev = (struct audio_device *)dev;
2268 in->dev = adev;
2312 struct audio_device *adev = (struct audio_device *)device;
2313 audio_route_free(adev->audio_route);
2314 free(adev->snd_dev_ref_cnt);
2315 platform_deinit(adev->platform);
2323 struct audio_device *adev;
2329 adev = calloc(1, sizeof(struct audio_device));
2331 adev->device.common.tag = HARDWARE_DEVICE_TAG;
2332 adev->device.common.version = AUDIO_DEVICE_API_VERSION_2_0;
2333 adev->device.common.module = (struct hw_module_t *)module;
2334 adev->device.common.close = adev_close;
2336 adev->device.init_check = adev_init_check;
2337 adev->device.set_voice_volume = adev_set_voice_volume;
2338 adev->device.set_master_volume = adev_set_master_volume;
2339 adev->device.get_master_volume = adev_get_master_volume;
2340 adev->device.set_master_mute = adev_set_master_mute;
2341 adev->device.get_master_mute = adev_get_master_mute;
2342 adev->device.set_mode = adev_set_mode;
2343 adev->device.set_mic_mute = adev_set_mic_mute;
2344 adev->device.get_mic_mute = adev_get_mic_mute;
2345 adev->device.set_parameters = adev_set_parameters;
2346 adev->device.get_parameters = adev_get_parameters;
2347 adev->device.get_input_buffer_size = adev_get_input_buffer_size;
2348 adev->device.open_output_stream = adev_open_output_stream;
2349 adev->device.close_output_stream = adev_close_output_stream;
2350 adev->device.open_input_stream = adev_open_input_stream;
2351 adev->device.close_input_stream = adev_close_input_stream;
2352 adev->device.dump = adev_dump;
2355 pthread_mutex_lock(&adev->lock);
2356 adev->mode = AUDIO_MODE_NORMAL;
2357 adev->active_input = NULL;
2358 adev->primary_output = NULL;
2359 adev->out_device = AUDIO_DEVICE_NONE;
2360 adev->voice_call_rx = NULL;
2361 adev->voice_call_tx = NULL;
2362 adev->voice_volume = 1.0f;
2363 adev->tty_mode = TTY_MODE_OFF;
2364 adev->bluetooth_nrec = true;
2365 adev->in_call = false;
2366 adev->acdb_settings = TTY_MODE_OFF;
2367 /* adev->cur_hdmi_channels = 0; by calloc() */
2368 adev->snd_dev_ref_cnt = calloc(SND_DEVICE_MAX, sizeof(int));
2369 list_init(&adev->usecase_list);
2370 pthread_mutex_unlock(&adev->lock);
2373 adev->platform = platform_init(adev);
2374 if (!adev->platform) {
2375 free(adev->snd_dev_ref_cnt);
2376 free(adev);
2383 adev->visualizer_lib = dlopen(VISUALIZER_LIBRARY_PATH, RTLD_NOW);
2384 if (adev->visualizer_lib == NULL) {
2388 adev->visualizer_start_output =
2389 (int (*)(audio_io_handle_t))dlsym(adev->visualizer_lib,
2391 adev->visualizer_stop_output =
2392 (int (*)(audio_io_handle_t))dlsym(adev->visualizer_lib,
2397 *device = &adev->device.common;