Lines Matching refs:wdata
62 static void wiimod_keys_in_keys(struct wiimote_data *wdata, const __u8 *keys) in wiimod_keys_in_keys() argument
64 input_report_key(wdata->input, wiimod_keys_map[WIIPROTO_KEY_LEFT], in wiimod_keys_in_keys()
66 input_report_key(wdata->input, wiimod_keys_map[WIIPROTO_KEY_RIGHT], in wiimod_keys_in_keys()
68 input_report_key(wdata->input, wiimod_keys_map[WIIPROTO_KEY_DOWN], in wiimod_keys_in_keys()
70 input_report_key(wdata->input, wiimod_keys_map[WIIPROTO_KEY_UP], in wiimod_keys_in_keys()
72 input_report_key(wdata->input, wiimod_keys_map[WIIPROTO_KEY_PLUS], in wiimod_keys_in_keys()
74 input_report_key(wdata->input, wiimod_keys_map[WIIPROTO_KEY_TWO], in wiimod_keys_in_keys()
76 input_report_key(wdata->input, wiimod_keys_map[WIIPROTO_KEY_ONE], in wiimod_keys_in_keys()
78 input_report_key(wdata->input, wiimod_keys_map[WIIPROTO_KEY_B], in wiimod_keys_in_keys()
80 input_report_key(wdata->input, wiimod_keys_map[WIIPROTO_KEY_A], in wiimod_keys_in_keys()
82 input_report_key(wdata->input, wiimod_keys_map[WIIPROTO_KEY_MINUS], in wiimod_keys_in_keys()
84 input_report_key(wdata->input, wiimod_keys_map[WIIPROTO_KEY_HOME], in wiimod_keys_in_keys()
86 input_sync(wdata->input); in wiimod_keys_in_keys()
90 struct wiimote_data *wdata) in wiimod_keys_probe() argument
94 set_bit(EV_KEY, wdata->input->evbit); in wiimod_keys_probe()
96 set_bit(wiimod_keys_map[i], wdata->input->keybit); in wiimod_keys_probe()
122 struct wiimote_data *wdata = container_of(work, struct wiimote_data, in wiimod_rumble_worker() local
125 spin_lock_irq(&wdata->state.lock); in wiimod_rumble_worker()
126 wiiproto_req_rumble(wdata, wdata->state.cache_rumble); in wiimod_rumble_worker()
127 spin_unlock_irq(&wdata->state.lock); in wiimod_rumble_worker()
133 struct wiimote_data *wdata = input_get_drvdata(dev); in wiimod_rumble_play() local
149 wdata->state.cache_rumble = value; in wiimod_rumble_play()
150 schedule_work(&wdata->rumble_worker); in wiimod_rumble_play()
156 struct wiimote_data *wdata) in wiimod_rumble_probe() argument
158 INIT_WORK(&wdata->rumble_worker, wiimod_rumble_worker); in wiimod_rumble_probe()
160 set_bit(FF_RUMBLE, wdata->input->ffbit); in wiimod_rumble_probe()
161 if (input_ff_create_memless(wdata->input, NULL, wiimod_rumble_play)) in wiimod_rumble_probe()
168 struct wiimote_data *wdata) in wiimod_rumble_remove() argument
172 cancel_work_sync(&wdata->rumble_worker); in wiimod_rumble_remove()
174 spin_lock_irqsave(&wdata->state.lock, flags); in wiimod_rumble_remove()
175 wiiproto_req_rumble(wdata, 0); in wiimod_rumble_remove()
176 spin_unlock_irqrestore(&wdata->state.lock, flags); in wiimod_rumble_remove()
203 struct wiimote_data *wdata = power_supply_get_drvdata(psy); in wiimod_battery_get_property() local
214 ret = wiimote_cmd_acquire(wdata); in wiimod_battery_get_property()
218 spin_lock_irqsave(&wdata->state.lock, flags); in wiimod_battery_get_property()
219 wiimote_cmd_set(wdata, WIIPROTO_REQ_SREQ, 0); in wiimod_battery_get_property()
220 wiiproto_req_status(wdata); in wiimod_battery_get_property()
221 spin_unlock_irqrestore(&wdata->state.lock, flags); in wiimod_battery_get_property()
223 wiimote_cmd_wait(wdata); in wiimod_battery_get_property()
224 wiimote_cmd_release(wdata); in wiimod_battery_get_property()
226 spin_lock_irqsave(&wdata->state.lock, flags); in wiimod_battery_get_property()
227 state = wdata->state.cmd_battery; in wiimod_battery_get_property()
228 spin_unlock_irqrestore(&wdata->state.lock, flags); in wiimod_battery_get_property()
235 struct wiimote_data *wdata) in wiimod_battery_probe() argument
237 struct power_supply_config psy_cfg = { .drv_data = wdata, }; in wiimod_battery_probe()
240 wdata->battery_desc.properties = wiimod_battery_props; in wiimod_battery_probe()
241 wdata->battery_desc.num_properties = ARRAY_SIZE(wiimod_battery_props); in wiimod_battery_probe()
242 wdata->battery_desc.get_property = wiimod_battery_get_property; in wiimod_battery_probe()
243 wdata->battery_desc.type = POWER_SUPPLY_TYPE_BATTERY; in wiimod_battery_probe()
244 wdata->battery_desc.use_for_apm = 0; in wiimod_battery_probe()
245 wdata->battery_desc.name = kasprintf(GFP_KERNEL, "wiimote_battery_%s", in wiimod_battery_probe()
246 wdata->hdev->uniq); in wiimod_battery_probe()
247 if (!wdata->battery_desc.name) in wiimod_battery_probe()
250 wdata->battery = power_supply_register(&wdata->hdev->dev, in wiimod_battery_probe()
251 &wdata->battery_desc, in wiimod_battery_probe()
253 if (IS_ERR(wdata->battery)) { in wiimod_battery_probe()
254 hid_err(wdata->hdev, "cannot register battery device\n"); in wiimod_battery_probe()
255 ret = PTR_ERR(wdata->battery); in wiimod_battery_probe()
259 power_supply_powers(wdata->battery, &wdata->hdev->dev); in wiimod_battery_probe()
263 kfree(wdata->battery_desc.name); in wiimod_battery_probe()
264 wdata->battery_desc.name = NULL; in wiimod_battery_probe()
269 struct wiimote_data *wdata) in wiimod_battery_remove() argument
271 if (!wdata->battery_desc.name) in wiimod_battery_remove()
274 power_supply_unregister(wdata->battery); in wiimod_battery_remove()
275 kfree(wdata->battery_desc.name); in wiimod_battery_remove()
276 wdata->battery_desc.name = NULL; in wiimod_battery_remove()
297 struct wiimote_data *wdata = dev_to_wii(dev); in wiimod_led_get() local
303 if (wdata->leds[i] == led_dev) { in wiimod_led_get()
304 spin_lock_irqsave(&wdata->state.lock, flags); in wiimod_led_get()
305 value = wdata->state.flags & WIIPROTO_FLAG_LED(i + 1); in wiimod_led_get()
306 spin_unlock_irqrestore(&wdata->state.lock, flags); in wiimod_led_get()
318 struct wiimote_data *wdata = dev_to_wii(dev); in wiimod_led_set() local
324 if (wdata->leds[i] == led_dev) { in wiimod_led_set()
326 spin_lock_irqsave(&wdata->state.lock, flags); in wiimod_led_set()
327 state = wdata->state.flags; in wiimod_led_set()
329 wiiproto_req_leds(wdata, state & ~flag); in wiimod_led_set()
331 wiiproto_req_leds(wdata, state | flag); in wiimod_led_set()
332 spin_unlock_irqrestore(&wdata->state.lock, flags); in wiimod_led_set()
339 struct wiimote_data *wdata) in wiimod_led_probe() argument
341 struct device *dev = &wdata->hdev->dev; in wiimod_led_probe()
360 wdata->leds[ops->arg] = led; in wiimod_led_probe()
367 spin_lock_irqsave(&wdata->state.lock, flags); in wiimod_led_probe()
368 wiiproto_req_leds(wdata, WIIPROTO_FLAG_LED1); in wiimod_led_probe()
369 spin_unlock_irqrestore(&wdata->state.lock, flags); in wiimod_led_probe()
375 wdata->leds[ops->arg] = NULL; in wiimod_led_probe()
381 struct wiimote_data *wdata) in wiimod_led_remove() argument
383 if (!wdata->leds[ops->arg]) in wiimod_led_remove()
386 led_classdev_unregister(wdata->leds[ops->arg]); in wiimod_led_remove()
387 kfree(wdata->leds[ops->arg]); in wiimod_led_remove()
388 wdata->leds[ops->arg] = NULL; in wiimod_led_remove()
425 static void wiimod_accel_in_accel(struct wiimote_data *wdata, in wiimod_accel_in_accel() argument
430 if (!(wdata->state.flags & WIIPROTO_FLAG_ACCEL)) in wiimod_accel_in_accel()
453 input_report_abs(wdata->accel, ABS_RX, x - 0x200); in wiimod_accel_in_accel()
454 input_report_abs(wdata->accel, ABS_RY, y - 0x200); in wiimod_accel_in_accel()
455 input_report_abs(wdata->accel, ABS_RZ, z - 0x200); in wiimod_accel_in_accel()
456 input_sync(wdata->accel); in wiimod_accel_in_accel()
461 struct wiimote_data *wdata = input_get_drvdata(dev); in wiimod_accel_open() local
464 spin_lock_irqsave(&wdata->state.lock, flags); in wiimod_accel_open()
465 wiiproto_req_accel(wdata, true); in wiimod_accel_open()
466 spin_unlock_irqrestore(&wdata->state.lock, flags); in wiimod_accel_open()
473 struct wiimote_data *wdata = input_get_drvdata(dev); in wiimod_accel_close() local
476 spin_lock_irqsave(&wdata->state.lock, flags); in wiimod_accel_close()
477 wiiproto_req_accel(wdata, false); in wiimod_accel_close()
478 spin_unlock_irqrestore(&wdata->state.lock, flags); in wiimod_accel_close()
482 struct wiimote_data *wdata) in wiimod_accel_probe() argument
486 wdata->accel = input_allocate_device(); in wiimod_accel_probe()
487 if (!wdata->accel) in wiimod_accel_probe()
490 input_set_drvdata(wdata->accel, wdata); in wiimod_accel_probe()
491 wdata->accel->open = wiimod_accel_open; in wiimod_accel_probe()
492 wdata->accel->close = wiimod_accel_close; in wiimod_accel_probe()
493 wdata->accel->dev.parent = &wdata->hdev->dev; in wiimod_accel_probe()
494 wdata->accel->id.bustype = wdata->hdev->bus; in wiimod_accel_probe()
495 wdata->accel->id.vendor = wdata->hdev->vendor; in wiimod_accel_probe()
496 wdata->accel->id.product = wdata->hdev->product; in wiimod_accel_probe()
497 wdata->accel->id.version = wdata->hdev->version; in wiimod_accel_probe()
498 wdata->accel->name = WIIMOTE_NAME " Accelerometer"; in wiimod_accel_probe()
500 set_bit(EV_ABS, wdata->accel->evbit); in wiimod_accel_probe()
501 set_bit(ABS_RX, wdata->accel->absbit); in wiimod_accel_probe()
502 set_bit(ABS_RY, wdata->accel->absbit); in wiimod_accel_probe()
503 set_bit(ABS_RZ, wdata->accel->absbit); in wiimod_accel_probe()
504 input_set_abs_params(wdata->accel, ABS_RX, -500, 500, 2, 4); in wiimod_accel_probe()
505 input_set_abs_params(wdata->accel, ABS_RY, -500, 500, 2, 4); in wiimod_accel_probe()
506 input_set_abs_params(wdata->accel, ABS_RZ, -500, 500, 2, 4); in wiimod_accel_probe()
508 ret = input_register_device(wdata->accel); in wiimod_accel_probe()
510 hid_err(wdata->hdev, "cannot register input device\n"); in wiimod_accel_probe()
517 input_free_device(wdata->accel); in wiimod_accel_probe()
518 wdata->accel = NULL; in wiimod_accel_probe()
523 struct wiimote_data *wdata) in wiimod_accel_remove() argument
525 if (!wdata->accel) in wiimod_accel_remove()
528 input_unregister_device(wdata->accel); in wiimod_accel_remove()
529 wdata->accel = NULL; in wiimod_accel_remove()
550 static void wiimod_ir_in_ir(struct wiimote_data *wdata, const __u8 *ir, in wiimod_ir_in_ir() argument
557 if (!(wdata->state.flags & WIIPROTO_FLAGS_IR)) in wiimod_ir_in_ir()
600 input_report_abs(wdata->ir, xid, x); in wiimod_ir_in_ir()
601 input_report_abs(wdata->ir, yid, y); in wiimod_ir_in_ir()
604 input_sync(wdata->ir); in wiimod_ir_in_ir()
607 static int wiimod_ir_change(struct wiimote_data *wdata, __u16 mode) in wiimod_ir_change() argument
618 spin_lock_irqsave(&wdata->state.lock, flags); in wiimod_ir_change()
620 if (mode == (wdata->state.flags & WIIPROTO_FLAGS_IR)) { in wiimod_ir_change()
621 spin_unlock_irqrestore(&wdata->state.lock, flags); in wiimod_ir_change()
626 wdata->state.flags &= ~WIIPROTO_FLAGS_IR; in wiimod_ir_change()
627 wiiproto_req_ir1(wdata, 0); in wiimod_ir_change()
628 wiiproto_req_ir2(wdata, 0); in wiimod_ir_change()
629 wiiproto_req_drm(wdata, WIIPROTO_REQ_NULL); in wiimod_ir_change()
630 spin_unlock_irqrestore(&wdata->state.lock, flags); in wiimod_ir_change()
634 spin_unlock_irqrestore(&wdata->state.lock, flags); in wiimod_ir_change()
636 ret = wiimote_cmd_acquire(wdata); in wiimod_ir_change()
641 spin_lock_irqsave(&wdata->state.lock, flags); in wiimod_ir_change()
642 wiimote_cmd_set(wdata, WIIPROTO_REQ_IR1, 0); in wiimod_ir_change()
643 wiiproto_req_ir1(wdata, 0x06); in wiimod_ir_change()
644 spin_unlock_irqrestore(&wdata->state.lock, flags); in wiimod_ir_change()
646 ret = wiimote_cmd_wait(wdata); in wiimod_ir_change()
649 if (wdata->state.cmd_err) { in wiimod_ir_change()
655 spin_lock_irqsave(&wdata->state.lock, flags); in wiimod_ir_change()
656 wiimote_cmd_set(wdata, WIIPROTO_REQ_IR2, 0); in wiimod_ir_change()
657 wiiproto_req_ir2(wdata, 0x06); in wiimod_ir_change()
658 spin_unlock_irqrestore(&wdata->state.lock, flags); in wiimod_ir_change()
660 ret = wiimote_cmd_wait(wdata); in wiimod_ir_change()
663 if (wdata->state.cmd_err) { in wiimod_ir_change()
669 ret = wiimote_cmd_write(wdata, 0xb00030, data_enable, in wiimod_ir_change()
675 ret = wiimote_cmd_write(wdata, 0xb00000, data_sens1, in wiimod_ir_change()
681 ret = wiimote_cmd_write(wdata, 0xb0001a, data_sens2, in wiimod_ir_change()
698 ret = wiimote_cmd_write(wdata, 0xb00033, &format, sizeof(format)); in wiimod_ir_change()
703 ret = wiimote_cmd_write(wdata, 0xb00030, data_fin, sizeof(data_fin)); in wiimod_ir_change()
708 spin_lock_irqsave(&wdata->state.lock, flags); in wiimod_ir_change()
709 wdata->state.flags &= ~WIIPROTO_FLAGS_IR; in wiimod_ir_change()
710 wdata->state.flags |= mode & WIIPROTO_FLAGS_IR; in wiimod_ir_change()
711 wiiproto_req_drm(wdata, WIIPROTO_REQ_NULL); in wiimod_ir_change()
712 spin_unlock_irqrestore(&wdata->state.lock, flags); in wiimod_ir_change()
715 wiimote_cmd_release(wdata); in wiimod_ir_change()
721 struct wiimote_data *wdata = input_get_drvdata(dev); in wiimod_ir_open() local
723 return wiimod_ir_change(wdata, WIIPROTO_FLAG_IR_BASIC); in wiimod_ir_open()
728 struct wiimote_data *wdata = input_get_drvdata(dev); in wiimod_ir_close() local
730 wiimod_ir_change(wdata, 0); in wiimod_ir_close()
734 struct wiimote_data *wdata) in wiimod_ir_probe() argument
738 wdata->ir = input_allocate_device(); in wiimod_ir_probe()
739 if (!wdata->ir) in wiimod_ir_probe()
742 input_set_drvdata(wdata->ir, wdata); in wiimod_ir_probe()
743 wdata->ir->open = wiimod_ir_open; in wiimod_ir_probe()
744 wdata->ir->close = wiimod_ir_close; in wiimod_ir_probe()
745 wdata->ir->dev.parent = &wdata->hdev->dev; in wiimod_ir_probe()
746 wdata->ir->id.bustype = wdata->hdev->bus; in wiimod_ir_probe()
747 wdata->ir->id.vendor = wdata->hdev->vendor; in wiimod_ir_probe()
748 wdata->ir->id.product = wdata->hdev->product; in wiimod_ir_probe()
749 wdata->ir->id.version = wdata->hdev->version; in wiimod_ir_probe()
750 wdata->ir->name = WIIMOTE_NAME " IR"; in wiimod_ir_probe()
752 set_bit(EV_ABS, wdata->ir->evbit); in wiimod_ir_probe()
753 set_bit(ABS_HAT0X, wdata->ir->absbit); in wiimod_ir_probe()
754 set_bit(ABS_HAT0Y, wdata->ir->absbit); in wiimod_ir_probe()
755 set_bit(ABS_HAT1X, wdata->ir->absbit); in wiimod_ir_probe()
756 set_bit(ABS_HAT1Y, wdata->ir->absbit); in wiimod_ir_probe()
757 set_bit(ABS_HAT2X, wdata->ir->absbit); in wiimod_ir_probe()
758 set_bit(ABS_HAT2Y, wdata->ir->absbit); in wiimod_ir_probe()
759 set_bit(ABS_HAT3X, wdata->ir->absbit); in wiimod_ir_probe()
760 set_bit(ABS_HAT3Y, wdata->ir->absbit); in wiimod_ir_probe()
761 input_set_abs_params(wdata->ir, ABS_HAT0X, 0, 1023, 2, 4); in wiimod_ir_probe()
762 input_set_abs_params(wdata->ir, ABS_HAT0Y, 0, 767, 2, 4); in wiimod_ir_probe()
763 input_set_abs_params(wdata->ir, ABS_HAT1X, 0, 1023, 2, 4); in wiimod_ir_probe()
764 input_set_abs_params(wdata->ir, ABS_HAT1Y, 0, 767, 2, 4); in wiimod_ir_probe()
765 input_set_abs_params(wdata->ir, ABS_HAT2X, 0, 1023, 2, 4); in wiimod_ir_probe()
766 input_set_abs_params(wdata->ir, ABS_HAT2Y, 0, 767, 2, 4); in wiimod_ir_probe()
767 input_set_abs_params(wdata->ir, ABS_HAT3X, 0, 1023, 2, 4); in wiimod_ir_probe()
768 input_set_abs_params(wdata->ir, ABS_HAT3Y, 0, 767, 2, 4); in wiimod_ir_probe()
770 ret = input_register_device(wdata->ir); in wiimod_ir_probe()
772 hid_err(wdata->hdev, "cannot register input device\n"); in wiimod_ir_probe()
779 input_free_device(wdata->ir); in wiimod_ir_probe()
780 wdata->ir = NULL; in wiimod_ir_probe()
785 struct wiimote_data *wdata) in wiimod_ir_remove() argument
787 if (!wdata->ir) in wiimod_ir_remove()
790 input_unregister_device(wdata->ir); in wiimod_ir_remove()
791 wdata->ir = NULL; in wiimod_ir_remove()
820 static void wiimod_nunchuk_in_ext(struct wiimote_data *wdata, const __u8 *ext) in wiimod_nunchuk_in_ext() argument
863 if (wdata->state.flags & WIIPROTO_FLAG_MP_ACTIVE) { in wiimod_nunchuk_in_ext()
878 input_report_abs(wdata->extension.input, ABS_HAT0X, bx); in wiimod_nunchuk_in_ext()
879 input_report_abs(wdata->extension.input, ABS_HAT0Y, by); in wiimod_nunchuk_in_ext()
881 input_report_abs(wdata->extension.input, ABS_RX, x); in wiimod_nunchuk_in_ext()
882 input_report_abs(wdata->extension.input, ABS_RY, y); in wiimod_nunchuk_in_ext()
883 input_report_abs(wdata->extension.input, ABS_RZ, z); in wiimod_nunchuk_in_ext()
885 if (wdata->state.flags & WIIPROTO_FLAG_MP_ACTIVE) { in wiimod_nunchuk_in_ext()
886 input_report_key(wdata->extension.input, in wiimod_nunchuk_in_ext()
889 input_report_key(wdata->extension.input, in wiimod_nunchuk_in_ext()
893 input_report_key(wdata->extension.input, in wiimod_nunchuk_in_ext()
896 input_report_key(wdata->extension.input, in wiimod_nunchuk_in_ext()
901 input_sync(wdata->extension.input); in wiimod_nunchuk_in_ext()
906 struct wiimote_data *wdata = input_get_drvdata(dev); in wiimod_nunchuk_open() local
909 spin_lock_irqsave(&wdata->state.lock, flags); in wiimod_nunchuk_open()
910 wdata->state.flags |= WIIPROTO_FLAG_EXT_USED; in wiimod_nunchuk_open()
911 wiiproto_req_drm(wdata, WIIPROTO_REQ_NULL); in wiimod_nunchuk_open()
912 spin_unlock_irqrestore(&wdata->state.lock, flags); in wiimod_nunchuk_open()
919 struct wiimote_data *wdata = input_get_drvdata(dev); in wiimod_nunchuk_close() local
922 spin_lock_irqsave(&wdata->state.lock, flags); in wiimod_nunchuk_close()
923 wdata->state.flags &= ~WIIPROTO_FLAG_EXT_USED; in wiimod_nunchuk_close()
924 wiiproto_req_drm(wdata, WIIPROTO_REQ_NULL); in wiimod_nunchuk_close()
925 spin_unlock_irqrestore(&wdata->state.lock, flags); in wiimod_nunchuk_close()
929 struct wiimote_data *wdata) in wiimod_nunchuk_probe() argument
933 wdata->extension.input = input_allocate_device(); in wiimod_nunchuk_probe()
934 if (!wdata->extension.input) in wiimod_nunchuk_probe()
937 input_set_drvdata(wdata->extension.input, wdata); in wiimod_nunchuk_probe()
938 wdata->extension.input->open = wiimod_nunchuk_open; in wiimod_nunchuk_probe()
939 wdata->extension.input->close = wiimod_nunchuk_close; in wiimod_nunchuk_probe()
940 wdata->extension.input->dev.parent = &wdata->hdev->dev; in wiimod_nunchuk_probe()
941 wdata->extension.input->id.bustype = wdata->hdev->bus; in wiimod_nunchuk_probe()
942 wdata->extension.input->id.vendor = wdata->hdev->vendor; in wiimod_nunchuk_probe()
943 wdata->extension.input->id.product = wdata->hdev->product; in wiimod_nunchuk_probe()
944 wdata->extension.input->id.version = wdata->hdev->version; in wiimod_nunchuk_probe()
945 wdata->extension.input->name = WIIMOTE_NAME " Nunchuk"; in wiimod_nunchuk_probe()
947 set_bit(EV_KEY, wdata->extension.input->evbit); in wiimod_nunchuk_probe()
950 wdata->extension.input->keybit); in wiimod_nunchuk_probe()
952 set_bit(EV_ABS, wdata->extension.input->evbit); in wiimod_nunchuk_probe()
953 set_bit(ABS_HAT0X, wdata->extension.input->absbit); in wiimod_nunchuk_probe()
954 set_bit(ABS_HAT0Y, wdata->extension.input->absbit); in wiimod_nunchuk_probe()
955 input_set_abs_params(wdata->extension.input, in wiimod_nunchuk_probe()
957 input_set_abs_params(wdata->extension.input, in wiimod_nunchuk_probe()
959 set_bit(ABS_RX, wdata->extension.input->absbit); in wiimod_nunchuk_probe()
960 set_bit(ABS_RY, wdata->extension.input->absbit); in wiimod_nunchuk_probe()
961 set_bit(ABS_RZ, wdata->extension.input->absbit); in wiimod_nunchuk_probe()
962 input_set_abs_params(wdata->extension.input, in wiimod_nunchuk_probe()
964 input_set_abs_params(wdata->extension.input, in wiimod_nunchuk_probe()
966 input_set_abs_params(wdata->extension.input, in wiimod_nunchuk_probe()
969 ret = input_register_device(wdata->extension.input); in wiimod_nunchuk_probe()
976 input_free_device(wdata->extension.input); in wiimod_nunchuk_probe()
977 wdata->extension.input = NULL; in wiimod_nunchuk_probe()
982 struct wiimote_data *wdata) in wiimod_nunchuk_remove() argument
984 if (!wdata->extension.input) in wiimod_nunchuk_remove()
987 input_unregister_device(wdata->extension.input); in wiimod_nunchuk_remove()
988 wdata->extension.input = NULL; in wiimod_nunchuk_remove()
1044 static void wiimod_classic_in_ext(struct wiimote_data *wdata, const __u8 *ext) in wiimod_classic_in_ext() argument
1093 if (wdata->state.flags & WIIPROTO_FLAG_MP_ACTIVE) { in wiimod_classic_in_ext()
1129 input_report_abs(wdata->extension.input, ABS_HAT1X, lx); in wiimod_classic_in_ext()
1130 input_report_abs(wdata->extension.input, ABS_HAT1Y, ly); in wiimod_classic_in_ext()
1131 input_report_abs(wdata->extension.input, ABS_HAT2X, rx - 0x20); in wiimod_classic_in_ext()
1132 input_report_abs(wdata->extension.input, ABS_HAT2Y, ry - 0x20); in wiimod_classic_in_ext()
1133 input_report_abs(wdata->extension.input, ABS_HAT3X, rt); in wiimod_classic_in_ext()
1134 input_report_abs(wdata->extension.input, ABS_HAT3Y, lt); in wiimod_classic_in_ext()
1136 input_report_key(wdata->extension.input, in wiimod_classic_in_ext()
1139 input_report_key(wdata->extension.input, in wiimod_classic_in_ext()
1142 input_report_key(wdata->extension.input, in wiimod_classic_in_ext()
1145 input_report_key(wdata->extension.input, in wiimod_classic_in_ext()
1148 input_report_key(wdata->extension.input, in wiimod_classic_in_ext()
1151 input_report_key(wdata->extension.input, in wiimod_classic_in_ext()
1154 input_report_key(wdata->extension.input, in wiimod_classic_in_ext()
1157 input_report_key(wdata->extension.input, in wiimod_classic_in_ext()
1160 input_report_key(wdata->extension.input, in wiimod_classic_in_ext()
1163 input_report_key(wdata->extension.input, in wiimod_classic_in_ext()
1166 input_report_key(wdata->extension.input, in wiimod_classic_in_ext()
1171 input_report_key(wdata->extension.input, in wiimod_classic_in_ext()
1174 input_report_key(wdata->extension.input, in wiimod_classic_in_ext()
1178 if (wdata->state.flags & WIIPROTO_FLAG_MP_ACTIVE) { in wiimod_classic_in_ext()
1179 input_report_key(wdata->extension.input, in wiimod_classic_in_ext()
1182 input_report_key(wdata->extension.input, in wiimod_classic_in_ext()
1186 input_report_key(wdata->extension.input, in wiimod_classic_in_ext()
1189 input_report_key(wdata->extension.input, in wiimod_classic_in_ext()
1195 input_sync(wdata->extension.input); in wiimod_classic_in_ext()
1200 struct wiimote_data *wdata = input_get_drvdata(dev); in wiimod_classic_open() local
1203 spin_lock_irqsave(&wdata->state.lock, flags); in wiimod_classic_open()
1204 wdata->state.flags |= WIIPROTO_FLAG_EXT_USED; in wiimod_classic_open()
1205 wiiproto_req_drm(wdata, WIIPROTO_REQ_NULL); in wiimod_classic_open()
1206 spin_unlock_irqrestore(&wdata->state.lock, flags); in wiimod_classic_open()
1213 struct wiimote_data *wdata = input_get_drvdata(dev); in wiimod_classic_close() local
1216 spin_lock_irqsave(&wdata->state.lock, flags); in wiimod_classic_close()
1217 wdata->state.flags &= ~WIIPROTO_FLAG_EXT_USED; in wiimod_classic_close()
1218 wiiproto_req_drm(wdata, WIIPROTO_REQ_NULL); in wiimod_classic_close()
1219 spin_unlock_irqrestore(&wdata->state.lock, flags); in wiimod_classic_close()
1223 struct wiimote_data *wdata) in wiimod_classic_probe() argument
1227 wdata->extension.input = input_allocate_device(); in wiimod_classic_probe()
1228 if (!wdata->extension.input) in wiimod_classic_probe()
1231 input_set_drvdata(wdata->extension.input, wdata); in wiimod_classic_probe()
1232 wdata->extension.input->open = wiimod_classic_open; in wiimod_classic_probe()
1233 wdata->extension.input->close = wiimod_classic_close; in wiimod_classic_probe()
1234 wdata->extension.input->dev.parent = &wdata->hdev->dev; in wiimod_classic_probe()
1235 wdata->extension.input->id.bustype = wdata->hdev->bus; in wiimod_classic_probe()
1236 wdata->extension.input->id.vendor = wdata->hdev->vendor; in wiimod_classic_probe()
1237 wdata->extension.input->id.product = wdata->hdev->product; in wiimod_classic_probe()
1238 wdata->extension.input->id.version = wdata->hdev->version; in wiimod_classic_probe()
1239 wdata->extension.input->name = WIIMOTE_NAME " Classic Controller"; in wiimod_classic_probe()
1241 set_bit(EV_KEY, wdata->extension.input->evbit); in wiimod_classic_probe()
1244 wdata->extension.input->keybit); in wiimod_classic_probe()
1246 set_bit(EV_ABS, wdata->extension.input->evbit); in wiimod_classic_probe()
1247 set_bit(ABS_HAT1X, wdata->extension.input->absbit); in wiimod_classic_probe()
1248 set_bit(ABS_HAT1Y, wdata->extension.input->absbit); in wiimod_classic_probe()
1249 set_bit(ABS_HAT2X, wdata->extension.input->absbit); in wiimod_classic_probe()
1250 set_bit(ABS_HAT2Y, wdata->extension.input->absbit); in wiimod_classic_probe()
1251 set_bit(ABS_HAT3X, wdata->extension.input->absbit); in wiimod_classic_probe()
1252 set_bit(ABS_HAT3Y, wdata->extension.input->absbit); in wiimod_classic_probe()
1253 input_set_abs_params(wdata->extension.input, in wiimod_classic_probe()
1255 input_set_abs_params(wdata->extension.input, in wiimod_classic_probe()
1257 input_set_abs_params(wdata->extension.input, in wiimod_classic_probe()
1259 input_set_abs_params(wdata->extension.input, in wiimod_classic_probe()
1261 input_set_abs_params(wdata->extension.input, in wiimod_classic_probe()
1263 input_set_abs_params(wdata->extension.input, in wiimod_classic_probe()
1266 ret = input_register_device(wdata->extension.input); in wiimod_classic_probe()
1273 input_free_device(wdata->extension.input); in wiimod_classic_probe()
1274 wdata->extension.input = NULL; in wiimod_classic_probe()
1279 struct wiimote_data *wdata) in wiimod_classic_remove() argument
1281 if (!wdata->extension.input) in wiimod_classic_remove()
1284 input_unregister_device(wdata->extension.input); in wiimod_classic_remove()
1285 wdata->extension.input = NULL; in wiimod_classic_remove()
1309 static void wiimod_bboard_in_keys(struct wiimote_data *wdata, const __u8 *keys) in wiimod_bboard_in_keys() argument
1311 input_report_key(wdata->extension.input, BTN_A, in wiimod_bboard_in_keys()
1313 input_sync(wdata->extension.input); in wiimod_bboard_in_keys()
1316 static void wiimod_bboard_in_ext(struct wiimote_data *wdata, in wiimod_bboard_in_ext() argument
1321 struct wiimote_state *s = &wdata->state; in wiimod_bboard_in_ext()
1382 input_report_abs(wdata->extension.input, ABS_HAT0X, val[0]); in wiimod_bboard_in_ext()
1383 input_report_abs(wdata->extension.input, ABS_HAT0Y, val[1]); in wiimod_bboard_in_ext()
1384 input_report_abs(wdata->extension.input, ABS_HAT1X, val[2]); in wiimod_bboard_in_ext()
1385 input_report_abs(wdata->extension.input, ABS_HAT1Y, val[3]); in wiimod_bboard_in_ext()
1386 input_sync(wdata->extension.input); in wiimod_bboard_in_ext()
1391 struct wiimote_data *wdata = input_get_drvdata(dev); in wiimod_bboard_open() local
1394 spin_lock_irqsave(&wdata->state.lock, flags); in wiimod_bboard_open()
1395 wdata->state.flags |= WIIPROTO_FLAG_EXT_USED; in wiimod_bboard_open()
1396 wiiproto_req_drm(wdata, WIIPROTO_REQ_NULL); in wiimod_bboard_open()
1397 spin_unlock_irqrestore(&wdata->state.lock, flags); in wiimod_bboard_open()
1404 struct wiimote_data *wdata = input_get_drvdata(dev); in wiimod_bboard_close() local
1407 spin_lock_irqsave(&wdata->state.lock, flags); in wiimod_bboard_close()
1408 wdata->state.flags &= ~WIIPROTO_FLAG_EXT_USED; in wiimod_bboard_close()
1409 wiiproto_req_drm(wdata, WIIPROTO_REQ_NULL); in wiimod_bboard_close()
1410 spin_unlock_irqrestore(&wdata->state.lock, flags); in wiimod_bboard_close()
1417 struct wiimote_data *wdata = dev_to_wii(dev); in wiimod_bboard_calib_show() local
1422 ret = wiimote_cmd_acquire(wdata); in wiimod_bboard_calib_show()
1426 ret = wiimote_cmd_read(wdata, 0xa40024, buf, 12); in wiimod_bboard_calib_show()
1428 wiimote_cmd_release(wdata); in wiimod_bboard_calib_show()
1431 ret = wiimote_cmd_read(wdata, 0xa40024 + 12, buf + 12, 12); in wiimod_bboard_calib_show()
1433 wiimote_cmd_release(wdata); in wiimod_bboard_calib_show()
1437 wiimote_cmd_release(wdata); in wiimod_bboard_calib_show()
1439 spin_lock_irq(&wdata->state.lock); in wiimod_bboard_calib_show()
1443 wdata->state.calib_bboard[j][i] = buf[offs]; in wiimod_bboard_calib_show()
1444 wdata->state.calib_bboard[j][i] <<= 8; in wiimod_bboard_calib_show()
1445 wdata->state.calib_bboard[j][i] |= buf[offs + 1]; in wiimod_bboard_calib_show()
1449 spin_unlock_irq(&wdata->state.lock); in wiimod_bboard_calib_show()
1454 val = wdata->state.calib_bboard[j][i]; in wiimod_bboard_calib_show()
1468 struct wiimote_data *wdata) in wiimod_bboard_probe() argument
1473 wiimote_cmd_acquire_noint(wdata); in wiimod_bboard_probe()
1475 ret = wiimote_cmd_read(wdata, 0xa40024, buf, 12); in wiimod_bboard_probe()
1477 wiimote_cmd_release(wdata); in wiimod_bboard_probe()
1480 ret = wiimote_cmd_read(wdata, 0xa40024 + 12, buf + 12, 12); in wiimod_bboard_probe()
1482 wiimote_cmd_release(wdata); in wiimod_bboard_probe()
1486 wiimote_cmd_release(wdata); in wiimod_bboard_probe()
1491 wdata->state.calib_bboard[j][i] = buf[offs]; in wiimod_bboard_probe()
1492 wdata->state.calib_bboard[j][i] <<= 8; in wiimod_bboard_probe()
1493 wdata->state.calib_bboard[j][i] |= buf[offs + 1]; in wiimod_bboard_probe()
1498 wdata->extension.input = input_allocate_device(); in wiimod_bboard_probe()
1499 if (!wdata->extension.input) in wiimod_bboard_probe()
1502 ret = device_create_file(&wdata->hdev->dev, in wiimod_bboard_probe()
1505 hid_err(wdata->hdev, "cannot create sysfs attribute\n"); in wiimod_bboard_probe()
1509 input_set_drvdata(wdata->extension.input, wdata); in wiimod_bboard_probe()
1510 wdata->extension.input->open = wiimod_bboard_open; in wiimod_bboard_probe()
1511 wdata->extension.input->close = wiimod_bboard_close; in wiimod_bboard_probe()
1512 wdata->extension.input->dev.parent = &wdata->hdev->dev; in wiimod_bboard_probe()
1513 wdata->extension.input->id.bustype = wdata->hdev->bus; in wiimod_bboard_probe()
1514 wdata->extension.input->id.vendor = wdata->hdev->vendor; in wiimod_bboard_probe()
1515 wdata->extension.input->id.product = wdata->hdev->product; in wiimod_bboard_probe()
1516 wdata->extension.input->id.version = wdata->hdev->version; in wiimod_bboard_probe()
1517 wdata->extension.input->name = WIIMOTE_NAME " Balance Board"; in wiimod_bboard_probe()
1519 set_bit(EV_KEY, wdata->extension.input->evbit); in wiimod_bboard_probe()
1520 set_bit(BTN_A, wdata->extension.input->keybit); in wiimod_bboard_probe()
1522 set_bit(EV_ABS, wdata->extension.input->evbit); in wiimod_bboard_probe()
1523 set_bit(ABS_HAT0X, wdata->extension.input->absbit); in wiimod_bboard_probe()
1524 set_bit(ABS_HAT0Y, wdata->extension.input->absbit); in wiimod_bboard_probe()
1525 set_bit(ABS_HAT1X, wdata->extension.input->absbit); in wiimod_bboard_probe()
1526 set_bit(ABS_HAT1Y, wdata->extension.input->absbit); in wiimod_bboard_probe()
1527 input_set_abs_params(wdata->extension.input, in wiimod_bboard_probe()
1529 input_set_abs_params(wdata->extension.input, in wiimod_bboard_probe()
1531 input_set_abs_params(wdata->extension.input, in wiimod_bboard_probe()
1533 input_set_abs_params(wdata->extension.input, in wiimod_bboard_probe()
1536 ret = input_register_device(wdata->extension.input); in wiimod_bboard_probe()
1543 device_remove_file(&wdata->hdev->dev, in wiimod_bboard_probe()
1546 input_free_device(wdata->extension.input); in wiimod_bboard_probe()
1547 wdata->extension.input = NULL; in wiimod_bboard_probe()
1552 struct wiimote_data *wdata) in wiimod_bboard_remove() argument
1554 if (!wdata->extension.input) in wiimod_bboard_remove()
1557 input_unregister_device(wdata->extension.input); in wiimod_bboard_remove()
1558 wdata->extension.input = NULL; in wiimod_bboard_remove()
1559 device_remove_file(&wdata->hdev->dev, in wiimod_bboard_remove()
1623 static void wiimod_pro_in_ext(struct wiimote_data *wdata, const __u8 *ext) in wiimod_pro_in_ext() argument
1684 if (!(wdata->state.flags & WIIPROTO_FLAG_PRO_CALIB_DONE)) { in wiimod_pro_in_ext()
1685 wdata->state.flags |= WIIPROTO_FLAG_PRO_CALIB_DONE; in wiimod_pro_in_ext()
1687 wdata->state.calib_pro_sticks[0] = -lx; in wiimod_pro_in_ext()
1689 wdata->state.calib_pro_sticks[1] = -ly; in wiimod_pro_in_ext()
1691 wdata->state.calib_pro_sticks[2] = -rx; in wiimod_pro_in_ext()
1693 wdata->state.calib_pro_sticks[3] = -ry; in wiimod_pro_in_ext()
1697 lx += wdata->state.calib_pro_sticks[0]; in wiimod_pro_in_ext()
1698 ly += wdata->state.calib_pro_sticks[1]; in wiimod_pro_in_ext()
1699 rx += wdata->state.calib_pro_sticks[2]; in wiimod_pro_in_ext()
1700 ry += wdata->state.calib_pro_sticks[3]; in wiimod_pro_in_ext()
1702 input_report_abs(wdata->extension.input, ABS_X, lx); in wiimod_pro_in_ext()
1703 input_report_abs(wdata->extension.input, ABS_Y, ly); in wiimod_pro_in_ext()
1704 input_report_abs(wdata->extension.input, ABS_RX, rx); in wiimod_pro_in_ext()
1705 input_report_abs(wdata->extension.input, ABS_RY, ry); in wiimod_pro_in_ext()
1707 input_report_key(wdata->extension.input, in wiimod_pro_in_ext()
1710 input_report_key(wdata->extension.input, in wiimod_pro_in_ext()
1713 input_report_key(wdata->extension.input, in wiimod_pro_in_ext()
1716 input_report_key(wdata->extension.input, in wiimod_pro_in_ext()
1719 input_report_key(wdata->extension.input, in wiimod_pro_in_ext()
1722 input_report_key(wdata->extension.input, in wiimod_pro_in_ext()
1725 input_report_key(wdata->extension.input, in wiimod_pro_in_ext()
1729 input_report_key(wdata->extension.input, in wiimod_pro_in_ext()
1732 input_report_key(wdata->extension.input, in wiimod_pro_in_ext()
1735 input_report_key(wdata->extension.input, in wiimod_pro_in_ext()
1738 input_report_key(wdata->extension.input, in wiimod_pro_in_ext()
1741 input_report_key(wdata->extension.input, in wiimod_pro_in_ext()
1744 input_report_key(wdata->extension.input, in wiimod_pro_in_ext()
1747 input_report_key(wdata->extension.input, in wiimod_pro_in_ext()
1750 input_report_key(wdata->extension.input, in wiimod_pro_in_ext()
1754 input_report_key(wdata->extension.input, in wiimod_pro_in_ext()
1757 input_report_key(wdata->extension.input, in wiimod_pro_in_ext()
1761 input_sync(wdata->extension.input); in wiimod_pro_in_ext()
1766 struct wiimote_data *wdata = input_get_drvdata(dev); in wiimod_pro_open() local
1769 spin_lock_irqsave(&wdata->state.lock, flags); in wiimod_pro_open()
1770 wdata->state.flags |= WIIPROTO_FLAG_EXT_USED; in wiimod_pro_open()
1771 wiiproto_req_drm(wdata, WIIPROTO_REQ_NULL); in wiimod_pro_open()
1772 spin_unlock_irqrestore(&wdata->state.lock, flags); in wiimod_pro_open()
1779 struct wiimote_data *wdata = input_get_drvdata(dev); in wiimod_pro_close() local
1782 spin_lock_irqsave(&wdata->state.lock, flags); in wiimod_pro_close()
1783 wdata->state.flags &= ~WIIPROTO_FLAG_EXT_USED; in wiimod_pro_close()
1784 wiiproto_req_drm(wdata, WIIPROTO_REQ_NULL); in wiimod_pro_close()
1785 spin_unlock_irqrestore(&wdata->state.lock, flags); in wiimod_pro_close()
1791 struct wiimote_data *wdata = input_get_drvdata(dev); in wiimod_pro_play() local
1807 wdata->state.cache_rumble = value; in wiimod_pro_play()
1808 schedule_work(&wdata->rumble_worker); in wiimod_pro_play()
1817 struct wiimote_data *wdata = dev_to_wii(dev); in wiimod_pro_calib_show() local
1821 r += sprintf(&out[r], "%+06hd:", wdata->state.calib_pro_sticks[0]); in wiimod_pro_calib_show()
1822 r += sprintf(&out[r], "%+06hd ", wdata->state.calib_pro_sticks[1]); in wiimod_pro_calib_show()
1823 r += sprintf(&out[r], "%+06hd:", wdata->state.calib_pro_sticks[2]); in wiimod_pro_calib_show()
1824 r += sprintf(&out[r], "%+06hd\n", wdata->state.calib_pro_sticks[3]); in wiimod_pro_calib_show()
1833 struct wiimote_data *wdata = dev_to_wii(dev); in wiimod_pro_calib_store() local
1838 spin_lock_irq(&wdata->state.lock); in wiimod_pro_calib_store()
1839 wdata->state.flags &= ~WIIPROTO_FLAG_PRO_CALIB_DONE; in wiimod_pro_calib_store()
1840 spin_unlock_irq(&wdata->state.lock); in wiimod_pro_calib_store()
1846 spin_lock_irq(&wdata->state.lock); in wiimod_pro_calib_store()
1847 wdata->state.flags |= WIIPROTO_FLAG_PRO_CALIB_DONE; in wiimod_pro_calib_store()
1848 spin_unlock_irq(&wdata->state.lock); in wiimod_pro_calib_store()
1850 wdata->state.calib_pro_sticks[0] = x1; in wiimod_pro_calib_store()
1851 wdata->state.calib_pro_sticks[1] = y1; in wiimod_pro_calib_store()
1852 wdata->state.calib_pro_sticks[2] = x2; in wiimod_pro_calib_store()
1853 wdata->state.calib_pro_sticks[3] = y2; in wiimod_pro_calib_store()
1863 struct wiimote_data *wdata) in wiimod_pro_probe() argument
1868 INIT_WORK(&wdata->rumble_worker, wiimod_rumble_worker); in wiimod_pro_probe()
1869 wdata->state.calib_pro_sticks[0] = 0; in wiimod_pro_probe()
1870 wdata->state.calib_pro_sticks[1] = 0; in wiimod_pro_probe()
1871 wdata->state.calib_pro_sticks[2] = 0; in wiimod_pro_probe()
1872 wdata->state.calib_pro_sticks[3] = 0; in wiimod_pro_probe()
1874 spin_lock_irqsave(&wdata->state.lock, flags); in wiimod_pro_probe()
1875 wdata->state.flags &= ~WIIPROTO_FLAG_PRO_CALIB_DONE; in wiimod_pro_probe()
1876 spin_unlock_irqrestore(&wdata->state.lock, flags); in wiimod_pro_probe()
1878 wdata->extension.input = input_allocate_device(); in wiimod_pro_probe()
1879 if (!wdata->extension.input) in wiimod_pro_probe()
1882 set_bit(FF_RUMBLE, wdata->extension.input->ffbit); in wiimod_pro_probe()
1883 input_set_drvdata(wdata->extension.input, wdata); in wiimod_pro_probe()
1885 if (input_ff_create_memless(wdata->extension.input, NULL, in wiimod_pro_probe()
1891 ret = device_create_file(&wdata->hdev->dev, in wiimod_pro_probe()
1894 hid_err(wdata->hdev, "cannot create sysfs attribute\n"); in wiimod_pro_probe()
1898 wdata->extension.input->open = wiimod_pro_open; in wiimod_pro_probe()
1899 wdata->extension.input->close = wiimod_pro_close; in wiimod_pro_probe()
1900 wdata->extension.input->dev.parent = &wdata->hdev->dev; in wiimod_pro_probe()
1901 wdata->extension.input->id.bustype = wdata->hdev->bus; in wiimod_pro_probe()
1902 wdata->extension.input->id.vendor = wdata->hdev->vendor; in wiimod_pro_probe()
1903 wdata->extension.input->id.product = wdata->hdev->product; in wiimod_pro_probe()
1904 wdata->extension.input->id.version = wdata->hdev->version; in wiimod_pro_probe()
1905 wdata->extension.input->name = WIIMOTE_NAME " Pro Controller"; in wiimod_pro_probe()
1907 set_bit(EV_KEY, wdata->extension.input->evbit); in wiimod_pro_probe()
1910 wdata->extension.input->keybit); in wiimod_pro_probe()
1912 set_bit(EV_ABS, wdata->extension.input->evbit); in wiimod_pro_probe()
1913 set_bit(ABS_X, wdata->extension.input->absbit); in wiimod_pro_probe()
1914 set_bit(ABS_Y, wdata->extension.input->absbit); in wiimod_pro_probe()
1915 set_bit(ABS_RX, wdata->extension.input->absbit); in wiimod_pro_probe()
1916 set_bit(ABS_RY, wdata->extension.input->absbit); in wiimod_pro_probe()
1917 input_set_abs_params(wdata->extension.input, in wiimod_pro_probe()
1919 input_set_abs_params(wdata->extension.input, in wiimod_pro_probe()
1921 input_set_abs_params(wdata->extension.input, in wiimod_pro_probe()
1923 input_set_abs_params(wdata->extension.input, in wiimod_pro_probe()
1926 ret = input_register_device(wdata->extension.input); in wiimod_pro_probe()
1933 device_remove_file(&wdata->hdev->dev, in wiimod_pro_probe()
1936 input_free_device(wdata->extension.input); in wiimod_pro_probe()
1937 wdata->extension.input = NULL; in wiimod_pro_probe()
1942 struct wiimote_data *wdata) in wiimod_pro_remove() argument
1946 if (!wdata->extension.input) in wiimod_pro_remove()
1949 input_unregister_device(wdata->extension.input); in wiimod_pro_remove()
1950 wdata->extension.input = NULL; in wiimod_pro_remove()
1951 cancel_work_sync(&wdata->rumble_worker); in wiimod_pro_remove()
1952 device_remove_file(&wdata->hdev->dev, in wiimod_pro_remove()
1955 spin_lock_irqsave(&wdata->state.lock, flags); in wiimod_pro_remove()
1956 wiiproto_req_rumble(wdata, 0); in wiimod_pro_remove()
1957 spin_unlock_irqrestore(&wdata->state.lock, flags); in wiimod_pro_remove()
1977 static inline void wiimod_drums_report_pressure(struct wiimote_data *wdata, in wiimod_drums_report_pressure() argument
1987 input_report_abs(wdata->extension.input, code, *store); in wiimod_drums_report_pressure()
1990 input_report_abs(wdata->extension.input, code, *store); in wiimod_drums_report_pressure()
1994 static void wiimod_drums_in_ext(struct wiimote_data *wdata, const __u8 *ext) in wiimod_drums_in_ext() argument
2045 if (wdata->state.flags & WIIPROTO_FLAG_MP_ACTIVE) { in wiimod_drums_in_ext()
2050 wiimod_drums_report_pressure(wdata, none, which, pressure, in wiimod_drums_in_ext()
2051 o, &wdata->state.pressure_drums[0], in wiimod_drums_in_ext()
2053 wiimod_drums_report_pressure(wdata, none, which, pressure, in wiimod_drums_in_ext()
2054 r, &wdata->state.pressure_drums[1], in wiimod_drums_in_ext()
2056 wiimod_drums_report_pressure(wdata, none, which, pressure, in wiimod_drums_in_ext()
2057 y, &wdata->state.pressure_drums[2], in wiimod_drums_in_ext()
2059 wiimod_drums_report_pressure(wdata, none, which, pressure, in wiimod_drums_in_ext()
2060 g, &wdata->state.pressure_drums[3], in wiimod_drums_in_ext()
2062 wiimod_drums_report_pressure(wdata, none, which, pressure, in wiimod_drums_in_ext()
2063 b, &wdata->state.pressure_drums[4], in wiimod_drums_in_ext()
2067 wiimod_drums_report_pressure(wdata, none, hhp ? 0xff : which, pressure, in wiimod_drums_in_ext()
2068 bass, &wdata->state.pressure_drums[5], in wiimod_drums_in_ext()
2071 wiimod_drums_report_pressure(wdata, none, hhp ? which : 0xff, pressure, in wiimod_drums_in_ext()
2072 0, &wdata->state.pressure_drums[6], in wiimod_drums_in_ext()
2075 input_report_abs(wdata->extension.input, ABS_X, sx - 0x20); in wiimod_drums_in_ext()
2076 input_report_abs(wdata->extension.input, ABS_Y, sy - 0x20); in wiimod_drums_in_ext()
2078 input_report_key(wdata->extension.input, BTN_START, bp); in wiimod_drums_in_ext()
2079 input_report_key(wdata->extension.input, BTN_SELECT, bm); in wiimod_drums_in_ext()
2081 input_sync(wdata->extension.input); in wiimod_drums_in_ext()
2086 struct wiimote_data *wdata = input_get_drvdata(dev); in wiimod_drums_open() local
2089 spin_lock_irqsave(&wdata->state.lock, flags); in wiimod_drums_open()
2090 wdata->state.flags |= WIIPROTO_FLAG_EXT_USED; in wiimod_drums_open()
2091 wiiproto_req_drm(wdata, WIIPROTO_REQ_NULL); in wiimod_drums_open()
2092 spin_unlock_irqrestore(&wdata->state.lock, flags); in wiimod_drums_open()
2099 struct wiimote_data *wdata = input_get_drvdata(dev); in wiimod_drums_close() local
2102 spin_lock_irqsave(&wdata->state.lock, flags); in wiimod_drums_close()
2103 wdata->state.flags &= ~WIIPROTO_FLAG_EXT_USED; in wiimod_drums_close()
2104 wiiproto_req_drm(wdata, WIIPROTO_REQ_NULL); in wiimod_drums_close()
2105 spin_unlock_irqrestore(&wdata->state.lock, flags); in wiimod_drums_close()
2109 struct wiimote_data *wdata) in wiimod_drums_probe() argument
2113 wdata->extension.input = input_allocate_device(); in wiimod_drums_probe()
2114 if (!wdata->extension.input) in wiimod_drums_probe()
2117 input_set_drvdata(wdata->extension.input, wdata); in wiimod_drums_probe()
2118 wdata->extension.input->open = wiimod_drums_open; in wiimod_drums_probe()
2119 wdata->extension.input->close = wiimod_drums_close; in wiimod_drums_probe()
2120 wdata->extension.input->dev.parent = &wdata->hdev->dev; in wiimod_drums_probe()
2121 wdata->extension.input->id.bustype = wdata->hdev->bus; in wiimod_drums_probe()
2122 wdata->extension.input->id.vendor = wdata->hdev->vendor; in wiimod_drums_probe()
2123 wdata->extension.input->id.product = wdata->hdev->product; in wiimod_drums_probe()
2124 wdata->extension.input->id.version = wdata->hdev->version; in wiimod_drums_probe()
2125 wdata->extension.input->name = WIIMOTE_NAME " Drums"; in wiimod_drums_probe()
2127 set_bit(EV_KEY, wdata->extension.input->evbit); in wiimod_drums_probe()
2128 set_bit(BTN_START, wdata->extension.input->keybit); in wiimod_drums_probe()
2129 set_bit(BTN_SELECT, wdata->extension.input->keybit); in wiimod_drums_probe()
2131 set_bit(EV_ABS, wdata->extension.input->evbit); in wiimod_drums_probe()
2132 set_bit(ABS_X, wdata->extension.input->absbit); in wiimod_drums_probe()
2133 set_bit(ABS_Y, wdata->extension.input->absbit); in wiimod_drums_probe()
2134 set_bit(ABS_HAT0X, wdata->extension.input->absbit); in wiimod_drums_probe()
2135 set_bit(ABS_HAT0Y, wdata->extension.input->absbit); in wiimod_drums_probe()
2136 set_bit(ABS_HAT1X, wdata->extension.input->absbit); in wiimod_drums_probe()
2137 set_bit(ABS_HAT2X, wdata->extension.input->absbit); in wiimod_drums_probe()
2138 set_bit(ABS_HAT2Y, wdata->extension.input->absbit); in wiimod_drums_probe()
2139 set_bit(ABS_HAT3X, wdata->extension.input->absbit); in wiimod_drums_probe()
2140 set_bit(ABS_HAT3Y, wdata->extension.input->absbit); in wiimod_drums_probe()
2141 input_set_abs_params(wdata->extension.input, in wiimod_drums_probe()
2143 input_set_abs_params(wdata->extension.input, in wiimod_drums_probe()
2145 input_set_abs_params(wdata->extension.input, in wiimod_drums_probe()
2147 input_set_abs_params(wdata->extension.input, in wiimod_drums_probe()
2149 input_set_abs_params(wdata->extension.input, in wiimod_drums_probe()
2151 input_set_abs_params(wdata->extension.input, in wiimod_drums_probe()
2153 input_set_abs_params(wdata->extension.input, in wiimod_drums_probe()
2155 input_set_abs_params(wdata->extension.input, in wiimod_drums_probe()
2157 input_set_abs_params(wdata->extension.input, in wiimod_drums_probe()
2160 ret = input_register_device(wdata->extension.input); in wiimod_drums_probe()
2167 input_free_device(wdata->extension.input); in wiimod_drums_probe()
2168 wdata->extension.input = NULL; in wiimod_drums_probe()
2173 struct wiimote_data *wdata) in wiimod_drums_remove() argument
2175 if (!wdata->extension.input) in wiimod_drums_remove()
2178 input_unregister_device(wdata->extension.input); in wiimod_drums_remove()
2179 wdata->extension.input = NULL; in wiimod_drums_remove()
2223 static void wiimod_guitar_in_ext(struct wiimote_data *wdata, const __u8 *ext) in wiimod_guitar_in_ext() argument
2272 if (wdata->state.flags & WIIPROTO_FLAG_MP_ACTIVE) { in wiimod_guitar_in_ext()
2278 input_report_abs(wdata->extension.input, ABS_X, sx - 0x20); in wiimod_guitar_in_ext()
2279 input_report_abs(wdata->extension.input, ABS_Y, sy - 0x20); in wiimod_guitar_in_ext()
2280 input_report_abs(wdata->extension.input, ABS_HAT0X, tb); in wiimod_guitar_in_ext()
2281 input_report_abs(wdata->extension.input, ABS_HAT1X, wb - 0x10); in wiimod_guitar_in_ext()
2283 input_report_key(wdata->extension.input, in wiimod_guitar_in_ext()
2286 input_report_key(wdata->extension.input, in wiimod_guitar_in_ext()
2289 input_report_key(wdata->extension.input, in wiimod_guitar_in_ext()
2292 input_report_key(wdata->extension.input, in wiimod_guitar_in_ext()
2295 input_report_key(wdata->extension.input, in wiimod_guitar_in_ext()
2298 input_report_key(wdata->extension.input, in wiimod_guitar_in_ext()
2301 input_report_key(wdata->extension.input, in wiimod_guitar_in_ext()
2304 input_report_key(wdata->extension.input, in wiimod_guitar_in_ext()
2307 input_report_key(wdata->extension.input, in wiimod_guitar_in_ext()
2311 input_sync(wdata->extension.input); in wiimod_guitar_in_ext()
2316 struct wiimote_data *wdata = input_get_drvdata(dev); in wiimod_guitar_open() local
2319 spin_lock_irqsave(&wdata->state.lock, flags); in wiimod_guitar_open()
2320 wdata->state.flags |= WIIPROTO_FLAG_EXT_USED; in wiimod_guitar_open()
2321 wiiproto_req_drm(wdata, WIIPROTO_REQ_NULL); in wiimod_guitar_open()
2322 spin_unlock_irqrestore(&wdata->state.lock, flags); in wiimod_guitar_open()
2329 struct wiimote_data *wdata = input_get_drvdata(dev); in wiimod_guitar_close() local
2332 spin_lock_irqsave(&wdata->state.lock, flags); in wiimod_guitar_close()
2333 wdata->state.flags &= ~WIIPROTO_FLAG_EXT_USED; in wiimod_guitar_close()
2334 wiiproto_req_drm(wdata, WIIPROTO_REQ_NULL); in wiimod_guitar_close()
2335 spin_unlock_irqrestore(&wdata->state.lock, flags); in wiimod_guitar_close()
2339 struct wiimote_data *wdata) in wiimod_guitar_probe() argument
2343 wdata->extension.input = input_allocate_device(); in wiimod_guitar_probe()
2344 if (!wdata->extension.input) in wiimod_guitar_probe()
2347 input_set_drvdata(wdata->extension.input, wdata); in wiimod_guitar_probe()
2348 wdata->extension.input->open = wiimod_guitar_open; in wiimod_guitar_probe()
2349 wdata->extension.input->close = wiimod_guitar_close; in wiimod_guitar_probe()
2350 wdata->extension.input->dev.parent = &wdata->hdev->dev; in wiimod_guitar_probe()
2351 wdata->extension.input->id.bustype = wdata->hdev->bus; in wiimod_guitar_probe()
2352 wdata->extension.input->id.vendor = wdata->hdev->vendor; in wiimod_guitar_probe()
2353 wdata->extension.input->id.product = wdata->hdev->product; in wiimod_guitar_probe()
2354 wdata->extension.input->id.version = wdata->hdev->version; in wiimod_guitar_probe()
2355 wdata->extension.input->name = WIIMOTE_NAME " Guitar"; in wiimod_guitar_probe()
2357 set_bit(EV_KEY, wdata->extension.input->evbit); in wiimod_guitar_probe()
2360 wdata->extension.input->keybit); in wiimod_guitar_probe()
2362 set_bit(EV_ABS, wdata->extension.input->evbit); in wiimod_guitar_probe()
2363 set_bit(ABS_X, wdata->extension.input->absbit); in wiimod_guitar_probe()
2364 set_bit(ABS_Y, wdata->extension.input->absbit); in wiimod_guitar_probe()
2365 set_bit(ABS_HAT0X, wdata->extension.input->absbit); in wiimod_guitar_probe()
2366 set_bit(ABS_HAT1X, wdata->extension.input->absbit); in wiimod_guitar_probe()
2367 input_set_abs_params(wdata->extension.input, in wiimod_guitar_probe()
2369 input_set_abs_params(wdata->extension.input, in wiimod_guitar_probe()
2371 input_set_abs_params(wdata->extension.input, in wiimod_guitar_probe()
2373 input_set_abs_params(wdata->extension.input, in wiimod_guitar_probe()
2376 ret = input_register_device(wdata->extension.input); in wiimod_guitar_probe()
2383 input_free_device(wdata->extension.input); in wiimod_guitar_probe()
2384 wdata->extension.input = NULL; in wiimod_guitar_probe()
2389 struct wiimote_data *wdata) in wiimod_guitar_remove() argument
2391 if (!wdata->extension.input) in wiimod_guitar_remove()
2394 input_unregister_device(wdata->extension.input); in wiimod_guitar_remove()
2395 wdata->extension.input = NULL; in wiimod_guitar_remove()
2439 static void wiimod_turntable_in_ext(struct wiimote_data *wdata, const __u8 *ext) in wiimod_turntable_in_ext() argument
2490 if (wdata->state.flags & WIIPROTO_FLAG_MP_ACTIVE) { in wiimod_turntable_in_ext()
2496 input_report_abs(wdata->extension.input, ABS_X, sx); in wiimod_turntable_in_ext()
2497 input_report_abs(wdata->extension.input, ABS_Y, sy); in wiimod_turntable_in_ext()
2498 input_report_abs(wdata->extension.input, ABS_HAT0X, rtt); in wiimod_turntable_in_ext()
2499 input_report_abs(wdata->extension.input, ABS_HAT1X, ltt); in wiimod_turntable_in_ext()
2500 input_report_abs(wdata->extension.input, ABS_HAT2X, cs); in wiimod_turntable_in_ext()
2501 input_report_abs(wdata->extension.input, ABS_HAT3X, ed); in wiimod_turntable_in_ext()
2502 input_report_key(wdata->extension.input, in wiimod_turntable_in_ext()
2505 input_report_key(wdata->extension.input, in wiimod_turntable_in_ext()
2508 input_report_key(wdata->extension.input, in wiimod_turntable_in_ext()
2511 input_report_key(wdata->extension.input, in wiimod_turntable_in_ext()
2514 input_report_key(wdata->extension.input, in wiimod_turntable_in_ext()
2517 input_report_key(wdata->extension.input, in wiimod_turntable_in_ext()
2520 input_report_key(wdata->extension.input, in wiimod_turntable_in_ext()
2523 input_report_key(wdata->extension.input, in wiimod_turntable_in_ext()
2526 input_report_key(wdata->extension.input, in wiimod_turntable_in_ext()
2530 input_sync(wdata->extension.input); in wiimod_turntable_in_ext()
2535 struct wiimote_data *wdata = input_get_drvdata(dev); in wiimod_turntable_open() local
2538 spin_lock_irqsave(&wdata->state.lock, flags); in wiimod_turntable_open()
2539 wdata->state.flags |= WIIPROTO_FLAG_EXT_USED; in wiimod_turntable_open()
2540 wiiproto_req_drm(wdata, WIIPROTO_REQ_NULL); in wiimod_turntable_open()
2541 spin_unlock_irqrestore(&wdata->state.lock, flags); in wiimod_turntable_open()
2548 struct wiimote_data *wdata = input_get_drvdata(dev); in wiimod_turntable_close() local
2551 spin_lock_irqsave(&wdata->state.lock, flags); in wiimod_turntable_close()
2552 wdata->state.flags &= ~WIIPROTO_FLAG_EXT_USED; in wiimod_turntable_close()
2553 wiiproto_req_drm(wdata, WIIPROTO_REQ_NULL); in wiimod_turntable_close()
2554 spin_unlock_irqrestore(&wdata->state.lock, flags); in wiimod_turntable_close()
2558 struct wiimote_data *wdata) in wiimod_turntable_probe() argument
2562 wdata->extension.input = input_allocate_device(); in wiimod_turntable_probe()
2563 if (!wdata->extension.input) in wiimod_turntable_probe()
2566 input_set_drvdata(wdata->extension.input, wdata); in wiimod_turntable_probe()
2567 wdata->extension.input->open = wiimod_turntable_open; in wiimod_turntable_probe()
2568 wdata->extension.input->close = wiimod_turntable_close; in wiimod_turntable_probe()
2569 wdata->extension.input->dev.parent = &wdata->hdev->dev; in wiimod_turntable_probe()
2570 wdata->extension.input->id.bustype = wdata->hdev->bus; in wiimod_turntable_probe()
2571 wdata->extension.input->id.vendor = wdata->hdev->vendor; in wiimod_turntable_probe()
2572 wdata->extension.input->id.product = wdata->hdev->product; in wiimod_turntable_probe()
2573 wdata->extension.input->id.version = wdata->hdev->version; in wiimod_turntable_probe()
2574 wdata->extension.input->name = WIIMOTE_NAME " Turntable"; in wiimod_turntable_probe()
2576 set_bit(EV_KEY, wdata->extension.input->evbit); in wiimod_turntable_probe()
2579 wdata->extension.input->keybit); in wiimod_turntable_probe()
2581 set_bit(EV_ABS, wdata->extension.input->evbit); in wiimod_turntable_probe()
2582 set_bit(ABS_X, wdata->extension.input->absbit); in wiimod_turntable_probe()
2583 set_bit(ABS_Y, wdata->extension.input->absbit); in wiimod_turntable_probe()
2584 set_bit(ABS_HAT0X, wdata->extension.input->absbit); in wiimod_turntable_probe()
2585 set_bit(ABS_HAT1X, wdata->extension.input->absbit); in wiimod_turntable_probe()
2586 set_bit(ABS_HAT2X, wdata->extension.input->absbit); in wiimod_turntable_probe()
2587 set_bit(ABS_HAT3X, wdata->extension.input->absbit); in wiimod_turntable_probe()
2588 input_set_abs_params(wdata->extension.input, in wiimod_turntable_probe()
2590 input_set_abs_params(wdata->extension.input, in wiimod_turntable_probe()
2592 input_set_abs_params(wdata->extension.input, in wiimod_turntable_probe()
2594 input_set_abs_params(wdata->extension.input, in wiimod_turntable_probe()
2596 input_set_abs_params(wdata->extension.input, in wiimod_turntable_probe()
2598 input_set_abs_params(wdata->extension.input, in wiimod_turntable_probe()
2600 ret = input_register_device(wdata->extension.input); in wiimod_turntable_probe()
2607 input_free_device(wdata->extension.input); in wiimod_turntable_probe()
2608 wdata->extension.input = NULL; in wiimod_turntable_probe()
2613 struct wiimote_data *wdata) in wiimod_turntable_remove() argument
2615 if (!wdata->extension.input) in wiimod_turntable_remove()
2618 input_unregister_device(wdata->extension.input); in wiimod_turntable_remove()
2619 wdata->extension.input = NULL; in wiimod_turntable_remove()
2638 struct wiimote_data *wdata) in wiimod_builtin_mp_probe() argument
2642 spin_lock_irqsave(&wdata->state.lock, flags); in wiimod_builtin_mp_probe()
2643 wdata->state.flags |= WIIPROTO_FLAG_BUILTIN_MP; in wiimod_builtin_mp_probe()
2644 spin_unlock_irqrestore(&wdata->state.lock, flags); in wiimod_builtin_mp_probe()
2650 struct wiimote_data *wdata) in wiimod_builtin_mp_remove() argument
2654 spin_lock_irqsave(&wdata->state.lock, flags); in wiimod_builtin_mp_remove()
2655 wdata->state.flags |= WIIPROTO_FLAG_BUILTIN_MP; in wiimod_builtin_mp_remove()
2656 spin_unlock_irqrestore(&wdata->state.lock, flags); in wiimod_builtin_mp_remove()
2674 struct wiimote_data *wdata) in wiimod_no_mp_probe() argument
2678 spin_lock_irqsave(&wdata->state.lock, flags); in wiimod_no_mp_probe()
2679 wdata->state.flags |= WIIPROTO_FLAG_NO_MP; in wiimod_no_mp_probe()
2680 spin_unlock_irqrestore(&wdata->state.lock, flags); in wiimod_no_mp_probe()
2686 struct wiimote_data *wdata) in wiimod_no_mp_remove() argument
2690 spin_lock_irqsave(&wdata->state.lock, flags); in wiimod_no_mp_remove()
2691 wdata->state.flags |= WIIPROTO_FLAG_NO_MP; in wiimod_no_mp_remove()
2692 spin_unlock_irqrestore(&wdata->state.lock, flags); in wiimod_no_mp_remove()
2712 static void wiimod_mp_in_mp(struct wiimote_data *wdata, const __u8 *ext) in wiimod_mp_in_mp() argument
2765 input_report_abs(wdata->mp, ABS_RX, x); in wiimod_mp_in_mp()
2766 input_report_abs(wdata->mp, ABS_RY, y); in wiimod_mp_in_mp()
2767 input_report_abs(wdata->mp, ABS_RZ, z); in wiimod_mp_in_mp()
2768 input_sync(wdata->mp); in wiimod_mp_in_mp()
2773 struct wiimote_data *wdata = input_get_drvdata(dev); in wiimod_mp_open() local
2776 spin_lock_irqsave(&wdata->state.lock, flags); in wiimod_mp_open()
2777 wdata->state.flags |= WIIPROTO_FLAG_MP_USED; in wiimod_mp_open()
2778 wiiproto_req_drm(wdata, WIIPROTO_REQ_NULL); in wiimod_mp_open()
2779 __wiimote_schedule(wdata); in wiimod_mp_open()
2780 spin_unlock_irqrestore(&wdata->state.lock, flags); in wiimod_mp_open()
2787 struct wiimote_data *wdata = input_get_drvdata(dev); in wiimod_mp_close() local
2790 spin_lock_irqsave(&wdata->state.lock, flags); in wiimod_mp_close()
2791 wdata->state.flags &= ~WIIPROTO_FLAG_MP_USED; in wiimod_mp_close()
2792 wiiproto_req_drm(wdata, WIIPROTO_REQ_NULL); in wiimod_mp_close()
2793 __wiimote_schedule(wdata); in wiimod_mp_close()
2794 spin_unlock_irqrestore(&wdata->state.lock, flags); in wiimod_mp_close()
2798 struct wiimote_data *wdata) in wiimod_mp_probe() argument
2802 wdata->mp = input_allocate_device(); in wiimod_mp_probe()
2803 if (!wdata->mp) in wiimod_mp_probe()
2806 input_set_drvdata(wdata->mp, wdata); in wiimod_mp_probe()
2807 wdata->mp->open = wiimod_mp_open; in wiimod_mp_probe()
2808 wdata->mp->close = wiimod_mp_close; in wiimod_mp_probe()
2809 wdata->mp->dev.parent = &wdata->hdev->dev; in wiimod_mp_probe()
2810 wdata->mp->id.bustype = wdata->hdev->bus; in wiimod_mp_probe()
2811 wdata->mp->id.vendor = wdata->hdev->vendor; in wiimod_mp_probe()
2812 wdata->mp->id.product = wdata->hdev->product; in wiimod_mp_probe()
2813 wdata->mp->id.version = wdata->hdev->version; in wiimod_mp_probe()
2814 wdata->mp->name = WIIMOTE_NAME " Motion Plus"; in wiimod_mp_probe()
2816 set_bit(EV_ABS, wdata->mp->evbit); in wiimod_mp_probe()
2817 set_bit(ABS_RX, wdata->mp->absbit); in wiimod_mp_probe()
2818 set_bit(ABS_RY, wdata->mp->absbit); in wiimod_mp_probe()
2819 set_bit(ABS_RZ, wdata->mp->absbit); in wiimod_mp_probe()
2820 input_set_abs_params(wdata->mp, in wiimod_mp_probe()
2822 input_set_abs_params(wdata->mp, in wiimod_mp_probe()
2824 input_set_abs_params(wdata->mp, in wiimod_mp_probe()
2827 ret = input_register_device(wdata->mp); in wiimod_mp_probe()
2834 input_free_device(wdata->mp); in wiimod_mp_probe()
2835 wdata->mp = NULL; in wiimod_mp_probe()
2840 struct wiimote_data *wdata) in wiimod_mp_remove() argument
2842 if (!wdata->mp) in wiimod_mp_remove()
2845 input_unregister_device(wdata->mp); in wiimod_mp_remove()
2846 wdata->mp = NULL; in wiimod_mp_remove()