diff options
author | tzafrir <tzafrir@5390a7c7-147a-4af0-8ec9-7488f05a26cb> | 2007-10-01 04:47:25 +0000 |
---|---|---|
committer | tzafrir <tzafrir@5390a7c7-147a-4af0-8ec9-7488f05a26cb> | 2007-10-01 04:47:25 +0000 |
commit | db81ae0a4f1704fe6b8c4186117a73000cbc2ee9 (patch) | |
tree | 5ba70b95b0ee3def2533cfb2a67596cf231f6f04 /ztdummy.c | |
parent | f0143f49057743c18839c473da80d64b34ca238b (diff) |
A slightly more complete merge of the hires times code to 1.2 .
git-svn-id: http://svn.digium.com/svn/zaptel/branches/1.2@3098 5390a7c7-147a-4af0-8ec9-7488f05a26cb
Diffstat (limited to 'ztdummy.c')
-rw-r--r-- | ztdummy.c | 43 |
1 files changed, 43 insertions, 0 deletions
@@ -181,6 +181,38 @@ static void ztdummy_rtc_interrupt(void *private_data) zt_transmit(&ztd->span); } } +#elif defined(USE_HIGHRESTIMER) +static enum hrtimer_restart ztdummy_hr_int(struct hrtimer *htmr) +{ + unsigned long overrun; + + /* Trigger Zaptel */ + zt_receive(&ztd->span); + zt_transmit(&ztd->span); + + /* Overrun should always return 1, since we are in the timer that + * expired. + * We should worry if overrun is 2 or more; then we really missed + * a tick */ + overrun = hrtimer_forward(&zaptimer, htmr->expires, + ktime_set(0, ZAPTEL_TIME_NS)); + if(overrun > 1) { + if(printk_ratelimit()) + printk(KERN_NOTICE "ztdummy: HRTimer missed %lu ticks\n", + overrun - 1); + } + + if(debug && DEBUG_TICKS) { + static int count = 0; + /* Printk every 5 seconds, good test to see if timer is + * running properly */ + if (count++ % 5000 == 0) + printk(KERN_DEBUG "ztdummy: 5000 ticks from hrtimer\n"); + } + + /* Always restart the timer */ + return HRTIMER_RESTART; +} #else /* use kernel system tick timer if PC architecture RTC is not available */ static void ztdummy_timer(unsigned long param) @@ -289,6 +321,17 @@ int init_module(void) } rtc_control(&ztd->rtc_task, RTC_IRQP_SET, 1024); /* 1024 Hz */ rtc_control(&ztd->rtc_task, RTC_PIE_ON, 0); +#elif defined(USE_HIGHRESTIMER) + printk(KERN_DEBUG "ztdummy: Trying to load High Resolution Timer\n"); + hrtimer_init(&zaptimer, CLOCK_MONOTONIC, HRTIMER_MODE_REL); + printk(KERN_DEBUG "ztdummy: Initialized High Resolution Timer\n"); + + /* Set timer callback function */ + zaptimer.function = ztdummy_hr_int; + + printk(KERN_DEBUG "ztdummy: Starting High Resolution Timer\n"); + hrtimer_start(&zaptimer, ktime_set(0, ZAPTEL_TIME_NS), HRTIMER_MODE_REL); + printk(KERN_INFO "ztdummy: High Resolution Timer started, good to go\n"); #else init_timer(&timer); timer.function = ztdummy_timer; |