Project

General

Profile

Linux Audio Support

TODO: Mention J23 and J8

Audio support for linux is based on the Linux for Qualcomm Software support. Information included here can also be reviewed on Qualcomm's site:

https://docs.qualcomm.com/bundle/publicresource/topics/80-70020-16/overview.html?vproduct=1601111740013072&version=1.5&facet=Audio#audio-overview

Development Board Configuration

Ensure that Switch S7 is set properly.
  • Switch 3 should be set to enable Audio, which is a top level enable to send 1.8 V to the audio codec chip SGTL5000XNBA3 (U16).
  • Switch 4 can be either set or not set
    • If Switch 4 is not set the 1.8V comes from the DC supply on the Development Kit
    • If Switch 4 is set the 1.8V comes from the SOM

Hardware Overview

A hardware block diagram of the audio subsystem is shown below. The following components are involved on the MitySOM-QC6490 devkit:

  • Application processor – This is the ARM CPU complex and handles audio processing tasks, including:
    • Managing audio record and playback
    • Decoding audio formats
    • Using LPAI for postprocessing tasks
  • Low Power AI (LPAI) – Subsystem that runs audio playback/record and voice-activation (VA) algorithms. It integrates with a dedicated Qualcomm® Hexagon™ Processor (QDSP6) and a low power island (LPI).
  • Audio codec – For the devkit this is a SGTL5000 and it is connected to the LPAI via I2S0 connections. It provides:
    • Analog-to-Digital Converter (ADC) for capturing microphone / line-in signals and converting them to I2S
    • Digital-to-Analog Converter (DAC) for converting stereo I2S data to analog outptus for either the Headphones or line-out signals
  • Headphone / Mic Jack

Software Overview (linux)

Note: Audio support for the MitySOM-QC6490 Devkit is not available in the 1.0 release of the BSP.

Examples Using the Headphone Jack (J8 on the Devkit)

This section covers some basic examples to checkout the audio functions on the Devkit J8 (CITA standard headphone+mic) audio jack. A simple headset with a mic was used to test these examples.

Capture from microphone

Using gstreamer

The development kit includes a pulsesink gstreamer plugin to support capture from pulse audio capture channels.

To capture a WAV file using streamer commands from the microphone:

gst-launch-1.0 pulsesrc ! audioconvert ! audioresample ! wavenc ! filesink location=output.wav

The gstreamer tools in the reference filesystem image also include support for recording an mp3 file or a flac compressed file with the following example commands:

gst-launch-1.0 pulsesrc ! audioconvert ! audioresample ! lamemp3enc bitrate=192 ! id3v2mux ! filesink location=output.mp3
gst-launch-1.0 pulsesrc ! flacenc ! flacparse ! filesink location=capture.flac

Using pulseaudio tools

Use the following command to record a WAV file from the microphone. Hit CTRL-C to stop:

parec -v --rate=48000 --format=s16le --channels=1 --file-format=wav test.wav

Playback to headphones

Using gstreamer

The development kit includes a pulsesink plugin that will configure the back end output of a PCM stream to route to the pulseaudio framework.

To play a simple 400 Hz test tone to the headphones (in stereo), run the following command. Note: all gstreamer commands can be cancelled / terminated using CTRL-C.

gst-launch-1.0 audiotestsrc ! audioconvert ! audio/x-raw,channels=2 ! pulsesink

To play an mp3 file, the following command could be used:

gst-play-1.0 02-Jump.mp3

Using pulseaudio tools

You can play back a WAV file, such as the one attached on this page, with the following command:

paplay LRMonoPhase4.wav -v

Examples Using the Audio Header (J23 on the Devkit)

This section covers some basic examples to checkout the audio functions on the Devkit J23 audio header. To test these examples, an adapter was used to connect a 3.5mm jack input/output to the 5 pin header. Input was ran from a PC but could be ran from any powered source. Output was ran to a simple headset and a set of speakers.

Capture from input (LINE_IN)

Record input

To capture input from a PC or other powered source, connect the input lines of J23 to whatever audio source you'd like to capture. Before trying to capture audio, ensure your tinymix settings are set similar to the ones below (this can be seen by running tinymix contents, as seen below):

