From 27f06942142e7a17757b5de1dc4f128c179b7c13 Mon Sep 17 00:00:00 2001 From: David Herrmann Date: Sun, 5 May 2013 23:12:51 +0200 Subject: HID: wiimote: add sub-device module infrastructure To avoid loading all sub-device drivers for every Wii Remote, even though the required hardware might not be available, we introduce a module layer. The module layer specifies which sub-devices are available on each device-type. After device detection, we only load the modules for the detected device. If module loading fails, we unload everything and mark the device as WIIMOTE_DEV_UNKNOWN. As long as a device is marked as "unknown", no sub-devices will be used and the device is considered unsupported. All the different sub-devices, including KEYS, RUMBLE, BATTERY, LEDS, ACCELEROMETER, IR and more will be ported in follow-up patches to the new module layer. Signed-off-by: David Herrmann Signed-off-by: Jiri Kosina --- drivers/hid/hid-wiimote.h | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'drivers/hid/hid-wiimote.h') diff --git a/drivers/hid/hid-wiimote.h b/drivers/hid/hid-wiimote.h index 34417021606e..3c94e3c657c6 100644 --- a/drivers/hid/hid-wiimote.h +++ b/drivers/hid/hid-wiimote.h @@ -108,6 +108,33 @@ struct wiimote_data { struct work_struct init_worker; }; +/* wiimote modules */ + +enum wiimod_module { + WIIMOD_NUM, + WIIMOD_NULL = WIIMOD_NUM, +}; + +#define WIIMOD_FLAG_INPUT 0x0001 + +struct wiimod_ops { + __u16 flags; + unsigned long arg; + int (*probe) (const struct wiimod_ops *ops, + struct wiimote_data *wdata); + void (*remove) (const struct wiimod_ops *ops, + struct wiimote_data *wdata); + + void (*in_keys) (struct wiimote_data *wdata, const __u8 *keys); + void (*in_accel) (struct wiimote_data *wdata, const __u8 *accel); + void (*in_ir) (struct wiimote_data *wdata, const __u8 *ir, bool packed, + unsigned int id); +}; + +extern const struct wiimod_ops *wiimod_table[WIIMOD_NUM]; + +/* wiimote requests */ + enum wiiproto_reqs { WIIPROTO_REQ_NULL = 0x0, WIIPROTO_REQ_RUMBLE = 0x10, -- cgit v1.2.3-59-g8ed1b