当前位置:网站首页>Chip debugging of es8316 of imx8mp
Chip debugging of es8316 of imx8mp
2022-07-06 04:43:00 【Never bald programmer】
List of articles
Recorded in the imx8mp Debug the audio chip on es8316 The notes , Because it is the first time to debug this chip on this platform , There are many problems encountered , Take notes once
One 、 Drive configuration
1.1 dts To configure
diff --git a/arch/arm64/boot/dts/freescale/vt_sbc_mx8mp_biol.dts b/arch/arm64/boot/dts/freescale/vt_sbc_mx8mp_biol.dts
index 1389f9a2ada5..9372cd63b3a5 100755
--- a/arch/arm64/boot/dts/freescale/vt_sbc_mx8mp_biol.dts
+++ b/arch/arm64/boot/dts/freescale/vt_sbc_mx8mp_biol.dts
@@ -188,8 +188,18 @@ bt_sco_codec: bt_sco_codec {
compatible = "linux,bt-sco";
};
+ sound-es8316 {
+ compatible = "fsl,imx-audio-es8316";
+ model = "imx-audio-es8316";
+ audio-cpu = <&sai3>;
+ audio-codec = <&codec_es8316>;
+ audio-routing =
+ "Ext Spk", "HPOL",
+ "Ext Spk", "HPOR";
+ };
&i2c1 {
+ codec_es8316: [email protected]10 {
+ compatible = "everest,es8316";
+ reg = <0x10>;
+ clocks = <&audio_blk_ctrl IMX8MP_CLK_AUDIO_BLK_CTRL_SAI3_MCLK1>;
+ clock-names = "mclk";
+ };
};
1.2 cpu End configuration
because es8316 It's not in fsl-asoc-card.c In the default configuration of , So we need to add configuration by ourselves :
+++ b/sound/soc/fsl/fsl-asoc-card.c
@@ -43,6 +43,7 @@ enum fsl_asoc_card_type {
CARD_WM8960,
CARD_WM8962,
CARD_SGTL5000,
+ CARD_ES8316,
CARD_AC97,
CARD_CS427X,
CARD_TLV320AIC32X4,
@@ -307,7 +308,7 @@ static int fsl_asoc_card_hw_params(struct snd_pcm_substream *substream,
priv->streams &= ~BIT(substream->stream);
return ret;
}
-
+#if 0
/*power off amp*/
static int direction_output_high(struct platform_device *pdev)
{
@@ -357,7 +358,7 @@ static int direction_output_low(struct platform_device *pdev)
return 0;
}
-
+#endif
static int fsl_asoc_card_hw_free(struct snd_pcm_substream *substream)
{
struct snd_soc_pcm_runtime *rtd = substream->private_data;
@@ -365,11 +366,11 @@ static int fsl_asoc_card_hw_free(struct snd_pcm_substream *substream)
struct codec_priv *codec_priv = &priv->codec_priv;
struct device *dev = rtd->card->dev;
int ret;
-
-
priv->streams &= ~BIT(substream->stream);
if (!priv->streams && codec_priv->pll_id && codec_priv->fll_id) {
@@ -391,6 +392,7 @@ static int fsl_asoc_card_hw_free(struct snd_pcm_substream *substream)
}
}
return 0;
}
@@ -405,14 +407,11 @@ static int fsl_asoc_card_startup(struct snd_pcm_substream *substream)
int ret;
int gpio;
gpio = gpio_get_value(amp_en);
if (priv->card_type == CARD_CS42888) {
if (priv->codec_priv.mclk_freq % 12288000 == 0) {
support_rates[0] = 48000;
@@ -448,7 +447,7 @@ static int fsl_asoc_card_startup(struct snd_pcm_substream *substream)
return ret;
}
-
return 0;
}
@@ -861,6 +860,10 @@ static int fsl_asoc_card_probe(struct platform_device *pdev)
priv->codec_priv.mclk_id = SGTL5000_SYSCLK;
priv->dai_fmt |= SND_SOC_DAIFMT_CBM_CFM;
priv->card_type = CARD_SGTL5000;
+ } else if (of_device_is_compatible(np, "fsl,imx-audio-es8316")) {
+ codec_dai_name = "ES8316 HiFi";
+ priv->dai_fmt |= SND_SOC_DAIFMT_CBS_CFS;
+ priv->card_type = CARD_ES8316;
} else if (of_device_is_compatible(np, "fsl,imx-audio-tlv320aic32x4")) {
codec_dai_name = "tlv320aic32x4-hifi";
priv->dai_fmt |= SND_SOC_DAIFMT_CBM_CFM;
@@ -1230,6 +1233,7 @@ static const struct of_device_id fsl_asoc_card_dt_ids[] = {
{
.compatible = "fsl,imx-audio-cs427x", },
{
.compatible = "fsl,imx-audio-tlv320aic32x4", },
{
.compatible = "fsl,imx-audio-sgtl5000", },
+ {
.compatible = "fsl,imx-audio-es8316", },
{
.compatible = "fsl,imx-audio-wm8962", },
{
.compatible = "fsl,imx-audio-wm8960", },
{
.compatible = "fsl,imx-audio-mqs", },
1.3 Add driver
This is directly added to the corresponding Makefile Just go inside the document , After compilation, generate the corresponding driver file .
There is also a hole in this and ,es8316 The default configuration of is off , So even if you successfully load the driver , You can't make a sound , This can be used tinymix Make changes .
evk_8mp:/ # tinymix
Mixer name: 'imx-audio-es8316'
Number of controls: 35
ctl type num name value
0 INT 2 Headphone Playback Volume 3 3
1 INT 2 Headphone Mixer Volume 0 0
2 ENUM 1 Playback Polarity Normal
3 INT 2 DAC Playback Volume 192 192 // The default is 0
4 BOOL 1 DAC Soft Ramp Switch Off
5 INT 1 DAC Soft Ramp Rate 4
6 BOOL 1 DAC Notch Filter Switch Off
7 BOOL 1 DAC Double Fs Switch Off
8 INT 1 DAC Stereo Enhancement 0
9 BOOL 1 DAC Mono Mix Switch Off
10 ENUM 1 Capture Polarity Normal
11 BOOL 1 Mic Boost Switch On
12 INT 1 ADC Capture Volume 0
13 INT 1 ADC PGA Gain Volume 0
14 BOOL 1 ADC Soft Ramp Switch On
15 BOOL 1 ADC Double Fs Switch Off
16 BOOL 1 ALC Capture Switch Off
17 INT 1 ALC Capture Max Volume 28
18 INT 1 ALC Capture Min Volume 0
19 INT 1 ALC Capture Target Volume 11
20 INT 1 ALC Capture Hold Time 0
21 INT 1 ALC Capture Decay Time 3
22 INT 1 ALC Capture Attack Time 2
23 BOOL 1 ALC Capture Noise Gate Switch Off
24 INT 1 ALC Capture Noise Gate Threshold 0
25 ENUM 1 ALC Capture Noise Gate Type Constant PGA Gain
26 ENUM 1 Differential Mux lin1-rin1
27 ENUM 1 Digital Mic Mux dmic disable
28 ENUM 1 DAC Source Mux LDATA TO LDAC, RDATA TO RDAC
29 ENUM 1 Left Headphone Mux lin1-rin1
30 ENUM 1 Right Headphone Mux lin1-rin1
31 BOOL 1 Left Headphone Mixer LLIN Switch Off
32 BOOL 1 Left Headphone Mixer Left DAC Switch on // The default is off
33 BOOL 1 Right Headphone Mixer RLIN Switch Off
34 BOOL 1 Right Headphone Mixer Right DAC Switch on // The default is off
It is mainly to modify these three corresponding registers
At first, I operated directly on the register in the driver :
* Documentation for this register is unclear and incomplete,
* but here is a vendor-provided value that improves volume
* and quality for Intel CHT platforms.
*/
snd_soc_component_write(component, ES8316_CLKMGR_ADCOSR, 0x32);
/* Add by default The configuration of these three registers , Then the corresponding configuration will be modified */
//snd_soc_component_write(component, ES8316_HPMIX_SWITCH, 0x88);
//snd_soc_component_write(component, ES8316_DAC_VOLL, 0x00);
//snd_soc_component_write(component, ES8316_DAC_VOLR, 0x00);
1.4 Corresponding verification
No accident , You can now go through cat /proc/asound/cards
There will be corresponding imx-audio-es8316 Sound card configuration
130|evk_8mp:/ # cat /proc/asound/cards
0 [imxaudioes8316 ]: imx-audio-es831 - imx-audio-es8316
imx-audio-es8316
1 [imxaudiomicfil ]: imx-audio-micfi - imx-audio-micfil
imx-audio-micfil
evk_8mp:/ #
The same can be done by tinypcminfo See the corresponding information
evk_8mp:/ # tinypcminfo -D 0 -d 0
Info for card 0, device 0:
PCM out:
Access: 0x000009
Format[0]: 0x000044
Format[1]: 00000000
Format Name: S16_LE, S24_LE
Subformat: 0x000001
Rate: min=16000Hz max=48000Hz
Channels: min=1 max=2
Sample bits: min=16 max=32
Period size: min=32 max=32767
Period count: min=2 max=8192
PCM in:
Access: 0x000009
Format[0]: 0x000044
Format[1]: 00000000
Format Name: S16_LE, S24_LE
Subformat: 0x000001
Rate: min=16000Hz max=48000Hz
Channels: min=1 max=2
Sample bits: min=16 max=32
Period size: min=32 max=32767
Period count: min=2 max=8192
evk_8mp:/ #
If there is no problem with the hardware wiring , You can use it tinymix Tools for recording and playing , because nxp There is something wrong with the wiring of , It will lead to the corresponding sound card RLCK This data is only 1.8v-0.9v The amplitude of , instead of 1.8v-0v, So your voice can't come out at this time . At that time, I thought it was my software problem , I haven't done it for a long time .
Two 、device Configuration under Directory
Upon completion of the above modifications , In my case, I can play music , But it is impossible to record through the corresponding recording tool .
I open the corresponding alsa Of DEBUG After adding the corresponding print macro
see log After the discovery :
07-01 07:40:22.095 2122 2122 I audio_hw_primary: parse_one_card: parse /vendor/etc/configs/audio/micfil_config.json
07-01 07:40:22.095 2122 2122 I audio_hw_primary: parse_control: ctl idx 0, [CH0 Volume 5]
07-01 07:40:22.095 2122 2122 I audio_hw_primary: parse_control: ctl idx 1, [CH1 Volume 5]
07-01 07:40:22.095 2122 2122 I audio_hw_primary: parse_control: ctl idx 2, [CH2 Volume 5]
07-01 07:40:22.095 2122 2122 I audio_hw_primary: parse_control: ctl idx 3, [CH3 Volume 5]
07-01 07:40:22.095 2122 2122 I audio_hw_primary: parse_control: ctl idx 4, [CH4 Volume 5]
07-01 07:40:22.096 2122 2122 I audio_hw_primary: parse_control: ctl idx 5, [CH5 Volume 5]
07-01 07:40:22.096 2122 2122 I audio_hw_primary: parse_control: ctl idx 6, [CH6 Volume 5]
07-01 07:40:22.096 2122 2122 I audio_hw_primary: parse_control: ctl idx 7, [CH7 Volume 5]
07-01 07:40:22.096 2122 2122 I audio_hw_primary: parse_one_card: driver name imx-audio-micfi, bus name (null), out_devices 0x0, in_devices 0x80000004, out_vol[0, 255], dsd 0, hfp 0, hdmi 0, multi_chn 0, out period_size 0, out period_count 0, in period_size 0, in period_count 0, secondary_bus_name: (null)
07-01 07:40:22.096 2122 2122 I audio_hw_primary: parse_one_card: parse /vendor/etc/configs/audio/btsco_config.json
07-01 07:40:22.096 2122 2122 I audio_hw_primary: parse_one_card: driver name bt-sco-audio, bus name (null), out_devices 0x70, in_devices 0x80000008, out_vol[0, 255], dsd 0, hfp 1, hdmi 0, multi_chn 0, out period_size 0, out period_count 0, in period_size 0, in period_count 0, secondary_bus_name: (null)
07-01 07:40:22.096 2122 2122 I audio_hw_primary: parse_one_card: parse /vendor/etc/configs/audio/hdmi_config.json
07-01 07:40:22.096 2122 2122 I audio_hw_primary: parse_one_card: driver name audio-hdmi, bus name (null), out_devices 0x400, in_devices 0x0, out_vol[0, 255], dsd 0, hfp 0, hdmi 1, multi_chn 0, out period_size 0, out period_count 0, in period_size 0, in period_count 0, secondary_bus_name: (null)
07-01 07:40:22.097 2122 2122 I audio_hw_primary: parse_one_card: parse /vendor/etc/configs/audio/wm8960_config.json
07-01 07:40:22.097 2122 2122 I audio_hw_primary: parse_control: ctl idx 0, [Left Output Mixer PCM Playback Switch 1]
07-01 07:40:22.097 2122 2122 I audio_hw_primary: parse_control: ctl idx 1, [Right Output Mixer PCM Playback Switch 1]
07-01 07:40:22.097 2122 2122 I audio_hw_primary: parse_control: ctl idx 2, [Playback Volume 230]
07-01 07:40:22.097 2122 2122 I audio_hw_primary: parse_control: ctl idx 3, [Speaker Playback Volume 120]
07-01 07:40:22.097 2122 2122 I audio_hw_primary: parse_control: ctl idx 4, [Headphone Playback Volume 120]
07-01 07:40:22.097 2122 2122 I audio_hw_primary: parse_control: ctl idx 0, [ALC Function 3]
07-01 07:40:22.097 2122 2122 I audio_hw_primary: parse_control: ctl idx 1, [Left Input Mixer Boost Switch 1]
07-01 07:40:22.097 2122 2122 I audio_hw_primary: parse_control: ctl idx 2, [ADC PCM Capture Volume 230]
07-01 07:40:22.097 2122 2122 I audio_hw_primary: parse_control: ctl idx 3, [Capture Volume 60]
07-01 07:40:22.097 2122 2122 I audio_hw_primary: parse_volume_control: ctl idx 0, name Playback Volume
07-01 07:40:22.097 2122 2122 I audio_hw_primary: parse_one_card: driver name wm8960-audio, bus name bus1_system_sound_out, out_devices 0x102000e, in_devices 0x80000014, out_vol[0, 255], dsd 0, hfp 0, hdmi 0, multi_chn 0, out period_size 0, out period_count 0, in period_size 0, in period_count 0, secondary_bus_name: (null)
07-01 07:40:22.098 2122 2122 E audio_hw_primary: cluo--> leave parse_all_cards, supported card num 4
07-01 07:40:22.098 2122 2122 I audio_hw_primary: cluo=========================================1===============
07-01 07:40:22.098 2122 2122 I audio_hw_primary: card0: imx-audio-es8316
07-01 07:40:22.098 2122 2122 E audio_hw_primary: cluo--> audio_card name = imx-audio-es8316
07-01 07:40:22.098 2122 2122 E audio_hw_primary: cluo--> audio_card = (null)
07-01 07:40:22.098 2122 2122 E audio_hw_primary: cluo--> audio_card = (null)
07-01 07:40:22.098 2122 2122 E audio_hw_primary: cluo---> !audio_card
07-01 07:40:22.098 2122 2122 I audio_hw_primary: cluo scan_available_device: card imx-audio-es8316 is not supported
He will analyze the corresponding /vendor/etc/configs/audio/xxxxxx.json File configuration
But no es8316 Default configuration , Check out the original wm8960 After the configuration file , It can be found through the corresponding json File to modify the configuration
diff --git a/common/audio-json/es8316_config.json b/common/audio-json/es8316_config.json
new file mode 100644
index 00000000..0b0f12e5
--- /dev/null
+++ b/common/audio-json/es8316_config.json
@@ -0,0 +1,17 @@
+{
+ "driver_name": "imx-audio-es8316",
+ "supported_in_devices": ["builtin_mic"],
+ "bus_name": "bus1_system_sound_out",
+ "supported_out_devices": ["speaker"],
+
+ "init_ctl": [
+ {
"name": "DAC Playback Volume", "type": "int", "val": 192},
+ {
"name": "Left Headphone Mixer Left DAC Switch", "type": "int", "val": 1},
+ {
"name": "Right Headphone Mixer Right DAC Switch", "type": "int", "val": 1}
+ ],
+
+ "builtin_mic_ctl": [
+ {
"name": "ADC Capture Volume", "type": "int", "val": 192},
+ {
"name": "ADC PGA Gain Volume", "type": "int", "val": 5}
+ ]
+}
This configuration file will configure the relevant settings , You can also see from this configuration file name Namely tinymix Medium name.
The most important thing is that he will pass "driver_name": “imx-audio-es8316”, To add a sound card , Otherwise, you can't use your sound card , That is, the line seen above log
07-01 07:40:22.098 2122 2122 I audio_hw_primary: cluo scan_available_device: card imx-audio-es8316 is not supported
Check again after adding the configuration file log
07-04 02:53:05.353 2205 2205 I audio_hw_primary: parse_one_card: parse /vendor/etc/configs/audio/es8316_config.json
07-04 02:53:05.353 2205 2205 I audio_hw_primary: parse_control: ctl idx 0, [DAC Playback Volume 192]
07-04 02:53:05.353 2205 2205 I audio_hw_primary: parse_control: ctl idx 1, [Left Headphone Mixer Left DAC Switch 1]
07-04 02:53:05.353 2205 2205 I audio_hw_primary: parse_control: ctl idx 2, [Right Headphone Mixer Right DAC Switch 1]
07-04 02:53:05.353 2205 2205 I audio_hw_primary: parse_control: ctl idx 0, [ADC Capture Volume 150]
07-04 02:53:05.353 2205 2205 I audio_hw_primary: parse_control: ctl idx 1, [ADC PGA Gain Volume 3]
07-04 02:53:05.353 2205 2205 I audio_hw_primary: parse_one_card: driver name imx-audio-es8316, bus name bus1_system_sound_out, out_devices 0x2, in_devices 0x80000004, out_vol[0, 255], dsd 0, hfp 0, hdmi 0, multi_chn 0, out period_size 0, out period_count 0, in period_size 0, in period_count 0, secondary_bus_name: (null)
07-04 02:53:05.354 2205 2205 I audio_hw_primary: parse_one_card: parse /vendor/etc/configs/audio/btsco_config.json
07-04 02:53:05.354 2205 2205 I audio_hw_primary: parse_one_card: driver name bt-sco-audio, bus name (null), out_devices 0x70, in_devices 0x80000008, out_vol[0, 255], dsd 0, hfp 1, hdmi 0, multi_chn 0, out period_size 0, out period_count 0, in period_size 0, in period_count 0, secondary_bus_name: (null)
07-04 02:53:05.354 2205 2205 E audio_hw_primary: cluo--> leave parse_all_cards, supported card num 5
07-04 02:53:05.354 2205 2205 I audio_hw_primary: cluo=========================================1===============
07-04 02:53:05.354 2205 2205 I audio_hw_primary: card0: imx-audio-es8316
07-04 02:53:05.354 2205 2205 E audio_hw_primary: cluo--> audio_card name = imx-audio-es8316
07-04 02:53:05.354 2205 2205 E audio_hw_primary: cluo--> audio_card = P��
07-04 02:53:05.354 2205 2205 E audio_hw_primary: cluo--> audio_card = P��
��-04 02:53:05.354 2205 2205 E audio_hw_primary: cluo--> audio_card = 0
��-04 02:53:05.354 2205 2205 E audio_hw_primary: cluo--> audio_card = 0
07-04 02:53:05.354 2205 2205 E audio_hw_primary: cluo--> audio_card = ��
07-04 02:53:05.354 2205 2205 E audio_hw_primary: cluo--> audio_card = ��
07-04 02:53:05.354 2205 2205 E audio_hw_primary: cluo--> audio_card = 0
07-04 02:53:05.354 2205 2205 E audio_hw_primary: ����
07-04 02:53:05.354 2205 2205 E audio_hw_primary: cluo--> audio_card = 0
07-04 02:53:05.354 2205 2205 E audio_hw_primary: ����
07-04 02:53:05.354 2205 2205 E audio_hw_primary: cluo---> audio_card->driver_name
07-04 02:53:05.362 2205 2205 E audio_hw_primary: PCM_FORMAT_S16_LE, format = 0
07-04 02:53:05.362 2205 2205 W audio_hw_primary: Supported input format imx-audio-es8316 , 0
07-04 02:53:05.362 2205 2205 E audio_hw_primary: adev->audio_card_num = card_num =1, card_name = imx-audio-es8316
Sound card already supports , We can also use the corresponding apk Record and play .
I haven't played before imx8mp The audio of , So I didn't know there would be these things , Later, I found the corresponding framework and use after my own experiment , We still need to understand the relevant knowledge of the platform .
边栏推荐
- 2328. Number of incremental paths in the grid graph (memory search)
- Vulnerability discovery - vulnerability probe type utilization and repair of web applications
- CADD course learning (8) -- virtual screening of Compound Library
- Meet diverse needs: jetmade creates three one-stop development packages to help efficient development
- [HBZ sharing] how to locate slow queries in cloud database
- Bill Gates posted his 18-year-old resume and expected an annual salary of $12000 48 years ago
- Basic explanation of turtle module - draw curve
- Scala function advanced
- 8. Static file
- [HBZ share] reasons for slow addition and deletion of ArrayList and fast query
猜你喜欢
Database - MySQL storage engine (deadlock)
A blog to achieve embedded entry
ORM aggregate query and native database operation
JVM garbage collector concept
[数学建模] 微分方程--捕鱼业的持续发展
The ECU of 21 Audi q5l 45tfsi brushes is upgraded to master special adjustment, and the horsepower is safely and stably increased to 305 horsepower
coreldraw2022新版本新功能介绍cdr2022
[detailed steps of FreeRTOS shift value for the first time]
ue5 小知识点 开启lumen的设置
Unity screen coordinates ugui coordinates world coordinates conversion between three coordinate systems
随机推荐
Quatre méthodes de redis pour dépanner les grandes clés sont nécessaires pour optimiser
2327. 知道秘密的人数(递推)
Mysql database storage engine
Use sentinel to interface locally
Sqlserver query results are not displayed in tabular form. How to modify them
8. Static file
Uva1592 Database
Introduction to hashtable
MIT CMS. 300 session 8 – immersion / immersion
Postman断言
SQL注入漏洞(MSSQL注入)
Bubble sort
Excellent PM must experience these three levels of transformation!
Crawler notes: improve data collection efficiency! Use of proxy pool and thread pool
Fedora/rehl installation semanage
Embedded development program framework
也算是學習中的小總結
View workflow
也算是学习中的小总结
几种RS485隔离通讯的方案介绍