#创作者激励#OpenHarmony支持HDMI接口声卡适配说明 原创

软通动力HOS
发布于 2023-3-17 16:27
浏览
1收藏

【本文正在参加2023年第一期优质创作者激励计划】

前言

带有HDMI声卡的设备比如电视、投影仪和一些带有音响的显示器,当我们的设备通过HDMI接口连接带有音响的显示设备时(如电视),声音一般都是有显示设备上的音响发出的。本文介绍了OpenHarmony系统支持HDMI声卡的适配过程。

1. 功能描述

OpenHarmony系统支持HDMI声卡的插拔识别,支持HDMI声卡的播放功能,包括启动、停止、暂停、恢复功能。

2. 构建开关

CONFIG_DRIVERS_HDF_AUDIO_
OpenHarmony要支持HDMI声卡首先要打开构建开关:CONFIG_DRIVERS_HDF_AUDIO_HDMI=y

3. 功能配置

3.1配置文件:device_info.hcs 添加hdmi声卡节点信息。

文件路径:vendor/isoftstone/yangfan-j/hdf_config/khdf/device_info/

            hostName = "audio_host";
            priority = 110;
            device_dai :: device {...
                device_hdmi :: deviceNode {
                    policy = 1;
                    priority = 50;
                    preload = 0;
                    permission = 0666;
                    moduleName = "DAI_RK3568";
                }
            }
            device_codec :: device {...
                device_hdmi :: deviceNode {
                    policy = 1;
                    priority = 50;
                    preload = 0;
                    permission = 0666;
                    moduleName = "AUDIO_HDMI_CODEC";
                }...
            }...
            device_dma :: device {...
                device_hdmi :: deviceNode {
                    policy = 1;
                    priority = 50;
                    preload = 0;
                    permission = 0666;
                    moduleName = "DMA_RK3568";
                }...
            }


            device_audio :: device {...
                device_hdmi :: deviceNode {
                    policy = 2;
                    priority = 60;
                    preload = 2;
                    permission = 0666;
                    moduleName = "HDF_AUDIO";
                }...
            }...
        }

3.2 配置文件:

audio_config.hcs 添加hdmi声卡服务信息。

    platform {
...
        controller_0x120c1001 :: card_controller {
            match_attr = "hdf_audio_driver";
            serviceName = "hdf_audio_codec_hdmi_dev";
        }
...
    }
}

3.3 配置文件:

dma_config.hcs 添加hdmi声卡硬件信息。

    platform {
        template dma_controller {
            match_attr = "";
            serviceName = "";
        }
    }
}

3.4 配置文件:

dai_config.hcs 添加hdmi声卡硬件信息。

    platform {
        template dai_controller {
            match_attr = "";
            serviceName = "";
        }
    }
}

3.5 配置文件:

codec_config.hcs 添加hdmi声卡硬件信息。

root {
    platform {
        template codec_controller {
            match_attr = "";
            serviceName = "";
            codecDaiName = "";
        }
...
}

4. 应用样例

hdc shell
cd /data/


./audio_sample_render YoungForYou.wav

5. 功能验证

使用hdc工具推送audio_sample_render和audio_sample_event和wav音频文件到开发板data目录下:
hdc file send E:\audio_sample_render /data
hdc file send E:\audio_sample_event /data
hdc file send E:\xxx.wav /data
HDMI音频类设备插拔检测进入shell端口进行一次HDMI设备插入、拔出流程。

# cd /data/# chmod +x audio_sample_event#./audio_sample_event

插入打印:

@@@@@ serviceName: audio_hdi_pnp_service
@@@@@ deviceClass: 32
@@@@@ status     : 1
@@@@@ info       : EVENT_TYPE=0x1;DEVICE_TYPE=0x400
===============================================================================

拔出打印:

@@@@@ serviceName: audio_hdi_pnp_service
@@@@@ deviceClass: 32
@@@@@ status     : 1
@@@@@ info       : EVENT_TYPE=0x2;DEVICE_TYPE=0x400
===============================================================================

HDMI音频类设备放音进入shell端口进行一次完整的播放、停止、退出流程。hdc shell

 ==================== Loading Mode ===================
| 1. Passthrough Loading                               |
| 2. IPC Loading                                       |
 ======================================================
Please enter your choice:
2
 ================= Select Audio Card ==================
 1. primary
 2. primary1
 3. hdmi
 4. usb
 5. a2dp
 ======================================================
Please enter your choice:
3
 ================== Play Render Menu ==================
| 1. Render Start                                      |
| 2. Render Stop                                       |
| 3. Render Resume                                     |
| 4. Render Pause                                      |
| 5. Render SetVolume                                  |
| 6. Render GetGain                                    |
| 7. Render SetMute                                    |
| 8. Render SetAttributes                              |
| 9. Render SelectScene                                |
| 10. Render getEXtParams                              |
| 11. Render getMmapPosition                           |
| 12.Exit                                              |
 ======================================================
your choice is:
1
Music channels = 2
Music Rate     = 44100 Hz
Music Bit      = 16 bit
 ============= Play Render Mode ==========
| 1. Render non-mmap                     |
| 2. Render mmap                         |
 ========================================
Please enter your choice:
1
Start Successful,Music is playing
 ================== Play Render Menu ==================
| 1. Render Start                                      |
| 2. Render Stop                                       |
| 3. Render Resume                                     |
| 4. Render Pause                                      |
| 5. Render SetVolume                                  |
| 6. Render GetGain                                    |
| 7. Render SetMute                                    |
| 8. Render SetAttributes                              |
| 9. Render SelectScene                                |
| 10. Render getEXtParams                              |
| 11. Render getMmapPosition                           |
| 12.Exit                                              |
 ======================================================
your choice is:
2
Stop Successful
 ================== Play Render Menu ==================
| 1. Render Start                                      |
| 2. Render Stop                                       |
| 3. Render Resume                                     |
| 4. Render Pause                                      |
| 5. Render SetVolume                                  |
| 6. Render GetGain                                    |
| 7. Render SetMute                                    |
| 8. Render SetAttributes                              |
| 9. Render SelectScene                                |
| 10. Render getEXtParams                              |
| 11. Render getMmapPosition                           |
| 12.Exit                                              |
 ======================================================
your choice is:
12

6. 总结

支持HDMI声卡是SwanLinkOS系统使用中不可或缺的一部分,是SwanLinkOS系统用于投影仪、电视显示和生活场景的重要功能,本文介绍了SwanLinkOS系统支持HDMI声卡的适配步骤希望对您有所帮助。

©著作权归作者所有,如需转载,请注明出处,否则将追究法律责任
2
收藏 1
回复
举报
回复
    相关推荐