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_v2 08/13] android/hid: Implement hid set report in daemon
Date: Tue, 5 Nov 2013 13:38:10 +0200 [thread overview]
Message-ID: <1383651495-12434-9-git-send-email-ravikumar.veeramally@linux.intel.com> (raw)
In-Reply-To: <1383651495-12434-1-git-send-email-ravikumar.veeramally@linux.intel.com>
This patch requests hid device to set report.
---
android/hal-hidhost.c | 2 ++
android/hal-msg.h | 6 ++++--
android/hid.c | 40 ++++++++++++++++++++++++++++++++++++++--
3 files changed, 44 insertions(+), 4 deletions(-)
diff --git a/android/hal-hidhost.c b/android/hal-hidhost.c
index f554cb2..29e3ee0 100644
--- a/android/hal-hidhost.c
+++ b/android/hal-hidhost.c
@@ -284,6 +284,8 @@ static bt_status_t hh_set_report(bt_bdaddr_t *bd_addr,
return BT_STATUS_PARM_INVALID;
memcpy(cmd.bdaddr, bd_addr, sizeof(cmd.bdaddr));
+ cmd.len = strlen(report);
+ memcpy(cmd.data, report, cmd.len);
switch (reportType) {
case BTHH_INPUT_REPORT:
diff --git a/android/hal-msg.h b/android/hal-msg.h
index bc7df6b..2c3067f 100644
--- a/android/hal-msg.h
+++ b/android/hal-msg.h
@@ -290,8 +290,10 @@ struct hal_cmd_hid_get_report {
#define HAL_OP_HID_SET_REPORT 0x08
struct hal_cmd_hid_set_report {
- uint8_t bdaddr[6];
- uint8_t type;
+ uint8_t bdaddr[6];
+ uint8_t type;
+ uint16_t len;
+ uint8_t data[670];
} __attribute__((packed));
#define HAL_OP_HID_SEND_DATA 0x09
diff --git a/android/hid.c b/android/hid.c
index f1bf9e8..25e33fa 100644
--- a/android/hid.c
+++ b/android/hid.c
@@ -56,6 +56,7 @@
/* HID message types */
#define HID_MSG_GET_REPORT 0x40
+#define HID_MSG_SET_REPORT 0x50
#define HID_MSG_GET_PROTOCOL 0x60
#define HID_MSG_SET_PROTOCOL 0x70
#define HID_MSG_DATA 0xa0
@@ -846,9 +847,44 @@ static uint8_t bt_hid_get_report(struct hal_cmd_hid_get_report *cmd,
static uint8_t bt_hid_set_report(struct hal_cmd_hid_set_report *cmd,
uint16_t len)
{
- DBG("Not Implemented");
+ struct hid_device *dev;
+ GSList *l;
+ bdaddr_t dst;
+ int fd;
+ uint8_t *req;
+ uint8_t req_size;
- return HAL_STATUS_FAILED;
+ DBG("");
+
+ if (len < sizeof(*cmd))
+ return HAL_STATUS_INVALID;
+
+ android2bdaddr(&cmd->bdaddr, &dst);
+
+ l = g_slist_find_custom(devices, &dst, device_cmp);
+ if (!l)
+ return HAL_STATUS_FAILED;
+
+ dev = l->data;
+ dev->hid_msg = HID_MSG_SET_REPORT;
+ req_size = 1 + cmd->len;
+ req = g_try_malloc0(req_size);
+ if (!req)
+ return HAL_STATUS_NOMEM;
+
+ req[0] = HID_MSG_SET_REPORT | cmd->type;
+ memcpy(req + 1, cmd->data, req_size - 1);
+
+ fd = g_io_channel_unix_get_fd(dev->ctrl_io);
+
+ if (write(fd, req, req_size) < 0) {
+ error("error while querying device protocol");
+ g_free(req);
+ return HAL_STATUS_FAILED;
+ }
+
+ g_free(req);
+ return HAL_STATUS_SUCCESS;
}
static uint8_t bt_hid_send_data(struct hal_cmd_hid_send_data *cmd,
--
1.8.1.2
next prev parent reply other threads:[~2013-11-05 11:38 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-11-05 11:38 [PATCH_v2 00/13] Implemented hid interfaces in daemon and hal Ravi kumar Veeramally
2013-11-05 11:38 ` [PATCH_v2 01/13] android/hid: Add hid event proto mode structure to hal msg headers Ravi kumar Veeramally
2013-11-05 11:38 ` [PATCH_v2 02/13] android/hid: Implement hid get protocol in daemon Ravi kumar Veeramally
2013-11-05 11:38 ` [PATCH_v2 03/13] android/hid: Implement hid set " Ravi kumar Veeramally
2013-11-05 11:38 ` [PATCH_v2 04/13] android/hid: Handle protocol mode notification in hal Ravi kumar Veeramally
2013-11-05 11:38 ` [PATCH_v2 05/13] android/hid: Add hid event get report structure to hal msg headers Ravi kumar Veeramally
2013-11-05 11:38 ` [PATCH_v2 06/13] android/hid: Implement hid get report in daemon Ravi kumar Veeramally
2013-11-05 11:38 ` [PATCH_v2 07/13] android/hid: Add missing set report parameters to ipc document Ravi kumar Veeramally
2013-11-05 11:38 ` Ravi kumar Veeramally [this message]
2013-11-05 11:38 ` [PATCH_v2 09/13] android/hid: Handle get report notification in hal Ravi kumar Veeramally
2013-11-05 11:38 ` [PATCH_v2 10/13] android/hid: Replace header checking magic number with defines Ravi kumar Veeramally
2013-11-05 11:38 ` [PATCH_v2 11/13] android/hid: Handle invalid parameters in hal Ravi kumar Veeramally
2013-11-05 11:38 ` [PATCH_v2 12/13] android/hid: Handle uhid events Ravi kumar Veeramally
2013-11-05 11:38 ` [PATCH_v2 13/13] android/hid: Align hal hid struct variables properly 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=1383651495-12434-9-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