linux ASOC(3)—— jack framwork & drv
2016-10-11 18:26
453 查看
1.涉及文件
kernel/sound/soc/soc-jack.c kernel/sound/soc/codes/wm8996.c kernel\cht\sound\soc\intel\board\Cht_bl_dpcm_rt5672.c
2.framwork
2.1重要结构
/** * struct snd_soc_jack_gpio - Describes a gpio pin for jack detection * * @gpio: gpio number * @name: gpio name * @report: value to report when jack detected * @invert: report presence in low state * @debouce_time: debouce time in ms * @wake: enable as wake source * @jack_status_check: callback function which overrides the detection * to provide more complex checks (eg, reading an * ADC). */ struct snd_soc_jack_gpio { unsigned int gpio; const char *name; int report; int invert; int debounce_time; bool wake; struct snd_soc_jack *jack; struct delayed_work work; void *data; /* drv中需要实现的重要回调函数,耳机的插入、拔出、按键的按下工作都需要从这个函数调度, jack按键中断处理函数也会调用这个函数(整个jack drv都围绕着这个回调函数进行)!!!!! */ int (*jack_status_check)(void *data); };
2.2涉及函数
// 1.Create a new jack snd_soc_jack_new(struct snd_soc_codec *codec, const char *id, int type, struct snd_soc_jack *jack) ---------- // 2.Set a key mapping on a jack,设置键值对应关系, snd_jack_set_key(ctx->jack.jack, SND_JACK_BTN_3, KEY_PREVIOUSSONG); ---------- /* 3.(核心函数) Associate GPIO pins with an ASoC jack,并且设置对应的gpio功能,设为中断模式 参数3:核心结构 */ snd_soc_jack_add_gpios(struct snd_soc_jack *jack, int count,struct snd_soc_jack_gpio *gpios) ---------- /* 4.上报键值*/ snd_soc_jack_report(struct snd_soc_jack *jack, int status, int mask)
(1)snd_jack_set_key 函数
snd_jack_set_key(ctx->jack.jack, SND_JACK_BTN_0, KEY_MEDIA); snd_jack_set_key(ctx->jack.jack, SND_JACK_BTN_1, KEY_VOLUMEUP); snd_jack_set_key(ctx->jack.jack, SND_JACK_BTN_2, KEY_VOLUMEDOWN); //changed by chen.lv,20161010 snd_jack_set_key(ctx->jack.jack, SND_JACK_BTN_3, KEY_PREVIOUSSONG); snd_jack_set_key(ctx->jack.jack, SND_JACK_BTN_4, KEY_NEXTSONG);
(2)snd_soc_jack_add_gpios 核心函数
snd_soc_jack_add_gpios(struct snd_soc_jack *jack, int count,struct snd_soc_jack_gpio *gpios)
// 1. 初始化gpio的 work
INIT_DELAYED_WORK(&gpios[i].work, gpio_work);
gpio_work
snd_soc_jack_gpio_detect
report = gpio->jack_status_check(gpio->data); // drv回调函数
/*---------------------from drv 回调----------------------*/ // 耳机的插入、拔出、按键的按下工作都需要从这个函数调度 snd_soc_jack_gpio->jack_status_check = cht_hs_detection /*-------------------------end -------------------------*/
// 2. 中断注册
ret = request_any_context_irq(gpio_to_irq(gpios[i].gpio),
gpio_handler, // 中断处理函数
IRQF_TRIGGER_RISING |
IRQF_TRIGGER_FALLING,
gpios[i].name,
&gpios[i]);
**// 中断处理函数中调度了 gpio的 work** queue_delayed_work(system_power_efficient_wq, &gpio->work, msecs_to_jiffies(gpio->debounce_time));
相关文章推荐
- Linux power supply framwork & drvs
- Linux power supply framwork & drvs
- Zynq AMP - Running Linux and Bare-Metal System on Both Zynq SoC Processors
- linux ALSA & ASOC (3) — widget 、route
- linux ALSA & ASOC (2) —— kcontrol
- Linux上 Can't connect to X11 window server 错误解决方法
- 我的ORACLE&LINUX常用命令集
- Real10 & Xpdf installation on Linux Box
- suse linux & welcome to this new beginning~
- "linux"发音,今天你发错了吗
- Linux AT&T 汇编语言开发指南
- Tcxxs'J BlackJack AlphaTest发布
- Linux学习笔记之后台进程(at和&)
- XSBase255 -linux 启动过程描述 引用自http://www.linuxeden.com/forum/blog/index.php?op=ViewArticle&articleId=230&blogId=102509
- linux平台下开发&gcc and g++相关参数!
- [Linux FAQ]init: Id "x" respawning too fast: disabled for 5 minutes
- 在 Linux for iSeries® 上设置高可用性防火墙
- LINUX的工具介绍(载抄venus'的blog)
- 嵌入式Linux 装置配"硬即时"系统 利弊参半
- LINUX、UNIX资料的网站&《c#高级编程》