1
完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
说明:本文适用于 RK3288 kernel4.4 SDK 版本。
RK3288 的 HDMI 和 codec 共用一组 i2s 。如果需要 HDMI 和 Codec 同时输出音频,直接使用 SDK 自带的 hdmi_analog_sound 节点配置。如果需要 HDMI 和 codec 可以单独输出,需要将 HDMI 单独注册成一个 PCM 设备。 注:hdmi_analog_sound 和 simple-audio-card 这两种注册方式只能二选一。 HDMI 和 Codec 同时输出 方案一:直接使用 hdmi_analog_sound 默认节点配置( 以 RT5640 为例 ) //RK3288 kernel4.4 / { hdmi_analog_sound: hdmi-analog-sound { status = "okay"; compatible = "rockchip,rk3288-hdmi-analog", "rockchip,rk3368-hdmi-analog"; rockchip,model = "rockchip,rt5640-codec"; rockchip,cpu = <&i2s>; rockchip,codec = <&rt5640>, <&hdmi>; rockchip,widgets = "Microphone", "Microphone Jack", "Headphone", "Headphone Jack"; rockchip,routing = "MIC1", "Microphone Jack", "MIC2", "Microphone Jack", "Microphone Jack", "micbias1", "Headphone Jack", "HPOL", "Headphone Jack", "HPOR"; }; }; &i2s { status = "okay"; }; &hdmi{ status = "okay"; }; &i2c2 { status = "okay"; rt5640: rt5640@1c { #sound-dai-cells = <0>; compatible = "realtek,rt5640"; reg = <0x1c>; clocks = <&cru SCLK_I2S0_OUT>; clock-names = "mclk"; interrupt-parent = <&gpio6>; interrupts = <7 IRQ_TYPE_EDGE_FALLING>; pinctrl-names = "default"; pinctrl-0 = <&i2s0_mclk>; }; }; 方案二:关闭上层 HDMI 设备插入检测,DTS 用 simple-audio-card 注册 Codec 声卡。 1、上层注释掉 hdmi 设备插入的检测: diff --git a/services/java/com/android/server/WiredAccessoryManager.java b/services/java/com/android/server/WiredAccessoryManager.java index c8d3510..2fb231e 100644 --- a/services/java/com/android/server/WiredAccessoryManager.java +++ b/services/java/com/android/server/WiredAccessoryManager.java @@ -374,7 +374,7 @@ final class WiredAccessoryManager implements WiredAccessoryCallbacks { // // If the kernel does not have an "hdmi_audio" switch, just fall back on the older // "hdmi" switch instead. - uei = new UEventInfo(NAME_HDMI_AUDIO, BIT_HDMI_AUDIO, 0); +/* uei = new UEventInfo(NAME_HDMI_AUDIO, BIT_HDMI_AUDIO, 0); if (uei.checkSwitchExists()) { retVal.add(uei); } else { @@ -385,7 +385,7 @@ final class WiredAccessoryManager implements WiredAccessoryCallbacks { Slog.w(TAG, "This kernel does not have HDMI audio support"); } } - +*/ return retVal; } 2、simple-audio-card 注册 Codec 声卡 //RK3288 kernel4.4 /{ rt5640_codec: rt5640-codec{ status = "okay"; compatible = "simple-audio-card"; simple-audio-card,format = "i2s"; simple-audio-card,name = "rockchip,rt5640-codec"; simple-audio-card,mclk-fs = <512>; simple-audio-card,widgets = "Microphone", "Microphone Jack", "Headphone", "Headphone Jack"; simple-audio-card,routing = "MIC1", "Microphone Jack", "MIC2", "Microphone Jack", "Microphone Jack", "micbias1", "Headphone Jack", "HPOL", "Headphone Jack", "HPOR"; simple-audio-card,dai-link@0 { format = "i2s"; cpu { sound-dai = <&i2s>; }; codec { sound-dai = <&rt5640>; }; }; }; &i2s { status = "okay"; }; &i2c2 { status = "okay"; rt5640: rt5640@1c { #sound-dai-cells = <0>; compatible = "realtek,rt5640"; reg = <0x1c>; clocks = <&cru SCLK_I2S0_OUT>; clock-names = "mclk"; interrupt-parent = <&gpio6>; interrupts = <7 IRQ_TYPE_EDGE_FALLING>; pinctrl-names = "default"; pinctrl-0 = <&i2s0_mclk>; }; }; HDMI 和 codec 单独输出 实现 HDMI 和 codec 音频单独输出需要将 hdmi 单独注册成一个 PCM 设备,HDMI 设备插入后上层会切换输出设备为 AUDIO_DEVICE_OUT_HDMI ,然后在 HAL 层打开对应的 PCM 设备即可。 DTS配置如下: //RK3288 kernel4.4 /{ rt5640_codec: rt5640-codec{ status = "okay"; compatible = "simple-audio-card"; simple-audio-card,format = "i2s"; simple-audio-card,name = "rockchip,rt5640-codec"; simple-audio-card,mclk-fs = <512>; simple-audio-card,widgets = "Microphone", "Microphone Jack", "Headphone", "Headphone Jack"; simple-audio-card,routing = "MIC1", "Microphone Jack", "MIC2", "Microphone Jack", "Microphone Jack", "micbias1", "Headphone Jack", "HPOL", "Headphone Jack", "HPOR"; simple-audio-card,dai-link@0 { format = "i2s"; cpu { sound-dai = <&i2s>; }; codec { sound-dai = <&rt5640>; }; }; simple-audio-card,dai-link@1 { format = "i2s"; cpu { sound-dai = <&i2s>; }; codec { sound-dai = <&hdmi>; }; }; }; }; &hdmi_analog_sound { status = "disabled"; }; &i2s { status = "okay"; }; &i2c2 { status = "okay"; rt5640: rt5640@1c { #sound-dai-cells = <0>; compatible = "realtek,rt5640"; reg = <0x1c>; clocks = <&cru SCLK_I2S0_OUT>; clock-names = "mclk"; interrupt-parent = <&gpio6>; interrupts = <7 IRQ_TYPE_EDGE_FALLING>; pinctrl-names = "default"; pinctrl-0 = <&i2s0_mclk>; }; }; 注册成功后,可以通过 adb 查看注册上的 pcm设备。 rk3228:/ # ls dev/snd ls dev/snd . .. controlC0 pcmC0D0c pcmC0D0p pcmC0D1p timer 其中 pcmC0D1p 对应的就是 HDMI pcm 设备,然后在 hal 层调用 pcmC0D1p ,修改如下: hardware/rockchip/audio/tinyalsa_hal$ git diff . diff --git a/tinyalsa_hal/audio_hw.c b/tinyalsa_hal/audio_hw.c index 13dd42e..fd7c664 100755 --- a/tinyalsa_hal/audio_hw.c +++ b/tinyalsa_hal/audio_hw.c @@ -615,7 +615,7 @@ static int start_output_stream(struct stream_out *out) } #endif #endif - out->pcm[PCM_CARD_HDMI] = pcm_open(PCM_CARD_HDMI, out->pcm_device, + out->pcm[PCM_CARD_HDMI] = pcm_open(0, 1, PCM_OUT | PCM_MONOTONIC, &out->config); if (out->pcm[PCM_CARD_HDMI] && !pcm_is_ready(out->pcm[PCM_CARD_HDMI])) { 注:具体 hdmi 对应的是哪个 pcm 设备需要根据实际情况来定,如果不清楚怎么确认,底层可以先通过 tinyalsa 来确定 hdmi 的 pcm 设备,然后参照上述 hal 层的代码修改成对应的 hdmi pcm 设备 即可。 |
|
|
|
你正在撰写答案
如果你是对答案或其他答案精选点评或询问,请使用“评论”功能。
基于米尔瑞芯微RK3576核心板/开发板的人脸疲劳检测应用方案
498 浏览 0 评论
768 浏览 1 评论
667 浏览 1 评论
1893 浏览 1 评论
3138 浏览 1 评论
小黑屋| 手机版| Archiver| 德赢Vwin官网 ( 湘ICP备2023018690号 )
GMT+8, 2024-12-22 01:58 , Processed in 0.657762 second(s), Total 70, Slave 54 queries .
Powered by 德赢Vwin官网 网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
德赢Vwin官网 观察
版权所有 © 湖南华秋数字科技有限公司
德赢Vwin官网 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号