linux-bluetooth.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH BlueZ v2 01/14] android/hal-ipc-api: Add Set Volume command
@ 2014-02-19 16:58 Luiz Augusto von Dentz
  2014-02-19 16:58 ` [PATCH BlueZ v2 02/14] android/hal-ipc-api: Use variable length for text attributes Luiz Augusto von Dentz
                   ` (13 more replies)
  0 siblings, 14 replies; 15+ messages in thread
From: Luiz Augusto von Dentz @ 2014-02-19 16:58 UTC (permalink / raw)
  To: linux-bluetooth

From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

---
v2: Use fixed buffers instead of allocating memory for ipc commands, also
change to use variable length for text attributes to avoid having to define a
huge MTU which in most cases would be filled with 0.

 android/hal-ipc-api.txt | 6 ++++++
 android/hal-msg.h       | 5 +++++
 2 files changed, 11 insertions(+)

diff --git a/android/hal-ipc-api.txt b/android/hal-ipc-api.txt
index ee3bd76..ea26d0d 100644
--- a/android/hal-ipc-api.txt
+++ b/android/hal-ipc-api.txt
@@ -1300,6 +1300,12 @@ Android HAL name: "avrcp" (BT_PROFILE_AV_RC_ID)
 		Valid type values : 0x00 = Interim
 		                    0x01 = Changed
 
+	Opcode 0x0a - Set Volume command/response
+
+		Command parameters: Value (1 octet)
+
+		In case of an error, the error response will be returned.
+
 	Opcode 0x81 - Remote Features notification
 
 		Notification parameters: Remote address (6 octets)
diff --git a/android/hal-msg.h b/android/hal-msg.h
index 6504408..9d396a1 100644
--- a/android/hal-msg.h
+++ b/android/hal-msg.h
@@ -882,6 +882,11 @@ struct hal_cmd_avrcp_register_notification {
 	uint8_t data[0];
 } __attribute__((packed));
 
+#define HAL_OP_AVRCP_SET_VOLUME			0x0a
+struct hal_cmd_avrcp_set_volume {
+	uint8_t value;
+};
+
 #define HAL_EV_AVRCP_REMOTE_FEATURES		0x81
 struct hal_ev_avrcp_remote_features {
 	uint8_t bdaddr[6];
-- 
1.8.5.3


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH BlueZ v2 02/14] android/hal-ipc-api: Use variable length for text attributes
  2014-02-19 16:58 [PATCH BlueZ v2 01/14] android/hal-ipc-api: Add Set Volume command Luiz Augusto von Dentz
@ 2014-02-19 16:58 ` Luiz Augusto von Dentz
  2014-02-19 16:58 ` [PATCH BlueZ v2 03/14] android/avrcp: Add command handlers stubs Luiz Augusto von Dentz
                   ` (12 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: Luiz Augusto von Dentz @ 2014-02-19 16:58 UTC (permalink / raw)
  To: linux-bluetooth

From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

This prevent having to increase the MTU size just to fit all attributes
when in fact some attributes are numbers (3 out of 8) in text format
which should not get even close to use 256 bytes defined by bt_rc.h.
---
 android/hal-ipc-api.txt | 6 ++++--
 android/hal-msg.h       | 3 ++-
 2 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/android/hal-ipc-api.txt b/android/hal-ipc-api.txt
index ea26d0d..02355dc 100644
--- a/android/hal-ipc-api.txt
+++ b/android/hal-ipc-api.txt
@@ -1251,7 +1251,8 @@ Android HAL name: "avrcp" (BT_PROFILE_AV_RC_ID)
 
 		Command parameters: Number of values (1 octet)
 		                    Value # (1 octet)
-		                    Value # text (255 octets)
+		                    Value # text length (1 octet)
+		                    Value # text (variable)
 		                    ...
 
 		In case of an error, the error response will be returned.
@@ -1260,7 +1261,8 @@ Android HAL name: "avrcp" (BT_PROFILE_AV_RC_ID)
 
 		Command parameters: Number of elements (1 octet)
 		                    Element # (1 octet)
-		                    Element # text (255 octets)
+		                    Element # text length (1 octet)
+		                    Element # text (variable)
 		                    ...
 
 		In case of an error, the error response will be returned.
diff --git a/android/hal-msg.h b/android/hal-msg.h
index 9d396a1..55ffd08 100644
--- a/android/hal-msg.h
+++ b/android/hal-msg.h
@@ -830,7 +830,8 @@ struct hal_cmd_avrcp_get_player_attrs {
 
 struct hal_avrcp_player_setting_text {
 	uint8_t id;
-	uint8_t text[255];
+	uint8_t len;
+	uint8_t text[0];
 } __attribute__((packed));
 
 #define HAL_OP_AVRCP_GET_PLAYER_ATTRS_TEXT	0x05
-- 
1.8.5.3


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH BlueZ v2 03/14] android/avrcp: Add command handlers stubs
  2014-02-19 16:58 [PATCH BlueZ v2 01/14] android/hal-ipc-api: Add Set Volume command Luiz Augusto von Dentz
  2014-02-19 16:58 ` [PATCH BlueZ v2 02/14] android/hal-ipc-api: Use variable length for text attributes Luiz Augusto von Dentz
