* [PATCH 1/3] android/handsfree: Add initial support for configure WBS commmand
@ 2014-12-17 14:53 Szymon Janc
2014-12-17 14:53 ` [PATCH 2/3] android/handsfree: Add support for configure WBS command Szymon Janc
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Szymon Janc @ 2014-12-17 14:53 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Szymon Janc
This adds required IPC message and handler for configure WBS command.
---
android/hal-handsfree.c | 17 ++++++++++++++---
android/hal-ipc-api.txt | 12 ++++++++++++
android/hal-msg.h | 10 ++++++++++
android/handsfree.c | 21 +++++++++++++++++++++
4 files changed, 57 insertions(+), 3 deletions(-)
diff --git a/android/hal-handsfree.c b/android/hal-handsfree.c
index 2c638e6..279b26a 100644
--- a/android/hal-handsfree.c
+++ b/android/hal-handsfree.c
@@ -832,11 +832,22 @@ static void cleanup(void)
#if ANDROID_VERSION >= PLATFORM_VER(5, 0, 0)
static bt_status_t configure_wbs(bt_bdaddr_t *bd_addr, bthf_wbs_config_t config)
{
- /* TODO: implement */
+ struct hal_cmd_handsfree_configure_wbs cmd;
- DBG("");
+ DBG("%u", config);
+
+ if (!interface_ready())
+ return BT_STATUS_NOT_READY;
- return BT_STATUS_UNSUPPORTED;
+ if (!bd_addr)
+ return BT_STATUS_PARM_INVALID;
+
+ memcpy(cmd.bdaddr, bd_addr, sizeof(cmd.bdaddr));
+ cmd.config = config;
+
+ return hal_ipc_cmd(HAL_SERVICE_ID_HANDSFREE,
+ HAL_OP_HANDSFREE_CONFIGURE_WBS,
+ sizeof(cmd), &cmd, NULL, NULL, NULL);
}
#endif
diff --git a/android/hal-ipc-api.txt b/android/hal-ipc-api.txt
index 01490fa..f15c12e 100644
--- a/android/hal-ipc-api.txt
+++ b/android/hal-ipc-api.txt
@@ -955,6 +955,18 @@ Commands and responses:
In case of an error, the error response will be returned.
+ Opcode 0x0f - Configure WBS command/response
+
+ Command parameters: Remote address (6 octets)
+ Config (1 octet)
+ Response parameters: <none>
+
+ Valid config values: 0x00 = None
+ 0x01 = No
+ 0x02 = Yes
+
+ In case of an error, the error response will be returned.
+
Notifications:
Opcode 0x81 - Connection State notification
diff --git a/android/hal-msg.h b/android/hal-msg.h
index 88b0c52..ecc1150 100644
--- a/android/hal-msg.h
+++ b/android/hal-msg.h
@@ -624,6 +624,16 @@ struct hal_cmd_handsfree_phone_state_change {
uint8_t number[0];
} __attribute__((packed));
+#define HAL_HANDSFREE_WBS_NONE 0x00
+#define HAL_HANDSFREE_WBS_NO 0x01
+#define HAL_HANDSFREE_WBS_YES 0x02
+
+#define HAL_OP_HANDSFREE_CONFIGURE_WBS 0x0F
+struct hal_cmd_handsfree_configure_wbs {
+ uint8_t bdaddr[6];
+ uint8_t config;
+} __attribute__((packed));
+
/* AVRCP TARGET HAL API */
#define HAL_AVRCP_PLAY_STATUS_STOPPED 0x00
diff --git a/android/handsfree.c b/android/handsfree.c
index 7fbe64b..da89623 100644
--- a/android/handsfree.c
+++ b/android/handsfree.c
@@ -2496,6 +2496,24 @@ failed:
HAL_OP_HANDSFREE_PHONE_STATE_CHANGE, status);
}
+static void handle_configure_wbs(const void *buf, uint16_t len)
+{
+ const struct hal_cmd_handsfree_configure_wbs *cmd = buf;
+ uint8_t status;
+
+ switch (cmd->config) {
+ case HAL_HANDSFREE_WBS_NONE:
+ case HAL_HANDSFREE_WBS_NO:
+ case HAL_HANDSFREE_WBS_YES:
+ default:
+ status = HAL_STATUS_FAILED;
+ break;
+ }
+
+ ipc_send_rsp(hal_ipc, HAL_SERVICE_ID_HANDSFREE,
+ HAL_OP_HANDSFREE_CONFIGURE_WBS, status);
+}
+
static const struct ipc_handler cmd_handlers[] = {
/* HAL_OP_HANDSFREE_CONNECT */
{ handle_connect, false,
@@ -2537,6 +2555,9 @@ static const struct ipc_handler cmd_handlers[] = {
/* HAL_OP_HANDSFREE_PHONE_STATE_CHANGE */
{ handle_phone_state_change, true,
sizeof(struct hal_cmd_handsfree_phone_state_change) },
+ /* HAL_OP_HANDSFREE_CONFIGURE_WBS */
+ { handle_configure_wbs, false,
+ sizeof(struct hal_cmd_handsfree_configure_wbs) },
};
static sdp_record_t *headset_ag_record(void)
--
1.9.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 2/3] android/handsfree: Add support for configure WBS command
2014-12-17 14:53 [PATCH 1/3] android/handsfree: Add initial support for configure WBS commmand Szymon Janc
@ 2014-12-17 14:53 ` Szymon Janc
2014-12-17 14:53 ` [PATCH 3/3] android/README: Update implementation status for handsfree Szymon Janc
2014-12-19 13:31 ` [PATCH 1/3] android/handsfree: Add initial support for configure WBS commmand Szymon Janc
2 siblings, 0 replies; 4+ messages in thread
From: Szymon Janc @ 2014-12-17 14:53 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Szymon Janc
This allows to disable/enable WBS on specific headset.
---
android/handsfree.c | 36 +++++++++++++++++++++++++++++++++++-
1 file changed, 35 insertions(+), 1 deletion(-)
diff --git a/android/handsfree.c b/android/handsfree.c
index da89623..f3ea770 100644
--- a/android/handsfree.c
+++ b/android/handsfree.c
@@ -2499,17 +2499,51 @@ failed:
static void handle_configure_wbs(const void *buf, uint16_t len)
{
const struct hal_cmd_handsfree_configure_wbs *cmd = buf;
+ struct hf_device *dev;
+ bdaddr_t bdaddr;
uint8_t status;
+ if (!(hfp_ag_features & HFP_AG_FEAT_CODEC)) {
+ status = HAL_STATUS_FAILED;
+ goto done;
+ }
+
+ android2bdaddr(cmd->bdaddr, &bdaddr);
+
+ dev = find_device(&bdaddr);
+ if (!dev) {
+ status = HAL_STATUS_FAILED;
+ goto done;
+ }
+
+ if (dev->audio_state != HAL_EV_HANDSFREE_AUDIO_STATE_DISCONNECTED){
+ status = HAL_STATUS_FAILED;
+ goto done;
+ }
+
switch (cmd->config) {
- case HAL_HANDSFREE_WBS_NONE:
case HAL_HANDSFREE_WBS_NO:
+ dev->codecs[MSBC_OFFSET].local_supported = false;
+ break;
case HAL_HANDSFREE_WBS_YES:
+ dev->codecs[MSBC_OFFSET].local_supported = true;
+ break;
+ case HAL_HANDSFREE_WBS_NONE:
+ /* TODO */
default:
status = HAL_STATUS_FAILED;
break;
}
+ /*
+ * cleanup negotiated codec if WBS support was changed, it will be
+ * renegotiated on next audio connection based on currently supported
+ * codecs
+ */
+ dev->negotiated_codec = 0;
+ status = HAL_STATUS_SUCCESS;
+
+done:
ipc_send_rsp(hal_ipc, HAL_SERVICE_ID_HANDSFREE,
HAL_OP_HANDSFREE_CONFIGURE_WBS, status);
}
--
1.9.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 3/3] android/README: Update implementation status for handsfree
2014-12-17 14:53 [PATCH 1/3] android/handsfree: Add initial support for configure WBS commmand Szymon Janc
2014-12-17 14:53 ` [PATCH 2/3] android/handsfree: Add support for configure WBS command Szymon Janc
@ 2014-12-17 14:53 ` Szymon Janc
2014-12-19 13:31 ` [PATCH 1/3] android/handsfree: Add initial support for configure WBS commmand Szymon Janc
2 siblings, 0 replies; 4+ messages in thread
From: Szymon Janc @ 2014-12-17 14:53 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Szymon Janc
---
android/README | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/android/README b/android/README
index 6e5c95a..b2864de 100644
--- a/android/README
+++ b/android/README
@@ -283,7 +283,7 @@ a2dp bt_av.h complete complete
gatt bt_gatt.h complete partial
bt_gatt_client.h complete partial
bt_gatt_server.h complete partial
-handsfree bt_hf.h complete partial
+handsfree bt_hf.h complete complete
hidhost bt_hh.h complete complete
health bt_hl.h complete complete
pan bt_pan.h complete complete
--
1.9.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH 1/3] android/handsfree: Add initial support for configure WBS commmand
2014-12-17 14:53 [PATCH 1/3] android/handsfree: Add initial support for configure WBS commmand Szymon Janc
2014-12-17 14:53 ` [PATCH 2/3] android/handsfree: Add support for configure WBS command Szymon Janc
2014-12-17 14:53 ` [PATCH 3/3] android/README: Update implementation status for handsfree Szymon Janc
@ 2014-12-19 13:31 ` Szymon Janc
2 siblings, 0 replies; 4+ messages in thread
From: Szymon Janc @ 2014-12-19 13:31 UTC (permalink / raw)
To: linux-bluetooth
On Wednesday 17 of December 2014 15:53:31 Szymon Janc wrote:
> This adds required IPC message and handler for configure WBS command.
> ---
> android/hal-handsfree.c | 17 ++++++++++++++---
> android/hal-ipc-api.txt | 12 ++++++++++++
> android/hal-msg.h | 10 ++++++++++
> android/handsfree.c | 21 +++++++++++++++++++++
> 4 files changed, 57 insertions(+), 3 deletions(-)
>
> diff --git a/android/hal-handsfree.c b/android/hal-handsfree.c
> index 2c638e6..279b26a 100644
> --- a/android/hal-handsfree.c
> +++ b/android/hal-handsfree.c
> @@ -832,11 +832,22 @@ static void cleanup(void)
> #if ANDROID_VERSION >= PLATFORM_VER(5, 0, 0)
> static bt_status_t configure_wbs(bt_bdaddr_t *bd_addr, bthf_wbs_config_t config)
> {
> - /* TODO: implement */
> + struct hal_cmd_handsfree_configure_wbs cmd;
>
> - DBG("");
> + DBG("%u", config);
> +
> + if (!interface_ready())
> + return BT_STATUS_NOT_READY;
>
> - return BT_STATUS_UNSUPPORTED;
> + if (!bd_addr)
> + return BT_STATUS_PARM_INVALID;
> +
> + memcpy(cmd.bdaddr, bd_addr, sizeof(cmd.bdaddr));
> + cmd.config = config;
> +
> + return hal_ipc_cmd(HAL_SERVICE_ID_HANDSFREE,
> + HAL_OP_HANDSFREE_CONFIGURE_WBS,
> + sizeof(cmd), &cmd, NULL, NULL, NULL);
> }
> #endif
>
> diff --git a/android/hal-ipc-api.txt b/android/hal-ipc-api.txt
> index 01490fa..f15c12e 100644
> --- a/android/hal-ipc-api.txt
> +++ b/android/hal-ipc-api.txt
> @@ -955,6 +955,18 @@ Commands and responses:
>
> In case of an error, the error response will be returned.
>
> + Opcode 0x0f - Configure WBS command/response
> +
> + Command parameters: Remote address (6 octets)
> + Config (1 octet)
> + Response parameters: <none>
> +
> + Valid config values: 0x00 = None
> + 0x01 = No
> + 0x02 = Yes
> +
> + In case of an error, the error response will be returned.
> +
> Notifications:
>
> Opcode 0x81 - Connection State notification
> diff --git a/android/hal-msg.h b/android/hal-msg.h
> index 88b0c52..ecc1150 100644
> --- a/android/hal-msg.h
> +++ b/android/hal-msg.h
> @@ -624,6 +624,16 @@ struct hal_cmd_handsfree_phone_state_change {
> uint8_t number[0];
> } __attribute__((packed));
>
> +#define HAL_HANDSFREE_WBS_NONE 0x00
> +#define HAL_HANDSFREE_WBS_NO 0x01
> +#define HAL_HANDSFREE_WBS_YES 0x02
> +
> +#define HAL_OP_HANDSFREE_CONFIGURE_WBS 0x0F
> +struct hal_cmd_handsfree_configure_wbs {
> + uint8_t bdaddr[6];
> + uint8_t config;
> +} __attribute__((packed));
> +
> /* AVRCP TARGET HAL API */
>
> #define HAL_AVRCP_PLAY_STATUS_STOPPED 0x00
> diff --git a/android/handsfree.c b/android/handsfree.c
> index 7fbe64b..da89623 100644
> --- a/android/handsfree.c
> +++ b/android/handsfree.c
> @@ -2496,6 +2496,24 @@ failed:
> HAL_OP_HANDSFREE_PHONE_STATE_CHANGE, status);
> }
>
> +static void handle_configure_wbs(const void *buf, uint16_t len)
> +{
> + const struct hal_cmd_handsfree_configure_wbs *cmd = buf;
> + uint8_t status;
> +
> + switch (cmd->config) {
> + case HAL_HANDSFREE_WBS_NONE:
> + case HAL_HANDSFREE_WBS_NO:
> + case HAL_HANDSFREE_WBS_YES:
> + default:
> + status = HAL_STATUS_FAILED;
> + break;
> + }
> +
> + ipc_send_rsp(hal_ipc, HAL_SERVICE_ID_HANDSFREE,
> + HAL_OP_HANDSFREE_CONFIGURE_WBS, status);
> +}
> +
> static const struct ipc_handler cmd_handlers[] = {
> /* HAL_OP_HANDSFREE_CONNECT */
> { handle_connect, false,
> @@ -2537,6 +2555,9 @@ static const struct ipc_handler cmd_handlers[] = {
> /* HAL_OP_HANDSFREE_PHONE_STATE_CHANGE */
> { handle_phone_state_change, true,
> sizeof(struct hal_cmd_handsfree_phone_state_change) },
> + /* HAL_OP_HANDSFREE_CONFIGURE_WBS */
> + { handle_configure_wbs, false,
> + sizeof(struct hal_cmd_handsfree_configure_wbs) },
> };
>
> static sdp_record_t *headset_ag_record(void)
>
Pushed (with some minor changes).
--
Best regards,
Szymon Janc
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2014-12-19 13:31 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-12-17 14:53 [PATCH 1/3] android/handsfree: Add initial support for configure WBS commmand Szymon Janc
2014-12-17 14:53 ` [PATCH 2/3] android/handsfree: Add support for configure WBS command Szymon Janc
2014-12-17 14:53 ` [PATCH 3/3] android/README: Update implementation status for handsfree Szymon Janc
2014-12-19 13:31 ` [PATCH 1/3] android/handsfree: Add initial support for configure WBS commmand Szymon Janc
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox