* [PATCH BlueZ 2/4] android/avrcp: Add support to receive volume changed notifications
2014-03-07 12:15 [PATCH BlueZ 1/4] android/avrcp-lib: Add avrcp_register_notification function Luiz Augusto von Dentz
@ 2014-03-07 12:15 ` Luiz Augusto von Dentz
2014-03-07 12:15 ` [PATCH BlueZ 3/4] android/avrcp-lib: Add avrcp_set_volume function Luiz Augusto von Dentz
` (2 subsequent siblings)
3 siblings, 0 replies; 7+ messages in thread
From: Luiz Augusto von Dentz @ 2014-03-07 12:15 UTC (permalink / raw)
To: linux-bluetooth
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This checks if remote stack supports volume changed notification and
in case it does register to receive notification when volume changes.
---
android/avrcp.c | 85 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 85 insertions(+)
diff --git a/android/avrcp.c b/android/avrcp.c
index 1d211ad..978e6c0 100644
--- a/android/avrcp.c
+++ b/android/avrcp.c
@@ -700,6 +700,83 @@ static const struct avrcp_control_handler control_handlers[] = {
{ },
};
+static gboolean register_notification_rsp(struct avctp *conn,
+ uint8_t code, uint8_t subunit,
+ uint8_t *operands, size_t operand_count,
+ void *user_data)
+{
+ struct avrcp_device *dev = user_data;
+ struct hal_ev_avrcp_volume_changed ev;
+ uint8_t *params;
+
+ if (code != AVC_CTYPE_INTERIM && code != AVC_CTYPE_CHANGED)
+ return FALSE;
+
+ if (operands == NULL || operand_count < 7)
+ return FALSE;
+
+ params = &operands[7];
+
+ if (params == NULL || params[0] != AVRCP_EVENT_VOLUME_CHANGED)
+ return FALSE;
+
+ switch (code) {
+ case AVC_CTYPE_INTERIM:
+ ev.type = HAL_AVRCP_EVENT_TYPE_INTERIM;
+ break;
+ case AVC_CTYPE_CHANGED:
+ ev.type = HAL_AVRCP_EVENT_TYPE_CHANGED;
+ break;
+ default:
+ return FALSE;
+ }
+
+ ev.volume = params[1] & 0x7F;
+
+ ipc_send_notif(hal_ipc, HAL_SERVICE_ID_AVRCP,
+ HAL_EV_AVRCP_VOLUME_CHANGED,
+ sizeof(ev), &ev);
+
+ if (code == AVC_CTYPE_INTERIM)
+ return TRUE;
+
+ avrcp_register_notification(dev->session, params[0], 0,
+ register_notification_rsp, dev);
+ return FALSE;
+}
+
+static gboolean get_capabilities_rsp(struct avctp *conn,
+ uint8_t code, uint8_t subunit,
+ uint8_t *operands, size_t operand_count,
+ void *user_data)
+{
+ struct avrcp_device *dev = user_data;
+ uint8_t *params;
+ uint8_t count;
+
+ if (operands == NULL || operand_count < 7)
+ return FALSE;
+
+ params = &operands[7];
+
+ if (params == NULL || params[0] != CAP_EVENTS_SUPPORTED)
+ return FALSE;
+
+ for (count = params[1]; count > 0; count--) {
+ uint8_t event = params[1 + count];
+
+ if (event != AVRCP_EVENT_VOLUME_CHANGED)
+ continue;
+
+ avrcp_register_notification(dev->session, event, 0,
+ register_notification_rsp,
+ dev);
+ return FALSE;
+ }
+
+ return FALSE;
+}
+
static int avrcp_device_add_session(struct avrcp_device *dev, int fd,
uint16_t imtu, uint16_t omtu)
{
@@ -732,6 +809,14 @@ static int avrcp_device_add_session(struct avrcp_device *dev, int fd,
ev.features |= HAL_AVRCP_FEATURE_METADATA;
+ if (dev->version < 0x0104)
+ goto done;
+
+ ev.features |= HAL_AVRCP_FEATURE_ABSOLUTE_VOLUME;
+
+ avrcp_get_capabilities(dev->session, CAP_EVENTS_SUPPORTED,
+ get_capabilities_rsp, dev);
+
done:
ipc_send_notif(hal_ipc, HAL_SERVICE_ID_AVRCP,
HAL_EV_AVRCP_REMOTE_FEATURES,
--
1.8.5.3
^ permalink raw reply related [flat|nested] 7+ messages in thread* [PATCH BlueZ 3/4] android/avrcp-lib: Add avrcp_set_volume function
2014-03-07 12:15 [PATCH BlueZ 1/4] android/avrcp-lib: Add avrcp_register_notification function Luiz Augusto von Dentz
2014-03-07 12:15 ` [PATCH BlueZ 2/4] android/avrcp: Add support to receive volume changed notifications Luiz Augusto von Dentz
@ 2014-03-07 12:15 ` Luiz Augusto von Dentz
2014-03-07 12:15 ` [PATCH BlueZ 4/4] android/avrcp: Add support to set volume command Luiz Augusto von Dentz
2014-03-07 12:22 ` [PATCH BlueZ 1/4] android/avrcp-lib: Add avrcp_register_notification function Andrei Emeltchenko
3 siblings, 0 replies; 7+ messages in thread
From: Luiz Augusto von Dentz @ 2014-03-07 12:15 UTC (permalink / raw)
To: linux-bluetooth
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This adds avrcp_set_volume function which can be used to send
SetAbsoluteVolume PDUs.
---
android/avrcp-lib.c | 9 +++++++++
android/avrcp-lib.h | 2 ++
2 files changed, 11 insertions(+)
diff --git a/android/avrcp-lib.c b/android/avrcp-lib.c
index a5530ec..bd1e7da 100644
--- a/android/avrcp-lib.c
+++ b/android/avrcp-lib.c
@@ -416,6 +416,15 @@ int avrcp_get_play_status(struct avrcp *session, avctp_rsp_cb func,
user_data);
}
+int avrcp_set_volume(struct avrcp *session, uint8_t volume, avctp_rsp_cb func,
+ void *user_data)
+{
+ return avrcp_send_req(session, AVC_CTYPE_CONTROL, AVC_SUBUNIT_PANEL,
+ AVRCP_SET_ABSOLUTE_VOLUME,
+ &volume, sizeof(volume),
+ func, user_data);
+}
+
int avrcp_get_play_status_rsp(struct avrcp *session, uint8_t transaction,
uint32_t position, uint32_t duration,
uint8_t status)
diff --git a/android/avrcp-lib.h b/android/avrcp-lib.h
index 4a49fe7..30d220e 100644
--- a/android/avrcp-lib.h
+++ b/android/avrcp-lib.h
@@ -148,6 +148,8 @@ int avrcp_get_current_player_value(struct avrcp *session, uint8_t *attrs,
void *user_data);
int avrcp_get_play_status(struct avrcp *session, avctp_rsp_cb func,
void *user_data);
+int avrcp_set_volume(struct avrcp *session, uint8_t volume, avctp_rsp_cb func,
+ void *user_data);
int avrcp_get_play_status_rsp(struct avrcp *session, uint8_t transaction,
uint32_t position, uint32_t duration,
--
1.8.5.3
^ permalink raw reply related [flat|nested] 7+ messages in thread* [PATCH BlueZ 4/4] android/avrcp: Add support to set volume command
2014-03-07 12:15 [PATCH BlueZ 1/4] android/avrcp-lib: Add avrcp_register_notification function Luiz Augusto von Dentz
2014-03-07 12:15 ` [PATCH BlueZ 2/4] android/avrcp: Add support to receive volume changed notifications Luiz Augusto von Dentz
2014-03-07 12:15 ` [PATCH BlueZ 3/4] android/avrcp-lib: Add avrcp_set_volume function Luiz Augusto von Dentz
@ 2014-03-07 12:15 ` Luiz Augusto von Dentz
2014-03-07 12:22 ` [PATCH BlueZ 1/4] android/avrcp-lib: Add avrcp_register_notification function Andrei Emeltchenko
3 siblings, 0 replies; 7+ messages in thread
From: Luiz Augusto von Dentz @ 2014-03-07 12:15 UTC (permalink / raw)
To: linux-bluetooth
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
---
android/avrcp.c | 27 ++++++++++++++++++++++++++-
1 file changed, 26 insertions(+), 1 deletion(-)
diff --git a/android/avrcp.c b/android/avrcp.c
index 978e6c0..11a2614 100644
--- a/android/avrcp.c
+++ b/android/avrcp.c
@@ -332,10 +332,35 @@ done:
static void handle_set_volume(const void *buf, uint16_t len)
{
+ struct hal_cmd_avrcp_set_volume *cmd = (void *) buf;
+ struct avrcp_device *dev;
+ uint8_t status;
+ int ret;
+
DBG("");
+ if (!devices) {
+ error("AVRCP: No device found to set volume");
+ status = HAL_STATUS_FAILED;
+ goto done;
+ }
+
+ /* Peek the first device since the HAL cannot really address a specific
+ * device it might mean there could only be one connected.
+ */
+ dev = devices->data;
+
+ ret = avrcp_set_volume(dev->session, cmd->value & 0x7f, NULL, NULL);
+ if (ret < 0) {
+ status = HAL_STATUS_FAILED;
+ goto done;
+ }
+
+ status = HAL_STATUS_SUCCESS;
+
+done:
ipc_send_rsp(hal_ipc, HAL_SERVICE_ID_AVRCP, HAL_OP_AVRCP_SET_VOLUME,
- HAL_STATUS_FAILED);
+ status);
}
static const struct ipc_handler cmd_handlers[] = {
--
1.8.5.3
^ permalink raw reply related [flat|nested] 7+ messages in thread* Re: [PATCH BlueZ 1/4] android/avrcp-lib: Add avrcp_register_notification function
2014-03-07 12:15 [PATCH BlueZ 1/4] android/avrcp-lib: Add avrcp_register_notification function Luiz Augusto von Dentz
` (2 preceding siblings ...)
2014-03-07 12:15 ` [PATCH BlueZ 4/4] android/avrcp: Add support to set volume command Luiz Augusto von Dentz
@ 2014-03-07 12:22 ` Andrei Emeltchenko
2014-03-07 13:00 ` Luiz Augusto von Dentz
3 siblings, 1 reply; 7+ messages in thread
From: Andrei Emeltchenko @ 2014-03-07 12:22 UTC (permalink / raw)
To: Luiz Augusto von Dentz; +Cc: linux-bluetooth
Hi Luiz,
On Fri, Mar 07, 2014 at 02:15:40PM +0200, Luiz Augusto von Dentz wrote:
> From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
>
> This adds avrcp_register_notification which can be used to send
> RegisterNotification PDUs.
Didn't I sent the same patch already? Why are we redoing the same work?
Best regards
Andrei Emeltchenko
> ---
> android/avrcp-lib.c | 15 +++++++++++++++
> android/avrcp-lib.h | 3 +++
> 2 files changed, 18 insertions(+)
>
> diff --git a/android/avrcp-lib.c b/android/avrcp-lib.c
> index d66560b..a5530ec 100644
> --- a/android/avrcp-lib.c
> +++ b/android/avrcp-lib.c
> @@ -334,6 +334,21 @@ int avrcp_get_capabilities(struct avrcp *session, uint8_t param,
> func, user_data);
> }
>
> +int avrcp_register_notification(struct avrcp *session, uint8_t event,
> + uint32_t interval, avctp_rsp_cb func,
> + void *user_data)
> +{
> + uint8_t params[5];
> +
> + params[0] = event;
> + bt_put_be32(interval, ¶ms[1]);
> +
> + return avrcp_send_req(session, AVC_CTYPE_NOTIFY, AVC_SUBUNIT_PANEL,
> + AVRCP_REGISTER_NOTIFICATION,
> + params, sizeof(params),
> + func, user_data);
> +}
> +
> int avrcp_list_player_attributes(struct avrcp *session, avctp_rsp_cb func,
> void *user_data)
> {
> diff --git a/android/avrcp-lib.h b/android/avrcp-lib.h
> index ba1d84a..4a49fe7 100644
> --- a/android/avrcp-lib.h
> +++ b/android/avrcp-lib.h
> @@ -132,6 +132,9 @@ int avrcp_send(struct avrcp *session, uint8_t transaction, uint8_t code,
> uint8_t *params, size_t params_len);
> int avrcp_get_capabilities(struct avrcp *session, uint8_t param,
> avctp_rsp_cb func, void *user_data);
> +int avrcp_register_notification(struct avrcp *session, uint8_t event,
> + uint32_t interval, avctp_rsp_cb func,
> + void *user_data);
> int avrcp_list_player_attributes(struct avrcp *session, avctp_rsp_cb func,
> void *user_data);
> int avrcp_get_player_attribute_text(struct avrcp *session, uint8_t *attributes,
> --
> 1.8.5.3
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 7+ messages in thread* Re: [PATCH BlueZ 1/4] android/avrcp-lib: Add avrcp_register_notification function
2014-03-07 12:22 ` [PATCH BlueZ 1/4] android/avrcp-lib: Add avrcp_register_notification function Andrei Emeltchenko
@ 2014-03-07 13:00 ` Luiz Augusto von Dentz
2014-03-07 13:09 ` Andrei Emeltchenko
0 siblings, 1 reply; 7+ messages in thread
From: Luiz Augusto von Dentz @ 2014-03-07 13:00 UTC (permalink / raw)
To: Andrei Emeltchenko, Luiz Augusto von Dentz,
linux-bluetooth@vger.kernel.org
Hi Andrei,
On Fri, Mar 7, 2014 at 2:22 PM, Andrei Emeltchenko
<andrei.emeltchenko.news@gmail.com> wrote:
> Hi Luiz,
>
> On Fri, Mar 07, 2014 at 02:15:40PM +0200, Luiz Augusto von Dentz wrote:
>> From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
>>
>> This adds avrcp_register_notification which can be used to send
>> RegisterNotification PDUs.
>
> Didn't I sent the same patch already? Why are we redoing the same work?
Im implementing the daemon side, this is the problem of sending big
patch sets it takes more time and I want to finish the AVRCP quickly
so we can have it tested. Btw, Im not sure why you are still defining
the PDU length public, this should probably be keep private until we
have proper struct defined, in fact I did mention that we might change
the way the handlers works in avrcp-lib to incorporate more logic and
do things like header checks that the unit test has been doing.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH BlueZ 1/4] android/avrcp-lib: Add avrcp_register_notification function
2014-03-07 13:00 ` Luiz Augusto von Dentz
@ 2014-03-07 13:09 ` Andrei Emeltchenko
0 siblings, 0 replies; 7+ messages in thread
From: Andrei Emeltchenko @ 2014-03-07 13:09 UTC (permalink / raw)
To: Luiz Augusto von Dentz; +Cc: linux-bluetooth@vger.kernel.org
Hi Luiz,
On Fri, Mar 07, 2014 at 03:00:30PM +0200, Luiz Augusto von Dentz wrote:
> Hi Andrei,
>
> On Fri, Mar 7, 2014 at 2:22 PM, Andrei Emeltchenko
> <andrei.emeltchenko.news@gmail.com> wrote:
> > Hi Luiz,
> >
> > On Fri, Mar 07, 2014 at 02:15:40PM +0200, Luiz Augusto von Dentz wrote:
> >> From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
> >>
> >> This adds avrcp_register_notification which can be used to send
> >> RegisterNotification PDUs.
> >
> > Didn't I sent the same patch already? Why are we redoing the same work?
>
> Im implementing the daemon side, this is the problem of sending big
> patch sets it takes more time and I want to finish the AVRCP quickly
> so we can have it tested. Btw, Im not sure why you are still defining
> the PDU length public,
The pdu lengths might be used in unit tests and avrcp-lib.
Best regards
Andrei Emeltchenko
> this should probably be keep private until we
> have proper struct defined, in fact I did mention that we might change
> the way the handlers works in avrcp-lib to incorporate more logic and
> do things like header checks that the unit test has been doing.
^ permalink raw reply [flat|nested] 7+ messages in thread