@ 2014-02-19 16:58 ` Luiz Augusto von Dentz
  2014-02-19 16:58 ` [PATCH BlueZ v2 04/14] android/hal-avrcp: Add .get_play_status implementation Luiz Augusto von Dentz
                   ` (11 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: Luiz Augusto von Dentz @ 2014-02-19 16:58 UTC (permalink / raw)
  To: linux-bluetooth

From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

---
 android/avrcp.c | 109 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 109 insertions(+)

diff --git a/android/avrcp.c b/android/avrcp.c
index 65b3417..b1b6dbe 100644
--- a/android/avrcp.c
+++ b/android/avrcp.c
@@ -57,7 +57,116 @@ struct avrcp_device {
 	GIOChannel	*io;
 };
 
+static void handle_get_play_status(const void *buf, uint16_t len)
+{
+	DBG("");
+
+	ipc_send_rsp(HAL_SERVICE_ID_AVRCP, HAL_OP_AVRCP_GET_PLAY_STATUS,
+							HAL_STATUS_FAILED);
+}
+
+static void handle_list_player_attrs(const void *buf, uint16_t len)
+{
+	DBG("");
+
+	ipc_send_rsp(HAL_SERVICE_ID_AVRCP, HAL_OP_AVRCP_LIST_PLAYER_ATTRS,
+							HAL_STATUS_FAILED);
+}
+
+static void handle_list_player_values(const void *buf, uint16_t len)
+{
+	DBG("");
+
+	ipc_send_rsp(HAL_SERVICE_ID_AVRCP, HAL_OP_AVRCP_LIST_PLAYER_VALUES,
+							HAL_STATUS_FAILED);
+}
+
+static void handle_get_player_attrs(const void *buf, uint16_t len)
+{
+	DBG("");
+
+	ipc_send_rsp(HAL_SERVICE_ID_AVRCP, HAL_OP_AVRCP_GET_PLAYER_ATTRS,
+							HAL_STATUS_FAILED);
+}
+
+static void handle_get_player_attrs_text(const void *buf, uint16_t len)
+{
+	DBG("");
+
+	ipc_send_rsp(HAL_SERVICE_ID_AVRCP, HAL_OP_AVRCP_GET_PLAYER_ATTRS_TEXT,
+							HAL_STATUS_FAILED);
+}
+
+static void handle_get_player_values_text(const void *buf, uint16_t len)
+{
+	DBG("");
+
+	ipc_send_rsp(HAL_SERVICE_ID_AVRCP, HAL_OP_AVRCP_GET_PLAYER_VALUES_TEXT,
+							HAL_STATUS_FAILED);
+}
+
+static void handle_get_element_attrs_text(const void *buf, uint16_t len)
+{
+	DBG("");
+
+	ipc_send_rsp(HAL_SERVICE_ID_AVRCP, HAL_OP_AVRCP_GET_ELEMENT_ATTRS_TEXT,
+							HAL_STATUS_FAILED);
+}
+
+static void handle_set_player_attrs_value(const void *buf, uint16_t len)
+{
+	DBG("");
+
+	ipc_send_rsp(HAL_SERVICE_ID_AVRCP, HAL_OP_AVRCP_SET_PLAYER_ATTRS_VALUE,
+							HAL_STATUS_FAILED);
+}
+
+static void handle_register_notification(const void *buf, uint16_t len)
+{
+	DBG("");
+
+	ipc_send_rsp(HAL_SERVICE_ID_AVRCP, HAL_OP_AVRCP_REGISTER_NOTIFICATION,
+							HAL_STATUS_FAILED);
+}
+
+static void handle_set_volume(const void *buf, uint16_t len)
+{
+	DBG("");
+
+	ipc_send_rsp(HAL_SERVICE_ID_AVRCP, HAL_OP_AVRCP_SET_VOLUME,
+							HAL_STATUS_FAILED);
+}
+
 static const struct ipc_handler cmd_handlers[] = {
+	/* HAL_OP_AVRCP_GET_PLAY_STATUS */
+	{ handle_get_play_status, false,
+			sizeof(struct hal_cmd_avrcp_get_play_status) },
+	/* HAL_OP_AVRCP_LIST_PLAYER_ATTRS */
+	{ handle_list_player_attrs, true,
+			sizeof(struct hal_cmd_avrcp_list_player_attrs) },
+	/* HAL_OP_AVRCP_LIST_PLAYER_VALUES */
+	{ handle_list_player_values, true,
+			sizeof(struct hal_cmd_avrcp_list_player_values) },
+	/* HAL_OP_AVRCP_GET_PLAYER_ATTRS */
+	{ handle_get_player_attrs, true,
+			sizeof(struct hal_cmd_avrcp_get_player_attrs) },
+	/* HAL_OP_AVRCP_GET_PLAYER_ATTRS_TEXT */
+	{ handle_get_player_attrs_text, true,
+			sizeof(struct hal_cmd_avrcp_get_player_attrs_text) },
+	/* HAL_OP_AVRCP_GET_PLAYER_VALUES_TEXT */
+	{ handle_get_player_values_text, true,
+			sizeof(struct hal_cmd_avrcp_get_player_values_text) },
+	/* HAL_OP_AVRCP_GET_ELEMENT_ATTRS_TEXT */
+	{ handle_get_element_attrs_text, true,
+			sizeof(struct hal_cmd_avrcp_get_element_attrs_text) },
+	/* HAL_OP_AVRCP_SET_PLAYER_ATTRS_VALUE */
+	{ handle_set_player_attrs_value, true,
+			sizeof(struct hal_cmd_avrcp_set_player_attrs_value) },
+	/* HAL_OP_AVRCP_REGISTER_NOTIFICATION */
+	{ handle_register_notification, true,
+			sizeof(struct hal_cmd_avrcp_register_notification) },
+	/* HAL_OP_AVRCP_SET_VOLUME */
+	{ handle_set_volume, false, sizeof(struct hal_cmd_avrcp_set_volume) },
 };
 
 static sdp_record_t *avrcp_record(void)
-- 
1.8.5.3


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH BlueZ v2 04/14] android/hal-avrcp: Add .get_play_status implementation
  2014-02-19 16:58 [PATCH BlueZ v2 01/14] android/hal-ipc-api: Add Set Volume command Luiz Augusto von Dentz
  2014-02-19 16:58 ` [PATCH BlueZ v2 02/14] android/hal-ipc-api: Use variable length for text attributes Luiz Augusto von Dentz
  2014-02-19 16:58 ` [PATCH BlueZ v2 03/14] android/avrcp: Add command handlers stubs Luiz Augusto von Dentz
@ 2014-02-19 16:58 ` Luiz Augusto von Dentz
  2014-02-19 16:58 ` [PATCH BlueZ v2 05/14] android/hal-avrcp: Add .list_player_app_attr_rsp implementation Luiz Augusto von Dentz
                   ` (10 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: Luiz Augusto von Dentz @ 2014-02-19 16:58 UTC (permalink / raw)
  To: linux-bluetooth

From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

---
 android/hal-avrcp.c | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/android/hal-avrcp.c b/android/hal-avrcp.c
index 01d233b..9937a11 100644
--- a/android/hal-avrcp.c
+++ b/android/hal-avrcp.c
@@ -56,6 +56,24 @@ static bt_status_t init(btrc_callbacks_t *callbacks)
 	return ret;
 }
 
+static bt_status_t get_play_status_rsp(btrc_play_status_t status,
+					uint32_t song_len, uint32_t song_pos)
+{
+	struct hal_cmd_avrcp_get_play_status cmd;
+
+	DBG("");
+
+	if (!interface_ready())
+		return BT_STATUS_NOT_READY;
+
+	cmd.status = status;
+	cmd.duration = song_len;
+	cmd.position = song_pos;
+
+	return hal_ipc_cmd(HAL_SERVICE_ID_AVRCP, HAL_OP_AVRCP_GET_PLAY_STATUS,
+					sizeof(cmd), &cmd, 0, NULL, NULL);
+}
+
 static void cleanup()
 {
 	struct hal_cmd_unregister_module cmd;
@@ -78,6 +96,7 @@ static void cleanup()
 static btrc_interface_t iface = {
 	.size = sizeof(iface),
 	.init = init,
+	.get_play_status_rsp = get_play_status_rsp,
 	.cleanup = cleanup
 };
 
-- 
1.8.5.3


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH BlueZ v2 05/14] android/hal-avrcp: Add .list_player_app_attr_rsp implementation
  2014-02-19 16:58 [PATCH BlueZ v2 01/14] android/hal-ipc-api: Add Set Volume command Luiz Augusto von Dentz
                   ` (2 preceding siblings ...)
  2014-02-19 16:58 ` [PATCH BlueZ v2 04/14] android/hal-avrcp: Add .get_play_status implementation Luiz Augusto von Dentz
