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(-)
--
2.1.0
Hi Ravi,
On Mon, Nov 10, 2014 at 3:42 PM, Ravi kumar Veeramally
<[email protected]> wrote:
> Hi Luiz,
>
>
> On 11/10/2014 03:32 PM, Luiz Augusto von Dentz wrote:
>>
>> Hi Ravi,
>>
>> On Mon, Nov 10, 2014 at 1:37 PM, Ravi kumar Veeramally
>> <[email protected]> wrote:
>>>
>>> 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(-)
>>>
>>> diff --git a/android/hal-ipc-api.txt b/android/hal-ipc-api.txt
>>> index 666e27f..fc78244 100644
>>> --- a/android/hal-ipc-api.txt
>>> +++ b/android/hal-ipc-api.txt
>>> @@ -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)
>>
>> 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.
>>
>> 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
Hi Luiz,
On 11/10/2014 03:32 PM, Luiz Augusto von Dentz wrote:
> Hi Ravi,
>
> On Mon, Nov 10, 2014 at 1:37 PM, Ravi kumar Veeramally
> <[email protected]> wrote:
>> 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(-)
>>
>> diff --git a/android/hal-ipc-api.txt b/android/hal-ipc-api.txt
>> index 666e27f..fc78244 100644
>> --- a/android/hal-ipc-api.txt
>> +++ b/android/hal-ipc-api.txt
>> @@ -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)
> 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.
> 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.
>> -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
>
>
Hi Ravi,
On Mon, Nov 10, 2014 at 1:37 PM, Ravi kumar Veeramally
<[email protected]> wrote:
> 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(-)
>
> diff --git a/android/hal-ipc-api.txt b/android/hal-ipc-api.txt
> index 666e27f..fc78244 100644
> --- a/android/hal-ipc-api.txt
> +++ b/android/hal-ipc-api.txt
> @@ -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)
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.
> -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
Hi Luiz,
On 11/10/2014 03:23 PM, Luiz Augusto von Dentz wrote:
> Hi Ravi,
>
> On Mon, Nov 10, 2014 at 1:37 PM, Ravi kumar Veeramally
> <[email protected]> wrote:
>> 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(-)
>>
>> diff --git a/android/hal-msg.h b/android/hal-msg.h
>> index eef226e..cb6f23b 100644
>> --- a/android/hal-msg.h
>> +++ b/android/hal-msg.h
>> @@ -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.
Ok, I'll add it at the end.
Ravi.
>> #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 0x81
>> struct 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
>
>
Hi Ravi,
On Mon, Nov 10, 2014 at 1:37 PM, Ravi kumar Veeramally
<[email protected]> wrote:
> 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(-)
>
> diff --git a/android/hal-msg.h b/android/hal-msg.h
> index eef226e..cb6f23b 100644
> --- a/android/hal-msg.h
> +++ b/android/hal-msg.h
> @@ -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.
> #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 0x81
> struct 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
--
Luiz Augusto von Dentz
---
android/client/if-bt.c | 2 ++
android/client/if-main.h | 2 ++
android/client/if-rc.c | 88 ++++++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 92 insertions(+)
diff --git a/android/client/if-bt.c b/android/client/if-bt.c
index 48aff1b..50212fc 100644
--- a/android/client/if-bt.c
+++ b/android/client/if-bt.c
@@ -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)
diff --git a/android/client/if-main.h b/android/client/if-main.h
index 93cc98d..96409aa 100644
--- a/android/client/if-main.h
+++ b/android/client/if-main.h
@@ -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
diff --git a/android/client/if-rc.c b/android/client/if-rc.c
index ed65600..b42b8c6 100644
--- a/android/client/if-rc.c
+++ b/android/client/if-rc.c
@@ -28,6 +28,10 @@
const btrc_interface_t *if_rc = NULL;
+#if ANDROID_VERSION >= PLATFORM_VER(5, 0, 0)
+const btrc_ctrl_interface_t *if_rc_ctrl = NULL;
+#endif
+
SINTMAP(btrc_play_status_t, -1, "(unknown)")
DELEMENT(BTRC_PLAYSTATE_STOPPED),
DELEMENT(BTRC_PLAYSTATE_PLAYING),
@@ -398,3 +402,87 @@ const struct interface rc_if = {
.name = "rc",
.methods = methods
};
+
+#if ANDROID_VERSION >= PLATFORM_VER(5, 0, 0)
+static void passthrough_rsp_cb(int id, int key_state)
+{
+ haltest_info("%s: id=%d key_state=%d\n", __func__, id, key_state);
+}
+
+static void connection_state_cb(bool state, bt_bdaddr_t *bd_addr)
+{
+ haltest_info("%s: state=%s bd_addr=%s\n", __func__,
+ state ? "true" : "false",
+ bt_bdaddr_t2str(bd_addr, last_addr));
+}
+
+static btrc_ctrl_callbacks_t rc_ctrl_cbacks = {
+ .size = sizeof(rc_ctrl_cbacks),
+ .passthrough_rsp_cb = passthrough_rsp_cb,
+ .connection_state_cb = connection_state_cb,
+};
+
+/* ctrl_init */
+
+static void ctrl_init_p(int argc, const char **argv)
+{
+ RETURN_IF_NULL(if_rc_ctrl);
+
+ EXEC(if_rc_ctrl->init, &rc_ctrl_cbacks);
+}
+
+/* ctrl_cleanup */
+
+static void ctrl_cleanup_p(int argc, const char **argv)
+{
+ RETURN_IF_NULL(if_rc_ctrl);
+
+ EXECV(if_rc_ctrl->cleanup);
+ if_rc_ctrl = NULL;
+}
+
+/* send_pass_through_cmd */
+
+static void send_pass_through_cmd_c(int argc, const char **argv,
+ enum_func *enum_func, void **user)
+{
+}
+
+static void send_pass_through_cmd_p(int argc, const char **argv)
+{
+ bt_bdaddr_t addr;
+ uint8_t key_code, key_state;
+
+ RETURN_IF_NULL(if_rc);
+ VERIFY_ADDR_ARG(2, &addr);
+
+ if (argc <= 4) {
+ haltest_error("No key code specified");
+ return;
+ }
+
+ key_code = (uint8_t) atoi(argv[3]);
+
+ if (argc <= 5) {
+ haltest_error("No key state specified");
+ return;
+ }
+
+ key_state = (uint8_t) atoi(argv[4]);
+
+ EXEC(if_rc_ctrl->send_pass_through_cmd, &addr, key_code, key_state);
+}
+
+static struct method ctrl_methods[] = {
+ STD_METHOD(ctrl_init),
+ STD_METHODCH(send_pass_through_cmd,
+ "<bd_addr> <key_code> <key_state>"),
+ STD_METHOD(ctrl_cleanup),
+ END_METHOD
+};
+
+const struct interface ctrl_rc_if = {
+ .name = "rc-ctrl",
+ .methods = ctrl_methods
+};
+#endif
--
2.1.0
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(-)
diff --git a/android/hal-msg.h b/android/hal-msg.h
index eef226e..cb6f23b 100644
--- a/android/hal-msg.h
+++ b/android/hal-msg.h
@@ -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 0x81
struct hal_ev_gatt_client_register_client {
int32_t status;
--
2.1.0
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(-)
diff --git a/android/hal-ipc-api.txt b/android/hal-ipc-api.txt
index 666e27f..fc78244 100644
--- a/android/hal-ipc-api.txt
+++ b/android/hal-ipc-api.txt
@@ -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)
--
2.1.0
---
android/hal-avrcp.c | 122 ++++++++++++++++++++++++++++++++++++++++++++++++
android/hal-bluetooth.c | 3 ++
android/hal.h | 1 +
3 files changed, 126 insertions(+)
diff --git a/android/hal-avrcp.c b/android/hal-avrcp.c
index 761ddfb..4202bfa 100644
--- a/android/hal-avrcp.c
+++ b/android/hal-avrcp.c
@@ -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
diff --git a/android/hal-bluetooth.c b/android/hal-bluetooth.c
index 9b5ce16..164e232 100644
--- a/android/hal-bluetooth.c
+++ b/android/hal-bluetooth.c
@@ -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();
diff --git a/android/hal.h b/android/hal.h
index 76555a0..9e29dff 100644
--- a/android/hal.h
+++ b/android/hal.h
@@ -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
--
2.1.0