diff options
author | tzafrir <tzafrir@5390a7c7-147a-4af0-8ec9-7488f05a26cb> | 2007-09-22 20:51:33 +0000 |
---|---|---|
committer | tzafrir <tzafrir@5390a7c7-147a-4af0-8ec9-7488f05a26cb> | 2007-09-22 20:51:33 +0000 |
commit | 362b77d3ae9a9ec208086fc014e90158bc1bc22a (patch) | |
tree | 98d44a7c8766a52095ab13bbe36d05832b4f848c /ztdummy.c | |
parent | d8408feade6cd16368f04f7b1f40b3448853c709 (diff) |
Backport support for high-resolution timers from 1.4. Allows 2.6.22
Fedoras to build again.
git-svn-id: http://svn.digium.com/svn/zaptel/branches/1.2@3083 5390a7c7-147a-4af0-8ec9-7488f05a26cb
Diffstat (limited to 'ztdummy.c')
-rw-r--r-- | ztdummy.c | 44 |
1 files changed, 39 insertions, 5 deletions
@@ -8,6 +8,8 @@ * Unified by Mark Spencer <markster@digium.com> * Converted to use RTC on i386 by Tony Mountifield <tony@softins.co.uk> * + * Converted to use HighResTimers on i386 by Jeffery Palmer <jeff@triggerinc.com> + * * Copyright (C) 2002, Hermes Softlab * Copyright (C) 2004, Digium, Inc. * @@ -28,6 +30,14 @@ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * */ + +/* + * To use the high resolution timers, in your kernel CONFIG_HIGH_RES_TIMERS + * needs to be enabled (Processor type and features -> High Resolution + * Timer Support), and optionally HPET (Processor type and features -> + * HPET Timer Support) provides a better clock source. + */ + #include <linux/version.h> #ifndef VERSION_CODE @@ -46,7 +56,12 @@ */ #if defined(__i386__) || defined(__x86_64__) #if LINUX_VERSION_CODE >= VERSION_CODE(2,6,13) +/* The symbol hrtimer_forward is only exported as of 2.6.22: */ +#if defined(CONFIG_HIGH_RES_TIMERS) && LINUX_VERSION_CODE >= VERSION_CODE(2,6,22) +#define USE_HIGHRESTIMER +#else #define USE_RTC +#endif #else #if 0 #define USE_RTC @@ -70,6 +85,9 @@ #include <asm/io.h> #endif #ifdef LINUX26 +#ifdef USE_HIGHRESTIMER +#include <linux/hrtimer.h> +#endif #ifdef USE_RTC #include <linux/rtc.h> #endif @@ -96,8 +114,14 @@ static struct ztdummy *ztd; static int debug = 0; #ifdef LINUX26 -#ifndef USE_RTC -/* New 2.6 kernel timer stuff */ +#ifdef USE_HIGHRESTIMER +#define CLOCK_SRC "HRtimer" +struct hrtimer zaptimer; +#elif defined(USE_RTC) +#define CLOCK_SRC "RTC" +#else /* Linux 2.6, but no RTC or HRTIMER used */ +#define CLOCK_SRC "Linux26" +/* 2.6 kernel timer stuff */ static struct timer_list timer; #if HZ != 1000 #warning This module will not be usable since the kernel HZ setting is not 1000 ticks per second. @@ -107,6 +131,7 @@ static struct timer_list timer; #if LINUX_VERSION_CODE < VERSION_CODE(2,4,5) # error "This kernel is too old: not supported by this file" #endif +#define CLOCK_SRC "UHCI" /* Old UCHI stuff */ static uhci_desc_t *td; static uhci_t *s; @@ -126,6 +151,15 @@ extern uhci_t **uhci_devices; #endif +#define ZAPTEL_RATE 1000 /* zaptel ticks per second */ +#define ZAPTEL_TIME (1000000 / ZAPTEL_RATE) /* zaptel tick time in us */ +#define ZAPTEL_TIME_NS (ZAPTEL_TIME * 1000) /* zaptel tick time in ns */ + +/* Different bits of the debug variable: */ +#define DEBUG_GENERAL (1 << 0) +#define DEBUG_TICKS (1 << 1) + + #ifdef LINUX26 #ifdef USE_RTC /* rtc_interrupt - called at 1024Hz from hook in RTC handler */ @@ -180,7 +214,7 @@ static int ztdummy_initialize(struct ztdummy *ztd) { /* Zapata stuff */ sprintf(ztd->span.name, "ZTDUMMY/1"); - sprintf(ztd->span.desc, "%s %d", ztd->span.name, 1); + sprintf(ztd->span.desc, "%s (source: " CLOCK_SRC ") %d", ztd->span.name, 1); sprintf(ztd->chan.name, "ZTDUMMY/%d/%d", 1, 0); ztd->chan.chanpos = 1; ztd->span.chans = &ztd->chan; @@ -220,12 +254,12 @@ int init_module(void) } #endif -#if defined(LINUX26) && !defined(USE_RTC) +#if defined(LINUX26) && !defined(USE_RTC) && !defined(USE_HIGHRESTIMER) if (HZ != 1000) { printk("ztdummy: This module requires the kernel HZ setting to be 1000 ticks per second\n"); return -ENODEV; } -#endif /* defined(LINUX26) && !defined(USE_RTC) */ +#endif /* defined(LINUX26) && !defined(USE_RTC) && !defined(USE_HIGHRESTIMER)*/ ztd = kmalloc(sizeof(struct ztdummy), GFP_KERNEL); if (ztd == NULL) { |