summaryrefslogtreecommitdiff
path: root/chip/ish/hid_subsys.c
diff options
context:
space:
mode:
Diffstat (limited to 'chip/ish/hid_subsys.c')
-rw-r--r--chip/ish/hid_subsys.c58
1 files changed, 30 insertions, 28 deletions
diff --git a/chip/ish/hid_subsys.c b/chip/ish/hid_subsys.c
index bd3f331fdc..555af9046a 100644
--- a/chip/ish/hid_subsys.c
+++ b/chip/ish/hid_subsys.c
@@ -1,4 +1,4 @@
-/* Copyright 2018 The Chromium OS Authors. All rights reserved.
+/* Copyright 2018 The ChromiumOS Authors
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
@@ -11,8 +11,8 @@
#ifdef HID_SUBSYS_DEBUG
#define CPUTS(outstr) cputs(CC_LPC, outstr)
-#define CPRINTS(format, args...) cprints(CC_LPC, format, ## args)
-#define CPRINTF(format, args...) cprintf(CC_LPC, format, ## args)
+#define CPRINTS(format, args...) cprints(CC_LPC, format, ##args)
+#define CPRINTF(format, args...) cprintf(CC_LPC, format, ##args)
#else
#define CPUTS(outstr)
#define CPRINTS(format, args...)
@@ -21,10 +21,15 @@
#define __packed __attribute__((packed))
-#define HECI_CLIENT_HID_GUID { 0x33AECD58, 0xB679, 0x4E54,\
- { 0x9B, 0xD9, 0xA0, 0x4D, 0x34, 0xF0, 0xC2, 0x26 } }
+#define HECI_CLIENT_HID_GUID \
+ { \
+ 0x33AECD58, 0xB679, 0x4E54, \
+ { \
+ 0x9B, 0xD9, 0xA0, 0x4D, 0x34, 0xF0, 0xC2, 0x26 \
+ } \
+ }
-#define HID_SUBSYS_MAX_HID_DEVICES 3
+#define HID_SUBSYS_MAX_HID_DEVICES 3
/*
* the following enum values and data structures with __packed are used for
@@ -55,13 +60,13 @@ struct hid_device_info {
uint16_t vid;
} __packed;
-struct hid_enum_payload {
+struct hid_enum_payload {
uint8_t num_of_hid_devices;
struct hid_device_info dev_info[0];
} __packed;
-#define COMMAND_MASK 0x7F
-#define RESPONSE_FLAG 0x80
+#define COMMAND_MASK 0x7F
+#define RESPONSE_FLAG 0x80
struct hid_msg_hdr {
uint8_t command; /* bit 7 is used to indicate "response" */
uint8_t device_id;
@@ -94,8 +99,8 @@ static struct hid_subsystem hid_subsys_ctx = {
.heci_handle = HECI_INVALID_HANDLE,
};
-#define handle_to_dev_id(_handle) ((uintptr_t)(_handle))
-#define dev_id_to_handle(_dev_id) ((hid_handle_t)(uintptr_t)(_dev_id))
+#define handle_to_dev_id(_handle) ((uintptr_t)(_handle))
+#define dev_id_to_handle(_dev_id) ((hid_handle_t)(uintptr_t)(_dev_id))
static inline hid_handle_t device_index_to_handle(int device_index)
{
@@ -108,8 +113,8 @@ static inline int is_valid_handle(hid_handle_t handle)
(uintptr_t)handle <= hid_subsys_ctx.num_of_hid_devices;
}
-static inline
-struct hid_subsys_hid_device *handle_to_hid_device(hid_handle_t handle)
+static inline struct hid_subsys_hid_device *
+handle_to_hid_device(hid_handle_t handle)
{
if (!is_valid_handle(handle))
return NULL;
@@ -117,7 +122,6 @@ struct hid_subsys_hid_device *handle_to_hid_device(hid_handle_t handle)
return &hid_subsys_ctx.hid_devices[(uintptr_t)handle - 1];
}
-
hid_handle_t hid_subsys_register_device(const struct hid_device *dev_info)
{
struct hid_subsys_hid_device *hid_device;
@@ -156,7 +160,7 @@ int hid_subsys_send_input_report(const hid_handle_t handle, uint8_t *buf,
const size_t buf_size)
{
struct hid_subsys_hid_device *hid_device;
- struct hid_msg_hdr hid_msg_hdr = {0};
+ struct hid_msg_hdr hid_msg_hdr = { 0 };
struct heci_msg_item msg_item[2];
struct heci_msg_list msg_list;
@@ -253,7 +257,7 @@ static int handle_hid_device_msg(struct hid_msg *hid_msg)
* re-use hid_msg from host for reply.
*/
switch (hid_msg->hdr.command & COMMAND_MASK) {
- case HID_GET_HID_DESCRIPTOR:
+ case HID_GET_HID_DESCRIPTOR:
if (cbs->get_hid_descriptor)
ret = cbs->get_hid_descriptor(handle, payload,
buf_size);
@@ -277,10 +281,8 @@ static int handle_hid_device_msg(struct hid_msg *hid_msg)
case HID_SET_FEATURE_REPORT:
if (cbs->set_feature_report) {
- ret = cbs->set_feature_report(handle,
- payload[0],
- payload,
- payload_size);
+ ret = cbs->set_feature_report(handle, payload[0],
+ payload, payload_size);
/*
* if no error, reply only with the report id.
* re-use the first byte of payload
@@ -293,8 +295,8 @@ static int handle_hid_device_msg(struct hid_msg *hid_msg)
break;
case HID_GET_INPUT_REPORT:
if (cbs->get_input_report)
- ret = cbs->get_input_report(handle, payload[0],
- payload, buf_size);
+ ret = cbs->get_input_report(handle, payload[0], payload,
+ buf_size);
break;
@@ -331,21 +333,21 @@ static int handle_hid_subsys_msg(struct hid_msg *hid_msg)
struct hid_enum_payload *enum_payload;
switch (hid_msg->hdr.command & COMMAND_MASK) {
- case HID_DM_ENUM_DEVICES:
+ case HID_DM_ENUM_DEVICES:
enum_payload = (struct hid_enum_payload *)hid_msg->payload;
for (i = 0; i < hid_subsys_ctx.num_of_hid_devices; i++) {
enum_payload->dev_info[i] =
- hid_subsys_ctx.hid_devices[i].info;
+ hid_subsys_ctx.hid_devices[i].info;
}
enum_payload->num_of_hid_devices =
- hid_subsys_ctx.num_of_hid_devices;
+ hid_subsys_ctx.num_of_hid_devices;
/* reply payload size */
size = sizeof(enum_payload->num_of_hid_devices);
size += enum_payload->num_of_hid_devices *
- sizeof(enum_payload->dev_info[0]);
+ sizeof(enum_payload->dev_info[0]);
break;
@@ -408,7 +410,7 @@ static int hid_subsys_resume(const heci_handle_t heci_handle)
for (i = 0; i < hid_subsys_ctx.num_of_hid_devices; i++) {
if (hid_subsys_ctx.hid_devices[i].cbs->resume)
ret |= hid_subsys_ctx.hid_devices[i].cbs->resume(
- device_index_to_handle(i));
+ device_index_to_handle(i));
}
return ret;
@@ -422,7 +424,7 @@ static int hid_subsys_suspend(const heci_handle_t heci_handle)
for (i = hid_subsys_ctx.num_of_hid_devices - 1; i >= 0; i--) {
if (hid_subsys_ctx.hid_devices[i].cbs->suspend)
ret |= hid_subsys_ctx.hid_devices[i].cbs->suspend(
- device_index_to_handle(i));
+ device_index_to_handle(i));
}
return ret;