The mic2 loopback to spk
The video cable and audio cable to the line corresponding to the vehicle computer, CD player to play music, found no sound, first check the hardware,
amount to when playing with waveform
note: To tune into the oscilloscope mode of communication module can see models
Check mtk online, see most of the interface, and that he later wrote apk, found no authority, no effect, written in their own suspicion is required apk system privileges
so he will go into the system apk, adjust a few parameters, found have the effect of
interfaces are:
turn on
Blowing
sAudioManager.setParameters("SET_LOOPBACK_TYPE=3,3");
You can hear the sound of
sAudioManager.setParameters("SET_LOOPBACK_TYPE=25,3");
In fact, this is not much difference between the two
shut down
sAudioManager.setParameters("SET_LOOPBACK_TYPE=0");
Fulfillment:
status_t AudioMTKHardware::setCommonParameters(const String8 &keyValuePairs) {
// Loopback
if (param.get(keySET_LOOPBACK_TYPE, value_str) == NO_ERROR) {
param.remove(keySET_LOOPBACK_TYPE);
// parse format like "SET_LOOPBACK_TYPE=1" / "SET_LOOPBACK_TYPE=1+0"
int type_value = NO_LOOPBACK;
int device_value = -1;
sscanf(value_str.string(), "%d,%d", &type_value, &device_value);
ALOGV("type_value = %d, device_value = %d", type_value, device_value);
const loopback_t loopback_type = (loopback_t)type_value;
loopback_output_device_t loopback_output_device;
if (loopback_type == NO_LOOPBACK) { // close loopback
LoopbackManager::GetInstance()->SetLoopbackOff();
} else { // open loopback
if (device_value == LOOPBACK_OUTPUT_RECEIVER ||
device_value == LOOPBACK_OUTPUT_EARPHONE ||
device_value == LOOPBACK_OUTPUT_SPEAKER) { // assign output device
loopback_output_device = (loopback_output_device_t)device_value;
} else { // not assign output device
if (AudioSystem::getDeviceConnectionState(AUDIO_DEVICE_OUT_WIRED_HEADSET, "") == AUDIO_POLICY_DEVICE_STATE_AVAILABLE ||
AudioSystem::getDeviceConnectionState(AUDIO_DEVICE_OUT_WIRED_HEADPHONE, "") == AUDIO_POLICY_DEVICE_STATE_AVAILABLE) {
loopback_output_device = LOOPBACK_OUTPUT_EARPHONE;
} else if (bForceUseLoudSpeakerInsteadOfReceiver == true) {
loopback_output_device = LOOPBACK_OUTPUT_SPEAKER;
} else {
loopback_output_device = LOOPBACK_OUTPUT_RECEIVER;
}
}
LoopbackManager::GetInstance()->SetLoopbackOn(loopback_type, loopback_output_device);
}
break;
}
You can be aware of: SET_LOOPBACK_TYPE = 25,3
Below 25 corresponding to the source device loopback MD_REF_MIC_ACOUSTIC_LOOPBACK , or AP_REF_MIC_AFE_LOOPBACK
our mic2 corresponding to this band is ref of the mic
// for loopback
enum loopback_t {
NO_LOOPBACK = 0,
// AFE Loopback
AP_MAIN_MIC_AFE_LOOPBACK = 1,
AP_HEADSET_MIC_AFE_LOOPBACK = 2,
AP_REF_MIC_AFE_LOOPBACK = 3,
AP_3RD_MIC_AFE_LOOPBACK = 4,
// Acoustic Loopback
MD_MAIN_MIC_ACOUSTIC_LOOPBACK = 21,
MD_HEADSET_MIC_ACOUSTIC_LOOPBACK = 22,
MD_DUAL_MIC_ACOUSTIC_LOOPBACK_WITHOUT_DMNR = 23,
MD_DUAL_MIC_ACOUSTIC_LOOPBACK_WITH_DMNR = 24,
MD_REF_MIC_ACOUSTIC_LOOPBACK = 25,
MD_3RD_MIC_ACOUSTIC_LOOPBACK = 26,
// BT Loopback with codec
AP_BT_LOOPBACK = 30,
MD_BT_LOOPBACK = 31,
// BT Loopback without codec
AP_BT_LOOPBACK_NO_CODEC = 32,
MD_BT_LOOPBACK_NO_CODEC = 33,
};
Target output device SET_LOOPBACK_TYPE = 25,3 3 after the comma that we want to output SPK, LOOPBACK_OUTPUT_SPEAKER
enum loopback_output_device_t {
LOOPBACK_OUTPUT_RECEIVER = 1,
LOOPBACK_OUTPUT_EARPHONE = 2,
LOOPBACK_OUTPUT_SPEAKER = 3,
};
There is a sound behind
Wherein the interface-enabled device
AudioALSALoopbackController::getInstance()->open(output_device, input_device);
Method is as follows: the device is found open configuration
mConfig.channels = 2;
mConfig.rate = 48000;
mConfig.period_size = 1024;
mConfig.period_count = 2;
mConfig.format = PCM_FORMAT_S16_LE;
mConfig.start_threshold = 0;
mConfig.stop_threshold = 0;
mConfig.silence_threshold = 0;
Open the device name is: ULDL_Loopback , the following cat /proc/asound/pcm
command to view the device information: a device on card0 dev4
It is in snd_soc_dai_link as follows:
\kernel-3.18\sound\soc\mediatek\mt6580\mt_soc_machine.c
{
.name = "ULDLOOPBACK",
.stream_name = MT_SOC_ULDLLOOPBACK_STREAM_NAME,
.cpu_dai_name = MT_SOC_ULDLLOOPBACK_NAME,
.platform_name = MT_SOC_ULDLLOOPBACK_PCM,
.codec_dai_name = MT_SOC_CODEC_ULDLLOOPBACK_NAME,
.codec_name = MT_SOC_CODEC_NAME,
.init = mt_soc_audio_init,
.ops = &mt_machine_audio_ops,
},
After hardware mic input and output waveform resolved, SET_LOOPBACK_TYPE = 25,3 with this problem will have intermittent sound
in mtk online search found the problem: the consequences of Noise generated
so changed the parameters "SET_LOOPBACK_TYPE = 3,3 look and found that this phenomenon is not blowing mode, it
Again go to the hardware test
After discovery does not play, the background noise is too large, debugging a bit mic2 gain: found little better, noise floor, the sound is clear
tinymix Audio_PGA2_Setting 0
ch007_27:/ # tinymix Audio_PGA2_Setting
Audio_PGA2_Setting: >-6Db 0Db 6Db 12Db 18Db 24Db
Pa gain adjustment method of
playing local music, the position of the platform 2 files, determine the magnitude of the good pa,
Do loopback, then mic2 software from the data dv machine to play pa, pa will be transferred to the specified output power, gain adjustment pa to play music with the same magnitude of a previous, an increase in arm volume to see if there is distortion, OK in this scene under gain
Eventually transferred to -5Db, the sound is too great platform