kcontrol设备

概要

asoc core提供struct snd_kcontrol_new接口供驱动定义kcontrols,在alsa core对应的实例是struct snd_kcontrol。kcontrol有三个回调函数info、get、put,一般情况下不需要驱动实现。

kcontrol的value字段是个union类型,其内容与control的类型有关。使用snd_ctl_new()或snd_ctl_new1()创建control实例,使用snd_ctl_add()把control实例添加到snd card上。

control设备文件创建流程

snd_card_new
-->snd_ctl_create
构造struct snd_device实例挂在到struct snd_card实例devices链表。其中struct snd_device实例ops字段指向struct snd_device_ops实例。

snd_card_register (遍历snd_card实例的devices链表,调用每个设备的回调dev_register)
->snd_device_register_all
->__snd_device_register
->dev->ops->dev_register()

control设备文件注册入口
snd_ctl_dev_register-->snd_register_device
构造struct snd_minor实例指向control设备操作集snd_ctl_f_ops,获取control设备的次设备号作为全局数组snd_minors 的index,指向snd_minor实例。
用次设备号和主设备号构造设备号,device_add()生产control设备.

struct dapm_kcontrol_data

struct dapm_kcontrol_data {
	unsigned int value;
	struct snd_soc_dapm_widget *widget;
	struct list_head paths;                        // 查找路由表,找到共享dapm kcontrol所有path实例
	struct snd_soc_dapm_widget_list *wlist;      // 查找路由表,找到共享dapm kcontrol所有目的widget实例
};
posted @ 2020-11-16 23:04  bobfly1984  阅读(328)  评论(0)    收藏  举报