linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCHes] Implement Bluetooth Wacom tablet's mode change in the kernel
@ 2010-01-18 16:49 Bastien Nocera
       [not found] ` <167e8a331001181144u54cefd15m65a5a63ca8c4c4b6@mail.gmail.com>
                   ` (2 more replies)
  0 siblings, 3 replies; 21+ messages in thread
From: Bastien Nocera @ 2010-01-18 16:49 UTC (permalink / raw)
  To: Dmitry Torokhov, linux-input, BlueZ development
  Cc: bgunn-2XggCk4BHTRBDgjK7y7TUQ, Ping

[-- Attachment #1: Type: text/plain, Size: 625 bytes --]

Heya,

Here's a patch to do the Bluetooth Wacom tablet's mode setting in the
kernel. In the past, it was done in a patch in bluetootd.

The first patch is probably completely wrong. Right now,
hid_output_raw_report is done on the intr socket, instead of the ctrl
socket. If it's correct to do it on the intr socket, we'd need to add
some API as a way to select the ctrl socket instead for use in that
driver.

I still have the exact same problems as with the user-space patch in
that an error occurs sending the second blob of data to the tablet, the
first time the driver is initialised. Ping, any ideas about that?

Cheers

[-- Attachment #2: 0001-hidp-Use-the-control-socket-for-raw-messages.patch --]
[-- Type: text/x-patch, Size: 3237 bytes --]

>From 024b4ebd722ddb18f5f455c4db4a3f5ff41caa38 Mon Sep 17 00:00:00 2001
From: Bastien Nocera <hadess-0MeiytkfxGOsTnJN9+BGXg@public.gmane.org>
Date: Mon, 18 Jan 2010 16:11:33 +0000
Subject: [PATCH 1/2] [hidp] Use the control socket for raw messages

In commit 2da31939a42f7a676a0bc5155d6a0a39ed8451f2, support
for Bluetooth hid_output_raw_report was added, but it pushes
the data to the intr socket instead of the ctrl one.

This patch makes hid_output_raw_report use the control socket
instead.

Signed-off-by: Bastien Nocera <hadess-0MeiytkfxGOsTnJN9+BGXg@public.gmane.org>
---
 net/bluetooth/hidp/core.c |   70 +++++++++++++++++++++++----------------------
 1 files changed, 36 insertions(+), 34 deletions(-)

diff --git a/net/bluetooth/hidp/core.c b/net/bluetooth/hidp/core.c
index 5697500..8866582 100644
--- a/net/bluetooth/hidp/core.c
+++ b/net/bluetooth/hidp/core.c
@@ -243,6 +243,39 @@ static void hidp_input_report(struct hidp_session *session, struct sk_buff *skb)
 	input_sync(dev);
 }
 
+static int __hidp_send_ctrl_message(struct hidp_session *session,
+			unsigned char hdr, unsigned char *data, int size)
+{
+	struct sk_buff *skb;
+
+	BT_DBG("session %p data %p size %d", session, data, size);
+
+	if (!(skb = alloc_skb(size + 1, GFP_ATOMIC))) {
+		BT_ERR("Can't allocate memory for new frame");
+		return -ENOMEM;
+	}
+
+	*skb_put(skb, 1) = hdr;
+	if (data && size > 0)
+		memcpy(skb_put(skb, size), data, size);
+
+	skb_queue_tail(&session->ctrl_transmit, skb);
+
+	return 0;
+}
+
+static inline int hidp_send_ctrl_message(struct hidp_session *session,
+			unsigned char hdr, unsigned char *data, int size)
+{
+	int err;
+
+	err = __hidp_send_ctrl_message(session, hdr, data, size);
+
+	hidp_schedule(session);
+
+	return err;
+}
+
 static int hidp_queue_report(struct hidp_session *session,
 				unsigned char *data, int size)
 {
@@ -282,7 +315,9 @@ static int hidp_send_report(struct hidp_session *session, struct hid_report *rep
 
 static int hidp_output_raw_report(struct hid_device *hid, unsigned char *data, size_t count)
 {
-	if (hidp_queue_report(hid->driver_data, data, count))
+	if (count <= 1)
+		return -EINVAL;
+	if (hidp_send_ctrl_message(hid->driver_data, data[0], data + 1, count - 1))
 		return -ENOMEM;
 	return count;
 }
@@ -307,39 +342,6 @@ static inline void hidp_del_timer(struct hidp_session *session)
 		del_timer(&session->timer);
 }
 
-static int __hidp_send_ctrl_message(struct hidp_session *session,
-			unsigned char hdr, unsigned char *data, int size)
-{
-	struct sk_buff *skb;
-
-	BT_DBG("session %p data %p size %d", session, data, size);
-
-	if (!(skb = alloc_skb(size + 1, GFP_ATOMIC))) {
-		BT_ERR("Can't allocate memory for new frame");
-		return -ENOMEM;
-	}
-
-	*skb_put(skb, 1) = hdr;
-	if (data && size > 0)
-		memcpy(skb_put(skb, size), data, size);
-
-	skb_queue_tail(&session->ctrl_transmit, skb);
-
-	return 0;
-}
-
-static inline int hidp_send_ctrl_message(struct hidp_session *session,
-			unsigned char hdr, unsigned char *data, int size)
-{
-	int err;
-
-	err = __hidp_send_ctrl_message(session, hdr, data, size);
-
-	hidp_schedule(session);
-
-	return err;
-}
-
 static void hidp_process_handshake(struct hidp_session *session,
 					unsigned char param)
 {
-- 
1.6.5.2


[-- Attachment #3: 0002-hid-Implement-Wacom-quirk-in-the-kernel.patch --]
[-- Type: text/x-patch, Size: 1733 bytes --]

>From 6f83c0d084631033db9cb9b9452f5cf2e2bf67c2 Mon Sep 17 00:00:00 2001
From: Bastien Nocera <hadess-0MeiytkfxGOsTnJN9+BGXg@public.gmane.org>
Date: Mon, 18 Jan 2010 16:13:41 +0000
Subject: [PATCH 2/2] [hid] Implement Wacom quirk in the kernel

The hid-wacom driver required user-space to poke at the tablet
to make it send data about the cursor location.

This patch makes it do the same thing but in the kernel.

Signed-off-by: Bastien Nocera <hadess-0MeiytkfxGOsTnJN9+BGXg@public.gmane.org>
---
 drivers/hid/hid-wacom.c |   13 +++++++++++++
 1 files changed, 13 insertions(+), 0 deletions(-)

diff --git a/drivers/hid/hid-wacom.c b/drivers/hid/hid-wacom.c
index 7475421..4030824 100644
--- a/drivers/hid/hid-wacom.c
+++ b/drivers/hid/hid-wacom.c
@@ -155,6 +155,7 @@ static int wacom_probe(struct hid_device *hdev,
 	struct hid_input *hidinput;
 	struct input_dev *input;
 	struct wacom_data *wdata;
+	char rep_data[3];
 	int ret;
 
 	wdata = kzalloc(sizeof(*wdata), GFP_KERNEL);
@@ -177,6 +178,18 @@ static int wacom_probe(struct hid_device *hdev,
 		goto err_free;
 	}
 
+	rep_data[0] = 0x53; /* HIDP_TRANS_SET_REPORT | HIDP_DATA_RTYPE_FEATURE */
+	rep_data[1] = 0x03; rep_data[2] = 0x00;
+	ret = hdev->hid_output_raw_report (hdev, rep_data, 3);
+	if (ret < 0)
+		dev_err(&hdev->dev, "failed to poke device #1, %d\n", ret);
+
+	rep_data[0] = 0x71; /* HIDP_TRANS_SET_REPORT | HIDP_DATA_RTYPE_FEATURE */
+	/* 0x06 - high reporting speed, 0x05 - low speed */
+	rep_data[1] = 0x06; rep_data[2] = 0x00;
+	ret = hdev->hid_output_raw_report (hdev, rep_data, 3);
+		dev_err(&hdev->dev, "failed to poke device #2, %d\n", ret);
+
 	hidinput = list_entry(hdev->inputs.next, struct hid_input, list);
 	input = hidinput->input;
 
-- 
1.6.5.2


^ permalink raw reply related	[flat|nested] 21+ messages in thread
* [PATCHes] Implement Bluetooth Wacom tablet's mode change in the kernel
@ 2010-01-20 11:47 Bastien Nocera
       [not found] ` <1263988051.1735.2474.camel-bi+AKbBUZKY6gyzm1THtWbp2dZbC/Bob@public.gmane.org>
  0 siblings, 1 reply; 21+ messages in thread
From: Bastien Nocera @ 2010-01-20 11:47 UTC (permalink / raw)
  To: Dmitry Torokhov, linux-input, BlueZ development, Jiri Kosina

[-- Attachment #1: Type: text/plain, Size: 611 bytes --]

Heya,

Here's a patch to do the Bluetooth Wacom tablet's mode setting in the
kernel. In the past, it was done in a patch in bluetootd.

- 0001-hidp-Use-the-control-socket-for-raw-messages.patch

As discussed, now uses the ctrl channel for sending raw reports to the device.

- 0002-hid-wacom-Implement-Wacom-quirk-in-the-kernel.patch

Uses the above to poke at the device and turn it into mode2

- 0001-hid-sony-Fix-typo-in-error-message.patch

Small typo, for the input tree

- 0001-hid-Enable-Sixaxis-controller-over-Bluetooth-as-well.patch

Use the hidp patch above to enable the sixaxis controller

Cheers


[-- Attachment #2: 0001-hid-Enable-Sixaxis-controller-over-Bluetooth-as-well.patch --]
[-- Type: text/x-patch, Size: 2595 bytes --]

>From 54d987380685cf69d3f9037ef007c73861bf5eff Mon Sep 17 00:00:00 2001
From: Bastien Nocera <hadess@hadess.net>
Date: Wed, 20 Jan 2010 11:31:04 +0000
Subject: [PATCH] [hid] Enable Sixaxis controller over Bluetooth as well

Now that hid_output_raw_report works, port the PS3 Sixaxis
Bluetooth quirk from user-space, into kernel-space.

Signed-off-by: Bastien Nocera <hadess@hadess.net>
---
 drivers/hid/hid-core.c |    1 +
 drivers/hid/hid-sony.c |   15 ++++++++++++++-
 2 files changed, 15 insertions(+), 1 deletions(-)

diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c
index 3773f69..d88bebf 100644
--- a/drivers/hid/hid-core.c
+++ b/drivers/hid/hid-core.c
@@ -1337,6 +1337,7 @@ static const struct hid_device_id hid_blacklist[] = {
 	{ HID_USB_DEVICE(USB_VENDOR_ID_PETALYNX, USB_DEVICE_ID_PETALYNX_MAXTER_REMOTE) },
 	{ HID_USB_DEVICE(USB_VENDOR_ID_SAMSUNG, USB_DEVICE_ID_SAMSUNG_IR_REMOTE) },
 	{ HID_USB_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_PS3_CONTROLLER) },
+	{ HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_PS3_CONTROLLER) },
 	{ HID_USB_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_VAIO_VGX_MOUSE) },
 	{ HID_USB_DEVICE(USB_VENDOR_ID_SUNPLUS, USB_DEVICE_ID_SUNPLUS_WDESKTOP) },
 	{ HID_USB_DEVICE(USB_VENDOR_ID_THRUSTMASTER, 0xb300) },
diff --git a/drivers/hid/hid-sony.c b/drivers/hid/hid-sony.c
index 96d723e..d69ac22 100644
--- a/drivers/hid/hid-sony.c
+++ b/drivers/hid/hid-sony.c
@@ -73,6 +73,12 @@ static int sony_set_operational(struct hid_device *hdev)
 	return ret;
 }
 
+static int sony_set_operational_bt(struct hid_device *hdev)
+{
+	unsigned char buf[] = { 0x53, 0xf4,  0x42, 0x03, 0x00, 0x00 };
+	return hdev->hid_output_raw_report(hdev, buf, sizeof(buf));
+}
+
 static int sony_probe(struct hid_device *hdev, const struct hid_device_id *id)
 {
 	int ret;
@@ -101,7 +107,13 @@ static int sony_probe(struct hid_device *hdev, const struct hid_device_id *id)
 		goto err_free;
 	}
 
-	ret = sony_set_operational(hdev);
+	if (hdev->bus == BUS_USB)
+		ret = sony_set_operational(hdev);
+	else if (hdev->bus == BUS_BLUETOOTH)
+		ret = sony_set_operational_bt(hdev);
+	else
+		ret = 0;
+
 	if (ret < 0)
 		goto err_stop;
 
@@ -121,6 +133,7 @@ static void sony_remove(struct hid_device *hdev)
 
 static const struct hid_device_id sony_devices[] = {
 	{ HID_USB_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_PS3_CONTROLLER) },
+	{ HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_PS3_CONTROLLER) },
 	{ HID_USB_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_VAIO_VGX_MOUSE),
 		.driver_data = VAIO_RDESC_CONSTANT },
 	{ }
-- 
1.6.5.2


[-- Attachment #3: 0001-hidp-Use-the-control-socket-for-raw-messages.patch --]
[-- Type: text/x-patch, Size: 3182 bytes --]

>From e7438e866e4281806393ab6de276d31cb955bfe6 Mon Sep 17 00:00:00 2001
From: Bastien Nocera <hadess@hadess.net>
Date: Mon, 18 Jan 2010 16:11:33 +0000
Subject: [PATCH 1/2] [hidp] Use the control socket for raw messages

In commit 2da31939a42f7a676a0bc5155d6a0a39ed8451f2, support
for Bluetooth hid_output_raw_report was added, but it pushes
the data to the intr socket instead of the ctrl one.

This patch makes hid_output_raw_report use the control socket
instead.

Signed-off-by: Bastien Nocera <hadess@hadess.net>
---
 net/bluetooth/hidp/core.c |   70 +++++++++++++++++++++++----------------------
 1 files changed, 36 insertions(+), 34 deletions(-)

diff --git a/net/bluetooth/hidp/core.c b/net/bluetooth/hidp/core.c
index 5697500..40879ed 100644
--- a/net/bluetooth/hidp/core.c
+++ b/net/bluetooth/hidp/core.c
@@ -243,6 +243,39 @@ static void hidp_input_report(struct hidp_session *session, struct sk_buff *skb)
 	input_sync(dev);
 }
 
+static int __hidp_send_ctrl_message(struct hidp_session *session,
+			unsigned char hdr, unsigned char *data, int size)
+{
+	struct sk_buff *skb;
+
+	BT_DBG("session %p data %p size %d", session, data, size);
+
+	if (!(skb = alloc_skb(size + 1, GFP_ATOMIC))) {
+		BT_ERR("Can't allocate memory for new frame");
+		return -ENOMEM;
+	}
+
+	*skb_put(skb, 1) = hdr;
+	if (data && size > 0)
+		memcpy(skb_put(skb, size), data, size);
+
+	skb_queue_tail(&session->ctrl_transmit, skb);
+
+	return 0;
+}
+
+static inline int hidp_send_ctrl_message(struct hidp_session *session,
+			unsigned char hdr, unsigned char *data, int size)
+{
+	int err;
+
+	err = __hidp_send_ctrl_message(session, hdr, data, size);
+
+	hidp_schedule(session);
+
+	return err;
+}
+
 static int hidp_queue_report(struct hidp_session *session,
 				unsigned char *data, int size)
 {
@@ -282,7 +315,9 @@ static int hidp_send_report(struct hidp_session *session, struct hid_report *rep
 
 static int hidp_output_raw_report(struct hid_device *hid, unsigned char *data, size_t count)
 {
-	if (hidp_queue_report(hid->driver_data, data, count))
+	if (hidp_send_ctrl_message(hid->driver_data,
+			HIDP_TRANS_SET_REPORT | HIDP_DATA_RTYPE_FEATURE,
+			data, count))
 		return -ENOMEM;
 	return count;
 }
@@ -307,39 +342,6 @@ static inline void hidp_del_timer(struct hidp_session *session)
 		del_timer(&session->timer);
 }
 
-static int __hidp_send_ctrl_message(struct hidp_session *session,
-			unsigned char hdr, unsigned char *data, int size)
-{
-	struct sk_buff *skb;
-
-	BT_DBG("session %p data %p size %d", session, data, size);
-
-	if (!(skb = alloc_skb(size + 1, GFP_ATOMIC))) {
-		BT_ERR("Can't allocate memory for new frame");
-		return -ENOMEM;
-	}
-
-	*skb_put(skb, 1) = hdr;
-	if (data && size > 0)
-		memcpy(skb_put(skb, size), data, size);
-
-	skb_queue_tail(&session->ctrl_transmit, skb);
-
-	return 0;
-}
-
-static inline int hidp_send_ctrl_message(struct hidp_session *session,
-			unsigned char hdr, unsigned char *data, int size)
-{
-	int err;
-
-	err = __hidp_send_ctrl_message(session, hdr, data, size);
-
-	hidp_schedule(session);
-
-	return err;
-}
-
 static void hidp_process_handshake(struct hidp_session *session,
 					unsigned char param)
 {
-- 
1.6.5.2


[-- Attachment #4: 0001-hid-sony-Fix-typo-in-error-message.patch --]
[-- Type: text/x-patch, Size: 761 bytes --]

>From 3b7f54ec73ca8966934100e136ebfe0749882e03 Mon Sep 17 00:00:00 2001
From: Bastien Nocera <hadess@hadess.net>
Date: Wed, 20 Jan 2010 01:16:22 +0000
Subject: [PATCH 1/2] [hid-sony] Fix typo in error message

---
 drivers/hid/hid-sony.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/hid/hid-sony.c b/drivers/hid/hid-sony.c
index 4e84502..96d723e 100644
--- a/drivers/hid/hid-sony.c
+++ b/drivers/hid/hid-sony.c
@@ -81,7 +81,7 @@ static int sony_probe(struct hid_device *hdev, const struct hid_device_id *id)
 
 	sc = kzalloc(sizeof(*sc), GFP_KERNEL);
 	if (sc == NULL) {
-		dev_err(&hdev->dev, "can't alloc apple descriptor\n");
+		dev_err(&hdev->dev, "can't alloc sony descriptor\n");
 		return -ENOMEM;
 	}
 
-- 
1.6.5.2


[-- Attachment #5: 0002-hid-wacom-Implement-Wacom-quirk-in-the-kernel.patch --]
[-- Type: text/x-patch, Size: 1992 bytes --]

>From cebe11030bd6b26d92f4f541d3f109f54be4ad70 Mon Sep 17 00:00:00 2001
From: Bastien Nocera <hadess@hadess.net>
Date: Mon, 18 Jan 2010 16:13:41 +0000
Subject: [PATCH 2/2] [hid-wacom] Implement Wacom quirk in the kernel

The hid-wacom driver required user-space to poke at the tablet
to make it send data about the cursor location.

This patch makes it do the same thing but in the kernel.

Signed-off-by: Bastien Nocera <hadess@hadess.net>
---
 drivers/hid/hid-wacom.c |   25 +++++++++++++++++++++++++
 1 files changed, 25 insertions(+), 0 deletions(-)

diff --git a/drivers/hid/hid-wacom.c b/drivers/hid/hid-wacom.c
index 7475421..e55ed3f 100644
--- a/drivers/hid/hid-wacom.c
+++ b/drivers/hid/hid-wacom.c
@@ -155,7 +155,9 @@ static int wacom_probe(struct hid_device *hdev,
 	struct hid_input *hidinput;
 	struct input_dev *input;
 	struct wacom_data *wdata;
+	char rep_data[2];
 	int ret;
+	int limit;
 
 	wdata = kzalloc(sizeof(*wdata), GFP_KERNEL);
 	if (wdata == NULL) {
@@ -165,6 +167,7 @@ static int wacom_probe(struct hid_device *hdev,
 
 	hid_set_drvdata(hdev, wdata);
 
+	/* Parse the HID report now */
 	ret = hid_parse(hdev);
 	if (ret) {
 		dev_err(&hdev->dev, "parse failed\n");
@@ -177,6 +180,28 @@ static int wacom_probe(struct hid_device *hdev,
 		goto err_free;
 	}
 
+	/* Set Wacom mode2 */
+	rep_data[0] = 0x03; rep_data[1] = 0x00;
+	limit =3;
+	do {
+		ret = hdev->hid_output_raw_report(hdev, rep_data, 2);
+	} while (ret < 0 && limit-- > 0);
+	if (ret < 0) {
+		dev_err(&hdev->dev, "failed to poke device #1, %d\n", ret);
+		goto err_free;
+	}
+
+	/* 0x06 - high reporting speed, 0x05 - low speed */
+	rep_data[0] = 0x06; rep_data[1] = 0x00;
+	limit = 3;
+	do {
+		ret = hdev->hid_output_raw_report(hdev, rep_data, 2);
+	} while (ret < 0 && limit-- > 0);
+	if (ret < 0) {
+		dev_err(&hdev->dev, "failed to poke device #2, %d\n", ret);
+		goto err_free;
+	}
+
 	hidinput = list_entry(hdev->inputs.next, struct hid_input, list);
 	input = hidinput->input;
 
-- 
1.6.5.2


^ permalink raw reply related	[flat|nested] 21+ messages in thread

end of thread, other threads:[~2010-01-29 13:53 UTC | newest]

Thread overview: 21+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-01-18 16:49 [PATCHes] Implement Bluetooth Wacom tablet's mode change in the kernel Bastien Nocera
     [not found] ` <167e8a331001181144u54cefd15m65a5a63ca8c4c4b6@mail.gmail.com>
2010-01-18 21:35   ` Bastien Nocera
     [not found]     ` <1263850557.20565.3204.camel-bi+AKbBUZKY6gyzm1THtWbp2dZbC/Bob@public.gmane.org>
2010-01-19  0:19       ` Bastien Nocera
     [not found] ` <1263833399.20565.2905.camel-bi+AKbBUZKY6gyzm1THtWbp2dZbC/Bob@public.gmane.org>
2010-01-18 22:01   ` Przemysław Firszt
2010-01-19  7:29 ` Marcel Holtmann
2010-01-19 10:30   ` Bastien Nocera
2010-01-19 14:20     ` Jiri Kosina
2010-01-19 16:36     ` Gunn, Brian
     [not found]       ` <FE57175CCE23E5419899C1B0CFA26FAD101B5F8B9D-qt6i7J1wJoTyaV9iOGU/das+acoFTUjB@public.gmane.org>
2010-01-19 17:03         ` Bastien Nocera
     [not found]           ` <1263920596.1816.56.camel-bi+AKbBUZKY6gyzm1THtWbp2dZbC/Bob@public.gmane.org>
2010-01-19 17:05             ` Gunn, Brian
2010-01-19 20:47               ` Gunn, Brian
2010-01-21  1:08     ` Gunn, Brian
2010-01-21  1:35       ` Bastien Nocera
     [not found]         ` <1264037759.1735.5008.camel-bi+AKbBUZKY6gyzm1THtWbp2dZbC/Bob@public.gmane.org>
2010-01-28 22:33           ` Gunn, Brian
     [not found]             ` <FE57175CCE23E5419899C1B0CFA26FAD12CDF72C0F-qt6i7J1wJoTyaV9iOGU/das+acoFTUjB@public.gmane.org>
2010-01-28 22:53               ` Bastien Nocera
2010-01-28 22:57                 ` Gunn, Brian
2010-01-29  9:39                   ` Jiri Kosina
2010-01-29 13:45                     ` Bastien Nocera
2010-01-29 13:53                       ` Jiri Kosina
2010-01-20 11:47 Bastien Nocera
     [not found] ` <1263988051.1735.2474.camel-bi+AKbBUZKY6gyzm1THtWbp2dZbC/Bob@public.gmane.org>
2010-01-20 11:52   ` Marcel Holtmann

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).