aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hid/usbhid
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/hid/usbhid')
-rw-r--r--drivers/hid/usbhid/hid-core.c35
-rw-r--r--drivers/hid/usbhid/hid-pidff.c80
-rw-r--r--drivers/hid/usbhid/hiddev.c8
-rw-r--r--drivers/hid/usbhid/usbhid.h3
4 files changed, 75 insertions, 51 deletions
diff --git a/drivers/hid/usbhid/hid-core.c b/drivers/hid/usbhid/hid-core.c
index 8e0c4bf94ebc..effcd3d6f5cf 100644
--- a/drivers/hid/usbhid/hid-core.c
+++ b/drivers/hid/usbhid/hid-core.c
@@ -639,7 +639,7 @@ static void __usbhid_submit_report(struct hid_device *hid, struct hid_report *re
639 } 639 }
640} 640}
641 641
642void usbhid_submit_report(struct hid_device *hid, struct hid_report *report, unsigned char dir) 642static void usbhid_submit_report(struct hid_device *hid, struct hid_report *report, unsigned char dir)
643{ 643{
644 struct usbhid_device *usbhid = hid->driver_data; 644 struct usbhid_device *usbhid = hid->driver_data;
645 unsigned long flags; 645 unsigned long flags;
@@ -648,7 +648,6 @@ void usbhid_submit_report(struct hid_device *hid, struct hid_report *report, uns
648 __usbhid_submit_report(hid, report, dir); 648 __usbhid_submit_report(hid, report, dir);
649 spin_unlock_irqrestore(&usbhid->lock, flags); 649 spin_unlock_irqrestore(&usbhid->lock, flags);
650} 650}
651EXPORT_SYMBOL_GPL(usbhid_submit_report);
652 651
653/* Workqueue routine to send requests to change LEDs */ 652/* Workqueue routine to send requests to change LEDs */
654static void hid_led(struct work_struct *work) 653static void hid_led(struct work_struct *work)
@@ -706,7 +705,7 @@ static int usb_hidinput_input_event(struct input_dev *dev, unsigned int type, un
706 return 0; 705 return 0;
707} 706}
708 707
709int usbhid_wait_io(struct hid_device *hid) 708static int usbhid_wait_io(struct hid_device *hid)
710{ 709{
711 struct usbhid_device *usbhid = hid->driver_data; 710 struct usbhid_device *usbhid = hid->driver_data;
712 711
@@ -720,7 +719,6 @@ int usbhid_wait_io(struct hid_device *hid)
720 719
721 return 0; 720 return 0;
722} 721}
723EXPORT_SYMBOL_GPL(usbhid_wait_io);
724 722
725static int hid_set_idle(struct usb_device *dev, int ifnum, int report, int idle) 723static int hid_set_idle(struct usb_device *dev, int ifnum, int report, int idle)
726{ 724{
@@ -1243,6 +1241,32 @@ static int usbhid_power(struct hid_device *hid, int lvl)
1243 return r; 1241 return r;
1244} 1242}
1245 1243
1244static void usbhid_request(struct hid_device *hid, struct hid_report *rep, int reqtype)
1245{
1246 switch (reqtype) {
1247 case HID_REQ_GET_REPORT:
1248 usbhid_submit_report(hid, rep, USB_DIR_IN);
1249 break;
1250 case HID_REQ_SET_REPORT:
1251 usbhid_submit_report(hid, rep, USB_DIR_OUT);
1252 break;
1253 }
1254}
1255
1256static int usbhid_idle(struct hid_device *hid, int report, int idle,
1257 int reqtype)
1258{
1259 struct usb_device *dev = hid_to_usb_dev(hid);
1260 struct usb_interface *intf = to_usb_interface(hid->dev.parent);
1261 struct usb_host_interface *interface = intf->cur_altsetting;
1262 int ifnum = interface->desc.bInterfaceNumber;
1263
1264 if (reqtype != HID_REQ_SET_IDLE)
1265 return -EINVAL;
1266
1267 return hid_set_idle(dev, ifnum, report, idle);
1268}
1269
1246static struct hid_ll_driver usb_hid_driver = { 1270static struct hid_ll_driver usb_hid_driver = {
1247 .parse = usbhid_parse, 1271 .parse = usbhid_parse,
1248 .start = usbhid_start, 1272 .start = usbhid_start,
@@ -1251,6 +1275,9 @@ static struct hid_ll_driver usb_hid_driver = {
1251 .close = usbhid_close, 1275 .close = usbhid_close,
1252 .power = usbhid_power, 1276 .power = usbhid_power,
1253 .hidinput_input_event = usb_hidinput_input_event, 1277 .hidinput_input_event = usb_hidinput_input_event,
1278 .request = usbhid_request,
1279 .wait = usbhid_wait_io,
1280 .idle = usbhid_idle,
1254}; 1281};
1255 1282
1256static int usbhid_probe(struct usb_interface *intf, const struct usb_device_id *id) 1283static int usbhid_probe(struct usb_interface *intf, const struct usb_device_id *id)
diff --git a/drivers/hid/usbhid/hid-pidff.c b/drivers/hid/usbhid/hid-pidff.c
index f91c136821f7..10b616702780 100644
--- a/drivers/hid/usbhid/hid-pidff.c
+++ b/drivers/hid/usbhid/hid-pidff.c
@@ -263,8 +263,8 @@ static void pidff_set_envelope_report(struct pidff_device *pidff,
263 envelope->attack_level, 263 envelope->attack_level,
264 pidff->set_envelope[PID_ATTACK_LEVEL].value[0]); 264 pidff->set_envelope[PID_ATTACK_LEVEL].value[0]);
265 265
266 usbhid_submit_report(pidff->hid, pidff->reports[PID_SET_ENVELOPE], 266 hid_hw_request(pidff->hid, pidff->reports[PID_SET_ENVELOPE],
267 USB_DIR_OUT); 267 HID_REQ_SET_REPORT);
268} 268}
269 269
270/* 270/*
@@ -290,8 +290,8 @@ static void pidff_set_constant_force_report(struct pidff_device *pidff,
290 pidff_set_signed(&pidff->set_constant[PID_MAGNITUDE], 290 pidff_set_signed(&pidff->set_constant[PID_MAGNITUDE],
291 effect->u.constant.level); 291 effect->u.constant.level);
292 292
293 usbhid_submit_report(pidff->hid, pidff->reports[PID_SET_CONSTANT], 293 hid_hw_request(pidff->hid, pidff->reports[PID_SET_CONSTANT],
294 USB_DIR_OUT); 294 HID_REQ_SET_REPORT);
295} 295}
296 296
297/* 297/*
@@ -325,8 +325,8 @@ static void pidff_set_effect_report(struct pidff_device *pidff,
325 pidff->effect_direction); 325 pidff->effect_direction);
326 pidff->set_effect[PID_START_DELAY].value[0] = effect->replay.delay; 326 pidff->set_effect[PID_START_DELAY].value[0] = effect->replay.delay;
327 327
328 usbhid_submit_report(pidff->hid, pidff->reports[PID_SET_EFFECT], 328 hid_hw_request(pidff->hid, pidff->reports[PID_SET_EFFECT],
329 USB_DIR_OUT); 329 HID_REQ_SET_REPORT);
330} 330}
331 331
332/* 332/*
@@ -357,8 +357,8 @@ static void pidff_set_periodic_report(struct pidff_device *pidff,
357 pidff_set(&pidff->set_periodic[PID_PHASE], effect->u.periodic.phase); 357 pidff_set(&pidff->set_periodic[PID_PHASE], effect->u.periodic.phase);
358 pidff->set_periodic[PID_PERIOD].value[0] = effect->u.periodic.period; 358 pidff->set_periodic[PID_PERIOD].value[0] = effect->u.periodic.period;
359 359
360 usbhid_submit_report(pidff->hid, pidff->reports[PID_SET_PERIODIC], 360 hid_hw_request(pidff->hid, pidff->reports[PID_SET_PERIODIC],
361 USB_DIR_OUT); 361 HID_REQ_SET_REPORT);
362 362
363} 363}
364 364
@@ -399,8 +399,8 @@ static void pidff_set_condition_report(struct pidff_device *pidff,
399 effect->u.condition[i].left_saturation); 399 effect->u.condition[i].left_saturation);
400 pidff_set(&pidff->set_condition[PID_DEAD_BAND], 400 pidff_set(&pidff->set_condition[PID_DEAD_BAND],
401 effect->u.condition[i].deadband); 401 effect->u.condition[i].deadband);
402 usbhid_submit_report(pidff->hid, pidff->reports[PID_SET_CONDITION], 402 hid_hw_request(pidff->hid, pidff->reports[PID_SET_CONDITION],
403 USB_DIR_OUT); 403 HID_REQ_SET_REPORT);
404 } 404 }
405} 405}
406 406
@@ -440,8 +440,8 @@ static void pidff_set_ramp_force_report(struct pidff_device *pidff,
440 effect->u.ramp.start_level); 440 effect->u.ramp.start_level);
441 pidff_set_signed(&pidff->set_ramp[PID_RAMP_END], 441 pidff_set_signed(&pidff->set_ramp[PID_RAMP_END],
442 effect->u.ramp.end_level); 442 effect->u.ramp.end_level);
443 usbhid_submit_report(pidff->hid, pidff->reports[PID_SET_RAMP], 443 hid_hw_request(pidff->hid, pidff->reports[PID_SET_RAMP],
444 USB_DIR_OUT); 444 HID_REQ_SET_REPORT);
445} 445}
446 446
447/* 447/*
@@ -465,19 +465,19 @@ static int pidff_request_effect_upload(struct pidff_device *pidff, int efnum)
465 int j; 465 int j;
466 466
467 pidff->create_new_effect_type->value[0] = efnum; 467 pidff->create_new_effect_type->value[0] = efnum;
468 usbhid_submit_report(pidff->hid, pidff->reports[PID_CREATE_NEW_EFFECT], 468 hid_hw_request(pidff->hid, pidff->reports[PID_CREATE_NEW_EFFECT],
469 USB_DIR_OUT); 469 HID_REQ_SET_REPORT);
470 hid_dbg(pidff->hid, "create_new_effect sent, type: %d\n", efnum); 470 hid_dbg(pidff->hid, "create_new_effect sent, type: %d\n", efnum);
471 471
472 pidff->block_load[PID_EFFECT_BLOCK_INDEX].value[0] = 0; 472 pidff->block_load[PID_EFFECT_BLOCK_INDEX].value[0] = 0;
473 pidff->block_load_status->value[0] = 0; 473 pidff->block_load_status->value[0] = 0;
474 usbhid_wait_io(pidff->hid); 474 hid_hw_wait(pidff->hid);
475 475
476 for (j = 0; j < 60; j++) { 476 for (j = 0; j < 60; j++) {
477 hid_dbg(pidff->hid, "pid_block_load requested\n"); 477 hid_dbg(pidff->hid, "pid_block_load requested\n");
478 usbhid_submit_report(pidff->hid, pidff->reports[PID_BLOCK_LOAD], 478 hid_hw_request(pidff->hid, pidff->reports[PID_BLOCK_LOAD],
479 USB_DIR_IN); 479 HID_REQ_GET_REPORT);
480 usbhid_wait_io(pidff->hid); 480 hid_hw_wait(pidff->hid);
481 if (pidff->block_load_status->value[0] == 481 if (pidff->block_load_status->value[0] ==
482 pidff->status_id[PID_BLOCK_LOAD_SUCCESS]) { 482 pidff->status_id[PID_BLOCK_LOAD_SUCCESS]) {
483 hid_dbg(pidff->hid, "device reported free memory: %d bytes\n", 483 hid_dbg(pidff->hid, "device reported free memory: %d bytes\n",
@@ -513,8 +513,8 @@ static void pidff_playback_pid(struct pidff_device *pidff, int pid_id, int n)
513 pidff->effect_operation[PID_LOOP_COUNT].value[0] = n; 513 pidff->effect_operation[PID_LOOP_COUNT].value[0] = n;
514 } 514 }
515 515
516 usbhid_submit_report(pidff->hid, pidff->reports[PID_EFFECT_OPERATION], 516 hid_hw_request(pidff->hid, pidff->reports[PID_EFFECT_OPERATION],
517 USB_DIR_OUT); 517 HID_REQ_SET_REPORT);
518} 518}
519 519
520/** 520/**
@@ -535,8 +535,8 @@ static int pidff_playback(struct input_dev *dev, int effect_id, int value)
535static void pidff_erase_pid(struct pidff_device *pidff, int pid_id) 535static void pidff_erase_pid(struct pidff_device *pidff, int pid_id)
536{ 536{
537 pidff->block_free[PID_EFFECT_BLOCK_INDEX].value[0] = pid_id; 537 pidff->block_free[PID_EFFECT_BLOCK_INDEX].value[0] = pid_id;
538 usbhid_submit_report(pidff->hid, pidff->reports[PID_BLOCK_FREE], 538 hid_hw_request(pidff->hid, pidff->reports[PID_BLOCK_FREE],
539 USB_DIR_OUT); 539 HID_REQ_SET_REPORT);
540} 540}
541 541
542/* 542/*
@@ -551,7 +551,7 @@ static int pidff_erase_effect(struct input_dev *dev, int effect_id)
551 effect_id, pidff->pid_id[effect_id]); 551 effect_id, pidff->pid_id[effect_id]);
552 /* Wait for the queue to clear. We do not want a full fifo to 552 /* Wait for the queue to clear. We do not want a full fifo to
553 prevent the effect removal. */ 553 prevent the effect removal. */
554 usbhid_wait_io(pidff->hid); 554 hid_hw_wait(pidff->hid);
555 pidff_playback_pid(pidff, pid_id, 0); 555 pidff_playback_pid(pidff, pid_id, 0);
556 pidff_erase_pid(pidff, pid_id); 556 pidff_erase_pid(pidff, pid_id);
557 557
@@ -718,8 +718,8 @@ static void pidff_set_gain(struct input_dev *dev, u16 gain)
718 struct pidff_device *pidff = dev->ff->private; 718 struct pidff_device *pidff = dev->ff->private;
719 719
720 pidff_set(&pidff->device_gain[PID_DEVICE_GAIN_FIELD], gain); 720 pidff_set(&pidff->device_gain[PID_DEVICE_GAIN_FIELD], gain);
721 usbhid_submit_report(pidff->hid, pidff->reports[PID_DEVICE_GAIN], 721 hid_hw_request(pidff->hid, pidff->reports[PID_DEVICE_GAIN],
722 USB_DIR_OUT); 722 HID_REQ_SET_REPORT);
723} 723}
724 724
725static void pidff_autocenter(struct pidff_device *pidff, u16 magnitude) 725static void pidff_autocenter(struct pidff_device *pidff, u16 magnitude)
@@ -744,8 +744,8 @@ static void pidff_autocenter(struct pidff_device *pidff, u16 magnitude)
744 pidff->set_effect[PID_DIRECTION_ENABLE].value[0] = 1; 744 pidff->set_effect[PID_DIRECTION_ENABLE].value[0] = 1;
745 pidff->set_effect[PID_START_DELAY].value[0] = 0; 745 pidff->set_effect[PID_START_DELAY].value[0] = 0;
746 746
747 usbhid_submit_report(pidff->hid, pidff->reports[PID_SET_EFFECT], 747 hid_hw_request(pidff->hid, pidff->reports[PID_SET_EFFECT],
748 USB_DIR_OUT); 748 HID_REQ_SET_REPORT);
749} 749}
750 750
751/* 751/*
@@ -1158,19 +1158,19 @@ static void pidff_reset(struct pidff_device *pidff)
1158 1158
1159 pidff->device_control->value[0] = pidff->control_id[PID_RESET]; 1159 pidff->device_control->value[0] = pidff->control_id[PID_RESET];
1160 /* We reset twice as sometimes hid_wait_io isn't waiting long enough */ 1160 /* We reset twice as sometimes hid_wait_io isn't waiting long enough */
1161 usbhid_submit_report(hid, pidff->reports[PID_DEVICE_CONTROL], USB_DIR_OUT); 1161 hid_hw_request(hid, pidff->reports[PID_DEVICE_CONTROL], HID_REQ_SET_REPORT);
1162 usbhid_wait_io(hid); 1162 hid_hw_wait(hid);
1163 usbhid_submit_report(hid, pidff->reports[PID_DEVICE_CONTROL], USB_DIR_OUT); 1163 hid_hw_request(hid, pidff->reports[PID_DEVICE_CONTROL], HID_REQ_SET_REPORT);
1164 usbhid_wait_io(hid); 1164 hid_hw_wait(hid);
1165 1165
1166 pidff->device_control->value[0] = 1166 pidff->device_control->value[0] =
1167 pidff->control_id[PID_ENABLE_ACTUATORS]; 1167 pidff->control_id[PID_ENABLE_ACTUATORS];
1168 usbhid_submit_report(hid, pidff->reports[PID_DEVICE_CONTROL], USB_DIR_OUT); 1168 hid_hw_request(hid, pidff->reports[PID_DEVICE_CONTROL], HID_REQ_SET_REPORT);
1169 usbhid_wait_io(hid); 1169 hid_hw_wait(hid);
1170 1170
1171 /* pool report is sometimes messed up, refetch it */ 1171 /* pool report is sometimes messed up, refetch it */
1172 usbhid_submit_report(hid, pidff->reports[PID_POOL], USB_DIR_IN); 1172 hid_hw_request(hid, pidff->reports[PID_POOL], HID_REQ_GET_REPORT);
1173 usbhid_wait_io(hid); 1173 hid_hw_wait(hid);
1174 1174
1175 if (pidff->pool[PID_SIMULTANEOUS_MAX].value) { 1175 if (pidff->pool[PID_SIMULTANEOUS_MAX].value) {
1176 while (pidff->pool[PID_SIMULTANEOUS_MAX].value[0] < 2) { 1176 while (pidff->pool[PID_SIMULTANEOUS_MAX].value[0] < 2) {
@@ -1181,9 +1181,9 @@ static void pidff_reset(struct pidff_device *pidff)
1181 break; 1181 break;
1182 } 1182 }
1183 hid_dbg(pidff->hid, "pid_pool requested again\n"); 1183 hid_dbg(pidff->hid, "pid_pool requested again\n");
1184 usbhid_submit_report(hid, pidff->reports[PID_POOL], 1184 hid_hw_request(hid, pidff->reports[PID_POOL],
1185 USB_DIR_IN); 1185 HID_REQ_GET_REPORT);
1186 usbhid_wait_io(hid); 1186 hid_hw_wait(hid);
1187 } 1187 }
1188 } 1188 }
1189} 1189}
@@ -1269,8 +1269,8 @@ int hid_pidff_init(struct hid_device *hid)
1269 1269
1270 if (test_bit(FF_GAIN, dev->ffbit)) { 1270 if (test_bit(FF_GAIN, dev->ffbit)) {
1271 pidff_set(&pidff->device_gain[PID_DEVICE_GAIN_FIELD], 0xffff); 1271 pidff_set(&pidff->device_gain[PID_DEVICE_GAIN_FIELD], 0xffff);
1272 usbhid_submit_report(hid, pidff->reports[PID_DEVICE_GAIN], 1272 hid_hw_request(hid, pidff->reports[PID_DEVICE_GAIN],
1273 USB_DIR_OUT); 1273 HID_REQ_SET_REPORT);
1274 } 1274 }
1275 1275
1276 error = pidff_check_autocenter(pidff, dev); 1276 error = pidff_check_autocenter(pidff, dev);
diff --git a/drivers/hid/usbhid/hiddev.c b/drivers/hid/usbhid/hiddev.c
index 87bd64959a91..2f1ddca6f2e0 100644
--- a/drivers/hid/usbhid/hiddev.c
+++ b/drivers/hid/usbhid/hiddev.c
@@ -705,8 +705,8 @@ static long hiddev_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
705 if (report == NULL) 705 if (report == NULL)
706 break; 706 break;
707 707
708 usbhid_submit_report(hid, report, USB_DIR_IN); 708 hid_hw_request(hid, report, HID_REQ_GET_REPORT);
709 usbhid_wait_io(hid); 709 hid_hw_wait(hid);
710 710
711 r = 0; 711 r = 0;
712 break; 712 break;
@@ -724,8 +724,8 @@ static long hiddev_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
724 if (report == NULL) 724 if (report == NULL)
725 break; 725 break;
726 726
727 usbhid_submit_report(hid, report, USB_DIR_OUT); 727 hid_hw_request(hid, report, HID_REQ_SET_REPORT);
728 usbhid_wait_io(hid); 728 hid_hw_wait(hid);
729 729
730 r = 0; 730 r = 0;
731 break; 731 break;
diff --git a/drivers/hid/usbhid/usbhid.h b/drivers/hid/usbhid/usbhid.h
index bd87a61e5303..dbb6af699135 100644
--- a/drivers/hid/usbhid/usbhid.h
+++ b/drivers/hid/usbhid/usbhid.h
@@ -34,12 +34,9 @@
34#include <linux/input.h> 34#include <linux/input.h>
35 35
36/* API provided by hid-core.c for USB HID drivers */ 36/* API provided by hid-core.c for USB HID drivers */
37int usbhid_wait_io(struct hid_device* hid);
38void usbhid_close(struct hid_device *hid); 37void usbhid_close(struct hid_device *hid);
39int usbhid_open(struct hid_device *hid); 38int usbhid_open(struct hid_device *hid);
40void usbhid_init_reports(struct hid_device *hid); 39void usbhid_init_reports(struct hid_device *hid);
41void usbhid_submit_report
42(struct hid_device *hid, struct hid_report *report, unsigned char dir);
43int usbhid_get_power(struct hid_device *hid); 40int usbhid_get_power(struct hid_device *hid);
44void usbhid_put_power(struct hid_device *hid); 41void usbhid_put_power(struct hid_device *hid);
45struct usb_interface *usbhid_find_interface(int minor); 42struct usb_interface *usbhid_find_interface(int minor);