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

Merge rsync://rsync.kernel.org/pub/scm/linux/kernel/git/dtor/input.git manually

Some manual fixups required due to clashes with the PF_FREEZE cleanups.

+2783 -1933
+1 -1
Documentation/kernel-parameters.txt
··· 1115 1115 See Documentation/ramdisk.txt. 1116 1116 1117 1117 psmouse.proto= [HW,MOUSE] Highest PS2 mouse protocol extension to 1118 - probe for (bare|imps|exps). 1118 + probe for (bare|imps|exps|lifebook|any). 1119 1119 psmouse.rate= [HW,MOUSE] Set desired mouse report rate, in reports 1120 1120 per second. 1121 1121 psmouse.resetafter=
+337 -90
drivers/input/evdev.c
··· 21 21 #include <linux/smp_lock.h> 22 22 #include <linux/device.h> 23 23 #include <linux/devfs_fs_kernel.h> 24 + #include <linux/compat.h> 24 25 25 26 struct evdev { 26 27 int exist; ··· 146 145 return 0; 147 146 } 148 147 148 + #ifdef CONFIG_COMPAT 149 + struct input_event_compat { 150 + struct compat_timeval time; 151 + __u16 type; 152 + __u16 code; 153 + __s32 value; 154 + }; 155 + 156 + #ifdef CONFIG_X86_64 157 + # define COMPAT_TEST test_thread_flag(TIF_IA32) 158 + #elif defined(CONFIG_IA64) 159 + # define COMPAT_TEST IS_IA32_PROCESS(ia64_task_regs(current)) 160 + #elif defined(CONFIG_ARCH_S390) 161 + # define COMPAT_TEST test_thread_flag(TIF_31BIT) 162 + #else 163 + # define COMPAT_TEST test_thread_flag(TIF_32BIT) 164 + #endif 165 + 166 + static ssize_t evdev_write_compat(struct file * file, const char __user * buffer, size_t count, loff_t *ppos) 167 + { 168 + struct evdev_list *list = file->private_data; 169 + struct input_event_compat event; 170 + int retval = 0; 171 + 172 + while (retval < count) { 173 + if (copy_from_user(&event, buffer + retval, sizeof(struct input_event_compat))) 174 + return -EFAULT; 175 + input_event(list->evdev->handle.dev, event.type, event.code, event.value); 176 + retval += sizeof(struct input_event_compat); 177 + } 178 + 179 + return retval; 180 + } 181 + #endif 182 + 149 183 static ssize_t evdev_write(struct file * file, const char __user * buffer, size_t count, loff_t *ppos) 150 184 { 151 185 struct evdev_list *list = file->private_data; ··· 188 152 int retval = 0; 189 153 190 154 if (!list->evdev->exist) return -ENODEV; 155 + 156 + #ifdef CONFIG_COMPAT 157 + if (COMPAT_TEST) 158 + return evdev_write_compat(file, buffer, count, ppos); 159 + #endif 191 160 192 161 while (retval < count) { 193 162 ··· 205 164 return retval; 206 165 } 207 166 167 + #ifdef CONFIG_COMPAT 168 + static ssize_t evdev_read_compat(struct file * file, char __user * buffer, size_t count, loff_t *ppos) 169 + { 170 + struct evdev_list *list = file->private_data; 171 + int retval; 172 + 173 + if (count < sizeof(struct input_event_compat)) 174 + return -EINVAL; 175 + 176 + if (list->head == list->tail && list->evdev->exist && (file->f_flags & O_NONBLOCK)) 177 + return -EAGAIN; 178 + 179 + retval = wait_event_interruptible(list->evdev->wait, 180 + list->head != list->tail || (!list->evdev->exist)); 181 + 182 + if (retval) 183 + return retval; 184 + 185 + if (!list->evdev->exist) 186 + return -ENODEV; 187 + 188 + while (list->head != list->tail && retval + sizeof(struct input_event_compat) <= count) { 189 + struct input_event *event = (struct input_event *) list->buffer + list->tail; 190 + struct input_event_compat event_compat; 191 + event_compat.time.tv_sec = event->time.tv_sec; 192 + event_compat.time.tv_usec = event->time.tv_usec; 193 + event_compat.type = event->type; 194 + event_compat.code = event->code; 195 + event_compat.value = event->value; 196 + 197 + if (copy_to_user(buffer + retval, &event_compat, 198 + sizeof(struct input_event_compat))) return -EFAULT; 199 + list->tail = (list->tail + 1) & (EVDEV_BUFFER_SIZE - 1); 200 + retval += sizeof(struct input_event_compat); 201 + } 202 + 203 + return retval; 204 + } 205 + #endif 206 + 208 207 static ssize_t evdev_read(struct file * file, char __user * buffer, size_t count, loff_t *ppos) 209 208 { 210 209 struct evdev_list *list = file->private_data; 211 210 int retval; 211 + 212 + #ifdef CONFIG_COMPAT 213 + if (COMPAT_TEST) 214 + return evdev_read_compat(file, buffer, count, ppos); 215 + #endif 212 216 213 217 if (count < sizeof(struct input_event)) 214 218 return -EINVAL; ··· 272 186 273 187 while (list->head != list->tail && retval + sizeof(struct input_event) <= count) { 274 188 if (copy_to_user(buffer + retval, list->buffer + list->tail, 275 - sizeof(struct input_event))) return -EFAULT; 189 + sizeof(struct input_event))) return -EFAULT; 276 190 list->tail = (list->tail + 1) & (EVDEV_BUFFER_SIZE - 1); 277 191 retval += sizeof(struct input_event); 278 192 } ··· 289 203 (list->evdev->exist ? 0 : (POLLHUP | POLLERR)); 290 204 } 291 205 292 - static int evdev_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg) 206 + static long evdev_ioctl(struct file *file, unsigned int cmd, unsigned long arg) 293 207 { 294 208 struct evdev_list *list = file->private_data; 295 209 struct evdev *evdev = list->evdev; ··· 371 285 372 286 default: 373 287 374 - if (_IOC_TYPE(cmd) != 'E' || _IOC_DIR(cmd) != _IOC_READ) 288 + if (_IOC_TYPE(cmd) != 'E') 375 289 return -EINVAL; 376 290 377 - if ((_IOC_NR(cmd) & ~EV_MAX) == _IOC_NR(EVIOCGBIT(0,0))) { 291 + if (_IOC_DIR(cmd) == _IOC_READ) { 378 292 379 - long *bits; 380 - int len; 293 + if ((_IOC_NR(cmd) & ~EV_MAX) == _IOC_NR(EVIOCGBIT(0,0))) { 381 294 382 - switch (_IOC_NR(cmd) & EV_MAX) { 383 - case 0: bits = dev->evbit; len = EV_MAX; break; 384 - case EV_KEY: bits = dev->keybit; len = KEY_MAX; break; 385 - case EV_REL: bits = dev->relbit; len = REL_MAX; break; 386 - case EV_ABS: bits = dev->absbit; len = ABS_MAX; break; 387 - case EV_MSC: bits = dev->mscbit; len = MSC_MAX; break; 388 - case EV_LED: bits = dev->ledbit; len = LED_MAX; break; 389 - case EV_SND: bits = dev->sndbit; len = SND_MAX; break; 390 - case EV_FF: bits = dev->ffbit; len = FF_MAX; break; 391 - default: return -EINVAL; 295 + long *bits; 296 + int len; 297 + 298 + switch (_IOC_NR(cmd) & EV_MAX) { 299 + case 0: bits = dev->evbit; len = EV_MAX; break; 300 + case EV_KEY: bits = dev->keybit; len = KEY_MAX; break; 301 + case EV_REL: bits = dev->relbit; len = REL_MAX; break; 302 + case EV_ABS: bits = dev->absbit; len = ABS_MAX; break; 303 + case EV_MSC: bits = dev->mscbit; len = MSC_MAX; break; 304 + case EV_LED: bits = dev->ledbit; len = LED_MAX; break; 305 + case EV_SND: bits = dev->sndbit; len = SND_MAX; break; 306 + case EV_FF: bits = dev->ffbit; len = FF_MAX; break; 307 + default: return -EINVAL; 308 + } 309 + len = NBITS(len) * sizeof(long); 310 + if (len > _IOC_SIZE(cmd)) len = _IOC_SIZE(cmd); 311 + return copy_to_user(p, bits, len) ? -EFAULT : len; 392 312 } 393 - len = NBITS(len) * sizeof(long); 394 - if (len > _IOC_SIZE(cmd)) len = _IOC_SIZE(cmd); 395 - return copy_to_user(p, bits, len) ? -EFAULT : len; 313 + 314 + if (_IOC_NR(cmd) == _IOC_NR(EVIOCGKEY(0))) { 315 + int len; 316 + len = NBITS(KEY_MAX) * sizeof(long); 317 + if (len > _IOC_SIZE(cmd)) len = _IOC_SIZE(cmd); 318 + return copy_to_user(p, dev->key, len) ? -EFAULT : len; 319 + } 320 + 321 + if (_IOC_NR(cmd) == _IOC_NR(EVIOCGLED(0))) { 322 + int len; 323 + len = NBITS(LED_MAX) * sizeof(long); 324 + if (len > _IOC_SIZE(cmd)) len = _IOC_SIZE(cmd); 325 + return copy_to_user(p, dev->led, len) ? -EFAULT : len; 326 + } 327 + 328 + if (_IOC_NR(cmd) == _IOC_NR(EVIOCGSND(0))) { 329 + int len; 330 + len = NBITS(SND_MAX) * sizeof(long); 331 + if (len > _IOC_SIZE(cmd)) len = _IOC_SIZE(cmd); 332 + return copy_to_user(p, dev->snd, len) ? -EFAULT : len; 333 + } 334 + 335 + if (_IOC_NR(cmd) == _IOC_NR(EVIOCGNAME(0))) { 336 + int len; 337 + if (!dev->name) return -ENOENT; 338 + len = strlen(dev->name) + 1; 339 + if (len > _IOC_SIZE(cmd)) len = _IOC_SIZE(cmd); 340 + return copy_to_user(p, dev->name, len) ? -EFAULT : len; 341 + } 342 + 343 + if (_IOC_NR(cmd) == _IOC_NR(EVIOCGPHYS(0))) { 344 + int len; 345 + if (!dev->phys) return -ENOENT; 346 + len = strlen(dev->phys) + 1; 347 + if (len > _IOC_SIZE(cmd)) len = _IOC_SIZE(cmd); 348 + return copy_to_user(p, dev->phys, len) ? -EFAULT : len; 349 + } 350 + 351 + if (_IOC_NR(cmd) == _IOC_NR(EVIOCGUNIQ(0))) { 352 + int len; 353 + if (!dev->uniq) return -ENOENT; 354 + len = strlen(dev->uniq) + 1; 355 + if (len > _IOC_SIZE(cmd)) len = _IOC_SIZE(cmd); 356 + return copy_to_user(p, dev->uniq, len) ? -EFAULT : len; 357 + } 358 + 359 + if ((_IOC_NR(cmd) & ~ABS_MAX) == _IOC_NR(EVIOCGABS(0))) { 360 + 361 + int t = _IOC_NR(cmd) & ABS_MAX; 362 + 363 + abs.value = dev->abs[t]; 364 + abs.minimum = dev->absmin[t]; 365 + abs.maximum = dev->absmax[t]; 366 + abs.fuzz = dev->absfuzz[t]; 367 + abs.flat = dev->absflat[t]; 368 + 369 + if (copy_to_user(p, &abs, sizeof(struct input_absinfo))) 370 + return -EFAULT; 371 + 372 + return 0; 373 + } 374 + 396 375 } 397 376 398 - if (_IOC_NR(cmd) == _IOC_NR(EVIOCGKEY(0))) { 399 - int len; 400 - len = NBITS(KEY_MAX) * sizeof(long); 401 - if (len > _IOC_SIZE(cmd)) len = _IOC_SIZE(cmd); 402 - return copy_to_user(p, dev->key, len) ? -EFAULT : len; 403 - } 377 + if (_IOC_DIR(cmd) == _IOC_WRITE) { 404 378 405 - if (_IOC_NR(cmd) == _IOC_NR(EVIOCGLED(0))) { 406 - int len; 407 - len = NBITS(LED_MAX) * sizeof(long); 408 - if (len > _IOC_SIZE(cmd)) len = _IOC_SIZE(cmd); 409 - return copy_to_user(p, dev->led, len) ? -EFAULT : len; 410 - } 379 + if ((_IOC_NR(cmd) & ~ABS_MAX) == _IOC_NR(EVIOCSABS(0))) { 411 380 412 - if (_IOC_NR(cmd) == _IOC_NR(EVIOCGSND(0))) { 413 - int len; 414 - len = NBITS(SND_MAX) * sizeof(long); 415 - if (len > _IOC_SIZE(cmd)) len = _IOC_SIZE(cmd); 416 - return copy_to_user(p, dev->snd, len) ? -EFAULT : len; 417 - } 381 + int t = _IOC_NR(cmd) & ABS_MAX; 418 382 419 - if (_IOC_NR(cmd) == _IOC_NR(EVIOCGNAME(0))) { 420 - int len; 421 - if (!dev->name) return -ENOENT; 422 - len = strlen(dev->name) + 1; 423 - if (len > _IOC_SIZE(cmd)) len = _IOC_SIZE(cmd); 424 - return copy_to_user(p, dev->name, len) ? -EFAULT : len; 425 - } 383 + if (copy_from_user(&abs, p, sizeof(struct input_absinfo))) 384 + return -EFAULT; 426 385 427 - if (_IOC_NR(cmd) == _IOC_NR(EVIOCGPHYS(0))) { 428 - int len; 429 - if (!dev->phys) return -ENOENT; 430 - len = strlen(dev->phys) + 1; 431 - if (len > _IOC_SIZE(cmd)) len = _IOC_SIZE(cmd); 432 - return copy_to_user(p, dev->phys, len) ? -EFAULT : len; 433 - } 386 + dev->abs[t] = abs.value; 387 + dev->absmin[t] = abs.minimum; 388 + dev->absmax[t] = abs.maximum; 389 + dev->absfuzz[t] = abs.fuzz; 390 + dev->absflat[t] = abs.flat; 434 391 435 - if (_IOC_NR(cmd) == _IOC_NR(EVIOCGUNIQ(0))) { 436 - int len; 437 - if (!dev->uniq) return -ENOENT; 438 - len = strlen(dev->uniq) + 1; 439 - if (len > _IOC_SIZE(cmd)) len = _IOC_SIZE(cmd); 440 - return copy_to_user(p, dev->uniq, len) ? -EFAULT : len; 441 - } 442 - 443 - if ((_IOC_NR(cmd) & ~ABS_MAX) == _IOC_NR(EVIOCGABS(0))) { 444 - 445 - int t = _IOC_NR(cmd) & ABS_MAX; 446 - 447 - abs.value = dev->abs[t]; 448 - abs.minimum = dev->absmin[t]; 449 - abs.maximum = dev->absmax[t]; 450 - abs.fuzz = dev->absfuzz[t]; 451 - abs.flat = dev->absflat[t]; 452 - 453 - if (copy_to_user(p, &abs, sizeof(struct input_absinfo))) 454 - return -EFAULT; 455 - 456 - return 0; 457 - } 458 - 459 - if ((_IOC_NR(cmd) & ~ABS_MAX) == _IOC_NR(EVIOCSABS(0))) { 460 - 461 - int t = _IOC_NR(cmd) & ABS_MAX; 462 - 463 - if (copy_from_user(&abs, p, sizeof(struct input_absinfo))) 464 - return -EFAULT; 465 - 466 - dev->abs[t] = abs.value; 467 - dev->absmin[t] = abs.minimum; 468 - dev->absmax[t] = abs.maximum; 469 - dev->absfuzz[t] = abs.fuzz; 470 - dev->absflat[t] = abs.flat; 471 - 472 - return 0; 392 + return 0; 393 + } 473 394 } 474 395 } 475 396 return -EINVAL; 476 397 } 398 + 399 + #ifdef CONFIG_COMPAT 400 + 401 + #define BITS_PER_LONG_COMPAT (sizeof(compat_long_t) * 8) 402 + #define NBITS_COMPAT(x) ((((x)-1)/BITS_PER_LONG_COMPAT)+1) 403 + #define OFF_COMPAT(x) ((x)%BITS_PER_LONG_COMPAT) 404 + #define BIT_COMPAT(x) (1UL<<OFF_COMPAT(x)) 405 + #define LONG_COMPAT(x) ((x)/BITS_PER_LONG_COMPAT) 406 + #define test_bit_compat(bit, array) ((array[LONG_COMPAT(bit)] >> OFF_COMPAT(bit)) & 1) 407 + 408 + #ifdef __BIG_ENDIAN 409 + #define bit_to_user(bit, max) \ 410 + do { \ 411 + int i; \ 412 + int len = NBITS_COMPAT((max)) * sizeof(compat_long_t); \ 413 + if (len > _IOC_SIZE(cmd)) len = _IOC_SIZE(cmd); \ 414 + for (i = 0; i < len / sizeof(compat_long_t); i++) \ 415 + if (copy_to_user((compat_long_t*) p + i, \ 416 + (compat_long_t*) (bit) + i + 1 - ((i % 2) << 1), \ 417 + sizeof(compat_long_t))) \ 418 + return -EFAULT; \ 419 + return len; \ 420 + } while (0) 421 + #else 422 + #define bit_to_user(bit, max) \ 423 + do { \ 424 + int len = NBITS_COMPAT((max)) * sizeof(compat_long_t); \ 425 + if (len > _IOC_SIZE(cmd)) len = _IOC_SIZE(cmd); \ 426 + return copy_to_user(p, (bit), len) ? -EFAULT : len; \ 427 + } while (0) 428 + #endif 429 + 430 + static long evdev_ioctl_compat(struct file *file, unsigned int cmd, unsigned long arg) 431 + { 432 + struct evdev_list *list = file->private_data; 433 + struct evdev *evdev = list->evdev; 434 + struct input_dev *dev = evdev->handle.dev; 435 + struct input_absinfo abs; 436 + void __user *p = compat_ptr(arg); 437 + 438 + if (!evdev->exist) return -ENODEV; 439 + 440 + switch (cmd) { 441 + 442 + case EVIOCGVERSION: 443 + case EVIOCGID: 444 + case EVIOCGKEYCODE: 445 + case EVIOCSKEYCODE: 446 + case EVIOCSFF: 447 + case EVIOCRMFF: 448 + case EVIOCGEFFECTS: 449 + case EVIOCGRAB: 450 + return evdev_ioctl(file, cmd, (unsigned long) p); 451 + 452 + default: 453 + 454 + if (_IOC_TYPE(cmd) != 'E') 455 + return -EINVAL; 456 + 457 + if (_IOC_DIR(cmd) == _IOC_READ) { 458 + 459 + if ((_IOC_NR(cmd) & ~EV_MAX) == _IOC_NR(EVIOCGBIT(0,0))) { 460 + long *bits; 461 + int max; 462 + 463 + switch (_IOC_NR(cmd) & EV_MAX) { 464 + case 0: bits = dev->evbit; max = EV_MAX; break; 465 + case EV_KEY: bits = dev->keybit; max = KEY_MAX; break; 466 + case EV_REL: bits = dev->relbit; max = REL_MAX; break; 467 + case EV_ABS: bits = dev->absbit; max = ABS_MAX; break; 468 + case EV_MSC: bits = dev->mscbit; max = MSC_MAX; break; 469 + case EV_LED: bits = dev->ledbit; max = LED_MAX; break; 470 + case EV_SND: bits = dev->sndbit; max = SND_MAX; break; 471 + case EV_FF: bits = dev->ffbit; max = FF_MAX; break; 472 + default: return -EINVAL; 473 + } 474 + bit_to_user(bits, max); 475 + } 476 + 477 + if (_IOC_NR(cmd) == _IOC_NR(EVIOCGKEY(0))) 478 + bit_to_user(dev->key, KEY_MAX); 479 + 480 + if (_IOC_NR(cmd) == _IOC_NR(EVIOCGLED(0))) 481 + bit_to_user(dev->led, LED_MAX); 482 + 483 + if (_IOC_NR(cmd) == _IOC_NR(EVIOCGSND(0))) 484 + bit_to_user(dev->snd, SND_MAX); 485 + 486 + if (_IOC_NR(cmd) == _IOC_NR(EVIOCGNAME(0))) { 487 + int len; 488 + if (!dev->name) return -ENOENT; 489 + len = strlen(dev->name) + 1; 490 + if (len > _IOC_SIZE(cmd)) len = _IOC_SIZE(cmd); 491 + return copy_to_user(p, dev->name, len) ? -EFAULT : len; 492 + } 493 + 494 + if (_IOC_NR(cmd) == _IOC_NR(EVIOCGPHYS(0))) { 495 + int len; 496 + if (!dev->phys) return -ENOENT; 497 + len = strlen(dev->phys) + 1; 498 + if (len > _IOC_SIZE(cmd)) len = _IOC_SIZE(cmd); 499 + return copy_to_user(p, dev->phys, len) ? -EFAULT : len; 500 + } 501 + 502 + if (_IOC_NR(cmd) == _IOC_NR(EVIOCGUNIQ(0))) { 503 + int len; 504 + if (!dev->uniq) return -ENOENT; 505 + len = strlen(dev->uniq) + 1; 506 + if (len > _IOC_SIZE(cmd)) len = _IOC_SIZE(cmd); 507 + return copy_to_user(p, dev->uniq, len) ? -EFAULT : len; 508 + } 509 + 510 + if ((_IOC_NR(cmd) & ~ABS_MAX) == _IOC_NR(EVIOCGABS(0))) { 511 + 512 + int t = _IOC_NR(cmd) & ABS_MAX; 513 + 514 + abs.value = dev->abs[t]; 515 + abs.minimum = dev->absmin[t]; 516 + abs.maximum = dev->absmax[t]; 517 + abs.fuzz = dev->absfuzz[t]; 518 + abs.flat = dev->absflat[t]; 519 + 520 + if (copy_to_user(p, &abs, sizeof(struct input_absinfo))) 521 + return -EFAULT; 522 + 523 + return 0; 524 + } 525 + } 526 + 527 + if (_IOC_DIR(cmd) == _IOC_WRITE) { 528 + 529 + if ((_IOC_NR(cmd) & ~ABS_MAX) == _IOC_NR(EVIOCSABS(0))) { 530 + 531 + int t = _IOC_NR(cmd) & ABS_MAX; 532 + 533 + if (copy_from_user(&abs, p, sizeof(struct input_absinfo))) 534 + return -EFAULT; 535 + 536 + dev->abs[t] = abs.value; 537 + dev->absmin[t] = abs.minimum; 538 + dev->absmax[t] = abs.maximum; 539 + dev->absfuzz[t] = abs.fuzz; 540 + dev->absflat[t] = abs.flat; 541 + 542 + return 0; 543 + } 544 + } 545 + } 546 + return -EINVAL; 547 + } 548 + #endif 477 549 478 550 static struct file_operations evdev_fops = { 479 551 .owner = THIS_MODULE, ··· 640 396 .poll = evdev_poll, 641 397 .open = evdev_open, 642 398 .release = evdev_release, 643 - .ioctl = evdev_ioctl, 399 + .unlocked_ioctl = evdev_ioctl, 400 + #ifdef CONFIG_COMPAT 401 + .compat_ioctl = evdev_ioctl_compat, 402 + #endif 644 403 .fasync = evdev_fasync, 645 404 .flush = evdev_flush 646 405 };
-14
drivers/input/gameport/Kconfig
··· 49 49 To compile this driver as a module, choose M here: the 50 50 module will be called emu10k1-gp. 51 51 52 - config GAMEPORT_VORTEX 53 - tristate "Aureal Vortex, Vortex 2 gameport support" 54 - depends on PCI 55 - help 56 - Say Y here if you have an Aureal Vortex 1 or 2 card and want 57 - to use its gameport. 58 - 59 - To compile this driver as a module, choose M here: the 60 - module will be called vortex. 61 - 62 52 config GAMEPORT_FM801 63 53 tristate "ForteMedia FM801 gameport support" 64 - depends on PCI 65 - 66 - config GAMEPORT_CS461X 67 - tristate "Crystal SoundFusion gameport support" 68 54 depends on PCI 69 55 70 56 endif
-2
drivers/input/gameport/Makefile
··· 5 5 # Each configuration option enables a list of files. 6 6 7 7 obj-$(CONFIG_GAMEPORT) += gameport.o 8 - obj-$(CONFIG_GAMEPORT_CS461X) += cs461x.o 9 8 obj-$(CONFIG_GAMEPORT_EMU10K1) += emu10k1-gp.o 10 9 obj-$(CONFIG_GAMEPORT_FM801) += fm801-gp.o 11 10 obj-$(CONFIG_GAMEPORT_L4) += lightning.o 12 11 obj-$(CONFIG_GAMEPORT_NS558) += ns558.o 13 - obj-$(CONFIG_GAMEPORT_VORTEX) += vortex.o
-322
drivers/input/gameport/cs461x.c
··· 1 - /* 2 - The all defines and part of code (such as cs461x_*) are 3 - contributed from ALSA 0.5.8 sources. 4 - See http://www.alsa-project.org/ for sources 5 - 6 - Tested on Linux 686 2.4.0-test9, ALSA 0.5.8a and CS4610 7 - */ 8 - 9 - #include <asm/io.h> 10 - 11 - #include <linux/module.h> 12 - #include <linux/ioport.h> 13 - #include <linux/config.h> 14 - #include <linux/init.h> 15 - #include <linux/gameport.h> 16 - #include <linux/slab.h> 17 - #include <linux/pci.h> 18 - 19 - MODULE_AUTHOR("Victor Krapivin"); 20 - MODULE_LICENSE("GPL"); 21 - 22 - /* 23 - These options are experimental 24 - 25 - #define CS461X_FULL_MAP 26 - */ 27 - 28 - 29 - #ifndef PCI_VENDOR_ID_CIRRUS 30 - #define PCI_VENDOR_ID_CIRRUS 0x1013 31 - #endif 32 - #ifndef PCI_DEVICE_ID_CIRRUS_4610 33 - #define PCI_DEVICE_ID_CIRRUS_4610 0x6001 34 - #endif 35 - #ifndef PCI_DEVICE_ID_CIRRUS_4612 36 - #define PCI_DEVICE_ID_CIRRUS_4612 0x6003 37 - #endif 38 - #ifndef PCI_DEVICE_ID_CIRRUS_4615 39 - #define PCI_DEVICE_ID_CIRRUS_4615 0x6004 40 - #endif 41 - 42 - /* Registers */ 43 - 44 - #define BA0_JSPT 0x00000480 45 - #define BA0_JSCTL 0x00000484 46 - #define BA0_JSC1 0x00000488 47 - #define BA0_JSC2 0x0000048C 48 - #define BA0_JSIO 0x000004A0 49 - 50 - /* Bits for JSPT */ 51 - 52 - #define JSPT_CAX 0x00000001 53 - #define JSPT_CAY 0x00000002 54 - #define JSPT_CBX 0x00000004 55 - #define JSPT_CBY 0x00000008 56 - #define JSPT_BA1 0x00000010 57 - #define JSPT_BA2 0x00000020 58 - #define JSPT_BB1 0x00000040 59 - #define JSPT_BB2 0x00000080 60 - 61 - /* Bits for JSCTL */ 62 - 63 - #define JSCTL_SP_MASK 0x00000003 64 - #define JSCTL_SP_SLOW 0x00000000 65 - #define JSCTL_SP_MEDIUM_SLOW 0x00000001 66 - #define JSCTL_SP_MEDIUM_FAST 0x00000002 67 - #define JSCTL_SP_FAST 0x00000003 68 - #define JSCTL_ARE 0x00000004 69 - 70 - /* Data register pairs masks */ 71 - 72 - #define JSC1_Y1V_MASK 0x0000FFFF 73 - #define JSC1_X1V_MASK 0xFFFF0000 74 - #define JSC1_Y1V_SHIFT 0 75 - #define JSC1_X1V_SHIFT 16 76 - #define JSC2_Y2V_MASK 0x0000FFFF 77 - #define JSC2_X2V_MASK 0xFFFF0000 78 - #define JSC2_Y2V_SHIFT 0 79 - #define JSC2_X2V_SHIFT 16 80 - 81 - /* JS GPIO */ 82 - 83 - #define JSIO_DAX 0x00000001 84 - #define JSIO_DAY 0x00000002 85 - #define JSIO_DBX 0x00000004 86 - #define JSIO_DBY 0x00000008 87 - #define JSIO_AXOE 0x00000010 88 - #define JSIO_AYOE 0x00000020 89 - #define JSIO_BXOE 0x00000040 90 - #define JSIO_BYOE 0x00000080 91 - 92 - /* 93 - The card initialization code is obfuscated; the module cs461x 94 - need to be loaded after ALSA modules initialized and something 95 - played on the CS 4610 chip (see sources for details of CS4610 96 - initialization code from ALSA) 97 - */ 98 - 99 - /* Card specific definitions */ 100 - 101 - #define CS461X_BA0_SIZE 0x2000 102 - #define CS461X_BA1_DATA0_SIZE 0x3000 103 - #define CS461X_BA1_DATA1_SIZE 0x3800 104 - #define CS461X_BA1_PRG_SIZE 0x7000 105 - #define CS461X_BA1_REG_SIZE 0x0100 106 - 107 - #define BA1_SP_DMEM0 0x00000000 108 - #define BA1_SP_DMEM1 0x00010000 109 - #define BA1_SP_PMEM 0x00020000 110 - #define BA1_SP_REG 0x00030000 111 - 112 - #define BA1_DWORD_SIZE (13 * 1024 + 512) 113 - #define BA1_MEMORY_COUNT 3 114 - 115 - /* 116 - Only one CS461x card is still suppoted; the code requires 117 - redesign to avoid this limitatuion. 118 - */ 119 - 120 - static unsigned long ba0_addr; 121 - static unsigned int __iomem *ba0; 122 - 123 - #ifdef CS461X_FULL_MAP 124 - static unsigned long ba1_addr; 125 - static union ba1_t { 126 - struct { 127 - unsigned int __iomem *data0; 128 - unsigned int __iomem *data1; 129 - unsigned int __iomem *pmem; 130 - unsigned int __iomem *reg; 131 - } name; 132 - unsigned int __iomem *idx[4]; 133 - } ba1; 134 - 135 - static void cs461x_poke(unsigned long reg, unsigned int val) 136 - { 137 - writel(val, &ba1.idx[(reg >> 16) & 3][(reg >> 2) & 0x3fff]); 138 - } 139 - 140 - static unsigned int cs461x_peek(unsigned long reg) 141 - { 142 - return readl(&ba1.idx[(reg >> 16) & 3][(reg >> 2) & 0x3fff]); 143 - } 144 - 145 - #endif 146 - 147 - static void cs461x_pokeBA0(unsigned long reg, unsigned int val) 148 - { 149 - writel(val, &ba0[reg >> 2]); 150 - } 151 - 152 - static unsigned int cs461x_peekBA0(unsigned long reg) 153 - { 154 - return readl(&ba0[reg >> 2]); 155 - } 156 - 157 - static int cs461x_free(struct pci_dev *pdev) 158 - { 159 - struct gameport *port = pci_get_drvdata(pdev); 160 - 161 - if (port) 162 - gameport_unregister_port(port); 163 - 164 - if (ba0) iounmap(ba0); 165 - #ifdef CS461X_FULL_MAP 166 - if (ba1.name.data0) iounmap(ba1.name.data0); 167 - if (ba1.name.data1) iounmap(ba1.name.data1); 168 - if (ba1.name.pmem) iounmap(ba1.name.pmem); 169 - if (ba1.name.reg) iounmap(ba1.name.reg); 170 - #endif 171 - return 0; 172 - } 173 - 174 - static void cs461x_gameport_trigger(struct gameport *gameport) 175 - { 176 - cs461x_pokeBA0(BA0_JSPT, 0xFF); //outb(gameport->io, 0xFF); 177 - } 178 - 179 - static unsigned char cs461x_gameport_read(struct gameport *gameport) 180 - { 181 - return cs461x_peekBA0(BA0_JSPT); //inb(gameport->io); 182 - } 183 - 184 - static int cs461x_gameport_cooked_read(struct gameport *gameport, int *axes, int *buttons) 185 - { 186 - unsigned js1, js2, jst; 187 - 188 - js1 = cs461x_peekBA0(BA0_JSC1); 189 - js2 = cs461x_peekBA0(BA0_JSC2); 190 - jst = cs461x_peekBA0(BA0_JSPT); 191 - 192 - *buttons = (~jst >> 4) & 0x0F; 193 - 194 - axes[0] = ((js1 & JSC1_Y1V_MASK) >> JSC1_Y1V_SHIFT) & 0xFFFF; 195 - axes[1] = ((js1 & JSC1_X1V_MASK) >> JSC1_X1V_SHIFT) & 0xFFFF; 196 - axes[2] = ((js2 & JSC2_Y2V_MASK) >> JSC2_Y2V_SHIFT) & 0xFFFF; 197 - axes[3] = ((js2 & JSC2_X2V_MASK) >> JSC2_X2V_SHIFT) & 0xFFFF; 198 - 199 - for(jst=0;jst<4;++jst) 200 - if(axes[jst]==0xFFFF) axes[jst] = -1; 201 - return 0; 202 - } 203 - 204 - static int cs461x_gameport_open(struct gameport *gameport, int mode) 205 - { 206 - switch (mode) { 207 - case GAMEPORT_MODE_COOKED: 208 - case GAMEPORT_MODE_RAW: 209 - return 0; 210 - default: 211 - return -1; 212 - } 213 - return 0; 214 - } 215 - 216 - static struct pci_device_id cs461x_pci_tbl[] = { 217 - { PCI_VENDOR_ID_CIRRUS, 0x6001, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, /* Cirrus CS4610 */ 218 - { PCI_VENDOR_ID_CIRRUS, 0x6003, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, /* Cirrus CS4612 */ 219 - { PCI_VENDOR_ID_CIRRUS, 0x6005, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, /* Cirrus CS4615 */ 220 - { 0, } 221 - }; 222 - MODULE_DEVICE_TABLE(pci, cs461x_pci_tbl); 223 - 224 - static int __devinit cs461x_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) 225 - { 226 - int rc; 227 - struct gameport* port; 228 - 229 - rc = pci_enable_device(pdev); 230 - if (rc) { 231 - printk(KERN_ERR "cs461x: Cannot enable PCI gameport (bus %d, devfn %d) error=%d\n", 232 - pdev->bus->number, pdev->devfn, rc); 233 - return rc; 234 - } 235 - 236 - ba0_addr = pci_resource_start(pdev, 0); 237 - #ifdef CS461X_FULL_MAP 238 - ba1_addr = pci_resource_start(pdev, 1); 239 - #endif 240 - if (ba0_addr == 0 || ba0_addr == ~0 241 - #ifdef CS461X_FULL_MAP 242 - || ba1_addr == 0 || ba1_addr == ~0 243 - #endif 244 - ) { 245 - printk(KERN_ERR "cs461x: wrong address - ba0 = 0x%lx\n", ba0_addr); 246 - #ifdef CS461X_FULL_MAP 247 - printk(KERN_ERR "cs461x: wrong address - ba1 = 0x%lx\n", ba1_addr); 248 - #endif 249 - cs461x_free(pdev); 250 - return -ENOMEM; 251 - } 252 - 253 - ba0 = ioremap(ba0_addr, CS461X_BA0_SIZE); 254 - #ifdef CS461X_FULL_MAP 255 - ba1.name.data0 = ioremap(ba1_addr + BA1_SP_DMEM0, CS461X_BA1_DATA0_SIZE); 256 - ba1.name.data1 = ioremap(ba1_addr + BA1_SP_DMEM1, CS461X_BA1_DATA1_SIZE); 257 - ba1.name.pmem = ioremap(ba1_addr + BA1_SP_PMEM, CS461X_BA1_PRG_SIZE); 258 - ba1.name.reg = ioremap(ba1_addr + BA1_SP_REG, CS461X_BA1_REG_SIZE); 259 - 260 - if (ba0 == NULL || ba1.name.data0 == NULL || 261 - ba1.name.data1 == NULL || ba1.name.pmem == NULL || 262 - ba1.name.reg == NULL) { 263 - cs461x_free(pdev); 264 - return -ENOMEM; 265 - } 266 - #else 267 - if (ba0 == NULL) { 268 - cs461x_free(pdev); 269 - return -ENOMEM; 270 - } 271 - #endif 272 - 273 - if (!(port = gameport_allocate_port())) { 274 - printk(KERN_ERR "cs461x: Memory allocation failed\n"); 275 - cs461x_free(pdev); 276 - return -ENOMEM; 277 - } 278 - 279 - pci_set_drvdata(pdev, port); 280 - 281 - port->open = cs461x_gameport_open; 282 - port->trigger = cs461x_gameport_trigger; 283 - port->read = cs461x_gameport_read; 284 - port->cooked_read = cs461x_gameport_cooked_read; 285 - 286 - gameport_set_name(port, "CS416x"); 287 - gameport_set_phys(port, "pci%s/gameport0", pci_name(pdev)); 288 - port->dev.parent = &pdev->dev; 289 - 290 - cs461x_pokeBA0(BA0_JSIO, 0xFF); // ? 291 - cs461x_pokeBA0(BA0_JSCTL, JSCTL_SP_MEDIUM_SLOW); 292 - 293 - gameport_register_port(port); 294 - 295 - return 0; 296 - } 297 - 298 - static void __devexit cs461x_pci_remove(struct pci_dev *pdev) 299 - { 300 - cs461x_free(pdev); 301 - } 302 - 303 - static struct pci_driver cs461x_pci_driver = { 304 - .name = "CS461x_gameport", 305 - .id_table = cs461x_pci_tbl, 306 - .probe = cs461x_pci_probe, 307 - .remove = __devexit_p(cs461x_pci_remove), 308 - }; 309 - 310 - static int __init cs461x_init(void) 311 - { 312 - return pci_register_driver(&cs461x_pci_driver); 313 - } 314 - 315 - static void __exit cs461x_exit(void) 316 - { 317 - pci_unregister_driver(&cs461x_pci_driver); 318 - } 319 - 320 - module_init(cs461x_init); 321 - module_exit(cs461x_exit); 322 -
+6 -6
drivers/input/gameport/ns558.c
··· 258 258 { 259 259 int i = 0; 260 260 261 + if (pnp_register_driver(&ns558_pnp_driver) >= 0) 262 + pnp_registered = 1; 263 + 261 264 /* 262 - * Probe ISA ports first so that PnP gets to choose free port addresses 263 - * not occupied by the ISA ports. 265 + * Probe ISA ports after PnP, so that PnP ports that are already 266 + * enabled get detected as PnP. This may be suboptimal in multi-device 267 + * configurations, but saves hassle with simple setups. 264 268 */ 265 269 266 270 while (ns558_isa_portlist[i]) 267 271 ns558_isa_probe(ns558_isa_portlist[i++]); 268 - 269 - if (pnp_register_driver(&ns558_pnp_driver) >= 0) 270 - pnp_registered = 1; 271 - 272 272 273 273 return (list_empty(&ns558_list) && !pnp_registered) ? -ENODEV : 0; 274 274 }
-186
drivers/input/gameport/vortex.c
··· 1 - /* 2 - * $Id: vortex.c,v 1.5 2002/07/01 15:39:30 vojtech Exp $ 3 - * 4 - * Copyright (c) 2000-2001 Vojtech Pavlik 5 - * 6 - * Based on the work of: 7 - * Raymond Ingles 8 - */ 9 - 10 - /* 11 - * Trident 4DWave and Aureal Vortex gameport driver for Linux 12 - */ 13 - 14 - /* 15 - * This program is free software; you can redistribute it and/or modify 16 - * it under the terms of the GNU General Public License as published by 17 - * the Free Software Foundation; either version 2 of the License, or 18 - * (at your option) any later version. 19 - * 20 - * This program is distributed in the hope that it will be useful, 21 - * but WITHOUT ANY WARRANTY; without even the implied warranty of 22 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 23 - * GNU General Public License for more details. 24 - * 25 - * You should have received a copy of the GNU General Public License 26 - * along with this program; if not, write to the Free Software 27 - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 28 - * 29 - * Should you need to contact me, the author, you can do so either by 30 - * e-mail - mail your message to <vojtech@ucw.cz>, or by paper mail: 31 - * Vojtech Pavlik, Simunkova 1594, Prague 8, 182 00 Czech Republic 32 - */ 33 - 34 - #include <asm/io.h> 35 - #include <linux/delay.h> 36 - #include <linux/errno.h> 37 - #include <linux/ioport.h> 38 - #include <linux/kernel.h> 39 - #include <linux/module.h> 40 - #include <linux/pci.h> 41 - #include <linux/init.h> 42 - #include <linux/slab.h> 43 - #include <linux/delay.h> 44 - #include <linux/gameport.h> 45 - 46 - MODULE_AUTHOR("Vojtech Pavlik <vojtech@ucw.cz>"); 47 - MODULE_DESCRIPTION("Aureal Vortex and Vortex2 gameport driver"); 48 - MODULE_LICENSE("GPL"); 49 - 50 - #define VORTEX_GCR 0x0c /* Gameport control register */ 51 - #define VORTEX_LEG 0x08 /* Legacy port location */ 52 - #define VORTEX_AXD 0x10 /* Axes start */ 53 - #define VORTEX_DATA_WAIT 20 /* 20 ms */ 54 - 55 - struct vortex { 56 - struct gameport *gameport; 57 - struct pci_dev *dev; 58 - unsigned char __iomem *base; 59 - unsigned char __iomem *io; 60 - }; 61 - 62 - static unsigned char vortex_read(struct gameport *gameport) 63 - { 64 - struct vortex *vortex = gameport->port_data; 65 - return readb(vortex->io + VORTEX_LEG); 66 - } 67 - 68 - static void vortex_trigger(struct gameport *gameport) 69 - { 70 - struct vortex *vortex = gameport->port_data; 71 - writeb(0xff, vortex->io + VORTEX_LEG); 72 - } 73 - 74 - static int vortex_cooked_read(struct gameport *gameport, int *axes, int *buttons) 75 - { 76 - struct vortex *vortex = gameport->port_data; 77 - int i; 78 - 79 - *buttons = (~readb(vortex->base + VORTEX_LEG) >> 4) & 0xf; 80 - 81 - for (i = 0; i < 4; i++) { 82 - axes[i] = readw(vortex->io + VORTEX_AXD + i * sizeof(u32)); 83 - if (axes[i] == 0x1fff) axes[i] = -1; 84 - } 85 - 86 - return 0; 87 - } 88 - 89 - static int vortex_open(struct gameport *gameport, int mode) 90 - { 91 - struct vortex *vortex = gameport->port_data; 92 - 93 - switch (mode) { 94 - case GAMEPORT_MODE_COOKED: 95 - writeb(0x40, vortex->io + VORTEX_GCR); 96 - msleep(VORTEX_DATA_WAIT); 97 - return 0; 98 - case GAMEPORT_MODE_RAW: 99 - writeb(0x00, vortex->io + VORTEX_GCR); 100 - return 0; 101 - default: 102 - return -1; 103 - } 104 - 105 - return 0; 106 - } 107 - 108 - static int __devinit vortex_probe(struct pci_dev *dev, const struct pci_device_id *id) 109 - { 110 - struct vortex *vortex; 111 - struct gameport *port; 112 - int i; 113 - 114 - vortex = kcalloc(1, sizeof(struct vortex), GFP_KERNEL); 115 - port = gameport_allocate_port(); 116 - if (!vortex || !port) { 117 - printk(KERN_ERR "vortex: Memory allocation failed.\n"); 118 - kfree(vortex); 119 - gameport_free_port(port); 120 - return -ENOMEM; 121 - } 122 - 123 - for (i = 0; i < 6; i++) 124 - if (~pci_resource_flags(dev, i) & IORESOURCE_IO) 125 - break; 126 - 127 - pci_enable_device(dev); 128 - 129 - vortex->dev = dev; 130 - vortex->gameport = port; 131 - vortex->base = ioremap(pci_resource_start(vortex->dev, i), 132 - pci_resource_len(vortex->dev, i)); 133 - vortex->io = vortex->base + id->driver_data; 134 - 135 - pci_set_drvdata(dev, vortex); 136 - 137 - port->port_data = vortex; 138 - port->fuzz = 64; 139 - 140 - gameport_set_name(port, "AU88x0"); 141 - gameport_set_phys(port, "pci%s/gameport0", pci_name(dev)); 142 - port->dev.parent = &dev->dev; 143 - port->read = vortex_read; 144 - port->trigger = vortex_trigger; 145 - port->cooked_read = vortex_cooked_read; 146 - port->open = vortex_open; 147 - 148 - gameport_register_port(port); 149 - 150 - return 0; 151 - } 152 - 153 - static void __devexit vortex_remove(struct pci_dev *dev) 154 - { 155 - struct vortex *vortex = pci_get_drvdata(dev); 156 - 157 - gameport_unregister_port(vortex->gameport); 158 - iounmap(vortex->base); 159 - kfree(vortex); 160 - } 161 - 162 - static struct pci_device_id vortex_id_table[] = { 163 - { 0x12eb, 0x0001, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0x11000 }, 164 - { 0x12eb, 0x0002, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0x28800 }, 165 - { 0 } 166 - }; 167 - 168 - static struct pci_driver vortex_driver = { 169 - .name = "vortex_gameport", 170 - .id_table = vortex_id_table, 171 - .probe = vortex_probe, 172 - .remove = __devexit_p(vortex_remove), 173 - }; 174 - 175 - static int __init vortex_init(void) 176 - { 177 - return pci_register_driver(&vortex_driver); 178 - } 179 - 180 - static void __exit vortex_exit(void) 181 - { 182 - pci_unregister_driver(&vortex_driver); 183 - } 184 - 185 - module_init(vortex_init); 186 - module_exit(vortex_exit);
+32 -5
drivers/input/input.c
··· 219 219 220 220 int input_open_device(struct input_handle *handle) 221 221 { 222 + struct input_dev *dev = handle->dev; 223 + int err; 224 + 225 + err = down_interruptible(&dev->sem); 226 + if (err) 227 + return err; 228 + 222 229 handle->open++; 223 - if (handle->dev->open) 224 - return handle->dev->open(handle->dev); 225 - return 0; 230 + 231 + if (!dev->users++ && dev->open) 232 + err = dev->open(dev); 233 + 234 + if (err) 235 + handle->open--; 236 + 237 + up(&dev->sem); 238 + 239 + return err; 226 240 } 227 241 228 242 int input_flush_device(struct input_handle* handle, struct file* file) ··· 249 235 250 236 void input_close_device(struct input_handle *handle) 251 237 { 238 + struct input_dev *dev = handle->dev; 239 + 252 240 input_release_device(handle); 253 - if (handle->dev->close) 254 - handle->dev->close(handle->dev); 241 + 242 + down(&dev->sem); 243 + 244 + if (!--dev->users && dev->close) 245 + dev->close(dev); 255 246 handle->open--; 247 + 248 + up(&dev->sem); 256 249 } 257 250 258 251 static void input_link_handle(struct input_handle *handle) ··· 435 414 struct input_device_id *id; 436 415 437 416 set_bit(EV_SYN, dev->evbit); 417 + 418 + init_MUTEX(&dev->sem); 438 419 439 420 /* 440 421 * If delay and period are pre-set by the driver, then autorepeating ··· 697 674 return (count > cnt) ? cnt : count; 698 675 } 699 676 677 + static struct file_operations input_fileops; 678 + 700 679 static int __init input_proc_init(void) 701 680 { 702 681 struct proc_dir_entry *entry; ··· 713 688 return -ENOMEM; 714 689 } 715 690 entry->owner = THIS_MODULE; 691 + input_fileops = *entry->proc_fops; 692 + entry->proc_fops = &input_fileops; 716 693 entry->proc_fops->poll = input_devices_poll; 717 694 entry = create_proc_read_entry("handlers", 0, proc_bus_input_dir, input_handlers_read, NULL); 718 695 if (entry == NULL) {
+91 -25
drivers/input/joydev.c
··· 285 285 (POLLIN | POLLRDNORM) : 0) | (list->joydev->exist ? 0 : (POLLHUP | POLLERR)); 286 286 } 287 287 288 - static int joydev_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg) 288 + static int joydev_ioctl_common(struct joydev *joydev, unsigned int cmd, void __user *argp) 289 289 { 290 - struct joydev_list *list = file->private_data; 291 - struct joydev *joydev = list->joydev; 292 290 struct input_dev *dev = joydev->handle.dev; 293 - void __user *argp = (void __user *)arg; 294 291 int i, j; 295 - 296 - if (!joydev->exist) return -ENODEV; 297 292 298 293 switch (cmd) { 299 294 300 295 case JS_SET_CAL: 301 296 return copy_from_user(&joydev->glue.JS_CORR, argp, 302 - sizeof(struct JS_DATA_TYPE)) ? -EFAULT : 0; 297 + sizeof(joydev->glue.JS_CORR)) ? -EFAULT : 0; 303 298 case JS_GET_CAL: 304 299 return copy_to_user(argp, &joydev->glue.JS_CORR, 305 - sizeof(struct JS_DATA_TYPE)) ? -EFAULT : 0; 300 + sizeof(joydev->glue.JS_CORR)) ? -EFAULT : 0; 306 301 case JS_SET_TIMEOUT: 307 - return get_user(joydev->glue.JS_TIMEOUT, (int __user *) arg); 302 + return get_user(joydev->glue.JS_TIMEOUT, (s32 __user *) argp); 308 303 case JS_GET_TIMEOUT: 309 - return put_user(joydev->glue.JS_TIMEOUT, (int __user *) arg); 310 - case JS_SET_TIMELIMIT: 311 - return get_user(joydev->glue.JS_TIMELIMIT, (long __user *) arg); 312 - case JS_GET_TIMELIMIT: 313 - return put_user(joydev->glue.JS_TIMELIMIT, (long __user *) arg); 314 - case JS_SET_ALL: 315 - return copy_from_user(&joydev->glue, argp, 316 - sizeof(struct JS_DATA_SAVE_TYPE)) ? -EFAULT : 0; 317 - case JS_GET_ALL: 318 - return copy_to_user(argp, &joydev->glue, 319 - sizeof(struct JS_DATA_SAVE_TYPE)) ? -EFAULT : 0; 304 + return put_user(joydev->glue.JS_TIMEOUT, (s32 __user *) argp); 320 305 321 306 case JSIOCGVERSION: 322 - return put_user(JS_VERSION, (__u32 __user *) arg); 307 + return put_user(JS_VERSION, (__u32 __user *) argp); 323 308 case JSIOCGAXES: 324 - return put_user(joydev->nabs, (__u8 __user *) arg); 309 + return put_user(joydev->nabs, (__u8 __user *) argp); 325 310 case JSIOCGBUTTONS: 326 - return put_user(joydev->nkey, (__u8 __user *) arg); 311 + return put_user(joydev->nkey, (__u8 __user *) argp); 327 312 case JSIOCSCORR: 328 313 if (copy_from_user(joydev->corr, argp, 329 - sizeof(struct js_corr) * joydev->nabs)) 314 + sizeof(joydev->corr[0]) * joydev->nabs)) 330 315 return -EFAULT; 331 316 for (i = 0; i < joydev->nabs; i++) { 332 317 j = joydev->abspam[i]; ··· 320 335 return 0; 321 336 case JSIOCGCORR: 322 337 return copy_to_user(argp, joydev->corr, 323 - sizeof(struct js_corr) * joydev->nabs) ? -EFAULT : 0; 338 + sizeof(joydev->corr[0]) * joydev->nabs) ? -EFAULT : 0; 324 339 case JSIOCSAXMAP: 325 340 if (copy_from_user(joydev->abspam, argp, sizeof(__u8) * (ABS_MAX + 1))) 326 341 return -EFAULT; ··· 356 371 return -EINVAL; 357 372 } 358 373 374 + #ifdef CONFIG_COMPAT 375 + static long joydev_compat_ioctl(struct file *file, unsigned int cmd, unsigned long arg) 376 + { 377 + struct joydev_list *list = file->private_data; 378 + struct joydev *joydev = list->joydev; 379 + void __user *argp = (void __user *)arg; 380 + s32 tmp32; 381 + struct JS_DATA_SAVE_TYPE_32 ds32; 382 + int err; 383 + 384 + if (!joydev->exist) return -ENODEV; 385 + switch(cmd) { 386 + case JS_SET_TIMELIMIT: 387 + err = get_user(tmp32, (s32 __user *) arg); 388 + if (err == 0) 389 + joydev->glue.JS_TIMELIMIT = tmp32; 390 + break; 391 + case JS_GET_TIMELIMIT: 392 + tmp32 = joydev->glue.JS_TIMELIMIT; 393 + err = put_user(tmp32, (s32 __user *) arg); 394 + break; 395 + 396 + case JS_SET_ALL: 397 + err = copy_from_user(&ds32, argp, 398 + sizeof(ds32)) ? -EFAULT : 0; 399 + if (err == 0) { 400 + joydev->glue.JS_TIMEOUT = ds32.JS_TIMEOUT; 401 + joydev->glue.BUSY = ds32.BUSY; 402 + joydev->glue.JS_EXPIRETIME = ds32.JS_EXPIRETIME; 403 + joydev->glue.JS_TIMELIMIT = ds32.JS_TIMELIMIT; 404 + joydev->glue.JS_SAVE = ds32.JS_SAVE; 405 + joydev->glue.JS_CORR = ds32.JS_CORR; 406 + } 407 + break; 408 + 409 + case JS_GET_ALL: 410 + ds32.JS_TIMEOUT = joydev->glue.JS_TIMEOUT; 411 + ds32.BUSY = joydev->glue.BUSY; 412 + ds32.JS_EXPIRETIME = joydev->glue.JS_EXPIRETIME; 413 + ds32.JS_TIMELIMIT = joydev->glue.JS_TIMELIMIT; 414 + ds32.JS_SAVE = joydev->glue.JS_SAVE; 415 + ds32.JS_CORR = joydev->glue.JS_CORR; 416 + 417 + err = copy_to_user(argp, &ds32, 418 + sizeof(ds32)) ? -EFAULT : 0; 419 + break; 420 + 421 + default: 422 + err = joydev_ioctl_common(joydev, cmd, argp); 423 + } 424 + return err; 425 + } 426 + #endif /* CONFIG_COMPAT */ 427 + 428 + static int joydev_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg) 429 + { 430 + struct joydev_list *list = file->private_data; 431 + struct joydev *joydev = list->joydev; 432 + void __user *argp = (void __user *)arg; 433 + 434 + if (!joydev->exist) return -ENODEV; 435 + 436 + switch(cmd) { 437 + case JS_SET_TIMELIMIT: 438 + return get_user(joydev->glue.JS_TIMELIMIT, (long __user *) arg); 439 + case JS_GET_TIMELIMIT: 440 + return put_user(joydev->glue.JS_TIMELIMIT, (long __user *) arg); 441 + case JS_SET_ALL: 442 + return copy_from_user(&joydev->glue, argp, 443 + sizeof(joydev->glue)) ? -EFAULT : 0; 444 + case JS_GET_ALL: 445 + return copy_to_user(argp, &joydev->glue, 446 + sizeof(joydev->glue)) ? -EFAULT : 0; 447 + default: 448 + return joydev_ioctl_common(joydev, cmd, argp); 449 + } 450 + } 451 + 359 452 static struct file_operations joydev_fops = { 360 453 .owner = THIS_MODULE, 361 454 .read = joydev_read, ··· 442 379 .open = joydev_open, 443 380 .release = joydev_release, 444 381 .ioctl = joydev_ioctl, 382 + #ifdef CONFIG_COMPAT 383 + .compat_ioctl = joydev_compat_ioctl, 384 + #endif 445 385 .fasync = joydev_fasync, 446 386 }; 447 387
+1 -1
drivers/input/joystick/a3d.c
··· 185 185 a3d->reads++; 186 186 if (a3d_read_packet(a3d->gameport, a3d->length, data) != a3d->length || 187 187 data[0] != a3d->mode || a3d_csum(data, a3d->length)) 188 - a3d->bads++; 188 + a3d->bads++; 189 189 else 190 190 a3d_read(a3d, data); 191 191 }
+2 -2
drivers/input/joystick/adi.c
··· 82 82 static char adi_wmf_abs[] = { ABS_WHEEL, ABS_GAS, ABS_BRAKE, ABS_HAT0X, ABS_HAT0Y, ABS_HAT1X, ABS_HAT1Y, ABS_HAT2X, ABS_HAT2Y }; 83 83 84 84 static short adi_wmgpe_key[] = { BTN_A, BTN_B, BTN_C, BTN_X, BTN_Y, BTN_Z, BTN_TL, BTN_TR, BTN_START, BTN_MODE, BTN_SELECT }; 85 - static short adi_wmi_key[] = { BTN_TRIGGER, BTN_TOP, BTN_THUMB, BTN_TOP2, BTN_BASE, BTN_BASE2, BTN_BASE3, BTN_BASE4, BTN_EXTRA }; 85 + static short adi_wmi_key[] = { BTN_TRIGGER, BTN_TOP, BTN_THUMB, BTN_TOP2, BTN_BASE, BTN_BASE2, BTN_BASE3, BTN_BASE4, BTN_EXTRA }; 86 86 static short adi_wmed3d_key[] = { BTN_TRIGGER, BTN_THUMB, BTN_THUMB2, BTN_TOP, BTN_TOP2, BTN_BASE, BTN_BASE2 }; 87 87 static short adi_cm2_key[] = { BTN_1, BTN_2, BTN_3, BTN_4, BTN_5, BTN_6, BTN_7, BTN_8 }; 88 88 ··· 183 183 int i; 184 184 struct adi *adi = port->adi; 185 185 186 - adi[0].idx = adi[1].idx = 0; 186 + adi[0].idx = adi[1].idx = 0; 187 187 188 188 if (adi[0].ret <= 0 || adi[1].ret <= 0) return; 189 189 if (adi[0].data[0] & 0x20 || ~adi[1].data[0] & 0x20) return;
+16 -13
drivers/input/joystick/amijoy.c
··· 51 51 52 52 __obsolete_setup("amijoy="); 53 53 54 - static int amijoy_used[2] = { 0, 0 }; 54 + static int amijoy_used; 55 + static DECLARE_MUTEX(amijoy_sem); 55 56 static struct input_dev amijoy_dev[2]; 56 57 static char *amijoy_phys[2] = { "amijoy/input0", "amijoy/input1" }; 57 58 ··· 85 84 86 85 static int amijoy_open(struct input_dev *dev) 87 86 { 88 - int *used = dev->private; 87 + int err; 89 88 90 - if ((*used)++) 91 - return 0; 89 + err = down_interruptible(&amijoy_sem); 90 + if (err) 91 + return err; 92 92 93 - if (request_irq(IRQ_AMIGA_VERTB, amijoy_interrupt, 0, "amijoy", amijoy_interrupt)) { 94 - (*used)--; 93 + if (!amijoy_used && request_irq(IRQ_AMIGA_VERTB, amijoy_interrupt, 0, "amijoy", amijoy_interrupt)) { 95 94 printk(KERN_ERR "amijoy.c: Can't allocate irq %d\n", IRQ_AMIGA_VERTB); 96 - return -EBUSY; 95 + err = -EBUSY; 96 + goto out; 97 97 } 98 98 99 - return 0; 99 + amijoy_used++; 100 + out: 101 + up(&amijoy_sem); 102 + return err; 100 103 } 101 104 102 105 static void amijoy_close(struct input_dev *dev) 103 106 { 104 - int *used = dev->private; 105 - 106 - if (!--(*used)) 107 + down(&amijoysem); 108 + if (!--amijoy_used) 107 109 free_irq(IRQ_AMIGA_VERTB, amijoy_interrupt); 110 + up(&amijoy_sem); 108 111 } 109 112 110 113 static int __init amijoy_init(void) ··· 142 137 amijoy_dev[i].id.vendor = 0x0001; 143 138 amijoy_dev[i].id.product = 0x0003; 144 139 amijoy_dev[i].id.version = 0x0100; 145 - 146 - amijoy_dev[i].private = amijoy_used + i; 147 140 148 141 input_register_device(amijoy_dev + i); 149 142 printk(KERN_INFO "input: %s at joy%ddat\n", amijoy_name, i);
+13 -4
drivers/input/joystick/db9.c
··· 87 87 #define DB9_NORMAL 0x0a 88 88 #define DB9_NOSELECT 0x08 89 89 90 - #define DB9_MAX_DEVICES 2 90 + #define DB9_MAX_DEVICES 2 91 91 92 92 #define DB9_GENESIS6_DELAY 14 93 93 #define DB9_REFRESH_TIME HZ/100 ··· 98 98 struct pardevice *pd; 99 99 int mode; 100 100 int used; 101 + struct semaphore sem; 101 102 char phys[2][32]; 102 103 }; 103 104 ··· 504 503 { 505 504 struct db9 *db9 = dev->private; 506 505 struct parport *port = db9->pd->port; 506 + int err; 507 + 508 + err = down_interruptible(&db9->sem); 509 + if (err) 510 + return err; 507 511 508 512 if (!db9->used++) { 509 513 parport_claim(db9->pd); ··· 520 514 mod_timer(&db9->timer, jiffies + DB9_REFRESH_TIME); 521 515 } 522 516 517 + up(&db9->sem); 523 518 return 0; 524 519 } 525 520 ··· 529 522 struct db9 *db9 = dev->private; 530 523 struct parport *port = db9->pd->port; 531 524 525 + down(&db9->sem); 532 526 if (!--db9->used) { 533 - del_timer(&db9->timer); 527 + del_timer_sync(&db9->timer); 534 528 parport_write_control(port, 0x00); 535 529 parport_data_forward(port); 536 530 parport_release(db9->pd); 537 531 } 532 + up(&db9->sem); 538 533 } 539 534 540 535 static struct db9 __init *db9_probe(int *config, int nargs) ··· 572 563 } 573 564 } 574 565 575 - if (!(db9 = kmalloc(sizeof(struct db9), GFP_KERNEL))) { 566 + if (!(db9 = kcalloc(1, sizeof(struct db9), GFP_KERNEL))) { 576 567 parport_put_port(pp); 577 568 return NULL; 578 569 } 579 - memset(db9, 0, sizeof(struct db9)); 580 570 571 + init_MUTEX(&db9->sem); 581 572 db9->mode = config[1]; 582 573 init_timer(&db9->timer); 583 574 db9->timer.data = (long) db9;
+21 -8
drivers/input/joystick/gamecon.c
··· 1 1 /* 2 2 * NES, SNES, N64, MultiSystem, PSX gamepad driver for Linux 3 3 * 4 - * Copyright (c) 1999-2004 Vojtech Pavlik <vojtech@suse.cz> 5 - * Copyright (c) 2004 Peter Nelson <rufus-kernel@hackish.org> 4 + * Copyright (c) 1999-2004 Vojtech Pavlik <vojtech@suse.cz> 5 + * Copyright (c) 2004 Peter Nelson <rufus-kernel@hackish.org> 6 6 * 7 7 * Based on the work of: 8 - * Andree Borrmann John Dahlstrom 9 - * David Kuder Nathan Hand 8 + * Andree Borrmann John Dahlstrom 9 + * David Kuder Nathan Hand 10 10 */ 11 11 12 12 /* ··· 81 81 struct timer_list timer; 82 82 unsigned char pads[GC_MAX + 1]; 83 83 int used; 84 + struct semaphore sem; 84 85 char phys[5][32]; 85 86 }; 86 87 ··· 434 433 gc_psx_read_packet(gc, data_psx, data); 435 434 436 435 for (i = 0; i < 5; i++) { 437 - switch (data[i]) { 436 + switch (data[i]) { 438 437 439 438 case GC_PSX_RUMBLE: 440 439 ··· 504 503 static int gc_open(struct input_dev *dev) 505 504 { 506 505 struct gc *gc = dev->private; 506 + int err; 507 + 508 + err = down_interruptible(&gc->sem); 509 + if (err) 510 + return err; 511 + 507 512 if (!gc->used++) { 508 513 parport_claim(gc->pd); 509 514 parport_write_control(gc->pd->port, 0x04); 510 515 mod_timer(&gc->timer, jiffies + GC_REFRESH_TIME); 511 516 } 517 + 518 + up(&gc->sem); 512 519 return 0; 513 520 } 514 521 515 522 static void gc_close(struct input_dev *dev) 516 523 { 517 524 struct gc *gc = dev->private; 525 + 526 + down(&gc->sem); 518 527 if (!--gc->used) { 519 - del_timer(&gc->timer); 528 + del_timer_sync(&gc->timer); 520 529 parport_write_control(gc->pd->port, 0x00); 521 530 parport_release(gc->pd); 522 531 } 532 + up(&gc->sem); 523 533 } 524 534 525 535 static struct gc __init *gc_probe(int *config, int nargs) ··· 554 542 return NULL; 555 543 } 556 544 557 - if (!(gc = kmalloc(sizeof(struct gc), GFP_KERNEL))) { 545 + if (!(gc = kcalloc(1, sizeof(struct gc), GFP_KERNEL))) { 558 546 parport_put_port(pp); 559 547 return NULL; 560 548 } 561 - memset(gc, 0, sizeof(struct gc)); 549 + 550 + init_MUTEX(&gc->sem); 562 551 563 552 gc->pd = parport_register_device(pp, "gamecon", NULL, NULL, NULL, PARPORT_DEV_EXCL, NULL); 564 553
+1 -1
drivers/input/joystick/gf2k.c
··· 329 329 330 330 for (i = 0; i < gf2k_axes[gf2k->id]; i++) { 331 331 gf2k->dev.absmax[gf2k_abs[i]] = (i < 2) ? gf2k->dev.abs[gf2k_abs[i]] * 2 - 32 : 332 - gf2k->dev.abs[gf2k_abs[0]] + gf2k->dev.abs[gf2k_abs[1]] - 32; 332 + gf2k->dev.abs[gf2k_abs[0]] + gf2k->dev.abs[gf2k_abs[1]] - 32; 333 333 gf2k->dev.absmin[gf2k_abs[i]] = 32; 334 334 gf2k->dev.absfuzz[gf2k_abs[i]] = 8; 335 335 gf2k->dev.absflat[gf2k_abs[i]] = (i < 2) ? 24 : 0;
+1 -1
drivers/input/joystick/grip_mp.c
··· 171 171 *packet = 0; 172 172 raw_data = gameport_read(gameport); 173 173 if (raw_data & 1) 174 - return IO_RETRY; 174 + return IO_RETRY; 175 175 176 176 for (i = 0; i < 64; i++) { 177 177 raw_data = gameport_read(gameport);
+1
drivers/input/joystick/iforce/iforce-main.c
··· 78 78 { 0x061c, 0xc0a4, "ACT LABS Force RS", btn_wheel, abs_wheel, ff_iforce }, //? 79 79 { 0x06f8, 0x0001, "Guillemot Race Leader Force Feedback", btn_wheel, abs_wheel, ff_iforce }, //? 80 80 { 0x06f8, 0x0004, "Guillemot Force Feedback Racing Wheel", btn_wheel, abs_wheel, ff_iforce }, //? 81 + { 0x06f8, 0x0004, "Gullemot Jet Leader 3D", btn_joystick, abs_joystick, ff_iforce }, //? 81 82 { 0x0000, 0x0000, "Unknown I-Force Device [%04x:%04x]", btn_joystick, abs_joystick, ff_iforce } 82 83 }; 83 84
+1
drivers/input/joystick/iforce/iforce-usb.c
··· 229 229 { USB_DEVICE(0x061c, 0xc0a4) }, /* ACT LABS Force RS */ 230 230 { USB_DEVICE(0x06f8, 0x0001) }, /* Guillemot Race Leader Force Feedback */ 231 231 { USB_DEVICE(0x06f8, 0x0004) }, /* Guillemot Force Feedback Racing Wheel */ 232 + { USB_DEVICE(0x06f8, 0xa302) }, /* Guillemot Jet Leader 3D */ 232 233 { } /* Terminating entry */ 233 234 }; 234 235
+2 -2
drivers/input/joystick/spaceball.c
··· 4 4 * Copyright (c) 1999-2001 Vojtech Pavlik 5 5 * 6 6 * Based on the work of: 7 - * David Thompson 8 - * Joseph Krahn 7 + * David Thompson 8 + * Joseph Krahn 9 9 */ 10 10 11 11 /*
+1 -1
drivers/input/joystick/spaceorb.c
··· 4 4 * Copyright (c) 1999-2001 Vojtech Pavlik 5 5 * 6 6 * Based on the work of: 7 - * David Thompson 7 + * David Thompson 8 8 */ 9 9 10 10 /*
+1 -1
drivers/input/joystick/tmdc.c
··· 79 79 { BTN_A, BTN_B, BTN_C, BTN_X, BTN_Y, BTN_Z, BTN_START, BTN_SELECT, BTN_TL, BTN_TR }; 80 80 static short tmdc_btn_joy[TMDC_BTN] = 81 81 { BTN_TRIGGER, BTN_THUMB, BTN_TOP, BTN_TOP2, BTN_BASE, BTN_BASE2, BTN_THUMB2, BTN_PINKIE, 82 - BTN_BASE3, BTN_BASE4, BTN_A, BTN_B, BTN_C, BTN_X, BTN_Y, BTN_Z }; 82 + BTN_BASE3, BTN_BASE4, BTN_A, BTN_B, BTN_C, BTN_X, BTN_Y, BTN_Z }; 83 83 static short tmdc_btn_fm[TMDC_BTN] = 84 84 { BTN_TRIGGER, BTN_C, BTN_B, BTN_A, BTN_THUMB, BTN_X, BTN_Y, BTN_Z, BTN_TOP, BTN_TOP2 }; 85 85 static short tmdc_btn_at[TMDC_BTN] =
+24 -11
drivers/input/joystick/turbografx.c
··· 84 84 char phys[7][32]; 85 85 int sticks; 86 86 int used; 87 + struct semaphore sem; 87 88 } *tgfx_base[3]; 88 89 89 90 /* ··· 100 99 for (i = 0; i < 7; i++) 101 100 if (tgfx->sticks & (1 << i)) { 102 101 103 - dev = tgfx->dev + i; 102 + dev = tgfx->dev + i; 104 103 105 104 parport_write_data(tgfx->pd->port, ~(1 << i)); 106 105 data1 = parport_read_status(tgfx->pd->port) ^ 0x7f; ··· 123 122 124 123 static int tgfx_open(struct input_dev *dev) 125 124 { 126 - struct tgfx *tgfx = dev->private; 127 - if (!tgfx->used++) { 125 + struct tgfx *tgfx = dev->private; 126 + int err; 127 + 128 + err = down_interruptible(&tgfx->sem); 129 + if (err) 130 + return err; 131 + 132 + if (!tgfx->used++) { 128 133 parport_claim(tgfx->pd); 129 134 parport_write_control(tgfx->pd->port, 0x04); 130 - mod_timer(&tgfx->timer, jiffies + TGFX_REFRESH_TIME); 135 + mod_timer(&tgfx->timer, jiffies + TGFX_REFRESH_TIME); 131 136 } 132 - return 0; 137 + 138 + up(&tgfx->sem); 139 + return 0; 133 140 } 134 141 135 142 static void tgfx_close(struct input_dev *dev) 136 143 { 137 - struct tgfx *tgfx = dev->private; 138 - if (!--tgfx->used) { 139 - del_timer(&tgfx->timer); 144 + struct tgfx *tgfx = dev->private; 145 + 146 + down(&tgfx->sem); 147 + if (!--tgfx->used) { 148 + del_timer_sync(&tgfx->timer); 140 149 parport_write_control(tgfx->pd->port, 0x00); 141 - parport_release(tgfx->pd); 150 + parport_release(tgfx->pd); 142 151 } 152 + up(&tgfx->sem); 143 153 } 144 154 145 155 /* ··· 178 166 return NULL; 179 167 } 180 168 181 - if (!(tgfx = kmalloc(sizeof(struct tgfx), GFP_KERNEL))) { 169 + if (!(tgfx = kcalloc(1, sizeof(struct tgfx), GFP_KERNEL))) { 182 170 parport_put_port(pp); 183 171 return NULL; 184 172 } 185 - memset(tgfx, 0, sizeof(struct tgfx)); 173 + 174 + init_MUTEX(&tgfx->sem); 186 175 187 176 tgfx->pd = parport_register_device(pp, "turbografx", NULL, NULL, NULL, PARPORT_DEV_EXCL, NULL); 188 177
+3 -3
drivers/input/keyboard/atkbd.c
··· 227 227 { \ 228 228 return atkbd_attr_set_helper(d, b, s, atkbd_set_##_name); \ 229 229 } \ 230 - static struct device_attribute atkbd_attr_##_name = \ 230 + static struct device_attribute atkbd_attr_##_name = \ 231 231 __ATTR(_name, S_IWUSR | S_IRUGO, atkbd_do_show_##_name, atkbd_do_set_##_name); 232 232 233 233 ATKBD_DEFINE_ATTR(extra); ··· 388 388 value = atkbd->release ? 0 : 389 389 (1 + (!atkbd->softrepeat && test_bit(atkbd->keycode[code], atkbd->dev.key))); 390 390 391 - switch (value) { /* Workaround Toshiba laptop multiple keypress */ 391 + switch (value) { /* Workaround Toshiba laptop multiple keypress */ 392 392 case 0: 393 393 atkbd->last = 0; 394 394 break; ··· 894 894 if (atkbd->write) { 895 895 param[0] = (test_bit(LED_SCROLLL, atkbd->dev.led) ? 1 : 0) 896 896 | (test_bit(LED_NUML, atkbd->dev.led) ? 2 : 0) 897 - | (test_bit(LED_CAPSL, atkbd->dev.led) ? 4 : 0); 897 + | (test_bit(LED_CAPSL, atkbd->dev.led) ? 4 : 0); 898 898 899 899 if (atkbd_probe(atkbd)) 900 900 return -1;
+4 -2
drivers/input/keyboard/corgikbd.c
··· 39 39 #define CORGI_KEY_CALENDER KEY_F1 40 40 #define CORGI_KEY_ADDRESS KEY_F2 41 41 #define CORGI_KEY_FN KEY_F3 42 + #define CORGI_KEY_CANCEL KEY_F4 42 43 #define CORGI_KEY_OFF KEY_SUSPEND 43 44 #define CORGI_KEY_EXOK KEY_F5 44 45 #define CORGI_KEY_EXCANCEL KEY_F6 ··· 47 46 #define CORGI_KEY_EXJOGUP KEY_F8 48 47 #define CORGI_KEY_JAP1 KEY_LEFTCTRL 49 48 #define CORGI_KEY_JAP2 KEY_LEFTALT 49 + #define CORGI_KEY_MAIL KEY_F10 50 50 #define CORGI_KEY_OK KEY_F11 51 51 #define CORGI_KEY_MENU KEY_F12 52 52 #define CORGI_HINGE_0 KEY_KP0 ··· 61 59 KEY_TAB, KEY_Q, KEY_E, KEY_T, KEY_G, KEY_U, KEY_J, KEY_K, 0, 0, 0, 0, 0, 0, 0, 0, /* 33-48 */ 62 60 CORGI_KEY_CALENDER, KEY_W, KEY_S, KEY_F, KEY_V, KEY_H, KEY_M, KEY_L, 0, KEY_RIGHTSHIFT, 0, 0, 0, 0, 0, 0, /* 49-64 */ 63 61 CORGI_KEY_ADDRESS, KEY_A, KEY_D, KEY_C, KEY_B, KEY_N, KEY_DOT, 0, KEY_ENTER, 0, KEY_LEFTSHIFT, 0, 0, 0, 0, 0, /* 65-80 */ 64 - KEY_MAIL, KEY_Z, KEY_X, KEY_MINUS, KEY_SPACE, KEY_COMMA, 0, KEY_UP, 0, 0, 0, CORGI_KEY_FN, 0, 0, 0, 0, /* 81-96 */ 65 - KEY_SYSRQ, CORGI_KEY_JAP1, CORGI_KEY_JAP2, KEY_CANCEL, CORGI_KEY_OK, CORGI_KEY_MENU, KEY_LEFT, KEY_DOWN, KEY_RIGHT, 0, 0, 0, 0, 0, 0, 0, /* 97-112 */ 62 + CORGI_KEY_MAIL, KEY_Z, KEY_X, KEY_MINUS, KEY_SPACE, KEY_COMMA, 0, KEY_UP, 0, 0, 0, CORGI_KEY_FN, 0, 0, 0, 0, /* 81-96 */ 63 + KEY_SYSRQ, CORGI_KEY_JAP1, CORGI_KEY_JAP2, CORGI_KEY_CANCEL, CORGI_KEY_OK, CORGI_KEY_MENU, KEY_LEFT, KEY_DOWN, KEY_RIGHT, 0, 0, 0, 0, 0, 0, 0, /* 97-112 */ 66 64 CORGI_KEY_OFF, CORGI_KEY_EXOK, CORGI_KEY_EXCANCEL, CORGI_KEY_EXJOGDOWN, CORGI_KEY_EXJOGUP, 0, 0, 0, 0, 0, 0, 0, /* 113-124 */ 67 65 CORGI_HINGE_0, CORGI_HINGE_1, CORGI_HINGE_2 /* 125-127 */ 68 66 };
+4 -4
drivers/input/keyboard/lkkbd.c
··· 15 15 * information given below, I will _not_ be liable! 16 16 * 17 17 * RJ10 pinout: To DE9: Or DB25: 18 - * 1 - RxD <----> Pin 3 (TxD) <-> Pin 2 (TxD) 19 - * 2 - GND <----> Pin 5 (GND) <-> Pin 7 (GND) 20 - * 4 - TxD <----> Pin 2 (RxD) <-> Pin 3 (RxD) 21 - * 3 - +12V (from HDD drive connector), DON'T connect to DE9 or DB25!!! 18 + * 1 - RxD <----> Pin 3 (TxD) <-> Pin 2 (TxD) 19 + * 2 - GND <----> Pin 5 (GND) <-> Pin 7 (GND) 20 + * 4 - TxD <----> Pin 2 (RxD) <-> Pin 3 (RxD) 21 + * 3 - +12V (from HDD drive connector), DON'T connect to DE9 or DB25!!! 22 22 * 23 23 * Pin numbers for DE9 and DB25 are noted on the plug (quite small:). For 24 24 * RJ10, it's like this:
+14 -14
drivers/input/keyboard/locomokbd.c
··· 42 42 MODULE_DESCRIPTION("LoCoMo keyboard driver"); 43 43 MODULE_LICENSE("GPL"); 44 44 45 - #define LOCOMOKBD_NUMKEYS 128 45 + #define LOCOMOKBD_NUMKEYS 128 46 46 47 47 #define KEY_ACTIVITY KEY_F16 48 48 #define KEY_CONTACT KEY_F18 ··· 61 61 KEY_G, KEY_F, KEY_X, KEY_S, 0, 0, 0, 0, 0, 0, /* 90 - 99 */ 62 62 0, 0, KEY_DOT, 0, KEY_COMMA, KEY_N, KEY_B, KEY_C, KEY_Z, KEY_A, /* 100 - 109 */ 63 63 KEY_LEFTSHIFT, KEY_TAB, KEY_LEFTCTRL, 0, 0, 0, 0, 0, 0, 0, /* 110 - 119 */ 64 - KEY_M, KEY_SPACE, KEY_V, KEY_APOSTROPHE, KEY_SLASH, 0, 0, 0 /* 120 - 128 */ 64 + KEY_M, KEY_SPACE, KEY_V, KEY_APOSTROPHE, KEY_SLASH, 0, 0, 0 /* 120 - 128 */ 65 65 }; 66 66 67 67 #define KB_ROWS 16 ··· 82 82 struct locomo_dev *ldev; 83 83 unsigned long base; 84 84 spinlock_t lock; 85 - 85 + 86 86 struct timer_list timer; 87 87 }; 88 88 ··· 95 95 static inline void locomokbd_activate_all(unsigned long membase) 96 96 { 97 97 unsigned long r; 98 - 98 + 99 99 locomo_writel(0, membase + LOCOMO_KSC); 100 100 r = locomo_readl(membase + LOCOMO_KIC); 101 101 r &= 0xFEFF; ··· 127 127 */ 128 128 129 129 /* Scan the hardware keyboard and push any changes up through the input layer */ 130 - static void locomokbd_scankeyboard(struct locomokbd *locomokbd, struct pt_regs *regs) 130 + static void locomokbd_scankeyboard(struct locomokbd *locomokbd, struct pt_regs *regs) 131 131 { 132 132 unsigned int row, col, rowd, scancode; 133 133 unsigned long flags; ··· 138 138 139 139 if (regs) 140 140 input_regs(&locomokbd->input, regs); 141 - 141 + 142 142 locomokbd_charge_all(membase); 143 143 144 144 num_pressed = 0; ··· 146 146 147 147 locomokbd_activate_col(membase, col); 148 148 udelay(KB_DELAY); 149 - 149 + 150 150 rowd = ~locomo_readl(membase + LOCOMO_KIB); 151 - for (row = 0; row < KB_ROWS; row++ ) { 151 + for (row = 0; row < KB_ROWS; row++) { 152 152 scancode = SCANCODE(col, row); 153 153 if (rowd & KB_ROWMASK(row)) { 154 154 num_pressed += 1; ··· 170 170 spin_unlock_irqrestore(&locomokbd->lock, flags); 171 171 } 172 172 173 - /* 173 + /* 174 174 * LoCoMo keyboard interrupt handler. 175 175 */ 176 176 static irqreturn_t locomokbd_interrupt(int irq, void *dev_id, struct pt_regs *regs) ··· 205 205 memset(locomokbd, 0, sizeof(struct locomokbd)); 206 206 207 207 /* try and claim memory region */ 208 - if (!request_mem_region((unsigned long) dev->mapbase, 209 - dev->length, 208 + if (!request_mem_region((unsigned long) dev->mapbase, 209 + dev->length, 210 210 LOCOMO_DRIVER_NAME(dev))) { 211 211 ret = -EBUSY; 212 212 printk(KERN_ERR "locomokbd: Can't acquire access to io memory for keyboard\n"); ··· 225 225 locomokbd->timer.data = (unsigned long) locomokbd; 226 226 227 227 locomokbd->input.evbit[0] = BIT(EV_KEY) | BIT(EV_REP); 228 - 228 + 229 229 init_input_dev(&locomokbd->input); 230 230 locomokbd->input.keycode = locomokbd->keycode; 231 231 locomokbd->input.keycodesize = sizeof(unsigned char); ··· 271 271 static int locomokbd_remove(struct locomo_dev *dev) 272 272 { 273 273 struct locomokbd *locomokbd = locomo_get_drvdata(dev); 274 - 274 + 275 275 free_irq(dev->irq[0], locomokbd); 276 276 277 277 del_timer_sync(&locomokbd->timer); 278 - 278 + 279 279 input_unregister_device(&locomokbd->input); 280 280 locomo_set_drvdata(dev, NULL); 281 281
+1 -21
drivers/input/keyboard/maple_keyb.c
··· 1 1 /* 2 2 * $Id: maple_keyb.c,v 1.4 2004/03/22 01:18:15 lethal Exp $ 3 - * SEGA Dreamcast keyboard driver 3 + * SEGA Dreamcast keyboard driver 4 4 * Based on drivers/usb/usbkbd.c 5 5 */ 6 6 ··· 40 40 struct input_dev dev; 41 41 unsigned char new[8]; 42 42 unsigned char old[8]; 43 - int open; 44 43 }; 45 44 46 45 ··· 94 95 } 95 96 } 96 97 97 - 98 - static int dc_kbd_open(struct input_dev *dev) 99 - { 100 - struct dc_kbd *kbd = dev->private; 101 - kbd->open++; 102 - return 0; 103 - } 104 - 105 - 106 - static void dc_kbd_close(struct input_dev *dev) 107 - { 108 - struct dc_kbd *kbd = dev->private; 109 - kbd->open--; 110 - } 111 - 112 - 113 98 static int dc_kbd_connect(struct maple_device *dev) 114 99 { 115 100 int i; ··· 116 133 clear_bit(0, kbd->dev.keybit); 117 134 118 135 kbd->dev.private = kbd; 119 - kbd->dev.open = dc_kbd_open; 120 - kbd->dev.close = dc_kbd_close; 121 - kbd->dev.event = NULL; 122 136 123 137 kbd->dev.name = dev->product_name; 124 138 kbd->dev.id.bustype = BUS_MAPLE;
+4 -2
drivers/input/misc/uinput.c
··· 298 298 /* check if absmin/absmax/absfuzz/absflat are filled as 299 299 * told in Documentation/input/input-programming.txt */ 300 300 if (test_bit(EV_ABS, dev->evbit)) { 301 - retval = uinput_validate_absbits(dev); 302 - if (retval < 0) 301 + int err = uinput_validate_absbits(dev); 302 + if (err < 0) { 303 + retval = err; 303 304 kfree(dev->name); 305 + } 304 306 } 305 307 306 308 exit:
+1 -1
drivers/input/mouse/Makefile
··· 15 15 obj-$(CONFIG_MOUSE_HIL) += hil_ptr.o 16 16 obj-$(CONFIG_MOUSE_VSXXXAA) += vsxxxaa.o 17 17 18 - psmouse-objs := psmouse-base.o alps.o logips2pp.o synaptics.o 18 + psmouse-objs := psmouse-base.o alps.o logips2pp.o synaptics.o lifebook.o
+31 -21
drivers/input/mouse/alps.c
··· 30 30 31 31 #define ALPS_DUALPOINT 0x01 32 32 #define ALPS_WHEEL 0x02 33 - #define ALPS_FW_BK 0x04 33 + #define ALPS_FW_BK_1 0x04 34 34 #define ALPS_4BTN 0x08 35 35 #define ALPS_OLDPROTO 0x10 36 36 #define ALPS_PASS 0x20 37 + #define ALPS_FW_BK_2 0x40 37 38 38 39 static struct alps_model_info alps_model_data[] = { 39 40 { { 0x33, 0x02, 0x0a }, 0x88, 0xf8, ALPS_OLDPROTO }, /* UMAX-530T */ ··· 44 43 { { 0x63, 0x02, 0x14 }, 0xf8, 0xf8, 0 }, 45 44 { { 0x63, 0x02, 0x28 }, 0xf8, 0xf8, 0 }, 46 45 { { 0x63, 0x02, 0x3c }, 0x8f, 0x8f, ALPS_WHEEL }, /* Toshiba Satellite S2400-103 */ 47 - { { 0x63, 0x02, 0x50 }, 0xef, 0xef, ALPS_FW_BK }, /* NEC Versa L320 */ 46 + { { 0x63, 0x02, 0x50 }, 0xef, 0xef, ALPS_FW_BK_1 }, /* NEC Versa L320 */ 48 47 { { 0x63, 0x02, 0x64 }, 0xf8, 0xf8, 0 }, 49 48 { { 0x63, 0x03, 0xc8 }, 0xf8, 0xf8, ALPS_PASS }, /* Dell Latitude D800 */ 50 49 { { 0x73, 0x02, 0x0a }, 0xf8, 0xf8, 0 }, 51 - { { 0x73, 0x02, 0x14 }, 0xf8, 0xf8, 0 }, 50 + { { 0x73, 0x02, 0x14 }, 0xf8, 0xf8, ALPS_FW_BK_2 }, /* Ahtec Laptop */ 52 51 { { 0x20, 0x02, 0x0e }, 0xf8, 0xf8, ALPS_PASS | ALPS_DUALPOINT }, /* XXX */ 53 52 { { 0x22, 0x02, 0x0a }, 0xf8, 0xf8, ALPS_PASS | ALPS_DUALPOINT }, 54 53 { { 0x22, 0x02, 0x14 }, 0xff, 0xff, ALPS_PASS | ALPS_DUALPOINT }, /* Dell Latitude D600 */ ··· 62 61 63 62 /* 64 63 * ALPS abolute Mode - new format 65 - * 66 - * byte 0: 1 ? ? ? 1 ? ? ? 64 + * 65 + * byte 0: 1 ? ? ? 1 ? ? ? 67 66 * byte 1: 0 x6 x5 x4 x3 x2 x1 x0 68 67 * byte 2: 0 x10 x9 x8 x7 ? fin ges 69 - * byte 3: 0 y9 y8 y7 1 M R L 68 + * byte 3: 0 y9 y8 y7 1 M R L 70 69 * byte 4: 0 y6 y5 y4 y3 y2 y1 y0 71 70 * byte 5: 0 z6 z5 z4 z3 z2 z1 z0 72 71 * ··· 82 81 struct input_dev *dev = &psmouse->dev; 83 82 struct input_dev *dev2 = &priv->dev2; 84 83 int x, y, z, ges, fin, left, right, middle; 84 + int back = 0, forward = 0; 85 85 86 86 input_regs(dev, regs); 87 87 88 88 if ((packet[0] & 0xc8) == 0x08) { /* 3-byte PS/2 packet */ 89 - input_report_key(dev2, BTN_LEFT, packet[0] & 1); 89 + input_report_key(dev2, BTN_LEFT, packet[0] & 1); 90 90 input_report_key(dev2, BTN_RIGHT, packet[0] & 2); 91 91 input_report_key(dev2, BTN_MIDDLE, packet[0] & 4); 92 92 input_report_rel(dev2, REL_X, ··· 112 110 x = packet[1] | ((packet[2] & 0x78) << (7 - 3)); 113 111 y = packet[4] | ((packet[3] & 0x70) << (7 - 4)); 114 112 z = packet[5]; 113 + } 114 + 115 + if (priv->i->flags & ALPS_FW_BK_1) { 116 + back = packet[2] & 4; 117 + forward = packet[0] & 0x10; 118 + } 119 + 120 + if (priv->i->flags & ALPS_FW_BK_2) { 121 + back = packet[3] & 4; 122 + forward = packet[2] & 4; 123 + if ((middle = forward && back)) 124 + forward = back = 0; 115 125 } 116 126 117 127 ges = packet[2] & 1; ··· 169 155 input_report_abs(dev, ABS_PRESSURE, z); 170 156 input_report_key(dev, BTN_TOOL_FINGER, z > 0); 171 157 172 - 173 158 if (priv->i->flags & ALPS_WHEEL) 174 159 input_report_rel(dev, REL_WHEEL, ((packet[0] >> 4) & 0x07) | ((packet[2] >> 2) & 0x08)); 175 160 176 - if (priv->i->flags & ALPS_FW_BK) { 177 - input_report_key(dev, BTN_FORWARD, packet[0] & 0x10); 178 - input_report_key(dev, BTN_BACK, packet[2] & 0x04); 161 + if (priv->i->flags & (ALPS_FW_BK_1 | ALPS_FW_BK_2)) { 162 + input_report_key(dev, BTN_FORWARD, forward); 163 + input_report_key(dev, BTN_BACK, back); 179 164 } 180 165 181 166 input_sync(dev); ··· 270 257 static int alps_passthrough_mode(struct psmouse *psmouse, int enable) 271 258 { 272 259 struct ps2dev *ps2dev = &psmouse->ps2dev; 273 - unsigned char param[3]; 274 260 int cmd = enable ? PSMOUSE_CMD_SETSCALE21 : PSMOUSE_CMD_SETSCALE11; 275 261 276 262 if (ps2_command(ps2dev, NULL, cmd) || ··· 279 267 return -1; 280 268 281 269 /* we may get 3 more bytes, just ignore them */ 282 - ps2_command(ps2dev, param, 0x0300); 270 + ps2_drain(ps2dev, 3, 100); 283 271 284 272 return 0; 285 273 } ··· 437 425 psmouse->dev.relbit[LONG(REL_WHEEL)] |= BIT(REL_WHEEL); 438 426 } 439 427 440 - if (priv->i->flags & ALPS_FW_BK) { 428 + if (priv->i->flags & (ALPS_FW_BK_1 | ALPS_FW_BK_2)) { 441 429 psmouse->dev.keybit[LONG(BTN_FORWARD)] |= BIT(BTN_FORWARD); 442 430 psmouse->dev.keybit[LONG(BTN_BACK)] |= BIT(BTN_BACK); 443 431 } ··· 448 436 priv->dev2.id.bustype = BUS_I8042; 449 437 priv->dev2.id.vendor = 0x0002; 450 438 priv->dev2.id.product = PSMOUSE_ALPS; 451 - priv->dev2.id.version = 0x0000; 452 - 439 + priv->dev2.id.version = 0x0000; 440 + 453 441 priv->dev2.evbit[0] = BIT(EV_KEY) | BIT(EV_REL); 454 442 priv->dev2.relbit[LONG(REL_X)] |= BIT(REL_X) | BIT(REL_Y); 455 443 priv->dev2.keybit[LONG(BTN_LEFT)] |= BIT(BTN_LEFT) | BIT(BTN_MIDDLE) | BIT(BTN_RIGHT); ··· 473 461 int alps_detect(struct psmouse *psmouse, int set_properties) 474 462 { 475 463 int version; 476 - struct alps_model_info *model; 464 + struct alps_model_info *model; 477 465 478 466 if (!(model = alps_get_model(psmouse, &version))) 479 467 return -1; 480 468 481 469 if (set_properties) { 482 470 psmouse->vendor = "ALPS"; 483 - if (model->flags & ALPS_DUALPOINT) 484 - psmouse->name = "DualPoint TouchPad"; 485 - else 486 - psmouse->name = "GlidePoint"; 471 + psmouse->name = model->flags & ALPS_DUALPOINT ? 472 + "DualPoint TouchPad" : "GlidePoint"; 487 473 psmouse->model = version; 488 474 } 489 475 return 0;
+1 -7
drivers/input/mouse/amimouse.c
··· 33 33 MODULE_DESCRIPTION("Amiga mouse driver"); 34 34 MODULE_LICENSE("GPL"); 35 35 36 - static int amimouse_used = 0; 37 36 static int amimouse_lastx, amimouse_lasty; 38 37 static struct input_dev amimouse_dev; 39 38 ··· 80 81 { 81 82 unsigned short joy0dat; 82 83 83 - if (amimouse_used++) 84 - return 0; 85 - 86 84 joy0dat = custom.joy0dat; 87 85 88 86 amimouse_lastx = joy0dat & 0xff; 89 87 amimouse_lasty = joy0dat >> 8; 90 88 91 89 if (request_irq(IRQ_AMIGA_VERTB, amimouse_interrupt, 0, "amimouse", amimouse_interrupt)) { 92 - amimouse_used--; 93 90 printk(KERN_ERR "amimouse.c: Can't allocate irq %d\n", IRQ_AMIGA_VERTB); 94 91 return -EBUSY; 95 92 } ··· 95 100 96 101 static void amimouse_close(struct input_dev *dev) 97 102 { 98 - if (!--amimouse_used) 99 - free_irq(IRQ_AMIGA_VERTB, amimouse_interrupt); 103 + free_irq(IRQ_AMIGA_VERTB, amimouse_interrupt); 100 104 } 101 105 102 106 static int __init amimouse_init(void)
+16 -22
drivers/input/mouse/inport.c
··· 17 17 /* 18 18 * This program is free software; you can redistribute it and/or modify 19 19 * it under the terms of the GNU General Public License as published by 20 - * the Free Software Foundation; either version 2 of the License, or 20 + * the Free Software Foundation; either version 2 of the License, or 21 21 * (at your option) any later version. 22 - * 22 + * 23 23 * This program is distributed in the hope that it will be useful, 24 24 * but WITHOUT ANY WARRANTY; without even the implied warranty of 25 25 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 26 26 * GNU General Public License for more details. 27 - * 27 + * 28 28 * You should have received a copy of the GNU General Public License 29 29 * along with this program; if not, write to the Free Software 30 30 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 31 - * 31 + * 32 32 * Should you need to contact me, the author, you can do so either by 33 33 * e-mail - mail your message to <vojtech@ucw.cz>, or by paper mail: 34 34 * Vojtech Pavlik, Simunkova 1594, Prague 8, 182 00 Czech Republic ··· 87 87 88 88 __obsolete_setup("inport_irq="); 89 89 90 - static int inport_used; 91 - 92 90 static irqreturn_t inport_interrupt(int irq, void *dev_id, struct pt_regs *regs); 93 91 94 92 static int inport_open(struct input_dev *dev) 95 93 { 96 - if (!inport_used++) { 97 - if (request_irq(inport_irq, inport_interrupt, 0, "inport", NULL)) 98 - return -EBUSY; 99 - outb(INPORT_REG_MODE, INPORT_CONTROL_PORT); 100 - outb(INPORT_MODE_IRQ | INPORT_MODE_BASE, INPORT_DATA_PORT); 101 - } 94 + if (request_irq(inport_irq, inport_interrupt, 0, "inport", NULL)) 95 + return -EBUSY; 96 + outb(INPORT_REG_MODE, INPORT_CONTROL_PORT); 97 + outb(INPORT_MODE_IRQ | INPORT_MODE_BASE, INPORT_DATA_PORT); 102 98 103 99 return 0; 104 100 } 105 101 106 102 static void inport_close(struct input_dev *dev) 107 103 { 108 - if (!--inport_used) { 109 - outb(INPORT_REG_MODE, INPORT_CONTROL_PORT); 110 - outb(INPORT_MODE_BASE, INPORT_DATA_PORT); 111 - free_irq(inport_irq, NULL); 112 - } 104 + outb(INPORT_REG_MODE, INPORT_CONTROL_PORT); 105 + outb(INPORT_MODE_BASE, INPORT_DATA_PORT); 106 + free_irq(inport_irq, NULL); 113 107 } 114 108 115 109 static struct input_dev inport_dev = { ··· 114 120 .close = inport_close, 115 121 .name = INPORT_NAME, 116 122 .phys = "isa023c/input0", 117 - .id = { 118 - .bustype = BUS_ISA, 119 - .vendor = INPORT_VENDOR, 120 - .product = 0x0001, 121 - .version = 0x0100, 123 + .id = { 124 + .bustype = BUS_ISA, 125 + .vendor = INPORT_VENDOR, 126 + .product = 0x0001, 127 + .version = 0x0100, 122 128 }, 123 129 }; 124 130
+134
drivers/input/mouse/lifebook.c
··· 1 + /* 2 + * Fujitsu B-series Lifebook PS/2 TouchScreen driver 3 + * 4 + * Copyright (c) 2005 Vojtech Pavlik <vojtech@suse.cz> 5 + * Copyright (c) 2005 Kenan Esau <kenan.esau@conan.de> 6 + * 7 + * TouchScreen detection, absolute mode setting and packet layout is taken from 8 + * Harald Hoyer's description of the device. 9 + * 10 + * This program is free software; you can redistribute it and/or modify it 11 + * under the terms of the GNU General Public License version 2 as published by 12 + * the Free Software Foundation. 13 + */ 14 + 15 + #include <linux/input.h> 16 + #include <linux/serio.h> 17 + #include <linux/libps2.h> 18 + #include <linux/dmi.h> 19 + 20 + #include "psmouse.h" 21 + #include "lifebook.h" 22 + 23 + static struct dmi_system_id lifebook_dmi_table[] = { 24 + { 25 + .ident = "Lifebook B", 26 + .matches = { 27 + DMI_MATCH(DMI_PRODUCT_NAME, "LIFEBOOK B Series"), 28 + }, 29 + }, 30 + { } 31 + }; 32 + 33 + 34 + static psmouse_ret_t lifebook_process_byte(struct psmouse *psmouse, struct pt_regs *regs) 35 + { 36 + unsigned char *packet = psmouse->packet; 37 + struct input_dev *dev = &psmouse->dev; 38 + 39 + if (psmouse->pktcnt != 3) 40 + return PSMOUSE_GOOD_DATA; 41 + 42 + input_regs(dev, regs); 43 + 44 + /* calculate X and Y */ 45 + if ((packet[0] & 0x08) == 0x00) { 46 + input_report_abs(dev, ABS_X, 47 + (packet[1] | ((packet[0] & 0x30) << 4))); 48 + input_report_abs(dev, ABS_Y, 49 + 1024 - (packet[2] | ((packet[0] & 0xC0) << 2))); 50 + } else { 51 + input_report_rel(dev, REL_X, 52 + ((packet[0] & 0x10) ? packet[1] - 256 : packet[1])); 53 + input_report_rel(dev, REL_Y, 54 + -(int)((packet[0] & 0x20) ? packet[2] - 256 : packet[2])); 55 + } 56 + 57 + input_report_key(dev, BTN_LEFT, packet[0] & 0x01); 58 + input_report_key(dev, BTN_RIGHT, packet[0] & 0x02); 59 + input_report_key(dev, BTN_TOUCH, packet[0] & 0x04); 60 + 61 + input_sync(dev); 62 + 63 + return PSMOUSE_FULL_PACKET; 64 + } 65 + 66 + static int lifebook_absolute_mode(struct psmouse *psmouse) 67 + { 68 + struct ps2dev *ps2dev = &psmouse->ps2dev; 69 + unsigned char param; 70 + 71 + if (psmouse_reset(psmouse)) 72 + return -1; 73 + 74 + /* 75 + Enable absolute output -- ps2_command fails always but if 76 + you leave this call out the touchsreen will never send 77 + absolute coordinates 78 + */ 79 + param = 0x07; 80 + ps2_command(ps2dev, &param, PSMOUSE_CMD_SETRES); 81 + 82 + return 0; 83 + } 84 + 85 + static void lifebook_set_resolution(struct psmouse *psmouse, unsigned int resolution) 86 + { 87 + unsigned char params[] = { 0, 1, 2, 2, 3 }; 88 + 89 + if (resolution == 0 || resolution > 400) 90 + resolution = 400; 91 + 92 + ps2_command(&psmouse->ps2dev, &params[resolution / 100], PSMOUSE_CMD_SETRES); 93 + psmouse->resolution = 50 << params[resolution / 100]; 94 + } 95 + 96 + static void lifebook_disconnect(struct psmouse *psmouse) 97 + { 98 + psmouse_reset(psmouse); 99 + } 100 + 101 + int lifebook_detect(struct psmouse *psmouse, int set_properties) 102 + { 103 + if (!dmi_check_system(lifebook_dmi_table)) 104 + return -1; 105 + 106 + if (set_properties) { 107 + psmouse->vendor = "Fujitsu"; 108 + psmouse->name = "Lifebook TouchScreen"; 109 + } 110 + 111 + return 0; 112 + } 113 + 114 + int lifebook_init(struct psmouse *psmouse) 115 + { 116 + if (lifebook_absolute_mode(psmouse)) 117 + return -1; 118 + 119 + psmouse->dev.evbit[0] = BIT(EV_ABS) | BIT(EV_KEY) | BIT(EV_REL); 120 + psmouse->dev.keybit[LONG(BTN_LEFT)] = BIT(BTN_LEFT) | BIT(BTN_MIDDLE) | BIT(BTN_RIGHT); 121 + psmouse->dev.keybit[LONG(BTN_TOUCH)] = BIT(BTN_TOUCH); 122 + psmouse->dev.relbit[0] = BIT(REL_X) | BIT(REL_Y); 123 + input_set_abs_params(&psmouse->dev, ABS_X, 0, 1024, 0, 0); 124 + input_set_abs_params(&psmouse->dev, ABS_Y, 0, 1024, 0, 0); 125 + 126 + psmouse->protocol_handler = lifebook_process_byte; 127 + psmouse->set_resolution = lifebook_set_resolution; 128 + psmouse->disconnect = lifebook_disconnect; 129 + psmouse->reconnect = lifebook_absolute_mode; 130 + psmouse->pktsize = 3; 131 + 132 + return 0; 133 + } 134 +
+17
drivers/input/mouse/lifebook.h
··· 1 + /* 2 + * Fujitsu B-series Lifebook PS/2 TouchScreen driver 3 + * 4 + * Copyright (c) 2005 Vojtech Pavlik 5 + * 6 + * This program is free software; you can redistribute it and/or modify it 7 + * under the terms of the GNU General Public License version 2 as published by 8 + * the Free Software Foundation. 9 + */ 10 + 11 + #ifndef _LIFEBOOK_H 12 + #define _LIFEBOOK_H 13 + 14 + int lifebook_detect(struct psmouse *psmouse, int set_properties); 15 + int lifebook_init(struct psmouse *psmouse); 16 + 17 + #endif
+5 -12
drivers/input/mouse/logibm.c
··· 18 18 /* 19 19 * This program is free software; you can redistribute it and/or modify 20 20 * it under the terms of the GNU General Public License as published by 21 - * the Free Software Foundation; either version 2 of the License, or 21 + * the Free Software Foundation; either version 2 of the License, or 22 22 * (at your option) any later version. 23 - * 23 + * 24 24 * This program is distributed in the hope that it will be useful, 25 25 * but WITHOUT ANY WARRANTY; without even the implied warranty of 26 26 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 27 27 * GNU General Public License for more details. 28 - * 28 + * 29 29 * You should have received a copy of the GNU General Public License 30 30 * along with this program; if not, write to the Free Software 31 31 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 32 - * 32 + * 33 33 * Should you need to contact me, the author, you can do so either by 34 34 * e-mail - mail your message to <vojtech@ucw.cz>, or by paper mail: 35 35 * Vojtech Pavlik, Simunkova 1594, Prague 8, 182 00 Czech Republic ··· 77 77 78 78 __obsolete_setup("logibm_irq="); 79 79 80 - static int logibm_used = 0; 81 - 82 80 static irqreturn_t logibm_interrupt(int irq, void *dev_id, struct pt_regs *regs); 83 81 84 82 static int logibm_open(struct input_dev *dev) 85 83 { 86 - if (logibm_used++) 87 - return 0; 88 84 if (request_irq(logibm_irq, logibm_interrupt, 0, "logibm", NULL)) { 89 - logibm_used--; 90 85 printk(KERN_ERR "logibm.c: Can't allocate irq %d\n", logibm_irq); 91 86 return -EBUSY; 92 87 } ··· 91 96 92 97 static void logibm_close(struct input_dev *dev) 93 98 { 94 - if (--logibm_used) 95 - return; 96 99 outb(LOGIBM_DISABLE_IRQ, LOGIBM_CONTROL_PORT); 97 100 free_irq(logibm_irq, NULL); 98 101 } ··· 160 167 outb(LOGIBM_DISABLE_IRQ, LOGIBM_CONTROL_PORT); 161 168 162 169 input_register_device(&logibm_dev); 163 - 170 + 164 171 printk(KERN_INFO "input: Logitech bus mouse at %#x irq %d\n", LOGIBM_BASE, logibm_irq); 165 172 166 173 return 0;
+23 -52
drivers/input/mouse/maplemouse.c
··· 1 1 /* 2 2 * $Id: maplemouse.c,v 1.2 2004/03/22 01:18:15 lethal Exp $ 3 - * SEGA Dreamcast mouse driver 3 + * SEGA Dreamcast mouse driver 4 4 * Based on drivers/usb/usbmouse.c 5 5 */ 6 6 ··· 15 15 MODULE_AUTHOR("YAEGASHI Takeshi <t@keshi.org>"); 16 16 MODULE_DESCRIPTION("SEGA Dreamcast mouse driver"); 17 17 18 - struct dc_mouse { 19 - struct input_dev dev; 20 - int open; 21 - }; 22 - 23 - 24 18 static void dc_mouse_callback(struct mapleq *mq) 25 19 { 26 20 int buttons, relx, rely, relz; 27 21 struct maple_device *mapledev = mq->dev; 28 - struct dc_mouse *mouse = mapledev->private_data; 29 - struct input_dev *dev = &mouse->dev; 22 + struct input_dev *dev = mapledev->private_data; 30 23 unsigned char *res = mq->recvbuf; 31 24 32 25 buttons = ~res[8]; 33 - relx=*(unsigned short *)(res+12)-512; 34 - rely=*(unsigned short *)(res+14)-512; 35 - relz=*(unsigned short *)(res+16)-512; 26 + relx = *(unsigned short *)(res + 12) - 512; 27 + rely = *(unsigned short *)(res + 14) - 512; 28 + relz = *(unsigned short *)(res + 16) - 512; 36 29 37 - input_report_key(dev, BTN_LEFT, buttons&4); 38 - input_report_key(dev, BTN_MIDDLE, buttons&9); 39 - input_report_key(dev, BTN_RIGHT, buttons&2); 30 + input_report_key(dev, BTN_LEFT, buttons & 4); 31 + input_report_key(dev, BTN_MIDDLE, buttons & 9); 32 + input_report_key(dev, BTN_RIGHT, buttons & 2); 40 33 input_report_rel(dev, REL_X, relx); 41 34 input_report_rel(dev, REL_Y, rely); 42 35 input_report_rel(dev, REL_WHEEL, relz); 43 36 input_sync(dev); 44 37 } 45 38 46 - 47 - static int dc_mouse_open(struct input_dev *dev) 48 - { 49 - struct dc_mouse *mouse = dev->private; 50 - mouse->open++; 51 - return 0; 52 - } 53 - 54 - 55 - static void dc_mouse_close(struct input_dev *dev) 56 - { 57 - struct dc_mouse *mouse = dev->private; 58 - mouse->open--; 59 - } 60 - 61 - 62 39 static int dc_mouse_connect(struct maple_device *dev) 63 40 { 64 41 unsigned long data = be32_to_cpu(dev->devinfo.function_data[0]); 65 - struct dc_mouse *mouse; 42 + struct input_dev *input_dev; 66 43 67 - if (!(mouse = kmalloc(sizeof(struct dc_mouse), GFP_KERNEL))) 44 + if (!(input_dev = kmalloc(sizeof(struct input_dev), GFP_KERNEL))) 68 45 return -1; 69 - memset(mouse, 0, sizeof(struct dc_mouse)); 70 46 71 - dev->private_data = mouse; 47 + dev->private_data = input_dev; 72 48 73 - mouse->dev.evbit[0] = BIT(EV_KEY) | BIT(EV_REL); 74 - mouse->dev.keybit[LONG(BTN_MOUSE)] = BIT(BTN_LEFT) | BIT(BTN_RIGHT) | BIT(BTN_MIDDLE); 75 - mouse->dev.relbit[0] = BIT(REL_X) | BIT(REL_Y) | BIT(REL_WHEEL); 49 + memset(input_dev, 0, sizeof(struct dc_mouse)); 50 + init_input_dev(input_dev); 51 + input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_REL); 52 + input_dev->keybit[LONG(BTN_MOUSE)] = BIT(BTN_LEFT) | BIT(BTN_RIGHT) | BIT(BTN_MIDDLE); 53 + input_dev->relbit[0] = BIT(REL_X) | BIT(REL_Y) | BIT(REL_WHEEL); 76 54 77 - init_input_dev(&mouse->dev); 55 + input_dev->name = dev->product_name; 56 + input_dev->id.bustype = BUS_MAPLE; 78 57 79 - mouse->dev.private = mouse; 80 - mouse->dev.open = dc_mouse_open; 81 - mouse->dev.close = dc_mouse_close; 82 - mouse->dev.event = NULL; 83 - 84 - mouse->dev.name = dev->product_name; 85 - mouse->dev.id.bustype = BUS_MAPLE; 86 - 87 - input_register_device(&mouse->dev); 58 + input_register_device(input_dev); 88 59 89 60 maple_getcond_callback(dev, dc_mouse_callback, 1, MAPLE_FUNC_MOUSE); 90 61 91 - printk(KERN_INFO "input: mouse(0x%lx): %s\n", data, mouse->dev.name); 62 + printk(KERN_INFO "input: mouse(0x%lx): %s\n", data, input_dev->name); 92 63 93 64 return 0; 94 65 } ··· 67 96 68 97 static void dc_mouse_disconnect(struct maple_device *dev) 69 98 { 70 - struct dc_mouse *mouse = dev->private_data; 99 + struct input_dev *input_dev = dev->private_data; 71 100 72 - input_unregister_device(&mouse->dev); 73 - kfree(mouse); 101 + input_unregister_device(input_dev); 102 + kfree(input_dev); 74 103 } 75 104 76 105
+8 -13
drivers/input/mouse/pc110pad.c
··· 4 4 * Copyright (c) 2000-2001 Vojtech Pavlik 5 5 * 6 6 * Based on the work of: 7 - * Alan Cox Robin O'Leary 7 + * Alan Cox Robin O'Leary 8 8 */ 9 9 10 10 /* ··· 56 56 static struct input_dev pc110pad_dev; 57 57 static int pc110pad_data[3]; 58 58 static int pc110pad_count; 59 - static int pc110pad_used; 60 59 61 60 static char *pc110pad_name = "IBM PC110 TouchPad"; 62 61 static char *pc110pad_phys = "isa15e0/input0"; ··· 73 74 74 75 if (pc110pad_count < 3) 75 76 return IRQ_HANDLED; 76 - 77 + 77 78 input_regs(&pc110pad_dev, regs); 78 79 input_report_key(&pc110pad_dev, BTN_TOUCH, 79 80 pc110pad_data[0] & 0x01); ··· 89 90 90 91 static void pc110pad_close(struct input_dev *dev) 91 92 { 92 - if (!--pc110pad_used) 93 - outb(PC110PAD_OFF, pc110pad_io + 2); 93 + outb(PC110PAD_OFF, pc110pad_io + 2); 94 94 } 95 95 96 96 static int pc110pad_open(struct input_dev *dev) 97 97 { 98 - if (pc110pad_used++) 99 - return 0; 100 - 101 98 pc110pad_interrupt(0,NULL,NULL); 102 99 pc110pad_interrupt(0,NULL,NULL); 103 100 pc110pad_interrupt(0,NULL,NULL); ··· 140 145 141 146 pc110pad_dev.absmax[ABS_X] = 0x1ff; 142 147 pc110pad_dev.absmax[ABS_Y] = 0x0ff; 143 - 148 + 144 149 pc110pad_dev.open = pc110pad_open; 145 150 pc110pad_dev.close = pc110pad_close; 146 151 ··· 151 156 pc110pad_dev.id.product = 0x0001; 152 157 pc110pad_dev.id.version = 0x0100; 153 158 154 - input_register_device(&pc110pad_dev); 159 + input_register_device(&pc110pad_dev); 155 160 156 161 printk(KERN_INFO "input: %s at %#x irq %d\n", 157 162 pc110pad_name, pc110pad_io, pc110pad_irq); 158 - 163 + 159 164 return 0; 160 165 } 161 - 166 + 162 167 static void __exit pc110pad_exit(void) 163 168 { 164 - input_unregister_device(&pc110pad_dev); 169 + input_unregister_device(&pc110pad_dev); 165 170 166 171 outb(PC110PAD_OFF, pc110pad_io + 2); 167 172
+297 -54
drivers/input/mouse/psmouse-base.c
··· 24 24 #include "synaptics.h" 25 25 #include "logips2pp.h" 26 26 #include "alps.h" 27 + #include "lifebook.h" 27 28 28 29 #define DRIVER_DESC "PS/2 mouse driver" 29 30 ··· 32 31 MODULE_DESCRIPTION(DRIVER_DESC); 33 32 MODULE_LICENSE("GPL"); 34 33 35 - static unsigned int psmouse_max_proto = -1U; 34 + static unsigned int psmouse_max_proto = PSMOUSE_AUTO; 36 35 static int psmouse_set_maxproto(const char *val, struct kernel_param *kp); 37 36 static int psmouse_get_maxproto(char *buffer, struct kernel_param *kp); 38 - static char *psmouse_proto_abbrev[] = { NULL, "bare", NULL, NULL, NULL, "imps", "exps", NULL, NULL, NULL }; 39 37 #define param_check_proto_abbrev(name, p) __param_check(name, p, unsigned int) 40 38 #define param_set_proto_abbrev psmouse_set_maxproto 41 39 #define param_get_proto_abbrev psmouse_get_maxproto ··· 57 57 module_param_named(resetafter, psmouse_resetafter, uint, 0644); 58 58 MODULE_PARM_DESC(resetafter, "Reset device after so many bad packets (0 = never)."); 59 59 60 + PSMOUSE_DEFINE_ATTR(protocol); 60 61 PSMOUSE_DEFINE_ATTR(rate); 61 62 PSMOUSE_DEFINE_ATTR(resolution); 62 63 PSMOUSE_DEFINE_ATTR(resetafter); ··· 68 67 __obsolete_setup("psmouse_resetafter="); 69 68 __obsolete_setup("psmouse_rate="); 70 69 71 - static char *psmouse_protocols[] = { "None", "PS/2", "PS2++", "ThinkPS/2", "GenPS/2", "ImPS/2", "ImExPS/2", "SynPS/2", "AlpsPS/2" }; 70 + /* 71 + * psmouse_sem protects all operations changing state of mouse 72 + * (connecting, disconnecting, changing rate or resolution via 73 + * sysfs). We could use a per-device semaphore but since there 74 + * rarely more than one PS/2 mouse connected and since semaphore 75 + * is taken in "slow" paths it is not worth it. 76 + */ 77 + static DECLARE_MUTEX(psmouse_sem); 78 + 79 + struct psmouse_protocol { 80 + enum psmouse_type type; 81 + char *name; 82 + char *alias; 83 + int maxproto; 84 + int (*detect)(struct psmouse *, int); 85 + int (*init)(struct psmouse *); 86 + }; 72 87 73 88 /* 74 89 * psmouse_process_byte() analyzes the PS/2 data stream and reports ··· 424 407 */ 425 408 static int ps2bare_detect(struct psmouse *psmouse, int set_properties) 426 409 { 427 - if (!psmouse->vendor) psmouse->vendor = "Generic"; 428 - if (!psmouse->name) psmouse->name = "Mouse"; 410 + if (set_properties) { 411 + if (!psmouse->vendor) psmouse->vendor = "Generic"; 412 + if (!psmouse->name) psmouse->name = "Mouse"; 413 + } 429 414 430 415 return 0; 431 416 } 417 + 432 418 433 419 /* 434 420 * psmouse_extensions() probes for any extensions to the basic PS/2 protocol ··· 442 422 unsigned int max_proto, int set_properties) 443 423 { 444 424 int synaptics_hardware = 0; 425 + 426 + /* 427 + * We always check for lifebook because it does not disturb mouse 428 + * (it only checks DMI information). 429 + */ 430 + if (lifebook_detect(psmouse, set_properties) == 0) { 431 + if (max_proto > PSMOUSE_IMEX) { 432 + if (!set_properties || lifebook_init(psmouse) == 0) 433 + return PSMOUSE_LIFEBOOK; 434 + } 435 + } 445 436 446 437 /* 447 438 * Try Kensington ThinkingMouse (we try first, because synaptics probe ··· 536 505 537 506 return PSMOUSE_PS2; 538 507 } 508 + 509 + static struct psmouse_protocol psmouse_protocols[] = { 510 + { 511 + .type = PSMOUSE_PS2, 512 + .name = "PS/2", 513 + .alias = "bare", 514 + .maxproto = 1, 515 + .detect = ps2bare_detect, 516 + }, 517 + { 518 + .type = PSMOUSE_PS2PP, 519 + .name = "PS2++", 520 + .alias = "logitech", 521 + .detect = ps2pp_init, 522 + }, 523 + { 524 + .type = PSMOUSE_THINKPS, 525 + .name = "ThinkPS/2", 526 + .alias = "thinkps", 527 + .detect = thinking_detect, 528 + }, 529 + { 530 + .type = PSMOUSE_GENPS, 531 + .name = "GenPS/2", 532 + .alias = "genius", 533 + .detect = genius_detect, 534 + }, 535 + { 536 + .type = PSMOUSE_IMPS, 537 + .name = "ImPS/2", 538 + .alias = "imps", 539 + .maxproto = 1, 540 + .detect = intellimouse_detect, 541 + }, 542 + { 543 + .type = PSMOUSE_IMEX, 544 + .name = "ImExPS/2", 545 + .alias = "exps", 546 + .maxproto = 1, 547 + .detect = im_explorer_detect, 548 + }, 549 + { 550 + .type = PSMOUSE_SYNAPTICS, 551 + .name = "SynPS/2", 552 + .alias = "synaptics", 553 + .detect = synaptics_detect, 554 + .init = synaptics_init, 555 + }, 556 + { 557 + .type = PSMOUSE_ALPS, 558 + .name = "AlpsPS/2", 559 + .alias = "alps", 560 + .detect = alps_detect, 561 + .init = alps_init, 562 + }, 563 + { 564 + .type = PSMOUSE_LIFEBOOK, 565 + .name = "LBPS/2", 566 + .alias = "lifebook", 567 + .init = lifebook_init, 568 + }, 569 + { 570 + .type = PSMOUSE_AUTO, 571 + .name = "auto", 572 + .alias = "any", 573 + .maxproto = 1, 574 + }, 575 + }; 576 + 577 + static struct psmouse_protocol *psmouse_protocol_by_type(enum psmouse_type type) 578 + { 579 + int i; 580 + 581 + for (i = 0; i < ARRAY_SIZE(psmouse_protocols); i++) 582 + if (psmouse_protocols[i].type == type) 583 + return &psmouse_protocols[i]; 584 + 585 + WARN_ON(1); 586 + return &psmouse_protocols[0]; 587 + } 588 + 589 + static struct psmouse_protocol *psmouse_protocol_by_name(const char *name, size_t len) 590 + { 591 + struct psmouse_protocol *p; 592 + int i; 593 + 594 + for (i = 0; i < ARRAY_SIZE(psmouse_protocols); i++) { 595 + p = &psmouse_protocols[i]; 596 + 597 + if ((strlen(p->name) == len && !strncmp(p->name, name, len)) || 598 + (strlen(p->alias) == len && !strncmp(p->alias, name, len))) 599 + return &psmouse_protocols[i]; 600 + } 601 + 602 + return NULL; 603 + } 604 + 539 605 540 606 /* 541 607 * psmouse_probe() probes for a PS/2 mouse. ··· 781 653 782 654 static void psmouse_disconnect(struct serio *serio) 783 655 { 784 - struct psmouse *psmouse, *parent; 656 + struct psmouse *psmouse, *parent = NULL; 785 657 658 + psmouse = serio_get_drvdata(serio); 659 + 660 + device_remove_file(&serio->dev, &psmouse_attr_protocol); 786 661 device_remove_file(&serio->dev, &psmouse_attr_rate); 787 662 device_remove_file(&serio->dev, &psmouse_attr_resolution); 788 663 device_remove_file(&serio->dev, &psmouse_attr_resetafter); 789 664 790 - psmouse = serio_get_drvdata(serio); 665 + down(&psmouse_sem); 666 + 791 667 psmouse_set_state(psmouse, PSMOUSE_CMD_MODE); 792 668 793 669 if (serio->parent && serio->id.type == SERIO_PS_PSTHRU) { 794 670 parent = serio_get_drvdata(serio->parent); 795 - if (parent->pt_deactivate) 796 - parent->pt_deactivate(parent); 671 + psmouse_deactivate(parent); 797 672 } 798 673 799 674 if (psmouse->disconnect) 800 675 psmouse->disconnect(psmouse); 676 + 677 + if (parent && parent->pt_deactivate) 678 + parent->pt_deactivate(parent); 801 679 802 680 psmouse_set_state(psmouse, PSMOUSE_IGNORE); 803 681 ··· 811 677 serio_close(serio); 812 678 serio_set_drvdata(serio, NULL); 813 679 kfree(psmouse); 680 + 681 + if (parent) 682 + psmouse_activate(parent); 683 + 684 + up(&psmouse_sem); 685 + } 686 + 687 + static int psmouse_switch_protocol(struct psmouse *psmouse, struct psmouse_protocol *proto) 688 + { 689 + memset(&psmouse->dev, 0, sizeof(struct input_dev)); 690 + 691 + init_input_dev(&psmouse->dev); 692 + 693 + psmouse->dev.private = psmouse; 694 + psmouse->dev.dev = &psmouse->ps2dev.serio->dev; 695 + 696 + psmouse->dev.evbit[0] = BIT(EV_KEY) | BIT(EV_REL); 697 + psmouse->dev.keybit[LONG(BTN_MOUSE)] = BIT(BTN_LEFT) | BIT(BTN_MIDDLE) | BIT(BTN_RIGHT); 698 + psmouse->dev.relbit[0] = BIT(REL_X) | BIT(REL_Y); 699 + 700 + psmouse->set_rate = psmouse_set_rate; 701 + psmouse->set_resolution = psmouse_set_resolution; 702 + psmouse->protocol_handler = psmouse_process_byte; 703 + psmouse->pktsize = 3; 704 + 705 + if (proto && (proto->detect || proto->init)) { 706 + if (proto->detect && proto->detect(psmouse, 1) < 0) 707 + return -1; 708 + 709 + if (proto->init && proto->init(psmouse) < 0) 710 + return -1; 711 + 712 + psmouse->type = proto->type; 713 + } 714 + else 715 + psmouse->type = psmouse_extensions(psmouse, psmouse_max_proto, 1); 716 + 717 + sprintf(psmouse->devname, "%s %s %s", 718 + psmouse_protocol_by_type(psmouse->type)->name, psmouse->vendor, psmouse->name); 719 + 720 + psmouse->dev.name = psmouse->devname; 721 + psmouse->dev.phys = psmouse->phys; 722 + psmouse->dev.id.bustype = BUS_I8042; 723 + psmouse->dev.id.vendor = 0x0002; 724 + psmouse->dev.id.product = psmouse->type; 725 + psmouse->dev.id.version = psmouse->model; 726 + 727 + return 0; 814 728 } 815 729 816 730 /* ··· 870 688 struct psmouse *psmouse, *parent = NULL; 871 689 int retval; 872 690 691 + down(&psmouse_sem); 692 + 873 693 /* 874 694 * If this is a pass-through port deactivate parent so the device 875 695 * connected to this port can be successfully identified ··· 881 697 psmouse_deactivate(parent); 882 698 } 883 699 884 - if (!(psmouse = kmalloc(sizeof(struct psmouse), GFP_KERNEL))) { 700 + if (!(psmouse = kcalloc(1, sizeof(struct psmouse), GFP_KERNEL))) { 885 701 retval = -ENOMEM; 886 702 goto out; 887 703 } 888 704 889 - memset(psmouse, 0, sizeof(struct psmouse)); 890 - 891 705 ps2_init(&psmouse->ps2dev, serio); 892 706 sprintf(psmouse->phys, "%s/input0", serio->phys); 893 - psmouse->dev.evbit[0] = BIT(EV_KEY) | BIT(EV_REL); 894 - psmouse->dev.keybit[LONG(BTN_MOUSE)] = BIT(BTN_LEFT) | BIT(BTN_MIDDLE) | BIT(BTN_RIGHT); 895 - psmouse->dev.relbit[0] = BIT(REL_X) | BIT(REL_Y); 896 - psmouse->dev.private = psmouse; 897 - psmouse->dev.dev = &serio->dev; 707 + 898 708 psmouse_set_state(psmouse, PSMOUSE_INITIALIZING); 899 709 900 710 serio_set_drvdata(serio, psmouse); ··· 912 734 psmouse->resolution = psmouse_resolution; 913 735 psmouse->resetafter = psmouse_resetafter; 914 736 psmouse->smartscroll = psmouse_smartscroll; 915 - psmouse->set_rate = psmouse_set_rate; 916 - psmouse->set_resolution = psmouse_set_resolution; 917 - psmouse->protocol_handler = psmouse_process_byte; 918 - psmouse->pktsize = 3; 919 737 920 - psmouse->type = psmouse_extensions(psmouse, psmouse_max_proto, 1); 921 - 922 - sprintf(psmouse->devname, "%s %s %s", 923 - psmouse_protocols[psmouse->type], psmouse->vendor, psmouse->name); 924 - 925 - psmouse->dev.name = psmouse->devname; 926 - psmouse->dev.phys = psmouse->phys; 927 - psmouse->dev.id.bustype = BUS_I8042; 928 - psmouse->dev.id.vendor = 0x0002; 929 - psmouse->dev.id.product = psmouse->type; 930 - psmouse->dev.id.version = psmouse->model; 738 + psmouse_switch_protocol(psmouse, NULL); 931 739 932 740 input_register_device(&psmouse->dev); 933 - 934 741 printk(KERN_INFO "input: %s on %s\n", psmouse->devname, serio->phys); 935 742 936 743 psmouse_set_state(psmouse, PSMOUSE_CMD_MODE); ··· 925 762 if (parent && parent->pt_activate) 926 763 parent->pt_activate(parent); 927 764 765 + device_create_file(&serio->dev, &psmouse_attr_protocol); 928 766 device_create_file(&serio->dev, &psmouse_attr_rate); 929 767 device_create_file(&serio->dev, &psmouse_attr_resolution); 930 768 device_create_file(&serio->dev, &psmouse_attr_resetafter); ··· 935 771 retval = 0; 936 772 937 773 out: 938 - /* If this is a pass-through port the parent awaits to be activated */ 774 + /* If this is a pass-through port the parent needs to be re-activated */ 939 775 if (parent) 940 776 psmouse_activate(parent); 941 777 778 + up(&psmouse_sem); 942 779 return retval; 943 780 } 944 781 ··· 955 790 printk(KERN_DEBUG "psmouse: reconnect request, but serio is disconnected, ignoring...\n"); 956 791 return -1; 957 792 } 793 + 794 + down(&psmouse_sem); 958 795 959 796 if (serio->parent && serio->id.type == SERIO_PS_PSTHRU) { 960 797 parent = serio_get_drvdata(serio->parent); ··· 990 823 if (parent) 991 824 psmouse_activate(parent); 992 825 826 + up(&psmouse_sem); 993 827 return rc; 994 828 } 995 829 ··· 1061 893 1062 894 if (serio->drv != &psmouse_drv) { 1063 895 retval = -ENODEV; 1064 - goto out; 896 + goto out_unpin; 897 + } 898 + 899 + retval = down_interruptible(&psmouse_sem); 900 + if (retval) 901 + goto out_unpin; 902 + 903 + if (psmouse->state == PSMOUSE_IGNORE) { 904 + retval = -ENODEV; 905 + goto out_up; 1065 906 } 1066 907 1067 908 if (serio->parent && serio->id.type == SERIO_PS_PSTHRU) { 1068 909 parent = serio_get_drvdata(serio->parent); 1069 910 psmouse_deactivate(parent); 1070 911 } 912 + 1071 913 psmouse_deactivate(psmouse); 1072 914 1073 915 retval = handler(psmouse, buf, count); 1074 916 1075 - psmouse_activate(psmouse); 917 + if (retval != -ENODEV) 918 + psmouse_activate(psmouse); 919 + 1076 920 if (parent) 1077 921 psmouse_activate(parent); 1078 922 1079 - out: 923 + out_up: 924 + up(&psmouse_sem); 925 + out_unpin: 1080 926 serio_unpin_driver(serio); 1081 927 return retval; 928 + } 929 + 930 + static ssize_t psmouse_attr_show_protocol(struct psmouse *psmouse, char *buf) 931 + { 932 + return sprintf(buf, "%s\n", psmouse_protocol_by_type(psmouse->type)->name); 933 + } 934 + 935 + static ssize_t psmouse_attr_set_protocol(struct psmouse *psmouse, const char *buf, size_t count) 936 + { 937 + struct serio *serio = psmouse->ps2dev.serio; 938 + struct psmouse *parent = NULL; 939 + struct psmouse_protocol *proto; 940 + int retry = 0; 941 + 942 + if (!(proto = psmouse_protocol_by_name(buf, count))) 943 + return -EINVAL; 944 + 945 + if (psmouse->type == proto->type) 946 + return count; 947 + 948 + while (serio->child) { 949 + if (++retry > 3) { 950 + printk(KERN_WARNING "psmouse: failed to destroy child port, protocol change aborted.\n"); 951 + return -EIO; 952 + } 953 + 954 + up(&psmouse_sem); 955 + serio_unpin_driver(serio); 956 + serio_unregister_child_port(serio); 957 + serio_pin_driver_uninterruptible(serio); 958 + down(&psmouse_sem); 959 + 960 + if (serio->drv != &psmouse_drv) 961 + return -ENODEV; 962 + 963 + if (psmouse->type == proto->type) 964 + return count; /* switched by other thread */ 965 + } 966 + 967 + if (serio->parent && serio->id.type == SERIO_PS_PSTHRU) { 968 + parent = serio_get_drvdata(serio->parent); 969 + if (parent->pt_deactivate) 970 + parent->pt_deactivate(parent); 971 + } 972 + 973 + if (psmouse->disconnect) 974 + psmouse->disconnect(psmouse); 975 + 976 + psmouse_set_state(psmouse, PSMOUSE_IGNORE); 977 + input_unregister_device(&psmouse->dev); 978 + 979 + psmouse_set_state(psmouse, PSMOUSE_INITIALIZING); 980 + 981 + if (psmouse_switch_protocol(psmouse, proto) < 0) { 982 + psmouse_reset(psmouse); 983 + /* default to PSMOUSE_PS2 */ 984 + psmouse_switch_protocol(psmouse, &psmouse_protocols[0]); 985 + } 986 + 987 + psmouse_initialize(psmouse); 988 + psmouse_set_state(psmouse, PSMOUSE_CMD_MODE); 989 + 990 + input_register_device(&psmouse->dev); 991 + printk(KERN_INFO "input: %s on %s\n", psmouse->devname, serio->phys); 992 + 993 + if (parent && parent->pt_activate) 994 + parent->pt_activate(parent); 995 + 996 + return count; 1082 997 } 1083 998 1084 999 static ssize_t psmouse_attr_show_rate(struct psmouse *psmouse, char *buf) ··· 1220 969 1221 970 static int psmouse_set_maxproto(const char *val, struct kernel_param *kp) 1222 971 { 1223 - int i; 972 + struct psmouse_protocol *proto; 1224 973 1225 974 if (!val) 1226 975 return -EINVAL; 1227 976 1228 - if (!strncmp(val, "any", 3)) { 1229 - *((unsigned int *)kp->arg) = -1U; 1230 - return 0; 1231 - } 977 + proto = psmouse_protocol_by_name(val, strlen(val)); 1232 978 1233 - for (i = 0; i < ARRAY_SIZE(psmouse_proto_abbrev); i++) { 1234 - if (!psmouse_proto_abbrev[i]) 1235 - continue; 979 + if (!proto || !proto->maxproto) 980 + return -EINVAL; 1236 981 1237 - if (!strncmp(val, psmouse_proto_abbrev[i], strlen(psmouse_proto_abbrev[i]))) { 1238 - *((unsigned int *)kp->arg) = i; 1239 - return 0; 1240 - } 1241 - } 982 + *((unsigned int *)kp->arg) = proto->type; 1242 983 1243 - return -EINVAL; \ 984 + return 0; \ 1244 985 } 1245 986 1246 987 static int psmouse_get_maxproto(char *buffer, struct kernel_param *kp) 1247 988 { 1248 - return sprintf(buffer, "%s\n", 1249 - psmouse_max_proto < ARRAY_SIZE(psmouse_proto_abbrev) ? 1250 - psmouse_proto_abbrev[psmouse_max_proto] : "any"); 989 + int type = *((unsigned int *)kp->arg); 990 + 991 + return sprintf(buffer, "%s\n", psmouse_protocol_by_type(type)->name); 1251 992 } 1252 993 1253 994 static int __init psmouse_init(void)
+3 -1
drivers/input/mouse/psmouse.h
··· 77 77 PSMOUSE_IMEX, 78 78 PSMOUSE_SYNAPTICS, 79 79 PSMOUSE_ALPS, 80 + PSMOUSE_LIFEBOOK, 81 + PSMOUSE_AUTO /* This one should always be last */ 80 82 }; 81 83 82 84 int psmouse_sliced_command(struct psmouse *psmouse, unsigned char command); ··· 101 99 { \ 102 100 return psmouse_attr_set_helper(d, b, s, psmouse_attr_set_##_name); \ 103 101 } \ 104 - static struct device_attribute psmouse_attr_##_name = \ 102 + static struct device_attribute psmouse_attr_##_name = \ 105 103 __ATTR(_name, S_IWUSR | S_IRUGO, \ 106 104 psmouse_do_show_##_name, psmouse_do_set_##_name); 107 105
+1 -1
drivers/input/mouse/rpcmouse.c
··· 59 59 b = (short) (__raw_readl(0xe0310000) ^ 0x70); 60 60 61 61 dx = x - rpcmouse_lastx; 62 - dy = y - rpcmouse_lasty; 62 + dy = y - rpcmouse_lasty; 63 63 64 64 rpcmouse_lastx = x; 65 65 rpcmouse_lasty = y;
+2 -2
drivers/input/mouse/vsxxxaa.c
··· 1 1 /* 2 2 * Driver for DEC VSXXX-AA mouse (hockey-puck mouse, ball or two rollers) 3 - * DEC VSXXX-GA mouse (rectangular mouse, with ball) 4 - * DEC VSXXX-AB tablet (digitizer with hair cross or stylus) 3 + * DEC VSXXX-GA mouse (rectangular mouse, with ball) 4 + * DEC VSXXX-AB tablet (digitizer with hair cross or stylus) 5 5 * 6 6 * Copyright (C) 2003-2004 by Jan-Benedict Glaw <jbglaw@lug-owl.de> 7 7 *
+6 -2
drivers/input/mousedev.c
··· 220 220 struct mousedev_list *list; 221 221 struct mousedev_motion *p; 222 222 unsigned long flags; 223 + int wake_readers = 0; 223 224 224 225 list_for_each_entry(list, &mousedev->list, node) { 225 226 spin_lock_irqsave(&list->packet_lock, flags); ··· 256 255 257 256 spin_unlock_irqrestore(&list->packet_lock, flags); 258 257 259 - if (list->ready) 258 + if (list->ready) { 260 259 kill_fasync(&list->fasync, SIGIO, POLL_IN); 260 + wake_readers = 1; 261 + } 261 262 } 262 263 263 - wake_up_interruptible(&mousedev->wait); 264 + if (wake_readers) 265 + wake_up_interruptible(&mousedev->wait); 264 266 } 265 267 266 268 static void mousedev_touchpad_touch(struct mousedev *mousedev, int value)
+100 -36
drivers/input/serio/libps2.c
··· 29 29 30 30 EXPORT_SYMBOL(ps2_init); 31 31 EXPORT_SYMBOL(ps2_sendbyte); 32 + EXPORT_SYMBOL(ps2_drain); 32 33 EXPORT_SYMBOL(ps2_command); 33 34 EXPORT_SYMBOL(ps2_schedule_command); 34 35 EXPORT_SYMBOL(ps2_handle_ack); ··· 46 45 47 46 48 47 /* 49 - * ps2_sendbyte() sends a byte to the mouse, and waits for acknowledge. 50 - * It doesn't handle retransmission, though it could - because when there would 51 - * be need for retransmissions, the mouse has to be replaced anyway. 48 + * ps2_sendbyte() sends a byte to the device and waits for acknowledge. 49 + * It doesn't handle retransmission, though it could - because if there 50 + * is a need for retransmissions device has to be replaced anyway. 52 51 * 53 - * ps2_sendbyte() can only be called from a process context 52 + * ps2_sendbyte() can only be called from a process context. 54 53 */ 55 54 56 55 int ps2_sendbyte(struct ps2dev *ps2dev, unsigned char byte, int timeout) ··· 73 72 } 74 73 75 74 /* 75 + * ps2_drain() waits for device to transmit requested number of bytes 76 + * and discards them. 77 + */ 78 + 79 + void ps2_drain(struct ps2dev *ps2dev, int maxbytes, int timeout) 80 + { 81 + if (maxbytes > sizeof(ps2dev->cmdbuf)) { 82 + WARN_ON(1); 83 + maxbytes = sizeof(ps2dev->cmdbuf); 84 + } 85 + 86 + down(&ps2dev->cmd_sem); 87 + 88 + serio_pause_rx(ps2dev->serio); 89 + ps2dev->flags = PS2_FLAG_CMD; 90 + ps2dev->cmdcnt = maxbytes; 91 + serio_continue_rx(ps2dev->serio); 92 + 93 + wait_event_timeout(ps2dev->wait, 94 + !(ps2dev->flags & PS2_FLAG_CMD), 95 + msecs_to_jiffies(timeout)); 96 + up(&ps2dev->cmd_sem); 97 + } 98 + 99 + /* 100 + * ps2_is_keyboard_id() checks received ID byte against the list of 101 + * known keyboard IDs. 102 + */ 103 + 104 + static inline int ps2_is_keyboard_id(char id_byte) 105 + { 106 + static char keyboard_ids[] = { 107 + 0xab, /* Regular keyboards */ 108 + 0xac, /* NCD Sun keyboard */ 109 + 0x2b, /* Trust keyboard, translated */ 110 + 0x5d, /* Trust keyboard */ 111 + 0x60, /* NMB SGI keyboard, translated */ 112 + 0x47, /* NMB SGI keyboard */ 113 + }; 114 + 115 + return memchr(keyboard_ids, id_byte, sizeof(keyboard_ids)) != NULL; 116 + } 117 + 118 + /* 119 + * ps2_adjust_timeout() is called after receiving 1st byte of command 120 + * response and tries to reduce remaining timeout to speed up command 121 + * completion. 122 + */ 123 + 124 + static int ps2_adjust_timeout(struct ps2dev *ps2dev, int command, int timeout) 125 + { 126 + switch (command) { 127 + case PS2_CMD_RESET_BAT: 128 + /* 129 + * Device has sent the first response byte after 130 + * reset command, reset is thus done, so we can 131 + * shorten the timeout. 132 + * The next byte will come soon (keyboard) or not 133 + * at all (mouse). 134 + */ 135 + if (timeout > msecs_to_jiffies(100)) 136 + timeout = msecs_to_jiffies(100); 137 + break; 138 + 139 + case PS2_CMD_GETID: 140 + /* 141 + * If device behind the port is not a keyboard there 142 + * won't be 2nd byte of ID response. 143 + */ 144 + if (!ps2_is_keyboard_id(ps2dev->cmdbuf[1])) { 145 + serio_pause_rx(ps2dev->serio); 146 + ps2dev->flags = ps2dev->cmdcnt = 0; 147 + serio_continue_rx(ps2dev->serio); 148 + timeout = 0; 149 + } 150 + break; 151 + 152 + default: 153 + break; 154 + } 155 + 156 + return timeout; 157 + } 158 + 159 + /* 76 160 * ps2_command() sends a command and its parameters to the mouse, 77 161 * then waits for the response and puts it in the param array. 78 162 * ··· 171 85 int receive = (command >> 8) & 0xf; 172 86 int rc = -1; 173 87 int i; 88 + 89 + if (receive > sizeof(ps2dev->cmdbuf)) { 90 + WARN_ON(1); 91 + return -1; 92 + } 174 93 175 94 down(&ps2dev->cmd_sem); 176 95 ··· 192 101 * ACKing the reset command, and so it can take a long 193 102 * time before the ACK arrrives. 194 103 */ 195 - if (command & 0xff) 196 - if (ps2_sendbyte(ps2dev, command & 0xff, 197 - command == PS2_CMD_RESET_BAT ? 1000 : 200)) 198 - goto out; 104 + if (ps2_sendbyte(ps2dev, command & 0xff, 105 + command == PS2_CMD_RESET_BAT ? 1000 : 200)) 106 + goto out; 199 107 200 108 for (i = 0; i < send; i++) 201 109 if (ps2_sendbyte(ps2dev, param[i], 200)) ··· 210 120 211 121 if (ps2dev->cmdcnt && timeout > 0) { 212 122 213 - if (command == PS2_CMD_RESET_BAT && timeout > msecs_to_jiffies(100)) { 214 - /* 215 - * Device has sent the first response byte 216 - * after a reset command, reset is thus done, 217 - * shorten the timeout. The next byte will come 218 - * soon (keyboard) or not at all (mouse). 219 - */ 220 - timeout = msecs_to_jiffies(100); 221 - } 222 - 223 - if (command == PS2_CMD_GETID && 224 - ps2dev->cmdbuf[receive - 1] != 0xab && /* Regular keyboards */ 225 - ps2dev->cmdbuf[receive - 1] != 0xac && /* NCD Sun keyboard */ 226 - ps2dev->cmdbuf[receive - 1] != 0x2b && /* Trust keyboard, translated */ 227 - ps2dev->cmdbuf[receive - 1] != 0x5d && /* Trust keyboard */ 228 - ps2dev->cmdbuf[receive - 1] != 0x60 && /* NMB SGI keyboard, translated */ 229 - ps2dev->cmdbuf[receive - 1] != 0x47) { /* NMB SGI keyboard */ 230 - /* 231 - * Device behind the port is not a keyboard 232 - * so we don't need to wait for the 2nd byte 233 - * of ID response. 234 - */ 235 - serio_pause_rx(ps2dev->serio); 236 - ps2dev->flags = ps2dev->cmdcnt = 0; 237 - serio_continue_rx(ps2dev->serio); 238 - } 239 - 123 + timeout = ps2_adjust_timeout(ps2dev, command, timeout); 240 124 wait_event_timeout(ps2dev->wait, 241 125 !(ps2dev->flags & PS2_FLAG_CMD), timeout); 242 126 } ··· 224 160 225 161 rc = 0; 226 162 227 - out: 163 + out: 228 164 serio_pause_rx(ps2dev->serio); 229 165 ps2dev->flags = 0; 230 166 serio_continue_rx(ps2dev->serio);
+1 -1
drivers/input/touchscreen/elo.c
··· 226 226 input_set_abs_params(&elo->dev, ABS_Y, 96, 4000, 0, 0); 227 227 input_set_abs_params(&elo->dev, ABS_PRESSURE, 0, 255, 0, 0); 228 228 break; 229 - 229 + 230 230 case 1: /* 6-byte protocol */ 231 231 input_set_abs_params(&elo->dev, ABS_PRESSURE, 0, 15, 0, 0); 232 232
+90 -90
drivers/input/touchscreen/h3600_ts_input.c
··· 89 89 #define H3600_SCANCODE_Q 4 /* 4 -> Q button */ 90 90 #define H3600_SCANCODE_START 5 /* 5 -> start menu */ 91 91 #define H3600_SCANCODE_UP 6 /* 6 -> up */ 92 - #define H3600_SCANCODE_RIGHT 7 /* 7 -> right */ 93 - #define H3600_SCANCODE_LEFT 8 /* 8 -> left */ 94 - #define H3600_SCANCODE_DOWN 9 /* 9 -> down */ 92 + #define H3600_SCANCODE_RIGHT 7 /* 7 -> right */ 93 + #define H3600_SCANCODE_LEFT 8 /* 8 -> left */ 94 + #define H3600_SCANCODE_DOWN 9 /* 9 -> down */ 95 95 96 96 static char *h3600_name = "H3600 TouchScreen"; 97 97 ··· 113 113 114 114 static irqreturn_t action_button_handler(int irq, void *dev_id, struct pt_regs *regs) 115 115 { 116 - int down = (GPLR & GPIO_BITSY_ACTION_BUTTON) ? 0 : 1; 116 + int down = (GPLR & GPIO_BITSY_ACTION_BUTTON) ? 0 : 1; 117 117 struct input_dev *dev = (struct input_dev *) dev_id; 118 118 119 119 input_regs(dev, regs); ··· 125 125 126 126 static irqreturn_t npower_button_handler(int irq, void *dev_id, struct pt_regs *regs) 127 127 { 128 - int down = (GPLR & GPIO_BITSY_NPOWER_BUTTON) ? 0 : 1; 128 + int down = (GPLR & GPIO_BITSY_NPOWER_BUTTON) ? 0 : 1; 129 129 struct input_dev *dev = (struct input_dev *) dev_id; 130 130 131 131 /* ··· 145 145 static int flite_brightness = 25; 146 146 147 147 enum flite_pwr { 148 - FLITE_PWR_OFF = 0, 149 - FLITE_PWR_ON = 1 148 + FLITE_PWR_OFF = 0, 149 + FLITE_PWR_ON = 1 150 150 }; 151 151 152 152 /* ··· 157 157 struct h3600_dev *ts = dev->private; 158 158 159 159 /* Must be in this order */ 160 - ts->serio->write(ts->serio, 1); 160 + ts->serio->write(ts->serio, 1); 161 161 ts->serio->write(ts->serio, pwr); 162 - ts->serio->write(ts->serio, brightness); 162 + ts->serio->write(ts->serio, brightness); 163 163 return 0; 164 164 } 165 165 ··· 169 169 { 170 170 struct input_dev *dev = (struct input_dev *) data; 171 171 172 - switch (req) { 173 - case PM_SUSPEND: /* enter D1-D3 */ 174 - suspended = 1; 175 - h3600_flite_power(dev, FLITE_PWR_OFF); 176 - break; 177 - case PM_BLANK: 178 - if (!suspended) 179 - h3600_flite_power(dev, FLITE_PWR_OFF); 180 - break; 181 - case PM_RESUME: /* enter D0 */ 182 - /* same as unblank */ 183 - case PM_UNBLANK: 184 - if (suspended) { 185 - //initSerial(); 186 - suspended = 0; 187 - } 188 - h3600_flite_power(dev, FLITE_PWR_ON); 189 - break; 190 - } 191 - return 0; 172 + switch (req) { 173 + case PM_SUSPEND: /* enter D1-D3 */ 174 + suspended = 1; 175 + h3600_flite_power(dev, FLITE_PWR_OFF); 176 + break; 177 + case PM_BLANK: 178 + if (!suspended) 179 + h3600_flite_power(dev, FLITE_PWR_OFF); 180 + break; 181 + case PM_RESUME: /* enter D0 */ 182 + /* same as unblank */ 183 + case PM_UNBLANK: 184 + if (suspended) { 185 + //initSerial(); 186 + suspended = 0; 187 + } 188 + h3600_flite_power(dev, FLITE_PWR_ON); 189 + break; 190 + } 191 + return 0; 192 192 } 193 193 #endif 194 194 ··· 199 199 */ 200 200 static void h3600ts_process_packet(struct h3600_dev *ts, struct pt_regs *regs) 201 201 { 202 - struct input_dev *dev = &ts->dev; 202 + struct input_dev *dev = &ts->dev; 203 203 static int touched = 0; 204 204 int key, down = 0; 205 205 206 206 input_regs(dev, regs); 207 207 208 - switch (ts->event) { 209 - /* 210 - Buttons - returned as a single byte 211 - 7 6 5 4 3 2 1 0 212 - S x x x N N N N 208 + switch (ts->event) { 209 + /* 210 + Buttons - returned as a single byte 211 + 7 6 5 4 3 2 1 0 212 + S x x x N N N N 213 213 214 - S switch state ( 0=pressed 1=released) 215 - x Unused. 216 - NNNN switch number 0-15 214 + S switch state ( 0=pressed 1=released) 215 + x Unused. 216 + NNNN switch number 0-15 217 217 218 - Note: This is true for non interrupt generated key events. 219 - */ 220 - case KEYBD_ID: 218 + Note: This is true for non interrupt generated key events. 219 + */ 220 + case KEYBD_ID: 221 221 down = (ts->buf[0] & 0x80) ? 0 : 1; 222 222 223 223 switch (ts->buf[0] & 0x7f) { ··· 229 229 break; 230 230 case H3600_SCANCODE_CONTACTS: 231 231 key = KEY_PROG2; 232 - break; 232 + break; 233 233 case H3600_SCANCODE_Q: 234 234 key = KEY_Q; 235 - break; 235 + break; 236 236 case H3600_SCANCODE_START: 237 237 key = KEY_PROG3; 238 - break; 238 + break; 239 239 case H3600_SCANCODE_UP: 240 240 key = KEY_UP; 241 - break; 241 + break; 242 242 case H3600_SCANCODE_RIGHT: 243 243 key = KEY_RIGHT; 244 - break; 244 + break; 245 245 case H3600_SCANCODE_LEFT: 246 246 key = KEY_LEFT; 247 - break; 247 + break; 248 248 case H3600_SCANCODE_DOWN: 249 249 key = KEY_DOWN; 250 - break; 250 + break; 251 251 default: 252 252 key = 0; 253 253 } 254 - if (key) 255 - input_report_key(dev, key, down); 256 - break; 257 - /* 258 - * Native touchscreen event data is formatted as shown below:- 259 - * 260 - * +-------+-------+-------+-------+ 261 - * | Xmsb | Xlsb | Ymsb | Ylsb | 262 - * +-------+-------+-------+-------+ 263 - * byte 0 1 2 3 264 - */ 265 - case TOUCHS_ID: 254 + if (key) 255 + input_report_key(dev, key, down); 256 + break; 257 + /* 258 + * Native touchscreen event data is formatted as shown below:- 259 + * 260 + * +-------+-------+-------+-------+ 261 + * | Xmsb | Xlsb | Ymsb | Ylsb | 262 + * +-------+-------+-------+-------+ 263 + * byte 0 1 2 3 264 + */ 265 + case TOUCHS_ID: 266 266 if (!touched) { 267 267 input_report_key(dev, BTN_TOUCH, 1); 268 268 touched = 1; ··· 272 272 unsigned short x, y; 273 273 274 274 x = ts->buf[0]; x <<= 8; x += ts->buf[1]; 275 - y = ts->buf[2]; y <<= 8; y += ts->buf[3]; 275 + y = ts->buf[2]; y <<= 8; y += ts->buf[3]; 276 276 277 - input_report_abs(dev, ABS_X, x); 278 - input_report_abs(dev, ABS_Y, y); 277 + input_report_abs(dev, ABS_X, x); 278 + input_report_abs(dev, ABS_Y, y); 279 279 } else { 280 - input_report_key(dev, BTN_TOUCH, 0); 280 + input_report_key(dev, BTN_TOUCH, 0); 281 281 touched = 0; 282 282 } 283 - break; 283 + break; 284 284 default: 285 285 /* Send a non input event elsewhere */ 286 286 break; 287 - } 287 + } 288 288 289 289 input_sync(dev); 290 290 } ··· 293 293 * h3600ts_event() handles events from the input module. 294 294 */ 295 295 static int h3600ts_event(struct input_dev *dev, unsigned int type, 296 - unsigned int code, int value) 296 + unsigned int code, int value) 297 297 { 298 298 struct h3600_dev *ts = dev->private; 299 299 ··· 332 332 static irqreturn_t h3600ts_interrupt(struct serio *serio, unsigned char data, 333 333 unsigned int flags, struct pt_regs *regs) 334 334 { 335 - struct h3600_dev *ts = serio_get_drvdata(serio); 335 + struct h3600_dev *ts = serio_get_drvdata(serio); 336 336 337 337 /* 338 - * We have a new frame coming in. 339 - */ 338 + * We have a new frame coming in. 339 + */ 340 340 switch (state) { 341 341 case STATE_SOF: 342 - if (data == CHAR_SOF) 343 - state = STATE_ID; 342 + if (data == CHAR_SOF) 343 + state = STATE_ID; 344 344 break; 345 - case STATE_ID: 345 + case STATE_ID: 346 346 ts->event = (data & 0xf0) >> 4; 347 347 ts->len = (data & 0xf); 348 348 ts->idx = 0; 349 349 if (ts->event >= MAX_ID) { 350 350 state = STATE_SOF; 351 - break; 351 + break; 352 352 } 353 353 ts->chksum = data; 354 - state = (ts->len > 0) ? STATE_DATA : STATE_EOF; 354 + state = (ts->len > 0) ? STATE_DATA : STATE_EOF; 355 355 break; 356 356 case STATE_DATA: 357 357 ts->chksum += data; 358 358 ts->buf[ts->idx]= data; 359 - if(++ts->idx == ts->len) 360 - state = STATE_EOF; 359 + if (++ts->idx == ts->len) 360 + state = STATE_EOF; 361 361 break; 362 362 case STATE_EOF: 363 - state = STATE_SOF; 364 - if (data == CHAR_EOF || data == ts->chksum) 363 + state = STATE_SOF; 364 + if (data == CHAR_EOF || data == ts->chksum) 365 365 h3600ts_process_packet(ts, regs); 366 - break; 367 - default: 368 - printk("Error3\n"); 369 - break; 366 + break; 367 + default: 368 + printk("Error3\n"); 369 + break; 370 370 } 371 371 372 372 return IRQ_HANDLED; ··· 390 390 init_input_dev(&ts->dev); 391 391 392 392 /* Device specific stuff */ 393 - set_GPIO_IRQ_edge(GPIO_BITSY_ACTION_BUTTON, GPIO_BOTH_EDGES); 394 - set_GPIO_IRQ_edge(GPIO_BITSY_NPOWER_BUTTON, GPIO_RISING_EDGE); 393 + set_GPIO_IRQ_edge(GPIO_BITSY_ACTION_BUTTON, GPIO_BOTH_EDGES); 394 + set_GPIO_IRQ_edge(GPIO_BITSY_NPOWER_BUTTON, GPIO_RISING_EDGE); 395 395 396 - if (request_irq(IRQ_GPIO_BITSY_ACTION_BUTTON, action_button_handler, 396 + if (request_irq(IRQ_GPIO_BITSY_ACTION_BUTTON, action_button_handler, 397 397 SA_SHIRQ | SA_INTERRUPT | SA_SAMPLE_RANDOM, 398 398 "h3600_action", &ts->dev)) { 399 399 printk(KERN_ERR "h3600ts.c: Could not allocate Action Button IRQ!\n"); ··· 401 401 return -EBUSY; 402 402 } 403 403 404 - if (request_irq(IRQ_GPIO_BITSY_NPOWER_BUTTON, npower_button_handler, 404 + if (request_irq(IRQ_GPIO_BITSY_NPOWER_BUTTON, npower_button_handler, 405 405 SA_SHIRQ | SA_INTERRUPT | SA_SAMPLE_RANDOM, 406 406 "h3600_suspend", &ts->dev)) { 407 407 free_irq(IRQ_GPIO_BITSY_ACTION_BUTTON, &ts->dev); ··· 433 433 434 434 sprintf(ts->phys, "%s/input0", serio->phys); 435 435 436 - ts->dev.event = h3600ts_event; 436 + ts->dev.event = h3600ts_event; 437 437 ts->dev.private = ts; 438 438 ts->dev.name = h3600_name; 439 439 ts->dev.phys = ts->phys; ··· 446 446 447 447 err = serio_open(serio, drv); 448 448 if (err) { 449 - free_irq(IRQ_GPIO_BITSY_ACTION_BUTTON, ts); 450 - free_irq(IRQ_GPIO_BITSY_NPOWER_BUTTON, ts); 449 + free_irq(IRQ_GPIO_BITSY_ACTION_BUTTON, ts); 450 + free_irq(IRQ_GPIO_BITSY_NPOWER_BUTTON, ts); 451 451 serio_set_drvdata(serio, NULL); 452 452 kfree(ts); 453 453 return err;
+8 -13
drivers/input/touchscreen/mk712.c
··· 17 17 * found in Gateway AOL Connected Touchpad computers. 18 18 * 19 19 * Documentation for ICS MK712 can be found at: 20 - * http://www.icst.com/pdf/mk712.pdf 20 + * http://www.icst.com/pdf/mk712.pdf 21 21 */ 22 22 23 23 /* ··· 77 77 #define MK712_READ_ONE_POINT 0x20 78 78 #define MK712_POWERUP 0x40 79 79 80 - static int mk712_used = 0; 81 80 static struct input_dev mk712_dev; 82 81 static DEFINE_SPINLOCK(mk712_lock); 83 82 ··· 129 130 130 131 spin_lock_irqsave(&mk712_lock, flags); 131 132 132 - if (!mk712_used++) { 133 + outb(0, mk712_io + MK712_CONTROL); /* Reset */ 133 134 134 - outb(0, mk712_io + MK712_CONTROL); /* Reset */ 135 + outb(MK712_ENABLE_INT | MK712_INT_ON_CONVERSION_COMPLETE | 136 + MK712_INT_ON_CHANGE_IN_TOUCH_STATUS | 137 + MK712_ENABLE_PERIODIC_CONVERSIONS | 138 + MK712_POWERUP, mk712_io + MK712_CONTROL); 135 139 136 - outb(MK712_ENABLE_INT | MK712_INT_ON_CONVERSION_COMPLETE | 137 - MK712_INT_ON_CHANGE_IN_TOUCH_STATUS | 138 - MK712_ENABLE_PERIODIC_CONVERSIONS | 139 - MK712_POWERUP, mk712_io + MK712_CONTROL); 140 - 141 - outb(10, mk712_io + MK712_RATE); /* 187 points per second */ 142 - } 140 + outb(10, mk712_io + MK712_RATE); /* 187 points per second */ 143 141 144 142 spin_unlock_irqrestore(&mk712_lock, flags); 145 143 ··· 149 153 150 154 spin_lock_irqsave(&mk712_lock, flags); 151 155 152 - if (!--mk712_used) 153 - outb(0, mk712_io + MK712_CONTROL); 156 + outb(0, mk712_io + MK712_CONTROL); 154 157 155 158 spin_unlock_irqrestore(&mk712_lock, flags); 156 159 }
+1
drivers/usb/Makefile
··· 31 31 obj-$(CONFIG_USB_MTOUCH) += input/ 32 32 obj-$(CONFIG_USB_POWERMATE) += input/ 33 33 obj-$(CONFIG_USB_WACOM) += input/ 34 + obj-$(CONFIG_USB_ACECAD) += input/ 34 35 obj-$(CONFIG_USB_XPAD) += input/ 35 36 36 37 obj-$(CONFIG_USB_DABUSB) += media/
+24
drivers/usb/input/Kconfig
··· 151 151 To compile this driver as a module, choose M here: the 152 152 module will be called wacom. 153 153 154 + config USB_ACECAD 155 + tristate "Acecad Flair tablet support" 156 + depends on USB && INPUT 157 + help 158 + Say Y here if you want to use the USB version of the Acecad Flair 159 + tablet. Make sure to say Y to "Mouse support" 160 + (CONFIG_INPUT_MOUSEDEV) and/or "Event interface support" 161 + (CONFIG_INPUT_EVDEV) as well. 162 + 163 + To compile this driver as a module, choose M here: the 164 + module will be called acecad. 165 + 154 166 config USB_KBTAB 155 167 tristate "KB Gear JamStudio tablet support" 156 168 depends on USB && INPUT ··· 201 189 202 190 To compile this driver as a module, choose M here: the 203 191 module will be called mtouchusb. 192 + 193 + config USB_ITMTOUCH 194 + tristate "ITM Touch USB Touchscreen Driver" 195 + depends on USB && INPUT 196 + ---help--- 197 + Say Y here if you want to use a ITM Touch USB 198 + Touchscreen controller. 199 + 200 + This touchscreen is used in LG 1510SF monitors. 201 + 202 + To compile this driver as a module, choose M here: the 203 + module will be called itmtouch. 204 204 205 205 config USB_EGALAX 206 206 tristate "eGalax TouchKit USB Touchscreen Driver"
+2
drivers/usb/input/Makefile
··· 33 33 obj-$(CONFIG_USB_KBTAB) += kbtab.o 34 34 obj-$(CONFIG_USB_MOUSE) += usbmouse.o 35 35 obj-$(CONFIG_USB_MTOUCH) += mtouchusb.o 36 + obj-$(CONFIG_USB_ITMTOUCH) += itmtouch.o 36 37 obj-$(CONFIG_USB_EGALAX) += touchkitusb.o 37 38 obj-$(CONFIG_USB_POWERMATE) += powermate.o 38 39 obj-$(CONFIG_USB_WACOM) += wacom.o 40 + obj-$(CONFIG_USB_ACECAD) += acecad.o 39 41 obj-$(CONFIG_USB_XPAD) += xpad.o
+285
drivers/usb/input/acecad.c
··· 1 + /* 2 + * Copyright (c) 2001-2005 Edouard TISSERANT <edouard.tisserant@wanadoo.fr> 3 + * Copyright (c) 2004-2005 Stephane VOLTZ <svoltz@numericable.fr> 4 + * 5 + * USB Acecad "Acecad Flair" tablet support 6 + * 7 + * Changelog: 8 + * v3.2 - Added sysfs support 9 + */ 10 + 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 as published by 14 + * the Free Software Foundation; either version 2 of the License, or 15 + * (at your option) any later version. 16 + * 17 + * This program is distributed in the hope that it will be useful, 18 + * but WITHOUT ANY WARRANTY; without even the implied warranty of 19 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 + * GNU General Public License for more details. 21 + * 22 + * You should have received a copy of the GNU General Public License 23 + * along with this program; if not, write to the Free Software 24 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 25 + * 26 + */ 27 + 28 + #include <linux/kernel.h> 29 + #include <linux/slab.h> 30 + #include <linux/input.h> 31 + #include <linux/module.h> 32 + #include <linux/init.h> 33 + #include <linux/usb.h> 34 + 35 + /* 36 + * Version Information 37 + */ 38 + #define DRIVER_VERSION "v3.2" 39 + #define DRIVER_DESC "USB Acecad Flair tablet driver" 40 + #define DRIVER_LICENSE "GPL" 41 + #define DRIVER_AUTHOR "Edouard TISSERANT <edouard.tisserant@wanadoo.fr>" 42 + 43 + MODULE_AUTHOR(DRIVER_AUTHOR); 44 + MODULE_DESCRIPTION(DRIVER_DESC); 45 + MODULE_LICENSE(DRIVER_LICENSE); 46 + 47 + #define USB_VENDOR_ID_ACECAD 0x0460 48 + #define USB_DEVICE_ID_FLAIR 0x0004 49 + #define USB_DEVICE_ID_302 0x0008 50 + 51 + struct usb_acecad { 52 + char name[128]; 53 + char phys[64]; 54 + struct usb_device *usbdev; 55 + struct input_dev dev; 56 + struct urb *irq; 57 + 58 + signed char *data; 59 + dma_addr_t data_dma; 60 + }; 61 + 62 + static void usb_acecad_irq(struct urb *urb, struct pt_regs *regs) 63 + { 64 + struct usb_acecad *acecad = urb->context; 65 + unsigned char *data = acecad->data; 66 + struct input_dev *dev = &acecad->dev; 67 + int prox, status; 68 + 69 + switch (urb->status) { 70 + case 0: 71 + /* success */ 72 + break; 73 + case -ECONNRESET: 74 + case -ENOENT: 75 + case -ESHUTDOWN: 76 + /* this urb is terminated, clean up */ 77 + dbg("%s - urb shutting down with status: %d", __FUNCTION__, urb->status); 78 + return; 79 + default: 80 + dbg("%s - nonzero urb status received: %d", __FUNCTION__, urb->status); 81 + goto resubmit; 82 + } 83 + 84 + prox = (data[0] & 0x04) >> 2; 85 + input_report_key(dev, BTN_TOOL_PEN, prox); 86 + 87 + if (prox) { 88 + int x = data[1] | (data[2] << 8); 89 + int y = data[3] | (data[4] << 8); 90 + /*Pressure should compute the same way for flair and 302*/ 91 + int pressure = data[5] | ((int)data[6] << 8); 92 + int touch = data[0] & 0x01; 93 + int stylus = (data[0] & 0x10) >> 4; 94 + int stylus2 = (data[0] & 0x20) >> 5; 95 + input_report_abs(dev, ABS_X, x); 96 + input_report_abs(dev, ABS_Y, y); 97 + input_report_abs(dev, ABS_PRESSURE, pressure); 98 + input_report_key(dev, BTN_TOUCH, touch); 99 + input_report_key(dev, BTN_STYLUS, stylus); 100 + input_report_key(dev, BTN_STYLUS2, stylus2); 101 + } 102 + 103 + /* event termination */ 104 + input_sync(dev); 105 + 106 + resubmit: 107 + status = usb_submit_urb (urb, GFP_ATOMIC); 108 + if (status) 109 + err ("can't resubmit intr, %s-%s/input0, status %d", 110 + acecad->usbdev->bus->bus_name, acecad->usbdev->devpath, status); 111 + } 112 + 113 + static int usb_acecad_open(struct input_dev *dev) 114 + { 115 + struct usb_acecad *acecad = dev->private; 116 + 117 + acecad->irq->dev = acecad->usbdev; 118 + if (usb_submit_urb(acecad->irq, GFP_KERNEL)) 119 + return -EIO; 120 + 121 + return 0; 122 + } 123 + 124 + static void usb_acecad_close(struct input_dev *dev) 125 + { 126 + struct usb_acecad *acecad = dev->private; 127 + 128 + usb_kill_urb(acecad->irq); 129 + } 130 + 131 + static int usb_acecad_probe(struct usb_interface *intf, const struct usb_device_id *id) 132 + { 133 + struct usb_device *dev = interface_to_usbdev(intf); 134 + struct usb_host_interface *interface = intf->cur_altsetting; 135 + struct usb_endpoint_descriptor *endpoint; 136 + struct usb_acecad *acecad; 137 + int pipe, maxp; 138 + char path[64]; 139 + 140 + if (interface->desc.bNumEndpoints != 1) 141 + return -ENODEV; 142 + 143 + endpoint = &interface->endpoint[0].desc; 144 + 145 + if (!(endpoint->bEndpointAddress & 0x80)) 146 + return -ENODEV; 147 + 148 + if ((endpoint->bmAttributes & 3) != 3) 149 + return -ENODEV; 150 + 151 + pipe = usb_rcvintpipe(dev, endpoint->bEndpointAddress); 152 + maxp = usb_maxpacket(dev, pipe, usb_pipeout(pipe)); 153 + 154 + acecad = kcalloc(1, sizeof(struct usb_acecad), GFP_KERNEL); 155 + if (!acecad) 156 + return -ENOMEM; 157 + 158 + acecad->data = usb_buffer_alloc(dev, 8, SLAB_KERNEL, &acecad->data_dma); 159 + if (!acecad->data) 160 + goto fail1; 161 + 162 + acecad->irq = usb_alloc_urb(0, GFP_KERNEL); 163 + if (!acecad->irq) 164 + goto fail2; 165 + 166 + if (dev->manufacturer) 167 + strlcpy(acecad->name, dev->manufacturer, sizeof(acecad->name)); 168 + 169 + if (dev->product) { 170 + if (dev->manufacturer) 171 + strlcat(acecad->name, " ", sizeof(acecad->name)); 172 + strlcat(acecad->name, dev->product, sizeof(acecad->name)); 173 + } 174 + 175 + usb_make_path(dev, path, sizeof(path)); 176 + snprintf(acecad->phys, sizeof(acecad->phys), "%s/input0", path); 177 + 178 + acecad->usbdev = dev; 179 + 180 + acecad->dev.evbit[0] = BIT(EV_KEY) | BIT(EV_ABS); 181 + acecad->dev.absbit[0] = BIT(ABS_X) | BIT(ABS_Y) | BIT(ABS_PRESSURE); 182 + acecad->dev.keybit[LONG(BTN_LEFT)] = BIT(BTN_LEFT) | BIT(BTN_RIGHT) | BIT(BTN_MIDDLE); 183 + acecad->dev.keybit[LONG(BTN_DIGI)] = BIT(BTN_TOOL_PEN) |BIT(BTN_TOUCH) | BIT(BTN_STYLUS) | BIT(BTN_STYLUS2); 184 + 185 + switch (id->driver_info) { 186 + case 0: 187 + acecad->dev.absmax[ABS_X] = 5000; 188 + acecad->dev.absmax[ABS_Y] = 3750; 189 + acecad->dev.absmax[ABS_PRESSURE] = 512; 190 + if (!strlen(acecad->name)) 191 + snprintf(acecad->name, sizeof(acecad->name), 192 + "USB Acecad Flair Tablet %04x:%04x", 193 + dev->descriptor.idVendor, dev->descriptor.idProduct); 194 + break; 195 + case 1: 196 + acecad->dev.absmax[ABS_X] = 3000; 197 + acecad->dev.absmax[ABS_Y] = 2250; 198 + acecad->dev.absmax[ABS_PRESSURE] = 1024; 199 + if (!strlen(acecad->name)) 200 + snprintf(acecad->name, sizeof(acecad->name), 201 + "USB Acecad 302 Tablet %04x:%04x", 202 + dev->descriptor.idVendor, dev->descriptor.idProduct); 203 + break; 204 + } 205 + 206 + acecad->dev.absfuzz[ABS_X] = 4; 207 + acecad->dev.absfuzz[ABS_Y] = 4; 208 + 209 + acecad->dev.private = acecad; 210 + acecad->dev.open = usb_acecad_open; 211 + acecad->dev.close = usb_acecad_close; 212 + 213 + acecad->dev.name = acecad->name; 214 + acecad->dev.phys = acecad->phys; 215 + acecad->dev.id.bustype = BUS_USB; 216 + acecad->dev.id.vendor = le16_to_cpu(dev->descriptor.idVendor); 217 + acecad->dev.id.product = le16_to_cpu(dev->descriptor.idProduct); 218 + acecad->dev.id.version = le16_to_cpu(dev->descriptor.bcdDevice); 219 + acecad->dev.dev = &intf->dev; 220 + 221 + usb_fill_int_urb(acecad->irq, dev, pipe, 222 + acecad->data, maxp > 8 ? 8 : maxp, 223 + usb_acecad_irq, acecad, endpoint->bInterval); 224 + acecad->irq->transfer_dma = acecad->data_dma; 225 + acecad->irq->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; 226 + 227 + input_register_device(&acecad->dev); 228 + 229 + printk(KERN_INFO "input: %s with packet size %d on %s\n", 230 + acecad->name, maxp, path); 231 + 232 + usb_set_intfdata(intf, acecad); 233 + 234 + return 0; 235 + 236 + fail2: usb_buffer_free(dev, 8, acecad->data, acecad->data_dma); 237 + fail1: kfree(acecad); 238 + return -ENOMEM; 239 + } 240 + 241 + static void usb_acecad_disconnect(struct usb_interface *intf) 242 + { 243 + struct usb_acecad *acecad = usb_get_intfdata(intf); 244 + 245 + usb_set_intfdata(intf, NULL); 246 + if (acecad) { 247 + usb_kill_urb(acecad->irq); 248 + input_unregister_device(&acecad->dev); 249 + usb_free_urb(acecad->irq); 250 + usb_buffer_free(interface_to_usbdev(intf), 10, acecad->data, acecad->data_dma); 251 + kfree(acecad); 252 + } 253 + } 254 + 255 + static struct usb_device_id usb_acecad_id_table [] = { 256 + { USB_DEVICE(USB_VENDOR_ID_ACECAD, USB_DEVICE_ID_FLAIR), .driver_info = 0 }, 257 + { USB_DEVICE(USB_VENDOR_ID_ACECAD, USB_DEVICE_ID_302), .driver_info = 1 }, 258 + { } 259 + }; 260 + 261 + MODULE_DEVICE_TABLE(usb, usb_acecad_id_table); 262 + 263 + static struct usb_driver usb_acecad_driver = { 264 + .owner = THIS_MODULE, 265 + .name = "usb_acecad", 266 + .probe = usb_acecad_probe, 267 + .disconnect = usb_acecad_disconnect, 268 + .id_table = usb_acecad_id_table, 269 + }; 270 + 271 + static int __init usb_acecad_init(void) 272 + { 273 + int result = usb_register(&usb_acecad_driver); 274 + if (result == 0) 275 + info(DRIVER_VERSION ":" DRIVER_DESC); 276 + return result; 277 + } 278 + 279 + static void __exit usb_acecad_exit(void) 280 + { 281 + usb_deregister(&usb_acecad_driver); 282 + } 283 + 284 + module_init(usb_acecad_init); 285 + module_exit(usb_acecad_exit);
+11 -21
drivers/usb/input/aiptek.c
··· 1 1 /* 2 2 * Native support for the Aiptek HyperPen USB Tablets 3 3 * (4000U/5000U/6000U/8000U/12000U) 4 - * 4 + * 5 5 * Copyright (c) 2001 Chris Atenasio <chris@crud.net> 6 6 * Copyright (c) 2002-2004 Bryan W. Headley <bwheadley@earthlink.net> 7 7 * ··· 31 31 * - Added support for the sysfs interface, deprecating the 32 32 * procfs interface for 2.5.x kernel. Also added support for 33 33 * Wheel command. Bryan W. Headley July-15-2003. 34 - * v1.2 - Reworked jitter timer as a kernel thread. 34 + * v1.2 - Reworked jitter timer as a kernel thread. 35 35 * Bryan W. Headley November-28-2003/Jan-10-2004. 36 36 * v1.3 - Repaired issue of kernel thread going nuts on single-processor 37 37 * machines, introduced programmableDelay as a command line ··· 49 49 * NOTE: 50 50 * This kernel driver is augmented by the "Aiptek" XFree86 input 51 51 * driver for your X server, as well as the Gaiptek GUI Front-end 52 - * "Tablet Manager". 53 - * These three products are highly interactive with one another, 52 + * "Tablet Manager". 53 + * These three products are highly interactive with one another, 54 54 * so therefore it's easier to document them all as one subsystem. 55 - * Please visit the project's "home page", located at, 55 + * Please visit the project's "home page", located at, 56 56 * http://aiptektablet.sourceforge.net. 57 57 * 58 58 * This program is free software; you can redistribute it and/or modify ··· 156 156 * Command/Data Description Return Bytes Return Value 157 157 * 0x10/0x00 SwitchToMouse 0 158 158 * 0x10/0x01 SwitchToTablet 0 159 - * 0x18/0x04 SetResolution 0 159 + * 0x18/0x04 SetResolution 0 160 160 * 0x12/0xFF AutoGainOn 0 161 161 * 0x17/0x00 FilterOn 0 162 162 * 0x01/0x00 GetXExtension 2 MaxX ··· 247 247 #define AIPTEK_DIAGNOSTIC_SENDING_ABSOLUTE_IN_RELATIVE 2 248 248 #define AIPTEK_DIAGNOSTIC_TOOL_DISALLOWED 3 249 249 250 - /* Time to wait (in ms) to help mask hand jittering 250 + /* Time to wait (in ms) to help mask hand jittering 251 251 * when pressing the stylus buttons. 252 252 */ 253 253 #define AIPTEK_JITTER_DELAY_DEFAULT 50 ··· 324 324 struct aiptek_settings curSetting; /* tablet's current programmable */ 325 325 struct aiptek_settings newSetting; /* ... and new param settings */ 326 326 unsigned int ifnum; /* interface number for IO */ 327 - int openCount; /* module use counter */ 328 327 int diagnostic; /* tablet diagnostic codes */ 329 328 unsigned long eventCount; /* event count */ 330 329 int inDelay; /* jitter: in jitter delay? */ ··· 790 791 * specific Aiptek model numbers, because there has been overlaps, 791 792 * use, and reuse of id's in existing models. Certain models have 792 793 * been known to use more than one ID, indicative perhaps of 793 - * manufacturing revisions. In any event, we consider these 794 + * manufacturing revisions. In any event, we consider these 794 795 * IDs to not be model-specific nor unique. 795 796 */ 796 797 static const struct usb_device_id aiptek_ids[] = { ··· 813 814 { 814 815 struct aiptek *aiptek = inputdev->private; 815 816 816 - if (aiptek->openCount++ > 0) { 817 - return 0; 818 - } 819 - 820 817 aiptek->urb->dev = aiptek->usbdev; 821 - if (usb_submit_urb(aiptek->urb, GFP_KERNEL) != 0) { 822 - aiptek->openCount--; 818 + if (usb_submit_urb(aiptek->urb, GFP_KERNEL) != 0) 823 819 return -EIO; 824 - } 825 820 826 821 return 0; 827 822 } ··· 827 834 { 828 835 struct aiptek *aiptek = inputdev->private; 829 836 830 - if (--aiptek->openCount == 0) { 831 - usb_kill_urb(aiptek->urb); 832 - } 837 + usb_kill_urb(aiptek->urb); 833 838 } 834 839 835 840 /*********************************************************************** 836 - * aiptek_set_report and aiptek_get_report() are borrowed from Linux 2.4.x, 841 + * aiptek_set_report and aiptek_get_report() are borrowed from Linux 2.4.x, 837 842 * where they were known as usb_set_report and usb_get_report. 838 843 */ 839 844 static int ··· 2243 2252 AIPTEK_PACKET_LENGTH, 2244 2253 aiptek->data, aiptek->data_dma); 2245 2254 kfree(aiptek); 2246 - aiptek = NULL; 2247 2255 } 2248 2256 } 2249 2257
+114 -133
drivers/usb/input/ati_remote.c
··· 1 - /* 1 + /* 2 2 * USB ATI Remote support 3 3 * 4 4 * Version 2.2.0 Copyright (c) 2004 Torrey Hoffman <thoffman@arnor.net> 5 5 * Version 2.1.1 Copyright (c) 2002 Vladimir Dergachev 6 6 * 7 7 * This 2.2.0 version is a rewrite / cleanup of the 2.1.1 driver, including 8 - * porting to the 2.6 kernel interfaces, along with other modification 8 + * porting to the 2.6 kernel interfaces, along with other modification 9 9 * to better match the style of the existing usb/input drivers. However, the 10 10 * protocol and hardware handling is essentially unchanged from 2.1.1. 11 - * 12 - * The 2.1.1 driver was derived from the usbati_remote and usbkbd drivers by 11 + * 12 + * The 2.1.1 driver was derived from the usbati_remote and usbkbd drivers by 13 13 * Vojtech Pavlik. 14 14 * 15 15 * Changes: ··· 23 23 * Added support for the "Lola" remote contributed by: 24 24 * Seth Cohn <sethcohn@yahoo.com> 25 25 * 26 - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 26 + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 27 27 * 28 28 * This program is free software; you can redistribute it and/or modify 29 29 * it under the terms of the GNU General Public License as published by 30 - * the Free Software Foundation; either version 2 of the License, or 30 + * the Free Software Foundation; either version 2 of the License, or 31 31 * (at your option) any later version. 32 - * 32 + * 33 33 * This program is distributed in the hope that it will be useful, 34 34 * but WITHOUT ANY WARRANTY; without even the implied warranty of 35 35 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 36 36 * GNU General Public License for more details. 37 - * 37 + * 38 38 * You should have received a copy of the GNU General Public License 39 39 * along with this program; if not, write to the Free Software 40 40 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 41 - * 42 - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 41 + * 42 + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 43 43 * 44 44 * Hardware & software notes 45 45 * 46 - * These remote controls are distributed by ATI as part of their 47 - * "All-In-Wonder" video card packages. The receiver self-identifies as a 46 + * These remote controls are distributed by ATI as part of their 47 + * "All-In-Wonder" video card packages. The receiver self-identifies as a 48 48 * "USB Receiver" with manufacturer "X10 Wireless Technology Inc". 49 49 * 50 - * The "Lola" remote is available from X10. See: 50 + * The "Lola" remote is available from X10. See: 51 51 * http://www.x10.com/products/lola_sg1.htm 52 52 * The Lola is similar to the ATI remote but has no mouse support, and slightly 53 53 * different keys. 54 54 * 55 - * It is possible to use multiple receivers and remotes on multiple computers 55 + * It is possible to use multiple receivers and remotes on multiple computers 56 56 * simultaneously by configuring them to use specific channels. 57 - * 58 - * The RF protocol used by the remote supports 16 distinct channels, 1 to 16. 59 - * Actually, it may even support more, at least in some revisions of the 57 + * 58 + * The RF protocol used by the remote supports 16 distinct channels, 1 to 16. 59 + * Actually, it may even support more, at least in some revisions of the 60 60 * hardware. 61 61 * 62 62 * Each remote can be configured to transmit on one channel as follows: 63 - * - Press and hold the "hand icon" button. 64 - * - When the red LED starts to blink, let go of the "hand icon" button. 65 - * - When it stops blinking, input the channel code as two digits, from 01 63 + * - Press and hold the "hand icon" button. 64 + * - When the red LED starts to blink, let go of the "hand icon" button. 65 + * - When it stops blinking, input the channel code as two digits, from 01 66 66 * to 16, and press the hand icon again. 67 - * 67 + * 68 68 * The timing can be a little tricky. Try loading the module with debug=1 69 69 * to have the kernel print out messages about the remote control number 70 70 * and mask. Note: debugging prints remote numbers as zero-based hexadecimal. 71 71 * 72 72 * The driver has a "channel_mask" parameter. This bitmask specifies which 73 - * channels will be ignored by the module. To mask out channels, just add 73 + * channels will be ignored by the module. To mask out channels, just add 74 74 * all the 2^channel_number values together. 75 75 * 76 76 * For instance, set channel_mask = 2^4 = 16 (binary 10000) to make ati_remote 77 - * ignore signals coming from remote controls transmitting on channel 4, but 77 + * ignore signals coming from remote controls transmitting on channel 4, but 78 78 * accept all other channels. 79 79 * 80 - * Or, set channel_mask = 65533, (0xFFFD), and all channels except 1 will be 80 + * Or, set channel_mask = 65533, (0xFFFD), and all channels except 1 will be 81 81 * ignored. 82 82 * 83 - * The default is 0 (respond to all channels). Bit 0 and bits 17-32 of this 83 + * The default is 0 (respond to all channels). Bit 0 and bits 17-32 of this 84 84 * parameter are unused. 85 85 * 86 86 */ ··· 99 99 /* 100 100 * Module and Version Information, Module Parameters 101 101 */ 102 - 103 - #define ATI_REMOTE_VENDOR_ID 0x0bc7 104 - #define ATI_REMOTE_PRODUCT_ID 0x004 105 - #define LOLA_REMOTE_PRODUCT_ID 0x002 102 + 103 + #define ATI_REMOTE_VENDOR_ID 0x0bc7 104 + #define ATI_REMOTE_PRODUCT_ID 0x004 105 + #define LOLA_REMOTE_PRODUCT_ID 0x002 106 106 #define MEDION_REMOTE_PRODUCT_ID 0x006 107 107 108 - #define DRIVER_VERSION "2.2.1" 108 + #define DRIVER_VERSION "2.2.1" 109 109 #define DRIVER_AUTHOR "Torrey Hoffman <thoffman@arnor.net>" 110 110 #define DRIVER_DESC "ATI/X10 RF USB Remote Control" 111 111 ··· 113 113 #define DATA_BUFSIZE 63 /* size of URB data buffers */ 114 114 #define ATI_INPUTNUM 1 /* Which input device to register as */ 115 115 116 - static unsigned long channel_mask = 0; 116 + static unsigned long channel_mask; 117 117 module_param(channel_mask, ulong, 0444); 118 118 MODULE_PARM_DESC(channel_mask, "Bitmask of remote control channels to ignore"); 119 119 120 - static int debug = 0; 120 + static int debug; 121 121 module_param(debug, int, 0444); 122 122 MODULE_PARM_DESC(debug, "Enable extra debug messages and information"); 123 123 124 124 #define dbginfo(dev, format, arg...) do { if (debug) dev_info(dev , format , ## arg); } while (0) 125 125 #undef err 126 126 #define err(format, arg...) printk(KERN_ERR format , ## arg) 127 - 127 + 128 128 static struct usb_device_id ati_remote_table[] = { 129 129 { USB_DEVICE(ATI_REMOTE_VENDOR_ID, ATI_REMOTE_PRODUCT_ID) }, 130 130 { USB_DEVICE(ATI_REMOTE_VENDOR_ID, LOLA_REMOTE_PRODUCT_ID) }, ··· 148 148 /* Acceleration curve for directional control pad */ 149 149 static char accel[] = { 1, 2, 4, 6, 9, 13, 20 }; 150 150 151 - /* Duplicate event filtering time. 151 + /* Duplicate event filtering time. 152 152 * Sequential, identical KIND_FILTERED inputs with less than 153 153 * FILTER_TIME jiffies between them are considered as repeat 154 154 * events. The hardware generates 5 events for the first keypress ··· 161 161 static DECLARE_MUTEX(disconnect_sem); 162 162 163 163 struct ati_remote { 164 - struct input_dev idev; 164 + struct input_dev idev; 165 165 struct usb_device *udev; 166 166 struct usb_interface *interface; 167 - 167 + 168 168 struct urb *irq_urb; 169 169 struct urb *out_urb; 170 170 struct usb_endpoint_descriptor *endpoint_in; ··· 174 174 dma_addr_t inbuf_dma; 175 175 dma_addr_t outbuf_dma; 176 176 177 - int open; /* open counter */ 178 - 179 177 unsigned char old_data[2]; /* Detect duplicate events */ 180 178 unsigned long old_jiffies; 181 179 unsigned long acc_jiffies; /* handle acceleration */ 182 180 unsigned int repeat_count; 183 - 181 + 184 182 char name[NAME_BUFSIZE]; 185 183 char phys[NAME_BUFSIZE]; 186 184 ··· 204 206 int type; 205 207 unsigned int code; 206 208 int value; 207 - } ati_remote_tbl[] = 209 + } ati_remote_tbl[] = 208 210 { 209 211 /* Directional control pad axes */ 210 212 {KIND_ACCEL, 0x35, 0x70, EV_REL, REL_X, -1}, /* left */ 211 213 {KIND_ACCEL, 0x36, 0x71, EV_REL, REL_X, 1}, /* right */ 212 214 {KIND_ACCEL, 0x37, 0x72, EV_REL, REL_Y, -1}, /* up */ 213 215 {KIND_ACCEL, 0x38, 0x73, EV_REL, REL_Y, 1}, /* down */ 214 - /* Directional control pad diagonals */ 216 + /* Directional control pad diagonals */ 215 217 {KIND_LU, 0x39, 0x74, EV_REL, 0, 0}, /* left up */ 216 218 {KIND_RU, 0x3a, 0x75, EV_REL, 0, 0}, /* right up */ 217 219 {KIND_LD, 0x3c, 0x77, EV_REL, 0, 0}, /* left down */ ··· 223 225 {KIND_LITERAL, 0x41, 0x7c, EV_KEY, BTN_RIGHT, 1},/* right btn down */ 224 226 {KIND_LITERAL, 0x42, 0x7d, EV_KEY, BTN_RIGHT, 0},/* right btn up */ 225 227 226 - /* Artificial "doubleclick" events are generated by the hardware. 228 + /* Artificial "doubleclick" events are generated by the hardware. 227 229 * They are mapped to the "side" and "extra" mouse buttons here. */ 228 230 {KIND_FILTERED, 0x3f, 0x7a, EV_KEY, BTN_SIDE, 1}, /* left dblclick */ 229 231 {KIND_FILTERED, 0x43, 0x7e, EV_KEY, BTN_EXTRA, 1},/* right dblclick */ ··· 271 273 {KIND_FILTERED, 0xea, 0x25, EV_KEY, KEY_PLAY, 1}, /* ( >) */ 272 274 {KIND_FILTERED, 0xe9, 0x24, EV_KEY, KEY_REWIND, 1}, /* (<<) */ 273 275 {KIND_FILTERED, 0xeb, 0x26, EV_KEY, KEY_FORWARD, 1}, /* (>>) */ 274 - {KIND_FILTERED, 0xed, 0x28, EV_KEY, KEY_STOP, 1}, /* ([]) */ 276 + {KIND_FILTERED, 0xed, 0x28, EV_KEY, KEY_STOP, 1}, /* ([]) */ 275 277 {KIND_FILTERED, 0xee, 0x29, EV_KEY, KEY_PAUSE, 1}, /* ('') */ 276 278 {KIND_FILTERED, 0xf0, 0x2b, EV_KEY, KEY_PREVIOUS, 1}, /* (<-) */ 277 279 {KIND_FILTERED, 0xef, 0x2a, EV_KEY, KEY_NEXT, 1}, /* (>+) */ 278 280 {KIND_FILTERED, 0xf2, 0x2D, EV_KEY, KEY_INFO, 1}, /* PLAYING */ 279 281 {KIND_FILTERED, 0xf3, 0x2E, EV_KEY, KEY_HOME, 1}, /* TOP */ 280 282 {KIND_FILTERED, 0xf4, 0x2F, EV_KEY, KEY_END, 1}, /* END */ 281 - {KIND_FILTERED, 0xf5, 0x30, EV_KEY, KEY_SELECT, 1}, /* SELECT */ 282 - 283 + {KIND_FILTERED, 0xf5, 0x30, EV_KEY, KEY_SELECT, 1}, /* SELECT */ 284 + 283 285 {KIND_END, 0x00, 0x00, EV_MAX + 1, 0, 0} 284 286 }; 285 287 ··· 313 315 if ((len == 1) && (data[0] != (unsigned char)0xff) && (data[0] != 0x00)) 314 316 warn("Weird byte 0x%02x", data[0]); 315 317 else if (len == 4) 316 - warn("Weird key %02x %02x %02x %02x", 318 + warn("Weird key %02x %02x %02x %02x", 317 319 data[0], data[1], data[2], data[3]); 318 320 else 319 321 warn("Weird data, len=%d %02x %02x %02x %02x %02x %02x ...", ··· 326 328 static int ati_remote_open(struct input_dev *inputdev) 327 329 { 328 330 struct ati_remote *ati_remote = inputdev->private; 329 - int retval = 0; 330 - 331 - down(&disconnect_sem); 332 - 333 - if (ati_remote->open++) 334 - goto exit; 335 331 336 332 /* On first open, submit the read urb which was set up previously. */ 337 333 ati_remote->irq_urb->dev = ati_remote->udev; 338 334 if (usb_submit_urb(ati_remote->irq_urb, GFP_KERNEL)) { 339 - dev_err(&ati_remote->interface->dev, 335 + dev_err(&ati_remote->interface->dev, 340 336 "%s: usb_submit_urb failed!\n", __FUNCTION__); 341 - ati_remote->open--; 342 - retval = -EIO; 337 + return -EIO; 343 338 } 344 339 345 - exit: 346 - up(&disconnect_sem); 347 - return retval; 340 + return 0; 348 341 } 349 342 350 343 /* ··· 344 355 static void ati_remote_close(struct input_dev *inputdev) 345 356 { 346 357 struct ati_remote *ati_remote = inputdev->private; 347 - 348 - if (!--ati_remote->open) 349 - usb_kill_urb(ati_remote->irq_urb); 358 + 359 + usb_kill_urb(ati_remote->irq_urb); 350 360 } 351 361 352 362 /* ··· 354 366 static void ati_remote_irq_out(struct urb *urb, struct pt_regs *regs) 355 367 { 356 368 struct ati_remote *ati_remote = urb->context; 357 - 369 + 358 370 if (urb->status) { 359 371 dev_dbg(&ati_remote->interface->dev, "%s: status %d\n", 360 372 __FUNCTION__, urb->status); 361 373 return; 362 374 } 363 - 375 + 364 376 ati_remote->send_flags |= SEND_FLAG_COMPLETE; 365 377 wmb(); 366 378 wake_up(&ati_remote->wait); ··· 368 380 369 381 /* 370 382 * ati_remote_sendpacket 371 - * 383 + * 372 384 * Used to send device initialization strings 373 385 */ 374 386 static int ati_remote_sendpacket(struct ati_remote *ati_remote, u16 cmd, unsigned char *data) 375 387 { 376 388 int retval = 0; 377 - 389 + 378 390 /* Set up out_urb */ 379 391 memcpy(ati_remote->out_urb->transfer_buffer + 1, data, LO(cmd)); 380 - ((char *) ati_remote->out_urb->transfer_buffer)[0] = HI(cmd); 392 + ((char *) ati_remote->out_urb->transfer_buffer)[0] = HI(cmd); 381 393 382 394 ati_remote->out_urb->transfer_buffer_length = LO(cmd) + 1; 383 395 ati_remote->out_urb->dev = ati_remote->udev; ··· 385 397 386 398 retval = usb_submit_urb(ati_remote->out_urb, GFP_ATOMIC); 387 399 if (retval) { 388 - dev_dbg(&ati_remote->interface->dev, 400 + dev_dbg(&ati_remote->interface->dev, 389 401 "sendpacket: usb_submit_urb failed: %d\n", retval); 390 402 return retval; 391 403 } 392 404 393 405 wait_event_timeout(ati_remote->wait, 394 406 ((ati_remote->out_urb->status != -EINPROGRESS) || 395 - (ati_remote->send_flags & SEND_FLAG_COMPLETE)), 407 + (ati_remote->send_flags & SEND_FLAG_COMPLETE)), 396 408 HZ); 397 409 usb_kill_urb(ati_remote->out_urb); 398 - 410 + 399 411 return retval; 400 412 } 401 413 ··· 407 419 int i; 408 420 409 421 for (i = 0; ati_remote_tbl[i].kind != KIND_END; i++) { 410 - /* 411 - * Decide if the table entry matches the remote input. 422 + /* 423 + * Decide if the table entry matches the remote input. 412 424 */ 413 425 if ((((ati_remote_tbl[i].data1 & 0x0f) == (d1 & 0x0f))) && 414 - ((((ati_remote_tbl[i].data1 >> 4) - 415 - (d1 >> 4) + rem) & 0x0f) == 0x0f) && 426 + ((((ati_remote_tbl[i].data1 >> 4) - 427 + (d1 >> 4) + rem) & 0x0f) == 0x0f) && 416 428 (ati_remote_tbl[i].data2 == d2)) 417 429 return i; 418 - 430 + 419 431 } 420 432 return -1; 421 433 } ··· 423 435 /* 424 436 * ati_remote_report_input 425 437 */ 426 - static void ati_remote_input_report(struct urb *urb, struct pt_regs *regs) 438 + static void ati_remote_input_report(struct urb *urb, struct pt_regs *regs) 427 439 { 428 440 struct ati_remote *ati_remote = urb->context; 429 441 unsigned char *data= ati_remote->inbuf; 430 - struct input_dev *dev = &ati_remote->idev; 442 + struct input_dev *dev = &ati_remote->idev; 431 443 int index, acc; 432 444 int remote_num; 433 - 445 + 434 446 /* Deal with strange looking inputs */ 435 - if ( (urb->actual_length != 4) || (data[0] != 0x14) || 447 + if ( (urb->actual_length != 4) || (data[0] != 0x14) || 436 448 ((data[3] & 0x0f) != 0x00) ) { 437 449 ati_remote_dump(data, urb->actual_length); 438 450 return; ··· 441 453 /* Mask unwanted remote channels. */ 442 454 /* note: remote_num is 0-based, channel 1 on remote == 0 here */ 443 455 remote_num = (data[3] >> 4) & 0x0f; 444 - if (channel_mask & (1 << (remote_num + 1))) { 456 + if (channel_mask & (1 << (remote_num + 1))) { 445 457 dbginfo(&ati_remote->interface->dev, 446 458 "Masked input from channel 0x%02x: data %02x,%02x, mask= 0x%02lx\n", 447 459 remote_num, data[1], data[2], channel_mask); ··· 451 463 /* Look up event code index in translation table */ 452 464 index = ati_remote_event_lookup(remote_num, data[1], data[2]); 453 465 if (index < 0) { 454 - dev_warn(&ati_remote->interface->dev, 455 - "Unknown input from channel 0x%02x: data %02x,%02x\n", 466 + dev_warn(&ati_remote->interface->dev, 467 + "Unknown input from channel 0x%02x: data %02x,%02x\n", 456 468 remote_num, data[1], data[2]); 457 469 return; 458 - } 459 - dbginfo(&ati_remote->interface->dev, 470 + } 471 + dbginfo(&ati_remote->interface->dev, 460 472 "channel 0x%02x; data %02x,%02x; index %d; keycode %d\n", 461 473 remote_num, data[1], data[2], index, ati_remote_tbl[index].code); 462 - 474 + 463 475 if (ati_remote_tbl[index].kind == KIND_LITERAL) { 464 476 input_regs(dev, regs); 465 477 input_event(dev, ati_remote_tbl[index].type, 466 478 ati_remote_tbl[index].code, 467 479 ati_remote_tbl[index].value); 468 480 input_sync(dev); 469 - 481 + 470 482 ati_remote->old_jiffies = jiffies; 471 483 return; 472 484 } 473 - 485 + 474 486 if (ati_remote_tbl[index].kind == KIND_FILTERED) { 475 487 /* Filter duplicate events which happen "too close" together. */ 476 - if ((ati_remote->old_data[0] == data[1]) && 477 - (ati_remote->old_data[1] == data[2]) && 478 - ((ati_remote->old_jiffies + FILTER_TIME) > jiffies)) { 488 + if ((ati_remote->old_data[0] == data[1]) && 489 + (ati_remote->old_data[1] == data[2]) && 490 + ((ati_remote->old_jiffies + FILTER_TIME) > jiffies)) { 479 491 ati_remote->repeat_count++; 480 - } 481 - else { 492 + } else { 482 493 ati_remote->repeat_count = 0; 483 494 } 484 - 495 + 485 496 ati_remote->old_data[0] = data[1]; 486 497 ati_remote->old_data[1] = data[2]; 487 498 ati_remote->old_jiffies = jiffies; ··· 488 501 if ((ati_remote->repeat_count > 0) 489 502 && (ati_remote->repeat_count < 5)) 490 503 return; 491 - 504 + 492 505 493 506 input_regs(dev, regs); 494 507 input_event(dev, ati_remote_tbl[index].type, ··· 498 511 input_sync(dev); 499 512 500 513 return; 501 - } 502 - 503 - /* 514 + } 515 + 516 + /* 504 517 * Other event kinds are from the directional control pad, and have an 505 518 * acceleration factor applied to them. Without this acceleration, the 506 519 * control pad is mostly unusable. 507 - * 520 + * 508 521 * If elapsed time since last event is > 1/4 second, user "stopped", 509 522 * so reset acceleration. Otherwise, user is probably holding the control 510 523 * pad down, so we increase acceleration, ramping up over two seconds to ··· 546 559 input_report_rel(dev, REL_Y, acc); 547 560 break; 548 561 default: 549 - dev_dbg(&ati_remote->interface->dev, "ati_remote kind=%d\n", 562 + dev_dbg(&ati_remote->interface->dev, "ati_remote kind=%d\n", 550 563 ati_remote_tbl[index].kind); 551 564 } 552 565 input_sync(dev); ··· 573 586 case -ESHUTDOWN: 574 587 dev_dbg(&ati_remote->interface->dev, "%s: urb error status, unlink? \n", 575 588 __FUNCTION__); 576 - return; 589 + return; 577 590 default: /* error */ 578 - dev_dbg(&ati_remote->interface->dev, "%s: Nonzero urb status %d\n", 591 + dev_dbg(&ati_remote->interface->dev, "%s: Nonzero urb status %d\n", 579 592 __FUNCTION__, urb->status); 580 593 } 581 - 594 + 582 595 retval = usb_submit_urb(urb, SLAB_ATOMIC); 583 596 if (retval) 584 597 dev_err(&ati_remote->interface->dev, "%s: usb_submit_urb()=%d\n", ··· 590 603 */ 591 604 static void ati_remote_delete(struct ati_remote *ati_remote) 592 605 { 593 - if (!ati_remote) return; 594 - 595 606 if (ati_remote->irq_urb) 596 607 usb_kill_urb(ati_remote->irq_urb); 597 608 ··· 599 614 input_unregister_device(&ati_remote->idev); 600 615 601 616 if (ati_remote->inbuf) 602 - usb_buffer_free(ati_remote->udev, DATA_BUFSIZE, 617 + usb_buffer_free(ati_remote->udev, DATA_BUFSIZE, 603 618 ati_remote->inbuf, ati_remote->inbuf_dma); 604 - 619 + 605 620 if (ati_remote->outbuf) 606 - usb_buffer_free(ati_remote->udev, DATA_BUFSIZE, 621 + usb_buffer_free(ati_remote->udev, DATA_BUFSIZE, 607 622 ati_remote->outbuf, ati_remote->outbuf_dma); 608 - 623 + 609 624 if (ati_remote->irq_urb) 610 625 usb_free_urb(ati_remote->irq_urb); 611 - 626 + 612 627 if (ati_remote->out_urb) 613 628 usb_free_urb(ati_remote->out_urb); 614 629 ··· 621 636 int i; 622 637 623 638 idev->evbit[0] = BIT(EV_KEY) | BIT(EV_REL); 624 - idev->keybit[LONG(BTN_MOUSE)] = ( BIT(BTN_LEFT) | BIT(BTN_RIGHT) | 639 + idev->keybit[LONG(BTN_MOUSE)] = ( BIT(BTN_LEFT) | BIT(BTN_RIGHT) | 625 640 BIT(BTN_SIDE) | BIT(BTN_EXTRA) ); 626 641 idev->relbit[0] = BIT(REL_X) | BIT(REL_Y); 627 642 for (i = 0; ati_remote_tbl[i].kind != KIND_END; i++) 628 643 if (ati_remote_tbl[i].type == EV_KEY) 629 644 set_bit(ati_remote_tbl[i].code, idev->keybit); 630 - 645 + 631 646 idev->private = ati_remote; 632 647 idev->open = ati_remote_open; 633 648 idev->close = ati_remote_close; 634 - 649 + 635 650 idev->name = ati_remote->name; 636 651 idev->phys = ati_remote->phys; 637 - 638 - idev->id.bustype = BUS_USB; 652 + 653 + idev->id.bustype = BUS_USB; 639 654 idev->id.vendor = le16_to_cpu(ati_remote->udev->descriptor.idVendor); 640 655 idev->id.product = le16_to_cpu(ati_remote->udev->descriptor.idProduct); 641 656 idev->id.version = le16_to_cpu(ati_remote->udev->descriptor.bcdDevice); ··· 645 660 { 646 661 struct usb_device *udev = ati_remote->udev; 647 662 int pipe, maxp; 648 - 663 + 649 664 init_waitqueue_head(&ati_remote->wait); 650 665 651 666 /* Set up irq_urb */ 652 667 pipe = usb_rcvintpipe(udev, ati_remote->endpoint_in->bEndpointAddress); 653 668 maxp = usb_maxpacket(udev, pipe, usb_pipeout(pipe)); 654 669 maxp = (maxp > DATA_BUFSIZE) ? DATA_BUFSIZE : maxp; 655 - 656 - usb_fill_int_urb(ati_remote->irq_urb, udev, pipe, ati_remote->inbuf, 657 - maxp, ati_remote_irq_in, ati_remote, 670 + 671 + usb_fill_int_urb(ati_remote->irq_urb, udev, pipe, ati_remote->inbuf, 672 + maxp, ati_remote_irq_in, ati_remote, 658 673 ati_remote->endpoint_in->bInterval); 659 674 ati_remote->irq_urb->transfer_dma = ati_remote->inbuf_dma; 660 675 ati_remote->irq_urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; 661 - 676 + 662 677 /* Set up out_urb */ 663 678 pipe = usb_sndintpipe(udev, ati_remote->endpoint_out->bEndpointAddress); 664 679 maxp = usb_maxpacket(udev, pipe, usb_pipeout(pipe)); 665 680 maxp = (maxp > DATA_BUFSIZE) ? DATA_BUFSIZE : maxp; 666 681 667 - usb_fill_int_urb(ati_remote->out_urb, udev, pipe, ati_remote->outbuf, 668 - maxp, ati_remote_irq_out, ati_remote, 682 + usb_fill_int_urb(ati_remote->out_urb, udev, pipe, ati_remote->outbuf, 683 + maxp, ati_remote_irq_out, ati_remote, 669 684 ati_remote->endpoint_out->bInterval); 670 685 ati_remote->out_urb->transfer_dma = ati_remote->outbuf_dma; 671 686 ati_remote->out_urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; ··· 673 688 /* send initialization strings */ 674 689 if ((ati_remote_sendpacket(ati_remote, 0x8004, init1)) || 675 690 (ati_remote_sendpacket(ati_remote, 0x8007, init2))) { 676 - dev_err(&ati_remote->interface->dev, 691 + dev_err(&ati_remote->interface->dev, 677 692 "Initializing ati_remote hardware failed.\n"); 678 693 return 1; 679 694 } 680 - 695 + 681 696 return 0; 682 697 } 683 698 ··· 754 769 755 770 if (!strlen(ati_remote->name)) 756 771 sprintf(ati_remote->name, DRIVER_DESC "(%04x,%04x)", 757 - le16_to_cpu(ati_remote->udev->descriptor.idVendor), 772 + le16_to_cpu(ati_remote->udev->descriptor.idVendor), 758 773 le16_to_cpu(ati_remote->udev->descriptor.idProduct)); 759 774 760 775 /* Device Hardware Initialization - fills in ati_remote->idev from udev. */ ··· 766 781 ati_remote_input_init(ati_remote); 767 782 input_register_device(&ati_remote->idev); 768 783 769 - dev_info(&ati_remote->interface->dev, "Input registered: %s on %s\n", 784 + dev_info(&ati_remote->interface->dev, "Input registered: %s on %s\n", 770 785 ati_remote->name, path); 771 786 772 787 usb_set_intfdata(interface, ati_remote); 773 - 788 + 774 789 error: 775 790 if (retval) 776 791 ati_remote_delete(ati_remote); ··· 785 800 { 786 801 struct ati_remote *ati_remote; 787 802 788 - down(&disconnect_sem); 789 - 790 803 ati_remote = usb_get_intfdata(interface); 791 804 usb_set_intfdata(interface, NULL); 792 805 if (!ati_remote) { 793 806 warn("%s - null device?\n", __FUNCTION__); 794 807 return; 795 808 } 796 - 797 - ati_remote_delete(ati_remote); 798 809 799 - up(&disconnect_sem); 810 + ati_remote_delete(ati_remote); 800 811 } 801 812 802 813 /* ··· 801 820 static int __init ati_remote_init(void) 802 821 { 803 822 int result; 804 - 823 + 805 824 result = usb_register(&ati_remote_driver); 806 825 if (result) 807 826 err("usb_register error #%d\n", result); ··· 819 838 usb_deregister(&ati_remote_driver); 820 839 } 821 840 822 - /* 823 - * module specification 841 + /* 842 + * module specification 824 843 */ 825 844 826 845 module_init(ati_remote_init);
+19 -7
drivers/usb/input/hid-core.c
··· 232 232 report->size += parser->global.report_size * parser->global.report_count; 233 233 234 234 if (!parser->local.usage_index) /* Ignore padding fields */ 235 - return 0; 235 + return 0; 236 236 237 237 usages = max_t(int, parser->local.usage_index, parser->global.report_count); 238 238 ··· 765 765 static __inline__ __u32 extract(__u8 *report, unsigned offset, unsigned n) 766 766 { 767 767 report += (offset >> 5) << 2; offset &= 31; 768 - return (le64_to_cpu(get_unaligned((__le64*)report)) >> offset) & ((1 << n) - 1); 768 + return (le64_to_cpu(get_unaligned((__le64*)report)) >> offset) & ((1ULL << n) - 1); 769 769 } 770 770 771 771 static __inline__ void implement(__u8 *report, unsigned offset, unsigned n, __u32 value) ··· 1233 1233 return 0; 1234 1234 } 1235 1235 1236 + static int hid_set_idle(struct usb_device *dev, int ifnum, int report, int idle) 1237 + { 1238 + return usb_control_msg(dev, usb_sndctrlpipe(dev, 0), 1239 + HID_REQ_SET_IDLE, USB_TYPE_CLASS | USB_RECIP_INTERFACE, (idle << 8) | report, 1240 + ifnum, NULL, 0, USB_CTRL_SET_TIMEOUT); 1241 + } 1242 + 1236 1243 static int hid_get_class_descriptor(struct usb_device *dev, int ifnum, 1237 1244 unsigned char type, void *buf, int size) 1238 1245 { ··· 1308 1301 1309 1302 if (err) 1310 1303 warn("timeout initializing reports\n"); 1311 - 1312 - usb_control_msg(hid->dev, usb_sndctrlpipe(hid->dev, 0), 1313 - HID_REQ_SET_IDLE, USB_TYPE_CLASS | USB_RECIP_INTERFACE, 0, 1314 - hid->ifnum, NULL, 0, USB_CTRL_SET_TIMEOUT); 1315 1304 } 1316 1305 1317 1306 #define USB_VENDOR_ID_WACOM 0x056a ··· 1320 1317 #define USB_DEVICE_ID_WACOM_PTU 0x0003 1321 1318 #define USB_DEVICE_ID_WACOM_INTUOS3 0x00B0 1322 1319 #define USB_DEVICE_ID_WACOM_CINTIQ 0x003F 1320 + 1321 + #define USB_VENDOR_ID_ACECAD 0x0460 1322 + #define USB_DEVICE_ID_ACECAD_FLAIR 0x0004 1323 + #define USB_DEVICE_ID_ACECAD_302 0x0008 1323 1324 1324 1325 #define USB_VENDOR_ID_KBGEAR 0x084e 1325 1326 #define USB_DEVICE_ID_KBGEAR_JAMSTUDIO 0x1001 ··· 1509 1502 { USB_VENDOR_ID_WISEGROUP, USB_DEVICE_ID_4_PHIDGETSERVO_20, HID_QUIRK_IGNORE }, 1510 1503 { USB_VENDOR_ID_WISEGROUP, USB_DEVICE_ID_1_PHIDGETSERVO_20, HID_QUIRK_IGNORE }, 1511 1504 1505 + { USB_VENDOR_ID_ACECAD, USB_DEVICE_ID_ACECAD_FLAIR, HID_QUIRK_IGNORE }, 1506 + { USB_VENDOR_ID_ACECAD, USB_DEVICE_ID_ACECAD_302, HID_QUIRK_IGNORE }, 1507 + 1512 1508 { USB_VENDOR_ID_ATEN, USB_DEVICE_ID_ATEN_UC100KM, HID_QUIRK_NOGET }, 1513 1509 { USB_VENDOR_ID_ATEN, USB_DEVICE_ID_ATEN_CS124U, HID_QUIRK_NOGET }, 1514 1510 { USB_VENDOR_ID_ATEN, USB_DEVICE_ID_ATEN_2PORTKVM, HID_QUIRK_NOGET }, ··· 1600 1590 return NULL; 1601 1591 } 1602 1592 1593 + hid_set_idle(dev, interface->desc.bInterfaceNumber, 0, 0); 1594 + 1603 1595 if ((n = hid_get_class_descriptor(dev, interface->desc.bInterfaceNumber, HID_DT_REPORT, rdesc, rsize)) < 0) { 1604 1596 dbg("reading report descriptor failed"); 1605 1597 kfree(rdesc); ··· 1647 1635 /* Change the polling interval of mice. */ 1648 1636 if (hid->collection->usage == HID_GD_MOUSE && hid_mousepoll_interval > 0) 1649 1637 interval = hid_mousepoll_interval; 1650 - 1638 + 1651 1639 if (endpoint->bEndpointAddress & USB_DIR_IN) { 1652 1640 if (hid->urbin) 1653 1641 continue;
+8 -8
drivers/usb/input/hid-debug.h
··· 67 67 {0, 0x44, "Vbry"}, 68 68 {0, 0x45, "Vbrz"}, 69 69 {0, 0x46, "Vno"}, 70 - {0, 0x80, "SystemControl"}, 70 + {0, 0x80, "SystemControl"}, 71 71 {0, 0x81, "SystemPowerDown"}, 72 72 {0, 0x82, "SystemSleep"}, 73 73 {0, 0x83, "SystemWakeUp"}, ··· 347 347 348 348 static void hid_dump_field(struct hid_field *field, int n) { 349 349 int j; 350 - 350 + 351 351 if (field->physical) { 352 352 tab(n); 353 353 printk("Physical("); ··· 408 408 printk("%s", units[sys][i]); 409 409 if(nibble != 1) { 410 410 /* This is a _signed_ nibble(!) */ 411 - 411 + 412 412 int val = nibble & 0x7; 413 413 if(nibble & 0x08) 414 414 val = -((0x7 & ~val) +1); ··· 443 443 struct list_head *list; 444 444 unsigned i,k; 445 445 static char *table[] = {"INPUT", "OUTPUT", "FEATURE"}; 446 - 446 + 447 447 for (i = 0; i < HID_REPORT_TYPES; i++) { 448 448 report_enum = device->report_enum + i; 449 449 list = report_enum->report_list.next; ··· 664 664 static char *relatives[REL_MAX + 1] = { 665 665 [REL_X] = "X", [REL_Y] = "Y", 666 666 [REL_Z] = "Z", [REL_HWHEEL] = "HWheel", 667 - [REL_DIAL] = "Dial", [REL_WHEEL] = "Wheel", 668 - [REL_MISC] = "Misc", 667 + [REL_DIAL] = "Dial", [REL_WHEEL] = "Wheel", 668 + [REL_MISC] = "Misc", 669 669 }; 670 670 671 671 static char *absolutes[ABS_MAX + 1] = { ··· 690 690 }; 691 691 692 692 static char *leds[LED_MAX + 1] = { 693 - [LED_NUML] = "NumLock", [LED_CAPSL] = "CapsLock", 693 + [LED_NUML] = "NumLock", [LED_CAPSL] = "CapsLock", 694 694 [LED_SCROLLL] = "ScrollLock", [LED_COMPOSE] = "Compose", 695 - [LED_KANA] = "Kana", [LED_SLEEP] = "Sleep", 695 + [LED_KANA] = "Kana", [LED_SLEEP] = "Sleep", 696 696 [LED_SUSPEND] = "Suspend", [LED_MUTE] = "Mute", 697 697 [LED_MISC] = "Misc", 698 698 };
+8 -8
drivers/usb/input/hid-input.c
··· 164 164 case HID_GD_X: case HID_GD_Y: case HID_GD_Z: 165 165 case HID_GD_RX: case HID_GD_RY: case HID_GD_RZ: 166 166 case HID_GD_SLIDER: case HID_GD_DIAL: case HID_GD_WHEEL: 167 - if (field->flags & HID_MAIN_ITEM_RELATIVE) 167 + if (field->flags & HID_MAIN_ITEM_RELATIVE) 168 168 map_rel(usage->hid & 0xf); 169 169 else 170 170 map_abs(usage->hid & 0xf); ··· 297 297 case HID_UP_MSVENDOR: 298 298 299 299 goto ignore; 300 - 300 + 301 301 case HID_UP_PID: 302 302 303 303 set_bit(EV_FF, input->evbit); ··· 349 349 goto ignore; 350 350 351 351 if ((device->quirks & (HID_QUIRK_2WHEEL_MOUSE_HACK_7 | HID_QUIRK_2WHEEL_MOUSE_HACK_5)) && 352 - (usage->type == EV_REL) && (usage->code == REL_WHEEL)) 352 + (usage->type == EV_REL) && (usage->code == REL_WHEEL)) 353 353 set_bit(REL_HWHEEL, bit); 354 354 355 355 if (((device->quirks & HID_QUIRK_2WHEEL_MOUSE_HACK_5) && (usage->hid == 0x00090005)) ··· 365 365 a = field->logical_minimum = 0; 366 366 b = field->logical_maximum = 255; 367 367 } 368 - 368 + 369 369 if (field->application == HID_GD_GAMEPAD || field->application == HID_GD_JOYSTICK) 370 370 input_set_abs_params(input, usage->code, a, b, (b - a) >> 8, (b - a) >> 4); 371 371 else input_set_abs_params(input, usage->code, a, b, 0, 0); 372 - 372 + 373 373 } 374 374 375 375 if (usage->hat_min < usage->hat_max || usage->hat_dir) { ··· 420 420 return; 421 421 } 422 422 423 - if (usage->hat_min < usage->hat_max || usage->hat_dir) { 423 + if (usage->hat_min < usage->hat_max || usage->hat_dir) { 424 424 int hat_dir = usage->hat_dir; 425 425 if (!hat_dir) 426 426 hat_dir = (value - usage->hat_min) * 8 / (usage->hat_max - usage->hat_min + 1) + 1; ··· 551 551 for (i = 0; i < hid->maxcollection; i++) 552 552 if (hid->collection[i].type == HID_COLLECTION_APPLICATION || 553 553 hid->collection[i].type == HID_COLLECTION_PHYSICAL) 554 - if (IS_INPUT_APPLICATION(hid->collection[i].usage)) 554 + if (IS_INPUT_APPLICATION(hid->collection[i].usage)) 555 555 break; 556 556 557 557 if (i == hid->maxcollection) ··· 592 592 for (j = 0; j < report->field[i]->maxusage; j++) 593 593 hidinput_configure_usage(hidinput, report->field[i], 594 594 report->field[i]->usage + j); 595 - 595 + 596 596 if (hid->quirks & HID_QUIRK_MULTI_INPUT) { 597 597 /* This will leave hidinput NULL, so that it 598 598 * allocates another one if we have more inputs on
+9 -9
drivers/usb/input/hid-lgff.c
··· 94 94 isn't really necessary */ 95 95 96 96 unsigned long flags[1]; /* Contains various information about the 97 - state of the driver for this device */ 97 + state of the driver for this device */ 98 98 99 99 struct timer_list timer; 100 100 }; ··· 234 234 kfree(ret); 235 235 return NULL; 236 236 } 237 - memset(ret->field[0]->value, 0, sizeof(s32[8])); 237 + memset(ret->field[0]->value, 0, sizeof(s32[8])); 238 238 239 239 return ret; 240 240 } ··· 295 295 unsigned long flags; 296 296 297 297 if (type != EV_FF) return -EINVAL; 298 - if (!LGFF_CHECK_OWNERSHIP(code, lgff)) return -EACCES; 298 + if (!LGFF_CHECK_OWNERSHIP(code, lgff)) return -EACCES; 299 299 if (value < 0) return -EINVAL; 300 300 301 301 spin_lock_irqsave(&lgff->lock, flags); 302 - 302 + 303 303 if (value > 0) { 304 304 if (test_bit(EFFECT_STARTED, effect->flags)) { 305 305 spin_unlock_irqrestore(&lgff->lock, flags); ··· 345 345 and perform ioctls on the same fd all at the same time */ 346 346 if ( current->pid == lgff->effects[i].owner 347 347 && test_bit(EFFECT_USED, lgff->effects[i].flags)) { 348 - 348 + 349 349 if (hid_lgff_erase(dev, i)) 350 350 warn("erase effect %d failed", i); 351 351 } ··· 378 378 struct lgff_effect new; 379 379 int id; 380 380 unsigned long flags; 381 - 381 + 382 382 dbg("ioctl rumble"); 383 383 384 384 if (!test_bit(effect->type, input->ffbit)) return -EINVAL; ··· 441 441 442 442 spin_lock_irqsave(&lgff->lock, flags); 443 443 444 - for (i=0; i<LGFF_EFFECTS; ++i) { 444 + for (i=0; i<LGFF_EFFECTS; ++i) { 445 445 struct lgff_effect* effect = lgff->effects +i; 446 446 447 447 if (test_bit(EFFECT_PLAYING, effect->flags)) { ··· 491 491 set_bit(EFFECT_PLAYING, lgff->effects[i].flags); 492 492 } 493 493 } 494 - } 494 + } 495 495 496 496 #define CLAMP(x) if (x < 0) x = 0; if (x > 0xff) x = 0xff 497 497 ··· 524 524 add_timer(&lgff->timer); 525 525 } 526 526 527 - spin_unlock_irqrestore(&lgff->lock, flags); 527 + spin_unlock_irqrestore(&lgff->lock, flags); 528 528 }
+9 -9
drivers/usb/input/hid.h
··· 118 118 #define HID_MAIN_ITEM_CONSTANT 0x001 119 119 #define HID_MAIN_ITEM_VARIABLE 0x002 120 120 #define HID_MAIN_ITEM_RELATIVE 0x004 121 - #define HID_MAIN_ITEM_WRAP 0x008 121 + #define HID_MAIN_ITEM_WRAP 0x008 122 122 #define HID_MAIN_ITEM_NONLINEAR 0x010 123 123 #define HID_MAIN_ITEM_NO_PREFERRED 0x020 124 124 #define HID_MAIN_ITEM_NULL_STATE 0x040 ··· 172 172 #define HID_USAGE_PAGE 0xffff0000 173 173 174 174 #define HID_UP_UNDEFINED 0x00000000 175 - #define HID_UP_GENDESK 0x00010000 176 - #define HID_UP_KEYBOARD 0x00070000 177 - #define HID_UP_LED 0x00080000 178 - #define HID_UP_BUTTON 0x00090000 179 - #define HID_UP_ORDINAL 0x000a0000 175 + #define HID_UP_GENDESK 0x00010000 176 + #define HID_UP_KEYBOARD 0x00070000 177 + #define HID_UP_LED 0x00080000 178 + #define HID_UP_BUTTON 0x00090000 179 + #define HID_UP_ORDINAL 0x000a0000 180 180 #define HID_UP_CONSUMER 0x000c0000 181 - #define HID_UP_DIGITIZER 0x000d0000 182 - #define HID_UP_PID 0x000f0000 181 + #define HID_UP_DIGITIZER 0x000d0000 182 + #define HID_UP_PID 0x000f0000 183 183 #define HID_UP_HPVENDOR 0xff7f0000 184 184 #define HID_UP_MSVENDOR 0xff000000 185 185 ··· 406 406 dma_addr_t outbuf_dma; /* Output buffer dma */ 407 407 spinlock_t outlock; /* Output fifo spinlock */ 408 408 409 - unsigned claimed; /* Claimed by hidinput, hiddev? */ 409 + unsigned claimed; /* Claimed by hidinput, hiddev? */ 410 410 unsigned quirks; /* Various quirks the device can pull on us */ 411 411 412 412 struct list_head inputs; /* The list of inputs */
+28 -28
drivers/usb/input/hiddev.c
··· 95 95 return NULL; 96 96 rinfo->report_id = ((struct hid_report *) list)->id; 97 97 break; 98 - 98 + 99 99 case HID_REPORT_ID_NEXT: 100 100 list = (struct list_head *) 101 101 report_enum->report_id_hash[rinfo->report_id & HID_REPORT_ID_MASK]; ··· 106 106 return NULL; 107 107 rinfo->report_id = ((struct hid_report *) list)->id; 108 108 break; 109 - 109 + 110 110 default: 111 111 return NULL; 112 112 } ··· 158 158 if (uref->field_index != HID_FIELD_INDEX_NONE || 159 159 (list->flags & HIDDEV_FLAG_REPORT) != 0) { 160 160 list->buffer[list->head] = *uref; 161 - list->head = (list->head + 1) & 161 + list->head = (list->head + 1) & 162 162 (HIDDEV_BUFFER_SIZE - 1); 163 163 kill_fasync(&list->fasync, SIGIO, POLL_IN); 164 164 } ··· 179 179 unsigned type = field->report_type; 180 180 struct hiddev_usage_ref uref; 181 181 182 - uref.report_type = 182 + uref.report_type = 183 183 (type == HID_INPUT_REPORT) ? HID_REPORT_TYPE_INPUT : 184 - ((type == HID_OUTPUT_REPORT) ? HID_REPORT_TYPE_OUTPUT : 184 + ((type == HID_OUTPUT_REPORT) ? HID_REPORT_TYPE_OUTPUT : 185 185 ((type == HID_FEATURE_REPORT) ? HID_REPORT_TYPE_FEATURE:0)); 186 186 uref.report_id = field->report->id; 187 187 uref.field_index = field->index; ··· 199 199 struct hiddev_usage_ref uref; 200 200 201 201 memset(&uref, 0, sizeof(uref)); 202 - uref.report_type = 202 + uref.report_type = 203 203 (type == HID_INPUT_REPORT) ? HID_REPORT_TYPE_INPUT : 204 - ((type == HID_OUTPUT_REPORT) ? HID_REPORT_TYPE_OUTPUT : 204 + ((type == HID_OUTPUT_REPORT) ? HID_REPORT_TYPE_OUTPUT : 205 205 ((type == HID_FEATURE_REPORT) ? HID_REPORT_TYPE_FEATURE:0)); 206 206 uref.report_id = report->id; 207 207 uref.field_index = HID_FIELD_INDEX_NONE; ··· 236 236 *listptr = (*listptr)->next; 237 237 238 238 if (!--list->hiddev->open) { 239 - if (list->hiddev->exist) 239 + if (list->hiddev->exist) 240 240 hid_close(list->hiddev->hid); 241 241 else 242 242 kfree(list->hiddev); ··· 303 303 if (list->head == list->tail) { 304 304 add_wait_queue(&list->hiddev->wait, &wait); 305 305 set_current_state(TASK_INTERRUPTIBLE); 306 - 306 + 307 307 while (list->head == list->tail) { 308 308 if (file->f_flags & O_NONBLOCK) { 309 309 retval = -EAGAIN; ··· 317 317 retval = -EIO; 318 318 break; 319 319 } 320 - 320 + 321 321 schedule(); 322 322 } 323 323 ··· 329 329 return retval; 330 330 331 331 332 - while (list->head != list->tail && 332 + while (list->head != list->tail && 333 333 retval + event_size <= count) { 334 334 if ((list->flags & HIDDEV_FLAG_UREF) == 0) { 335 335 if (list->buffer[list->tail].field_index != ··· 405 405 return -EINVAL; 406 406 407 407 for (i = 0; i < hid->maxcollection; i++) 408 - if (hid->collection[i].type == 408 + if (hid->collection[i].type == 409 409 HID_COLLECTION_APPLICATION && arg-- == 0) 410 410 break; 411 - 411 + 412 412 if (i == hid->maxcollection) 413 413 return -EINVAL; 414 414 ··· 562 562 if (!uref_multi) 563 563 return -ENOMEM; 564 564 uref = &uref_multi->uref; 565 - if (copy_from_user(uref, user_arg, sizeof(*uref))) 565 + if (copy_from_user(uref, user_arg, sizeof(*uref))) 566 566 goto fault; 567 567 568 568 rinfo.report_type = uref->report_type; ··· 595 595 return -ENOMEM; 596 596 uref = &uref_multi->uref; 597 597 if (cmd == HIDIOCGUSAGES || cmd == HIDIOCSUSAGES) { 598 - if (copy_from_user(uref_multi, user_arg, 598 + if (copy_from_user(uref_multi, user_arg, 599 599 sizeof(*uref_multi))) 600 600 goto fault; 601 601 } else { ··· 603 603 goto fault; 604 604 } 605 605 606 - if (cmd != HIDIOCGUSAGE && 606 + if (cmd != HIDIOCGUSAGE && 607 607 cmd != HIDIOCGUSAGES && 608 608 uref->report_type == HID_REPORT_TYPE_INPUT) 609 609 goto inval; ··· 651 651 return field->usage[uref->usage_index].collection_index; 652 652 case HIDIOCGUSAGES: 653 653 for (i = 0; i < uref_multi->num_values; i++) 654 - uref_multi->values[i] = 654 + uref_multi->values[i] = 655 655 field->value[uref->usage_index + i]; 656 - if (copy_to_user(user_arg, uref_multi, 656 + if (copy_to_user(user_arg, uref_multi, 657 657 sizeof(*uref_multi))) 658 658 goto fault; 659 659 goto goodreturn; 660 660 case HIDIOCSUSAGES: 661 661 for (i = 0; i < uref_multi->num_values; i++) 662 - field->value[uref->usage_index + i] = 663 - uref_multi->values[i]; 662 + field->value[uref->usage_index + i] = 663 + uref_multi->values[i]; 664 664 goto goodreturn; 665 665 } 666 666 ··· 670 670 fault: 671 671 kfree(uref_multi); 672 672 return -EFAULT; 673 - inval: 673 + inval: 674 674 kfree(uref_multi); 675 675 return -EINVAL; 676 676 ··· 734 734 .name = "usb/hid/hiddev%d", 735 735 .fops = &hiddev_fops, 736 736 .mode = S_IFCHR | S_IRUGO | S_IWUSR, 737 - .minor_base = HIDDEV_MINOR_BASE, 737 + .minor_base = HIDDEV_MINOR_BASE, 738 738 }; 739 739 740 740 /* ··· 747 747 int retval; 748 748 749 749 for (i = 0; i < hid->maxcollection; i++) 750 - if (hid->collection[i].type == 750 + if (hid->collection[i].type == 751 751 HID_COLLECTION_APPLICATION && 752 752 !IS_INPUT_APPLICATION(hid->collection[i].usage)) 753 753 break; ··· 755 755 if (i == hid->maxcollection && (hid->quirks & HID_QUIRK_HIDDEV) == 0) 756 756 return -1; 757 757 758 - if (!(hiddev = kmalloc(sizeof(struct hiddev), GFP_KERNEL))) 758 + if (!(hiddev = kmalloc(sizeof(struct hiddev), GFP_KERNEL))) 759 759 return -1; 760 760 memset(hiddev, 0, sizeof(struct hiddev)); 761 761 762 - retval = usb_register_dev(hid->intf, &hiddev_class); 762 + retval = usb_register_dev(hid->intf, &hiddev_class); 763 763 if (retval) { 764 764 err("Not able to get a minor for this device."); 765 765 kfree(hiddev); ··· 768 768 769 769 init_waitqueue_head(&hiddev->wait); 770 770 771 - hiddev_table[hid->intf->minor - HIDDEV_MINOR_BASE] = hiddev; 771 + hiddev_table[hid->intf->minor - HIDDEV_MINOR_BASE] = hiddev; 772 772 773 773 hiddev->hid = hid; 774 774 hiddev->exist = 1; 775 775 776 - hid->minor = hid->intf->minor; 776 + hid->minor = hid->intf->minor; 777 777 hid->hiddev = hiddev; 778 778 779 779 return 0; ··· 818 818 /* We never attach in this manner, and rely on HID to connect us. This 819 819 * is why there is no disconnect routine defined in the usb_driver either. 820 820 */ 821 - static int hiddev_usbd_probe(struct usb_interface *intf, 821 + static int hiddev_usbd_probe(struct usb_interface *intf, 822 822 const struct usb_device_id *hiddev_info) 823 823 { 824 824 return -ENODEV;
+268
drivers/usb/input/itmtouch.c
··· 1 + /****************************************************************************** 2 + * itmtouch.c -- Driver for ITM touchscreen panel 3 + * 4 + * This program is free software; you can redistribute it and/or 5 + * modify it under the terms of the GNU General Public License as 6 + * published by the Free Software Foundation; either version 2 of the 7 + * License, or (at your option) any later version. 8 + * 9 + * This program is distributed in the hope that it will be useful, but 10 + * WITHOUT ANY WARRANTY; without even the implied warranty of 11 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 + * General Public License for more details. 13 + * 14 + * You should have received a copy of the GNU General Public License 15 + * along with this program; if not, write to the Free Software 16 + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 + * 18 + * Based upon original work by Chris Collins <xfire-itmtouch@xware.cx>. 19 + * 20 + * Kudos to ITM for providing me with the datasheet for the panel, 21 + * even though it was a day later than I had finished writing this 22 + * driver. 23 + * 24 + * It has meant that I've been able to correct my interpretation of the 25 + * protocol packets however. 26 + * 27 + * CC -- 2003/9/29 28 + * 29 + * History 30 + * 1.0 & 1.1 2003 (CC) vojtech@suse.cz 31 + * Original version for 2.4.x kernels 32 + * 33 + * 1.2 02/03/2005 (HCE) hc@mivu.no 34 + * Complete rewrite to support Linux 2.6.10, thanks to mtouchusb.c for hints. 35 + * Unfortunately no calibration support at this time. 36 + * 37 + * 1.2.1 09/03/2005 (HCE) hc@mivu.no 38 + * Code cleanup and adjusting syntax to start matching kernel standards 39 + * 40 + *****************************************************************************/ 41 + 42 + #include <linux/config.h> 43 + 44 + #ifdef CONFIG_USB_DEBUG 45 + #define DEBUG 46 + #else 47 + #undef DEBUG 48 + #endif 49 + 50 + #include <linux/kernel.h> 51 + #include <linux/slab.h> 52 + #include <linux/input.h> 53 + #include <linux/module.h> 54 + #include <linux/init.h> 55 + #include <linux/usb.h> 56 + 57 + /* only an 8 byte buffer necessary for a single packet */ 58 + #define ITM_BUFSIZE 8 59 + #define PATH_SIZE 64 60 + 61 + #define USB_VENDOR_ID_ITMINC 0x0403 62 + #define USB_PRODUCT_ID_TOUCHPANEL 0xf9e9 63 + 64 + #define DRIVER_AUTHOR "Hans-Christian Egtvedt <hc@mivu.no>" 65 + #define DRIVER_VERSION "v1.2.1" 66 + #define DRIVER_DESC "USB ITM Inc Touch Panel Driver" 67 + #define DRIVER_LICENSE "GPL" 68 + 69 + MODULE_AUTHOR( DRIVER_AUTHOR ); 70 + MODULE_DESCRIPTION( DRIVER_DESC ); 71 + MODULE_LICENSE( DRIVER_LICENSE ); 72 + 73 + struct itmtouch_dev { 74 + struct usb_device *usbdev; /* usb device */ 75 + struct input_dev inputdev; /* input device */ 76 + struct urb *readurb; /* urb */ 77 + char rbuf[ITM_BUFSIZE]; /* data */ 78 + int users; 79 + char name[128]; 80 + char phys[64]; 81 + }; 82 + 83 + static struct usb_device_id itmtouch_ids [] = { 84 + { USB_DEVICE(USB_VENDOR_ID_ITMINC, USB_PRODUCT_ID_TOUCHPANEL) }, 85 + { } 86 + }; 87 + 88 + static void itmtouch_irq(struct urb *urb, struct pt_regs *regs) 89 + { 90 + struct itmtouch_dev * itmtouch = urb->context; 91 + unsigned char *data = urb->transfer_buffer; 92 + struct input_dev *dev = &itmtouch->inputdev; 93 + int retval; 94 + 95 + switch (urb->status) { 96 + case 0: 97 + /* success */ 98 + break; 99 + case -ETIMEDOUT: 100 + /* this urb is timing out */ 101 + dbg("%s - urb timed out - was the device unplugged?", 102 + __FUNCTION__); 103 + return; 104 + case -ECONNRESET: 105 + case -ENOENT: 106 + case -ESHUTDOWN: 107 + /* this urb is terminated, clean up */ 108 + dbg("%s - urb shutting down with status: %d", 109 + __FUNCTION__, urb->status); 110 + return; 111 + default: 112 + dbg("%s - nonzero urb status received: %d", 113 + __FUNCTION__, urb->status); 114 + goto exit; 115 + } 116 + 117 + input_regs(dev, regs); 118 + 119 + /* if pressure has been released, then don't report X/Y */ 120 + if (data[7] & 0x20) { 121 + input_report_abs(dev, ABS_X, (data[0] & 0x1F) << 7 | (data[3] & 0x7F)); 122 + input_report_abs(dev, ABS_Y, (data[1] & 0x1F) << 7 | (data[4] & 0x7F)); 123 + } 124 + 125 + input_report_abs(dev, ABS_PRESSURE, (data[2] & 1) << 7 | (data[5] & 0x7F)); 126 + input_report_key(dev, BTN_TOUCH, ~data[7] & 0x20); 127 + input_sync(dev); 128 + 129 + exit: 130 + retval = usb_submit_urb (urb, GFP_ATOMIC); 131 + if (retval) 132 + printk(KERN_ERR "%s - usb_submit_urb failed with result: %d", 133 + __FUNCTION__, retval); 134 + } 135 + 136 + static int itmtouch_open(struct input_dev *input) 137 + { 138 + struct itmtouch_dev *itmtouch = input->private; 139 + 140 + itmtouch->readurb->dev = itmtouch->usbdev; 141 + 142 + if (usb_submit_urb(itmtouch->readurb, GFP_KERNEL)) 143 + return -EIO; 144 + 145 + return 0; 146 + } 147 + 148 + static void itmtouch_close(struct input_dev *input) 149 + { 150 + struct itmtouch_dev *itmtouch = input->private; 151 + 152 + usb_kill_urb(itmtouch->readurb); 153 + } 154 + 155 + static int itmtouch_probe(struct usb_interface *intf, const struct usb_device_id *id) 156 + { 157 + struct itmtouch_dev *itmtouch; 158 + struct usb_host_interface *interface; 159 + struct usb_endpoint_descriptor *endpoint; 160 + struct usb_device *udev = interface_to_usbdev(intf); 161 + unsigned int pipe; 162 + unsigned int maxp; 163 + char path[PATH_SIZE]; 164 + 165 + interface = intf->cur_altsetting; 166 + endpoint = &interface->endpoint[0].desc; 167 + 168 + if (!(itmtouch = kcalloc(1, sizeof(struct itmtouch_dev), GFP_KERNEL))) { 169 + err("%s - Out of memory.", __FUNCTION__); 170 + return -ENOMEM; 171 + } 172 + 173 + itmtouch->usbdev = udev; 174 + 175 + itmtouch->inputdev.private = itmtouch; 176 + itmtouch->inputdev.open = itmtouch_open; 177 + itmtouch->inputdev.close = itmtouch_close; 178 + 179 + usb_make_path(udev, path, PATH_SIZE); 180 + 181 + itmtouch->inputdev.evbit[0] = BIT(EV_KEY) | BIT(EV_ABS); 182 + itmtouch->inputdev.absbit[0] = BIT(ABS_X) | BIT(ABS_Y) | BIT(ABS_PRESSURE); 183 + itmtouch->inputdev.keybit[LONG(BTN_TOUCH)] = BIT(BTN_TOUCH); 184 + 185 + itmtouch->inputdev.name = itmtouch->name; 186 + itmtouch->inputdev.phys = itmtouch->phys; 187 + itmtouch->inputdev.id.bustype = BUS_USB; 188 + itmtouch->inputdev.id.vendor = udev->descriptor.idVendor; 189 + itmtouch->inputdev.id.product = udev->descriptor.idProduct; 190 + itmtouch->inputdev.id.version = udev->descriptor.bcdDevice; 191 + itmtouch->inputdev.dev = &intf->dev; 192 + 193 + if (!strlen(itmtouch->name)) 194 + sprintf(itmtouch->name, "USB ITM touchscreen"); 195 + 196 + /* device limits */ 197 + /* as specified by the ITM datasheet, X and Y are 12bit, 198 + * Z (pressure) is 8 bit. However, the fields are defined up 199 + * to 14 bits for future possible expansion. 200 + */ 201 + input_set_abs_params(&itmtouch->inputdev, ABS_X, 0, 0x0FFF, 2, 0); 202 + input_set_abs_params(&itmtouch->inputdev, ABS_Y, 0, 0x0FFF, 2, 0); 203 + input_set_abs_params(&itmtouch->inputdev, ABS_PRESSURE, 0, 0xFF, 2, 0); 204 + 205 + /* initialise the URB so we can read from the transport stream */ 206 + pipe = usb_rcvintpipe(itmtouch->usbdev, endpoint->bEndpointAddress); 207 + maxp = usb_maxpacket(udev, pipe, usb_pipeout(pipe)); 208 + 209 + if (maxp > ITM_BUFSIZE) 210 + maxp = ITM_BUFSIZE; 211 + 212 + itmtouch->readurb = usb_alloc_urb(0, GFP_KERNEL); 213 + 214 + if (!itmtouch->readurb) { 215 + dbg("%s - usb_alloc_urb failed: itmtouch->readurb", __FUNCTION__); 216 + kfree(itmtouch); 217 + return -ENOMEM; 218 + } 219 + 220 + usb_fill_int_urb(itmtouch->readurb, itmtouch->usbdev, pipe, itmtouch->rbuf, 221 + maxp, itmtouch_irq, itmtouch, endpoint->bInterval); 222 + 223 + input_register_device(&itmtouch->inputdev); 224 + 225 + printk(KERN_INFO "itmtouch: %s registered on %s\n", itmtouch->name, path); 226 + usb_set_intfdata(intf, itmtouch); 227 + 228 + return 0; 229 + } 230 + 231 + static void itmtouch_disconnect(struct usb_interface *intf) 232 + { 233 + struct itmtouch_dev *itmtouch = usb_get_intfdata(intf); 234 + 235 + usb_set_intfdata(intf, NULL); 236 + 237 + if (itmtouch) { 238 + input_unregister_device(&itmtouch->inputdev); 239 + usb_kill_urb(itmtouch->readurb); 240 + usb_free_urb(itmtouch->readurb); 241 + kfree(itmtouch); 242 + } 243 + } 244 + 245 + MODULE_DEVICE_TABLE(usb, itmtouch_ids); 246 + 247 + static struct usb_driver itmtouch_driver = { 248 + .owner = THIS_MODULE, 249 + .name = "itmtouch", 250 + .probe = itmtouch_probe, 251 + .disconnect = itmtouch_disconnect, 252 + .id_table = itmtouch_ids, 253 + }; 254 + 255 + static int __init itmtouch_init(void) 256 + { 257 + info(DRIVER_DESC " " DRIVER_VERSION); 258 + info(DRIVER_AUTHOR); 259 + return usb_register(&itmtouch_driver); 260 + } 261 + 262 + static void __exit itmtouch_exit(void) 263 + { 264 + usb_deregister(&itmtouch_driver); 265 + } 266 + 267 + module_init(itmtouch_init); 268 + module_exit(itmtouch_exit);
+5 -12
drivers/usb/input/kbtab.c
··· 36 36 struct input_dev dev; 37 37 struct usb_device *usbdev; 38 38 struct urb *irq; 39 - int open; 40 39 int x, y; 41 40 int button; 42 41 int pressure; ··· 78 79 /*input_report_key(dev, BTN_TOUCH , data[0] & 0x01);*/ 79 80 input_report_key(dev, BTN_RIGHT, data[0] & 0x02); 80 81 81 - if( -1 == kb_pressure_click){ 82 + if (-1 == kb_pressure_click) { 82 83 input_report_abs(dev, ABS_PRESSURE, kbtab->pressure); 83 84 } else { 84 85 input_report_key(dev, BTN_LEFT, (kbtab->pressure > kb_pressure_click) ? 1 : 0); 85 86 }; 86 - 87 + 87 88 input_sync(dev); 88 89 89 90 exit: ··· 104 105 { 105 106 struct kbtab *kbtab = dev->private; 106 107 107 - if (kbtab->open++) 108 - return 0; 109 - 110 108 kbtab->irq->dev = kbtab->usbdev; 111 - if (usb_submit_urb(kbtab->irq, GFP_KERNEL)) { 112 - kbtab->open--; 109 + if (usb_submit_urb(kbtab->irq, GFP_KERNEL)) 113 110 return -EIO; 114 - } 115 111 116 112 return 0; 117 113 } ··· 115 121 { 116 122 struct kbtab *kbtab = dev->private; 117 123 118 - if (!--kbtab->open) 119 - usb_kill_urb(kbtab->irq); 124 + usb_kill_urb(kbtab->irq); 120 125 } 121 126 122 127 static int kbtab_probe(struct usb_interface *intf, const struct usb_device_id *id) ··· 154 161 kbtab->dev.absmax[ABS_X] = 0x2000; 155 162 kbtab->dev.absmax[ABS_Y] = 0x1750; 156 163 kbtab->dev.absmax[ABS_PRESSURE] = 0xff; 157 - 164 + 158 165 kbtab->dev.absfuzz[ABS_X] = 4; 159 166 kbtab->dev.absfuzz[ABS_Y] = 4; 160 167
+174 -194
drivers/usb/input/mtouchusb.c
··· 42 42 #include <linux/config.h> 43 43 44 44 #ifdef CONFIG_USB_DEBUG 45 - #define DEBUG 45 + #define DEBUG 46 46 #else 47 - #undef DEBUG 47 + #undef DEBUG 48 48 #endif 49 49 50 50 #include <linux/kernel.h> ··· 93 93 MODULE_PARM_DESC(raw_coordinates, "report raw coordinate values (y, default) or hardware-calibrated coordinate values (n)"); 94 94 95 95 struct mtouch_usb { 96 - unsigned char *data; 97 - dma_addr_t data_dma; 98 - struct urb *irq; 99 - struct usb_device *udev; 100 - struct input_dev input; 101 - int open; 102 - char name[128]; 103 - char phys[64]; 96 + unsigned char *data; 97 + dma_addr_t data_dma; 98 + struct urb *irq; 99 + struct usb_device *udev; 100 + struct input_dev input; 101 + char name[128]; 102 + char phys[64]; 104 103 }; 105 104 106 - static struct usb_device_id mtouchusb_devices [] = { 107 - { USB_DEVICE(0x0596, 0x0001) }, 108 - { } 105 + static struct usb_device_id mtouchusb_devices[] = { 106 + { USB_DEVICE(0x0596, 0x0001) }, 107 + { } 109 108 }; 110 109 111 110 static void mtouchusb_irq(struct urb *urb, struct pt_regs *regs) 112 111 { 113 - struct mtouch_usb *mtouch = urb->context; 114 - int retval; 112 + struct mtouch_usb *mtouch = urb->context; 113 + int retval; 115 114 116 - switch (urb->status) { 117 - case 0: 118 - /* success */ 119 - break; 120 - case -ETIMEDOUT: 121 - /* this urb is timing out */ 122 - dbg("%s - urb timed out - was the device unplugged?", 123 - __FUNCTION__); 124 - return; 125 - case -ECONNRESET: 126 - case -ENOENT: 127 - case -ESHUTDOWN: 128 - /* this urb is terminated, clean up */ 129 - dbg("%s - urb shutting down with status: %d", 130 - __FUNCTION__, urb->status); 131 - return; 132 - default: 133 - dbg("%s - nonzero urb status received: %d", 134 - __FUNCTION__, urb->status); 135 - goto exit; 136 - } 115 + switch (urb->status) { 116 + case 0: 117 + /* success */ 118 + break; 119 + case -ETIMEDOUT: 120 + /* this urb is timing out */ 121 + dbg("%s - urb timed out - was the device unplugged?", 122 + __FUNCTION__); 123 + return; 124 + case -ECONNRESET: 125 + case -ENOENT: 126 + case -ESHUTDOWN: 127 + /* this urb is terminated, clean up */ 128 + dbg("%s - urb shutting down with status: %d", 129 + __FUNCTION__, urb->status); 130 + return; 131 + default: 132 + dbg("%s - nonzero urb status received: %d", 133 + __FUNCTION__, urb->status); 134 + goto exit; 135 + } 137 136 138 - input_regs(&mtouch->input, regs); 139 - input_report_key(&mtouch->input, BTN_TOUCH, 140 - MTOUCHUSB_GET_TOUCHED(mtouch->data)); 141 - input_report_abs(&mtouch->input, ABS_X, 142 - MTOUCHUSB_GET_XC(mtouch->data)); 143 - input_report_abs(&mtouch->input, ABS_Y, 137 + input_regs(&mtouch->input, regs); 138 + input_report_key(&mtouch->input, BTN_TOUCH, 139 + MTOUCHUSB_GET_TOUCHED(mtouch->data)); 140 + input_report_abs(&mtouch->input, ABS_X, MTOUCHUSB_GET_XC(mtouch->data)); 141 + input_report_abs(&mtouch->input, ABS_Y, 144 142 (raw_coordinates ? MTOUCHUSB_MAX_RAW_YC : MTOUCHUSB_MAX_CALIB_YC) 145 - - MTOUCHUSB_GET_YC(mtouch->data)); 146 - input_sync(&mtouch->input); 143 + - MTOUCHUSB_GET_YC(mtouch->data)); 144 + input_sync(&mtouch->input); 147 145 148 146 exit: 149 - retval = usb_submit_urb (urb, GFP_ATOMIC); 150 - if (retval) 151 - err ("%s - usb_submit_urb failed with result: %d", 152 - __FUNCTION__, retval); 147 + retval = usb_submit_urb(urb, GFP_ATOMIC); 148 + if (retval) 149 + err("%s - usb_submit_urb failed with result: %d", 150 + __FUNCTION__, retval); 153 151 } 154 152 155 - static int mtouchusb_open (struct input_dev *input) 153 + static int mtouchusb_open(struct input_dev *input) 156 154 { 157 - struct mtouch_usb *mtouch = input->private; 155 + struct mtouch_usb *mtouch = input->private; 158 156 159 - if (mtouch->open++) 160 - return 0; 157 + mtouch->irq->dev = mtouch->udev; 161 158 162 - mtouch->irq->dev = mtouch->udev; 159 + if (usb_submit_urb(mtouch->irq, GFP_ATOMIC)) 160 + return -EIO; 163 161 164 - if (usb_submit_urb (mtouch->irq, GFP_ATOMIC)) { 165 - mtouch->open--; 166 - return -EIO; 167 - } 168 - 169 - return 0; 162 + return 0; 170 163 } 171 164 172 - static void mtouchusb_close (struct input_dev *input) 165 + static void mtouchusb_close(struct input_dev *input) 173 166 { 174 - struct mtouch_usb *mtouch = input->private; 167 + struct mtouch_usb *mtouch = input->private; 175 168 176 - if (!--mtouch->open) 177 - usb_kill_urb (mtouch->irq); 169 + usb_kill_urb(mtouch->irq); 178 170 } 179 171 180 172 static int mtouchusb_alloc_buffers(struct usb_device *udev, struct mtouch_usb *mtouch) 181 173 { 182 - dbg("%s - called", __FUNCTION__); 174 + dbg("%s - called", __FUNCTION__); 183 175 184 - mtouch->data = usb_buffer_alloc(udev, MTOUCHUSB_REPORT_DATA_SIZE, 185 - SLAB_ATOMIC, &mtouch->data_dma); 176 + mtouch->data = usb_buffer_alloc(udev, MTOUCHUSB_REPORT_DATA_SIZE, 177 + SLAB_ATOMIC, &mtouch->data_dma); 186 178 187 - if (!mtouch->data) 188 - return -1; 179 + if (!mtouch->data) 180 + return -1; 189 181 190 - return 0; 182 + return 0; 191 183 } 192 184 193 185 static void mtouchusb_free_buffers(struct usb_device *udev, struct mtouch_usb *mtouch) 194 186 { 195 - dbg("%s - called", __FUNCTION__); 187 + dbg("%s - called", __FUNCTION__); 196 188 197 - if (mtouch->data) 198 - usb_buffer_free(udev, MTOUCHUSB_REPORT_DATA_SIZE, 199 - mtouch->data, mtouch->data_dma); 189 + if (mtouch->data) 190 + usb_buffer_free(udev, MTOUCHUSB_REPORT_DATA_SIZE, 191 + mtouch->data, mtouch->data_dma); 200 192 } 201 193 202 194 static int mtouchusb_probe(struct usb_interface *intf, const struct usb_device_id *id) 203 195 { 204 - struct mtouch_usb *mtouch; 205 - struct usb_host_interface *interface; 206 - struct usb_endpoint_descriptor *endpoint; 207 - struct usb_device *udev = interface_to_usbdev (intf); 208 - char path[64]; 209 - int nRet; 196 + struct mtouch_usb *mtouch; 197 + struct usb_host_interface *interface; 198 + struct usb_endpoint_descriptor *endpoint; 199 + struct usb_device *udev = interface_to_usbdev(intf); 200 + char path[64]; 201 + int nRet; 210 202 211 - dbg("%s - called", __FUNCTION__); 203 + dbg("%s - called", __FUNCTION__); 212 204 213 - dbg("%s - setting interface", __FUNCTION__); 214 - interface = intf->cur_altsetting; 205 + dbg("%s - setting interface", __FUNCTION__); 206 + interface = intf->cur_altsetting; 215 207 216 - dbg("%s - setting endpoint", __FUNCTION__); 217 - endpoint = &interface->endpoint[0].desc; 208 + dbg("%s - setting endpoint", __FUNCTION__); 209 + endpoint = &interface->endpoint[0].desc; 218 210 219 - if (!(mtouch = kmalloc (sizeof (struct mtouch_usb), GFP_KERNEL))) { 220 - err("%s - Out of memory.", __FUNCTION__); 221 - return -ENOMEM; 222 - } 211 + if (!(mtouch = kmalloc(sizeof(struct mtouch_usb), GFP_KERNEL))) { 212 + err("%s - Out of memory.", __FUNCTION__); 213 + return -ENOMEM; 214 + } 223 215 224 - memset(mtouch, 0, sizeof(struct mtouch_usb)); 225 - mtouch->udev = udev; 216 + memset(mtouch, 0, sizeof(struct mtouch_usb)); 217 + mtouch->udev = udev; 226 218 227 - dbg("%s - allocating buffers", __FUNCTION__); 228 - if (mtouchusb_alloc_buffers(udev, mtouch)) { 229 - mtouchusb_free_buffers(udev, mtouch); 230 - kfree(mtouch); 231 - return -ENOMEM; 232 - } 219 + dbg("%s - allocating buffers", __FUNCTION__); 220 + if (mtouchusb_alloc_buffers(udev, mtouch)) { 221 + mtouchusb_free_buffers(udev, mtouch); 222 + kfree(mtouch); 223 + return -ENOMEM; 224 + } 233 225 234 - mtouch->input.private = mtouch; 235 - mtouch->input.open = mtouchusb_open; 236 - mtouch->input.close = mtouchusb_close; 226 + mtouch->input.private = mtouch; 227 + mtouch->input.open = mtouchusb_open; 228 + mtouch->input.close = mtouchusb_close; 237 229 238 - usb_make_path(udev, path, 64); 239 - sprintf(mtouch->phys, "%s/input0", path); 230 + usb_make_path(udev, path, 64); 231 + sprintf(mtouch->phys, "%s/input0", path); 240 232 241 - mtouch->input.name = mtouch->name; 242 - mtouch->input.phys = mtouch->phys; 243 - mtouch->input.id.bustype = BUS_USB; 244 - mtouch->input.id.vendor = le16_to_cpu(udev->descriptor.idVendor); 245 - mtouch->input.id.product = le16_to_cpu(udev->descriptor.idProduct); 246 - mtouch->input.id.version = le16_to_cpu(udev->descriptor.bcdDevice); 247 - mtouch->input.dev = &intf->dev; 233 + mtouch->input.name = mtouch->name; 234 + mtouch->input.phys = mtouch->phys; 235 + mtouch->input.id.bustype = BUS_USB; 236 + mtouch->input.id.vendor = le16_to_cpu(udev->descriptor.idVendor); 237 + mtouch->input.id.product = le16_to_cpu(udev->descriptor.idProduct); 238 + mtouch->input.id.version = le16_to_cpu(udev->descriptor.bcdDevice); 239 + mtouch->input.dev = &intf->dev; 248 240 249 - mtouch->input.evbit[0] = BIT(EV_KEY) | BIT(EV_ABS); 250 - mtouch->input.absbit[0] = BIT(ABS_X) | BIT(ABS_Y); 251 - mtouch->input.keybit[LONG(BTN_TOUCH)] = BIT(BTN_TOUCH); 241 + mtouch->input.evbit[0] = BIT(EV_KEY) | BIT(EV_ABS); 242 + mtouch->input.absbit[0] = BIT(ABS_X) | BIT(ABS_Y); 243 + mtouch->input.keybit[LONG(BTN_TOUCH)] = BIT(BTN_TOUCH); 252 244 253 - /* Used to Scale Compensated Data and Flip Y */ 254 - mtouch->input.absmin[ABS_X] = MTOUCHUSB_MIN_XC; 255 - mtouch->input.absmax[ABS_X] = raw_coordinates ? \ 256 - MTOUCHUSB_MAX_RAW_XC : MTOUCHUSB_MAX_CALIB_XC; 257 - mtouch->input.absfuzz[ABS_X] = MTOUCHUSB_XC_FUZZ; 258 - mtouch->input.absflat[ABS_X] = MTOUCHUSB_XC_FLAT; 259 - mtouch->input.absmin[ABS_Y] = MTOUCHUSB_MIN_YC; 260 - mtouch->input.absmax[ABS_Y] = raw_coordinates ? \ 261 - MTOUCHUSB_MAX_RAW_YC : MTOUCHUSB_MAX_CALIB_YC; 262 - mtouch->input.absfuzz[ABS_Y] = MTOUCHUSB_YC_FUZZ; 263 - mtouch->input.absflat[ABS_Y] = MTOUCHUSB_YC_FLAT; 245 + /* Used to Scale Compensated Data and Flip Y */ 246 + mtouch->input.absmin[ABS_X] = MTOUCHUSB_MIN_XC; 247 + mtouch->input.absmax[ABS_X] = raw_coordinates ? 248 + MTOUCHUSB_MAX_RAW_XC : MTOUCHUSB_MAX_CALIB_XC; 249 + mtouch->input.absfuzz[ABS_X] = MTOUCHUSB_XC_FUZZ; 250 + mtouch->input.absflat[ABS_X] = MTOUCHUSB_XC_FLAT; 251 + mtouch->input.absmin[ABS_Y] = MTOUCHUSB_MIN_YC; 252 + mtouch->input.absmax[ABS_Y] = raw_coordinates ? 253 + MTOUCHUSB_MAX_RAW_YC : MTOUCHUSB_MAX_CALIB_YC; 254 + mtouch->input.absfuzz[ABS_Y] = MTOUCHUSB_YC_FUZZ; 255 + mtouch->input.absflat[ABS_Y] = MTOUCHUSB_YC_FLAT; 264 256 265 257 if (udev->manufacturer) 266 258 strcat(mtouch->name, udev->manufacturer); 267 259 if (udev->product) 268 260 sprintf(mtouch->name, "%s %s", mtouch->name, udev->product); 269 261 270 - if (!strlen(mtouch->name)) 271 - sprintf(mtouch->name, "USB Touchscreen %04x:%04x", 272 - mtouch->input.id.vendor, mtouch->input.id.product); 262 + if (!strlen(mtouch->name)) 263 + sprintf(mtouch->name, "USB Touchscreen %04x:%04x", 264 + mtouch->input.id.vendor, mtouch->input.id.product); 273 265 274 - nRet = usb_control_msg(mtouch->udev, 275 - usb_rcvctrlpipe(udev, 0), 276 - MTOUCHUSB_RESET, 277 - USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE, 278 - 1, 279 - 0, 280 - NULL, 281 - 0, 282 - USB_CTRL_SET_TIMEOUT); 283 - dbg("%s - usb_control_msg - MTOUCHUSB_RESET - bytes|err: %d", 284 - __FUNCTION__, nRet); 266 + nRet = usb_control_msg(mtouch->udev, usb_rcvctrlpipe(udev, 0), 267 + MTOUCHUSB_RESET, 268 + USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE, 269 + 1, 0, NULL, 0, USB_CTRL_SET_TIMEOUT); 270 + dbg("%s - usb_control_msg - MTOUCHUSB_RESET - bytes|err: %d", 271 + __FUNCTION__, nRet); 285 272 286 - dbg("%s - usb_alloc_urb: mtouch->irq", __FUNCTION__); 287 - mtouch->irq = usb_alloc_urb(0, GFP_KERNEL); 288 - if (!mtouch->irq) { 289 - dbg("%s - usb_alloc_urb failed: mtouch->irq", __FUNCTION__); 290 - mtouchusb_free_buffers(udev, mtouch); 291 - kfree(mtouch); 292 - return -ENOMEM; 293 - } 273 + dbg("%s - usb_alloc_urb: mtouch->irq", __FUNCTION__); 274 + mtouch->irq = usb_alloc_urb(0, GFP_KERNEL); 275 + if (!mtouch->irq) { 276 + dbg("%s - usb_alloc_urb failed: mtouch->irq", __FUNCTION__); 277 + mtouchusb_free_buffers(udev, mtouch); 278 + kfree(mtouch); 279 + return -ENOMEM; 280 + } 294 281 295 - dbg("%s - usb_fill_int_urb", __FUNCTION__); 296 - usb_fill_int_urb(mtouch->irq, 297 - mtouch->udev, 298 - usb_rcvintpipe(mtouch->udev, 0x81), 299 - mtouch->data, 300 - MTOUCHUSB_REPORT_DATA_SIZE, 301 - mtouchusb_irq, 302 - mtouch, 303 - endpoint->bInterval); 282 + dbg("%s - usb_fill_int_urb", __FUNCTION__); 283 + usb_fill_int_urb(mtouch->irq, mtouch->udev, 284 + usb_rcvintpipe(mtouch->udev, 0x81), 285 + mtouch->data, MTOUCHUSB_REPORT_DATA_SIZE, 286 + mtouchusb_irq, mtouch, endpoint->bInterval); 304 287 305 - dbg("%s - input_register_device", __FUNCTION__); 306 - input_register_device(&mtouch->input); 288 + dbg("%s - input_register_device", __FUNCTION__); 289 + input_register_device(&mtouch->input); 307 290 308 - nRet = usb_control_msg(mtouch->udev, 309 - usb_rcvctrlpipe(udev, 0), 310 - MTOUCHUSB_ASYNC_REPORT, 311 - USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE, 312 - 1, 313 - 1, 314 - NULL, 315 - 0, 316 - USB_CTRL_SET_TIMEOUT); 317 - dbg("%s - usb_control_msg - MTOUCHUSB_ASYNC_REPORT - bytes|err: %d", 318 - __FUNCTION__, nRet); 291 + nRet = usb_control_msg(mtouch->udev, usb_rcvctrlpipe(udev, 0), 292 + MTOUCHUSB_ASYNC_REPORT, 293 + USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE, 294 + 1, 1, NULL, 0, USB_CTRL_SET_TIMEOUT); 295 + dbg("%s - usb_control_msg - MTOUCHUSB_ASYNC_REPORT - bytes|err: %d", 296 + __FUNCTION__, nRet); 319 297 320 - printk(KERN_INFO "input: %s on %s\n", mtouch->name, path); 321 - usb_set_intfdata(intf, mtouch); 298 + printk(KERN_INFO "input: %s on %s\n", mtouch->name, path); 299 + usb_set_intfdata(intf, mtouch); 322 300 323 - return 0; 301 + return 0; 324 302 } 325 303 326 304 static void mtouchusb_disconnect(struct usb_interface *intf) 327 305 { 328 - struct mtouch_usb *mtouch = usb_get_intfdata (intf); 306 + struct mtouch_usb *mtouch = usb_get_intfdata(intf); 329 307 330 - dbg("%s - called", __FUNCTION__); 331 - usb_set_intfdata(intf, NULL); 332 - if (mtouch) { 333 - dbg("%s - mtouch is initialized, cleaning up", __FUNCTION__); 334 - usb_kill_urb(mtouch->irq); 335 - input_unregister_device(&mtouch->input); 336 - usb_free_urb(mtouch->irq); 337 - mtouchusb_free_buffers(interface_to_usbdev(intf), mtouch); 338 - kfree(mtouch); 339 - } 308 + dbg("%s - called", __FUNCTION__); 309 + usb_set_intfdata(intf, NULL); 310 + if (mtouch) { 311 + dbg("%s - mtouch is initialized, cleaning up", __FUNCTION__); 312 + usb_kill_urb(mtouch->irq); 313 + input_unregister_device(&mtouch->input); 314 + usb_free_urb(mtouch->irq); 315 + mtouchusb_free_buffers(interface_to_usbdev(intf), mtouch); 316 + kfree(mtouch); 317 + } 340 318 } 341 319 342 - MODULE_DEVICE_TABLE (usb, mtouchusb_devices); 320 + MODULE_DEVICE_TABLE(usb, mtouchusb_devices); 343 321 344 322 static struct usb_driver mtouchusb_driver = { 345 - .owner = THIS_MODULE, 346 - .name = "mtouchusb", 347 - .probe = mtouchusb_probe, 348 - .disconnect = mtouchusb_disconnect, 349 - .id_table = mtouchusb_devices, 323 + .owner = THIS_MODULE, 324 + .name = "mtouchusb", 325 + .probe = mtouchusb_probe, 326 + .disconnect = mtouchusb_disconnect, 327 + .id_table = mtouchusb_devices, 350 328 }; 351 329 352 - static int __init mtouchusb_init(void) { 353 - dbg("%s - called", __FUNCTION__); 354 - return usb_register(&mtouchusb_driver); 330 + static int __init mtouchusb_init(void) 331 + { 332 + dbg("%s - called", __FUNCTION__); 333 + return usb_register(&mtouchusb_driver); 355 334 } 356 335 357 - static void __exit mtouchusb_cleanup(void) { 358 - dbg("%s - called", __FUNCTION__); 359 - usb_deregister(&mtouchusb_driver); 336 + static void __exit mtouchusb_cleanup(void) 337 + { 338 + dbg("%s - called", __FUNCTION__); 339 + usb_deregister(&mtouchusb_driver); 360 340 } 361 341 362 342 module_init(mtouchusb_init); 363 343 module_exit(mtouchusb_cleanup); 364 344 365 - MODULE_AUTHOR( DRIVER_AUTHOR ); 366 - MODULE_DESCRIPTION( DRIVER_DESC ); 345 + MODULE_AUTHOR(DRIVER_AUTHOR); 346 + MODULE_DESCRIPTION(DRIVER_DESC); 367 347 MODULE_LICENSE("GPL");
+15 -15
drivers/usb/input/powermate.c
··· 10 10 * back to the host when polled by the USB controller. 11 11 * 12 12 * Testing with the knob I have has shown that it measures approximately 94 "clicks" 13 - * for one full rotation. Testing with my High Speed Rotation Actuator (ok, it was 13 + * for one full rotation. Testing with my High Speed Rotation Actuator (ok, it was 14 14 * a variable speed cordless electric drill) has shown that the device can measure 15 15 * speeds of up to 7 clicks either clockwise or anticlockwise between pollings from 16 16 * the host. If it counts more than 7 clicks before it is polled, it will wrap back ··· 120 120 /* Decide if we need to issue a control message and do so. Must be called with pm->lock taken */ 121 121 static void powermate_sync_state(struct powermate_device *pm) 122 122 { 123 - if (pm->requires_update == 0) 123 + if (pm->requires_update == 0) 124 124 return; /* no updates are required */ 125 - if (pm->config->status == -EINPROGRESS) 125 + if (pm->config->status == -EINPROGRESS) 126 126 return; /* an update is already in progress; it'll issue this update when it completes */ 127 127 128 128 if (pm->requires_update & UPDATE_PULSE_ASLEEP){ ··· 142 142 2: multiply the speed 143 143 the argument only has an effect for operations 0 and 2, and ranges between 144 144 1 (least effect) to 255 (maximum effect). 145 - 145 + 146 146 thus, several states are equivalent and are coalesced into one state. 147 147 148 148 we map this onto a range from 0 to 510, with: ··· 151 151 256 -- 510 -- use multiple (510 = fastest). 152 152 153 153 Only values of 'arg' quite close to 255 are particularly useful/spectacular. 154 - */ 154 + */ 155 155 if (pm->pulse_speed < 255){ 156 156 op = 0; // divide 157 157 arg = 255 - pm->pulse_speed; ··· 199 199 200 200 if (urb->status) 201 201 printk(KERN_ERR "powermate: config urb returned %d\n", urb->status); 202 - 202 + 203 203 spin_lock_irqsave(&pm->lock, flags); 204 204 powermate_sync_state(pm); 205 205 spin_unlock_irqrestore(&pm->lock, flags); 206 206 } 207 207 208 208 /* Set the LED up as described and begin the sync with the hardware if required */ 209 - static void powermate_pulse_led(struct powermate_device *pm, int static_brightness, int pulse_speed, 209 + static void powermate_pulse_led(struct powermate_device *pm, int static_brightness, int pulse_speed, 210 210 int pulse_table, int pulse_asleep, int pulse_awake) 211 211 { 212 212 unsigned long flags; ··· 229 229 /* mark state updates which are required */ 230 230 if (static_brightness != pm->static_brightness){ 231 231 pm->static_brightness = static_brightness; 232 - pm->requires_update |= UPDATE_STATIC_BRIGHTNESS; 232 + pm->requires_update |= UPDATE_STATIC_BRIGHTNESS; 233 233 } 234 234 if (pulse_asleep != pm->pulse_asleep){ 235 235 pm->pulse_asleep = pulse_asleep; ··· 246 246 } 247 247 248 248 powermate_sync_state(pm); 249 - 249 + 250 250 spin_unlock_irqrestore(&pm->lock, flags); 251 251 } 252 252 ··· 257 257 struct powermate_device *pm = dev->private; 258 258 259 259 if (type == EV_MSC && code == MSC_PULSELED){ 260 - /* 260 + /* 261 261 bits 0- 7: 8 bits: LED brightness 262 262 bits 8-16: 9 bits: pulsing speed modifier (0 ... 510); 0-254 = slower, 255 = standard, 256-510 = faster. 263 263 bits 17-18: 2 bits: pulse table (0, 1, 2 valid) 264 264 bit 19: 1 bit : pulse whilst asleep? 265 265 bit 20: 1 bit : pulse constantly? 266 - */ 266 + */ 267 267 int static_brightness = command & 0xFF; // bits 0-7 268 268 int pulse_speed = (command >> 8) & 0x1FF; // bits 8-16 269 269 int pulse_table = (command >> 17) & 0x3; // bits 17-18 270 270 int pulse_asleep = (command >> 19) & 0x1; // bit 19 271 271 int pulse_awake = (command >> 20) & 0x1; // bit 20 272 - 272 + 273 273 powermate_pulse_led(pm, static_brightness, pulse_speed, pulse_table, pulse_asleep, pulse_awake); 274 274 } 275 275 ··· 378 378 switch (le16_to_cpu(udev->descriptor.idProduct)) { 379 379 case POWERMATE_PRODUCT_NEW: pm->input.name = pm_name_powermate; break; 380 380 case POWERMATE_PRODUCT_OLD: pm->input.name = pm_name_soundknob; break; 381 - default: 381 + default: 382 382 pm->input.name = pm_name_soundknob; 383 383 printk(KERN_WARNING "powermate: unknown product id %04x\n", 384 384 le16_to_cpu(udev->descriptor.idProduct)); ··· 402 402 usb_make_path(udev, path, 64); 403 403 snprintf(pm->phys, 64, "%s/input0", path); 404 404 printk(KERN_INFO "input: %s on %s\n", pm->input.name, pm->input.phys); 405 - 405 + 406 406 /* force an update of everything */ 407 407 pm->requires_update = UPDATE_PULSE_ASLEEP | UPDATE_PULSE_AWAKE | UPDATE_PULSE_MODE | UPDATE_STATIC_BRIGHTNESS; 408 408 powermate_pulse_led(pm, 0x80, 255, 0, 1, 0); // set default pulse parameters 409 - 409 + 410 410 usb_set_intfdata(intf, pm); 411 411 return 0; 412 412 }
+2 -9
drivers/usb/input/touchkitusb.c
··· 69 69 struct urb *irq; 70 70 struct usb_device *udev; 71 71 struct input_dev input; 72 - int open; 73 72 char name[128]; 74 73 char phys[64]; 75 74 }; ··· 133 134 { 134 135 struct touchkit_usb *touchkit = input->private; 135 136 136 - if (touchkit->open++) 137 - return 0; 138 - 139 137 touchkit->irq->dev = touchkit->udev; 140 138 141 - if (usb_submit_urb(touchkit->irq, GFP_ATOMIC)) { 142 - touchkit->open--; 139 + if (usb_submit_urb(touchkit->irq, GFP_ATOMIC)) 143 140 return -EIO; 144 - } 145 141 146 142 return 0; 147 143 } ··· 145 151 { 146 152 struct touchkit_usb *touchkit = input->private; 147 153 148 - if (!--touchkit->open) 149 - usb_kill_urb(touchkit->irq); 154 + usb_kill_urb(touchkit->irq); 150 155 } 151 156 152 157 static int touchkit_alloc_buffers(struct usb_device *udev,
+11 -18
drivers/usb/input/usbkbd.c
··· 9 9 /* 10 10 * This program is free software; you can redistribute it and/or modify 11 11 * it under the terms of the GNU General Public License as published by 12 - * the Free Software Foundation; either version 2 of the License, or 12 + * the Free Software Foundation; either version 2 of the License, or 13 13 * (at your option) any later version. 14 - * 14 + * 15 15 * This program is distributed in the hope that it will be useful, 16 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 18 * GNU General Public License for more details. 19 - * 19 + * 20 20 * You should have received a copy of the GNU General Public License 21 21 * along with this program; if not, write to the Free Software 22 22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 23 - * 23 + * 24 24 * Should you need to contact me, the author, you can do so either by 25 25 * e-mail - mail your message to <vojtech@ucw.cz>, or by paper mail: 26 26 * Vojtech Pavlik, Simunkova 1594, Prague 8, 182 00 Czech Republic ··· 72 72 unsigned char newleds; 73 73 char name[128]; 74 74 char phys[64]; 75 - int open; 76 75 77 76 unsigned char *new; 78 77 struct usb_ctrlrequest *cr; ··· 165 166 166 167 if (urb->status) 167 168 warn("led urb status %d received", urb->status); 168 - 169 + 169 170 if (*(kbd->leds) == kbd->newleds) 170 171 return; 171 172 ··· 179 180 { 180 181 struct usb_kbd *kbd = dev->private; 181 182 182 - if (kbd->open++) 183 - return 0; 184 - 185 183 kbd->irq->dev = kbd->usbdev; 186 - if (usb_submit_urb(kbd->irq, GFP_KERNEL)) { 187 - kbd->open--; 184 + if (usb_submit_urb(kbd->irq, GFP_KERNEL)) 188 185 return -EIO; 189 - } 190 186 191 187 return 0; 192 188 } ··· 190 196 { 191 197 struct usb_kbd *kbd = dev->private; 192 198 193 - if (!--kbd->open) 194 - usb_kill_urb(kbd->irq); 199 + usb_kill_urb(kbd->irq); 195 200 } 196 201 197 202 static int usb_kbd_alloc_mem(struct usb_device *dev, struct usb_kbd *kbd) ··· 223 230 usb_buffer_free(dev, 1, kbd->leds, kbd->leds_dma); 224 231 } 225 232 226 - static int usb_kbd_probe(struct usb_interface *iface, 233 + static int usb_kbd_probe(struct usb_interface *iface, 227 234 const struct usb_device_id *id) 228 235 { 229 236 struct usb_device * dev = interface_to_usbdev(iface); ··· 265 272 for (i = 0; i < 255; i++) 266 273 set_bit(usb_kbd_keycode[i], kbd->dev.keybit); 267 274 clear_bit(0, kbd->dev.keybit); 268 - 275 + 269 276 kbd->dev.private = kbd; 270 277 kbd->dev.event = usb_kbd_event; 271 278 kbd->dev.open = usb_kbd_open; ··· 287 294 sprintf(kbd->phys, "%s/input0", path); 288 295 289 296 kbd->dev.name = kbd->name; 290 - kbd->dev.phys = kbd->phys; 297 + kbd->dev.phys = kbd->phys; 291 298 kbd->dev.id.bustype = BUS_USB; 292 299 kbd->dev.id.vendor = le16_to_cpu(dev->descriptor.idVendor); 293 300 kbd->dev.id.product = le16_to_cpu(dev->descriptor.idProduct); ··· 322 329 static void usb_kbd_disconnect(struct usb_interface *intf) 323 330 { 324 331 struct usb_kbd *kbd = usb_get_intfdata (intf); 325 - 332 + 326 333 usb_set_intfdata(intf, NULL); 327 334 if (kbd) { 328 335 usb_kill_urb(kbd->irq);
+12 -19
drivers/usb/input/usbmouse.c
··· 9 9 /* 10 10 * This program is free software; you can redistribute it and/or modify 11 11 * it under the terms of the GNU General Public License as published by 12 - * the Free Software Foundation; either version 2 of the License, or 12 + * the Free Software Foundation; either version 2 of the License, or 13 13 * (at your option) any later version. 14 - * 14 + * 15 15 * This program is distributed in the hope that it will be useful, 16 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 18 * GNU General Public License for more details. 19 - * 19 + * 20 20 * You should have received a copy of the GNU General Public License 21 21 * along with this program; if not, write to the Free Software 22 22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 23 - * 23 + * 24 24 * Should you need to contact me, the author, you can do so either by 25 25 * e-mail - mail your message to <vojtech@ucw.cz>, or by paper mail: 26 26 * Vojtech Pavlik, Simunkova 1594, Prague 8, 182 00 Czech Republic ··· 51 51 struct usb_device *usbdev; 52 52 struct input_dev dev; 53 53 struct urb *irq; 54 - int open; 55 54 56 55 signed char *data; 57 56 dma_addr_t data_dma; ··· 100 101 { 101 102 struct usb_mouse *mouse = dev->private; 102 103 103 - if (mouse->open++) 104 - return 0; 105 - 106 104 mouse->irq->dev = mouse->usbdev; 107 - if (usb_submit_urb(mouse->irq, GFP_KERNEL)) { 108 - mouse->open--; 105 + if (usb_submit_urb(mouse->irq, GFP_KERNEL)) 109 106 return -EIO; 110 - } 111 107 112 108 return 0; 113 109 } ··· 111 117 { 112 118 struct usb_mouse *mouse = dev->private; 113 119 114 - if (!--mouse->open) 115 - usb_kill_urb(mouse->irq); 120 + usb_kill_urb(mouse->irq); 116 121 } 117 122 118 123 static int usb_mouse_probe(struct usb_interface * intf, const struct usb_device_id * id) ··· 125 132 126 133 interface = intf->cur_altsetting; 127 134 128 - if (interface->desc.bNumEndpoints != 1) 135 + if (interface->desc.bNumEndpoints != 1) 129 136 return -ENODEV; 130 137 131 138 endpoint = &interface->endpoint[0].desc; 132 - if (!(endpoint->bEndpointAddress & 0x80)) 139 + if (!(endpoint->bEndpointAddress & 0x80)) 133 140 return -ENODEV; 134 - if ((endpoint->bmAttributes & 3) != 3) 141 + if ((endpoint->bmAttributes & 3) != 3) 135 142 return -ENODEV; 136 143 137 144 pipe = usb_rcvintpipe(dev, endpoint->bEndpointAddress); 138 145 maxp = usb_maxpacket(dev, pipe, usb_pipeout(pipe)); 139 146 140 - if (!(mouse = kmalloc(sizeof(struct usb_mouse), GFP_KERNEL))) 147 + if (!(mouse = kmalloc(sizeof(struct usb_mouse), GFP_KERNEL))) 141 148 return -ENOMEM; 142 149 memset(mouse, 0, sizeof(struct usb_mouse)); 143 150 ··· 202 209 static void usb_mouse_disconnect(struct usb_interface *intf) 203 210 { 204 211 struct usb_mouse *mouse = usb_get_intfdata (intf); 205 - 212 + 206 213 usb_set_intfdata(intf, NULL); 207 214 if (mouse) { 208 215 usb_kill_urb(mouse->irq); ··· 231 238 static int __init usb_mouse_init(void) 232 239 { 233 240 int retval = usb_register(&usb_mouse_driver); 234 - if (retval == 0) 241 + if (retval == 0) 235 242 info(DRIVER_VERSION ":" DRIVER_DESC); 236 243 return retval; 237 244 }
+171 -227
drivers/usb/input/wacom.c
··· 9 9 * Copyright (c) 2000 Daniel Egger <egger@suse.de> 10 10 * Copyright (c) 2001 Frederic Lepied <flepied@mandrakesoft.com> 11 11 * Copyright (c) 2004 Panagiotis Issaris <panagiotis.issaris@mech.kuleuven.ac.be> 12 - * Copyright (c) 2002-2004 Ping Cheng <pingc@wacom.com> 12 + * Copyright (c) 2002-2005 Ping Cheng <pingc@wacom.com> 13 13 * 14 14 * ChangeLog: 15 15 * v0.1 (vp) - Initial release ··· 18 18 * v0.4 (sm) - Support for more Intuos models, menustrip 19 19 * relative mode, proximity. 20 20 * v0.5 (vp) - Big cleanup, nifty features removed, 21 - * they belong in userspace 21 + * they belong in userspace 22 22 * v1.8 (vp) - Submit URB only when operating, moved to CVS, 23 23 * use input_report_key instead of report_btn and 24 24 * other cleanups ··· 51 51 * - Cleanups here and there 52 52 * v1.30.1 (pi) - Added Graphire3 support 53 53 * v1.40 (pc) - Add support for several new devices, fix eraser reporting, ... 54 + * v1.43 (pc) - Added support for Cintiq 21UX 55 + - Fixed a Graphire bug 56 + - Merged wacom_intuos3_irq into wacom_intuos_irq 54 57 */ 55 58 56 59 /* ··· 75 72 /* 76 73 * Version Information 77 74 */ 78 - #define DRIVER_VERSION "v1.40" 75 + #define DRIVER_VERSION "v1.43" 79 76 #define DRIVER_AUTHOR "Vojtech Pavlik <vojtech@ucw.cz>" 80 77 #define DRIVER_DESC "USB Wacom Graphire and Wacom Intuos tablet driver" 81 78 #define DRIVER_LICENSE "GPL" ··· 85 82 MODULE_LICENSE(DRIVER_LICENSE); 86 83 87 84 #define USB_VENDOR_ID_WACOM 0x056a 85 + 86 + enum { 87 + PENPARTNER = 0, 88 + GRAPHIRE, 89 + PL, 90 + INTUOS, 91 + INTUOS3, 92 + CINTIQ, 93 + MAX_TYPE 94 + }; 88 95 89 96 struct wacom_features { 90 97 char *name; ··· 115 102 struct urb *irq; 116 103 struct wacom_features *features; 117 104 int tool[2]; 118 - int open; 119 105 __u32 serial[2]; 120 106 char phys[32]; 121 107 }; ··· 161 149 prox = data[1] & 0x40; 162 150 163 151 input_regs(dev, regs); 164 - 152 + 165 153 if (prox) { 166 154 167 155 pressure = (signed char)((data[7] << 1) | ((data[4] >> 2) & 1)); ··· 178 166 if (!wacom->tool[0]) { 179 167 /* Going into proximity select tool */ 180 168 wacom->tool[1] = (data[4] & 0x20)? BTN_TOOL_RUBBER : BTN_TOOL_PEN; 181 - } 182 - else { 169 + } else { 183 170 /* was entered with stylus2 pressed */ 184 171 if (wacom->tool[1] == BTN_TOOL_RUBBER && !(data[4] & 0x20) ) { 185 172 /* report out proximity for previous tool */ ··· 193 182 wacom->tool[1] = BTN_TOOL_PEN; 194 183 } 195 184 input_report_key(dev, wacom->tool[1], prox); /* report in proximity for tool */ 196 - input_report_abs(dev, ABS_X, data[3] | ((__u32)data[2] << 7) | ((__u32)(data[1] & 0x03) << 14)); 197 - input_report_abs(dev, ABS_Y, data[6] | ((__u32)data[5] << 7) | ((__u32)(data[4] & 0x03) << 14)); 185 + input_report_abs(dev, ABS_X, data[3] | (data[2] << 7) | ((data[1] & 0x03) << 14)); 186 + input_report_abs(dev, ABS_Y, data[6] | (data[5] << 7) | ((data[4] & 0x03) << 14)); 198 187 input_report_abs(dev, ABS_PRESSURE, pressure); 199 188 200 189 input_report_key(dev, BTN_TOUCH, data[4] & 0x08); 201 190 input_report_key(dev, BTN_STYLUS, data[4] & 0x10); 202 191 /* Only allow the stylus2 button to be reported for the pen tool. */ 203 192 input_report_key(dev, BTN_STYLUS2, (wacom->tool[1] == BTN_TOOL_PEN) && (data[4] & 0x20)); 204 - } 205 - else { 193 + } else { 206 194 /* report proximity-out of a (valid) tool */ 207 195 if (wacom->tool[1] != BTN_TOOL_RUBBER) { 208 196 /* Unknown tool selected default to pen tool */ ··· 213 203 wacom->tool[0] = prox; /* Save proximity state */ 214 204 input_sync(dev); 215 205 216 - exit: 206 + exit: 217 207 retval = usb_submit_urb (urb, GFP_ATOMIC); 218 208 if (retval) 219 209 err ("%s - usb_submit_urb failed with result %d", ··· 242 232 goto exit; 243 233 } 244 234 245 - if (data[0] != 2) 246 - { 235 + if (data[0] != 2) { 247 236 printk(KERN_INFO "wacom_ptu_irq: received unknown report #%d\n", data[0]); 248 237 goto exit; 249 238 } 250 239 251 240 input_regs(dev, regs); 252 - if (data[1] & 0x04) 253 - { 241 + if (data[1] & 0x04) { 254 242 input_report_key(dev, BTN_TOOL_RUBBER, data[1] & 0x20); 255 243 input_report_key(dev, BTN_TOUCH, data[1] & 0x08); 256 - } 257 - else 258 - { 244 + } else { 259 245 input_report_key(dev, BTN_TOOL_PEN, data[1] & 0x20); 260 246 input_report_key(dev, BTN_TOUCH, data[1] & 0x01); 261 247 } ··· 263 257 264 258 input_sync(dev); 265 259 266 - exit: 260 + exit: 267 261 retval = usb_submit_urb (urb, GFP_ATOMIC); 268 262 if (retval) 269 263 err ("%s - usb_submit_urb failed with result %d", ··· 306 300 input_report_key(dev, BTN_STYLUS, (data[5] & 0x40)); 307 301 input_sync(dev); 308 302 309 - exit: 303 + exit: 310 304 retval = usb_submit_urb (urb, GFP_ATOMIC); 311 305 if (retval) 312 306 err ("%s - usb_submit_urb failed with result %d", ··· 346 340 347 341 input_regs(dev, regs); 348 342 349 - switch ((data[1] >> 5) & 3) { 343 + if (data[1] & 0x10) { /* in prox */ 350 344 351 - case 0: /* Pen */ 352 - input_report_key(dev, BTN_TOOL_PEN, data[1] & 0x80); 353 - break; 345 + switch ((data[1] >> 5) & 3) { 354 346 355 - case 1: /* Rubber */ 356 - input_report_key(dev, BTN_TOOL_RUBBER, data[1] & 0x80); 357 - break; 347 + case 0: /* Pen */ 348 + wacom->tool[0] = BTN_TOOL_PEN; 349 + break; 358 350 359 - case 2: /* Mouse with wheel */ 360 - input_report_key(dev, BTN_MIDDLE, data[1] & 0x04); 361 - input_report_rel(dev, REL_WHEEL, (signed char) data[6]); 362 - /* fall through */ 351 + case 1: /* Rubber */ 352 + wacom->tool[0] = BTN_TOOL_RUBBER; 353 + break; 363 354 364 - case 3: /* Mouse without wheel */ 365 - input_report_key(dev, BTN_TOOL_MOUSE, data[7] > 24); 366 - input_report_key(dev, BTN_LEFT, data[1] & 0x01); 367 - input_report_key(dev, BTN_RIGHT, data[1] & 0x02); 368 - input_report_abs(dev, ABS_DISTANCE, data[7]); 355 + case 2: /* Mouse with wheel */ 356 + input_report_key(dev, BTN_MIDDLE, data[1] & 0x04); 357 + input_report_rel(dev, REL_WHEEL, (signed char) data[6]); 358 + /* fall through */ 369 359 370 - input_report_abs(dev, ABS_X, x); 371 - input_report_abs(dev, ABS_Y, y); 372 - 373 - input_sync(dev); 374 - goto exit; 360 + case 3: /* Mouse without wheel */ 361 + wacom->tool[0] = BTN_TOOL_MOUSE; 362 + input_report_key(dev, BTN_LEFT, data[1] & 0x01); 363 + input_report_key(dev, BTN_RIGHT, data[1] & 0x02); 364 + input_report_abs(dev, ABS_DISTANCE, data[7]); 365 + break; 366 + } 375 367 } 376 368 377 369 if (data[1] & 0x80) { 378 370 input_report_abs(dev, ABS_X, x); 379 371 input_report_abs(dev, ABS_Y, y); 380 372 } 373 + if (wacom->tool[0] != BTN_TOOL_MOUSE) { 374 + input_report_abs(dev, ABS_PRESSURE, le16_to_cpu(*(__le16 *) &data[6])); 375 + input_report_key(dev, BTN_TOUCH, data[1] & 0x01); 376 + input_report_key(dev, BTN_STYLUS, data[1] & 0x02); 377 + input_report_key(dev, BTN_STYLUS2, data[1] & 0x04); 378 + } 381 379 382 - input_report_abs(dev, ABS_PRESSURE, le16_to_cpu(*(__le16 *) &data[6])); 383 - input_report_key(dev, BTN_TOUCH, data[1] & 0x01); 384 - input_report_key(dev, BTN_STYLUS, data[1] & 0x02); 385 - input_report_key(dev, BTN_STYLUS2, data[1] & 0x04); 386 - 380 + input_report_key(dev, wacom->tool[0], data[1] & 0x10); 387 381 input_sync(dev); 388 382 389 - exit: 383 + exit: 390 384 retval = usb_submit_urb (urb, GFP_ATOMIC); 391 385 if (retval) 392 386 err ("%s - usb_submit_urb failed with result %d", ··· 404 398 idx = data[1] & 0x01; 405 399 406 400 /* Enter report */ 407 - if ((data[1] & 0xfc) == 0xc0) 408 - { 401 + if ((data[1] & 0xfc) == 0xc0) { 409 402 /* serial number of the tool */ 410 - wacom->serial[idx] = ((__u32)(data[3] & 0x0f) << 28) + 411 - ((__u32)data[4] << 20) + ((__u32)data[5] << 12) + 412 - ((__u32)data[6] << 4) + (data[7] >> 4); 403 + wacom->serial[idx] = ((data[3] & 0x0f) << 28) + 404 + (data[4] << 20) + (data[5] << 12) + 405 + (data[6] << 4) + (data[7] >> 4); 413 406 414 - switch (((__u32)data[2] << 4) | (data[3] >> 4)) { 407 + switch ((data[2] << 4) | (data[3] >> 4)) { 415 408 case 0x812: /* Inking pen */ 416 409 case 0x801: /* Intuos3 Inking pen */ 417 410 case 0x012: ··· 454 449 case 0x112: 455 450 case 0x913: /* Intuos3 Airbrush */ 456 451 wacom->tool[idx] = BTN_TOOL_AIRBRUSH; 457 - break; /* Airbrush */ 452 + break; 458 453 default: /* Unknown tool */ 459 454 wacom->tool[idx] = BTN_TOOL_PEN; 460 455 } ··· 483 478 unsigned int t; 484 479 485 480 /* general pen packet */ 486 - if ((data[1] & 0xb8) == 0xa0) 487 - { 488 - t = ((__u32)data[6] << 2) | ((data[7] >> 6) & 3); 481 + if ((data[1] & 0xb8) == 0xa0) { 482 + t = (data[6] << 2) | ((data[7] >> 6) & 3); 489 483 input_report_abs(dev, ABS_PRESSURE, t); 490 484 input_report_abs(dev, ABS_TILT_X, 491 485 ((data[7] << 1) & 0x7e) | (data[8] >> 7)); ··· 495 491 } 496 492 497 493 /* airbrush second packet */ 498 - if ((data[1] & 0xbc) == 0xb4) 499 - { 494 + if ((data[1] & 0xbc) == 0xb4) { 500 495 input_report_abs(dev, ABS_WHEEL, 501 - ((__u32)data[6] << 2) | ((data[7] >> 6) & 3)); 496 + (data[6] << 2) | ((data[7] >> 6) & 3)); 502 497 input_report_abs(dev, ABS_TILT_X, 503 498 ((data[7] << 1) & 0x7e) | (data[8] >> 7)); 504 499 input_report_abs(dev, ABS_TILT_Y, data[8] & 0x7f); ··· 529 526 goto exit; 530 527 } 531 528 532 - if (data[0] != 2 && data[0] != 5 && data[0] != 6) { 529 + if (data[0] != 2 && data[0] != 5 && data[0] != 6 && data[0] != 12) { 533 530 dbg("wacom_intuos_irq: received unknown report #%d", data[0]); 534 531 goto exit; 535 532 } ··· 539 536 /* tool number */ 540 537 idx = data[1] & 0x01; 541 538 542 - /* process in/out prox events */ 543 - if (wacom_intuos_inout(urb)) goto exit; 544 - 545 - input_report_abs(dev, ABS_X, be16_to_cpu(*(__be16 *) &data[2])); 546 - input_report_abs(dev, ABS_Y, be16_to_cpu(*(__be16 *) &data[4])); 547 - input_report_abs(dev, ABS_DISTANCE, data[9]); 548 - 549 - /* process general packets */ 550 - wacom_intuos_general(urb); 551 - 552 - if ((data[1] & 0xbc) == 0xa8 || (data[1] & 0xbe) == 0xb0) { /* 4D mouse or Lens cursor packets */ 553 - 554 - if (data[1] & 0x02) { /* Rotation packet */ 555 - 556 - t = ((__u32)data[6] << 3) | ((data[7] >> 5) & 7); 557 - input_report_abs(dev, ABS_RZ, (data[7] & 0x20) ? ((t - 1) / 2) : -t / 2); 558 - 559 - } else { 560 - 561 - if ((data[1] & 0x10) == 0) { /* 4D mouse packets */ 562 - 563 - input_report_key(dev, BTN_LEFT, data[8] & 0x01); 564 - input_report_key(dev, BTN_MIDDLE, data[8] & 0x02); 565 - input_report_key(dev, BTN_RIGHT, data[8] & 0x04); 566 - 567 - input_report_key(dev, BTN_SIDE, data[8] & 0x20); 568 - input_report_key(dev, BTN_EXTRA, data[8] & 0x10); 569 - t = ((__u32)data[6] << 2) | ((data[7] >> 6) & 3); 570 - input_report_abs(dev, ABS_THROTTLE, (data[8] & 0x08) ? -t : t); 571 - 572 - } else { 573 - if (wacom->tool[idx] == BTN_TOOL_MOUSE) { /* 2D mouse packets */ 574 - input_report_key(dev, BTN_LEFT, data[8] & 0x04); 575 - input_report_key(dev, BTN_MIDDLE, data[8] & 0x08); 576 - input_report_key(dev, BTN_RIGHT, data[8] & 0x10); 577 - input_report_rel(dev, REL_WHEEL, 578 - (-(__u32)(data[8] & 0x01) + (__u32)((data[8] & 0x02) >> 1))); 579 - } 580 - else { /* Lens cursor packets */ 581 - input_report_key(dev, BTN_LEFT, data[8] & 0x01); 582 - input_report_key(dev, BTN_MIDDLE, data[8] & 0x02); 583 - input_report_key(dev, BTN_RIGHT, data[8] & 0x04); 584 - input_report_key(dev, BTN_SIDE, data[8] & 0x10); 585 - input_report_key(dev, BTN_EXTRA, data[8] & 0x08); 586 - } 587 - } 588 - } 589 - } 590 - 591 - input_report_key(dev, wacom->tool[idx], 1); 592 - input_event(dev, EV_MSC, MSC_SERIAL, wacom->serial[idx]); 593 - input_sync(dev); 594 - 595 - exit: 596 - retval = usb_submit_urb (urb, GFP_ATOMIC); 597 - if (retval) 598 - err ("%s - usb_submit_urb failed with result %d", 599 - __FUNCTION__, retval); 600 - } 601 - 602 - static void wacom_intuos3_irq(struct urb *urb, struct pt_regs *regs) 603 - { 604 - struct wacom *wacom = urb->context; 605 - unsigned char *data = wacom->data; 606 - struct input_dev *dev = &wacom->dev; 607 - unsigned int t; 608 - int idx, retval; 609 - 610 - switch (urb->status) { 611 - case 0: 612 - /* success */ 613 - break; 614 - case -ECONNRESET: 615 - case -ENOENT: 616 - case -ESHUTDOWN: 617 - /* this urb is terminated, clean up */ 618 - dbg("%s - urb shutting down with status: %d", __FUNCTION__, urb->status); 619 - return; 620 - default: 621 - dbg("%s - nonzero urb status received: %d", __FUNCTION__, urb->status); 622 - goto exit; 623 - } 624 - 625 - /* check for valid report */ 626 - if (data[0] != 2 && data[0] != 5 && data[0] != 12) 627 - { 628 - printk(KERN_INFO "wacom_intuos3_irq: received unknown report #%d\n", data[0]); 629 - goto exit; 630 - } 631 - 632 - input_regs(dev, regs); 633 - 634 - /* tool index is always 0 here since there is no dual input tool */ 635 - idx = data[1] & 0x01; 636 - 637 539 /* pad packets. Works as a second tool and is always in prox */ 638 - if (data[0] == 12) 639 - { 540 + if (data[0] == 12) { 640 541 /* initiate the pad as a device */ 641 - if (wacom->tool[1] != BTN_TOOL_FINGER) 642 - { 542 + if (wacom->tool[1] != BTN_TOOL_FINGER) { 643 543 wacom->tool[1] = BTN_TOOL_FINGER; 644 544 input_report_key(dev, wacom->tool[1], 1); 645 545 } ··· 562 656 } 563 657 564 658 /* process in/out prox events */ 565 - if (wacom_intuos_inout(urb)) goto exit; 659 + if (wacom_intuos_inout(urb)) 660 + goto exit; 566 661 567 - input_report_abs(dev, ABS_X, ((__u32)data[2] << 9) | ((__u32)data[3] << 1) | ((data[9] >> 1) & 1)); 568 - input_report_abs(dev, ABS_Y, ((__u32)data[4] << 9) | ((__u32)data[5] << 1) | (data[9] & 1)); 569 - input_report_abs(dev, ABS_DISTANCE, ((data[9] >> 2) & 0x3f)); 662 + /* Cintiq doesn't send data when RDY bit isn't set */ 663 + if ((wacom->features->type == CINTIQ) && !(data[1] & 0x40)) 664 + return; 665 + 666 + if (wacom->features->type >= INTUOS3) { 667 + input_report_abs(dev, ABS_X, (data[2] << 9) | (data[3] << 1) | ((data[9] >> 1) & 1)); 668 + input_report_abs(dev, ABS_Y, (data[4] << 9) | (data[5] << 1) | (data[9] & 1)); 669 + input_report_abs(dev, ABS_DISTANCE, ((data[9] >> 2) & 0x3f)); 670 + } else { 671 + input_report_abs(dev, ABS_X, be16_to_cpu(*(__be16 *) &data[2])); 672 + input_report_abs(dev, ABS_Y, be16_to_cpu(*(__be16 *) &data[4])); 673 + input_report_abs(dev, ABS_DISTANCE, ((data[9] >> 3) & 0x1f)); 674 + } 570 675 571 676 /* process general packets */ 572 677 wacom_intuos_general(urb); 573 678 574 - if ((data[1] & 0xbc) == 0xa8 || (data[1] & 0xbe) == 0xb0) 575 - { 576 - /* Marker pen rotation packet. Reported as wheel due to valuator limitation */ 577 - if (data[1] & 0x02) 578 - { 579 - t = ((__u32)data[6] << 3) | ((data[7] >> 5) & 7); 580 - t = (data[7] & 0x20) ? ((t > 900) ? ((t-1) / 2 - 1350) : 581 - ((t-1) / 2 + 450)) : (450 - t / 2) ; 582 - input_report_abs(dev, ABS_WHEEL, t); 583 - } 679 + /* 4D mouse, 2D mouse, marker pen rotation, or Lens cursor packets */ 680 + if ((data[1] & 0xbc) == 0xa8 || (data[1] & 0xbe) == 0xb0) { 584 681 585 - /* 2D mouse packets */ 586 - if (wacom->tool[idx] == BTN_TOOL_MOUSE) 587 - { 682 + if (data[1] & 0x02) { 683 + /* Rotation packet */ 684 + if (wacom->features->type >= INTUOS3) { 685 + /* I3 marker pen rotation reported as wheel 686 + * due to valuator limitation 687 + */ 688 + t = (data[6] << 3) | ((data[7] >> 5) & 7); 689 + t = (data[7] & 0x20) ? ((t > 900) ? ((t-1) / 2 - 1350) : 690 + ((t-1) / 2 + 450)) : (450 - t / 2) ; 691 + input_report_abs(dev, ABS_WHEEL, t); 692 + } else { 693 + /* 4D mouse rotation packet */ 694 + t = (data[6] << 3) | ((data[7] >> 5) & 7); 695 + input_report_abs(dev, ABS_RZ, (data[7] & 0x20) ? 696 + ((t - 1) / 2) : -t / 2); 697 + } 698 + 699 + } else if (!(data[1] & 0x10) && wacom->features->type < INTUOS3) { 700 + /* 4D mouse packet */ 701 + input_report_key(dev, BTN_LEFT, data[8] & 0x01); 702 + input_report_key(dev, BTN_MIDDLE, data[8] & 0x02); 703 + input_report_key(dev, BTN_RIGHT, data[8] & 0x04); 704 + 705 + input_report_key(dev, BTN_SIDE, data[8] & 0x20); 706 + input_report_key(dev, BTN_EXTRA, data[8] & 0x10); 707 + t = (data[6] << 2) | ((data[7] >> 6) & 3); 708 + input_report_abs(dev, ABS_THROTTLE, (data[8] & 0x08) ? -t : t); 709 + 710 + } else if (wacom->tool[idx] == BTN_TOOL_MOUSE) { 711 + /* 2D mouse packet */ 588 712 input_report_key(dev, BTN_LEFT, data[8] & 0x04); 589 713 input_report_key(dev, BTN_MIDDLE, data[8] & 0x08); 590 714 input_report_key(dev, BTN_RIGHT, data[8] & 0x10); 591 - input_report_key(dev, BTN_SIDE, data[8] & 0x40); 592 - input_report_key(dev, BTN_EXTRA, data[8] & 0x20); 593 - /* mouse wheel is positive when rolled backwards */ 594 - input_report_rel(dev, REL_WHEEL, ((__u32)((data[8] & 0x02) >> 1) 595 - - (__u32)(data[8] & 0x01))); 715 + input_report_rel(dev, REL_WHEEL, ((data[8] & 0x02) >> 1) 716 + - (data[8] & 0x01)); 717 + 718 + /* I3 2D mouse side buttons */ 719 + if (wacom->features->type == INTUOS3) { 720 + input_report_key(dev, BTN_SIDE, data[8] & 0x40); 721 + input_report_key(dev, BTN_EXTRA, data[8] & 0x20); 722 + } 723 + 724 + } else if (wacom->features->type < INTUOS3) { 725 + /* Lens cursor packets */ 726 + input_report_key(dev, BTN_LEFT, data[8] & 0x01); 727 + input_report_key(dev, BTN_MIDDLE, data[8] & 0x02); 728 + input_report_key(dev, BTN_RIGHT, data[8] & 0x04); 729 + input_report_key(dev, BTN_SIDE, data[8] & 0x10); 730 + input_report_key(dev, BTN_EXTRA, data[8] & 0x08); 596 731 } 597 732 } 598 733 ··· 649 702 } 650 703 651 704 static struct wacom_features wacom_features[] = { 652 - { "Wacom Penpartner", 7, 5040, 3780, 255, 32, 0, wacom_penpartner_irq }, 653 - { "Wacom Graphire", 8, 10206, 7422, 511, 32, 1, wacom_graphire_irq }, 654 - { "Wacom Graphire2 4x5", 8, 10206, 7422, 511, 32, 1, wacom_graphire_irq }, 655 - { "Wacom Graphire2 5x7", 8, 13918, 10206, 511, 32, 1, wacom_graphire_irq }, 656 - { "Wacom Graphire3", 8, 10208, 7424, 511, 32, 1, wacom_graphire_irq }, 657 - { "Wacom Graphire3 6x8", 8, 16704, 12064, 511, 32, 1, wacom_graphire_irq }, 658 - { "Wacom Intuos 4x5", 10, 12700, 10600, 1023, 15, 2, wacom_intuos_irq }, 659 - { "Wacom Intuos 6x8", 10, 20320, 16240, 1023, 15, 2, wacom_intuos_irq }, 660 - { "Wacom Intuos 9x12", 10, 30480, 24060, 1023, 15, 2, wacom_intuos_irq }, 661 - { "Wacom Intuos 12x12", 10, 30480, 31680, 1023, 15, 2, wacom_intuos_irq }, 662 - { "Wacom Intuos 12x18", 10, 45720, 31680, 1023, 15, 2, wacom_intuos_irq }, 663 - { "Wacom PL400", 8, 5408, 4056, 255, 32, 3, wacom_pl_irq }, 664 - { "Wacom PL500", 8, 6144, 4608, 255, 32, 3, wacom_pl_irq }, 665 - { "Wacom PL600", 8, 6126, 4604, 255, 32, 3, wacom_pl_irq }, 666 - { "Wacom PL600SX", 8, 6260, 5016, 255, 32, 3, wacom_pl_irq }, 667 - { "Wacom PL550", 8, 6144, 4608, 511, 32, 3, wacom_pl_irq }, 668 - { "Wacom PL800", 8, 7220, 5780, 511, 32, 3, wacom_pl_irq }, 669 - { "Wacom Intuos2 4x5", 10, 12700, 10600, 1023, 15, 2, wacom_intuos_irq }, 670 - { "Wacom Intuos2 6x8", 10, 20320, 16240, 1023, 15, 2, wacom_intuos_irq }, 671 - { "Wacom Intuos2 9x12", 10, 30480, 24060, 1023, 15, 2, wacom_intuos_irq }, 672 - { "Wacom Intuos2 12x12", 10, 30480, 31680, 1023, 15, 2, wacom_intuos_irq }, 673 - { "Wacom Intuos2 12x18", 10, 45720, 31680, 1023, 15, 2, wacom_intuos_irq }, 674 - { "Wacom Volito", 8, 5104, 3712, 511, 32, 1, wacom_graphire_irq }, 675 - { "Wacom Cintiq Partner",8, 20480, 15360, 511, 32, 3, wacom_ptu_irq }, 676 - { "Wacom Intuos3 4x5", 10, 25400, 20320, 1023, 15, 4, wacom_intuos3_irq }, 677 - { "Wacom Intuos3 6x8", 10, 40640, 30480, 1023, 15, 4, wacom_intuos3_irq }, 678 - { "Wacom Intuos3 9x12", 10, 60960, 45720, 1023, 15, 4, wacom_intuos3_irq }, 679 - { "Wacom Intuos2 6x8", 10, 20320, 16240, 1023, 15, 2, wacom_intuos_irq }, 680 - { } 705 + { "Wacom Penpartner", 7, 5040, 3780, 255, 32, PENPARTNER, wacom_penpartner_irq }, 706 + { "Wacom Graphire", 8, 10206, 7422, 511, 32, GRAPHIRE, wacom_graphire_irq }, 707 + { "Wacom Graphire2 4x5", 8, 10206, 7422, 511, 32, GRAPHIRE, wacom_graphire_irq }, 708 + { "Wacom Graphire2 5x7", 8, 13918, 10206, 511, 32, GRAPHIRE, wacom_graphire_irq }, 709 + { "Wacom Graphire3", 8, 10208, 7424, 511, 32, GRAPHIRE, wacom_graphire_irq }, 710 + { "Wacom Graphire3 6x8", 8, 16704, 12064, 511, 32, GRAPHIRE, wacom_graphire_irq }, 711 + { "Wacom Intuos 4x5", 10, 12700, 10600, 1023, 15, INTUOS, wacom_intuos_irq }, 712 + { "Wacom Intuos 6x8", 10, 20320, 16240, 1023, 15, INTUOS, wacom_intuos_irq }, 713 + { "Wacom Intuos 9x12", 10, 30480, 24060, 1023, 15, INTUOS, wacom_intuos_irq }, 714 + { "Wacom Intuos 12x12", 10, 30480, 31680, 1023, 15, INTUOS, wacom_intuos_irq }, 715 + { "Wacom Intuos 12x18", 10, 45720, 31680, 1023, 15, INTUOS, wacom_intuos_irq }, 716 + { "Wacom PL400", 8, 5408, 4056, 255, 32, PL, wacom_pl_irq }, 717 + { "Wacom PL500", 8, 6144, 4608, 255, 32, PL, wacom_pl_irq }, 718 + { "Wacom PL600", 8, 6126, 4604, 255, 32, PL, wacom_pl_irq }, 719 + { "Wacom PL600SX", 8, 6260, 5016, 255, 32, PL, wacom_pl_irq }, 720 + { "Wacom PL550", 8, 6144, 4608, 511, 32, PL, wacom_pl_irq }, 721 + { "Wacom PL800", 8, 7220, 5780, 511, 32, PL, wacom_pl_irq }, 722 + { "Wacom Intuos2 4x5", 10, 12700, 10600, 1023, 15, INTUOS, wacom_intuos_irq }, 723 + { "Wacom Intuos2 6x8", 10, 20320, 16240, 1023, 15, INTUOS, wacom_intuos_irq }, 724 + { "Wacom Intuos2 9x12", 10, 30480, 24060, 1023, 15, INTUOS, wacom_intuos_irq }, 725 + { "Wacom Intuos2 12x12", 10, 30480, 31680, 1023, 15, INTUOS, wacom_intuos_irq }, 726 + { "Wacom Intuos2 12x18", 10, 45720, 31680, 1023, 15, INTUOS, wacom_intuos_irq }, 727 + { "Wacom Volito", 8, 5104, 3712, 511, 32, GRAPHIRE, wacom_graphire_irq }, 728 + { "Wacom Cintiq Partner",8, 20480, 15360, 511, 32, PL, wacom_ptu_irq }, 729 + { "Wacom Intuos3 4x5", 10, 25400, 20320, 1023, 15, INTUOS3, wacom_intuos_irq }, 730 + { "Wacom Intuos3 6x8", 10, 40640, 30480, 1023, 15, INTUOS3, wacom_intuos_irq }, 731 + { "Wacom Intuos3 9x12", 10, 60960, 45720, 1023, 15, INTUOS3, wacom_intuos_irq }, 732 + { "Wacom Cintiq 21UX", 10, 87200, 65600, 1023, 15, CINTIQ, wacom_intuos_irq }, 733 + { "Wacom Intuos2 6x8", 10, 20320, 16240, 1023, 15, INTUOS, wacom_intuos_irq }, 734 + { } 681 735 }; 682 736 683 737 static struct usb_device_id wacom_ids[] = { ··· 709 761 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0xB0) }, 710 762 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0xB1) }, 711 763 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0xB2) }, 764 + { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x3F) }, 712 765 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x47) }, 713 766 { } 714 767 }; ··· 720 771 { 721 772 struct wacom *wacom = dev->private; 722 773 723 - if (wacom->open++) 724 - return 0; 725 - 726 774 wacom->irq->dev = wacom->usbdev; 727 - if (usb_submit_urb(wacom->irq, GFP_KERNEL)) { 728 - wacom->open--; 775 + if (usb_submit_urb(wacom->irq, GFP_KERNEL)) 729 776 return -EIO; 730 - } 731 777 732 778 return 0; 733 779 } ··· 731 787 { 732 788 struct wacom *wacom = dev->private; 733 789 734 - if (!--wacom->open) 735 - usb_kill_urb(wacom->irq); 790 + usb_kill_urb(wacom->irq); 736 791 } 737 792 738 793 static int wacom_probe(struct usb_interface *intf, const struct usb_device_id *id) ··· 766 823 wacom->dev.keybit[LONG(BTN_DIGI)] |= BIT(BTN_TOOL_PEN) | BIT(BTN_TOUCH) | BIT(BTN_STYLUS); 767 824 768 825 switch (wacom->features->type) { 769 - case 1: 826 + case GRAPHIRE: 770 827 wacom->dev.evbit[0] |= BIT(EV_REL); 771 828 wacom->dev.relbit[0] |= BIT(REL_WHEEL); 772 829 wacom->dev.absbit[0] |= BIT(ABS_DISTANCE); 773 830 wacom->dev.keybit[LONG(BTN_LEFT)] |= BIT(BTN_LEFT) | BIT(BTN_RIGHT) | BIT(BTN_MIDDLE); 774 - wacom->dev.keybit[LONG(BTN_DIGI)] |= BIT(BTN_TOOL_RUBBER) | BIT(BTN_TOOL_MOUSE) | BIT(BTN_STYLUS2); 831 + wacom->dev.keybit[LONG(BTN_DIGI)] |= BIT(BTN_TOOL_RUBBER) | BIT(BTN_TOOL_MOUSE) | BIT(BTN_STYLUS2); 775 832 break; 776 833 777 - case 4: /* new functions for Intuos3 */ 834 + case INTUOS3: 835 + case CINTIQ: 778 836 wacom->dev.keybit[LONG(BTN_DIGI)] |= BIT(BTN_TOOL_FINGER); 779 837 wacom->dev.keybit[LONG(BTN_LEFT)] |= BIT(BTN_0) | BIT(BTN_1) | BIT(BTN_2) | BIT(BTN_3) | BIT(BTN_4) | BIT(BTN_5) | BIT(BTN_6) | BIT(BTN_7); 780 838 wacom->dev.absbit[0] |= BIT(ABS_RX) | BIT(ABS_RY); 781 839 /* fall through */ 782 840 783 - case 2: 841 + case INTUOS: 784 842 wacom->dev.evbit[0] |= BIT(EV_MSC) | BIT(EV_REL); 785 843 wacom->dev.mscbit[0] |= BIT(MSC_SERIAL); 786 844 wacom->dev.relbit[0] |= BIT(REL_WHEEL); 787 845 wacom->dev.keybit[LONG(BTN_LEFT)] |= BIT(BTN_LEFT) | BIT(BTN_RIGHT) | BIT(BTN_MIDDLE) | BIT(BTN_SIDE) | BIT(BTN_EXTRA); 788 - wacom->dev.keybit[LONG(BTN_DIGI)] |= BIT(BTN_TOOL_RUBBER) | BIT(BTN_TOOL_MOUSE) | BIT(BTN_TOOL_BRUSH) 846 + wacom->dev.keybit[LONG(BTN_DIGI)] |= BIT(BTN_TOOL_RUBBER) | BIT(BTN_TOOL_MOUSE) | BIT(BTN_TOOL_BRUSH) 789 847 | BIT(BTN_TOOL_PENCIL) | BIT(BTN_TOOL_AIRBRUSH) | BIT(BTN_TOOL_LENS) | BIT(BTN_STYLUS2); 790 848 wacom->dev.absbit[0] |= BIT(ABS_DISTANCE) | BIT(ABS_WHEEL) | BIT(ABS_TILT_X) | BIT(ABS_TILT_Y) | BIT(ABS_RZ) | BIT(ABS_THROTTLE); 791 849 break; 792 850 793 - case 3: 794 - wacom->dev.keybit[LONG(BTN_DIGI)] |= BIT(BTN_STYLUS2) | BIT(BTN_TOOL_RUBBER); 851 + case PL: 852 + wacom->dev.keybit[LONG(BTN_DIGI)] |= BIT(BTN_STYLUS2) | BIT(BTN_TOOL_RUBBER); 795 853 break; 796 854 } 797 855
+34 -41
drivers/usb/input/xpad.c
··· 104 104 struct usb_xpad { 105 105 struct input_dev dev; /* input device interface */ 106 106 struct usb_device *udev; /* usb device */ 107 - 107 + 108 108 struct urb *irq_in; /* urb for interrupt in report */ 109 109 unsigned char *idata; /* input data */ 110 110 dma_addr_t idata_dma; 111 - 111 + 112 112 char phys[65]; /* physical device path */ 113 - int open_count; /* reference count */ 114 113 }; 115 114 116 115 /* ··· 127 128 struct input_dev *dev = &xpad->dev; 128 129 129 130 input_regs(dev, regs); 130 - 131 + 131 132 /* left stick */ 132 133 input_report_abs(dev, ABS_X, (__s16) (((__s16)data[13] << 8) | data[12])); 133 134 input_report_abs(dev, ABS_Y, (__s16) (((__s16)data[15] << 8) | data[14])); 134 - 135 + 135 136 /* right stick */ 136 137 input_report_abs(dev, ABS_RX, (__s16) (((__s16)data[17] << 8) | data[16])); 137 138 input_report_abs(dev, ABS_RY, (__s16) (((__s16)data[19] << 8) | data[18])); 138 - 139 + 139 140 /* triggers left/right */ 140 141 input_report_abs(dev, ABS_Z, data[10]); 141 142 input_report_abs(dev, ABS_RZ, data[11]); 142 - 143 + 143 144 /* digital pad */ 144 145 input_report_abs(dev, ABS_HAT0X, !!(data[2] & 0x08) - !!(data[2] & 0x04)); 145 146 input_report_abs(dev, ABS_HAT0Y, !!(data[2] & 0x02) - !!(data[2] & 0x01)); 146 - 147 + 147 148 /* start/back buttons and stick press left/right */ 148 149 input_report_key(dev, BTN_START, (data[2] & 0x10) >> 4); 149 150 input_report_key(dev, BTN_BACK, (data[2] & 0x20) >> 5); 150 151 input_report_key(dev, BTN_THUMBL, (data[2] & 0x40) >> 6); 151 152 input_report_key(dev, BTN_THUMBR, data[2] >> 7); 152 - 153 + 153 154 /* "analog" buttons A, B, X, Y */ 154 155 input_report_key(dev, BTN_A, data[4]); 155 156 input_report_key(dev, BTN_B, data[5]); 156 157 input_report_key(dev, BTN_X, data[6]); 157 158 input_report_key(dev, BTN_Y, data[7]); 158 - 159 + 159 160 /* "analog" buttons black, white */ 160 161 input_report_key(dev, BTN_C, data[8]); 161 162 input_report_key(dev, BTN_Z, data[9]); ··· 167 168 { 168 169 struct usb_xpad *xpad = urb->context; 169 170 int retval; 170 - 171 + 171 172 switch (urb->status) { 172 173 case 0: 173 174 /* success */ ··· 182 183 dbg("%s - nonzero urb status received: %d", __FUNCTION__, urb->status); 183 184 goto exit; 184 185 } 185 - 186 + 186 187 xpad_process_packet(xpad, 0, xpad->idata, regs); 187 188 188 189 exit: ··· 195 196 static int xpad_open (struct input_dev *dev) 196 197 { 197 198 struct usb_xpad *xpad = dev->private; 198 - 199 - if (xpad->open_count++) 200 - return 0; 201 - 199 + 202 200 xpad->irq_in->dev = xpad->udev; 203 - if (usb_submit_urb(xpad->irq_in, GFP_KERNEL)) { 204 - xpad->open_count--; 201 + if (usb_submit_urb(xpad->irq_in, GFP_KERNEL)) 205 202 return -EIO; 206 - } 207 - 203 + 208 204 return 0; 209 205 } 210 206 211 207 static void xpad_close (struct input_dev *dev) 212 208 { 213 209 struct usb_xpad *xpad = dev->private; 214 - 215 - if (!--xpad->open_count) 216 - usb_kill_urb(xpad->irq_in); 210 + 211 + usb_kill_urb(xpad->irq_in); 217 212 } 218 213 219 214 static int xpad_probe(struct usb_interface *intf, const struct usb_device_id *id) ··· 217 224 struct usb_endpoint_descriptor *ep_irq_in; 218 225 char path[64]; 219 226 int i; 220 - 227 + 221 228 for (i = 0; xpad_device[i].idVendor; i++) { 222 229 if ((le16_to_cpu(udev->descriptor.idVendor) == xpad_device[i].idVendor) && 223 230 (le16_to_cpu(udev->descriptor.idProduct) == xpad_device[i].idProduct)) 224 231 break; 225 232 } 226 - 233 + 227 234 if ((xpad = kmalloc (sizeof(struct usb_xpad), GFP_KERNEL)) == NULL) { 228 235 err("cannot allocate memory for new pad"); 229 236 return -ENOMEM; 230 237 } 231 238 memset(xpad, 0, sizeof(struct usb_xpad)); 232 - 239 + 233 240 xpad->idata = usb_buffer_alloc(udev, XPAD_PKT_LEN, 234 241 SLAB_ATOMIC, &xpad->idata_dma); 235 242 if (!xpad->idata) { ··· 244 251 kfree(xpad); 245 252 return -ENOMEM; 246 253 } 247 - 254 + 248 255 ep_irq_in = &intf->cur_altsetting->endpoint[0].desc; 249 - 256 + 250 257 usb_fill_int_urb(xpad->irq_in, udev, 251 258 usb_rcvintpipe(udev, ep_irq_in->bEndpointAddress), 252 259 xpad->idata, XPAD_PKT_LEN, xpad_irq_in, 253 260 xpad, ep_irq_in->bInterval); 254 261 xpad->irq_in->transfer_dma = xpad->idata_dma; 255 262 xpad->irq_in->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; 256 - 263 + 257 264 xpad->udev = udev; 258 - 265 + 259 266 xpad->dev.id.bustype = BUS_USB; 260 267 xpad->dev.id.vendor = le16_to_cpu(udev->descriptor.idVendor); 261 268 xpad->dev.id.product = le16_to_cpu(udev->descriptor.idProduct); ··· 266 273 xpad->dev.phys = xpad->phys; 267 274 xpad->dev.open = xpad_open; 268 275 xpad->dev.close = xpad_close; 269 - 276 + 270 277 usb_make_path(udev, path, 64); 271 278 snprintf(xpad->phys, 64, "%s/input0", path); 272 - 279 + 273 280 xpad->dev.evbit[0] = BIT(EV_KEY) | BIT(EV_ABS); 274 - 281 + 275 282 for (i = 0; xpad_btn[i] >= 0; i++) 276 283 set_bit(xpad_btn[i], xpad->dev.keybit); 277 - 284 + 278 285 for (i = 0; xpad_abs[i] >= 0; i++) { 279 - 286 + 280 287 signed short t = xpad_abs[i]; 281 - 288 + 282 289 set_bit(t, xpad->dev.absbit); 283 - 290 + 284 291 switch (t) { 285 292 case ABS_X: 286 293 case ABS_Y: ··· 303 310 break; 304 311 } 305 312 } 306 - 313 + 307 314 input_register_device(&xpad->dev); 308 - 315 + 309 316 printk(KERN_INFO "input: %s on %s", xpad->dev.name, path); 310 - 317 + 311 318 usb_set_intfdata(intf, xpad); 312 319 return 0; 313 320 } ··· 315 322 static void xpad_disconnect(struct usb_interface *intf) 316 323 { 317 324 struct usb_xpad *xpad = usb_get_intfdata (intf); 318 - 325 + 319 326 usb_set_intfdata(intf, NULL); 320 327 if (xpad) { 321 328 usb_kill_urb(xpad->irq_in);
+4
include/linux/input.h
··· 859 859 int (*erase_effect)(struct input_dev *dev, int effect_id); 860 860 861 861 struct input_handle *grab; 862 + 863 + struct semaphore sem; /* serializes open and close operations */ 864 + unsigned int users; 865 + 862 866 struct device *dev; 863 867 864 868 struct list_head h_list;
+25 -8
include/linux/joystick.h
··· 111 111 #define JS_SET_ALL 8 112 112 113 113 struct JS_DATA_TYPE { 114 - int buttons; 115 - int x; 116 - int y; 114 + __s32 buttons; 115 + __s32 x; 116 + __s32 y; 117 117 }; 118 118 119 - struct JS_DATA_SAVE_TYPE { 120 - int JS_TIMEOUT; 121 - int BUSY; 122 - long JS_EXPIRETIME; 123 - long JS_TIMELIMIT; 119 + struct JS_DATA_SAVE_TYPE_32 { 120 + __s32 JS_TIMEOUT; 121 + __s32 BUSY; 122 + __s32 JS_EXPIRETIME; 123 + __s32 JS_TIMELIMIT; 124 124 struct JS_DATA_TYPE JS_SAVE; 125 125 struct JS_DATA_TYPE JS_CORR; 126 126 }; 127 + 128 + struct JS_DATA_SAVE_TYPE_64 { 129 + __s32 JS_TIMEOUT; 130 + __s32 BUSY; 131 + __s64 JS_EXPIRETIME; 132 + __s64 JS_TIMELIMIT; 133 + struct JS_DATA_TYPE JS_SAVE; 134 + struct JS_DATA_TYPE JS_CORR; 135 + }; 136 + 137 + #if BITS_PER_LONG == 64 138 + #define JS_DATA_SAVE_TYPE JS_DATA_SAVE_TYPE_64 139 + #elif BITS_PER_LONG == 32 140 + #define JS_DATA_SAVE_TYPE JS_DATA_SAVE_TYPE_32 141 + #else 142 + #error Unexpected BITS_PER_LONG 143 + #endif 127 144 128 145 #endif /* _LINUX_JOYSTICK_H */
+1
include/linux/libps2.h
··· 41 41 42 42 void ps2_init(struct ps2dev *ps2dev, struct serio *serio); 43 43 int ps2_sendbyte(struct ps2dev *ps2dev, unsigned char byte, int timeout); 44 + void ps2_drain(struct ps2dev *ps2dev, int maxbytes, int timeout); 44 45 int ps2_command(struct ps2dev *ps2dev, unsigned char *param, int command); 45 46 int ps2_schedule_command(struct ps2dev *ps2dev, unsigned char *param, int command); 46 47 int ps2_handle_ack(struct ps2dev *ps2dev, unsigned char data);
+6
include/linux/serio.h
··· 83 83 } 84 84 85 85 void serio_unregister_port(struct serio *serio); 86 + void serio_unregister_child_port(struct serio *serio); 86 87 void __serio_unregister_port_delayed(struct serio *serio, struct module *owner); 87 88 static inline void serio_unregister_port_delayed(struct serio *serio) 88 89 { ··· 152 151 static inline int serio_pin_driver(struct serio *serio) 153 152 { 154 153 return down_interruptible(&serio->drv_sem); 154 + } 155 + 156 + static inline void serio_pin_driver_uninterruptible(struct serio *serio) 157 + { 158 + down(&serio->drv_sem); 155 159 } 156 160 157 161 static inline void serio_unpin_driver(struct serio *serio)
+1 -1
sound/oss/Kconfig
··· 52 52 53 53 config SOUND_CMPCI_JOYSTICK 54 54 bool "Enable joystick" 55 - depends on SOUND_CMPCI && X86 55 + depends on SOUND_CMPCI && X86 && (GAMEPORT=y || SOUND_CMPCI=GAMEPORT) 56 56 help 57 57 Say Y here in order to enable the joystick port on a sound card using 58 58 the CMI8338 or the CMI8738 chipset. You need to config the
+58 -30
sound/oss/es1370.c
··· 162 162 #include <asm/page.h> 163 163 #include <asm/uaccess.h> 164 164 165 + #if defined(CONFIG_GAMEPORT) || (defined(MODULE) && defined(CONFIG_GAMEPORT_MODULE)) 166 + #define SUPPORT_JOYSTICK 167 + #endif 168 + 165 169 /* --------------------------------------------------------------------- */ 166 170 167 171 #undef OSS_DOCUMENTED_MIXER_SEMANTICS ··· 389 385 unsigned char obuf[MIDIOUTBUF]; 390 386 } midi; 391 387 388 + #ifdef SUPPORT_JOYSTICK 392 389 struct gameport *gameport; 390 + #endif 391 + 393 392 struct semaphore sem; 394 393 }; 395 394 ··· 2561 2554 { SOUND_MIXER_WRITE_OGAIN, 0x4040 } 2562 2555 }; 2563 2556 2557 + #ifdef SUPPORT_JOYSTICK 2558 + 2559 + static int __devinit es1370_register_gameport(struct es1370_state *s) 2560 + { 2561 + struct gameport *gp; 2562 + 2563 + if (!request_region(0x200, JOY_EXTENT, "es1370")) { 2564 + printk(KERN_ERR "es1370: joystick io port 0x200 in use\n"); 2565 + return -EBUSY; 2566 + } 2567 + 2568 + s->gameport = gp = gameport_allocate_port(); 2569 + if (!gp) { 2570 + printk(KERN_ERR "es1370: can not allocate memory for gameport\n"); 2571 + release_region(0x200, JOY_EXTENT); 2572 + return -ENOMEM; 2573 + } 2574 + 2575 + gameport_set_name(gp, "ESS1370"); 2576 + gameport_set_phys(gp, "pci%s/gameport0", pci_name(s->dev)); 2577 + gp->dev.parent = &s->dev->dev; 2578 + gp->io = 0x200; 2579 + 2580 + s->ctrl |= CTRL_JYSTK_EN; 2581 + outl(s->ctrl, s->io + ES1370_REG_CONTROL); 2582 + 2583 + gameport_register_port(gp); 2584 + 2585 + return 0; 2586 + } 2587 + 2588 + static inline void es1370_unregister_gameport(struct es1370_state *s) 2589 + { 2590 + if (s->gameport) { 2591 + int gpio = s->gameport->io; 2592 + gameport_unregister_port(s->gameport); 2593 + release_region(gpio, JOY_EXTENT); 2594 + 2595 + } 2596 + } 2597 + 2598 + #else 2599 + static inline int es1370_register_gameport(struct es1370_state *s) { return -ENOSYS; } 2600 + static inline void es1370_unregister_gameport(struct es1370_state *s) { } 2601 + #endif /* SUPPORT_JOYSTICK */ 2602 + 2564 2603 static int __devinit es1370_probe(struct pci_dev *pcidev, const struct pci_device_id *pciid) 2565 2604 { 2566 2605 struct es1370_state *s; 2567 - struct gameport *gp = NULL; 2568 2606 mm_segment_t fs; 2569 2607 int i, val, ret; 2570 2608 ··· 2658 2606 /* note: setting CTRL_SERR_DIS is reported to break 2659 2607 * mic bias setting (by Kim.Berts@fisub.mail.abb.com) */ 2660 2608 s->ctrl = CTRL_CDC_EN | (DAC2_SRTODIV(8000) << CTRL_SH_PCLKDIV) | (1 << CTRL_SH_WTSRSEL); 2661 - if (!request_region(0x200, JOY_EXTENT, "es1370")) { 2662 - printk(KERN_ERR "es1370: joystick io port 0x200 in use\n"); 2663 - } else if (!(s->gameport = gp = gameport_allocate_port())) { 2664 - printk(KERN_ERR "es1370: can not allocate memory for gameport\n"); 2665 - release_region(0x200, JOY_EXTENT); 2666 - } else { 2667 - gameport_set_name(gp, "ESS1370"); 2668 - gameport_set_phys(gp, "pci%s/gameport0", pci_name(s->dev)); 2669 - gp->dev.parent = &s->dev->dev; 2670 - gp->io = 0x200; 2671 - s->ctrl |= CTRL_JYSTK_EN; 2672 - } 2673 2609 if (lineout[devindex]) 2674 2610 s->ctrl |= CTRL_XCTL0; 2675 2611 if (micbias[devindex]) 2676 2612 s->ctrl |= CTRL_XCTL1; 2677 2613 s->sctrl = 0; 2678 - printk(KERN_INFO "es1370: found adapter at io %#lx irq %u\n" 2679 - KERN_INFO "es1370: features: joystick %s, line %s, mic impedance %s\n", 2680 - s->io, s->irq, (s->ctrl & CTRL_JYSTK_EN) ? "on" : "off", 2681 - (s->ctrl & CTRL_XCTL0) ? "out" : "in", 2682 - (s->ctrl & CTRL_XCTL1) ? "1" : "0"); 2614 + printk(KERN_INFO "es1370: adapter at io %#lx irq %u, line %s, mic impedance %s\n", 2615 + s->io, s->irq, (s->ctrl & CTRL_XCTL0) ? "out" : "in", 2616 + (s->ctrl & CTRL_XCTL1) ? "1" : "0"); 2683 2617 /* register devices */ 2684 2618 if ((s->dev_audio = register_sound_dsp(&es1370_audio_fops, -1)) < 0) { 2685 2619 ret = s->dev_audio; ··· 2711 2673 } 2712 2674 set_fs(fs); 2713 2675 2714 - /* register gameport */ 2715 - if (gp) 2716 - gameport_register_port(gp); 2676 + es1370_register_gameport(s); 2717 2677 2718 2678 /* store it in the driver field */ 2719 2679 pci_set_drvdata(pcidev, s); ··· 2733 2697 err_dev1: 2734 2698 printk(KERN_ERR "es1370: cannot register misc device\n"); 2735 2699 free_irq(s->irq, s); 2736 - if (s->gameport) { 2737 - release_region(s->gameport->io, JOY_EXTENT); 2738 - gameport_free_port(s->gameport); 2739 - } 2740 2700 err_irq: 2741 2701 release_region(s->io, ES1370_EXTENT); 2742 2702 err_region: ··· 2751 2719 outl(0, s->io+ES1370_REG_SERIAL_CONTROL); /* clear serial interrupts */ 2752 2720 synchronize_irq(s->irq); 2753 2721 free_irq(s->irq, s); 2754 - if (s->gameport) { 2755 - int gpio = s->gameport->io; 2756 - gameport_unregister_port(s->gameport); 2757 - release_region(gpio, JOY_EXTENT); 2758 - } 2722 + es1370_unregister_gameport(s); 2759 2723 release_region(s->io, ES1370_EXTENT); 2760 2724 unregister_sound_dsp(s->dev_audio); 2761 2725 unregister_sound_mixer(s->dev_mixer);
+63 -32
sound/oss/es1371.c
··· 134 134 #include <asm/page.h> 135 135 #include <asm/uaccess.h> 136 136 137 + #if defined(CONFIG_GAMEPORT) || (defined(MODULE) && defined(CONFIG_GAMEPORT_MODULE)) 138 + #define SUPPORT_JOYSTICK 139 + #endif 140 + 137 141 /* --------------------------------------------------------------------- */ 138 142 139 143 #undef OSS_DOCUMENTED_MIXER_SEMANTICS ··· 458 454 unsigned char obuf[MIDIOUTBUF]; 459 455 } midi; 460 456 457 + #ifdef SUPPORT_JOYSTICK 461 458 struct gameport *gameport; 459 + #endif 460 + 462 461 struct semaphore sem; 463 462 }; 464 463 ··· 2794 2787 { PCI_ANY_ID, PCI_ANY_ID } 2795 2788 }; 2796 2789 2790 + #ifdef SUPPORT_JOYSTICK 2791 + 2792 + static int __devinit es1371_register_gameport(struct es1371_state *s) 2793 + { 2794 + struct gameport *gp; 2795 + int gpio; 2796 + 2797 + for (gpio = 0x218; gpio >= 0x200; gpio -= 0x08) 2798 + if (request_region(gpio, JOY_EXTENT, "es1371")) 2799 + break; 2800 + 2801 + if (gpio < 0x200) { 2802 + printk(KERN_ERR PFX "no free joystick address found\n"); 2803 + return -EBUSY; 2804 + } 2805 + 2806 + s->gameport = gp = gameport_allocate_port(); 2807 + if (!gp) { 2808 + printk(KERN_ERR PFX "can not allocate memory for gameport\n"); 2809 + release_region(gpio, JOY_EXTENT); 2810 + return -ENOMEM; 2811 + } 2812 + 2813 + gameport_set_name(gp, "ESS1371 Gameport"); 2814 + gameport_set_phys(gp, "isa%04x/gameport0", gpio); 2815 + gp->dev.parent = &s->dev->dev; 2816 + gp->io = gpio; 2817 + 2818 + s->ctrl |= CTRL_JYSTK_EN | (((gpio >> 3) & CTRL_JOY_MASK) << CTRL_JOY_SHIFT); 2819 + outl(s->ctrl, s->io + ES1371_REG_CONTROL); 2820 + 2821 + gameport_register_port(gp); 2822 + 2823 + return 0; 2824 + } 2825 + 2826 + static inline void es1371_unregister_gameport(struct es1371_state *s) 2827 + { 2828 + if (s->gameport) { 2829 + int gpio = s->gameport->io; 2830 + gameport_unregister_port(s->gameport); 2831 + release_region(gpio, JOY_EXTENT); 2832 + 2833 + } 2834 + } 2835 + 2836 + #else 2837 + static inline int es1371_register_gameport(struct es1371_state *s) { return -ENOSYS; } 2838 + static inline void es1371_unregister_gameport(struct es1371_state *s) { } 2839 + #endif /* SUPPORT_JOYSTICK */ 2840 + 2841 + 2797 2842 static int __devinit es1371_probe(struct pci_dev *pcidev, const struct pci_device_id *pciid) 2798 2843 { 2799 2844 struct es1371_state *s; 2800 - struct gameport *gp; 2801 2845 mm_segment_t fs; 2802 - int i, gpio, val, res = -1; 2846 + int i, val, res = -1; 2803 2847 int idx; 2804 2848 unsigned long tmo; 2805 2849 signed long tmo2; ··· 2941 2883 } 2942 2884 } 2943 2885 2944 - for (gpio = 0x218; gpio >= 0x200; gpio -= 0x08) 2945 - if (request_region(gpio, JOY_EXTENT, "es1371")) 2946 - break; 2947 - 2948 - if (gpio < 0x200) { 2949 - printk(KERN_ERR PFX "no free joystick address found\n"); 2950 - } else if (!(s->gameport = gp = gameport_allocate_port())) { 2951 - printk(KERN_ERR PFX "can not allocate memory for gameport\n"); 2952 - release_region(gpio, JOY_EXTENT); 2953 - } else { 2954 - gameport_set_name(gp, "ESS1371 Gameport"); 2955 - gameport_set_phys(gp, "isa%04x/gameport0", gpio); 2956 - gp->dev.parent = &s->dev->dev; 2957 - gp->io = gpio; 2958 - s->ctrl |= CTRL_JYSTK_EN | (((gpio >> 3) & CTRL_JOY_MASK) << CTRL_JOY_SHIFT); 2959 - } 2960 - 2961 2886 s->sctrl = 0; 2962 2887 cssr = 0; 2963 2888 s->spdif_volume = -1; ··· 3010 2969 /* turn on S/PDIF output driver if requested */ 3011 2970 outl(cssr, s->io+ES1371_REG_STATUS); 3012 2971 3013 - /* register gameport */ 3014 - if (s->gameport) 3015 - gameport_register_port(s->gameport); 2972 + es1371_register_gameport(s); 3016 2973 3017 2974 /* store it in the driver field */ 3018 2975 pci_set_drvdata(pcidev, s); ··· 3019 2980 /* increment devindex */ 3020 2981 if (devindex < NR_DEVICE-1) 3021 2982 devindex++; 3022 - return 0; 2983 + return 0; 3023 2984 3024 2985 err_gp: 3025 - if (s->gameport) { 3026 - release_region(s->gameport->io, JOY_EXTENT); 3027 - gameport_free_port(s->gameport); 3028 - } 3029 2986 #ifdef ES1371_DEBUG 3030 2987 if (s->ps) 3031 2988 remove_proc_entry("es1371", NULL); ··· 3060 3025 outl(0, s->io+ES1371_REG_SERIAL_CONTROL); /* clear serial interrupts */ 3061 3026 synchronize_irq(s->irq); 3062 3027 free_irq(s->irq, s); 3063 - if (s->gameport) { 3064 - int gpio = s->gameport->io; 3065 - gameport_unregister_port(s->gameport); 3066 - release_region(gpio, JOY_EXTENT); 3067 - } 3028 + es1371_unregister_gameport(s); 3068 3029 release_region(s->io, ES1371_EXTENT); 3069 3030 unregister_sound_dsp(s->dev_audio); 3070 3031 unregister_sound_mixer(s->codec->dev_mixer);
+21 -5
sound/oss/esssolo1.c
··· 150 150 151 151 #define FMODE_DMFM 0x10 152 152 153 + #if defined(CONFIG_GAMEPORT) || (defined(MODULE) && defined(CONFIG_GAMEPORT_MODULE)) 154 + #define SUPPORT_JOYSTICK 1 155 + #endif 156 + 153 157 static struct pci_driver solo1_driver; 154 158 155 159 /* --------------------------------------------------------------------- */ ··· 231 227 unsigned char obuf[MIDIOUTBUF]; 232 228 } midi; 233 229 230 + #if SUPPORT_JOYSTICK 234 231 struct gameport *gameport; 232 + #endif 235 233 }; 236 234 237 235 /* --------------------------------------------------------------------- */ ··· 2287 2281 return 0; 2288 2282 } 2289 2283 2284 + #ifdef SUPPORT_JOYSTICK 2290 2285 static int __devinit solo1_register_gameport(struct solo1_state *s, int io_port) 2291 2286 { 2292 2287 struct gameport *gp; ··· 2313 2306 2314 2307 return 0; 2315 2308 } 2309 + 2310 + static inline void solo1_unregister_gameport(struct solo1_state *s) 2311 + { 2312 + if (s->gameport) { 2313 + int gpio = s->gameport->io; 2314 + gameport_unregister_port(s->gameport); 2315 + release_region(gpio, GAMEPORT_EXTENT); 2316 + } 2317 + } 2318 + #else 2319 + static inline int solo1_register_gameport(struct solo1_state *s, int io_port) { return -ENOSYS; } 2320 + static inline void solo1_unregister_gameport(struct solo1_state *s) { } 2321 + #endif /* SUPPORT_JOYSTICK */ 2316 2322 2317 2323 static int __devinit solo1_probe(struct pci_dev *pcidev, const struct pci_device_id *pciid) 2318 2324 { ··· 2458 2438 synchronize_irq(s->irq); 2459 2439 pci_write_config_word(s->dev, 0x60, 0); /* turn off DDMA controller address space */ 2460 2440 free_irq(s->irq, s); 2461 - if (s->gameport) { 2462 - int gpio = s->gameport->io; 2463 - gameport_unregister_port(s->gameport); 2464 - release_region(gpio, GAMEPORT_EXTENT); 2465 - } 2441 + solo1_unregister_gameport(s); 2466 2442 release_region(s->iobase, IOBASE_EXTENT); 2467 2443 release_region(s->sbbase+FMSYNTH_EXTENT, SBBASE_EXTENT-FMSYNTH_EXTENT); 2468 2444 release_region(s->ddmabase, DDMABASE_EXTENT);
+23 -7
sound/oss/mad16.c
··· 50 50 #include "sb.h" 51 51 #include "mpu401.h" 52 52 53 + #if defined(CONFIG_GAMEPORT) || (defined(MODULE) && defined(CONFIG_GAMEPORT_MODULE)) 54 + #define SUPPORT_JOYSTICK 1 55 + #endif 56 + 53 57 static int mad16_conf; 54 58 static int mad16_cdsel; 55 - static struct gameport *gameport; 56 59 static DEFINE_SPINLOCK(lock); 57 60 58 61 #define C928 1 ··· 905 902 -1, -1, -1, -1 906 903 }; 907 904 905 + #ifdef SUPPORT_JOYSTICK 906 + 907 + static struct gameport *gameport; 908 + 908 909 static int __devinit mad16_register_gameport(int io_port) 909 910 { 910 911 if (!request_region(io_port, 1, "mad16 gameport")) { ··· 931 924 932 925 return 0; 933 926 } 927 + 928 + static inline void mad16_unregister_gameport(void) 929 + { 930 + if (gameport) { 931 + /* the gameport was initialized so we must free it up */ 932 + gameport_unregister_port(gameport); 933 + gameport = NULL; 934 + release_region(0x201, 1); 935 + } 936 + } 937 + #else 938 + static inline int mad16_register_gameport(int io_port) { return -ENOSYS; } 939 + static inline void mad16_unregister_gameport(void) { } 940 + #endif 934 941 935 942 static int __devinit init_mad16(void) 936 943 { ··· 1081 1060 { 1082 1061 if (found_mpu) 1083 1062 unload_mad16_mpu(&cfg_mpu); 1084 - if (gameport) { 1085 - /* the gameport was initialized so we must free it up */ 1086 - gameport_unregister_port(gameport); 1087 - gameport = NULL; 1088 - release_region(0x201, 1); 1089 - } 1063 + mad16_unregister_gameport(); 1090 1064 unload_mad16(&cfg); 1091 1065 release_region(MC0_PORT, 12); 1092 1066 }
+20 -5
sound/oss/sonicvibes.c
··· 122 122 123 123 #include "dm.h" 124 124 125 + #if defined(CONFIG_GAMEPORT) || (defined(MODULE) && defined(CONFIG_GAMEPORT_MODULE)) 126 + #define SUPPORT_JOYSTICK 1 127 + #endif 125 128 126 129 /* --------------------------------------------------------------------- */ 127 130 ··· 368 365 unsigned char obuf[MIDIOUTBUF]; 369 366 } midi; 370 367 368 + #if SUPPORT_JOYSTICK 371 369 struct gameport *gameport; 370 + #endif 372 371 }; 373 372 374 373 /* --------------------------------------------------------------------- */ ··· 2490 2485 #define RSRCISIOREGION(dev,num) (pci_resource_start((dev), (num)) != 0 && \ 2491 2486 (pci_resource_flags((dev), (num)) & IORESOURCE_IO)) 2492 2487 2488 + #ifdef SUPPORT_JOYSTICK 2493 2489 static int __devinit sv_register_gameport(struct sv_state *s, int io_port) 2494 2490 { 2495 2491 struct gameport *gp; ··· 2516 2510 2517 2511 return 0; 2518 2512 } 2513 + 2514 + static inline void sv_unregister_gameport(struct sv_state *s) 2515 + { 2516 + if (s->gameport) { 2517 + int gpio = s->gameport->io; 2518 + gameport_unregister_port(s->gameport); 2519 + release_region(gpio, SV_EXTENT_GAME); 2520 + } 2521 + } 2522 + #else 2523 + static inline int sv_register_gameport(struct sv_state *s, int io_port) { return -ENOSYS; } 2524 + static inline void sv_unregister_gameport(struct sv_state *s) { } 2525 + #endif /* SUPPORT_JOYSTICK */ 2519 2526 2520 2527 static int __devinit sv_probe(struct pci_dev *pcidev, const struct pci_device_id *pciid) 2521 2528 { ··· 2730 2711 /*outb(0, s->iodmaa + SV_DMA_RESET);*/ 2731 2712 /*outb(0, s->iodmac + SV_DMA_RESET);*/ 2732 2713 free_irq(s->irq, s); 2733 - if (s->gameport) { 2734 - int gpio = s->gameport->io; 2735 - gameport_unregister_port(s->gameport); 2736 - release_region(gpio, SV_EXTENT_GAME); 2737 - } 2714 + sv_unregister_gameport(s); 2738 2715 release_region(s->iodmac, SV_EXTENT_DMA); 2739 2716 release_region(s->iodmaa, SV_EXTENT_DMA); 2740 2717 release_region(s->ioenh, SV_EXTENT_ENH);
+25 -12
sound/oss/trident.c
··· 228 228 229 229 #define DRIVER_VERSION "0.14.10j-2.6" 230 230 231 + #if defined(CONFIG_GAMEPORT) || (defined(MODULE) && defined(CONFIG_GAMEPORT_MODULE)) 232 + #define SUPPORT_JOYSTICK 1 233 + #endif 234 + 231 235 /* magic numbers to protect our data structures */ 232 236 #define TRIDENT_CARD_MAGIC 0x5072696E /* "Prin" */ 233 237 #define TRIDENT_STATE_MAGIC 0x63657373 /* "cess" */ ··· 4256 4252 return num_ac97 + 1; 4257 4253 } 4258 4254 4255 + #ifdef SUPPORT_JOYSTICK 4259 4256 /* Gameport functions for the cards ADC gameport */ 4260 4257 4261 - static unsigned char 4262 - trident_game_read(struct gameport *gameport) 4258 + static unsigned char trident_game_read(struct gameport *gameport) 4263 4259 { 4264 4260 struct trident_card *card = gameport->port_data; 4261 + 4265 4262 return inb(TRID_REG(card, T4D_GAME_LEG)); 4266 4263 } 4267 4264 4268 - static void 4269 - trident_game_trigger(struct gameport *gameport) 4265 + static void trident_game_trigger(struct gameport *gameport) 4270 4266 { 4271 4267 struct trident_card *card = gameport->port_data; 4268 + 4272 4269 outb(0xff, TRID_REG(card, T4D_GAME_LEG)); 4273 4270 } 4274 4271 4275 - static int 4276 - trident_game_cooked_read(struct gameport *gameport, int *axes, int *buttons) 4272 + static int trident_game_cooked_read(struct gameport *gameport, 4273 + int *axes, int *buttons) 4277 4274 { 4278 4275 struct trident_card *card = gameport->port_data; 4279 4276 int i; ··· 4290 4285 return 0; 4291 4286 } 4292 4287 4293 - static int 4294 - trident_game_open(struct gameport *gameport, int mode) 4288 + static int trident_game_open(struct gameport *gameport, int mode) 4295 4289 { 4296 4290 struct trident_card *card = gameport->port_data; 4297 4291 ··· 4309 4305 return 0; 4310 4306 } 4311 4307 4312 - static int __devinit 4313 - trident_register_gameport(struct trident_card *card) 4308 + static int __devinit trident_register_gameport(struct trident_card *card) 4314 4309 { 4315 4310 struct gameport *gp; 4316 4311 ··· 4332 4329 4333 4330 return 0; 4334 4331 } 4332 + 4333 + static inline void trident_unregister_gameport(struct trident_card *card) 4334 + { 4335 + if (card->gameport) 4336 + gameport_unregister_port(card->gameport); 4337 + } 4338 + 4339 + #else 4340 + static inline int trident_register_gameport(struct trident_card *card) { return -ENOSYS; } 4341 + static inline void trident_unregister_gameport(struct trident_card *card) { } 4342 + #endif /* SUPPORT_JOYSTICK */ 4335 4343 4336 4344 /* install the driver, we do not allocate hardware channel nor DMA buffer */ 4337 4345 /* now, they are defered until "ACCESS" time (in prog_dmabuf called by */ ··· 4583 4569 } 4584 4570 4585 4571 /* Unregister gameport */ 4586 - if (card->gameport) 4587 - gameport_unregister_port(card->gameport); 4572 + trident_unregister_gameport(card); 4588 4573 4589 4574 /* Kill interrupts, and SP/DIF */ 4590 4575 trident_disable_loop_interrupts(card);
-5
sound/pci/cs4281.c
··· 1338 1338 static inline void snd_cs4281_free_gameport(cs4281_t *chip) { } 1339 1339 #endif /* CONFIG_GAMEPORT || (MODULE && CONFIG_GAMEPORT_MODULE) */ 1340 1340 1341 - 1342 - /* 1343 - 1344 - */ 1345 - 1346 1341 static int snd_cs4281_free(cs4281_t *chip) 1347 1342 { 1348 1343 snd_cs4281_free_gameport(chip);