mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH][RFC] sort out CLOCK_TICK_RATE usage [0/3]
@ 2004-04-12  7:55 Thorsten Kranzkowski
  2004-04-12  7:57 ` [PATCH][RFC] sort out CLOCK_TICK_RATE usage [1/3] Thorsten Kranzkowski
                   ` (2 more replies)
  0 siblings, 3 replies; 21+ messages in thread
From: Thorsten Kranzkowski @ 2004-04-12  7:55 UTC (permalink / raw)
  To: linux-kernel
  Cc: rth, spyro, rmk, davidm, paulus, benh, jes, ralf, matthew, davem,
	wesolows, jdike, ak

Hello!

With every 2.6 kernel I tried the system speaker on my Alpha produces a 
rather unpleasant high pitched tone instead of the normal system beep.
This is because in p|cspkr.c the calculation of the counter values is
incorrectly based on CLOCK_TICK_RATE. 
To solve this problem I came up with these tree patches:

1/3:	introduce PIC_TICK_RATE constant. It seems this is not always
	the same value.
2/3:	use PIC_TICK_RATE in *spkr.c and some other places where the
	PIC is directly programmed.
3/3:	use CLOCK_TICK_RATE where 1193180 was used in timing calculations.

Tested on Alpha, compile & boot-tested on i386 (unrelated LVM problems here)

Arch maintainers please have a look whether I got the constants right or
if your architecture has a PIC at all.

Comments welcome.

Bye,
Thorsten


-- 
| Thorsten Kranzkowski        Internet: dl8bcu@dl8bcu.de                      |
| Mobile: ++49 170 1876134       Snail: Kiebitzstr. 14, 49324 Melle, Germany  |
| Ampr: dl8bcu@db0lj.#rpl.deu.eu, dl8bcu@marvin.dl8bcu.ampr.org [44.130.8.19] |

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH][RFC] sort out CLOCK_TICK_RATE usage [1/3]
  2004-04-12  7:55 [PATCH][RFC] sort out CLOCK_TICK_RATE usage [0/3] Thorsten Kranzkowski
@ 2004-04-12  7:57 ` Thorsten Kranzkowski
  2004-04-12  7:57   ` [PATCH][RFC] sort out CLOCK_TICK_RATE usage [2/3] Thorsten Kranzkowski
  2004-04-12 16:39   ` [PATCH][RFC] sort out CLOCK_TICK_RATE usage [1/3] David Mosberger
  2004-04-12 16:47 ` [PATCH][RFC] sort out CLOCK_TICK_RATE usage [0/3] Zwane Mwaikambo
  2004-04-13 21:58 ` [PATCH] sort out CLOCK_TICK_RATE usage, 2nd try [0/3] Thorsten Kranzkowski
  2 siblings, 2 replies; 21+ messages in thread
From: Thorsten Kranzkowski @ 2004-04-12  7:57 UTC (permalink / raw)
  To: linux-kernel, rth, spyro, rmk, davidm, paulus, benh, jes, ralf,
	matthew, davem, wesolows, jdike, ak


Introducing PIC_TIC_RATE.



diff -ur linux-2.6.5-th/arch/alpha/kernel/time.c linux-2.6.5-1/arch/alpha/kernel/time.c
--- linux-2.6.5-th/arch/alpha/kernel/time.c	Sun Apr 11 14:24:42 2004
+++ linux-2.6.5-1/arch/alpha/kernel/time.c	Sun Apr 11 14:28:18 2004
@@ -254,7 +254,6 @@
  * arch/i386/time.c.
  */
 
-#define PIC_TICK_RATE	1193180UL
 #define CALIBRATE_LATCH	0xffff
 #define TIMEOUT_COUNT	0x100000
 
diff -ur linux-2.6.5-th/include/asm-alpha/timex.h linux-2.6.5-1/include/asm-alpha/timex.h
--- linux-2.6.5-th/include/asm-alpha/timex.h	Thu Dec 18 02:58:56 2003
+++ linux-2.6.5-1/include/asm-alpha/timex.h	Sun Apr 11 14:17:48 2004
@@ -10,6 +10,8 @@
    the 32.768kHz reference clock, which nicely divides down to our HZ.  */
 #define CLOCK_TICK_RATE	32768
 
+#define PIC_TICK_RATE	1193180UL
+
 /*
  * Standard way to access the cycle counter.
  * Currently only used on SMP for scheduling.
diff -ur linux-2.6.5-th/include/asm-arm/timex.h linux-2.6.5-1/include/asm-arm/timex.h
--- linux-2.6.5-th/include/asm-arm/timex.h	Thu Dec 18 02:58:17 2003
+++ linux-2.6.5-1/include/asm-arm/timex.h	Sun Apr 11 14:11:25 2004
@@ -23,4 +23,6 @@
 	return 0;
 }
 
+#define PIC_TICK_RATE	1193182UL
+
 #endif
diff -ur linux-2.6.5-th/include/asm-arm26/timex.h linux-2.6.5-1/include/asm-arm26/timex.h
--- linux-2.6.5-th/include/asm-arm26/timex.h	Thu Dec 18 02:59:05 2003
+++ linux-2.6.5-1/include/asm-arm26/timex.h	Sun Apr 11 14:11:57 2004
@@ -12,6 +12,9 @@
 #ifndef _ASMARM_TIMEX_H
 #define _ASMARM_TIMEX_H
 
+
+#define PIC_TICK_RATE		1193182UL
+
 /*
  * On the RiscPC, the clock ticks at 2MHz.
  */
diff -ur linux-2.6.5-th/include/asm-cris/timex.h linux-2.6.5-1/include/asm-cris/timex.h
--- linux-2.6.5-th/include/asm-cris/timex.h	Thu Dec 18 02:59:30 2003
+++ linux-2.6.5-1/include/asm-cris/timex.h	Sun Apr 11 14:14:35 2004
@@ -9,6 +9,8 @@
 
 #include <asm/arch/timex.h>
 
+#define PIC_TICK_RATE	1193182UL
+
 /*
  * We don't have a cycle-counter.. but we do not support SMP anyway where this is
  * used so it does not matter.
diff -ur linux-2.6.5-th/include/asm-h8300/timex.h linux-2.6.5-1/include/asm-h8300/timex.h
--- linux-2.6.5-th/include/asm-h8300/timex.h	Thu Dec 18 02:58:49 2003
+++ linux-2.6.5-1/include/asm-h8300/timex.h	Sun Apr 11 14:14:56 2004
@@ -10,6 +10,8 @@
 #include <asm/machine-depend.h>
 #undef  H8300_TIMER_DEFINE
 
+#define PIC_TICK_RATE	1193182UL
+
 #define CLOCK_TICK_RATE H8300_TIMER_FREQ
 #define CLOCK_TICK_FACTOR	20	/* Factor of both 1000000 and CLOCK_TICK_RATE */
 #define FINETUNE ((((((long)LATCH * HZ - CLOCK_TICK_RATE) << SHIFT_HZ) * \
diff -ur linux-2.6.5-th/include/asm-i386/timex.h linux-2.6.5-1/include/asm-i386/timex.h
--- linux-2.6.5-th/include/asm-i386/timex.h	Sun Apr 11 14:24:36 2004
+++ linux-2.6.5-1/include/asm-i386/timex.h	Sun Apr 11 13:47:57 2004
@@ -19,6 +19,9 @@
 #endif
 #endif
 
+#define PIC_TICK_RATE CLOCK_TICK_RATE
+
+
 #define CLOCK_TICK_FACTOR	20	/* Factor of both 1000000 and CLOCK_TICK_RATE */
 #define FINETUNE ((((((long)LATCH * HZ - CLOCK_TICK_RATE) << SHIFT_HZ) * \
 	(1000000/CLOCK_TICK_FACTOR) / (CLOCK_TICK_RATE/CLOCK_TICK_FACTOR)) \
diff -ur linux-2.6.5-th/include/asm-ia64/timex.h linux-2.6.5-1/include/asm-ia64/timex.h
--- linux-2.6.5-th/include/asm-ia64/timex.h	Thu Dec 18 02:59:27 2003
+++ linux-2.6.5-1/include/asm-ia64/timex.h	Sun Apr 11 13:54:39 2004
@@ -28,6 +28,8 @@
  */
 #define CLOCK_TICK_RATE		(HZ * 100000UL)
 
+#define PIC_TICK_RATE		1193182UL
+
 static inline cycles_t
 get_cycles (void)
 {
diff -ur linux-2.6.5-th/include/asm-m68k/timex.h linux-2.6.5-1/include/asm-m68k/timex.h
--- linux-2.6.5-th/include/asm-m68k/timex.h	Thu Dec 18 02:58:07 2003
+++ linux-2.6.5-1/include/asm-m68k/timex.h	Sun Apr 11 13:55:55 2004
@@ -6,7 +6,9 @@
 #ifndef _ASMm68k_TIMEX_H
 #define _ASMm68k_TIMEX_H
 
-#define CLOCK_TICK_RATE	1193180 /* Underlying HZ */
+#define PIC_TICK_RATE	1193180UL
+
+#define CLOCK_TICK_RATE	PIC_TICK_RATE	/* Underlying HZ */
 #define CLOCK_TICK_FACTOR	20	/* Factor of both 1000000 and CLOCK_TICK_RATE */
 #define FINETUNE ((((((long)LATCH * HZ - CLOCK_TICK_RATE) << SHIFT_HZ) * \
 	(1000000/CLOCK_TICK_FACTOR) / (CLOCK_TICK_RATE/CLOCK_TICK_FACTOR)) \
diff -ur linux-2.6.5-th/include/asm-mips/timex.h linux-2.6.5-1/include/asm-mips/timex.h
--- linux-2.6.5-th/include/asm-mips/timex.h	Sun Apr 11 14:24:36 2004
+++ linux-2.6.5-1/include/asm-mips/timex.h	Sun Apr 11 14:02:21 2004
@@ -31,6 +31,9 @@
  * no reason to make this a separate architecture.
  */
 
+#define PIC_TICK_RATE	1193182UL
+
+
 #include <timex.h>
 
 /*
diff -ur linux-2.6.5-th/include/asm-parisc/timex.h linux-2.6.5-1/include/asm-parisc/timex.h
--- linux-2.6.5-th/include/asm-parisc/timex.h	Thu Dec 18 02:58:49 2003
+++ linux-2.6.5-1/include/asm-parisc/timex.h	Sun Apr 11 14:03:23 2004
@@ -8,7 +8,8 @@
 
 #include <asm/system.h>
 
-#define CLOCK_TICK_RATE	1193180 /* Underlying HZ */
+#define	PIC_TICK_RATE	1193180UL
+#define CLOCK_TICK_RATE	PIC_TICK_RATE	/* Underlying HZ */
 
 typedef unsigned long cycles_t;
 
diff -ur linux-2.6.5-th/include/asm-ppc/timex.h linux-2.6.5-1/include/asm-ppc/timex.h
--- linux-2.6.5-th/include/asm-ppc/timex.h	Thu Dec 18 02:58:49 2003
+++ linux-2.6.5-1/include/asm-ppc/timex.h	Sun Apr 11 14:04:06 2004
@@ -10,7 +10,8 @@
 #include <linux/config.h>
 #include <asm/cputable.h>
 
-#define CLOCK_TICK_RATE	1193180 /* Underlying HZ */
+#define PIC_TICK_RATE	1193180UL
+#define CLOCK_TICK_RATE	PIC_TICK_RATE	/* Underlying HZ */
 #define CLOCK_TICK_FACTOR	20	/* Factor of both 1000000 and CLOCK_TICK_RATE */
 #define FINETUNE ((((((long)LATCH * HZ - CLOCK_TICK_RATE) << SHIFT_HZ) * \
 	(1000000/CLOCK_TICK_FACTOR) / (CLOCK_TICK_RATE/CLOCK_TICK_FACTOR)) \
diff -ur linux-2.6.5-th/include/asm-ppc64/timex.h linux-2.6.5-1/include/asm-ppc64/timex.h
--- linux-2.6.5-th/include/asm-ppc64/timex.h	Thu Dec 18 02:59:59 2003
+++ linux-2.6.5-1/include/asm-ppc64/timex.h	Sun Apr 11 14:04:45 2004
@@ -11,7 +11,8 @@
 #ifndef _ASMPPC64_TIMEX_H
 #define _ASMPPC64_TIMEX_H
 
-#define CLOCK_TICK_RATE	1193180 /* Underlying HZ */
+#define PIC_TICK_RATE	1193180UL
+#define CLOCK_TICK_RATE	PIC_TICK_RATE	/* Underlying HZ */
 #define CLOCK_TICK_FACTOR	20	/* Factor of both 1000000 and CLOCK_TICK_RATE */
 #define FINETUNE ((((((long)LATCH * HZ - CLOCK_TICK_RATE) << SHIFT_HZ) * \
 	(1000000/CLOCK_TICK_FACTOR) / (CLOCK_TICK_RATE/CLOCK_TICK_FACTOR)) \
diff -ur linux-2.6.5-th/include/asm-s390/timex.h linux-2.6.5-1/include/asm-s390/timex.h
--- linux-2.6.5-th/include/asm-s390/timex.h	Sun Apr 11 14:23:27 2004
+++ linux-2.6.5-1/include/asm-s390/timex.h	Sun Apr 11 14:05:25 2004
@@ -11,7 +11,8 @@
 #ifndef _ASM_S390_TIMEX_H
 #define _ASM_S390_TIMEX_H
 
-#define CLOCK_TICK_RATE	1193180 /* Underlying HZ */
+#define PIC_TICK_RATE	1193180UL
+#define CLOCK_TICK_RATE	PIC_TICK_RATE	/* Underlying HZ */
 #define CLOCK_TICK_FACTOR	20	/* Factor of both 1000000 and CLOCK_TICK_RATE */
 #define FINETUNE ((((((long)LATCH * HZ - CLOCK_TICK_RATE) << SHIFT_HZ) * \
 	(1000000/CLOCK_TICK_FACTOR) / (CLOCK_TICK_RATE/CLOCK_TICK_FACTOR)) \
diff -ur linux-2.6.5-th/include/asm-sh/timex.h linux-2.6.5-1/include/asm-sh/timex.h
--- linux-2.6.5-th/include/asm-sh/timex.h	Sun Apr 11 14:23:27 2004
+++ linux-2.6.5-1/include/asm-sh/timex.h	Sun Apr 11 14:06:38 2004
@@ -6,6 +6,7 @@
 #ifndef __ASM_SH_TIMEX_H
 #define __ASM_SH_TIMEX_H
 
+#define PIC_TICK_RATE	1193182UL
 #define CLOCK_TICK_RATE		(CONFIG_SH_PCLK_FREQ / 4) /* Underlying HZ */
 #define CLOCK_TICK_FACTOR	20	/* Factor of both 1000000 and CLOCK_TICK_RATE */
 #define FINETUNE ((((((long)LATCH * HZ - CLOCK_TICK_RATE) << SHIFT_HZ) * \
diff -ur linux-2.6.5-th/include/asm-sparc/timex.h linux-2.6.5-1/include/asm-sparc/timex.h
--- linux-2.6.5-th/include/asm-sparc/timex.h	Thu Dec 18 02:59:05 2003
+++ linux-2.6.5-1/include/asm-sparc/timex.h	Sun Apr 11 14:07:08 2004
@@ -6,7 +6,8 @@
 #ifndef _ASMsparc_TIMEX_H
 #define _ASMsparc_TIMEX_H
 
-#define CLOCK_TICK_RATE	1193180 /* Underlying HZ */
+#define PIC_TICK_RATE	1193180UL
+#define CLOCK_TICK_RATE	PIC_TICK_RATE	/* Underlying HZ */
 #define CLOCK_TICK_FACTOR	20	/* Factor of both 1000000 and CLOCK_TICK_RATE */
 #define FINETUNE ((((((long)LATCH * HZ - CLOCK_TICK_RATE) << SHIFT_HZ) * \
 	(1000000/CLOCK_TICK_FACTOR) / (CLOCK_TICK_RATE/CLOCK_TICK_FACTOR)) \
diff -ur linux-2.6.5-th/include/asm-sparc64/timex.h linux-2.6.5-1/include/asm-sparc64/timex.h
--- linux-2.6.5-th/include/asm-sparc64/timex.h	Thu Dec 18 02:58:49 2003
+++ linux-2.6.5-1/include/asm-sparc64/timex.h	Sun Apr 11 14:07:37 2004
@@ -8,7 +8,8 @@
 
 #include <asm/timer.h>
 
-#define CLOCK_TICK_RATE	1193180 /* Underlying HZ */
+#define PIC_TICK_RATE	1193180UL
+#define CLOCK_TICK_RATE	PIC_TICK_RATE	/* Underlying HZ */
 #define CLOCK_TICK_FACTOR	20	/* Factor of both 1000000 and CLOCK_TICK_RATE */
 #define FINETUNE ((((((long)LATCH * HZ - CLOCK_TICK_RATE) << SHIFT_HZ) * \
 	(1000000/CLOCK_TICK_FACTOR) / (CLOCK_TICK_RATE/CLOCK_TICK_FACTOR)) \
diff -ur linux-2.6.5-th/include/asm-um/timex.h linux-2.6.5-1/include/asm-um/timex.h
--- linux-2.6.5-th/include/asm-um/timex.h	Thu Dec 18 02:59:05 2003
+++ linux-2.6.5-1/include/asm-um/timex.h	Sun Apr 11 14:09:13 2004
@@ -12,6 +12,7 @@
 	return 0;
 }
 
+#define PIC_TICK_RATE	1193182UL
 #define CLOCK_TICK_RATE (HZ)
 
 #endif
diff -ur linux-2.6.5-th/include/asm-v850/timex.h linux-2.6.5-1/include/asm-v850/timex.h
--- linux-2.6.5-th/include/asm-v850/timex.h	Thu Dec 18 02:59:40 2003
+++ linux-2.6.5-1/include/asm-v850/timex.h	Sun Apr 11 14:10:00 2004
@@ -6,7 +6,8 @@
 #ifndef __V850_TIMEX_H__
 #define __V850_TIMEX_H__
 
-#define CLOCK_TICK_RATE	1193180 /* Underlying HZ */
+#define PIC_TICK_RATE	1193180UL
+#define CLOCK_TICK_RATE	PIC_TICK_RATE	/* Underlying HZ */
 #define CLOCK_TICK_FACTOR	20	/* Factor of both 1000000 and CLOCK_TICK_RATE */
 #define FINETUNE ((((((long)LATCH * HZ - CLOCK_TICK_RATE) << SHIFT_HZ) * \
 	(1000000/CLOCK_TICK_FACTOR) / (CLOCK_TICK_RATE/CLOCK_TICK_FACTOR)) \
diff -ur linux-2.6.5-th/include/asm-x86_64/timex.h linux-2.6.5-1/include/asm-x86_64/timex.h
--- linux-2.6.5-th/include/asm-x86_64/timex.h	Sun Apr 11 14:23:27 2004
+++ linux-2.6.5-1/include/asm-x86_64/timex.h	Sun Apr 11 14:10:35 2004
@@ -11,7 +11,8 @@
 #include <asm/vsyscall.h>
 #include <asm/hpet.h>
 
-#define CLOCK_TICK_RATE	1193182 /* Underlying HZ */
+#define PIC_TICK_RATE	1193182UL
+#define CLOCK_TICK_RATE	PIC_TICK_RATE	/* Underlying HZ */
 #define CLOCK_TICK_FACTOR	20	/* Factor of both 1000000 and CLOCK_TICK_RATE */
 #define FINETUNE ((((((int)LATCH * HZ - CLOCK_TICK_RATE) << SHIFT_HZ) * \
 	(1000000/CLOCK_TICK_FACTOR) / (CLOCK_TICK_RATE/CLOCK_TICK_FACTOR)) \


-- 
| Thorsten Kranzkowski        Internet: dl8bcu@dl8bcu.de                      |
| Mobile: ++49 170 1876134       Snail: Kiebitzstr. 14, 49324 Melle, Germany  |
| Ampr: dl8bcu@db0lj.#rpl.deu.eu, dl8bcu@marvin.dl8bcu.ampr.org [44.130.8.19] |

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH][RFC] sort out CLOCK_TICK_RATE usage [2/3]
  2004-04-12  7:57 ` [PATCH][RFC] sort out CLOCK_TICK_RATE usage [1/3] Thorsten Kranzkowski