root@qcs6490-mitysom-devkit:~# tinymix contents
Number of controls: 28
ctl     type    num     name                                            device  value
0       INT     2       PCM Playback Volume                             0144, 144 (range 0->192)
1       INT     2       Capture Volume                                  015, 15 (range 0->15)
2       BOOL    1       Capture Attenuate Switch (-6dB)                 0Off
3       BOOL    1       Capture ZC Switch                               0On
4       BOOL    1       Capture Switch                                  0On
5       INT     2       Headphone Playback Volume                       0127, 127 (range 0->127)
6       BOOL    1       Headphone Playback Switch                       0On
7       BOOL    1       Headphone Playback ZC Switch                    0On
8       INT     1       Mic Volume                                      03 (range 0->3)
9       INT     2       Lineout Playback Volume                         031, 31 (range 0->31)
10      BOOL    1       Lineout Playback Switch                         0On
11      INT     1       DAP Main channel                                032768 (range 0->65535)
12      INT     1       DAP Mix channel                                 00 (range 0->65535)
13      BOOL    1       AVC Switch                                      0Off
14      BOOL    1       AVC Hard Limiter Switch                         0Off
15      INT     1       AVC Max Gain Volume                             01 (range 0->2)
16      INT     1       AVC Integrator Response                         01 (range 0->3)
17      INT     1       AVC Threshold Volume                            012 (range 0->96)
18      INT     1       BASS 0                                          047 (range 0->95)
19      INT     1       BASS 1                                          047 (range 0->95)
20      INT     1       BASS 2                                          047 (range 0->95)
21      INT     1       BASS 3                                          047 (range 0->95)
22      INT     1       BASS 4                                          047 (range 0->95)
23      ENUM    1       Capture Mux                                     0MIC_IN, > LINE_IN, 
24      ENUM    1       Headphone Mux                                   0DAC, > LINE_IN, 
25      ENUM    1       Digital Input Mux                               0> ADC, I2S, Rsvrd, DAP, 
26      ENUM    1       DAP Mux                                         0> ADC, I2S, 
27      ENUM    1       DAP MIX Mux                                     0> ADC, I2S,

The most important settings to pay attention to are Capture Mux, which must be set to LINE_IN, Capture Switch, which must be On, and Capture Volume, which should not be 0. If you have these settings and are encountering issues capturing audio, the configuration above is from a successful capture. Checking that your other settings match the above ones could be beneficial in alleviating issues. After configuring the CODEC with tinymix, running gst-launch-1.0 pulsesrc ! audioconvert ! audioresample ! wavenc ! filesink location=output.wav and then providing audio input from whatever source is used will allow audio to be captured and stored as output.wav. To playback the recorded audio, you can follow the above instructions on playback.

Live playback

Headphones (J8)
To get live playback over the headphones, set the following tinymix settings:

root@qcs6490-mitysom-devkit:~# tinymix set 'Headphone Mux' 1
root@qcs6490-mitysom-devkit:~# tinymix set 'Headphone Playback Volume' 127 127
root@qcs6490-mitysom-devkit:~# tinymix set 'Headphone Playback Switch' 1

Then, play audio from your source plugged into LINE_IN (J23), and it should be heard over the headphones plugged into the audio jack (J8).

Playback to audio output (LINEOUT)

To play audio over LINEOUT (J23), ensure the following tinymix settings are set and that something is connected to J23 to recieve the audio output (such as speakers or headphones).

root@qcs6490-mitysom-devkit:~# tinymix set 'Lineout Playback Switch' 1
root@qcs6490-mitysom-devkit:~# tinymix set 'Lineout Playback Volume' 31 31

These should ensure Lineout Playback is enabled and that the Playback Volume is not 0 (could set to any value in range of 0 to 31, but max volume is recommended to ensure output is heard). LINEOUT should always receive output as it's not MUXed with anything (per the diagram here). Now, running gst-launch-1.0 audiotestsrc ! audioconvert ! audio/x-raw,channels=2 ! pulsesink will play a test tone to verify LINEOUT functionality. The commands used to playback to headphones in the above instructions can also be used to play audio files over LINEOUT.

