关于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進行修改。
主要是修改這三個對應的寄存器
最開始我是在驅動中直接操作的寄存器:
1.4 對應的驗證
不出意外,你現在可以通過cat /proc/asound/cards
看到會有對應的 imx-audio-es8316的聲卡配置
同樣的可以通過 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后發現:
他會去解析對應的 /vendor/etc/configs/audio/xxxxxx.json的文件配置
但是沒有es8316的默認配置,查看原來的wm8960的配置文件后,發現可以通過對應的json文件去修改配置
這個配置文件會去配置相關的設置,從這里也可以看出來這個配置文件中的name就是tinymix中的name。
最重要的是他會通過"driver_name": “imx-audio-es8316”, 去添加聲卡,不然的花你的聲卡的不能使用的,也就是上面看到的這一行log
在添加完配置文件后再次查看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的芯片调试的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 下午去银行办理按揭手续,不得已调休半天
- 下一篇: 按季度分类汇总_2019年纯碱行业相关上