audio: hal: add support for Transcoding in LATV

- audio_policy clean up for LATV.
- Transcode changes in QAF.
- 3D audio prop set to false.
- Changes to enable routing to BT.

Change-Id: I1d76672cbbb29274bac29ec779dee31c0d3e9469
This commit is contained in:
Tejaswini Devanaboyina 2017-11-21 14:51:13 +05:30 committed by Naresh Tanniru
parent 9dff3597ae
commit 71b928edda
3 changed files with 152 additions and 23 deletions

2
configs/apq8098_latv/apq8098_latv.mk Normal file → Executable file
View File

@ -30,7 +30,7 @@ AUDIO_FEATURE_ENABLED_HW_ACCELERATED_EFFECTS := false
AUDIO_FEATURE_ENABLED_AUDIOSPHERE := true
AUDIO_FEATURE_ENABLED_USB_TUNNEL_AUDIO := true
AUDIO_FEATURE_ENABLED_SPLIT_A2DP := true
AUDIO_FEATURE_ENABLED_3D_AUDIO := true
AUDIO_FEATURE_ENABLED_3D_AUDIO := false
AUDIO_FEATURE_ENABLED_VOICE_PRINT := false
USE_LEGACY_AUDIO_DAEMON := false
USE_LEGACY_AUDIO_MEASUREMENT := false

View File

