diff mbox

[03/16] HID: wiimote: Add drm request

Message ID 1311869316-17128-4-git-send-email-dh.herrmann@googlemail.com (mailing list archive)
State New, archived
Delegated to: Jiri Kosina
Headers show

Commit Message

David Herrmann July 28, 2011, 4:08 p.m. UTC
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 calculated 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>
---
 drivers/hid/hid-wiimote.c |   27 +++++++++++++++++++++++++++
 1 files changed, 27 insertions(+), 0 deletions(-)

Comments

Oliver Neukum July 28, 2011, 6:05 p.m. UTC | #1
Am Donnerstag, 28. Juli 2011, 18:08:23 schrieb David Herrmann:
> +static void wiiproto_req_drm(struct wiimote_data *wdata, __u8 drm)
> +{
> +       __u8 cmd[3];

Are you sure these buffers nned not be safe for DMA?

	Regards
		Oliver
David Herrmann July 28, 2011, 6:41 p.m. UTC | #2
On Thu, Jul 28, 2011 at 8:05 PM, Oliver Neukum <oneukum@suse.de> wrote:
> Am Donnerstag, 28. Juli 2011, 18:08:23 schrieb David Herrmann:
>> +static void wiiproto_req_drm(struct wiimote_data *wdata, __u8 drm)
>> +{
>> +       __u8 cmd[3];
>
> Are you sure these buffers nned not be safe for DMA?

wiimote_queue() allocates a buffer for every request. This should be
fine for DMA then. All wiimote_req_*() functions work the same way.

>        Regards
>                Oliver

Regards
David
--
To unsubscribe from this list: send the line "unsubscribe linux-input" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Oliver Neukum July 28, 2011, 6:47 p.m. UTC | #3
Am Donnerstag, 28. Juli 2011, 20:41:18 schrieb David Herrmann:
> On Thu, Jul 28, 2011 at 8:05 PM, Oliver Neukum <oneukum@suse.de> wrote:
> > Am Donnerstag, 28. Juli 2011, 18:08:23 schrieb David Herrmann:
> >> +static void wiiproto_req_drm(struct wiimote_data *wdata, __u8 drm)
> >> +{
> >> +       __u8 cmd[3];
> >
> > Are you sure these buffers nned not be safe for DMA?
> 
> wiimote_queue() allocates a buffer for every request. This should be
> fine for DMA then. All wiimote_req_*() functions work the same way.
> 

Yes, that's safe.

	Regards
		Oliver
--
To unsubscribe from this list: send the line "unsubscribe linux-input" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/drivers/hid/hid-wiimote.c b/drivers/hid/hid-wiimote.c
index 4070060..dfb8707 100644
--- a/drivers/hid/hid-wiimote.c
+++ b/drivers/hid/hid-wiimote.c
@@ -55,8 +55,10 @@  struct wiimote_data {
 					WIIPROTO_FLAG_LED3 | WIIPROTO_FLAG_LED4)
 
 enum wiiproto_reqs {
+	WIIPROTO_REQ_NULL = 0x0,
 	WIIPROTO_REQ_RUMBLE = 0x10,
 	WIIPROTO_REQ_LED = 0x11,
+	WIIPROTO_REQ_DRM = 0x12,
 	WIIPROTO_REQ_DRM_K = 0x30,
 };
 
@@ -228,6 +230,31 @@  static void wiiproto_req_leds(struct wiimote_data *wdata, int leds)
 	wiimote_queue(wdata, cmd, sizeof(cmd));
 }
 
+/*
+ * Check what peripherals of the wiimote are currently
+ * active and select a proper DRM that supports all of
+ * the requested data inputs.
+ */
+static __u8 select_drm(struct wiimote_data *wdata)
+{
+	return WIIPROTO_REQ_DRM_K;
+}
+
+static void wiiproto_req_drm(struct wiimote_data *wdata, __u8 drm)
+{
+	__u8 cmd[3];
+
+	if (drm == WIIPROTO_REQ_NULL)
+		drm = select_drm(wdata);
+
+	cmd[0] = WIIPROTO_REQ_DRM;
+	cmd[1] = 0;
+	cmd[2] = drm;
+
+	wiiproto_keep_rumble(wdata, &cmd[1]);
+	wiimote_queue(wdata, cmd, sizeof(cmd));
+}
+
 #define wiifs_led_show_set(num)						\
 static ssize_t wiifs_led_show_##num(struct device *dev,			\
 			struct device_attribute *attr, char *buf)	\