android/avrcp-lib: Add avrcp_register_notification function
Luiz Augusto von Dentz
maintainerPATCH 1/4 android/avrcp-lib: Add avrcp_register_notification function
From: Luiz Augusto von Dentz <[email protected]>
This adds avrcp_register_notification which can be used to send RegisterNotification PDUs.
--- android/avrcp-lib.c | 15 +++++++++++++++ android/avrcp-lib.h | 3 +++ 2 files changed, 18 insertions(+)
android/avrcp-lib.c +15 -0
@@ -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) {
android/avrcp-lib.h +3 -0
@@ -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,
Signature · 1 line
1.8.5.3
Luiz Augusto von Dentz
maintainerPATCH 2/4 android/avrcp: Add support to receive volume changed notifications
From: Luiz Augusto von Dentz <[email protected]>
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(+)
android/avrcp.c +85 -0
@@ -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,
Signature · 1 line
1.8.5.3
Luiz Augusto von Dentz
maintainerPATCH 3/4 android/avrcp-lib: Add avrcp_set_volume function
In reply to Luiz Augusto von DentzFrom: Luiz Augusto von Dentz <[email protected]>
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(+)
android/avrcp-lib.c +9 -0
@@ -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)
android/avrcp-lib.h +2 -0
@@ -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,
Signature · 1 line
1.8.5.3
Luiz Augusto von Dentz
maintainerPATCH 4/4 android/avrcp: Add support to set volume command
In reply to Luiz Augusto von DentzFrom: Luiz Augusto von Dentz <[email protected]>
--- android/avrcp.c | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-)
android/avrcp.c +26 -1
@@ -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[] = {
Signature · 1 line
1.8.5.3
Hi Luiz,
Quoted 4 lines · Luiz Augusto von Dentz
From: Luiz Augusto von Dentz <[email protected]>
This adds
avrcp_register_notificationwhich 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
Quoted 52 lines
--- android/avrcp-lib.c | 15 +++++++++++++++ android/avrcp-lib.h | 3 +++ 2 files changed, 18 insertions(+)android/avrcp-lib.c +15
-0@@ -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) {android/avrcp-lib.h +3
-0@@ -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,Signature · 6 lines
1.8.5.3 -- To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Luiz Augusto von Dentz
maintainerHi Andrei,
Quoted 9 lines · Andrei Emeltchenko
Hi Luiz,
Quoted 4 lines · Luiz Augusto von Dentz
From: Luiz Augusto von Dentz <[email protected]>
This adds
avrcp_register_notificationwhich 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.
Hi Luiz,
Quoted 12 lines · Luiz Augusto von Dentz
Hi Andrei,
Quoted 8 lines · Andrei Emeltchenko
Hi Luiz,
Quoted 4 lines · Luiz Augusto von Dentz
From: Luiz Augusto von Dentz <[email protected]>
This adds
avrcp_register_notificationwhich can be used to send RegisterNotification PDUs.
Quoted 6 lines
Quoted 1 line
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
Quoted 4 lines
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.