看看alsa-lib的controlC0节点方法snd_ctl_ioctl如果处理ioctl扩展的cmd的
比如:SNDRV_CTL_IOCTL_PCM_PREFER_SUBDEVICE
应用层
alsa-lib库
snd_pcm_hw_open
snd_ctl_pcm_prefer_subdevice(ctl, subdevice);
ctl->ops->pcm_prefer_subdevice(ctl, subdev);也就是snd_ctl_hw_ops.snd_ctl_hw_pcm_prefer_subdevice
snd_ctl_hw_pcm_prefer_subdevice
ioctl(hw->fd, SNDRV_CTL_IOCTL_PCM_PREFER_SUBDEVICE, &subdev);
内核层
snd_ctl_f_ops.snd_ctl_ioctl
{
snd_soc_new_pcms
snd_card_create
snd_ctl_create
snd_ctl_dev_register创建"controlC%i"声卡对应的控制节点,
他的fops为snd_ctl_f_ops
}
snd_ctl_ioctl如果传递进来的cmd不能直接在这里处理,那么调用snd_control_ioctls链表上注册的扩展处理方法[luther.gliethttp]
list_for_each_entry(p, &snd_control_ioctls, list) {
err = p->fioctl(card, ctl, cmd, arg);
if (err != -ENOIOCTLCMD) { // 如果本p->fioctl不能处理该cmd,那么它将返回-ENOIOCTLCMD,否则返回其他值[luther.gliethttp]
up_read(&snd_ioctl_rwsem);
return err;
}
}
那snd_control_ioctls什么时候登记上处理SNDRV_CTL_IOCTL_PCM_PREFER_SUBDEVICE消息的方法的呢
module_init(alsa_pcm_init);
alsa_pcm_init
snd_ctl_register_ioctl(snd_pcm_control_ioctl); // 登记snd_pcm_control_ioctl到snd_control_ioctls链表
看看
snd_pcm_control_ioctl
case SNDRV_CTL_IOCTL_PCM_PREFER_SUBDEVICE:
{
int val;
if (get_user(val, (int __user *)arg))
return -EFAULT;
control->prefer_pcm_subdevice = val; // 将该subdevice存放到snd_ctl_f_ops.snd_ctl_open打开时创建的struct snd_ctl_file单元中
return 0;
}
阅读(3421) | 评论(1) | 转发(0) |