alsa结构体流程3
2012-07-06 14:53
127 查看
/* SoC Audio Codec device */ struct snd_soc_codec { const char *name; /* Codec的名字*/ const char *name_prefix; int id; struct device *dev; /* 指向Codec设备的指针 */ const struct snd_soc_codec_driver *driver; /* 指向该codec的驱动的指针 */ struct mutex mutex; struct snd_soc_card *card; /* 指向Machine驱动的card实例 */ struct list_head list; struct list_head card_list; int num_dai; /* 该Codec数字接口的个数,目前越来越多的Codec带有多个I2S或者是PCM接口 */ enum snd_soc_compress_type compress_type; 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); /* runtime */ struct snd_ac97 *ac97; /* for ad-hoc ac97 devices */ unsigned int active; unsigned int cache_bypass:1; /* Suppress access to the cache */ unsigned int suspended:1; /* Codec is in suspend PM state */ unsigned int probed:1; /* Codec has been probed */ unsigned int ac97_registered:1; /* Codec has been AC97 registered */ unsigned int ac97_created:1; /* Codec has been created by SoC */ unsigned int sysfs_registered:1; /* codec has been sysfs registered */ unsigned int cache_init:1; /* codec cache has been initialized */ u32 cache_only; /* Suppress writes to hardware */ u32 cache_sync; /* Cache needs to be synced to hardware */ /* codec IO */ void *control_data; /* codec control (i2c/3wire) data 该指针指向的结构用于对codec的控制,通常和read,write字段联合使用 */ hw_write_t hw_write; unsigned int (*hw_read)(struct snd_soc_codec *, unsigned int); unsigned int (*read)(struct snd_soc_codec *, unsigned int); /* 读取Codec寄存器的函数 */ int (*write)(struct snd_soc_codec *, unsigned int, unsigned int); /* 写入Codec寄存器的函数 */ void *reg_cache; const void *reg_def_copy; const struct snd_soc_cache_ops *cache_ops; struct mutex cache_rw_mutex; /* dapm */ struct snd_soc_dapm_context dapm; /* 用于DAPM控件 */ #ifdef CONFIG_DEBUG_FS struct dentry *debugfs_codec_root; struct dentry *debugfs_reg; struct dentry *debugfs_dapm; #endif };
/* codec driver */ struct snd_soc_codec_driver { /* driver ops */ int (*probe)(struct snd_soc_codec *); int (*remove)(struct snd_soc_codec *); int (*suspend)(struct snd_soc_codec *, pm_message_t state); int (*resume)(struct snd_soc_codec *); /* Default DAPM setup, added after probe() is run */ const struct snd_soc_dapm_widget *dapm_widgets; int num_dapm_widgets; const struct snd_soc_dapm_route *dapm_routes; int num_dapm_routes; /* codec wide operations */ int (*set_sysclk)(struct snd_soc_codec *codec, int clk_id, unsigned int freq, int dir); int (*set_pll)(struct snd_soc_codec *codec, int pll_id, int source, unsigned int freq_in, unsigned int freq_out); /* codec IO */ unsigned int (*read)(struct snd_soc_codec *, unsigned int); int (*write)(struct snd_soc_codec *, unsigned int, unsigned int); int (*display_register)(struct snd_soc_codec *, char *, size_t, unsigned int); int (*volatile_register)(struct snd_soc_codec *, unsigned int); int (*readable_register)(struct snd_soc_codec *, unsigned int); short reg_cache_size; short reg_cache_step; short reg_word_size; const void *reg_cache_default; short reg_access_size; const struct snd_soc_reg_access *reg_access_default; enum snd_soc_compress_type compress_type; /* codec bias level */ int (*set_bias_level)(struct snd_soc_codec *, enum snd_soc_bias_level level); void (*seq_notifier)(struct snd_soc_dapm_context *, enum snd_soc_dapm_type, int); };
codec驱动把自己注册为一个platform driver,那对应的platform device在哪里定义?
答案是在以下代码文件中:/drivers/mfd/wm8994-core.c。
WM8994本身具备多种功能,除了codec外,它还有作为LDO和GPIO使用,这几种功能共享一些IO和中断资源,linux为这种设备提供了一套标准的实现方法:mfd设备。其基本思想是为这些功能的公共部分实现一个父设备,以便共享某些系统资源和功能,然后每个子功能实现为它的子设备,这样既共享了资源和代码,又能实现合理的设备层次结构,主要利用到的API就是:mfd_add_devices(),mfd_remove_devices(),mfd_cell_enable(),mfd_cell_disable(),mfd_clone_cell()。
from:
Linux ALSA声卡驱动之八:ASoC架构中的Platform
相关文章推荐
- [转载]用ALSA驱动声卡流程详解
- 用ALSA驱动声卡流程详解
- 26. OP-TEE驱动篇----libteec和tee_supplicant调用驱动流程和重要结构体
- linux audio(alsa) 驱动注册的简明流程.
- Linux的声卡驱动中ALSA与OSS的区别和简单流程介
- 用ALSA驱动声卡流程详解
- alsa----流程
- [转]基于uda34x的ALSA声卡驱动之设备建立流程
- 用ALSA驱动声卡流程详解
- Linux中用ALSA驱动声卡流程详解
- 【Alsa】播放声音和录音详细流程
- alsa生成/dev/snd/下设备节点函数调用流程
- Dalvik虚拟机java方法执行流程和Method结构体分析
- /dev/dsp与alsa框架下设备节点打开和创建简易流程
- linux audio(alsa) 驱动注册的简明流程.
- Linux中用ALSA驱动声卡流程详解
- 转 alsa录音放音执行流程详解
- Linux的声卡驱动中ALSA与OSS的区别和简单流程介
- alsa声卡/dev/snd/pcmC0D0p的open打开流程
- alsa录音放音执行流程详解