@ 2014-02-19 16:58 ` Luiz Augusto von Dentz
  2014-02-19 16:58 ` [PATCH BlueZ v2 06/14] android/hal-avrcp: Add .list_player_app_value_rsp implementation Luiz Augusto von Dentz
                   ` (9 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: Luiz Augusto von Dentz @ 2014-02-19 16:58 UTC (permalink / raw)
  To: linux-bluetooth

From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

---
 android/hal-avrcp.c | 29 +++++++++++++++++++++++++++++
 1 file changed, 29 insertions(+)

diff --git a/android/hal-avrcp.c b/android/hal-avrcp.c
index 9937a11..9735c22 100644
--- a/android/hal-avrcp.c
+++ b/android/hal-avrcp.c
@@ -18,6 +18,7 @@
 #include <stdbool.h>
 #include <stddef.h>
 #include <string.h>
+#include <stdlib.h>
 
 #include "hal-log.h"
 #include "hal.h"
@@ -74,6 +75,33 @@ static bt_status_t get_play_status_rsp(btrc_play_status_t status,
 					sizeof(cmd), &cmd, 0, NULL, NULL);
 }
 
+static bt_status_t list_player_app_attr_rsp(int num_attr,
+						btrc_player_attr_t *p_attrs)
+{
+	char buf[BLUEZ_HAL_MTU];
+	struct hal_cmd_avrcp_list_player_attrs *cmd = (void *) buf;
+	size_t len;
+
+	DBG("");
+
+	if (!interface_ready())
+		return BT_STATUS_NOT_READY;
+
+	if (num_attr < 0)
+		return BT_STATUS_PARM_INVALID;
+
+	len = sizeof(*cmd) + num_attr;
+	if (len > BLUEZ_HAL_MTU)
+		return BT_STATUS_PARM_INVALID;
+
+	cmd->number = num_attr;
+	memcpy(cmd->attrs, p_attrs, num_attr);
+
+	return hal_ipc_cmd(HAL_SERVICE_ID_AVRCP,
+					HAL_OP_AVRCP_LIST_PLAYER_ATTRS,
+					len, cmd, 0, NULL, NULL);
+}
+
 static void cleanup()
 {
 	struct hal_cmd_unregister_module cmd;
@@ -97,6 +125,7 @@ static btrc_interface_t iface = {
 	.size = sizeof(iface),
 	.init = init,
 	.get_play_status_rsp = get_play_status_rsp,
+	.list_player_app_attr_rsp = list_player_app_attr_rsp,
 	.cleanup = cleanup
 };
 
-- 
1.8.5.3


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH BlueZ v2 06/14] android/hal-avrcp: Add .list_player_app_value_rsp implementation
  2014-02-19 16:58 [PATCH BlueZ v2 01/14] android/hal-ipc-api: Add Set Volume command Luiz Augusto von Dentz
                   ` (3 preceding siblings ...)
  2014-02-19 16:58 ` [PATCH BlueZ v2 05/14] android/hal-avrcp: Add .list_player_app_attr_rsp implementation Luiz Augusto von Dentz
@ 2014-02-19 16:58 ` Luiz Augusto von Dentz
  2014-02-19 16:58 ` [PATCH BlueZ v2 07/14] android/hal-avrcp: Add .get_player_app_value_rsp implementation Luiz Augusto von Dentz
                   ` (8 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: Luiz Augusto von Dentz @ 2014-02-19 16:58 UTC (permalink / raw)
  To: linux-bluetooth

From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

---
 android/hal-avrcp.c | 28 ++++++++++++++++++++++++++++
 1 file changed, 28 insertions(+)

diff --git a/android/hal-avrcp.c b/android/hal-avrcp.c
index 9735c22..42b1dad 100644
--- a/android/hal-avrcp.c
+++ b/android/hal-avrcp.c
@@ -102,6 +102,33 @@ static bt_status_t list_player_app_attr_rsp(int num_attr,
 					len, cmd, 0, NULL, NULL);
 }
 
+static bt_status_t list_player_app_value_rsp(int num_val, uint8_t *p_vals)
+{
+	char buf[BLUEZ_HAL_MTU];
+	struct hal_cmd_avrcp_list_player_values *cmd = (void *) buf;
+	size_t len;
+
+	DBG("");
+
+	if (!interface_ready())
+		return BT_STATUS_NOT_READY;
+
+	if (num_val < 0)
+		return BT_STATUS_PARM_INVALID;
+
+	len = sizeof(*cmd) + num_val;
+
+	if (len > BLUEZ_HAL_MTU)
+		return BT_STATUS_PARM_INVALID;
+
+	cmd->number = num_val;
+	memcpy(cmd->values, p_vals, num_val);
+
+	return hal_ipc_cmd(HAL_SERVICE_ID_AVRCP,
+					HAL_OP_AVRCP_LIST_PLAYER_VALUES,
+					len, cmd, 0, NULL, NULL);
+}
+
 static void cleanup()
 {
 	struct hal_cmd_unregister_module cmd;
@@ -126,6 +153,7 @@ static btrc_interface_t iface = {
 	.init = init,
 	.get_play_status_rsp = get_play_status_rsp,
 	.list_player_app_attr_rsp = list_player_app_attr_rsp,
+	.list_player_app_value_rsp = list_player_app_value_rsp,
 	.cleanup = cleanup
 };
 
-- 
1.8.5.3


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH BlueZ v2 07/14] android/hal-avrcp: Add .get_player_app_value_rsp implementation
  2014-02-19 16:58 [PATCH BlueZ v2 01/14] android/hal-ipc-api: Add Set Volume command Luiz Augusto von Dentz
                   ` (4 preceding siblings ...)
  2014-02-19 16:58 ` [PATCH BlueZ v2 06/14] android/hal-avrcp: Add .list_player_app_value_rsp implementation Luiz Augusto von Dentz
@ 2014-02-19 16:58 ` Luiz Augusto von Dentz
  2014-02-19 16:58 ` [PATCH BlueZ v2 08/14] android/hal-avrcp: Add .get_player_app_attr_text_rsp implementation Luiz Augusto von Dentz
                   ` (7 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: Luiz Augusto von Dentz @ 2014-02-19 16:58 UTC (permalink / raw)
  To: linux-bluetooth

From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

---
 android/hal-avrcp.c | 35 +++++++++++++++++++++++++++++++++++
 1 file changed, 35 insertions(+)

diff --git a/android/hal-avrcp.c b/android/hal-avrcp.c
index 42b1dad..c9e1be2 100644
--- a/android/hal-avrcp.c
+++ b/android/hal-avrcp.c
@@ -129,6 +129,40 @@ static bt_status_t list_player_app_value_rsp(int num_val, uint8_t *p_vals)
 					len, cmd, 0, NULL, NULL);
 }
 
+static bt_status_t get_player_app_value_rsp(btrc_player_settings_t *p_vals)
+{
+	char buf[BLUEZ_HAL_MTU];
+	struct hal_cmd_avrcp_get_player_attrs *cmd = (void *) buf;
+	size_t len, attrs_len;
+	int i;
+
+	DBG("");
+
+	if (!interface_ready())
+		return BT_STATUS_NOT_READY;
+
+	if (!p_vals)
+		return BT_STATUS_PARM_INVALID;
+
+	attrs_len = p_vals->num_attr *
+				sizeof(struct hal_avrcp_player_attr_value);
+	len = sizeof(*cmd) + attrs_len;
+
+	if (len > BLUEZ_HAL_MTU)
+		return BT_STATUS_PARM_INVALID;
+
+	cmd->number = p_vals->num_attr;
+
+	for (i = 0; i < p_vals->num_attr; i++) {
+		cmd->attrs[i].attr = p_vals->attr_ids[i];
+		cmd->attrs[i].value = p_vals->attr_values[i];
+	}
+
+	return hal_ipc_cmd(HAL_SERVICE_ID_AVRCP,
+					HAL_OP_AVRCP_GET_PLAYER_ATTRS,
+					len, cmd, 0, NULL, NULL);
+}
+
 static void cleanup()
 {
 	struct hal_cmd_unregister_module cmd;
@@ -154,6 +188,7 @@ static btrc_interface_t iface = {
 	.get_play_status_rsp = get_play_status_rsp,
 	.list_player_app_attr_rsp = list_player_app_attr_rsp,
 	.list_player_app_value_rsp = list_player_app_value_rsp,
+	.get_player_app_value_rsp = get_player_app_value_rsp,
 	.cleanup = cleanup
 };
 
-- 
1.8.5.3


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH BlueZ v2 08/14] android/hal-avrcp: Add .get_player_app_attr_text_rsp implementation
  2014-02-19 16:58 [PATCH BlueZ v2 01/14] android/hal-ipc-api: Add Set Volume command Luiz Augusto von Dentz
                   ` (5 preceding siblings ...)
  2014-02-19 16:58 ` [PATCH BlueZ v2 07/14] android/hal-avrcp: Add .get_player_app_value_rsp implementation Luiz Augusto von Dentz
@ 2014-02-19 16:58 ` Luiz Augusto von Dentz
  2014-02-19 16:58 ` [PATCH BlueZ v2 09/14] android/hal-avrcp: Add .get_player_app_value_text_rsp implementation Luiz Augusto von Dentz
                   ` (6 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: Luiz Augusto von Dentz @ 2014-02-19 16:58 UTC (permalink / raw)
  To: linux-bluetooth

From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

---
 android/hal-avrcp.c | 69 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 69 insertions(+)

diff --git a/android/hal-avrcp.c b/android/hal-avrcp.c
index c9e1be2..5d1bb94 100644
--- a/android/hal-avrcp.c
+++ b/android/hal-avrcp.c
@@ -163,6 +163,74 @@ static bt_status_t get_player_app_value_rsp(btrc_player_settings_t *p_vals)
 					len, cmd, 0, NULL, NULL);
 }
 
