linux-bluetooth.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH BlueZ 01/13] android/hal-ipc-api: Add Set Volume command
@ 2014-02-18 14:24 Luiz Augusto von Dentz
  2014-02-18 14:24 ` [PATCH BlueZ 02/13] android/avrcp: Add command handlers stubs Luiz Augusto von Dentz
                   ` (11 more replies)
  0 siblings, 12 replies; 14+ messages in thread
From: Luiz Augusto von Dentz @ 2014-02-18 14:24 UTC (permalink / raw)
  To: linux-bluetooth

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

---
 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] 14+ messages in thread

* [PATCH BlueZ 02/13] android/avrcp: Add command handlers stubs
  2014-02-18 14:24 [PATCH BlueZ 01/13] android/hal-ipc-api: Add Set Volume command Luiz Augusto von Dentz
@ 2014-02-18 14:24 ` Luiz Augusto von Dentz
  2014-02-18 14:24 ` [PATCH BlueZ 03/13] android/hal-avrcp: Add .get_play_status implementation Luiz Augusto von Dentz
                   ` (10 subsequent siblings)
  11 siblings, 0 replies; 14+ messages in thread
From: Luiz Augusto von Dentz @ 2014-02-18 14:24 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 b8304f5..2cca64a 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] 14+ messages in thread

* [PATCH BlueZ 03/13] android/hal-avrcp: Add .get_play_status implementation
  2014-02-18 14:24 [PATCH BlueZ 01/13] android/hal-ipc-api: Add Set Volume command Luiz Augusto von Dentz
  2014-02-18 14:24 ` [PATCH BlueZ 02/13] android/avrcp: Add command handlers stubs Luiz Augusto von Dentz
