背景

  • Platform: RK3399
  • OS: Android7.1.2
  • Kernel: v4.4.103

主要针对HDMI-OUT, HDMI-IN这里不做讨论

内核HDMI声卡驱动

HDMI相关的声卡驱动官方已支持,只需修改DTS配置:
dts:

hdmi_sound: hdmi-sound {
	status = "disabled";
	compatible = "simple-audio-card";
	simple-audio-card,format = "i2s";
	simple-audio-card,mclk-fs = <256>;
	simple-audio-card,name = "rockchip,hdmi";

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

&hdmi_sound {
	status = "okay";
};

&i2s2 {
	status = "okay";
};

查看ALSA device list是否有对应声卡,及相应编号

HAL

tinyAlsa处理
out->stream.write = out_write;
添加处理:

  1. 读取HDMI的连接状态及相应参数,RK3399对应的节点路径为/sys/class/drm/card0-HDMI-A-1/, 下面有audioformatstatus等一些属性
  2. pcm_open打开HDMI声卡
  3. pcm_write处理相应输出音频数据