+static int write_text(uint8_t *ptr, uint8_t id, uint8_t *text, size_t *len)
+{
+	struct hal_avrcp_player_setting_text *value = (void *) ptr;
+	size_t attr_len = sizeof(*value);
+
+	if (attr_len + *len > BLUEZ_HAL_MTU)
+		return 0;
+
+	value->id = id;
+	value->len = strnlen((const char *) text, BTRC_MAX_ATTR_STR_LEN);
+
+	*len += attr_len;
+	ptr += attr_len;
+
+	if (value->len + *len > BLUEZ_HAL_MTU)
+		value->len = BLUEZ_HAL_MTU - *len;
+
+	memcpy(value->text, text, value->len);
+
+	*len += value->len;
+
+	return attr_len + value->len;
+}
+
+static uint8_t write_player_setting_text(uint8_t *ptr, uint8_t num_attr,
+					btrc_player_setting_text_t *p_attrs,
+					size_t *len)
+{
+	int i;
+
+	for (i = 0; i < num_attr && *len < BLUEZ_HAL_MTU; i++) {
+		int ret;
+
+		ret = write_text(ptr, p_attrs[i].id, p_attrs[i].text, len);
+		if (ret == 0)
+			break;
+
+		ptr += ret;
+	}
+
+	return i;
+}
+
+static bt_status_t get_player_app_attr_text_rsp(int num_attr,
+					btrc_player_setting_text_t *p_attrs)
+{
+	char buf[BLUEZ_HAL_MTU];
+	struct hal_cmd_avrcp_get_player_attrs_text *cmd = (void *) buf;
+	uint8_t *ptr;
+	size_t len;
+
+	DBG("");
+
+	if (!interface_ready())
+		return BT_STATUS_NOT_READY;
+
+	if (num_attr < 0 || num_attr > BTRC_MAX_APP_SETTINGS)
+		return BT_STATUS_PARM_INVALID;
+
+	len = sizeof(*cmd);
+	ptr = (uint8_t *) &cmd->attrs[0];
+	cmd->number = write_player_setting_text(ptr, num_attr, p_attrs, &len);
+
+	return hal_ipc_cmd(HAL_SERVICE_ID_AVRCP,
+					HAL_OP_AVRCP_GET_PLAYER_ATTRS_TEXT,
+					len, cmd, 0, NULL, NULL);
+}
+
 static void cleanup()
 {
 	struct hal_cmd_unregister_module cmd;
@@ -189,6 +257,7 @@ static btrc_interface_t iface = {
 	.list_player_app_attr_rsp = list_player_app_attr_rsp,
 	.list_player_app_value_rsp = list_player_app_value_rsp,
 	.get_player_app_value_rsp = get_player_app_value_rsp,
+	.get_player_app_attr_text_rsp = get_player_app_attr_text_rsp,
 	.cleanup = cleanup
 };
 
-- 
1.8.5.3


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH BlueZ v2 09/14] android/hal-avrcp: Add .get_player_app_value_text_rsp implementation
  2014-02-19 16:58 [PATCH BlueZ v2 01/14] android/hal-ipc-api: Add Set Volume command Luiz Augusto von Dentz
                   ` (6 preceding siblings ...)
  2014-02-19 16:58 ` [PATCH BlueZ v2 08/14] android/hal-avrcp: Add .get_player_app_attr_text_rsp implementation Luiz Augusto von Dentz
@ 2014-02-19 16:58 ` Luiz Augusto von Dentz
  2014-02-19 16:58 ` [PATCH BlueZ v2 10/14] android/hal-avrcp: Add .get_element_attr_rsp implementation Luiz Augusto von Dentz
                   ` (5 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: Luiz Augusto von Dentz @ 2014-02-19 16:58 UTC (permalink / raw)
  To: linux-bluetooth

From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

---
 android/hal-avrcp.c | 26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)

diff --git a/android/hal-avrcp.c b/android/hal-avrcp.c
index 5d1bb94..df32e2f 100644
--- a/android/hal-avrcp.c
+++ b/android/hal-avrcp.c
@@ -231,6 +231,31 @@ static bt_status_t get_player_app_attr_text_rsp(int num_attr,
 					len, cmd, 0, NULL, NULL);
 }
 
+static bt_status_t get_player_app_value_text_rsp(int num_val,
+					btrc_player_setting_text_t *p_vals)
+{
+	char buf[BLUEZ_HAL_MTU];
+	struct hal_cmd_avrcp_get_player_values_text *cmd = (void *) buf;
+	uint8_t *ptr;
+	size_t len;
+
+	DBG("");
+
+	if (!interface_ready())
+		return BT_STATUS_NOT_READY;
+
+	if (num_val < 0)
+		return BT_STATUS_PARM_INVALID;
+
+	len = sizeof(*cmd);
+	ptr = (uint8_t *) &cmd->values[0];
+	cmd->number = write_player_setting_text(ptr, num_val, p_vals, &len);
+
+	return hal_ipc_cmd(HAL_SERVICE_ID_AVRCP,
+					HAL_OP_AVRCP_GET_PLAYER_VALUES_TEXT,
+					len, cmd, 0, NULL, NULL);
+}
+
 static void cleanup()
 {
 	struct hal_cmd_unregister_module cmd;
@@ -258,6 +283,7 @@ static btrc_interface_t iface = {
 	.list_player_app_value_rsp = list_player_app_value_rsp,
 	.get_player_app_value_rsp = get_player_app_value_rsp,
 	.get_player_app_attr_text_rsp = get_player_app_attr_text_rsp,
+	.get_player_app_value_text_rsp = get_player_app_value_text_rsp,
 	.cleanup = cleanup
 };
 
-- 
1.8.5.3


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH BlueZ v2 10/14] android/hal-avrcp: Add .get_element_attr_rsp implementation
  2014-02-19 16:58 [PATCH BlueZ v2 01/14] android/hal-ipc-api: Add Set Volume command Luiz Augusto von Dentz
                   ` (7 preceding siblings ...)
  2014-02-19 16:58 ` [PATCH BlueZ v2 09/14] android/hal-avrcp: Add .get_player_app_value_text_rsp implementation Luiz Augusto von Dentz
@ 2014-02-19 16:58 ` Luiz Augusto von Dentz
  2014-02-19 16:58 ` [PATCH BlueZ v2 11/14] android/hal-avrcp: Add .set_player_app_value_rsp implementation Luiz Augusto von Dentz
                   ` (4 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: Luiz Augusto von Dentz @ 2014-02-19 16:58 UTC (permalink / raw)
  To: linux-bluetooth

From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

---
 android/hal-avrcp.c | 42 ++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 42 insertions(+)

diff --git a/android/hal-avrcp.c b/android/hal-avrcp.c
index df32e2f..3a39918 100644
--- a/android/hal-avrcp.c
+++ b/android/hal-avrcp.c
@@ -256,6 +256,47 @@ static bt_status_t get_player_app_value_text_rsp(int num_val,
 					len, cmd, 0, NULL, NULL);
 }
 
