Linux ALSA音频框架分析五:HDA Driver分析

一 概述

HDA(High Definition Audio)是intel设计的用来取代AC97的音频标准,硬件架构上由hda dodec和hda controller组成见图1:

图1

二 Stream 的概念

HAD 引入了 Streams 的概念来组织数据,并通过 HDA Link 总线进行数据传输。Stream 是一个在系统内存缓冲区和 codec 之间创建的逻辑的或虚拟的连接用以来呈现数据,该连接由单个 DMA 通道通过 Link总线驱动。一个 Stream 包含一个或多个相关的组件或数据 channels,每个 channel 都被动态绑定到 codec 中的一个单一 converter 上来呈现。例如,一个立体声 Stream 包括两个 channels:左和右,在此 Stream 中的每一个采样点应该包括两个采样数据:左和右。这些采样在缓冲区中和在链路上传输的时候是组合在一起的,但是却在 codec 中连接不同的DA 转换器。

三 HDA driver 分析

3.1重要结构体azx

azx 是hda controller的结构体,其中struct hda_bus bus、struct snd_card *card、struct pci_dev *pci是三个重要结构体,分别表示总线、卡、设备。其kernel4.6版的结构体见下:

struct azx {
    struct hda_bus bus;

struct snd_card *card;
    struct pci_dev *pci;
    int dev_index;

/* chip type specific */
    int driver_type;
    unsigned int driver_caps;
    int playback_streams;
    int playback_index_offset;
    int capture_streams;
    int capture_index_offset;
    int num_streams;
    const int *jackpoll_ms; /* per-card jack poll interval */

/* Register interaction. */
    const struct hda_controller_ops *ops;

/* position adjustment callbacks */
    azx_get_pos_callback_t get_position[2];
    azx_get_delay_callback_t get_delay[2];

/* locks */
    struct mutex open_mutex; /* Prevents concurrent open/close operations */

/* PCM */
    struct list_head pcm_list; /* azx_pcm list */

/* HD codec */
    int  codec_probe_mask; /* copied from probe_mask option */
    unsigned int beep_mode;

#ifdef CONFIG_SND_HDA_PATCH_LOADER
    const struct firmware *fw;
#endif

/* flags */
    int bdl_pos_adj;
    int poll_count;
    unsigned int running:1;
    unsigned int single_cmd:1;
    unsigned int polling_mode:1;
    unsigned int msi:1;
    unsigned int probing:1; /* codec probing phase */
    unsigned int snoop:1;
    unsigned int align_buffer_size:1;
    unsigned int region_requested:1;
    unsigned int disabled:1; /* disabled by vga_switcheroo */

#ifdef CONFIG_SND_HDA_DSP_LOADER
    struct azx_dev saved_azx_dev;
#endif
};

3.2 hda dirver需要实现的操作功能函数

操作函数主要有两类,一个是IO级操作函数,即寄存器读写;一个是功能级操作函数;

IO级操作:

struct hdac_io_ops {
    /* mapped register accesses */
    void (*reg_writel)(u32 value, u32 __iomem *addr);
    u32 (*reg_readl)(u32 __iomem *addr);
    void (*reg_writew)(u16 value, u16 __iomem *addr);
    u16 (*reg_readw)(u16 __iomem *addr);
    void (*reg_writeb)(u8 value, u8 __iomem *addr);
    u8 (*reg_readb)(u8 __iomem *addr);
    /* Allocation ops */
    int (*dma_alloc_pages)(struct hdac_bus *bus, int type, size_t size,
                   struct snd_dma_buffer *buf);
    void (*dma_free_pages)(struct hdac_bus *bus,
                   struct snd_dma_buffer *buf);
};

功能级操作:

struct hda_controller_ops {
    /* Disable msi if supported, PCI only */
    int (*disable_msi_reset_irq)(struct azx *);
    int (*substream_alloc_pages)(struct azx *chip,
                     struct snd_pcm_substream *substream,
                     size_t size);
    int (*substream_free_pages)(struct azx *chip,
                    struct snd_pcm_substream *substream);
    void (*pcm_mmap_prepare)(struct snd_pcm_substream *substream,
                 struct vm_area_struct *area);
    /* Check if current position is acceptable */
    int (*position_check)(struct azx *chip, struct azx_dev *azx_dev);
    /* enable/disable the link power */
    int (*link_power)(struct azx *chip, bool enable);
};