@ 2004-04-12  7:57   ` Thorsten Kranzkowski
  2004-04-12  7:58     ` [PATCH][RFC] sort out CLOCK_TICK_RATE usage [3/3] Thorsten Kranzkowski
  2004-04-12 16:39   ` [PATCH][RFC] sort out CLOCK_TICK_RATE usage [1/3] David Mosberger
  1 sibling, 1 reply; 21+ messages in thread
From: Thorsten Kranzkowski @ 2004-04-12  7:57 UTC (permalink / raw)
  To: linux-kernel, rth, spyro, rmk, davidm, paulus, benh, jes, ralf,
	matthew, davem, wesolows, jdike, ak


diff -ur linux-2.6.5-1/drivers/char/vt_ioctl.c linux-2.6.5-2/drivers/char/vt_ioctl.c
--- linux-2.6.5-1/drivers/char/vt_ioctl.c	Sat Apr 10 11:10:27 2004
+++ linux-2.6.5-2/drivers/char/vt_ioctl.c	Sun Apr 11 14:42:08 2004
@@ -26,6 +26,7 @@
 #include <linux/console.h>
 
 #include <asm/io.h>
+#include <asm/timex.h>
 #include <asm/uaccess.h>
 
 #include <linux/kbd_kern.h>
@@ -391,7 +392,7 @@
 		if (!perm)
 			return -EPERM;
 		if (arg)
-			arg = 1193182 / arg;
+			arg = PIC_TICK_RATE / arg;
 		kd_mksound(arg, 0);
 		return 0;
 
@@ -408,7 +409,7 @@
 		ticks = HZ * ((arg >> 16) & 0xffff) / 1000;
 		count = ticks ? (arg & 0xffff) : 0;
 		if (count)
-			count = 1193182 / count;
+			count = PIC_TICK_RATE / count;
 		kd_mksound(count, ticks);
 		return 0;
 	}
diff -ur linux-2.6.5-1/drivers/input/misc/98spkr.c linux-2.6.5-2/drivers/input/misc/98spkr.c
--- linux-2.6.5-1/drivers/input/misc/98spkr.c	Thu Dec 18 02:58:17 2003
+++ linux-2.6.5-2/drivers/input/misc/98spkr.c	Sun Apr 11 14:42:59 2004
@@ -44,7 +44,7 @@
 	} 
 
 	if (value > 20 && value < 32767)
-		count = CLOCK_TICK_RATE / value;
+		count = PIC_TICK_RATE / value;
 	
 	spin_lock_irqsave(&i8253_beep_lock, flags);
 
diff -ur linux-2.6.5-1/drivers/input/misc/m68kspkr.c linux-2.6.5-2/drivers/input/misc/m68kspkr.c
--- linux-2.6.5-1/drivers/input/misc/m68kspkr.c	Thu Dec 18 02:58:15 2003
+++ linux-2.6.5-2/drivers/input/misc/m68kspkr.c	Sun Apr 11 14:43:34 2004
@@ -42,7 +42,7 @@
 	}
 
 	if (value > 20 && value < 32767)
-		count = 1193182 / value;
+		count = PIC_TICK_RATE / value;
 
 	mach_beep(count, -1);
 
diff -ur linux-2.6.5-1/drivers/input/misc/pcspkr.c linux-2.6.5-2/drivers/input/misc/pcspkr.c
--- linux-2.6.5-1/drivers/input/misc/pcspkr.c	Thu Dec 18 02:58:57 2003
+++ linux-2.6.5-2/drivers/input/misc/pcspkr.c	Sun Apr 11 14:43:56 2004
@@ -43,7 +43,7 @@
 	} 
 
 	if (value > 20 && value < 32767)
-		count = CLOCK_TICK_RATE / value;
+		count = PIC_TICK_RATE / value;
 	
 	spin_lock_irqsave(&i8253_beep_lock, flags);
 

diff -ur linux-2.6.5-2/arch/x86_64/kernel/time.c linux-2.6.5-3/arch/x86_64/kernel/time.c
--- linux-2.6.5-2/arch/x86_64/kernel/time.c	Sat Apr 10 11:10:26 2004
+++ linux-2.6.5-3/arch/x86_64/kernel/time.c	Sun Apr 11 15:26:49 2004
@@ -54,7 +54,7 @@
 unsigned int cpu_khz;					/* TSC clocks / usec, not used here */
 unsigned long hpet_period;				/* fsecs / HPET clock */
 unsigned long hpet_tick;				/* HPET clocks / interrupt */
-unsigned long vxtime_hz = 1193182;
+unsigned long vxtime_hz = PIC_TICK_RATE;
 int report_lost_ticks;				/* command line option */
 unsigned long long monotonic_base;
 
@@ -600,8 +600,8 @@
 	outb((inb(0x61) & ~0x02) | 0x01, 0x61);
 
 	outb(0xb0, 0x43);
-	outb((1193182 / (1000 / 50)) & 0xff, 0x42);
-	outb((1193182 / (1000 / 50)) >> 8, 0x42);
+	outb((PIC_TICK_RATE / (1000 / 50)) & 0xff, 0x42);
+	outb((PIC_TICK_RATE / (1000 / 50)) >> 8, 0x42);
 	rdtscll(start);
 	sync_core();
 	while ((inb(0x61) & 0x20) == 0);
diff -ur linux-2.6.5-2/drivers/input/gameport/gameport.c linux-2.6.5-3/drivers/input/gameport/gameport.c
--- linux-2.6.5-2/drivers/input/gameport/gameport.c	Thu Dec 18 02:58:49 2003
+++ linux-2.6.5-3/drivers/input/gameport/gameport.c	Sun Apr 11 15:23:35 2004
@@ -37,7 +37,7 @@
 
 #ifdef __i386__
 
-#define DELTA(x,y)      ((y)-(x)+((y)<(x)?1193182/HZ:0))
+#define DELTA(x,y)      ((y)-(x)+((y)<(x)?PIC_TICK_RATE/HZ:0))
 #define GET_TIME(x)     do { x = get_time_pit(); } while (0)
 
 static unsigned int get_time_pit(void)
-- 
| Thorsten Kranzkowski        Internet: dl8bcu@dl8bcu.de                      |
| Mobile: ++49 170 1876134       Snail: Kiebitzstr. 14, 49324 Melle, Germany  |
| Ampr: dl8bcu@db0lj.#rpl.deu.eu, dl8bcu@marvin.dl8bcu.ampr.org [44.130.8.19] |

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH][RFC] sort out CLOCK_TICK_RATE usage [3/3]
  2004-04-12  7:57   ` [PATCH][RFC] sort out CLOCK_TICK_RATE usage [2/3] Thorsten Kranzkowski
