home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #19 / NN_1992_19.iso / spool / comp / os / linux / 9399 < prev    next >
Encoding:
Text File  |  1992-08-30  |  9.4 KB  |  374 lines

  1. Newsgroups: comp.os.linux
  2. Path: sparky!uunet!stanford.edu!rock!cole
  3. From: cole@concert.net (Derrick C. Cole)
  4. Subject: Microsoft Bus Mouse patch 2a
  5. Message-ID: <1992Aug30.021148.21070@rock.concert.net>
  6. Sender: news@rock.concert.net
  7. Organization: MCNC Data Operations
  8. Date: Sun, 30 Aug 1992 02:11:48 GMT
  9. Lines: 363
  10.  
  11. Greetings!
  12.  
  13. This patch is to be made against pristine linux-0.97 patchlevel 1.  The default
  14. choice in linux/Makefile is for the Microsoft mouse.  You can of course choose
  15. the Logitech driver, or comment out both choices for no bus mouse driver.
  16.  
  17. Any questions, problems can be directed to me at cole@concert.net, or to the
  18. newsgroup.
  19.  
  20. Thanks again Frank, Teemu, Andrew and the original Logitech driver writers!
  21.  
  22. Good luck!
  23. Derrick
  24.  
  25. --- cut here ---
  26.  
  27. *** linux/Makefile.orig    Fri Aug 28 21:24:31 1992
  28. --- linux/Makefile    Fri Aug 28 21:48:31 1992
  29. *************** KEYBOARD = -DKBD_US -DKBDFLAGS=0
  30. *** 46,51 ****
  31. --- 46,57 ----
  32.   # KEYBOARD = -DKDB_NO
  33.   
  34.   #
  35. + # if you want a bus mouse driver, uncomment your choice
  36. + #
  37. + # BUSMOUSE = -DBUSMOUSE=LOGITECH
  38. + BUSMOUSE = -DBUSMOUSE=MICROSOFT
  39. + #
  40.   # comment this line if you don't want the emulation-code
  41.   #
  42.   
  43. *** linux/kernel/chr_drv/Makefile.orig    Fri Aug 28 21:21:07 1992
  44. --- linux/kernel/chr_drv/Makefile    Fri Aug 28 21:51:03 1992
  45. *************** chr_drv.a: $(OBJS)
  46. *** 26,31 ****
  47. --- 26,37 ----
  48.   keyboard.o: keyboard.c
  49.       $(CC) $(CFLAGS) $(KEYBOARD) -c -o keyboard.o keyboard.c
  50.   
  51. + mouse.o: mouse.c
  52. +     $(CC) $(CFLAGS) $(BUSMOUSE) -c -o mouse.o mouse.c
  53. + mem.o: mem.c
  54. +     $(CC) $(CFLAGS) $(BUSMOUSE) -c -o mem.o mem.c
  55.   clean:
  56.       rm -f core *.o *.a tmp_make keyboard.s
  57.       for i in *.c;do rm -f `basename $$i .c`.s;done
  58. *** linux/kernel/chr_drv/mem.c.orig    Fri Aug 28 21:50:00 1992
  59. --- linux/kernel/chr_drv/mem.c    Fri Aug 28 21:50:00 1992
  60. *************** long chr_dev_init(long mem_start, long m
  61. *** 256,261 ****
  62. --- 256,263 ----
  63.       chrdev_fops[1] = &mem_fops;
  64.       mem_start = tty_init(mem_start);
  65.       mem_start = lp_init(mem_start);
  66. + #ifdef BUSMOUSE    
  67.       mem_start = mouse_init(mem_start);
  68. + #endif    
  69.       return mem_start;
  70.   }
  71. *** linux/kernel/chr_drv/mouse.c.orig    Fri Aug 28 16:34:44 1992
  72. --- linux/kernel/chr_drv/mouse.c    Sat Aug 29 20:27:39 1992
  73. ***************
  74. *** 13,21 ****
  75.    * Modified the select() code blindly to conform to the VFS
  76.    *   requirements. 92.07.14 - Linus. Somebody should test it out.
  77.    * 
  78. !  * version 0.1
  79.    */
  80.   
  81.   #include    <linux/kernel.h>
  82.   #include    <linux/sched.h>
  83.   #include    <linux/mouse.h>
  84. --- 13,40 ----
  85.    * Modified the select() code blindly to conform to the VFS
  86.    *   requirements. 92.07.14 - Linus. Somebody should test it out.
  87.    * 
  88. !  * Added MicroSoft busmouse support by Teemu Rantanen (tvr@cs.hut.fi) (02AUG92)
  89. !  *
  90. !  * Modified by Derrick Cole (cole@concert.net) 8/28/92
  91. !  *   modified the read_mouse() code to handle a Microsoft mouse with the
  92. !  *      following settings:
  93. !  *
  94. !  *        J2=NORMAL
  95. !  *        J3=PRIMARY INPORT
  96. !  *        J4=5
  97. !  *
  98. !  *      Works for me.  Changes to Teemu's code inspired by code received from
  99. !  *      Frank ten Wolde (franky@duteca.et.tudelft.nl.)  Please check this code
  100. !  *      out.  We may be dealing with different types of Microsoft Mice, or
  101. !  *      different settings bring about drastic code changes.
  102. !  *   mouse_init() should check for a bus mouse generically, too.  Anyone know
  103. !  *      how to do this?
  104. !  *
  105. !  * version 0.2a
  106.    */
  107.   
  108. + #ifdef    BUSMOUSE
  109.   #include    <linux/kernel.h>
  110.   #include    <linux/sched.h>
  111.   #include    <linux/mouse.h>
  112. *************** static void mouse_interrupt(int unused)
  113. *** 34,39 ****
  114. --- 53,59 ----
  115.   {
  116.       char dx, dy, buttons;
  117.   
  118. + #if (BUSMOUSE == LOGITECH)
  119.       MSE_INT_OFF();
  120.       
  121.       outb(MSE_READ_X_LOW, MSE_CONTROL_PORT);
  122. *************** static void mouse_interrupt(int unused)
  123. *** 50,55 ****
  124. --- 70,93 ----
  125.   
  126.       dy |= (buttons & 0xf) << 4;
  127.       buttons = ((buttons >> 5) & 0x07);
  128. + #endif
  129. + #if (BUSMOUSE == MICROSOFT)
  130. +     outb(MSE_COMMAND_MODE, MSE_CONTROL_PORT);
  131. +     outb(inb(MSE_DATA_PORT) | 0x20, MSE_DATA_PORT);
  132. +     outb(MSE_READ_X, MSE_CONTROL_PORT);
  133. +     dx = inb(MSE_DATA_PORT);
  134. +     outb(MSE_READ_Y, MSE_CONTROL_PORT);
  135. +     dy = inb(MSE_DATA_PORT);
  136. +     outb(MSE_READ_BUTTONS, MSE_CONTROL_PORT);
  137. +     buttons = ~(inb(MSE_DATA_PORT)) & 0x07;
  138. +     outb(MSE_COMMAND_MODE, MSE_CONTROL_PORT);
  139. +     outb(inb(MSE_DATA_PORT) & 0xdf, MSE_DATA_PORT);
  140. + #endif
  141.   
  142.       mouse.buttons = buttons;
  143.       mouse.latch_buttons |= buttons;
  144. *************** static void mouse_interrupt(int unused)
  145. *** 58,65 ****
  146.       mouse.ready = 1;
  147.       if (mouse.inode && mouse.inode->i_wait)
  148.            wake_up(&mouse.inode->i_wait);
  149. !     
  150.       MSE_INT_ON();
  151.   }
  152.   
  153.   static void release_mouse(struct inode * inode, struct file * file)
  154. --- 96,105 ----
  155.       mouse.ready = 1;
  156.       if (mouse.inode && mouse.inode->i_wait)
  157.            wake_up(&mouse.inode->i_wait);
  158. ! #if (BUSMOUSE == LOGITECH)    
  159.       MSE_INT_ON();
  160. + #endif
  161.   }
  162.   
  163.   static void release_mouse(struct inode * inode, struct file * file)
  164. *************** static int open_mouse(struct inode * ino
  165. *** 88,93 ****
  166. --- 128,137 ----
  167.           mouse.active = 0;  /* it's not active, fix it */
  168.           return -EBUSY;     /* IRQ is busy, so we're BUSY */
  169.       } /* if we can't get the IRQ and mouse not active */
  170. + #if (BUSMOUSE == MICROSOFT)
  171. +     outb(MSE_START, MSE_CONTROL_PORT);
  172. + #endif
  173.       MSE_INT_ON();    
  174.       return 0;
  175.   }
  176. *************** static int read_mouse(struct inode * ino
  177. *** 103,110 ****
  178.   
  179.       if (count < 3) return -EINVAL;
  180.       if (!mouse.ready) return -EAGAIN;
  181. !     
  182.       MSE_INT_OFF();
  183.           
  184.       put_fs_byte(mouse.latch_buttons | 0x80, buffer);
  185.       
  186. --- 147,156 ----
  187.   
  188.       if (count < 3) return -EINVAL;
  189.       if (!mouse.ready) return -EAGAIN;
  190. ! #if (BUSMOUSE == LOGITECH)    
  191.       MSE_INT_OFF();
  192. + #endif
  193.           
  194.       put_fs_byte(mouse.latch_buttons | 0x80, buffer);
  195.       
  196. *************** static int read_mouse(struct inode * ino
  197. *** 121,132 ****
  198.       for (i = 3; i < count; i++)
  199.           put_fs_byte(0x00, buffer + i);
  200.           
  201. !     mouse.dx = 0;
  202. !     mouse.dy = 0;
  203.       mouse.latch_buttons = mouse.buttons;
  204.       mouse.ready = 0;
  205. !     
  206.       MSE_INT_ON();
  207.       return i;    
  208.   }
  209.   
  210. --- 167,179 ----
  211.       for (i = 3; i < count; i++)
  212.           put_fs_byte(0x00, buffer + i);
  213.           
  214. !     mouse.dx = mouse.dy = 0;
  215.       mouse.latch_buttons = mouse.buttons;
  216.       mouse.ready = 0;
  217. ! #if (BUSMOUSE == LOGITECH)    
  218.       MSE_INT_ON();
  219. + #endif
  220.       return i;    
  221.   }
  222.   
  223. *************** static struct file_operations mouse_fops
  224. *** 153,160 ****
  225.   
  226.   long mouse_init(long kmem_start)
  227.   {    
  228.       int i;
  229.       outb(MSE_CONFIG_BYTE, MSE_CONFIG_PORT);
  230.       outb(MSE_SIGNATURE_BYTE, MSE_SIGNATURE_PORT);
  231.       
  232. --- 200,208 ----
  233.   
  234.   long mouse_init(long kmem_start)
  235.   {    
  236. + #if (BUSMOUSE == LOGITECH)
  237.       int i;
  238. !         
  239.       outb(MSE_CONFIG_BYTE, MSE_CONFIG_PORT);
  240.       outb(MSE_SIGNATURE_BYTE, MSE_SIGNATURE_PORT);
  241.       
  242. *************** long mouse_init(long kmem_start)
  243. *** 164,180 ****
  244.           mouse.present = 0;
  245.           return kmem_start;
  246.       }
  247.       chrdev_fops[10] = &mouse_fops;
  248.       outb(MSE_DEFAULT_MODE, MSE_CONFIG_PORT);
  249.       
  250.       MSE_INT_OFF();
  251.       
  252.       mouse.present = 1;
  253. !     mouse.active = 0;
  254. !     mouse.ready = 0;
  255.       mouse.buttons = mouse.latch_buttons = 0x80;
  256. !     mouse.dx = 0;
  257. !     mouse.dy = 0;
  258. !     printk("Bus mouse detected and installed.\n");
  259.       return kmem_start;
  260.   }
  261. --- 212,237 ----
  262.           mouse.present = 0;
  263.           return kmem_start;
  264.       }
  265. + #endif
  266. +     
  267.       chrdev_fops[10] = &mouse_fops;
  268. + #if (BUSMOUSE == LOGITECH)
  269.       outb(MSE_DEFAULT_MODE, MSE_CONFIG_PORT);
  270. + #endif
  271.       
  272.       MSE_INT_OFF();
  273.       
  274.       mouse.present = 1;
  275. !     mouse.active = mouse.ready = 0;
  276.       mouse.buttons = mouse.latch_buttons = 0x80;
  277. !     mouse.dx = mouse.dy = 0;
  278. ! #if (BUSMOUSE == LOGITECH)    
  279. !     printk("Logitech Bus Mouse detected and installed.\n");
  280. ! #elif (BUSMOUSE == MICROSOFT)
  281. !     printk("Microsoft Bus Mouse detected and installed.\n");
  282. ! #endif        
  283.       return kmem_start;
  284.   }
  285. + #endif
  286. *** linux/include/linux/mouse.h.orig    Thu Aug 27 20:37:13 1992
  287. --- linux/include/linux/mouse.h    Sat Aug 29 00:03:35 1992
  288. ***************
  289. *** 12,21 ****
  290. --- 12,32 ----
  291.    * Minor modifications for Linux 0.96c-pl1 by Nathan Laredo
  292.    * gt7080a@prism.gatech.edu (13JUL92)
  293.    *
  294. +  * Microsoft BusMouse support by Teemu Rantanen (tvr@cs.hut.fi) (02AUG92)
  295. +  *
  296. +  * Microsoft Bus Mouse support modified by Derrick Cole (cole@concert.net)
  297. +  *    8/28/92
  298.    */
  299.   
  300. + #if defined (BUSMOUSE)
  301. + #define LOGITECH        1
  302. + #define MICROSOFT        2
  303.   #define MOUSE_IRQ        5
  304.   
  305. + #if (BUSMOUSE == LOGITECH)
  306.   #define    MSE_DATA_PORT        0x23c
  307.   #define    MSE_SIGNATURE_PORT    0x23d
  308.   #define    MSE_CONTROL_PORT    0x23e
  309. ***************
  310. *** 40,45 ****
  311. --- 51,81 ----
  312.   #define MSE_INT_OFF()    outb(MSE_DISABLE_INTERRUPTS, MSE_CONTROL_PORT)
  313.   #define MSE_INT_ON()    outb(MSE_ENABLE_INTERRUPTS, MSE_CONTROL_PORT)
  314.    
  315. + #endif
  316. + #if (BUSMOUSE == MICROSOFT)
  317. + #define MSE_CONTROL_PORT        0x23c
  318. + #define MSE_DATA_PORT           0x23d
  319. + #define    MSE_SIGNATURE_PORT    0x23d
  320. + #define    MSE_CONFIG_PORT        0x23f
  321. + #define MSE_ENABLE_INTERRUPTS   0x11
  322. + #define MSE_DISABLE_INTERRUPTS  0x10
  323. + #define MSE_READ_BUTTONS        0x00
  324. + #define MSE_READ_X              0x01
  325. + #define MSE_READ_Y              0x02
  326. + #define MSE_START               0x80
  327. + #define MSE_COMMAND_MODE        0x07
  328. + /* useful macros */
  329. + #define MSE_INT_OFF()    {outb(MSE_COMMAND_MODE, MSE_CONTROL_PORT); outb(MSE_DISABLE_INTERRUPTS, MSE_DATA_PORT);}
  330. + #define MSE_INT_ON()    {outb(MSE_COMMAND_MODE, MSE_CONTROL_PORT); outb(MSE_ENABLE_INTERRUPTS, MSE_DATA_PORT);}
  331. + #endif
  332.   struct mouse_status
  333.       {
  334.       char        buttons;
  335. *************** struct mouse_status
  336. *** 57,61 ****
  337. --- 93,98 ----
  338.   /* Function Prototypes */
  339.   extern long mouse_init(long);
  340.   
  341. + #endif
  342.   #endif
  343.   
  344. -- 
  345. ---
  346. Derrick Cole                                  MCNC Center for Communications
  347.