*/intsnd_card_get_index(constchar*string){intcard;snd_ctl_t*handle;snd_ctl_card_info_tinfo;if(!string|| *string=='\0')return-EINVAL;if((isdigit(*string) && *(string+1) ==0) || (isdigit(*string) &&isdigit(*(string+1)) && *(string+2) ==0)) {if(sscanf(string,"%i", &car...
.close = snd_ctl_hw_close, .nonblock = snd_ctl_hw_nonblock, .async = snd_ctl_hw_async, .subscribe_events = snd_ctl_hw_subscribe_events, .card_info = snd_ctl_hw_card_info, .element_list = snd_ctl_hw_elem_list, .element_info = snd_ctl_hw_elem_info, .element_add = snd_ctl_...
{ snd_kcontrol_tlv_rw_t...*info; snd_kcontrol_get_t *get; snd_kcontrol_put_t *put; 高通SOC 代码片段 static long snd_ctl_ioctl(struct...但是这个框架通过linux的sysfs,设备驱动的虚拟文件系统暴露了一些信息给用户空间的应用(sysfs 是 Linux 内核中设计较新的一种虚拟的基于内存的文件系统,一般挂载...
staticintctp_wm5102_init(struct snd_soc_pcm_runtime *runtime){intret;structsnd_soc_card*card=runtime->card;structctp_mc_private*ctx=snd_soc_card_get_drvdata(runtime->card);structsnd_soc_codec*codec;structsnd_soc_dapm_context*dapm;codec = ctp_get_codec(card,"wm5102-codec");if(!codec...
对于普通的kcontrol,里面有一个snd_kcontrol_new结构体,里面有info、put、get等函数。将snd_kcontrol_new结构体封装成一个snd_kcontrol结构体,使用函数snd_ctl_add函数添加到声卡中(即放到声卡的controls链表中)。 驱动程序使用以下API函数创建widget snd_soc_dapm_new_controls ...
{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, / .info = snd_soc_info_volsw, .get = snd_soc_get_volsw,/ .put = snd_soc_put_volsw, / .private_value = SOC_SINGLE_VALUE(reg, shift, max, invert) } 这个宏的对象是MIXER,对寄存器reg的位偏移shift可以设置0-max的数值。
{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xna me, / 3. .info = snd_soc_info_volsw, .get = snd_soc_get_volsw,/ 4. .put = snd_soc_put_volsw, / 5. .private_value = SOC_SINGLE_VALUE(reg, shift, max, inve rt) } 6. //这个宏的对象是 MIXER,对寄存器 reg 的偏移 ...
{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, / .info = snd_soc_info_volsw, .get = snd_soc_get_volsw,/ .put = snd_soc_put_volsw, / .private_value = SOC_SINGLE_VALUE(reg, shift, max, invert) } 这个宏的对象是MIXER,对寄存器reg的位偏移shift可以设置0-max的数值。
#define SOC_SINGLE(xname, reg, shift, max, invert) / { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, / .info = snd_soc_info_volsw, .get = snd_soc_get_volsw,/ .put = snd_soc_put_volsw, / .private_value = SOC_SINGLE_VALUE(reg, shift, max, invert) } ...
==> snd_pcm_hw_open(pcmp, name, card, device, subdevice, stream, mode | (nonblock ? SND_PCM_NONBLOCK : 0), 0, sync_ptr_ioctl); ==> snd_ctl_hw_open filename等于"/dev/snd/controlC0" ==> snd_open_device(filename, fmode); ctl->ops = &snd_ctl_hw_ops; ctl->private_data...