@ 2004-04-12  7:58     ` Thorsten Kranzkowski
  0 siblings, 0 replies; 21+ messages in thread
From: Thorsten Kranzkowski @ 2004-04-12  7:58 UTC (permalink / raw)
  To: linux-kernel, rth, spyro, rmk, davidm, paulus, benh, jes, ralf,
	matthew, davem, wesolows, jdike, ak


diff -ur linux-2.6.5-2/drivers/input/joystick/analog.c linux-2.6.5-3/drivers/input/joystick/analog.c
--- linux-2.6.5-2/drivers/input/joystick/analog.c	Sat Apr 10 11:11:01 2004
+++ linux-2.6.5-3/drivers/input/joystick/analog.c	Sun Apr 11 15:19:11 2004
@@ -142,7 +142,7 @@
 
 #ifdef __i386__
 #define GET_TIME(x)	do { if (cpu_has_tsc) rdtscl(x); else x = get_time_pit(); } while (0)
-#define DELTA(x,y)	(cpu_has_tsc?((y)-(x)):((x)-(y)+((x)<(y)?1193182L/HZ:0)))
+#define DELTA(x,y)	(cpu_has_tsc?((y)-(x)):((x)-(y)+((x)<(y)?CLOCK_TICK_RATE/HZ:0)))
 #define TIME_NAME	(cpu_has_tsc?"TSC":"PIT")
 static unsigned int get_time_pit(void)
 {
diff -ur linux-2.6.5-2/sound/oss/pas2_pcm.c linux-2.6.5-3/sound/oss/pas2_pcm.c
--- linux-2.6.5-2/sound/oss/pas2_pcm.c	Thu Dec 18 02:58:28 2003
+++ linux-2.6.5-3/sound/oss/pas2_pcm.c	Sun Apr 11 15:18:27 2004
@@ -17,6 +17,7 @@
 
 #include <linux/init.h>
 #include <linux/spinlock.h>
+#include <asm/timex.h>
 #include "sound_config.h"
 
 #include "pas2.h"
@@ -62,13 +63,13 @@
 
 	if (pcm_channels & 2)
 	{
-		foo = (596590 + (arg / 2)) / arg;
-		arg = (596590 + (foo / 2)) / foo;
+		foo = ((CLOCK_TICK_RATE/2) + (arg / 2)) / arg;
+		arg = ((CLOCK_TICK_RATE/2) + (foo / 2)) / foo;
 	}
 	else
 	{
-		foo = (1193180 + (arg / 2)) / arg;
-		arg = (1193180 + (foo / 2)) / foo;
+		foo = (CLOCK_TICK_RATE + (arg / 2)) / arg;
+		arg = (CLOCK_TICK_RATE + (foo / 2)) / foo;
 	}
 
 	pcm_speed = arg;
-- 
| Thorsten Kranzkowski        Internet: dl8bcu@dl8bcu.de                      |
| Mobile: ++49 170 1876134       Snail: Kiebitzstr. 14, 49324 Melle, Germany  |
| Ampr: dl8bcu@db0lj.#rpl.deu.eu, dl8bcu@marvin.dl8bcu.ampr.org [44.130.8.19] |

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH][RFC] sort out CLOCK_TICK_RATE usage [1/3]
  2004-04-12  7:57 ` [PATCH][RFC] sort out CLOCK_TICK_RATE usage [1/3] Thorsten Kranzkowski
  2004-04-12  7:57   ` [PATCH][RFC] sort out CLOCK_TICK_RATE usage [2/3] Thorsten Kranzkowski
@ 2004-04-12 16:39   ` David Mosberger
  2004-04-12 20:08     ` Thorsten Kranzkowski
  1 sibling, 1 reply; 21+ messages in thread
From: David Mosberger @ 2004-04-12 16:39 UTC (permalink / raw)
  To: dl8bcu
  Cc: linux-kernel, rth, spyro, rmk, davidm, paulus, benh, jes, ralf,
	matthew, davem, wesolows, jdike, ak

>>>>> On Mon, 12 Apr 2004 07:57:05 +0000, Thorsten Kranzkowski <dl8bcu@dl8bcu.de> said:

  Thorsten> Introducing PIC_TIC_RATE.

What's this meant for?  At least for IA-64, there is zero guarantee
that there will be a timer ticking at this rate.  There are some
machines where this is the case (the ones using Intel chipsets, I
believe), but it isn't true for most machines with non-Intel chipsets
(which are common).

	--david

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH][RFC] sort out CLOCK_TICK_RATE usage [0/3]
  2004-04-12  7:55 [PATCH][RFC] sort out CLOCK_TICK_RATE usage [0/3] Thorsten Kranzkowski
  2004-04-12  7:57 ` [PATCH][RFC] sort out CLOCK_TICK_RATE usage [1/3] Thorsten Kranzkowski
@ 2004-04-12 16:47 ` Zwane Mwaikambo
  2004-04-12 20:11   ` Thorsten Kranzkowski
  2004-04-13 21:58 ` [PATCH] sort out CLOCK_TICK_RATE usage, 2nd try [0/3] Thorsten Kranzkowski
  2 siblings, 1 reply; 21+ messages in thread
From: Zwane Mwaikambo @ 2004-04-12 16:47 UTC (permalink / raw)
  To: Thorsten Kranzkowski
  Cc: linux-kernel, rth, spyro, rmk, davidm, paulus, benh, jes, ralf,
	matthew, davem, wesolows, jdike, ak

On Mon, 12 Apr 2004, Thorsten Kranzkowski wrote:

> With every 2.6 kernel I tried the system speaker on my Alpha produces a
> rather unpleasant high pitched tone instead of the normal system beep.
> This is because in p|cspkr.c the calculation of the counter values is
> incorrectly based on CLOCK_TICK_RATE.
> To solve this problem I came up with these tree patches:
>
> 1/3:	introduce PIC_TICK_RATE constant. It seems this is not always
> 	the same value.
> 2/3:	use PIC_TICK_RATE in *spkr.c and some other places where the
> 	PIC is directly programmed.
> 3/3:	use CLOCK_TICK_RATE where 1193180 was used in timing calculations.
>
> Tested on Alpha, compile & boot-tested on i386 (unrelated LVM problems here)
>
> Arch maintainers please have a look whether I got the constants right or
> if your architecture has a PIC at all.

Isn't this supposed to be PIT_TICK_RATE?

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH][RFC] sort out CLOCK_TICK_RATE usage [1/3]
  2004-04-12 16:39   ` [PATCH][RFC] sort out CLOCK_TICK_RATE usage [1/3] David Mosberger
@ 2004-04-12 20:08     ` Thorsten Kranzkowski
  2004-04-12 20:32       ` David Mosberger
  0 siblings, 1 reply; 21+ messages in thread
From: Thorsten Kranzkowski @ 2004-04-12 20:08 UTC (permalink / raw)
  To: davidm
  Cc: linux-kernel, rth, spyro, rmk, paulus, benh, jes, ralf, matthew,
	davem, wesolows, jdike, ak

On Mon, Apr 12, 2004 at 09:39:43AM -0700, David Mosberger wrote:
> >>>>> On Mon, 12 Apr 2004 07:57:05 +0000, Thorsten Kranzkowski <dl8bcu@dl8bcu.de> said:
> 
>   Thorsten> Introducing PIC_TIC_RATE.
> 
> What's this meant for?  At least for IA-64, there is zero guarantee
> that there will be a timer ticking at this rate.  There are some
> machines where this is the case (the ones using Intel chipsets, I
> believe), but it isn't true for most machines with non-Intel chipsets
> (which are common).

This is the base frequency of the programmable interrupt timer/counter 
(originally a 8253 I think) that on some architectures serves as the 
system timer but on even more architectures drives the system speaker
with it's 3rd timer.

There are these lines in the pcspkr.c (and the other *spkr.c):

        if (value > 20 && value < 32767)
                count = PIC_TICK_RATE / value;