3.3 HDA dirver初始化流程

hda dirver的初始化流程见图2:

图2

Linux ALSA音频框架分析五:HDA Driver分析相关推荐

  1. HDA Driver分析

    Linux ALSA音频框架分析五:HDA Driver分析 一 概述 HDA(High Definition Audio)是intel设计的用来取代AC97的音频标准,硬件架构上由hda dodec ...

  2. Linux ALSA音频子系统二

    From 本文以高通平台为例,介绍一下android下的音频结构.android使用的是tinyALSA作为音频系统,使用方法和基本框架与linux中常用的ALSA音频子系统是一致的. ALSA音频框 ...

  3. Linux ALSA 音频系统:物理链路篇

    原址 1. Overview 硬件平台及软件版本: Kernel - 3.4.5 SoC - Samsung exynos CODEC - WM8994 Machine - goni_wm8994 U ...

  4. (一)Linux ALSA 音频系统:物理链路篇

    物理链路篇 转自:https://me.csdn.net/zyuanyun Linux ALSA 音频系统:物理链路篇 Linux ALSA 音频系统:物理链路篇 原创 zyuanyun 最后发布于2 ...

  5. Linux ALSA音频系统:platform,machine,codec

    版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明. 本文链接:https://blog.csdn.net/weixin_41965270/arti ...

  6. (二)Linux ALSA 音频系统:逻辑设备篇

    逻辑设备篇 转自:https://me.csdn.net/zyuanyun Linux ALSA 音频系统:逻辑设备篇 Linux ALSA 音频系统:逻辑设备篇 原创 zyuanyun 最后发布于2 ...

  7. linux音频时钟bclk,linux alsa音频中采样率fs、比特率BCLK 、主时钟MCLK关系

    转:https://blog.csdn.net/lugandong/article/details/72468831 一. 拿512fs说话: 看图知道采样的位深是32bit(位),左右声道各占了8* ...

  8. Linux ALSA驱动框架(一)--ALSA架构简介--声卡的创建

    (1)ALSA简介 (1) Native ALSA Application:tinyplay/tinycap/tinymix,这些用户程序直接调用 alsa 用户库接口来实现放音.录音.控制 ALSA ...

  9. Linux ALSA音频驱动之一:框架概述

    1.ALSA概述 ALSA表示高级Linux声音体系结构(Advanced Linux Sound Architecture).它由一系列内核驱动,应用程序编译接口(API)以及支持Linux下声音的 ...

最新文章

  1. 双通输入法源码公布 by 尉迟方
  2. ThinkPhp5 | 模块分析
  3. java jsp学习指南_JSP教程–最终指南
  4. python安装pyqt4_Python-Mac 安装 PyQt4
  5. rails常用验证方法 (转)
  6. python seaborn_Python数据分析之Seaborn(回归分析绘图)
  7. 用c语言实现二叉树的三种遍历_利用循环和递归实现二叉树的三种遍历
  8. 一步完成 MySQL 向 Redis 迁移
  9. uni-app完整实现小程序获取用户信息
  10. WAV音频文件格式介绍
  11. 各省简称 拼音 缩写_全国所有城市拼音跟缩写.docx
  12. idea安装插件方式及个人使用插件
  13. Abnova循环肿瘤DNA丨全血分离,基因组DNA萃取分析
  14. 魔兽世界3D版启动方法 教你做红蓝3D眼镜
  15. java答题软件_非常实用的java自动答题计时计分器
  16. BIM技术在家装中有5大应用,您知道吗?
  17. 网络安全课程笔记(1)
  18. [知识点整理]中科院/国科大 网络与系统安全 期末考试知识点整理
  19. 微信小程序(uniapp)-实现分享图片给微信好友
  20. SpringBoot开发文档二(MD5二次加密)

热门文章

  1. 源码分析 | Mybatis接口没有实现类为什么可以执行增删改查
  2. 一蝙蝠岛VB诶黑分工表vueg
  3. Griffon学习笔记1 - HelloWorld
  4. 智能手机的硬件体系结构
  5. 行政区划数据方案设计
  6. es6模板字符串中标签模板作为参数时产生空元素的问题
  7. idea java代码注释中@标签模板创建,apidoc接口文档@标签模板创建
  8. osg+pdal大数据点云的LOD可视化
  9. 论项目合同管理(转)
  10. Makefile 编译动态库文件及链接动态库