+static uint8_t write_element_attr_text(uint8_t *ptr, uint8_t num_attr,
+					btrc_element_attr_val_t *p_attrs,
+					size_t *len)
+{
+	int i;
+
+	for (i = 0; i < num_attr && *len < BLUEZ_HAL_MTU; i++) {
+		int ret;
+
+		ret = write_text(ptr, p_attrs[i].attr_id, p_attrs[i].text, len);
+		if (ret == 0)
+			break;
+
+		ptr += ret;
+	}
+
+	return i;
+}
+
+static bt_status_t get_element_attr_rsp(uint8_t num_attr,
+					btrc_element_attr_val_t *p_attrs)
+{
+	char buf[BLUEZ_HAL_MTU];
+	struct hal_cmd_avrcp_get_element_attrs_text *cmd = (void *) buf;
+	size_t len;
+	uint8_t *ptr;
+
+	DBG("");
+
+	if (!interface_ready())
+		return BT_STATUS_NOT_READY;
+
+	len = sizeof(*cmd);
+	ptr = (uint8_t *) &cmd->values[0];
+	cmd->number = write_element_attr_text(ptr, num_attr, p_attrs, &len);
+
+	return hal_ipc_cmd(HAL_SERVICE_ID_AVRCP,
+					HAL_OP_AVRCP_GET_ELEMENT_ATTRS_TEXT,
+					len, cmd, 0, NULL, NULL);
+}
+
 static void cleanup()
 {
 	struct hal_cmd_unregister_module cmd;
@@ -284,6 +325,7 @@ static btrc_interface_t iface = {
 	.get_player_app_value_rsp = get_player_app_value_rsp,
 	.get_player_app_attr_text_rsp = get_player_app_attr_text_rsp,
 	.get_player_app_value_text_rsp = get_player_app_value_text_rsp,
+	.get_element_attr_rsp = get_element_attr_rsp,
 	.cleanup = cleanup
 };
 
-- 
1.8.5.3


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH BlueZ v2 11/14] android/hal-avrcp: Add .set_player_app_value_rsp implementation
  2014-02-19 16:58 [PATCH BlueZ v2 01/14] android/hal-ipc-api: Add Set Volume command Luiz Augusto von Dentz
                   ` (8 preceding siblings ...)
  2014-02-19 16:58 ` [PATCH BlueZ v2 10/14] android/hal-avrcp: Add .get_element_attr_rsp implementation Luiz Augusto von Dentz
@ 2014-02-19 16:58 ` Luiz Augusto von Dentz
  2014-02-19 16:58 ` [PATCH BlueZ v2 12/14] android/hal-avrcp: Add .register_notification_rsp implementation Luiz Augusto von Dentz
                   ` (3 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: Luiz Augusto von Dentz @ 2014-02-19 16:58 UTC (permalink / raw)
  To: linux-bluetooth

From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

---
 android/hal-avrcp.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/android/hal-avrcp.c b/android/hal-avrcp.c
index 3a39918..d9069c0 100644
--- a/android/hal-avrcp.c
+++ b/android/hal-avrcp.c
@@ -297,6 +297,22 @@ static bt_status_t get_element_attr_rsp(uint8_t num_attr,
 					len, cmd, 0, NULL, NULL);
 }
 
+static bt_status_t set_player_app_value_rsp(btrc_status_t rsp_status)
+{
+	struct hal_cmd_avrcp_set_player_attrs_value cmd;
+
+	DBG("");
+
+	if (!interface_ready())
+		return BT_STATUS_NOT_READY;
+
+	cmd.status = rsp_status;
+
+	return hal_ipc_cmd(HAL_SERVICE_ID_AVRCP,
+					HAL_OP_AVRCP_SET_PLAYER_ATTRS_VALUE,
+					sizeof(cmd), &cmd, 0, NULL, NULL);
+}
+
 static void cleanup()
 {
 	struct hal_cmd_unregister_module cmd;
@@ -326,6 +342,7 @@ static btrc_interface_t iface = {
 	.get_player_app_attr_text_rsp = get_player_app_attr_text_rsp,
 	.get_player_app_value_text_rsp = get_player_app_value_text_rsp,
 	.get_element_attr_rsp = get_element_attr_rsp,
+	.set_player_app_value_rsp = set_player_app_value_rsp,
 	.cleanup = cleanup
 };
 
-- 
1.8.5.3


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH BlueZ v2 12/14] android/hal-avrcp: Add .register_notification_rsp implementation
  2014-02-19 16:58 [PATCH BlueZ v2 01/14] android/hal-ipc-api: Add Set Volume command Luiz Augusto von Dentz
                   ` (9 preceding siblings ...)
  2014-02-19 16:58 ` [PATCH BlueZ v2 11/14] android/hal-avrcp: Add .set_player_app_value_rsp implementation Luiz Augusto von Dentz
@ 2014-02-19 16:58 ` Luiz Augusto von Dentz
  2014-02-19 16:58 ` [PATCH BlueZ v2 13/14] android/hal-avrcp: Add .set_volume implementation Luiz Augusto von Dentz
                   ` (2 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: Luiz Augusto von Dentz @ 2014-02-19 16:58 UTC (permalink / raw)
  To: linux-bluetooth

From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

---
 android/hal-avrcp.c | 141 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 141 insertions(+)

diff --git a/android/hal-avrcp.c b/android/hal-avrcp.c
index d9069c0..bf3e3dc 100644
--- a/android/hal-avrcp.c
+++ b/android/hal-avrcp.c
@@ -313,6 +313,146 @@ static bt_status_t set_player_app_value_rsp(btrc_status_t rsp_status)
 					sizeof(cmd), &cmd, 0, NULL, NULL);
 }
 
