Lines Matching refs:a2dp

253 struct a2dp_data a2dp;  variable
545 a2dp.a2dp_started = false; in a2dp_common_init()
546 a2dp.a2dp_total_active_session_request = 0; in a2dp_common_init()
547 a2dp.a2dp_suspended = false; in a2dp_common_init()
548 a2dp.bt_encoder_format = ENC_CODEC_TYPE_INVALID; in a2dp_common_init()
549 a2dp.bt_state = A2DP_STATE_DISCONNECTED; in a2dp_common_init()
550 a2dp.abr_config.is_abr_enabled = false; in a2dp_common_init()
551 a2dp.abr_config.abr_started = false; in a2dp_common_init()
552 a2dp.abr_config.imc_instance = 0; in a2dp_common_init()
553 a2dp.abr_config.abr_tx_handle = NULL; in a2dp_common_init()
558 a2dp.is_a2dp_offload_enabled = in update_offload_codec_support()
563 a2dp.is_a2dp_offload_enabled); in update_offload_codec_support()
575 if (a2dp.abr_config.abr_tx_handle != NULL) { in stop_abr()
576 pcm_close(a2dp.abr_config.abr_tx_handle); in stop_abr()
577 a2dp.abr_config.abr_tx_handle = NULL; in stop_abr()
579 a2dp.abr_config.abr_started = false; in stop_abr()
580 a2dp.abr_config.imc_instance = 0; in stop_abr()
583 ctl_set_bt_feedback_channel = mixer_get_ctl_by_name(a2dp.adev->mixer, in stop_abr()
596 ctl_abr_tx_path = mixer_get_ctl_by_name(a2dp.adev->mixer, in stop_abr()
617 if (!a2dp.abr_config.is_abr_enabled) { in start_abr()
622 if (a2dp.abr_config.abr_started) { in start_abr()
629 ctl_abr_tx_path = mixer_get_ctl_by_name(a2dp.adev->mixer, in start_abr()
642 ctl_set_bt_feedback_channel = mixer_get_ctl_by_name(a2dp.adev->mixer, in start_abr()
656 if (!a2dp.abr_config.abr_tx_handle) { in start_abr()
657 a2dp.abr_config.abr_tx_handle = pcm_open(a2dp.adev->snd_card, in start_abr()
660 if (a2dp.abr_config.abr_tx_handle == NULL || in start_abr()
661 !pcm_is_ready(a2dp.abr_config.abr_tx_handle)) in start_abr()
664 ret = pcm_start(a2dp.abr_config.abr_tx_handle); in start_abr()
667 a2dp.abr_config.abr_started = true; in start_abr()
672 ALOGE("%s: %s", __func__, pcm_get_error(a2dp.abr_config.abr_tx_handle)); in start_abr()
685 if (a2dp.bt_state != A2DP_STATE_DISCONNECTED) { in open_a2dp_output()
687 __func__, a2dp.bt_state); in open_a2dp_output()
691 if (a2dp.bt_lib_handle == NULL) { in open_a2dp_output()
695 a2dp.bt_lib_handle = dlopen(BTAUDIO_OFFLOAD_LIB_NAME, RTLD_NOW); in open_a2dp_output()
697 a2dp.bt_lib_handle = dlopen(BT_IPC_LIB_NAME, RTLD_NOW); in open_a2dp_output()
699 if (a2dp.bt_lib_handle == NULL) { in open_a2dp_output()
703 a2dp.bt_state = A2DP_STATE_DISCONNECTED; in open_a2dp_output()
706 a2dp.audio_stream_open = (audio_stream_open_t) in open_a2dp_output()
707 dlsym(a2dp.bt_lib_handle, "audio_stream_open"); in open_a2dp_output()
708 a2dp.audio_stream_start = (audio_stream_start_t) in open_a2dp_output()
709 dlsym(a2dp.bt_lib_handle, "audio_stream_start"); in open_a2dp_output()
710 a2dp.audio_get_codec_config = (audio_get_codec_config_t) in open_a2dp_output()
711 dlsym(a2dp.bt_lib_handle, "audio_get_codec_config"); in open_a2dp_output()
712 a2dp.audio_stream_suspend = (audio_stream_suspend_t) in open_a2dp_output()
713 dlsym(a2dp.bt_lib_handle, "audio_stream_suspend"); in open_a2dp_output()
714 a2dp.audio_handoff_triggered = (audio_handoff_triggered_t) in open_a2dp_output()
715 dlsym(a2dp.bt_lib_handle, "audio_handoff_triggered"); in open_a2dp_output()
716 a2dp.clear_a2dp_suspend_flag = (clear_a2dp_suspend_flag_t) in open_a2dp_output()
717 dlsym(a2dp.bt_lib_handle, "clear_a2dp_suspend_flag"); in open_a2dp_output()
718 a2dp.audio_stream_stop = (audio_stream_stop_t) in open_a2dp_output()
719 dlsym(a2dp.bt_lib_handle, "audio_stream_stop"); in open_a2dp_output()
720 a2dp.audio_stream_close = (audio_stream_close_t) in open_a2dp_output()
721 dlsym(a2dp.bt_lib_handle, "audio_stream_close"); in open_a2dp_output()
722 a2dp.audio_check_a2dp_ready = (audio_check_a2dp_ready_t) in open_a2dp_output()
723 dlsym(a2dp.bt_lib_handle,"audio_check_a2dp_ready"); in open_a2dp_output()
724 a2dp.audio_is_scrambling_enabled = (audio_is_scrambling_enabled_t) in open_a2dp_output()
725 dlsym(a2dp.bt_lib_handle,"audio_is_scrambling_enabled"); in open_a2dp_output()
726 a2dp.audio_get_a2dp_sink_latency = (audio_get_a2dp_sink_latency_t) in open_a2dp_output()
727 dlsym(a2dp.bt_lib_handle,"audio_get_a2dp_sink_latency"); in open_a2dp_output()
731 if (a2dp.bt_lib_handle && a2dp.audio_stream_open) { in open_a2dp_output()
733 ret = a2dp.audio_stream_open(); in open_a2dp_output()
736 dlclose(a2dp.bt_lib_handle); in open_a2dp_output()
737 a2dp.bt_lib_handle = NULL; in open_a2dp_output()
738 a2dp.bt_state = A2DP_STATE_DISCONNECTED; in open_a2dp_output()
741 a2dp.bt_state = A2DP_STATE_CONNECTED; in open_a2dp_output()
744 a2dp.bt_state = A2DP_STATE_DISCONNECTED; in open_a2dp_output()
754 if (!(a2dp.bt_lib_handle && a2dp.audio_stream_close)) { in close_a2dp_output()
758 if (a2dp.bt_state != A2DP_STATE_DISCONNECTED) { in close_a2dp_output()
760 if (a2dp.audio_stream_close() == false) in close_a2dp_output()
764 a2dp.enc_sampling_rate = 0; in close_a2dp_output()
765 a2dp.enc_channels = 0; in close_a2dp_output()
775 if (a2dp.audio_is_scrambling_enabled && (a2dp.bt_state != A2DP_STATE_DISCONNECTED)) in a2dp_check_and_set_scrambler()
776 scrambler_mode = a2dp.audio_is_scrambling_enabled(); in a2dp_check_and_set_scrambler()
782 ctrl_scrambler_mode = mixer_get_ctl_by_name(a2dp.adev->mixer, in a2dp_check_and_set_scrambler()
801 uint32_t sampling_rate_rx = a2dp.enc_sampling_rate; in a2dp_set_backend_cfg()
806 if ((a2dp.bt_encoder_format == ENC_CODEC_TYPE_LDAC) && in a2dp_set_backend_cfg()
811 if (a2dp.bt_encoder_format == ENC_CODEC_TYPE_PCM) { in a2dp_set_backend_cfg()
832 ctl_sample_rate = mixer_get_ctl_by_name(a2dp.adev->mixer, in a2dp_set_backend_cfg()
844 if (a2dp.abr_config.is_abr_enabled) { in a2dp_set_backend_cfg()
848 ctl_sample_rate = mixer_get_ctl_by_name(a2dp.adev->mixer, in a2dp_set_backend_cfg()
862 switch (a2dp.enc_channels) { in a2dp_set_backend_cfg()
872 ALOGV("%s: set AFE input channels = %d", __func__, a2dp.enc_channels); in a2dp_set_backend_cfg()
873 ctrl_in_channels = mixer_get_ctl_by_name(a2dp.adev->mixer, in a2dp_set_backend_cfg()
880 ALOGE("%s: Failed to set AFE in channels = %d", __func__, a2dp.enc_channels); in a2dp_set_backend_cfg()
907 ctrl_bit_format = mixer_get_ctl_by_name(a2dp.adev->mixer, in a2dp_set_bit_format()
928 ctl_sample_rate_rx = mixer_get_ctl_by_name(a2dp.adev->mixer, in a2dp_reset_backend_cfg()
939 if (a2dp.abr_config.is_abr_enabled) { in a2dp_reset_backend_cfg()
940 ctl_sample_rate_tx = mixer_get_ctl_by_name(a2dp.adev->mixer, in a2dp_reset_backend_cfg()
954 ctrl_in_channels = mixer_get_ctl_by_name(a2dp.adev->mixer, in a2dp_reset_backend_cfg()
961 ALOGE("%s: Failed to reset AFE in channels = %d", __func__, a2dp.enc_channels); in a2dp_reset_backend_cfg()
975 if (a2dp.abr_config.is_abr_enabled) { in configure_a2dp_decoder_format()
976 ctl_dec_data = mixer_get_ctl_by_name(a2dp.adev->mixer, MIXER_DEC_CONFIG_BLOCK); in configure_a2dp_decoder_format()
986 dec_cfg.imc_info.comm_instance = a2dp.abr_config.imc_instance; in configure_a2dp_decoder_format()
1012 ctl_enc_data = mixer_get_ctl_by_name(a2dp.adev->mixer, MIXER_ENC_CONFIG_BLOCK); in configure_sbc_enc_format()
1056 a2dp.bt_encoder_format = ENC_CODEC_TYPE_SBC; in configure_sbc_enc_format()
1057 a2dp.enc_sampling_rate = sbc_bt_cfg->sampling_rate; in configure_sbc_enc_format()
1060 a2dp.enc_channels = 1; in configure_sbc_enc_format()
1062 a2dp.enc_channels = 2; in configure_sbc_enc_format()
1085 ctl_enc_data = mixer_get_ctl_by_name(a2dp.adev->mixer, MIXER_ENC_CONFIG_BLOCK); in configure_aptx_enc_format()
1095 if (!a2dp.is_aptx_dual_mono_supported) { in configure_aptx_enc_format()
1127 a2dp.bt_encoder_format = ENC_CODEC_TYPE_APTX; in configure_aptx_enc_format()
1128 a2dp.enc_channels = aptx_dsp_cfg.custom_cfg.num_channels; in configure_aptx_enc_format()
1129 if (!a2dp.is_aptx_dual_mono_supported) { in configure_aptx_enc_format()
1130 a2dp.enc_sampling_rate = aptx_bt_cfg->default_cfg->sampling_rate; in configure_aptx_enc_format()
1135 a2dp.enc_sampling_rate = aptx_bt_cfg->dual_mono_cfg->sampling_rate; in configure_aptx_enc_format()
1161 ctl_enc_data = mixer_get_ctl_by_name(a2dp.adev->mixer, MIXER_ENC_CONFIG_BLOCK); in configure_aptx_hd_enc_format()
1195 a2dp.bt_encoder_format = ENC_CODEC_TYPE_APTX_HD; in configure_aptx_hd_enc_format()
1196 a2dp.enc_sampling_rate = aptx_bt_cfg->sampling_rate; in configure_aptx_hd_enc_format()
1197 a2dp.enc_channels = aptx_bt_cfg->channels; in configure_aptx_hd_enc_format()
1217 ctl_enc_data = mixer_get_ctl_by_name(a2dp.adev->mixer, MIXER_ENC_CONFIG_BLOCK); in configure_aac_enc_format()
1256 a2dp.bt_encoder_format = ENC_CODEC_TYPE_AAC; in configure_aac_enc_format()
1257 a2dp.enc_sampling_rate = aac_bt_cfg->sampling_rate; in configure_aac_enc_format()
1258 a2dp.enc_channels = aac_bt_cfg->channels; in configure_aac_enc_format()
1277 ldac_enc_data = mixer_get_ctl_by_name(a2dp.adev->mixer, MIXER_ENC_CONFIG_BLOCK); in configure_ldac_enc_format()
1310 ldac_dsp_cfg.abr_cfg.imc_info.comm_instance = a2dp.abr_config.imc_instance; in configure_ldac_enc_format()
1327 a2dp.bt_encoder_format = ENC_CODEC_TYPE_LDAC; in configure_ldac_enc_format()
1328 a2dp.enc_sampling_rate = ldac_bt_cfg->sampling_rate; in configure_ldac_enc_format()
1329 a2dp.enc_channels = ldac_dsp_cfg.custom_cfg.num_channels; in configure_ldac_enc_format()
1330 a2dp.abr_config.is_abr_enabled = ldac_bt_cfg->is_abr_enabled; in configure_ldac_enc_format()
1346 if (!a2dp.audio_get_codec_config) { in configure_a2dp_encoder_format()
1351 codec_info = a2dp.audio_get_codec_config(&multi_cast, &num_dev, in configure_a2dp_encoder_format()
1355 a2dp.abr_config.is_abr_enabled = false; in configure_a2dp_encoder_format()
1365 a2dp.is_aptx_dual_mono_supported = false; in configure_a2dp_encoder_format()
1384 a2dp.abr_config.imc_instance = instance_id--; in configure_a2dp_encoder_format()
1391 a2dp.bt_encoder_format = ENC_CODEC_TYPE_PCM; in configure_a2dp_encoder_format()
1408 if (!(a2dp.bt_lib_handle && a2dp.audio_stream_start in audio_extn_a2dp_start_playback()
1409 && a2dp.audio_get_codec_config)) { in audio_extn_a2dp_start_playback()
1414 if (a2dp.a2dp_suspended) { in audio_extn_a2dp_start_playback()
1420 if (!a2dp.a2dp_started && !a2dp.a2dp_total_active_session_request) { in audio_extn_a2dp_start_playback()
1423 ret = a2dp.audio_stream_start(); in audio_extn_a2dp_start_playback()
1426 a2dp.a2dp_started = false; in audio_extn_a2dp_start_playback()
1429 a2dp.a2dp_started = true; in audio_extn_a2dp_start_playback()
1434 a2dp.a2dp_started = false; in audio_extn_a2dp_start_playback()
1440 if (a2dp.a2dp_started) { in audio_extn_a2dp_start_playback()
1441 a2dp.a2dp_total_active_session_request++; in audio_extn_a2dp_start_playback()
1444 if (a2dp.abr_config.is_abr_enabled) in audio_extn_a2dp_start_playback()
1449 a2dp.a2dp_total_active_session_request); in audio_extn_a2dp_start_playback()
1461 ctl_enc_config = mixer_get_ctl_by_name(a2dp.adev->mixer, in reset_a2dp_enc_config_params()
1468 a2dp.bt_encoder_format = ENC_MEDIA_FMT_NONE; in reset_a2dp_enc_config_params()
1482 if (a2dp.abr_config.is_abr_enabled) { in reset_a2dp_dec_config_params()
1483 ctl_dec_data = mixer_get_ctl_by_name(a2dp.adev->mixer, MIXER_DEC_CONFIG_BLOCK); in reset_a2dp_dec_config_params()
1504 if (a2dp.abr_config.is_abr_enabled && a2dp.abr_config.abr_started) in reset_a2dp_config()
1506 a2dp.abr_config.is_abr_enabled = false; in reset_a2dp_config()
1514 if (!(a2dp.bt_lib_handle && a2dp.audio_stream_stop)) { in audio_extn_a2dp_stop_playback()
1519 if (a2dp.a2dp_total_active_session_request > 0) in audio_extn_a2dp_stop_playback()
1520 a2dp.a2dp_total_active_session_request--; in audio_extn_a2dp_stop_playback()
1524 if (a2dp.a2dp_started && !a2dp.a2dp_total_active_session_request) { in audio_extn_a2dp_stop_playback()
1526 ret = a2dp.audio_stream_stop(); in audio_extn_a2dp_stop_playback()
1531 if (!a2dp.a2dp_suspended) in audio_extn_a2dp_stop_playback()
1533 a2dp.a2dp_started = false; in audio_extn_a2dp_stop_playback()
1536 a2dp.a2dp_total_active_session_request); in audio_extn_a2dp_stop_playback()
1548 if (a2dp.is_a2dp_offload_enabled == false) { in audio_extn_a2dp_set_parameters()
1580 if (a2dp.bt_lib_handle && (a2dp.bt_state != A2DP_STATE_DISCONNECTED)) { in audio_extn_a2dp_set_parameters()
1582 if (a2dp.a2dp_suspended) { in audio_extn_a2dp_set_parameters()
1587 a2dp.a2dp_suspended = true; in audio_extn_a2dp_set_parameters()
1588 list_for_each(node, &a2dp.adev->usecase_list) { in audio_extn_a2dp_set_parameters()
1592 pthread_mutex_unlock(&a2dp.adev->lock); in audio_extn_a2dp_set_parameters()
1593 check_a2dp_restore(a2dp.adev, uc_info->stream.out, false); in audio_extn_a2dp_set_parameters()
1594 pthread_mutex_lock(&a2dp.adev->lock); in audio_extn_a2dp_set_parameters()
1598 if (a2dp.audio_stream_suspend) { in audio_extn_a2dp_set_parameters()
1599 a2dp.audio_stream_suspend(); in audio_extn_a2dp_set_parameters()
1602 if (!a2dp.a2dp_suspended) { in audio_extn_a2dp_set_parameters()
1609 if (a2dp.clear_a2dp_suspend_flag) { in audio_extn_a2dp_set_parameters()
1610 a2dp.clear_a2dp_suspend_flag(); in audio_extn_a2dp_set_parameters()
1612 a2dp.a2dp_suspended = false; in audio_extn_a2dp_set_parameters()
1624 if (a2dp.a2dp_total_active_session_request > 0) { in audio_extn_a2dp_set_parameters()
1626 if (a2dp.audio_stream_start) { in audio_extn_a2dp_set_parameters()
1627 status = a2dp.audio_stream_start(); in audio_extn_a2dp_set_parameters()
1630 a2dp.a2dp_started = false; in audio_extn_a2dp_set_parameters()
1634 a2dp.a2dp_started = false; in audio_extn_a2dp_set_parameters()
1639 if (a2dp.a2dp_started) { in audio_extn_a2dp_set_parameters()
1641 if (a2dp.abr_config.is_abr_enabled) in audio_extn_a2dp_set_parameters()
1645 list_for_each(node, &a2dp.adev->usecase_list) { in audio_extn_a2dp_set_parameters()
1649 pthread_mutex_unlock(&a2dp.adev->lock); in audio_extn_a2dp_set_parameters()
1650 check_a2dp_restore(a2dp.adev, uc_info->stream.out, true); in audio_extn_a2dp_set_parameters()
1651 pthread_mutex_lock(&a2dp.adev->lock); in audio_extn_a2dp_set_parameters()
1662 if (a2dp.is_a2dp_offload_enabled && in audio_extn_a2dp_set_parameters()
1663 a2dp.bt_state != A2DP_STATE_DISCONNECTED) { in audio_extn_a2dp_set_parameters()
1676 a2dp.is_handoff_in_progress = is_on; in audio_extn_a2dp_set_handoff_mode()
1684 return a2dp.is_handoff_in_progress || !a2dp.a2dp_started; in audio_extn_a2dp_is_force_device_switch()
1689 *sample_rate = a2dp.enc_sampling_rate; in audio_extn_a2dp_get_sample_rate()
1696 if (a2dp.a2dp_suspended) in audio_extn_a2dp_is_ready()
1699 if ((a2dp.bt_state != A2DP_STATE_DISCONNECTED) && in audio_extn_a2dp_is_ready()
1700 (a2dp.is_a2dp_offload_enabled) && in audio_extn_a2dp_is_ready()
1701 (a2dp.audio_check_a2dp_ready)) in audio_extn_a2dp_is_ready()
1702 ret = a2dp.audio_check_a2dp_ready(); in audio_extn_a2dp_is_ready()
1710 return a2dp.a2dp_suspended; in audio_extn_a2dp_is_suspended()
1715 a2dp.adev = (struct audio_device*)adev; in audio_extn_a2dp_init()
1716 a2dp.bt_lib_handle = NULL; in audio_extn_a2dp_init()
1718 a2dp.enc_sampling_rate = 48000; in audio_extn_a2dp_init()
1719 a2dp.is_a2dp_offload_enabled = false; in audio_extn_a2dp_init()
1720 a2dp.is_handoff_in_progress = false; in audio_extn_a2dp_init()
1721 a2dp.is_aptx_dual_mono_supported = false; in audio_extn_a2dp_init()
1747 if (a2dp.audio_get_a2dp_sink_latency && a2dp.bt_state != A2DP_STATE_DISCONNECTED) { in audio_extn_a2dp_get_encoder_latency()
1748 slatency_ms = a2dp.audio_get_a2dp_sink_latency(); in audio_extn_a2dp_get_encoder_latency()
1751 switch (a2dp.bt_encoder_format) { in audio_extn_a2dp_get_encoder_latency()
1792 val = a2dp.is_a2dp_offload_enabled; in audio_extn_a2dp_get_parameters()