audio card创建

  • Post author:
  • Post category:其他


代码位置

soc-core.c

相关结构体

/* SoC card */

struct snd_soc_card {

const char *name;

const char *long_name;

const char *driver_name;

struct device *dev;

struct snd_card *snd_card;

struct module *owner;

struct mutex mutex;

struct mutex dapm_mutex;

struct mutex dapm_power_mutex;

bool instantiated;

int (*probe)(struct snd_soc_card *card);

int (*late_probe)(struct snd_soc_card *card);

int (*remove)(struct snd_soc_card *card);

/* the pre and post PM functions are used to do any PM work before and

* after the codec and DAI’s do any PM work. */

int (*suspend_pre)(struct snd_soc_card *card);

int (*suspend_post)(struct snd_soc_card *card);

int (*resume_pre)(struct snd_soc_card *card);

int (*resume_post)(struct snd_soc_card *card);

/* callbacks */

int (*set_bias_level)(struct snd_soc_card *,

struct snd_soc_dapm_context *dapm,

enum snd_soc_bias_level level);

int (*set_bias_level_post)(struct snd_soc_card *,

struct snd_soc_dapm_context *dapm,

enum snd_soc_bias_level level);

long pmdown_time;

/* CPU <–> Codec DAI links  */

struct snd_soc_dai_link *dai_link;

int num_links;

struct snd_soc_pcm_runtime *rtd;

int num_rtd;

/* optional codec specific configuration */

struct snd_soc_codec_conf *codec_conf;

int num_configs;

/*

* optional auxiliary devices such as amplifiers or codecs with DAI

* link unused

*/

struct snd_soc_aux_dev *aux_dev;

int num_aux_devs;

struct snd_soc_pcm_runtime *rtd_aux;

int num_aux_rtd;

const struct snd_kcontrol_new *controls;

int num_controls;

/*

* Card-specific routes and widgets.

*/

const struct snd_soc_dapm_widget *dapm_widgets;

int num_dapm_widgets;

const struct snd_soc_dapm_route *dapm_routes;

int num_dapm_routes;

bool fully_routed;

struct work_struct deferred_resume_work;

/* lists of probed devices belonging to this card */

struct list_head codec_dev_list;

struct list_head widgets;

struct list_head paths;

struct list_head dapm_list;

struct list_head dapm_dirty;

/* Generic DAPM context for the card */

struct snd_soc_dapm_context dapm;

struct snd_soc_dapm_stats dapm_stats;

struct snd_soc_dapm_update *update;

#ifdef CONFIG_DEBUG_FS

struct dentry *debugfs_card_root;

struct dentry *debugfs_pop_time;

#endif

u32 pop_time;

void *drvdata;

};

/* main structure for soundcard */

struct snd_card {

int number;            /* number of soundcard (index to

snd_cards) */

char id[16];            /* id string of this card */

char driver[16];        /* driver name */

char shortname[32];        /* short name of this soundcard */

char longname[80];        /* name of this soundcard */

char mixername[80];        /* mixer name */

char components[128];        /* card components delimited with

space */

struct module *module;        /* top-level module */

void *private_data;        /* private data for soundcard */

void (*private_free) (struct snd_card *card); /* callback for freeing of

private data */

struct list_head devices;    /* devices */

unsigned int last_numid;    /* last used numeric ID */

struct rw_semaphore controls_rwsem;    /* controls list lock */

rwlock_t ctl_files_rwlock;    /* ctl_files list lock */

int controls_count;        /* count of all controls */

int user_ctl_count;        /* count of all user controls */

struct list_head controls;    /* all controls for this card */

struct list_head ctl_files;    /* active control files */

struct mutex user_ctl_lock;    /* protects user controls against

concurrent access */

struct snd_info_entry *proc_root;    /* root for soundcard specific files */

struct snd_info_entry *proc_id;    /* the card id */

struct proc_dir_entry *proc_root_link;    /* number link to real id */

struct list_head files_list;    /* all files associated to this card */

struct snd_shutdown_f_ops *s_f_ops; /* file operations in the shutdown

state */

spinlock_t files_lock;        /* lock the files for this card */

int shutdown;            /* this card is going down */

struct completion *release_completion;

struct device *dev;        /* device assigned to this card */

struct device card_dev;        /* cardX object for sysfs */

bool registered;        /* card_dev is registered? */

int offline;            /* if this sound card is offline */

unsigned long offline_change;

wait_queue_head_t offline_poll_wait;

#ifdef CONFIG_PM

unsigned int power_state;    /* power state */

struct mutex power_lock;    /* power lock */

wait_queue_head_t power_sleep;

#endif

#if defined(CONFIG_SND_MIXER_OSS) || defined(CONFIG_SND_MIXER_OSS_MODULE)

struct snd_mixer_oss *mixer_oss;

int mixer_oss_change_count;

#endif

};

代码调用关系

snd_soc_init

–》platform_driver_register

–》soc_probe

–》snd_soc_register_card

–》snd_soc_instantiate_card

–》snd_card_new                         create and initialize a soundcard structure

–》 snd_info_card_create        create a card proc file

–》snd_card_register                    register the soundcard

–》 init_info_for_card              init card info



版权声明:本文为wantingfy原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。