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: [PATCH 1/3] android/hidhost: Handle uhid output and feature events
Date: Mon, 11 Nov 2013 14:15:28 +0200 [thread overview]
Message-ID: <1384172130-29837-1-git-send-email-ravikumar.veeramally@linux.intel.com> (raw)
Data read on uhid events output and feature has to be send through
SET_REPORT request to HID device.
---
android/hidhost.c | 37 ++++++++++++++++++++++++++++++++++++-
1 file changed, 36 insertions(+), 1 deletion(-)
diff --git a/android/hidhost.c b/android/hidhost.c
index 683938f..816fe3e 100644
--- a/android/hidhost.c
+++ b/android/hidhost.c
@@ -155,7 +155,42 @@ 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;
+ uint8_t *req = NULL;
+ uint8_t req_size = 0;
+
+ if (!(dev->ctrl_io))
+ return;
+
+ switch (ev->type) {
+ case UHID_OUTPUT:
+ req_size = 1 + ev->u.output.size;
+ req = g_try_malloc0(req_size);
+ if (!req)
+ return;
+
+ req[0] = HID_MSG_SET_REPORT | HID_DATA_TYPE_OUTPUT;
+ memcpy(req + 1, ev->u.output.data, ev->u.output.size);
+ break;
+
+ case UHID_FEATURE:
+ req_size = sizeof(struct uhid_feature_req);
+ req = g_try_malloc0(req_size);
+ if (!req)
+ return;
+
+ req[0] = HID_MSG_SET_REPORT | HID_DATA_TYPE_FEATURE;
+ memcpy(req + 1, (ev + sizeof(ev->type)), req_size - 1);
+ break;
+ }
+
+ fd = g_io_channel_unix_get_fd(dev->ctrl_io);
+
+ if (write(fd, req, req_size) < 0)
+ error("error writing hid_set_report: %s (%d)",
+ strerror(errno), errno);
+
+ g_free(req);
}
static gboolean uhid_event_cb(GIOChannel *io, GIOCondition cond,
--
1.8.3.2
next reply other threads:[~2013-11-11 12:15 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-11-11 12:15 Ravi kumar Veeramally [this message]
2013-11-11 12:15 ` [PATCH 2/3] android/hidhost: Remove deprecated idle opcode from ipc document Ravi kumar Veeramally
2013-11-11 23:05 ` Marcel Holtmann
2013-11-12 9:29 ` Ravi Kumar Veeramally
2013-11-12 14:00 ` Ravi Kumar Veeramally
2013-11-12 15:57 ` Marcel Holtmann
2013-11-11 12:15 ` [PATCH 3/3] android/hidhost: Set info request from HAL is not supported Ravi kumar Veeramally
2013-11-12 10:11 ` [PATCH 1/3] android/hidhost: Handle uhid output and feature events Ravi Kumar Veeramally
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=1384172130-29837-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;
as well as URLs for NNTP newsgroup(s).