欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

[RK3399][Android7.1] 调试笔记 --- HDMI输出没有音频信号

程序员文章站 2022-05-11 23:00:28
...

Platform: RK3399
OS: Android 7.1 industry
Kernel: v4.4.83

现象:
主屏使用HDMI,插入显示屏播放音乐,只有显示没有声音。


Log:
01-18 08:51:20.024 414 437 D AudioHardwareTiny: start_output_stream: the number of HDMI is invalid,please check


分析:
根据Log分析查到HDMI number号从下面函数中获取:

 static void read_out_sound_card(struct stream_out *out)
{
    while((size = get_line(file,buf,sizeof(buf))) >= 0){
        ALOGD("%s: buf = %s",__FUNCTION__,buf);
        if(is_speaker_out_sound_card(buf)){
            device->out_card[SND_OUT_SOUND_CARD_SPEAKER] = get_card_number(buf);
        }else if(is_hdmi_out_sound_card(buf)){
            device->out_card[SND_OUT_SOUND_CARD_HDMI] = get_card_number(buf);
        }else if(is_spdif_out_sound_card(buf)){
            device->out_card[SND_OUT_SOUND_CARD_SPDIF] = get_card_number(buf);
        }else if(is_bt_out_sound_card(buf)){
            device->out_card[SND_OUT_SOUND_CARD_BT] = get_card_number(buf);
        }
    }
}

关注HDMI获取部分:

static bool is_hdmi_out_sound_card(char* buf)
{
    const char* NAME [] =
    {
       "rockchiphdmi",
       "rkhdmidpsound",
    };
......
}

也就是说需要是rockchiphdmi或者rkhdmidpsound名字的声卡才可以。

查看声卡设备信息:

rk3399_all:/ # cat /proc/asound/cards   
 0 [realtekrt5651co]: realtekrt5651co - realtekrt5651codec_hdmiin
                      realtekrt5651codec_hdmiin                                     
 1 [HDMICODEC      ]: HDMI-CODEC - HDMI-CODEC
                      HDMI-CODEC

并没我们需要的,查看dts,发现codec里的card name写成了 “HDMI-CODEC”。(dts参考的是rk3399-firefly-android.dts)

	hdmi_codec: hdmi-codec {
		compatible = "simple-audio-card";
		simple-audio-card,format = "i2s";
		simple-audio-card,mclk-fs = <256>;
		simple-audio-card,name = "HDMI-CODEC";

		simple-audio-card,cpu {
			sound-dai = <&i2s2>;
		};

		simple-audio-card,codec {
			sound-dai = <&hdmi>;
		};
	};

解决方法:
把“HDMI-CODEC”改成"rockchip,hdmi" 就能正常。

再查看就正常了:

rk3399_all:/ # cat /proc/asound/cards                                          
 0 [realtekrt5651co]: realtekrt5651co - realtekrt5651codec_hdmiin
                      realtekrt5651codec_hdmiin
 1 [rockchiphdmi   ]: rockchip_hdmi - rockchip,hdmi
                      rockchip,hdmi

参考:
HDMI_IN_开发指南_V1.1_20190226.pdf