| /* |
| * Copyright (C) 2017 The Android Open Source Project |
| * |
| * Licensed under the Apache License, Version 2.0 (the "License"); |
| * you may not use this file except in compliance with the License. |
| * You may obtain a copy of the License at |
| * |
| * http://www.apache.org/licenses/LICENSE-2.0 |
| * |
| * Unless required by applicable law or agreed to in writing, software |
| * distributed under the License is distributed on an "AS IS" BASIS, |
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| * See the License for the specific language governing permissions and |
| * limitations under the License. |
| */ |
| |
| #ifndef AUDIO_PROXY_H |
| #define AUDIO_PROXY_H |
| |
| #include <system/audio.h> |
| #include <hardware/hardware.h> |
| #include <hardware/audio.h> |
| #include <hardware/audio_alsaops.h> |
| |
| #include <audio_utils/resampler.h> |
| |
| #include "alsa_device_profile.h" |
| #include "alsa_device_proxy.h" |
| #include "alsa_logging.h" |
| |
| #include "audio_streams.h" |
| #include "audio_usages.h" |
| #include "audio_devices.h" |
| #include "audio_offload.h" |
| |
| #include "audio_pcm.h" |
| #include "audio_mixer.h" |
| #include "audio_abox.h" |
| #include "audio_streamconfig.h" |
| #include "audio_board_info.h" |
| |
| /* Data Structure for Audio Proxy */ |
| struct audio_proxy_stream |
| { |
| audio_stream_type stream_type; |
| audio_usage stream_usage; |
| |
| // Real configuration for PCM/Compress Device |
| int sound_card; |
| int sound_device; |
| |
| /* DMA pcm handle is required for triggering Virtual node use-case */ |
| struct pcm *dma_pcm; |
| /* Can be actual DMA handle or virtual pcm depends upon scenario */ |
| struct pcm *pcm; |
| struct pcm_config pcmconfig; |
| |
| // Offload Specific |
| struct compress *compress; |
| struct compr_config comprconfig; |
| |
| int nonblock_flag; |
| int ready_new_metadata; |
| struct compr_gapless_mdata offload_metadata; |
| |
| // USB Specific |
| alsa_device_profile *usb_profile; |
| alsa_device_proxy *usb_proxy; |
| |
| // Common |
| unsigned int requested_sample_rate; |
| audio_channel_mask_t requested_channel_mask; |
| audio_format_t requested_format; |
| |
| float vol_left, vol_right; |
| |
| uint64_t frames; /* total frames written, not cleared when entering standby */ |
| |
| |
| // Channel Conversion & Resample for Recording |
| bool need_channelconversion; |
| bool need_resampling; |
| |
| int16_t* actual_read_buf; |
| int actual_read_status; |
| size_t actual_read_buf_size; |
| size_t read_buf_frames; |
| |
| void * proc_buf_out; |
| int proc_buf_size; |
| |
| // Resampler |
| struct resampler_itfe * resampler; |
| struct resampler_buffer_provider buf_provider; |
| |
| |
| #ifdef SUPPORT_STHAL_INTERFACE |
| int soundtrigger_handle; |
| #ifdef SEAMLESS_DUMP |
| FILE *fp; |
| #endif |
| #endif |
| |
| bool need_update_pcm_config; |
| bool skip_ch_convert; |
| bool need_channelpadding; |
| }; |
| |
| struct audio_proxy |
| { |
| // Audio Path Routing |
| struct mixer *mixer; |
| struct audio_route *aroute; |
| char *xml_path; |
| |
| // Mixer Update Thread |
| pthread_rwlock_t mixer_update_lock; |
| pthread_t mixer_update_thread; |
| |
| audio_usage active_playback_ausage; |
| device_type active_playback_device; |
| modifier_type active_playback_modifier; |
| |
| audio_usage active_capture_ausage; |
| device_type active_capture_device; |
| modifier_type active_capture_modifier; |
| |
| // Primary Output Stream Proxy |
| struct audio_proxy_stream *primary_out; |
| |
| /* Device Configuration */ |
| int num_earpiece; |
| int num_speaker; |
| int num_proximity; |
| |
| /* BuiltIn MIC Characteristics Map */ |
| int num_mic; |
| struct audio_microphone_characteristic_t mic_info[AUDIO_MICROPHONE_MAX_COUNT]; |
| |
| // PCM Devices for Audio Path(Loopback / ERAP) |
| bool support_out_loopback; |
| struct pcm *out_loopback; |
| struct pcm *erap_in; |
| |
| /* Speaker AMP Configuration */ |
| bool support_spkamp; |
| struct pcm *spkamp_reference; |
| struct pcm *spkamp_playback; |
| |
| /* Bluetooth Configuration */ |
| bool bt_internal; |
| bool bt_external; |
| |
| #ifdef SUPPORT_BTA2DP_OFFLOAD |
| pthread_mutex_t a2dp_lock; |
| bool support_bta2dp; |
| bool a2dp_out_enabled; |
| bool a2dp_suspend; |
| uint32_t a2dp_delay; |
| uint32_t a2dp_default_delay; |
| struct pcm *bta2dp_playback; |
| struct pcm *bta2dp_out_loopback; |
| struct pcm *a2dp_mute_playback; |
| #endif |
| |
| bool support_btsco; |
| struct pcm *btsco_erap[BTSCO_MAX_ERAP_IDX]; |
| int btsco_samplerate; |
| |
| /* FM Radio Configuration */ |
| bool fm_internal; |
| bool fm_external; |
| |
| struct pcm *fm_playback; // FM PCM Playback from A-Box |
| struct pcm *fm_capture; // FM PCM Capture to A-Box |
| |
| /* USB Configuration */ |
| bool usb_by_primary; |
| bool is_usb_single_clksrc; // USB device clock source info |
| |
| void *usb_aproxy; |
| |
| // PCM Devices for USB Audio |
| bool support_usb_out_loopback; |
| struct pcm *usb_out_loopback; |
| bool support_usb_in_loopback; |
| struct pcm *usb_in_loopback; |
| |
| /* PCM Devices for Voice Call */ |
| struct pcm *call_rx; // CP to Output Devices |
| struct pcm *call_tx; // Input Devices to CP |
| struct pcm *call_tx_direct; // Direct routing for Input Devices |
| |
| // Call State |
| bool call_state; |
| |
| /* Audio Mode */ |
| int audio_mode; |
| bool skip_internalpath; // flag to skip internal pcm close/re-open |
| |
| // Voice WakeUp |
| #ifdef SUPPORT_STHAL_INTERFACE |
| /* SoundTrigger library interface */ |
| void *sound_trigger_lib; |
| int (*sound_trigger_open_for_streaming)(); |
| size_t (*sound_trigger_read_samples)(int, void*, size_t); |
| int (*sound_trigger_close_for_streaming)(int); |
| int (*sound_trigger_open_recording)(); |
| size_t (*sound_trigger_read_recording_samples)(void*, size_t); |
| int (*sound_trigger_close_recording)(); |
| |
| int (*sound_trigger_headset_status)(int); |
| int (*sound_trigger_voicecall_status)(int); |
| |
| int sthal_state; |
| #endif |
| |
| void *offload_effect_lib; |
| void (*offload_effect_lib_update)(struct mixer *, int); |
| |
| bool support_dualspk; //Dual Speaker |
| bool spk_ampL_powerOn; //Dual Speaker |
| }; |
| |
| |
| #define MIXER_UPDATE_TIMEOUT 5 // 5 seconds |
| |
| #define STR(s) #s |
| #define XSTR(s) STR(s) |
| |
| #ifdef SUPPORT_STHAL_INTERFACE |
| #define SOUND_TRIGGER_HAL_LIBRARY_PATH "sound_trigger.primary.%s.so" |
| #endif |
| |
| #endif /* AUDIO_PROXY_H */ |