diff -ru linux-2.1.103/arch/ppc/config.in linux-2.1.103-macx-mouse-merge/arch/ppc/config.in --- linux-2.1.103/arch/ppc/config.in Sun May 31 20:04:16 1998 +++ linux-2.1.103-macx-mouse-merge/arch/ppc/config.in Sat Sep 19 21:15:10 1998 @@ -62,6 +62,7 @@ bool 'Sysctl support' CONFIG_SYSCTL bool 'System V IPC' CONFIG_SYSVIPC bool 'BSD Process Accounting' CONFIG_BSD_PROCESS_ACCT +bool 'Apple Desktop Bus Accounting' CONFIG_ADB_ACCT # only elf supported, a.out is not -- Cort define_bool CONFIG_BINFMT_ELF y @@ -107,6 +108,10 @@ bool 'Support for PowerMac serial ports' CONFIG_MAC_SERIAL if [ "$CONFIG_EXPERIMENTAL" = "y" ]; then bool 'Support for PowerMac mouse (EXPERIMENTAL)' CONFIG_MACMOUSE + bool 'Support for MacX 3 Button mouse (EXPERIMENTAL)' CONFIG_MACX_MOUSE + if [ "$CONFIG_MACX_MOUSE" = "y" ]; then + bool 'MacX mouse driver printk debugging' CONFIG_MACX_MOUSE_DEBUG + fi fi bool 'Support for Open Firmware device tree in /proc' CONFIG_PROC_DEVICETREE bool 'Include kgdb kernel debugger' CONFIG_KGDB diff -ru linux-2.1.103/arch/ppc/pmac_defconfig linux-2.1.103-macx-mouse-merge/arch/ppc/pmac_defconfig --- linux-2.1.103/arch/ppc/pmac_defconfig Sun May 31 19:59:55 1998 +++ linux-2.1.103-macx-mouse-merge/arch/ppc/pmac_defconfig Sat Sep 19 21:15:10 1998 @@ -41,6 +41,7 @@ CONFIG_MAC_FLOPPY=y CONFIG_MAC_SERIAL=y CONFIG_MACMOUSE=y +# CONFIG_MACX_MOUSE is not set CONFIG_PROC_DEVICETREE=y # CONFIG_KGDB is not set # CONFIG_XMON is not set diff -ru linux-2.1.103/drivers/macintosh/adb.c linux-2.1.103-macx-mouse-merge/drivers/macintosh/adb.c --- linux-2.1.103/drivers/macintosh/adb.c Mon May 4 22:55:55 1998 +++ linux-2.1.103-macx-mouse-merge/drivers/macintosh/adb.c Sat Sep 19 21:15:10 1998 @@ -19,6 +19,10 @@ #include #include +#ifdef CONFIG_ADB_ACCT +#include +#endif + enum adb_hw adb_hardware = ADB_NONE; int (*adb_send_request)(struct adb_request *req, int sync); int (*adb_autopoll)(int on); @@ -28,6 +32,10 @@ void (*handler)(unsigned char *, int, struct pt_regs *, int); int original_address; int handler_id; +#ifdef CONFIG_ADB_ACCT + unsigned int inp; + unsigned int outp; +#endif } adb_handler[16]; __openfirmware @@ -37,6 +45,7 @@ return -1; } + #if 0 static void printADBreply(struct adb_request *req) { @@ -138,6 +147,33 @@ printk("\n"); } +#ifdef CONFIG_ADB_ACCT +int adb_proc_read_devices(char *buf, char **start, off_t offset, + int len, int unused){ + + int i; + len = 0; + len += sprintf(buf+len, + "Dev ID\tOrig ID\tHandler ID\tIN\tOUT\tHandler func\n"); + for ( i = 0 ; i < 16 ; i++) + len += sprintf(buf+len, + " %d \t%d \t%d \t%u\tNA\t0x%x\n", + i, adb_handler[i].original_address, adb_handler[i].handler_id, + adb_handler[i].inp,/*adb_handler[i].outp,*/adb_handler[i].handler); + return len; +} + +struct proc_dir_entry adb_proc_entry = { + 0, + 11, "adb-devices", + S_IFREG | S_IRUGO, + 1,0,0, + 0, + NULL, + &adb_proc_read_devices, +}; +#endif /*CONFIG_ADB_ACCT*/ + void adb_init(void) { adb_send_request = (void *) adb_nodev; @@ -153,6 +189,9 @@ adb_scan_bus(); adb_autopoll(1); } +#ifdef CONFIG_ADB_ACCT + proc_register(&proc_root,&adb_proc_entry); +#endif /*CONFIG_ADB_ACCT*/ } int @@ -185,23 +224,74 @@ { int i; + int dump = 0; + +/* DKH:9/98 -- RETHINK THE LOGIC FOR THIS FUNCTION.... DOESN'T FEEL RIGHT */ + ids->nids = 0; for (i = 1; i < 16; i++) { if ((adb_handler[i].original_address == default_id) || (adb_handler[i].handler_id == handler_id)) { if (adb_handler[i].handler != 0) { - printk(KERN_ERR - "Two handlers for ADB device %d\n", - default_id); - return 0; + printk(KERN_ERR "Replacing old ADB handler for device %d\n", i); + dump = 1; } adb_handler[i].handler = handler; ids->id[ids->nids++] = i; } } +#ifdef CONFIG_MACX_MOUSE_DEBUG + /* DKH:9/98 -- Dump out all of the adb information */ + + /* THIS SHOULD REALLY BE A PROC FILE AS WELL */ + + if ( dump ) + { + int j; + printk("address orig address handler_id handler \n"); + for ( j = 1 ; j < 16 ; j++ ){ + printk("%d ",j); + printk("%d ",adb_handler[j].original_address); + printk("%d ",adb_handler[j].handler_id); + printk("0x%x\n",adb_handler[j].handler); + } + } +#endif + return 1; } + +/* DKH:9/98 -- Allow specific individual handlers to be swapped + We want to be able to have multiple "keyboards" that use different + handler functions to allow the MacX mice to function. + + CHECK: Is adb_ids being used properly in this case? */ +int +adb_register_by_id(int id, struct adb_ids *ids, + void (*handler)(unsigned char *, int, struct pt_regs *, int)) +{ + if ( id < 1 || id > 15 ) + return 0; + ids->nids = 0; + adb_handler[id].handler = handler; + ids->id[ids->nids++] = id; +#ifdef CONFIG_MACX_MOUSE_DEBUG + { + int j; + printk("address orig address handler_id handler \n"); + for ( j = 1 ; j < 16 ; j++ ){ + printk("%d ",j); + printk("%d ",adb_handler[j].original_address); + printk("%d ",adb_handler[j].handler_id); + printk("0x%x\n",adb_handler[j].handler); + } + } +#endif /*CONFIG_MACX_MOUSE_DEBUG*/ + return 1; +} + + void adb_input(unsigned char *buf, int nb, struct pt_regs *regs, int autopoll) { @@ -215,6 +305,9 @@ printk(" %x", buf[i]); printk(", id = %d\n", id); } +#ifdef CONFIG_ADB_ACCT + adb_handler[id].inp++; +#endif if (adb_handler[id].handler != 0) { (*adb_handler[id].handler)(buf, nb, regs, autopoll); } diff -ru linux-2.1.103/drivers/macintosh/mac_keyb.c linux-2.1.103-macx-mouse-merge/drivers/macintosh/mac_keyb.c --- linux-2.1.103/drivers/macintosh/mac_keyb.c Mon May 18 21:09:27 1998 +++ linux-2.1.103-macx-mouse-merge/drivers/macintosh/mac_keyb.c Sat Sep 19 21:15:10 1998 @@ -176,6 +176,12 @@ static int adb_emulate_buttons = 0; extern int console_loglevel; +#ifdef CONFIG_MACX_MOUSE +/* DKH:9/98 -- State variables for the MacX mouse */ +static unsigned char macx_middle_button = 0x7f; +static unsigned char macx_right_button = 0x7f; +#endif /*CONFIG_MACX_MOUSE*/ + extern struct kbd_struct kbd_table[]; extern void handle_scancode(unsigned char); @@ -247,6 +253,65 @@ input_keycode(data[2], 0); } +#ifdef CONFIG_MACX_MOUSE +/* DKH:9/98 -- Take care of the fake keyboard that the middle and right buttons + of the MacX mouse act like*/ +static void +fake_keyboard_input(unsigned char *data, int nb, struct pt_regs *regs, int apoll) +{ +/* This does not work with the adb mouse driver right now */ +/* + if (adb_mouse_interrupt_hook) + adb_mouse_interrupt_hook(data, nb); +*/ + + if (nb != 3 || (data[0] & 3) != KEYB_KEYREG) + return; + kbd_pt_regs = regs; + + /* If it's not the mouse, re-register as regular keyboard + and call keyboard_input so we don't loose this keystroke (HACK)*/ + switch(data[1]){ + case 0x3b: + macx_middle_button = 0xff; + put_queue( 0x3f ); + break; + case 0xbb: + macx_middle_button = 0x7f; + put_queue( 0xbf ); + break; + case 0x3c: + macx_right_button = 0xff; + put_queue( 0x40 ); + break; + case 0xbc: + macx_right_button = 0x7f; + put_queue( 0xc0 ); + break; + default: +#ifdef CONFIG_MACX_MOUSE_DEBUG + printk("Whoops, looks like this isn't the MacX mouse.\n"); +#endif + adb_register_by_id( data[0]>>4 , &keyboard_ids, keyboard_input); + keyboard_input(data, nb, regs, apoll); + return; + } + +#ifdef CONFIG_MACX_MOUSE_DEBUG + { + int i, id; + printk("Fake keyboard input of keycode 0x%x\n",data[1]); + + id = data[0] >> 4; + printk("adb packet: "); + for (i = 0; i < nb; ++i) + printk(" %x", data[i]); + printk(", id = %d\n", id); + } +#endif /*CONFIG_MACX_MOUSE_DEBUG*/ +} +#endif /*CONFIG_MACX_MOUSE*/ + static void input_keycode(int keycode, int repeat) { @@ -496,6 +561,33 @@ } } +#ifdef CONFIG_MACX_MOUSE +static void +macx_mouse_input(unsigned char *data, int nb, struct pt_regs *regs, int autopoll) +{ + /* It would be nice if this would check to see if we have mouse data from + a real three button mouse and then re-register the real handler + function. */ + + struct kbd_struct *kbd; + + /* Store the button states in data */ + data[2] = data[2] & macx_middle_button; + data[3] = data[3] & macx_right_button; + + if (adb_mouse_interrupt_hook) + adb_mouse_interrupt_hook(data, nb); + kbd = kbd_table + fg_console; + + /* Only send mouse codes when keyboard is in raw mode. */ + if (kbd->kbdmode == VC_RAW) { + put_queue( 0x7e ); + put_queue( data[1] ); + put_queue( data[2] ); + } +} +#endif /*CONFIG_MACX_MOUSE*/ + /* Map led flags as defined in kbd_kern.h to bits for Apple keyboard. */ static unsigned char mac_ledmap[8] = { 0, /* none */ @@ -574,8 +666,14 @@ /* initialize mouse interrupt hook */ adb_mouse_interrupt_hook = NULL; +#ifndef CONFIG_MACX_MOUSE /*Not sure if this is the best way */ + adb_register(ADB_KEYBOARD, 5, &keyboard_ids, keyboard_input); adb_register(ADB_MOUSE, 1, &mouse_ids, mouse_input); +#else + adb_register(ADB_MOUSE, 3, &mouse_ids, macx_mouse_input); + adb_register(ADB_KEYBOARD, 5, &keyboard_ids, fake_keyboard_input); +#endif for(i = 0; i < keyboard_ids.nids; i++) { /* turn off all leds */ @@ -633,6 +731,11 @@ ADB_WRITEREG(mouse_ids.id[i],1), 03,0x38); } } + +#ifdef CONFIG_MACX_MOUSE_DEBUG_FALSE + panic("Forced panic for CONFIG_MACX_MOUSE_DEBUG"); +#endif + } void adb_setup_mouse( char *s, int *ints )