Linux Alsa声卡驱动(*):代码分析

本文详细介绍了Linux Alsa声卡驱动的初始化和注册过程,包括如何注册ALSA、初始化接口信息,以及声卡功能部件如control、pcm的注册。通过对snd_register_device接口的使用,实现了在内核中的设备匹配。同时,文章探讨了ALSA接口在proc目录下的组织结构,以及ctl和pcm部件的创建细节。
摘要由CSDN通过智能技术生成

一:初始化/注册声卡设备

(1)注册ALSA

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 */
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值