news 2026/5/22 12:45:36

rk3576 sai tdm调试

作者头像

张小明

前端开发工程师

1.2k 24
文章封面图
rk3576 sai tdm调试

RK3576 SAI TDM 调试

  • 驱动
  • HAL 层
    • SO 修改
    • SO 编译
    • audio_policy_configuration.xml修改
    • 调试&验证
      • 调试信息
      • 抓取送往驱动前的原始数据
      • dumpsys

配置 SAI1 输出 16 声道数据

驱动

采用外挂 DSP 的方案,只管输出数据就行

---a/common/kernel-6.1/arch/arm64/boot/dts/rockchip/xxx.dtsi+++b/common/kernel-6.1/arch/arm64/boot/dts/rockchip/xxx.dtsi @@-91,8+91,37@@ regulator-min-microvolt=<12000000>;regulator-max-microvolt=<12000000>;};+++dummy_codec:dummy-codec{+status="okay";+compatible="rockchip,dummy-codec";+#sound-dai-cells=<0>;+};++vehicle_adsp_sound:vehicle-adsp-sound{+status="okay";+compatible="simple-audio-card";+simple-audio-card,name="rockchip,tdm";+simple-audio-card,format="dsp_b";+simple-audio-card,mclk-fs=<512>;+simple-audio-card,cpu{+sound-dai=<&sai1>;+dai-tdm-slot-num=<16>;+dai-tdm-slot-width=<32>;+};+simple-audio-card,codec{+sound-dai=<&dummy_codec>;+};+};};+&es8388_sound{+status="disabled";+};

HAL 层

SO 修改

源码路径:hardware/rockchip/audio/tinyalsa_hal/audio_hw.c

---a/common/hardware/rockchip/audio/tinyalsa_hal/audio_hw.c+++b/common/hardware/rockchip/audio/tinyalsa_hal/audio_hw.c @@-92,6+92,16@@staticstructpcm_configpcm_config={.format=PCM_FORMAT_S16_LE,};++staticstructpcm_configpcm_config_16ch_out={+.channels=16,+.rate=48000,+.period_size=1024,+.period_count=4,+.format=PCM_FORMAT_S16_LE,+};++staticstructpcm_configpcm_config_in={#ifPCM_REFERENCE_CHANNELS.channels=PCM_CAPTURE_CHANNELS+PCM_REFERENCE_CHANNELS,@@-651,7+661,8@@structdev_proc_infoSPEAKER_OUT_NAME[]=/* add codes& dai name here*/{"rockchiprt5670c",NULL,},{"rockchiprt5672c",NULL,},{"rockchipaw882xx",NULL,},-{"rk3528acodec",NULL},+{"rk3528acodec",NULL,},+{"rockchiptdm",NULL,},{NULL,NULL},/* Note! Must end with NULL, else will cause crash */};@@-4200,8+4218,18@@staticintadev_open_output_stream(structaudio_hw_device*dev,type=OUTPUT_LOW_LATENCY;}-ALOGD("out->config.rate = %d, out->config.channels = %d out->config.format = %d",-out->config.rate,out->config.channels,out->config.format);++if(devices==AUDIO_DEVICE_OUT_SPEAKER){+ALOGE("speaker out 16 chn");+out->supported_channel_masks[0]=AUDIO_CHANNEL_OUT_5POINT1;+out->supported_channel_masks[1]=AUDIO_CHANNEL_INDEX_MASK_16;+out->config=pcm_config_16ch_out;+out->channel_mask=AUDIO_CHANNEL_INDEX_MASK_16;//AUDIO_CHANNEL_OUT_9POINT1POINT6;+}++ALOGE("out->config.rate = %d, out->config.channels = %d out->config.format = %d, config->channel_mask = 0x%x",+out->config.rate,out->config.channels,out->config.format,config->channel_mask);out->stream.common.get_sample_rate=out_get_sample_rate;out->stream.common.set_sample_rate=out_set_sample_rate;@@-5098,6+5126,7@@staticvoidadev_open_init(structaudio_device*adev)charvalue[PROPERTY_VALUE_MAX];if(property_get("vendor.audio.period_size",value,NULL)>0){pcm_config.period_size=atoi(value);+pcm_config_16ch_out.period_size=pcm_config.period_size;pcm_config_in.period_size=pcm_config.period_size;}if(property_get("vendor.audio.in_period_size",value,NULL)>0)

SO 编译

source build/envsetup.sh lunch rk3576s_u-userdebug mmm hardware/rockchip/audio/tinyalsa_hal/adb-d root adb-d remount adb-d push audio.primary.rk30board.so/vendor/lib/hw/adb-d reboot

audio_policy_configuration.xml修改

源码路径:device/rockchip/common/audio_policy_configuration_singlehal.xml

diff--git a/device/rockchip/common/audio_policy_configuration_singlehal.xml b/device/rockchip/common/audio_policy_configuration_singlehal.xml index eba2888f797..d43adf27793100644---a/device/rockchip/common/audio_policy_configuration_singlehal.xml+++b/device/rockchip/common/audio_policy_configuration_singlehal.xml @@-28,7+28,7@@<mixPorts><mixPort name="primary output"role="source"flags="AUDIO_OUTPUT_FLAG_PRIMARY"><profile name=""format="AUDIO_FORMAT_PCM_16_BIT"-samplingRates="44100 48000"channelMasks="AUDIO_CHANNEL_OUT_STEREO"/>+samplingRates="44100 48000"channelMasks="AUDIO_CHANNEL_INDEX_MASK_16"/></mixPort><mixPort name="spdif_passthrough"role="source"flags="AUDIO_OUTPUT_FLAG_DIRECT">

调试&验证

调试信息

部分调试信息不显示,可以执行logcat -G 64M增大 log 缓冲区

logcat-s modules.primary.audio_hal

抓取送往驱动前的原始数据

vendor.audio.record指定抓取多少 MB

rm/data/misc/audioserver/debug.pcm mkdir-p/data/misc/audioserver/touch/data/misc/audioserver/debug.pcm setprop vendor.audio.record5chmod777-R/data/misc/audioserver setenforce0du-h/data/misc/audioserver/adb-d pull/data/misc/audioserver/debug.pcm adb-d root adb-d remount adb-d push audio_policy_configuration_singlehal.xml/vendor/etc/adb-d shell sync adb-d shell stop adb-d shell start

抓取原始数据后使用Audacity 进行播放(文件 -> 导入 -> 原始数据 -> 根据播放的音源设置

dumpsys

dumpsys media.audio_flinger可以查看送往hal层的数据格式

Output thread0xb400007f6c7958f0,name AudioOut_D,tid3147,type0(MIXER):I/O handle:13Standby:no Sample rate:48000Hz HAL frame count:960HAL format:0x1(AUDIO_FORMAT_PCM_16_BIT)HAL buffer size:30720bytes Channel count:16Channel mask:0x8000ffff(index mask,bits:0xffff)Processing format:0x1(AUDIO_FORMAT_PCM_16_BIT)Processing frame size:32bytes Pending config events:none Output devices:0x2(AUDIO_DEVICE_OUT_SPEAKER)Input device:0(AUDIO_DEVICE_NONE)Audio source:0(AUDIO_SOURCE_DEFAULT)Timestamp stats:n=2328disc=1cold=0nRdy=0err=3rate=1jitterMs(ave=6.18763e-06std=0.0178616min=-0.0625277max=0.0458923)localSR(48000,3.60454e-11)correctedJitterMs(ave=-1.70485e-07std=0.00835348min=-0.022509max=0.0245337)Timestamp corrected:no Last writeoccurred(msecs):32

dumpsys media.audio_policy可以查看当生效的配置文件

...Config source:/vendor/etc/audio_policy_configuration_singlehal.xml...

以及配置的输出格式

Hardwaremodules(4):1.Handle:10;"primary"-OutputMixPorts(3):1."primary output";0x0002(AUDIO_OUTPUT_FLAG_PRIMARY)-Profiles(1):1."";AUDIO_FORMAT_PCM_16_BIT(0x1)sampling rates:44100,48000channel masks:0x8000ffffAUDIO_ENCAPSULATION_TYPE_NONE
版权声明: 本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若内容造成侵权/违法违规/事实不符,请联系邮箱:809451989@qq.com进行投诉反馈,一经查实,立即删除!
网站建设 2026/5/22 12:45:35

答辩加分秘籍!长江学者特聘教授专属PPT定制

长江学者特聘教授答辩&#xff0c;拼的不只是科研硬实力&#xff0c;PPT更是“第一印象分”关键&#xff01;很多学术大佬深耕科研多年&#xff0c;成果满满&#xff0c;却栽在PPT上——排版杂乱、重点不突出、学术质感不足&#xff0c;明明实力够硬&#xff0c;却没能在答辩现…

作者头像 李华
网站建设 2026/5/22 12:44:34

通过curl命令直接测试Taotoken接口,快速验证密钥与模型连通性

&#x1f680; 告别海外账号与网络限制&#xff01;稳定直连全球优质大模型&#xff0c;限时半价接入中。 &#x1f449; 点击领取海量免费额度 通过curl命令直接测试Taotoken接口&#xff0c;快速验证密钥与模型连通性 对于开发者而言&#xff0c;在集成大模型服务时&#xf…

作者头像 李华
网站建设 2026/5/22 12:43:48

Agent的发展阶段

Agent技术的发展经历了多个关键阶段&#xff0c;从早期的简单规则系统到现代的智能自主系统。以下是主要发展阶段的分类和特点&#xff1a;第一阶段&#xff1a;基于规则的Agent&#xff08;1950s-1980s&#xff09;早期Agent系统依赖于预定义的规则和逻辑。这些系统在封闭环境…

作者头像 李华
网站建设 2026/5/22 12:43:43

在昆明选二手手机专卖店,看准这几点不踩坑

在昆明选购二手手机&#xff0c;面对琳琅满目的店铺和报价&#xff0c;很多消费者往往感到无从下手。二手市场虽然有高性价比的优势&#xff0c;但同时也伴随着产品品质参差不齐、价格套路多、售后服务缺失等常见痛点。对于昆明二手手机专卖店的选择&#xff0c;选对店铺是决定…

作者头像 李华