patch-2.1.97 linux/include/asm-ppc/keyboard.h

Next file: linux/include/asm-ppc/kgdb.h
Previous file: linux/include/asm-ppc/irq.h
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.1.96/linux/include/asm-ppc/keyboard.h linux/include/asm-ppc/keyboard.h
@@ -16,8 +16,11 @@
 #ifdef __KERNEL__
 
 #include <linux/config.h>
+#include <asm/adb.h>
 
-#ifdef CONFIG_MAC_KEYBOARD
+#define KEYBOARD_IRQ			1
+#define DISABLE_KBD_DURING_INTERRUPTS	0
+#define INIT_KBD
 
 extern int mackbd_setkeycode(unsigned int scancode, unsigned int keycode);
 extern int mackbd_getkeycode(unsigned int scancode);
@@ -28,19 +31,6 @@
 extern void mackbd_leds(unsigned char leds);
 extern void mackbd_init_hw(void);
 
-#define kbd_setkeycode		mackbd_setkeycode
-#define kbd_getkeycode		mackbd_getkeycode
-#define kbd_pretranslate	mackbd_pretranslate
-#define kbd_translate		mackbd_translate
-#define kbd_unexpected_up	mackbd_unexpected_up
-#define kbd_leds		mackbd_leds
-#define kbd_init_hw		mackbd_init_hw
-
-#else /* CONFIG_MAC_KEYBOARD */
-
-#define KEYBOARD_IRQ			1
-#define DISABLE_KBD_DURING_INTERRUPTS	0
-
 extern int pckbd_setkeycode(unsigned int scancode, unsigned int keycode);
 extern int pckbd_getkeycode(unsigned int scancode);
 extern int pckbd_pretranslate(unsigned char scancode, char raw_mode);
@@ -50,16 +40,133 @@
 extern void pckbd_leds(unsigned char leds);
 extern void pckbd_init_hw(void);
 
-#define kbd_setkeycode		pckbd_setkeycode
-#define kbd_getkeycode		pckbd_getkeycode
-#define kbd_pretranslate	pckbd_pretranslate
-#define kbd_translate		pckbd_translate
-#define kbd_unexpected_up	pckbd_unexpected_up
-#define kbd_leds		pckbd_leds
-#define kbd_init_hw		pckbd_init_hw
-
-#define INIT_KBD
-#endif /* CONFIG_MAC_KEYBOARD */
+static inline int kbd_setkeycode(unsigned int scancode, unsigned int keycode)
+{
+	if ( is_prep )
+		return pckbd_setkeycode(scancode,keycode);
+	else if ( is_chrp )
+#ifndef CONFIG_MAC_KEYBOARD
+		return pckbd_setkeycode(scancode,keycode);
+#else
+		/* I'm not actually sure if it's legal to have a CHRP machine
+		 * without an ADB controller. In any case, this should really
+		 * be changed to be a test to see if an ADB _keyboard_ exists
+		 * (not just a controller), but that's another story for
+		 * another night.
+		 */
+		if ( adb_hardware == ADB_NONE )
+			return pckbd_setkeycode(scancode,keycode);
+		else
+			return mackbd_setkeycode(scancode,keycode);
+#endif
+	else
+		return mackbd_setkeycode(scancode,keycode);
+}
+
+static inline int kbd_getkeycode(unsigned int x)
+{
+	if ( is_prep )
+		return pckbd_getkeycode(x);
+	else if ( is_chrp )
+#ifndef CONFIG_MAC_KEYBOARD
+		return pckbd_getkeycode(x);
+#else
+		if ( adb_hardware == ADB_NONE )
+			return pckbd_getkeycode(x);
+		else
+			return mackbd_getkeycode(x);
+#endif
+	else
+		return mackbd_getkeycode(x);
+}
+
+static inline int kbd_pretranslate(unsigned char x,char y)
+{
+	if ( is_prep )
+		return pckbd_pretranslate(x,y);
+	else if ( is_chrp )
+#ifndef CONFIG_MAC_KEYBOARD
+		return pckbd_pretranslate(x,y);
+#else
+		if ( adb_hardware == ADB_NONE )
+			return pckbd_pretranslate(x,y);
+		else
+			return mackbd_pretranslate(x,y);
+#endif
+	else
+		return mackbd_pretranslate(x,y);
+}
+
+static inline int kbd_translate(unsigned char keycode, unsigned char *keycodep,
+		     char raw_mode)
+{
+	if ( is_prep )
+		return pckbd_translate(keycode,keycodep,raw_mode);
+	else if ( is_chrp )
+#ifndef CONFIG_MAC_KEYBOARD
+		return pckbd_translate(keycode,keycodep,raw_mode);
+#else
+		if ( adb_hardware == ADB_NONE )
+			return pckbd_translate(keycode,keycodep,raw_mode);
+		else
+			return mackbd_translate(keycode,keycodep,raw_mode);
+#endif
+	else
+		return mackbd_translate(keycode,keycodep,raw_mode);
+	
+}
+
+static inline int kbd_unexpected_up(unsigned char keycode)
+{
+	if ( is_prep )
+		return pckbd_unexpected_up(keycode);
+	else if ( is_chrp )
+#ifndef CONFIG_MAC_KEYBOARD
+		return pckbd_unexpected_up(keycode);
+#else
+		if ( adb_hardware == ADB_NONE )
+			return pckbd_unexpected_up(keycode);
+		else
+			return mackbd_unexpected_up(keycode);
+#endif
+	else
+		return mackbd_unexpected_up(keycode);
+	
+}
+
+static inline void kbd_leds(unsigned char leds)
+{
+	if ( is_prep )
+		pckbd_leds(leds);
+	else if ( is_chrp )
+#ifndef CONFIG_MAC_KEYBOARD
+		pckbd_leds(leds);
+#else
+		if ( adb_hardware == ADB_NONE )
+			pckbd_leds(leds);
+		else
+			mackbd_leds(leds);
+#endif
+	else
+		mackbd_leds(leds);
+}
+
+static inline void kbd_init_hw(void)
+{
+	if ( is_prep )
+		pckbd_init_hw();
+	else if ( is_chrp )
+#ifndef CONFIG_MAC_KEYBOARD
+		pckbd_init_hw();
+#else
+		if ( adb_hardware == ADB_NONE )
+			pckbd_init_hw();
+		else
+			mackbd_init_hw();
+#endif
+	else
+		mackbd_init_hw();
+}
 
 #endif /* __KERNEL__ */
 

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen, slshen@lbl.gov