Thos evaluates the count the timer is programmed to generate a
given frequency (value).
In 2.6.5 this reads CLOCK_TICK_RATE which is definitely not correct
as the system clock is not necessarily driven by this chip (timer 0).
Older versions (kernel 2.4.x) of the speaker driver used a hardcoded
value but there seem to exist at least some strange i386 variants where 
this frequency is not the traditional one. 

So I thought an architectural define was appropriate. Maybe timex.h is
not the best place to put it in.


Bye,
Thorsten

-- 
| Thorsten Kranzkowski        Internet: dl8bcu@dl8bcu.de                      |
| Mobile: ++49 170 1876134       Snail: Kiebitzstr. 14, 49324 Melle, Germany  |
| Ampr: dl8bcu@db0lj.#rpl.deu.eu, dl8bcu@marvin.dl8bcu.ampr.org [44.130.8.19] |

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH][RFC] sort out CLOCK_TICK_RATE usage [0/3]
  2004-04-12 16:47 ` [PATCH][RFC] sort out CLOCK_TICK_RATE usage [0/3] Zwane Mwaikambo
@ 2004-04-12 20:11   ` Thorsten Kranzkowski
  2004-04-12 20:50     ` Zwane Mwaikambo
  0 siblings, 1 reply; 21+ messages in thread
From: Thorsten Kranzkowski @ 2004-04-12 20:11 UTC (permalink / raw)
  To: Zwane Mwaikambo
  Cc: linux-kernel, rth, spyro, rmk, davidm, paulus, benh, jes, ralf,
	matthew, davem, wesolows, jdike, ak

On Mon, Apr 12, 2004 at 12:47:08PM -0400, Zwane Mwaikambo wrote:
> On Mon, 12 Apr 2004, Thorsten Kranzkowski wrote:
> 
> > With every 2.6 kernel I tried the system speaker on my Alpha produces a
> > rather unpleasant high pitched tone instead of the normal system beep.
> > This is because in p|cspkr.c the calculation of the counter values is
> > incorrectly based on CLOCK_TICK_RATE.
> > To solve this problem I came up with these tree patches:
> >
> > 1/3:	introduce PIC_TICK_RATE constant. It seems this is not always
> > 	the same value.
> > 2/3:	use PIC_TICK_RATE in *spkr.c and some other places where the
> > 	PIC is directly programmed.
> > 3/3:	use CLOCK_TICK_RATE where 1193180 was used in timing calculations.
> >
> > Tested on Alpha, compile & boot-tested on i386 (unrelated LVM problems here)
> >
> > Arch maintainers please have a look whether I got the constants right or
> > if your architecture has a PIC at all.
> 
> Isn't this supposed to be PIT_TICK_RATE?
 

I reused the define in arch/alpha/kernel/time.c that served exactly 
the same purpose. I have no problems to call this a timer instead
of a counter, though. :)


Bye,
Thorsten


-- 
| Thorsten Kranzkowski        Internet: dl8bcu@dl8bcu.de                      |
| Mobile: ++49 170 1876134       Snail: Kiebitzstr. 14, 49324 Melle, Germany  |
| Ampr: dl8bcu@db0lj.#rpl.deu.eu, dl8bcu@marvin.dl8bcu.ampr.org [44.130.8.19] |

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH][RFC] sort out CLOCK_TICK_RATE usage [1/3]
  2004-04-12 20:08     ` Thorsten Kranzkowski
@ 2004-04-12 20:32       ` David Mosberger
  2004-04-12 21:17         ` Thorsten Kranzkowski
  0 siblings, 1 reply; 21+ messages in thread
From: David Mosberger @ 2004-04-12 20:32 UTC (permalink / raw)
  To: dl8bcu
  Cc: davidm, linux-kernel, rth, spyro, rmk, paulus, benh, jes, ralf,
	matthew, davem, wesolows, jdike, ak

>>>>> On Mon, 12 Apr 2004 20:08:36 +0000, Thorsten Kranzkowski <dl8bcu@dl8bcu.de> said:

  Thorsten> So I thought an architectural define was
  Thorsten> appropriate. Maybe timex.h is not the best place to put it
  Thorsten> in.

Yes, a #define is probably needed, but I do think timex.h is the wrong
place.  Perhaps <asm/8253pit.h> along with a suitable CONFIG_8253PIT
Kconfig option?

	--david

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH][RFC] sort out CLOCK_TICK_RATE usage [0/3]
  2004-04-12 20:11   ` Thorsten Kranzkowski
@ 2004-04-12 20:50     ` Zwane Mwaikambo
  0 siblings, 0 replies; 21+ messages in thread
From: Zwane Mwaikambo @ 2004-04-12 20:50 UTC (permalink / raw)
  To: Thorsten Kranzkowski
  Cc: linux-kernel, rth, spyro, rmk, davidm, paulus, benh, jes, ralf,
	matthew, davem, wesolows, jdike, ak

On Mon, 12 Apr 2004, Thorsten Kranzkowski wrote:

> > Isn't this supposed to be PIT_TICK_RATE?
>
>
> I reused the define in arch/alpha/kernel/time.c that served exactly
> the same purpose. I have no problems to call this a timer instead
> of a counter, though. :)

Well i was thinking more Programmable Interrupt Controller.

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH][RFC] sort out CLOCK_TICK_RATE usage [1/3]
  2004-04-12 20:32       ` David Mosberger
@ 2004-04-12 21:17         ` Thorsten Kranzkowski
  2004-04-13  4:04           ` Miles Bader
  0 siblings, 1 reply; 21+ messages in thread
From: Thorsten Kranzkowski @ 2004-04-12 21:17 UTC (permalink / raw)
  To: davidm
  Cc: linux-kernel, rth, spyro, rmk, paulus, benh, jes, ralf, matthew,
	davem, wesolows, jdike, ak

On Mon, Apr 12, 2004 at 01:32:25PM -0700, David Mosberger wrote:
> Yes, a #define is probably needed, but I do think timex.h is the wrong
> place.  Perhaps <asm/8253pit.h> along with a suitable CONFIG_8253PIT
> Kconfig option?

The header is fine with me but what do you have in mind with the Kconfig
option? where should it be used? 
Since INPUT_PCSPKR seems to be available on all archs, every arch must
have some idea of PI[CT]_TICK_RATE, no?

Thanks for your comments, I'll rework my patch tomorrow.

Bye,
Thorsten

-- 
| Thorsten Kranzkowski        Internet: dl8bcu@dl8bcu.de                      |
| Mobile: ++49 170 1876134       Snail: Kiebitzstr. 14, 49324 Melle, Germany  |
| Ampr: dl8bcu@db0lj.#rpl.deu.eu, dl8bcu@marvin.dl8bcu.ampr.org [44.130.8.19] |

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH][RFC] sort out CLOCK_TICK_RATE usage [1/3]
  2004-04-12 21:17         ` Thorsten Kranzkowski
@ 2004-04-13  4:04           ` Miles Bader
  2004-04-13 17:00             ` Thorsten Kranzkowski
  0 siblings, 1 reply; 21+ messages in thread
From: Miles Bader @ 2004-04-13  4:04 UTC (permalink / raw)
  To: dl8bcu
  Cc: davidm, linux-kernel, rth, spyro, rmk, paulus, benh, jes, ralf,
	matthew, davem, wesolows, jdike, ak

Thorsten Kranzkowski <dl8bcu@dl8bcu.de> writes:
> Since INPUT_PCSPKR seems to be available on all archs, every arch must
> have some idea of PI[CT]_TICK_RATE, no?

What are you talking about?  I see no INPUT_PCSPKR defined on my arch
anywhere, and don't even know what an 8253 is... [so it would be damn
silly to have <asm/8253pit.h> as a required header!]

Don't assume everything is like a PC.

-Miles
-- 
"1971 pickup truck; will trade for guns"

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH][RFC] sort out CLOCK_TICK_RATE usage [1/3]
  2004-04-13  4:04           ` Miles Bader
@ 2004-04-13 17:00             ` Thorsten Kranzkowski
  2004-04-14  1:45               ` Miles Bader
  0 siblings, 1 reply; 21+ messages in thread
From: Thorsten Kranzkowski @ 2004-04-13 17:00 UTC (permalink / raw)
  To: Miles Bader
  Cc: davidm, linux-kernel, rth, spyro, rmk, paulus, benh, jes, ralf,
	matthew, davem, wesolows, jdike, ak

On Tue, Apr 13, 2004 at 01:04:31PM +0900, Miles Bader wrote:
> Thorsten Kranzkowski <dl8bcu@dl8bcu.de> writes:
> > Since INPUT_PCSPKR seems to be available on all archs, every arch must
> > have some idea of PI[CT]_TICK_RATE, no?
> 
> What are you talking about?  I see no INPUT_PCSPKR defined on my arch

drivers/inkut/Kconfig:
	menu "Input device support"

	config INPUT
		tristate "Input devices (needed for keyboard, mouse, ...)" if EMBEDDED
		default y
	[...]

	source "drivers/input/misc/Kconfig"

drivers/input/misc/Kconfig:
	config INPUT_MISC
		bool "Misc"
		depends on INPUT
	[...]
	config INPUT_PCSPKR
		tristate "PC Speaker support"
		depends on INPUT && INPUT_MISC


I'm by no means a Kconfig expert, but I read this as there's nothing 
that prevents you to select INPUT_PCSPKR on every architecture.

I don't know your architecture, maybe it doesn't have a system speaker.

> anywhere, and don't even know what an 8253 is... [so it would be damn
> silly to have <asm/8253pit.h> as a required header!]

Ok, I won't create one, then. (just to be shure: asm-v850, right?) 

> Don't assume everything is like a PC.

Hell, no! I actually like my Alphas! ;)

Bye,
Thorsten

-- 
| Thorsten Kranzkowski        Internet: dl8bcu@dl8bcu.de                      |
| Mobile: ++49 170 1876134       Snail: Kiebitzstr. 14, 49324 Melle, Germany  |
| Ampr: dl8bcu@db0lj.#rpl.deu.eu, dl8bcu@marvin.dl8bcu.ampr.org [44.130.8.19] |

^ permalink raw reply	[flat|nested] 21+ messages in thread

* [PATCH] sort out CLOCK_TICK_RATE usage, 2nd try  [0/3]
  2004-04-12  7:55 [PATCH][RFC] sort out CLOCK_TICK_RATE usage [0/3] Thorsten Kranzkowski
  2004-04-12  7:57 ` [PATCH][RFC] sort out CLOCK_TICK_RATE usage [1/3] Thorsten Kranzkowski
  2004-04-12 16:47 ` [PATCH][RFC] sort out CLOCK_TICK_RATE usage [0/3] Zwane Mwaikambo
@ 2004-04-13 21:58 ` Thorsten Kranzkowski
  2004-04-13 21:59   ` [PATCH] sort out CLOCK_TICK_RATE usage, 2nd try [1/3] Thorsten Kranzkowski
  2004-04-14 14:12   ` [PATCH] sort out CLOCK_TICK_RATE usage, 2nd try [0/3] Matthew Wilcox
  2 siblings, 2 replies; 21+ messages in thread
From: Thorsten Kranzkowski @ 2004-04-13 21:58 UTC (permalink / raw)
  To: linux-kernel, rth, spyro, rmk, davidm, paulus, benh, jes, ralf,
	matthew, davem, wesolows, jdike, ak

Hello!

The calculation of the counter values in drivers/input/misc/pcspkr.c is
incorrectly based on CLOCK_TICK_RATE. This goes unnoticed in i386 
because there the system clock is driven by the same Programmable 
Interval Timer chip as the speaker. But this doesn't hold true on
other archs, e.g. Alpha.

To solve this problem I made these tree patches:

1/3:	introduce asm-*/8253pit.h, #defining PIT_TICK_RATE constant. 
	It seems this is not always the same value.
2/3:	use PIT_TICK_RATE in *spkr.c and some other places where the
 	PIT is directly programmed.
