Add support for new AVRCP ctrl interface
cover Add support for new AVRCP ctrl interface
Android Lollipop has new interface for AVRCP controller. It has one command and two callbacks. Patchset updates support for IPC doc, hal-msg, HAL part and client part.
Ravi kumar Veeramally (4):
android/hal-ipc-txt: Add support for new AVRCP CTRL interface android/hal-msg: Add support for new AVRCP CTRL interface android/hal-avrcp: Add suuport for new AVRCP ctrl interface android/client: Add support for new AVRCP CTRL interface
android/client/if-bt.c | 2 + android/client/if-main.h | 2 + android/client/if-rc.c | 88 ++++++++++++++++++++++++++++++++++ android/hal-avrcp.c | 122 +++++++++++++++++++++++++++++++++++++++++++++++ android/hal-bluetooth.c | 3 ++ android/hal-ipc-api.txt | 49 +++++++++++++++++-- android/hal-msg.h | 30 ++++++++++-- android/hal.h | 1 + 8 files changed, 289 insertions(+), 8 deletions(-)
Signature · 1 line
2.1.0
PATCH 1/4 android/hal-ipc-txt: Add support for new AVRCP CTRL interface
AVRCP controller interface added in Android Lollipop. Update it's commands and notifications.
--- android/hal-ipc-api.txt | 49 +++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 45 insertions(+), 4 deletions(-)
android/hal-ipc-api.txt +45 -4
@@ -1241,7 +1241,7 @@ Notifications: 0x04 = Destroyed -Bluetooth Remote Control HAL (ID 8) +Bluetooth Remote Control Target HAL (ID 8) =================================== Android HAL name: "avrcp" (BT_PROFILE_AV_RC_ID)
@@ -1470,8 +1470,49 @@ Notifications: Notification parameters: ID (1 octet) State (1 octet) +Bluetooth Remote Control Controller HAL (ID 9) +=================================== + +Android HAL name: "avrcp-ctrl" (BT_PROFILE_AV_RC_CTRL_ID) + +Commands and responses: + + Opcode 0x00 - Error response + + Response parameters: Status (1 octet) + + Valid status values: 0x01 = Fail + 0x02 = Not ready + 0x03 = No memory + 0x04 = Busy + 0x05 = Done (already completed) + 0x06 = Unsupported + 0x07 = Parameter invalid + 0x08 = Unhandled + 0x09 = Authentication failure + 0x0a = Remote device down + + Opcode 0x01 - Send Pass Through command/response + + Command parameters: Remote Address (6 octets) + Key Code (1 octet) + Key State (1 octet) + + In case of an error, the error response will be returned. + +Notifications: + + Opcode 0x81 - Passthrough Response Notification + + Notification parameters: ID (1 octet) + Key State (1 octet) + + Opcode 0x82 - Connection State Notification + + Notification parameters: State (1 octet) + Remote Address (6 octets) -Bluetooth GATT HAL (ID 9) +Bluetooth GATT HAL (ID 10) ========================= Android HAL name: "gatt" (BT_PROFILE_GATT_ID)
@@ -2119,7 +2160,7 @@ Notifications: Handle (4 octets) -Bluetooth Handsfree Client HAL (ID 10) +Bluetooth Handsfree Client HAL (ID 11) ====================================== Android HAL name: "hf_client" (BT_PROFILE_HANDSFREE_CLIENT_ID)
@@ -2465,7 +2506,7 @@ Notifications: Notification parameters: <none> -Bluetooth Map Client HAL (ID 11) +Bluetooth Map Client HAL (ID 12) ========================= Android HAL name: "map_client" (BT_PROFILE_MAP_CLIENT_ID)
Signature · 1 line
2.1.0
Luiz Augusto von Dentz
maintainerRe: [PATCH 1/4] android/hal-ipc-txt: Add support for new AVRCP CTRL interface
Hi Ravi,
Quoted 54 lines · Ravi kumar Veeramally
AVRCP controller interface added in Android Lollipop. Update it's commands and notifications.
--- android/hal-ipc-api.txt | 49 +++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 45 insertions(+), 4 deletions(-)android/hal-ipc-api.txt +32
-1@@ -1241,7 +1241,7 @@ Notifications: 0x04 = Destroyed -Bluetooth Remote Control HAL (ID 8) +Bluetooth Remote Control Target HAL (ID 8) =================================== Android HAL name: "avrcp" (BT_PROFILE_AV_RC_ID)@@ -1470,8 +1470,49 @@ Notifications: Notification parameters: ID (1 octet) State (1 octet) +Bluetooth Remote Control Controller HAL (ID 9) +=================================== + +Android HAL name: "avrcp-ctrl" (BT_PROFILE_AV_RC_CTRL_ID) + +Commands and responses: + + Opcode 0x00 - Error response + + Response parameters: Status (1 octet) + + Valid status values: 0x01 = Fail + 0x02 = Not ready + 0x03 = No memory + 0x04 = Busy + 0x05 = Done (already completed) + 0x06 = Unsupported + 0x07 = Parameter invalid + 0x08 = Unhandled + 0x09 = Authentication failure + 0x0a = Remote device down + + Opcode 0x01 - Send Pass Through command/response + + Command parameters: Remote Address (6 octets) + Key Code (1 octet) + Key State (1 octet) + + In case of an error, the error response will be returned. + +Notifications:
android/hal-ipc-api.txt Notifications: · line 1513
Quoted 10 lines
android/hal-ipc-api.txt +10
-0+ + Opcode 0x81 - Passthrough Response Notification + + Notification parameters: ID (1 octet) + Key State (1 octet) + + Opcode 0x82 - Connection State Notification + + Notification parameters: State (1 octet) + Remote Address (6 octets)
This should probably be added to the bottom as we did with other new HAL. Btw, perhaps we should keep a history of API changes e.g. since:
5.0 per opcode so it become easier to identify changes in the future.
Quoted 30 lines
android/hal-ipc-api.txt +3
-4-Bluetooth GATT HAL (ID 9) +Bluetooth GATT HAL (ID 10) ========================= Android HAL name: "gatt" (BT_PROFILE_GATT_ID)@@ -2119,7 +2160,7 @@ Notifications: Handle (4 octets) -Bluetooth Handsfree Client HAL (ID 10) +Bluetooth Handsfree Client HAL (ID 11) ====================================== Android HAL name: "hf_client" (BT_PROFILE_HANDSFREE_CLIENT_ID)@@ -2465,7 +2506,7 @@ Notifications: Notification parameters: <none> -Bluetooth Map Client HAL (ID 11) +Bluetooth Map Client HAL (ID 12) ========================= Android HAL name: "map_client" (BT_PROFILE_MAP_CLIENT_ID) --2.1.0
--
To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Signature · 1 line
Luiz Augusto von Dentz
Re: [PATCH 1/4] android/hal-ipc-txt: Add support for new AVRCP CTRL interface
Hi Luiz,
Quoted 62 lines · Luiz Augusto von Dentz
Hi Ravi,
Quoted 58 lines · Ravi kumar Veeramally
AVRCP controller interface added in Android Lollipop. Update it's commands and notifications.
--- android/hal-ipc-api.txt | 49 +++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 45 insertions(+), 4 deletions(-)android/hal-ipc-api.txt +36
-1@@ -1241,7 +1241,7 @@ Notifications: 0x04 = Destroyed -Bluetooth Remote Control HAL (ID 8) +Bluetooth Remote Control Target HAL (ID 8) =================================== Android HAL name: "avrcp" (BT_PROFILE_AV_RC_ID)@@ -1470,8 +1470,49 @@ Notifications: Notification parameters: ID (1 octet) State (1 octet) +Bluetooth Remote Control Controller HAL (ID 9) +=================================== + +Android HAL name: "avrcp-ctrl" (BT_PROFILE_AV_RC_CTRL_ID) + +Commands and responses: + + Opcode 0x00 - Error response + + Response parameters: Status (1 octet) + + Valid status values: 0x01 = Fail + 0x02 = Not ready + 0x03 = No memory + 0x04 = Busy + 0x05 = Done (already completed) + 0x06 = Unsupported + 0x07 = Parameter invalid + 0x08 = Unhandled + 0x09 = Authentication failure + 0x0a = Remote device down + + Opcode 0x01 - Send Pass Through command/response + + Command parameters: Remote Address (6 octets) + Key Code (1 octet) + Key State (1 octet) + + In case of an error, the error response will be returned. + +Notifications: + + Opcode 0x81 - Passthrough Response Notification + + Notification parameters: ID (1 octet)
Quoted 8 lines
android/hal-ipc-api.txt Notifications: · line 1513
Quoted 6 lines
android/hal-ipc-api.txt +6
-0+ Key State (1 octet) + + Opcode 0x82 - Connection State Notification + + Notification parameters: State (1 octet) + Remote Address (6 octets)This should probably be added to the bottom as we did with other new HAL.
Sure, I will add at bottom in both hal-ipc-txt and hal-msg.h.
Quoted 2 lines
Btw, perhaps we should keep a history of API changes e.g. since:
5.0 per opcode so it become easier to identify changes in the future.
So where should we keep changes related 5.0?
Thanks,
Ravi.
Quoted 32 lines
Quoted 30 lines
android/hal-ipc-api.txt +3
-4-Bluetooth GATT HAL (ID 9) +Bluetooth GATT HAL (ID 10) ========================= Android HAL name: "gatt" (BT_PROFILE_GATT_ID)@@ -2119,7 +2160,7 @@ Notifications: Handle (4 octets) -Bluetooth Handsfree Client HAL (ID 10) +Bluetooth Handsfree Client HAL (ID 11) ====================================== Android HAL name: "hf_client" (BT_PROFILE_HANDSFREE_CLIENT_ID)@@ -2465,7 +2506,7 @@ Notifications: Notification parameters: <none> -Bluetooth Map Client HAL (ID 11) +Bluetooth Map Client HAL (ID 12) ========================= Android HAL name: "map_client" (BT_PROFILE_MAP_CLIENT_ID) --2.1.0
--
To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Luiz Augusto von Dentz
maintainerRe: [PATCH 1/4] android/hal-ipc-txt: Add support for new AVRCP CTRL interface
Hi Ravi,
Quoted 79 lines · Ravi kumar Veeramally
Hi Luiz,
Quoted 66 lines · Luiz Augusto von Dentz
Hi Ravi,
Quoted 61 lines · Ravi kumar Veeramally
AVRCP controller interface added in Android Lollipop. Update it's commands and notifications.
--- android/hal-ipc-api.txt | 49 +++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 45 insertions(+), 4 deletions(-)android/hal-ipc-api.txt +37
-1@@ -1241,7 +1241,7 @@ Notifications: 0x04 = Destroyed -Bluetooth Remote Control HAL (ID 8) +Bluetooth Remote Control Target HAL (ID 8) =================================== Android HAL name: "avrcp" (BT_PROFILE_AV_RC_ID)@@ -1470,8 +1470,49 @@ Notifications: Notification parameters: ID (1 octet) State (1 octet) +Bluetooth Remote Control Controller HAL (ID 9) +=================================== + +Android HAL name: "avrcp-ctrl" (BT_PROFILE_AV_RC_CTRL_ID) + +Commands and responses: + + Opcode 0x00 - Error response + + Response parameters: Status (1 octet) + + Valid status values: 0x01 = Fail + 0x02 = Not ready + 0x03 = No memory + 0x04 = Busy + 0x05 = Done (already completed) + 0x06 = Unsupported + 0x07 = Parameter invalid + 0x08 = Unhandled + 0x09 = Authentication failure + 0x0a = Remote device down + + Opcode 0x01 - Send Pass Through command/response + + Command parameters: Remote Address (6 octets) + Key Code (1 octet) + Key State (1 octet) + + In case of an error, the error response will be returned. + +Notifications: + + Opcode 0x81 - Passthrough Response Notification + + Notification parameters: ID (1 octet) + Key State (1 octet)Quoted 8 lines
android/hal-ipc-api.txt Notifications: · line 1513
Quoted 5 lines
android/hal-ipc-api.txt +5
-0+ + Opcode 0x82 - Connection State Notification + + Notification parameters: State (1 octet) + Remote Address (6 octets)This should probably be added to the bottom as we did with other new HAL.
Quoted 6 lines
Sure, I will add at bottom in both hal-ipc-txt and
hal-msg.h.Quoted 3 lines
Btw, perhaps we should keep a history of API changes e.g. since:
5.0 per opcode so it become easier to identify changes in the future.So where should we keep changes related 5.0?
I was thinking in something like this:
Opcode 0x82 - Connection State Notification
Notification parameters: State (1 octet)
Remote Address (6 octets)
since: 5.0
PATCH 2/4 android/hal-msg: Add support for new AVRCP CTRL interface
In reply to Ravi kumar VeeramallyAVRCP controller interface added in Android Lollipop. Update it's commands and notifications. Update service ids also.
--- android/hal-msg.h | 30 ++++++++++++++++++++++++++---- 1 file changed, 26 insertions(+), 4 deletions(-)
android/hal-msg.h +26 -4
@@ -34,9 +34,10 @@ static const char BLUEZ_HAL_SK_PATH[] = "\0bluez_hal_socket";#define HAL_SERVICE_ID_A2DP 6#define HAL_SERVICE_ID_HEALTH 7#define HAL_SERVICE_ID_AVRCP 8 -#define HAL_SERVICE_ID_GATT 9 -#define HAL_SERVICE_ID_HANDSFREE_CLIENT 10 -#define HAL_SERVICE_ID_MAP_CLIENT 11 +#define HAL_SERVICE_ID_AVRCP_CTRL 9 +#define HAL_SERVICE_ID_GATT 10 +#define HAL_SERVICE_ID_HANDSFREE_CLIENT 11 +#define HAL_SERVICE_ID_MAP_CLIENT 12#define HAL_SERVICE_ID_MAX HAL_SERVICE_ID_MAP_CLIENT
@@ -607,7 +608,7 @@ struct hal_cmd_handsfree_phone_state_change {uint8_t number[0 ]; } __attribute__((packed)); -/* AVRCP HAL API */ +/* AVRCP TARGET HAL API */ #define HAL_AVRCP_PLAY_STATUS_STOPPED 0x00#define HAL_AVRCP_PLAY_STATUS_PLAYING 0x01
@@ -711,6 +712,15 @@ struct hal_cmd_avrcp_set_volume {uint8_t value; } __attribute__((packed)); +/* AVRCP CTRL HAL API */ + +#define HAL_OP_AVRCP_CTRL_SEND_PASSTHROUGH 0x01 +struct hal_cmd_avrcp_ctrl_send_passthrough { +uint8_t bdaddr[6 ]; +uint8_t key_code; +uint8_t key_state; +} __attribute__((packed)); +/* GATT HAL API */ #define HAL_OP_GATT_CLIENT_REGISTER 0x01
@@ -1499,6 +1509,18 @@ struct hal_ev_avrcp_passthrough_cmd {uint8_t state; } __attribute__((packed)); +#define HAL_EV_AVRCP_CTRL_CONN_STATE 0x80 +struct hal_ev_avrcp_ctrl_conn_state { +uint8_t state; +uint8_t bdaddr[6 ]; +} __attribute__((packed)); + +#define HAL_EV_AVRCP_CTRL_PASSTHROUGH_RSP 0x81 +struct hal_ev_avrcp_ctrl_passthrough_rsp { +uint8_t id; +uint8_t key_state; +} __attribute__((packed)); +#define HAL_EV_GATT_CLIENT_REGISTER_CLIENT 0x81struct hal_ev_gatt_client_register_client {int32_t status;
Signature · 1 line
2.1.0
Luiz Augusto von Dentz
maintainerRe: [PATCH 2/4] android/hal-msg: Add support for new AVRCP CTRL interface
Hi Ravi,
Quoted 11 lines · Ravi kumar Veeramally
AVRCP controller interface added in Android Lollipop. Update it's commands and notifications. Update service ids also.
--- android/hal-msg.h | 30 ++++++++++++++++++++++++++---- 1 file changed, 26 insertions(+), 4 deletions(-)android/hal-msg.h +0
-0
android/hal-msg.h static const char BLUEZ_HAL_SK_PATH[] = "\0bluez_hal_socket"; · line 40
Quoted 10 lines
android/hal-msg.h +4
-3@@ -34,9 +34,10 @@ static const char BLUEZ_HAL_SK_PATH[] = "\0bluez_hal_socket";#define HAL_SERVICE_ID_A2DP 6#define HAL_SERVICE_ID_HEALTH 7#define HAL_SERVICE_ID_AVRCP 8 -#define HAL_SERVICE_ID_GATT 9 -#define HAL_SERVICE_ID_HANDSFREE_CLIENT 10 -#define HAL_SERVICE_ID_MAP_CLIENT 11 +#define HAL_SERVICE_ID_AVRCP_CTRL 9 +#define HAL_SERVICE_ID_GATT 10 +#define HAL_SERVICE_ID_HANDSFREE_CLIENT 11 +#define HAL_SERVICE_ID_MAP_CLIENT 12
Since for the others interface added in 5.0 we did append to the end this one should also go there, otherwise we will have to reorganize all the ids.
Quoted 53 lines
android/hal-msg.h +22
-2#define HAL_SERVICE_ID_MAX HAL_SERVICE_ID_MAP_CLIENT@@ -607,7 +608,7 @@ struct hal_cmd_handsfree_phone_state_change {uint8_t number[0 ]; } __attribute__((packed)); -/* AVRCP HAL API */ +/* AVRCP TARGET HAL API */ #define HAL_AVRCP_PLAY_STATUS_STOPPED 0x00#define HAL_AVRCP_PLAY_STATUS_PLAYING 0x01@@ -711,6 +712,15 @@ struct hal_cmd_avrcp_set_volume {uint8_t value; } __attribute__((packed)); +/* AVRCP CTRL HAL API */ + +#define HAL_OP_AVRCP_CTRL_SEND_PASSTHROUGH 0x01 +struct hal_cmd_avrcp_ctrl_send_passthrough { +uint8_t bdaddr[6 ]; +uint8_t key_code; +uint8_t key_state; +} __attribute__((packed)); +/* GATT HAL API */ #define HAL_OP_GATT_CLIENT_REGISTER 0x01@@ -1499,6 +1509,18 @@ struct hal_ev_avrcp_passthrough_cmd {uint8_t state; } __attribute__((packed)); +#define HAL_EV_AVRCP_CTRL_CONN_STATE 0x80 +struct hal_ev_avrcp_ctrl_conn_state { +uint8_t state; +uint8_t bdaddr[6 ]; +} __attribute__((packed)); + +#define HAL_EV_AVRCP_CTRL_PASSTHROUGH_RSP 0x81 +struct hal_ev_avrcp_ctrl_passthrough_rsp { +uint8_t id; +uint8_t key_state; +} __attribute__((packed)); +#define HAL_EV_GATT_CLIENT_REGISTER_CLIENT 0x81struct hal_ev_gatt_client_register_client {int32_t status; --2.1.0
--
To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Signature · 1 line
Luiz Augusto von Dentz
Re: [PATCH 2/4] android/hal-msg: Add support for new AVRCP CTRL interface
Hi Luiz,
Quoted 20 lines · Luiz Augusto von Dentz
Hi Ravi,
Quoted 16 lines · Ravi kumar Veeramally
AVRCP controller interface added in Android Lollipop. Update it's commands and notifications. Update service ids also.
--- android/hal-msg.h | 30 ++++++++++++++++++++++++++---- 1 file changed, 26 insertions(+), 4 deletions(-)android/hal-msg.h +0
-2@@ -34,9 +34,10 @@ static const char BLUEZ_HAL_SK_PATH[] = "\0bluez_hal_socket";#define HAL_SERVICE_ID_A2DP 6#define HAL_SERVICE_ID_HEALTH 7#define HAL_SERVICE_ID_AVRCP 8 -#define HAL_SERVICE_ID_GATT 9 -#define HAL_SERVICE_ID_HANDSFREE_CLIENT 10
Quoted 8 lines
android/hal-msg.h static const char BLUEZ_HAL_SK_PATH[] = "\0bluez_hal_socket"; · line 40
Quoted 5 lines
android/hal-msg.h +4
-1-#define HAL_SERVICE_ID_MAP_CLIENT 11 +#define HAL_SERVICE_ID_AVRCP_CTRL 9 +#define HAL_SERVICE_ID_GATT 10 +#define HAL_SERVICE_ID_HANDSFREE_CLIENT 11 +#define HAL_SERVICE_ID_MAP_CLIENT 12Since for the others interface added in 5.0 we did append to the end this one should also go there, otherwise we will have to reorganize all the ids.
Ok, I'll add it at the end.
Ravi.
Quoted 55 lines
Quoted 53 lines
android/hal-msg.h +22
-2#define HAL_SERVICE_ID_MAX HAL_SERVICE_ID_MAP_CLIENT@@ -607,7 +608,7 @@ struct hal_cmd_handsfree_phone_state_change {uint8_t number[0 ]; } __attribute__((packed)); -/* AVRCP HAL API */ +/* AVRCP TARGET HAL API */ #define HAL_AVRCP_PLAY_STATUS_STOPPED 0x00#define HAL_AVRCP_PLAY_STATUS_PLAYING 0x01@@ -711,6 +712,15 @@ struct hal_cmd_avrcp_set_volume {uint8_t value; } __attribute__((packed)); +/* AVRCP CTRL HAL API */ + +#define HAL_OP_AVRCP_CTRL_SEND_PASSTHROUGH 0x01 +struct hal_cmd_avrcp_ctrl_send_passthrough { +uint8_t bdaddr[6 ]; +uint8_t key_code; +uint8_t key_state; +} __attribute__((packed)); +/* GATT HAL API */ #define HAL_OP_GATT_CLIENT_REGISTER 0x01@@ -1499,6 +1509,18 @@ struct hal_ev_avrcp_passthrough_cmd {uint8_t state; } __attribute__((packed)); +#define HAL_EV_AVRCP_CTRL_CONN_STATE 0x80 +struct hal_ev_avrcp_ctrl_conn_state { +uint8_t state; +uint8_t bdaddr[6 ]; +} __attribute__((packed)); + +#define HAL_EV_AVRCP_CTRL_PASSTHROUGH_RSP 0x81 +struct hal_ev_avrcp_ctrl_passthrough_rsp { +uint8_t id; +uint8_t key_state; +} __attribute__((packed)); +#define HAL_EV_GATT_CLIENT_REGISTER_CLIENT 0x81struct hal_ev_gatt_client_register_client {int32_t status; --2.1.0
--
To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH 3/4 android/hal-avrcp: Add suuport for new AVRCP ctrl interface
In reply to Ravi kumar Veeramally--- android/hal-avrcp.c | 122 ++++++++++++++++++++++++++++++++++++++++++++++++ android/hal-bluetooth.c | 3 ++ android/hal.h | 1 + 3 files changed, 126 insertions(+)
android/hal-avrcp.c +122 -0
@@ -20,6 +20,7 @@#include <string.h> #include <stdlib.h> +#include "hal-utils.h" #include "hal-log.h" #include "hal.h" #include "hal-msg.h"
@@ -28,6 +29,10 @@static const btrc_callbacks_t *cbs =NULL ; +#if ANDROID_VERSION >=PLATFORM_VER (5 ,0 ,0 ) +static const btrc_ctrl_callbacks_t *ctrl_cbs =NULL ; +#endif +static bool interface_ready (void ) {return cbs !=NULL ;
@@ -684,3 +689,120 @@ btrc_interface_t *bt_get_avrcp_interface(void) {return &iface; } + +#if ANDROID_VERSION >=PLATFORM_VER (5 ,0 ,0 ) + +static bool ctrl_interface_ready (void ) +{ +return ctrl_cbs !=NULL ; +} + +static void handle_connection_state (void *buf,uint16_t len,int fd) +{ +struct hal_ev_avrcp_ctrl_conn_state *ev = buf; + +if (ctrl_cbs->connection_state_cb) + ctrl_cbs->connection_state_cb (ev->state, + (bt_bdaddr_t *) (ev->bdaddr)); +} + +static void handle_passthrough_rsp (void *buf,uint16_t len,int fd) +{ +struct hal_ev_avrcp_ctrl_passthrough_rsp *ev = buf; + +if (ctrl_cbs->passthrough_rsp_cb) + ctrl_cbs->passthrough_rsp_cb (ev->id, ev->key_state); +} + +/* +* handlers will be called from notification thread context, +* index in table equals to 'opcode - HAL_MINIMUM_EVENT' +*/ +static const struct hal_ipc_handler ctrl_ev_handlers[] = { +/* HAL_EV_AVRCP_CTRL_CONN_STATE */ + { handle_connection_state, false, +sizeof (struct hal_ev_avrcp_ctrl_conn_state ) }, +/* HAL_EV_AVRCP_CTRL_PASSTHROUGH_RSP */ + { handle_passthrough_rsp, false, +sizeof (struct hal_ev_avrcp_ctrl_passthrough_rsp ) }, +}; + +static bt_status_t ctrl_init (btrc_ctrl_callbacks_t *callbacks) +{ +struct hal_cmd_register_module cmd; +int ret; + +DBG ("" ); + +if (ctrl_interface_ready ()) +return BT_STATUS_DONE ; + + ctrl_cbs = callbacks; + +hal_ipc_register (HAL_SERVICE_ID_AVRCP_CTRL , ctrl_ev_handlers, +sizeof (ctrl_ev_handlers) /sizeof (ctrl_ev_handlers[0 ])); + + cmd.service_id =HAL_SERVICE_ID_AVRCP_CTRL ; + cmd.mode =HAL_MODE_DEFAULT ; + + ret =hal_ipc_cmd (HAL_SERVICE_ID_CORE ,HAL_OP_REGISTER_MODULE , +sizeof (cmd), &cmd,NULL ,NULL ,NULL ); + +if (ret !=BT_STATUS_SUCCESS ) { + cbs =NULL ; +hal_ipc_unregister (HAL_SERVICE_ID_AVRCP_CTRL ); + } + +return ret; +} + +static bt_status_t send_pass_through_cmd (bt_bdaddr_t *bd_addr,uint8_t key_code, +uint8_t key_state) +{ +struct hal_cmd_avrcp_ctrl_send_passthrough cmd; + +DBG ("" ); + +if (!ctrl_interface_ready ()) +return BT_STATUS_NOT_READY ; + +memcpy (cmd.bdaddr, bd_addr,sizeof (cmd.bdaddr)); + cmd.key_code = key_code; + cmd.key_state = key_state; + +return hal_ipc_cmd (HAL_SERVICE_ID_AVRCP_CTRL , +HAL_OP_AVRCP_CTRL_SEND_PASSTHROUGH , +sizeof (cmd), &cmd,NULL ,NULL ,NULL ); +} + +static void ctrl_cleanup (void ) +{ +struct hal_cmd_unregister_module cmd; + +DBG ("" ); + +if (!ctrl_interface_ready ()) +return ; + + ctrl_cbs =NULL ; + + cmd.service_id =HAL_SERVICE_ID_AVRCP_CTRL ; + +hal_ipc_cmd (HAL_SERVICE_ID_CORE ,HAL_OP_UNREGISTER_MODULE , +sizeof (cmd), &cmd,NULL ,NULL ,NULL ); + +hal_ipc_unregister (HAL_SERVICE_ID_AVRCP_CTRL ); +} + +static btrc_ctrl_interface_t ctrl_iface = { + .size =sizeof (ctrl_iface), + .init = ctrl_init, + .send_pass_through_cmd = send_pass_through_cmd, + .cleanup = ctrl_cleanup +}; + +btrc_ctrl_interface_t *bt_get_avrcp_ctrl_interface (void ) +{ +return &ctrl_iface; +} +#endif
android/hal-bluetooth.c +3 -0
@@ -866,6 +866,9 @@ static const void *get_profile_interface(const char *profile_id)return bt_get_health_interface ();#if ANDROID_VERSION >=PLATFORM_VER (5 ,0 ,0 ) +if (!strcmp (profile_id,BT_PROFILE_AV_RC_CTRL_ID )) +return bt_get_avrcp_ctrl_interface (); +if (!strcmp (profile_id,BT_PROFILE_HANDSFREE_CLIENT_ID ))return bt_get_hf_client_interface ();
android/hal.h +1 -0
@@ -44,6 +44,7 @@ btgatt_interface_t *bt_get_gatt_interface(void);bthl_interface_t *bt_get_health_interface (void );#if ANDROID_VERSION >=PLATFORM_VER (5 ,0 ,0 ) +btrc_ctrl_interface_t *bt_get_avrcp_ctrl_interface (void );bthf_client_interface_t *bt_get_hf_client_interface (void );btmce_interface_t *bt_get_map_client_interface (void );#endif
Signature · 1 line
2.1.0
PATCH 4/4 android/client: Add support for new AVRCP CTRL interface
In reply to Ravi kumar Veeramally--- android/client/if-bt.c | 2 ++ android/client/if-main.h | 2 ++ android/client/if-rc.c | 88 ++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 92 insertions(+)
android/client/if-bt.c +2 -0
@@ -800,6 +800,8 @@ static void get_profile_interface_p(int argc, const char **argv)else if (strcmp (BT_PROFILE_GATT_ID , id) ==0 ) pif = (const void **) &if_gatt;#if ANDROID_VERSION >=PLATFORM_VER (5 ,0 ,0 ) + else if (strcmp(BT_PROFILE_AV_RC_CTRL_ID, id) == 0) + pif = (const void **) &if_rc_ctrl; else if (strcmp(BT_PROFILE_HANDSFREE_CLIENT_ID, id) == 0) pif = (const void **) &if_hf_client; else if (strcmp(BT_PROFILE_MAP_CLIENT_ID, id) == 0)
android/client/if-main.h +2 -0
@@ -65,6 +65,7 @@ extern const btgatt_interface_t *if_gatt;extern const btgatt_server_interface_t *if_gatt_server;extern const btgatt_client_interface_t *if_gatt_client;#if ANDROID_VERSION >=PLATFORM_VER (5 ,0 ,0 ) +extern const btrc_ctrl_interface_t *if_rc_ctrl;extern const bthf_client_interface_t *if_hf_client;extern const btmce_interface_t *if_mce;#endif
@@ -92,6 +93,7 @@ extern const struct interface hf_if;extern const struct interface hh_if;extern const struct interface hl_if;#if ANDROID_VERSION >=PLATFORM_VER (5 ,0 ,0 ) +extern const struct interface ctrl_rc_if;extern const struct interface hf_client_if;extern const struct interface mce_if;#endif
android/client/if-rc.c +88 -0
97 lines not on this page · raw message
Signature · 1 line
2.1.0