@ 2014-02-18 14:24 ` Luiz Augusto von Dentz
  2014-02-18 14:24 ` [PATCH BlueZ 04/13] android/hal-avrcp: Add .list_player_app_attr_rsp implementation Luiz Augusto von Dentz
                   ` (9 subsequent siblings)
  11 siblings, 0 replies; 14+ messages in thread
From: Luiz Augusto von Dentz @ 2014-02-18 14:24 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] 14+ messages in thread

* [PATCH BlueZ 04/13] android/hal-avrcp: Add .list_player_app_attr_rsp implementation
  2014-02-18 14:24 [PATCH BlueZ 01/13] android/hal-ipc-api: Add Set Volume command Luiz Augusto von Dentz
  2014-02-18 14:24 ` [PATCH BlueZ 02/13] android/avrcp: Add command handlers stubs Luiz Augusto von Dentz
  2014-02-18 14:24 ` [PATCH BlueZ 03/13] android/hal-avrcp: Add .get_play_status implementation Luiz Augusto von Dentz
@ 2014-02-18 14:24 ` Luiz Augusto von Dentz
  2014-02-18 20:36   ` Szymon Janc
  2014-02-18 14:24 ` [PATCH BlueZ 05/13] android/hal-avrcp: Add .list_player_app_value_rsp implementation Luiz Augusto von Dentz
                   ` (8 subsequent siblings)
  11 siblings, 1 reply; 14+ messages in thread
From: Luiz Augusto von Dentz @ 2014-02-18 14:24 UTC (permalink / raw)
  To: linux-bluetooth

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

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

diff --git a/android/hal-avrcp.c b/android/hal-avrcp.c
index 9937a11..244f77a 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,36 @@ 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)
+{
+	struct hal_cmd_avrcp_list_player_attrs *cmd;
+	bt_status_t status;
+	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;
+	cmd = malloc(len);
+
+	cmd->number = num_attr;
+	memcpy(cmd->attrs, p_attrs, num_attr);
+
+	status =  hal_ipc_cmd(HAL_SERVICE_ID_AVRCP,
+					HAL_OP_AVRCP_LIST_PLAYER_ATTRS,
+					len, cmd, 0, NULL, NULL);
+
+	free(cmd);
+
+	return status;
+}
+
 static void cleanup()
 {
 	struct hal_cmd_unregister_module cmd;
@@ -97,6 +128,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] 14+ messages in thread

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

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

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

diff --git a/android/hal-avrcp.c b/android/hal-avrcp.c
index 244f77a..4bc8073 100644
--- a/android/hal-avrcp.c
+++ b/android/hal-avrcp.c
@@ -105,6 +105,35 @@ static bt_status_t list_player_app_attr_rsp(int num_attr,
 	return status;
 }
 
+static bt_status_t list_player_app_value_rsp(int num_val, uint8_t *p_vals)
+{
+	struct hal_cmd_avrcp_list_player_values *cmd;
+	bt_status_t status;
+	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;
+	cmd = malloc(len);
+
+	cmd->number = num_val;
+	memcpy(cmd->values, p_vals, num_val);
+
+	status = hal_ipc_cmd(HAL_SERVICE_ID_AVRCP,
+					HAL_OP_AVRCP_LIST_PLAYER_VALUES,
+					len, cmd, 0, NULL, NULL);
+
+	free(cmd);
+
+	return status;
+}
+
 static void cleanup()
 {
 	struct hal_cmd_unregister_module cmd;
@@ -129,6 +158,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] 14+ messages in thread

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

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

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

diff --git a/android/hal-avrcp.c b/android/hal-avrcp.c
index 4bc8073..4110388 100644
--- a/android/hal-avrcp.c
+++ b/android/hal-avrcp.c
@@ -134,6 +134,42 @@ static bt_status_t list_player_app_value_rsp(int num_val, uint8_t *p_vals)
 	return status;
 }
 
+static bt_status_t get_player_app_value_rsp(btrc_player_settings_t *p_vals)
+{
+	struct hal_cmd_avrcp_get_player_attrs *cmd;
+	bt_status_t status;
+	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;
+	cmd = malloc(len);
+
+	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];
+	}
+
+	status = hal_ipc_cmd(HAL_SERVICE_ID_AVRCP,
+					HAL_OP_AVRCP_GET_PLAYER_ATTRS,
+					len, cmd, 0, NULL, NULL);
+
+	free(cmd);
+
+	return status;
+}
+
 static void cleanup()
 {
 	struct hal_cmd_unregister_module cmd;
@@ -159,6 +195,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] 14+ messages in thread

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

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

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

diff --git a/android/hal-avrcp.c b/android/hal-avrcp.c
index 4110388..36513c6 100644
--- a/android/hal-avrcp.c
+++ b/android/hal-avrcp.c
@@ -170,6 +170,37 @@ static bt_status_t get_player_app_value_rsp(btrc_player_settings_t *p_vals)
 	return status;
 }
 
+static bt_status_t get_player_app_attr_text_rsp(int num_attr,
+					btrc_player_setting_text_t *p_attrs)
+{
+	struct hal_cmd_avrcp_get_player_attrs_text *cmd;
+	bt_status_t status;
+	size_t len, attrs_len;
+
+	DBG("");
+
+	if (!interface_ready())
+		return BT_STATUS_NOT_READY;
+
+	if (num_attr < 0)
+		return BT_STATUS_PARM_INVALID;
+
+	attrs_len = num_attr * sizeof(*p_attrs);
+	len = sizeof(*cmd) + attrs_len;
+	cmd = malloc(len);
+
+	cmd->number = num_attr;
+	memcpy(cmd->attrs, p_attrs, attrs_len);
+
+	status = hal_ipc_cmd(HAL_SERVICE_ID_AVRCP,
+					HAL_OP_AVRCP_GET_PLAYER_ATTRS_TEXT,
+					len, cmd, 0, NULL, NULL);
+
+	free(cmd);
+
+	return status;
+}
+
 static void cleanup()
 {
 	struct hal_cmd_unregister_module cmd;
@@ -196,6 +227,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] 14+ messages in thread

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

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

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

diff --git a/android/hal-avrcp.c b/android/hal-avrcp.c
index 36513c6..d7d47f8 100644
--- a/android/hal-avrcp.c
+++ b/android/hal-avrcp.c
@@ -201,6 +201,37 @@ static bt_status_t get_player_app_attr_text_rsp(int num_attr,
 	return status;
 }
 
+static bt_status_t get_player_app_value_text_rsp(int num_val,
+					btrc_player_setting_text_t *p_vals)
+{
+	struct hal_cmd_avrcp_get_player_values_text *cmd;
+	bt_status_t status;
+	size_t len, values_len;
+
+	DBG("");
+
+	if (!interface_ready())
+		return BT_STATUS_NOT_READY;
+
+	if (num_val < 0)
+		return BT_STATUS_PARM_INVALID;
+
+	values_len = num_val * sizeof(*p_vals);
+	len = sizeof(*cmd) + values_len;
+	cmd = malloc(len);
+
+	cmd->number = num_val;
+	memcpy(cmd->values, p_vals, values_len);
+
+	status = hal_ipc_cmd(HAL_SERVICE_ID_AVRCP,
+					HAL_OP_AVRCP_GET_PLAYER_VALUES_TEXT,
+					len, cmd, 0, NULL, NULL);
+
+	free(cmd);
+
+	return status;
+}
+
 static void cleanup()
 {
 	struct hal_cmd_unregister_module cmd;
@@ -228,6 +259,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] 14+ messages in thread

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

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

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

diff --git a/android/hal-avrcp.c b/android/hal-avrcp.c
index d7d47f8..2b8b58a 100644
--- a/android/hal-avrcp.c
+++ b/android/hal-avrcp.c
@@ -232,6 +232,41 @@ static bt_status_t get_player_app_value_text_rsp(int num_val,
 	return status;
 }
 
+static bt_status_t get_element_attr_rsp(uint8_t num_attr,
+					btrc_element_attr_val_t *p_attrs)
+{
+	struct hal_cmd_avrcp_get_element_attrs_text *cmd;
+	bt_status_t status;
+	size_t len, attrs_len;
+	int i;
+
+	DBG("");
+
+	if (!interface_ready())
+		return BT_STATUS_NOT_READY;
+
+	attrs_len = num_attr * sizeof(struct hal_avrcp_player_setting_text);
+	len = sizeof(*cmd) + attrs_len;
+	cmd = malloc(len);
+
+	cmd->number = num_attr;
+
+	for (i = 0; i < num_attr; i++) {
+		/* We are unable to memcpy the id since it is uint32_t */
+		cmd->values[i].id = p_attrs[i].attr_id;
+		memcpy(cmd->values[i].text, p_attrs[i].text,
+						sizeof(cmd->values[i].text));
+	}
+
+	status = hal_ipc_cmd(HAL_SERVICE_ID_AVRCP,
+					HAL_OP_AVRCP_GET_ELEMENT_ATTRS_TEXT,
+					len, cmd, 0, NULL, NULL);
+
+	free(cmd);
+
+	return status;
+}
+
 static void cleanup()
 {
 	struct hal_cmd_unregister_module cmd;
@@ -260,6 +295,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] 14+ messages in thread

* [PATCH BlueZ 10/13] android/hal-avrcp: Add .set_player_app_value_rsp implementation
  2014-02-18 14:24 [PATCH BlueZ 01/13] android/hal-ipc-api: Add Set Volume command Luiz Augusto von Dentz
                   ` (7 preceding siblings ...)
  2014-02-18 14:24 ` [PATCH BlueZ 09/13] android/hal-avrcp: Add .get_element_attr_rsp implementation Luiz Augusto von Dentz
@ 2014-02-18 14:24 ` Luiz Augusto von Dentz
  2014-02-18 14:24 ` [PATCH BlueZ 11/13] android/hal-avrcp: Add .register_notification_rsp implementation Luiz Augusto von Dentz
                   ` (2 subsequent siblings)
  11 siblings, 0 replies; 14+ messages in thread
From: Luiz Augusto von Dentz @ 2014-02-18 14:24 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 2b8b58a..d32cdff 100644
--- a/android/hal-avrcp.c
+++ b/android/hal-avrcp.c
@@ -267,6 +267,22 @@ static bt_status_t get_element_attr_rsp(uint8_t num_attr,
 	return status;
 }
 
+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;
@@ -296,6 +312,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] 14+ messages in thread

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

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

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

diff --git a/android/hal-avrcp.c b/android/hal-avrcp.c
index d32cdff..41349f2 100644
--- a/android/hal-avrcp.c
+++ b/android/hal-avrcp.c
@@ -283,6 +283,147 @@ static bt_status_t set_player_app_value_rsp(btrc_status_t rsp_status)
 					sizeof(cmd), &cmd, 0, NULL, NULL);
 }
 
+static void *play_status_changed_rsp(btrc_notification_type_t type,
+						btrc_play_status_t *play_status)
+{
+	struct hal_cmd_avrcp_register_notification *cmd;
+	size_t param_len;
+
+	param_len = 1;
+	cmd = malloc(sizeof(*cmd) + param_len);
+	cmd->event = BTRC_EVT_PLAY_STATUS_CHANGED;
+	cmd->type = type;
+	cmd->len = param_len;
+	memcpy(cmd->data, play_status, cmd->len);
+
+	return cmd;
+}
+
+static void *track_change_rsp(btrc_notification_type_t type, btrc_uid_t *track)
+{
+	struct hal_cmd_avrcp_register_notification *cmd;
+	size_t param_len;
+
+	param_len = sizeof(*track);
+	cmd = malloc(sizeof(*cmd) + param_len);
+	cmd->event = BTRC_EVT_TRACK_CHANGE;
+	cmd->type = type;
+	cmd->len = param_len;
+	memcpy(cmd->data, track, cmd->len);
+
+	return cmd;
+}
+
+static void *track_reached_end_rsp(btrc_notification_type_t type)
+{
+	struct hal_cmd_avrcp_register_notification *cmd;
+
+	cmd = malloc(sizeof(*cmd));
+	cmd->event = BTRC_EVT_TRACK_REACHED_END;
+	cmd->type = type;
+	cmd->len = 0;
+
+	return cmd;
+}
+
+static void *track_reached_start_rsp(btrc_notification_type_t type)
+{
+	struct hal_cmd_avrcp_register_notification *cmd;
+
+	cmd = malloc(sizeof(*cmd));
+	cmd->event = BTRC_EVT_TRACK_REACHED_START;
+	cmd->type = type;
+	cmd->len = 0;
+
+	return cmd;
+}
+
+static void *play_pos_changed_rsp(btrc_notification_type_t type,
+							uint32_t *song_pos)
+{
+	struct hal_cmd_avrcp_register_notification *cmd;
+	size_t param_len;
+
+	param_len = sizeof(*song_pos);
+	cmd = malloc(sizeof(*cmd) + param_len);
+	cmd->event = BTRC_EVT_PLAY_POS_CHANGED;
+	cmd->type = type;
+	cmd->len = param_len;
+	memcpy(cmd->data, song_pos, cmd->len);
+
+	return cmd;
+}
+
+static void *settings_changed_rsp(btrc_notification_type_t type,
+					btrc_player_settings_t *player_setting)
+{
+	struct hal_cmd_avrcp_register_notification *cmd;
+	struct hal_avrcp_player_attr_value *attrs;
+	size_t param_len;
+	int i;
+
+	param_len = player_setting->num_attr * sizeof(*attrs);
+	cmd = malloc(sizeof(*cmd) + param_len);
+	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 cmd;
+}
+
+static bt_status_t register_notification_rsp(btrc_event_id_t event_id,
+					btrc_notification_type_t type,
+					btrc_register_notification_t *p_param)
+{
+	struct hal_cmd_avrcp_register_notification *cmd;
+	bt_status_t status;
+	size_t len;
+
+	DBG("");
+
+	if (!interface_ready())
+		return BT_STATUS_NOT_READY;
+
+	switch (event_id) {
+	case BTRC_EVT_PLAY_STATUS_CHANGED:
+		cmd = play_status_changed_rsp(type, &p_param->play_status);
+		break;
+	case BTRC_EVT_TRACK_CHANGE:
+		cmd = track_change_rsp(type, &p_param->track);
+		break;
+	case BTRC_EVT_TRACK_REACHED_END:
+		cmd = track_reached_end_rsp(type);
+		break;
+	case BTRC_EVT_TRACK_REACHED_START:
+		cmd = track_reached_start_rsp(type);
+		break;
+	case BTRC_EVT_PLAY_POS_CHANGED:
+		cmd = play_pos_changed_rsp(type, &p_param->song_pos);
+		break;
+	case BTRC_EVT_APP_SETTINGS_CHANGED:
+		cmd = settings_changed_rsp(type, &p_param->player_setting);
+		break;
+	default:
+		return BT_STATUS_PARM_INVALID;
+	}
+
+	len = sizeof(*cmd) + cmd->len;
+
+	status = hal_ipc_cmd(HAL_SERVICE_ID_AVRCP,
+					HAL_OP_AVRCP_REGISTER_NOTIFICATION,
+					len, cmd, 0, NULL, NULL);
+
+	free(cmd);
+
+	return status;
+}
+
 static void cleanup()
 {
 	struct hal_cmd_unregister_module cmd;
@@ -313,6 +454,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] 14+ messages in thread