3/3:	use CLOCK_TICK_RATE where 1193180 was used in general timing 
	calculations.
 
Tested on Alpha and i386. Many thanks to David Mosberger, Miles Bader
and Zwane Mwaikambo for their comments.
 
Arch maintainers please have a look whether I got the constants right or
if your architecture has a PIC or speaker at all.

Comments welcome.
 
Bye,
Thorsten

-- 
| Thorsten Kranzkowski        Internet: dl8bcu@dl8bcu.de                      |
| Mobile: ++49 170 1876134       Snail: Kiebitzstr. 14, 49324 Melle, Germany  |
| Ampr: dl8bcu@db0lj.#rpl.deu.eu, dl8bcu@marvin.dl8bcu.ampr.org [44.130.8.19] |

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH] sort out CLOCK_TICK_RATE usage, 2nd try  [1/3]
  2004-04-13 21:58 ` [PATCH] sort out CLOCK_TICK_RATE usage, 2nd try [0/3] Thorsten Kranzkowski
@ 2004-04-13 21:59   ` Thorsten Kranzkowski
  2004-04-13 22:01     ` [PATCH] sort out CLOCK_TICK_RATE usage, 2nd try [2/3] Thorsten Kranzkowski
  2004-04-14 14:12   ` [PATCH] sort out CLOCK_TICK_RATE usage, 2nd try [0/3] Matthew Wilcox
  1 sibling, 1 reply; 21+ messages in thread
From: Thorsten Kranzkowski @ 2004-04-13 21:59 UTC (permalink / raw)
  To: linux-kernel, rth, spyro, rmk, davidm, paulus, benh, jes, ralf,
	matthew, davem, wesolows, jdike, ak

1/3:	introduce asm-*/8253pit.h, #defining PIT_TICK_RATE constant. 
 	It seems this is not always the same value.

diff -urN linux-2.6.5/arch/alpha/kernel/time.c linux-2.6.5-1a/arch/alpha/kernel/time.c
--- linux-2.6.5/arch/alpha/kernel/time.c	Sun Apr 11 14:24:42 2004
+++ linux-2.6.5-1a/arch/alpha/kernel/time.c	Tue Apr 13 17:18:19 2004
@@ -45,6 +45,7 @@
 #include <asm/uaccess.h>
 #include <asm/io.h>
 #include <asm/hwrpb.h>
+#include <asm/8253pit.h>
 
 #include <linux/mc146818rtc.h>
 #include <linux/time.h>
@@ -254,12 +255,11 @@
  * arch/i386/time.c.
  */
 
-#define PIC_TICK_RATE	1193180UL
 #define CALIBRATE_LATCH	0xffff
 #define TIMEOUT_COUNT	0x100000
 
 static unsigned long __init
-calibrate_cc_with_pic(void)
+calibrate_cc_with_pit(void)
 {
 	int cc, count = 0;
 
@@ -287,7 +287,7 @@
 	if (count <= 1 || count == TIMEOUT_COUNT)
 		return 0;
 
-	return ((long)cc * PIC_TICK_RATE) / (CALIBRATE_LATCH + 1);
+	return ((long)cc * PIT_TICK_RATE) / (CALIBRATE_LATCH + 1);
 }
 
 /* The Linux interpretation of the CMOS clock register contents:
@@ -313,7 +313,7 @@
 
 	/* Calibrate CPU clock -- attempt #1.  */
 	if (!est_cycle_freq)
-		est_cycle_freq = validate_cc_value(calibrate_cc_with_pic());
+		est_cycle_freq = validate_cc_value(calibrate_cc_with_pit());
 
 	cc1 = rpcc_after_update_in_progress();
 
diff -urN linux-2.6.5/include/asm-alpha/8253pit.h linux-2.6.5-1a/include/asm-alpha/8253pit.h
--- linux-2.6.5/include/asm-alpha/8253pit.h	Thu Jan  1 00:00:00 1970
+++ linux-2.6.5-1a/include/asm-alpha/8253pit.h	Tue Apr 13 17:14:40 2004
@@ -0,0 +1,10 @@
+/*
+ * 8253/8254 Programmable Interval Timer
+ */
+
+#ifndef _8253PIT_H
+#define _8253PIT_H
+
+#define PIT_TICK_RATE 	1193180UL
+
+#endif
diff -urN linux-2.6.5/include/asm-arm/8253pit.h linux-2.6.5-1a/include/asm-arm/8253pit.h
--- linux-2.6.5/include/asm-arm/8253pit.h	Thu Jan  1 00:00:00 1970
+++ linux-2.6.5-1a/include/asm-arm/8253pit.h	Tue Apr 13 17:19:31 2004
@@ -0,0 +1,10 @@
+/*
+ * 8253/8254 Programmable Interval Timer
+ */
+
+#ifndef _8253PIT_H
+#define _8253PIT_H
+
+#define PIT_TICK_RATE 	1193182UL
+
+#endif
diff -urN linux-2.6.5/include/asm-arm26/8253pit.h linux-2.6.5-1a/include/asm-arm26/8253pit.h
--- linux-2.6.5/include/asm-arm26/8253pit.h	Thu Jan  1 00:00:00 1970
+++ linux-2.6.5-1a/include/asm-arm26/8253pit.h	Tue Apr 13 17:20:08 2004
@@ -0,0 +1,10 @@
+/*
+ * 8253/8254 Programmable Interval Timer
+ */
+
+#ifndef _8253PIT_H
+#define _8253PIT_H
+
+#define PIT_TICK_RATE 	1193182UL
+
+#endif
diff -urN linux-2.6.5/include/asm-cris/8253pit.h linux-2.6.5-1a/include/asm-cris/8253pit.h
--- linux-2.6.5/include/asm-cris/8253pit.h	Thu Jan  1 00:00:00 1970
+++ linux-2.6.5-1a/include/asm-cris/8253pit.h	Tue Apr 13 17:20:25 2004
@@ -0,0 +1,10 @@
+/*
+ * 8253/8254 Programmable Interval Timer
+ */
+
+#ifndef _8253PIT_H
+#define _8253PIT_H
+
+#define PIT_TICK_RATE 	1193182UL
+
+#endif
diff -urN linux-2.6.5/include/asm-h8300/8253pit.h linux-2.6.5-1a/include/asm-h8300/8253pit.h
--- linux-2.6.5/include/asm-h8300/8253pit.h	Thu Jan  1 00:00:00 1970
+++ linux-2.6.5-1a/include/asm-h8300/8253pit.h	Tue Apr 13 17:20:42 2004
@@ -0,0 +1,10 @@
+/*
+ * 8253/8254 Programmable Interval Timer
+ */
+
+#ifndef _8253PIT_H
+#define _8253PIT_H
+
+#define PIT_TICK_RATE 	1193182UL
+
+#endif
diff -urN linux-2.6.5/include/asm-i386/8253pit.h linux-2.6.5-1a/include/asm-i386/8253pit.h
--- linux-2.6.5/include/asm-i386/8253pit.h	Thu Jan  1 00:00:00 1970
+++ linux-2.6.5-1a/include/asm-i386/8253pit.h	Tue Apr 13 17:21:49 2004
@@ -0,0 +1,12 @@
+/*
+ * 8253/8254 Programmable Interval Timer
+ */
+
+#ifndef _8253PIT_H
+#define _8253PIT_H
+
+#include <asm/timex.h>
+
+#define PIT_TICK_RATE 	CLOCK_TICK_RATE
+
+#endif
diff -urN linux-2.6.5/include/asm-ia64/8253pit.h linux-2.6.5-1a/include/asm-ia64/8253pit.h
--- linux-2.6.5/include/asm-ia64/8253pit.h	Thu Jan  1 00:00:00 1970
+++ linux-2.6.5-1a/include/asm-ia64/8253pit.h	Tue Apr 13 17:22:10 2004
@@ -0,0 +1,10 @@
+/*
+ * 8253/8254 Programmable Interval Timer
+ */
+
+#ifndef _8253PIT_H
+#define _8253PIT_H
+
+#define PIT_TICK_RATE 	1193182UL
+
+#endif
diff -urN linux-2.6.5/include/asm-m68k/8253pit.h linux-2.6.5-1a/include/asm-m68k/8253pit.h
--- linux-2.6.5/include/asm-m68k/8253pit.h	Thu Jan  1 00:00:00 1970
+++ linux-2.6.5-1a/include/asm-m68k/8253pit.h	Tue Apr 13 17:23:24 2004
@@ -0,0 +1,10 @@
+/*
+ * 8253/8254 Programmable Interval Timer
+ */
+
+#ifndef _8253PIT_H
+#define _8253PIT_H
+
+#define PIT_TICK_RATE 	1193180UL
+
+#endif
diff -urN linux-2.6.5/include/asm-m68k/timex.h linux-2.6.5-1a/include/asm-m68k/timex.h
--- linux-2.6.5/include/asm-m68k/timex.h	Thu Dec 18 02:58:07 2003
+++ linux-2.6.5-1a/include/asm-m68k/timex.h	Tue Apr 13 17:24:50 2004
@@ -6,7 +6,9 @@
 #ifndef _ASMm68k_TIMEX_H
 #define _ASMm68k_TIMEX_H
 
-#define CLOCK_TICK_RATE	1193180 /* Underlying HZ */
+#include <asm/8253pit.h>
+
+#define CLOCK_TICK_RATE	PIT_TICK_RATE	/* Underlying HZ */
 #define CLOCK_TICK_FACTOR	20	/* Factor of both 1000000 and CLOCK_TICK_RATE */
 #define FINETUNE ((((((long)LATCH * HZ - CLOCK_TICK_RATE) << SHIFT_HZ) * \
 	(1000000/CLOCK_TICK_FACTOR) / (CLOCK_TICK_RATE/CLOCK_TICK_FACTOR)) \
diff -urN linux-2.6.5/include/asm-m68knommu/8253pit.h linux-2.6.5-1a/include/asm-m68knommu/8253pit.h
--- linux-2.6.5/include/asm-m68knommu/8253pit.h	Thu Jan  1 00:00:00 1970
+++ linux-2.6.5-1a/include/asm-m68knommu/8253pit.h	Tue Apr 13 21:23:13 2004
@@ -0,0 +1,10 @@
+/*
+ * 8253/8254 Programmable Interval Timer
+ */
+
+#ifndef _8253PIT_H
+#define _8253PIT_H
+
+#define PIT_TICK_RATE 	1193180UL
+
+#endif
diff -urN linux-2.6.5/include/asm-mips/8253pit.h linux-2.6.5-1a/include/asm-mips/8253pit.h
--- linux-2.6.5/include/asm-mips/8253pit.h	Thu Jan  1 00:00:00 1970
+++ linux-2.6.5-1a/include/asm-mips/8253pit.h	Tue Apr 13 17:25:12 2004
@@ -0,0 +1,10 @@
+/*
+ * 8253/8254 Programmable Interval Timer
+ */
+
+#ifndef _8253PIT_H
+#define _8253PIT_H
+
+#define PIT_TICK_RATE 	1193182UL
+
+#endif
diff -urN linux-2.6.5/include/asm-parisc/8253pit.h linux-2.6.5-1a/include/asm-parisc/8253pit.h
--- linux-2.6.5/include/asm-parisc/8253pit.h	Thu Jan  1 00:00:00 1970
+++ linux-2.6.5-1a/include/asm-parisc/8253pit.h	Tue Apr 13 17:25:29 2004
@@ -0,0 +1,10 @@
+/*
+ * 8253/8254 Programmable Interval Timer
+ */
+
+#ifndef _8253PIT_H
+#define _8253PIT_H
+
+#define PIT_TICK_RATE 	1193180UL
+
+#endif
diff -urN linux-2.6.5/include/asm-parisc/timex.h linux-2.6.5-1a/include/asm-parisc/timex.h
--- linux-2.6.5/include/asm-parisc/timex.h	Thu Dec 18 02:58:49 2003
+++ linux-2.6.5-1a/include/asm-parisc/timex.h	Tue Apr 13 17:26:16 2004
@@ -6,9 +6,10 @@
 #ifndef _ASMPARISC_TIMEX_H
 #define _ASMPARISC_TIMEX_H
 
