Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

at v2.6.12-rc4 137 lines 3.4 kB view raw
1/* 2 * Amiga mouse driver for Linux/m68k 3 * 4 * Copyright (c) 2000-2002 Vojtech Pavlik 5 * 6 * Based on the work of: 7 * Michael Rausch James Banks 8 * Matther Dillon David Giller 9 * Nathan Laredo Linus Torvalds 10 * Johan Myreen Jes Sorensen 11 * Russell King 12 */ 13 14/* 15 * This program is free software; you can redistribute it and/or modify it 16 * under the terms of the GNU General Public License version 2 as published by 17 * the Free Software Foundation 18 */ 19 20#include <linux/module.h> 21#include <linux/init.h> 22#include <linux/input.h> 23#include <linux/interrupt.h> 24 25#include <asm/irq.h> 26#include <asm/setup.h> 27#include <asm/system.h> 28#include <asm/uaccess.h> 29#include <asm/amigahw.h> 30#include <asm/amigaints.h> 31 32MODULE_AUTHOR("Vojtech Pavlik <vojtech@ucw.cz>"); 33MODULE_DESCRIPTION("Amiga mouse driver"); 34MODULE_LICENSE("GPL"); 35 36static int amimouse_used = 0; 37static int amimouse_lastx, amimouse_lasty; 38static struct input_dev amimouse_dev; 39 40static char *amimouse_name = "Amiga mouse"; 41static char *amimouse_phys = "amimouse/input0"; 42 43static irqreturn_t amimouse_interrupt(int irq, void *dummy, struct pt_regs *fp) 44{ 45 unsigned short joy0dat, potgor; 46 int nx, ny, dx, dy; 47 48 joy0dat = custom.joy0dat; 49 50 nx = joy0dat & 0xff; 51 ny = joy0dat >> 8; 52 53 dx = nx - amimouse_lastx; 54 dy = ny - amimouse_lasty; 55 56 if (dx < -127) dx = (256 + nx) - amimouse_lastx; 57 if (dx > 127) dx = (nx - 256) - amimouse_lastx; 58 if (dy < -127) dy = (256 + ny) - amimouse_lasty; 59 if (dy > 127) dy = (ny - 256) - amimouse_lasty; 60 61 amimouse_lastx = nx; 62 amimouse_lasty = ny; 63 64 potgor = custom.potgor; 65 66 input_regs(&amimouse_dev, fp); 67 68 input_report_rel(&amimouse_dev, REL_X, dx); 69 input_report_rel(&amimouse_dev, REL_Y, dy); 70 71 input_report_key(&amimouse_dev, BTN_LEFT, ciaa.pra & 0x40); 72 input_report_key(&amimouse_dev, BTN_MIDDLE, potgor & 0x0100); 73 input_report_key(&amimouse_dev, BTN_RIGHT, potgor & 0x0400); 74 75 input_sync(&amimouse_dev); 76 77 return IRQ_HANDLED; 78} 79 80static int amimouse_open(struct input_dev *dev) 81{ 82 unsigned short joy0dat; 83 84 if (amimouse_used++) 85 return 0; 86 87 joy0dat = custom.joy0dat; 88 89 amimouse_lastx = joy0dat & 0xff; 90 amimouse_lasty = joy0dat >> 8; 91 92 if (request_irq(IRQ_AMIGA_VERTB, amimouse_interrupt, 0, "amimouse", amimouse_interrupt)) { 93 amimouse_used--; 94 printk(KERN_ERR "amimouse.c: Can't allocate irq %d\n", IRQ_AMIGA_VERTB); 95 return -EBUSY; 96 } 97 98 return 0; 99} 100 101static void amimouse_close(struct input_dev *dev) 102{ 103 if (!--amimouse_used) 104 free_irq(IRQ_AMIGA_VERTB, amimouse_interrupt); 105} 106 107static int __init amimouse_init(void) 108{ 109 if (!MACH_IS_AMIGA || !AMIGAHW_PRESENT(AMI_MOUSE)) 110 return -ENODEV; 111 112 amimouse_dev.evbit[0] = BIT(EV_KEY) | BIT(EV_REL); 113 amimouse_dev.relbit[0] = BIT(REL_X) | BIT(REL_Y); 114 amimouse_dev.keybit[LONG(BTN_LEFT)] = BIT(BTN_LEFT) | BIT(BTN_MIDDLE) | BIT(BTN_RIGHT); 115 amimouse_dev.open = amimouse_open; 116 amimouse_dev.close = amimouse_close; 117 118 amimouse_dev.name = amimouse_name; 119 amimouse_dev.phys = amimouse_phys; 120 amimouse_dev.id.bustype = BUS_AMIGA; 121 amimouse_dev.id.vendor = 0x0001; 122 amimouse_dev.id.product = 0x0002; 123 amimouse_dev.id.version = 0x0100; 124 125 input_register_device(&amimouse_dev); 126 127 printk(KERN_INFO "input: %s at joy0dat\n", amimouse_name); 128 return 0; 129} 130 131static void __exit amimouse_exit(void) 132{ 133 input_unregister_device(&amimouse_dev); 134} 135 136module_init(amimouse_init); 137module_exit(amimouse_exit);