X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=drivers%2Finput%2Fjoystick%2Fgamecon.c;h=900587acdb47c16d1c983f9c36c27a067fb375d0;hb=987b0145d94eecf292d8b301228356f44611ab7c;hp=ecbdb6b9bbd6dd64323a929a98a5b95d6d97dc52;hpb=f7ed79d23a47594e7834d66a8f14449796d4f3e6;p=linux-2.6.git diff --git a/drivers/input/joystick/gamecon.c b/drivers/input/joystick/gamecon.c index ecbdb6b9b..900587acd 100644 --- a/drivers/input/joystick/gamecon.c +++ b/drivers/input/joystick/gamecon.c @@ -7,7 +7,6 @@ * Based on the work of: * Andree Borrmann John Dahlstrom * David Kuder Nathan Hand - * Raphael Assenat */ /* @@ -37,7 +36,6 @@ #include #include #include -#include MODULE_AUTHOR("Vojtech Pavlik "); MODULE_DESCRIPTION("NES, SNES, N64, MultiSystem, PSX gamepad driver"); @@ -74,9 +72,8 @@ __obsolete_setup("gc_3="); #define GC_N64 6 #define GC_PSX 7 #define GC_DDR 8 -#define GC_SNESMOUSE 9 -#define GC_MAX 9 +#define GC_MAX 8 #define GC_REFRESH_TIME HZ/100 @@ -86,7 +83,7 @@ struct gc { struct timer_list timer; unsigned char pads[GC_MAX + 1]; int used; - struct mutex mutex; + struct semaphore sem; char phys[GC_MAX_DEVICES][32]; }; @@ -96,7 +93,7 @@ static int gc_status_bit[] = { 0x40, 0x80, 0x20, 0x10, 0x08 }; static char *gc_names[] = { NULL, "SNES pad", "NES pad", "NES FourPort", "Multisystem joystick", "Multisystem 2-button joystick", "N64 controller", "PSX controller", - "PSX DDR controller", "SNES mouse" }; + "PSX DDR controller" }; /* * N64 support. */ @@ -208,12 +205,9 @@ static void gc_n64_process_packet(struct gc *gc) * NES/SNES support. */ -#define GC_NES_DELAY 6 /* Delay between bits - 6us */ -#define GC_NES_LENGTH 8 /* The NES pads use 8 bits of data */ -#define GC_SNES_LENGTH 12 /* The SNES true length is 16, but the - last 4 bits are unused */ -#define GC_SNESMOUSE_LENGTH 32 /* The SNES mouse uses 32 bits, the first - 16 bits are equivalent to a gamepad */ +#define GC_NES_DELAY 6 /* Delay between bits - 6us */ +#define GC_NES_LENGTH 8 /* The NES pads use 8 bits of data */ +#define GC_SNES_LENGTH 12 /* The SNES true length is 16, but the last 4 bits are unused */ #define GC_NES_POWER 0xfc #define GC_NES_CLOCK 0x01 @@ -248,15 +242,11 @@ static void gc_nes_read_packet(struct gc *gc, int length, unsigned char *data) static void gc_nes_process_packet(struct gc *gc) { - unsigned char data[GC_SNESMOUSE_LENGTH]; + unsigned char data[GC_SNES_LENGTH]; struct input_dev *dev; - int i, j, s, len; - char x_rel, y_rel; - - len = gc->pads[GC_SNESMOUSE] ? GC_SNESMOUSE_LENGTH : - (gc->pads[GC_SNES] ? GC_SNES_LENGTH : GC_NES_LENGTH); + int i, j, s; - gc_nes_read_packet(gc, len, data); + gc_nes_read_packet(gc, gc->pads[GC_SNES] ? GC_SNES_LENGTH : GC_NES_LENGTH, data); for (i = 0; i < GC_MAX_DEVICES; i++) { @@ -279,44 +269,6 @@ static void gc_nes_process_packet(struct gc *gc) for (j = 0; j < 8; j++) input_report_key(dev, gc_snes_btn[j], s & data[gc_snes_bytes[j]]); - if (s & gc->pads[GC_SNESMOUSE]) { - /* - * The 4 unused bits from SNES controllers appear to be ID bits - * so use them to make sure iwe are dealing with a mouse. - * gamepad is connected. This is important since - * my SNES gamepad sends 1's for bits 16-31, which - * cause the mouse pointer to quickly move to the - * upper left corner of the screen. - */ - if (!(s & data[12]) && !(s & data[13]) && - !(s & data[14]) && (s & data[15])) { - input_report_key(dev, BTN_LEFT, s & data[9]); - input_report_key(dev, BTN_RIGHT, s & data[8]); - - x_rel = y_rel = 0; - for (j = 0; j < 7; j++) { - x_rel <<= 1; - if (data[25 + j] & s) - x_rel |= 1; - - y_rel <<= 1; - if (data[17 + j] & s) - y_rel |= 1; - } - - if (x_rel) { - if (data[24] & s) - x_rel = -x_rel; - input_report_rel(dev, REL_X, x_rel); - } - - if (y_rel) { - if (data[16] & s) - y_rel = -y_rel; - input_report_rel(dev, REL_Y, y_rel); - } - } - } input_sync(dev); } } @@ -572,10 +524,10 @@ static void gc_timer(unsigned long private) gc_n64_process_packet(gc); /* - * NES and SNES pads or mouse + * NES and SNES pads */ - if (gc->pads[GC_NES] || gc->pads[GC_SNES] || gc->pads[GC_SNESMOUSE]) + if (gc->pads[GC_NES] || gc->pads[GC_SNES]) gc_nes_process_packet(gc); /* @@ -600,7 +552,7 @@ static int gc_open(struct input_dev *dev) struct gc *gc = dev->private; int err; - err = mutex_lock_interruptible(&gc->mutex); + err = down_interruptible(&gc->sem); if (err) return err; @@ -610,7 +562,7 @@ static int gc_open(struct input_dev *dev) mod_timer(&gc->timer, jiffies + GC_REFRESH_TIME); } - mutex_unlock(&gc->mutex); + up(&gc->sem); return 0; } @@ -618,13 +570,13 @@ static void gc_close(struct input_dev *dev) { struct gc *gc = dev->private; - mutex_lock(&gc->mutex); + down(&gc->sem); if (!--gc->used) { del_timer_sync(&gc->timer); parport_write_control(gc->pd->port, 0x00); parport_release(gc->pd); } - mutex_unlock(&gc->mutex); + up(&gc->sem); } static int __init gc_setup_pad(struct gc *gc, int idx, int pad_type) @@ -657,13 +609,10 @@ static int __init gc_setup_pad(struct gc *gc, int idx, int pad_type) input_dev->open = gc_open; input_dev->close = gc_close; - if (pad_type != GC_SNESMOUSE) { - input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_ABS); + input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_ABS); - for (i = 0; i < 2; i++) - input_set_abs_params(input_dev, ABS_X + i, -1, 1, 0, 0); - } else - input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_REL); + for (i = 0; i < 2; i++) + input_set_abs_params(input_dev, ABS_X + i, -1, 1, 0, 0); gc->pads[0] |= gc_status_bit[idx]; gc->pads[pad_type] |= gc_status_bit[idx]; @@ -681,13 +630,6 @@ static int __init gc_setup_pad(struct gc *gc, int idx, int pad_type) break; - case GC_SNESMOUSE: - set_bit(BTN_LEFT, input_dev->keybit); - set_bit(BTN_RIGHT, input_dev->keybit); - set_bit(REL_X, input_dev->relbit); - set_bit(REL_Y, input_dev->relbit); - break; - case GC_SNES: for (i = 4; i < 8; i++) set_bit(gc_snes_btn[i], input_dev->keybit); @@ -751,7 +693,7 @@ static struct gc __init *gc_probe(int parport, int *pads, int n_pads) goto err_unreg_pardev; } - mutex_init(&gc->mutex); + init_MUTEX(&gc->sem); gc->pd = pd; init_timer(&gc->timer); gc->timer.data = (long) gc;