一:初始化/注册声卡设备
kernel\sound\core:sound.c
int __init alsa_sound_init(void)
{
... ...
if (register_chrdev(major, "alsa", &snd_fops))
... ...
}
static const struct file_operations snd_fops =
{
.owner = THIS_MODULE,
.open = snd_open,
.llseek = noop_llseek,
};
static int snd_open(struct inode *inode, struct file *file)
{
unsigned int minor = iminor(inode);
struct snd_minor *mptr = NULL;
const struct file_operations *new_fops;
mptr = snd_minors[minor];
... ...
new_fops = fops_get(mptr->f_ops);
... ...
}
static struct snd_minor *snd_minors[SNDRV_OS_MINORS];
struct snd_minor {
int type; /* SNDRV_DEVICE_TYPE_XXX */
int card; /* card number */
int device; /* device number */
const struct file_operations *f_ops; /* file operations */
void *private_data; /* private data for f_ops->open */
struct device *dev; /* device for sysfs */
struct snd_card *
|