16b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta/* 26b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta * Copyright (C) 2015 The Android Open Source Project 35738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project * 46b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta * Licensed under the Apache License, Version 2.0 (the "License"); 56b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta * you may not use this file except in compliance with the License. 66b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta * You may obtain a copy of the License at 75738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project * 86b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta * http://www.apache.org/licenses/LICENSE-2.0 95738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project * 106b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta * Unless required by applicable law or agreed to in writing, software 116b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta * distributed under the License is distributed on an "AS IS" BASIS, 126b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 136b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta * See the License for the specific language governing permissions and 146b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta * limitations under the License. 156b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta */ 165738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 175738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/***************************************************************************** 185738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project * 195738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project * Filename: btif_rc.c 205738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project * 215738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project * Description: Bluetooth AVRC implementation 225738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project * 235738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project *****************************************************************************/ 2449a86709488e5cfd5e23759da18bf9613e15b04dMarie Janssen 2549a86709488e5cfd5e23759da18bf9613e15b04dMarie Janssen#define LOG_TAG "bt_btif_avrc" 2649a86709488e5cfd5e23759da18bf9613e15b04dMarie Janssen 27642f233005cdcbbbcb92b77d6297fc080b7f072ePavlin Radoslavov#include <errno.h> 285738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#include <fcntl.h> 29d30195cbf09735da593e186c4c99cce6232b072eArman Uguray#include <pthread.h> 30c7503db23f91676b2df732becb9579d5ccdcc7a7Ian Coolidge#include <string.h> 31642f233005cdcbbbcb92b77d6297fc080b7f072ePavlin Radoslavov#include <time.h> 32d30195cbf09735da593e186c4c99cce6232b072eArman Uguray#include <unistd.h> 33d30195cbf09735da593e186c4c99cce6232b072eArman Uguray 3449a86709488e5cfd5e23759da18bf9613e15b04dMarie Janssen#include <hardware/bluetooth.h> 3549a86709488e5cfd5e23759da18bf9613e15b04dMarie Janssen#include <hardware/bt_rc.h> 3649a86709488e5cfd5e23759da18bf9613e15b04dMarie Janssen 3749a86709488e5cfd5e23759da18bf9613e15b04dMarie Janssen#include "avrc_defs.h" 385738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#include "bta_api.h" 395738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#include "bta_av_api.h" 4049a86709488e5cfd5e23759da18bf9613e15b04dMarie Janssen#include "btif_av.h" 415738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#include "btif_common.h" 429adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan#include "btif_util.h" 43258c2538e3b62a8cdb403f2730c45d721e5292b4Pavlin Radoslavov#include "bt_common.h" 44d0aa6cc53abaf122a2426c20691ccfa025ca7369Andre Eisenbach#include "device/include/interop.h" 459adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan#include "uinput.h" 4669682acf0149e9e51cda5b8747866ca9dc37b907Ayan Ghosh#include "bdaddr.h" 476b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta#include "osi/include/list.h" 482998946db9b820806d4a3e6decf1d01f090a8031Jakub Pawlowski#include "osi/include/properties.h" 496b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta#include "btu.h" 506b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta#define RC_INVALID_TRACK_ID (0xFFFFFFFFFFFFFFFFULL) 5169682acf0149e9e51cda5b8747866ca9dc37b907Ayan Ghosh 525738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/***************************************************************************** 535738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Constants & Macros 545738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project******************************************************************************/ 555738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 565738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/* cod value for Headsets */ 575738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#define COD_AV_HEADSETS 0x0404 589adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan/* for AVRC 1.4 need to change this */ 596b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta#define MAX_RC_NOTIFICATIONS AVRC_EVT_VOLUME_CHANGE 609adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan 619adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan#define IDX_GET_PLAY_STATUS_RSP 0 629adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan#define IDX_LIST_APP_ATTR_RSP 1 639adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan#define IDX_LIST_APP_VALUE_RSP 2 649adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan#define IDX_GET_CURR_APP_VAL_RSP 3 659adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan#define IDX_SET_APP_VAL_RSP 4 669adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan#define IDX_GET_APP_ATTR_TXT_RSP 5 679adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan#define IDX_GET_APP_VAL_TXT_RSP 6 689adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan#define IDX_GET_ELEMENT_ATTR_RSP 7 69247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji#define MAX_VOLUME 128 70247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji#define MAX_LABEL 16 71247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji#define MAX_TRANSACTIONS_PER_SESSION 16 729adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan#define MAX_CMD_QUEUE_LEN 8 739c5d0727dd4cd09e44c032506c28ab4120ad3b88Anubhav Gupta#define PLAY_STATUS_PLAYING 1 749adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan 759adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan#define CHECK_RC_CONNECTED \ 76e8c3d75b75493911ebf0f99c83676359657178f7Sharvil Nanavati BTIF_TRACE_DEBUG("## %s ##", __FUNCTION__); \ 776b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta if (btif_rc_cb.rc_connected == FALSE) \ 789adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan { \ 79e8c3d75b75493911ebf0f99c83676359657178f7Sharvil Nanavati BTIF_TRACE_WARNING("Function %s() called when RC is not connected", __FUNCTION__); \ 809adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan return BT_STATUS_NOT_READY; \ 819adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan } 829adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan 839adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan#define FILL_PDU_QUEUE(index, ctype, label, pending) \ 849adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan{ \ 859adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan btif_rc_cb.rc_pdu_info[index].ctype = ctype; \ 869adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan btif_rc_cb.rc_pdu_info[index].label = label; \ 879adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan btif_rc_cb.rc_pdu_info[index].is_rsp_pending = pending; \ 889adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan} 899adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan 909adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan#define SEND_METAMSG_RSP(index, avrc_rsp) \ 919adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan{ \ 926b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta if (btif_rc_cb.rc_pdu_info[index].is_rsp_pending == FALSE) \ 939adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan { \ 94e8c3d75b75493911ebf0f99c83676359657178f7Sharvil Nanavati BTIF_TRACE_WARNING("%s Not sending response as no PDU was registered", __FUNCTION__); \ 959adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan return BT_STATUS_UNHANDLED; \ 969adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan } \ 979adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan send_metamsg_rsp(btif_rc_cb.rc_handle, btif_rc_cb.rc_pdu_info[index].label, \ 989adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan btif_rc_cb.rc_pdu_info[index].ctype, avrc_rsp); \ 999adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan btif_rc_cb.rc_pdu_info[index].ctype = 0; \ 1009adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan btif_rc_cb.rc_pdu_info[index].label = 0; \ 1019adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan btif_rc_cb.rc_pdu_info[index].is_rsp_pending = FALSE; \ 1029adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan} 1035738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 1045738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/***************************************************************************** 1055738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Local type definitions 1065738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project******************************************************************************/ 1075738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projecttypedef struct { 1089adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan UINT8 bNotify; 1099adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan UINT8 label; 1109adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan} btif_rc_reg_notifications_t; 1119adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan 1129adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajantypedef struct 1139adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan{ 1149adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan UINT8 label; 1159adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan UINT8 ctype; 1169adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan BOOLEAN is_rsp_pending; 1179adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan} btif_rc_cmd_ctxt_t; 1189adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan 1196b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta/* 2 second timeout to get interim response */ 12078bcff79e1b1f0efce436b33bdd6da88745bfc8aPavlin Radoslavov#define BTIF_TIMEOUT_RC_INTERIM_RSP_MS (2 * 1000) 12178bcff79e1b1f0efce436b33bdd6da88745bfc8aPavlin Radoslavov#define BTIF_TIMEOUT_RC_STATUS_CMD_MS (2 * 1000) 12278bcff79e1b1f0efce436b33bdd6da88745bfc8aPavlin Radoslavov#define BTIF_TIMEOUT_RC_CONTROL_CMD_MS (2 * 1000) 1236b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta 1246b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta 1256b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Guptatypedef enum 1266b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta{ 1276b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta eNOT_REGISTERED, 1286b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta eREGISTERED, 1296b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta eINTERIM 1306b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta} btif_rc_nfn_reg_status_t; 1316b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta 1326b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Guptatypedef struct { 1336b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta UINT8 event_id; 1346b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta UINT8 label; 1356b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta btif_rc_nfn_reg_status_t status; 1366b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta} btif_rc_supported_event_t; 1376b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta 1386b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta#define BTIF_RC_STS_TIMEOUT 0xFE 1396b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Guptatypedef struct { 1406b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta UINT8 label; 1416b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta UINT8 pdu_id; 1426b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta} btif_rc_status_cmd_timer_t; 1436b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta 1446b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Guptatypedef struct { 1456b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta UINT8 label; 1466b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta UINT8 pdu_id; 1476b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta} btif_rc_control_cmd_timer_t; 1486b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta 1496b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Guptatypedef struct { 1506b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta union { 1516b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta btif_rc_status_cmd_timer_t rc_status_cmd; 1526b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta btif_rc_control_cmd_timer_t rc_control_cmd; 1536b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta }; 1546b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta} btif_rc_timer_context_t; 1556b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta 1566b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Guptatypedef struct { 1576b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta BOOLEAN query_started; 1586b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta UINT8 num_attrs; 1596b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta UINT8 num_ext_attrs; 1606b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta 1616b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta UINT8 attr_index; 1626b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta UINT8 ext_attr_index; 1636b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta UINT8 ext_val_index; 1646b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta btrc_player_app_attr_t attrs[AVRC_MAX_APP_ATTR_SIZE]; 1656b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta btrc_player_app_ext_attr_t ext_attrs[AVRC_MAX_APP_ATTR_SIZE]; 1666b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta} btif_rc_player_app_settings_t; 1676b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta 1689adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan/* TODO : Merge btif_rc_reg_notifications_t and btif_rc_cmd_ctxt_t to a single struct */ 1699adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajantypedef struct { 1705738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project BOOLEAN rc_connected; 1715738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project UINT8 rc_handle; 1729adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan tBTA_AV_FEAT rc_features; 1735738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project BD_ADDR rc_addr; 1745738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project UINT16 rc_pending_play; 1759adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan btif_rc_cmd_ctxt_t rc_pdu_info[MAX_CMD_QUEUE_LEN]; 1769adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan btif_rc_reg_notifications_t rc_notif[MAX_RC_NOTIFICATIONS]; 177247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji unsigned int rc_volume; 178247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji uint8_t rc_vol_label; 1796b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta list_t *rc_supported_event_list; 1806b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta btif_rc_player_app_settings_t rc_app_settings; 18178bcff79e1b1f0efce436b33bdd6da88745bfc8aPavlin Radoslavov alarm_t *rc_play_status_timer; 1826b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta BOOLEAN rc_features_processed; 1836b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta UINT64 rc_playing_uid; 1846b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta BOOLEAN rc_procedure_complete; 1855738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project} btif_rc_cb_t; 1865738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 187247c68fe6eee3660cbdcf4509195fe735ae25573Satya Callojitypedef struct { 188247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji BOOLEAN in_use; 189247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji UINT8 lbl; 190247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji UINT8 handle; 19178bcff79e1b1f0efce436b33bdd6da88745bfc8aPavlin Radoslavov btif_rc_timer_context_t txn_timer_context; 19278bcff79e1b1f0efce436b33bdd6da88745bfc8aPavlin Radoslavov alarm_t *txn_timer; 193247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji} rc_transaction_t; 194247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji 195247c68fe6eee3660cbdcf4509195fe735ae25573Satya Callojitypedef struct 196247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji{ 197247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji pthread_mutex_t lbllock; 198247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji rc_transaction_t transaction[MAX_TRANSACTIONS_PER_SESSION]; 199247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji} rc_device_t; 200247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji 201247c68fe6eee3660cbdcf4509195fe735ae25573Satya Callojirc_device_t device; 202247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji 2035738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#define MAX_UINPUT_PATHS 3 2045738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectstatic const char* uinput_dev_path[] = 2055738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project {"/dev/uinput", "/dev/input/uinput", "/dev/misc/uinput" }; 2065738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectstatic int uinput_fd = -1; 2075738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 2085738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectstatic int send_event (int fd, uint16_t type, uint16_t code, int32_t value); 2095738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectstatic void send_key (int fd, uint16_t key, int pressed); 2105738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectstatic int uinput_driver_check(); 2115738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectstatic int uinput_create(char *name); 2125738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectstatic int init_uinput (void); 2135738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectstatic void close_uinput (void); 21478bcff79e1b1f0efce436b33bdd6da88745bfc8aPavlin Radoslavovstatic void sleep_ms(period_ms_t timeout_ms); 2155738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 2169adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajanstatic const struct { 2175738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project const char *name; 2185738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project uint8_t avrcp; 2195738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project uint16_t mapped_id; 2205738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project uint8_t release_quirk; 2215738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project} key_map[] = { 2225738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { "PLAY", AVRC_ID_PLAY, KEY_PLAYCD, 1 }, 2235738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { "STOP", AVRC_ID_STOP, KEY_STOPCD, 0 }, 2245738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { "PAUSE", AVRC_ID_PAUSE, KEY_PAUSECD, 1 }, 2255738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { "FORWARD", AVRC_ID_FORWARD, KEY_NEXTSONG, 0 }, 2265738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { "BACKWARD", AVRC_ID_BACKWARD, KEY_PREVIOUSSONG, 0 }, 2275738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { "REWIND", AVRC_ID_REWIND, KEY_REWIND, 0 }, 22898497a520010fc996a8ce490665cac6c1439dd2dJohn Du { "FAST FORWARD", AVRC_ID_FAST_FOR, KEY_FAST_FORWARD, 0 }, 2295738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { NULL, 0, 0, 0 } 2305738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project}; 2315738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 2329adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajanstatic void send_reject_response (UINT8 rc_handle, UINT8 label, 2339adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan UINT8 pdu, UINT8 status); 2349adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajanstatic UINT8 opcode_from_pdu(UINT8 pdu); 2359adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajanstatic void send_metamsg_rsp (UINT8 rc_handle, UINT8 label, 2369adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan tBTA_AV_CODE code, tAVRC_RESPONSE *pmetamsg_resp); 237a5090f2c33919f57c82107ec62ce5ec5705e7e21Prashant Malani#if (AVRC_ADV_CTRL_INCLUDED == TRUE) 238247c68fe6eee3660cbdcf4509195fe735ae25573Satya Callojistatic void register_volumechange(UINT8 label); 239a5090f2c33919f57c82107ec62ce5ec5705e7e21Prashant Malani#endif 240247c68fe6eee3660cbdcf4509195fe735ae25573Satya Callojistatic void lbl_init(); 241247c68fe6eee3660cbdcf4509195fe735ae25573Satya Callojistatic void lbl_destroy(); 242247c68fe6eee3660cbdcf4509195fe735ae25573Satya Callojistatic void init_all_transactions(); 243247c68fe6eee3660cbdcf4509195fe735ae25573Satya Callojistatic bt_status_t get_transaction(rc_transaction_t **ptransaction); 244247c68fe6eee3660cbdcf4509195fe735ae25573Satya Callojistatic void release_transaction(UINT8 label); 245247c68fe6eee3660cbdcf4509195fe735ae25573Satya Callojistatic rc_transaction_t* get_transaction_by_lbl(UINT8 label); 246a5090f2c33919f57c82107ec62ce5ec5705e7e21Prashant Malani#if (AVRC_ADV_CTRL_INCLUDED == TRUE) 247247c68fe6eee3660cbdcf4509195fe735ae25573Satya Callojistatic void handle_rc_metamsg_rsp(tBTA_AV_META_MSG *pmeta_msg); 248a5090f2c33919f57c82107ec62ce5ec5705e7e21Prashant Malani#endif 2496b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta#if (AVRC_CTLR_INCLUDED == TRUE) 2506b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Guptastatic void handle_avk_rc_metamsg_cmd(tBTA_AV_META_MSG *pmeta_msg); 2516b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Guptastatic void handle_avk_rc_metamsg_rsp(tBTA_AV_META_MSG *pmeta_msg); 2526b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Guptastatic void btif_rc_ctrl_upstreams_rsp_cmd( 2536b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta UINT8 event, tAVRC_COMMAND *pavrc_cmd, UINT8 label); 2546b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Guptastatic void rc_ctrl_procedure_complete(); 25578bcff79e1b1f0efce436b33bdd6da88745bfc8aPavlin Radoslavovstatic void rc_stop_play_status_timer(); 2566b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Guptastatic void register_for_event_notification (btif_rc_supported_event_t *p_event); 2576b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Guptastatic void handle_get_capability_response (tBTA_AV_META_MSG *pmeta_msg, tAVRC_GET_CAPS_RSP *p_rsp); 2586b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Guptastatic void handle_app_attr_response (tBTA_AV_META_MSG *pmeta_msg, tAVRC_LIST_APP_ATTR_RSP *p_rsp); 2596b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Guptastatic void handle_app_val_response (tBTA_AV_META_MSG *pmeta_msg, tAVRC_LIST_APP_VALUES_RSP *p_rsp); 2606b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Guptastatic void handle_app_cur_val_response (tBTA_AV_META_MSG *pmeta_msg, tAVRC_GET_CUR_APP_VALUE_RSP *p_rsp); 2616b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Guptastatic void handle_app_attr_txt_response (tBTA_AV_META_MSG *pmeta_msg, tAVRC_GET_APP_ATTR_TXT_RSP *p_rsp); 2626b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Guptastatic void handle_app_attr_val_txt_response (tBTA_AV_META_MSG *pmeta_msg, tAVRC_GET_APP_ATTR_TXT_RSP *p_rsp); 2636b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Guptastatic void handle_get_playstatus_response (tBTA_AV_META_MSG *pmeta_msg, tAVRC_GET_PLAY_STATUS_RSP *p_rsp); 2646b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Guptastatic void handle_get_elem_attr_response (tBTA_AV_META_MSG *pmeta_msg, tAVRC_GET_ELEM_ATTRS_RSP *p_rsp); 2656b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Guptastatic void handle_set_app_attr_val_response (tBTA_AV_META_MSG *pmeta_msg, tAVRC_RSP *p_rsp); 2666b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Guptastatic bt_status_t get_play_status_cmd(void); 2676b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Guptastatic bt_status_t get_player_app_setting_attr_text_cmd (UINT8 *attrs, UINT8 num_attrs); 2686b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Guptastatic bt_status_t get_player_app_setting_value_text_cmd (UINT8 *vals, UINT8 num_vals); 2696b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Guptastatic bt_status_t register_notification_cmd (UINT8 label, UINT8 event_id, UINT32 event_value); 2706b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Guptastatic bt_status_t get_element_attribute_cmd (uint8_t num_attribute, uint32_t *p_attr_ids); 2716b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Guptastatic bt_status_t getcapabilities_cmd (uint8_t cap_id); 2726b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Guptastatic bt_status_t list_player_app_setting_attrib_cmd(void); 2736b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Guptastatic bt_status_t list_player_app_setting_value_cmd(uint8_t attrib_id); 2746b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Guptastatic bt_status_t get_player_app_setting_cmd(uint8_t num_attrib, uint8_t* attrib_ids); 2756b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta#endif 2769adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajanstatic void btif_rc_upstreams_evt(UINT16 event, tAVRC_COMMAND* p_param, UINT8 ctype, UINT8 label); 277a5090f2c33919f57c82107ec62ce5ec5705e7e21Prashant Malani#if (AVRC_ADV_CTRL_INCLUDED == TRUE) 278247c68fe6eee3660cbdcf4509195fe735ae25573Satya Callojistatic void btif_rc_upstreams_rsp_evt(UINT16 event, tAVRC_RESPONSE *pavrc_resp, UINT8 ctype, UINT8 label); 279a5090f2c33919f57c82107ec62ce5ec5705e7e21Prashant Malani#endif 28078bcff79e1b1f0efce436b33bdd6da88745bfc8aPavlin Radoslavovstatic void rc_start_play_status_timer(void); 28190b71eac9b45f90ff3267fa0a400cc1daaec88d4Andre Eisenbachstatic bool absolute_volume_disabled(void); 282ecfeff6782aeb61adfaf19f70e6a55ff97c3a9d6Ajay Panickerstatic char const* key_id_to_str(uint16_t id); 2835738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 2845738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/***************************************************************************** 2855738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Static variables 2865738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project******************************************************************************/ 2875738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectstatic btif_rc_cb_t btif_rc_cb; 2889adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajanstatic btrc_callbacks_t *bt_rc_callbacks = NULL; 2894ad470e33021be4246ae539e1bcb7a346dbb4405Mike Lockwoodstatic btrc_ctrl_callbacks_t *bt_rc_ctrl_callbacks = NULL; 2905738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 2915738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/***************************************************************************** 2925738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Static functions 2935738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project******************************************************************************/ 2945738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 2955738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/***************************************************************************** 2965738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Externs 2975738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project******************************************************************************/ 2985738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectextern BOOLEAN btif_hf_call_terminated_recently(); 2995738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectextern BOOLEAN check_cod(const bt_bdaddr_t *remote_bdaddr, uint32_t cod); 3009adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan 30178bcff79e1b1f0efce436b33bdd6da88745bfc8aPavlin Radoslavovextern fixed_queue_t *btu_general_alarm_queue; 30278bcff79e1b1f0efce436b33bdd6da88745bfc8aPavlin Radoslavov 3035738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/***************************************************************************** 3045738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Functions 3055738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project******************************************************************************/ 3065738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 3075738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/***************************************************************************** 3085738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Local uinput helper functions 3095738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project******************************************************************************/ 3105738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectint send_event (int fd, uint16_t type, uint16_t code, int32_t value) 3115738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project{ 3125738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project struct uinput_event event; 313e8c3d75b75493911ebf0f99c83676359657178f7Sharvil Nanavati BTIF_TRACE_DEBUG("%s type:%u code:%u value:%d", __FUNCTION__, 3149adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan type, code, value); 3155738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project memset(&event, 0, sizeof(event)); 3165738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project event.type = type; 3175738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project event.code = code; 3185738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project event.value = value; 3195738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 320574dcfb73e3741d715f7d4394fe5d3bd587cb0d2Pavlin Radoslavov ssize_t ret; 321574dcfb73e3741d715f7d4394fe5d3bd587cb0d2Pavlin Radoslavov OSI_NO_INTR(ret = write(fd, &event, sizeof(event))); 322574dcfb73e3741d715f7d4394fe5d3bd587cb0d2Pavlin Radoslavov return (int)ret; 3235738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project} 3245738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 3255738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectvoid send_key (int fd, uint16_t key, int pressed) 3265738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project{ 327e8c3d75b75493911ebf0f99c83676359657178f7Sharvil Nanavati BTIF_TRACE_DEBUG("%s fd:%d key:%u pressed:%d", __FUNCTION__, 3289adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan fd, key, pressed); 3299adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan 3309adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan if (fd < 0) 3319adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan { 3325738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project return; 3335738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 3345738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 335ecfeff6782aeb61adfaf19f70e6a55ff97c3a9d6Ajay Panicker LOG_INFO(LOG_TAG, "AVRCP: Send key %s (%d) fd=%d", key_id_to_str(key), pressed, fd); 3365738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project send_event(fd, EV_KEY, key, pressed); 3375738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project send_event(fd, EV_SYN, SYN_REPORT, 0); 3385738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project} 3395738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 3405738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/************** uinput related functions **************/ 3415738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectint uinput_driver_check() 3425738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project{ 3435738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project uint32_t i; 3445738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project for (i=0; i < MAX_UINPUT_PATHS; i++) 3455738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 3465738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if (access(uinput_dev_path[i], O_RDWR) == 0) { 3475738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project return 0; 3485738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 3495738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 350e8c3d75b75493911ebf0f99c83676359657178f7Sharvil Nanavati BTIF_TRACE_ERROR("%s ERROR: uinput device is not in the system", __FUNCTION__); 3515738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project return -1; 3525738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project} 3535738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 3545738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectint uinput_create(char *name) 3555738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project{ 3565738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project struct uinput_dev dev; 357104e3f238f500cacdb8afaccdc672dfc34eae7eeBernhard Rosenkränzer int fd, x = 0; 3585738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 3595738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project for(x=0; x < MAX_UINPUT_PATHS; x++) 3605738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 3615738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project fd = open(uinput_dev_path[x], O_RDWR); 3625738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if (fd < 0) 3635738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project continue; 3645738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project break; 3655738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 3665738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if (x == MAX_UINPUT_PATHS) { 367e8c3d75b75493911ebf0f99c83676359657178f7Sharvil Nanavati BTIF_TRACE_ERROR("%s ERROR: uinput device open failed", __FUNCTION__); 3685738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project return -1; 3695738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 3705738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project memset(&dev, 0, sizeof(dev)); 3715738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if (name) 3724540f59bc447dc2b7b31a3e974b74a60b2417e7dVenkatRaghavan VijayaRaghavan strncpy(dev.name, name, UINPUT_MAX_NAME_SIZE-1); 3735738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 3745738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project dev.id.bustype = BUS_BLUETOOTH; 3755738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project dev.id.vendor = 0x0000; 3765738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project dev.id.product = 0x0000; 3775738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project dev.id.version = 0x0000; 3785738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 379574dcfb73e3741d715f7d4394fe5d3bd587cb0d2Pavlin Radoslavov ssize_t ret; 380574dcfb73e3741d715f7d4394fe5d3bd587cb0d2Pavlin Radoslavov OSI_NO_INTR(ret = write(fd, &dev, sizeof(dev))); 381574dcfb73e3741d715f7d4394fe5d3bd587cb0d2Pavlin Radoslavov if (ret < 0) { 382e8c3d75b75493911ebf0f99c83676359657178f7Sharvil Nanavati BTIF_TRACE_ERROR("%s Unable to write device information", __FUNCTION__); 3835738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project close(fd); 3845738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project return -1; 3855738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 3865738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 3875738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project ioctl(fd, UI_SET_EVBIT, EV_KEY); 3885738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project ioctl(fd, UI_SET_EVBIT, EV_REL); 3895738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project ioctl(fd, UI_SET_EVBIT, EV_SYN); 3905738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 3915738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project for (x = 0; key_map[x].name != NULL; x++) 3925738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project ioctl(fd, UI_SET_KEYBIT, key_map[x].mapped_id); 3935738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 3945738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if (ioctl(fd, UI_DEV_CREATE, NULL) < 0) { 395e8c3d75b75493911ebf0f99c83676359657178f7Sharvil Nanavati BTIF_TRACE_ERROR("%s Unable to create uinput device", __FUNCTION__); 3965738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project close(fd); 3975738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project return -1; 3985738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 3995738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project return fd; 4005738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project} 4015738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 4025738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectint init_uinput (void) 4035738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project{ 4045738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project char *name = "AVRCP"; 4055738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 406e8c3d75b75493911ebf0f99c83676359657178f7Sharvil Nanavati BTIF_TRACE_DEBUG("%s", __FUNCTION__); 4075738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project uinput_fd = uinput_create(name); 4085738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if (uinput_fd < 0) { 409e8c3d75b75493911ebf0f99c83676359657178f7Sharvil Nanavati BTIF_TRACE_ERROR("%s AVRCP: Failed to initialize uinput for %s (%d)", 4105738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project __FUNCTION__, name, uinput_fd); 4115738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } else { 412e8c3d75b75493911ebf0f99c83676359657178f7Sharvil Nanavati BTIF_TRACE_DEBUG("%s AVRCP: Initialized uinput for %s (fd=%d)", 4135738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project __FUNCTION__, name, uinput_fd); 4145738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 4155738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project return uinput_fd; 4165738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project} 4175738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 4185738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectvoid close_uinput (void) 4195738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project{ 420e8c3d75b75493911ebf0f99c83676359657178f7Sharvil Nanavati BTIF_TRACE_DEBUG("%s", __FUNCTION__); 4215738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if (uinput_fd > 0) { 4225738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project ioctl(uinput_fd, UI_DEV_DESTROY); 4235738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 4245738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project close(uinput_fd); 4255738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project uinput_fd = -1; 4265738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 4275738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project} 4285738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 4296b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta#if (AVRC_CTLR_INCLUDED == TRUE) 4306b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Guptavoid rc_cleanup_sent_cmd (void *p_data) 4316b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta{ 4326b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta BTIF_TRACE_DEBUG("%s", __FUNCTION__); 4336b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta 4346b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta} 4356b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta 4366b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Guptavoid handle_rc_ctrl_features(BD_ADDR bd_addr) 4376b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta{ 4386b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta if ((btif_rc_cb.rc_features & BTA_AV_FEAT_RCTG)|| 4396b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta ((btif_rc_cb.rc_features & BTA_AV_FEAT_RCCT)&& 4406b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta (btif_rc_cb.rc_features & BTA_AV_FEAT_ADV_CTRL))) 4416b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta { 4426b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta bt_bdaddr_t rc_addr; 4436b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta int rc_features = 0; 4446b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta bdcpy(rc_addr.address,bd_addr); 4456b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta 4466b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta if ((btif_rc_cb.rc_features & BTA_AV_FEAT_ADV_CTRL)&& 4476b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta (btif_rc_cb.rc_features & BTA_AV_FEAT_RCCT)) 4486b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta { 4496b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta rc_features |= BTRC_FEAT_ABSOLUTE_VOLUME; 4506b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta } 4516b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta if ((btif_rc_cb.rc_features & BTA_AV_FEAT_METADATA)&& 4526b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta (btif_rc_cb.rc_features & BTA_AV_FEAT_VENDOR)&& 4536b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta (btif_rc_cb.rc_features_processed != TRUE)) 4546b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta { 4556b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta rc_features |= BTRC_FEAT_METADATA; 4566b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta /* Mark rc features processed to avoid repeating 4576b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta * the AVRCP procedure every time on receiving this 4586b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta * update. 4596b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta */ 4606b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta btif_rc_cb.rc_features_processed = TRUE; 461470466e6beea7ee10675ec780a2afa23bd8a3cd4AnubhavGupta 462470466e6beea7ee10675ec780a2afa23bd8a3cd4AnubhavGupta if (btif_av_is_sink_enabled()) 463470466e6beea7ee10675ec780a2afa23bd8a3cd4AnubhavGupta getcapabilities_cmd (AVRC_CAP_COMPANY_ID); 4646b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta } 4656b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta BTIF_TRACE_DEBUG("%s Update rc features to CTRL %d", __FUNCTION__, rc_features); 4666b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta HAL_CBACK(bt_rc_ctrl_callbacks, getrcfeatures_cb, &rc_addr, rc_features); 4676b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta } 4686b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta} 4696b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta#endif 4706b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta 4716b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Guptavoid handle_rc_features(BD_ADDR bd_addr) 472247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji{ 4736b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta if (bt_rc_callbacks != NULL) 4746b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta { 475247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji btrc_remote_features_t rc_features = BTRC_FEAT_NONE; 476247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji bt_bdaddr_t rc_addr; 47769682acf0149e9e51cda5b8747866ca9dc37b907Ayan Ghosh 478247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji bdcpy(rc_addr.address, btif_rc_cb.rc_addr); 47969682acf0149e9e51cda5b8747866ca9dc37b907Ayan Ghosh bt_bdaddr_t avdtp_addr = btif_av_get_addr(); 48069682acf0149e9e51cda5b8747866ca9dc37b907Ayan Ghosh 48169682acf0149e9e51cda5b8747866ca9dc37b907Ayan Ghosh bdstr_t addr1, addr2; 48269682acf0149e9e51cda5b8747866ca9dc37b907Ayan Ghosh BTIF_TRACE_DEBUG("%s: AVDTP Address: %s AVCTP address: %s", __func__, 48369682acf0149e9e51cda5b8747866ca9dc37b907Ayan Ghosh bdaddr_to_string(&avdtp_addr, addr1, sizeof(addr1)), 48469682acf0149e9e51cda5b8747866ca9dc37b907Ayan Ghosh bdaddr_to_string(&rc_addr, addr2, sizeof(addr2))); 4859adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan 48695673843582fccf026d8af7592428f9b864f52fdAndre Eisenbach if (interop_match_addr(INTEROP_DISABLE_ABSOLUTE_VOLUME, &rc_addr) 48769682acf0149e9e51cda5b8747866ca9dc37b907Ayan Ghosh || absolute_volume_disabled() 48869682acf0149e9e51cda5b8747866ca9dc37b907Ayan Ghosh || bdcmp(avdtp_addr.address, rc_addr.address)) 489d0aa6cc53abaf122a2426c20691ccfa025ca7369Andre Eisenbach btif_rc_cb.rc_features &= ~BTA_AV_FEAT_ADV_CTRL; 490a7ae4a15e954fe143326d4f869f8dac8e76ee8ceMatthew Xie 491247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji if (btif_rc_cb.rc_features & BTA_AV_FEAT_BROWSE) 492247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji { 493247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji rc_features |= BTRC_FEAT_BROWSE; 494247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji } 49558593a02736ff9ac9bdccd0e3186602f17452cdfAndre Eisenbach 4965bcbaa498c0d12806a4d57a3b09a05dff5aa5a9eSharvil Nanavati#if (AVRC_ADV_CTRL_INCLUDED == TRUE) 497247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji if ( (btif_rc_cb.rc_features & BTA_AV_FEAT_ADV_CTRL) && 498247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji (btif_rc_cb.rc_features & BTA_AV_FEAT_RCTG)) 499247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji { 500247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji rc_features |= BTRC_FEAT_ABSOLUTE_VOLUME; 501247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji } 5025bcbaa498c0d12806a4d57a3b09a05dff5aa5a9eSharvil Nanavati#endif 50358593a02736ff9ac9bdccd0e3186602f17452cdfAndre Eisenbach 504247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji if (btif_rc_cb.rc_features & BTA_AV_FEAT_METADATA) 505247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji { 506247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji rc_features |= BTRC_FEAT_METADATA; 507247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji } 50858593a02736ff9ac9bdccd0e3186602f17452cdfAndre Eisenbach 509e8c3d75b75493911ebf0f99c83676359657178f7Sharvil Nanavati BTIF_TRACE_DEBUG("%s: rc_features=0x%x", __FUNCTION__, rc_features); 510247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji HAL_CBACK(bt_rc_callbacks, remote_features_cb, &rc_addr, rc_features) 511247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji 512247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji#if (AVRC_ADV_CTRL_INCLUDED == TRUE) 5136b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta BTIF_TRACE_DEBUG("%s Checking for feature flags in btif_rc_handler with label %d", 5146b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta __FUNCTION__, btif_rc_cb.rc_vol_label); 515247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji // Register for volume change on connect 5166b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta if (btif_rc_cb.rc_features & BTA_AV_FEAT_ADV_CTRL && 517247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji btif_rc_cb.rc_features & BTA_AV_FEAT_RCTG) 518247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji { 519247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji rc_transaction_t *p_transaction=NULL; 520247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji bt_status_t status = BT_STATUS_NOT_READY; 5216b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta if (MAX_LABEL==btif_rc_cb.rc_vol_label) 522247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji { 523247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji status=get_transaction(&p_transaction); 524247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji } 525247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji else 526247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji { 527247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji p_transaction=get_transaction_by_lbl(btif_rc_cb.rc_vol_label); 5286b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta if (NULL!=p_transaction) 529247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji { 5306b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta BTIF_TRACE_DEBUG("%s register_volumechange already in progress for label %d", 5316b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta __FUNCTION__, btif_rc_cb.rc_vol_label); 532247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji return; 533247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji } 534247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji else 535247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji status=get_transaction(&p_transaction); 536247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji } 537247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji 5386b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta if (BT_STATUS_SUCCESS == status && NULL!=p_transaction) 539247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji { 540247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji btif_rc_cb.rc_vol_label=p_transaction->lbl; 541247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji register_volumechange(btif_rc_cb.rc_vol_label); 542247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji } 543247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji } 544247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji#endif 5456b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta } 546247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji} 5479adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan 5485738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/*************************************************************************** 5495738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project * Function handle_rc_connect 5505738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project * 55198497a520010fc996a8ce490665cac6c1439dd2dJohn Du * - Argument: tBTA_AV_RC_OPEN RC open data structure 5525738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project * 5535738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project * - Description: RC connection event handler 5545738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project * 5555738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project ***************************************************************************/ 5565738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectvoid handle_rc_connect (tBTA_AV_RC_OPEN *p_rc_open) 5575738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project{ 558e8c3d75b75493911ebf0f99c83676359657178f7Sharvil Nanavati BTIF_TRACE_DEBUG("%s: rc_handle: %d", __FUNCTION__, p_rc_open->rc_handle); 5599adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan bt_status_t result = BT_STATUS_SUCCESS; 56093912473fde12ab5ab4b1be8774bbf43d47c7ddcMike Lockwood#if (AVRC_CTLR_INCLUDED == TRUE) 56193912473fde12ab5ab4b1be8774bbf43d47c7ddcMike Lockwood bt_bdaddr_t rc_addr; 56293912473fde12ab5ab4b1be8774bbf43d47c7ddcMike Lockwood#endif 5635738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 5646b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta if (p_rc_open->status == BTA_AV_SUCCESS) 5659adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan { 566137bed026881654febddfa2d797e06ce9f8e58faAnubhav Gupta //check if already some RC is connected 567137bed026881654febddfa2d797e06ce9f8e58faAnubhav Gupta if (btif_rc_cb.rc_connected) 568137bed026881654febddfa2d797e06ce9f8e58faAnubhav Gupta { 5696b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta BTIF_TRACE_ERROR("%s Got RC OPEN in connected state, Connected RC: %d \ 5706b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta and Current RC: %d", __FUNCTION__, btif_rc_cb.rc_handle,p_rc_open->rc_handle ); 571137bed026881654febddfa2d797e06ce9f8e58faAnubhav Gupta if ((btif_rc_cb.rc_handle != p_rc_open->rc_handle) 572137bed026881654febddfa2d797e06ce9f8e58faAnubhav Gupta && (bdcmp(btif_rc_cb.rc_addr, p_rc_open->peer_addr))) 573137bed026881654febddfa2d797e06ce9f8e58faAnubhav Gupta { 5746b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta BTIF_TRACE_DEBUG("%s Got RC connected for some other handle", __FUNCTION__); 575137bed026881654febddfa2d797e06ce9f8e58faAnubhav Gupta BTA_AvCloseRc(p_rc_open->rc_handle); 576137bed026881654febddfa2d797e06ce9f8e58faAnubhav Gupta return; 577137bed026881654febddfa2d797e06ce9f8e58faAnubhav Gupta } 578137bed026881654febddfa2d797e06ce9f8e58faAnubhav Gupta } 5799adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan memcpy(btif_rc_cb.rc_addr, p_rc_open->peer_addr, sizeof(BD_ADDR)); 5809adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan btif_rc_cb.rc_features = p_rc_open->peer_features; 581247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji btif_rc_cb.rc_vol_label=MAX_LABEL; 582247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji btif_rc_cb.rc_volume=MAX_VOLUME; 5839adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan 5849adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan btif_rc_cb.rc_connected = TRUE; 5859adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan btif_rc_cb.rc_handle = p_rc_open->rc_handle; 5865738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 587247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji /* on locally initiated connection we will get remote features as part of connect */ 588247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji if (btif_rc_cb.rc_features != 0) 5896b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta handle_rc_features(btif_rc_cb.rc_addr); 5906b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta if (bt_rc_callbacks) 5916b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta { 5926b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta result = uinput_driver_check(); 5936b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta if (result == BT_STATUS_SUCCESS) 5946b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta { 5956b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta init_uinput(); 5966b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta } 5976b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta } 5986b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta else 5999adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan { 6006b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta BTIF_TRACE_WARNING("%s Avrcp TG role not enabled, not initializing UInput", 6016b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta __FUNCTION__); 6029adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan } 6036b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta BTIF_TRACE_DEBUG("%s handle_rc_connect features %d ",__FUNCTION__, btif_rc_cb.rc_features); 6044ad470e33021be4246ae539e1bcb7a346dbb4405Mike Lockwood#if (AVRC_CTLR_INCLUDED == TRUE) 6056b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta btif_rc_cb.rc_playing_uid = RC_INVALID_TRACK_ID; 6064ad470e33021be4246ae539e1bcb7a346dbb4405Mike Lockwood bdcpy(rc_addr.address, btif_rc_cb.rc_addr); 6076b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta if (bt_rc_ctrl_callbacks != NULL) 6086b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta { 6096b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta HAL_CBACK(bt_rc_ctrl_callbacks, connection_state_cb, TRUE, &rc_addr); 6106b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta } 6116b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta /* report connection state if remote device is AVRCP target */ 6126b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta if ((btif_rc_cb.rc_features & BTA_AV_FEAT_RCTG)|| 6136b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta ((btif_rc_cb.rc_features & BTA_AV_FEAT_RCCT)&& 6146b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta (btif_rc_cb.rc_features & BTA_AV_FEAT_ADV_CTRL))) 6156b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta { 6166b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta handle_rc_ctrl_features(btif_rc_cb.rc_addr); 6174ad470e33021be4246ae539e1bcb7a346dbb4405Mike Lockwood } 6184ad470e33021be4246ae539e1bcb7a346dbb4405Mike Lockwood#endif 6199adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan } 6209adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan else 6219adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan { 622e8c3d75b75493911ebf0f99c83676359657178f7Sharvil Nanavati BTIF_TRACE_ERROR("%s Connect failed with error code: %d", 6239adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan __FUNCTION__, p_rc_open->status); 6249adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan btif_rc_cb.rc_connected = FALSE; 6259adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan } 6265738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project} 6275738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 6285738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/*************************************************************************** 6295738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project * Function handle_rc_disconnect 6305738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project * 63198497a520010fc996a8ce490665cac6c1439dd2dJohn Du * - Argument: tBTA_AV_RC_CLOSE RC close data structure 6325738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project * 6335738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project * - Description: RC disconnection event handler 6345738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project * 6355738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project ***************************************************************************/ 6365738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectvoid handle_rc_disconnect (tBTA_AV_RC_CLOSE *p_rc_close) 6375738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project{ 6384ad470e33021be4246ae539e1bcb7a346dbb4405Mike Lockwood#if (AVRC_CTLR_INCLUDED == TRUE) 6394ad470e33021be4246ae539e1bcb7a346dbb4405Mike Lockwood bt_bdaddr_t rc_addr; 6404ad470e33021be4246ae539e1bcb7a346dbb4405Mike Lockwood tBTA_AV_FEAT features; 6414ad470e33021be4246ae539e1bcb7a346dbb4405Mike Lockwood#endif 642e8c3d75b75493911ebf0f99c83676359657178f7Sharvil Nanavati BTIF_TRACE_DEBUG("%s: rc_handle: %d", __FUNCTION__, p_rc_close->rc_handle); 643137bed026881654febddfa2d797e06ce9f8e58faAnubhav Gupta if ((p_rc_close->rc_handle != btif_rc_cb.rc_handle) 644137bed026881654febddfa2d797e06ce9f8e58faAnubhav Gupta && (bdcmp(btif_rc_cb.rc_addr, p_rc_close->peer_addr))) 645137bed026881654febddfa2d797e06ce9f8e58faAnubhav Gupta { 646137bed026881654febddfa2d797e06ce9f8e58faAnubhav Gupta BTIF_TRACE_ERROR("Got disconnect of unknown device"); 647137bed026881654febddfa2d797e06ce9f8e58faAnubhav Gupta return; 648137bed026881654febddfa2d797e06ce9f8e58faAnubhav Gupta } 6496b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta#if (AVRC_CTLR_INCLUDED == TRUE) 6506b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta bdcpy(rc_addr.address, btif_rc_cb.rc_addr); 6516b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta features = btif_rc_cb.rc_features; 6526b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta /* Clean up AVRCP procedure flags */ 6536b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta memset(&btif_rc_cb.rc_app_settings, 0, 6546b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta sizeof(btif_rc_player_app_settings_t)); 6556b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta btif_rc_cb.rc_features_processed = FALSE; 6566b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta btif_rc_cb.rc_procedure_complete = FALSE; 65778bcff79e1b1f0efce436b33bdd6da88745bfc8aPavlin Radoslavov rc_stop_play_status_timer(); 6586b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta /* Check and clear the notification event list */ 6596b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta if (btif_rc_cb.rc_supported_event_list != NULL) 6606b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta { 6616b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta list_clear(btif_rc_cb.rc_supported_event_list); 6626b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta btif_rc_cb.rc_supported_event_list = NULL; 6636b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta } 6646b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta#endif 6655738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project btif_rc_cb.rc_handle = 0; 6665738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project btif_rc_cb.rc_connected = FALSE; 6675738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project memset(btif_rc_cb.rc_addr, 0, sizeof(BD_ADDR)); 66868c53ded6523113ddcc1932fa5bcb7d378b12209Nitin Srivastava memset(btif_rc_cb.rc_notif, 0, sizeof(btif_rc_cb.rc_notif)); 6696b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta 6709adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan btif_rc_cb.rc_features = 0; 671247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji btif_rc_cb.rc_vol_label=MAX_LABEL; 672247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji btif_rc_cb.rc_volume=MAX_VOLUME; 673247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji init_all_transactions(); 6746b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta if (bt_rc_callbacks != NULL) 6756b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta { 6766b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta close_uinput(); 6776b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta } 6786b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta else 6796b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta { 6806b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta BTIF_TRACE_WARNING("%s Avrcp TG role not enabled, not closing UInput", __FUNCTION__); 6816b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta } 6826b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta 6834ad470e33021be4246ae539e1bcb7a346dbb4405Mike Lockwood memset(btif_rc_cb.rc_addr, 0, sizeof(BD_ADDR)); 6844ad470e33021be4246ae539e1bcb7a346dbb4405Mike Lockwood#if (AVRC_CTLR_INCLUDED == TRUE) 6854ad470e33021be4246ae539e1bcb7a346dbb4405Mike Lockwood /* report connection state if device is AVRCP target */ 6866b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta if (bt_rc_ctrl_callbacks != NULL) 6876b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta { 6886b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta HAL_CBACK(bt_rc_ctrl_callbacks, connection_state_cb, FALSE, &rc_addr); 6896b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta } 6904ad470e33021be4246ae539e1bcb7a346dbb4405Mike Lockwood#endif 6915738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project} 6925738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 6935738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/*************************************************************************** 6945738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project * Function handle_rc_passthrough_cmd 6955738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project * 6965738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project * - Argument: tBTA_AV_RC rc_id remote control command ID 6975738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project * tBTA_AV_STATE key_state status of key press 6985738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project * 6995738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project * - Description: Remote control command handler 7005738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project * 7015738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project ***************************************************************************/ 7025738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectvoid handle_rc_passthrough_cmd ( tBTA_AV_REMOTE_CMD *p_remote_cmd) 7035738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project{ 7045738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project const char *status; 7055738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project int pressed, i; 7065738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 707e8c3d75b75493911ebf0f99c83676359657178f7Sharvil Nanavati BTIF_TRACE_DEBUG("%s: p_remote_cmd->rc_id=%d", __FUNCTION__, p_remote_cmd->rc_id); 70898497a520010fc996a8ce490665cac6c1439dd2dJohn Du 7095738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* If AVRC is open and peer sends PLAY but there is no AVDT, then we queue-up this PLAY */ 7105738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if (p_remote_cmd) 7115738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 7125738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* queue AVRC PLAY if GAVDTP Open notification to app is pending (2 second timer) */ 7135738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if ((p_remote_cmd->rc_id == BTA_AV_RC_PLAY) && (!btif_av_is_connected())) 7145738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 7155738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if (p_remote_cmd->key_state == AVRC_STATE_PRESS) 7165738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 717e8c3d75b75493911ebf0f99c83676359657178f7Sharvil Nanavati APPL_TRACE_WARNING("%s: AVDT not open, queuing the PLAY command", __FUNCTION__); 7185738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project btif_rc_cb.rc_pending_play = TRUE; 7195738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 7205738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project return; 7215738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 7225738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 7235738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if ((p_remote_cmd->rc_id == BTA_AV_RC_PAUSE) && (btif_rc_cb.rc_pending_play)) 7245738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 725e8c3d75b75493911ebf0f99c83676359657178f7Sharvil Nanavati APPL_TRACE_WARNING("%s: Clear the pending PLAY on PAUSE received", __FUNCTION__); 7265738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project btif_rc_cb.rc_pending_play = FALSE; 7275738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project return; 7285738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 7296b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta if ((p_remote_cmd->rc_id == BTA_AV_RC_VOL_UP)||(p_remote_cmd->rc_id == BTA_AV_RC_VOL_DOWN)) 7306b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta return; // this command is not to be sent to UINPUT, only needed for PTS 7315738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 7321f9dfcbb526c8d0cba080e02df7c4613b7433f18Anubhav Gupta 7331f9dfcbb526c8d0cba080e02df7c4613b7433f18Anubhav Gupta if ((p_remote_cmd->rc_id == BTA_AV_RC_STOP) && (!btif_av_stream_started_ready())) 7341f9dfcbb526c8d0cba080e02df7c4613b7433f18Anubhav Gupta { 7351f9dfcbb526c8d0cba080e02df7c4613b7433f18Anubhav Gupta APPL_TRACE_WARNING("%s: Stream suspended, ignore STOP cmd",__FUNCTION__); 7361f9dfcbb526c8d0cba080e02df7c4613b7433f18Anubhav Gupta return; 7371f9dfcbb526c8d0cba080e02df7c4613b7433f18Anubhav Gupta } 7381f9dfcbb526c8d0cba080e02df7c4613b7433f18Anubhav Gupta 7395738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if (p_remote_cmd->key_state == AVRC_STATE_RELEASE) { 7405738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project status = "released"; 7415738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project pressed = 0; 7425738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } else { 7435738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project status = "pressed"; 7445738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project pressed = 1; 7455738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 7465738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 74798497a520010fc996a8ce490665cac6c1439dd2dJohn Du if (p_remote_cmd->rc_id == BTA_AV_RC_FAST_FOR || p_remote_cmd->rc_id == BTA_AV_RC_REWIND) { 74898497a520010fc996a8ce490665cac6c1439dd2dJohn Du HAL_CBACK(bt_rc_callbacks, passthrough_cmd_cb, p_remote_cmd->rc_id, pressed); 74998497a520010fc996a8ce490665cac6c1439dd2dJohn Du return; 75098497a520010fc996a8ce490665cac6c1439dd2dJohn Du } 75198497a520010fc996a8ce490665cac6c1439dd2dJohn Du 7525738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project for (i = 0; key_map[i].name != NULL; i++) { 7535738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if (p_remote_cmd->rc_id == key_map[i].avrcp) { 754e8c3d75b75493911ebf0f99c83676359657178f7Sharvil Nanavati BTIF_TRACE_DEBUG("%s: %s %s", __FUNCTION__, key_map[i].name, status); 7555738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 7565738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* MusicPlayer uses a long_press_timeout of 1 second for PLAYPAUSE button 7575738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project * and maps that to autoshuffle. So if for some reason release for PLAY/PAUSE 7585738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project * comes 1 second after the press, the MediaPlayer UI goes into a bad state. 7595738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project * The reason for the delay could be sniff mode exit or some AVDTP procedure etc. 7605738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project * The fix is to generate a release right after the press and drown the 'actual' 7615738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project * release. 7625738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project */ 7635738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if ((key_map[i].release_quirk == 1) && (pressed == 0)) 7645738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 765e8c3d75b75493911ebf0f99c83676359657178f7Sharvil Nanavati BTIF_TRACE_DEBUG("%s: AVRC %s Release Faked earlier, drowned now", 7665738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project __FUNCTION__, key_map[i].name); 7675738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project return; 7685738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 7695738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project send_key(uinput_fd, key_map[i].mapped_id, pressed); 7705738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if ((key_map[i].release_quirk == 1) && (pressed == 1)) 7715738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 772642f233005cdcbbbcb92b77d6297fc080b7f072ePavlin Radoslavov sleep_ms(30); 773e8c3d75b75493911ebf0f99c83676359657178f7Sharvil Nanavati BTIF_TRACE_DEBUG("%s: AVRC %s Release quirk enabled, send release now", 7745738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project __FUNCTION__, key_map[i].name); 7755738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project send_key(uinput_fd, key_map[i].mapped_id, 0); 7765738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 7775738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project break; 7785738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 7795738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 7805738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 7815738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if (key_map[i].name == NULL) 782e8c3d75b75493911ebf0f99c83676359657178f7Sharvil Nanavati BTIF_TRACE_ERROR("%s AVRCP: unknown button 0x%02X %s", __FUNCTION__, 7835738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_remote_cmd->rc_id, status); 7845738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project} 7855738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 7864ad470e33021be4246ae539e1bcb7a346dbb4405Mike Lockwood/*************************************************************************** 7874ad470e33021be4246ae539e1bcb7a346dbb4405Mike Lockwood * Function handle_rc_passthrough_rsp 7884ad470e33021be4246ae539e1bcb7a346dbb4405Mike Lockwood * 7894ad470e33021be4246ae539e1bcb7a346dbb4405Mike Lockwood * - Argument: tBTA_AV_REMOTE_RSP passthrough command response 7904ad470e33021be4246ae539e1bcb7a346dbb4405Mike Lockwood * 7914ad470e33021be4246ae539e1bcb7a346dbb4405Mike Lockwood * - Description: Remote control passthrough response handler 7924ad470e33021be4246ae539e1bcb7a346dbb4405Mike Lockwood * 7934ad470e33021be4246ae539e1bcb7a346dbb4405Mike Lockwood ***************************************************************************/ 7944ad470e33021be4246ae539e1bcb7a346dbb4405Mike Lockwoodvoid handle_rc_passthrough_rsp ( tBTA_AV_REMOTE_RSP *p_remote_rsp) 7954ad470e33021be4246ae539e1bcb7a346dbb4405Mike Lockwood{ 7964ad470e33021be4246ae539e1bcb7a346dbb4405Mike Lockwood#if (AVRC_CTLR_INCLUDED == TRUE) 7974ad470e33021be4246ae539e1bcb7a346dbb4405Mike Lockwood const char *status; 7984ad470e33021be4246ae539e1bcb7a346dbb4405Mike Lockwood if (btif_rc_cb.rc_features & BTA_AV_FEAT_RCTG) 7994ad470e33021be4246ae539e1bcb7a346dbb4405Mike Lockwood { 8004ad470e33021be4246ae539e1bcb7a346dbb4405Mike Lockwood int key_state; 8014ad470e33021be4246ae539e1bcb7a346dbb4405Mike Lockwood if (p_remote_rsp->key_state == AVRC_STATE_RELEASE) 8024ad470e33021be4246ae539e1bcb7a346dbb4405Mike Lockwood { 8034ad470e33021be4246ae539e1bcb7a346dbb4405Mike Lockwood status = "released"; 8044ad470e33021be4246ae539e1bcb7a346dbb4405Mike Lockwood key_state = 1; 8054ad470e33021be4246ae539e1bcb7a346dbb4405Mike Lockwood } 8064ad470e33021be4246ae539e1bcb7a346dbb4405Mike Lockwood else 8074ad470e33021be4246ae539e1bcb7a346dbb4405Mike Lockwood { 8084ad470e33021be4246ae539e1bcb7a346dbb4405Mike Lockwood status = "pressed"; 8094ad470e33021be4246ae539e1bcb7a346dbb4405Mike Lockwood key_state = 0; 8104ad470e33021be4246ae539e1bcb7a346dbb4405Mike Lockwood } 8114ad470e33021be4246ae539e1bcb7a346dbb4405Mike Lockwood 812e8c3d75b75493911ebf0f99c83676359657178f7Sharvil Nanavati BTIF_TRACE_DEBUG("%s: rc_id=%d status=%s", __FUNCTION__, p_remote_rsp->rc_id, status); 8134ad470e33021be4246ae539e1bcb7a346dbb4405Mike Lockwood 8144ad470e33021be4246ae539e1bcb7a346dbb4405Mike Lockwood release_transaction(p_remote_rsp->label); 8153a2fa83dac1b07b661a20e2412aad9bf81492106Pavlin Radoslavov if (bt_rc_ctrl_callbacks != NULL) { 8163a2fa83dac1b07b661a20e2412aad9bf81492106Pavlin Radoslavov HAL_CBACK(bt_rc_ctrl_callbacks, passthrough_rsp_cb, p_remote_rsp->rc_id, key_state); 8173a2fa83dac1b07b661a20e2412aad9bf81492106Pavlin Radoslavov } 8184ad470e33021be4246ae539e1bcb7a346dbb4405Mike Lockwood } 8194ad470e33021be4246ae539e1bcb7a346dbb4405Mike Lockwood else 8204ad470e33021be4246ae539e1bcb7a346dbb4405Mike Lockwood { 821e8c3d75b75493911ebf0f99c83676359657178f7Sharvil Nanavati BTIF_TRACE_ERROR("%s DUT does not support AVRCP controller role", __FUNCTION__); 8224ad470e33021be4246ae539e1bcb7a346dbb4405Mike Lockwood } 8234ad470e33021be4246ae539e1bcb7a346dbb4405Mike Lockwood#else 824e8c3d75b75493911ebf0f99c83676359657178f7Sharvil Nanavati BTIF_TRACE_ERROR("%s AVRCP controller role is not enabled", __FUNCTION__); 8254ad470e33021be4246ae539e1bcb7a346dbb4405Mike Lockwood#endif 8264ad470e33021be4246ae539e1bcb7a346dbb4405Mike Lockwood} 8274ad470e33021be4246ae539e1bcb7a346dbb4405Mike Lockwood 8286b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta/*************************************************************************** 8296b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta * Function handle_rc_vendorunique_rsp 8306b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta * 8316b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta * - Argument: tBTA_AV_REMOTE_RSP command response 8326b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta * 8336b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta * - Description: Remote control vendor unique response handler 8346b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta * 8356b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta ***************************************************************************/ 8366b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Guptavoid handle_rc_vendorunique_rsp ( tBTA_AV_REMOTE_RSP *p_remote_rsp) 8376b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta{ 8386b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta#if (AVRC_CTLR_INCLUDED == TRUE) 8396b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta const char *status; 8406b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta UINT8 vendor_id = 0; 8416b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta if (btif_rc_cb.rc_features & BTA_AV_FEAT_RCTG) 8426b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta { 8436b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta int key_state; 8446b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta if (p_remote_rsp->key_state == AVRC_STATE_RELEASE) 8456b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta { 8466b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta status = "released"; 8476b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta key_state = 1; 8486b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta } 8496b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta else 8506b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta { 8516b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta status = "pressed"; 8526b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta key_state = 0; 8536b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta } 8546b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta 8556b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta if (p_remote_rsp->len > 0) 8566b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta { 8576b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta if (p_remote_rsp->len >= AVRC_PASS_THRU_GROUP_LEN) 8586b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta vendor_id = p_remote_rsp->p_data[AVRC_PASS_THRU_GROUP_LEN -1]; 859abd70abb5e42c9431df94fe9d2c4a78a0d8d9af9Pavlin Radoslavov osi_free_and_reset((void **)&p_remote_rsp->p_data); 8606b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta } 8616b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta BTIF_TRACE_DEBUG("%s: vendor_id=%d status=%s", __FUNCTION__, vendor_id, status); 8626b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta 8636b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta release_transaction(p_remote_rsp->label); 8646b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta HAL_CBACK(bt_rc_ctrl_callbacks, groupnavigation_rsp_cb, vendor_id, key_state); 8656b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta } 8666b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta else 8676b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta { 8686b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta BTIF_TRACE_ERROR("%s Remote does not support AVRCP TG role", __FUNCTION__); 8696b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta } 8706b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta#else 8716b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta BTIF_TRACE_ERROR("%s AVRCP controller role is not enabled", __FUNCTION__); 8726b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta#endif 8736b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta} 8746b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta 8759adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajanvoid handle_uid_changed_notification(tBTA_AV_META_MSG *pmeta_msg, tAVRC_COMMAND *pavrc_command) 8765738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project{ 8779adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan tAVRC_RESPONSE avrc_rsp = {0}; 8789adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan avrc_rsp.rsp.pdu = pavrc_command->pdu; 8799adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan avrc_rsp.rsp.status = AVRC_STS_NO_ERROR; 8809adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan avrc_rsp.rsp.opcode = pavrc_command->cmd.opcode; 8819adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan 8829adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan avrc_rsp.reg_notif.event_id = pavrc_command->reg_notif.event_id; 8839adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan avrc_rsp.reg_notif.param.uid_counter = 0; 8849adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan 8859adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan send_metamsg_rsp(pmeta_msg->rc_handle, pmeta_msg->label, AVRC_RSP_INTERIM, &avrc_rsp); 8869adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan send_metamsg_rsp(pmeta_msg->rc_handle, pmeta_msg->label, AVRC_RSP_CHANGED, &avrc_rsp); 8875738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 8889adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan} 8899adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan 8909adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan/*************************************************************************** 8919adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan * Function handle_rc_metamsg_cmd 8929adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan * 8939adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan * - Argument: tBTA_AV_VENDOR Structure containing the received 8949adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan * metamsg command 8959adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan * 8969adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan * - Description: Remote control metamsg command handler (AVRCP 1.3) 8979adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan * 8989adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan ***************************************************************************/ 8999adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajanvoid handle_rc_metamsg_cmd (tBTA_AV_META_MSG *pmeta_msg) 9009adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan{ 9019adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan /* Parse the metamsg command and pass it on to BTL-IFS */ 9029adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan UINT8 scratch_buf[512] = {0}; 9039adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan tAVRC_COMMAND avrc_command = {0}; 9049adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan tAVRC_STS status; 9059adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan 906e8c3d75b75493911ebf0f99c83676359657178f7Sharvil Nanavati BTIF_TRACE_EVENT("+ %s", __FUNCTION__); 9079adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan 9089adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan if (pmeta_msg->p_msg->hdr.opcode != AVRC_OP_VENDOR) 9099adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan { 910e8c3d75b75493911ebf0f99c83676359657178f7Sharvil Nanavati BTIF_TRACE_WARNING("Invalid opcode: %x", pmeta_msg->p_msg->hdr.opcode); 9119adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan return; 9129adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan } 9139adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan if (pmeta_msg->len < 3) 9149adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan { 915e8c3d75b75493911ebf0f99c83676359657178f7Sharvil Nanavati BTIF_TRACE_WARNING("Invalid length.Opcode: 0x%x, len: 0x%x", pmeta_msg->p_msg->hdr.opcode, 9169adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan pmeta_msg->len); 9179adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan return; 9189adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan } 9199adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan 9209adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan if (pmeta_msg->code >= AVRC_RSP_NOT_IMPL) 9219adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan { 922247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji#if (AVRC_ADV_CTRL_INCLUDED == TRUE) 923247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji{ 924247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji rc_transaction_t *transaction=NULL; 925247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji transaction=get_transaction_by_lbl(pmeta_msg->label); 9266b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta if (NULL!=transaction) 927247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji { 928247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji handle_rc_metamsg_rsp(pmeta_msg); 929247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji } 930247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji else 931247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji { 932e8c3d75b75493911ebf0f99c83676359657178f7Sharvil Nanavati BTIF_TRACE_DEBUG("%s:Discard vendor dependent rsp. code: %d label:%d.", 933247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji __FUNCTION__, pmeta_msg->code, pmeta_msg->label); 934247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji } 935247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji return; 936247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji} 937247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji#else 938247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji{ 939e8c3d75b75493911ebf0f99c83676359657178f7Sharvil Nanavati BTIF_TRACE_DEBUG("%s:Received vendor dependent rsp. code: %d len: %d. Not processing it.", 9409adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan __FUNCTION__, pmeta_msg->code, pmeta_msg->len); 9419adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan return; 942247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji} 943247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji#endif 944247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji } 945247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji 946247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji status=AVRC_ParsCommand(pmeta_msg->p_msg, &avrc_command, scratch_buf, sizeof(scratch_buf)); 9476b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta BTIF_TRACE_DEBUG("%s Received vendor command.code,PDU and label: %d, %d,%d", 9486b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta __FUNCTION__, pmeta_msg->code, avrc_command.cmd.pdu, pmeta_msg->label); 9499adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan 9509adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan if (status != AVRC_STS_NO_ERROR) 9519adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan { 9529adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan /* return error */ 953e8c3d75b75493911ebf0f99c83676359657178f7Sharvil Nanavati BTIF_TRACE_WARNING("%s: Error in parsing received metamsg command. status: 0x%02x", 9549adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan __FUNCTION__, status); 9559adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan send_reject_response(pmeta_msg->rc_handle, pmeta_msg->label, avrc_command.pdu, status); 9569adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan } 9579adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan else 9589adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan { 9599adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan /* if RegisterNotification, add it to our registered queue */ 9609adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan 9619adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan if (avrc_command.cmd.pdu == AVRC_PDU_REGISTER_NOTIFICATION) 9629adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan { 9639adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan UINT8 event_id = avrc_command.reg_notif.event_id; 964e8c3d75b75493911ebf0f99c83676359657178f7Sharvil Nanavati BTIF_TRACE_EVENT("%s:New register notification received.event_id:%s,label:0x%x,code:%x", 965247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji __FUNCTION__,dump_rc_notification_event_id(event_id), pmeta_msg->label,pmeta_msg->code); 9669adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan btif_rc_cb.rc_notif[event_id-1].bNotify = TRUE; 9679adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan btif_rc_cb.rc_notif[event_id-1].label = pmeta_msg->label; 9689adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan 9696b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta if (event_id == AVRC_EVT_UIDS_CHANGE) 9709adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan { 9719adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan handle_uid_changed_notification(pmeta_msg, &avrc_command); 9729adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan return; 9739adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan } 9749adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan 9759adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan } 9769adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan 977e8c3d75b75493911ebf0f99c83676359657178f7Sharvil Nanavati BTIF_TRACE_EVENT("%s: Passing received metamsg command to app. pdu: %s", 9789adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan __FUNCTION__, dump_rc_pdu(avrc_command.cmd.pdu)); 9799adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan 9809adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan /* Since handle_rc_metamsg_cmd() itself is called from 9819adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan *btif context, no context switching is required. Invoke 9829adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan * btif_rc_upstreams_evt directly from here. */ 9839adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan btif_rc_upstreams_evt((uint16_t)avrc_command.cmd.pdu, &avrc_command, pmeta_msg->code, 984247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji pmeta_msg->label); 9859adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan } 9865738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project} 9875738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 9885738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/*************************************************************************** 9895738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project ** 9905738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project ** Function btif_rc_handler 9915738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project ** 9925738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project ** Description RC event handler 9935738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project ** 9945738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project ***************************************************************************/ 9955738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectvoid btif_rc_handler(tBTA_AV_EVT event, tBTA_AV *p_data) 9965738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project{ 997e8c3d75b75493911ebf0f99c83676359657178f7Sharvil Nanavati BTIF_TRACE_DEBUG ("%s event:%s", __FUNCTION__, dump_rc_event(event)); 9985738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project switch (event) 9995738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 10005738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project case BTA_AV_RC_OPEN_EVT: 10015738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 10026b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta BTIF_TRACE_DEBUG("%s Peer_features:%x", __FUNCTION__, p_data->rc_open.peer_features); 10035738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project handle_rc_connect( &(p_data->rc_open) ); 10045738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project }break; 10055738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 10065738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project case BTA_AV_RC_CLOSE_EVT: 10075738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 10085738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project handle_rc_disconnect( &(p_data->rc_close) ); 10095738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project }break; 10105738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 10115738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project case BTA_AV_REMOTE_CMD_EVT: 10125738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 10136b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta if (bt_rc_callbacks != NULL) 10146b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta { 10156b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta BTIF_TRACE_DEBUG("%s rc_id:0x%x key_state:%d", 10166b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta __FUNCTION__, p_data->remote_cmd.rc_id, 10175738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_data->remote_cmd.key_state); 10186b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta /** In race conditions just after 2nd AVRCP is connected 10196b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta * remote might send pass through commands, so check for 10206b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta * Rc handle before processing pass through commands 10216b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta **/ 10226b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta if (btif_rc_cb.rc_handle == p_data->remote_cmd.rc_handle) 10236b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta { 10246b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta handle_rc_passthrough_cmd( (&p_data->remote_cmd) ); 10256b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta } 10266b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta else 10276b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta { 10286b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta BTIF_TRACE_DEBUG("%s Pass-through command for Invalid rc handle", __FUNCTION__); 10296b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta } 10306b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta } 10316b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta else 10326b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta { 10336b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta BTIF_TRACE_ERROR("AVRCP TG role not up, drop passthrough commands"); 10346b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta } 10359adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan } 10369adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan break; 10376b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta 103893912473fde12ab5ab4b1be8774bbf43d47c7ddcMike Lockwood#if (AVRC_CTLR_INCLUDED == TRUE) 103993912473fde12ab5ab4b1be8774bbf43d47c7ddcMike Lockwood case BTA_AV_REMOTE_RSP_EVT: 104093912473fde12ab5ab4b1be8774bbf43d47c7ddcMike Lockwood { 1041d2e3b538edf83060d163c603e6ffd0c0977604eeSanket Agarwal BTIF_TRACE_DEBUG("%s RSP: rc_id:0x%x key_state:%d", 10426b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta __FUNCTION__, p_data->remote_rsp.rc_id, p_data->remote_rsp.key_state); 10436b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta if (p_data->remote_rsp.rc_id == AVRC_ID_VENDOR) 10446b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta { 10456b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta handle_rc_vendorunique_rsp(&p_data->remote_rsp); 10466b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta } 10476b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta else 10486b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta { 10496b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta handle_rc_passthrough_rsp(&p_data->remote_rsp); 10506b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta } 105193912473fde12ab5ab4b1be8774bbf43d47c7ddcMike Lockwood } 105293912473fde12ab5ab4b1be8774bbf43d47c7ddcMike Lockwood break; 10536b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta 105493912473fde12ab5ab4b1be8774bbf43d47c7ddcMike Lockwood#endif 10559adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan case BTA_AV_RC_FEAT_EVT: 10569adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan { 10576b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta BTIF_TRACE_DEBUG("%s Peer_features:%x", __FUNCTION__, p_data->rc_feat.peer_features); 10589adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan btif_rc_cb.rc_features = p_data->rc_feat.peer_features; 10596b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta handle_rc_features(p_data->rc_feat.peer_addr); 10606b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta#if (AVRC_CTLR_INCLUDED == TRUE) 10616b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta if ((btif_rc_cb.rc_connected) && (bt_rc_ctrl_callbacks != NULL)) 10626b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta { 10636b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta handle_rc_ctrl_features(btif_rc_cb.rc_addr); 10646b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta } 10656b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta#endif 10669adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan } 10679adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan break; 10686b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta 10699adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan case BTA_AV_META_MSG_EVT: 10709adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan { 10716b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta if (bt_rc_callbacks != NULL) 10726b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta { 10736b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta BTIF_TRACE_DEBUG("%s BTA_AV_META_MSG_EVT code:%d label:%d", 10746b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta __FUNCTION__, 10756b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta p_data->meta_msg.code, 10766b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta p_data->meta_msg.label); 10776b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta BTIF_TRACE_DEBUG("%s company_id:0x%x len:%d handle:%d", 10786b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta __FUNCTION__, 10796b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta p_data->meta_msg.company_id, 10806b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta p_data->meta_msg.len, 10816b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta p_data->meta_msg.rc_handle); 10826b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta /* handle the metamsg command */ 10836b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta handle_rc_metamsg_cmd(&(p_data->meta_msg)); 10846b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta /* Free the Memory allocated for tAVRC_MSG */ 10856b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta } 10866b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta#if (AVRC_CTLR_INCLUDED == TRUE) 10876b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta else if ((bt_rc_callbacks == NULL)&&(bt_rc_ctrl_callbacks != NULL)) 10886b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta { 10896b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta /* This is case of Sink + CT + TG(for abs vol)) */ 10906b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta BTIF_TRACE_DEBUG("%s BTA_AV_META_MSG_EVT code:%d label:%d", 10916b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta __FUNCTION__, 10926b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta p_data->meta_msg.code, 10936b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta p_data->meta_msg.label); 10946b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta BTIF_TRACE_DEBUG("%s company_id:0x%x len:%d handle:%d", 10956b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta __FUNCTION__, 10966b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta p_data->meta_msg.company_id, 10976b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta p_data->meta_msg.len, 10986b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta p_data->meta_msg.rc_handle); 10996b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta if ((p_data->meta_msg.code >= AVRC_RSP_NOT_IMPL)&& 11006b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta (p_data->meta_msg.code <= AVRC_RSP_INTERIM)) 11016b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta { 11026b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta /* Its a response */ 11036b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta handle_avk_rc_metamsg_rsp(&(p_data->meta_msg)); 11046b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta } 11056b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta else if (p_data->meta_msg.code <= AVRC_CMD_GEN_INQ) 11066b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta { 11076b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta /* Its a command */ 11086b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta handle_avk_rc_metamsg_cmd(&(p_data->meta_msg)); 11096b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta } 11106b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta 11116b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta } 11126b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta#endif 11136b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta else 11146b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta { 11156b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta BTIF_TRACE_ERROR("Neither CTRL, nor TG is up, drop meta commands"); 11166b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta } 11179adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan } 11189adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan break; 11196b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta 11205738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project default: 11216b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta BTIF_TRACE_DEBUG("%s Unhandled RC event : 0x%x", __FUNCTION__, event); 11225738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 11235738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project} 11245738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 11255738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/*************************************************************************** 11265738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project ** 11275738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project ** Function btif_rc_get_connected_peer 11285738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project ** 11295738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project ** Description Fetches the connected headset's BD_ADDR if any 11305738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project ** 11315738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project ***************************************************************************/ 11325738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source ProjectBOOLEAN btif_rc_get_connected_peer(BD_ADDR peer_addr) 11335738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project{ 11345738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if (btif_rc_cb.rc_connected == TRUE) { 11355738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project bdcpy(peer_addr, btif_rc_cb.rc_addr); 11365738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project return TRUE; 11375738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 11385738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project return FALSE; 11395738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project} 11405738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 11415738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/*************************************************************************** 11425738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project ** 11436b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta ** Function btif_rc_get_connected_peer_handle 11446b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta ** 11456b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta ** Description Fetches the connected headset's handle if any 11466b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta ** 11476b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta ***************************************************************************/ 11486b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav GuptaUINT8 btif_rc_get_connected_peer_handle(void) 11496b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta{ 11506b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta return btif_rc_cb.rc_handle; 11516b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta} 11526b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta 11536b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta/*************************************************************************** 11546b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta ** 11555738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project ** Function btif_rc_check_handle_pending_play 11565738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project ** 11575738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project ** Description Clears the queued PLAY command. if bSend is TRUE, forwards to app 11585738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project ** 11595738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project ***************************************************************************/ 11605738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 11615738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/* clear the queued PLAY command. if bSend is TRUE, forward to app */ 11625738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectvoid btif_rc_check_handle_pending_play (BD_ADDR peer_addr, BOOLEAN bSendToApp) 11635738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project{ 11645cd8bff2dd0337cb52bf48f312e3d2d55a8882fbMike J. Chen UNUSED(peer_addr); 11655cd8bff2dd0337cb52bf48f312e3d2d55a8882fbMike J. Chen 1166e8c3d75b75493911ebf0f99c83676359657178f7Sharvil Nanavati BTIF_TRACE_DEBUG("%s: bSendToApp=%d", __FUNCTION__, bSendToApp); 11675738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if (btif_rc_cb.rc_pending_play) 11685738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 11695738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if (bSendToApp) 11705738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 11715738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project tBTA_AV_REMOTE_CMD remote_cmd; 1172e8c3d75b75493911ebf0f99c83676359657178f7Sharvil Nanavati APPL_TRACE_DEBUG("%s: Sending queued PLAYED event to app", __FUNCTION__); 11735738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 11745738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project memset (&remote_cmd, 0, sizeof(tBTA_AV_REMOTE_CMD)); 11755738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project remote_cmd.rc_handle = btif_rc_cb.rc_handle; 11765738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project remote_cmd.rc_id = AVRC_ID_PLAY; 11775738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project remote_cmd.hdr.ctype = AVRC_CMD_CTRL; 11785738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project remote_cmd.hdr.opcode = AVRC_OP_PASS_THRU; 11795738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 11805738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* delay sending to app, else there is a timing issue in the framework, 11815738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project ** which causes the audio to be on th device's speaker. Delay between 11825738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project ** OPEN & RC_PLAYs 11835738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project */ 1184642f233005cdcbbbcb92b77d6297fc080b7f072ePavlin Radoslavov sleep_ms(200); 11855738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* send to app - both PRESSED & RELEASED */ 11865738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project remote_cmd.key_state = AVRC_STATE_PRESS; 11875738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project handle_rc_passthrough_cmd( &remote_cmd ); 11885738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 1189642f233005cdcbbbcb92b77d6297fc080b7f072ePavlin Radoslavov sleep_ms(100); 11905738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 11915738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project remote_cmd.key_state = AVRC_STATE_RELEASE; 11925738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project handle_rc_passthrough_cmd( &remote_cmd ); 11935738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 11945738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project btif_rc_cb.rc_pending_play = FALSE; 11955738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 11965738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project} 11975738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 11989adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan/* Generic reject response */ 11999adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajanstatic void send_reject_response (UINT8 rc_handle, UINT8 label, UINT8 pdu, UINT8 status) 12009adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan{ 12019adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan UINT8 ctype = AVRC_RSP_REJ; 12029adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan tAVRC_RESPONSE avrc_rsp; 12039adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan BT_HDR *p_msg = NULL; 12049adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan memset (&avrc_rsp, 0, sizeof(tAVRC_RESPONSE)); 12059adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan 12069adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan avrc_rsp.rsp.opcode = opcode_from_pdu(pdu); 12079adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan avrc_rsp.rsp.pdu = pdu; 12089adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan avrc_rsp.rsp.status = status; 12099adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan 12109adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan if (AVRC_STS_NO_ERROR == (status = AVRC_BldResponse(rc_handle, &avrc_rsp, &p_msg)) ) 12119adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan { 1212e8c3d75b75493911ebf0f99c83676359657178f7Sharvil Nanavati BTIF_TRACE_DEBUG("%s:Sending error notification to handle:%d. pdu:%s,status:0x%02x", 12139adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan __FUNCTION__, rc_handle, dump_rc_pdu(pdu), status); 12149adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan BTA_AvMetaRsp(rc_handle, label, ctype, p_msg); 12159adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan } 12169adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan} 12179adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan 12189adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan/*************************************************************************** 12199adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan * Function send_metamsg_rsp 12209adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan * 12219adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan * - Argument: 12229adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan * rc_handle RC handle corresponding to the connected RC 12239adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan * label Label of the RC response 12249adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan * code Response type 12259adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan * pmetamsg_resp Vendor response 12269adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan * 12279adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan * - Description: Remote control metamsg response handler (AVRCP 1.3) 12289adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan * 12299adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan ***************************************************************************/ 12309adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajanstatic void send_metamsg_rsp (UINT8 rc_handle, UINT8 label, tBTA_AV_CODE code, 12319adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan tAVRC_RESPONSE *pmetamsg_resp) 12329adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan{ 12339adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan UINT8 ctype; 12349adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan 12359adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan if (!pmetamsg_resp) 12369adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan { 1237e8c3d75b75493911ebf0f99c83676359657178f7Sharvil Nanavati BTIF_TRACE_WARNING("%s: Invalid response received from application", __FUNCTION__); 12389adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan return; 12399adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan } 12409adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan 1241e8c3d75b75493911ebf0f99c83676359657178f7Sharvil Nanavati BTIF_TRACE_EVENT("+%s: rc_handle: %d, label: %d, code: 0x%02x, pdu: %s", __FUNCTION__, 12429adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan rc_handle, label, code, dump_rc_pdu(pmetamsg_resp->rsp.pdu)); 12439adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan 12449adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan if (pmetamsg_resp->rsp.status != AVRC_STS_NO_ERROR) 12459adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan { 12469adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan ctype = AVRC_RSP_REJ; 12479adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan } 12489adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan else 12499adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan { 12509adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan if ( code < AVRC_RSP_NOT_IMPL) 12519adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan { 12529adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan if (code == AVRC_CMD_NOTIF) 12539adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan { 12549adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan ctype = AVRC_RSP_INTERIM; 12559adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan } 12569adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan else if (code == AVRC_CMD_STATUS) 12579adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan { 12589adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan ctype = AVRC_RSP_IMPL_STBL; 12599adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan } 12609adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan else 12619adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan { 12629adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan ctype = AVRC_RSP_ACCEPT; 12639adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan } 12649adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan } 12659adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan else 12669adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan { 12679adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan ctype = code; 12689adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan } 12699adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan } 12709adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan /* if response is for register_notification, make sure the rc has 12719adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan actually registered for this */ 12726b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta if ((pmetamsg_resp->rsp.pdu == AVRC_PDU_REGISTER_NOTIFICATION) && (code == AVRC_RSP_CHANGED)) 12739adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan { 12749adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan BOOLEAN bSent = FALSE; 12759adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan UINT8 event_id = pmetamsg_resp->reg_notif.event_id; 12769adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan BOOLEAN bNotify = (btif_rc_cb.rc_connected) && (btif_rc_cb.rc_notif[event_id-1].bNotify); 12779adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan 12789adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan /* de-register this notification for a CHANGED response */ 12799adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan btif_rc_cb.rc_notif[event_id-1].bNotify = FALSE; 1280e8c3d75b75493911ebf0f99c83676359657178f7Sharvil Nanavati BTIF_TRACE_DEBUG("%s rc_handle: %d. event_id: 0x%02d bNotify:%u", __FUNCTION__, 12819adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan btif_rc_cb.rc_handle, event_id, bNotify); 12829adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan if (bNotify) 12839adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan { 12849adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan BT_HDR *p_msg = NULL; 12859adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan tAVRC_STS status; 12869adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan 12879adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan if (AVRC_STS_NO_ERROR == (status = AVRC_BldResponse(btif_rc_cb.rc_handle, 12889adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan pmetamsg_resp, &p_msg)) ) 12899adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan { 1290e8c3d75b75493911ebf0f99c83676359657178f7Sharvil Nanavati BTIF_TRACE_DEBUG("%s Sending notification to rc_handle: %d. event_id: 0x%02d", 12919adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan __FUNCTION__, btif_rc_cb.rc_handle, event_id); 12929adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan bSent = TRUE; 12939adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan BTA_AvMetaRsp(btif_rc_cb.rc_handle, btif_rc_cb.rc_notif[event_id-1].label, 12949adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan ctype, p_msg); 12959adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan } 12969adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan else 12979adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan { 1298e8c3d75b75493911ebf0f99c83676359657178f7Sharvil Nanavati BTIF_TRACE_WARNING("%s failed to build metamsg response. status: 0x%02x", 12999adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan __FUNCTION__, status); 13009adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan } 13019adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan 13029adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan } 13039adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan 13049adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan if (!bSent) 13059adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan { 1306e8c3d75b75493911ebf0f99c83676359657178f7Sharvil Nanavati BTIF_TRACE_DEBUG("%s: Notification not sent, as there are no RC connections or the \ 13079adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan CT has not subscribed for event_id: %s", __FUNCTION__, dump_rc_notification_event_id(event_id)); 13089adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan } 13099adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan } 13109adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan else 13119adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan { 13129adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan /* All other commands go here */ 13139adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan 13149adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan BT_HDR *p_msg = NULL; 13159adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan tAVRC_STS status; 13169adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan 13179adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan status = AVRC_BldResponse(rc_handle, pmetamsg_resp, &p_msg); 13189adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan 13199adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan if (status == AVRC_STS_NO_ERROR) 13209adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan { 13219adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan BTA_AvMetaRsp(rc_handle, label, ctype, p_msg); 13229adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan } 13239adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan else 13249adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan { 1325e8c3d75b75493911ebf0f99c83676359657178f7Sharvil Nanavati BTIF_TRACE_ERROR("%s: failed to build metamsg response. status: 0x%02x", 13269adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan __FUNCTION__, status); 13279adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan } 13289adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan } 13299adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan} 13309adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan 13319adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajanstatic UINT8 opcode_from_pdu(UINT8 pdu) 13329adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan{ 13339adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan UINT8 opcode = 0; 13349adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan 13359adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan switch (pdu) 13369adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan { 13379adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan case AVRC_PDU_NEXT_GROUP: 13389adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan case AVRC_PDU_PREV_GROUP: /* pass thru */ 13399adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan opcode = AVRC_OP_PASS_THRU; 13409adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan break; 13419adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan 13429adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan default: /* vendor */ 13439adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan opcode = AVRC_OP_VENDOR; 13449adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan break; 13459adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan } 13469adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan 13479adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan return opcode; 13489adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan} 13499adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan 13509adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan/******************************************************************************* 13519adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan** 13529adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan** Function btif_rc_upstreams_evt 13539adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan** 13549adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan** Description Executes AVRC UPSTREAMS events in btif context. 13559adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan** 13569adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan** Returns void 13579adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan** 13589adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan*******************************************************************************/ 13599adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajanstatic void btif_rc_upstreams_evt(UINT16 event, tAVRC_COMMAND *pavrc_cmd, UINT8 ctype, UINT8 label) 13609adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan{ 1361e8c3d75b75493911ebf0f99c83676359657178f7Sharvil Nanavati BTIF_TRACE_EVENT("%s pdu: %s handle: 0x%x ctype:%x label:%x", __FUNCTION__, 13629adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan dump_rc_pdu(pavrc_cmd->pdu), btif_rc_cb.rc_handle, ctype, label); 13639adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan 13649adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan switch (event) 13659adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan { 13669adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan case AVRC_PDU_GET_PLAY_STATUS: 13679adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan { 13689adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan FILL_PDU_QUEUE(IDX_GET_PLAY_STATUS_RSP, ctype, label, TRUE) 13699adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan HAL_CBACK(bt_rc_callbacks, get_play_status_cb); 13709adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan } 13719adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan break; 13729adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan case AVRC_PDU_LIST_PLAYER_APP_ATTR: 13739adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan case AVRC_PDU_LIST_PLAYER_APP_VALUES: 13749adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan case AVRC_PDU_GET_CUR_PLAYER_APP_VALUE: 13759adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan case AVRC_PDU_SET_PLAYER_APP_VALUE: 13769adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan case AVRC_PDU_GET_PLAYER_APP_ATTR_TEXT: 13779adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan case AVRC_PDU_GET_PLAYER_APP_VALUE_TEXT: 13789adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan { 13799adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan /* TODO: Add support for Application Settings */ 1380081d6e548bed5a91c0ba9abda518c06a1b0ba7f5Zhihai Xu send_reject_response (btif_rc_cb.rc_handle, label, pavrc_cmd->pdu, AVRC_STS_BAD_CMD); 13819adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan } 13829adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan break; 13839adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan case AVRC_PDU_GET_ELEMENT_ATTR: 13849adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan { 13859adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan btrc_media_attr_t element_attrs[BTRC_MAX_ELEM_ATTR_SIZE]; 13869adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan UINT8 num_attr; 1387841e5b5092bcdbc1acffd6cf7255ec423fe15fdbRavi Nagarajan memset(&element_attrs, 0, sizeof(element_attrs)); 13889adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan if (pavrc_cmd->get_elem_attrs.num_attr == 0) 13899adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan { 13909adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan /* CT requests for all attributes */ 13919adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan int attr_cnt; 1392841e5b5092bcdbc1acffd6cf7255ec423fe15fdbRavi Nagarajan num_attr = BTRC_MAX_ELEM_ATTR_SIZE; 1393841e5b5092bcdbc1acffd6cf7255ec423fe15fdbRavi Nagarajan for (attr_cnt = 0; attr_cnt < BTRC_MAX_ELEM_ATTR_SIZE; attr_cnt++) 13949adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan { 1395841e5b5092bcdbc1acffd6cf7255ec423fe15fdbRavi Nagarajan element_attrs[attr_cnt] = attr_cnt + 1; 13969adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan } 13979adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan } 13989adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan else if (pavrc_cmd->get_elem_attrs.num_attr == 0xFF) 13999adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan { 1400841e5b5092bcdbc1acffd6cf7255ec423fe15fdbRavi Nagarajan /* 0xff indicates, no attributes requested - reject */ 1401841e5b5092bcdbc1acffd6cf7255ec423fe15fdbRavi Nagarajan send_reject_response (btif_rc_cb.rc_handle, label, pavrc_cmd->pdu, 1402841e5b5092bcdbc1acffd6cf7255ec423fe15fdbRavi Nagarajan AVRC_STS_BAD_PARAM); 1403841e5b5092bcdbc1acffd6cf7255ec423fe15fdbRavi Nagarajan return; 14049adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan } 14059adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan else 14069adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan { 14070d65d4cdafc165484dfc8d1c5af4ac1cb7453fd7Mallikarjuna GB int attr_cnt, filled_attr_count; 14080d65d4cdafc165484dfc8d1c5af4ac1cb7453fd7Mallikarjuna GB 14090d65d4cdafc165484dfc8d1c5af4ac1cb7453fd7Mallikarjuna GB num_attr = 0; 14100d65d4cdafc165484dfc8d1c5af4ac1cb7453fd7Mallikarjuna GB /* Attribute IDs from 1 to AVRC_MAX_NUM_MEDIA_ATTR_ID are only valid, 14110d65d4cdafc165484dfc8d1c5af4ac1cb7453fd7Mallikarjuna GB * hence HAL definition limits the attributes to AVRC_MAX_NUM_MEDIA_ATTR_ID. 14120d65d4cdafc165484dfc8d1c5af4ac1cb7453fd7Mallikarjuna GB * Fill only valid entries. 14130d65d4cdafc165484dfc8d1c5af4ac1cb7453fd7Mallikarjuna GB */ 14140d65d4cdafc165484dfc8d1c5af4ac1cb7453fd7Mallikarjuna GB for (attr_cnt = 0; (attr_cnt < pavrc_cmd->get_elem_attrs.num_attr) && 14150d65d4cdafc165484dfc8d1c5af4ac1cb7453fd7Mallikarjuna GB (num_attr < AVRC_MAX_NUM_MEDIA_ATTR_ID); attr_cnt++) 14160d65d4cdafc165484dfc8d1c5af4ac1cb7453fd7Mallikarjuna GB { 14170d65d4cdafc165484dfc8d1c5af4ac1cb7453fd7Mallikarjuna GB if ((pavrc_cmd->get_elem_attrs.attrs[attr_cnt] > 0) && 14180d65d4cdafc165484dfc8d1c5af4ac1cb7453fd7Mallikarjuna GB (pavrc_cmd->get_elem_attrs.attrs[attr_cnt] <= AVRC_MAX_NUM_MEDIA_ATTR_ID)) 14190d65d4cdafc165484dfc8d1c5af4ac1cb7453fd7Mallikarjuna GB { 14200d65d4cdafc165484dfc8d1c5af4ac1cb7453fd7Mallikarjuna GB /* Skip the duplicate entries : PTS sends duplicate entries for Fragment cases 14210d65d4cdafc165484dfc8d1c5af4ac1cb7453fd7Mallikarjuna GB */ 14220d65d4cdafc165484dfc8d1c5af4ac1cb7453fd7Mallikarjuna GB for (filled_attr_count = 0; filled_attr_count < num_attr; filled_attr_count++) 14230d65d4cdafc165484dfc8d1c5af4ac1cb7453fd7Mallikarjuna GB { 14240d65d4cdafc165484dfc8d1c5af4ac1cb7453fd7Mallikarjuna GB if (element_attrs[filled_attr_count] == pavrc_cmd->get_elem_attrs.attrs[attr_cnt]) 14250d65d4cdafc165484dfc8d1c5af4ac1cb7453fd7Mallikarjuna GB break; 14260d65d4cdafc165484dfc8d1c5af4ac1cb7453fd7Mallikarjuna GB } 14270d65d4cdafc165484dfc8d1c5af4ac1cb7453fd7Mallikarjuna GB if (filled_attr_count == num_attr) 14280d65d4cdafc165484dfc8d1c5af4ac1cb7453fd7Mallikarjuna GB { 14290d65d4cdafc165484dfc8d1c5af4ac1cb7453fd7Mallikarjuna GB element_attrs[num_attr] = pavrc_cmd->get_elem_attrs.attrs[attr_cnt]; 14300d65d4cdafc165484dfc8d1c5af4ac1cb7453fd7Mallikarjuna GB num_attr++; 14310d65d4cdafc165484dfc8d1c5af4ac1cb7453fd7Mallikarjuna GB } 14320d65d4cdafc165484dfc8d1c5af4ac1cb7453fd7Mallikarjuna GB } 14330d65d4cdafc165484dfc8d1c5af4ac1cb7453fd7Mallikarjuna GB } 14349adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan } 14359adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan FILL_PDU_QUEUE(IDX_GET_ELEMENT_ATTR_RSP, ctype, label, TRUE); 14369adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan HAL_CBACK(bt_rc_callbacks, get_element_attr_cb, num_attr, element_attrs); 14379adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan } 14389adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan break; 14399adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan case AVRC_PDU_REGISTER_NOTIFICATION: 14409adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan { 14416b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta if (pavrc_cmd->reg_notif.event_id == BTRC_EVT_PLAY_POS_CHANGED && 14429adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan pavrc_cmd->reg_notif.param == 0) 14439adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan { 1444e8c3d75b75493911ebf0f99c83676359657178f7Sharvil Nanavati BTIF_TRACE_WARNING("%s Device registering position changed with illegal param 0.", 14459adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan __FUNCTION__); 14469adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan send_reject_response (btif_rc_cb.rc_handle, label, pavrc_cmd->pdu, AVRC_STS_BAD_PARAM); 14479adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan /* de-register this notification for a rejected response */ 14489adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan btif_rc_cb.rc_notif[BTRC_EVT_PLAY_POS_CHANGED - 1].bNotify = FALSE; 14499adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan return; 14509adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan } 14519adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan HAL_CBACK(bt_rc_callbacks, register_notification_cb, pavrc_cmd->reg_notif.event_id, 14529adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan pavrc_cmd->reg_notif.param); 14539adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan } 14549adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan break; 14559adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan case AVRC_PDU_INFORM_DISPLAY_CHARSET: 14569adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan { 14579adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan tAVRC_RESPONSE avrc_rsp; 1458e8c3d75b75493911ebf0f99c83676359657178f7Sharvil Nanavati BTIF_TRACE_EVENT("%s() AVRC_PDU_INFORM_DISPLAY_CHARSET", __FUNCTION__); 14596b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta if (btif_rc_cb.rc_connected == TRUE) 14609adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan { 14619adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan memset(&(avrc_rsp.inform_charset), 0, sizeof(tAVRC_RSP)); 14629adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan avrc_rsp.inform_charset.opcode=opcode_from_pdu(AVRC_PDU_INFORM_DISPLAY_CHARSET); 14639adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan avrc_rsp.inform_charset.pdu=AVRC_PDU_INFORM_DISPLAY_CHARSET; 14649adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan avrc_rsp.inform_charset.status=AVRC_STS_NO_ERROR; 14659adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan send_metamsg_rsp(btif_rc_cb.rc_handle, label, ctype, &avrc_rsp); 14669adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan } 14679adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan } 14689adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan break; 14699adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan default: 14709adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan { 14719adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan send_reject_response (btif_rc_cb.rc_handle, label, pavrc_cmd->pdu, 14729adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan (pavrc_cmd->pdu == AVRC_PDU_SEARCH)?AVRC_STS_SEARCH_NOT_SUP:AVRC_STS_BAD_CMD); 14739adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan return; 14749adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan } 14759adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan break; 14769adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan } 14776b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta} 14786b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta 14796b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta#if (AVRC_CTLR_INCLUDED == TRUE) 14806b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta/******************************************************************************* 14816b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta** 14826b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta** Function btif_rc_ctrl_upstreams_rsp_cmd 14836b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta** 14846b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta** Description Executes AVRC UPSTREAMS response events in btif context. 14856b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta** 14866b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta** Returns void 14876b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta** 14886b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta*******************************************************************************/ 14896b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Guptastatic void btif_rc_ctrl_upstreams_rsp_cmd(UINT8 event, tAVRC_COMMAND *pavrc_cmd, 14906b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta UINT8 label) 14916b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta{ 14926b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta BTIF_TRACE_DEBUG("%s pdu: %s handle: 0x%x", __FUNCTION__, 14936b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta dump_rc_pdu(pavrc_cmd->pdu), btif_rc_cb.rc_handle); 14946b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta bt_bdaddr_t rc_addr; 14956b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta bdcpy(rc_addr.address, btif_rc_cb.rc_addr); 14966b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta#if (AVRC_CTLR_INCLUDED == TRUE) 14976b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta switch (event) 14986b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta { 14996b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta case AVRC_PDU_SET_ABSOLUTE_VOLUME: 15006b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta HAL_CBACK(bt_rc_ctrl_callbacks,setabsvol_cmd_cb, &rc_addr, 15016b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta pavrc_cmd->volume.volume, label); 15026b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta break; 15036b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta case AVRC_PDU_REGISTER_NOTIFICATION: 15046b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta if (pavrc_cmd->reg_notif.event_id == AVRC_EVT_VOLUME_CHANGE) 15056b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta { 15066b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta HAL_CBACK(bt_rc_ctrl_callbacks, registernotification_absvol_cb, 15076b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta &rc_addr, label); 15086b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta } 15096b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta break; 15106b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta } 15116b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta#endif 15126b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta} 15136b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta#endif 15149adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan 1515a5090f2c33919f57c82107ec62ce5ec5705e7e21Prashant Malani#if (AVRC_ADV_CTRL_INCLUDED == TRUE) 1516247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji/******************************************************************************* 1517247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji** 1518247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji** Function btif_rc_upstreams_rsp_evt 1519247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji** 1520247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji** Description Executes AVRC UPSTREAMS response events in btif context. 1521247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji** 1522247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji** Returns void 1523247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji** 1524247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji*******************************************************************************/ 1525247c68fe6eee3660cbdcf4509195fe735ae25573Satya Callojistatic void btif_rc_upstreams_rsp_evt(UINT16 event, tAVRC_RESPONSE *pavrc_resp, UINT8 ctype, UINT8 label) 1526247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji{ 1527e8c3d75b75493911ebf0f99c83676359657178f7Sharvil Nanavati BTIF_TRACE_EVENT("%s pdu: %s handle: 0x%x ctype:%x label:%x", __FUNCTION__, 1528247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji dump_rc_pdu(pavrc_resp->pdu), btif_rc_cb.rc_handle, ctype, label); 1529247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji 1530247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji switch (event) 1531247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji { 1532247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji case AVRC_PDU_REGISTER_NOTIFICATION: 1533247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji { 15346b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta if (AVRC_RSP_CHANGED==ctype) 1535247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji btif_rc_cb.rc_volume=pavrc_resp->reg_notif.param.volume; 1536247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji HAL_CBACK(bt_rc_callbacks, volume_change_cb, pavrc_resp->reg_notif.param.volume,ctype) 1537247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji } 1538247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji break; 1539247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji 1540247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji case AVRC_PDU_SET_ABSOLUTE_VOLUME: 1541247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji { 15426b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta BTIF_TRACE_DEBUG("%s Set absolute volume change event received: volume %d,ctype %d", 15436b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta __FUNCTION__, pavrc_resp->volume.volume,ctype); 15446b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta if (AVRC_RSP_ACCEPT==ctype) 1545247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji btif_rc_cb.rc_volume=pavrc_resp->volume.volume; 1546247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji HAL_CBACK(bt_rc_callbacks,volume_change_cb,pavrc_resp->volume.volume,ctype) 1547247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji } 1548247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji break; 1549247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji 1550247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji default: 1551247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji return; 1552247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji } 1553247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji} 1554a5090f2c33919f57c82107ec62ce5ec5705e7e21Prashant Malani#endif 1555247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji 15569adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan/************************************************************************************ 15579adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan** AVRCP API Functions 15589adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan************************************************************************************/ 15599adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan 15609adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan/******************************************************************************* 15619adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan** 15629adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan** Function init 15639adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan** 15649adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan** Description Initializes the AVRC interface 15659adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan** 15669adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan** Returns bt_status_t 15679adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan** 15689adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan*******************************************************************************/ 15699adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajanstatic bt_status_t init(btrc_callbacks_t* callbacks ) 15709adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan{ 1571e8c3d75b75493911ebf0f99c83676359657178f7Sharvil Nanavati BTIF_TRACE_EVENT("## %s ##", __FUNCTION__); 15729adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan bt_status_t result = BT_STATUS_SUCCESS; 15739adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan 15749adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan if (bt_rc_callbacks) 15759adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan return BT_STATUS_DONE; 15769adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan 15779adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan bt_rc_callbacks = callbacks; 15789adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan memset (&btif_rc_cb, 0, sizeof(btif_rc_cb)); 1579247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji btif_rc_cb.rc_vol_label=MAX_LABEL; 1580247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji btif_rc_cb.rc_volume=MAX_VOLUME; 1581247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji lbl_init(); 15829adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan 15839adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan return result; 15849adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan} 15859adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan 15864ad470e33021be4246ae539e1bcb7a346dbb4405Mike Lockwood/******************************************************************************* 15874ad470e33021be4246ae539e1bcb7a346dbb4405Mike Lockwood** 15884ad470e33021be4246ae539e1bcb7a346dbb4405Mike Lockwood** Function init_ctrl 15894ad470e33021be4246ae539e1bcb7a346dbb4405Mike Lockwood** 15904ad470e33021be4246ae539e1bcb7a346dbb4405Mike Lockwood** Description Initializes the AVRC interface 15914ad470e33021be4246ae539e1bcb7a346dbb4405Mike Lockwood** 15924ad470e33021be4246ae539e1bcb7a346dbb4405Mike Lockwood** Returns bt_status_t 15934ad470e33021be4246ae539e1bcb7a346dbb4405Mike Lockwood** 15944ad470e33021be4246ae539e1bcb7a346dbb4405Mike Lockwood*******************************************************************************/ 15954ad470e33021be4246ae539e1bcb7a346dbb4405Mike Lockwoodstatic bt_status_t init_ctrl(btrc_ctrl_callbacks_t* callbacks ) 15964ad470e33021be4246ae539e1bcb7a346dbb4405Mike Lockwood{ 1597e8c3d75b75493911ebf0f99c83676359657178f7Sharvil Nanavati BTIF_TRACE_EVENT("## %s ##", __FUNCTION__); 15984ad470e33021be4246ae539e1bcb7a346dbb4405Mike Lockwood bt_status_t result = BT_STATUS_SUCCESS; 15994ad470e33021be4246ae539e1bcb7a346dbb4405Mike Lockwood 16004ad470e33021be4246ae539e1bcb7a346dbb4405Mike Lockwood if (bt_rc_ctrl_callbacks) 16014ad470e33021be4246ae539e1bcb7a346dbb4405Mike Lockwood return BT_STATUS_DONE; 16024ad470e33021be4246ae539e1bcb7a346dbb4405Mike Lockwood 16034ad470e33021be4246ae539e1bcb7a346dbb4405Mike Lockwood bt_rc_ctrl_callbacks = callbacks; 16044ad470e33021be4246ae539e1bcb7a346dbb4405Mike Lockwood memset (&btif_rc_cb, 0, sizeof(btif_rc_cb)); 16054ad470e33021be4246ae539e1bcb7a346dbb4405Mike Lockwood btif_rc_cb.rc_vol_label=MAX_LABEL; 16064ad470e33021be4246ae539e1bcb7a346dbb4405Mike Lockwood btif_rc_cb.rc_volume=MAX_VOLUME; 16074ad470e33021be4246ae539e1bcb7a346dbb4405Mike Lockwood lbl_init(); 16084ad470e33021be4246ae539e1bcb7a346dbb4405Mike Lockwood 16094ad470e33021be4246ae539e1bcb7a346dbb4405Mike Lockwood return result; 16104ad470e33021be4246ae539e1bcb7a346dbb4405Mike Lockwood} 16114ad470e33021be4246ae539e1bcb7a346dbb4405Mike Lockwood 16126b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Guptastatic void rc_ctrl_procedure_complete () 16136b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta{ 16146b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta if (btif_rc_cb.rc_procedure_complete == TRUE) 16156b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta { 16166b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta return; 16176b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta } 16186b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta btif_rc_cb.rc_procedure_complete = TRUE; 16196b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta UINT32 attr_list[] = { 16206b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta AVRC_MEDIA_ATTR_ID_TITLE, 16216b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta AVRC_MEDIA_ATTR_ID_ARTIST, 16226b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta AVRC_MEDIA_ATTR_ID_ALBUM, 16236b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta AVRC_MEDIA_ATTR_ID_TRACK_NUM, 16246b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta AVRC_MEDIA_ATTR_ID_NUM_TRACKS, 16256b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta AVRC_MEDIA_ATTR_ID_GENRE, 16266b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta AVRC_MEDIA_ATTR_ID_PLAYING_TIME 16276b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta }; 16286b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta get_element_attribute_cmd (AVRC_MAX_NUM_MEDIA_ATTR_ID, attr_list); 16296b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta} 16306b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta 16319adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan/*************************************************************************** 16329adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan** 16339adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan** Function get_play_status_rsp 16349adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan** 16359adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan** Description Returns the current play status. 16369adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan** This method is called in response to 16379adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan** GetPlayStatus request. 16389adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan** 16399adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan** Returns bt_status_t 16409adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan** 16419adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan***************************************************************************/ 16429adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajanstatic bt_status_t get_play_status_rsp(btrc_play_status_t play_status, uint32_t song_len, 16439adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan uint32_t song_pos) 16449adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan{ 16459adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan tAVRC_RESPONSE avrc_rsp; 16469adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan CHECK_RC_CONNECTED 16479adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan memset(&(avrc_rsp.get_play_status), 0, sizeof(tAVRC_GET_PLAY_STATUS_RSP)); 16489adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan avrc_rsp.get_play_status.song_len = song_len; 16499adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan avrc_rsp.get_play_status.song_pos = song_pos; 16509adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan avrc_rsp.get_play_status.play_status = play_status; 16519adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan 16529adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan avrc_rsp.get_play_status.pdu = AVRC_PDU_GET_PLAY_STATUS; 16539adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan avrc_rsp.get_play_status.opcode = opcode_from_pdu(AVRC_PDU_GET_PLAY_STATUS); 1654b88fc6cb5636c4af17077502fe3313ffb32d93eeRavi Nagarajan avrc_rsp.get_play_status.status = AVRC_STS_NO_ERROR; 16559adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan /* Send the response */ 16569adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan SEND_METAMSG_RSP(IDX_GET_PLAY_STATUS_RSP, &avrc_rsp); 16579adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan return BT_STATUS_SUCCESS; 16589adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan} 16599adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan 16609adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan/*************************************************************************** 16619adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan** 16629adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan** Function get_element_attr_rsp 16639adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan** 16649adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan** Description Returns the current songs' element attributes 16659adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan** in text. 16669adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan** 16679adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan** Returns bt_status_t 16689adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan** 16699adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan***************************************************************************/ 16709adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajanstatic bt_status_t get_element_attr_rsp(uint8_t num_attr, btrc_element_attr_val_t *p_attrs) 16719adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan{ 16729adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan tAVRC_RESPONSE avrc_rsp; 16739adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan UINT32 i; 16749adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan tAVRC_ATTR_ENTRY element_attrs[BTRC_MAX_ELEM_ATTR_SIZE]; 16759adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan CHECK_RC_CONNECTED 16769adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan memset(element_attrs, 0, sizeof(tAVRC_ATTR_ENTRY) * num_attr); 16779adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan 16789adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan if (num_attr == 0) 16799adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan { 16809adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan avrc_rsp.get_play_status.status = AVRC_STS_BAD_PARAM; 16819adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan } 16829adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan else 16839adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan { 16849adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan for (i=0; i<num_attr; i++) { 16859adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan element_attrs[i].attr_id = p_attrs[i].attr_id; 16869adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan element_attrs[i].name.charset_id = AVRC_CHARSET_ID_UTF8; 16879adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan element_attrs[i].name.str_len = (UINT16)strlen((char *)p_attrs[i].text); 16889adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan element_attrs[i].name.p_str = p_attrs[i].text; 1689e8c3d75b75493911ebf0f99c83676359657178f7Sharvil Nanavati BTIF_TRACE_DEBUG("%s attr_id:0x%x, charset_id:0x%x, str_len:%d, str:%s", 16906b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta __FUNCTION__, (unsigned int)element_attrs[i].attr_id, 16916b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta element_attrs[i].name.charset_id, element_attrs[i].name.str_len, 16926b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta element_attrs[i].name.p_str); 16939adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan } 16949adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan avrc_rsp.get_play_status.status = AVRC_STS_NO_ERROR; 16959adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan } 16969adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan avrc_rsp.get_elem_attrs.num_attr = num_attr; 16979adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan avrc_rsp.get_elem_attrs.p_attrs = element_attrs; 16989adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan avrc_rsp.get_elem_attrs.pdu = AVRC_PDU_GET_ELEMENT_ATTR; 16999adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan avrc_rsp.get_elem_attrs.opcode = opcode_from_pdu(AVRC_PDU_GET_ELEMENT_ATTR); 17009adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan /* Send the response */ 17019adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan SEND_METAMSG_RSP(IDX_GET_ELEMENT_ATTR_RSP, &avrc_rsp); 17029adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan return BT_STATUS_SUCCESS; 17039adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan} 17049adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan 17059adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan/*************************************************************************** 17069adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan** 17079adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan** Function register_notification_rsp 17089adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan** 17099adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan** Description Response to the register notification request. 17109adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan** in text. 17119adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan** 17129adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan** Returns bt_status_t 17139adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan** 17149adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan***************************************************************************/ 17159adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajanstatic bt_status_t register_notification_rsp(btrc_event_id_t event_id, 17169adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan btrc_notification_type_t type, btrc_register_notification_t *p_param) 17179adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan{ 17189adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan tAVRC_RESPONSE avrc_rsp; 17199adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan CHECK_RC_CONNECTED 1720e8c3d75b75493911ebf0f99c83676359657178f7Sharvil Nanavati BTIF_TRACE_EVENT("## %s ## event_id:%s", __FUNCTION__, dump_rc_notification_event_id(event_id)); 172168c53ded6523113ddcc1932fa5bcb7d378b12209Nitin Srivastava if (btif_rc_cb.rc_notif[event_id-1].bNotify == FALSE) 172268c53ded6523113ddcc1932fa5bcb7d378b12209Nitin Srivastava { 1723e8c3d75b75493911ebf0f99c83676359657178f7Sharvil Nanavati BTIF_TRACE_ERROR("Avrcp Event id not registered: event_id = %x", event_id); 172468c53ded6523113ddcc1932fa5bcb7d378b12209Nitin Srivastava return BT_STATUS_NOT_READY; 172568c53ded6523113ddcc1932fa5bcb7d378b12209Nitin Srivastava } 17269adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan memset(&(avrc_rsp.reg_notif), 0, sizeof(tAVRC_REG_NOTIF_RSP)); 17279adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan avrc_rsp.reg_notif.event_id = event_id; 17289adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan 17299adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan switch(event_id) 17309adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan { 17319adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan case BTRC_EVT_PLAY_STATUS_CHANGED: 17329adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan avrc_rsp.reg_notif.param.play_status = p_param->play_status; 17339c5d0727dd4cd09e44c032506c28ab4120ad3b88Anubhav Gupta if (avrc_rsp.reg_notif.param.play_status == PLAY_STATUS_PLAYING) 17349c5d0727dd4cd09e44c032506c28ab4120ad3b88Anubhav Gupta btif_av_clear_remote_suspend_flag(); 17359adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan break; 17369adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan case BTRC_EVT_TRACK_CHANGE: 17379adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan memcpy(&(avrc_rsp.reg_notif.param.track), &(p_param->track), sizeof(btrc_uid_t)); 17389adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan break; 1739b88fc6cb5636c4af17077502fe3313ffb32d93eeRavi Nagarajan case BTRC_EVT_PLAY_POS_CHANGED: 1740b88fc6cb5636c4af17077502fe3313ffb32d93eeRavi Nagarajan avrc_rsp.reg_notif.param.play_pos = p_param->song_pos; 1741b88fc6cb5636c4af17077502fe3313ffb32d93eeRavi Nagarajan break; 17429adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan default: 1743e8c3d75b75493911ebf0f99c83676359657178f7Sharvil Nanavati BTIF_TRACE_WARNING("%s : Unhandled event ID : 0x%x", __FUNCTION__, event_id); 17449adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan return BT_STATUS_UNHANDLED; 17459adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan } 17469adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan 17479adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan avrc_rsp.reg_notif.pdu = AVRC_PDU_REGISTER_NOTIFICATION; 17489adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan avrc_rsp.reg_notif.opcode = opcode_from_pdu(AVRC_PDU_REGISTER_NOTIFICATION); 17499adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan avrc_rsp.get_play_status.status = AVRC_STS_NO_ERROR; 17509adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan 17519adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan /* Send the response. */ 17529adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan send_metamsg_rsp(btif_rc_cb.rc_handle, btif_rc_cb.rc_notif[event_id-1].label, 17539adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan ((type == BTRC_NOTIFICATION_TYPE_INTERIM)?AVRC_CMD_NOTIF:AVRC_RSP_CHANGED), &avrc_rsp); 17549adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan return BT_STATUS_SUCCESS; 17559adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan} 17569adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan 17579adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan/*************************************************************************** 17589adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan** 1759247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji** Function set_volume 1760247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji** 1761247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji** Description Send current volume setting to remote side. 1762247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji** Support limited to SetAbsoluteVolume 1763247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji** This can be enhanced to support Relative Volume (AVRCP 1.0). 1764247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji** With RelateVolume, we will send VOLUME_UP/VOLUME_DOWN 1765247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji** as opposed to absolute volume level 1766247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji** volume: Should be in the range 0-127. bit7 is reseved and cannot be set 1767247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji** 1768247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji** Returns bt_status_t 1769247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji** 1770247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji***************************************************************************/ 1771247c68fe6eee3660cbdcf4509195fe735ae25573Satya Callojistatic bt_status_t set_volume(uint8_t volume) 1772247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji{ 1773e8c3d75b75493911ebf0f99c83676359657178f7Sharvil Nanavati BTIF_TRACE_DEBUG("%s", __FUNCTION__); 1774247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji CHECK_RC_CONNECTED 1775247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji tAVRC_STS status = BT_STATUS_UNSUPPORTED; 1776247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji rc_transaction_t *p_transaction=NULL; 1777247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji 17786b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta if (btif_rc_cb.rc_volume==volume) 1779247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji { 1780247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji status=BT_STATUS_DONE; 1781e8c3d75b75493911ebf0f99c83676359657178f7Sharvil Nanavati BTIF_TRACE_ERROR("%s: volume value already set earlier: 0x%02x",__FUNCTION__, volume); 1782247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji return status; 1783247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji } 1784247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji 1785247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji if ((btif_rc_cb.rc_features & BTA_AV_FEAT_RCTG) && 1786247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji (btif_rc_cb.rc_features & BTA_AV_FEAT_ADV_CTRL)) 1787247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji { 1788247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji tAVRC_COMMAND avrc_cmd = {0}; 1789247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji BT_HDR *p_msg = NULL; 1790247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji 1791e8c3d75b75493911ebf0f99c83676359657178f7Sharvil Nanavati BTIF_TRACE_DEBUG("%s: Peer supports absolute volume. newVolume=%d", __FUNCTION__, volume); 1792247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji avrc_cmd.volume.opcode = AVRC_OP_VENDOR; 1793247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji avrc_cmd.volume.pdu = AVRC_PDU_SET_ABSOLUTE_VOLUME; 1794247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji avrc_cmd.volume.status = AVRC_STS_NO_ERROR; 1795247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji avrc_cmd.volume.volume = volume; 1796247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji 1797247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji if (AVRC_BldCommand(&avrc_cmd, &p_msg) == AVRC_STS_NO_ERROR) 1798247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji { 1799247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji bt_status_t tran_status=get_transaction(&p_transaction); 18006b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta if (BT_STATUS_SUCCESS == tran_status && NULL!=p_transaction) 1801247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji { 1802e8c3d75b75493911ebf0f99c83676359657178f7Sharvil Nanavati BTIF_TRACE_DEBUG("%s msgreq being sent out with label %d", 1803247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji __FUNCTION__,p_transaction->lbl); 1804247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji BTA_AvMetaCmd(btif_rc_cb.rc_handle,p_transaction->lbl, AVRC_CMD_CTRL, p_msg); 1805247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji status = BT_STATUS_SUCCESS; 1806247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji } 1807247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji else 1808247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji { 1809abd70abb5e42c9431df94fe9d2c4a78a0d8d9af9Pavlin Radoslavov osi_free(p_msg); 1810e8c3d75b75493911ebf0f99c83676359657178f7Sharvil Nanavati BTIF_TRACE_ERROR("%s: failed to obtain transaction details. status: 0x%02x", 1811247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji __FUNCTION__, tran_status); 1812247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji status = BT_STATUS_FAIL; 1813247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji } 1814247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji } 1815247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji else 1816247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji { 1817e8c3d75b75493911ebf0f99c83676359657178f7Sharvil Nanavati BTIF_TRACE_ERROR("%s: failed to build absolute volume command. status: 0x%02x", 1818247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji __FUNCTION__, status); 1819247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji status = BT_STATUS_FAIL; 1820247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji } 1821247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji } 1822247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji else 1823247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji status=BT_STATUS_NOT_READY; 1824247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji return status; 1825247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji} 1826247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji 1827a5090f2c33919f57c82107ec62ce5ec5705e7e21Prashant Malani#if (AVRC_ADV_CTRL_INCLUDED == TRUE) 1828247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji/*************************************************************************** 1829247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji** 1830247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji** Function register_volumechange 1831247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji** 1832247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji** Description Register for volume change notification from remote side. 1833247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji** 1834247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji** Returns void 1835247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji** 1836247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji***************************************************************************/ 1837247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji 1838247c68fe6eee3660cbdcf4509195fe735ae25573Satya Callojistatic void register_volumechange (UINT8 lbl) 1839247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji{ 1840247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji tAVRC_COMMAND avrc_cmd = {0}; 1841247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji BT_HDR *p_msg = NULL; 1842247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji tAVRC_STS BldResp=AVRC_STS_BAD_CMD; 1843247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji rc_transaction_t *p_transaction=NULL; 1844247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji 1845e8c3d75b75493911ebf0f99c83676359657178f7Sharvil Nanavati BTIF_TRACE_DEBUG("%s called with label:%d",__FUNCTION__,lbl); 1846247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji 1847247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji avrc_cmd.cmd.opcode=0x00; 1848247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji avrc_cmd.pdu = AVRC_PDU_REGISTER_NOTIFICATION; 1849247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji avrc_cmd.reg_notif.event_id = AVRC_EVT_VOLUME_CHANGE; 1850247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji avrc_cmd.reg_notif.status = AVRC_STS_NO_ERROR; 18516b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta avrc_cmd.reg_notif.param = 0; 1852247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji 1853247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji BldResp=AVRC_BldCommand(&avrc_cmd, &p_msg); 185420524d393e8b3bea4c573f7980cd843500b0e6a4Pavlin Radoslavov if (AVRC_STS_NO_ERROR == BldResp && p_msg) { 185520524d393e8b3bea4c573f7980cd843500b0e6a4Pavlin Radoslavov p_transaction = get_transaction_by_lbl(lbl); 185620524d393e8b3bea4c573f7980cd843500b0e6a4Pavlin Radoslavov if (p_transaction != NULL) { 185720524d393e8b3bea4c573f7980cd843500b0e6a4Pavlin Radoslavov BTA_AvMetaCmd(btif_rc_cb.rc_handle, p_transaction->lbl, 185820524d393e8b3bea4c573f7980cd843500b0e6a4Pavlin Radoslavov AVRC_CMD_NOTIF, p_msg); 185920524d393e8b3bea4c573f7980cd843500b0e6a4Pavlin Radoslavov BTIF_TRACE_DEBUG("%s:BTA_AvMetaCmd called", __func__); 186020524d393e8b3bea4c573f7980cd843500b0e6a4Pavlin Radoslavov } else { 1861abd70abb5e42c9431df94fe9d2c4a78a0d8d9af9Pavlin Radoslavov osi_free(p_msg); 186220524d393e8b3bea4c573f7980cd843500b0e6a4Pavlin Radoslavov BTIF_TRACE_ERROR("%s transaction not obtained with label: %d", 186320524d393e8b3bea4c573f7980cd843500b0e6a4Pavlin Radoslavov __func__, lbl); 1864247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji } 186520524d393e8b3bea4c573f7980cd843500b0e6a4Pavlin Radoslavov } else { 186620524d393e8b3bea4c573f7980cd843500b0e6a4Pavlin Radoslavov BTIF_TRACE_ERROR("%s failed to build command:%d", __func__, BldResp); 1867247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji } 1868247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji} 1869247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji 1870247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji/*************************************************************************** 1871247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji** 1872247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji** Function handle_rc_metamsg_rsp 1873247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji** 1874247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji** Description Handle RC metamessage response 1875247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji** 1876247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji** Returns void 1877247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji** 1878247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji***************************************************************************/ 1879247c68fe6eee3660cbdcf4509195fe735ae25573Satya Callojistatic void handle_rc_metamsg_rsp(tBTA_AV_META_MSG *pmeta_msg) 1880247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji{ 1881247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji tAVRC_RESPONSE avrc_response = {0}; 1882247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji UINT8 scratch_buf[512] = {0}; 1883247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji tAVRC_STS status = BT_STATUS_UNSUPPORTED; 1884247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji 18856b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta if (AVRC_OP_VENDOR==pmeta_msg->p_msg->hdr.opcode &&(AVRC_RSP_CHANGED==pmeta_msg->code 1886247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji || AVRC_RSP_INTERIM==pmeta_msg->code || AVRC_RSP_ACCEPT==pmeta_msg->code 1887247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji || AVRC_RSP_REJ==pmeta_msg->code || AVRC_RSP_NOT_IMPL==pmeta_msg->code)) 1888247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji { 1889247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji status=AVRC_ParsResponse(pmeta_msg->p_msg, &avrc_response, scratch_buf, sizeof(scratch_buf)); 1890e8c3d75b75493911ebf0f99c83676359657178f7Sharvil Nanavati BTIF_TRACE_DEBUG("%s: code %d,event ID %d,PDU %x,parsing status %d, label:%d", 1891247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji __FUNCTION__,pmeta_msg->code,avrc_response.reg_notif.event_id,avrc_response.reg_notif.pdu, 1892247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji status, pmeta_msg->label); 1893247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji 1894247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji if (status != AVRC_STS_NO_ERROR) 1895247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji { 18966b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta if (AVRC_PDU_REGISTER_NOTIFICATION==avrc_response.rsp.pdu 1897247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji && AVRC_EVT_VOLUME_CHANGE==avrc_response.reg_notif.event_id 1898247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji && btif_rc_cb.rc_vol_label==pmeta_msg->label) 1899247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji { 1900247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji btif_rc_cb.rc_vol_label=MAX_LABEL; 1901247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji release_transaction(btif_rc_cb.rc_vol_label); 1902247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji } 19036b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta else if (AVRC_PDU_SET_ABSOLUTE_VOLUME==avrc_response.rsp.pdu) 1904247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji { 1905247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji release_transaction(pmeta_msg->label); 1906247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji } 1907247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji return; 1908247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji } 19096b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta else if (AVRC_PDU_REGISTER_NOTIFICATION==avrc_response.rsp.pdu 1910247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji && AVRC_EVT_VOLUME_CHANGE==avrc_response.reg_notif.event_id 1911247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji && btif_rc_cb.rc_vol_label!=pmeta_msg->label) 1912247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji { 1913247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji // Just discard the message, if the device sends back with an incorrect label 1914e8c3d75b75493911ebf0f99c83676359657178f7Sharvil Nanavati BTIF_TRACE_DEBUG("%s:Discarding register notfn in rsp.code: %d and label %d", 1915247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji __FUNCTION__, pmeta_msg->code, pmeta_msg->label); 1916247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji return; 1917247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji } 1918247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji } 1919247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji else 1920247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji { 1921e8c3d75b75493911ebf0f99c83676359657178f7Sharvil Nanavati BTIF_TRACE_DEBUG("%s:Received vendor dependent in adv ctrl rsp. code: %d len: %d. Not processing it.", 1922247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji __FUNCTION__, pmeta_msg->code, pmeta_msg->len); 1923247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji return; 1924247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji } 1925247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji 19266b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta if (AVRC_PDU_REGISTER_NOTIFICATION==avrc_response.rsp.pdu 1927247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji && AVRC_EVT_VOLUME_CHANGE==avrc_response.reg_notif.event_id 1928247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji && AVRC_RSP_CHANGED==pmeta_msg->code) 1929247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji { 1930247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji /* re-register for volume change notification */ 1931247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji // Do not re-register for rejected case, as it might get into endless loop 1932247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji register_volumechange(btif_rc_cb.rc_vol_label); 1933247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji } 19346b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta else if (AVRC_PDU_SET_ABSOLUTE_VOLUME==avrc_response.rsp.pdu) 1935247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji { 1936247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji /* free up the label here */ 1937247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji release_transaction(pmeta_msg->label); 1938247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji } 1939247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji 1940e8c3d75b75493911ebf0f99c83676359657178f7Sharvil Nanavati BTIF_TRACE_EVENT("%s: Passing received metamsg response to app. pdu: %s", 1941247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji __FUNCTION__, dump_rc_pdu(avrc_response.pdu)); 1942247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji btif_rc_upstreams_rsp_evt((uint16_t)avrc_response.rsp.pdu, &avrc_response, pmeta_msg->code, 1943247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji pmeta_msg->label); 1944247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji} 1945a5090f2c33919f57c82107ec62ce5ec5705e7e21Prashant Malani#endif 1946247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji 19476b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta#if (AVRC_CTLR_INCLUDED == TRUE) 1948247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji/*************************************************************************** 1949247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji** 19506b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta** Function iterate_supported_event_list_for_interim_rsp 19519adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan** 19526b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta** Description iterator callback function to match the event and handle 19536b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta** timer cleanup 195469a34362c65533155578623d30845b04fa6285b1Pavlin Radoslavov** Returns true to continue iterating, false to stop 19559adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan** 19569adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan***************************************************************************/ 19576b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Guptabool iterate_supported_event_list_for_interim_rsp(void *data, void *cb_data) 19589adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan{ 19596b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta UINT8 *p_event_id; 19606b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta btif_rc_supported_event_t *p_event = (btif_rc_supported_event_t *)data; 19616b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta 19626b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta p_event_id = (UINT8*)cb_data; 19636b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta 19646b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta if (p_event->event_id == *p_event_id) 19659adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan { 19666b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta p_event->status = eINTERIM; 196769a34362c65533155578623d30845b04fa6285b1Pavlin Radoslavov return false; 19689adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan } 196969a34362c65533155578623d30845b04fa6285b1Pavlin Radoslavov return true; 19709adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan} 19719adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan 1972daddea9cf1f5dbf51b9a2e9c2b02956a41d77a6cAnubhav Gupta/*************************************************************************** 1973daddea9cf1f5dbf51b9a2e9c2b02956a41d77a6cAnubhav Gupta** 19746b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta** Function iterate_supported_event_list_for_timeout 1975daddea9cf1f5dbf51b9a2e9c2b02956a41d77a6cAnubhav Gupta** 19766b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta** Description Iterator callback function for timeout handling. 19776b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta** As part of the failure handling, it releases the 19786b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta** transaction label and removes the event from list, 19796b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta** this event will not be requested again during 19806b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta** the lifetime of the connection. 19816b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta** Returns false to stop iterating, true to continue 1982daddea9cf1f5dbf51b9a2e9c2b02956a41d77a6cAnubhav Gupta** 1983daddea9cf1f5dbf51b9a2e9c2b02956a41d77a6cAnubhav Gupta***************************************************************************/ 19846b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Guptabool iterate_supported_event_list_for_timeout(void *data, void *cb_data) 1985daddea9cf1f5dbf51b9a2e9c2b02956a41d77a6cAnubhav Gupta{ 19866b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta UINT8 label; 19876b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta btif_rc_supported_event_t *p_event = (btif_rc_supported_event_t *)data; 1988daddea9cf1f5dbf51b9a2e9c2b02956a41d77a6cAnubhav Gupta 198969a34362c65533155578623d30845b04fa6285b1Pavlin Radoslavov label = (*(UINT8*)cb_data) & 0xFF; 19906b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta 19916b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta if (p_event->label == label) 1992daddea9cf1f5dbf51b9a2e9c2b02956a41d77a6cAnubhav Gupta { 19936b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta list_remove(btif_rc_cb.rc_supported_event_list, p_event); 199469a34362c65533155578623d30845b04fa6285b1Pavlin Radoslavov return false; 1995daddea9cf1f5dbf51b9a2e9c2b02956a41d77a6cAnubhav Gupta } 199669a34362c65533155578623d30845b04fa6285b1Pavlin Radoslavov return true; 1997daddea9cf1f5dbf51b9a2e9c2b02956a41d77a6cAnubhav Gupta} 19989adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan 19996b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta/*************************************************************************** 20006b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta** 20016b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta** Function rc_notification_interim_timout 20026b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta** 20036b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta** Description Interim response timeout handler. 20046b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta** Runs the iterator to check and clear the timed out event. 20056b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta** Proceeds to register for the unregistered events. 20066b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta** Returns None 20076b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta** 20086b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta***************************************************************************/ 20096b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Guptastatic void rc_notification_interim_timout (UINT8 label) 20104ad470e33021be4246ae539e1bcb7a346dbb4405Mike Lockwood{ 20116b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta list_node_t *node; 20126b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta 20136b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta list_foreach(btif_rc_cb.rc_supported_event_list, 201469a34362c65533155578623d30845b04fa6285b1Pavlin Radoslavov iterate_supported_event_list_for_timeout, &label); 20156b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta /* Timeout happened for interim response for the registered event, 20166b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta * check if there are any pending for registration 20176b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta */ 20186b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta node = list_begin(btif_rc_cb.rc_supported_event_list); 20196b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta while (node != NULL) 20204ad470e33021be4246ae539e1bcb7a346dbb4405Mike Lockwood { 20216b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta btif_rc_supported_event_t *p_event; 20226b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta 20236b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta p_event = (btif_rc_supported_event_t *)list_node(node); 20246b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta if ((p_event != NULL) && (p_event->status == eNOT_REGISTERED)) 20254ad470e33021be4246ae539e1bcb7a346dbb4405Mike Lockwood { 20266b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta register_for_event_notification(p_event); 20276b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta break; 20284ad470e33021be4246ae539e1bcb7a346dbb4405Mike Lockwood } 20296b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta node = list_next (node); 20304ad470e33021be4246ae539e1bcb7a346dbb4405Mike Lockwood } 20316b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta /* Todo. Need to initiate application settings query if this 20326b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta * is the last event registration. 20336b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta */ 20344ad470e33021be4246ae539e1bcb7a346dbb4405Mike Lockwood} 20354ad470e33021be4246ae539e1bcb7a346dbb4405Mike Lockwood 20366b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta/*************************************************************************** 20376b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta** 203878bcff79e1b1f0efce436b33bdd6da88745bfc8aPavlin Radoslavov** Function btif_rc_status_cmd_timeout_handler 20396b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta** 204078bcff79e1b1f0efce436b33bdd6da88745bfc8aPavlin Radoslavov** Description RC status command timeout handler (Runs in BTIF context). 20416b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta** Returns None 20426b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta** 20436b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta***************************************************************************/ 204478bcff79e1b1f0efce436b33bdd6da88745bfc8aPavlin Radoslavovstatic void btif_rc_status_cmd_timeout_handler(UNUSED_ATTR uint16_t event, 204578bcff79e1b1f0efce436b33bdd6da88745bfc8aPavlin Radoslavov char *data) 20466b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta{ 204778bcff79e1b1f0efce436b33bdd6da88745bfc8aPavlin Radoslavov btif_rc_timer_context_t *p_context; 204878bcff79e1b1f0efce436b33bdd6da88745bfc8aPavlin Radoslavov tAVRC_RESPONSE avrc_response = {0}; 204978bcff79e1b1f0efce436b33bdd6da88745bfc8aPavlin Radoslavov tBTA_AV_META_MSG meta_msg; 205078bcff79e1b1f0efce436b33bdd6da88745bfc8aPavlin Radoslavov 205178bcff79e1b1f0efce436b33bdd6da88745bfc8aPavlin Radoslavov p_context = (btif_rc_timer_context_t *)data; 205278bcff79e1b1f0efce436b33bdd6da88745bfc8aPavlin Radoslavov memset(&meta_msg, 0, sizeof(tBTA_AV_META_MSG)); 205378bcff79e1b1f0efce436b33bdd6da88745bfc8aPavlin Radoslavov meta_msg.rc_handle = btif_rc_cb.rc_handle; 205478bcff79e1b1f0efce436b33bdd6da88745bfc8aPavlin Radoslavov 205578bcff79e1b1f0efce436b33bdd6da88745bfc8aPavlin Radoslavov switch (p_context->rc_status_cmd.pdu_id) { 205678bcff79e1b1f0efce436b33bdd6da88745bfc8aPavlin Radoslavov case AVRC_PDU_REGISTER_NOTIFICATION: 205778bcff79e1b1f0efce436b33bdd6da88745bfc8aPavlin Radoslavov rc_notification_interim_timout(p_context->rc_status_cmd.label); 205878bcff79e1b1f0efce436b33bdd6da88745bfc8aPavlin Radoslavov break; 205978bcff79e1b1f0efce436b33bdd6da88745bfc8aPavlin Radoslavov 206078bcff79e1b1f0efce436b33bdd6da88745bfc8aPavlin Radoslavov case AVRC_PDU_GET_CAPABILITIES: 206178bcff79e1b1f0efce436b33bdd6da88745bfc8aPavlin Radoslavov avrc_response.get_caps.status = BTIF_RC_STS_TIMEOUT; 206278bcff79e1b1f0efce436b33bdd6da88745bfc8aPavlin Radoslavov handle_get_capability_response(&meta_msg, &avrc_response.get_caps); 206378bcff79e1b1f0efce436b33bdd6da88745bfc8aPavlin Radoslavov break; 206478bcff79e1b1f0efce436b33bdd6da88745bfc8aPavlin Radoslavov 206578bcff79e1b1f0efce436b33bdd6da88745bfc8aPavlin Radoslavov case AVRC_PDU_LIST_PLAYER_APP_ATTR: 206678bcff79e1b1f0efce436b33bdd6da88745bfc8aPavlin Radoslavov avrc_response.list_app_attr.status = BTIF_RC_STS_TIMEOUT; 206778bcff79e1b1f0efce436b33bdd6da88745bfc8aPavlin Radoslavov handle_app_attr_response(&meta_msg, &avrc_response.list_app_attr); 206878bcff79e1b1f0efce436b33bdd6da88745bfc8aPavlin Radoslavov break; 206978bcff79e1b1f0efce436b33bdd6da88745bfc8aPavlin Radoslavov 207078bcff79e1b1f0efce436b33bdd6da88745bfc8aPavlin Radoslavov case AVRC_PDU_LIST_PLAYER_APP_VALUES: 207178bcff79e1b1f0efce436b33bdd6da88745bfc8aPavlin Radoslavov avrc_response.list_app_values.status = BTIF_RC_STS_TIMEOUT; 207278bcff79e1b1f0efce436b33bdd6da88745bfc8aPavlin Radoslavov handle_app_val_response(&meta_msg, &avrc_response.list_app_values); 207378bcff79e1b1f0efce436b33bdd6da88745bfc8aPavlin Radoslavov break; 20746b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta 207578bcff79e1b1f0efce436b33bdd6da88745bfc8aPavlin Radoslavov case AVRC_PDU_GET_CUR_PLAYER_APP_VALUE: 207678bcff79e1b1f0efce436b33bdd6da88745bfc8aPavlin Radoslavov avrc_response.get_cur_app_val.status = BTIF_RC_STS_TIMEOUT; 207778bcff79e1b1f0efce436b33bdd6da88745bfc8aPavlin Radoslavov handle_app_cur_val_response(&meta_msg, &avrc_response.get_cur_app_val); 207878bcff79e1b1f0efce436b33bdd6da88745bfc8aPavlin Radoslavov break; 207978bcff79e1b1f0efce436b33bdd6da88745bfc8aPavlin Radoslavov 208078bcff79e1b1f0efce436b33bdd6da88745bfc8aPavlin Radoslavov case AVRC_PDU_GET_PLAYER_APP_ATTR_TEXT: 208178bcff79e1b1f0efce436b33bdd6da88745bfc8aPavlin Radoslavov avrc_response.get_app_attr_txt.status = BTIF_RC_STS_TIMEOUT; 208278bcff79e1b1f0efce436b33bdd6da88745bfc8aPavlin Radoslavov handle_app_attr_txt_response(&meta_msg, &avrc_response.get_app_attr_txt); 208378bcff79e1b1f0efce436b33bdd6da88745bfc8aPavlin Radoslavov break; 208478bcff79e1b1f0efce436b33bdd6da88745bfc8aPavlin Radoslavov 208578bcff79e1b1f0efce436b33bdd6da88745bfc8aPavlin Radoslavov case AVRC_PDU_GET_PLAYER_APP_VALUE_TEXT: 208678bcff79e1b1f0efce436b33bdd6da88745bfc8aPavlin Radoslavov avrc_response.get_app_val_txt.status = BTIF_RC_STS_TIMEOUT; 208778bcff79e1b1f0efce436b33bdd6da88745bfc8aPavlin Radoslavov handle_app_attr_txt_response(&meta_msg, &avrc_response.get_app_val_txt); 208878bcff79e1b1f0efce436b33bdd6da88745bfc8aPavlin Radoslavov break; 208978bcff79e1b1f0efce436b33bdd6da88745bfc8aPavlin Radoslavov 209078bcff79e1b1f0efce436b33bdd6da88745bfc8aPavlin Radoslavov case AVRC_PDU_GET_ELEMENT_ATTR: 209178bcff79e1b1f0efce436b33bdd6da88745bfc8aPavlin Radoslavov avrc_response.get_elem_attrs.status = BTIF_RC_STS_TIMEOUT; 209278bcff79e1b1f0efce436b33bdd6da88745bfc8aPavlin Radoslavov handle_get_elem_attr_response(&meta_msg, &avrc_response.get_elem_attrs); 209378bcff79e1b1f0efce436b33bdd6da88745bfc8aPavlin Radoslavov break; 209478bcff79e1b1f0efce436b33bdd6da88745bfc8aPavlin Radoslavov 209578bcff79e1b1f0efce436b33bdd6da88745bfc8aPavlin Radoslavov case AVRC_PDU_GET_PLAY_STATUS: 2096470466e6beea7ee10675ec780a2afa23bd8a3cd4AnubhavGupta avrc_response.get_play_status.status = BTIF_RC_STS_TIMEOUT; 2097470466e6beea7ee10675ec780a2afa23bd8a3cd4AnubhavGupta handle_get_playstatus_response(&meta_msg, &avrc_response.get_play_status); 209878bcff79e1b1f0efce436b33bdd6da88745bfc8aPavlin Radoslavov break; 209978bcff79e1b1f0efce436b33bdd6da88745bfc8aPavlin Radoslavov } 210078bcff79e1b1f0efce436b33bdd6da88745bfc8aPavlin Radoslavov release_transaction(p_context->rc_status_cmd.label); 21016b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta} 21026b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta 21036b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta/*************************************************************************** 21046b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta** 210578bcff79e1b1f0efce436b33bdd6da88745bfc8aPavlin Radoslavov** Function btif_rc_status_cmd_timer_timeout 21066b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta** 210778bcff79e1b1f0efce436b33bdd6da88745bfc8aPavlin Radoslavov** Description RC status command timeout callback. 210878bcff79e1b1f0efce436b33bdd6da88745bfc8aPavlin Radoslavov** This is called from BTU context and switches to BTIF 210978bcff79e1b1f0efce436b33bdd6da88745bfc8aPavlin Radoslavov** context to handle the timeout events 21106b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta** Returns None 21116b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta** 21126b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta***************************************************************************/ 211378bcff79e1b1f0efce436b33bdd6da88745bfc8aPavlin Radoslavovstatic void btif_rc_status_cmd_timer_timeout(void *data) 21146b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta{ 211578bcff79e1b1f0efce436b33bdd6da88745bfc8aPavlin Radoslavov btif_rc_timer_context_t *p_data = (btif_rc_timer_context_t *)data; 211678bcff79e1b1f0efce436b33bdd6da88745bfc8aPavlin Radoslavov 211778bcff79e1b1f0efce436b33bdd6da88745bfc8aPavlin Radoslavov btif_transfer_context(btif_rc_status_cmd_timeout_handler, 0, 211878bcff79e1b1f0efce436b33bdd6da88745bfc8aPavlin Radoslavov (char *)p_data, sizeof(btif_rc_timer_context_t), 211978bcff79e1b1f0efce436b33bdd6da88745bfc8aPavlin Radoslavov NULL); 21206b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta} 21216b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta 21226b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta/*************************************************************************** 21236b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta** 212478bcff79e1b1f0efce436b33bdd6da88745bfc8aPavlin Radoslavov** Function btif_rc_control_cmd_timeout_handler 21256b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta** 212678bcff79e1b1f0efce436b33bdd6da88745bfc8aPavlin Radoslavov** Description RC control command timeout handler (Runs in BTIF context). 21276b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta** Returns None 21286b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta** 21296b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta***************************************************************************/ 213078bcff79e1b1f0efce436b33bdd6da88745bfc8aPavlin Radoslavovstatic void btif_rc_control_cmd_timeout_handler(UNUSED_ATTR uint16_t event, 213178bcff79e1b1f0efce436b33bdd6da88745bfc8aPavlin Radoslavov char *data) 21326b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta{ 213378bcff79e1b1f0efce436b33bdd6da88745bfc8aPavlin Radoslavov btif_rc_timer_context_t *p_context = (btif_rc_timer_context_t *)data; 213478bcff79e1b1f0efce436b33bdd6da88745bfc8aPavlin Radoslavov tAVRC_RESPONSE avrc_response = {0}; 213578bcff79e1b1f0efce436b33bdd6da88745bfc8aPavlin Radoslavov tBTA_AV_META_MSG meta_msg; 213678bcff79e1b1f0efce436b33bdd6da88745bfc8aPavlin Radoslavov 213778bcff79e1b1f0efce436b33bdd6da88745bfc8aPavlin Radoslavov memset(&meta_msg, 0, sizeof(tBTA_AV_META_MSG)); 213878bcff79e1b1f0efce436b33bdd6da88745bfc8aPavlin Radoslavov meta_msg.rc_handle = btif_rc_cb.rc_handle; 213978bcff79e1b1f0efce436b33bdd6da88745bfc8aPavlin Radoslavov 214078bcff79e1b1f0efce436b33bdd6da88745bfc8aPavlin Radoslavov switch (p_context->rc_control_cmd.pdu_id) { 214178bcff79e1b1f0efce436b33bdd6da88745bfc8aPavlin Radoslavov case AVRC_PDU_SET_PLAYER_APP_VALUE: 214278bcff79e1b1f0efce436b33bdd6da88745bfc8aPavlin Radoslavov avrc_response.set_app_val.status = BTIF_RC_STS_TIMEOUT; 214378bcff79e1b1f0efce436b33bdd6da88745bfc8aPavlin Radoslavov handle_set_app_attr_val_response(&meta_msg, 214478bcff79e1b1f0efce436b33bdd6da88745bfc8aPavlin Radoslavov &avrc_response.set_app_val); 214578bcff79e1b1f0efce436b33bdd6da88745bfc8aPavlin Radoslavov break; 21466b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta } 214778bcff79e1b1f0efce436b33bdd6da88745bfc8aPavlin Radoslavov release_transaction(p_context->rc_control_cmd.label); 21486b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta} 21496b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta 21506b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta/*************************************************************************** 21516b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta** 215278bcff79e1b1f0efce436b33bdd6da88745bfc8aPavlin Radoslavov** Function btif_rc_control_cmd_timer_timeout 21536b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta** 215478bcff79e1b1f0efce436b33bdd6da88745bfc8aPavlin Radoslavov** Description RC control command timeout callback. 215578bcff79e1b1f0efce436b33bdd6da88745bfc8aPavlin Radoslavov** This is called from BTU context and switches to BTIF 215678bcff79e1b1f0efce436b33bdd6da88745bfc8aPavlin Radoslavov** context to handle the timeout events 21576b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta** Returns None 21586b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta** 21596b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta***************************************************************************/ 216078bcff79e1b1f0efce436b33bdd6da88745bfc8aPavlin Radoslavovstatic void btif_rc_control_cmd_timer_timeout(void *data) 21616b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta{ 216278bcff79e1b1f0efce436b33bdd6da88745bfc8aPavlin Radoslavov btif_rc_timer_context_t *p_data = (btif_rc_timer_context_t *)data; 21636b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta 216478bcff79e1b1f0efce436b33bdd6da88745bfc8aPavlin Radoslavov btif_transfer_context(btif_rc_control_cmd_timeout_handler, 0, 216578bcff79e1b1f0efce436b33bdd6da88745bfc8aPavlin Radoslavov (char *)p_data, sizeof(btif_rc_timer_context_t), 216678bcff79e1b1f0efce436b33bdd6da88745bfc8aPavlin Radoslavov NULL); 216778bcff79e1b1f0efce436b33bdd6da88745bfc8aPavlin Radoslavov} 21686b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta 216978bcff79e1b1f0efce436b33bdd6da88745bfc8aPavlin Radoslavov/*************************************************************************** 217078bcff79e1b1f0efce436b33bdd6da88745bfc8aPavlin Radoslavov** 217178bcff79e1b1f0efce436b33bdd6da88745bfc8aPavlin Radoslavov** Function btif_rc_play_status_timeout_handler 217278bcff79e1b1f0efce436b33bdd6da88745bfc8aPavlin Radoslavov** 217378bcff79e1b1f0efce436b33bdd6da88745bfc8aPavlin Radoslavov** Description RC play status timeout handler (Runs in BTIF context). 217478bcff79e1b1f0efce436b33bdd6da88745bfc8aPavlin Radoslavov** Returns None 217578bcff79e1b1f0efce436b33bdd6da88745bfc8aPavlin Radoslavov** 217678bcff79e1b1f0efce436b33bdd6da88745bfc8aPavlin Radoslavov***************************************************************************/ 217778bcff79e1b1f0efce436b33bdd6da88745bfc8aPavlin Radoslavovstatic void btif_rc_play_status_timeout_handler(UNUSED_ATTR uint16_t event, 217878bcff79e1b1f0efce436b33bdd6da88745bfc8aPavlin Radoslavov UNUSED_ATTR char *p_data) 217978bcff79e1b1f0efce436b33bdd6da88745bfc8aPavlin Radoslavov{ 218078bcff79e1b1f0efce436b33bdd6da88745bfc8aPavlin Radoslavov get_play_status_cmd(); 218178bcff79e1b1f0efce436b33bdd6da88745bfc8aPavlin Radoslavov rc_start_play_status_timer(); 218278bcff79e1b1f0efce436b33bdd6da88745bfc8aPavlin Radoslavov} 21836b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta 218478bcff79e1b1f0efce436b33bdd6da88745bfc8aPavlin Radoslavov/*************************************************************************** 218578bcff79e1b1f0efce436b33bdd6da88745bfc8aPavlin Radoslavov** 218678bcff79e1b1f0efce436b33bdd6da88745bfc8aPavlin Radoslavov** Function btif_rc_play_status_timer_timeout 218778bcff79e1b1f0efce436b33bdd6da88745bfc8aPavlin Radoslavov** 218878bcff79e1b1f0efce436b33bdd6da88745bfc8aPavlin Radoslavov** Description RC play status timeout callback. 218978bcff79e1b1f0efce436b33bdd6da88745bfc8aPavlin Radoslavov** This is called from BTU context and switches to BTIF 219078bcff79e1b1f0efce436b33bdd6da88745bfc8aPavlin Radoslavov** context to handle the timeout events 219178bcff79e1b1f0efce436b33bdd6da88745bfc8aPavlin Radoslavov** Returns None 219278bcff79e1b1f0efce436b33bdd6da88745bfc8aPavlin Radoslavov** 219378bcff79e1b1f0efce436b33bdd6da88745bfc8aPavlin Radoslavov***************************************************************************/ 219478bcff79e1b1f0efce436b33bdd6da88745bfc8aPavlin Radoslavovstatic void btif_rc_play_status_timer_timeout(UNUSED_ATTR void *data) 219578bcff79e1b1f0efce436b33bdd6da88745bfc8aPavlin Radoslavov{ 219678bcff79e1b1f0efce436b33bdd6da88745bfc8aPavlin Radoslavov btif_transfer_context(btif_rc_play_status_timeout_handler, 0, 0, 0, NULL); 219778bcff79e1b1f0efce436b33bdd6da88745bfc8aPavlin Radoslavov} 21986b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta 219978bcff79e1b1f0efce436b33bdd6da88745bfc8aPavlin Radoslavov/*************************************************************************** 220078bcff79e1b1f0efce436b33bdd6da88745bfc8aPavlin Radoslavov** 220178bcff79e1b1f0efce436b33bdd6da88745bfc8aPavlin Radoslavov** Function rc_start_play_status_timer 220278bcff79e1b1f0efce436b33bdd6da88745bfc8aPavlin Radoslavov** 220378bcff79e1b1f0efce436b33bdd6da88745bfc8aPavlin Radoslavov** Description Helper function to start the timer to fetch play status. 220478bcff79e1b1f0efce436b33bdd6da88745bfc8aPavlin Radoslavov** Returns None 220578bcff79e1b1f0efce436b33bdd6da88745bfc8aPavlin Radoslavov** 220678bcff79e1b1f0efce436b33bdd6da88745bfc8aPavlin Radoslavov***************************************************************************/ 220778bcff79e1b1f0efce436b33bdd6da88745bfc8aPavlin Radoslavovstatic void rc_start_play_status_timer(void) 220878bcff79e1b1f0efce436b33bdd6da88745bfc8aPavlin Radoslavov{ 220978bcff79e1b1f0efce436b33bdd6da88745bfc8aPavlin Radoslavov /* Start the Play status timer only if it is not started */ 221078bcff79e1b1f0efce436b33bdd6da88745bfc8aPavlin Radoslavov if (!alarm_is_scheduled(btif_rc_cb.rc_play_status_timer)) { 221178bcff79e1b1f0efce436b33bdd6da88745bfc8aPavlin Radoslavov if (btif_rc_cb.rc_play_status_timer == NULL) { 221278bcff79e1b1f0efce436b33bdd6da88745bfc8aPavlin Radoslavov btif_rc_cb.rc_play_status_timer = 221378bcff79e1b1f0efce436b33bdd6da88745bfc8aPavlin Radoslavov alarm_new("btif_rc.rc_play_status_timer"); 221478bcff79e1b1f0efce436b33bdd6da88745bfc8aPavlin Radoslavov } 221578bcff79e1b1f0efce436b33bdd6da88745bfc8aPavlin Radoslavov alarm_set_on_queue(btif_rc_cb.rc_play_status_timer, 221678bcff79e1b1f0efce436b33bdd6da88745bfc8aPavlin Radoslavov BTIF_TIMEOUT_RC_INTERIM_RSP_MS, 221778bcff79e1b1f0efce436b33bdd6da88745bfc8aPavlin Radoslavov btif_rc_play_status_timer_timeout, NULL, 221878bcff79e1b1f0efce436b33bdd6da88745bfc8aPavlin Radoslavov btu_general_alarm_queue); 22196b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta } 22206b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta} 22216b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta 22226b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta/*************************************************************************** 22236b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta** 222478bcff79e1b1f0efce436b33bdd6da88745bfc8aPavlin Radoslavov** Function rc_stop_play_status_timer 222578bcff79e1b1f0efce436b33bdd6da88745bfc8aPavlin Radoslavov** 222678bcff79e1b1f0efce436b33bdd6da88745bfc8aPavlin Radoslavov** Description Helper function to stop the play status timer. 222778bcff79e1b1f0efce436b33bdd6da88745bfc8aPavlin Radoslavov** Returns None 222878bcff79e1b1f0efce436b33bdd6da88745bfc8aPavlin Radoslavov** 222978bcff79e1b1f0efce436b33bdd6da88745bfc8aPavlin Radoslavov***************************************************************************/ 223078bcff79e1b1f0efce436b33bdd6da88745bfc8aPavlin Radoslavovvoid rc_stop_play_status_timer() 223178bcff79e1b1f0efce436b33bdd6da88745bfc8aPavlin Radoslavov{ 223278bcff79e1b1f0efce436b33bdd6da88745bfc8aPavlin Radoslavov if (btif_rc_cb.rc_play_status_timer != NULL) 223378bcff79e1b1f0efce436b33bdd6da88745bfc8aPavlin Radoslavov alarm_cancel(btif_rc_cb.rc_play_status_timer); 223478bcff79e1b1f0efce436b33bdd6da88745bfc8aPavlin Radoslavov} 223578bcff79e1b1f0efce436b33bdd6da88745bfc8aPavlin Radoslavov 223678bcff79e1b1f0efce436b33bdd6da88745bfc8aPavlin Radoslavov/*************************************************************************** 223778bcff79e1b1f0efce436b33bdd6da88745bfc8aPavlin Radoslavov** 22386b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta** Function register_for_event_notification 22396b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta** 22406b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta** Description Helper function registering notification events 22416b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta** sets an interim response timeout to handle if the remote 22426b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta** does not respond. 22436b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta** Returns None 22446b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta** 22456b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta***************************************************************************/ 224678bcff79e1b1f0efce436b33bdd6da88745bfc8aPavlin Radoslavovstatic void register_for_event_notification(btif_rc_supported_event_t *p_event) 22476b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta{ 22486b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta bt_status_t status; 22496b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta rc_transaction_t *p_transaction; 22506b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta 22516b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta status = get_transaction(&p_transaction); 22526b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta if (status == BT_STATUS_SUCCESS) 22536b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta { 225478bcff79e1b1f0efce436b33bdd6da88745bfc8aPavlin Radoslavov btif_rc_timer_context_t *p_context = &p_transaction->txn_timer_context; 22556b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta 22566b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta status = register_notification_cmd (p_transaction->lbl, p_event->event_id, 0); 22576b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta if (status != BT_STATUS_SUCCESS) 22586b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta { 22596b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta BTIF_TRACE_ERROR("%s Error in Notification registration %d", 22606b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta __FUNCTION__, status); 22616b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta release_transaction (p_transaction->lbl); 22626b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta return; 22636b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta } 22646b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta p_event->label = p_transaction->lbl; 22656b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta p_event->status = eREGISTERED; 226678bcff79e1b1f0efce436b33bdd6da88745bfc8aPavlin Radoslavov p_context->rc_status_cmd.label = p_transaction->lbl; 226778bcff79e1b1f0efce436b33bdd6da88745bfc8aPavlin Radoslavov p_context->rc_status_cmd.pdu_id = AVRC_PDU_REGISTER_NOTIFICATION; 226878bcff79e1b1f0efce436b33bdd6da88745bfc8aPavlin Radoslavov 226978bcff79e1b1f0efce436b33bdd6da88745bfc8aPavlin Radoslavov alarm_free(p_transaction->txn_timer); 227078bcff79e1b1f0efce436b33bdd6da88745bfc8aPavlin Radoslavov p_transaction->txn_timer = 227178bcff79e1b1f0efce436b33bdd6da88745bfc8aPavlin Radoslavov alarm_new("btif_rc.status_command_txn_timer"); 227278bcff79e1b1f0efce436b33bdd6da88745bfc8aPavlin Radoslavov alarm_set_on_queue(p_transaction->txn_timer, 227378bcff79e1b1f0efce436b33bdd6da88745bfc8aPavlin Radoslavov BTIF_TIMEOUT_RC_INTERIM_RSP_MS, 227478bcff79e1b1f0efce436b33bdd6da88745bfc8aPavlin Radoslavov btif_rc_status_cmd_timer_timeout, p_context, 227578bcff79e1b1f0efce436b33bdd6da88745bfc8aPavlin Radoslavov btu_general_alarm_queue); 22766b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta } 22776b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta else 22786b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta { 22796b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta BTIF_TRACE_ERROR("%s Error No more Transaction label %d", 22806b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta __FUNCTION__, status); 22816b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta } 22826b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta} 22836b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta 228478bcff79e1b1f0efce436b33bdd6da88745bfc8aPavlin Radoslavovstatic void start_status_command_timer(UINT8 pdu_id, rc_transaction_t *p_txn) 22856b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta{ 228678bcff79e1b1f0efce436b33bdd6da88745bfc8aPavlin Radoslavov btif_rc_timer_context_t *p_context = &p_txn->txn_timer_context; 228778bcff79e1b1f0efce436b33bdd6da88745bfc8aPavlin Radoslavov p_context->rc_status_cmd.label = p_txn->lbl; 228878bcff79e1b1f0efce436b33bdd6da88745bfc8aPavlin Radoslavov p_context->rc_status_cmd.pdu_id = pdu_id; 228978bcff79e1b1f0efce436b33bdd6da88745bfc8aPavlin Radoslavov 229078bcff79e1b1f0efce436b33bdd6da88745bfc8aPavlin Radoslavov alarm_free(p_txn->txn_timer); 229178bcff79e1b1f0efce436b33bdd6da88745bfc8aPavlin Radoslavov p_txn->txn_timer = alarm_new("btif_rc.status_command_txn_timer"); 229278bcff79e1b1f0efce436b33bdd6da88745bfc8aPavlin Radoslavov alarm_set_on_queue(p_txn->txn_timer, BTIF_TIMEOUT_RC_STATUS_CMD_MS, 229378bcff79e1b1f0efce436b33bdd6da88745bfc8aPavlin Radoslavov btif_rc_status_cmd_timer_timeout, p_context, 229478bcff79e1b1f0efce436b33bdd6da88745bfc8aPavlin Radoslavov btu_general_alarm_queue); 22956b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta} 22966b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta 229778bcff79e1b1f0efce436b33bdd6da88745bfc8aPavlin Radoslavovstatic void start_control_command_timer(UINT8 pdu_id, rc_transaction_t *p_txn) 22986b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta{ 229978bcff79e1b1f0efce436b33bdd6da88745bfc8aPavlin Radoslavov btif_rc_timer_context_t *p_context = &p_txn->txn_timer_context; 230078bcff79e1b1f0efce436b33bdd6da88745bfc8aPavlin Radoslavov p_context->rc_control_cmd.label = p_txn->lbl; 230178bcff79e1b1f0efce436b33bdd6da88745bfc8aPavlin Radoslavov p_context->rc_control_cmd.pdu_id = pdu_id; 230278bcff79e1b1f0efce436b33bdd6da88745bfc8aPavlin Radoslavov 230378bcff79e1b1f0efce436b33bdd6da88745bfc8aPavlin Radoslavov alarm_free(p_txn->txn_timer); 230478bcff79e1b1f0efce436b33bdd6da88745bfc8aPavlin Radoslavov p_txn->txn_timer = alarm_new("btif_rc.control_command_txn_timer"); 230578bcff79e1b1f0efce436b33bdd6da88745bfc8aPavlin Radoslavov alarm_set_on_queue(p_txn->txn_timer, 230678bcff79e1b1f0efce436b33bdd6da88745bfc8aPavlin Radoslavov BTIF_TIMEOUT_RC_CONTROL_CMD_MS, 230778bcff79e1b1f0efce436b33bdd6da88745bfc8aPavlin Radoslavov btif_rc_control_cmd_timer_timeout, p_context, 230878bcff79e1b1f0efce436b33bdd6da88745bfc8aPavlin Radoslavov btu_general_alarm_queue); 23096b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta} 23106b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta 23116b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta/*************************************************************************** 23126b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta** 23136b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta** Function handle_get_capability_response 23146b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta** 23156b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta** Description Handles the get_cap_response to populate company id info 23166b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta** and query the supported events. 23176b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta** Initiates Notification registration for events supported 23186b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta** Returns None 23196b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta** 23206b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta***************************************************************************/ 23216b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Guptastatic void handle_get_capability_response (tBTA_AV_META_MSG *pmeta_msg, tAVRC_GET_CAPS_RSP *p_rsp) 23226b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta{ 23236b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta int xx = 0; 23246b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta 23256b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta /* Todo: Do we need to retry on command timeout */ 23266b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta if (p_rsp->status != AVRC_STS_NO_ERROR) 23276b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta { 23286b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta BTIF_TRACE_ERROR("%s Error capability response 0x%02X", 23296b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta __FUNCTION__, p_rsp->status); 23306b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta return; 23316b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta } 23326b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta 23336b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta if (p_rsp->capability_id == AVRC_CAP_EVENTS_SUPPORTED) 23346b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta { 23356b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta btif_rc_supported_event_t *p_event; 23366b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta 23376b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta /* Todo: Check if list can be active when we hit here */ 2338abd70abb5e42c9431df94fe9d2c4a78a0d8d9af9Pavlin Radoslavov btif_rc_cb.rc_supported_event_list = list_new(osi_free); 23396b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta for (xx = 0; xx < p_rsp->count; xx++) 23406b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta { 23416b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta /* Skip registering for Play position change notification */ 23426b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta if ((p_rsp->param.event_id[xx] == AVRC_EVT_PLAY_STATUS_CHANGE)|| 23436b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta (p_rsp->param.event_id[xx] == AVRC_EVT_TRACK_CHANGE)|| 23446b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta (p_rsp->param.event_id[xx] == AVRC_EVT_APP_SETTING_CHANGE)) 23456b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta { 2346abd70abb5e42c9431df94fe9d2c4a78a0d8d9af9Pavlin Radoslavov p_event = (btif_rc_supported_event_t *)osi_malloc(sizeof(btif_rc_supported_event_t)); 23476b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta p_event->event_id = p_rsp->param.event_id[xx]; 23486b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta p_event->status = eNOT_REGISTERED; 23496b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta list_append(btif_rc_cb.rc_supported_event_list, p_event); 23506b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta } 23516b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta } 23526b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta p_event = list_front(btif_rc_cb.rc_supported_event_list); 23536b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta if (p_event != NULL) 23546b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta { 23556b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta register_for_event_notification(p_event); 23566b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta } 23576b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta } 23586b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta else if (p_rsp->capability_id == AVRC_CAP_COMPANY_ID) 23596b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta { 23606b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta getcapabilities_cmd (AVRC_CAP_EVENTS_SUPPORTED); 23616b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta BTIF_TRACE_EVENT("%s AVRC_CAP_COMPANY_ID: ", __FUNCTION__); 23626b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta for (xx = 0; xx < p_rsp->count; xx++) 23636b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta { 23646b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta BTIF_TRACE_EVENT("%s : %d", __FUNCTION__, p_rsp->param.company_id[xx]); 23656b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta } 23666b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta } 23676b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta} 23686b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta 23696b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Guptabool rc_is_track_id_valid (tAVRC_UID uid) 23706b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta{ 23716b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta tAVRC_UID invalid_uid = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}; 23726b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta 23736b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta if (memcmp(uid, invalid_uid, sizeof(tAVRC_UID)) == 0) 23746b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta { 23756b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta return false; 23766b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta } 23776b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta else 23786b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta { 23796b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta return true; 23806b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta } 23816b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta} 23826b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta 23836b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta/*************************************************************************** 23846b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta** 23856b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta** Function handle_notification_response 23866b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta** 23876b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta** Description Main handler for notification responses to registered events 23886b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta** 1. Register for unregistered event(in interim response path) 23896b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta** 2. After registering for all supported events, start 23906b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta** retrieving application settings and values 23916b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta** 3. Reregister for events on getting changed response 23926b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta** 4. Run play status timer for getting position when the 23936b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta** status changes to playing 23946b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta** 5. Get the Media details when the track change happens 23956b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta** or track change interim response is received with 23966b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta** valid track id 23976b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta** 6. HAL callback for play status change and application 23986b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta** setting change 23996b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta** Returns None 24006b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta** 24016b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta***************************************************************************/ 24026b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Guptastatic void handle_notification_response (tBTA_AV_META_MSG *pmeta_msg, tAVRC_REG_NOTIF_RSP *p_rsp) 24036b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta{ 24046b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta bt_bdaddr_t rc_addr; 24056b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta UINT32 attr_list[] = { 24066b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta AVRC_MEDIA_ATTR_ID_TITLE, 24076b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta AVRC_MEDIA_ATTR_ID_ARTIST, 24086b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta AVRC_MEDIA_ATTR_ID_ALBUM, 24096b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta AVRC_MEDIA_ATTR_ID_TRACK_NUM, 24106b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta AVRC_MEDIA_ATTR_ID_NUM_TRACKS, 24116b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta AVRC_MEDIA_ATTR_ID_GENRE, 24126b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta AVRC_MEDIA_ATTR_ID_PLAYING_TIME 24136b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta }; 24146b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta 24156b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta 24166b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta bdcpy(rc_addr.address, btif_rc_cb.rc_addr); 24176b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta 24186b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta if (pmeta_msg->code == AVRC_RSP_INTERIM) 24196b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta { 24206b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta btif_rc_supported_event_t *p_event; 24216b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta list_node_t *node; 24226b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta 24236b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta BTIF_TRACE_DEBUG("%s Interim response : 0x%2X ", __FUNCTION__, p_rsp->event_id); 24246b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta switch (p_rsp->event_id) 24256b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta { 24266b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta case AVRC_EVT_PLAY_STATUS_CHANGE: 24276b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta /* Start timer to get play status periodically 24286b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta * if the play state is playing. 24296b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta */ 24306b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta if (p_rsp->param.play_status == AVRC_PLAYSTATE_PLAYING) 24316b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta { 24326b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta rc_start_play_status_timer(); 24336b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta } 24346b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta HAL_CBACK(bt_rc_ctrl_callbacks, play_status_changed_cb, 24356b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta &rc_addr, p_rsp->param.play_status); 24366b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta break; 24376b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta 24386b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta case AVRC_EVT_TRACK_CHANGE: 24396b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta if (rc_is_track_id_valid (p_rsp->param.track) != true) 24406b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta { 24416b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta break; 24426b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta } 24436b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta else 24446b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta { 24456b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta UINT8 *p_data = p_rsp->param.track; 24466b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta /* Update the UID for current track 24476b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta * Attributes will be fetched after the AVRCP procedure 24486b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta */ 24496b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta BE_STREAM_TO_UINT64(btif_rc_cb.rc_playing_uid, p_data); 24506b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta } 24516b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta break; 24526b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta 24536b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta case AVRC_EVT_APP_SETTING_CHANGE: 24546b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta break; 24556b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta 24566b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta case AVRC_EVT_NOW_PLAYING_CHANGE: 24576b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta break; 24586b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta 24596b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta case AVRC_EVT_AVAL_PLAYERS_CHANGE: 24606b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta break; 24616b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta 24626b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta case AVRC_EVT_ADDR_PLAYER_CHANGE: 24636b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta break; 24646b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta 24656b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta case AVRC_EVT_UIDS_CHANGE: 24666b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta break; 24676b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta 24686b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta case AVRC_EVT_TRACK_REACHED_END: 24696b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta case AVRC_EVT_TRACK_REACHED_START: 24706b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta case AVRC_EVT_PLAY_POS_CHANGED: 24716b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta case AVRC_EVT_BATTERY_STATUS_CHANGE: 24726b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta case AVRC_EVT_SYSTEM_STATUS_CHANGE: 24736b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta default: 24746b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta BTIF_TRACE_ERROR("%s Unhandled interim response 0x%2X", __FUNCTION__, 24756b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta p_rsp->event_id); 24766b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta return; 24776b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta } 24786b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta list_foreach(btif_rc_cb.rc_supported_event_list, 247969a34362c65533155578623d30845b04fa6285b1Pavlin Radoslavov iterate_supported_event_list_for_interim_rsp, 248069a34362c65533155578623d30845b04fa6285b1Pavlin Radoslavov &p_rsp->event_id); 24816b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta 24826b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta node = list_begin(btif_rc_cb.rc_supported_event_list); 24836b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta while (node != NULL) 24846b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta { 24856b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta p_event = (btif_rc_supported_event_t *)list_node(node); 24866b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta if ((p_event != NULL) && (p_event->status == eNOT_REGISTERED)) 24876b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta { 24886b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta register_for_event_notification(p_event); 24896b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta break; 24906b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta } 24916b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta node = list_next (node); 24926b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta p_event = NULL; 24936b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta } 24946b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta /* Registered for all events, we can request application settings */ 24956b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta if ((p_event == NULL) && (btif_rc_cb.rc_app_settings.query_started == false)) 24966b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta { 24976b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta /* we need to do this only if remote TG supports 24986b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta * player application settings 24996b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta */ 25006b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta btif_rc_cb.rc_app_settings.query_started = TRUE; 25016b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta if (btif_rc_cb.rc_features & BTA_AV_FEAT_APP_SETTING) 25026b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta { 25036b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta list_player_app_setting_attrib_cmd(); 25046b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta } 25056b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta else 25066b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta { 25076b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta BTIF_TRACE_DEBUG("%s App setting not supported, complete procedure", __FUNCTION__); 25086b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta rc_ctrl_procedure_complete(); 25096b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta } 25106b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta } 25116b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta } 25126b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta else if (pmeta_msg->code == AVRC_RSP_CHANGED) 25136b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta { 25146b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta btif_rc_supported_event_t *p_event; 25156b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta list_node_t *node; 25166b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta 25176b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta BTIF_TRACE_DEBUG("%s Notification completed : 0x%2X ", __FUNCTION__, 25186b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta p_rsp->event_id); 25196b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta 25206b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta node = list_begin(btif_rc_cb.rc_supported_event_list); 25216b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta while (node != NULL) 25226b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta { 25236b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta p_event = (btif_rc_supported_event_t *)list_node(node); 25246b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta if ((p_event != NULL) && (p_event->event_id == p_rsp->event_id)) 25256b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta { 25266b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta p_event->status = eNOT_REGISTERED; 25276b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta register_for_event_notification(p_event); 25286b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta break; 25296b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta } 25306b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta node = list_next (node); 25316b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta } 25326b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta 25336b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta switch (p_rsp->event_id) 25346b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta { 25356b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta case AVRC_EVT_PLAY_STATUS_CHANGE: 25366b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta /* Start timer to get play status periodically 25376b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta * if the play state is playing. 25386b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta */ 25396b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta if (p_rsp->param.play_status == AVRC_PLAYSTATE_PLAYING) 25406b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta { 25416b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta rc_start_play_status_timer(); 25426b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta } 25436b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta else 25446b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta { 25456b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta rc_stop_play_status_timer(); 25466b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta } 25476b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta HAL_CBACK(bt_rc_ctrl_callbacks, play_status_changed_cb, 25486b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta &rc_addr, p_rsp->param.play_status); 25496b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta break; 25506b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta 25516b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta case AVRC_EVT_TRACK_CHANGE: 25526b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta if (rc_is_track_id_valid (p_rsp->param.track) != true) 25536b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta { 25546b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta break; 25556b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta } 25566b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta get_element_attribute_cmd (AVRC_MAX_NUM_MEDIA_ATTR_ID, attr_list); 25576b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta break; 25586b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta 25596b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta case AVRC_EVT_APP_SETTING_CHANGE: 25606b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta { 25616b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta btrc_player_settings_t app_settings; 25626b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta UINT16 xx; 25636b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta 25646b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta app_settings.num_attr = p_rsp->param.player_setting.num_attr; 25656b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta for (xx = 0; xx < app_settings.num_attr; xx++) 25666b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta { 25676b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta app_settings.attr_ids[xx] = p_rsp->param.player_setting.attr_id[xx]; 25686b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta app_settings.attr_values[xx] = p_rsp->param.player_setting.attr_value[xx]; 25696b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta } 25706b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta HAL_CBACK(bt_rc_ctrl_callbacks, playerapplicationsetting_changed_cb, 25716b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta &rc_addr, &app_settings); 25726b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta } 25736b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta break; 25746b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta 25756b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta case AVRC_EVT_NOW_PLAYING_CHANGE: 25766b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta break; 25776b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta 25786b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta case AVRC_EVT_AVAL_PLAYERS_CHANGE: 25796b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta break; 25806b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta 25816b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta case AVRC_EVT_ADDR_PLAYER_CHANGE: 25826b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta break; 25836b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta 25846b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta case AVRC_EVT_UIDS_CHANGE: 25856b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta break; 25866b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta 25876b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta case AVRC_EVT_TRACK_REACHED_END: 25886b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta case AVRC_EVT_TRACK_REACHED_START: 25896b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta case AVRC_EVT_PLAY_POS_CHANGED: 25906b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta case AVRC_EVT_BATTERY_STATUS_CHANGE: 25916b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta case AVRC_EVT_SYSTEM_STATUS_CHANGE: 25926b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta default: 25936b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta BTIF_TRACE_ERROR("%s Unhandled completion response 0x%2X", 25946b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta __FUNCTION__, p_rsp->event_id); 25956b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta return; 25966b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta } 25976b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta } 25986b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta} 25996b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta 26006b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta/*************************************************************************** 26016b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta** 26026b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta** Function handle_app_attr_response 26036b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta** 26046b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta** Description handles the the application attributes response and 26056b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta** initiates procedure to fetch the attribute values 26066b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta** Returns None 26076b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta** 26086b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta***************************************************************************/ 26096b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Guptastatic void handle_app_attr_response (tBTA_AV_META_MSG *pmeta_msg, tAVRC_LIST_APP_ATTR_RSP *p_rsp) 26106b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta{ 26116b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta UINT8 xx; 26126b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta 26136b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta if (p_rsp->status != AVRC_STS_NO_ERROR) 26146b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta { 26156b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta BTIF_TRACE_ERROR("%s Error getting Player application settings: 0x%2X", 26166b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta __FUNCTION__, p_rsp->status); 26176b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta rc_ctrl_procedure_complete(); 26186b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta return; 26196b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta } 26206b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta 26216b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta for (xx = 0; xx < p_rsp->num_attr; xx++) 26226b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta { 26236b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta UINT8 st_index; 26246b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta 26256b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta if (p_rsp->attrs[xx] > AVRC_PLAYER_SETTING_LOW_MENU_EXT) 26266b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta { 26276b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta st_index = btif_rc_cb.rc_app_settings.num_ext_attrs; 26286b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta btif_rc_cb.rc_app_settings.ext_attrs[st_index].attr_id = p_rsp->attrs[xx]; 26296b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta btif_rc_cb.rc_app_settings.num_ext_attrs++; 26306b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta } 26316b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta else 26326b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta { 26336b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta st_index = btif_rc_cb.rc_app_settings.num_attrs; 26346b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta btif_rc_cb.rc_app_settings.attrs[st_index].attr_id = p_rsp->attrs[xx]; 26356b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta btif_rc_cb.rc_app_settings.num_attrs++; 26366b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta } 26376b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta } 26386b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta btif_rc_cb.rc_app_settings.attr_index = 0; 26396b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta btif_rc_cb.rc_app_settings.ext_attr_index = 0; 26406b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta btif_rc_cb.rc_app_settings.ext_val_index = 0; 26416b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta if (p_rsp->num_attr) 26426b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta { 26436b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta list_player_app_setting_value_cmd (btif_rc_cb.rc_app_settings.attrs[0].attr_id); 26446b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta } 26456b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta else 26466b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta { 26476b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta BTIF_TRACE_ERROR("%s No Player application settings found", 26486b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta __FUNCTION__); 26496b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta } 26506b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta} 26516b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta 26526b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta/*************************************************************************** 26536b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta** 26546b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta** Function handle_app_val_response 26556b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta** 26566b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta** Description handles the the attributes value response and if extended 26576b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta** menu is available, it initiates query for the attribute 26586b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta** text. If not, it initiates procedure to get the current 26596b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta** attribute values and calls the HAL callback for provding 26606b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta** application settings information. 26616b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta** Returns None 26626b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta** 26636b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta***************************************************************************/ 26646b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Guptastatic void handle_app_val_response (tBTA_AV_META_MSG *pmeta_msg, tAVRC_LIST_APP_VALUES_RSP *p_rsp) 26656b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta{ 26666b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta UINT8 xx, attr_index; 26676b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta UINT8 attrs[AVRC_MAX_APP_ATTR_SIZE]; 26686b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta btif_rc_player_app_settings_t *p_app_settings; 26696b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta bt_bdaddr_t rc_addr; 26706b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta 26716b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta /* Todo: Do we need to retry on command timeout */ 26726b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta if (p_rsp->status != AVRC_STS_NO_ERROR) 26736b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta { 26746b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta BTIF_TRACE_ERROR("%s Error fetching attribute values 0x%02X", 26756b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta __FUNCTION__, p_rsp->status); 26766b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta return; 26776b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta } 26786b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta 26796b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta p_app_settings = &btif_rc_cb.rc_app_settings; 26806b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta bdcpy(rc_addr.address, btif_rc_cb.rc_addr); 26816b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta 26826b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta if (p_app_settings->attr_index < p_app_settings->num_attrs) 26836b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta { 26846b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta attr_index = p_app_settings->attr_index; 26856b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta p_app_settings->attrs[attr_index].num_val = p_rsp->num_val; 26866b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta for (xx = 0; xx < p_rsp->num_val; xx++) 26876b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta { 26886b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta p_app_settings->attrs[attr_index].attr_val[xx] = p_rsp->vals[xx]; 26896b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta } 26906b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta attr_index++; 26916b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta p_app_settings->attr_index++; 26926b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta if (attr_index < p_app_settings->num_attrs) 26936b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta { 26946b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta list_player_app_setting_value_cmd (p_app_settings->attrs[p_app_settings->attr_index].attr_id); 26956b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta } 26966b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta else if (p_app_settings->ext_attr_index < p_app_settings->num_ext_attrs) 26976b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta { 26986b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta attr_index = 0; 26996b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta p_app_settings->ext_attr_index = 0; 27006b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta list_player_app_setting_value_cmd (p_app_settings->ext_attrs[attr_index].attr_id); 27016b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta } 27026b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta else 27036b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta { 27046b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta for (xx = 0; xx < p_app_settings->num_attrs; xx++) 27056b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta { 27066b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta attrs[xx] = p_app_settings->attrs[xx].attr_id; 27076b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta } 27086b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta get_player_app_setting_cmd (p_app_settings->num_attrs, attrs); 27096b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta HAL_CBACK (bt_rc_ctrl_callbacks, playerapplicationsetting_cb, &rc_addr, 271012265e39b511f28425236b0dc97c78e7d837304bPavlin Radoslavov p_app_settings->num_attrs, p_app_settings->attrs, 0, NULL); 27116b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta } 27126b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta } 27136b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta else if (p_app_settings->ext_attr_index < p_app_settings->num_ext_attrs) 27146b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta { 27156b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta attr_index = p_app_settings->ext_attr_index; 27166b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta p_app_settings->ext_attrs[attr_index].num_val = p_rsp->num_val; 27176b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta for (xx = 0; xx < p_rsp->num_val; xx++) 27186b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta { 27196b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta p_app_settings->ext_attrs[attr_index].ext_attr_val[xx].val = p_rsp->vals[xx]; 27206b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta } 27216b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta attr_index++; 27226b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta p_app_settings->ext_attr_index++; 27236b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta if (attr_index < p_app_settings->num_ext_attrs) 27246b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta { 27256b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta list_player_app_setting_value_cmd (p_app_settings->ext_attrs[p_app_settings->ext_attr_index].attr_id); 27266b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta } 27276b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta else 27286b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta { 27296b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta UINT8 attr[AVRC_MAX_APP_ATTR_SIZE]; 27306b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta UINT8 xx; 27316b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta 27326b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta for (xx = 0; xx < p_app_settings->num_ext_attrs; xx++) 27336b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta { 27346b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta attr[xx] = p_app_settings->ext_attrs[xx].attr_id; 27356b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta } 27366b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta get_player_app_setting_attr_text_cmd(attr, xx); 27376b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta } 27386b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta } 27396b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta} 27406b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta 27416b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta/*************************************************************************** 27426b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta** 27436b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta** Function handle_app_cur_val_response 27446b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta** 27456b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta** Description handles the the get attributes value response. 27466b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta** 27476b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta** Returns None 27486b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta** 27496b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta***************************************************************************/ 27506b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Guptastatic void handle_app_cur_val_response (tBTA_AV_META_MSG *pmeta_msg, tAVRC_GET_CUR_APP_VALUE_RSP *p_rsp) 27516b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta{ 27526b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta btrc_player_settings_t app_settings; 27536b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta bt_bdaddr_t rc_addr; 27546b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta UINT16 xx; 27556b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta 27566b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta /* Todo: Do we need to retry on command timeout */ 27576b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta if (p_rsp->status != AVRC_STS_NO_ERROR) 27586b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta { 27596b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta BTIF_TRACE_ERROR("%s Error fetching current settings: 0x%02X", 27606b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta __FUNCTION__, p_rsp->status); 27616b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta return; 27626b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta } 27636b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta 27646b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta bdcpy(rc_addr.address, btif_rc_cb.rc_addr); 27656b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta 27666b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta app_settings.num_attr = p_rsp->num_val; 27676b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta for (xx = 0; xx < app_settings.num_attr; xx++) 27686b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta { 27696b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta app_settings.attr_ids[xx] = p_rsp->p_vals[xx].attr_id; 27706b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta app_settings.attr_values[xx] = p_rsp->p_vals[xx].attr_val; 27716b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta } 27726b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta HAL_CBACK(bt_rc_ctrl_callbacks, playerapplicationsetting_changed_cb, 27736b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta &rc_addr, &app_settings); 27746b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta /* Application settings are fetched only once for initial values 27756b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta * initiate anything that follows after RC procedure. 27766b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta * Defer it if browsing is supported till players query 27776b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta */ 27786b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta rc_ctrl_procedure_complete (); 2779abd70abb5e42c9431df94fe9d2c4a78a0d8d9af9Pavlin Radoslavov osi_free_and_reset((void **)&p_rsp->p_vals); 27806b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta} 27816b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta 27826b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta/*************************************************************************** 27836b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta** 27846b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta** Function handle_app_attr_txt_response 27856b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta** 27866b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta** Description handles the the get attributes text response, if fails 27876b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta** calls HAL callback with just normal settings and initiates 27886b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta** query for current settings else initiates query for value text 27896b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta** Returns None 27906b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta** 27916b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta***************************************************************************/ 27926b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Guptastatic void handle_app_attr_txt_response (tBTA_AV_META_MSG *pmeta_msg, tAVRC_GET_APP_ATTR_TXT_RSP *p_rsp) 27936b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta{ 279478bcff79e1b1f0efce436b33bdd6da88745bfc8aPavlin Radoslavov UINT8 xx; 27956b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta UINT8 vals[AVRC_MAX_APP_ATTR_SIZE]; 27966b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta btif_rc_player_app_settings_t *p_app_settings; 27976b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta bt_bdaddr_t rc_addr; 27986b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta 27996b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta p_app_settings = &btif_rc_cb.rc_app_settings; 28006b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta bdcpy(rc_addr.address, btif_rc_cb.rc_addr); 28016b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta 28026b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta /* Todo: Do we need to retry on command timeout */ 28036b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta if (p_rsp->status != AVRC_STS_NO_ERROR) 28046b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta { 28056b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta UINT8 attrs[AVRC_MAX_APP_ATTR_SIZE]; 28066b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta 28076b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta BTIF_TRACE_ERROR("%s Error fetching attribute text: 0x%02X", 28086b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta __FUNCTION__, p_rsp->status); 28096b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta /* Not able to fetch Text for extended Menu, skip the process 28106b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta * and cleanup used memory. Proceed to get the current settings 28116b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta * for standard attributes. 28126b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta */ 28136b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta p_app_settings->num_ext_attrs = 0; 28146b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta for (xx = 0; xx < p_app_settings->ext_attr_index; xx++) 2815abd70abb5e42c9431df94fe9d2c4a78a0d8d9af9Pavlin Radoslavov osi_free_and_reset((void **)&p_app_settings->ext_attrs[xx].p_str); 28166b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta p_app_settings->ext_attr_index = 0; 28176b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta 28186b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta for (xx = 0; xx < p_app_settings->num_attrs; xx++) 28196b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta { 28206b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta attrs[xx] = p_app_settings->attrs[xx].attr_id; 28216b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta } 28226b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta HAL_CBACK (bt_rc_ctrl_callbacks, playerapplicationsetting_cb, &rc_addr, 282312265e39b511f28425236b0dc97c78e7d837304bPavlin Radoslavov p_app_settings->num_attrs, p_app_settings->attrs, 0, NULL); 28246b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta 28256b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta get_player_app_setting_cmd (xx, attrs); 28266b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta return; 28276b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta } 28286b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta 28296b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta for (xx = 0; xx < p_rsp->num_attr; xx++) 28306b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta { 28316b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta UINT8 x; 28326b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta for (x = 0; x < p_app_settings->num_ext_attrs; x++) 28336b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta { 28346b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta if (p_app_settings->ext_attrs[x].attr_id == p_rsp->p_attrs[xx].attr_id) 28356b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta { 28366b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta p_app_settings->ext_attrs[x].charset_id = p_rsp->p_attrs[xx].charset_id; 28376b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta p_app_settings->ext_attrs[x].str_len = p_rsp->p_attrs[xx].str_len; 28386b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta p_app_settings->ext_attrs[x].p_str = p_rsp->p_attrs[xx].p_str; 28396b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta break; 28406b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta } 28416b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta } 28426b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta } 28436b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta 28446b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta for (xx = 0; xx < p_app_settings->ext_attrs[0].num_val; xx++) 28456b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta { 28466b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta vals[xx] = p_app_settings->ext_attrs[0].ext_attr_val[xx].val; 28476b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta } 28486b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta get_player_app_setting_value_text_cmd(vals, xx); 28496b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta} 28506b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta 28516b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta 28526b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta/*************************************************************************** 28536b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta** 28546b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta** Function handle_app_attr_val_txt_response 28556b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta** 28566b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta** Description handles the the get attributes value text response, if fails 28576b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta** calls HAL callback with just normal settings and initiates 28586b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta** query for current settings 28596b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta** Returns None 28606b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta** 28616b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta***************************************************************************/ 28626b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Guptastatic void handle_app_attr_val_txt_response (tBTA_AV_META_MSG *pmeta_msg, tAVRC_GET_APP_ATTR_TXT_RSP *p_rsp) 28636b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta{ 28646b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta UINT8 xx, attr_index; 28656b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta UINT8 vals[AVRC_MAX_APP_ATTR_SIZE]; 28666b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta UINT8 attrs[AVRC_MAX_APP_ATTR_SIZE]; 28676b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta btif_rc_player_app_settings_t *p_app_settings; 28686b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta bt_bdaddr_t rc_addr; 28696b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta 28706b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta bdcpy(rc_addr.address, btif_rc_cb.rc_addr); 28716b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta p_app_settings = &btif_rc_cb.rc_app_settings; 28726b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta 28736b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta /* Todo: Do we need to retry on command timeout */ 28746b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta if (p_rsp->status != AVRC_STS_NO_ERROR) 28756b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta { 28766b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta UINT8 attrs[AVRC_MAX_APP_ATTR_SIZE]; 28776b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta 28786b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta BTIF_TRACE_ERROR("%s Error fetching attribute value text: 0x%02X", 28796b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta __FUNCTION__, p_rsp->status); 28806b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta 28816b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta /* Not able to fetch Text for extended Menu, skip the process 28826b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta * and cleanup used memory. Proceed to get the current settings 28836b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta * for standard attributes. 28846b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta */ 28856b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta p_app_settings->num_ext_attrs = 0; 28866b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta for (xx = 0; xx < p_app_settings->ext_attr_index; xx++) 28876b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta { 28886b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta int x; 28896b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta btrc_player_app_ext_attr_t *p_ext_attr = &p_app_settings->ext_attrs[xx]; 28906b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta 28916b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta for (x = 0; x < p_ext_attr->num_val; x++) 2892abd70abb5e42c9431df94fe9d2c4a78a0d8d9af9Pavlin Radoslavov osi_free_and_reset((void **)&p_ext_attr->ext_attr_val[x].p_str); 28936b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta p_ext_attr->num_val = 0; 2894abd70abb5e42c9431df94fe9d2c4a78a0d8d9af9Pavlin Radoslavov osi_free_and_reset((void **)&p_app_settings->ext_attrs[xx].p_str); 28956b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta } 28966b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta p_app_settings->ext_attr_index = 0; 28976b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta 28986b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta for (xx = 0; xx < p_app_settings->num_attrs; xx++) 28996b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta { 29006b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta attrs[xx] = p_app_settings->attrs[xx].attr_id; 29016b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta } 29026b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta HAL_CBACK (bt_rc_ctrl_callbacks, playerapplicationsetting_cb, &rc_addr, 290312265e39b511f28425236b0dc97c78e7d837304bPavlin Radoslavov p_app_settings->num_attrs, p_app_settings->attrs, 0, NULL); 29046b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta 29056b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta get_player_app_setting_cmd (xx, attrs); 29066b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta return; 29076b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta } 29086b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta 29096b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta for (xx = 0; xx < p_rsp->num_attr; xx++) 29106b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta { 29116b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta UINT8 x; 29126b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta btrc_player_app_ext_attr_t *p_ext_attr; 29136b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta p_ext_attr = &p_app_settings->ext_attrs[p_app_settings->ext_val_index]; 29146b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta for (x = 0; x < p_rsp->num_attr; x++) 29156b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta { 29166b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta if (p_ext_attr->ext_attr_val[x].val == p_rsp->p_attrs[xx].attr_id) 29176b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta { 29186b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta p_ext_attr->ext_attr_val[x].charset_id = p_rsp->p_attrs[xx].charset_id; 29196b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta p_ext_attr->ext_attr_val[x].str_len = p_rsp->p_attrs[xx].str_len; 29206b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta p_ext_attr->ext_attr_val[x].p_str = p_rsp->p_attrs[xx].p_str; 29216b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta break; 29226b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta } 29236b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta } 29246b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta } 29256b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta p_app_settings->ext_val_index++; 29266b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta 29276b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta if (p_app_settings->ext_val_index < p_app_settings->num_ext_attrs) 29286b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta { 29296b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta attr_index = p_app_settings->ext_val_index; 29306b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta for (xx = 0; xx < p_app_settings->ext_attrs[attr_index].num_val; xx++) 29316b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta { 29326b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta vals[xx] = p_app_settings->ext_attrs[attr_index].ext_attr_val[xx].val; 29336b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta } 29346b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta get_player_app_setting_value_text_cmd(vals, xx); 29356b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta } 29366b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta else 29376b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta { 29386b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta UINT8 x; 29396b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta 29406b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta for (xx = 0; xx < p_app_settings->num_attrs; xx++) 29416b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta { 29426b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta attrs[xx] = p_app_settings->attrs[xx].attr_id; 29436b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta } 29446b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta for (x = 0; x < p_app_settings->num_ext_attrs; x++) 29456b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta { 29466b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta attrs[xx+x] = p_app_settings->ext_attrs[x].attr_id; 29476b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta } 29486b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta HAL_CBACK (bt_rc_ctrl_callbacks, playerapplicationsetting_cb, &rc_addr, 294912265e39b511f28425236b0dc97c78e7d837304bPavlin Radoslavov p_app_settings->num_attrs, p_app_settings->attrs, 295012265e39b511f28425236b0dc97c78e7d837304bPavlin Radoslavov p_app_settings->num_ext_attrs, p_app_settings->ext_attrs); 29516b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta get_player_app_setting_cmd (xx + x, attrs); 29526b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta 29536b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta /* Free the application settings information after sending to 29546b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta * application. 29556b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta */ 29566b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta for (xx = 0; xx < p_app_settings->ext_attr_index; xx++) 29576b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta { 29586b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta int x; 29596b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta btrc_player_app_ext_attr_t *p_ext_attr = &p_app_settings->ext_attrs[xx]; 29606b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta 29616b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta for (x = 0; x < p_ext_attr->num_val; x++) 2962abd70abb5e42c9431df94fe9d2c4a78a0d8d9af9Pavlin Radoslavov osi_free_and_reset((void **)&p_ext_attr->ext_attr_val[x].p_str); 29636b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta p_ext_attr->num_val = 0; 2964abd70abb5e42c9431df94fe9d2c4a78a0d8d9af9Pavlin Radoslavov osi_free_and_reset((void **)&p_app_settings->ext_attrs[xx].p_str); 29656b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta } 29666b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta p_app_settings->num_attrs = 0; 29676b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta } 29686b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta} 29696b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta 29706b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta/*************************************************************************** 29716b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta** 29726b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta** Function handle_set_app_attr_val_response 29736b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta** 29746b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta** Description handles the the set attributes value response, if fails 29756b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta** calls HAL callback to indicate the failure 29766b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta** Returns None 29776b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta** 29786b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta***************************************************************************/ 29796b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Guptastatic void handle_set_app_attr_val_response (tBTA_AV_META_MSG *pmeta_msg, tAVRC_RSP *p_rsp) 29806b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta{ 29816b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta uint8_t accepted = 0; 29826b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta bt_bdaddr_t rc_addr; 29836b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta 29846b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta bdcpy(rc_addr.address, btif_rc_cb.rc_addr); 29856b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta 29866b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta /* For timeout pmeta_msg will be NULL, else we need to 29876b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta * check if this is accepted by TG 29886b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta */ 29896b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta if (pmeta_msg && (pmeta_msg->code == AVRC_RSP_ACCEPT)) 29906b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta { 29916b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta accepted = 1; 29926b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta } 29936b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta HAL_CBACK(bt_rc_ctrl_callbacks, setplayerappsetting_rsp_cb, &rc_addr, accepted); 29946b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta} 29956b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta 29966b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta/*************************************************************************** 29976b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta** 29986b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta** Function handle_get_elem_attr_response 29996b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta** 30006b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta** Description handles the the element attributes response, calls 30016b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta** HAL callback to update track change information. 30026b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta** Returns None 30036b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta** 30046b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta***************************************************************************/ 30055fe6f0cf6b223e3ed6be4912d55b3ed5b41ce0cdPavlin Radoslavovstatic void handle_get_elem_attr_response (tBTA_AV_META_MSG *pmeta_msg, 30065fe6f0cf6b223e3ed6be4912d55b3ed5b41ce0cdPavlin Radoslavov tAVRC_GET_ELEM_ATTRS_RSP *p_rsp) 30076b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta{ 30085fe6f0cf6b223e3ed6be4912d55b3ed5b41ce0cdPavlin Radoslavov if (p_rsp->status == AVRC_STS_NO_ERROR) { 30095fe6f0cf6b223e3ed6be4912d55b3ed5b41ce0cdPavlin Radoslavov bt_bdaddr_t rc_addr; 30105fe6f0cf6b223e3ed6be4912d55b3ed5b41ce0cdPavlin Radoslavov size_t buf_size = p_rsp->num_attr * sizeof(btrc_element_attr_val_t); 30115fe6f0cf6b223e3ed6be4912d55b3ed5b41ce0cdPavlin Radoslavov btrc_element_attr_val_t *p_attr = 30125fe6f0cf6b223e3ed6be4912d55b3ed5b41ce0cdPavlin Radoslavov (btrc_element_attr_val_t *)osi_calloc(buf_size); 30136b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta 30145fe6f0cf6b223e3ed6be4912d55b3ed5b41ce0cdPavlin Radoslavov bdcpy(rc_addr.address, btif_rc_cb.rc_addr); 30156b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta 30165fe6f0cf6b223e3ed6be4912d55b3ed5b41ce0cdPavlin Radoslavov for (int i = 0; i < p_rsp->num_attr; i++) { 30175fe6f0cf6b223e3ed6be4912d55b3ed5b41ce0cdPavlin Radoslavov p_attr[i].attr_id = p_rsp->p_attrs[i].attr_id; 301878bcff79e1b1f0efce436b33bdd6da88745bfc8aPavlin Radoslavov /* Todo. Legth limit check to include null */ 30195fe6f0cf6b223e3ed6be4912d55b3ed5b41ce0cdPavlin Radoslavov if (p_rsp->p_attrs[i].name.str_len && 30205fe6f0cf6b223e3ed6be4912d55b3ed5b41ce0cdPavlin Radoslavov p_rsp->p_attrs[i].name.p_str) { 30215fe6f0cf6b223e3ed6be4912d55b3ed5b41ce0cdPavlin Radoslavov memcpy(p_attr[i].text, p_rsp->p_attrs[i].name.p_str, 30225fe6f0cf6b223e3ed6be4912d55b3ed5b41ce0cdPavlin Radoslavov p_rsp->p_attrs[i].name.str_len); 30235fe6f0cf6b223e3ed6be4912d55b3ed5b41ce0cdPavlin Radoslavov osi_free_and_reset((void **)&p_rsp->p_attrs[i].name.p_str); 30246b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta } 30256b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta } 302678bcff79e1b1f0efce436b33bdd6da88745bfc8aPavlin Radoslavov HAL_CBACK(bt_rc_ctrl_callbacks, track_changed_cb, 302778bcff79e1b1f0efce436b33bdd6da88745bfc8aPavlin Radoslavov &rc_addr, p_rsp->num_attr, p_attr); 3028abd70abb5e42c9431df94fe9d2c4a78a0d8d9af9Pavlin Radoslavov osi_free(p_attr); 30295fe6f0cf6b223e3ed6be4912d55b3ed5b41ce0cdPavlin Radoslavov } else if (p_rsp->status == BTIF_RC_STS_TIMEOUT) { 30306b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta /* Retry for timeout case, this covers error handling 30316b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta * for continuation failure also. 30326b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta */ 30336b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta UINT32 attr_list[] = { 30346b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta AVRC_MEDIA_ATTR_ID_TITLE, 30356b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta AVRC_MEDIA_ATTR_ID_ARTIST, 30366b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta AVRC_MEDIA_ATTR_ID_ALBUM, 30376b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta AVRC_MEDIA_ATTR_ID_TRACK_NUM, 30386b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta AVRC_MEDIA_ATTR_ID_NUM_TRACKS, 30396b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta AVRC_MEDIA_ATTR_ID_GENRE, 30406b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta AVRC_MEDIA_ATTR_ID_PLAYING_TIME 30416b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta }; 30426b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta get_element_attribute_cmd (AVRC_MAX_NUM_MEDIA_ATTR_ID, attr_list); 30435fe6f0cf6b223e3ed6be4912d55b3ed5b41ce0cdPavlin Radoslavov } else { 30446b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta BTIF_TRACE_ERROR("%s: Error in get element attr procedure %d", 30455fe6f0cf6b223e3ed6be4912d55b3ed5b41ce0cdPavlin Radoslavov __func__, p_rsp->status); 30466b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta } 30476b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta} 30486b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta 30496b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta/*************************************************************************** 30506b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta** 30516b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta** Function handle_get_playstatus_response 30526b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta** 30536b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta** Description handles the the play status response, calls 30546b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta** HAL callback to update play position. 30556b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta** Returns None 30566b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta** 30576b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta***************************************************************************/ 30586b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Guptastatic void handle_get_playstatus_response (tBTA_AV_META_MSG *pmeta_msg, tAVRC_GET_PLAY_STATUS_RSP *p_rsp) 30596b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta{ 30606b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta bt_bdaddr_t rc_addr; 30616b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta 30626b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta bdcpy(rc_addr.address, btif_rc_cb.rc_addr); 30636b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta 30646b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta if (p_rsp->status == AVRC_STS_NO_ERROR) 30656b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta { 30666b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta HAL_CBACK(bt_rc_ctrl_callbacks, play_position_changed_cb, 30676b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta &rc_addr, p_rsp->song_len, p_rsp->song_pos); 30686b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta } 30696b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta else 30706b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta { 30716b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta BTIF_TRACE_ERROR("%s: Error in get play status procedure %d", 30726b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta __FUNCTION__, p_rsp->status); 30736b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta } 30746b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta} 30756b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta 30766b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta/*************************************************************************** 30776b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta** 30786b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta** Function clear_cmd_timeout 30796b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta** 30806b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta** Description helper function to stop the command timeout timer 30816b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta** Returns None 30826b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta** 30836b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta***************************************************************************/ 30846b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Guptastatic void clear_cmd_timeout (UINT8 label) 30856b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta{ 30866b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta rc_transaction_t *p_txn; 30876b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta 30886b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta p_txn = get_transaction_by_lbl (label); 30896b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta if (p_txn == NULL) 30906b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta { 30916b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta BTIF_TRACE_ERROR("%s: Error in transaction label lookup", __FUNCTION__); 30926b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta return; 30936b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta } 30946b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta 309578bcff79e1b1f0efce436b33bdd6da88745bfc8aPavlin Radoslavov if (p_txn->txn_timer != NULL) 309678bcff79e1b1f0efce436b33bdd6da88745bfc8aPavlin Radoslavov alarm_cancel(p_txn->txn_timer); 30976b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta} 30986b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta 30996b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta/*************************************************************************** 31006b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta** 31016b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta** Function handle_avk_rc_metamsg_rsp 31026b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta** 31036b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta** Description Handle RC metamessage response 31046b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta** 31056b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta** Returns void 31066b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta** 31076b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta***************************************************************************/ 31086b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Guptastatic void handle_avk_rc_metamsg_rsp(tBTA_AV_META_MSG *pmeta_msg) 31096b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta{ 31106b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta tAVRC_RESPONSE avrc_response = {0}; 31116b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta UINT8 scratch_buf[512] = {0};// this variable is unused 31126b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta UINT16 buf_len; 31136b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta tAVRC_STS status; 31146b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta 31156b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta BTIF_TRACE_DEBUG("%s opcode = %d rsp_code = %d ", __FUNCTION__, 31166b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta pmeta_msg->p_msg->hdr.opcode, pmeta_msg->code); 31176b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta 31186b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta if ((AVRC_OP_VENDOR == pmeta_msg->p_msg->hdr.opcode)&& 31196b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta (pmeta_msg->code >= AVRC_RSP_NOT_IMPL)&& 31206b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta (pmeta_msg->code <= AVRC_RSP_INTERIM)) 31216b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta { 31226b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta status = AVRC_Ctrl_ParsResponse(pmeta_msg->p_msg, &avrc_response, scratch_buf, &buf_len); 31236b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta BTIF_TRACE_DEBUG("%s parse status %d pdu = %d rsp_status = %d", 31246b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta __FUNCTION__, status, avrc_response.pdu, 31256b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta pmeta_msg->p_msg->vendor.hdr.ctype); 31266b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta 31276b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta switch (avrc_response.pdu) 31286b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta { 31296b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta case AVRC_PDU_REGISTER_NOTIFICATION: 31306b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta handle_notification_response(pmeta_msg, &avrc_response.reg_notif); 31316b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta if (pmeta_msg->code == AVRC_RSP_INTERIM) 31326b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta { 31336b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta /* Don't free the transaction Id */ 31346b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta clear_cmd_timeout (pmeta_msg->label); 31356b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta return; 31366b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta } 31376b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta break; 31386b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta 31396b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta case AVRC_PDU_GET_CAPABILITIES: 31406b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta handle_get_capability_response(pmeta_msg, &avrc_response.get_caps); 31416b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta break; 31426b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta 31436b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta case AVRC_PDU_LIST_PLAYER_APP_ATTR: 31446b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta handle_app_attr_response(pmeta_msg, &avrc_response.list_app_attr); 31456b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta break; 31466b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta 31476b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta case AVRC_PDU_LIST_PLAYER_APP_VALUES: 31486b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta handle_app_val_response(pmeta_msg, &avrc_response.list_app_values); 31496b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta break; 31506b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta 31516b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta case AVRC_PDU_GET_CUR_PLAYER_APP_VALUE: 31526b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta handle_app_cur_val_response(pmeta_msg, &avrc_response.get_cur_app_val); 31536b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta break; 31546b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta 31556b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta case AVRC_PDU_GET_PLAYER_APP_ATTR_TEXT: 31566b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta handle_app_attr_txt_response(pmeta_msg, &avrc_response.get_app_attr_txt); 31576b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta break; 31586b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta 31596b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta case AVRC_PDU_GET_PLAYER_APP_VALUE_TEXT: 31606b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta handle_app_attr_val_txt_response(pmeta_msg, &avrc_response.get_app_val_txt); 31616b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta break; 31626b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta 31636b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta case AVRC_PDU_SET_PLAYER_APP_VALUE: 31646b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta handle_set_app_attr_val_response(pmeta_msg, &avrc_response.set_app_val); 31656b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta break; 31666b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta 31676b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta case AVRC_PDU_GET_ELEMENT_ATTR: 31686b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta handle_get_elem_attr_response(pmeta_msg, &avrc_response.get_elem_attrs); 31696b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta break; 31706b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta 31716b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta case AVRC_PDU_GET_PLAY_STATUS: 31726b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta handle_get_playstatus_response(pmeta_msg, &avrc_response.get_play_status); 31736b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta break; 31746b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta } 31756b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta release_transaction(pmeta_msg->label); 31766b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta } 31776b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta else 31786b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta { 31796b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta BTIF_TRACE_DEBUG("%s:Invalid Vendor Command code: %d len: %d. Not processing it.", 31806b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta __FUNCTION__, pmeta_msg->code, pmeta_msg->len); 31816b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta return; 31826b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta } 31836b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta} 31846b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta 31856b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta/*************************************************************************** 31866b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta** 31876b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta** Function handle_avk_rc_metamsg_cmd 31886b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta** 31896b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta** Description Handle RC metamessage response 31906b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta** 31916b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta** Returns void 31926b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta** 31936b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta***************************************************************************/ 31946b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Guptastatic void handle_avk_rc_metamsg_cmd(tBTA_AV_META_MSG *pmeta_msg) 31956b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta{ 31966b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta tAVRC_COMMAND avrc_cmd = {0}; 31976b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta tAVRC_STS status = BT_STATUS_UNSUPPORTED; 31986b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta BTIF_TRACE_DEBUG("%s opcode = %d rsp_code = %d ",__FUNCTION__, 31996b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta pmeta_msg->p_msg->hdr.opcode,pmeta_msg->code); 32006b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta if ((AVRC_OP_VENDOR==pmeta_msg->p_msg->hdr.opcode)&& 32016b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta (pmeta_msg->code <= AVRC_CMD_GEN_INQ)) 32026b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta { 32036b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta status = AVRC_Ctrl_ParsCommand(pmeta_msg->p_msg, &avrc_cmd); 32046b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta BTIF_TRACE_DEBUG("%s Received vendor command.code %d, PDU %d label %d", 32056b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta __FUNCTION__, pmeta_msg->code, avrc_cmd.pdu, pmeta_msg->label); 32066b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta 32076b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta if (status != AVRC_STS_NO_ERROR) 32086b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta { 32096b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta /* return error */ 32106b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta BTIF_TRACE_WARNING("%s: Error in parsing received metamsg command. status: 0x%02x", 32116b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta __FUNCTION__, status); 32126b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta send_reject_response(pmeta_msg->rc_handle, pmeta_msg->label, avrc_cmd.pdu, status); 32136b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta } 32146b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta else 32156b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta { 32166b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta if (avrc_cmd.pdu == AVRC_PDU_REGISTER_NOTIFICATION) 32176b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta { 32186b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta UINT8 event_id = avrc_cmd.reg_notif.event_id; 32196b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta BTIF_TRACE_EVENT("%s:Register notification event_id: %s", 32206b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta __FUNCTION__, dump_rc_notification_event_id(event_id)); 32216b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta } 32226b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta else if (avrc_cmd.pdu == AVRC_PDU_SET_ABSOLUTE_VOLUME) 32236b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta { 32246b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta BTIF_TRACE_EVENT("%s: Abs Volume Cmd Recvd", __FUNCTION__); 32256b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta } 32266b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta btif_rc_ctrl_upstreams_rsp_cmd(avrc_cmd.pdu, &avrc_cmd, pmeta_msg->label); 32276b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta } 32286b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta } 32296b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta else 32306b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta { 32316b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta BTIF_TRACE_DEBUG("%s:Invalid Vendor Command code: %d len: %d. Not processing it.", 32326b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta __FUNCTION__, pmeta_msg->code, pmeta_msg->len); 32336b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta return; 32346b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta } 32356b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta} 32366b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta#endif 32376b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta 32386b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta/*************************************************************************** 32396b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta** 32406b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta** Function cleanup 32416b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta** 32426b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta** Description Closes the AVRC interface 32436b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta** 32446b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta** Returns void 32456b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta** 32466b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta***************************************************************************/ 32476b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Guptastatic void cleanup() 32486b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta{ 32496b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta BTIF_TRACE_EVENT("## %s ##", __FUNCTION__); 32506b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta close_uinput(); 32516b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta if (bt_rc_callbacks) 32526b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta { 32536b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta bt_rc_callbacks = NULL; 32546b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta } 325578bcff79e1b1f0efce436b33bdd6da88745bfc8aPavlin Radoslavov alarm_free(btif_rc_cb.rc_play_status_timer); 32566b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta memset(&btif_rc_cb, 0, sizeof(btif_rc_cb_t)); 32576b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta lbl_destroy(); 32586b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta BTIF_TRACE_EVENT("## %s ## completed", __FUNCTION__); 32596b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta} 32606b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta 32616b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta/*************************************************************************** 32626b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta** 32636b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta** Function cleanup_ctrl 32646b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta** 32656b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta** Description Closes the AVRC Controller interface 32666b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta** 32676b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta** Returns void 32686b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta** 32696b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta***************************************************************************/ 32706b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Guptastatic void cleanup_ctrl() 32716b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta{ 32726b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta BTIF_TRACE_EVENT("## %s ##", __FUNCTION__); 32736b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta 32746b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta if (bt_rc_ctrl_callbacks) 32756b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta { 32766b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta bt_rc_ctrl_callbacks = NULL; 32776b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta } 327878bcff79e1b1f0efce436b33bdd6da88745bfc8aPavlin Radoslavov alarm_free(btif_rc_cb.rc_play_status_timer); 32796b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta memset(&btif_rc_cb, 0, sizeof(btif_rc_cb_t)); 32806b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta lbl_destroy(); 32816b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta BTIF_TRACE_EVENT("## %s ## completed", __FUNCTION__); 32826b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta} 32836b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta 32846b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta/*************************************************************************** 32856b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta** 32866b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta** Function getcapabilities_cmd 32876b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta** 32886b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta** Description GetCapabilties from Remote(Company_ID, Events_Supported) 32896b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta** 32906b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta** Returns void 32916b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta** 32926b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta***************************************************************************/ 32936b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Guptastatic bt_status_t getcapabilities_cmd (uint8_t cap_id) 32946b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta{ 32956b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta tAVRC_STS status = BT_STATUS_UNSUPPORTED; 32966b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta rc_transaction_t *p_transaction = NULL; 32976b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta#if (AVRC_CTLR_INCLUDED == TRUE) 32986b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta BTIF_TRACE_DEBUG("%s: cap_id %d", __FUNCTION__, cap_id); 32996b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta CHECK_RC_CONNECTED 33006b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta bt_status_t tran_status=get_transaction(&p_transaction); 33016b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta if (BT_STATUS_SUCCESS != tran_status) 33026b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta return BT_STATUS_FAIL; 33036b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta 33046b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta tAVRC_COMMAND avrc_cmd = {0}; 33056b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta BT_HDR *p_msg = NULL; 33066b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta avrc_cmd.get_caps.opcode = AVRC_OP_VENDOR; 33076b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta avrc_cmd.get_caps.capability_id = cap_id; 33086b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta avrc_cmd.get_caps.pdu = AVRC_PDU_GET_CAPABILITIES; 33096b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta avrc_cmd.get_caps.status = AVRC_STS_NO_ERROR; 33106b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta status = AVRC_BldCommand(&avrc_cmd, &p_msg); 33116b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta if ((status == AVRC_STS_NO_ERROR)&&(p_msg != NULL)) 33126b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta { 33136b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta UINT8* data_start = (UINT8*)(p_msg + 1) + p_msg->offset; 33146b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta BTIF_TRACE_DEBUG("%s msgreq being sent out with label %d", 33156b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta __FUNCTION__,p_transaction->lbl); 33166b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta BTA_AvVendorCmd(btif_rc_cb.rc_handle,p_transaction->lbl,AVRC_CMD_STATUS, 33176b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta data_start, p_msg->len); 33186b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta status = BT_STATUS_SUCCESS; 33196b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta start_status_command_timer (AVRC_PDU_GET_CAPABILITIES, p_transaction); 33206b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta } 33216b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta else 33226b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta { 33236b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta BTIF_TRACE_ERROR("%s: failed to build command. status: 0x%02x", 33246b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta __FUNCTION__, status); 33256b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta } 3326abd70abb5e42c9431df94fe9d2c4a78a0d8d9af9Pavlin Radoslavov osi_free(p_msg); 33276b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta#else 33286b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta BTIF_TRACE_DEBUG("%s: feature not enabled", __FUNCTION__); 33296b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta#endif 33306b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta return status; 33316b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta} 33326b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta 33336b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta/*************************************************************************** 33346b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta** 33356b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta** Function list_player_app_setting_attrib_cmd 33366b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta** 33376b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta** Description Get supported List Player Attributes 33386b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta** 33396b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta** Returns void 33406b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta** 33416b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta***************************************************************************/ 33426b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Guptastatic bt_status_t list_player_app_setting_attrib_cmd(void) 33436b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta{ 33446b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta tAVRC_STS status = BT_STATUS_UNSUPPORTED; 33456b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta rc_transaction_t *p_transaction = NULL; 33466b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta#if (AVRC_CTLR_INCLUDED == TRUE) 33476b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta BTIF_TRACE_DEBUG("%s: ", __FUNCTION__); 33486b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta CHECK_RC_CONNECTED 33496b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta bt_status_t tran_status=get_transaction(&p_transaction); 33506b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta if (BT_STATUS_SUCCESS != tran_status) 33516b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta return BT_STATUS_FAIL; 33526b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta 33536b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta tAVRC_COMMAND avrc_cmd = {0}; 33546b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta BT_HDR *p_msg = NULL; 33556b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta avrc_cmd.list_app_attr.opcode = AVRC_OP_VENDOR; 33566b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta avrc_cmd.list_app_attr.pdu = AVRC_PDU_LIST_PLAYER_APP_ATTR; 33576b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta avrc_cmd.list_app_attr.status = AVRC_STS_NO_ERROR; 33586b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta status = AVRC_BldCommand(&avrc_cmd, &p_msg); 33596b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta if ((status == AVRC_STS_NO_ERROR)&&(p_msg != NULL)) 33606b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta { 33616b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta UINT8* data_start = (UINT8*)(p_msg + 1) + p_msg->offset; 33626b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta BTIF_TRACE_DEBUG("%s msgreq being sent out with label %d", 33636b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta __FUNCTION__,p_transaction->lbl); 33646b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta BTA_AvVendorCmd(btif_rc_cb.rc_handle,p_transaction->lbl,AVRC_CMD_STATUS, 33656b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta data_start, p_msg->len); 33666b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta status = BT_STATUS_SUCCESS; 33676b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta start_status_command_timer (AVRC_PDU_LIST_PLAYER_APP_ATTR, p_transaction); 33686b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta } 33696b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta else 33706b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta { 33716b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta 33726b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta BTIF_TRACE_ERROR("%s: failed to build command. status: 0x%02x", 33736b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta __FUNCTION__, status); 33746b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta } 3375abd70abb5e42c9431df94fe9d2c4a78a0d8d9af9Pavlin Radoslavov osi_free(p_msg); 33766b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta#else 33776b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta BTIF_TRACE_DEBUG("%s: feature not enabled", __FUNCTION__); 33786b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta#endif 33796b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta return status; 33806b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta} 33816b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta 33826b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta/*************************************************************************** 33836b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta** 33846b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta** Function list_player_app_setting_value_cmd 33856b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta** 33866b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta** Description Get values of supported Player Attributes 33876b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta** 33886b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta** Returns void 33896b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta** 33906b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta***************************************************************************/ 33916b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Guptastatic bt_status_t list_player_app_setting_value_cmd(uint8_t attrib_id) 33926b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta{ 33936b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta tAVRC_STS status = BT_STATUS_UNSUPPORTED; 33946b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta rc_transaction_t *p_transaction=NULL; 33956b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta#if (AVRC_CTLR_INCLUDED == TRUE) 33966b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta BTIF_TRACE_DEBUG("%s: attrib_id %d", __FUNCTION__, attrib_id); 33976b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta CHECK_RC_CONNECTED 33986b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta bt_status_t tran_status=get_transaction(&p_transaction); 33996b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta if (BT_STATUS_SUCCESS != tran_status) 34006b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta return BT_STATUS_FAIL; 34016b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta 34026b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta tAVRC_COMMAND avrc_cmd = {0}; 34036b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta BT_HDR *p_msg = NULL; 34046b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta avrc_cmd.list_app_values.attr_id = attrib_id; 34056b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta avrc_cmd.list_app_values.opcode = AVRC_OP_VENDOR; 34066b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta avrc_cmd.list_app_values.pdu = AVRC_PDU_LIST_PLAYER_APP_VALUES; 34076b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta avrc_cmd.list_app_values.status = AVRC_STS_NO_ERROR; 34086b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta status = AVRC_BldCommand(&avrc_cmd, &p_msg); 34096b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta if ((status == AVRC_STS_NO_ERROR) && (p_msg != NULL)) 34106b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta { 34116b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta UINT8* data_start = (UINT8*)(p_msg + 1) + p_msg->offset; 34126b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta BTIF_TRACE_DEBUG("%s msgreq being sent out with label %d", 34136b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta __FUNCTION__,p_transaction->lbl); 34146b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta BTA_AvVendorCmd(btif_rc_cb.rc_handle,p_transaction->lbl,AVRC_CMD_STATUS, 34156b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta data_start, p_msg->len); 34166b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta status = BT_STATUS_SUCCESS; 34176b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta start_status_command_timer (AVRC_PDU_LIST_PLAYER_APP_VALUES, p_transaction); 34186b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta } 34196b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta else 34206b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta { 34216b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta BTIF_TRACE_ERROR("%s: failed to build command. status: 0x%02x", __FUNCTION__, status); 34226b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta } 3423abd70abb5e42c9431df94fe9d2c4a78a0d8d9af9Pavlin Radoslavov osi_free(p_msg); 34246b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta#else 34256b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta BTIF_TRACE_DEBUG("%s: feature not enabled", __FUNCTION__); 34266b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta#endif 34276b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta return status; 34286b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta} 34296b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta 34306b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta/*************************************************************************** 34316b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta** 34326b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta** Function get_player_app_setting_cmd 34336b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta** 34346b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta** Description Get current values of Player Attributes 34356b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta** 34366b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta** Returns void 34376b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta** 34386b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta***************************************************************************/ 34396b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Guptastatic bt_status_t get_player_app_setting_cmd(uint8_t num_attrib, uint8_t* attrib_ids) 34406b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta{ 34416b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta tAVRC_STS status = BT_STATUS_UNSUPPORTED; 34426b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta rc_transaction_t *p_transaction = NULL; 34436b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta int count = 0; 34446b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta#if (AVRC_CTLR_INCLUDED == TRUE) 34456b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta BTIF_TRACE_DEBUG("%s: num attrib_id %d", __FUNCTION__, num_attrib); 34466b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta CHECK_RC_CONNECTED 34476b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta bt_status_t tran_status=get_transaction(&p_transaction); 34486b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta if (BT_STATUS_SUCCESS != tran_status) 34496b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta return BT_STATUS_FAIL; 34506b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta 34516b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta tAVRC_COMMAND avrc_cmd = {0}; 34526b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta BT_HDR *p_msg = NULL; 34536b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta avrc_cmd.get_cur_app_val.opcode = AVRC_OP_VENDOR; 34546b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta avrc_cmd.get_cur_app_val.status = AVRC_STS_NO_ERROR; 34556b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta avrc_cmd.get_cur_app_val.num_attr = num_attrib; 34566b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta avrc_cmd.get_cur_app_val.pdu = AVRC_PDU_GET_CUR_PLAYER_APP_VALUE; 34576b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta 34586b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta for (count = 0; count < num_attrib; count++) 34596b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta { 34606b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta avrc_cmd.get_cur_app_val.attrs[count] = attrib_ids[count]; 34616b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta } 34626b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta status = AVRC_BldCommand(&avrc_cmd, &p_msg); 34636b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta if ((status == AVRC_STS_NO_ERROR) && (p_msg != NULL)) 34646b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta { 34656b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta UINT8* data_start = (UINT8*)(p_msg + 1) + p_msg->offset; 34666b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta BTIF_TRACE_DEBUG("%s msgreq being sent out with label %d", 34676b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta __FUNCTION__,p_transaction->lbl); 34686b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta BTA_AvVendorCmd(btif_rc_cb.rc_handle,p_transaction->lbl,AVRC_CMD_STATUS, 34696b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta data_start, p_msg->len); 34706b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta status = BT_STATUS_SUCCESS; 34716b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta start_status_command_timer (AVRC_PDU_GET_CUR_PLAYER_APP_VALUE, p_transaction); 34726b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta } 34736b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta else 34746b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta { 34756b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta BTIF_TRACE_ERROR("%s: failed to build command. status: 0x%02x", 34766b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta __FUNCTION__, status); 34776b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta } 3478abd70abb5e42c9431df94fe9d2c4a78a0d8d9af9Pavlin Radoslavov osi_free(p_msg); 34796b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta#else 34806b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta BTIF_TRACE_DEBUG("%s: feature not enabled", __FUNCTION__); 34816b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta#endif 34826b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta return status; 34836b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta} 34846b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta 34856b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta/*************************************************************************** 34866b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta** 34876b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta** Function change_player_app_setting 34886b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta** 34896b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta** Description Set current values of Player Attributes 34906b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta** 34916b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta** Returns void 34926b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta** 34936b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta***************************************************************************/ 34946b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Guptastatic bt_status_t change_player_app_setting(bt_bdaddr_t *bd_addr, uint8_t num_attrib, uint8_t* attrib_ids, uint8_t* attrib_vals) 34956b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta{ 34966b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta tAVRC_STS status = BT_STATUS_UNSUPPORTED; 34976b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta rc_transaction_t *p_transaction = NULL; 34986b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta int count = 0; 34996b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta#if (AVRC_CTLR_INCLUDED == TRUE) 35006b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta BTIF_TRACE_DEBUG("%s: num attrib_id %d", __FUNCTION__, num_attrib); 35016b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta CHECK_RC_CONNECTED 35026b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta bt_status_t tran_status=get_transaction(&p_transaction); 35036b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta if (BT_STATUS_SUCCESS != tran_status) 35046b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta return BT_STATUS_FAIL; 35056b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta 35066b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta tAVRC_COMMAND avrc_cmd = {0}; 35076b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta BT_HDR *p_msg = NULL; 35086b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta avrc_cmd.set_app_val.opcode = AVRC_OP_VENDOR; 35096b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta avrc_cmd.set_app_val.status = AVRC_STS_NO_ERROR; 35106b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta avrc_cmd.set_app_val.num_val = num_attrib; 35116b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta avrc_cmd.set_app_val.pdu = AVRC_PDU_SET_PLAYER_APP_VALUE; 35126b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta avrc_cmd.set_app_val.p_vals = 3513abd70abb5e42c9431df94fe9d2c4a78a0d8d9af9Pavlin Radoslavov (tAVRC_APP_SETTING *)osi_malloc(sizeof(tAVRC_APP_SETTING) * num_attrib); 35146b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta for (count = 0; count < num_attrib; count++) 35156b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta { 35166b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta avrc_cmd.set_app_val.p_vals[count].attr_id = attrib_ids[count]; 35176b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta avrc_cmd.set_app_val.p_vals[count].attr_val = attrib_vals[count]; 35186b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta } 35196b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta status = AVRC_BldCommand(&avrc_cmd, &p_msg); 35206b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta if ((status == AVRC_STS_NO_ERROR) && (p_msg != NULL)) 35216b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta { 35226b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta UINT8* data_start = (UINT8*)(p_msg + 1) + p_msg->offset; 35236b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta BTIF_TRACE_DEBUG("%s msgreq being sent out with label %d", 35246b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta __FUNCTION__,p_transaction->lbl); 35256b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta BTA_AvVendorCmd(btif_rc_cb.rc_handle,p_transaction->lbl,AVRC_CMD_CTRL, 35266b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta data_start, p_msg->len); 35276b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta status = BT_STATUS_SUCCESS; 35286b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta start_control_command_timer (AVRC_PDU_SET_PLAYER_APP_VALUE, p_transaction); 35296b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta } 35306b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta else 35316b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta { 35326b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta BTIF_TRACE_ERROR("%s: failed to build command. status: 0x%02x", 35336b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta __FUNCTION__, status); 35346b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta } 3535abd70abb5e42c9431df94fe9d2c4a78a0d8d9af9Pavlin Radoslavov osi_free(p_msg); 3536abd70abb5e42c9431df94fe9d2c4a78a0d8d9af9Pavlin Radoslavov osi_free_and_reset((void **)&avrc_cmd.set_app_val.p_vals); 35376b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta#else 35386b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta BTIF_TRACE_DEBUG("%s: feature not enabled", __FUNCTION__); 35396b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta#endif 35406b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta return status; 35416b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta} 35426b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta 35436b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta/*************************************************************************** 35446b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta** 35456b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta** Function get_player_app_setting_attr_text_cmd 35466b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta** 35476b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta** Description Get text description for app attribute 35486b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta** 35496b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta** Returns void 35506b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta** 35516b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta***************************************************************************/ 35526b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Guptastatic bt_status_t get_player_app_setting_attr_text_cmd (UINT8 *attrs, UINT8 num_attrs) 35536b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta{ 35546b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta tAVRC_STS status = BT_STATUS_UNSUPPORTED; 35556b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta rc_transaction_t *p_transaction = NULL; 35566b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta int count = 0; 35576b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta#if (AVRC_CTLR_INCLUDED == TRUE) 35586b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta tAVRC_COMMAND avrc_cmd = {0}; 35596b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta BT_HDR *p_msg = NULL; 35606b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta bt_status_t tran_status; 35616b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta CHECK_RC_CONNECTED 35626b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta 35636b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta BTIF_TRACE_DEBUG("%s: num attrs %d", __FUNCTION__, num_attrs); 35646b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta 35656b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta tran_status = get_transaction(&p_transaction); 35666b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta if (BT_STATUS_SUCCESS != tran_status) 35676b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta return BT_STATUS_FAIL; 35686b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta 35696b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta avrc_cmd.pdu = AVRC_PDU_GET_PLAYER_APP_ATTR_TEXT; 35706b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta avrc_cmd.get_app_attr_txt.opcode = AVRC_OP_VENDOR; 35716b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta avrc_cmd.get_app_attr_txt.num_attr = num_attrs; 35726b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta 35736b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta for (count = 0; count < num_attrs; count++) 35746b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta { 35756b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta avrc_cmd.get_app_attr_txt.attrs[count] = attrs[count]; 35766b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta } 35776b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta status = AVRC_BldCommand(&avrc_cmd, &p_msg); 35786b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta if (status == AVRC_STS_NO_ERROR) 35796b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta { 35806b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta UINT8* data_start = (UINT8*)(p_msg + 1) + p_msg->offset; 35816b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta BTIF_TRACE_DEBUG("%s msgreq being sent out with label %d", 35826b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta __FUNCTION__, p_transaction->lbl); 35836b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta BTA_AvVendorCmd(btif_rc_cb.rc_handle, p_transaction->lbl, 35846b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta AVRC_CMD_STATUS, data_start, p_msg->len); 3585abd70abb5e42c9431df94fe9d2c4a78a0d8d9af9Pavlin Radoslavov osi_free(p_msg); 35866b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta status = BT_STATUS_SUCCESS; 35876b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta start_status_command_timer (AVRC_PDU_GET_PLAYER_APP_ATTR_TEXT, p_transaction); 35886b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta } 35896b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta else 35906b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta { 35916b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta BTIF_TRACE_ERROR("%s: failed to build command. status: 0x%02x", __FUNCTION__, status); 35926b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta } 3593abd70abb5e42c9431df94fe9d2c4a78a0d8d9af9Pavlin Radoslavov osi_free(p_msg); 35946b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta#else 35956b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta BTIF_TRACE_DEBUG("%s: feature not enabled", __FUNCTION__); 35966b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta#endif 35976b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta return status; 35986b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta} 35996b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta 36006b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta/*************************************************************************** 36016b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta** 36026b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta** Function get_player_app_setting_val_text_cmd 36036b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta** 36046b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta** Description Get text description for app attribute values 36056b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta** 36066b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta** Returns void 36076b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta** 36086b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta***************************************************************************/ 36096b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Guptastatic bt_status_t get_player_app_setting_value_text_cmd (UINT8 *vals, UINT8 num_vals) 36106b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta{ 36116b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta tAVRC_STS status = BT_STATUS_UNSUPPORTED; 36126b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta rc_transaction_t *p_transaction = NULL; 36136b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta int count = 0; 36146b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta#if (AVRC_CTLR_INCLUDED == TRUE) 36156b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta tAVRC_COMMAND avrc_cmd = {0}; 36166b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta BT_HDR *p_msg = NULL; 36176b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta bt_status_t tran_status; 36186b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta CHECK_RC_CONNECTED 36196b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta 36206b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta BTIF_TRACE_DEBUG("%s: num_vals %d", __FUNCTION__, num_vals); 36216b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta 36226b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta tran_status = get_transaction(&p_transaction); 36236b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta if (BT_STATUS_SUCCESS != tran_status) 36246b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta return BT_STATUS_FAIL; 36256b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta 36266b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta avrc_cmd.pdu = AVRC_PDU_GET_PLAYER_APP_VALUE_TEXT; 36276b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta avrc_cmd.get_app_val_txt.opcode = AVRC_OP_VENDOR; 36286b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta avrc_cmd.get_app_val_txt.num_val = num_vals; 36296b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta 36306b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta for (count = 0; count < num_vals; count++) 36316b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta { 36326b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta avrc_cmd.get_app_val_txt.vals[count] = vals[count]; 36336b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta } 36346b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta status = AVRC_BldCommand(&avrc_cmd, &p_msg); 36356b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta if (status == AVRC_STS_NO_ERROR) 36366b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta { 36376b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta UINT8* data_start = (UINT8*)(p_msg + 1) + p_msg->offset; 36386b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta BTIF_TRACE_DEBUG("%s msgreq being sent out with label %d", 36396b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta __FUNCTION__, p_transaction->lbl); 36406b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta if (p_msg != NULL) 36416b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta { 36426b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta BTA_AvVendorCmd(btif_rc_cb.rc_handle, p_transaction->lbl, 36436b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta AVRC_CMD_STATUS, data_start, p_msg->len); 36446b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta status = BT_STATUS_SUCCESS; 36456b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta start_status_command_timer (AVRC_PDU_GET_PLAYER_APP_VALUE_TEXT, p_transaction); 36466b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta } 36476b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta } 36486b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta else 36496b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta { 36506b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta BTIF_TRACE_ERROR("%s: failed to build command. status: 0x%02x", 36516b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta __FUNCTION__, status); 36526b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta } 3653abd70abb5e42c9431df94fe9d2c4a78a0d8d9af9Pavlin Radoslavov osi_free(p_msg); 36546b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta#else 36556b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta BTIF_TRACE_DEBUG("%s: feature not enabled", __FUNCTION__); 36566b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta#endif 36576b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta return status; 36586b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta} 36596b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta 36606b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta/*************************************************************************** 36616b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta** 36626b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta** Function register_notification_cmd 36636b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta** 36646b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta** Description Send Command to register for a Notification ID 36656b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta** 36666b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta** Returns void 36676b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta** 36686b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta***************************************************************************/ 36696b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Guptastatic bt_status_t register_notification_cmd (UINT8 label, UINT8 event_id, UINT32 event_value) 36706b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta{ 36716b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta 36726b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta tAVRC_STS status = BT_STATUS_UNSUPPORTED; 36736b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta#if (AVRC_CTLR_INCLUDED == TRUE) 36746b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta tAVRC_COMMAND avrc_cmd = {0}; 36756b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta BT_HDR *p_msg = NULL; 36766b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta CHECK_RC_CONNECTED 36776b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta 36786b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta 36796b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta BTIF_TRACE_DEBUG("%s: event_id %d event_value", __FUNCTION__, event_id, event_value); 36806b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta 36816b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta avrc_cmd.reg_notif.opcode = AVRC_OP_VENDOR; 36826b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta avrc_cmd.reg_notif.status = AVRC_STS_NO_ERROR; 36836b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta avrc_cmd.reg_notif.event_id = event_id; 36846b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta avrc_cmd.reg_notif.pdu = AVRC_PDU_REGISTER_NOTIFICATION; 36856b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta avrc_cmd.reg_notif.param = event_value; 36866b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta status = AVRC_BldCommand(&avrc_cmd, &p_msg); 36876b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta if (status == AVRC_STS_NO_ERROR) 36886b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta { 36896b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta UINT8* data_start = (UINT8*)(p_msg + 1) + p_msg->offset; 36906b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta BTIF_TRACE_DEBUG("%s msgreq being sent out with label %d", 36916b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta __FUNCTION__, label); 36926b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta if (p_msg != NULL) 36936b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta { 36946b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta BTA_AvVendorCmd(btif_rc_cb.rc_handle, label, AVRC_CMD_NOTIF, 36956b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta data_start, p_msg->len); 36966b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta status = BT_STATUS_SUCCESS; 36976b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta } 36986b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta } 36996b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta else 37006b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta { 37016b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta BTIF_TRACE_ERROR("%s: failed to build command. status: 0x%02x", 37026b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta __FUNCTION__, status); 37036b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta } 3704abd70abb5e42c9431df94fe9d2c4a78a0d8d9af9Pavlin Radoslavov osi_free(p_msg); 37056b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta#else 37066b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta BTIF_TRACE_DEBUG("%s: feature not enabled", __FUNCTION__); 37076b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta#endif 37086b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta return status; 37096b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta} 37106b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta 37116b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta/*************************************************************************** 37126b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta** 37136b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta** Function get_element_attribute_cmd 37146b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta** 37156b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta** Description Get Element Attribute for attributeIds 37166b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta** 37176b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta** Returns void 37186b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta** 37196b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta***************************************************************************/ 37206b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Guptastatic bt_status_t get_element_attribute_cmd (uint8_t num_attribute, uint32_t *p_attr_ids) 37216b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta{ 37226b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta tAVRC_STS status = BT_STATUS_UNSUPPORTED; 37236b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta rc_transaction_t *p_transaction=NULL; 37246b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta int count = 0; 37256b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta#if (AVRC_CTLR_INCLUDED == TRUE) 37266b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta tAVRC_COMMAND avrc_cmd = {0}; 37276b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta BT_HDR *p_msg = NULL; 37286b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta bt_status_t tran_status; 37296b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta CHECK_RC_CONNECTED 37306b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta 37316b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta BTIF_TRACE_DEBUG("%s: num_attribute %d attribute_id %d", 37326b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta __FUNCTION__, num_attribute, p_attr_ids[0]); 37336b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta 37346b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta tran_status = get_transaction(&p_transaction); 37356b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta if (BT_STATUS_SUCCESS != tran_status) 37366b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta return BT_STATUS_FAIL; 37376b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta 37386b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta avrc_cmd.get_elem_attrs.opcode = AVRC_OP_VENDOR; 37396b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta avrc_cmd.get_elem_attrs.status = AVRC_STS_NO_ERROR; 37406b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta avrc_cmd.get_elem_attrs.num_attr = num_attribute; 37416b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta avrc_cmd.get_elem_attrs.pdu = AVRC_PDU_GET_ELEMENT_ATTR; 37426b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta for (count = 0; count < num_attribute; count++) 37436b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta { 37446b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta avrc_cmd.get_elem_attrs.attrs[count] = p_attr_ids[count]; 37456b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta } 37466b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta 37476b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta status = AVRC_BldCommand(&avrc_cmd, &p_msg); 37486b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta if (status == AVRC_STS_NO_ERROR) 37496b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta { 37506b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta UINT8* data_start = (UINT8*)(p_msg + 1) + p_msg->offset; 37516b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta BTIF_TRACE_DEBUG("%s msgreq being sent out with label %d", 37526b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta __FUNCTION__, p_transaction->lbl); 37536b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta if (p_msg != NULL) 37546b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta { 37556b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta BTA_AvVendorCmd(btif_rc_cb.rc_handle, p_transaction->lbl, 37566b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta AVRC_CMD_STATUS, data_start, p_msg->len); 37576b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta status = BT_STATUS_SUCCESS; 37586b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta start_status_command_timer (AVRC_PDU_GET_ELEMENT_ATTR, 37596b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta p_transaction); 37606b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta } 37616b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta } 37626b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta else 37636b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta { 37646b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta BTIF_TRACE_ERROR("%s: failed to build command. status: 0x%02x", 37656b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta __FUNCTION__, status); 37666b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta } 3767abd70abb5e42c9431df94fe9d2c4a78a0d8d9af9Pavlin Radoslavov osi_free(p_msg); 37686b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta#else 37696b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta BTIF_TRACE_DEBUG("%s: feature not enabled", __FUNCTION__); 37706b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta#endif 37716b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta return status; 37726b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta} 37736b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta 37746b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta/*************************************************************************** 37756b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta** 37766b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta** Function get_play_status_cmd 37776b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta** 37786b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta** Description Get Element Attribute for attributeIds 37796b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta** 37806b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta** Returns void 37816b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta** 37826b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta***************************************************************************/ 37836b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Guptastatic bt_status_t get_play_status_cmd(void) 37846b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta{ 37856b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta tAVRC_STS status = BT_STATUS_UNSUPPORTED; 37866b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta rc_transaction_t *p_transaction = NULL; 37876b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta#if (AVRC_CTLR_INCLUDED == TRUE) 37886b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta tAVRC_COMMAND avrc_cmd = {0}; 37896b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta BT_HDR *p_msg = NULL; 37906b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta bt_status_t tran_status; 37916b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta CHECK_RC_CONNECTED 37926b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta 37936b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta BTIF_TRACE_DEBUG("%s: ", __FUNCTION__); 37946b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta tran_status = get_transaction(&p_transaction); 37956b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta if (BT_STATUS_SUCCESS != tran_status) 37966b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta return BT_STATUS_FAIL; 37976b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta 37986b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta avrc_cmd.get_play_status.opcode = AVRC_OP_VENDOR; 37996b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta avrc_cmd.get_play_status.pdu = AVRC_PDU_GET_PLAY_STATUS; 38006b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta avrc_cmd.get_play_status.status = AVRC_STS_NO_ERROR; 38016b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta status = AVRC_BldCommand(&avrc_cmd, &p_msg); 38026b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta if (status == AVRC_STS_NO_ERROR) 38036b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta { 38046b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta UINT8* data_start = (UINT8*)(p_msg + 1) + p_msg->offset; 38056b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta BTIF_TRACE_DEBUG("%s msgreq being sent out with label %d", 38066b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta __FUNCTION__, p_transaction->lbl); 38076b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta if (p_msg != NULL) 38086b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta { 38096b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta BTA_AvVendorCmd(btif_rc_cb.rc_handle,p_transaction->lbl, 38106b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta AVRC_CMD_STATUS, data_start, p_msg->len); 38116b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta status = BT_STATUS_SUCCESS; 38126b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta start_status_command_timer (AVRC_PDU_GET_PLAY_STATUS, p_transaction); 38136b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta } 38146b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta } 38156b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta else 38166b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta { 38176b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta BTIF_TRACE_ERROR("%s: failed to build command. status: 0x%02x", 38186b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta __FUNCTION__, status); 38196b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta } 3820abd70abb5e42c9431df94fe9d2c4a78a0d8d9af9Pavlin Radoslavov osi_free(p_msg); 38216b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta#else 38226b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta BTIF_TRACE_DEBUG("%s: feature not enabled", __FUNCTION__); 38236b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta#endif 38246b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta return status; 38256b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta 38266b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta} 38276b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta 38286b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta/*************************************************************************** 38296b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta** 38306b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta** Function set_volume_rsp 38316b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta** 38326b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta** Description Rsp for SetAbsoluteVolume Command 38336b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta** 38346b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta** Returns void 38356b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta** 38366b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta***************************************************************************/ 38376b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Guptastatic bt_status_t set_volume_rsp(bt_bdaddr_t *bd_addr, uint8_t abs_vol, uint8_t label) 38386b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta{ 38396b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta tAVRC_STS status = BT_STATUS_UNSUPPORTED; 38406b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta#if (AVRC_CTLR_INCLUDED == TRUE) 38416b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta tAVRC_RESPONSE avrc_rsp; 38426b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta BT_HDR *p_msg = NULL; 38436b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta CHECK_RC_CONNECTED 38446b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta 38456b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta BTIF_TRACE_DEBUG("%s: abs_vol %d", __FUNCTION__, abs_vol); 38466b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta 38476b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta avrc_rsp.volume.opcode = AVRC_OP_VENDOR; 38486b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta avrc_rsp.volume.pdu = AVRC_PDU_SET_ABSOLUTE_VOLUME; 38496b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta avrc_rsp.volume.status = AVRC_STS_NO_ERROR; 38506b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta avrc_rsp.volume.volume = abs_vol; 38516b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta status = AVRC_BldResponse(btif_rc_cb.rc_handle, &avrc_rsp, &p_msg); 38526b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta if (status == AVRC_STS_NO_ERROR) 38536b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta { 38546b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta UINT8* data_start = (UINT8*)(p_msg + 1) + p_msg->offset; 38556b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta BTIF_TRACE_DEBUG("%s msgreq being sent out with label %d", 38566b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta __FUNCTION__, btif_rc_cb.rc_vol_label); 38576b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta if (p_msg != NULL) 38586b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta { 38596b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta BTA_AvVendorRsp(btif_rc_cb.rc_handle, label, 38606b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta BTA_AV_RSP_ACCEPT, data_start, p_msg->len, 0); 38616b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta status = BT_STATUS_SUCCESS; 38626b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta } 38636b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta } 38646b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta else 38656b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta { 38666b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta BTIF_TRACE_ERROR("%s: failed to build command. status: 0x%02x", 38676b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta __FUNCTION__, status); 38686b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta } 3869abd70abb5e42c9431df94fe9d2c4a78a0d8d9af9Pavlin Radoslavov osi_free(p_msg); 38706b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta#else 38716b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta BTIF_TRACE_DEBUG("%s: feature not enabled", __FUNCTION__); 38726b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta#endif 38736b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta return status; 38746b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta} 38756b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta 38766b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta/*************************************************************************** 38776b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta** 38786b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta** Function send_register_abs_vol_rsp 38796b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta** 38806b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta** Description Rsp for Notification of Absolute Volume 38816b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta** 38826b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta** Returns void 38836b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta** 38846b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta***************************************************************************/ 38856b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Guptastatic bt_status_t volume_change_notification_rsp(bt_bdaddr_t *bd_addr, btrc_notification_type_t rsp_type, 38866b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta uint8_t abs_vol, uint8_t label) 38876b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta{ 38886b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta tAVRC_STS status = BT_STATUS_UNSUPPORTED; 38896b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta tAVRC_RESPONSE avrc_rsp; 38906b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta BT_HDR *p_msg = NULL; 38916b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta#if (AVRC_CTLR_INCLUDED == TRUE) 389220524d393e8b3bea4c573f7980cd843500b0e6a4Pavlin Radoslavov BTIF_TRACE_DEBUG("%s: rsp_type %d abs_vol %d", __func__, rsp_type, abs_vol); 38936b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta CHECK_RC_CONNECTED 38946b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta 389520524d393e8b3bea4c573f7980cd843500b0e6a4Pavlin Radoslavov avrc_rsp.reg_notif.opcode = AVRC_OP_VENDOR; 389620524d393e8b3bea4c573f7980cd843500b0e6a4Pavlin Radoslavov avrc_rsp.reg_notif.pdu = AVRC_PDU_REGISTER_NOTIFICATION; 389720524d393e8b3bea4c573f7980cd843500b0e6a4Pavlin Radoslavov avrc_rsp.reg_notif.status = AVRC_STS_NO_ERROR; 389820524d393e8b3bea4c573f7980cd843500b0e6a4Pavlin Radoslavov avrc_rsp.reg_notif.param.volume = abs_vol; 389920524d393e8b3bea4c573f7980cd843500b0e6a4Pavlin Radoslavov avrc_rsp.reg_notif.event_id = AVRC_EVT_VOLUME_CHANGE; 39006b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta 39016b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta status = AVRC_BldResponse(btif_rc_cb.rc_handle, &avrc_rsp, &p_msg); 390220524d393e8b3bea4c573f7980cd843500b0e6a4Pavlin Radoslavov if (status == AVRC_STS_NO_ERROR) { 390320524d393e8b3bea4c573f7980cd843500b0e6a4Pavlin Radoslavov BTIF_TRACE_DEBUG("%s msgreq being sent out with label %d", 390420524d393e8b3bea4c573f7980cd843500b0e6a4Pavlin Radoslavov __func__, label); 390520524d393e8b3bea4c573f7980cd843500b0e6a4Pavlin Radoslavov UINT8* data_start = (UINT8*)(p_msg + 1) + p_msg->offset; 390620524d393e8b3bea4c573f7980cd843500b0e6a4Pavlin Radoslavov BTA_AvVendorRsp(btif_rc_cb.rc_handle, label, 390720524d393e8b3bea4c573f7980cd843500b0e6a4Pavlin Radoslavov (rsp_type == BTRC_NOTIFICATION_TYPE_INTERIM) ? 390820524d393e8b3bea4c573f7980cd843500b0e6a4Pavlin Radoslavov AVRC_RSP_INTERIM : AVRC_RSP_CHANGED, 390920524d393e8b3bea4c573f7980cd843500b0e6a4Pavlin Radoslavov data_start, p_msg->len, 0); 391020524d393e8b3bea4c573f7980cd843500b0e6a4Pavlin Radoslavov status = BT_STATUS_SUCCESS; 391120524d393e8b3bea4c573f7980cd843500b0e6a4Pavlin Radoslavov } else { 391220524d393e8b3bea4c573f7980cd843500b0e6a4Pavlin Radoslavov BTIF_TRACE_ERROR("%s: failed to build command. status: 0x%02x", 391320524d393e8b3bea4c573f7980cd843500b0e6a4Pavlin Radoslavov __func__, status); 391420524d393e8b3bea4c573f7980cd843500b0e6a4Pavlin Radoslavov } 3915abd70abb5e42c9431df94fe9d2c4a78a0d8d9af9Pavlin Radoslavov osi_free(p_msg); 391620524d393e8b3bea4c573f7980cd843500b0e6a4Pavlin Radoslavov 39176b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta#else 391820524d393e8b3bea4c573f7980cd843500b0e6a4Pavlin Radoslavov BTIF_TRACE_DEBUG("%s: feature not enabled", __func__); 39196b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta#endif 39206b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta return status; 39216b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta} 39226b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta 39236b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta/*************************************************************************** 39246b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta** 39256b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta** Function send_groupnavigation_cmd 39266b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta** 39276b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta** Description Send Pass-Through command 39286b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta** 39296b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta** Returns void 39306b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta** 39316b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta***************************************************************************/ 39326b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Guptastatic bt_status_t send_groupnavigation_cmd(bt_bdaddr_t *bd_addr, uint8_t key_code, 39336b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta uint8_t key_state) 39346b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta{ 39356b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta tAVRC_STS status = BT_STATUS_UNSUPPORTED; 39366b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta#if (AVRC_CTLR_INCLUDED == TRUE) 39376b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta rc_transaction_t *p_transaction=NULL; 39386b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta BTIF_TRACE_DEBUG("%s: key-code: %d, key-state: %d", __FUNCTION__, 39396b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta key_code, key_state); 39406b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta CHECK_RC_CONNECTED 39416b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta if (btif_rc_cb.rc_features & BTA_AV_FEAT_RCTG) 39426b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta { 39436b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta bt_status_t tran_status = get_transaction(&p_transaction); 394478bcff79e1b1f0efce436b33bdd6da88745bfc8aPavlin Radoslavov if ((BT_STATUS_SUCCESS == tran_status) && (NULL != p_transaction)) { 3945f94e67c2d96d25f221e0503f334f4a0a277bc68cPavlin Radoslavov UINT8 buffer[AVRC_PASS_THRU_GROUP_LEN] = {0}; 3946f94e67c2d96d25f221e0503f334f4a0a277bc68cPavlin Radoslavov UINT8* start = buffer; 394778bcff79e1b1f0efce436b33bdd6da88745bfc8aPavlin Radoslavov UINT24_TO_BE_STREAM(start, AVRC_CO_METADATA); 394878bcff79e1b1f0efce436b33bdd6da88745bfc8aPavlin Radoslavov *(start)++ = 0; 394978bcff79e1b1f0efce436b33bdd6da88745bfc8aPavlin Radoslavov UINT8_TO_BE_STREAM(start, key_code); 395078bcff79e1b1f0efce436b33bdd6da88745bfc8aPavlin Radoslavov BTA_AvRemoteVendorUniqueCmd(btif_rc_cb.rc_handle, 395178bcff79e1b1f0efce436b33bdd6da88745bfc8aPavlin Radoslavov p_transaction->lbl, 3952f94e67c2d96d25f221e0503f334f4a0a277bc68cPavlin Radoslavov (tBTA_AV_STATE)key_state, buffer, 395378bcff79e1b1f0efce436b33bdd6da88745bfc8aPavlin Radoslavov AVRC_PASS_THRU_GROUP_LEN); 395478bcff79e1b1f0efce436b33bdd6da88745bfc8aPavlin Radoslavov status = BT_STATUS_SUCCESS; 395578bcff79e1b1f0efce436b33bdd6da88745bfc8aPavlin Radoslavov BTIF_TRACE_DEBUG("%s: succesfully sent group_navigation command to BTA", 395678bcff79e1b1f0efce436b33bdd6da88745bfc8aPavlin Radoslavov __FUNCTION__); 39576b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta } 39586b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta else 39596b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta { 39606b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta status = BT_STATUS_FAIL; 39616b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta BTIF_TRACE_DEBUG("%s: error in fetching transaction", __FUNCTION__); 39626b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta } 39636b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta } 39646b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta else 39656b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta { 39666b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta status = BT_STATUS_FAIL; 39676b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta BTIF_TRACE_DEBUG("%s: feature not supported", __FUNCTION__); 39686b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta } 39696b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta#else 39706b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta BTIF_TRACE_DEBUG("%s: feature not enabled", __FUNCTION__); 39716b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta#endif 39726b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta return status; 39736b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta} 39746b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta 39756b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta/*************************************************************************** 39766b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta** 39776b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta** Function send_passthrough_cmd 39786b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta** 39796b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta** Description Send Pass-Through command 39806b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta** 39816b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta** Returns void 39826b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta** 39836b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta***************************************************************************/ 39846b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Guptastatic bt_status_t send_passthrough_cmd(bt_bdaddr_t *bd_addr, uint8_t key_code, uint8_t key_state) 39856b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta{ 39866b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta tAVRC_STS status = BT_STATUS_UNSUPPORTED; 39876b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta#if (AVRC_CTLR_INCLUDED == TRUE) 39886b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta CHECK_RC_CONNECTED 39896b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta rc_transaction_t *p_transaction=NULL; 39906b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta BTIF_TRACE_DEBUG("%s: key-code: %d, key-state: %d", __FUNCTION__, 39916b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta key_code, key_state); 39926b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta if (btif_rc_cb.rc_features & BTA_AV_FEAT_RCTG) 39936b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta { 39946b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta bt_status_t tran_status = get_transaction(&p_transaction); 39956b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta if (BT_STATUS_SUCCESS == tran_status && NULL != p_transaction) 39966b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta { 39976b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta BTA_AvRemoteCmd(btif_rc_cb.rc_handle, p_transaction->lbl, 39986b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta (tBTA_AV_RC)key_code, (tBTA_AV_STATE)key_state); 39996b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta status = BT_STATUS_SUCCESS; 40006b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta BTIF_TRACE_DEBUG("%s: succesfully sent passthrough command to BTA", __FUNCTION__); 40016b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta } 40026b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta else 40036b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta { 40046b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta status = BT_STATUS_FAIL; 40056b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta BTIF_TRACE_DEBUG("%s: error in fetching transaction", __FUNCTION__); 40066b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta } 40076b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta } 40086b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta else 40096b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta { 40106b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta status = BT_STATUS_FAIL; 40116b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta BTIF_TRACE_DEBUG("%s: feature not supported", __FUNCTION__); 40126b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta } 40136b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta#else 40146b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta BTIF_TRACE_DEBUG("%s: feature not enabled", __FUNCTION__); 40156b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta#endif 40166b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta return status; 40176b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta} 40186b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta 40196b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Guptastatic const btrc_interface_t bt_rc_interface = { 40206b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta sizeof(bt_rc_interface), 40216b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta init, 40229adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan get_play_status_rsp, 40239adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan NULL, /* list_player_app_attr_rsp */ 40249adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan NULL, /* list_player_app_value_rsp */ 40259adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan NULL, /* get_player_app_value_rsp */ 40269adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan NULL, /* get_player_app_attr_text_rsp */ 40279adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan NULL, /* get_player_app_value_text_rsp */ 40289adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan get_element_attr_rsp, 40299adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan NULL, /* set_player_app_value_rsp */ 40309adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan register_notification_rsp, 4031247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji set_volume, 40329adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan cleanup, 40339adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan}; 40349adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan 40354ad470e33021be4246ae539e1bcb7a346dbb4405Mike Lockwoodstatic const btrc_ctrl_interface_t bt_rc_ctrl_interface = { 40364ad470e33021be4246ae539e1bcb7a346dbb4405Mike Lockwood sizeof(bt_rc_ctrl_interface), 40374ad470e33021be4246ae539e1bcb7a346dbb4405Mike Lockwood init_ctrl, 40384ad470e33021be4246ae539e1bcb7a346dbb4405Mike Lockwood send_passthrough_cmd, 40396b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta send_groupnavigation_cmd, 40406b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta change_player_app_setting, 40416b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta set_volume_rsp, 40426b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta volume_change_notification_rsp, 4043daddea9cf1f5dbf51b9a2e9c2b02956a41d77a6cAnubhav Gupta cleanup_ctrl, 40444ad470e33021be4246ae539e1bcb7a346dbb4405Mike Lockwood}; 40454ad470e33021be4246ae539e1bcb7a346dbb4405Mike Lockwood 40469adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan/******************************************************************************* 40479adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan** 40489adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan** Function btif_rc_get_interface 40499adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan** 40504ad470e33021be4246ae539e1bcb7a346dbb4405Mike Lockwood** Description Get the AVRCP Target callback interface 40519adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan** 40529adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan** Returns btav_interface_t 40539adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan** 40549adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan*******************************************************************************/ 40559adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajanconst btrc_interface_t *btif_rc_get_interface(void) 40569adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan{ 4057e8c3d75b75493911ebf0f99c83676359657178f7Sharvil Nanavati BTIF_TRACE_EVENT("%s", __FUNCTION__); 40589adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan return &bt_rc_interface; 4059247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji} 4060247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji 4061247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji/******************************************************************************* 40624ad470e33021be4246ae539e1bcb7a346dbb4405Mike Lockwood** 40634ad470e33021be4246ae539e1bcb7a346dbb4405Mike Lockwood** Function btif_rc_ctrl_get_interface 40644ad470e33021be4246ae539e1bcb7a346dbb4405Mike Lockwood** 40654ad470e33021be4246ae539e1bcb7a346dbb4405Mike Lockwood** Description Get the AVRCP Controller callback interface 40664ad470e33021be4246ae539e1bcb7a346dbb4405Mike Lockwood** 40674ad470e33021be4246ae539e1bcb7a346dbb4405Mike Lockwood** Returns btav_interface_t 40684ad470e33021be4246ae539e1bcb7a346dbb4405Mike Lockwood** 40694ad470e33021be4246ae539e1bcb7a346dbb4405Mike Lockwood*******************************************************************************/ 40704ad470e33021be4246ae539e1bcb7a346dbb4405Mike Lockwoodconst btrc_ctrl_interface_t *btif_rc_ctrl_get_interface(void) 40714ad470e33021be4246ae539e1bcb7a346dbb4405Mike Lockwood{ 4072e8c3d75b75493911ebf0f99c83676359657178f7Sharvil Nanavati BTIF_TRACE_EVENT("%s", __FUNCTION__); 40734ad470e33021be4246ae539e1bcb7a346dbb4405Mike Lockwood return &bt_rc_ctrl_interface; 40744ad470e33021be4246ae539e1bcb7a346dbb4405Mike Lockwood} 40754ad470e33021be4246ae539e1bcb7a346dbb4405Mike Lockwood 40764ad470e33021be4246ae539e1bcb7a346dbb4405Mike Lockwood/******************************************************************************* 4077247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji** Function initialize_transaction 4078247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji** 4079247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji** Description Initializes fields of the transaction structure 4080247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji** 4081247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji** Returns void 4082247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji*******************************************************************************/ 4083247c68fe6eee3660cbdcf4509195fe735ae25573Satya Callojistatic void initialize_transaction(int lbl) 4084247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji{ 4085247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji pthread_mutex_lock(&device.lbllock); 408678bcff79e1b1f0efce436b33bdd6da88745bfc8aPavlin Radoslavov if (lbl < MAX_TRANSACTIONS_PER_SESSION) { 408778bcff79e1b1f0efce436b33bdd6da88745bfc8aPavlin Radoslavov if (alarm_is_scheduled(device.transaction[lbl].txn_timer)) { 408878bcff79e1b1f0efce436b33bdd6da88745bfc8aPavlin Radoslavov clear_cmd_timeout(lbl); 40896b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta } 409078bcff79e1b1f0efce436b33bdd6da88745bfc8aPavlin Radoslavov device.transaction[lbl].lbl = lbl; 409178bcff79e1b1f0efce436b33bdd6da88745bfc8aPavlin Radoslavov device.transaction[lbl].in_use=FALSE; 409278bcff79e1b1f0efce436b33bdd6da88745bfc8aPavlin Radoslavov device.transaction[lbl].handle=0; 4093247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji } 4094247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji pthread_mutex_unlock(&device.lbllock); 4095247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji} 4096247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji 4097247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji/******************************************************************************* 4098247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji** Function lbl_init 4099247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji** 4100247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji** Description Initializes label structures and mutexes. 4101247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji** 4102247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji** Returns void 4103247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji*******************************************************************************/ 4104247c68fe6eee3660cbdcf4509195fe735ae25573Satya Callojivoid lbl_init() 4105247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji{ 4106247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji memset(&device,0,sizeof(rc_device_t)); 4107247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji pthread_mutexattr_t attr; 4108247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji pthread_mutexattr_init(&attr); 41096b84f291c4edce7e4102efd8d4052a63bcb4b9dcAnubhav Gupta pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE); 4110247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji pthread_mutex_init(&(device.lbllock), &attr); 4111247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji pthread_mutexattr_destroy(&attr); 4112247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji init_all_transactions(); 4113247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji} 4114247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji 4115247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji/******************************************************************************* 4116247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji** 4117247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji** Function init_all_transactions 4118247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji** 4119247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji** Description Initializes all transactions 4120247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji** 4121247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji** Returns void 4122247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji*******************************************************************************/ 4123247c68fe6eee3660cbdcf4509195fe735ae25573Satya Callojivoid init_all_transactions() 4124247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji{ 4125247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji UINT8 txn_indx=0; 4126247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji for(txn_indx=0; txn_indx < MAX_TRANSACTIONS_PER_SESSION; txn_indx++) 4127247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji { 4128247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji initialize_transaction(txn_indx); 4129247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji } 4130247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji} 4131247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji 4132247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji/******************************************************************************* 4133247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji** 4134247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji** Function get_transaction_by_lbl 4135247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji** 4136247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji** Description Will return a transaction based on the label. If not inuse 4137247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji** will return an error. 4138247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji** 4139247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji** Returns bt_status_t 4140247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji*******************************************************************************/ 4141247c68fe6eee3660cbdcf4509195fe735ae25573Satya Callojirc_transaction_t *get_transaction_by_lbl(UINT8 lbl) 4142247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji{ 4143247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji rc_transaction_t *transaction = NULL; 4144247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji pthread_mutex_lock(&device.lbllock); 4145247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji 4146247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji /* Determine if this is a valid label */ 4147247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji if (lbl < MAX_TRANSACTIONS_PER_SESSION) 4148247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji { 4149247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji if (FALSE==device.transaction[lbl].in_use) 4150247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji { 4151247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji transaction = NULL; 4152247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji } 4153247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji else 4154247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji { 4155247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji transaction = &(device.transaction[lbl]); 4156e8c3d75b75493911ebf0f99c83676359657178f7Sharvil Nanavati BTIF_TRACE_DEBUG("%s: Got transaction.label: %d",__FUNCTION__,lbl); 4157247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji } 4158247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji } 4159247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji 4160247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji pthread_mutex_unlock(&device.lbllock); 4161247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji return transaction; 4162247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji} 4163247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji 4164247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji/******************************************************************************* 4165247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji** 4166247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji** Function get_transaction 4167247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji** 4168247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji** Description Obtains the transaction details. 4169247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji** 4170247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji** Returns bt_status_t 4171247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji*******************************************************************************/ 4172247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji 4173247c68fe6eee3660cbdcf4509195fe735ae25573Satya Callojibt_status_t get_transaction(rc_transaction_t **ptransaction) 4174247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji{ 4175247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji bt_status_t result = BT_STATUS_NOMEM; 4176247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji UINT8 i=0; 4177247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji pthread_mutex_lock(&device.lbllock); 4178247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji 4179247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji // Check for unused transactions 4180247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji for (i=0; i<MAX_TRANSACTIONS_PER_SESSION; i++) 4181247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji { 4182247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji if (FALSE==device.transaction[i].in_use) 4183247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji { 4184e8c3d75b75493911ebf0f99c83676359657178f7Sharvil Nanavati BTIF_TRACE_DEBUG("%s:Got transaction.label: %d",__FUNCTION__,device.transaction[i].lbl); 4185247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji device.transaction[i].in_use = TRUE; 4186247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji *ptransaction = &(device.transaction[i]); 4187247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji result = BT_STATUS_SUCCESS; 4188247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji break; 4189247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji } 4190247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji } 4191247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji 4192247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji pthread_mutex_unlock(&device.lbllock); 4193247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji return result; 4194247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji} 4195247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji 4196247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji/******************************************************************************* 4197247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji** 4198247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji** Function release_transaction 4199247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji** 4200247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji** Description Will release a transaction for reuse 4201247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji** 4202247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji** Returns bt_status_t 4203247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji*******************************************************************************/ 4204247c68fe6eee3660cbdcf4509195fe735ae25573Satya Callojivoid release_transaction(UINT8 lbl) 4205247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji{ 4206247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji rc_transaction_t *transaction = get_transaction_by_lbl(lbl); 4207247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji 4208247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji /* If the transaction is in use... */ 4209247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji if (transaction != NULL) 4210247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji { 4211e8c3d75b75493911ebf0f99c83676359657178f7Sharvil Nanavati BTIF_TRACE_DEBUG("%s: lbl: %d", __FUNCTION__, lbl); 4212247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji initialize_transaction(lbl); 4213247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji } 4214247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji} 4215247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji 4216247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji/******************************************************************************* 4217247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji** 4218247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji** Function lbl_destroy 4219247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji** 4220247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji** Description Cleanup of the mutex 4221247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji** 4222247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji** Returns void 4223247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji*******************************************************************************/ 4224247c68fe6eee3660cbdcf4509195fe735ae25573Satya Callojivoid lbl_destroy() 4225247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji{ 4226247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji pthread_mutex_destroy(&(device.lbllock)); 4227247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji} 4228a7ae4a15e954fe143326d4f869f8dac8e76ee8ceMatthew Xie 4229a7ae4a15e954fe143326d4f869f8dac8e76ee8ceMatthew Xie/******************************************************************************* 4230642f233005cdcbbbcb92b77d6297fc080b7f072ePavlin Radoslavov** Function sleep_ms 4231642f233005cdcbbbcb92b77d6297fc080b7f072ePavlin Radoslavov** 4232642f233005cdcbbbcb92b77d6297fc080b7f072ePavlin Radoslavov** Description Sleep the calling thread unconditionally for 4233642f233005cdcbbbcb92b77d6297fc080b7f072ePavlin Radoslavov** |timeout_ms| milliseconds. 4234642f233005cdcbbbcb92b77d6297fc080b7f072ePavlin Radoslavov** 4235642f233005cdcbbbcb92b77d6297fc080b7f072ePavlin Radoslavov** Returns void 4236642f233005cdcbbbcb92b77d6297fc080b7f072ePavlin Radoslavov*******************************************************************************/ 423778bcff79e1b1f0efce436b33bdd6da88745bfc8aPavlin Radoslavovstatic void sleep_ms(period_ms_t timeout_ms) { 4238642f233005cdcbbbcb92b77d6297fc080b7f072ePavlin Radoslavov struct timespec delay; 4239642f233005cdcbbbcb92b77d6297fc080b7f072ePavlin Radoslavov delay.tv_sec = timeout_ms / 1000; 4240642f233005cdcbbbcb92b77d6297fc080b7f072ePavlin Radoslavov delay.tv_nsec = 1000 * 1000 * (timeout_ms % 1000); 4241642f233005cdcbbbcb92b77d6297fc080b7f072ePavlin Radoslavov 4242574dcfb73e3741d715f7d4394fe5d3bd587cb0d2Pavlin Radoslavov OSI_NO_INTR(nanosleep(&delay, &delay)); 4243642f233005cdcbbbcb92b77d6297fc080b7f072ePavlin Radoslavov} 424490b71eac9b45f90ff3267fa0a400cc1daaec88d4Andre Eisenbach 424590b71eac9b45f90ff3267fa0a400cc1daaec88d4Andre Eisenbachstatic bool absolute_volume_disabled() { 424690b71eac9b45f90ff3267fa0a400cc1daaec88d4Andre Eisenbach char volume_disabled[PROPERTY_VALUE_MAX] = {0}; 42472998946db9b820806d4a3e6decf1d01f090a8031Jakub Pawlowski osi_property_get("persist.bluetooth.disableabsvol", volume_disabled, "false"); 424890b71eac9b45f90ff3267fa0a400cc1daaec88d4Andre Eisenbach if (strncmp(volume_disabled, "true", 4) == 0) { 424990b71eac9b45f90ff3267fa0a400cc1daaec88d4Andre Eisenbach BTIF_TRACE_WARNING("%s: Absolute volume disabled by property", __func__); 425090b71eac9b45f90ff3267fa0a400cc1daaec88d4Andre Eisenbach return true; 425190b71eac9b45f90ff3267fa0a400cc1daaec88d4Andre Eisenbach } 425290b71eac9b45f90ff3267fa0a400cc1daaec88d4Andre Eisenbach return false; 425390b71eac9b45f90ff3267fa0a400cc1daaec88d4Andre Eisenbach} 4254ecfeff6782aeb61adfaf19f70e6a55ff97c3a9d6Ajay Panicker 4255ecfeff6782aeb61adfaf19f70e6a55ff97c3a9d6Ajay Panickerstatic char const* key_id_to_str(uint16_t id) { 4256ecfeff6782aeb61adfaf19f70e6a55ff97c3a9d6Ajay Panicker for (int i = 0; key_map[i].name != NULL; i++) { 4257ecfeff6782aeb61adfaf19f70e6a55ff97c3a9d6Ajay Panicker if (id == key_map[i].mapped_id) 4258ecfeff6782aeb61adfaf19f70e6a55ff97c3a9d6Ajay Panicker return key_map[i].name; 4259ecfeff6782aeb61adfaf19f70e6a55ff97c3a9d6Ajay Panicker } 4260ecfeff6782aeb61adfaf19f70e6a55ff97c3a9d6Ajay Panicker return "UNKNOWN KEY"; 4261ecfeff6782aeb61adfaf19f70e6a55ff97c3a9d6Ajay Panicker} 4262