+#include <asm8253pit.h>
 #include <asm/system.h>
 
-#define CLOCK_TICK_RATE	1193180 /* Underlying HZ */
+#define CLOCK_TICK_RATE	PIT_TICK_RATE	/* Underlying HZ */
 
 typedef unsigned long cycles_t;
 
diff -urN linux-2.6.5/include/asm-ppc/8253pit.h linux-2.6.5-1a/include/asm-ppc/8253pit.h
--- linux-2.6.5/include/asm-ppc/8253pit.h	Thu Jan  1 00:00:00 1970
+++ linux-2.6.5-1a/include/asm-ppc/8253pit.h	Tue Apr 13 17:26:35 2004
@@ -0,0 +1,10 @@
+/*
+ * 8253/8254 Programmable Interval Timer
+ */
+
+#ifndef _8253PIT_H
+#define _8253PIT_H
+
+#define PIT_TICK_RATE 	1193180UL
+
+#endif
diff -urN linux-2.6.5/include/asm-ppc/timex.h linux-2.6.5-1a/include/asm-ppc/timex.h
--- linux-2.6.5/include/asm-ppc/timex.h	Thu Dec 18 02:58:49 2003
+++ linux-2.6.5-1a/include/asm-ppc/timex.h	Tue Apr 13 17:27:36 2004
@@ -8,9 +8,10 @@
 #define _ASMppc_TIMEX_H
 
 #include <linux/config.h>
+#include <asm/8253pit.h>
 #include <asm/cputable.h>
 
-#define CLOCK_TICK_RATE	1193180 /* Underlying HZ */
+#define CLOCK_TICK_RATE	PIT_TICK_RATE	/* Underlying HZ */
 #define CLOCK_TICK_FACTOR	20	/* Factor of both 1000000 and CLOCK_TICK_RATE */
 #define FINETUNE ((((((long)LATCH * HZ - CLOCK_TICK_RATE) << SHIFT_HZ) * \
 	(1000000/CLOCK_TICK_FACTOR) / (CLOCK_TICK_RATE/CLOCK_TICK_FACTOR)) \
diff -urN linux-2.6.5/include/asm-ppc64/8253pit.h linux-2.6.5-1a/include/asm-ppc64/8253pit.h
--- linux-2.6.5/include/asm-ppc64/8253pit.h	Thu Jan  1 00:00:00 1970
+++ linux-2.6.5-1a/include/asm-ppc64/8253pit.h	Tue Apr 13 17:27:52 2004
@@ -0,0 +1,10 @@
+/*
+ * 8253/8254 Programmable Interval Timer
+ */
+
+#ifndef _8253PIT_H
+#define _8253PIT_H
+
+#define PIT_TICK_RATE 	1193180UL
+
+#endif
diff -urN linux-2.6.5/include/asm-ppc64/timex.h linux-2.6.5-1a/include/asm-ppc64/timex.h
--- linux-2.6.5/include/asm-ppc64/timex.h	Thu Dec 18 02:59:59 2003
+++ linux-2.6.5-1a/include/asm-ppc64/timex.h	Tue Apr 13 17:28:32 2004
@@ -11,7 +11,9 @@
 #ifndef _ASMPPC64_TIMEX_H
 #define _ASMPPC64_TIMEX_H
 
-#define CLOCK_TICK_RATE	1193180 /* Underlying HZ */
+#include <asm/8253pit.h>
+
+#define CLOCK_TICK_RATE	PIT_TICK_RATE	/* Underlying HZ */
 #define CLOCK_TICK_FACTOR	20	/* Factor of both 1000000 and CLOCK_TICK_RATE */
 #define FINETUNE ((((((long)LATCH * HZ - CLOCK_TICK_RATE) << SHIFT_HZ) * \
 	(1000000/CLOCK_TICK_FACTOR) / (CLOCK_TICK_RATE/CLOCK_TICK_FACTOR)) \
diff -urN linux-2.6.5/include/asm-s390/8253pit.h linux-2.6.5-1a/include/asm-s390/8253pit.h
--- linux-2.6.5/include/asm-s390/8253pit.h	Thu Jan  1 00:00:00 1970
+++ linux-2.6.5-1a/include/asm-s390/8253pit.h	Tue Apr 13 17:28:50 2004
@@ -0,0 +1,10 @@
+/*
+ * 8253/8254 Programmable Interval Timer
+ */
+
+#ifndef _8253PIT_H
+#define _8253PIT_H
+
+#define PIT_TICK_RATE 	1193180UL
+
+#endif
diff -urN linux-2.6.5/include/asm-s390/timex.h linux-2.6.5-1a/include/asm-s390/timex.h
--- linux-2.6.5/include/asm-s390/timex.h	Sun Apr 11 14:23:27 2004
+++ linux-2.6.5-1a/include/asm-s390/timex.h	Tue Apr 13 17:29:23 2004
@@ -11,7 +11,9 @@
 #ifndef _ASM_S390_TIMEX_H
 #define _ASM_S390_TIMEX_H
 
-#define CLOCK_TICK_RATE	1193180 /* Underlying HZ */
+#include <asm/8253pit.h>
+
+#define CLOCK_TICK_RATE	PIT_TICK_RATE	/* Underlying HZ */
 #define CLOCK_TICK_FACTOR	20	/* Factor of both 1000000 and CLOCK_TICK_RATE */
 #define FINETUNE ((((((long)LATCH * HZ - CLOCK_TICK_RATE) << SHIFT_HZ) * \
 	(1000000/CLOCK_TICK_FACTOR) / (CLOCK_TICK_RATE/CLOCK_TICK_FACTOR)) \
diff -urN linux-2.6.5/include/asm-sh/8253pit.h linux-2.6.5-1a/include/asm-sh/8253pit.h
--- linux-2.6.5/include/asm-sh/8253pit.h	Thu Jan  1 00:00:00 1970
+++ linux-2.6.5-1a/include/asm-sh/8253pit.h	Tue Apr 13 17:30:06 2004
@@ -0,0 +1,10 @@
+/*
+ * 8253/8254 Programmable Interval Timer
+ */
+
+#ifndef _8253PIT_H
+#define _8253PIT_H
+
+#define PIT_TICK_RATE 	1193182UL
+
+#endif
diff -urN linux-2.6.5/include/asm-sparc/8253pit.h linux-2.6.5-1a/include/asm-sparc/8253pit.h
--- linux-2.6.5/include/asm-sparc/8253pit.h	Thu Jan  1 00:00:00 1970
+++ linux-2.6.5-1a/include/asm-sparc/8253pit.h	Tue Apr 13 17:30:31 2004
@@ -0,0 +1,10 @@
+/*
+ * 8253/8254 Programmable Interval Timer
+ */
+
+#ifndef _8253PIT_H
+#define _8253PIT_H
+
+#define PIT_TICK_RATE 	1193180UL
+
+#endif
diff -urN linux-2.6.5/include/asm-sparc/timex.h linux-2.6.5-1a/include/asm-sparc/timex.h
--- linux-2.6.5/include/asm-sparc/timex.h	Thu Dec 18 02:59:05 2003
+++ linux-2.6.5-1a/include/asm-sparc/timex.h	Tue Apr 13 17:31:19 2004
@@ -6,7 +6,9 @@
 #ifndef _ASMsparc_TIMEX_H
 #define _ASMsparc_TIMEX_H
 
-#define CLOCK_TICK_RATE	1193180 /* Underlying HZ */
+#include <asm/8253pit.h>
+
+#define CLOCK_TICK_RATE	PIT_TICK_RATE	/* Underlying HZ */
 #define CLOCK_TICK_FACTOR	20	/* Factor of both 1000000 and CLOCK_TICK_RATE */
 #define FINETUNE ((((((long)LATCH * HZ - CLOCK_TICK_RATE) << SHIFT_HZ) * \
 	(1000000/CLOCK_TICK_FACTOR) / (CLOCK_TICK_RATE/CLOCK_TICK_FACTOR)) \
diff -urN linux-2.6.5/include/asm-sparc64/8253pit.h linux-2.6.5-1a/include/asm-sparc64/8253pit.h
--- linux-2.6.5/include/asm-sparc64/8253pit.h	Thu Jan  1 00:00:00 1970
+++ linux-2.6.5-1a/include/asm-sparc64/8253pit.h	Tue Apr 13 17:31:29 2004
@@ -0,0 +1,10 @@
+/*
+ * 8253/8254 Programmable Interval Timer
+ */
+
+#ifndef _8253PIT_H
+#define _8253PIT_H
+
+#define PIT_TICK_RATE 	1193180UL
+
+#endif
diff -urN linux-2.6.5/include/asm-sparc64/timex.h linux-2.6.5-1a/include/asm-sparc64/timex.h
--- linux-2.6.5/include/asm-sparc64/timex.h	Thu Dec 18 02:58:49 2003
+++ linux-2.6.5-1a/include/asm-sparc64/timex.h	Tue Apr 13 17:32:16 2004
@@ -6,9 +6,10 @@
 #ifndef _ASMsparc64_TIMEX_H
 #define _ASMsparc64_TIMEX_H
 
+#include <asm/8253pit.h>
 #include <asm/timer.h>
 
-#define CLOCK_TICK_RATE	1193180 /* Underlying HZ */
+#define CLOCK_TICK_RATE	PIT_TICK_RATE	/* Underlying HZ */
 #define CLOCK_TICK_FACTOR	20	/* Factor of both 1000000 and CLOCK_TICK_RATE */
 #define FINETUNE ((((((long)LATCH * HZ - CLOCK_TICK_RATE) << SHIFT_HZ) * \
 	(1000000/CLOCK_TICK_FACTOR) / (CLOCK_TICK_RATE/CLOCK_TICK_FACTOR)) \
diff -urN linux-2.6.5/include/asm-um/8253pit.h linux-2.6.5-1a/include/asm-um/8253pit.h
--- linux-2.6.5/include/asm-um/8253pit.h	Thu Jan  1 00:00:00 1970
+++ linux-2.6.5-1a/include/asm-um/8253pit.h	Tue Apr 13 17:32:34 2004
@@ -0,0 +1,10 @@
+/*
+ * 8253/8254 Programmable Interval Timer
+ */
+
+#ifndef _8253PIT_H
+#define _8253PIT_H
+
+#define PIT_TICK_RATE 	1193182UL
+
+#endif
diff -urN linux-2.6.5/include/asm-x86_64/8253pit.h linux-2.6.5-1a/include/asm-x86_64/8253pit.h
--- linux-2.6.5/include/asm-x86_64/8253pit.h	Thu Jan  1 00:00:00 1970
+++ linux-2.6.5-1a/include/asm-x86_64/8253pit.h	Tue Apr 13 17:32:49 2004
@@ -0,0 +1,10 @@
+/*
+ * 8253/8254 Programmable Interval Timer
+ */
+
+#ifndef _8253PIT_H
+#define _8253PIT_H
+
+#define PIT_TICK_RATE 	1193182UL
+
+#endif
diff -urN linux-2.6.5/include/asm-x86_64/timex.h linux-2.6.5-1a/include/asm-x86_64/timex.h
--- linux-2.6.5/include/asm-x86_64/timex.h	Sun Apr 11 14:23:27 2004
+++ linux-2.6.5-1a/include/asm-x86_64/timex.h	Tue Apr 13 17:33:26 2004
@@ -7,11 +7,12 @@
 #define _ASMx8664_TIMEX_H
 
 #include <linux/config.h>
