日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

关于imx8mp的es8316的芯片调试

發布時間:2023/12/9 编程问答 44 豆豆
生活随笔 收集整理的這篇文章主要介紹了 关于imx8mp的es8316的芯片调试 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

文章目錄

  • 一、驅動配置
    • 1.1 dts配置
    • 1.2 cpu端的配置
    • 1.3 添加驅動
  • 1.4 對應的驗證
  • 二、device目錄下的配置

記錄在imx8mp上調試音頻芯片es8316的筆記,因為在這個平臺上是第一次調試這個芯片,遇到的一些問題比較多,做一次筆記

一、驅動配置

1.1 dts配置

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: es8316@10 { + compatible = "everest,es8316"; + reg = <0x10>; + clocks = <&audio_blk_ctrl IMX8MP_CLK_AUDIO_BLK_CTRL_SAI3_MCLK1>; + clock-names = "mclk"; + };};

1.2 cpu端的配置

因為es8316并不在fsl-asoc-card.c的默認配置內,所以我們需要自己去添加配置:

+++ 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;} - +#endifstatic 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 添加驅動

這個就直接添加在對應的Makefile文件里面去就好了,編譯完后生成對應的驅動文件就行。
這個還有一個比較坑的地方再與,es8316的默認配置是關閉了的,所以你即使成功的加載驅動,你也無法發出聲音,這個可以用tinymix進行修改。

evk_8mp:/ # tinymix Mixer name: 'imx-audio-es8316' Number of controls: 35 ctl type num name value0 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 //默認是 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 //默認是off 33 BOOL 1 Right Headphone Mixer RLIN Switch Off 34 BOOL 1 Right Headphone Mixer Right DAC Switch on //默認是off

主要是修改這三個對應的寄存器
最開始我是在驅動中直接操作的寄存器:

* 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);/* 后面默認去添加 這三個寄存器的配置,然后就會修改對應的配置*///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 對應的驗證

不出意外,你現在可以通過cat /proc/asound/cards
看到會有對應的 imx-audio-es8316的聲卡配置

130|evk_8mp:/ # cat /proc/asound/cards 0 [imxaudioes8316 ]: imx-audio-es831 - imx-audio-es8316imx-audio-es83161 [imxaudiomicfil ]: imx-audio-micfi - imx-audio-micfilimx-audio-micfil evk_8mp:/ #

同樣的可以通過 tinypcminfo 看到對應的信息

evk_8mp:/ # tinypcminfo -D 0 -d 0 Info for card 0, device 0:PCM out:Access: 0x000009Format[0]: 0x000044Format[1]: 00000000Format Name: S16_LE, S24_LESubformat: 0x000001Rate: min=16000Hz max=48000HzChannels: min=1 max=2Sample bits: min=16 max=32Period size: min=32 max=32767 Period count: min=2 max=8192PCM in:Access: 0x000009Format[0]: 0x000044Format[1]: 00000000Format Name: S16_LE, S24_LESubformat: 0x000001Rate: min=16000Hz max=48000HzChannels: min=1 max=2Sample bits: min=16 max=32Period size: min=32 max=32767 Period count: min=2 max=8192 evk_8mp:/ #

如果硬件接線沒有問題的話,你就可以使用 tinymix的工具進行錄音和播放了,因為nxp的接線有些問題,會導致對應的聲卡的RLCK這個數據只有1.8v-0.9v的幅值,而不是1.8v-0v,所以這個時候你的聲音是沒法出來的。當時我還以為是我軟件的問題,干了好久都沒干出來。

二、device目錄下的配置

上述修改完成后,我的情況是可以播放音樂,但是無法通過對應的錄音工具進行錄音.
我打開對應的alsa的DEBUG宏添加對應的打印后
查看log后發現:

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

他會去解析對應的 /vendor/etc/configs/audio/xxxxxx.json的文件配置
但是沒有es8316的默認配置,查看原來的wm8960的配置文件后,發現可以通過對應的json文件去修改配置

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} + ] +}

這個配置文件會去配置相關的設置,從這里也可以看出來這個配置文件中的name就是tinymix中的name。
最重要的是他會通過"driver_name": “imx-audio-es8316”, 去添加聲卡,不然的花你的聲卡的不能使用的,也就是上面看到的這一行log

07-01 07:40:22.098 2122 2122 I audio_hw_primary: cluo scan_available_device: card imx-audio-es8316 is not supported

在添加完配置文件后再次查看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

聲卡已經支持,我們也可以使用對應的apk進行錄音和播放。
之前沒玩過imx8mp的音頻,所以我也不知道會有這些東西,后面自己去實驗后才發現對應框架以及使用,還是要去了解平臺的相關知識阿。

總結

以上是生活随笔為你收集整理的关于imx8mp的es8316的芯片调试的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。