+static bt_status_t play_status_changed_rsp(btrc_notification_type_t type,
+						btrc_play_status_t *play_status)
+{
+	char buf[BLUEZ_HAL_MTU];
+	struct hal_cmd_avrcp_register_notification *cmd = (void *) buf;
+	size_t len;
+
+	cmd->event = BTRC_EVT_PLAY_STATUS_CHANGED;
+	cmd->type = type;
+	cmd->len = 1;
+	memcpy(cmd->data, play_status, cmd->len);
+
+	len = sizeof(*cmd) + cmd->len;
+
+	return hal_ipc_cmd(HAL_SERVICE_ID_AVRCP,
+					HAL_OP_AVRCP_REGISTER_NOTIFICATION,
+					len, cmd, 0, NULL, NULL);
+}
+
+static bt_status_t track_change_rsp(btrc_notification_type_t type,
+							btrc_uid_t *track)
+{
+	char buf[BLUEZ_HAL_MTU];
+	struct hal_cmd_avrcp_register_notification *cmd = (void *) buf;
+	size_t len;
+
+	cmd->event = BTRC_EVT_TRACK_CHANGE;
+	cmd->type = type;
+	cmd->len = sizeof(*track);
+	memcpy(cmd->data, track, cmd->len);
+
+	len = sizeof(*cmd) + cmd->len;
+
+	return hal_ipc_cmd(HAL_SERVICE_ID_AVRCP,
+					HAL_OP_AVRCP_REGISTER_NOTIFICATION,
+					len, cmd, 0, NULL, NULL);
+}
+
+static bt_status_t track_reached_end_rsp(btrc_notification_type_t type)
+{
+	struct hal_cmd_avrcp_register_notification cmd;
+
+	cmd.event = BTRC_EVT_TRACK_REACHED_END;
+	cmd.type = type;
+	cmd.len = 0;
+
+	return hal_ipc_cmd(HAL_SERVICE_ID_AVRCP,
+					HAL_OP_AVRCP_REGISTER_NOTIFICATION,
+					sizeof(cmd), &cmd, 0, NULL, NULL);
+}
+
+static bt_status_t track_reached_start_rsp(btrc_notification_type_t type)
+{
+	struct hal_cmd_avrcp_register_notification cmd;
+
+	cmd.event = BTRC_EVT_TRACK_REACHED_START;
+	cmd.type = type;
+	cmd.len = 0;
+
+	return hal_ipc_cmd(HAL_SERVICE_ID_AVRCP,
+					HAL_OP_AVRCP_REGISTER_NOTIFICATION,
+					sizeof(cmd), &cmd, 0, NULL, NULL);
+}
+
+static bt_status_t play_pos_changed_rsp(btrc_notification_type_t type,
+							uint32_t *song_pos)
+{
+	char buf[BLUEZ_HAL_MTU];
+	struct hal_cmd_avrcp_register_notification *cmd = (void *) buf;
+	size_t len;
+
+	cmd->event = BTRC_EVT_PLAY_POS_CHANGED;
+	cmd->type = type;
+	cmd->len = sizeof(*song_pos);
+	memcpy(cmd->data, song_pos, cmd->len);
+
+	len = sizeof(*cmd) + cmd->len;
+
+	return hal_ipc_cmd(HAL_SERVICE_ID_AVRCP,
+					HAL_OP_AVRCP_REGISTER_NOTIFICATION,
+					len, cmd, 0, NULL, NULL);
+}
+
+static bt_status_t settings_changed_rsp(btrc_notification_type_t type,
+					btrc_player_settings_t *player_setting)
+{
+	char buf[BLUEZ_HAL_MTU];
+	struct hal_cmd_avrcp_register_notification *cmd = (void *) buf;
+	struct hal_avrcp_player_attr_value *attrs;
+	size_t len, param_len;
+	int i;
+
+	param_len = player_setting->num_attr * sizeof(*attrs);
+	len = sizeof(*cmd) + param_len;
+
+	if (len > BLUEZ_HAL_MTU)
+		return BT_STATUS_PARM_INVALID;
+
+	cmd->event = BTRC_EVT_APP_SETTINGS_CHANGED;
+	cmd->type = type;
+	cmd->len = param_len;
+
+	attrs = (struct hal_avrcp_player_attr_value *) &cmd->data[0];
+	for (i = 0; i < player_setting->num_attr; i++) {
+		attrs[i].attr = player_setting->attr_ids[i];
+		attrs[i].value = player_setting->attr_values[i];
+	}
+
+	return hal_ipc_cmd(HAL_SERVICE_ID_AVRCP,
+					HAL_OP_AVRCP_REGISTER_NOTIFICATION,
+					len, cmd, 0, NULL, NULL);
+}
+
+static bt_status_t register_notification_rsp(btrc_event_id_t event_id,
+					btrc_notification_type_t type,
+					btrc_register_notification_t *p_param)
+{
+	DBG("");
+
+	if (!interface_ready())
+		return BT_STATUS_NOT_READY;
+
+	switch (event_id) {
+	case BTRC_EVT_PLAY_STATUS_CHANGED:
+		return play_status_changed_rsp(type, &p_param->play_status);
+	case BTRC_EVT_TRACK_CHANGE:
+		return track_change_rsp(type, &p_param->track);
+	case BTRC_EVT_TRACK_REACHED_END:
+		return track_reached_end_rsp(type);
+	case BTRC_EVT_TRACK_REACHED_START:
+		return track_reached_start_rsp(type);
+	case BTRC_EVT_PLAY_POS_CHANGED:
+		return play_pos_changed_rsp(type, &p_param->song_pos);
+	case BTRC_EVT_APP_SETTINGS_CHANGED:
+		return settings_changed_rsp(type, &p_param->player_setting);
+	default:
+		return BT_STATUS_PARM_INVALID;
+	}
+}
+
 static void cleanup()
 {
 	struct hal_cmd_unregister_module cmd;
@@ -343,6 +483,7 @@ static btrc_interface_t iface = {
 	.get_player_app_value_text_rsp = get_player_app_value_text_rsp,
 	.get_element_attr_rsp = get_element_attr_rsp,
 	.set_player_app_value_rsp = set_player_app_value_rsp,
+	.register_notification_rsp = register_notification_rsp,
 	.cleanup = cleanup
 };
 
-- 
1.8.5.3


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH BlueZ v2 13/14] android/hal-avrcp: Add .set_volume implementation
  2014-02-19 16:58 [PATCH BlueZ v2 01/14] android/hal-ipc-api: Add Set Volume command Luiz Augusto von Dentz
                   ` (10 preceding siblings ...)
  2014-02-19 16:58 ` [PATCH BlueZ v2 12/14] android/hal-avrcp: Add .register_notification_rsp implementation Luiz Augusto von Dentz
