关闭

ALSA音频架构

504人阅读 评论(0) 收藏 举报
分类:


Codec结构体:

 

struct snd_soc_codec

{

        const char *name;

        const struct snd_soc_codec_driver *driver;

        struct snd_soc_card *card;

        struct list_head list;

        struct list_head card_list;

 

        寄存器列表

        size_t reg_size;        /* reg_cache_size * reg_word_size */

        寄存器属性判断函数

        int (*volatile_register)(struct snd_soc_codec *, unsigned int);

        int (*readable_register)(struct snd_soc_codec *, unsigned int);

        int (*writable_register)(struct snd_soc_codec *, unsigned int);

 

        寄存器读写接口

        unsigned int (*read)(struct snd_soc_codec *, unsigned int);

        int (*write)(struct snd_soc_codec *, unsigned int, unsigned int);

}

 

Codec初始化流程:

 

rt5670_probe

 

  àsnd_soc_codec_set_cache_io               初始化寄存器读写接口        soc/soc-io.c

 

                  à codec->write = hw_write                     

                 à codec->read = hw_read

 

àrt5670_reset                                              复位Codec                                                             

 

àrt5670_reg_init                                          初始化Codec寄存器

 

àrt5670_dsp_probe                                    初始化DSP

 

 

hw_write

        àregmap_write(codec->control_data, reg, value)                 driver/base/regmap/regmap.c

hw_read

        à regmap_read(codec->control_data, reg, &val)                   driver/base/regmap/regmap.c

 

 

snd_soc_codec_set_cache_io调用后,codec可以使用以下接口来读写寄存器。

 

snd_soc_read                                                                                              soc/soc-core.c

        àcodec->read

snd_soc_write                                                                                                      soc/soc-core.c

        àcodec->write

 

snd_soc_update_bits                                                                                soc/soc-core.c

        àsnd_soc_read

        àsnd_soc_write

 

 

Codec注册流程:

 

        rt5670_i2c_probe

 

                  à snd_soc_register_codec                                                  soc/soc-core.c

 

snd_soc_codec动态创建

                       àcodec = kzalloc(sizeof(struct snd_soc_codec), GFP_KERNEL)

                           snd_soc_codec加入全局链表

àlist_add(&codec->list, &codec_list)                      soc/soc-core.c

 

àsnd_soc_register_dais                                                      soc/soc-core.c

 

snd_soc_dai动态创建

àdai = kzalloc(sizeof(struct snd_soc_dai), GFP_KERNEL)

snd_soc_dai加入全局链表

àlist_add(&dai->list, &dai_list)                       soc/soc-core.c

 

 

 

SoundCard注册流程:

 

snd_soc_register_card                                                                             soc/soc-core.c

        

        codecdai实例赋值到card->rtd

        àsoc_bind_dai_link

 

        创建card实例

àsnd_card_create

 

 

 

初始化codec

àsoc_probe_link_components

      àsoc_probe_codec

                  àdriver->probe(codec)

 

àsoc_probe_link_dais

        初始化dai

àcodec_dai->driver->probe(codec_dai)

 

àsoc_new_pcm                                                                               soc/soc-pcm.c

 

àsnd_pcm_new                                                                      core/pcm.c

                  àsnd_pcm_new_stream(capture)                                    core/pcm.c

                  àsnd_pcm_new_stream(playback)                         core/pcm.c

        àsnd_pcm_set_ops                                                               core/pcm-lib.c

 

àsnd_card_register                                                                        init.c

 

        àsnd_device_register_all     

                  à调用设备各自的注册函数

 

 

SoundCard注册完成后:

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 


PCM注册流程:

 

 

snd_pcm_dev_register                                                                    core/pcm.c

        

        注册snd_pcm_f_ops                                                              core/pcm_native.c

à snd_register_device_for_dev             

 

        alsa-lib会调用到snd_pcm_f_ops中的接口

 

 

ALSA架构layer:

 

 

 

 

 


SOC-layer API:

 

platform driver调用以下API初始化codec

snd_soc_dai_set_fmt                                                                                soc/soc-core.c

snd_soc_dai_set_pll                                                                                  soc/soc-core.c

snd_soc_dai_set_sysclk                                                                           soc/soc-core.c

snd_soc_dai_set_clkdiv                                                                            soc/soc-core.c

 

codec调用以下API读写寄存器

snd_soc_read                                                                                              soc/soc-core.c

snd_soc_write                                                                                                      soc/soc-core.c

snd_soc_update_bits                                                                              soc/soc-core.c

0
0

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:273857次
    • 积分:3706
    • 等级:
    • 排名:第8790名
    • 原创:69篇
    • 转载:155篇
    • 译文:0篇
    • 评论:27条
    最新评论