Linux bluetooth development
 help / color / mirror / Atom feed
From: Jakub Tyszkowski <jakub.tyszkowski@tieto.com>
To: linux-bluetooth@vger.kernel.org
Cc: Jakub Tyszkowski <jakub.tyszkowski@tieto.com>
Subject: [PATCHv2 3/4] android/hid: Support handshake message
Date: Thu, 20 Nov 2014 12:18:50 +0100	[thread overview]
Message-ID: <1416482331-3766-3-git-send-email-jakub.tyszkowski@tieto.com> (raw)
In-Reply-To: <1416482331-3766-1-git-send-email-jakub.tyszkowski@tieto.com>

---
 android/hidhost.c | 32 ++++++++++++++++++++++++++++++--
 1 file changed, 30 insertions(+), 2 deletions(-)

diff --git a/android/hidhost.c b/android/hidhost.c
index 657fa8f..75e895b 100644
--- a/android/hidhost.c
+++ b/android/hidhost.c
@@ -58,6 +58,7 @@
 #define L2CAP_PSM_HIDP_INTR	0x13
 
 /* HID message types */
+#define HID_MSG_HANDSHAKE	0x00
 #define HID_MSG_CONTROL		0x10
 #define HID_MSG_GET_REPORT	0x40
 #define HID_MSG_SET_REPORT	0x50
@@ -65,6 +66,8 @@
 #define HID_MSG_SET_PROTOCOL	0x70
 #define HID_MSG_DATA		0xa0
 
+#define HID_MSG_TYPE_MASK	0xf0
+
 /* HID data types */
 #define HID_DATA_TYPE_INPUT	0x01
 #define HID_DATA_TYPE_OUTPUT	0x02
@@ -391,6 +394,22 @@ send:
 	g_free(ev);
 }
 
+static void bt_hid_notify_handshake(struct hid_device *dev, uint8_t *buf,
+									int len)
+{
+	struct hal_ev_hidhost_handshake ev;
+
+	bdaddr2android(&dev->dst, ev.bdaddr);
+
+	/* crop result code to handshake status range from HAL */
+	ev.status = buf[0];
+	if (ev.status > HAL_HIDHOST_HS_ERROR)
+		ev.status = HAL_HIDHOST_HS_ERROR;
+
+	ipc_send_notif(hal_ipc, HAL_SERVICE_ID_HIDHOST,
+				HAL_EV_HIDHOST_HANDSHAKE, sizeof(ev), &ev);
+}
+
 static void bt_hid_notify_virtual_unplug(struct hid_device *dev,
 							uint8_t *buf, int len)
 {
@@ -441,8 +460,17 @@ static gboolean ctrl_io_watch_cb(GIOChannel *chan, gpointer data)
 		break;
 	}
 
-	if (buf[0] == (HID_MSG_CONTROL | HID_VIRTUAL_CABLE_UNPLUG))
-		bt_hid_notify_virtual_unplug(dev, buf, bread);
+	switch (buf[0] & HID_MSG_TYPE_MASK) {
+	case HID_MSG_HANDSHAKE:
+		bt_hid_notify_handshake(dev, buf, bread);
+		break;
+	case HID_MSG_CONTROL:
+		if ((buf[0] & !HID_MSG_TYPE_MASK) == HID_VIRTUAL_CABLE_UNPLUG)
+			bt_hid_notify_virtual_unplug(dev, buf, bread);
+		break;
+	default:
+		break;
+	}
 
 	/* reset msg type request */
 	dev->last_hid_msg = 0;
-- 
1.9.1


  parent reply	other threads:[~2014-11-20 11:18 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-11-20 11:18 [PATCHv2 1/4] android/hal-ipc-api: Update HidHost with Android 5 API Jakub Tyszkowski
2014-11-20 11:18 ` [PATCHv2 2/4] android/hal: Update HidHost HAL for Android 5 Jakub Tyszkowski
2014-11-20 11:18 ` Jakub Tyszkowski [this message]
2014-11-20 11:18 ` [PATCHv2 4/4] android/client: Add handshake callback Jakub Tyszkowski
2014-11-20 15:23 ` [PATCHv2 1/4] android/hal-ipc-api: Update HidHost with Android 5 API Szymon Janc

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1416482331-3766-3-git-send-email-jakub.tyszkowski@tieto.com \
    --to=jakub.tyszkowski@tieto.com \
    --cc=linux-bluetooth@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox