Reagrding audio device flow, we can find some document for AMSS such as 80-VH828-1.
However, there is few code flow document for MSM7227 Android regarding device handling. Here shows device code flow in Android part.
Brief flow fordevice is "Application --> Libaudio --> qdsp5 --> QDSP or AMSS(ARM9)"
There are four parts for device handling.
1) Audio routing : do_routing / Android
2) Audio Tuning : AudioFilter.csv / Android
3) Voice Tuning : voccal.c / AMSS
4) ADIE setting : msm_aud.h / AMSS
Android source is starting from 'do_routing' in AudioHardware.cpp
There are two paths in audio routing function. One is for ADSP and the other is for AMSS.
* ADSP path
1) msm72xx_enable_audpp() : open device 'msm_pcm_ctl' to handle AFE
sending filter parameters through ioctl().
2) audpp_ioctl in /qdsp5/audio_out.c : msms_adsp_write() is sending audio filter parameters.
ex) MBADRC setting is called by audpp_dsp_set_mbadrc().
* AMSS path
1) doAudioRouteOrMute() : open device 'msm_snd' to handle AFE
do_route_audio_rpc() is sending routing parameter through ioctl for RPC.
2) snd_ioctl in qdsp5/snd.c : msms_rpc_call is called to send the paramters to AMSS
ex) SND DEVICE
volume table, ADIE configuration is defined in AMSS with SND_DEVICE id from Android.
Showing posts with label aduio. Show all posts
Showing posts with label aduio. Show all posts
6/22/2012
How to enable Analog audio over HS USB port on Qualcomm Android?
Q) could you provide the details about FEATURE_HS_USB_ANALOG_AUDIO? (Or)
Q) How to enable Analog audio over HS USB port?
Ans) If OEM enabled HS-USB feature "FEATURE_HS_USB_ANALOG_AUDIO" in the build, it will provide anhsu_analog_audio_config() API(in Hsu_analog_audio.c file) for switching between the normal USB mode(for data transmission) and one of the supported Analog Audio configurations. When switching to Analog audio mode USB PHY will be disconnected from D+/D- and ID lines and enter Low Power mode.
In the Analog Audio mode, audio can be routed in one of the following ways:
Please look in to hsu_analog_audio_config_phy_to_mode() function(in Hsu_analog_audio.c)for all the supported modes.
Stereo speaker : Left speaker D-, Right speaker D+( HSU_AUDIO_MODE_STEREO_SPK).
Stereo speaker & Mic : Left speaker D-, Right speaker D+, Mic over ID(HSU_AUDIO_MODE_STEREO_SPK_MIC).
Mono speaker : Left speaker D-, Right speaker D+( HSU_AUDIO_MODE_MONO_SPK).
Mono speaker & Mic : Speaker D-, Mic D+( HSU_AUDIO_MODE_MONO_SPK_MIC).
If OEM switch HS USB mode for normal USB operation from analog audio, the USB PHY will be reconnected.
OEM can add their code in below API for USB headset detection:
otg_notify_b_peripheral_state_transition_cb ( otg_appctx_t appctx ) in Hsu_otg_app.c file
The above callback is called by the USB stack when Vbus raised above B-Device Session Valid threshold, OEM can add their code to check headset detection and to switch analog audio mode.
Note: For electrical specification and software register settings OEM's can refer to doc 80-VM151-11.
Q) How to enable Analog audio over HS USB port?
Ans) If OEM enabled HS-USB feature "FEATURE_HS_USB_ANALOG_AUDIO" in the build, it will provide anhsu_analog_audio_config() API(in Hsu_analog_audio.c file) for switching between the normal USB mode(for data transmission) and one of the supported Analog Audio configurations. When switching to Analog audio mode USB PHY will be disconnected from D+/D- and ID lines and enter Low Power mode.
In the Analog Audio mode, audio can be routed in one of the following ways:
Please look in to hsu_analog_audio_config_phy_to_mode() function(in Hsu_analog_audio.c)for all the supported modes.
Stereo speaker : Left speaker D-, Right speaker D+( HSU_AUDIO_MODE_STEREO_SPK).
Stereo speaker & Mic : Left speaker D-, Right speaker D+, Mic over ID(HSU_AUDIO_MODE_STEREO_SPK_MIC).
Mono speaker : Left speaker D-, Right speaker D+( HSU_AUDIO_MODE_MONO_SPK).
Mono speaker & Mic : Speaker D-, Mic D+( HSU_AUDIO_MODE_MONO_SPK_MIC).
If OEM switch HS USB mode for normal USB operation from analog audio, the USB PHY will be reconnected.
OEM can add their code in below API for USB headset detection:
otg_notify_b_peripheral_state_transition_cb ( otg_appctx_t appctx ) in Hsu_otg_app.c file
The above callback is called by the USB stack when Vbus raised above B-Device Session Valid threshold, OEM can add their code to check headset detection and to switch analog audio mode.
Note: For electrical specification and software register settings OEM's can refer to doc 80-VM151-11.
6/02/2012
ac3 compressed audio playback over HDMI using ADB
1.Connect HDMI cable to the target and enable HDMI from UI using Qualcomm setting App.
2. Connect the target through ADB and run the below commends
a. Run the command "mm-audio-native-test &" to start the test app.
b. Run the command "mm-audio-native-test -format devctl"
This command will list all the devices with ID's.Ex:for HDMI,device ID is 23.
c. Switch the device to HDMI device
#echo "devctl -cmd=dev_switch_rx -dev_id=23" > /data/audio_test
d. Play the ac3 compressed audio
#echo "hdmi_ac3 /data/surround_test.ac3 -id=1 -dev=/dev/msm_lpa_if_out" > /data/audio_test
Test app source code is available in \vendor\qcom\opensource\kernel-tests\mm-audio\audio-native\qdsp5\audiotest.c
2. Connect the target through ADB and run the below commends
a. Run the command "mm-audio-native-test &" to start the test app.
b. Run the command "mm-audio-native-test -format devctl"
This command will list all the devices with ID's.Ex:for HDMI,device ID is 23.
c. Switch the device to HDMI device
#echo "devctl -cmd=dev_switch_rx -dev_id=23" > /data/audio_test
d. Play the ac3 compressed audio
#echo "hdmi_ac3 /data/surround_test.ac3 -id=1 -dev=/dev/msm_lpa_if_out" > /data/audio_test
Test app source code is available in \vendor\qcom\opensource\kernel-tests\mm-audio\audio-native\qdsp5\audiotest.c
8K Linux: How to change the maximum count of audio session?
QDSP6 supports multiple sessions operation which means that we can support playback/recording with different formats/configurations simultaneously. The default setting will allow for 4 playbacks and 4 recordings with different formats at the same time. This feature is currently only available in LE(Linux Enablement) build, not in Android.
Question:
How to increase the maximum count of audio session?
Answer:
- To change count of decoding session, refer to Q6_DEC_MAX_STREAM_COUNT.
- To change count of encoding session, refer to Q6_ENC_MAX_SESSION_COUNT.
- To change count of audio CAD session, refer to CAD_MAX_SESSION.
- CAD_MAX_SESSION > (Q6_DEC_MAX_STREAM_COUNT+Q6_ENC_MAX_SESSION_COUNT)
- These definitions are all in ARM, not Q6.
Additional information provided from Jason Hu,
Entering Q6, typical audio/video session instance is pre-defined and controlled by PM, e.g.,
#define AUD_TCM_MEMORY_PERF_4 0
#define AUD_MIPS_PERF_4 78000
#define AUD_MIN_Q6_FREQUENCY_PERF_4 115000
#define AUD_AXI_FREQUENCY_PERF_4 18000
For example, purely considering the above one "Audio Media session",
Q6 CPU max freq = 600MHz, then we can have 600,000 / 115,000 = 5.2
Q6 AXI max freq = 128MHz, then we can have 128,000 / 18,000 = 7.1
Therefore, considering some margin of other application/resource usage, 4 is a reasonable number for limiting from outside of Q6.
Question:
How to increase the maximum count of audio session?
Answer:
- To change count of decoding session, refer to Q6_DEC_MAX_STREAM_COUNT.
- To change count of encoding session, refer to Q6_ENC_MAX_SESSION_COUNT.
- To change count of audio CAD session, refer to CAD_MAX_SESSION.
- CAD_MAX_SESSION > (Q6_DEC_MAX_STREAM_COUNT+Q6_ENC_MAX_SESSION_COUNT)
- These definitions are all in ARM, not Q6.
Additional information provided from Jason Hu,
Entering Q6, typical audio/video session instance is pre-defined and controlled by PM, e.g.,
#define AUD_TCM_MEMORY_PERF_4 0
#define AUD_MIPS_PERF_4 78000
#define AUD_MIN_Q6_FREQUENCY_PERF_4 115000
#define AUD_AXI_FREQUENCY_PERF_4 18000
For example, purely considering the above one "Audio Media session",
Q6 CPU max freq = 600MHz, then we can have 600,000 / 115,000 = 5.2
Q6 AXI max freq = 128MHz, then we can have 128,000 / 18,000 = 7.1
Therefore, considering some margin of other application/resource usage, 4 is a reasonable number for limiting from outside of Q6.
MSM8660 Audio Playback Power measurement Procedure
1. After loading MSM build, load device QCN, place in airplane mode before measurements.
2. Insert SD card in the device
3. Push required files to the SD card (Make sure SD card is formatted if using for the first time)
4. Make sure the device is ON, and USB is connected when executing the steps given below
a. Make sure that SD card read-only lock is not on
b. adb push FILE_PATH /sdcard/ (for example: adb push C:\AU4.mp3 /sdcard/)
c. If it is not able to write, change permissions as "chmod 777 /sdcard/"
5. Insert headset
6. Reboot the device
7. Connect USB to the device
8. Set Class D using batch file(classd.bat) - This step is only for 8660 Spartanized FFA
9. Disconnect USB
10. Play the audio file under e.g. Main menu > Music > Songs tab > select AU4.mp3
11. Set volume to 9/15
12. Turn off the display using the power key
13. Start power measurement
Note: SD card contribution should be subtracted for power measurement
2. Insert SD card in the device
3. Push required files to the SD card (Make sure SD card is formatted if using for the first time)
4. Make sure the device is ON, and USB is connected when executing the steps given below
a. Make sure that SD card read-only lock is not on
b. adb push FILE_PATH /sdcard/ (for example: adb push C:\AU4.mp3 /sdcard/)
c. If it is not able to write, change permissions as "chmod 777 /sdcard/"
5. Insert headset
6. Reboot the device
7. Connect USB to the device
8. Set Class D using batch file(classd.bat) - This step is only for 8660 Spartanized FFA
9. Disconnect USB
10. Play the audio file under e.g. Main menu > Music > Songs tab > select AU4.mp3
11. Set volume to 9/15
12. Turn off the display using the power key
13. Start power measurement
Note: SD card contribution should be subtracted for power measurement
6/01/2012
How to capture PCM data with LPA mode on Android build?
QCT provide LPA feature on Android build.
but PCM flow of LPA mode is different from normal playback.
Normal playback : decoded PCM data -> Stagefright/Opencore -> Audioflinger -> Audio HAL -> PCM out driver -> DSP -> ADIE
LPA playback : decoded PCM data -> Opencore with custom MIO -> PMEM (LPA PCM out driver) -> DSP -> ADIE
As a PCM path, PCM data is not sent to Audioflinger and used custom MIO for LPA mode
You we need to capture the PCM in custom MIO(Android_audio_lpadecode.cpp) as below.
void AndroidAudioLPADecode::writeAudioLPABuffer(uint8* aData, uint32 aDataLen, PVMFCommandId cmdId, OsclAny* aContext, PVMFTimestamp aTimestamp, int32 pmem_fd)
{
int fd;
// queue up buffer and signal audio thread to process it
fd = ::open("/data/lpa_dump.pcm",O_WRONLY | O_APPEND ); // we need to make file in /data/lpa_dump.pcm
if( fd<0)
{
LOGE("NO lpa_dump.pcm file");
}
else
{
::write(fd,aData,aDataLen);
::close(fd);
}
PCM data will be sent to AndroidAudioLPADecode::writeAudioLPABuffer() in Android_audio_lpadecode.cpp
but PCM flow of LPA mode is different from normal playback.
Normal playback : decoded PCM data -> Stagefright/Opencore -> Audioflinger -> Audio HAL -> PCM out driver -> DSP -> ADIE
LPA playback : decoded PCM data -> Opencore with custom MIO -> PMEM (LPA PCM out driver) -> DSP -> ADIE
As a PCM path, PCM data is not sent to Audioflinger and used custom MIO for LPA mode
You we need to capture the PCM in custom MIO(Android_audio_lpadecode.cpp) as below.
void AndroidAudioLPADecode::writeAudioLPABuffer(uint8* aData, uint32 aDataLen, PVMFCommandId cmdId, OsclAny* aContext, PVMFTimestamp aTimestamp, int32 pmem_fd)
{
int fd;
// queue up buffer and signal audio thread to process it
fd = ::open("/data/lpa_dump.pcm",O_WRONLY | O_APPEND ); // we need to make file in /data/lpa_dump.pcm
if( fd<0)
{
LOGE("NO lpa_dump.pcm file");
}
else
{
::write(fd,aData,aDataLen);
::close(fd);
}
PCM data will be sent to AndroidAudioLPADecode::writeAudioLPABuffer() in Android_audio_lpadecode.cpp
Subscribe to:
Posts (Atom)