+#include <asm/8253pit.h>
 #include <asm/msr.h>
 #include <asm/vsyscall.h>
 #include <asm/hpet.h>
 
-#define CLOCK_TICK_RATE	1193182 /* Underlying HZ */
+#define CLOCK_TICK_RATE	PIT_TICK_RATE	/* Underlying HZ */
 #define CLOCK_TICK_FACTOR	20	/* Factor of both 1000000 and CLOCK_TICK_RATE */
 #define FINETUNE ((((((int)LATCH * HZ - CLOCK_TICK_RATE) << SHIFT_HZ) * \
 	(1000000/CLOCK_TICK_FACTOR) / (CLOCK_TICK_RATE/CLOCK_TICK_FACTOR)) \
-- 
| Thorsten Kranzkowski        Internet: dl8bcu@dl8bcu.de                      |
| Mobile: ++49 170 1876134       Snail: Kiebitzstr. 14, 49324 Melle, Germany  |
| Ampr: dl8bcu@db0lj.#rpl.deu.eu, dl8bcu@marvin.dl8bcu.ampr.org [44.130.8.19] |

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH] sort out CLOCK_TICK_RATE usage, 2nd try  [2/3]
  2004-04-13 21:59   ` [PATCH] sort out CLOCK_TICK_RATE usage, 2nd try [1/3] Thorsten Kranzkowski
@ 2004-04-13 22:01     ` Thorsten Kranzkowski
  2004-04-13 22:02       ` [PATCH] sort out CLOCK_TICK_RATE usage, 2nd try [3/3] Thorsten Kranzkowski
  0 siblings, 1 reply; 21+ messages in thread
From: Thorsten Kranzkowski @ 2004-04-13 22:01 UTC (permalink / raw)
  To: linux-kernel, rth, spyro, rmk, davidm, paulus, benh, jes, ralf,
	matthew, davem, wesolows, jdike, ak


2/3 	use PIT_TICK_RATE in *spkr.c etc.



diff -urN linux-2.6.5-1a/arch/x86_64/kernel/time.c linux-2.6.5-2a/arch/x86_64/kernel/time.c
--- linux-2.6.5-1a/arch/x86_64/kernel/time.c	Sun Apr 11 14:24:16 2004
+++ linux-2.6.5-2a/arch/x86_64/kernel/time.c	Tue Apr 13 18:03:28 2004
@@ -27,6 +27,7 @@
 #include <linux/sysdev.h>
 #include <linux/bcd.h>
 #include <linux/kallsyms.h>
+#include <asm/8253pit.h>
 #include <asm/pgtable.h>
 #include <asm/vsyscall.h>
 #include <asm/timex.h>
@@ -54,7 +55,7 @@
 unsigned int cpu_khz;					/* TSC clocks / usec, not used here */
 unsigned long hpet_period;				/* fsecs / HPET clock */
 unsigned long hpet_tick;				/* HPET clocks / interrupt */
-unsigned long vxtime_hz = 1193182;
+unsigned long vxtime_hz = PIT_TICK_RATE;
 int report_lost_ticks;				/* command line option */
 unsigned long long monotonic_base;
 
@@ -600,8 +601,8 @@
 	outb((inb(0x61) & ~0x02) | 0x01, 0x61);
 
 	outb(0xb0, 0x43);
-	outb((1193182 / (1000 / 50)) & 0xff, 0x42);
-	outb((1193182 / (1000 / 50)) >> 8, 0x42);
+	outb((PIT_TICK_RATE / (1000 / 50)) & 0xff, 0x42);
+	outb((PIT_TICK_RATE / (1000 / 50)) >> 8, 0x42);
 	rdtscll(start);
 	sync_core();
 	while ((inb(0x61) & 0x20) == 0);
diff -urN linux-2.6.5-1a/drivers/char/vt_ioctl.c linux-2.6.5-2a/drivers/char/vt_ioctl.c
--- linux-2.6.5-1a/drivers/char/vt_ioctl.c	Sun Apr 11 14:24:19 2004
+++ linux-2.6.5-2a/drivers/char/vt_ioctl.c	Tue Apr 13 17:56:07 2004
@@ -25,6 +25,7 @@
 #include <linux/fs.h>
 #include <linux/console.h>
 
+#include <asm/8253pit.h>
 #include <asm/io.h>
 #include <asm/uaccess.h>
 
@@ -391,7 +392,7 @@
 		if (!perm)
 			return -EPERM;
 		if (arg)
-			arg = 1193182 / arg;
+			arg = PIT_TICK_RATE / arg;
 		kd_mksound(arg, 0);
 		return 0;
 
@@ -408,7 +409,7 @@
 		ticks = HZ * ((arg >> 16) & 0xffff) / 1000;
 		count = ticks ? (arg & 0xffff) : 0;
 		if (count)
-			count = 1193182 / count;
+			count = PIT_TICK_RATE / count;
 		kd_mksound(count, ticks);
 		return 0;
 	}
diff -urN linux-2.6.5-1a/drivers/input/gameport/gameport.c linux-2.6.5-2a/drivers/input/gameport/gameport.c
--- linux-2.6.5-1a/drivers/input/gameport/gameport.c	Thu Dec 18 02:58:49 2003
+++ linux-2.6.5-2a/drivers/input/gameport/gameport.c	Tue Apr 13 18:24:47 2004
@@ -10,6 +10,7 @@
  * the Free Software Foundation.
  */
 
+#include <asm/8253pit.h>
 #include <asm/io.h>
 #include <linux/module.h>
 #include <linux/ioport.h>
@@ -37,7 +38,7 @@
 
 #ifdef __i386__
 
-#define DELTA(x,y)      ((y)-(x)+((y)<(x)?1193182/HZ:0))
+#define DELTA(x,y)      ((y)-(x)+((y)<(x)?PIT_TICK_RATE/HZ:0))
 #define GET_TIME(x)     do { x = get_time_pit(); } while (0)
 
 static unsigned int get_time_pit(void)
diff -urN linux-2.6.5-1a/drivers/input/misc/98spkr.c linux-2.6.5-2a/drivers/input/misc/98spkr.c
--- linux-2.6.5-1a/drivers/input/misc/98spkr.c	Thu Dec 18 02:58:17 2003
+++ linux-2.6.5-2a/drivers/input/misc/98spkr.c	Tue Apr 13 18:32:44 2004
@@ -17,6 +17,7 @@
 #include <linux/module.h>
 #include <linux/init.h>
 #include <linux/input.h>
+#include <asm/8253pit.h>
 #include <asm/io.h>
 
 MODULE_AUTHOR("Osamu Tomita <tomita@cinet.co.jp>");
@@ -44,7 +45,7 @@
 	} 
 
 	if (value > 20 && value < 32767)
-		count = CLOCK_TICK_RATE / value;
+		count = PIT_TICK_RATE / value;
 	
 	spin_lock_irqsave(&i8253_beep_lock, flags);
 
diff -urN linux-2.6.5-1a/drivers/input/misc/m68kspkr.c linux-2.6.5-2a/drivers/input/misc/m68kspkr.c
--- linux-2.6.5-1a/drivers/input/misc/m68kspkr.c	Thu Dec 18 02:58:15 2003
+++ linux-2.6.5-2a/drivers/input/misc/m68kspkr.c	Tue Apr 13 17:58:30 2004
@@ -17,6 +17,7 @@
 #include <linux/module.h>
 #include <linux/init.h>
 #include <linux/input.h>
+#include <asm/8253pit.h>
 #include <asm/machdep.h>
 #include <asm/io.h>
 
@@ -42,7 +43,7 @@
 	}
 
 	if (value > 20 && value < 32767)
-		count = 1193182 / value;
+		count = PIT_TICK_RATE / value;
 
 	mach_beep(count, -1);
 
diff -urN linux-2.6.5-1a/drivers/input/misc/pcspkr.c linux-2.6.5-2a/drivers/input/misc/pcspkr.c
--- linux-2.6.5-1a/drivers/input/misc/pcspkr.c	Thu Dec 18 02:58:57 2003
+++ linux-2.6.5-2a/drivers/input/misc/pcspkr.c	Tue Apr 13 17:59:41 2004
@@ -16,6 +16,7 @@
 #include <linux/module.h>
 #include <linux/init.h>
 #include <linux/input.h>
+#include <asm/8253pit.h>
 #include <asm/io.h>
 
 MODULE_AUTHOR("Vojtech Pavlik <vojtech@ucw.cz>");
@@ -43,7 +44,7 @@
 	} 
 
 	if (value > 20 && value < 32767)
-		count = CLOCK_TICK_RATE / value;
+		count = PIT_TICK_RATE / value;
 	
 	spin_lock_irqsave(&i8253_beep_lock, flags);
 

-- 
| Thorsten Kranzkowski        Internet: dl8bcu@dl8bcu.de                      |
| Mobile: ++49 170 1876134       Snail: Kiebitzstr. 14, 49324 Melle, Germany  |
| Ampr: dl8bcu@db0lj.#rpl.deu.eu, dl8bcu@marvin.dl8bcu.ampr.org [44.130.8.19] |

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH] sort out CLOCK_TICK_RATE usage, 2nd try  [3/3]
  2004-04-13 22:01     ` [PATCH] sort out CLOCK_TICK_RATE usage, 2nd try [2/3] Thorsten Kranzkowski
@ 2004-04-13 22:02       ` Thorsten Kranzkowski
  2004-04-13 22:39         ` Randy.Dunlap
  0 siblings, 1 reply; 21+ messages in thread
From: Thorsten Kranzkowski @ 2004-04-13 22:02 UTC (permalink / raw)
  To: linux-kernel, rth, spyro, rmk, davidm, paulus, benh, jes, ralf,
	matthew, davem, wesolows, jdike, ak


3/3	use CLOCK_TICK_RATE where 1193182 constant was used in timing 
	calculations



diff -urN linux-2.6.5-2a/drivers/input/joystick/analog.c linux-2.6.5-3a/drivers/input/joystick/analog.c
--- linux-2.6.5-2a/drivers/input/joystick/analog.c	Sun Apr 11 14:24:48 2004
+++ linux-2.6.5-3a/drivers/input/joystick/analog.c	Tue Apr 13 18:38:03 2004
@@ -142,7 +142,7 @@
 
 #ifdef __i386__
 #define GET_TIME(x)	do { if (cpu_has_tsc) rdtscl(x); else x = get_time_pit(); } while (0)
