summaryrefslogtreecommitdiff
path: root/drivers/hid/hid-wiimote.c
AgeCommit message (Collapse)Author
2011-08-23HID: wiimote: Add status and return request handlersDavid Herrmann
The wiimote resets the current drm when an extension is plugged in. Fortunately, it also sends a status report in this situation so we just reset the drm on every status report to keep the drm consistent. Also handle return reports from the wiimote which indicate success and failure of requests that we've sent. Signed-off-by: David Herrmann <dh.herrmann@googlemail.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2011-08-23HID: wiimote: Add drm requestDavid Herrmann
The wiimote reports data in several data reporting modes (DRM). The DRM request makes the wiimote send data in the requested drm. The DRM mode can be set explicitely or can be chosen by the driver. To let the driver choose the DRM mode, pass WIIPROTO_REQ_NULL placeholder to it. This is no valid request and is replaced with an appropriate DRM. Currently, the driver always sets the basic DRM_K mode, but this will be extended when further peripherals like accelerometer and IR are supported. Signed-off-by: David Herrmann <dh.herrmann@googlemail.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2011-08-23HID: wiimote: Register led class devicesDavid Herrmann
This registers 4 led devices to allow controlling the wiimote leds via standard LED sysfs API. It removes the four sysfs attributes so we don't have two APIs for one device. Signed-off-by: David Herrmann <dh.herrmann@googlemail.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2011-08-23HID: wiimote: Correctly call HID open/close callbacksDavid Herrmann
Even though the bluetooth hid backend does not react on open/close callbacks, we should call them to be consistent with other hid drivers. Also the new input open/close handlers will be used in future to prepare the wiimote device for IR/extension input. Signed-off-by: David Herrmann <dh.herrmann@googlemail.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2011-08-23HID: wiimote: Simplify synchronizationDavid Herrmann
The new locking scheme in HID core allows us to remove a bit of synchronization. Since the HID layer acts synchronously we simply register input core last and there are no synchonization issues anymore. Also register sysfs files after that to simplify the code. Signed-off-by: David Herrmann <dh.herrmann@googlemail.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2011-07-11HID: wiimote: Add sysfs support to wiimote driverDavid Herrmann
Add sysfs files for each led of the wiimote. Writing 1 to the file enables the led and 0 disables the led. We do not need memory barriers when checking wdata->ready since we use a spinlock directly after it. Signed-off-by: David Herrmann <dh.herrmann@googlemail.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2011-07-11HID: wiimote: Cache wiimote led stateDavid Herrmann
Save the current state of the leds in the wiimote data structure. This allows us to discard new led requests that wouldn't change anything. Protect the whole state structure by a spinlock. Every wiiproto_* function expects this spinlock to be held when called. Signed-off-by: David Herrmann <dh.herrmann@googlemail.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2011-07-11HID: wiimote: Add wiimote led requestDavid Herrmann
Add new request that sets the leds on the target device. Also, per default, set led1 after initializing a device. Signed-off-by: David Herrmann <dh.herrmann@googlemail.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2011-07-11HID: wiimote: Add wiimote input button parserDavid Herrmann
Parse input report 0x30 from the wiimote as button input. We need to send events for all buttons on every input report because the wiimote does not send events for single buttons but always for all buttons to us. The input layer, however, filters redundant events. Signed-off-by: David Herrmann <dh.herrmann@googlemail.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2011-07-11HID: wiimote: Add wiimote event handlerDavid Herrmann
Create array of all event handlers and call each handler when we receive the related event. Signed-off-by: David Herrmann <dh.herrmann@googlemail.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2011-07-11HID: wiimote: Add output queue for wiimote driverDavid Herrmann
The raw hid output function that is supported by bluetooth low-level hid driver does not provide an output queue and also may sleep. The wiimote driver, though, may need to send data in atomic context so this patch adds a buffered output queue for the wiimote driver. We use the shared workqueue to send our buffer to the hid device. There is always only one active worker which flushes the whole output queue to the device. If our queue is full, every further output is discarded. Special care is needed in the deinitialization routine. When wiimote_hid_remove is called, HID input is already disabled, but HID output may still be used from our worker and is then discarded by the lower HID layers. Therefore, we can safely disable the input layer since it is the only layer that still sends input events. Future sysfs attributes must be freed before unregistering input to avoid the sysfs handlers to send input events to a non-existing input layer. Signed-off-by: David Herrmann <dh.herrmann@googlemail.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2011-07-11HID: wiimote: Add wiimote send functionDavid Herrmann
The wiimote driver needs to send raw output reports to the wiimote device. Otherwise we could not manage the peripherals of the wiimote or perform memory operations on the wiimote. We cannot use hidinput_input_event of the lowlevel hid driver, since this does not accept raw input. Therefore, we need to use the same function that hidraw uses to send output. Side effect is, the raw output function is not buffered and can sleep. Signed-off-by: David Herrmann <dh.herrmann@googlemail.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2011-07-11HID: wiimote: Synchronize wiimote input and hid event handlingDavid Herrmann
The wiimote first starts HID hardware and then registers the input device. We need to synchronize the startup so no event handler will start parsing events when the wiimote device is not ready, yet. Signed-off-by: David Herrmann <dh.herrmann@googlemail.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2011-07-11HID: wiimote: Register input device in wiimote hid driverDavid Herrmann
Register input device so the wiimote can report input events on it. We do not use HIDINPUT because the wiimote does not provide any descriptor table which might be used by HIDINPUT. So we avoid having HIDINPUT parse the wiimote descriptor and create unrelated or unknown event flags. Instead we register our own input device that we have full control of. Signed-off-by: David Herrmann <dh.herrmann@googlemail.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2011-07-11HID: wiimote: Add wiimote device structureDavid Herrmann
Allocate wiimote device structure with all wiimote related data when registering new wiimote devices. Signed-off-by: David Herrmann <dh.herrmann@googlemail.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2011-07-11HID: wiimote: Register wiimote hid driver stubDavid Herrmann
The wiimote uses a fake HID protocol. Hence, we need to prevent HIDINPUT and HIDDEV from parsing wiimote data and instead parse raw hid events. Add VID/PID to hid-core so the special driver is loaded on new wiimotes. Signed-off-by: David Herrmann <dh.herrmann@googlemail.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2011-07-11HID: wiimote: Add Nintendo Wii Remote driver stubDavid Herrmann
Add stub driver for the Nintendo Wii Remote. The wii remote uses the HID protocol to communicate with the host over bluetooth. Hence, add dependency for HIDP and place driver in hid subsystem. Signed-off-by: David Herrmann <dh.herrmann@googlemail.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz>