Lines Matching refs:state

61 			spin_lock_irqsave(&wdata->state.lock, flags);  in wiimote_queue_worker()
63 spin_unlock_irqrestore(&wdata->state.lock, flags); in wiimote_queue_worker()
129 if (wdata->state.flags & WIIPROTO_FLAG_RUMBLE) in wiiproto_keep_rumble()
138 if (rumble == !!(wdata->state.flags & WIIPROTO_FLAG_RUMBLE)) in wiiproto_req_rumble()
142 wdata->state.flags |= WIIPROTO_FLAG_RUMBLE; in wiiproto_req_rumble()
144 wdata->state.flags &= ~WIIPROTO_FLAG_RUMBLE; in wiiproto_req_rumble()
158 if ((wdata->state.flags & WIIPROTO_FLAGS_LEDS) == leds) in wiiproto_req_leds()
160 wdata->state.flags = (wdata->state.flags & ~WIIPROTO_FLAGS_LEDS) | leds; in wiiproto_req_leds()
199 __u8 ir = wdata->state.flags & WIIPROTO_FLAGS_IR; in select_drm()
202 ext = (wdata->state.flags & WIIPROTO_FLAG_EXT_USED) || in select_drm()
203 (wdata->state.flags & WIIPROTO_FLAG_MP_USED); in select_drm()
206 if (wdata->state.devtype == WIIMOTE_DEV_BALANCE_BOARD) { in select_drm()
214 if (wdata->state.flags & WIIPROTO_FLAG_ACCEL) { in select_drm()
229 if (wdata->state.flags & WIIPROTO_FLAG_ACCEL) { in select_drm()
247 if (wdata->state.flags & WIIPROTO_FLAG_DRM_LOCKED) in wiiproto_req_drm()
248 drm = wdata->state.drm; in wiiproto_req_drm()
256 wdata->state.drm = drm; in wiiproto_req_drm()
275 if (accel == !!(wdata->state.flags & WIIPROTO_FLAG_ACCEL)) in wiiproto_req_accel()
279 wdata->state.flags |= WIIPROTO_FLAG_ACCEL; in wiiproto_req_accel()
281 wdata->state.flags &= ~WIIPROTO_FLAG_ACCEL; in wiiproto_req_accel()
371 spin_lock_irqsave(&wdata->state.lock, flags); in wiimote_cmd_write()
374 spin_unlock_irqrestore(&wdata->state.lock, flags); in wiimote_cmd_write()
377 if (!ret && wdata->state.cmd_err) in wiimote_cmd_write()
390 spin_lock_irqsave(&wdata->state.lock, flags); in wiimote_cmd_read()
391 wdata->state.cmd_read_size = size; in wiimote_cmd_read()
392 wdata->state.cmd_read_buf = rmem; in wiimote_cmd_read()
395 spin_unlock_irqrestore(&wdata->state.lock, flags); in wiimote_cmd_read()
399 spin_lock_irqsave(&wdata->state.lock, flags); in wiimote_cmd_read()
400 wdata->state.cmd_read_buf = NULL; in wiimote_cmd_read()
401 spin_unlock_irqrestore(&wdata->state.lock, flags); in wiimote_cmd_read()
404 if (wdata->state.cmd_read_size == 0) in wiimote_cmd_read()
407 ret = wdata->state.cmd_read_size; in wiimote_cmd_read()
662 spin_lock_irq(&wdata->state.lock); in wiimote_modules_load()
663 wdata->state.devtype = devtype; in wiimote_modules_load()
664 spin_unlock_irq(&wdata->state.lock); in wiimote_modules_load()
686 mods = wiimote_devtype_mods[wdata->state.devtype]; in wiimote_modules_unload()
688 spin_lock_irqsave(&wdata->state.lock, flags); in wiimote_modules_unload()
689 wdata->state.devtype = WIIMOTE_DEV_UNKNOWN; in wiimote_modules_unload()
690 spin_unlock_irqrestore(&wdata->state.lock, flags); in wiimote_modules_unload()
729 spin_lock_irqsave(&wdata->state.lock, flags); in wiimote_ext_load()
730 wdata->state.exttype = ext; in wiimote_ext_load()
731 spin_unlock_irqrestore(&wdata->state.lock, flags); in wiimote_ext_load()
739 ops = wiimod_ext_table[wdata->state.exttype]; in wiimote_ext_unload()
741 spin_lock_irqsave(&wdata->state.lock, flags); in wiimote_ext_unload()
742 wdata->state.exttype = WIIMOTE_EXT_UNKNOWN; in wiimote_ext_unload()
743 wdata->state.flags &= ~WIIPROTO_FLAG_EXT_USED; in wiimote_ext_unload()
744 spin_unlock_irqrestore(&wdata->state.lock, flags); in wiimote_ext_unload()
764 spin_lock_irqsave(&wdata->state.lock, flags); in wiimote_mp_load()
765 wdata->state.mp = mode; in wiimote_mp_load()
766 spin_unlock_irqrestore(&wdata->state.lock, flags); in wiimote_mp_load()
774 if (wdata->state.mp < 2) in wiimote_mp_unload()
779 spin_lock_irqsave(&wdata->state.lock, flags); in wiimote_mp_unload()
780 wdata->state.mp = 0; in wiimote_mp_unload()
781 wdata->state.flags &= ~WIIPROTO_FLAG_MP_USED; in wiimote_mp_unload()
782 spin_unlock_irqrestore(&wdata->state.lock, flags); in wiimote_mp_unload()
866 spin_lock_irq(&wdata->state.lock); in wiimote_init_detect()
867 wdata->state.devtype = WIIMOTE_DEV_UNKNOWN; in wiimote_init_detect()
870 spin_unlock_irq(&wdata->state.lock); in wiimote_init_detect()
876 spin_lock_irq(&wdata->state.lock); in wiimote_init_detect()
877 ext = wdata->state.flags & WIIPROTO_FLAG_EXT_PLUGGED; in wiimote_init_detect()
878 spin_unlock_irq(&wdata->state.lock); in wiimote_init_detect()
891 spin_lock_irq(&wdata->state.lock); in wiimote_init_detect()
892 if (!(wdata->state.flags & WIIPROTO_FLAG_BUILTIN_MP) && in wiimote_init_detect()
893 !(wdata->state.flags & WIIPROTO_FLAG_NO_MP)) in wiimote_init_detect()
895 spin_unlock_irq(&wdata->state.lock); in wiimote_init_detect()
916 if (!wdata->state.mp) { in wiimote_init_poll_mp()
920 } else if (wdata->state.mp) { in wiimote_init_poll_mp()
943 spin_lock_irq(&wdata->state.lock); in wiimote_init_check()
944 flags = wdata->state.flags; in wiimote_init_check()
945 spin_unlock_irq(&wdata->state.lock); in wiimote_init_check()
956 if (wdata->state.exttype == WIIMOTE_EXT_NONE && in wiimote_init_check()
957 wdata->state.mp > 0 && (flags & WIIPROTO_FLAG_MP_USED)) { in wiimote_init_check()
961 spin_lock_irq(&wdata->state.lock); in wiimote_init_check()
962 ret = ret && !(wdata->state.flags & WIIPROTO_FLAG_EXT_ACTIVE); in wiimote_init_check()
963 ret = ret && !(wdata->state.flags & WIIPROTO_FLAG_MP_PLUGGED); in wiimote_init_check()
964 ret = ret && (wdata->state.flags & WIIPROTO_FLAG_MP_ACTIVE); in wiimote_init_check()
965 spin_unlock_irq(&wdata->state.lock); in wiimote_init_check()
982 wdata->state.exttype != WIIMOTE_EXT_NONE) { in wiimote_init_check()
984 ret = type == wdata->state.exttype; in wiimote_init_check()
986 spin_lock_irq(&wdata->state.lock); in wiimote_init_check()
987 ret = ret && !(wdata->state.flags & WIIPROTO_FLAG_MP_ACTIVE); in wiimote_init_check()
988 ret = ret && (wdata->state.flags & WIIPROTO_FLAG_EXT_ACTIVE); in wiimote_init_check()
989 spin_unlock_irq(&wdata->state.lock); in wiimote_init_check()
1008 wdata->state.exttype == WIIMOTE_EXT_NONE) { in wiimote_init_check()
1010 ret = type == wdata->state.exttype; in wiimote_init_check()
1012 spin_lock_irq(&wdata->state.lock); in wiimote_init_check()
1013 ret = ret && !(wdata->state.flags & WIIPROTO_FLAG_EXT_ACTIVE); in wiimote_init_check()
1014 ret = ret && !(wdata->state.flags & WIIPROTO_FLAG_MP_ACTIVE); in wiimote_init_check()
1015 ret = ret && !(wdata->state.flags & WIIPROTO_FLAG_EXT_PLUGGED); in wiimote_init_check()
1016 spin_unlock_irq(&wdata->state.lock); in wiimote_init_check()
1035 if (wdata->state.exttype != WIIMOTE_EXT_NONE && in wiimote_init_check()
1036 wdata->state.mp > 0 && (flags & WIIPROTO_FLAG_MP_USED)) { in wiimote_init_check()
1042 spin_lock_irq(&wdata->state.lock); in wiimote_init_check()
1043 ret = ret && (wdata->state.flags & WIIPROTO_FLAG_EXT_PLUGGED); in wiimote_init_check()
1044 ret = ret && (wdata->state.flags & WIIPROTO_FLAG_EXT_ACTIVE); in wiimote_init_check()
1045 ret = ret && (wdata->state.flags & WIIPROTO_FLAG_MP_ACTIVE); in wiimote_init_check()
1046 spin_unlock_irq(&wdata->state.lock); in wiimote_init_check()
1098 spin_lock_irq(&wdata->state.lock); in wiimote_init_hotplug()
1101 flags = wdata->state.flags; in wiimote_init_hotplug()
1104 wdata->state.flags &= ~WIIPROTO_FLAG_EXT_ACTIVE; in wiimote_init_hotplug()
1105 wdata->state.flags &= ~WIIPROTO_FLAG_MP_ACTIVE; in wiimote_init_hotplug()
1107 spin_unlock_irq(&wdata->state.lock); in wiimote_init_hotplug()
1122 if (exttype != wdata->state.exttype) { in wiimote_init_hotplug()
1130 spin_lock_irq(&wdata->state.lock); in wiimote_init_hotplug()
1131 wdata->state.exttype = WIIMOTE_EXT_NONE; in wiimote_init_hotplug()
1132 spin_unlock_irq(&wdata->state.lock); in wiimote_init_hotplug()
1143 if (!wdata->state.mp) { in wiimote_init_hotplug()
1147 } else if (wdata->state.mp) { in wiimote_init_hotplug()
1170 spin_lock_irq(&wdata->state.lock); in wiimote_init_hotplug()
1174 wdata->state.flags |= WIIPROTO_FLAG_MP_ACTIVE; in wiimote_init_hotplug()
1175 if (wdata->state.exttype == WIIMOTE_EXT_NONE) { in wiimote_init_hotplug()
1176 wdata->state.flags &= ~WIIPROTO_FLAG_EXT_PLUGGED; in wiimote_init_hotplug()
1177 wdata->state.flags &= ~WIIPROTO_FLAG_MP_PLUGGED; in wiimote_init_hotplug()
1179 wdata->state.flags &= ~WIIPROTO_FLAG_EXT_PLUGGED; in wiimote_init_hotplug()
1180 wdata->state.flags |= WIIPROTO_FLAG_MP_PLUGGED; in wiimote_init_hotplug()
1181 wdata->state.flags |= WIIPROTO_FLAG_EXT_ACTIVE; in wiimote_init_hotplug()
1183 } else if (wdata->state.exttype != WIIMOTE_EXT_NONE) { in wiimote_init_hotplug()
1184 wdata->state.flags |= WIIPROTO_FLAG_EXT_ACTIVE; in wiimote_init_hotplug()
1190 spin_unlock_irq(&wdata->state.lock); in wiimote_init_hotplug()
1193 wdata->state.mp, wdata->state.exttype); in wiimote_init_hotplug()
1202 if (wdata->state.devtype == WIIMOTE_DEV_PENDING) { in wiimote_init_worker()
1216 if (!(wdata->state.flags & WIIPROTO_FLAG_EXITING)) in __wiimote_schedule()
1224 spin_lock_irqsave(&wdata->state.lock, flags); in wiimote_schedule()
1226 spin_unlock_irqrestore(&wdata->state.lock, flags); in wiimote_schedule()
1243 ops = wiimod_ext_table[wdata->state.exttype]; in handler_keys()
1249 mods = wiimote_devtype_mods[wdata->state.devtype]; in handler_keys()
1264 ops = wiimod_ext_table[wdata->state.exttype]; in handler_accel()
1270 mods = wiimote_devtype_mods[wdata->state.devtype]; in handler_accel()
1311 if (wdata->state.flags & WIIPROTO_FLAG_MP_ACTIVE) { in handler_ext()
1317 if (!(wdata->state.flags & WIIPROTO_FLAG_MP_PLUGGED)) { in handler_ext()
1319 wdata->state.flags |= WIIPROTO_FLAG_MP_PLUGGED; in handler_ext()
1323 if (wdata->state.flags & WIIPROTO_FLAG_MP_PLUGGED) { in handler_ext()
1325 wdata->state.flags &= ~WIIPROTO_FLAG_MP_PLUGGED; in handler_ext()
1326 wdata->state.flags &= ~WIIPROTO_FLAG_EXT_ACTIVE; in handler_ext()
1338 if (!(wdata->state.flags & WIIPROTO_FLAG_EXT_ACTIVE) && !is_mp) in handler_ext()
1342 ops = wiimod_ext_table[wdata->state.exttype]; in handler_ext()
1362 mods = wiimote_devtype_mods[wdata->state.devtype]; in handler_ext()
1386 ops = wiimod_ext_table[wdata->state.exttype]; in handler_ir()
1392 mods = wiimote_devtype_mods[wdata->state.devtype]; in handler_ir()
1419 if (!(wdata->state.flags & WIIPROTO_FLAG_EXT_PLUGGED)) { in handler_status()
1421 wdata->state.flags |= WIIPROTO_FLAG_EXT_PLUGGED; in handler_status()
1425 if (wdata->state.flags & WIIPROTO_FLAG_EXT_PLUGGED) { in handler_status()
1427 wdata->state.flags &= ~WIIPROTO_FLAG_EXT_PLUGGED; in handler_status()
1428 wdata->state.flags &= ~WIIPROTO_FLAG_MP_PLUGGED; in handler_status()
1429 wdata->state.flags &= ~WIIPROTO_FLAG_EXT_ACTIVE; in handler_status()
1430 wdata->state.flags &= ~WIIPROTO_FLAG_MP_ACTIVE; in handler_status()
1435 wdata->state.cmd_battery = payload[5]; in handler_status()
1457 else if (size > wdata->state.cmd_read_size) in handler_data()
1458 size = wdata->state.cmd_read_size; in handler_data()
1460 wdata->state.cmd_read_size = size; in handler_data()
1461 if (wdata->state.cmd_read_buf) in handler_data()
1462 memcpy(wdata->state.cmd_read_buf, &payload[5], size); in handler_data()
1475 wdata->state.cmd_err = err; in handler_return()
1548 wdata->state.accel_split[0] = payload[2]; in handler_drm_SKAI1()
1549 wdata->state.accel_split[1] = (payload[0] >> 1) & (0x10 | 0x20); in handler_drm_SKAI1()
1550 wdata->state.accel_split[1] |= (payload[1] << 1) & (0x40 | 0x80); in handler_drm_SKAI1()
1562 wdata->state.accel_split[1] |= (payload[0] >> 5) & (0x01 | 0x02); in handler_drm_SKAI2()
1563 wdata->state.accel_split[1] |= (payload[1] >> 3) & (0x04 | 0x08); in handler_drm_SKAI2()
1567 buf[2] = wdata->state.accel_split[0]; in handler_drm_SKAI2()
1569 buf[4] = wdata->state.accel_split[1]; in handler_drm_SKAI2()
1621 spin_lock_irqsave(&wdata->state.lock, flags); in wiimote_hid_event()
1635 spin_unlock_irqrestore(&wdata->state.lock, flags); in wiimote_hid_event()
1648 spin_lock_irqsave(&wdata->state.lock, flags); in wiimote_ext_show()
1649 type = wdata->state.exttype; in wiimote_ext_show()
1650 spin_unlock_irqrestore(&wdata->state.lock, flags); in wiimote_ext_show()
1696 spin_lock_irqsave(&wdata->state.lock, flags); in wiimote_dev_show()
1697 type = wdata->state.devtype; in wiimote_dev_show()
1698 spin_unlock_irqrestore(&wdata->state.lock, flags); in wiimote_dev_show()
1736 spin_lock_init(&wdata->state.lock); in wiimote_create()
1737 init_completion(&wdata->state.ready); in wiimote_create()
1738 mutex_init(&wdata->state.sync); in wiimote_create()
1739 wdata->state.drm = WIIPROTO_REQ_DRM_K; in wiimote_create()
1740 wdata->state.cmd_battery = 0xff; in wiimote_create()
1755 spin_lock_irqsave(&wdata->state.lock, flags); in wiimote_destroy()
1756 wdata->state.flags |= WIIPROTO_FLAG_EXITING; in wiimote_destroy()
1757 spin_unlock_irqrestore(&wdata->state.lock, flags); in wiimote_destroy()