Skip to contentSkip to conversation

Implement Bluetooth Wacom tablet's mode change in the kernel

PATCH In review Bastien Nocera 2 participants 2 messages Jan 20, 2010

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Implement Bluetooth Wacom tablet's mode change in the kernel

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

Quoted 1 line

From 54d987380685cf69d3f9037ef007c73861bf5eff Mon Sep 17 00:00:00 2001

From: Bastien Nocera <[email protected]>
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.

---
 drivers/hid/hid-core.c |    1 +
 drivers/hid/hid-sony.c |   15 ++++++++++++++-
 2 files changed, 15 insertions(+), 1 deletions(-)
drivers/hid/hid-core.c +1 -0
index 3773f69..d88bebf 100644
@@ -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) },
drivers/hid/hid-sony.c +14 -1
index 96d723e..d69ac22 100644
@@ -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 },
 	{ }
Signature · 1 line
1.6.5.2
Quoted 1 line

From e7438e866e4281806393ab6de276d31cb955bfe6 Mon Sep 17 00:00:00 2001

From: Bastien Nocera <[email protected]>
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.

---
 net/bluetooth/hidp/core.c |   70 +++++++++++++++++++++++----------------------
 1 files changed, 36 insertions(+), 34 deletions(-)
net/bluetooth/hidp/core.c +36 -34

88 lines not on this page · raw message

Signature · 1 line
1.6.5.2
Quoted 1 line

From 3b7f54ec73ca8966934100e136ebfe0749882e03 Mon Sep 17 00:00:00 2001

From: Bastien Nocera <[email protected]>
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(-)
drivers/hid/hid-sony.c +1 -1
index 4e84502..96d723e 100644
@@ -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;
 	}
 
Signature · 1 line
1.6.5.2
Quoted 1 line

From cebe11030bd6b26d92f4f541d3f109f54be4ad70 Mon Sep 17 00:00:00 2001

From: Bastien Nocera <[email protected]>
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.

---
 drivers/hid/hid-wacom.c |   25 +++++++++++++++++++++++++
 1 files changed, 25 insertions(+), 0 deletions(-)
drivers/hid/hid-wacom.c +25 -0
index 7475421..e55ed3f 100644
@@ -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;
 
Signature · 1 line
1.6.5.2
maintainer
#1 lore raw

Hi Bastien,

Quoted 11 lines

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

Quoted 7 lines

- 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

please send them one patch per email and send them inline. In case of troubles just use git send-email.

Regards

Marcel