* [PATCH BlueZ 12/13] android/hal-avrcp: Add .set_volume implementation
  2014-02-18 14:24 [PATCH BlueZ 01/13] android/hal-ipc-api: Add Set Volume command Luiz Augusto von Dentz
                   ` (9 preceding siblings ...)
  2014-02-18 14:24 ` [PATCH BlueZ 11/13] android/hal-avrcp: Add .register_notification_rsp implementation Luiz Augusto von Dentz
@ 2014-02-18 14:24 ` Luiz Augusto von Dentz
  2014-02-18 14:24 ` [PATCH BlueZ 13/13] android/hal-avrcp: Add notification handlers Luiz Augusto von Dentz
  11 siblings, 0 replies; 14+ messages in thread
From: Luiz Augusto von Dentz @ 2014-02-18 14:24 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 41349f2..469de3f 100644
--- a/android/hal-avrcp.c
+++ b/android/hal-avrcp.c
@@ -424,6 +424,21 @@ static bt_status_t register_notification_rsp(btrc_event_id_t event_id,
 	return status;
 }
 
+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;
@@ -455,6 +470,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] 14+ messages in thread

* [PATCH BlueZ 13/13] android/hal-avrcp: Add notification handlers
  2014-02-18 14:24 [PATCH BlueZ 01/13] android/hal-ipc-api: Add Set Volume command Luiz Augusto von Dentz
                   ` (10 preceding siblings ...)
  2014-02-18 14:24 ` [PATCH BlueZ 12/13] android/hal-avrcp: Add .set_volume implementation Luiz Augusto von Dentz