Additional Notes and Troubleshooting

If any issues are encountered, referencing the CODEC and controls section, tracing through the system block diagram, and then checking your tinymix settings with tinymix contents could help spot any issues in your configuration. Also ensuring that settings from other configurations (such as going from trying to record input from MIC_IN to LINE_IN as those signals are MUXed) aren't interfering with the current configuration could alleviate issues.

SGTL5000 CODEC and Controls

The linux SGTL5000 codec driver includes several controls for the routing and data within the SGTL5000 chip (between the jacks and the I2S0 bus). A top level block diagram of the SGTL5000 is shown below:

From the picture, the 3 signal audio jack is connected to the Headphone outputs (stereo) and microphone inputs (mono) for use with a standard analog headset with microphone. The line in and line out signals are routed to the expansion header J23. By default, playback commands will be routed to the HeadPhone interface and capture commands will capture from the microphone input.

The available controls of the output SGTL5000 codec can be listed (along with their settings) with the tinymix command as shown below.

root@qcs6490-mitysom-devkit:~# tinymix contents
Number of controls: 28
ctl     type    num     name                                            device  value
0       INT     2       PCM Playback Volume                             0144, 144 (range 0->192)
1       INT     2       Capture Volume                                  012, 12 (range 0->15)
2       BOOL    1       Capture Attenuate Switch (-6dB)                 0Off
3       BOOL    1       Capture ZC Switch                               0On
4       BOOL    1       Capture Switch                                  0On
5       INT     2       Headphone Playback Volume                       0110, 110 (range 0->127)
6       BOOL    1       Headphone Playback Switch                       0On
7       BOOL    1       Headphone Playback ZC Switch                    0On
8       INT     1       Mic Volume                                      00 (range 0->3)
9       INT     2       Lineout Playback Volume                         016, 16 (range 0->31)
10      BOOL    1       Lineout Playback Switch                         0Off
11      INT     1       DAP Main channel                                032768 (range 0->65535)
12      INT     1       DAP Mix channel                                 00 (range 0->65535)
13      BOOL    1       AVC Switch                                      0Off
14      BOOL    1       AVC Hard Limiter Switch                         0Off
15      INT     1       AVC Max Gain Volume                             01 (range 0->2)
16      INT     1       AVC Integrator Response                         01 (range 0->3)
17      INT     1       AVC Threshold Volume                            012 (range 0->96)
18      INT     1       BASS 0                                          047 (range 0->95)
19      INT     1       BASS 1                                          047 (range 0->95)
20      INT     1       BASS 2                                          047 (range 0->95)
21      INT     1       BASS 3                                          047 (range 0->95)
22      INT     1       BASS 4                                          047 (range 0->95)
23      ENUM    1       Capture Mux                                     0> MIC_IN, LINE_IN,
24      ENUM    1       Headphone Mux                                   0> DAC, LINE_IN,
25      ENUM    1       Digital Input Mux                               0ADC, > I2S, Rsvrd, DAP,
26      ENUM    1       DAP Mux                                         0> ADC, I2S,
27      ENUM    1       DAP MIX Mux                                     0> ADC, I2S,

Note: the tinymix command does not put a space between the device number (always "0" in this case) and the settings.

In this case, the 'PCM Playback Volume' represents the digital DAC Volume Control, the 'Headphone Playback Volume' represents the analog gain on the Headphone volume control, the 'Capture Volume' represents the Analog Gain block entering the ADC, and the 'Mic Volume' represents the MIC GAIN block.

The tinymix tool can be used to adjust these settings. For example, to increase the analog output volume of the headphones channel:

tinymix set 'Headphone Playback Volume' 120 120

This will set both the left and right channel gain setting to be "120".

There are other features of the codec not discussed here (including routing the audio to the line-in and line-out and leveraging the CODEC audio signal processing blocks) but can be leveraged in a similar manner.

Go to top
Add picture from clipboard (Maximum size: 1 GB)