Linux I2S Driver Porting*
The GX8008 can be used as an I2S master device to output audio. In Linux or Android systems, it needs to be wrapped as a standard codec sound card device. The GX8008 does not require driver control; it automatically runs upon power-up and continuously outputs I2S data.
However, in Linux or Android systems, a codec driver is still required to wrap the GX8008 as a standard sound card device. This allows tools like arecord, tinycap, or recording applications on Linux or Android to record audio correctly.
The following documentation describes the process for both GX8008 and GX8008C, as they have the same driver.
1. Driver Porting Instructions*
1.1 Reference Driver: 8008C_I2S_Sample.zip
1.2 Driver Code Description:
- Driver Code: vcodec.c
- After compilation: vcodec.ko
- Compilation: Modify the makefile to match your platform's GCC toolchain and Linux kernel header files, then execute
make
.
1.3 This driver is based on the ASoC (ALSA System on Chip) framework.
1.4 Let's take the MTK platform as an example.
Before MTK verification, do the following: (where codec refers to GX8008)
- MTK as I2S Slave, verify that it can record.
- Find the MTK's own I2S driver's
snd_soc_dai_link
. The codec's name needs to be attached for later binding.
In vcodec.c, the DAI name is set as vcodec_dai
, and GX8008C is only used as a capture device and does not support playback.
Therefore, the codec's DAI name needs to be bound to the MTK's snd_soc_dai_link
. This is related to the MTK's I2S driver code, and you need to find codec_dai_name
and modify it. For example:
Then, you need to set up the MTK's driver as follows (note: MTK needs to be set as I2S Slave).
GX8008C I2S Format:
Sample Rate | 48K |
---|---|
Bit Width | Output 32-bit, Valid 16-bit |
FS | 48K |
BCLK | 64fs |
Alignment | Standard I2S format |
After the driver is generated, load it using insmod
and use arecord -l
to check.
You will see a new sound card device has been generated, supporting recording (recording audio from both left and right channels).
To record using arecord:
arecord -D hw:1,0 -d 10 -c 2 -r 48000 -f S16_LE test.wav
To record using tinycap: (modify the device number according to your platform if necessary)
./tinycap /sdcard/record.pcm -D 0 -d 1 -c 2 -r 48000 -b 16