@ 2014-02-18 14:24 ` Luiz Augusto von Dentz
  11 siblings, 0 replies; 14+ messages in thread
From: Luiz Augusto von Dentz @ 2014-02-18 14:24 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 469de3f..c08604d 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] 14+ messages in thread

* Re: [PATCH BlueZ 04/13] android/hal-avrcp: Add .list_player_app_attr_rsp implementation
  2014-02-18 14:24 ` [PATCH BlueZ 04/13] android/hal-avrcp: Add .list_player_app_attr_rsp implementation Luiz Augusto von Dentz
@ 2014-02-18 20:36   ` Szymon Janc
  0 siblings, 0 replies; 14+ messages in thread
From: Szymon Janc @ 2014-02-18 20:36 UTC (permalink / raw)
  To: Luiz Augusto von Dentz; +Cc: linux-bluetooth

Hi Luiz,

On Tuesday 18 February 2014 16:24:21 Luiz Augusto von Dentz wrote:
> From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
> 
> ---
>  android/hal-avrcp.c | 32 ++++++++++++++++++++++++++++++++
>  1 file changed, 32 insertions(+)
> 
> diff --git a/android/hal-avrcp.c b/android/hal-avrcp.c
> index 9937a11..244f77a 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,36 @@ 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)
> +{
> +	struct hal_cmd_avrcp_list_player_attrs *cmd;
> +	bt_status_t status;
> +	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;
> +	cmd = malloc(len);
> +

We should check for allocation error (highly unlikely though) here and return 
error status. Other option would be to use VLA or fixed size array for buffer.

(same goes for other HAL functions implementations in this serie)

> +	cmd->number = num_attr;
> +	memcpy(cmd->attrs, p_attrs, num_attr);
> +
> +	status =  hal_ipc_cmd(HAL_SERVICE_ID_AVRCP,
> +					HAL_OP_AVRCP_LIST_PLAYER_ATTRS,
> +					len, cmd, 0, NULL, NULL);
> +
> +	free(cmd);
> +
> +	return status;
> +}
> +
>  static void cleanup()
>  {
>  	struct hal_cmd_unregister_module cmd;
> @@ -97,6 +128,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
>  };

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

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

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

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

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).