From: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
To: linux-bluetooth@vger.kernel.org
Cc: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
Subject: [RFC] android/hid: Handle virtual unplug event from hid device
Date: Fri, 8 Nov 2013 16:14:54 +0200 [thread overview]
Message-ID: <1383920094-20498-1-git-send-email-ravikumar.veeramally@linux.intel.com> (raw)
If hid host receives the virtual unplug event from hid device
recipient shall destroy or invalidate all bluetooth bonding and
virtual cable information
---
android/hal-msg.h | 1 +
android/hidhost.c | 28 ++++++++++++++++++++++++++++
2 files changed, 29 insertions(+)
diff --git a/android/hal-msg.h b/android/hal-msg.h
index 4c7d344..569c8ea 100644
--- a/android/hal-msg.h
+++ b/android/hal-msg.h
@@ -449,6 +449,7 @@ struct hal_ev_hidhost_conn_state {
} __attribute__((packed));
#define HAL_HIDHOST_STATUS_OK 0x00
+#define HAL_HIDHOST_GENERAL_ERROR 0x06
#define HAL_EV_HIDHOST_INFO 0x82
struct hal_ev_hidhost_info {
diff --git a/android/hidhost.c b/android/hidhost.c
index d36cb82..683938f 100644
--- a/android/hidhost.c
+++ b/android/hidhost.c
@@ -379,6 +379,31 @@ send:
g_free(ev);
}
+static void bt_hid_notify_virtual_unplug(struct hid_device *dev,
+ uint8_t *buf, int len)
+{
+ struct hal_ev_hidhost_virtual_unplug ev;
+ char address[18];
+
+ ba2str(&dev->dst, address);
+ DBG("device %s", address);
+ bdaddr2android(&dev->dst, ev.bdaddr);
+
+ ev.status = HAL_HIDHOST_GENERAL_ERROR;
+
+ /* Wait either channels to HUP */
+ if (dev->intr_io && dev->ctrl_io) {
+ g_io_channel_shutdown(dev->intr_io, TRUE, NULL);
+ g_io_channel_shutdown(dev->ctrl_io, TRUE, NULL);
+ bt_hid_notify_state(dev, HAL_HIDHOST_STATE_DISCONNECTING);
+ ev.status = HAL_HIDHOST_STATUS_OK;
+ }
+
+ ipc_send(notification_sk, HAL_SERVICE_ID_HIDHOST,
+ HAL_EV_HIDHOST_VIRTUAL_UNPLUG, sizeof(ev), &ev, -1);
+
+}
+
static gboolean ctrl_io_watch_cb(GIOChannel *chan, gpointer data)
{
struct hid_device *dev = data;
@@ -404,6 +429,9 @@ 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);
+
/* reset msg type request */
dev->last_hid_msg = 0;
--
1.8.3.2
next reply other threads:[~2013-11-08 14:14 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-11-08 14:14 Ravi kumar Veeramally [this message]
2013-11-11 8:33 ` [RFC] android/hid: Handle virtual unplug event from hid device Johan Hedberg
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=1383920094-20498-1-git-send-email-ravikumar.veeramally@linux.intel.com \
--to=ravikumar.veeramally@linux.intel.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