Audio

Q1: How to get the sound collected by AI?

By MI_S32 MI_AI_GetVqeVolume(MI_AUDIO_DEV AiDevId, MI_AI_CHN AiChn, MI_S32*ps32VolumeDb) api.

Q2: Audio playback is not smooth, log: MI_AO_IMPL_SendFrame[2695]: Device 0 is empty

Make sure that the logic of sending data is fast enough, and try to enable the high-precision clock of the kernel.

Q3: How to use the device tree to configure the audio speaker's amplifier enable pin?

A: In arch/arm/boot/dts/infinity2m.dtsi, set the amp-gpio in the sound node to <PAD_GPIO12 1> //PAD_GPIO12 is the actual hardware enable pin

B:In arch/arm/boot/dts/infinity2m-ssc011a-s01a-padmux-display.dtsi, change the u32Puse of the corresponding pin to MDRV_PUSE_AIO_AMP_PWR (*padmux-display.dtsi is modified according to the actual file)

Q4:How to configure i2s pin settings?

  1. Configure the following i2s-padmux into the corresponding mode in infinity2m.dtsi, eg:

    Corresponds to mode 1, padmux fills in 1:

  2. Configure the corresponding i2s mode in the corresponding padmux file, eg:

    <PAD_GPIO0 PINMUX_FOR_I2S_MODE_1 MDRV_PUSE_I2S_WCK >,
    <PAD_GPIO1 PINMUX_FOR_I2S_MODE_1 MDRV_PUSE_I2S_BCK >,
    <PAD_GPIO2 PINMUX_FOR_I2S_MODE_1 MDRV_PUSE_I2S_SDI >,
    <PAD_GPIO3 PINMUX_FOR_I2S_MODE_1 MDRV_PUSE_I2S_SDO >,
    

Q5:How to check the status of AO data processing?

By checking the current audio data buffer status in the AO channel.

MI_S32 MI_AO_QueryChnStat(MI_AUDIO_DEV AoDevId, MI_AO_CHN AoChn, MI_AO_ChnState_t*pstStatus);

u32ChnTotalNum: The total buffer bytes of the output channel.

u32ChnFreeNum: Available free buffer bytes.

u32ChnBusyNum: Occupied cache bytes.

EX:

MI_AO_QueryChnStat(pstAoInChn->AoDevId, pstAoInChn->AoChn,&pstStatus );
while(pstStatus.u32ChnFreeNum < s32RdSize )
{
    MI_AO_QueryChnStat(pstAoInChn->AoDevId, pstAoInChn->AoChn,&pstStatus );
    WW_Usec_Sleep(1000);
}

Q6:Does AO support cross-process calls?

No, it doesn't.

If you need to use AO in both processes, you must ensure that one process calls the relevant API to Deinit AO Dev, the other to Init AO Dev, and reconfigure AO related parameters.

Q7: How to deal with [MI ERR ]: MI_AO_SendFrame[3995]: Need size[69760] > total Dma buffer size[65536]?

The blocking time is not set or set too short when calling MI_AO_SendFrame, causing the AO cached data to exceed the maximum value (64K).

The blocking time can be estimated based on the bytes, audio sampling rate, data format and sound channel sent to AO each time, such as sending 2048 bytes, 48K sampling rate, mono, S16 PCM data:

2048 / 48000 / 2 = 22ms, set the blocking time greater than 22ms, MI_AO_SendFrame(AUDIO_DEV, AUDIO_CHN, &stAoSendFrame, 22);