Resent-Date: Wed, 23 Jun 1999 13:27:41 +0200 (MET DST)
Date: Wed, 23 Jun 1999 06:27:17 -0500
From: Chris Lawrence <quango@watervalley.net>
To: Linux/m68k Mailing List <linux-m68k@lists.linux-m68k.org>,
        Linux/APUS Mailing List <linux-apus@sunsite.auc.dk>
Cc: Jes Sorensen <Jes.Sorensen@cern.ch>
Subject: Re: Heartbeat disable patch for 2.2.8 (APUS and m68k/Amiga)
Mail-Followup-To: Linux/m68k Mailing List <linux-m68k@lists.linux-m68k.org>,
	Linux/APUS Mailing List <linux-apus@sunsite.auc.dk>,
	Jes Sorensen <Jes.Sorensen@cern.ch>
References: <19990623062353.A291@quango2.watervalley.net>
In-Reply-To: <19990623062353.A291@quango2.watervalley.net>; from Chris Lawrence on Wed, Jun 23, 1999 at 06:23:53AM -0500
Organization: Kathie Lee's Sweatshops
X-Operating-System: Linux/ppc 2.2.8
Resent-From: linux-m68k@phil.uni-sb.de

On Jun 23, Chris Lawrence wrote:
> Here's a patch relative to 2.2.8 which disables the Amiga's heartbeat
> when any sound device is open...

Guess who isn't awake this morning.  The patch follows...

diff -urN --exclude-from=exclude-list linux-apus-2.2.8/arch/m68k/kernel/m68k_ksyms.c linux/arch/m68k/kernel/m68k_ksyms.c
--- linux-apus-2.2.8/arch/m68k/kernel/m68k_ksyms.c	Sun Jun  6 21:44:06 1999
+++ linux/arch/m68k/kernel/m68k_ksyms.c	Wed Jun 23 03:16:20 1999
@@ -61,6 +61,11 @@
 /* Networking helper routines. */
 EXPORT_SYMBOL(csum_partial_copy);
 
+#ifdef CONFIG_HEARTBEAT
+EXPORT_SYMBOL(enable_heartbeat);
+EXPORT_SYMBOL(disable_heartbeat);
+#endif
+
 /* The following are special because they're not called
    explicitly (the C compiler generates them).  Fortunately,
    their interface isn't gonna change any time soon now, so
diff -urN --exclude-from=exclude-list linux-apus-2.2.8/arch/m68k/kernel/time.c linux/arch/m68k/kernel/time.c
--- linux-apus-2.2.8/arch/m68k/kernel/time.c	Sun Jun  6 21:43:18 1999
+++ linux/arch/m68k/kernel/time.c	Wed Jun 23 03:36:54 1999
@@ -23,6 +23,9 @@
 
 #include <linux/timex.h>
 
+#ifdef CONFIG_HEARTBEAT
+static int heartbeat_enabled = 1;
+#endif
 
 static inline int set_rtc_mmss(unsigned long nowtime)
 {
@@ -81,7 +84,7 @@
 	/* use power LED as a heartbeat instead -- much more useful
 	   for debugging -- based on the version for PReP by Cort */
 	/* acts like an actual heart beat -- ie thump-thump-pause... */
-	if (mach_heartbeat) {
+	if (mach_heartbeat && heartbeat_enabled) {
 	    static unsigned cnt = 0, period = 0, dist = 0;
 
 	    if (cnt == 0 || cnt == dist)
@@ -101,6 +104,19 @@
 	}
 #endif /* CONFIG_HEARTBEAT */
 }
+
+#ifdef CONFIG_HEARTBEAT
+void enable_heartbeat(void)
+{
+	heartbeat_enabled = 1;
+}
+
+void disable_heartbeat(void)
+{
+	heartbeat_enabled = 0;
+	mach_heartbeat(0);
+}
+#endif
 
 /* Converts Gregorian date to seconds since 1970-01-01 00:00:00.
  * Assumes input in normal date format, i.e. 1980-12-31 23:59:59
diff -urN --exclude-from=exclude-list linux-apus-2.2.8/arch/ppc/kernel/ppc_ksyms.c linux/arch/ppc/kernel/ppc_ksyms.c
--- linux-apus-2.2.8/arch/ppc/kernel/ppc_ksyms.c	Sun Jun  6 21:47:54 1999
+++ linux/arch/ppc/kernel/ppc_ksyms.c	Wed Jun 23 03:15:44 1999
@@ -226,7 +226,11 @@
 #endif /* CONFIG_APUS */
 
 EXPORT_SYMBOL(abs);
-EXPORT_SYMBOL(device_is_compatible);
+
+#ifdef CONFIG_HEARTBEAT
+EXPORT_SYMBOL(enable_heartbeat);
+EXPORT_SYMBOL(disable_heartbeat);
+#endif
 
 /* The following are special because they're not called
    explicitly (the C compiler generates them).  Fortunately,
diff -urN --exclude-from=exclude-list linux-apus-2.2.8/arch/ppc/kernel/time.c linux/arch/ppc/kernel/time.c
--- linux-apus-2.2.8/arch/ppc/kernel/time.c	Sun Jun  6 21:44:07 1999
+++ linux/arch/ppc/kernel/time.c	Wed Jun 23 03:37:20 1999
@@ -63,6 +63,10 @@
 unsigned count_period_num;	/* 1 decrementer count equals */
 unsigned count_period_den;	/* count_period_num / count_period_den us */
 
+#ifdef CONFIG_HEARTBEAT
+static int heartbeat_enabled = 1;
+#endif
+
 /*
  * timer_interrupt - gets called when the decrementer overflows,
  * with interrupts disabled.
@@ -127,7 +131,8 @@
 #endif		
 
 	/* Fixme - make this more generic - Corey */
