Skip to contentSkip to conversation

android/hidhost: Handle uhid output and feature events

PATCH In review Ravi kumar Veeramally 2 participants 6 messages Nov 12, 2013 – Nov 13, 2013 Bluetooth drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/3 android/hidhost: Handle uhid output and feature events

Data read on uhid events output and feature has to be send through SET_REPORT request to HID device.

---
 android/hidhost.c | 25 ++++++++++++++++++++++++-
 1 file changed, 24 insertions(+), 1 deletion(-)
android/hidhost.c +24 -1
index cba80a6..556e5a5 100644
@@ -155,7 +155,30 @@ static void hid_device_free(struct hid_device *dev)
 
 static void handle_uhid_event(struct hid_device *dev, struct uhid_event *ev)
 {
-	DBG("UHID_OUTPUT UHID_FEATURE unsupported");
+	int fd, i;
+	uint8_t *req = NULL;
+	uint8_t req_size = 0;
+
+	if (!(dev->ctrl_io))
+		return;
+
+	req_size = 1 + (ev->u.output.size / 2);
+	req = g_try_malloc0(req_size);
+	if (!req)
+		return;
+
+	req[0] = HID_MSG_SET_REPORT | ev->u.output.rtype;
+	for (i = 0; i < (req_size - 1); i++)
+		sscanf((char *) &(ev->u.output.data)[i * 2],
+							"%hhx", &(req + 1)[i]);
+
+	fd = g_io_channel_unix_get_fd(dev->ctrl_io);
+
+	if (write(fd, req, req_size) < 0)
+		error("error writing set_report: %s (%d)",
+						strerror(errno), errno);
+
+	g_free(req);
 }
 
 static gboolean uhid_event_cb(GIOChannel *io, GIOCondition cond,
Signature · 1 line
1.8.3.2
#1 lore raw

PATCH 2/3 android/hidhost: Remove deprecated idle opcode from ipc document

Idle time is deprecated in HID_SPEC1_1. So get and set idle time api's are removed and not implemented. But callback is left out in Android bt_hh.h. Generally this callback needs to be called when HAL requests get and set idle time calls with status. So the method calls itself removed, no point to implement this callback.
Also update GET_REPORT and VIRTUAL_UNPLUG opcode values.

---
 android/hal-ipc-api.txt | 10 ++--------
 android/hal-msg.h       |  4 ++--
 2 files changed, 4 insertions(+), 10 deletions(-)
android/hal-ipc-api.txt +2 -8
index 91ea280..57f4c13 100644
@@ -614,20 +614,14 @@ Notifications:
 		                      0x01 = Boot
 		                      0xff = Unsupported
 
-	Opcode 0x84 - Idle Time notification
-
-		Notification parameters: Remote address (6 octets)
-		                         Status (1 octet)
-		                         Idle time (2 octets)
-
-	Opcode 0x85 - Get Report notification
+	Opcode 0x84 - Get Report notification
 
 		Notification parameters: Remote address (6 octets)
 		                         Status (1 octet)
 		                         Report length (2 octets)
 		                         Report data (variable)
 
-	Opcode 0x86 - Virtual Unplug notification
+	Opcode 0x85 - Virtual Unplug notification
 
 		Notification parameters: Remote address (6 octets)
 		                         Status (1 octet)
android/hal-msg.h +2 -2
index 4dfd555..847cc1f 100644
@@ -499,7 +499,7 @@ struct hal_ev_hidhost_proto_mode {
 	uint8_t mode;
 } __attribute__((packed));
 
-#define HAL_EV_HIDHOST_GET_REPORT		0x85
+#define HAL_EV_HIDHOST_GET_REPORT		0x84
 struct hal_ev_hidhost_get_report {
 	uint8_t  bdaddr[6];
 	uint8_t  status;
@@ -507,7 +507,7 @@ struct hal_ev_hidhost_get_report {
 	uint8_t  data[0];
 } __attribute__((packed));
 
-#define HAL_EV_HIDHOST_VIRTUAL_UNPLUG		0x86
+#define HAL_EV_HIDHOST_VIRTUAL_UNPLUG		0x85
 struct hal_ev_hidhost_virtual_unplug {
 	uint8_t  bdaddr[6];
 	uint8_t  status;
Signature · 1 line
1.8.3.2
#2 lore raw

PATCH 3/3 android/hidhost: Set info request from HAL is not supported

In reply to Ravi kumar Veeramally

Data from hal_cmd_hidhost_set_info is usefull only when we create UHID device. Once device is created all the transactions will be done through the fd. There is no way to use this information once device is created with HID internals.

---
 android/hidhost.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
android/hidhost.c +6 -2
index 556e5a5..95a98c3 100644
@@ -839,9 +839,13 @@ static uint8_t bt_hid_virtual_unplug(struct hal_cmd_hidhost_virtual_unplug *cmd,
 
 static uint8_t bt_hid_info(struct hal_cmd_hidhost_set_info *cmd, uint16_t len)
 {
-	DBG("Not Implemented");
+	/* Data from hal_cmd_hidhost_set_info is usefull only when we create
+	 * UHID device. Once device is created all the transactions will be
+	 * done through the fd. There is no way to use this information
+	 * once device is created with HID internals. */
+	DBG("Not supported");
 
-	return HAL_STATUS_FAILED;
+	return HAL_STATUS_UNSUPPORTED;
 }
 
 static uint8_t bt_hid_get_protocol(struct hal_cmd_hidhost_get_protocol *cmd,
Signature · 1 line
1.8.3.2
#3 lore raw
In reply to Ravi kumar Veeramally

Hi Ravi,

android/hidhost.c static void hid_device_free(struct hid_device *dev) · line 173

Quoted 2 lines · Ravi kumar Veeramally
android/hidhost.c +2 -0
+		sscanf((char *) &(ev->u.output.data)[i * 2],
+							"%hhx", &(req + 1)[i]);

The last parameter is a bit of a brain twister. How about simply &req[1 + i]?

Johan

#4 lore raw

Hi Johan,

Quoted 4 lines

android/hidhost.c static void hid_device_free(struct hid_device *dev) · line 173

Quoted 2 lines
android/hidhost.c +2 -0
+		sscanf((char *) &(ev->u.output.data)[i * 2],
+							"%hhx", &(req + 1)[i]);

The last parameter is a bit of a brain twister. How about simply &req[1 + i]?

Yeap, simple :).

Thanks,
Ravi.

#5 lore raw

Hi Ravi,

Quoted 7 lines · Ravi Kumar Veeramally

Hi Johan,

Quoted 4 lines

android/hidhost.c static void hid_device_free(struct hid_device *dev) · line 173

Quoted 2 lines
android/hidhost.c +2 -0
+		sscanf((char *) &(ev->u.output.data)[i * 2],
+							"%hhx", &(req + 1)[i]);

The last parameter is a bit of a brain twister. How about simply &req[1 + i]?

Yeap, simple :).

I fixed this up myself, so all three patches have now been applied.

Johan