diff options
author | David Herrmann <dh.herrmann@gmail.com> | 2013-05-05 17:12:51 -0400 |
---|---|---|
committer | Jiri Kosina <jkosina@suse.cz> | 2013-06-03 05:07:00 -0400 |
commit | 27f06942142e7a17757b5de1dc4f128c179b7c13 (patch) | |
tree | a494da599d33a444d530314221e2738f1f0a39cf /drivers/hid/hid-wiimote.h | |
parent | d758b1f0c527aedc5e83a565a0737d9ac21ea46a (diff) |
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 <dh.herrmann@gmail.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
Diffstat (limited to 'drivers/hid/hid-wiimote.h')
-rw-r--r-- | drivers/hid/hid-wiimote.h | 27 |
1 files changed, 27 insertions, 0 deletions
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 { | |||
108 | struct work_struct init_worker; | 108 | struct work_struct init_worker; |
109 | }; | 109 | }; |
110 | 110 | ||
111 | /* wiimote modules */ | ||
112 | |||
113 | enum wiimod_module { | ||
114 | WIIMOD_NUM, | ||
115 | WIIMOD_NULL = WIIMOD_NUM, | ||
116 | }; | ||
117 | |||
118 | #define WIIMOD_FLAG_INPUT 0x0001 | ||
119 | |||
120 | struct wiimod_ops { | ||
121 | __u16 flags; | ||
122 | unsigned long arg; | ||
123 | int (*probe) (const struct wiimod_ops *ops, | ||
124 | struct wiimote_data *wdata); | ||
125 | void (*remove) (const struct wiimod_ops *ops, | ||
126 | struct wiimote_data *wdata); | ||
127 | |||
128 | void (*in_keys) (struct wiimote_data *wdata, const __u8 *keys); | ||
129 | void (*in_accel) (struct wiimote_data *wdata, const __u8 *accel); | ||
130 | void (*in_ir) (struct wiimote_data *wdata, const __u8 *ir, bool packed, | ||
131 | unsigned int id); | ||
132 | }; | ||
133 | |||
134 | extern const struct wiimod_ops *wiimod_table[WIIMOD_NUM]; | ||
135 | |||
136 | /* wiimote requests */ | ||
137 | |||
111 | enum wiiproto_reqs { | 138 | enum wiiproto_reqs { |
112 | WIIPROTO_REQ_NULL = 0x0, | 139 | WIIPROTO_REQ_NULL = 0x0, |
113 | WIIPROTO_REQ_RUMBLE = 0x10, | 140 | WIIPROTO_REQ_RUMBLE = 0x10, |