@ -21,6 +21,7 @@
<!-- version section contains a “version” tag in the form “major.minor” e.g version=”1.0” -->
<!-- Global configuration Decalaration -->
<globalConfiguration speaker_drc_enabled="true"/>
<!-- Modules section:
@ -48,7 +49,9 @@
<!-- Primary Audio HAL -->
<module name="primary" halVersion="2.0">
<attachedDevices>
<item>HDMI</item>
<item>Telephony Tx</item>
<item>Built-In Mic</item>
<item>Built-In Back Mic</item>
</attachedDevices>
<defaultOutputDevice>HDMI</defaultOutputDevice>
<mixPorts>
@ -56,26 +59,20 @@
<profile name="" format="AUDIO_FORMAT_PCM_16_BIT"
samplingRates="48000" channelMasks="AUDIO_CHANNEL_OUT_STEREO"/>
</mixPort>
<mixPort name="raw" role="source"
flags="AUDIO_OUTPUT_FLAG_FAST|AUDIO_OUTPUT_FLAG_RAW">
<profile name="" format="AUDIO_FORMAT_PCM_16_BIT"
samplingRates="48000" channelMasks="AUDIO_CHANNEL_OUT_STEREO"/>
</mixPort>
<mixPort name="mmap_no_irq_out" role="source" flags="AUDIO_OUTPUT_FLAG_DIRECT|AUDIO_OUTPUT_FLAG_MMAP_NOIRQ">
<profile name="" format="AUDIO_FORMAT_PCM_16_BIT"
samplingRates="48000" channelMasks="AUDIO_CHANNEL_OUT_STEREO"/>
</mixPort>
<mixPort name="compress_passthrough" role="source"
flags="AUDIO_OUTPUT_FLAG_DIRECT|AUDIO_OUTPUT_FLAG_COMPRESS_OFFLOAD|AUDIO_OUTPUT_FLAG_NON_BLOCKING">
<profile name="" format="dynamic"
samplingRates="dynamic" channelMasks="dynamic"/>
</mixPort>
<mixPort name="direct_pcm" role="source"
flags="AUDIO_OUTPUT_FLAG_DIRECT">
<profile name="" format="AUDIO_FORMAT_PCM_16_BIT"
samplingRates="8000,11025,12000,16000,22050,24000,32000,44100,48000,64000,88200,96000,128000,176400,192000"
channelMasks="AUDIO_CHANNEL_OUT_MONO,AUDIO_CHANNEL_OUT_STEREO,AUDIO_CHANNEL_OUT_2POINT1,AUDIO_CHANNEL_OUT_QUAD,AUDIO_CHANNEL_OUT_PENTA,AUDIO_CHANNEL_OUT_5POINT1,AUDIO_CHANNEL_OUT_6POINT1,AUDIO_CHANNEL_OUT_7POINT1"/>
<profile name="" format="AUDIO_FORMAT_PCM_8_24_BIT"
samplingRates="8000,11025,12000,16000,22050,24000,32000,44100,48000,64000,88200,96000,128000,176400,192000,352800,384000"
channelMasks="AUDIO_CHANNEL_OUT_MONO,AUDIO_CHANNEL_OUT_STEREO,AUDIO_CHANNEL_OUT_2POINT1,AUDIO_CHANNEL_OUT_QUAD,AUDIO_CHANNEL_OUT_PENTA,AUDIO_CHANNEL_OUT_5POINT1,AUDIO_CHANNEL_OUT_6POINT1,AUDIO_CHANNEL_OUT_7POINT1"/>
<profile name="" format="AUDIO_FORMAT_PCM_24_BIT_PACKED"
samplingRates="8000,11025,12000,16000,22050,24000,32000,44100,48000,64000,88200,96000,128000,176400,192000,352800,384000"
channelMasks="AUDIO_CHANNEL_OUT_MONO,AUDIO_CHANNEL_OUT_STEREO,AUDIO_CHANNEL_OUT_2POINT1,AUDIO_CHANNEL_OUT_QUAD,AUDIO_CHANNEL_OUT_PENTA,AUDIO_CHANNEL_OUT_5POINT1,AUDIO_CHANNEL_OUT_6POINT1,AUDIO_CHANNEL_OUT_7POINT1"/>
<profile name="" format="AUDIO_FORMAT_PCM_32_BIT"
samplingRates="8000,11025,12000,16000,22050,24000,32000,44100,48000,64000,88200,96000,128000,176400,192000,352800,384000"
channelMasks="AUDIO_CHANNEL_OUT_MONO,AUDIO_CHANNEL_OUT_STEREO,AUDIO_CHANNEL_OUT_2POINT1,AUDIO_CHANNEL_OUT_QUAD,AUDIO_CHANNEL_OUT_PENTA,AUDIO_CHANNEL_OUT_5POINT1,AUDIO_CHANNEL_OUT_6POINT1,AUDIO_CHANNEL_OUT_7POINT1"/>
</mixPort>
<mixPort name="compressed_offload" role="source"
flags="AUDIO_OUTPUT_FLAG_DIRECT|AUDIO_OUTPUT_FLAG_COMPRESS_OFFLOAD|AUDIO_OUTPUT_FLAG_NON_BLOCKING">
<profile name="" format="AUDIO_FORMAT_MP2"
@ -109,10 +106,50 @@
samplingRates="8000,11025,12000,16000,22050,24000,32000,44100,48000,64000,88200,96000"
channelMasks="AUDIO_CHANNEL_OUT_STEREO,AUDIO_CHANNEL_OUT_MONO"/>
</mixPort>
<mixPort name="voice_tx" role="source">
<profile name="" format="AUDIO_FORMAT_PCM_16_BIT"
samplingRates="8000,16000,48000" channelMasks="AUDIO_CHANNEL_OUT_MONO,AUDIO_CHANNEL_OUT_STEREO"/>
</mixPort>
<mixPort name="voip_rx" role="source"
flags="AUDIO_OUTPUT_FLAG_DIRECT|AUDIO_OUTPUT_FLAG_VOIP_RX">
<profile name="" format="AUDIO_FORMAT_PCM_16_BIT"
samplingRates="8000,16000,32000,48000" channelMasks="AUDIO_CHANNEL_OUT_MONO"/>
</mixPort>
<mixPort name="primary input" role="sink">
<profile name="" format="AUDIO_FORMAT_PCM_16_BIT"
samplingRates="8000,11025,12000,16000,22050,24000,32000,44100,48000"
channelMasks="AUDIO_CHANNEL_IN_MONO,AUDIO_CHANNEL_IN_STEREO,AUDIO_CHANNEL_IN_FRONT_BACK"/>
</mixPort>
<mixPort name="surround_sound" role="sink">
<profile name="" format="AUDIO_FORMAT_PCM_16_BIT"
samplingRates="8000,11025,12000,16000,22050,24000,32000,44100,48000"
channelMasks="AUDIO_CHANNEL_IN_MONO,AUDIO_CHANNEL_IN_STEREO,AUDIO_CHANNEL_IN_FRONT_BACK,AUDIO_CHANNEL_INDEX_MASK_3,AUDIO_CHANNEL_INDEX_MASK_4,AUDIO_CHANNEL_IN_5POINT1,AUDIO_CHANNEL_INDEX_MASK_6"/>
</mixPort>
<mixPort name="record_24" role="sink">
<profile name="" format="AUDIO_FORMAT_PCM_24_BIT_PACKED"
samplingRates="8000,11025,12000,16000,22050,24000,32000,44100,48000,96000,192000"
channelMasks="AUDIO_CHANNEL_IN_MONO,AUDIO_CHANNEL_IN_STEREO,AUDIO_CHANNEL_IN_FRONT_BACK,AUDIO_CHANNEL_INDEX_MASK_3,AUDIO_CHANNEL_INDEX_MASK_4"/>
<profile name="" format="AUDIO_FORMAT_PCM_8_24_BIT"
samplingRates="8000,11025,12000,16000,22050,24000,32000,44100,48000,96000,192000"
channelMasks="AUDIO_CHANNEL_IN_MONO,AUDIO_CHANNEL_IN_STEREO,AUDIO_CHANNEL_IN_FRONT_BACK,AUDIO_CHANNEL_INDEX_MASK_3,AUDIO_CHANNEL_INDEX_MASK_4"/>
<profile name="" format="AUDIO_FORMAT_PCM_FLOAT"
samplingRates="8000,11025,12000,16000,22050,24000,32000,44100,48000,96000,192000"
channelMasks="AUDIO_CHANNEL_IN_MONO,AUDIO_CHANNEL_IN_STEREO,AUDIO_CHANNEL_IN_FRONT_BACK,AUDIO_CHANNEL_INDEX_MASK_3,AUDIO_CHANNEL_INDEX_MASK_4"/>
</mixPort>
<mixPort name="mmap_no_irq_in" role="sink" flags="AUDIO_INPUT_FLAG_MMAP_NOIRQ">
<profile name="" format="AUDIO_FORMAT_PCM_16_BIT"
samplingRates="8000,11025,12000,16000,22050,24000,32000,44100,48000"
channelMasks="AUDIO_CHANNEL_IN_MONO,AUDIO_CHANNEL_IN_STEREO,AUDIO_CHANNEL_IN_FRONT_BACK,AUDIO_CHANNEL_INDEX_MASK_3"/>
</mixPort>
</mixPorts>
<devicePorts>
<!-- Output devices declaration, i.e. Sink DEVICE PORT -->
<devicePort tagName="Telephony Tx" type="AUDIO_DEVICE_OUT_TELEPHONY_TX" role="sink">
<profile name="" format="AUDIO_FORMAT_PCM_16_BIT"
samplingRates="8000,16000" channelMasks="AUDIO_CHANNEL_OUT_MONO,AUDIO_CHANNEL_OUT_STEREO"/>
</devicePort>
<devicePort tagName="HDMI" type="AUDIO_DEVICE_OUT_AUX_DIGITAL" role="sink">
<profile name="" format="AUDIO_FORMAT_PCM_16_BIT"
samplingRates="8000,11025,16000,22050,32000,44100,48000,64000,88200,96000,128000,176400,192000" channelMasks="dynamic"/>
@ -129,17 +166,41 @@
<profile name="" format="AUDIO_FORMAT_PCM_16_BIT"
samplingRates="48000" channelMasks="AUDIO_CHANNEL_OUT_STEREO"/>
</devicePort>
<devicePort tagName="Built-In Mic" type="AUDIO_DEVICE_IN_BUILTIN_MIC" role="source">
<profile name="" format="AUDIO_FORMAT_PCM_16_BIT"
samplingRates="8000,11025,12000,16000,22050,24000,32000,44100,48000"
channelMasks="AUDIO_CHANNEL_IN_MONO,AUDIO_CHANNEL_IN_STEREO,AUDIO_CHANNEL_IN_FRONT_BACK"/>
</devicePort>
<devicePort tagName="Built-In Back Mic" type="AUDIO_DEVICE_IN_BACK_MIC" role="source">
<profile name="" format="AUDIO_FORMAT_PCM_16_BIT"
samplingRates="8000,11025,12000,16000,22050,24000,32000,44100,48000"
channelMasks="AUDIO_CHANNEL_IN_MONO,AUDIO_CHANNEL_IN_STEREO,AUDIO_CHANNEL_IN_FRONT_BACK"/>
</devicePort>
<devicePort tagName="BT SCO Headset Mic" type="AUDIO_DEVICE_IN_BLUETOOTH_SCO_HEADSET" role="source">
<profile name="" format="AUDIO_FORMAT_PCM_16_BIT"
samplingRates="8000,16000" channelMasks="AUDIO_CHANNEL_IN_MONO"/>
</devicePort>
</devicePorts>
<!-- route declaration, i.e. list all available sources for a given sink -->
<routes>
<route type="mix" sink="HDMI"
sources="primary output,direct_pcm,compressed_offload,compress_passthrough"/>
sources="primary output,raw,compressed_offload,compress_passthrough"/>
<route type="mix" sink="Telephony Tx"
sources="voice_tx"/>
<route type="mix" sink="primary input"
sources="BT SCO Headset Mic"/>
<route type="mix" sink="surround_sound"
sources="Built-In Mic,Built-In Back Mic"/>
<route type="mix" sink="record_24"
sources="Built-In Mic,Built-In Back Mic"/>
<route type="mix" sink="mmap_no_irq_in"
sources="Built-In Mic,Built-In Back Mic"/>
<route type="mix" sink="BT A2DP Out"
sources="primary output,direct_pcm,compressed_offload"/>
sources="primary output,raw,compressed_offload"/>
<route type="mix" sink="BT A2DP Headphones"
sources="primary output,direct_pcm,compressed_offload"/>
sources="primary output,raw,compressed_offload"/>
<route type="mix" sink="BT A2DP Speaker"
sources="primary output,direct_pcm,compressed_offload"/>
sources="primary output,raw,compressed_offload"/>
</routes>
</module>

