diff options
author | Steven Whitehouse <steve@men-an-tol.chygwyn.com> | 2006-02-23 04:49:43 -0500 |
---|---|---|
committer | Steven Whitehouse <swhiteho@redhat.com> | 2006-02-23 04:49:43 -0500 |
commit | d35462b4bb847b68321c55e95c926aa485aecce2 (patch) | |
tree | b08e18bf6e672633402871ee763102fdb5e63229 /drivers/input | |
parent | 91ffd7db71e7451f89941a8f428b4daa2a7c1e38 (diff) | |
parent | 9e956c2dac9bec602ed1ba29181b45ba6d2b6448 (diff) |
Merge branch 'master'
Diffstat (limited to 'drivers/input')
23 files changed, 656 insertions, 338 deletions
diff --git a/drivers/input/joystick/a3d.c b/drivers/input/joystick/a3d.c index 4571ea3a4b92..4612d13ea756 100644 --- a/drivers/input/joystick/a3d.c +++ b/drivers/input/joystick/a3d.c | |||
@@ -57,7 +57,7 @@ static char *a3d_names[] = { NULL, "FP-Gaming Assassin 3D", "MadCatz Panther", " | |||
57 | struct a3d { | 57 | struct a3d { |
58 | struct gameport *gameport; | 58 | struct gameport *gameport; |
59 | struct gameport *adc; | 59 | struct gameport *adc; |
60 | struct input_dev dev; | 60 | struct input_dev *dev; |
61 | int axes[4]; | 61 | int axes[4]; |
62 | int buttons; | 62 | int buttons; |
63 | int mode; | 63 | int mode; |
@@ -115,7 +115,7 @@ static int a3d_csum(char *data, int count) | |||
115 | 115 | ||
116 | static void a3d_read(struct a3d *a3d, unsigned char *data) | 116 | static void a3d_read(struct a3d *a3d, unsigned char *data) |
117 | { | 117 | { |
118 | struct input_dev *dev = &a3d->dev; | 118 | struct input_dev *dev = a3d->dev; |
119 | 119 | ||
120 | switch (a3d->mode) { | 120 | switch (a3d->mode) { |
121 | 121 | ||
@@ -265,14 +265,20 @@ static void a3d_close(struct input_dev *dev) | |||
265 | static int a3d_connect(struct gameport *gameport, struct gameport_driver *drv) | 265 | static int a3d_connect(struct gameport *gameport, struct gameport_driver *drv) |
266 | { | 266 | { |
267 | struct a3d *a3d; | 267 | struct a3d *a3d; |
268 | struct input_dev *input_dev; | ||
268 | struct gameport *adc; | 269 | struct gameport *adc; |
269 | unsigned char data[A3D_MAX_LENGTH]; | 270 | unsigned char data[A3D_MAX_LENGTH]; |
270 | int i; | 271 | int i; |
271 | int err; | 272 | int err; |
272 | 273 | ||
273 | if (!(a3d = kzalloc(sizeof(struct a3d), GFP_KERNEL))) | 274 | a3d = kzalloc(sizeof(struct a3d), GFP_KERNEL); |
274 | return -ENOMEM; | 275 | input_dev = input_allocate_device(); |
276 | if (!a3d || !input_dev) { | ||
277 | err = -ENOMEM; | ||
278 | goto fail1; | ||
279 | } | ||
275 | 280 | ||
281 | a3d->dev = input_dev; | ||
276 | a3d->gameport = gameport; | 282 | a3d->gameport = gameport; |
277 | 283 | ||
278 | gameport_set_drvdata(gameport, a3d); | 284 | gameport_set_drvdata(gameport, a3d); |
@@ -302,42 +308,48 @@ static int a3d_connect(struct gameport *gameport, struct gameport_driver *drv) | |||
302 | 308 | ||
303 | sprintf(a3d->phys, "%s/input0", gameport->phys); | 309 | sprintf(a3d->phys, "%s/input0", gameport->phys); |
304 | 310 | ||
311 | input_dev->name = a3d_names[a3d->mode]; | ||
312 | input_dev->phys = a3d->phys; | ||
313 | input_dev->id.bustype = BUS_GAMEPORT; | ||
314 | input_dev->id.vendor = GAMEPORT_ID_VENDOR_MADCATZ; | ||
315 | input_dev->id.product = a3d->mode; | ||
316 | input_dev->id.version = 0x0100; | ||
317 | input_dev->cdev.dev = &gameport->dev; | ||
318 | input_dev->private = a3d; | ||
319 | input_dev->open = a3d_open; | ||
320 | input_dev->close = a3d_close; | ||
321 | |||
305 | if (a3d->mode == A3D_MODE_PXL) { | 322 | if (a3d->mode == A3D_MODE_PXL) { |
306 | 323 | ||
307 | int axes[] = { ABS_X, ABS_Y, ABS_THROTTLE, ABS_RUDDER }; | 324 | int axes[] = { ABS_X, ABS_Y, ABS_THROTTLE, ABS_RUDDER }; |
308 | 325 | ||
309 | a3d->length = 33; | 326 | a3d->length = 33; |
310 | 327 | ||
311 | init_input_dev(&a3d->dev); | 328 | input_dev->evbit[0] |= BIT(EV_ABS) | BIT(EV_KEY) | BIT(EV_REL); |
312 | 329 | input_dev->relbit[0] |= BIT(REL_X) | BIT(REL_Y); | |
313 | a3d->dev.evbit[0] |= BIT(EV_ABS) | BIT(EV_KEY) | BIT(EV_REL); | 330 | input_dev->absbit[0] |= BIT(ABS_X) | BIT(ABS_Y) | BIT(ABS_THROTTLE) | BIT(ABS_RUDDER) |
314 | a3d->dev.relbit[0] |= BIT(REL_X) | BIT(REL_Y); | 331 | | BIT(ABS_HAT0X) | BIT(ABS_HAT0Y) | BIT(ABS_HAT1X) | BIT(ABS_HAT1Y); |
315 | a3d->dev.absbit[0] |= BIT(ABS_X) | BIT(ABS_Y) | BIT(ABS_THROTTLE) | BIT(ABS_RUDDER) | 332 | input_dev->keybit[LONG(BTN_MOUSE)] |= BIT(BTN_RIGHT) | BIT(BTN_LEFT) | BIT(BTN_MIDDLE) |
316 | | BIT(ABS_HAT0X) | BIT(ABS_HAT0Y) | BIT(ABS_HAT1X) | BIT(ABS_HAT1Y); | 333 | | BIT(BTN_SIDE) | BIT(BTN_EXTRA); |
317 | 334 | input_dev->keybit[LONG(BTN_JOYSTICK)] |= BIT(BTN_TRIGGER) | BIT(BTN_THUMB) | BIT(BTN_TOP) | |
318 | a3d->dev.keybit[LONG(BTN_MOUSE)] |= BIT(BTN_RIGHT) | BIT(BTN_LEFT) | BIT(BTN_MIDDLE) | 335 | | BIT(BTN_PINKIE); |
319 | | BIT(BTN_SIDE) | BIT(BTN_EXTRA); | ||
320 | |||
321 | a3d->dev.keybit[LONG(BTN_JOYSTICK)] |= BIT(BTN_TRIGGER) | BIT(BTN_THUMB) | BIT(BTN_TOP) | BIT(BTN_PINKIE); | ||
322 | 336 | ||
323 | a3d_read(a3d, data); | 337 | a3d_read(a3d, data); |
324 | 338 | ||
325 | for (i = 0; i < 4; i++) { | 339 | for (i = 0; i < 4; i++) { |
326 | if (i < 2) | 340 | if (i < 2) |
327 | input_set_abs_params(&a3d->dev, axes[i], 48, a3d->dev.abs[axes[i]] * 2 - 48, 0, 8); | 341 | input_set_abs_params(input_dev, axes[i], 48, input_dev->abs[axes[i]] * 2 - 48, 0, 8); |
328 | else | 342 | else |
329 | input_set_abs_params(&a3d->dev, axes[i], 2, 253, 0, 0); | 343 | input_set_abs_params(input_dev, axes[i], 2, 253, 0, 0); |
330 | input_set_abs_params(&a3d->dev, ABS_HAT0X + i, -1, 1, 0, 0); | 344 | input_set_abs_params(input_dev, ABS_HAT0X + i, -1, 1, 0, 0); |
331 | } | 345 | } |
332 | 346 | ||
333 | } else { | 347 | } else { |
334 | a3d->length = 29; | 348 | a3d->length = 29; |
335 | 349 | ||
336 | init_input_dev(&a3d->dev); | 350 | input_dev->evbit[0] |= BIT(EV_KEY) | BIT(EV_REL); |
337 | 351 | input_dev->relbit[0] |= BIT(REL_X) | BIT(REL_Y); | |
338 | a3d->dev.evbit[0] |= BIT(EV_KEY) | BIT(EV_REL); | 352 | input_dev->keybit[LONG(BTN_MOUSE)] |= BIT(BTN_RIGHT) | BIT(BTN_LEFT) | BIT(BTN_MIDDLE); |
339 | a3d->dev.relbit[0] |= BIT(REL_X) | BIT(REL_Y); | ||
340 | a3d->dev.keybit[LONG(BTN_MOUSE)] |= BIT(BTN_RIGHT) | BIT(BTN_LEFT) | BIT(BTN_MIDDLE); | ||
341 | 353 | ||
342 | a3d_read(a3d, data); | 354 | a3d_read(a3d, data); |
343 | 355 | ||
@@ -358,24 +370,17 @@ static int a3d_connect(struct gameport *gameport, struct gameport_driver *drv) | |||
358 | } | 370 | } |
359 | } | 371 | } |
360 | 372 | ||
361 | a3d->dev.private = a3d; | 373 | err = input_register_device(a3d->dev); |
362 | a3d->dev.open = a3d_open; | 374 | if (err) |
363 | a3d->dev.close = a3d_close; | 375 | goto fail3; |
364 | |||
365 | a3d->dev.name = a3d_names[a3d->mode]; | ||
366 | a3d->dev.phys = a3d->phys; | ||
367 | a3d->dev.id.bustype = BUS_GAMEPORT; | ||
368 | a3d->dev.id.vendor = GAMEPORT_ID_VENDOR_MADCATZ; | ||
369 | a3d->dev.id.product = a3d->mode; | ||
370 | a3d->dev.id.version = 0x0100; | ||
371 | |||
372 | input_register_device(&a3d->dev); | ||
373 | printk(KERN_INFO "input: %s on %s\n", a3d_names[a3d->mode], a3d->phys); | ||
374 | 376 | ||
375 | return 0; | 377 | return 0; |
376 | 378 | ||
377 | fail2: gameport_close(gameport); | 379 | fail3: if (a3d->adc) |
378 | fail1: gameport_set_drvdata(gameport, NULL); | 380 | gameport_unregister_port(a3d->adc); |
381 | fail2: gameport_close(gameport); | ||
382 | fail1: gameport_set_drvdata(gameport, NULL); | ||
383 | input_free_device(input_dev); | ||
379 | kfree(a3d); | 384 | kfree(a3d); |
380 | return err; | 385 | return err; |
381 | } | 386 | } |
@@ -384,11 +389,9 @@ static void a3d_disconnect(struct gameport *gameport) | |||
384 | { | 389 | { |
385 | struct a3d *a3d = gameport_get_drvdata(gameport); | 390 | struct a3d *a3d = gameport_get_drvdata(gameport); |
386 | 391 | ||
387 | input_unregister_device(&a3d->dev); | 392 | input_unregister_device(a3d->dev); |
388 | if (a3d->adc) { | 393 | if (a3d->adc) |
389 | gameport_unregister_port(a3d->adc); | 394 | gameport_unregister_port(a3d->adc); |
390 | a3d->adc = NULL; | ||
391 | } | ||
392 | gameport_close(gameport); | 395 | gameport_close(gameport); |
393 | gameport_set_drvdata(gameport, NULL); | 396 | gameport_set_drvdata(gameport, NULL); |
394 | kfree(a3d); | 397 | kfree(a3d); |
@@ -397,6 +400,7 @@ static void a3d_disconnect(struct gameport *gameport) | |||
397 | static struct gameport_driver a3d_drv = { | 400 | static struct gameport_driver a3d_drv = { |
398 | .driver = { | 401 | .driver = { |
399 | .name = "adc", | 402 | .name = "adc", |
403 | .owner = THIS_MODULE, | ||
400 | }, | 404 | }, |
401 | .description = DRIVER_DESC, | 405 | .description = DRIVER_DESC, |
402 | .connect = a3d_connect, | 406 | .connect = a3d_connect, |
diff --git a/drivers/input/joystick/db9.c b/drivers/input/joystick/db9.c index 499344c72756..dcffc34f30c3 100644 --- a/drivers/input/joystick/db9.c +++ b/drivers/input/joystick/db9.c | |||
@@ -275,68 +275,70 @@ static unsigned char db9_saturn_read_packet(struct parport *port, unsigned char | |||
275 | /* | 275 | /* |
276 | * db9_saturn_report() analyzes packet and reports. | 276 | * db9_saturn_report() analyzes packet and reports. |
277 | */ | 277 | */ |
278 | static int db9_saturn_report(unsigned char id, unsigned char data[60], struct input_dev *dev, int n, int max_pads) | 278 | static int db9_saturn_report(unsigned char id, unsigned char data[60], struct input_dev *devs[], int n, int max_pads) |
279 | { | 279 | { |
280 | struct input_dev *dev; | ||
280 | int tmp, i, j; | 281 | int tmp, i, j; |
281 | 282 | ||
282 | tmp = (id == 0x41) ? 60 : 10; | 283 | tmp = (id == 0x41) ? 60 : 10; |
283 | for (j = 0; (j < tmp) && (n < max_pads); j += 10, n++) { | 284 | for (j = 0; j < tmp && n < max_pads; j += 10, n++) { |
285 | dev = devs[n]; | ||
284 | switch (data[j]) { | 286 | switch (data[j]) { |
285 | case 0x16: /* multi controller (analog 4 axis) */ | 287 | case 0x16: /* multi controller (analog 4 axis) */ |
286 | input_report_abs(dev + n, db9_abs[5], data[j + 6]); | 288 | input_report_abs(dev, db9_abs[5], data[j + 6]); |
287 | case 0x15: /* mission stick (analog 3 axis) */ | 289 | case 0x15: /* mission stick (analog 3 axis) */ |
288 | input_report_abs(dev + n, db9_abs[3], data[j + 4]); | 290 | input_report_abs(dev, db9_abs[3], data[j + 4]); |
289 | input_report_abs(dev + n, db9_abs[4], data[j + 5]); | 291 | input_report_abs(dev, db9_abs[4], data[j + 5]); |
290 | case 0x13: /* racing controller (analog 1 axis) */ | 292 | case 0x13: /* racing controller (analog 1 axis) */ |
291 | input_report_abs(dev + n, db9_abs[2], data[j + 3]); | 293 | input_report_abs(dev, db9_abs[2], data[j + 3]); |
292 | case 0x34: /* saturn keyboard (udlr ZXC ASD QE Esc) */ | 294 | case 0x34: /* saturn keyboard (udlr ZXC ASD QE Esc) */ |
293 | case 0x02: /* digital pad (digital 2 axis + buttons) */ | 295 | case 0x02: /* digital pad (digital 2 axis + buttons) */ |
294 | input_report_abs(dev + n, db9_abs[0], !(data[j + 1] & 128) - !(data[j + 1] & 64)); | 296 | input_report_abs(dev, db9_abs[0], !(data[j + 1] & 128) - !(data[j + 1] & 64)); |
295 | input_report_abs(dev + n, db9_abs[1], !(data[j + 1] & 32) - !(data[j + 1] & 16)); | 297 | input_report_abs(dev, db9_abs[1], !(data[j + 1] & 32) - !(data[j + 1] & 16)); |
296 | for (i = 0; i < 9; i++) | 298 | for (i = 0; i < 9; i++) |
297 | input_report_key(dev + n, db9_cd32_btn[i], ~data[j + db9_saturn_byte[i]] & db9_saturn_mask[i]); | 299 | input_report_key(dev, db9_cd32_btn[i], ~data[j + db9_saturn_byte[i]] & db9_saturn_mask[i]); |
298 | break; | 300 | break; |
299 | case 0x19: /* mission stick x2 (analog 6 axis + buttons) */ | 301 | case 0x19: /* mission stick x2 (analog 6 axis + buttons) */ |
300 | input_report_abs(dev + n, db9_abs[0], !(data[j + 1] & 128) - !(data[j + 1] & 64)); | 302 | input_report_abs(dev, db9_abs[0], !(data[j + 1] & 128) - !(data[j + 1] & 64)); |
301 | input_report_abs(dev + n, db9_abs[1], !(data[j + 1] & 32) - !(data[j + 1] & 16)); | 303 | input_report_abs(dev, db9_abs[1], !(data[j + 1] & 32) - !(data[j + 1] & 16)); |
302 | for (i = 0; i < 9; i++) | 304 | for (i = 0; i < 9; i++) |
303 | input_report_key(dev + n, db9_cd32_btn[i], ~data[j + db9_saturn_byte[i]] & db9_saturn_mask[i]); | 305 | input_report_key(dev, db9_cd32_btn[i], ~data[j + db9_saturn_byte[i]] & db9_saturn_mask[i]); |
304 | input_report_abs(dev + n, db9_abs[2], data[j + 3]); | 306 | input_report_abs(dev, db9_abs[2], data[j + 3]); |
305 | input_report_abs(dev + n, db9_abs[3], data[j + 4]); | 307 | input_report_abs(dev, db9_abs[3], data[j + 4]); |
306 | input_report_abs(dev + n, db9_abs[4], data[j + 5]); | 308 | input_report_abs(dev, db9_abs[4], data[j + 5]); |
307 | /* | 309 | /* |
308 | input_report_abs(dev + n, db9_abs[8], (data[j + 6] & 128 ? 0 : 1) - (data[j + 6] & 64 ? 0 : 1)); | 310 | input_report_abs(dev, db9_abs[8], (data[j + 6] & 128 ? 0 : 1) - (data[j + 6] & 64 ? 0 : 1)); |
309 | input_report_abs(dev + n, db9_abs[9], (data[j + 6] & 32 ? 0 : 1) - (data[j + 6] & 16 ? 0 : 1)); | 311 | input_report_abs(dev, db9_abs[9], (data[j + 6] & 32 ? 0 : 1) - (data[j + 6] & 16 ? 0 : 1)); |
310 | */ | 312 | */ |
311 | input_report_abs(dev + n, db9_abs[6], data[j + 7]); | 313 | input_report_abs(dev, db9_abs[6], data[j + 7]); |
312 | input_report_abs(dev + n, db9_abs[7], data[j + 8]); | 314 | input_report_abs(dev, db9_abs[7], data[j + 8]); |
313 | input_report_abs(dev + n, db9_abs[5], data[j + 9]); | 315 | input_report_abs(dev, db9_abs[5], data[j + 9]); |
314 | break; | 316 | break; |
315 | case 0xd3: /* sankyo ff (analog 1 axis + stop btn) */ | 317 | case 0xd3: /* sankyo ff (analog 1 axis + stop btn) */ |
316 | input_report_key(dev + n, BTN_A, data[j + 3] & 0x80); | 318 | input_report_key(dev, BTN_A, data[j + 3] & 0x80); |
317 | input_report_abs(dev + n, db9_abs[2], data[j + 3] & 0x7f); | 319 | input_report_abs(dev, db9_abs[2], data[j + 3] & 0x7f); |
318 | break; | 320 | break; |
319 | case 0xe3: /* shuttle mouse (analog 2 axis + buttons. signed value) */ | 321 | case 0xe3: /* shuttle mouse (analog 2 axis + buttons. signed value) */ |
320 | input_report_key(dev + n, BTN_START, data[j + 1] & 0x08); | 322 | input_report_key(dev, BTN_START, data[j + 1] & 0x08); |
321 | input_report_key(dev + n, BTN_A, data[j + 1] & 0x04); | 323 | input_report_key(dev, BTN_A, data[j + 1] & 0x04); |
322 | input_report_key(dev + n, BTN_C, data[j + 1] & 0x02); | 324 | input_report_key(dev, BTN_C, data[j + 1] & 0x02); |
323 | input_report_key(dev + n, BTN_B, data[j + 1] & 0x01); | 325 | input_report_key(dev, BTN_B, data[j + 1] & 0x01); |
324 | input_report_abs(dev + n, db9_abs[2], data[j + 2] ^ 0x80); | 326 | input_report_abs(dev, db9_abs[2], data[j + 2] ^ 0x80); |
325 | input_report_abs(dev + n, db9_abs[3], (0xff-(data[j + 3] ^ 0x80))+1); /* */ | 327 | input_report_abs(dev, db9_abs[3], (0xff-(data[j + 3] ^ 0x80))+1); /* */ |
326 | break; | 328 | break; |
327 | case 0xff: | 329 | case 0xff: |
328 | default: /* no pad */ | 330 | default: /* no pad */ |
329 | input_report_abs(dev + n, db9_abs[0], 0); | 331 | input_report_abs(dev, db9_abs[0], 0); |
330 | input_report_abs(dev + n, db9_abs[1], 0); | 332 | input_report_abs(dev, db9_abs[1], 0); |
331 | for (i = 0; i < 9; i++) | 333 | for (i = 0; i < 9; i++) |
332 | input_report_key(dev + n, db9_cd32_btn[i], 0); | 334 | input_report_key(dev, db9_cd32_btn[i], 0); |
333 | break; | 335 | break; |
334 | } | 336 | } |
335 | } | 337 | } |
336 | return n; | 338 | return n; |
337 | } | 339 | } |
338 | 340 | ||
339 | static int db9_saturn(int mode, struct parport *port, struct input_dev *dev) | 341 | static int db9_saturn(int mode, struct parport *port, struct input_dev *devs[]) |
340 | { | 342 | { |
341 | unsigned char id, data[60]; | 343 | unsigned char id, data[60]; |
342 | int type, n, max_pads; | 344 | int type, n, max_pads; |
@@ -361,7 +363,7 @@ static int db9_saturn(int mode, struct parport *port, struct input_dev *dev) | |||
361 | max_pads = min(db9_modes[mode].n_pads, DB9_MAX_DEVICES); | 363 | max_pads = min(db9_modes[mode].n_pads, DB9_MAX_DEVICES); |
362 | for (tmp = 0, i = 0; i < n; i++) { | 364 | for (tmp = 0, i = 0; i < n; i++) { |
363 | id = db9_saturn_read_packet(port, data, type + i, 1); | 365 | id = db9_saturn_read_packet(port, data, type + i, 1); |
364 | tmp = db9_saturn_report(id, data, dev, tmp, max_pads); | 366 | tmp = db9_saturn_report(id, data, devs, tmp, max_pads); |
365 | } | 367 | } |
366 | return 0; | 368 | return 0; |
367 | } | 369 | } |
@@ -489,7 +491,7 @@ static void db9_timer(unsigned long private) | |||
489 | case DB9_SATURN_DPP: | 491 | case DB9_SATURN_DPP: |
490 | case DB9_SATURN_DPP_2: | 492 | case DB9_SATURN_DPP_2: |
491 | 493 | ||
492 | db9_saturn(db9->mode, port, dev); | 494 | db9_saturn(db9->mode, port, db9->dev); |
493 | break; | 495 | break; |
494 | 496 | ||
495 | case DB9_CD32_PAD: | 497 | case DB9_CD32_PAD: |
@@ -614,7 +616,7 @@ static struct db9 __init *db9_probe(int parport, int mode) | |||
614 | if (!input_dev) { | 616 | if (!input_dev) { |
615 | printk(KERN_ERR "db9.c: Not enough memory for input device\n"); | 617 | printk(KERN_ERR "db9.c: Not enough memory for input device\n"); |
616 | err = -ENOMEM; | 618 | err = -ENOMEM; |
617 | goto err_free_devs; | 619 | goto err_unreg_devs; |
618 | } | 620 | } |
619 | 621 | ||
620 | sprintf(db9->phys[i], "%s/input%d", db9->pd->port->name, i); | 622 | sprintf(db9->phys[i], "%s/input%d", db9->pd->port->name, i); |
@@ -640,13 +642,17 @@ static struct db9 __init *db9_probe(int parport, int mode) | |||
640 | input_set_abs_params(input_dev, db9_abs[j], 1, 255, 0, 0); | 642 | input_set_abs_params(input_dev, db9_abs[j], 1, 255, 0, 0); |
641 | } | 643 | } |
642 | 644 | ||
643 | input_register_device(input_dev); | 645 | err = input_register_device(input_dev); |
646 | if (err) | ||
647 | goto err_free_dev; | ||
644 | } | 648 | } |
645 | 649 | ||
646 | parport_put_port(pp); | 650 | parport_put_port(pp); |
647 | return db9; | 651 | return db9; |
648 | 652 | ||
649 | err_free_devs: | 653 | err_free_dev: |
654 | input_free_device(db9->dev[i]); | ||
655 | err_unreg_devs: | ||
650 | while (--i >= 0) | 656 | while (--i >= 0) |
651 | input_unregister_device(db9->dev[i]); | 657 | input_unregister_device(db9->dev[i]); |
652 | kfree(db9); | 658 | kfree(db9); |
@@ -658,7 +664,7 @@ static struct db9 __init *db9_probe(int parport, int mode) | |||
658 | return ERR_PTR(err); | 664 | return ERR_PTR(err); |
659 | } | 665 | } |
660 | 666 | ||
661 | static void __exit db9_remove(struct db9 *db9) | 667 | static void db9_remove(struct db9 *db9) |
662 | { | 668 | { |
663 | int i; | 669 | int i; |
664 | 670 | ||
@@ -696,7 +702,8 @@ static int __init db9_init(void) | |||
696 | 702 | ||
697 | if (err) { | 703 | if (err) { |
698 | while (--i >= 0) | 704 | while (--i >= 0) |
699 | db9_remove(db9_base[i]); | 705 | if (db9_base[i]) |
706 | db9_remove(db9_base[i]); | ||
700 | return err; | 707 | return err; |
701 | } | 708 | } |
702 | 709 | ||
diff --git a/drivers/input/joystick/gamecon.c b/drivers/input/joystick/gamecon.c index 7df2d82f2c83..900587acdb47 100644 --- a/drivers/input/joystick/gamecon.c +++ b/drivers/input/joystick/gamecon.c | |||
@@ -159,6 +159,48 @@ static void gc_n64_read_packet(struct gc *gc, unsigned char *data) | |||
159 | 159 | ||
160 | } | 160 | } |
161 | 161 | ||
162 | static void gc_n64_process_packet(struct gc *gc) | ||
163 | { | ||
164 | unsigned char data[GC_N64_LENGTH]; | ||
165 | signed char axes[2]; | ||
166 | struct input_dev *dev; | ||
167 | int i, j, s; | ||
168 | |||
169 | gc_n64_read_packet(gc, data); | ||
170 | |||
171 | for (i = 0; i < GC_MAX_DEVICES; i++) { | ||
172 | |||
173 | dev = gc->dev[i]; | ||
174 | if (!dev) | ||
175 | continue; | ||
176 | |||
177 | s = gc_status_bit[i]; | ||
178 | |||
179 | if (s & gc->pads[GC_N64] & ~(data[8] | data[9])) { | ||
180 | |||
181 | axes[0] = axes[1] = 0; | ||
182 | |||
183 | for (j = 0; j < 8; j++) { | ||
184 | if (data[23 - j] & s) | ||
185 | axes[0] |= 1 << j; | ||
186 | if (data[31 - j] & s) | ||
187 | axes[1] |= 1 << j; | ||
188 | } | ||
189 | |||
190 | input_report_abs(dev, ABS_X, axes[0]); | ||
191 | input_report_abs(dev, ABS_Y, -axes[1]); | ||
192 | |||
193 | input_report_abs(dev, ABS_HAT0X, !(s & data[6]) - !(s & data[7])); | ||
194 | input_report_abs(dev, ABS_HAT0Y, !(s & data[4]) - !(s & data[5])); | ||
195 | |||
196 | for (j = 0; j < 10; j++) | ||
197 | input_report_key(dev, gc_n64_btn[j], s & data[gc_n64_bytes[j]]); | ||
198 | |||
199 | input_sync(dev); | ||
200 | } | ||
201 | } | ||
202 | } | ||
203 | |||
162 | /* | 204 | /* |
163 | * NES/SNES support. | 205 | * NES/SNES support. |
164 | */ | 206 | */ |
@@ -198,6 +240,39 @@ static void gc_nes_read_packet(struct gc *gc, int length, unsigned char *data) | |||
198 | } | 240 | } |
199 | } | 241 | } |
200 | 242 | ||
243 | static void gc_nes_process_packet(struct gc *gc) | ||
244 | { | ||
245 | unsigned char data[GC_SNES_LENGTH]; | ||
246 | struct input_dev *dev; | ||
247 | int i, j, s; | ||
248 | |||
249 | gc_nes_read_packet(gc, gc->pads[GC_SNES] ? GC_SNES_LENGTH : GC_NES_LENGTH, data); | ||
250 | |||
251 | for (i = 0; i < GC_MAX_DEVICES; i++) { | ||
252 | |||
253 | dev = gc->dev[i]; | ||
254 | if (!dev) | ||
255 | continue; | ||
256 | |||
257 | s = gc_status_bit[i]; | ||
258 | |||
259 | if (s & (gc->pads[GC_NES] | gc->pads[GC_SNES])) { | ||
260 | input_report_abs(dev, ABS_X, !(s & data[6]) - !(s & data[7])); | ||
261 | input_report_abs(dev, ABS_Y, !(s & data[4]) - !(s & data[5])); | ||
262 | } | ||
263 | |||
264 | if (s & gc->pads[GC_NES]) | ||
265 | for (j = 0; j < 4; j++) | ||
266 | input_report_key(dev, gc_snes_btn[j], s & data[gc_nes_bytes[j]]); | ||
267 | |||
268 | if (s & gc->pads[GC_SNES]) | ||
269 | for (j = 0; j < 8; j++) | ||
270 | input_report_key(dev, gc_snes_btn[j], s & data[gc_snes_bytes[j]]); | ||
271 | |||
272 | input_sync(dev); | ||
273 | } | ||
274 | } | ||
275 | |||
201 | /* | 276 | /* |
202 | * Multisystem joystick support | 277 | * Multisystem joystick support |
203 | */ | 278 | */ |
@@ -219,6 +294,35 @@ static void gc_multi_read_packet(struct gc *gc, int length, unsigned char *data) | |||
219 | } | 294 | } |
220 | } | 295 | } |
221 | 296 | ||
297 | static void gc_multi_process_packet(struct gc *gc) | ||
298 | { | ||
299 | unsigned char data[GC_MULTI2_LENGTH]; | ||
300 | struct input_dev *dev; | ||
301 | int i, s; | ||
302 | |||
303 | gc_multi_read_packet(gc, gc->pads[GC_MULTI2] ? GC_MULTI2_LENGTH : GC_MULTI_LENGTH, data); | ||
304 | |||
305 | for (i = 0; i < GC_MAX_DEVICES; i++) { | ||
306 | |||
307 | dev = gc->dev[i]; | ||
308 | if (!dev) | ||
309 | continue; | ||
310 | |||
311 | s = gc_status_bit[i]; | ||
312 | |||
313 | if (s & (gc->pads[GC_MULTI] | gc->pads[GC_MULTI2])) { | ||
314 | input_report_abs(dev, ABS_X, !(s & data[2]) - !(s & data[3])); | ||
315 | input_report_abs(dev, ABS_Y, !(s & data[0]) - !(s & data[1])); | ||
316 | input_report_key(dev, BTN_TRIGGER, s & data[4]); | ||
317 | } | ||
318 | |||
319 | if (s & gc->pads[GC_MULTI2]) | ||
320 | input_report_key(dev, BTN_THUMB, s & data[5]); | ||
321 | |||
322 | input_sync(dev); | ||
323 | } | ||
324 | } | ||
325 | |||
222 | /* | 326 | /* |
223 | * PSX support | 327 | * PSX support |
224 | * | 328 | * |
@@ -263,10 +367,11 @@ static short gc_psx_ddr_btn[] = { BTN_0, BTN_1, BTN_2, BTN_3 }; | |||
263 | * the psx pad. | 367 | * the psx pad. |
264 | */ | 368 | */ |
265 | 369 | ||
266 | static void gc_psx_command(struct gc *gc, int b, unsigned char data[5]) | 370 | static void gc_psx_command(struct gc *gc, int b, unsigned char data[GC_MAX_DEVICES]) |
267 | { | 371 | { |
268 | int i, j, cmd, read; | 372 | int i, j, cmd, read; |
269 | for (i = 0; i < 5; i++) | 373 | |
374 | for (i = 0; i < GC_MAX_DEVICES; i++) | ||
270 | data[i] = 0; | 375 | data[i] = 0; |
271 | 376 | ||
272 | for (i = 0; i < GC_PSX_LENGTH; i++, b >>= 1) { | 377 | for (i = 0; i < GC_PSX_LENGTH; i++, b >>= 1) { |
@@ -274,7 +379,7 @@ static void gc_psx_command(struct gc *gc, int b, unsigned char data[5]) | |||
274 | parport_write_data(gc->pd->port, cmd | GC_PSX_POWER); | 379 | parport_write_data(gc->pd->port, cmd | GC_PSX_POWER); |
275 | udelay(gc_psx_delay); | 380 | udelay(gc_psx_delay); |
276 | read = parport_read_status(gc->pd->port) ^ 0x80; | 381 | read = parport_read_status(gc->pd->port) ^ 0x80; |
277 | for (j = 0; j < 5; j++) | 382 | for (j = 0; j < GC_MAX_DEVICES; j++) |
278 | data[j] |= (read & gc_status_bit[j] & (gc->pads[GC_PSX] | gc->pads[GC_DDR])) ? (1 << i) : 0; | 383 | data[j] |= (read & gc_status_bit[j] & (gc->pads[GC_PSX] | gc->pads[GC_DDR])) ? (1 << i) : 0; |
279 | parport_write_data(gc->pd->port, cmd | GC_PSX_CLOCK | GC_PSX_POWER); | 384 | parport_write_data(gc->pd->port, cmd | GC_PSX_CLOCK | GC_PSX_POWER); |
280 | udelay(gc_psx_delay); | 385 | udelay(gc_psx_delay); |
@@ -286,11 +391,12 @@ static void gc_psx_command(struct gc *gc, int b, unsigned char data[5]) | |||
286 | * device identifier code. | 391 | * device identifier code. |
287 | */ | 392 | */ |
288 | 393 | ||
289 | static void gc_psx_read_packet(struct gc *gc, unsigned char data[5][GC_PSX_BYTES], unsigned char id[5]) | 394 | static void gc_psx_read_packet(struct gc *gc, unsigned char data[GC_MAX_DEVICES][GC_PSX_BYTES], |
395 | unsigned char id[GC_MAX_DEVICES]) | ||
290 | { | 396 | { |
291 | int i, j, max_len = 0; | 397 | int i, j, max_len = 0; |
292 | unsigned long flags; | 398 | unsigned long flags; |
293 | unsigned char data2[5]; | 399 | unsigned char data2[GC_MAX_DEVICES]; |
294 | 400 | ||
295 | parport_write_data(gc->pd->port, GC_PSX_CLOCK | GC_PSX_SELECT | GC_PSX_POWER); /* Select pad */ | 401 | parport_write_data(gc->pd->port, GC_PSX_CLOCK | GC_PSX_SELECT | GC_PSX_POWER); /* Select pad */ |
296 | udelay(gc_psx_delay); | 402 | udelay(gc_psx_delay); |
@@ -303,7 +409,7 @@ static void gc_psx_read_packet(struct gc *gc, unsigned char data[5][GC_PSX_BYTES | |||
303 | gc_psx_command(gc, 0x42, id); /* Get device ids */ | 409 | gc_psx_command(gc, 0x42, id); /* Get device ids */ |
304 | gc_psx_command(gc, 0, data2); /* Dump status */ | 410 | gc_psx_command(gc, 0, data2); /* Dump status */ |
305 | 411 | ||
306 | for (i =0; i < 5; i++) /* Find the longest pad */ | 412 | for (i =0; i < GC_MAX_DEVICES; i++) /* Find the longest pad */ |
307 | if((gc_status_bit[i] & (gc->pads[GC_PSX] | gc->pads[GC_DDR])) | 413 | if((gc_status_bit[i] & (gc->pads[GC_PSX] | gc->pads[GC_DDR])) |
308 | && (GC_PSX_LEN(id[i]) > max_len) | 414 | && (GC_PSX_LEN(id[i]) > max_len) |
309 | && (GC_PSX_LEN(id[i]) <= GC_PSX_BYTES)) | 415 | && (GC_PSX_LEN(id[i]) <= GC_PSX_BYTES)) |
@@ -311,7 +417,7 @@ static void gc_psx_read_packet(struct gc *gc, unsigned char data[5][GC_PSX_BYTES | |||
311 | 417 | ||
312 | for (i = 0; i < max_len; i++) { /* Read in all the data */ | 418 | for (i = 0; i < max_len; i++) { /* Read in all the data */ |
313 | gc_psx_command(gc, 0, data2); | 419 | gc_psx_command(gc, 0, data2); |
314 | for (j = 0; j < 5; j++) | 420 | for (j = 0; j < GC_MAX_DEVICES; j++) |
315 | data[j][i] = data2[j]; | 421 | data[j][i] = data2[j]; |
316 | } | 422 | } |
317 | 423 | ||
@@ -319,185 +425,124 @@ static void gc_psx_read_packet(struct gc *gc, unsigned char data[5][GC_PSX_BYTES | |||
319 | 425 | ||
320 | parport_write_data(gc->pd->port, GC_PSX_CLOCK | GC_PSX_SELECT | GC_PSX_POWER); | 426 | parport_write_data(gc->pd->port, GC_PSX_CLOCK | GC_PSX_SELECT | GC_PSX_POWER); |
321 | 427 | ||
322 | for(i = 0; i < 5; i++) /* Set id's to the real value */ | 428 | for(i = 0; i < GC_MAX_DEVICES; i++) /* Set id's to the real value */ |
323 | id[i] = GC_PSX_ID(id[i]); | 429 | id[i] = GC_PSX_ID(id[i]); |
324 | } | 430 | } |
325 | 431 | ||
326 | /* | 432 | static void gc_psx_process_packet(struct gc *gc) |
327 | * gc_timer() reads and analyzes console pads data. | 433 | { |
328 | */ | 434 | unsigned char data[GC_MAX_DEVICES][GC_PSX_BYTES]; |
435 | unsigned char id[GC_MAX_DEVICES]; | ||
436 | struct input_dev *dev; | ||
437 | int i, j; | ||
329 | 438 | ||
330 | #define GC_MAX_LENGTH GC_N64_LENGTH | 439 | gc_psx_read_packet(gc, data, id); |
331 | 440 | ||
332 | static void gc_timer(unsigned long private) | 441 | for (i = 0; i < GC_MAX_DEVICES; i++) { |
333 | { | ||
334 | struct gc *gc = (void *) private; | ||
335 | unsigned char data[GC_MAX_LENGTH]; | ||
336 | unsigned char data_psx[5][GC_PSX_BYTES]; | ||
337 | int i, j, s; | ||
338 | 442 | ||
339 | /* | 443 | dev = gc->dev[i]; |
340 | * N64 pads - must be read first, any read confuses them for 200 us | 444 | if (!dev) |
341 | */ | 445 | continue; |
342 | 446 | ||
343 | if (gc->pads[GC_N64]) { | 447 | switch (id[i]) { |
344 | 448 | ||
345 | gc_n64_read_packet(gc, data); | 449 | case GC_PSX_RUMBLE: |
346 | 450 | ||
347 | for (i = 0; i < 5; i++) { | 451 | input_report_key(dev, BTN_THUMBL, ~data[i][0] & 0x04); |
452 | input_report_key(dev, BTN_THUMBR, ~data[i][0] & 0x02); | ||
348 | 453 | ||
349 | s = gc_status_bit[i]; | 454 | case GC_PSX_NEGCON: |
455 | case GC_PSX_ANALOG: | ||
350 | 456 | ||
351 | if (s & gc->pads[GC_N64] & ~(data[8] | data[9])) { | 457 | if (gc->pads[GC_DDR] & gc_status_bit[i]) { |
458 | for(j = 0; j < 4; j++) | ||
459 | input_report_key(dev, gc_psx_ddr_btn[j], ~data[i][0] & (0x10 << j)); | ||
460 | } else { | ||
461 | for (j = 0; j < 4; j++) | ||
462 | input_report_abs(dev, gc_psx_abs[j + 2], data[i][j + 2]); | ||
352 | 463 | ||
353 | signed char axes[2]; | 464 | input_report_abs(dev, ABS_X, 128 + !(data[i][0] & 0x20) * 127 - !(data[i][0] & 0x80) * 128); |
354 | axes[0] = axes[1] = 0; | 465 | input_report_abs(dev, ABS_Y, 128 + !(data[i][0] & 0x40) * 127 - !(data[i][0] & 0x10) * 128); |
466 | } | ||
355 | 467 | ||
356 | for (j = 0; j < 8; j++) { | 468 | for (j = 0; j < 8; j++) |
357 | if (data[23 - j] & s) axes[0] |= 1 << j; | 469 | input_report_key(dev, gc_psx_btn[j], ~data[i][1] & (1 << j)); |
358 | if (data[31 - j] & s) axes[1] |= 1 << j; | 470 | |
471 | input_report_key(dev, BTN_START, ~data[i][0] & 0x08); | ||
472 | input_report_key(dev, BTN_SELECT, ~data[i][0] & 0x01); | ||
473 | |||
474 | input_sync(dev); | ||
475 | |||
476 | break; | ||
477 | |||
478 | case GC_PSX_NORMAL: | ||
479 | if (gc->pads[GC_DDR] & gc_status_bit[i]) { | ||
480 | for(j = 0; j < 4; j++) | ||
481 | input_report_key(dev, gc_psx_ddr_btn[j], ~data[i][0] & (0x10 << j)); | ||
482 | } else { | ||
483 | input_report_abs(dev, ABS_X, 128 + !(data[i][0] & 0x20) * 127 - !(data[i][0] & 0x80) * 128); | ||
484 | input_report_abs(dev, ABS_Y, 128 + !(data[i][0] & 0x40) * 127 - !(data[i][0] & 0x10) * 128); | ||
485 | |||
486 | /* for some reason if the extra axes are left unset they drift */ | ||
487 | /* for (j = 0; j < 4; j++) | ||
488 | input_report_abs(dev, gc_psx_abs[j + 2], 128); | ||
489 | * This needs to be debugged properly, | ||
490 | * maybe fuzz processing needs to be done in input_sync() | ||
491 | * --vojtech | ||
492 | */ | ||
359 | } | 493 | } |
360 | 494 | ||
361 | input_report_abs(gc->dev[i], ABS_X, axes[0]); | 495 | for (j = 0; j < 8; j++) |
362 | input_report_abs(gc->dev[i], ABS_Y, -axes[1]); | 496 | input_report_key(dev, gc_psx_btn[j], ~data[i][1] & (1 << j)); |
497 | |||
498 | input_report_key(dev, BTN_START, ~data[i][0] & 0x08); | ||
499 | input_report_key(dev, BTN_SELECT, ~data[i][0] & 0x01); | ||
363 | 500 | ||
364 | input_report_abs(gc->dev[i], ABS_HAT0X, !(s & data[6]) - !(s & data[7])); | 501 | input_sync(dev); |
365 | input_report_abs(gc->dev[i], ABS_HAT0Y, !(s & data[4]) - !(s & data[5])); | ||
366 | 502 | ||
367 | for (j = 0; j < 10; j++) | 503 | break; |
368 | input_report_key(gc->dev[i], gc_n64_btn[j], s & data[gc_n64_bytes[j]]); | ||
369 | 504 | ||
370 | input_sync(gc->dev[i]); | 505 | case 0: /* not a pad, ignore */ |
371 | } | 506 | break; |
372 | } | 507 | } |
373 | } | 508 | } |
509 | } | ||
374 | 510 | ||
375 | /* | 511 | /* |
376 | * NES and SNES pads | 512 | * gc_timer() initiates reads of console pads data. |
377 | */ | 513 | */ |
378 | 514 | ||
379 | if (gc->pads[GC_NES] || gc->pads[GC_SNES]) { | 515 | static void gc_timer(unsigned long private) |
380 | 516 | { | |
381 | gc_nes_read_packet(gc, gc->pads[GC_SNES] ? GC_SNES_LENGTH : GC_NES_LENGTH, data); | 517 | struct gc *gc = (void *) private; |
382 | |||
383 | for (i = 0; i < 5; i++) { | ||
384 | |||
385 | s = gc_status_bit[i]; | ||
386 | 518 | ||
387 | if (s & (gc->pads[GC_NES] | gc->pads[GC_SNES])) { | 519 | /* |
388 | input_report_abs(gc->dev[i], ABS_X, !(s & data[6]) - !(s & data[7])); | 520 | * N64 pads - must be read first, any read confuses them for 200 us |
389 | input_report_abs(gc->dev[i], ABS_Y, !(s & data[4]) - !(s & data[5])); | 521 | */ |
390 | } | ||
391 | 522 | ||
392 | if (s & gc->pads[GC_NES]) | 523 | if (gc->pads[GC_N64]) |
393 | for (j = 0; j < 4; j++) | 524 | gc_n64_process_packet(gc); |
394 | input_report_key(gc->dev[i], gc_snes_btn[j], s & data[gc_nes_bytes[j]]); | ||
395 | 525 | ||
396 | if (s & gc->pads[GC_SNES]) | 526 | /* |
397 | for (j = 0; j < 8; j++) | 527 | * NES and SNES pads |
398 | input_report_key(gc->dev[i], gc_snes_btn[j], s & data[gc_snes_bytes[j]]); | 528 | */ |
399 | 529 | ||
400 | input_sync(gc->dev[i]); | 530 | if (gc->pads[GC_NES] || gc->pads[GC_SNES]) |
401 | } | 531 | gc_nes_process_packet(gc); |
402 | } | ||
403 | 532 | ||
404 | /* | 533 | /* |
405 | * Multi and Multi2 joysticks | 534 | * Multi and Multi2 joysticks |
406 | */ | 535 | */ |
407 | 536 | ||
408 | if (gc->pads[GC_MULTI] || gc->pads[GC_MULTI2]) { | 537 | if (gc->pads[GC_MULTI] || gc->pads[GC_MULTI2]) |
409 | 538 | gc_multi_process_packet(gc); | |
410 | gc_multi_read_packet(gc, gc->pads[GC_MULTI2] ? GC_MULTI2_LENGTH : GC_MULTI_LENGTH, data); | ||
411 | |||
412 | for (i = 0; i < 5; i++) { | ||
413 | |||
414 | s = gc_status_bit[i]; | ||
415 | |||
416 | if (s & (gc->pads[GC_MULTI] | gc->pads[GC_MULTI2])) { | ||
417 | input_report_abs(gc->dev[i], ABS_X, !(s & data[2]) - !(s & data[3])); | ||
418 | input_report_abs(gc->dev[i], ABS_Y, !(s & data[0]) - !(s & data[1])); | ||
419 | input_report_key(gc->dev[i], BTN_TRIGGER, s & data[4]); | ||
420 | } | ||
421 | |||
422 | if (s & gc->pads[GC_MULTI2]) | ||
423 | input_report_key(gc->dev[i], BTN_THUMB, s & data[5]); | ||
424 | |||
425 | input_sync(gc->dev[i]); | ||
426 | } | ||
427 | } | ||
428 | 539 | ||
429 | /* | 540 | /* |
430 | * PSX controllers | 541 | * PSX controllers |
431 | */ | 542 | */ |
432 | 543 | ||
433 | if (gc->pads[GC_PSX] || gc->pads[GC_DDR]) { | 544 | if (gc->pads[GC_PSX] || gc->pads[GC_DDR]) |
434 | 545 | gc_psx_process_packet(gc); | |
435 | gc_psx_read_packet(gc, data_psx, data); | ||
436 | |||
437 | for (i = 0; i < 5; i++) { | ||
438 | switch (data[i]) { | ||
439 | |||
440 | case GC_PSX_RUMBLE: | ||
441 | |||
442 | input_report_key(gc->dev[i], BTN_THUMBL, ~data_psx[i][0] & 0x04); | ||
443 | input_report_key(gc->dev[i], BTN_THUMBR, ~data_psx[i][0] & 0x02); | ||
444 | |||
445 | case GC_PSX_NEGCON: | ||
446 | case GC_PSX_ANALOG: | ||
447 | |||
448 | if (gc->pads[GC_DDR] & gc_status_bit[i]) { | ||
449 | for(j = 0; j < 4; j++) | ||
450 | input_report_key(gc->dev[i], gc_psx_ddr_btn[j], ~data_psx[i][0] & (0x10 << j)); | ||
451 | } else { | ||
452 | for (j = 0; j < 4; j++) | ||
453 | input_report_abs(gc->dev[i], gc_psx_abs[j+2], data_psx[i][j + 2]); | ||
454 | |||
455 | input_report_abs(gc->dev[i], ABS_X, 128 + !(data_psx[i][0] & 0x20) * 127 - !(data_psx[i][0] & 0x80) * 128); | ||
456 | input_report_abs(gc->dev[i], ABS_Y, 128 + !(data_psx[i][0] & 0x40) * 127 - !(data_psx[i][0] & 0x10) * 128); | ||
457 | } | ||
458 | |||
459 | for (j = 0; j < 8; j++) | ||
460 | input_report_key(gc->dev[i], gc_psx_btn[j], ~data_psx[i][1] & (1 << j)); | ||
461 | |||
462 | input_report_key(gc->dev[i], BTN_START, ~data_psx[i][0] & 0x08); | ||
463 | input_report_key(gc->dev[i], BTN_SELECT, ~data_psx[i][0] & 0x01); | ||
464 | |||
465 | input_sync(gc->dev[i]); | ||
466 | |||
467 | break; | ||
468 | |||
469 | case GC_PSX_NORMAL: | ||
470 | if (gc->pads[GC_DDR] & gc_status_bit[i]) { | ||
471 | for(j = 0; j < 4; j++) | ||
472 | input_report_key(gc->dev[i], gc_psx_ddr_btn[j], ~data_psx[i][0] & (0x10 << j)); | ||
473 | } else { | ||
474 | input_report_abs(gc->dev[i], ABS_X, 128 + !(data_psx[i][0] & 0x20) * 127 - !(data_psx[i][0] & 0x80) * 128); | ||
475 | input_report_abs(gc->dev[i], ABS_Y, 128 + !(data_psx[i][0] & 0x40) * 127 - !(data_psx[i][0] & 0x10) * 128); | ||
476 | |||
477 | /* for some reason if the extra axes are left unset they drift */ | ||
478 | /* for (j = 0; j < 4; j++) | ||
479 | input_report_abs(gc->dev[i], gc_psx_abs[j+2], 128); | ||
480 | * This needs to be debugged properly, | ||
481 | * maybe fuzz processing needs to be done in input_sync() | ||
482 | * --vojtech | ||
483 | */ | ||
484 | } | ||
485 | |||
486 | for (j = 0; j < 8; j++) | ||
487 | input_report_key(gc->dev[i], gc_psx_btn[j], ~data_psx[i][1] & (1 << j)); | ||
488 | |||
489 | input_report_key(gc->dev[i], BTN_START, ~data_psx[i][0] & 0x08); | ||
490 | input_report_key(gc->dev[i], BTN_SELECT, ~data_psx[i][0] & 0x01); | ||
491 | |||
492 | input_sync(gc->dev[i]); | ||
493 | |||
494 | break; | ||
495 | |||
496 | case 0: /* not a pad, ignore */ | ||
497 | break; | ||
498 | } | ||
499 | } | ||
500 | } | ||
501 | 546 | ||
502 | mod_timer(&gc->timer, jiffies + GC_REFRESH_TIME); | 547 | mod_timer(&gc->timer, jiffies + GC_REFRESH_TIME); |
503 | } | 548 | } |
@@ -654,16 +699,18 @@ static struct gc __init *gc_probe(int parport, int *pads, int n_pads) | |||
654 | gc->timer.data = (long) gc; | 699 | gc->timer.data = (long) gc; |
655 | gc->timer.function = gc_timer; | 700 | gc->timer.function = gc_timer; |
656 | 701 | ||
657 | for (i = 0; i < n_pads; i++) { | 702 | for (i = 0; i < n_pads && i < GC_MAX_DEVICES; i++) { |
658 | if (!pads[i]) | 703 | if (!pads[i]) |
659 | continue; | 704 | continue; |
660 | 705 | ||
661 | sprintf(gc->phys[i], "%s/input%d", gc->pd->port->name, i); | 706 | sprintf(gc->phys[i], "%s/input%d", gc->pd->port->name, i); |
662 | err = gc_setup_pad(gc, i, pads[i]); | 707 | err = gc_setup_pad(gc, i, pads[i]); |
663 | if (err) | 708 | if (err) |
664 | goto err_free_devs; | 709 | goto err_unreg_devs; |
665 | 710 | ||
666 | input_register_device(gc->dev[i]); | 711 | err = input_register_device(gc->dev[i]); |
712 | if (err) | ||
713 | goto err_free_dev; | ||
667 | } | 714 | } |
668 | 715 | ||
669 | if (!gc->pads[0]) { | 716 | if (!gc->pads[0]) { |
@@ -675,9 +722,12 @@ static struct gc __init *gc_probe(int parport, int *pads, int n_pads) | |||
675 | parport_put_port(pp); | 722 | parport_put_port(pp); |
676 | return gc; | 723 | return gc; |
677 | 724 | ||
678 | err_free_devs: | 725 | err_free_dev: |
726 | input_free_device(gc->dev[i]); | ||
727 | err_unreg_devs: | ||
679 | while (--i >= 0) | 728 | while (--i >= 0) |
680 | input_unregister_device(gc->dev[i]); | 729 | if (gc->dev[i]) |
730 | input_unregister_device(gc->dev[i]); | ||
681 | err_free_gc: | 731 | err_free_gc: |
682 | kfree(gc); | 732 | kfree(gc); |
683 | err_unreg_pardev: | 733 | err_unreg_pardev: |
@@ -688,7 +738,7 @@ static struct gc __init *gc_probe(int parport, int *pads, int n_pads) | |||
688 | return ERR_PTR(err); | 738 | return ERR_PTR(err); |
689 | } | 739 | } |
690 | 740 | ||
691 | static void __exit gc_remove(struct gc *gc) | 741 | static void gc_remove(struct gc *gc) |
692 | { | 742 | { |
693 | int i; | 743 | int i; |
694 | 744 | ||
@@ -726,7 +776,8 @@ static int __init gc_init(void) | |||
726 | 776 | ||
727 | if (err) { | 777 | if (err) { |
728 | while (--i >= 0) | 778 | while (--i >= 0) |
729 | gc_remove(gc_base[i]); | 779 | if (gc_base[i]) |
780 | gc_remove(gc_base[i]); | ||
730 | return err; | 781 | return err; |
731 | } | 782 | } |
732 | 783 | ||
diff --git a/drivers/input/joystick/grip.c b/drivers/input/joystick/grip.c index a936e7aedb10..20cb98ac2d79 100644 --- a/drivers/input/joystick/grip.c +++ b/drivers/input/joystick/grip.c | |||
@@ -192,6 +192,9 @@ static void grip_poll(struct gameport *gameport) | |||
192 | for (i = 0; i < 2; i++) { | 192 | for (i = 0; i < 2; i++) { |
193 | 193 | ||
194 | dev = grip->dev[i]; | 194 | dev = grip->dev[i]; |
195 | if (!dev) | ||
196 | continue; | ||
197 | |||
195 | grip->reads++; | 198 | grip->reads++; |
196 | 199 | ||
197 | switch (grip->mode[i]) { | 200 | switch (grip->mode[i]) { |
@@ -381,12 +384,15 @@ static int grip_connect(struct gameport *gameport, struct gameport_driver *drv) | |||
381 | if (t > 0) | 384 | if (t > 0) |
382 | set_bit(t, input_dev->keybit); | 385 | set_bit(t, input_dev->keybit); |
383 | 386 | ||
384 | input_register_device(grip->dev[i]); | 387 | err = input_register_device(grip->dev[i]); |
388 | if (err) | ||
389 | goto fail4; | ||
385 | } | 390 | } |
386 | 391 | ||
387 | return 0; | 392 | return 0; |
388 | 393 | ||
389 | fail3: for (i = 0; i < 2; i++) | 394 | fail4: input_free_device(grip->dev[i]); |
395 | fail3: while (--i >= 0) | ||
390 | if (grip->dev[i]) | 396 | if (grip->dev[i]) |
391 | input_unregister_device(grip->dev[i]); | 397 | input_unregister_device(grip->dev[i]); |
392 | fail2: gameport_close(gameport); | 398 | fail2: gameport_close(gameport); |
@@ -411,6 +417,7 @@ static void grip_disconnect(struct gameport *gameport) | |||
411 | static struct gameport_driver grip_drv = { | 417 | static struct gameport_driver grip_drv = { |
412 | .driver = { | 418 | .driver = { |
413 | .name = "grip", | 419 | .name = "grip", |
420 | .owner = THIS_MODULE, | ||
414 | }, | 421 | }, |
415 | .description = DRIVER_DESC, | 422 | .description = DRIVER_DESC, |
416 | .connect = grip_connect, | 423 | .connect = grip_connect, |
diff --git a/drivers/input/joystick/iforce/iforce-main.c b/drivers/input/joystick/iforce/iforce-main.c index 64b9c31c47fc..b6bc04998047 100644 --- a/drivers/input/joystick/iforce/iforce-main.c +++ b/drivers/input/joystick/iforce/iforce-main.c | |||
@@ -345,7 +345,7 @@ int iforce_init_device(struct iforce *iforce) | |||
345 | int i; | 345 | int i; |
346 | 346 | ||
347 | input_dev = input_allocate_device(); | 347 | input_dev = input_allocate_device(); |
348 | if (input_dev) | 348 | if (!input_dev) |
349 | return -ENOMEM; | 349 | return -ENOMEM; |
350 | 350 | ||
351 | init_waitqueue_head(&iforce->wait); | 351 | init_waitqueue_head(&iforce->wait); |
diff --git a/drivers/input/joystick/iforce/iforce-packets.c b/drivers/input/joystick/iforce/iforce-packets.c index 4a2629243e19..76cb1f88f4e8 100644 --- a/drivers/input/joystick/iforce/iforce-packets.c +++ b/drivers/input/joystick/iforce/iforce-packets.c | |||
@@ -167,9 +167,9 @@ void iforce_process_packet(struct iforce *iforce, u16 cmd, unsigned char *data, | |||
167 | iforce->expect_packet = 0; | 167 | iforce->expect_packet = 0; |
168 | iforce->ecmd = cmd; | 168 | iforce->ecmd = cmd; |
169 | memcpy(iforce->edata, data, IFORCE_MAX_LENGTH); | 169 | memcpy(iforce->edata, data, IFORCE_MAX_LENGTH); |
170 | wake_up(&iforce->wait); | ||
171 | } | 170 | } |
172 | #endif | 171 | #endif |
172 | wake_up(&iforce->wait); | ||
173 | 173 | ||
174 | if (!iforce->type) { | 174 | if (!iforce->type) { |
175 | being_used--; | 175 | being_used--; |
@@ -264,7 +264,7 @@ int iforce_get_id_packet(struct iforce *iforce, char *packet) | |||
264 | wait_event_interruptible_timeout(iforce->wait, | 264 | wait_event_interruptible_timeout(iforce->wait, |
265 | iforce->ctrl->status != -EINPROGRESS, HZ); | 265 | iforce->ctrl->status != -EINPROGRESS, HZ); |
266 | 266 | ||
267 | if (iforce->ctrl->status != -EINPROGRESS) { | 267 | if (iforce->ctrl->status) { |
268 | usb_unlink_urb(iforce->ctrl); | 268 | usb_unlink_urb(iforce->ctrl); |
269 | return -1; | 269 | return -1; |
270 | } | 270 | } |
diff --git a/drivers/input/joystick/iforce/iforce-usb.c b/drivers/input/joystick/iforce/iforce-usb.c index bc2fce60f9f8..fe79d158456d 100644 --- a/drivers/input/joystick/iforce/iforce-usb.c +++ b/drivers/input/joystick/iforce/iforce-usb.c | |||
@@ -95,7 +95,6 @@ static void iforce_usb_irq(struct urb *urb, struct pt_regs *regs) | |||
95 | goto exit; | 95 | goto exit; |
96 | } | 96 | } |
97 | 97 | ||
98 | wake_up(&iforce->wait); | ||
99 | iforce_process_packet(iforce, | 98 | iforce_process_packet(iforce, |
100 | (iforce->data[0] << 8) | (urb->actual_length - 1), iforce->data + 1, regs); | 99 | (iforce->data[0] << 8) | (urb->actual_length - 1), iforce->data + 1, regs); |
101 | 100 | ||
diff --git a/drivers/input/joystick/sidewinder.c b/drivers/input/joystick/sidewinder.c index 78dd163cd702..2b2ec1057dee 100644 --- a/drivers/input/joystick/sidewinder.c +++ b/drivers/input/joystick/sidewinder.c | |||
@@ -736,7 +736,7 @@ static int sw_connect(struct gameport *gameport, struct gameport_driver *drv) | |||
736 | sprintf(sw->name, "Microsoft SideWinder %s", sw_name[sw->type]); | 736 | sprintf(sw->name, "Microsoft SideWinder %s", sw_name[sw->type]); |
737 | sprintf(sw->phys[i], "%s/input%d", gameport->phys, i); | 737 | sprintf(sw->phys[i], "%s/input%d", gameport->phys, i); |
738 | 738 | ||
739 | input_dev = input_allocate_device(); | 739 | sw->dev[i] = input_dev = input_allocate_device(); |
740 | if (!input_dev) { | 740 | if (!input_dev) { |
741 | err = -ENOMEM; | 741 | err = -ENOMEM; |
742 | goto fail3; | 742 | goto fail3; |
@@ -771,12 +771,15 @@ static int sw_connect(struct gameport *gameport, struct gameport_driver *drv) | |||
771 | 771 | ||
772 | dbg("%s%s [%d-bit id %d data %d]\n", sw->name, comment, m, l, k); | 772 | dbg("%s%s [%d-bit id %d data %d]\n", sw->name, comment, m, l, k); |
773 | 773 | ||
774 | input_register_device(sw->dev[i]); | 774 | err = input_register_device(sw->dev[i]); |
775 | if (err) | ||
776 | goto fail4; | ||
775 | } | 777 | } |
776 | 778 | ||
777 | return 0; | 779 | return 0; |
778 | 780 | ||
779 | fail3: while (--i >= 0) | 781 | fail4: input_free_device(sw->dev[i]); |
782 | fail3: while (--i >= 0) | ||
780 | input_unregister_device(sw->dev[i]); | 783 | input_unregister_device(sw->dev[i]); |
781 | fail2: gameport_close(gameport); | 784 | fail2: gameport_close(gameport); |
782 | fail1: gameport_set_drvdata(gameport, NULL); | 785 | fail1: gameport_set_drvdata(gameport, NULL); |
@@ -801,6 +804,7 @@ static void sw_disconnect(struct gameport *gameport) | |||
801 | static struct gameport_driver sw_drv = { | 804 | static struct gameport_driver sw_drv = { |
802 | .driver = { | 805 | .driver = { |
803 | .name = "sidewinder", | 806 | .name = "sidewinder", |
807 | .owner = THIS_MODULE, | ||
804 | }, | 808 | }, |
805 | .description = DRIVER_DESC, | 809 | .description = DRIVER_DESC, |
806 | .connect = sw_connect, | 810 | .connect = sw_connect, |
diff --git a/drivers/input/joystick/tmdc.c b/drivers/input/joystick/tmdc.c index 60e2aac7d06e..bb23ed2a04a6 100644 --- a/drivers/input/joystick/tmdc.c +++ b/drivers/input/joystick/tmdc.c | |||
@@ -284,13 +284,13 @@ static int tmdc_setup_port(struct tmdc *tmdc, int idx, unsigned char *data) | |||
284 | struct tmdc_port *port; | 284 | struct tmdc_port *port; |
285 | struct input_dev *input_dev; | 285 | struct input_dev *input_dev; |
286 | int i, j, b = 0; | 286 | int i, j, b = 0; |
287 | int err; | ||
287 | 288 | ||
288 | tmdc->port[idx] = port = kzalloc(sizeof (struct tmdc_port), GFP_KERNEL); | 289 | tmdc->port[idx] = port = kzalloc(sizeof (struct tmdc_port), GFP_KERNEL); |
289 | input_dev = input_allocate_device(); | 290 | input_dev = input_allocate_device(); |
290 | if (!port || !input_dev) { | 291 | if (!port || !input_dev) { |
291 | kfree(port); | 292 | err = -ENOMEM; |
292 | input_free_device(input_dev); | 293 | goto fail; |
293 | return -ENOMEM; | ||
294 | } | 294 | } |
295 | 295 | ||
296 | port->mode = data[TMDC_BYTE_ID]; | 296 | port->mode = data[TMDC_BYTE_ID]; |
@@ -347,9 +347,15 @@ static int tmdc_setup_port(struct tmdc *tmdc, int idx, unsigned char *data) | |||
347 | b += port->btnc[i]; | 347 | b += port->btnc[i]; |
348 | } | 348 | } |
349 | 349 | ||
350 | input_register_device(port->dev); | 350 | err = input_register_device(port->dev); |
351 | if (err) | ||
352 | goto fail; | ||
351 | 353 | ||
352 | return 0; | 354 | return 0; |
355 | |||
356 | fail: input_free_device(input_dev); | ||
357 | kfree(port); | ||
358 | return err; | ||
353 | } | 359 | } |
354 | 360 | ||
355 | /* | 361 | /* |
@@ -424,6 +430,7 @@ static void tmdc_disconnect(struct gameport *gameport) | |||
424 | static struct gameport_driver tmdc_drv = { | 430 | static struct gameport_driver tmdc_drv = { |
425 | .driver = { | 431 | .driver = { |
426 | .name = "tmdc", | 432 | .name = "tmdc", |
433 | .owner = THIS_MODULE, | ||
427 | }, | 434 | }, |
428 | .description = DRIVER_DESC, | 435 | .description = DRIVER_DESC, |
429 | .connect = tmdc_connect, | 436 | .connect = tmdc_connect, |
diff --git a/drivers/input/joystick/turbografx.c b/drivers/input/joystick/turbografx.c index 7e9764937d06..b154938e88a4 100644 --- a/drivers/input/joystick/turbografx.c +++ b/drivers/input/joystick/turbografx.c | |||
@@ -204,14 +204,14 @@ static struct tgfx __init *tgfx_probe(int parport, int *n_buttons, int n_devs) | |||
204 | if (n_buttons[i] > 6) { | 204 | if (n_buttons[i] > 6) { |
205 | printk(KERN_ERR "turbografx.c: Invalid number of buttons %d\n", n_buttons[i]); | 205 | printk(KERN_ERR "turbografx.c: Invalid number of buttons %d\n", n_buttons[i]); |
206 | err = -EINVAL; | 206 | err = -EINVAL; |
207 | goto err_free_devs; | 207 | goto err_unreg_devs; |
208 | } | 208 | } |
209 | 209 | ||
210 | tgfx->dev[i] = input_dev = input_allocate_device(); | 210 | tgfx->dev[i] = input_dev = input_allocate_device(); |
211 | if (!input_dev) { | 211 | if (!input_dev) { |
212 | printk(KERN_ERR "turbografx.c: Not enough memory for input device\n"); | 212 | printk(KERN_ERR "turbografx.c: Not enough memory for input device\n"); |
213 | err = -ENOMEM; | 213 | err = -ENOMEM; |
214 | goto err_free_devs; | 214 | goto err_unreg_devs; |
215 | } | 215 | } |
216 | 216 | ||
217 | tgfx->sticks |= (1 << i); | 217 | tgfx->sticks |= (1 << i); |
@@ -238,7 +238,9 @@ static struct tgfx __init *tgfx_probe(int parport, int *n_buttons, int n_devs) | |||
238 | for (j = 0; j < n_buttons[i]; j++) | 238 | for (j = 0; j < n_buttons[i]; j++) |
239 | set_bit(tgfx_buttons[j], input_dev->keybit); | 239 | set_bit(tgfx_buttons[j], input_dev->keybit); |
240 | 240 | ||
241 | input_register_device(tgfx->dev[i]); | 241 | err = input_register_device(tgfx->dev[i]); |
242 | if (err) | ||
243 | goto err_free_dev; | ||
242 | } | 244 | } |
243 | 245 | ||
244 | if (!tgfx->sticks) { | 246 | if (!tgfx->sticks) { |
@@ -249,9 +251,12 @@ static struct tgfx __init *tgfx_probe(int parport, int *n_buttons, int n_devs) | |||
249 | 251 | ||
250 | return tgfx; | 252 | return tgfx; |
251 | 253 | ||
252 | err_free_devs: | 254 | err_free_dev: |
255 | input_free_device(tgfx->dev[i]); | ||
256 | err_unreg_devs: | ||
253 | while (--i >= 0) | 257 | while (--i >= 0) |
254 | input_unregister_device(tgfx->dev[i]); | 258 | if (tgfx->dev[i]) |
259 | input_unregister_device(tgfx->dev[i]); | ||
255 | err_free_tgfx: | 260 | err_free_tgfx: |
256 | kfree(tgfx); | 261 | kfree(tgfx); |
257 | err_unreg_pardev: | 262 | err_unreg_pardev: |
@@ -262,7 +267,7 @@ static struct tgfx __init *tgfx_probe(int parport, int *n_buttons, int n_devs) | |||
262 | return ERR_PTR(err); | 267 | return ERR_PTR(err); |
263 | } | 268 | } |
264 | 269 | ||
265 | static void __exit tgfx_remove(struct tgfx *tgfx) | 270 | static void tgfx_remove(struct tgfx *tgfx) |
266 | { | 271 | { |
267 | int i; | 272 | int i; |
268 | 273 | ||
@@ -300,7 +305,8 @@ static int __init tgfx_init(void) | |||
300 | 305 | ||
301 | if (err) { | 306 | if (err) { |
302 | while (--i >= 0) | 307 | while (--i >= 0) |
303 | tgfx_remove(tgfx_base[i]); | 308 | if (tgfx_base[i]) |
309 | tgfx_remove(tgfx_base[i]); | ||
304 | return err; | 310 | return err; |
305 | } | 311 | } |
306 | 312 | ||
diff --git a/drivers/input/joystick/twidjoy.c b/drivers/input/joystick/twidjoy.c index cd3a1e742a30..7f8b0093c5bc 100644 --- a/drivers/input/joystick/twidjoy.c +++ b/drivers/input/joystick/twidjoy.c | |||
@@ -265,13 +265,13 @@ static struct serio_driver twidjoy_drv = { | |||
265 | * The functions for inserting/removing us as a module. | 265 | * The functions for inserting/removing us as a module. |
266 | */ | 266 | */ |
267 | 267 | ||
268 | int __init twidjoy_init(void) | 268 | static int __init twidjoy_init(void) |
269 | { | 269 | { |
270 | serio_register_driver(&twidjoy_drv); | 270 | serio_register_driver(&twidjoy_drv); |
271 | return 0; | 271 | return 0; |
272 | } | 272 | } |
273 | 273 | ||
274 | void __exit twidjoy_exit(void) | 274 | static void __exit twidjoy_exit(void) |
275 | { | 275 | { |
276 | serio_unregister_driver(&twidjoy_drv); | 276 | serio_unregister_driver(&twidjoy_drv); |
277 | } | 277 | } |
diff --git a/drivers/input/keyboard/Makefile b/drivers/input/keyboard/Makefile index 6e0afbb22383..2708167ba175 100644 --- a/drivers/input/keyboard/Makefile +++ b/drivers/input/keyboard/Makefile | |||
@@ -11,7 +11,6 @@ obj-$(CONFIG_KEYBOARD_XTKBD) += xtkbd.o | |||
11 | obj-$(CONFIG_KEYBOARD_AMIGA) += amikbd.o | 11 | obj-$(CONFIG_KEYBOARD_AMIGA) += amikbd.o |
12 | obj-$(CONFIG_KEYBOARD_LOCOMO) += locomokbd.o | 12 | obj-$(CONFIG_KEYBOARD_LOCOMO) += locomokbd.o |
13 | obj-$(CONFIG_KEYBOARD_NEWTON) += newtonkbd.o | 13 | obj-$(CONFIG_KEYBOARD_NEWTON) += newtonkbd.o |
14 | obj-$(CONFIG_KEYBOARD_98KBD) += 98kbd.o | ||
15 | obj-$(CONFIG_KEYBOARD_CORGI) += corgikbd.o | 14 | obj-$(CONFIG_KEYBOARD_CORGI) += corgikbd.o |
16 | obj-$(CONFIG_KEYBOARD_SPITZ) += spitzkbd.o | 15 | obj-$(CONFIG_KEYBOARD_SPITZ) += spitzkbd.o |
17 | obj-$(CONFIG_KEYBOARD_HIL) += hil_kbd.o | 16 | obj-$(CONFIG_KEYBOARD_HIL) += hil_kbd.o |
diff --git a/drivers/input/misc/Kconfig b/drivers/input/misc/Kconfig index e08dbe08f46d..4bad588d0e5d 100644 --- a/drivers/input/misc/Kconfig +++ b/drivers/input/misc/Kconfig | |||
@@ -50,6 +50,18 @@ config INPUT_WISTRON_BTNS | |||
50 | To compile this driver as a module, choose M here: the module will | 50 | To compile this driver as a module, choose M here: the module will |
51 | be called wistron_btns. | 51 | be called wistron_btns. |
52 | 52 | ||
53 | config INPUT_IXP4XX_BEEPER | ||
54 | tristate "IXP4XX Beeper support" | ||
55 | depends on ARCH_IXP4XX | ||
56 | help | ||
57 | If you say yes here, you can connect a beeper to the | ||
58 | ixp4xx gpio pins. This is used by the LinkSys NSLU2. | ||
59 | |||
60 | If unsure, say Y. | ||
61 | |||
62 | To compile this driver as a module, choose M here: the | ||
63 | module will be called ixp4xx-beeper. | ||
64 | |||
53 | config INPUT_UINPUT | 65 | config INPUT_UINPUT |
54 | tristate "User level driver support" | 66 | tristate "User level driver support" |
55 | help | 67 | help |
diff --git a/drivers/input/misc/Makefile b/drivers/input/misc/Makefile index ce44cce01285..415c49178985 100644 --- a/drivers/input/misc/Makefile +++ b/drivers/input/misc/Makefile | |||
@@ -7,7 +7,7 @@ | |||
7 | obj-$(CONFIG_INPUT_SPARCSPKR) += sparcspkr.o | 7 | obj-$(CONFIG_INPUT_SPARCSPKR) += sparcspkr.o |
8 | obj-$(CONFIG_INPUT_PCSPKR) += pcspkr.o | 8 | obj-$(CONFIG_INPUT_PCSPKR) += pcspkr.o |
9 | obj-$(CONFIG_INPUT_M68K_BEEP) += m68kspkr.o | 9 | obj-$(CONFIG_INPUT_M68K_BEEP) += m68kspkr.o |
10 | obj-$(CONFIG_INPUT_98SPKR) += 98spkr.o | ||
11 | obj-$(CONFIG_INPUT_UINPUT) += uinput.o | 10 | obj-$(CONFIG_INPUT_UINPUT) += uinput.o |
12 | obj-$(CONFIG_INPUT_WISTRON_BTNS) += wistron_btns.o | 11 | obj-$(CONFIG_INPUT_WISTRON_BTNS) += wistron_btns.o |
13 | obj-$(CONFIG_HP_SDC_RTC) += hp_sdc_rtc.o | 12 | obj-$(CONFIG_HP_SDC_RTC) += hp_sdc_rtc.o |
13 | obj-$(CONFIG_INPUT_IXP4XX_BEEPER) += ixp4xx-beeper.o | ||
diff --git a/drivers/input/misc/ixp4xx-beeper.c b/drivers/input/misc/ixp4xx-beeper.c new file mode 100644 index 000000000000..3a6ae85cd69c --- /dev/null +++ b/drivers/input/misc/ixp4xx-beeper.c | |||
@@ -0,0 +1,184 @@ | |||
1 | /* | ||
2 | * Generic IXP4xx beeper driver | ||
3 | * | ||
4 | * Copyright (C) 2005 Tower Technologies | ||
5 | * | ||
6 | * based on nslu2-io.c | ||
7 | * Copyright (C) 2004 Karen Spearel | ||
8 | * | ||
9 | * Author: Alessandro Zummo <a.zummo@towertech.it> | ||
10 | * Maintainers: http://www.nslu2-linux.org/ | ||
11 | * | ||
12 | * This program is free software; you can redistribute it and/or modify | ||
13 | * it under the terms of the GNU General Public License version 2 as | ||
14 | * published by the Free Software Foundation. | ||
15 | * | ||
16 | */ | ||
17 | |||
18 | #include <linux/module.h> | ||
19 | #include <linux/input.h> | ||
20 | #include <linux/delay.h> | ||
21 | #include <linux/platform_device.h> | ||
22 | #include <linux/interrupt.h> | ||
23 | #include <asm/hardware.h> | ||
24 | |||
25 | MODULE_AUTHOR("Alessandro Zummo <a.zummo@towertech.it>"); | ||
26 | MODULE_DESCRIPTION("ixp4xx beeper driver"); | ||
27 | MODULE_LICENSE("GPL"); | ||
28 | |||
29 | static DEFINE_SPINLOCK(beep_lock); | ||
30 | |||
31 | static void ixp4xx_spkr_control(unsigned int pin, unsigned int count) | ||
32 | { | ||
33 | unsigned long flags; | ||
34 | |||
35 | spin_lock_irqsave(&beep_lock, flags); | ||
36 | |||
37 | if (count) { | ||
38 | gpio_line_config(pin, IXP4XX_GPIO_OUT); | ||
39 | gpio_line_set(pin, IXP4XX_GPIO_LOW); | ||
40 | |||
41 | *IXP4XX_OSRT2 = (count & ~IXP4XX_OST_RELOAD_MASK) | IXP4XX_OST_ENABLE; | ||
42 | } else { | ||
43 | gpio_line_config(pin, IXP4XX_GPIO_IN); | ||
44 | gpio_line_set(pin, IXP4XX_GPIO_HIGH); | ||
45 | |||
46 | *IXP4XX_OSRT2 = 0; | ||
47 | } | ||
48 | |||
49 | spin_unlock_irqrestore(&beep_lock, flags); | ||
50 | } | ||
51 | |||
52 | static int ixp4xx_spkr_event(struct input_dev *dev, unsigned int type, unsigned int code, int value) | ||
53 | { | ||
54 | unsigned int pin = (unsigned int) dev->private; | ||
55 | unsigned int count = 0; | ||
56 | |||
57 | if (type != EV_SND) | ||
58 | return -1; | ||
59 | |||
60 | switch (code) { | ||
61 | case SND_BELL: | ||
62 | if (value) | ||
63 | value = 1000; | ||
64 | case SND_TONE: | ||
65 | break; | ||
66 | default: | ||
67 | return -1; | ||
68 | } | ||
69 | |||
70 | if (value > 20 && value < 32767) | ||
71 | #ifndef FREQ | ||
72 | count = (ixp4xx_get_board_tick_rate() / (value * 4)) - 1; | ||
73 | #else | ||
74 | count = (FREQ / (value * 4)) - 1; | ||
75 | #endif | ||
76 | |||
77 | ixp4xx_spkr_control(pin, count); | ||
78 | |||
79 | return 0; | ||
80 | } | ||
81 | |||
82 | static irqreturn_t ixp4xx_spkr_interrupt(int irq, void *dev_id, struct pt_regs *regs) | ||
83 | { | ||
84 | /* clear interrupt */ | ||
85 | *IXP4XX_OSST = IXP4XX_OSST_TIMER_2_PEND; | ||
86 | |||
87 | /* flip the beeper output */ | ||
88 | *IXP4XX_GPIO_GPOUTR ^= (1 << (unsigned int) dev_id); | ||
89 | |||
90 | return IRQ_HANDLED; | ||
91 | } | ||
92 | |||
93 | static int __devinit ixp4xx_spkr_probe(struct platform_device *dev) | ||
94 | { | ||
95 | struct input_dev *input_dev; | ||
96 | int err; | ||
97 | |||
98 | input_dev = input_allocate_device(); | ||
99 | if (!input_dev) | ||
100 | return -ENOMEM; | ||
101 | |||
102 | input_dev->private = (void *) dev->id; | ||
103 | input_dev->name = "ixp4xx beeper", | ||
104 | input_dev->phys = "ixp4xx/gpio"; | ||
105 | input_dev->id.bustype = BUS_HOST; | ||
106 | input_dev->id.vendor = 0x001f; | ||
107 | input_dev->id.product = 0x0001; | ||
108 | input_dev->id.version = 0x0100; | ||
109 | input_dev->cdev.dev = &dev->dev; | ||
110 | |||
111 | input_dev->evbit[0] = BIT(EV_SND); | ||
112 | input_dev->sndbit[0] = BIT(SND_BELL) | BIT(SND_TONE); | ||
113 | input_dev->event = ixp4xx_spkr_event; | ||
114 | |||
115 | err = request_irq(IRQ_IXP4XX_TIMER2, &ixp4xx_spkr_interrupt, | ||
116 | SA_INTERRUPT | SA_TIMER, "ixp4xx-beeper", (void *) dev->id); | ||
117 | if (err) | ||
118 | goto err_free_device; | ||
119 | |||
120 | err = input_register_device(input_dev); | ||
121 | if (err) | ||
122 | goto err_free_irq; | ||
123 | |||
124 | platform_set_drvdata(dev, input_dev); | ||
125 | |||
126 | return 0; | ||
127 | |||
128 | err_free_irq: | ||
129 | free_irq(IRQ_IXP4XX_TIMER2, dev); | ||
130 | err_free_device: | ||
131 | input_free_device(input_dev); | ||
132 | |||
133 | return err; | ||
134 | } | ||
135 | |||
136 | static int __devexit ixp4xx_spkr_remove(struct platform_device *dev) | ||
137 | { | ||
138 | struct input_dev *input_dev = platform_get_drvdata(dev); | ||
139 | unsigned int pin = (unsigned int) input_dev->private; | ||
140 | |||
141 | input_unregister_device(input_dev); | ||
142 | platform_set_drvdata(dev, NULL); | ||
143 | |||
144 | /* turn the speaker off */ | ||
145 | disable_irq(IRQ_IXP4XX_TIMER2); | ||
146 | ixp4xx_spkr_control(pin, 0); | ||
147 | |||
148 | free_irq(IRQ_IXP4XX_TIMER2, dev); | ||
149 | |||
150 | return 0; | ||
151 | } | ||
152 | |||
153 | static void ixp4xx_spkr_shutdown(struct platform_device *dev) | ||
154 | { | ||
155 | struct input_dev *input_dev = platform_get_drvdata(dev); | ||
156 | unsigned int pin = (unsigned int) input_dev->private; | ||
157 | |||
158 | /* turn off the speaker */ | ||
159 | disable_irq(IRQ_IXP4XX_TIMER2); | ||
160 | ixp4xx_spkr_control(pin, 0); | ||
161 | } | ||
162 | |||
163 | static struct platform_driver ixp4xx_spkr_platform_driver = { | ||
164 | .driver = { | ||
165 | .name = "ixp4xx-beeper", | ||
166 | .owner = THIS_MODULE, | ||
167 | }, | ||
168 | .probe = ixp4xx_spkr_probe, | ||
169 | .remove = __devexit_p(ixp4xx_spkr_remove), | ||
170 | .shutdown = ixp4xx_spkr_shutdown, | ||
171 | }; | ||
172 | |||
173 | static int __init ixp4xx_spkr_init(void) | ||
174 | { | ||
175 | return platform_driver_register(&ixp4xx_spkr_platform_driver); | ||
176 | } | ||
177 | |||
178 | static void __exit ixp4xx_spkr_exit(void) | ||
179 | { | ||
180 | platform_driver_unregister(&ixp4xx_spkr_platform_driver); | ||
181 | } | ||
182 | |||
183 | module_init(ixp4xx_spkr_init); | ||
184 | module_exit(ixp4xx_spkr_exit); | ||
diff --git a/drivers/input/mouse/logips2pp.c b/drivers/input/mouse/logips2pp.c index c88520d3d13c..40333d61093c 100644 --- a/drivers/input/mouse/logips2pp.c +++ b/drivers/input/mouse/logips2pp.c | |||
@@ -232,6 +232,7 @@ static struct ps2pp_info *get_model_info(unsigned char model) | |||
232 | { 88, PS2PP_KIND_WHEEL, PS2PP_WHEEL }, | 232 | { 88, PS2PP_KIND_WHEEL, PS2PP_WHEEL }, |
233 | { 96, 0, 0 }, | 233 | { 96, 0, 0 }, |
234 | { 97, PS2PP_KIND_TP3, PS2PP_WHEEL | PS2PP_HWHEEL }, | 234 | { 97, PS2PP_KIND_TP3, PS2PP_WHEEL | PS2PP_HWHEEL }, |
235 | { 99, PS2PP_KIND_WHEEL, PS2PP_WHEEL }, | ||
235 | { 100, PS2PP_KIND_MX, /* MX510 */ | 236 | { 100, PS2PP_KIND_MX, /* MX510 */ |
236 | PS2PP_WHEEL | PS2PP_SIDE_BTN | PS2PP_TASK_BTN | | 237 | PS2PP_WHEEL | PS2PP_SIDE_BTN | PS2PP_TASK_BTN | |
237 | PS2PP_EXTRA_BTN | PS2PP_NAV_BTN }, | 238 | PS2PP_EXTRA_BTN | PS2PP_NAV_BTN }, |
diff --git a/drivers/input/mouse/psmouse-base.c b/drivers/input/mouse/psmouse-base.c index 7665fd9ce559..19b1b0121726 100644 --- a/drivers/input/mouse/psmouse-base.c +++ b/drivers/input/mouse/psmouse-base.c | |||
@@ -403,6 +403,7 @@ static int genius_detect(struct psmouse *psmouse, int set_properties) | |||
403 | set_bit(REL_WHEEL, psmouse->dev->relbit); | 403 | set_bit(REL_WHEEL, psmouse->dev->relbit); |
404 | 404 | ||
405 | psmouse->vendor = "Genius"; | 405 | psmouse->vendor = "Genius"; |
406 | psmouse->name = "Mouse"; | ||
406 | psmouse->pktsize = 4; | 407 | psmouse->pktsize = 4; |
407 | } | 408 | } |
408 | 409 | ||
diff --git a/drivers/input/mouse/trackpoint.c b/drivers/input/mouse/trackpoint.c index b4898d8a68e2..6d9ec9ab1b90 100644 --- a/drivers/input/mouse/trackpoint.c +++ b/drivers/input/mouse/trackpoint.c | |||
@@ -68,15 +68,19 @@ struct trackpoint_attr_data { | |||
68 | size_t field_offset; | 68 | size_t field_offset; |
69 | unsigned char command; | 69 | unsigned char command; |
70 | unsigned char mask; | 70 | unsigned char mask; |
71 | unsigned char inverted; | ||
71 | }; | 72 | }; |
72 | 73 | ||
73 | static ssize_t trackpoint_show_int_attr(struct psmouse *psmouse, void *data, char *buf) | 74 | static ssize_t trackpoint_show_int_attr(struct psmouse *psmouse, void *data, char *buf) |
74 | { | 75 | { |
75 | struct trackpoint_data *tp = psmouse->private; | 76 | struct trackpoint_data *tp = psmouse->private; |
76 | struct trackpoint_attr_data *attr = data; | 77 | struct trackpoint_attr_data *attr = data; |
77 | unsigned char *field = (unsigned char *)((char *)tp + attr->field_offset); | 78 | unsigned char value = *(unsigned char *)((char *)tp + attr->field_offset); |
79 | |||
80 | if (attr->inverted) | ||
81 | value = !value; | ||
78 | 82 | ||
79 | return sprintf(buf, "%u\n", *field); | 83 | return sprintf(buf, "%u\n", value); |
80 | } | 84 | } |
81 | 85 | ||
82 | static ssize_t trackpoint_set_int_attr(struct psmouse *psmouse, void *data, | 86 | static ssize_t trackpoint_set_int_attr(struct psmouse *psmouse, void *data, |
@@ -120,6 +124,9 @@ static ssize_t trackpoint_set_bit_attr(struct psmouse *psmouse, void *data, | |||
120 | if (*rest || value > 1) | 124 | if (*rest || value > 1) |
121 | return -EINVAL; | 125 | return -EINVAL; |
122 | 126 | ||
127 | if (attr->inverted) | ||
128 | value = !value; | ||
129 | |||
123 | if (*field != value) { | 130 | if (*field != value) { |
124 | *field = value; | 131 | *field = value; |
125 | trackpoint_toggle_bit(&psmouse->ps2dev, attr->command, attr->mask); | 132 | trackpoint_toggle_bit(&psmouse->ps2dev, attr->command, attr->mask); |
@@ -129,11 +136,12 @@ static ssize_t trackpoint_set_bit_attr(struct psmouse *psmouse, void *data, | |||
129 | } | 136 | } |
130 | 137 | ||
131 | 138 | ||
132 | #define TRACKPOINT_BIT_ATTR(_name, _command, _mask) \ | 139 | #define TRACKPOINT_BIT_ATTR(_name, _command, _mask, _inv) \ |
133 | static struct trackpoint_attr_data trackpoint_attr_##_name = { \ | 140 | static struct trackpoint_attr_data trackpoint_attr_##_name = { \ |
134 | .field_offset = offsetof(struct trackpoint_data, _name), \ | 141 | .field_offset = offsetof(struct trackpoint_data, _name), \ |
135 | .command = _command, \ | 142 | .command = _command, \ |
136 | .mask = _mask, \ | 143 | .mask = _mask, \ |
144 | .inverted = _inv, \ | ||
137 | }; \ | 145 | }; \ |
138 | PSMOUSE_DEFINE_ATTR(_name, S_IWUSR | S_IRUGO, \ | 146 | PSMOUSE_DEFINE_ATTR(_name, S_IWUSR | S_IRUGO, \ |
139 | &trackpoint_attr_##_name, \ | 147 | &trackpoint_attr_##_name, \ |
@@ -150,9 +158,9 @@ TRACKPOINT_INT_ATTR(upthresh, TP_UP_THRESH); | |||
150 | TRACKPOINT_INT_ATTR(ztime, TP_Z_TIME); | 158 | TRACKPOINT_INT_ATTR(ztime, TP_Z_TIME); |
151 | TRACKPOINT_INT_ATTR(jenks, TP_JENKS_CURV); | 159 | TRACKPOINT_INT_ATTR(jenks, TP_JENKS_CURV); |
152 | 160 | ||
153 | TRACKPOINT_BIT_ATTR(press_to_select, TP_TOGGLE_PTSON, TP_MASK_PTSON); | 161 | TRACKPOINT_BIT_ATTR(press_to_select, TP_TOGGLE_PTSON, TP_MASK_PTSON, 0); |
154 | TRACKPOINT_BIT_ATTR(skipback, TP_TOGGLE_SKIPBACK, TP_MASK_SKIPBACK); | 162 | TRACKPOINT_BIT_ATTR(skipback, TP_TOGGLE_SKIPBACK, TP_MASK_SKIPBACK, 0); |
155 | TRACKPOINT_BIT_ATTR(ext_dev, TP_TOGGLE_EXT_DEV, TP_MASK_EXT_DEV); | 163 | TRACKPOINT_BIT_ATTR(ext_dev, TP_TOGGLE_EXT_DEV, TP_MASK_EXT_DEV, 1); |
156 | 164 | ||
157 | static struct attribute *trackpoint_attrs[] = { | 165 | static struct attribute *trackpoint_attrs[] = { |
158 | &psmouse_attr_sensitivity.dattr.attr, | 166 | &psmouse_attr_sensitivity.dattr.attr, |
diff --git a/drivers/input/mouse/trackpoint.h b/drivers/input/mouse/trackpoint.h index 9857d8b6ad66..050298b1a09d 100644 --- a/drivers/input/mouse/trackpoint.h +++ b/drivers/input/mouse/trackpoint.h | |||
@@ -78,7 +78,7 @@ | |||
78 | 78 | ||
79 | #define TP_TOGGLE_MB 0x23 /* Disable/Enable Middle Button */ | 79 | #define TP_TOGGLE_MB 0x23 /* Disable/Enable Middle Button */ |
80 | #define TP_MASK_MB 0x01 | 80 | #define TP_MASK_MB 0x01 |
81 | #define TP_TOGGLE_EXT_DEV 0x23 /* Toggle external device */ | 81 | #define TP_TOGGLE_EXT_DEV 0x23 /* Disable external device */ |
82 | #define TP_MASK_EXT_DEV 0x02 | 82 | #define TP_MASK_EXT_DEV 0x02 |
83 | #define TP_TOGGLE_DRIFT 0x23 /* Drift Correction */ | 83 | #define TP_TOGGLE_DRIFT 0x23 /* Drift Correction */ |
84 | #define TP_MASK_DRIFT 0x80 | 84 | #define TP_MASK_DRIFT 0x80 |
@@ -125,7 +125,7 @@ | |||
125 | #define TP_DEF_MB 0x00 | 125 | #define TP_DEF_MB 0x00 |
126 | #define TP_DEF_PTSON 0x00 | 126 | #define TP_DEF_PTSON 0x00 |
127 | #define TP_DEF_SKIPBACK 0x00 | 127 | #define TP_DEF_SKIPBACK 0x00 |
128 | #define TP_DEF_EXT_DEV 0x01 | 128 | #define TP_DEF_EXT_DEV 0x00 /* 0 means enabled */ |
129 | 129 | ||
130 | #define MAKE_PS2_CMD(params, results, cmd) ((params<<12) | (results<<8) | (cmd)) | 130 | #define MAKE_PS2_CMD(params, results, cmd) ((params<<12) | (results<<8) | (cmd)) |
131 | 131 | ||
diff --git a/drivers/input/mousedev.c b/drivers/input/mousedev.c index 81fd7a97a93d..9abed18d2ecf 100644 --- a/drivers/input/mousedev.c +++ b/drivers/input/mousedev.c | |||
@@ -356,7 +356,7 @@ static void mousedev_free(struct mousedev *mousedev) | |||
356 | kfree(mousedev); | 356 | kfree(mousedev); |
357 | } | 357 | } |
358 | 358 | ||
359 | static int mixdev_release(void) | 359 | static void mixdev_release(void) |
360 | { | 360 | { |
361 | struct input_handle *handle; | 361 | struct input_handle *handle; |
362 | 362 | ||
@@ -370,8 +370,6 @@ static int mixdev_release(void) | |||
370 | mousedev_free(mousedev); | 370 | mousedev_free(mousedev); |
371 | } | 371 | } |
372 | } | 372 | } |
373 | |||
374 | return 0; | ||
375 | } | 373 | } |
376 | 374 | ||
377 | static int mousedev_release(struct inode * inode, struct file * file) | 375 | static int mousedev_release(struct inode * inode, struct file * file) |
@@ -384,9 +382,8 @@ static int mousedev_release(struct inode * inode, struct file * file) | |||
384 | 382 | ||
385 | if (!--list->mousedev->open) { | 383 | if (!--list->mousedev->open) { |
386 | if (list->mousedev->minor == MOUSEDEV_MIX) | 384 | if (list->mousedev->minor == MOUSEDEV_MIX) |
387 | return mixdev_release(); | 385 | mixdev_release(); |
388 | 386 | else if (!mousedev_mix.open) { | |
389 | if (!mousedev_mix.open) { | ||
390 | if (list->mousedev->exist) | 387 | if (list->mousedev->exist) |
391 | input_close_device(&list->mousedev->handle); | 388 | input_close_device(&list->mousedev->handle); |
392 | else | 389 | else |
diff --git a/drivers/input/serio/Makefile b/drivers/input/serio/Makefile index 678a8599f9ff..4155197867a3 100644 --- a/drivers/input/serio/Makefile +++ b/drivers/input/serio/Makefile | |||
@@ -13,7 +13,6 @@ obj-$(CONFIG_SERIO_RPCKBD) += rpckbd.o | |||
13 | obj-$(CONFIG_SERIO_SA1111) += sa1111ps2.o | 13 | obj-$(CONFIG_SERIO_SA1111) += sa1111ps2.o |
14 | obj-$(CONFIG_SERIO_AMBAKMI) += ambakmi.o | 14 | obj-$(CONFIG_SERIO_AMBAKMI) += ambakmi.o |
15 | obj-$(CONFIG_SERIO_Q40KBD) += q40kbd.o | 15 | obj-$(CONFIG_SERIO_Q40KBD) += q40kbd.o |
16 | obj-$(CONFIG_SERIO_98KBD) += 98kbd-io.o | ||
17 | obj-$(CONFIG_SERIO_GSCPS2) += gscps2.o | 16 | obj-$(CONFIG_SERIO_GSCPS2) += gscps2.o |
18 | obj-$(CONFIG_HP_SDC) += hp_sdc.o | 17 | obj-$(CONFIG_HP_SDC) += hp_sdc.o |
19 | obj-$(CONFIG_HIL_MLC) += hp_sdc_mlc.o hil_mlc.o | 18 | obj-$(CONFIG_HIL_MLC) += hp_sdc_mlc.o hil_mlc.o |
diff --git a/drivers/input/touchscreen/ads7846.c b/drivers/input/touchscreen/ads7846.c index dd8c6a9ffc76..8c12a974b411 100644 --- a/drivers/input/touchscreen/ads7846.c +++ b/drivers/input/touchscreen/ads7846.c | |||
@@ -29,9 +29,6 @@ | |||
29 | #ifdef CONFIG_ARCH_OMAP | 29 | #ifdef CONFIG_ARCH_OMAP |
30 | #include <asm/arch/gpio.h> | 30 | #include <asm/arch/gpio.h> |
31 | #endif | 31 | #endif |
32 | |||
33 | #else | ||
34 | #define set_irq_type(irq,type) do{}while(0) | ||
35 | #endif | 32 | #endif |
36 | 33 | ||
37 | 34 | ||
@@ -51,10 +48,13 @@ | |||
51 | 48 | ||
52 | #define TS_POLL_PERIOD msecs_to_jiffies(10) | 49 | #define TS_POLL_PERIOD msecs_to_jiffies(10) |
53 | 50 | ||
51 | /* this driver doesn't aim at the peak continuous sample rate */ | ||
52 | #define SAMPLE_BITS (8 /*cmd*/ + 16 /*sample*/ + 2 /* before, after */) | ||
53 | |||
54 | struct ts_event { | 54 | struct ts_event { |
55 | /* For portability, we can't read 12 bit values using SPI (which | 55 | /* For portability, we can't read 12 bit values using SPI (which |
56 | * would make the controller deliver them as native byteorder u16 | 56 | * would make the controller deliver them as native byteorder u16 |
57 | * with msbs zeroed). Instead, we read them as two 8-byte values, | 57 | * with msbs zeroed). Instead, we read them as two 8-bit values, |
58 | * which need byteswapping then range adjustment. | 58 | * which need byteswapping then range adjustment. |
59 | */ | 59 | */ |
60 | __be16 x; | 60 | __be16 x; |
@@ -63,7 +63,7 @@ struct ts_event { | |||
63 | }; | 63 | }; |
64 | 64 | ||
65 | struct ads7846 { | 65 | struct ads7846 { |
66 | struct input_dev input; | 66 | struct input_dev *input; |
67 | char phys[32]; | 67 | char phys[32]; |
68 | 68 | ||
69 | struct spi_device *spi; | 69 | struct spi_device *spi; |
@@ -71,6 +71,7 @@ struct ads7846 { | |||
71 | u16 vref_delay_usecs; | 71 | u16 vref_delay_usecs; |
72 | u16 x_plate_ohms; | 72 | u16 x_plate_ohms; |
73 | 73 | ||
74 | u8 read_x, read_y, read_z1, read_z2; | ||
74 | struct ts_event tc; | 75 | struct ts_event tc; |
75 | 76 | ||
76 | struct spi_transfer xfer[8]; | 77 | struct spi_transfer xfer[8]; |
@@ -120,10 +121,10 @@ struct ads7846 { | |||
120 | #define READ_12BIT_DFR(x) (ADS_START | ADS_A2A1A0_d_ ## x \ | 121 | #define READ_12BIT_DFR(x) (ADS_START | ADS_A2A1A0_d_ ## x \ |
121 | | ADS_12_BIT | ADS_DFR) | 122 | | ADS_12_BIT | ADS_DFR) |
122 | 123 | ||
123 | static const u8 read_y = READ_12BIT_DFR(y) | ADS_PD10_ADC_ON; | 124 | #define READ_Y (READ_12BIT_DFR(y) | ADS_PD10_ADC_ON) |
124 | static const u8 read_z1 = READ_12BIT_DFR(z1) | ADS_PD10_ADC_ON; | 125 | #define READ_Z1 (READ_12BIT_DFR(z1) | ADS_PD10_ADC_ON) |
125 | static const u8 read_z2 = READ_12BIT_DFR(z2) | ADS_PD10_ADC_ON; | 126 | #define READ_Z2 (READ_12BIT_DFR(z2) | ADS_PD10_ADC_ON) |
126 | static const u8 read_x = READ_12BIT_DFR(x) | ADS_PD10_PDOWN; /* LAST */ | 127 | #define READ_X (READ_12BIT_DFR(x) | ADS_PD10_PDOWN) /* LAST */ |
127 | 128 | ||
128 | /* single-ended samples need to first power up reference voltage; | 129 | /* single-ended samples need to first power up reference voltage; |
129 | * we leave both ADC and VREF powered | 130 | * we leave both ADC and VREF powered |
@@ -131,8 +132,8 @@ static const u8 read_x = READ_12BIT_DFR(x) | ADS_PD10_PDOWN; /* LAST */ | |||
131 | #define READ_12BIT_SER(x) (ADS_START | ADS_A2A1A0_ ## x \ | 132 | #define READ_12BIT_SER(x) (ADS_START | ADS_A2A1A0_ ## x \ |
132 | | ADS_12_BIT | ADS_SER) | 133 | | ADS_12_BIT | ADS_SER) |
133 | 134 | ||
134 | static const u8 ref_on = READ_12BIT_DFR(x) | ADS_PD10_ALL_ON; | 135 | #define REF_ON (READ_12BIT_DFR(x) | ADS_PD10_ALL_ON) |
135 | static const u8 ref_off = READ_12BIT_DFR(y) | ADS_PD10_PDOWN; | 136 | #define REF_OFF (READ_12BIT_DFR(y) | ADS_PD10_PDOWN) |
136 | 137 | ||
137 | /*--------------------------------------------------------------------------*/ | 138 | /*--------------------------------------------------------------------------*/ |
138 | 139 | ||
@@ -141,7 +142,9 @@ static const u8 ref_off = READ_12BIT_DFR(y) | ADS_PD10_PDOWN; | |||
141 | */ | 142 | */ |
142 | 143 | ||
143 | struct ser_req { | 144 | struct ser_req { |
145 | u8 ref_on; | ||
144 | u8 command; | 146 | u8 command; |
147 | u8 ref_off; | ||
145 | u16 scratch; | 148 | u16 scratch; |
146 | __be16 sample; | 149 | __be16 sample; |
147 | struct spi_message msg; | 150 | struct spi_message msg; |
@@ -155,7 +158,7 @@ static int ads7846_read12_ser(struct device *dev, unsigned command) | |||
155 | struct ser_req *req = kzalloc(sizeof *req, SLAB_KERNEL); | 158 | struct ser_req *req = kzalloc(sizeof *req, SLAB_KERNEL); |
156 | int status; | 159 | int status; |
157 | int sample; | 160 | int sample; |
158 | int i; | 161 | int i; |
159 | 162 | ||
160 | if (!req) | 163 | if (!req) |
161 | return -ENOMEM; | 164 | return -ENOMEM; |
@@ -163,7 +166,8 @@ static int ads7846_read12_ser(struct device *dev, unsigned command) | |||
163 | INIT_LIST_HEAD(&req->msg.transfers); | 166 | INIT_LIST_HEAD(&req->msg.transfers); |
164 | 167 | ||
165 | /* activate reference, so it has time to settle; */ | 168 | /* activate reference, so it has time to settle; */ |
166 | req->xfer[0].tx_buf = &ref_on; | 169 | req->ref_on = REF_ON; |
170 | req->xfer[0].tx_buf = &req->ref_on; | ||
167 | req->xfer[0].len = 1; | 171 | req->xfer[0].len = 1; |
168 | req->xfer[1].rx_buf = &req->scratch; | 172 | req->xfer[1].rx_buf = &req->scratch; |
169 | req->xfer[1].len = 2; | 173 | req->xfer[1].len = 2; |
@@ -185,7 +189,8 @@ static int ads7846_read12_ser(struct device *dev, unsigned command) | |||
185 | /* REVISIT: take a few more samples, and compare ... */ | 189 | /* REVISIT: take a few more samples, and compare ... */ |
186 | 190 | ||
187 | /* turn off reference */ | 191 | /* turn off reference */ |
188 | req->xfer[4].tx_buf = &ref_off; | 192 | req->ref_off = REF_OFF; |
193 | req->xfer[4].tx_buf = &req->ref_off; | ||
189 | req->xfer[4].len = 1; | 194 | req->xfer[4].len = 1; |
190 | req->xfer[5].rx_buf = &req->scratch; | 195 | req->xfer[5].rx_buf = &req->scratch; |
191 | req->xfer[5].len = 2; | 196 | req->xfer[5].len = 2; |
@@ -239,11 +244,12 @@ SHOW(vbatt) | |||
239 | 244 | ||
240 | static void ads7846_rx(void *ads) | 245 | static void ads7846_rx(void *ads) |
241 | { | 246 | { |
242 | struct ads7846 *ts = ads; | 247 | struct ads7846 *ts = ads; |
243 | unsigned Rt; | 248 | struct input_dev *input_dev = ts->input; |
244 | unsigned sync = 0; | 249 | unsigned Rt; |
245 | u16 x, y, z1, z2; | 250 | unsigned sync = 0; |
246 | unsigned long flags; | 251 | u16 x, y, z1, z2; |
252 | unsigned long flags; | ||
247 | 253 | ||
248 | /* adjust: 12 bit samples (left aligned), built from | 254 | /* adjust: 12 bit samples (left aligned), built from |
249 | * two 8 bit values writen msb-first. | 255 | * two 8 bit values writen msb-first. |
@@ -279,21 +285,21 @@ static void ads7846_rx(void *ads) | |||
279 | * won't notice that, even if nPENIRQ never fires ... | 285 | * won't notice that, even if nPENIRQ never fires ... |
280 | */ | 286 | */ |
281 | if (!ts->pendown && Rt != 0) { | 287 | if (!ts->pendown && Rt != 0) { |
282 | input_report_key(&ts->input, BTN_TOUCH, 1); | 288 | input_report_key(input_dev, BTN_TOUCH, 1); |
283 | sync = 1; | 289 | sync = 1; |
284 | } else if (ts->pendown && Rt == 0) { | 290 | } else if (ts->pendown && Rt == 0) { |
285 | input_report_key(&ts->input, BTN_TOUCH, 0); | 291 | input_report_key(input_dev, BTN_TOUCH, 0); |
286 | sync = 1; | 292 | sync = 1; |
287 | } | 293 | } |
288 | 294 | ||
289 | if (Rt) { | 295 | if (Rt) { |
290 | input_report_abs(&ts->input, ABS_X, x); | 296 | input_report_abs(input_dev, ABS_X, x); |
291 | input_report_abs(&ts->input, ABS_Y, y); | 297 | input_report_abs(input_dev, ABS_Y, y); |
292 | input_report_abs(&ts->input, ABS_PRESSURE, Rt); | 298 | input_report_abs(input_dev, ABS_PRESSURE, Rt); |
293 | sync = 1; | 299 | sync = 1; |
294 | } | 300 | } |
295 | if (sync) | 301 | if (sync) |
296 | input_sync(&ts->input); | 302 | input_sync(input_dev); |
297 | 303 | ||
298 | #ifdef VERBOSE | 304 | #ifdef VERBOSE |
299 | if (Rt || ts->pendown) | 305 | if (Rt || ts->pendown) |
@@ -399,9 +405,10 @@ static int ads7846_resume(struct spi_device *spi) | |||
399 | static int __devinit ads7846_probe(struct spi_device *spi) | 405 | static int __devinit ads7846_probe(struct spi_device *spi) |
400 | { | 406 | { |
401 | struct ads7846 *ts; | 407 | struct ads7846 *ts; |
408 | struct input_dev *input_dev; | ||
402 | struct ads7846_platform_data *pdata = spi->dev.platform_data; | 409 | struct ads7846_platform_data *pdata = spi->dev.platform_data; |
403 | struct spi_transfer *x; | 410 | struct spi_transfer *x; |
404 | int i; | 411 | int err; |
405 | 412 | ||
406 | if (!spi->irq) { | 413 | if (!spi->irq) { |
407 | dev_dbg(&spi->dev, "no IRQ?\n"); | 414 | dev_dbg(&spi->dev, "no IRQ?\n"); |
@@ -414,9 +421,9 @@ static int __devinit ads7846_probe(struct spi_device *spi) | |||
414 | } | 421 | } |
415 | 422 | ||
416 | /* don't exceed max specified sample rate */ | 423 | /* don't exceed max specified sample rate */ |
417 | if (spi->max_speed_hz > (125000 * 16)) { | 424 | if (spi->max_speed_hz > (125000 * SAMPLE_BITS)) { |
418 | dev_dbg(&spi->dev, "f(sample) %d KHz?\n", | 425 | dev_dbg(&spi->dev, "f(sample) %d KHz?\n", |
419 | (spi->max_speed_hz/16)/1000); | 426 | (spi->max_speed_hz/SAMPLE_BITS)/1000); |
420 | return -EINVAL; | 427 | return -EINVAL; |
421 | } | 428 | } |
422 | 429 | ||
@@ -426,13 +433,18 @@ static int __devinit ads7846_probe(struct spi_device *spi) | |||
426 | * to discard the four garbage LSBs. | 433 | * to discard the four garbage LSBs. |
427 | */ | 434 | */ |
428 | 435 | ||
429 | if (!(ts = kzalloc(sizeof(struct ads7846), GFP_KERNEL))) | 436 | ts = kzalloc(sizeof(struct ads7846), GFP_KERNEL); |
430 | return -ENOMEM; | 437 | input_dev = input_allocate_device(); |
438 | if (!ts || !input_dev) { | ||
439 | err = -ENOMEM; | ||
440 | goto err_free_mem; | ||
441 | } | ||
431 | 442 | ||
432 | dev_set_drvdata(&spi->dev, ts); | 443 | dev_set_drvdata(&spi->dev, ts); |
444 | spi->dev.power.power_state = PMSG_ON; | ||
433 | 445 | ||
434 | ts->spi = spi; | 446 | ts->spi = spi; |
435 | spi->dev.power.power_state = PMSG_ON; | 447 | ts->input = input_dev; |
436 | 448 | ||
437 | init_timer(&ts->timer); | 449 | init_timer(&ts->timer); |
438 | ts->timer.data = (unsigned long) ts; | 450 | ts->timer.data = (unsigned long) ts; |
@@ -442,81 +454,90 @@ static int __devinit ads7846_probe(struct spi_device *spi) | |||
442 | ts->vref_delay_usecs = pdata->vref_delay_usecs ? : 100; | 454 | ts->vref_delay_usecs = pdata->vref_delay_usecs ? : 100; |
443 | ts->x_plate_ohms = pdata->x_plate_ohms ? : 400; | 455 | ts->x_plate_ohms = pdata->x_plate_ohms ? : 400; |
444 | 456 | ||
445 | init_input_dev(&ts->input); | 457 | snprintf(ts->phys, sizeof(ts->phys), "%s/input0", spi->dev.bus_id); |
446 | 458 | ||
447 | ts->input.dev = &spi->dev; | 459 | input_dev->name = "ADS784x Touchscreen"; |
448 | ts->input.name = "ADS784x Touchscreen"; | 460 | input_dev->phys = ts->phys; |
449 | snprintf(ts->phys, sizeof ts->phys, "%s/input0", spi->dev.bus_id); | 461 | input_dev->cdev.dev = &spi->dev; |
450 | ts->input.phys = ts->phys; | ||
451 | 462 | ||
452 | ts->input.evbit[0] = BIT(EV_KEY) | BIT(EV_ABS); | 463 | input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_ABS); |
453 | ts->input.keybit[LONG(BTN_TOUCH)] = BIT(BTN_TOUCH); | 464 | input_dev->keybit[LONG(BTN_TOUCH)] = BIT(BTN_TOUCH); |
454 | input_set_abs_params(&ts->input, ABS_X, | 465 | input_set_abs_params(input_dev, ABS_X, |
455 | pdata->x_min ? : 0, | 466 | pdata->x_min ? : 0, |
456 | pdata->x_max ? : MAX_12BIT, | 467 | pdata->x_max ? : MAX_12BIT, |
457 | 0, 0); | 468 | 0, 0); |
458 | input_set_abs_params(&ts->input, ABS_Y, | 469 | input_set_abs_params(input_dev, ABS_Y, |
459 | pdata->y_min ? : 0, | 470 | pdata->y_min ? : 0, |
460 | pdata->y_max ? : MAX_12BIT, | 471 | pdata->y_max ? : MAX_12BIT, |
461 | 0, 0); | 472 | 0, 0); |
462 | input_set_abs_params(&ts->input, ABS_PRESSURE, | 473 | input_set_abs_params(input_dev, ABS_PRESSURE, |
463 | pdata->pressure_min, pdata->pressure_max, 0, 0); | 474 | pdata->pressure_min, pdata->pressure_max, 0, 0); |
464 | 475 | ||
465 | input_register_device(&ts->input); | ||
466 | |||
467 | /* set up the transfers to read touchscreen state; this assumes we | 476 | /* set up the transfers to read touchscreen state; this assumes we |
468 | * use formula #2 for pressure, not #3. | 477 | * use formula #2 for pressure, not #3. |
469 | */ | 478 | */ |
479 | INIT_LIST_HEAD(&ts->msg.transfers); | ||
470 | x = ts->xfer; | 480 | x = ts->xfer; |
471 | 481 | ||
472 | /* y- still on; turn on only y+ (and ADC) */ | 482 | /* y- still on; turn on only y+ (and ADC) */ |
473 | x->tx_buf = &read_y; | 483 | ts->read_y = READ_Y; |
484 | x->tx_buf = &ts->read_y; | ||
474 | x->len = 1; | 485 | x->len = 1; |
486 | spi_message_add_tail(x, &ts->msg); | ||
487 | |||
475 | x++; | 488 | x++; |
476 | x->rx_buf = &ts->tc.y; | 489 | x->rx_buf = &ts->tc.y; |
477 | x->len = 2; | 490 | x->len = 2; |
478 | x++; | 491 | spi_message_add_tail(x, &ts->msg); |
479 | 492 | ||
480 | /* turn y+ off, x- on; we'll use formula #2 */ | 493 | /* turn y+ off, x- on; we'll use formula #2 */ |
481 | if (ts->model == 7846) { | 494 | if (ts->model == 7846) { |
482 | x->tx_buf = &read_z1; | 495 | x++; |
496 | ts->read_z1 = READ_Z1; | ||
497 | x->tx_buf = &ts->read_z1; | ||
483 | x->len = 1; | 498 | x->len = 1; |
499 | spi_message_add_tail(x, &ts->msg); | ||
500 | |||
484 | x++; | 501 | x++; |
485 | x->rx_buf = &ts->tc.z1; | 502 | x->rx_buf = &ts->tc.z1; |
486 | x->len = 2; | 503 | x->len = 2; |
487 | x++; | 504 | spi_message_add_tail(x, &ts->msg); |
488 | 505 | ||
489 | x->tx_buf = &read_z2; | 506 | x++; |
507 | ts->read_z2 = READ_Z2; | ||
508 | x->tx_buf = &ts->read_z2; | ||
490 | x->len = 1; | 509 | x->len = 1; |
510 | spi_message_add_tail(x, &ts->msg); | ||
511 | |||
491 | x++; | 512 | x++; |
492 | x->rx_buf = &ts->tc.z2; | 513 | x->rx_buf = &ts->tc.z2; |
493 | x->len = 2; | 514 | x->len = 2; |
494 | x++; | 515 | spi_message_add_tail(x, &ts->msg); |
495 | } | 516 | } |
496 | 517 | ||
497 | /* turn y- off, x+ on, then leave in lowpower */ | 518 | /* turn y- off, x+ on, then leave in lowpower */ |
498 | x->tx_buf = &read_x; | 519 | x++; |
520 | ts->read_x = READ_X; | ||
521 | x->tx_buf = &ts->read_x; | ||
499 | x->len = 1; | 522 | x->len = 1; |
523 | spi_message_add_tail(x, &ts->msg); | ||
524 | |||
500 | x++; | 525 | x++; |
501 | x->rx_buf = &ts->tc.x; | 526 | x->rx_buf = &ts->tc.x; |
502 | x->len = 2; | 527 | x->len = 2; |
503 | x++; | 528 | CS_CHANGE(*x); |
504 | 529 | spi_message_add_tail(x, &ts->msg); | |
505 | CS_CHANGE(x[-1]); | ||
506 | 530 | ||
507 | for (i = 0; i < x - ts->xfer; i++) | ||
508 | spi_message_add_tail(&ts->xfer[i], &ts->msg); | ||
509 | ts->msg.complete = ads7846_rx; | 531 | ts->msg.complete = ads7846_rx; |
510 | ts->msg.context = ts; | 532 | ts->msg.context = ts; |
511 | 533 | ||
512 | if (request_irq(spi->irq, ads7846_irq, SA_SAMPLE_RANDOM, | 534 | if (request_irq(spi->irq, ads7846_irq, |
513 | spi->dev.bus_id, ts)) { | 535 | SA_SAMPLE_RANDOM | SA_TRIGGER_FALLING, |
536 | spi->dev.bus_id, ts)) { | ||
514 | dev_dbg(&spi->dev, "irq %d busy?\n", spi->irq); | 537 | dev_dbg(&spi->dev, "irq %d busy?\n", spi->irq); |
515 | input_unregister_device(&ts->input); | 538 | err = -EBUSY; |
516 | kfree(ts); | 539 | goto err_free_mem; |
517 | return -EBUSY; | ||
518 | } | 540 | } |
519 | set_irq_type(spi->irq, IRQT_FALLING); | ||
520 | 541 | ||
521 | dev_info(&spi->dev, "touchscreen, irq %d\n", spi->irq); | 542 | dev_info(&spi->dev, "touchscreen, irq %d\n", spi->irq); |
522 | 543 | ||
@@ -537,7 +558,18 @@ static int __devinit ads7846_probe(struct spi_device *spi) | |||
537 | device_create_file(&spi->dev, &dev_attr_vbatt); | 558 | device_create_file(&spi->dev, &dev_attr_vbatt); |
538 | device_create_file(&spi->dev, &dev_attr_vaux); | 559 | device_create_file(&spi->dev, &dev_attr_vaux); |
539 | 560 | ||
561 | err = input_register_device(input_dev); | ||
562 | if (err) | ||
563 | goto err_free_irq; | ||
564 | |||
540 | return 0; | 565 | return 0; |
566 | |||
567 | err_free_irq: | ||
568 | free_irq(spi->irq, ts); | ||
569 | err_free_mem: | ||
570 | input_free_device(input_dev); | ||
571 | kfree(ts); | ||
572 | return err; | ||
541 | } | 573 | } |
542 | 574 | ||
543 | static int __devexit ads7846_remove(struct spi_device *spi) | 575 | static int __devexit ads7846_remove(struct spi_device *spi) |
@@ -557,7 +589,7 @@ static int __devexit ads7846_remove(struct spi_device *spi) | |||
557 | device_remove_file(&spi->dev, &dev_attr_vbatt); | 589 | device_remove_file(&spi->dev, &dev_attr_vbatt); |
558 | device_remove_file(&spi->dev, &dev_attr_vaux); | 590 | device_remove_file(&spi->dev, &dev_attr_vaux); |
559 | 591 | ||
560 | input_unregister_device(&ts->input); | 592 | input_unregister_device(ts->input); |
561 | kfree(ts); | 593 | kfree(ts); |
562 | 594 | ||
563 | dev_dbg(&spi->dev, "unregistered touchscreen\n"); | 595 | dev_dbg(&spi->dev, "unregistered touchscreen\n"); |
diff --git a/drivers/input/touchscreen/mk712.c b/drivers/input/touchscreen/mk712.c index 4844d250a5eb..3226830eea08 100644 --- a/drivers/input/touchscreen/mk712.c +++ b/drivers/input/touchscreen/mk712.c | |||
@@ -154,7 +154,7 @@ static void mk712_close(struct input_dev *dev) | |||
154 | spin_unlock_irqrestore(&mk712_lock, flags); | 154 | spin_unlock_irqrestore(&mk712_lock, flags); |
155 | } | 155 | } |
156 | 156 | ||
157 | int __init mk712_init(void) | 157 | static int __init mk712_init(void) |
158 | { | 158 | { |
159 | int err; | 159 | int err; |
160 | 160 | ||