创建control device

/dev/snd # ll
crw-rw---- system   audio    116,   0 2014-09-19 10:36 controlC0
crw-rw---- system   audio    116,  32 2014-09-19 10:36 controlC1
crw-rw---- system   audio    116,  64 2014-09-19 10:36 controlC2
crw-rw---- system   audio    116,  96 2014-09-19 10:36 controlC3
创建controldevice的过程和pcm类似

snd_soc_register_card
	snd_soc_instantiate_card
		snd_card_create
			snd_ctl_create

用户态对controlCx的操作怎么到kernel的哪?关键在snd_ctl_create中的注册函数snd_ctl_dev_register

static const struct file_operations snd_ctl_f_ops =
{
    .owner =    THIS_MODULE,
    .read =     snd_ctl_read,
    .open =     snd_ctl_open,
    .release =  snd_ctl_release,
    .llseek =   no_llseek,
    .poll =     snd_ctl_poll,
    .unlocked_ioctl =   snd_ctl_ioctl,
    .compat_ioctl = snd_ctl_ioctl_compat,
    .fasync =   snd_ctl_fasync,
};


static int snd_ctl_dev_register(struct snd_device *device)
{
    if ((err = snd_register_device(SNDRV_DEVICE_TYPE_CONTROL, card, -1,
                       &snd_ctl_f_ops, card, name)) < 0) 
}

snd_ctl_ioctl
   snd_ctl_elem_read_user
      snd_ctl_elem_read
         snd_ctl_find_id(card, &control->id);
         kctl->get(kctl, control);

kctl来自card的controls链表。用户态传入的时候会有一个num id指定这个kcontrol

num id可以关注mixer_open中SNDRV_CTL_IOCTL_ELEM_LIST

对应于kernel中的snd_ctl_elem_list

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值