72
hal/audio_extn/qaf.c Normal file → Executable file
View File

@ -131,6 +131,7 @@ FILE *fp_output_writer_hdmi = NULL;
#endif
void set_hdmi_configuration_to_module();
void set_bt_configuration_to_module();
struct qaf_adsp_hdlr_config_state {
struct audio_adsp_event event_params;
@ -228,6 +229,7 @@ struct qaf {
pthread_mutex_t lock;
bool bt_connect;
bool hdmi_connect;
int hdmi_sink_channels;
@ -1951,8 +1953,10 @@ static int audio_extn_qaf_session_open(mm_module_type mod_type, struct stream_ou
qaf_mod,
&notify_event_callback,
AUDIO_DATA_EVENT_V2);
set_hdmi_configuration_to_module();
if(p_qaf->bt_connect)
set_bt_configuration_to_module();
else
set_hdmi_configuration_to_module();
#ifdef AUDIO_EXTN_IP_HDLR_ENABLED
if (mod_type == MS12) {
@ -2316,6 +2320,7 @@ static int qaf_out_set_parameters(struct audio_stream *stream, const char *kvpai
*/
out->devices = val;
#ifndef SPLIT_A2DP_ENABLED
if (val == AUDIO_DEVICE_OUT_BLUETOOTH_A2DP) {
//If device is BT then open the BT stream if not already opened.
if ( audio_extn_bt_hal_get_output_stream(qaf_mod->bt_hdl) == NULL
@ -2334,6 +2339,7 @@ static int qaf_out_set_parameters(struct audio_stream *stream, const char *kvpai
audio_extn_bt_hal_close_output_stream(qaf_mod->bt_hdl);
}
}
#endif
if (p_qaf->passthrough_in == out) { //Device routing is received for QAF passthrough stream.
@ -2512,6 +2518,14 @@ int audio_extn_qaf_open_output_stream(struct audio_hw_device *dev,
return ret;
}
#ifndef LINUX_ENABLED
//Bypass QAF for dummy PCM session opened by APM during boot time
if(flags == 0) {
ALOGD("bypassing QAF for flags is equal to none");
return ret;
}
#endif
out = (struct stream_out *)*stream_out;
ret = qaf_stream_open(out, config, flags, devices);
@ -2606,6 +2620,50 @@ bool audio_extn_qaf_is_enabled()
return (prop_enabled);
}
void set_bt_configuration_to_module()
{
if (!p_qaf) {
return;
}
if (!p_qaf->bt_connect) {
DEBUG_MSG("BT is not connected.");
return;
}
struct str_parms *qaf_params;
char *format_params = NULL;
qaf_params = str_parms_create();
if (qaf_params) {
//ms12 wrapper don't support bt, treat this as speaker and routign to bt
//will take care as a part of data callback notifier
str_parms_add_str(qaf_params,
AUDIO_QAF_PARAMETER_KEY_DEVICE,
AUDIO_QAF_PARAMETER_VALUE_DEVICE_SPEAKER);
str_parms_add_str(qaf_params,
AUDIO_QAF_PARAMETER_KEY_RENDER_FORMAT,
AUDIO_QAF_PARAMETER_VALUE_PCM);
format_params = str_parms_to_str(qaf_params);
if (p_qaf->qaf_mod[MS12].session_handle && p_qaf->qaf_mod[MS12].qaf_audio_session_set_param) {
ALOGE(" Configuring BT/speaker for MS12 wrapper");
p_qaf->qaf_mod[MS12].qaf_audio_session_set_param(p_qaf->qaf_mod[MS12].session_handle,
format_params);
}
if (p_qaf->qaf_mod[DTS_M8].session_handle
&& p_qaf->qaf_mod[DTS_M8].qaf_audio_session_set_param) {
ALOGE(" Configuring BT/speaker for MS12 wrapper");
p_qaf->qaf_mod[DTS_M8].qaf_audio_session_set_param(p_qaf->qaf_mod[DTS_M8].session_handle,
format_params);
}
}
str_parms_destroy(qaf_params);
}
/* Query HDMI EDID and sets module output accordingly.*/
void set_hdmi_configuration_to_module()
{
@ -2828,6 +2886,9 @@ int audio_extn_qaf_set_parameters(struct audio_device *adev, struct str_parms *p
set_hdmi_configuration_to_module();
} else if (val & AUDIO_DEVICE_OUT_BLUETOOTH_A2DP) {
p_qaf->bt_connect = 1;
set_bt_configuration_to_module();
#ifndef SPLIT_A2DP_ENABLED
for (k = 0; k < MAX_MM_MODULE_TYPE; k++) {
if (!p_qaf->qaf_mod[k].bt_hdl) {
DEBUG_MSG("Opening a2dp output...");
@ -2838,6 +2899,7 @@ int audio_extn_qaf_set_parameters(struct audio_device *adev, struct str_parms *p
}
}
}
#endif
}
//TODO else if: Need to consider other devices.
}
@ -2873,6 +2935,11 @@ int audio_extn_qaf_set_parameters(struct audio_device *adev, struct str_parms *p
str_parms_destroy(qaf_params);
close_qaf_passthrough_stream();
} else if (val & AUDIO_DEVICE_OUT_BLUETOOTH_A2DP) {
p_qaf->bt_connect = 0;
//reconfig HDMI as end device (if connected)
if(p_qaf->hdmi_connect)
set_hdmi_configuration_to_module();
#ifndef SPLIT_A2DP_ENABLED
DEBUG_MSG("Closing a2dp output...");
for (k = 0; k < MAX_MM_MODULE_TYPE; k++) {
if (p_qaf->qaf_mod[k].bt_hdl) {
@ -2880,6 +2947,7 @@ int audio_extn_qaf_set_parameters(struct audio_device *adev, struct str_parms *p
p_qaf->qaf_mod[k].bt_hdl = NULL;
}
}
#endif
}
//TODO else if: Need to consider other devices.
}