aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hid/hid-wiimote-modules.c
diff options
context:
space:
mode:
authorDavid Herrmann <dh.herrmann@gmail.com>2013-05-05 17:13:07 -0400
committerJiri Kosina <jkosina@suse.cz>2013-06-03 05:07:06 -0400
commit9f329741a6d7253f044677af00a999b47e85721e (patch)
tree83e95fb89963553dc418c09022ffb138518e7133 /drivers/hid/hid-wiimote-modules.c
parent45ec9fff8629dda47d0c7645174220bcf5d9b6ba (diff)
HID: wiimote: add MP quirks
Devices which have built-in motion plus ports don't need MP detection logic. The new WIIMOD_BUILTIN_MP modules sets the WIIPROTO_FLAG_BUILTIN_MP flag which disables polling for MP. Some other devices erroneously report that they support motion-plus. For these devices and all devices without extension ports, we load WIIMOD_NO_MP which sets WIIPROTO_FLAG_NO_MP. This effectively disables all MP detection logic. Signed-off-by: David Herrmann <dh.herrmann@gmail.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
Diffstat (limited to 'drivers/hid/hid-wiimote-modules.c')
-rw-r--r--drivers/hid/hid-wiimote-modules.c74
1 files changed, 74 insertions, 0 deletions
diff --git a/drivers/hid/hid-wiimote-modules.c b/drivers/hid/hid-wiimote-modules.c
index 19b8b1c4acb4..e2afe065991d 100644
--- a/drivers/hid/hid-wiimote-modules.c
+++ b/drivers/hid/hid-wiimote-modules.c
@@ -1540,6 +1540,78 @@ static const struct wiimod_ops wiimod_bboard = {
1540}; 1540};
1541 1541
1542/* 1542/*
1543 * Builtin Motion Plus
1544 * This module simply sets the WIIPROTO_FLAG_BUILTIN_MP protocol flag which
1545 * disables polling for Motion-Plus. This should be set only for devices which
1546 * don't allow MP hotplugging.
1547 */
1548
1549static int wiimod_builtin_mp_probe(const struct wiimod_ops *ops,
1550 struct wiimote_data *wdata)
1551{
1552 unsigned long flags;
1553
1554 spin_lock_irqsave(&wdata->state.lock, flags);
1555 wdata->state.flags |= WIIPROTO_FLAG_BUILTIN_MP;
1556 spin_unlock_irqrestore(&wdata->state.lock, flags);
1557
1558 return 0;
1559}
1560
1561static void wiimod_builtin_mp_remove(const struct wiimod_ops *ops,
1562 struct wiimote_data *wdata)
1563{
1564 unsigned long flags;
1565
1566 spin_lock_irqsave(&wdata->state.lock, flags);
1567 wdata->state.flags |= WIIPROTO_FLAG_BUILTIN_MP;
1568 spin_unlock_irqrestore(&wdata->state.lock, flags);
1569}
1570
1571static const struct wiimod_ops wiimod_builtin_mp = {
1572 .flags = 0,
1573 .arg = 0,
1574 .probe = wiimod_builtin_mp_probe,
1575 .remove = wiimod_builtin_mp_remove,
1576};
1577
1578/*
1579 * No Motion Plus
1580 * This module simply sets the WIIPROTO_FLAG_NO_MP protocol flag which
1581 * disables motion-plus. This is needed for devices that advertise this but we
1582 * don't know how to use it (or whether it is actually present).
1583 */
1584
1585static int wiimod_no_mp_probe(const struct wiimod_ops *ops,
1586 struct wiimote_data *wdata)
1587{
1588 unsigned long flags;
1589
1590 spin_lock_irqsave(&wdata->state.lock, flags);
1591 wdata->state.flags |= WIIPROTO_FLAG_NO_MP;
1592 spin_unlock_irqrestore(&wdata->state.lock, flags);
1593
1594 return 0;
1595}
1596
1597static void wiimod_no_mp_remove(const struct wiimod_ops *ops,
1598 struct wiimote_data *wdata)
1599{
1600 unsigned long flags;
1601
1602 spin_lock_irqsave(&wdata->state.lock, flags);
1603 wdata->state.flags |= WIIPROTO_FLAG_NO_MP;
1604 spin_unlock_irqrestore(&wdata->state.lock, flags);
1605}
1606
1607static const struct wiimod_ops wiimod_no_mp = {
1608 .flags = 0,
1609 .arg = 0,
1610 .probe = wiimod_no_mp_probe,
1611 .remove = wiimod_no_mp_remove,
1612};
1613
1614/*
1543 * Motion Plus 1615 * Motion Plus
1544 * The Motion Plus extension provides rotation sensors (gyro) as a small 1616 * The Motion Plus extension provides rotation sensors (gyro) as a small
1545 * extension device for Wii Remotes. Many devices have them built-in so 1617 * extension device for Wii Remotes. Many devices have them built-in so
@@ -1706,6 +1778,8 @@ const struct wiimod_ops *wiimod_table[WIIMOD_NUM] = {
1706 [WIIMOD_LED4] = &wiimod_leds[3], 1778 [WIIMOD_LED4] = &wiimod_leds[3],
1707 [WIIMOD_ACCEL] = &wiimod_accel, 1779 [WIIMOD_ACCEL] = &wiimod_accel,
1708 [WIIMOD_IR] = &wiimod_ir, 1780 [WIIMOD_IR] = &wiimod_ir,
1781 [WIIMOD_BUILTIN_MP] = &wiimod_builtin_mp,
1782 [WIIMOD_NO_MP] = &wiimod_no_mp,
1709}; 1783};
1710 1784
1711const struct wiimod_ops *wiimod_ext_table[WIIMOTE_EXT_NUM] = { 1785const struct wiimod_ops *wiimod_ext_table[WIIMOTE_EXT_NUM] = {