Timer in Linux Device Driver
Recently, I am debugging the Audio driver on Atmel AT91SAM9M10 with Linux-2.6.30 kernel version. The detail information as following.
Hardware: AT91SAM9M10, TLV320AIC3100, interface between them: Atmel SSC (I2S)
Software: Linux 2.6.30
Objective: using software to implement the exchange between headset and speaker
As the hardware design, there is no interrupt line can be connect to CPU, so using polling method to solve it. Then, the linux timer (define in include/linux/time.h) is be used.
The following is the example code:
++++++++++++++++++++++++++++
struct timer_list mytimer;
init_timer(&mytimer);
mytimer.expires = jiffies + HZ/1000; // jiffies define in include/linux/jiffies.h
mytimer.data = (unsigned long) codec;
mytimer.function = headset_det_task;
add_timer(&mytimer);
++++++++++++++++++++++++++++
The "headset_det_task" function as following
++++++++++++++++++++++++++++
int headset_det_task(unsigned long data)
{
... ...
mod_timer(&mytimer, jiffies + HZ); /* re-open the timer */
}
++++++++++++++++++++++++++++
In my mind, this function also can be implemented by kernel thread function. So this need to be go study.
TODO:
Linux定时器在音频驱动中的应用
本文介绍在Atmel AT91SAM9M10平台上使用Linux内核定时器实现耳机与扬声器切换的方法。由于硬件设计限制,无法使用中断方式,故采用轮询并借助Linux定时器进行检测。
1021

被折叠的 条评论
为什么被折叠?