@ 2014-02-19 16:58 ` Luiz Augusto von Dentz
  2014-02-19 16:58 ` [PATCH BlueZ v2 14/14] android/hal-avrcp: Add notification handlers Luiz Augusto von Dentz
  2014-02-19 18:20 ` [PATCH BlueZ v2 01/14] android/hal-ipc-api: Add Set Volume command Szymon Janc
  13 siblings, 0 replies; 15+ messages in thread
From: Luiz Augusto von Dentz @ 2014-02-19 16:58 UTC (permalink / raw)
  To: linux-bluetooth

From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

---
 android/hal-avrcp.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/android/hal-avrcp.c b/android/hal-avrcp.c
index bf3e3dc..f982f48 100644
--- a/android/hal-avrcp.c
+++ b/android/hal-avrcp.c
@@ -453,6 +453,21 @@ static bt_status_t register_notification_rsp(btrc_event_id_t event_id,
 	}
 }
 
+static bt_status_t set_volume(uint8_t volume)
+{
+	struct hal_cmd_avrcp_set_volume cmd;
+
+	DBG("");
+
+	if (!interface_ready())
+		return BT_STATUS_NOT_READY;
+
+	cmd.value = volume;
+
+	return hal_ipc_cmd(HAL_SERVICE_ID_AVRCP, HAL_OP_AVRCP_SET_VOLUME,
+					sizeof(cmd), &cmd, 0, NULL, NULL);
+}
+
 static void cleanup()
 {
 	struct hal_cmd_unregister_module cmd;
@@ -484,6 +499,7 @@ static btrc_interface_t iface = {
 	.get_element_attr_rsp = get_element_attr_rsp,
 	.set_player_app_value_rsp = set_player_app_value_rsp,
 	.register_notification_rsp = register_notification_rsp,
+	.set_volume = set_volume,
 	.cleanup = cleanup
 };
 
-- 
1.8.5.3


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH BlueZ v2 14/14] android/hal-avrcp: Add notification handlers
  2014-02-19 16:58 [PATCH BlueZ v2 01/14] android/hal-ipc-api: Add Set Volume command Luiz Augusto von Dentz
                   ` (11 preceding siblings ...)
  2014-02-19 16:58 ` [PATCH BlueZ v2 13/14] android/hal-avrcp: Add .set_volume implementation Luiz Augusto von Dentz
@ 2014-02-19 16:58 ` Luiz Augusto von Dentz
  2014-02-19 18:20 ` [PATCH BlueZ v2 01/14] android/hal-ipc-api: Add Set Volume command Szymon Janc
  13 siblings, 0 replies; 15+ messages in thread
From: Luiz Augusto von Dentz @ 2014-02-19 16:58 UTC (permalink / raw)
  To: linux-bluetooth

From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

---
 android/hal-avrcp.c | 174 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 174 insertions(+)

diff --git a/android/hal-avrcp.c b/android/hal-avrcp.c
index f982f48..a11aaa3 100644
--- a/android/hal-avrcp.c
+++ b/android/hal-avrcp.c
@@ -32,6 +32,177 @@ static bool interface_ready(void)
 	return cbs != NULL;
 }
 
+static void handle_remote_features(void *buf, uint16_t len)
+{
+	struct hal_ev_avrcp_remote_features *ev = buf;
+
+	if (cbs->remote_features_cb)
+		cbs->remote_features_cb((bt_bdaddr_t *) (ev->bdaddr),
+								ev->features);
+}
+
+static void handle_get_play_status(void *buf, uint16_t len)
+{
+	if (cbs->get_play_status_cb)
+		cbs->get_play_status_cb();
+}
+
+static void handle_list_player_attrs(void *buf, uint16_t len)
+{
+	if (cbs->list_player_app_attr_cb)
+		cbs->list_player_app_attr_cb();
+}
+
+static void handle_list_player_values(void *buf, uint16_t len)
+{
+	struct hal_ev_avrcp_list_player_values *ev = buf;
+
+	if (cbs->list_player_app_values_cb)
+		cbs->list_player_app_values_cb(ev->attr);
+}
+
+static void handle_get_player_values(void *buf, uint16_t len)
+{
+	struct hal_ev_avrcp_get_player_values *ev = buf;
+	btrc_player_attr_t attrs[4];
+	int i;
+
+	if (!cbs->get_player_app_value_cb)
+		return;
+
+	/* Convert uint8_t array to btrc_player_attr_t array */
+	for (i = 0; i < ev->number; i++)
+		attrs[i] = ev->attrs[i];
+
+	cbs->get_player_app_value_cb(ev->number, attrs);
+}
+
+static void handle_get_player_attrs_text(void *buf, uint16_t len)
+{
+	struct hal_ev_avrcp_get_player_attrs_text *ev = buf;
+	btrc_player_attr_t attrs[4];
+	int i;
+
+	if (!cbs->get_player_app_attrs_text_cb)
+		return;
+
+	/* Convert uint8_t array to btrc_player_attr_t array */
+	for (i = 0; i < ev->number; i++)
+		attrs[i] = ev->attrs[i];
+
+	cbs->get_player_app_attrs_text_cb(ev->number, attrs);
+}
+
+static void handle_get_player_values_text(void *buf, uint16_t len)
+{
+	struct hal_ev_avrcp_get_player_values_text *ev = buf;
+
+	if (cbs->get_player_app_values_text_cb)
+		cbs->get_player_app_values_text_cb(ev->attr, ev->number,
+								ev->values);
+}
+
+static void handle_set_player_value(void *buf, uint16_t len)
+{
+	struct hal_ev_avrcp_set_player_values *ev = buf;
+	struct hal_avrcp_player_attr_value *attrs;
+	btrc_player_settings_t values;
+	int i;
+
+	if (!cbs->set_player_app_value_cb)
+		return;
+
+	attrs = (struct hal_avrcp_player_attr_value *) ev->attrs;
+
+	/* Convert to btrc_player_settings_t */
+	values.num_attr = ev->number;
+	for (i = 0; i < ev->number; i++) {
+		values.attr_ids[i] = attrs[i].attr;
+		values.attr_values[i] = attrs[i].value;
+	}
+
+	cbs->set_player_app_value_cb(&values);
+}
+
+static void handle_get_element_attrs(void *buf, uint16_t len)
+{
+	struct hal_ev_avrcp_get_element_attrs *ev = buf;
+	btrc_media_attr_t attrs[BTRC_MAX_APP_SETTINGS];
+	int i;
+
+	if (!cbs->get_element_attr_cb)
+		return;
+
+	/* Convert uint8_t array to btrc_media_attr_t array */
+	for (i = 0; i < ev->number; i++)
+		attrs[i] = ev->attrs[i];
+
+	cbs->get_element_attr_cb(ev->number, attrs);
+}
+
+static void handle_register_notification(void *buf, uint16_t len)
+{
+	struct hal_ev_avrcp_register_notification *ev = buf;
+
+	if (cbs->register_notification_cb)
+		cbs->register_notification_cb(ev->event, ev->param);
+}
+
+static void handle_volume_changed(void *buf, uint16_t len)
+{
+	struct hal_ev_avrcp_volume_changed *ev = buf;
+
+	if (cbs->volume_change_cb)
+		cbs->volume_change_cb(ev->volume, ev->type);
+}
+
+static void handle_passthrough_cmd(void *buf, uint16_t len)
+{
+	struct hal_ev_avrcp_passthrough_cmd *ev = buf;
+
+	if (cbs->passthrough_cmd_cb)
+		cbs->passthrough_cmd_cb(ev->id, ev->state);
+}
+
+/* handlers will be called from notification thread context,
+ * index in table equals to 'opcode - HAL_MINIMUM_EVENT' */
+static const struct hal_ipc_handler ev_handlers[] = {
+	/* HAL_EV_AVRCP_REMOTE_FEATURES */
+	{ handle_remote_features, false,
+			sizeof(struct hal_ev_avrcp_remote_features) },
+	/* HAL_EV_AVRCP_GET_PLAY_STATUS */
+	{ handle_get_play_status, false, 0 },
+	/* HAL_EV_AVRCP_LIST_PLAYER_ATTRS */
+	{ handle_list_player_attrs, false, 0 },
+	/* HAL_EV_AVRCP_LIST_PLAYER_VALUES */
+	{ handle_list_player_values, false,
+			sizeof(struct hal_ev_avrcp_list_player_values) },
+	/* HAL_EV_AVRCP_GET_PLAYER_VALUES */
+	{ handle_get_player_values, true,
+			sizeof(struct hal_ev_avrcp_get_player_values) },
+	/* HAL_EV_AVRCP_GET_PLAYER_ATTRS_TEXT */
+	{ handle_get_player_attrs_text, true,
+			sizeof(struct hal_ev_avrcp_get_player_attrs_text) },
+	/* HAL_EV_AVRCP_GET_PLAYER_VALUES_TEXT */
+	{ handle_get_player_values_text, true,
+			sizeof(struct hal_ev_avrcp_get_player_values_text) },
+	/* HAL_EV_AVRCP_SET_PLAYER_VALUES */
+	{ handle_set_player_value, true,
+			sizeof(struct hal_ev_avrcp_set_player_values) },
+	/* HAL_EV_AVRCP_GET_ELEMENT_ATTRS */
+	{ handle_get_element_attrs, true,
+			sizeof(struct hal_ev_avrcp_get_element_attrs) },
+	/* HAL_EV_AVRCP_REGISTER_NOTIFICATION */
+	{ handle_register_notification, false,
+			sizeof(struct hal_ev_avrcp_register_notification) },
+	/* HAL_EV_AVRCP_VOLUME_CHANGED */
+	{ handle_volume_changed, false,
+			sizeof(struct hal_ev_avrcp_volume_changed) },
+	/* HAL_EV_AVRCP_PASSTHROUGH_CMD */
+	{ handle_passthrough_cmd, false,
+			sizeof(struct hal_ev_avrcp_passthrough_cmd) },
+};
+
 static bt_status_t init(btrc_callbacks_t *callbacks)
 {
 	struct hal_cmd_register_module cmd;
@@ -44,6 +215,9 @@ static bt_status_t init(btrc_callbacks_t *callbacks)
 
 	cbs = callbacks;
 
+	hal_ipc_register(HAL_SERVICE_ID_AVRCP, ev_handlers,
+				sizeof(ev_handlers) / sizeof(ev_handlers[0]));
+
 	cmd.service_id = HAL_SERVICE_ID_AVRCP;
 
 	ret = hal_ipc_cmd(HAL_SERVICE_ID_CORE, HAL_OP_REGISTER_MODULE,
-- 
1.8.5.3


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* Re: [PATCH BlueZ v2 01/14] android/hal-ipc-api: Add Set Volume command
  2014-02-19 16:58 [PATCH BlueZ v2 01/14] android/hal-ipc-api: Add Set Volume command Luiz Augusto von Dentz
                   ` (12 preceding siblings ...)
  2014-02-19 16:58 ` [PATCH BlueZ v2 14/14] android/hal-avrcp: Add notification handlers Luiz Augusto von Dentz
@ 2014-02-19 18:20 ` Szymon Janc
  13 siblings, 0 replies; 15+ messages in thread
