Chinaunix首页 | 论坛 | 博客
  • 博客访问: 15350451
  • 博文数量: 2005
  • 博客积分: 11986
  • 博客等级: 上将
  • 技术积分: 22535
  • 用 户 组: 普通用户
  • 注册时间: 2007-05-17 13:56
文章分类

全部博文(2005)

文章存档

2014年(2)

2013年(2)

2012年(16)

2011年(66)

2010年(368)

2009年(743)

2008年(491)

2007年(317)

分类:

2010-06-04 11:50:35

看看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;
        }
 
阅读(3378) | 评论(1) | 转发(0) |
给主人留下些什么吧!~~

chinaunix网友2010-06-17 23:02:55

cheapWomens MBT Chapa Shoe MBT Lami Shoe discountMBT Shoes on sale! MBT Shoes can lessen back pain and relieve neck tension. You will have a comfortable feeling like walking on sandy beach or on soft moss when you wear 回复 | 举报