-#ifdef CONFIG_APUS
+#if defined(CONFIG_APUS) && defined(CONFIG_HEARTBEAT)
+        if( heartbeat_enabled )
 	{
 		extern void apus_heartbeat (void);
 		apus_heartbeat ();
@@ -135,6 +140,19 @@
 #endif
 	hardirq_exit(cpu);
 }
+
+#ifdef CONFIG_HEARTBEAT
+void enable_heartbeat(void)
+{
+	heartbeat_enabled = 1;
+}
+
+void disable_heartbeat(void)
+{
+	heartbeat_enabled = 0;
+	mach_heartbeat(0);
+}
+#endif
 
 /*
  * This version of gettimeofday has microsecond resolution.
diff -urN --exclude-from=exclude-list linux-apus-2.2.8/drivers/sound/dmasound.c linux/drivers/sound/dmasound.c
--- linux-apus-2.2.8/drivers/sound/dmasound.c	Sun Jun  6 21:47:54 1999
+++ linux/drivers/sound/dmasound.c	Wed Jun 23 04:01:35 1999
@@ -121,6 +121,7 @@
 
 #include "dmasound.h"
 #include <linux/soundcard.h>
+#include <asm/machdep.h>
 
 #define HAS_8BIT_TABLES
 
@@ -845,6 +846,7 @@
 
 /*** Common stuff ********************************************************/
 
+static void check_heartbeat(void);
 static long long sound_lseek(struct file *file, long long offset, int orig);
 static inline int ioctl_return(int *addr, int value)
 {
@@ -3795,6 +3797,7 @@
 {
 	MOD_INC_USE_COUNT;
 	mixer.busy = 1;
+	check_heartbeat();
 	return 0;
 }
 
@@ -3802,6 +3805,7 @@
 static int mixer_release(struct inode *inode, struct file *file)
 {
 	mixer.busy = 0;
+	check_heartbeat();
 	MOD_DEC_USE_COUNT;
 	return 0;
 }
@@ -4223,6 +4227,7 @@
 	mixer.busy = 0;
 	sound.treble = 0;
 	sound.bass = 0;
+	check_heartbeat();
 	switch (sound.mach.type) {
 #ifdef CONFIG_ATARI
 	case DMASND_TT:
@@ -4428,6 +4433,7 @@
 		rc = 0;
 	}
 	sq.busy = 1;
+	check_heartbeat();
 	rc = sq_allocate_buffers();
 	if (rc)
 		goto err_out_nobusy;
@@ -4448,6 +4454,7 @@
 	return 0;
 err_out_nobusy:
 	sq.busy = 0;
+	check_heartbeat();
 	WAKE_UP(sq.open_queue);
 err_out:
 	MOD_DEC_USE_COUNT;
@@ -4500,6 +4507,7 @@
 	MOD_DEC_USE_COUNT;
 
 	sq.busy = 0;
+	check_heartbeat();
 	WAKE_UP(sq.open_queue);
 	/* Wake up a process waiting for the queue being released.
 	 * Note: There may be several processes waiting for a call
@@ -4625,6 +4633,7 @@
 
 	sq.write_queue = sq.open_queue = sq.sync_queue = 0;
 	sq.busy = 0;
+	check_heartbeat();
 
 	/* whatever you like as startup mode for /dev/dsp,
 	 * (/dev/audio hasn't got a startup mode). note that
@@ -4681,6 +4690,7 @@
 	MOD_INC_USE_COUNT;
 	state.ptr = 0;
 	state.busy = 1;
+	check_heartbeat();
 
 	switch (sound.mach.type) {
 #ifdef CONFIG_ATARI
@@ -4777,6 +4787,7 @@
 static int state_release(struct inode *inode, struct file *file)
 {
 	state.busy = 0;
+	check_heartbeat();
 	MOD_DEC_USE_COUNT;
 	return 0;
 }
@@ -4821,6 +4832,22 @@
 	if (state_unit < 0)
 		return;
 	state.busy = 0;
+	check_heartbeat();
+}
+
+/* Disable heartbeat on the Amiga when device is in use, because the LED
+   blinking also fools with the low-pass filter. */
+
+static void check_heartbeat(void)
+{
+#if defined(CONFIG_HEARTBEAT) && defined(CONFIG_AMIGA)
+	if( sound.mach.type == DMASND_AMIGA ) {
+		if( state.busy || mixer.busy || sq.busy )
+			disable_heartbeat();
+		else
+			enable_heartbeat();
+	}
+#endif
 }
 
 
diff -urN --exclude-from=exclude-list linux-apus-2.2.8/include/asm-m68k/machdep.h linux/include/asm-m68k/machdep.h
--- linux-apus-2.2.8/include/asm-m68k/machdep.h	Mon Jan 11 08:20:39 1999
+++ linux/include/asm-m68k/machdep.h	Wed Jun 23 03:17:37 1999
@@ -42,4 +42,9 @@
 extern int mach_sysrq_shift_mask;
 extern char *mach_sysrq_xlate;
 
+#ifdef CONFIG_HEARTBEAT
+extern void enable_heartbeat(void);
+extern void disable_heartbeat(void);
+#endif
+
 #endif /* _M68K_MACHDEP_H */



Chris
-- 
=============================================================================
|          Chris Lawrence         |       Get your Debian 2.1 CD-ROMs       |
|     <quango@watervalley.net>    |        http://www.lordsutch.com/        |
|                                 |                                         |
|     Grad Student, Pol. Sci.     |     Do you want your bank to snoop?     |
|    University of Mississippi    |    http://www.defendyourprivacy.com/    |
=============================================================================

