android: Add initial code for hidhost virtual unplug
PATCH 1/5 android: Add initial code for hidhost virtual unplug
This adds initial code for hidhost .virtual_unplug interface
--- android/hal-hidhost.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)
android/hal-hidhost.c +9 -1
@@ -79,6 +79,8 @@ static bt_status_t hh_disconnect(bt_bdaddr_t *bd_addr)static bt_status_t hh_virtual_unplug (bt_bdaddr_t *bd_addr) { +struct hal_msg_cmd_bt_hid_vp cmd; +DBG ("" );if (!interface_ready ())
@@ -87,7 +89,13 @@ static bt_status_t hh_virtual_unplug(bt_bdaddr_t *bd_addr)if (!bd_addr)return BT_STATUS_PARM_INVALID ; -return BT_STATUS_UNSUPPORTED ; +memcpy (cmd.bdaddr, bd_addr,sizeof (cmd.bdaddr)); + +if (hal_ipc_cmd (HAL_SERVICE_ID_HIDHOST ,HAL_MSG_OP_BT_HID_VP , +sizeof (cmd), &cmd,0 ,NULL ,NULL ) <0 ) +return BT_STATUS_FAIL ; + +return BT_STATUS_SUCCESS ; }static bt_status_t hh_set_info (bt_bdaddr_t *bd_addr,bthh_hid_info_t hid_info)
Signature · 1 line
1.7.9.5
PATCH 2/5 android: Add initial code for hidhost get and set protocol
This adds the initial code for hidhost .get_protocol and .set_protocol interfaces
--- android/hal-hidhost.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 46 insertions(+), 2 deletions(-)
android/hal-hidhost.c +46 -2
@@ -114,6 +114,8 @@ static bt_status_t hh_set_info(bt_bdaddr_t *bd_addr, bthh_hid_info_t hid_info)static bt_status_t hh_get_protocol (bt_bdaddr_t *bd_addr,bthh_protocol_mode_t protocolMode) { +struct hal_msg_cmd_bt_hid_get_protocol cmd; +DBG ("" );if (!interface_ready ())
@@ -122,12 +124,34 @@ static bt_status_t hh_get_protocol(bt_bdaddr_t *bd_addr,if (!bd_addr)return BT_STATUS_PARM_INVALID ; -return BT_STATUS_UNSUPPORTED ; +memcpy (cmd.bdaddr, bd_addr,sizeof (cmd.bdaddr)); + +switch (protocolMode) { +case BTHH_REPORT_MODE : + cmd.mode =HAL_MSG_BT_HID_REPORT_PROTOCOL ; +break ; +case BTHH_BOOT_MODE : + cmd.mode =HAL_MSG_BT_HID_BOOT_PROTOCOL ; +break ; +case BTHH_UNSUPPORTED_MODE : + cmd.mode =HAL_MSG_BT_HID_UNSUPPORTED_PROTOCOL ; +break ; + } + +if (hal_ipc_cmd (HAL_SERVICE_ID_HIDHOST ,HAL_MSG_OP_BT_HID_GET_PROTOCOL , +sizeof (cmd), &cmd,0 ,NULL ,NULL ) <0 ) { +error ("Failed to get hid device protocol" ); +return BT_STATUS_FAIL ; + } + +return BT_STATUS_SUCCESS ; }static bt_status_t hh_set_protocol (bt_bdaddr_t *bd_addr,bthh_protocol_mode_t protocolMode) { +struct hal_msg_cmd_bt_hid_set_protocol cmd; +DBG ("" );if (!interface_ready ())
@@ -136,7 +160,27 @@ static bt_status_t hh_set_protocol(bt_bdaddr_t *bd_addr,if (!bd_addr)return BT_STATUS_PARM_INVALID ; -return BT_STATUS_UNSUPPORTED ; +memcpy (cmd.bdaddr, bd_addr,sizeof (cmd.bdaddr)); + +switch (protocolMode) { +case BTHH_REPORT_MODE : + cmd.mode =HAL_MSG_BT_HID_REPORT_PROTOCOL ; +break ; +case BTHH_BOOT_MODE : + cmd.mode =HAL_MSG_BT_HID_BOOT_PROTOCOL ; +break ; +case BTHH_UNSUPPORTED_MODE : + cmd.mode =HAL_MSG_BT_HID_UNSUPPORTED_PROTOCOL ; +break ; + } + +if (hal_ipc_cmd (HAL_SERVICE_ID_HIDHOST ,HAL_MSG_OP_BT_HID_SET_PROTOCOL , +sizeof (cmd), &cmd,0 ,NULL ,NULL ) <0 ) { +error ("Failed to set hid device protocol" ); +return BT_STATUS_FAIL ; + } + +return BT_STATUS_SUCCESS ; } static bt_status_t hh_get_report(bt_bdaddr_t *bd_addr,
Signature · 1 line
1.7.9.5
PATCH 3/5 android: Add initial code for hidhost get and set report
In reply to Ravi kumar VeeramallyThis adds the initial code for hidhost .get_report and .set_report interfaces
--- android/hal-hidhost.c | 49 +++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 47 insertions(+), 2 deletions(-)
android/hal-hidhost.c +47 -2
@@ -188,6 +188,8 @@ static bt_status_t hh_get_report(bt_bdaddr_t *bd_addr, uint8_t reportId, int bufferSize) { +struct hal_msg_cmd_bt_hid_get_report cmd; +DBG ("" );if (!interface_ready ())
@@ -196,13 +198,36 @@ static bt_status_t hh_get_report(bt_bdaddr_t *bd_addr,if (!bd_addr)return BT_STATUS_PARM_INVALID ; -return BT_STATUS_UNSUPPORTED ; +memcpy (cmd.bdaddr, bd_addr,sizeof (cmd.bdaddr)); + cmd.id = reportId; + +switch (reportType) { +case BTHH_INPUT_REPORT : + cmd.type =HAL_MSG_BT_HID_INPUT_REPORT ; +break ; +case BTHH_OUTPUT_REPORT : + cmd.type =HAL_MSG_BT_HID_OUTPUT_REPORT ; +break ; +case BTHH_FEATURE_REPORT : + cmd.type =HAL_MSG_BT_HID_FEATURE_REPORT ; +break ; + } + +if (hal_ipc_cmd (HAL_SERVICE_ID_HIDHOST ,HAL_MSG_OP_BT_HID_GET_REPORT , +sizeof (cmd), &cmd,0 ,NULL ,NULL ) <0 ) { +error ("Failed to get hid devie report" ); +return BT_STATUS_FAIL ; + } + +return BT_STATUS_SUCCESS ; }static bt_status_t hh_set_report (bt_bdaddr_t *bd_addr,bthh_report_type_t reportType,char *report) { +struct hal_msg_cmd_bt_hid_set_report cmd; +DBG ("" );if (!interface_ready ())
@@ -211,7 +236,27 @@ static bt_status_t hh_set_report(bt_bdaddr_t *bd_addr,if (!bd_addr || !report)return BT_STATUS_PARM_INVALID ; -return BT_STATUS_UNSUPPORTED ; +memcpy (cmd.bdaddr, bd_addr,sizeof (cmd.bdaddr)); + +switch (reportType) { +case BTHH_INPUT_REPORT : + cmd.type =HAL_MSG_BT_HID_INPUT_REPORT ; +break ; +case BTHH_OUTPUT_REPORT : + cmd.type =HAL_MSG_BT_HID_OUTPUT_REPORT ; +break ; +case BTHH_FEATURE_REPORT : + cmd.type =HAL_MSG_BT_HID_FEATURE_REPORT ; +break ; + } + +if (hal_ipc_cmd (HAL_SERVICE_ID_HIDHOST ,HAL_MSG_OP_BT_HID_SET_REPORT , +sizeof (cmd), &cmd,0 ,NULL ,NULL ) <0 ) { +error ("Failed to set hid devie report" ); +return BT_STATUS_FAIL ; + } + +return BT_STATUS_SUCCESS ; }static bt_status_t hh_send_data (bt_bdaddr_t *bd_addr,char *data)
Signature · 1 line
1.7.9.5
PATCH 4/5 android: Add initial code for hidhost send data
In reply to Ravi kumar VeeramallyThis adds the initial code for hidhost .send_data interface
--- android/hal-hidhost.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-)
android/hal-hidhost.c +11 -1
@@ -261,6 +261,8 @@ static bt_status_t hh_set_report(bt_bdaddr_t *bd_addr,static bt_status_t hh_send_data (bt_bdaddr_t *bd_addr,char *data) { +struct hal_msg_cmd_bt_hid_send_data cmd; +DBG ("" );if (!interface_ready ())
@@ -269,7 +271,15 @@ static bt_status_t hh_send_data(bt_bdaddr_t *bd_addr, char *data)if (!bd_addr || !data)return BT_STATUS_PARM_INVALID ; -return BT_STATUS_UNSUPPORTED ; +memcpy (cmd.bdaddr, bd_addr,sizeof (cmd.bdaddr)); + +if (hal_ipc_cmd (HAL_SERVICE_ID_HIDHOST ,HAL_MSG_OP_BT_HID_SEND_DATA , +sizeof (cmd), &cmd,0 ,NULL ,NULL ) <0 ) { +error ("Failed to send data to hid devie" ); +return BT_STATUS_FAIL ; + } + +return BT_STATUS_SUCCESS ; }static bt_status_t hh_init (bthh_callbacks_t *callbacks)
Signature · 1 line
1.7.9.5
PATCH 5/5 android: Add initial code for hidhost set hid information
In reply to Ravi kumar VeeramallyThis adds the initial code for hidhost .set_info interface
--- android/hal-hidhost.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-)
android/hal-hidhost.c +19 -1
@@ -100,6 +100,8 @@ static bt_status_t hh_virtual_unplug(bt_bdaddr_t *bd_addr)static bt_status_t hh_set_info (bt_bdaddr_t *bd_addr,bthh_hid_info_t hid_info) { +struct hal_msg_cmd_bt_hid_set_info cmd; +DBG ("" );if (!interface_ready ())
@@ -108,7 +110,23 @@ static bt_status_t hh_set_info(bt_bdaddr_t *bd_addr, bthh_hid_info_t hid_info)if (!bd_addr)return BT_STATUS_PARM_INVALID ; -return BT_STATUS_UNSUPPORTED ; +memcpy (cmd.bdaddr, bd_addr,sizeof (cmd.bdaddr)); + cmd.attr = hid_info.attr_mask; + cmd.subclass = hid_info.sub_class; + cmd.app_id = hid_info.app_id; + cmd.vendor = hid_info.vendor_id; + cmd.product = hid_info.product_id; + cmd.country = hid_info.ctry_code; + cmd.descr_len = hid_info.dl_len; +memcpy (cmd.descr, hid_info.dsc_list, cmd.descr_len); + +if (hal_ipc_cmd (HAL_SERVICE_ID_HIDHOST ,HAL_MSG_OP_BT_HID_SET_INFO , +sizeof (cmd), &cmd,0 ,NULL ,NULL ) <0 ) { +error ("Failed to set hid info on device" ); +return BT_STATUS_FAIL ; + } + +return BT_STATUS_SUCCESS ; } static bt_status_t hh_get_protocol(bt_bdaddr_t *bd_addr,
Signature · 1 line
1.7.9.5
Hi Ravi,
android/hal-hidhost.c static bt_status_t hh_virtual_unplug(bt_bdaddr_t *bd_addr) · line 99
Quoted 13 lines · Ravi kumar Veeramally
android/hal-hidhost.c +7
-1@@ -87,7 +89,13 @@ static bt_status_t hh_virtual_unplug(bt_bdaddr_t *bd_addr)if (!bd_addr)return BT_STATUS_PARM_INVALID ; -return BT_STATUS_UNSUPPORTED ; +memcpy (cmd.bdaddr, bd_addr,sizeof (cmd.bdaddr)); + +if (hal_ipc_cmd (HAL_SERVICE_ID_HIDHOST ,HAL_MSG_OP_BT_HID_VP , +sizeof (cmd), &cmd,0 ,NULL ,NULL ) <0 ) +return BT_STATUS_FAIL ; + +return BT_STATUS_SUCCESS ; }
It seems you haven't quite paid attention to what happened in the upstream tree today. Take a look at commit 039369d809dedcdfd3c09fb
Basically you should be able to simply do "return hal_ipc_cmd(...);" in most cases now.
Johan