From 9f329741a6d7253f044677af00a999b47e85721e Mon Sep 17 00:00:00 2001 From: David Herrmann Date: Sun, 5 May 2013 23:13:07 +0200 Subject: 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 Signed-off-by: Jiri Kosina --- drivers/hid/hid-wiimote-modules.c | 74 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 74 insertions(+) (limited to 'drivers/hid/hid-wiimote-modules.c') 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 @@ -1539,6 +1539,78 @@ static const struct wiimod_ops wiimod_bboard = { .in_ext = wiimod_bboard_in_ext, }; +/* + * Builtin Motion Plus + * This module simply sets the WIIPROTO_FLAG_BUILTIN_MP protocol flag which + * disables polling for Motion-Plus. This should be set only for devices which + * don't allow MP hotplugging. + */ + +static int wiimod_builtin_mp_probe(const struct wiimod_ops *ops, + struct wiimote_data *wdata) +{ + unsigned long flags; + + spin_lock_irqsave(&wdata->state.lock, flags); + wdata->state.flags |= WIIPROTO_FLAG_BUILTIN_MP; + spin_unlock_irqrestore(&wdata->state.lock, flags); + + return 0; +} + +static void wiimod_builtin_mp_remove(const struct wiimod_ops *ops, + struct wiimote_data *wdata) +{ + unsigned long flags; + + spin_lock_irqsave(&wdata->state.lock, flags); + wdata->state.flags |= WIIPROTO_FLAG_BUILTIN_MP; + spin_unlock_irqrestore(&wdata->state.lock, flags); +} + +static const struct wiimod_ops wiimod_builtin_mp = { + .flags = 0, + .arg = 0, + .probe = wiimod_builtin_mp_probe, + .remove = wiimod_builtin_mp_remove, +}; + +/* + * No Motion Plus + * This module simply sets the WIIPROTO_FLAG_NO_MP protocol flag which + * disables motion-plus. This is needed for devices that advertise this but we + * don't know how to use it (or whether it is actually present). + */ + +static int wiimod_no_mp_probe(const struct wiimod_ops *ops, + struct wiimote_data *wdata) +{ + unsigned long flags; + + spin_lock_irqsave(&wdata->state.lock, flags); + wdata->state.flags |= WIIPROTO_FLAG_NO_MP; + spin_unlock_irqrestore(&wdata->state.lock, flags); + + return 0; +} + +static void wiimod_no_mp_remove(const struct wiimod_ops *ops, + struct wiimote_data *wdata) +{ + unsigned long flags; + + spin_lock_irqsave(&wdata->state.lock, flags); + wdata->state.flags |= WIIPROTO_FLAG_NO_MP; + spin_unlock_irqrestore(&wdata->state.lock, flags); +} + +static const struct wiimod_ops wiimod_no_mp = { + .flags = 0, + .arg = 0, + .probe = wiimod_no_mp_probe, + .remove = wiimod_no_mp_remove, +}; + /* * Motion Plus * The Motion Plus extension provides rotation sensors (gyro) as a small @@ -1706,6 +1778,8 @@ const struct wiimod_ops *wiimod_table[WIIMOD_NUM] = { [WIIMOD_LED4] = &wiimod_leds[3], [WIIMOD_ACCEL] = &wiimod_accel, [WIIMOD_IR] = &wiimod_ir, + [WIIMOD_BUILTIN_MP] = &wiimod_builtin_mp, + [WIIMOD_NO_MP] = &wiimod_no_mp, }; const struct wiimod_ops *wiimod_ext_table[WIIMOTE_EXT_NUM] = { -- cgit v1.2.3