-#define DELTA(x,y)	(cpu_has_tsc?((y)-(x)):((x)-(y)+((x)<(y)?1193182L/HZ:0)))
+#define DELTA(x,y)	(cpu_has_tsc?((y)-(x)):((x)-(y)+((x)<(y)?CLOCK_TICK_RATE/HZ:0)))
 #define TIME_NAME	(cpu_has_tsc?"TSC":"PIT")
 static unsigned int get_time_pit(void)
 {
diff -urN linux-2.6.5-2a/sound/oss/pas2_pcm.c linux-2.6.5-3a/sound/oss/pas2_pcm.c
--- linux-2.6.5-2a/sound/oss/pas2_pcm.c	Thu Dec 18 02:58:28 2003
+++ linux-2.6.5-3a/sound/oss/pas2_pcm.c	Tue Apr 13 18:39:22 2004
@@ -17,6 +17,7 @@
 
 #include <linux/init.h>
 #include <linux/spinlock.h>
+#include <asm/timex.h>
 #include "sound_config.h"
 
 #include "pas2.h"
@@ -62,13 +63,13 @@
 
 	if (pcm_channels & 2)
 	{
-		foo = (596590 + (arg / 2)) / arg;
-		arg = (596590 + (foo / 2)) / foo;
+		foo = ((CLOCK_TICK_RATE/2) + (arg / 2)) / arg;
+		arg = ((CLOCK_TICK_RATE/2) + (foo / 2)) / foo;
 	}
 	else
 	{
-		foo = (1193180 + (arg / 2)) / arg;
-		arg = (1193180 + (foo / 2)) / foo;
+		foo = (CLOCK_TICK_RATE + (arg / 2)) / arg;
+		arg = (CLOCK_TICK_RATE + (foo / 2)) / foo;
 	}
 
 	pcm_speed = arg;

-- 
| Thorsten Kranzkowski        Internet: dl8bcu@dl8bcu.de                      |
| Mobile: ++49 170 1876134       Snail: Kiebitzstr. 14, 49324 Melle, Germany  |
| Ampr: dl8bcu@db0lj.#rpl.deu.eu, dl8bcu@marvin.dl8bcu.ampr.org [44.130.8.19] |

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH] sort out CLOCK_TICK_RATE usage, 2nd try  [3/3]
  2004-04-13 22:02       ` [PATCH] sort out CLOCK_TICK_RATE usage, 2nd try [3/3] Thorsten Kranzkowski
@ 2004-04-13 22:39         ` Randy.Dunlap
  0 siblings, 0 replies; 21+ messages in thread
From: Randy.Dunlap @ 2004-04-13 22:39 UTC (permalink / raw)
  To: dl8bcu
  Cc: linux-kernel, rth, spyro, rmk, davidm, paulus, benh, jes, ralf,
	matthew, davem, wesolows, jdike, ak


General comment:  diffstat -p1 patch_file
would be a good addition.


On Tue, 13 Apr 2004 22:02:30 +0000 Thorsten Kranzkowski wrote:

| 
| 3/3	use CLOCK_TICK_RATE where 1193182 constant was used in timing 
| 	calculations
| 
| 
| diff -urN linux-2.6.5-2a/drivers/input/joystick/analog.c linux-2.6.5-3a/drivers/input/joystick/analog.c
| --- linux-2.6.5-2a/drivers/input/joystick/analog.c	Sun Apr 11 14:24:48 2004
| +++ linux-2.6.5-3a/drivers/input/joystick/analog.c	Tue Apr 13 18:38:03 2004
| @@ -142,7 +142,7 @@
|  
|  #ifdef __i386__
|  #define GET_TIME(x)	do { if (cpu_has_tsc) rdtscl(x); else x = get_time_pit(); } while (0)
| -#define DELTA(x,y)	(cpu_has_tsc?((y)-(x)):((x)-(y)+((x)<(y)?1193182L/HZ:0)))
| +#define DELTA(x,y)	(cpu_has_tsc?((y)-(x)):((x)-(y)+((x)<(y)?CLOCK_TICK_RATE/HZ:0)))
|  #define TIME_NAME	(cpu_has_tsc?"TSC":"PIT")
|  static unsigned int get_time_pit(void)
|  {

* Add spaces around operators please.  It's much more readable
that way.

| diff -urN linux-2.6.5-2a/sound/oss/pas2_pcm.c linux-2.6.5-3a/sound/oss/pas2_pcm.c
| --- linux-2.6.5-2a/sound/oss/pas2_pcm.c	Thu Dec 18 02:58:28 2003
| +++ linux-2.6.5-3a/sound/oss/pas2_pcm.c	Tue Apr 13 18:39:22 2004
| @@ -62,13 +63,13 @@
|  
|  	if (pcm_channels & 2)
|  	{
| -		foo = (596590 + (arg / 2)) / arg;
| -		arg = (596590 + (foo / 2)) / foo;
| +		foo = ((CLOCK_TICK_RATE/2) + (arg / 2)) / arg;
| +		arg = ((CLOCK_TICK_RATE/2) + (foo / 2)) / foo;

* Add spaces around operators, as:     ((CLOCK_TICK_RATE / 2)


And finally, does this change support (or allow) CLOCK_TICK_RATE
to be a variable instead of a #define?

as in include/asm-i386/mach-pc9800/setup_arch_pre.h:
int CLOCK_TICK_RATE;

and include/asm-i386/timex.h:
#ifdef CONFIG_X86_PC9800
   extern int CLOCK_TICK_RATE;

More likely (IMO), X86_PC9800 sub-arch will have to be changed
(if it ever works).

--
~Randy

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH][RFC] sort out CLOCK_TICK_RATE usage [1/3]
  2004-04-13 17:00             ` Thorsten Kranzkowski
@ 2004-04-14  1:45               ` Miles Bader
  0 siblings, 0 replies; 21+ messages in thread
From: Miles Bader @ 2004-04-14  1:45 UTC (permalink / raw)
  To: dl8bcu
  Cc: davidm, linux-kernel, rth, spyro, rmk, paulus, benh, jes, ralf,
	matthew, davem, wesolows, jdike, ak

Thorsten Kranzkowski <dl8bcu@dl8bcu.de> writes:
> 	config INPUT_PCSPKR
> 		tristate "PC Speaker support"
> 		depends on INPUT && INPUT_MISC
> 
> I'm by no means a Kconfig expert, but I read this as there's nothing 
> that prevents you to select INPUT_PCSPKR on every architecture.

Indeed, but the code (pcspkr.c) looks completely non-portable, e.g.:

   outb_p(inb_p(0x61) | 3, 0x61);

[no comment]

So I'd guess that the Kconfig file should have more dependencies added;
what they are I have no idea.  [I guess it has something to do with old
ISA-bus-compatibility stuff.]

> > anywhere, and don't even know what an 8253 is... [so it would be damn
> > silly to have <asm/8253pit.h> as a required header!]
> 
> Ok, I won't create one, then. (just to be shure: asm-v850, right?) 

Yeah, v850.  I'd think you shouldn't do it for any arch except those
you know actually support this stuff.

-Miles
-- 
"Unless there are slaves to do the ugly, horrible, uninteresting work, culture
and contemplation become almost impossible. Human slavery is wrong, insecure,
and demoralizing.  On mechanical slavery, on the slavery of the machine, the
future of the world depends." -Oscar Wilde, "The Soul of Man Under Socialism"

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH] sort out CLOCK_TICK_RATE usage, 2nd try  [0/3]
  2004-04-13 21:58 ` [PATCH] sort out CLOCK_TICK_RATE usage, 2nd try [0/3] Thorsten Kranzkowski
  2004-04-13 21:59   ` [PATCH] sort out CLOCK_TICK_RATE usage, 2nd try [1/3] Thorsten Kranzkowski
@ 2004-04-14 14:12   ` Matthew Wilcox
  2004-04-16  9:05     ` Geert Uytterhoeven
  1 sibling, 1 reply; 21+ messages in thread
From: Matthew Wilcox @ 2004-04-14 14:12 UTC (permalink / raw)
  To: linux-kernel, rth, spyro, rmk, davidm, paulus, benh, jes, ralf,
	matthew, davem, wesolows, jdike, ak

On Tue, Apr 13, 2004 at 09:58:33PM +0000, Thorsten Kranzkowski wrote:
> Arch maintainers please have a look whether I got the constants right or
> if your architecture has a PIC or speaker at all.

parisc certainly doesn't.  i'd start by making this change for alpha,
x86 and x86_64 and make the PC speaker depend on (ALPHA || X86 || X86_64)
then other arches can take it from there if they want to supoprt the
pc speaker.

-- 
"Next the statesmen will invent cheap lies, putting the blame upon 
the nation that is attacked, and every man will be glad of those
conscience-soothing falsities, and will diligently study them, and refuse
to examine any refutations of them; and thus he will by and by convince 
himself that the war is just, and will thank God for the better sleep 
he enjoys after this process of grotesque self-deception." -- Mark Twain

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH] sort out CLOCK_TICK_RATE usage, 2nd try  [0/3]
  2004-04-14 14:12   ` [PATCH] sort out CLOCK_TICK_RATE usage, 2nd try [0/3] Matthew Wilcox
@ 2004-04-16  9:05     ` Geert Uytterhoeven
  0 siblings, 0 replies; 21+ messages in thread
From: Geert Uytterhoeven @ 2004-04-16  9:05 UTC (permalink / raw)
  To: Thorsten Kranzkowski
  Cc: Linux Kernel Development, rth, spyro, Russell King, davidm,
	paulus, Benjamin Herrenschmidt, Jes Sorensen, ralf, matthew,
	David S. Miller, wesolows, jdike, ak, Matthew Wilcox

On Wed, 14 Apr 2004, Matthew Wilcox wrote:
> On Tue, Apr 13, 2004 at 09:58:33PM +0000, Thorsten Kranzkowski wrote:
> > Arch maintainers please have a look whether I got the constants right or
> > if your architecture has a PIC or speaker at all.
>
> parisc certainly doesn't.  i'd start by making this change for alpha,
> x86 and x86_64 and make the PC speaker depend on (ALPHA || X86 || X86_64)
> then other arches can take it from there if they want to supoprt the
> pc speaker.

M68k has m68kspkr, which beeps through the m68k beep abstraction.

The only reason there's a 1193182 in drivers/input/misc/m68kspkr.c is for
userspace compatibility with ia32. So please don't introduce
include/asm-m68k/8253pit.h and keep CLOCK_TICK_RATE for m68k like it is.

Gr{oetje,eeting}s,

						Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
							    -- Linus Torvalds

^ permalink raw reply	[flat|nested] 21+ messages in thread

end of thread, other threads:[~2004-04-16  9:25 UTC | newest]

Thread overview: 21+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-04-12  7:55 [PATCH][RFC] sort out CLOCK_TICK_RATE usage [0/3] Thorsten Kranzkowski
2004-04-12  7:57 ` [PATCH][RFC] sort out CLOCK_TICK_RATE usage [1/3] Thorsten Kranzkowski
2004-04-12  7:57   ` [PATCH][RFC] sort out CLOCK_TICK_RATE usage [2/3] Thorsten Kranzkowski
2004-04-12  7:58     ` [PATCH][RFC] sort out CLOCK_TICK_RATE usage [3/3] Thorsten Kranzkowski
2004-04-12 16:39   ` [PATCH][RFC] sort out CLOCK_TICK_RATE usage [1/3] David Mosberger
2004-04-12 20:08     ` Thorsten Kranzkowski
2004-04-12 20:32       ` David Mosberger
2004-04-12 21:17         ` Thorsten Kranzkowski
2004-04-13  4:04           ` Miles Bader
2004-04-13 17:00             ` Thorsten Kranzkowski
2004-04-14  1:45               ` Miles Bader
2004-04-12 16:47 ` [PATCH][RFC] sort out CLOCK_TICK_RATE usage [0/3] Zwane Mwaikambo
2004-04-12 20:11   ` Thorsten Kranzkowski
2004-04-12 20:50     ` Zwane Mwaikambo
2004-04-13 21:58 ` [PATCH] sort out CLOCK_TICK_RATE usage, 2nd try [0/3] Thorsten Kranzkowski
2004-04-13 21:59   ` [PATCH] sort out CLOCK_TICK_RATE usage, 2nd try [1/3] Thorsten Kranzkowski
2004-04-13 22:01     ` [PATCH] sort out CLOCK_TICK_RATE usage, 2nd try [2/3] Thorsten Kranzkowski
2004-04-13 22:02       ` [PATCH] sort out CLOCK_TICK_RATE usage, 2nd try [3/3] Thorsten Kranzkowski
2004-04-13 22:39         ` Randy.Dunlap
2004-04-14 14:12   ` [PATCH] sort out CLOCK_TICK_RATE usage, 2nd try [0/3] Matthew Wilcox
2004-04-16  9:05     ` Geert Uytterhoeven

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®