From: Szymon Janc @ 2014-02-19 18:20 UTC (permalink / raw)
  To: Luiz Augusto von Dentz; +Cc: linux-bluetooth

Hi Luiz,

On Wednesday 19 February 2014 18:58:45 Luiz Augusto von Dentz wrote:
> From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
> 
> ---
> v2: Use fixed buffers instead of allocating memory for ipc commands, also
> change to use variable length for text attributes to avoid having to define
> a huge MTU which in most cases would be filled with 0.
> 
>  android/hal-ipc-api.txt | 6 ++++++
>  android/hal-msg.h       | 5 +++++
>  2 files changed, 11 insertions(+)
> 
> diff --git a/android/hal-ipc-api.txt b/android/hal-ipc-api.txt
> index ee3bd76..ea26d0d 100644
> --- a/android/hal-ipc-api.txt
> +++ b/android/hal-ipc-api.txt
> @@ -1300,6 +1300,12 @@ Android HAL name: "avrcp" (BT_PROFILE_AV_RC_ID)
>  		Valid type values : 0x00 = Interim
>  		                    0x01 = Changed
> 
> +	Opcode 0x0a - Set Volume command/response
> +
> +		Command parameters: Value (1 octet)
> +
> +		In case of an error, the error response will be returned.
> +
>  	Opcode 0x81 - Remote Features notification
> 
>  		Notification parameters: Remote address (6 octets)
> diff --git a/android/hal-msg.h b/android/hal-msg.h
> index 6504408..9d396a1 100644
> --- a/android/hal-msg.h
> +++ b/android/hal-msg.h
> @@ -882,6 +882,11 @@ struct hal_cmd_avrcp_register_notification {
>  	uint8_t data[0];
>  } __attribute__((packed));
> 
> +#define HAL_OP_AVRCP_SET_VOLUME			0x0a
> +struct hal_cmd_avrcp_set_volume {
> +	uint8_t value;
> +};
> +
>  #define HAL_EV_AVRCP_REMOTE_FEATURES		0x81
>  struct hal_ev_avrcp_remote_features {
>  	uint8_t bdaddr[6];

All patches are now upstream, thanks.

-- 
Szymon K. Janc
szymon.janc@gmail.com

^ permalink raw reply	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2014-02-19 18:20 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-02-19 16:58 [PATCH BlueZ v2 01/14] android/hal-ipc-api: Add Set Volume command Luiz Augusto von Dentz
2014-02-19 16:58 ` [PATCH BlueZ v2 02/14] android/hal-ipc-api: Use variable length for text attributes Luiz Augusto von Dentz
2014-02-19 16:58 ` [PATCH BlueZ v2 03/14] android/avrcp: Add command handlers stubs Luiz Augusto von Dentz
2014-02-19 16:58 ` [PATCH BlueZ v2 04/14] android/hal-avrcp: Add .get_play_status implementation Luiz Augusto von Dentz
2014-02-19 16:58 ` [PATCH BlueZ v2 05/14] android/hal-avrcp: Add .list_player_app_attr_rsp implementation Luiz Augusto von Dentz
2014-02-19 16:58 ` [PATCH BlueZ v2 06/14] android/hal-avrcp: Add .list_player_app_value_rsp implementation Luiz Augusto von Dentz
2014-02-19 16:58 ` [PATCH BlueZ v2 07/14] android/hal-avrcp: Add .get_player_app_value_rsp implementation Luiz Augusto von Dentz
2014-02-19 16:58 ` [PATCH BlueZ v2 08/14] android/hal-avrcp: Add .get_player_app_attr_text_rsp implementation Luiz Augusto von Dentz
2014-02-19 16:58 ` [PATCH BlueZ v2 09/14] android/hal-avrcp: Add .get_player_app_value_text_rsp implementation Luiz Augusto von Dentz
2014-02-19 16:58 ` [PATCH BlueZ v2 10/14] android/hal-avrcp: Add .get_element_attr_rsp implementation Luiz Augusto von Dentz
2014-02-19 16:58 ` [PATCH BlueZ v2 11/14] android/hal-avrcp: Add .set_player_app_value_rsp implementation Luiz Augusto von Dentz
2014-02-19 16:58 ` [PATCH BlueZ v2 12/14] android/hal-avrcp: Add .register_notification_rsp implementation Luiz Augusto von Dentz
2014-02-19 16:58 ` [PATCH BlueZ v2 13/14] android/hal-avrcp: Add .set_volume implementation Luiz Augusto von Dentz
2014-02-19 16:58 ` [PATCH BlueZ v2 14/14] android/hal-avrcp: Add notification handlers Luiz Augusto von Dentz
2014-02-19 18:20 ` [PATCH BlueZ v2 01/14] android/hal-ipc-api: Add Set Volume command Szymon Janc

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).