From 07548918df8d0a6a65d531d7a9466817b6066d42 Mon Sep 17 00:00:00 2001 From: wangmengyang Date: Wed, 8 Mar 2017 19:25:58 +0800 Subject: [PATCH] component/bt: clean up AVRC logic and the header file --- components/bt/bluedroid/btc/core/btc_main.c | 1 + .../bluedroid/btc/profile/std/a2dp/btc_avk.c | 8 +- .../bluedroid/btc/profile/std/avrc/btc_avrc.c | 1065 +---------------- .../btc/profile/std/include/btc_avrc.h | 243 +--- components/bt/bluedroid/btif/include/uinput.h | 594 --------- 5 files changed, 16 insertions(+), 1895 deletions(-) delete mode 100644 components/bt/bluedroid/btif/include/uinput.h diff --git a/components/bt/bluedroid/btc/core/btc_main.c b/components/bt/bluedroid/btc/core/btc_main.c index d6bf256c8e..ae3d3f5fc9 100644 --- a/components/bt/bluedroid/btc/core/btc_main.c +++ b/components/bt/bluedroid/btc/core/btc_main.c @@ -50,6 +50,7 @@ static void btc_enable_bluetooth(void) static void btc_disable_bluetooth(void) { + btc_config_shut_down(); if (BTA_DisableBluetooth() != BTA_SUCCESS) { future_ready(*btc_main_get_future_p(BTC_MAIN_DISABLE_FUTURE), FUTURE_FAIL); } diff --git a/components/bt/bluedroid/btc/profile/std/a2dp/btc_avk.c b/components/bt/bluedroid/btc/profile/std/a2dp/btc_avk.c index b6d5c19f1a..f67a2ea3a2 100644 --- a/components/bt/bluedroid/btc/profile/std/a2dp/btc_avk.c +++ b/components/bt/bluedroid/btc/profile/std/a2dp/btc_avk.c @@ -403,13 +403,7 @@ static BOOLEAN btc_av_state_opening_handler(btc_sm_event_t event, void *p_data) btc_report_connection_state(state, &(btc_av_cb.peer_bda), 0); /* change state to open/idle based on the status */ btc_sm_change_state(btc_av_cb.sm_handle, av_state); - if (btc_av_cb.peer_sep == AVDT_TSEP_SNK) { - /* if queued PLAY command, send it now */ - btc_rc_check_handle_pending_play(p_bta_data->open.bd_addr, - (p_bta_data->open.status == BTA_AV_SUCCESS)); - } else if (btc_av_cb.peer_sep == AVDT_TSEP_SRC) { - /* if queued PLAY command, send it now */ - btc_rc_check_handle_pending_play(p_bta_data->open.bd_addr, FALSE); + if (btc_av_cb.peer_sep == AVDT_TSEP_SRC) { /* Bring up AVRCP connection too */ BTA_AvOpenRc(btc_av_cb.bta_handle); } diff --git a/components/bt/bluedroid/btc/profile/std/avrc/btc_avrc.c b/components/bt/bluedroid/btc/profile/std/avrc/btc_avrc.c index 529723b705..97c7ae8523 100644 --- a/components/bt/bluedroid/btc/profile/std/avrc/btc_avrc.c +++ b/components/bt/bluedroid/btc/profile/std/avrc/btc_avrc.c @@ -30,39 +30,18 @@ #include "btc_av.h" #include "btc_avrc.h" #include "btc_manage.h" -#include "uinput.h" #include "esp_avrc_api.h" /***************************************************************************** ** Constants & Macros ******************************************************************************/ - -/* cod value for Headsets */ -#define COD_AV_HEADSETS 0x0404 /* for AVRC 1.4 need to change this */ #define MAX_RC_NOTIFICATIONS AVRC_EVT_APP_SETTING_CHANGE -#define IDX_GET_PLAY_STATUS_RSP 0 -#define IDX_LIST_APP_ATTR_RSP 1 -#define IDX_LIST_APP_VALUE_RSP 2 -#define IDX_GET_CURR_APP_VAL_RSP 3 -#define IDX_SET_APP_VAL_RSP 4 -#define IDX_GET_APP_ATTR_TXT_RSP 5 -#define IDX_GET_APP_VAL_TXT_RSP 6 -#define IDX_GET_ELEMENT_ATTR_RSP 7 #define MAX_VOLUME 128 #define MAX_LABEL 16 #define MAX_TRANSACTIONS_PER_SESSION 16 #define MAX_CMD_QUEUE_LEN 8 -#define PLAY_STATUS_PLAYING 1 - -#define CHECK_RC_CONNECTED \ - LOG_DEBUG("## %s ##", __FUNCTION__); \ - if(btc_rc_cb.rc_connected == FALSE) \ - { \ - LOG_WARN("Function %s() called when RC is not connected", __FUNCTION__); \ - return BT_STATUS_NOT_READY; \ - } #define CHECK_ESP_RC_CONNECTED do { \ LOG_DEBUG("## %s ##", __FUNCTION__); \ @@ -72,27 +51,6 @@ } \ } while (0) -#define FILL_PDU_QUEUE(index, ctype, label, pending) \ -{ \ - btc_rc_vb.rc_pdu_info[index].ctype = ctype; \ - btc_rc_vb.rc_pdu_info[index].label = label; \ - btc_rc_vb.rc_pdu_info[index].is_rsp_pending = pending; \ -} - -#define SEND_METAMSG_RSP(index, avrc_rsp) \ -{ \ - if(btc_rc_vb.rc_pdu_info[index].is_rsp_pending == FALSE) \ - { \ - LOG_WARN("%s Not sending response as no PDU was registered", __FUNCTION__); \ - return BT_STATUS_UNHANDLED; \ - } \ - send_metamsg_rsp(btc_rc_vb.rc_handle, btc_rc_vb.rc_pdu_info[index].label, \ - btc_rc_vb.rc_pdu_info[index].ctype, avrc_rsp); \ - btc_rc_vb.rc_pdu_info[index].ctype = 0; \ - btc_rc_vb.rc_pdu_info[index].label = 0; \ - btc_rc_vb.rc_pdu_info[index].is_rsp_pending = FALSE; \ -} - /***************************************************************************** ** Local type definitions ******************************************************************************/ @@ -133,87 +91,32 @@ typedef struct rc_transaction_t transaction[MAX_TRANSACTIONS_PER_SESSION]; } rc_device_t; - rc_device_t device; -static int uinput_fd = -1; -static void send_key (int fd, uint16_t key, int pressed); - -static const struct { - const char *name; - uint8_t avrcp; - uint16_t mapped_id; - uint8_t release_quirk; -} key_map[] = { - { "PLAY", AVRC_ID_PLAY, KEY_PLAYCD, 1 }, - { "STOP", AVRC_ID_STOP, KEY_STOPCD, 0 }, - { "PAUSE", AVRC_ID_PAUSE, KEY_PAUSECD, 1 }, - { "FORWARD", AVRC_ID_FORWARD, KEY_NEXTSONG, 0 }, - { "BACKWARD", AVRC_ID_BACKWARD, KEY_PREVIOUSSONG, 0 }, - { "REWIND", AVRC_ID_REWIND, KEY_REWIND, 0 }, - { "FAST FORWARD", AVRC_ID_FAST_FOR, KEY_FAST_FORWARD, 0 }, - { NULL, 0, 0, 0 } -}; - -static void send_reject_response (UINT8 rc_handle, UINT8 label, - UINT8 pdu, UINT8 status); -static UINT8 opcode_from_pdu(UINT8 pdu); -static void send_metamsg_rsp (UINT8 rc_handle, UINT8 label, - tBTA_AV_CODE code, tAVRC_RESPONSE *pmetamsg_resp); -static void register_volumechange(UINT8 label); -static void lbl_init(); -static void lbl_destroy(); -static void init_all_transactions(); -static bt_status_t get_transaction(rc_transaction_t **ptransaction); -static void release_transaction(UINT8 label); -static rc_transaction_t* get_transaction_by_lbl(UINT8 label); -static void handle_rc_metamsg_rsp(tBTA_AV_META_MSG *pmeta_msg); -static void btc_rc_upstreams_evt(UINT16 event, tAVRC_COMMAND* p_param, UINT8 ctype, UINT8 label); -static void btc_rc_upstreams_rsp_evt(UINT16 event, tAVRC_RESPONSE *pavrc_resp, UINT8 ctype, UINT8 label); - static void handle_rc_connect (tBTA_AV_RC_OPEN *p_rc_open); static void handle_rc_disconnect (tBTA_AV_RC_CLOSE *p_rc_close); static void handle_rc_passthrough_rsp ( tBTA_AV_REMOTE_RSP *p_remote_rsp); -static void handle_rc_passthrough_cmd ( tBTA_AV_REMOTE_CMD *p_remote_cmd); -static void handle_uid_changed_notification(tBTA_AV_META_MSG *pmeta_msg, tAVRC_COMMAND *pavrc_command); -static void handle_rc_metamsg_cmd (tBTA_AV_META_MSG *pmeta_msg); + /***************************************************************************** ** Static variables ******************************************************************************/ static btc_rc_cb_t btc_rc_vb; -static btrc_callbacks_t *bt_rc_callbacks = NULL; - -/***************************************************************************** -** Static functions -******************************************************************************/ /***************************************************************************** ** Externs ******************************************************************************/ -#if BTC_HF_INCLUDED -extern BOOLEAN btc_hf_call_terminated_recently(); -#endif - /***************************************************************************** -** Local uinput helper functions +** Static functions ******************************************************************************/ static inline void btc_avrc_ct_cb_to_app(esp_avrc_ct_cb_event_t event, esp_avrc_ct_cb_param_t *param) { - esp_a2d_cb_t btc_avrc_cb = (esp_a2d_cb_t)btc_profile_cb_get(BTC_PID_AVRC); + esp_avrc_ct_cb_t btc_avrc_cb = (esp_avrc_ct_cb_t)btc_profile_cb_get(BTC_PID_AVRC); if (btc_avrc_cb) { btc_avrc_cb(event, param); } } -void send_key (int fd, uint16_t key, int pressed) -{ - LOG_DEBUG("%s fd:%d key:%u pressed:%d, func not implemented", __FUNCTION__, - fd, key, pressed); - - return; -} - -static void handle_rc_features() +static void handle_rc_features(void) { btrc_remote_features_t rc_features = BTRC_FEAT_NONE; bt_bdaddr_t rc_addr; @@ -244,40 +147,6 @@ static void handle_rc_features() LOG_DEBUG("%s: rc_features=0x%x", __FUNCTION__, rc_features); // todo: uncomment the following line when added the AVRC target role // BTC_HAL_CBACK(bt_rc_callbacks, remote_features_cb, &rc_addr, rc_features) - -#if (AVRC_ADV_CTRL_INCLUDED == TRUE) - LOG_DEBUG("Checking for feature flags in btc_rc_handler with label %d", - btc_rc_vb.rc_vol_label); - // Register for volume change on connect - if(btc_rc_vb.rc_features & BTA_AV_FEAT_ADV_CTRL && - btc_rc_vb.rc_features & BTA_AV_FEAT_RCTG) - { - rc_transaction_t *p_transaction=NULL; - bt_status_t status = BT_STATUS_NOT_READY; - if(MAX_LABEL==btc_rc_vb.rc_vol_label) - { - status=get_transaction(&p_transaction); - } - else - { - p_transaction=get_transaction_by_lbl(btc_rc_vb.rc_vol_label); - if(NULL!=p_transaction) - { - LOG_DEBUG("register_volumechange already in progress for label %d", - btc_rc_vb.rc_vol_label); - return; - } - else - status=get_transaction(&p_transaction); - } - - if(BT_STATUS_SUCCESS == status && NULL!=p_transaction) - { - btc_rc_vb.rc_vol_label=p_transaction->lbl; - register_volumechange(btc_rc_vb.rc_vol_label); - } - } -#endif } @@ -313,8 +182,8 @@ static void handle_rc_connect (tBTA_AV_RC_OPEN *p_rc_open) } memcpy(btc_rc_vb.rc_addr, p_rc_open->peer_addr, sizeof(BD_ADDR)); btc_rc_vb.rc_features = p_rc_open->peer_features; - btc_rc_vb.rc_vol_label=MAX_LABEL; - btc_rc_vb.rc_volume=MAX_VOLUME; + btc_rc_vb.rc_vol_label = MAX_LABEL; + btc_rc_vb.rc_volume = MAX_VOLUME; btc_rc_vb.rc_connected = TRUE; btc_rc_vb.rc_handle = p_rc_open->rc_handle; @@ -322,12 +191,6 @@ static void handle_rc_connect (tBTA_AV_RC_OPEN *p_rc_open) /* on locally initiated connection we will get remote features as part of connect */ if (btc_rc_vb.rc_features != 0) handle_rc_features(); -#if UINPUT_INCLUDED - if(uinput_driver_check() == BT_STATUS_SUCCESS) - { - init_uinput(); - } -#endif /* UINPUT_INCLUDED */ #if (AVRC_CTLR_INCLUDED == TRUE) bdcpy(rc_addr.address, btc_rc_vb.rc_addr); /* report connection state if device is AVRCP target */ @@ -381,10 +244,6 @@ static void handle_rc_disconnect (tBTA_AV_RC_CLOSE *p_rc_close) btc_rc_vb.rc_features = 0; btc_rc_vb.rc_vol_label=MAX_LABEL; btc_rc_vb.rc_volume=MAX_VOLUME; - init_all_transactions(); -#if UINPUT_INCLUDED - close_uinput(); -#endif /* UINPUT_INCLUDED */ #if (AVRC_CTLR_INCLUDED == TRUE) bdcpy(rc_addr.address, btc_rc_vb.rc_addr); #endif @@ -401,118 +260,6 @@ static void handle_rc_disconnect (tBTA_AV_RC_CLOSE *p_rc_close) #endif } -/*************************************************************************** - * Function handle_rc_passthrough_cmd - * - * - Argument: tBTA_AV_RC rc_id remote control command ID - * tBTA_AV_STATE key_state status of key press - * - * - Description: Remote control command handler - * - ***************************************************************************/ -static void handle_rc_passthrough_cmd ( tBTA_AV_REMOTE_CMD *p_remote_cmd) -{ - const char *status; - int pressed, i; - - LOG_DEBUG("%s: p_remote_cmd->rc_id=%d", __FUNCTION__, p_remote_cmd->rc_id); - - /* If AVRC is open and peer sends PLAY but there is no AVDT, then we queue-up this PLAY */ - if (p_remote_cmd) - { - /* queue AVRC PLAY if GAVDTP Open notification to app is pending (2 second timer) */ - if ((p_remote_cmd->rc_id == BTA_AV_RC_PLAY) && (!btc_av_is_connected())) - { - if (p_remote_cmd->key_state == AVRC_STATE_PRESS) - { - APPL_TRACE_WARNING("%s: AVDT not open, queuing the PLAY command", __FUNCTION__); - btc_rc_vb.rc_pending_play = TRUE; - } - return; - } - - if ((p_remote_cmd->rc_id == BTA_AV_RC_PAUSE) && (btc_rc_vb.rc_pending_play)) - { - APPL_TRACE_WARNING("%s: Clear the pending PLAY on PAUSE received", __FUNCTION__); - btc_rc_vb.rc_pending_play = FALSE; - return; - } - } - - if ((p_remote_cmd->rc_id == BTA_AV_RC_STOP) && (!btc_av_stream_started_ready())) - { - APPL_TRACE_WARNING("%s: Stream suspended, ignore STOP cmd",__FUNCTION__); - return; - } - - if (p_remote_cmd->key_state == AVRC_STATE_RELEASE) { - status = "released"; - pressed = 0; - } else { - status = "pressed"; - pressed = 1; - } - - /* If this is Play/Pause command (press or release) before processing, check the following - * a voice call has ended recently - * the remote device is not of type headset - * If the above conditions meet, drop the Play/Pause command - * This fix is to interop with certain carkits which sends an automatic PLAY or PAUSE - * commands right after call ends - */ - if((p_remote_cmd->rc_id == BTA_AV_RC_PLAY || p_remote_cmd->rc_id == BTA_AV_RC_PAUSE) -#ifdef BTC_HF_INCLUDED - && (btc_hf_call_terminated_recently() == TRUE) -#endif -#if 0 // temporary hack since no btc_storage module is not ported for now - && (check_cod( (const bt_bdaddr_t*)&(btc_rc_vb.rc_addr), COD_AV_HEADSETS) != TRUE) -#endif - ) - { - LOG_DEBUG("%s:Dropping the play/Pause command received right after call end cmd:%d", - __FUNCTION__,p_remote_cmd->rc_id); - return; - } - - if (p_remote_cmd->rc_id == BTA_AV_RC_FAST_FOR || p_remote_cmd->rc_id == BTA_AV_RC_REWIND) { - BTC_HAL_CBACK(bt_rc_callbacks, passthrough_cmd_cb, p_remote_cmd->rc_id, pressed); - return; - } - - for (i = 0; key_map[i].name != NULL; i++) { - if (p_remote_cmd->rc_id == key_map[i].avrcp) { - LOG_DEBUG("%s: %s %s", __FUNCTION__, key_map[i].name, status); - - /* MusicPlayer uses a long_press_timeout of 1 second for PLAYPAUSE button - * and maps that to autoshuffle. So if for some reason release for PLAY/PAUSE - * comes 1 second after the press, the MediaPlayer UI goes into a bad state. - * The reason for the delay could be sniff mode exit or some AVDTP procedure etc. - * The fix is to generate a release right after the press and drown the 'actual' - * release. - */ - if ((key_map[i].release_quirk == 1) && (pressed == 0)) - { - LOG_DEBUG("%s: AVRC %s Release Faked earlier, drowned now", - __FUNCTION__, key_map[i].name); - return; - } - send_key(uinput_fd, key_map[i].mapped_id, pressed); - if ((key_map[i].release_quirk == 1) && (pressed == 1)) - { - GKI_delay(30); // 30ms - LOG_DEBUG("%s: AVRC %s Release quirk enabled, send release now", - __FUNCTION__, key_map[i].name); - send_key(uinput_fd, key_map[i].mapped_id, 0); - } - break; - } - } - - if (key_map[i].name == NULL) - LOG_ERROR("%s AVRCP: unknown button 0x%02X %s", __FUNCTION__, - p_remote_cmd->rc_id, status); -} - /*************************************************************************** * Function handle_rc_passthrough_rsp * @@ -559,119 +306,6 @@ static void handle_rc_passthrough_rsp ( tBTA_AV_REMOTE_RSP *p_remote_rsp) #endif } -static void handle_uid_changed_notification(tBTA_AV_META_MSG *pmeta_msg, tAVRC_COMMAND *pavrc_command) -{ - tAVRC_RESPONSE avrc_rsp = {0}; - avrc_rsp.rsp.pdu = pavrc_command->pdu; - avrc_rsp.rsp.status = AVRC_STS_NO_ERROR; - avrc_rsp.rsp.opcode = pavrc_command->cmd.opcode; - - avrc_rsp.reg_notif.event_id = pavrc_command->reg_notif.event_id; - avrc_rsp.reg_notif.param.uid_counter = 0; - - send_metamsg_rsp(pmeta_msg->rc_handle, pmeta_msg->label, AVRC_RSP_INTERIM, &avrc_rsp); - send_metamsg_rsp(pmeta_msg->rc_handle, pmeta_msg->label, AVRC_RSP_CHANGED, &avrc_rsp); - -} - - -/*************************************************************************** - * Function handle_rc_metamsg_cmd - * - * - Argument: tBTA_AV_VENDOR Structure containing the received - * metamsg command - * - * - Description: Remote control metamsg command handler (AVRCP 1.3) - * - ***************************************************************************/ -static void handle_rc_metamsg_cmd (tBTA_AV_META_MSG *pmeta_msg) -{ - /* Parse the metamsg command and pass it on to BTL-IFS */ - UINT8 scratch_buf[512] = {0}; - tAVRC_COMMAND avrc_command = {0}; - tAVRC_STS status; - - LOG_INFO("+ %s", __FUNCTION__); - - if (pmeta_msg->p_msg->hdr.opcode != AVRC_OP_VENDOR) - { - LOG_WARN("Invalid opcode: %x", pmeta_msg->p_msg->hdr.opcode); - return; - } - if (pmeta_msg->len < 3) - { - LOG_WARN("Invalid length.Opcode: 0x%x, len: 0x%x", pmeta_msg->p_msg->hdr.opcode, - pmeta_msg->len); - return; - } - - if (pmeta_msg->code >= AVRC_RSP_NOT_IMPL) - { -#if (AVRC_ADV_CTRL_INCLUDED == TRUE) -{ - rc_transaction_t *transaction=NULL; - transaction=get_transaction_by_lbl(pmeta_msg->label); - if(NULL!=transaction) - { - handle_rc_metamsg_rsp(pmeta_msg); - } - else - { - LOG_DEBUG("%s:Discard vendor dependent rsp. code: %d label:%d.", - __FUNCTION__, pmeta_msg->code, pmeta_msg->label); - } - return; -} -#else -{ - LOG_DEBUG("%s:Received vendor dependent rsp. code: %d len: %d. Not processing it.", - __FUNCTION__, pmeta_msg->code, pmeta_msg->len); - return; -} -#endif - } - - status=AVRC_ParsCommand(pmeta_msg->p_msg, &avrc_command, scratch_buf, sizeof(scratch_buf)); - LOG_DEBUG("Received vendor command.code,PDU and label: %d, %d,%d",pmeta_msg->code, - avrc_command.cmd.pdu, pmeta_msg->label); - - if (status != AVRC_STS_NO_ERROR) - { - /* return error */ - LOG_WARN("%s: Error in parsing received metamsg command. status: 0x%02x", - __FUNCTION__, status); - send_reject_response(pmeta_msg->rc_handle, pmeta_msg->label, avrc_command.pdu, status); - } - else - { - /* if RegisterNotification, add it to our registered queue */ - - if (avrc_command.cmd.pdu == AVRC_PDU_REGISTER_NOTIFICATION) - { - UINT8 event_id = avrc_command.reg_notif.event_id; - LOG_INFO("%s:New register notification received.event_id:%s,label:0x%x,code:%x", - __FUNCTION__,dump_rc_notification_event_id(event_id), pmeta_msg->label,pmeta_msg->code); - btc_rc_vb.rc_notif[event_id-1].bNotify = TRUE; - btc_rc_vb.rc_notif[event_id-1].label = pmeta_msg->label; - - if(event_id == AVRC_EVT_UIDS_CHANGE) - { - handle_uid_changed_notification(pmeta_msg, &avrc_command); - return; - } - - } - - LOG_INFO("%s: Passing received metamsg command to app. pdu: %s", - __FUNCTION__, dump_rc_pdu(avrc_command.cmd.pdu)); - - /* Since handle_rc_metamsg_cmd() itself is called from - * btc context, no context switching is required. Invoke - * btc_rc_upstreams_evt directly from here. */ - btc_rc_upstreams_evt((uint16_t)avrc_command.cmd.pdu, &avrc_command, pmeta_msg->code, - pmeta_msg->label); - } -} /*************************************************************************** ** @@ -696,18 +330,11 @@ void btc_rc_handler(tBTA_AV_EVT event, tBTA_AV *p_data) handle_rc_disconnect( &(p_data->rc_close) ); }break; - case BTA_AV_REMOTE_CMD_EVT: - { - LOG_DEBUG("rc_id:0x%x key_state:%d", p_data->remote_cmd.rc_id, - p_data->remote_cmd.key_state); - handle_rc_passthrough_cmd( (&p_data->remote_cmd) ); - } - break; #if (AVRC_CTLR_INCLUDED == TRUE) case BTA_AV_REMOTE_RSP_EVT: { LOG_DEBUG("RSP: rc_id:0x%x key_state:%d", p_data->remote_rsp.rc_id, - p_data->remote_rsp.key_state); + p_data->remote_rsp.key_state); handle_rc_passthrough_rsp( (&p_data->remote_rsp) ); } break; @@ -719,16 +346,10 @@ void btc_rc_handler(tBTA_AV_EVT event, tBTA_AV *p_data) handle_rc_features(); } break; + + // below events are not handled for now case BTA_AV_META_MSG_EVT: - { - LOG_DEBUG("BTA_AV_META_MSG_EVT code:%d label:%d", p_data->meta_msg.code, - p_data->meta_msg.label); - LOG_DEBUG(" company_id:0x%x len:%d handle:%d", p_data->meta_msg.company_id, - p_data->meta_msg.len, p_data->meta_msg.rc_handle); - /* handle the metamsg command */ - handle_rc_metamsg_cmd(&(p_data->meta_msg)); - } - break; + case BTA_AV_REMOTE_CMD_EVT: default: LOG_DEBUG("Unhandled RC event : 0x%x", event); } @@ -750,399 +371,10 @@ BOOLEAN btc_rc_get_connected_peer(BD_ADDR peer_addr) return FALSE; } -/*************************************************************************** - ** - ** Function btc_rc_check_handle_pending_play - ** - ** Description Clears the queued PLAY command. if bSend is TRUE, forwards to app - ** - ***************************************************************************/ - -/* clear the queued PLAY command. if bSend is TRUE, forward to app */ -void btc_rc_check_handle_pending_play (BD_ADDR peer_addr, BOOLEAN bSendToApp) -{ - UNUSED(peer_addr); - - LOG_DEBUG("%s: bSendToApp=%d", __FUNCTION__, bSendToApp); - if (btc_rc_vb.rc_pending_play) - { - if (bSendToApp) - { - tBTA_AV_REMOTE_CMD remote_cmd; - APPL_TRACE_DEBUG("%s: Sending queued PLAYED event to app", __FUNCTION__); - - memset (&remote_cmd, 0, sizeof(tBTA_AV_REMOTE_CMD)); - remote_cmd.rc_handle = btc_rc_vb.rc_handle; - remote_cmd.rc_id = AVRC_ID_PLAY; - remote_cmd.hdr.ctype = AVRC_CMD_CTRL; - remote_cmd.hdr.opcode = AVRC_OP_PASS_THRU; - - /* delay sending to app, else there is a timing issue in the framework, - ** which causes the audio to be on th device's speaker. Delay between - ** OPEN & RC_PLAYs - */ - GKI_delay (200); - /* send to app - both PRESSED & RELEASED */ - remote_cmd.key_state = AVRC_STATE_PRESS; - handle_rc_passthrough_cmd( &remote_cmd ); - - GKI_delay (100); - - remote_cmd.key_state = AVRC_STATE_RELEASE; - handle_rc_passthrough_cmd( &remote_cmd ); - } - btc_rc_vb.rc_pending_play = FALSE; - } -} - -/* Generic reject response */ -static void send_reject_response (UINT8 rc_handle, UINT8 label, UINT8 pdu, UINT8 status) -{ - UINT8 ctype = AVRC_RSP_REJ; - tAVRC_RESPONSE avrc_rsp; - BT_HDR *p_msg = NULL; - memset (&avrc_rsp, 0, sizeof(tAVRC_RESPONSE)); - - avrc_rsp.rsp.opcode = opcode_from_pdu(pdu); - avrc_rsp.rsp.pdu = pdu; - avrc_rsp.rsp.status = status; - - if (AVRC_STS_NO_ERROR == (status = AVRC_BldResponse(rc_handle, &avrc_rsp, &p_msg)) ) - { - LOG_DEBUG("%s:Sending error notification to handle:%d. pdu:%s,status:0x%02x", - __FUNCTION__, rc_handle, dump_rc_pdu(pdu), status); - BTA_AvMetaRsp(rc_handle, label, ctype, p_msg); - } -} - -/*************************************************************************** - * Function send_metamsg_rsp - * - * - Argument: - * rc_handle RC handle corresponding to the connected RC - * label Label of the RC response - * code Response type - * pmetamsg_resp Vendor response - * - * - Description: Remote control metamsg response handler (AVRCP 1.3) - * - ***************************************************************************/ -static void send_metamsg_rsp (UINT8 rc_handle, UINT8 label, tBTA_AV_CODE code, - tAVRC_RESPONSE *pmetamsg_resp) -{ - UINT8 ctype; - - if (!pmetamsg_resp) - { - LOG_WARN("%s: Invalid response received from application", __FUNCTION__); - return; - } - - LOG_INFO("+%s: rc_handle: %d, label: %d, code: 0x%02x, pdu: %s", __FUNCTION__, - rc_handle, label, code, dump_rc_pdu(pmetamsg_resp->rsp.pdu)); - - if (pmetamsg_resp->rsp.status != AVRC_STS_NO_ERROR) - { - ctype = AVRC_RSP_REJ; - } - else - { - if ( code < AVRC_RSP_NOT_IMPL) - { - if (code == AVRC_CMD_NOTIF) - { - ctype = AVRC_RSP_INTERIM; - } - else if (code == AVRC_CMD_STATUS) - { - ctype = AVRC_RSP_IMPL_STBL; - } - else - { - ctype = AVRC_RSP_ACCEPT; - } - } - else - { - ctype = code; - } - } - /* if response is for register_notification, make sure the rc has - actually registered for this */ - if((pmetamsg_resp->rsp.pdu == AVRC_PDU_REGISTER_NOTIFICATION) && (code == AVRC_RSP_CHANGED)) - { - BOOLEAN bSent = FALSE; - UINT8 event_id = pmetamsg_resp->reg_notif.event_id; - BOOLEAN bNotify = (btc_rc_vb.rc_connected) && (btc_rc_vb.rc_notif[event_id-1].bNotify); - - /* de-register this notification for a CHANGED response */ - btc_rc_vb.rc_notif[event_id-1].bNotify = FALSE; - LOG_DEBUG("%s rc_handle: %d. event_id: 0x%02d bNotify:%u", __FUNCTION__, - btc_rc_vb.rc_handle, event_id, bNotify); - if (bNotify) - { - BT_HDR *p_msg = NULL; - tAVRC_STS status; - - if (AVRC_STS_NO_ERROR == (status = AVRC_BldResponse(btc_rc_vb.rc_handle, - pmetamsg_resp, &p_msg)) ) - { - LOG_DEBUG("%s Sending notification to rc_handle: %d. event_id: 0x%02d", - __FUNCTION__, btc_rc_vb.rc_handle, event_id); - bSent = TRUE; - BTA_AvMetaRsp(btc_rc_vb.rc_handle, btc_rc_vb.rc_notif[event_id-1].label, - ctype, p_msg); - } - else - { - LOG_WARN("%s failed to build metamsg response. status: 0x%02x", - __FUNCTION__, status); - } - - } - - if (!bSent) - { - LOG_DEBUG("%s: Notification not sent, as there are no RC connections or the \ - CT has not subscribed for event_id: %s", __FUNCTION__, dump_rc_notification_event_id(event_id)); - } - } - else - { - /* All other commands go here */ - - BT_HDR *p_msg = NULL; - tAVRC_STS status; - - status = AVRC_BldResponse(rc_handle, pmetamsg_resp, &p_msg); - - if (status == AVRC_STS_NO_ERROR) - { - BTA_AvMetaRsp(rc_handle, label, ctype, p_msg); - } - else - { - LOG_ERROR("%s: failed to build metamsg response. status: 0x%02x", - __FUNCTION__, status); - } - } -} - -static UINT8 opcode_from_pdu(UINT8 pdu) -{ - UINT8 opcode = 0; - - switch (pdu) - { - case AVRC_PDU_NEXT_GROUP: - case AVRC_PDU_PREV_GROUP: /* pass thru */ - opcode = AVRC_OP_PASS_THRU; - break; - - default: /* vendor */ - opcode = AVRC_OP_VENDOR; - break; - } - - return opcode; -} - -/******************************************************************************* -** -** Function btc_rc_upstreams_evt -** -** Description Executes AVRC UPSTREAMS events in btc context. -** -** Returns void -** -*******************************************************************************/ -static void btc_rc_upstreams_evt(UINT16 event, tAVRC_COMMAND *pavrc_cmd, UINT8 ctype, UINT8 label) -{ - LOG_INFO("%s pdu: %s handle: 0x%x ctype:%x label:%x", __FUNCTION__, - dump_rc_pdu(pavrc_cmd->pdu), btc_rc_vb.rc_handle, ctype, label); - - switch (event) - { - case AVRC_PDU_GET_PLAY_STATUS: - { - FILL_PDU_QUEUE(IDX_GET_PLAY_STATUS_RSP, ctype, label, TRUE) - BTC_HAL_CBACK(bt_rc_callbacks, get_play_status_cb); - } - break; - case AVRC_PDU_LIST_PLAYER_APP_ATTR: - case AVRC_PDU_LIST_PLAYER_APP_VALUES: - case AVRC_PDU_GET_CUR_PLAYER_APP_VALUE: - case AVRC_PDU_SET_PLAYER_APP_VALUE: - case AVRC_PDU_GET_PLAYER_APP_ATTR_TEXT: - case AVRC_PDU_GET_PLAYER_APP_VALUE_TEXT: - { - /* TODO: Add support for Application Settings */ - send_reject_response (btc_rc_vb.rc_handle, label, pavrc_cmd->pdu, AVRC_STS_BAD_CMD); - } - break; - case AVRC_PDU_GET_ELEMENT_ATTR: - { - btrc_media_attr_t element_attrs[BTRC_MAX_ELEM_ATTR_SIZE]; - UINT8 num_attr; - memset(&element_attrs, 0, sizeof(element_attrs)); - if (pavrc_cmd->get_elem_attrs.num_attr == 0) - { - /* CT requests for all attributes */ - int attr_cnt; - num_attr = BTRC_MAX_ELEM_ATTR_SIZE; - for (attr_cnt = 0; attr_cnt < BTRC_MAX_ELEM_ATTR_SIZE; attr_cnt++) - { - element_attrs[attr_cnt] = attr_cnt + 1; - } - } - else if (pavrc_cmd->get_elem_attrs.num_attr == 0xFF) - { - /* 0xff indicates, no attributes requested - reject */ - send_reject_response (btc_rc_vb.rc_handle, label, pavrc_cmd->pdu, - AVRC_STS_BAD_PARAM); - return; - } - else - { - int attr_cnt, filled_attr_count; - - num_attr = 0; - /* Attribute IDs from 1 to AVRC_MAX_NUM_MEDIA_ATTR_ID are only valid, - * hence HAL definition limits the attributes to AVRC_MAX_NUM_MEDIA_ATTR_ID. - * Fill only valid entries. - */ - for (attr_cnt = 0; (attr_cnt < pavrc_cmd->get_elem_attrs.num_attr) && - (num_attr < AVRC_MAX_NUM_MEDIA_ATTR_ID); attr_cnt++) - { - if ((pavrc_cmd->get_elem_attrs.attrs[attr_cnt] > 0) && - (pavrc_cmd->get_elem_attrs.attrs[attr_cnt] <= AVRC_MAX_NUM_MEDIA_ATTR_ID)) - { - /* Skip the duplicate entries : PTS sends duplicate entries for Fragment cases - */ - for (filled_attr_count = 0; filled_attr_count < num_attr; filled_attr_count++) - { - if (element_attrs[filled_attr_count] == pavrc_cmd->get_elem_attrs.attrs[attr_cnt]) - break; - } - if (filled_attr_count == num_attr) - { - element_attrs[num_attr] = pavrc_cmd->get_elem_attrs.attrs[attr_cnt]; - num_attr++; - } - } - } - } - FILL_PDU_QUEUE(IDX_GET_ELEMENT_ATTR_RSP, ctype, label, TRUE); - BTC_HAL_CBACK(bt_rc_callbacks, get_element_attr_cb, num_attr, element_attrs); - } - break; - case AVRC_PDU_REGISTER_NOTIFICATION: - { - if(pavrc_cmd->reg_notif.event_id == BTRC_EVT_PLAY_POS_CHANGED && - pavrc_cmd->reg_notif.param == 0) - { - LOG_WARN("%s Device registering position changed with illegal param 0.", - __FUNCTION__); - send_reject_response (btc_rc_vb.rc_handle, label, pavrc_cmd->pdu, AVRC_STS_BAD_PARAM); - /* de-register this notification for a rejected response */ - btc_rc_vb.rc_notif[BTRC_EVT_PLAY_POS_CHANGED - 1].bNotify = FALSE; - return; - } - BTC_HAL_CBACK(bt_rc_callbacks, register_notification_cb, pavrc_cmd->reg_notif.event_id, - pavrc_cmd->reg_notif.param); - } - break; - case AVRC_PDU_INFORM_DISPLAY_CHARSET: - { - tAVRC_RESPONSE avrc_rsp; - LOG_INFO("%s() AVRC_PDU_INFORM_DISPLAY_CHARSET", __FUNCTION__); - if(btc_rc_vb.rc_connected == TRUE) - { - memset(&(avrc_rsp.inform_charset), 0, sizeof(tAVRC_RSP)); - avrc_rsp.inform_charset.opcode=opcode_from_pdu(AVRC_PDU_INFORM_DISPLAY_CHARSET); - avrc_rsp.inform_charset.pdu=AVRC_PDU_INFORM_DISPLAY_CHARSET; - avrc_rsp.inform_charset.status=AVRC_STS_NO_ERROR; - send_metamsg_rsp(btc_rc_vb.rc_handle, label, ctype, &avrc_rsp); - } - } - break; - default: - { - send_reject_response (btc_rc_vb.rc_handle, label, pavrc_cmd->pdu, - (pavrc_cmd->pdu == AVRC_PDU_SEARCH)?AVRC_STS_SEARCH_NOT_SUP:AVRC_STS_BAD_CMD); - return; - } - break; - } - -} - - -/******************************************************************************* -** -** Function btc_rc_upstreams_rsp_evt -** -** Description Executes AVRC UPSTREAMS response events in btc context. -** -** Returns void -** -*******************************************************************************/ -static void btc_rc_upstreams_rsp_evt(UINT16 event, tAVRC_RESPONSE *pavrc_resp, UINT8 ctype, UINT8 label) -{ - LOG_INFO("%s pdu: %s handle: 0x%x ctype:%x label:%x", __FUNCTION__, - dump_rc_pdu(pavrc_resp->pdu), btc_rc_vb.rc_handle, ctype, label); - -#if (AVRC_ADV_CTRL_INCLUDED == TRUE) - switch (event) - { - case AVRC_PDU_REGISTER_NOTIFICATION: - { - if(AVRC_RSP_CHANGED==ctype) - btc_rc_vb.rc_volume=pavrc_resp->reg_notif.param.volume; - BTC_HAL_CBACK(bt_rc_callbacks, volume_change_cb, pavrc_resp->reg_notif.param.volume,ctype) - } - break; - - case AVRC_PDU_SET_ABSOLUTE_VOLUME: - { - LOG_DEBUG("Set absolute volume change event received: volume %d,ctype %d", - pavrc_resp->volume.volume,ctype); - if(AVRC_RSP_ACCEPT==ctype) - btc_rc_vb.rc_volume=pavrc_resp->volume.volume; - BTC_HAL_CBACK(bt_rc_callbacks,volume_change_cb,pavrc_resp->volume.volume,ctype) - } - break; - - default: - return; - } -#endif -} - /************************************************************************************ ** AVRCP API Functions ************************************************************************************/ -#if 0 -/******************************************************************************* -** -** Function esp_avrc_ct_register_callback -** -** Description Register AVRCP controller callback function -** -** Returns esp_err_t -** -*******************************************************************************/ -esp_err_t esp_avrc_ct_register_callback(esp_avrc_ct_cb_t callback) -{ - if (bt_rc_ctrl_callback) - return ESP_FAIL; - - bt_rc_ctrl_callback = callback; - return ESP_OK; -} -#endif - /******************************************************************************* ** ** Function btc_avrc_ct_init @@ -1159,129 +391,6 @@ static void btc_avrc_ct_init(void) memset (&btc_rc_vb, 0, sizeof(btc_rc_vb)); btc_rc_vb.rc_vol_label=MAX_LABEL; btc_rc_vb.rc_volume=MAX_VOLUME; - lbl_init(); -} - - -/*************************************************************************** -** -** Function register_volumechange -** -** Description Register for volume change notification from remote side. -** -** Returns void -** -***************************************************************************/ - -static void register_volumechange (UINT8 lbl) -{ - tAVRC_COMMAND avrc_cmd = {0}; - BT_HDR *p_msg = NULL; - tAVRC_STS BldResp=AVRC_STS_BAD_CMD; - rc_transaction_t *p_transaction=NULL; - - LOG_DEBUG("%s called with label:%d",__FUNCTION__,lbl); - - avrc_cmd.cmd.opcode=0x00; - avrc_cmd.pdu = AVRC_PDU_REGISTER_NOTIFICATION; - avrc_cmd.reg_notif.event_id = AVRC_EVT_VOLUME_CHANGE; - avrc_cmd.reg_notif.status = AVRC_STS_NO_ERROR; - - BldResp=AVRC_BldCommand(&avrc_cmd, &p_msg); - if(AVRC_STS_NO_ERROR==BldResp && p_msg) - { - p_transaction=get_transaction_by_lbl(lbl); - if(NULL!=p_transaction) - { - BTA_AvMetaCmd(btc_rc_vb.rc_handle,p_transaction->lbl, AVRC_CMD_NOTIF, p_msg); - LOG_DEBUG("%s:BTA_AvMetaCmd called",__FUNCTION__); - } - else - { - if(NULL!=p_msg) - GKI_freebuf(p_msg); - LOG_ERROR("%s transaction not obtained with label: %d",__FUNCTION__,lbl); - } - } - else - LOG_ERROR("%s failed to build command:%d",__FUNCTION__,BldResp); -} - - -/*************************************************************************** -** -** Function handle_rc_metamsg_rsp -** -** Description Handle RC metamessage response -** -** Returns void -** -***************************************************************************/ -static void handle_rc_metamsg_rsp(tBTA_AV_META_MSG *pmeta_msg) -{ - tAVRC_RESPONSE avrc_response = {0}; - UINT8 scratch_buf[512] = {0}; - tAVRC_STS status = BT_STATUS_UNSUPPORTED; - - if(AVRC_OP_VENDOR==pmeta_msg->p_msg->hdr.opcode &&(AVRC_RSP_CHANGED==pmeta_msg->code - || AVRC_RSP_INTERIM==pmeta_msg->code || AVRC_RSP_ACCEPT==pmeta_msg->code - || AVRC_RSP_REJ==pmeta_msg->code || AVRC_RSP_NOT_IMPL==pmeta_msg->code)) - { - status=AVRC_ParsResponse(pmeta_msg->p_msg, &avrc_response, scratch_buf, sizeof(scratch_buf)); - LOG_DEBUG("%s: code %d,event ID %d,PDU %x,parsing status %d, label:%d", - __FUNCTION__,pmeta_msg->code,avrc_response.reg_notif.event_id,avrc_response.reg_notif.pdu, - status, pmeta_msg->label); - - if (status != AVRC_STS_NO_ERROR) - { - if(AVRC_PDU_REGISTER_NOTIFICATION==avrc_response.rsp.pdu - && AVRC_EVT_VOLUME_CHANGE==avrc_response.reg_notif.event_id - && btc_rc_vb.rc_vol_label==pmeta_msg->label) - { - btc_rc_vb.rc_vol_label=MAX_LABEL; - release_transaction(btc_rc_vb.rc_vol_label); - } - else if(AVRC_PDU_SET_ABSOLUTE_VOLUME==avrc_response.rsp.pdu) - { - release_transaction(pmeta_msg->label); - } - return; - } - else if(AVRC_PDU_REGISTER_NOTIFICATION==avrc_response.rsp.pdu - && AVRC_EVT_VOLUME_CHANGE==avrc_response.reg_notif.event_id - && btc_rc_vb.rc_vol_label!=pmeta_msg->label) - { - // Just discard the message, if the device sends back with an incorrect label - LOG_DEBUG("%s:Discarding register notfn in rsp.code: %d and label %d", - __FUNCTION__, pmeta_msg->code, pmeta_msg->label); - return; - } - } - else - { - LOG_DEBUG("%s:Received vendor dependent in adv ctrl rsp. code: %d len: %d. Not processing it.", - __FUNCTION__, pmeta_msg->code, pmeta_msg->len); - return; - } - - if(AVRC_PDU_REGISTER_NOTIFICATION==avrc_response.rsp.pdu - && AVRC_EVT_VOLUME_CHANGE==avrc_response.reg_notif.event_id - && AVRC_RSP_CHANGED==pmeta_msg->code) - { - /* re-register for volume change notification */ - // Do not re-register for rejected case, as it might get into endless loop - register_volumechange(btc_rc_vb.rc_vol_label); - } - else if(AVRC_PDU_SET_ABSOLUTE_VOLUME==avrc_response.rsp.pdu) - { - /* free up the label here */ - release_transaction(pmeta_msg->label); - } - - LOG_INFO("%s: Passing received metamsg response to app. pdu: %s", - __FUNCTION__, dump_rc_pdu(avrc_response.pdu)); - btc_rc_upstreams_rsp_evt((uint16_t)avrc_response.rsp.pdu, &avrc_response, pmeta_msg->code, - pmeta_msg->label); } @@ -1299,7 +408,6 @@ static void btc_avrc_ct_deinit(void) LOG_INFO("## %s ##", __FUNCTION__); memset(&btc_rc_vb, 0, sizeof(btc_rc_cb_t)); - lbl_destroy(); LOG_INFO("## %s ## completed", __FUNCTION__); } @@ -1333,159 +441,6 @@ static bt_status_t btc_avrc_ct_send_passthrough_cmd(uint8_t tl, uint8_t key_code return status; } -/******************************************************************************* -** Function initialize_transaction -** -** Description Initializes fields of the transaction structure -** -** Returns void -*******************************************************************************/ -static void initialize_transaction(int lbl) -{ - pthread_mutex_lock(&device.lbllock); - if(lbl < MAX_TRANSACTIONS_PER_SESSION) - { - device.transaction[lbl].lbl = lbl; - device.transaction[lbl].in_use=FALSE; - device.transaction[lbl].handle=0; - } - pthread_mutex_unlock(&device.lbllock); -} - -/******************************************************************************* -** Function lbl_init -** -** Description Initializes label structures and mutexes. -** -** Returns void -*******************************************************************************/ -void lbl_init() -{ - memset(&device,0,sizeof(rc_device_t)); - // pthread_mutexattr_t attr; - // pthread_mutexattr_init(&attr); - // pthread_mutex_init(&(device.lbllock), &attr); - // pthread_mutexattr_destroy(&attr); - pthread_mutex_init(&(device.lbllock), NULL); - - init_all_transactions(); -} - -/******************************************************************************* -** -** Function init_all_transactions -** -** Description Initializes all transactions -** -** Returns void -*******************************************************************************/ -void init_all_transactions() -{ - UINT8 txn_indx=0; - for(txn_indx=0; txn_indx < MAX_TRANSACTIONS_PER_SESSION; txn_indx++) - { - initialize_transaction(txn_indx); - } -} - -/******************************************************************************* -** -** Function get_transaction_by_lbl -** -** Description Will return a transaction based on the label. If not inuse -** will return an error. -** -** Returns bt_status_t -*******************************************************************************/ -rc_transaction_t *get_transaction_by_lbl(UINT8 lbl) -{ - rc_transaction_t *transaction = NULL; - pthread_mutex_lock(&device.lbllock); - - /* Determine if this is a valid label */ - if (lbl < MAX_TRANSACTIONS_PER_SESSION) - { - if (FALSE==device.transaction[lbl].in_use) - { - transaction = NULL; - } - else - { - transaction = &(device.transaction[lbl]); - LOG_DEBUG("%s: Got transaction.label: %d",__FUNCTION__,lbl); - } - } - - pthread_mutex_unlock(&device.lbllock); - return transaction; -} - -/******************************************************************************* -** -** Function get_transaction -** -** Description Obtains the transaction details. -** -** Returns bt_status_t -*******************************************************************************/ - -bt_status_t get_transaction(rc_transaction_t **ptransaction) -{ - bt_status_t result = BT_STATUS_NOMEM; - UINT8 i=0; - pthread_mutex_lock(&device.lbllock); - - // Check for unused transactions - for (i=0; iarg); diff --git a/components/bt/bluedroid/btc/profile/std/include/btc_avrc.h b/components/bt/bluedroid/btc/profile/std/include/btc_avrc.h index e553816a1a..5d91dde2f5 100644 --- a/components/bt/bluedroid/btc/profile/std/include/btc_avrc.h +++ b/components/bt/bluedroid/btc/profile/std/include/btc_avrc.h @@ -23,16 +23,11 @@ #include "bt_types.h" #include "bta_av_api.h" +#ifndef BTC_AVRC_TGT_INCLUDED +#define BTC_AVRC_TGT_INCLUDED FALSE +#endif + /* Macros */ -#define BTRC_MAX_ATTR_STR_LEN 255 -#define BTRC_UID_SIZE 8 -#define BTRC_MAX_APP_SETTINGS 8 -#define BTRC_MAX_FOLDER_DEPTH 4 -#define BTRC_MAX_APP_ATTR_SIZE 16 -#define BTRC_MAX_ELEM_ATTR_SIZE 7 - -typedef uint8_t btrc_uid_t[BTRC_UID_SIZE]; - typedef enum { BTRC_FEAT_NONE = 0x00, /* AVRCP 1.0 */ BTRC_FEAT_METADATA = 0x01, /* AVRCP 1.3 */ @@ -40,73 +35,6 @@ typedef enum { BTRC_FEAT_BROWSE = 0x04, /* AVRCP 1.4 and up, with Browsing support */ } btrc_remote_features_t; -typedef enum { - BTRC_PLAYSTATE_STOPPED = 0x00, /* Stopped */ - BTRC_PLAYSTATE_PLAYING = 0x01, /* Playing */ - BTRC_PLAYSTATE_PAUSED = 0x02, /* Paused */ - BTRC_PLAYSTATE_FWD_SEEK = 0x03, /* Fwd Seek*/ - BTRC_PLAYSTATE_REV_SEEK = 0x04, /* Rev Seek*/ - BTRC_PLAYSTATE_ERROR = 0xFF, /* Error */ -} btrc_play_status_t; - -typedef enum { - BTRC_EVT_PLAY_STATUS_CHANGED = 0x01, - BTRC_EVT_TRACK_CHANGE = 0x02, - BTRC_EVT_TRACK_REACHED_END = 0x03, - BTRC_EVT_TRACK_REACHED_START = 0x04, - BTRC_EVT_PLAY_POS_CHANGED = 0x05, - BTRC_EVT_APP_SETTINGS_CHANGED = 0x08, -} btrc_event_id_t; - -typedef enum { - BTRC_NOTIFICATION_TYPE_INTERIM = 0, - BTRC_NOTIFICATION_TYPE_CHANGED = 1, -} btrc_notification_type_t; - -typedef enum { - BTRC_PLAYER_ATTR_EQUALIZER = 0x01, - BTRC_PLAYER_ATTR_REPEAT = 0x02, - BTRC_PLAYER_ATTR_SHUFFLE = 0x03, - BTRC_PLAYER_ATTR_SCAN = 0x04, -} btrc_player_attr_t; - -typedef enum { - BTRC_MEDIA_ATTR_TITLE = 0x01, - BTRC_MEDIA_ATTR_ARTIST = 0x02, - BTRC_MEDIA_ATTR_ALBUM = 0x03, - BTRC_MEDIA_ATTR_TRACK_NUM = 0x04, - BTRC_MEDIA_ATTR_NUM_TRACKS = 0x05, - BTRC_MEDIA_ATTR_GENRE = 0x06, - BTRC_MEDIA_ATTR_PLAYING_TIME = 0x07, -} btrc_media_attr_t; - -typedef enum { - BTRC_PLAYER_VAL_OFF_REPEAT = 0x01, - BTRC_PLAYER_VAL_SINGLE_REPEAT = 0x02, - BTRC_PLAYER_VAL_ALL_REPEAT = 0x03, - BTRC_PLAYER_VAL_GROUP_REPEAT = 0x04 -} btrc_player_repeat_val_t; - -typedef enum { - BTRC_PLAYER_VAL_OFF_SHUFFLE = 0x01, - BTRC_PLAYER_VAL_ALL_SHUFFLE = 0x02, - BTRC_PLAYER_VAL_GROUP_SHUFFLE = 0x03 -} btrc_player_shuffle_val_t; - -typedef enum { - BTRC_STS_BAD_CMD = 0x00, /* Invalid command */ - BTRC_STS_BAD_PARAM = 0x01, /* Invalid parameter */ - BTRC_STS_NOT_FOUND = 0x02, /* Specified parameter is wrong or not found */ - BTRC_STS_INTERNAL_ERR = 0x03, /* Internal Error */ - BTRC_STS_NO_ERROR = 0x04 /* Operation Success */ -} btrc_status_t; - -typedef struct { - uint8_t num_attr; - uint8_t attr_ids[BTRC_MAX_APP_SETTINGS]; - uint8_t attr_values[BTRC_MAX_APP_SETTINGS]; -} btrc_player_settings_t; - typedef enum { BTC_AVRC_CTRL_API_INIT_EVT = 0, BTC_AVRC_CTRL_API_DEINIT_EVT, @@ -129,167 +57,7 @@ typedef union { } pt_cmd; } btc_avrc_args_t; -typedef union -{ - btrc_play_status_t play_status; - btrc_uid_t track; /* queue position in NowPlaying */ - uint32_t song_pos; - btrc_player_settings_t player_setting; -} btrc_register_notification_t; - -typedef struct { - uint8_t id; /* can be attr_id or value_id */ - uint8_t text[BTRC_MAX_ATTR_STR_LEN]; -} btrc_player_setting_text_t; - -typedef struct { - uint32_t attr_id; - uint8_t text[BTRC_MAX_ATTR_STR_LEN]; -} btrc_element_attr_val_t; - -/** Callback for the controller's supported feautres */ -typedef void (* btrc_remote_features_callback)(bt_bdaddr_t *bd_addr, - btrc_remote_features_t features); - -/** Callback for play status request */ -typedef void (* btrc_get_play_status_callback)(); - -/** Callback for list player application attributes (Shuffle, Repeat,...) */ -typedef void (* btrc_list_player_app_attr_callback)(); - -/** Callback for list player application attributes (Shuffle, Repeat,...) */ -typedef void (* btrc_list_player_app_values_callback)(btrc_player_attr_t attr_id); - -/** Callback for getting the current player application settings value -** num_attr: specifies the number of attribute ids contained in p_attrs -*/ -typedef void (* btrc_get_player_app_value_callback) (uint8_t num_attr, btrc_player_attr_t *p_attrs); - -/** Callback for getting the player application settings attributes' text -** num_attr: specifies the number of attribute ids contained in p_attrs -*/ -typedef void (* btrc_get_player_app_attrs_text_callback) (uint8_t num_attr, btrc_player_attr_t *p_attrs); - -/** Callback for getting the player application settings values' text -** num_attr: specifies the number of value ids contained in p_vals -*/ -typedef void (* btrc_get_player_app_values_text_callback) (uint8_t attr_id, uint8_t num_val, uint8_t *p_vals); - -/** Callback for setting the player application settings values */ -typedef void (* btrc_set_player_app_value_callback) (btrc_player_settings_t *p_vals); - -/** Callback to fetch the get element attributes of the current song -** num_attr: specifies the number of attributes requested in p_attrs -*/ -typedef void (* btrc_get_element_attr_callback) (uint8_t num_attr, btrc_media_attr_t *p_attrs); - -/** Callback for register notification (Play state change/track change/...) -** param: Is only valid if event_id is BTRC_EVT_PLAY_POS_CHANGED -*/ -typedef void (* btrc_register_notification_callback) (btrc_event_id_t event_id, uint32_t param); - -/* AVRCP 1.4 Enhancements */ -/** Callback for volume change on CT -** volume: Current volume setting on the CT (0-127) -*/ -typedef void (* btrc_volume_change_callback) (uint8_t volume, uint8_t ctype); - -/** Callback for passthrough commands */ -typedef void (* btrc_passthrough_cmd_callback) (int id, int key_state); - -/** BT-RC Target callback structure. */ -typedef struct { - /** set to sizeof(BtRcCallbacks) */ - size_t size; - btrc_remote_features_callback remote_features_cb; - btrc_get_play_status_callback get_play_status_cb; - btrc_list_player_app_attr_callback list_player_app_attr_cb; - btrc_list_player_app_values_callback list_player_app_values_cb; - btrc_get_player_app_value_callback get_player_app_value_cb; - btrc_get_player_app_attrs_text_callback get_player_app_attrs_text_cb; - btrc_get_player_app_values_text_callback get_player_app_values_text_cb; - btrc_set_player_app_value_callback set_player_app_value_cb; - btrc_get_element_attr_callback get_element_attr_cb; - btrc_register_notification_callback register_notification_cb; - btrc_volume_change_callback volume_change_cb; - btrc_passthrough_cmd_callback passthrough_cmd_cb; -} btrc_callbacks_t; - -/** Represents the standard BT-RC AVRCP Target interface. */ -typedef struct { - - /** set to sizeof(BtRcInterface) */ - size_t size; - /** - * Register the BtRc callbacks - */ - bt_status_t (*init)( btrc_callbacks_t* callbacks ); - - /** Respose to GetPlayStatus request. Contains the current - ** 1. Play status - ** 2. Song duration/length - ** 3. Song position - */ - bt_status_t (*get_play_status_rsp)( btrc_play_status_t play_status, uint32_t song_len, uint32_t song_pos); - - /** Lists the support player application attributes (Shuffle/Repeat/...) - ** num_attr: Specifies the number of attributes contained in the pointer p_attrs - */ - bt_status_t (*list_player_app_attr_rsp)( int num_attr, btrc_player_attr_t *p_attrs); - - /** Lists the support player application attributes (Shuffle Off/On/Group) - ** num_val: Specifies the number of values contained in the pointer p_vals - */ - bt_status_t (*list_player_app_value_rsp)( int num_val, uint8_t *p_vals); - - /** Returns the current application attribute values for each of the specified attr_id */ - bt_status_t (*get_player_app_value_rsp)( btrc_player_settings_t *p_vals); - - /** Returns the application attributes text ("Shuffle"/"Repeat"/...) - ** num_attr: Specifies the number of attributes' text contained in the pointer p_attrs - */ - bt_status_t (*get_player_app_attr_text_rsp)( int num_attr, btrc_player_setting_text_t *p_attrs); - - /** Returns the application attributes text ("Shuffle"/"Repeat"/...) - ** num_attr: Specifies the number of attribute values' text contained in the pointer p_vals - */ - bt_status_t (*get_player_app_value_text_rsp)( int num_val, btrc_player_setting_text_t *p_vals); - - /** Returns the current songs' element attributes text ("Title"/"Album"/"Artist") - ** num_attr: Specifies the number of attributes' text contained in the pointer p_attrs - */ - bt_status_t (*get_element_attr_rsp)( uint8_t num_attr, btrc_element_attr_val_t *p_attrs); - - /** Response to set player attribute request ("Shuffle"/"Repeat") - ** rsp_status: Status of setting the player attributes for the current media player - */ - bt_status_t (*set_player_app_value_rsp)(btrc_status_t rsp_status); - - /* Response to the register notification request (Play state change/track change/...). - ** event_id: Refers to the event_id this notification change corresponds too - ** type: Response type - interim/changed - ** p_params: Based on the event_id, this parameter should be populated - */ - bt_status_t (*register_notification_rsp)(btrc_event_id_t event_id, - btrc_notification_type_t type, - btrc_register_notification_t *p_param); - - /* AVRCP 1.4 enhancements */ - - /**Send current volume setting to remote side. Support limited to SetAbsoluteVolume - ** This can be enhanced to support Relative Volume (AVRCP 1.0). - ** With RelateVolume, we will send VOLUME_UP/VOLUME_DOWN opposed to absolute volume level - ** volume: Should be in the range 0-127. bit7 is reseved and cannot be set - */ - bt_status_t (*set_volume)(uint8_t volume); - - /** Closes the interface. */ - void (*cleanup)( void ); -} btrc_interface_t; - - /** BT-RC Controller callback structure. */ - typedef void (* btrc_passthrough_rsp_callback) (int id, int key_state); typedef void (* btrc_connection_state_callback) (bool state, bt_bdaddr_t *bd_addr); @@ -298,9 +66,6 @@ void btc_rc_handler(tBTA_AV_EVT event, tBTA_AV *p_data); BOOLEAN btc_rc_get_connected_peer(BD_ADDR peer_addr); -void btc_rc_check_handle_pending_play (BD_ADDR peer_addr, BOOLEAN bSendToApp); - - /******************************************************************************* ** BTC AVRC API ********************************************************************************/ diff --git a/components/bt/bluedroid/btif/include/uinput.h b/components/bt/bluedroid/btif/include/uinput.h deleted file mode 100644 index 0e03ef2495..0000000000 --- a/components/bt/bluedroid/btif/include/uinput.h +++ /dev/null @@ -1,594 +0,0 @@ -/****************************************************************************** - * - * Copyright (C) 2009-2012 Broadcom Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at: - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - ******************************************************************************/ - -#ifndef __UINPUT_H -#define __UINPUT_H - -#ifdef __cplusplus -extern "C" { -#endif - -#include -// #include -// #include - -/******************************************************************************* -** Constants & Macros -********************************************************************************/ - -/* Events */ - -#define EV_SYN 0x00 -#define EV_KEY 0x01 -#define EV_REL 0x02 -#define EV_ABS 0x03 -#define EV_MSC 0x04 -#define EV_LED 0x11 -#define EV_SND 0x12 -#define EV_REP 0x14 -#define EV_FF 0x15 -#define EV_PWR 0x16 -#define EV_FF_STATUS 0x17 -#define EV_MAX 0x1f - -/* Synchronization events */ - -#define SYN_REPORT 0 -#define SYN_CONFIG 1 - -/* Keys and buttons */ - -#define KEY_RESERVED 0 -#define KEY_ESC 1 -#define KEY_1 2 -#define KEY_2 3 -#define KEY_3 4 -#define KEY_4 5 -#define KEY_5 6 -#define KEY_6 7 -#define KEY_7 8 -#define KEY_8 9 -#define KEY_9 10 -#define KEY_0 11 -#define KEY_MINUS 12 -#define KEY_EQUAL 13 -#define KEY_BACKSPACE 14 -#define KEY_TAB 15 -#define KEY_Q 16 -#define KEY_W 17 -#define KEY_E 18 -#define KEY_R 19 -#define KEY_T 20 -#define KEY_Y 21 -#define KEY_U 22 -#define KEY_I 23 -#define KEY_O 24 -#define KEY_P 25 -#define KEY_LEFTBRACE 26 -#define KEY_RIGHTBRACE 27 -#define KEY_ENTER 28 -#define KEY_LEFTCTRL 29 -#define KEY_A 30 -#define KEY_S 31 -#define KEY_D 32 -#define KEY_F 33 -#define KEY_G 34 -#define KEY_H 35 -#define KEY_J 36 -#define KEY_K 37 -#define KEY_L 38 -#define KEY_SEMICOLON 39 -#define KEY_APOSTROPHE 40 -#define KEY_GRAVE 41 -#define KEY_LEFTSHIFT 42 -#define KEY_BACKSLASH 43 -#define KEY_Z 44 -#define KEY_X 45 -#define KEY_C 46 -#define KEY_V 47 -#define KEY_B 48 -#define KEY_N 49 -#define KEY_M 50 -#define KEY_COMMA 51 -#define KEY_DOT 52 -#define KEY_SLASH 53 -#define KEY_RIGHTSHIFT 54 -#define KEY_KPASTERISK 55 -#define KEY_LEFTALT 56 -#define KEY_SPACE 57 -#define KEY_CAPSLOCK 58 -#define KEY_F1 59 -#define KEY_F2 60 -#define KEY_F3 61 -#define KEY_F4 62 -#define KEY_F5 63 -#define KEY_F6 64 -#define KEY_F7 65 -#define KEY_F8 66 -#define KEY_F9 67 -#define KEY_F10 68 -#define KEY_NUMLOCK 69 -#define KEY_SCROLLLOCK 70 -#define KEY_KP7 71 -#define KEY_KP8 72 -#define KEY_KP9 73 -#define KEY_KPMINUS 74 -#define KEY_KP4 75 -#define KEY_KP5 76 -#define KEY_KP6 77 -#define KEY_KPPLUS 78 -#define KEY_KP1 79 -#define KEY_KP2 80 -#define KEY_KP3 81 -#define KEY_KP0 82 -#define KEY_KPDOT 83 -#define KEY_103RD 84 -#define KEY_F13 85 -#define KEY_102ND 86 -#define KEY_F11 87 -#define KEY_F12 88 -#define KEY_F14 89 -#define KEY_F15 90 -#define KEY_F16 91 -#define KEY_F17 92 -#define KEY_F18 93 -#define KEY_F19 94 -#define KEY_F20 95 -#define KEY_KPENTER 96 -#define KEY_RIGHTCTRL 97 -#define KEY_KPSLASH 98 -#define KEY_SYSRQ 99 -#define KEY_RIGHTALT 100 -#define KEY_LINEFEED 101 -#define KEY_HOME 102 -#define KEY_UP 103 -#define KEY_PAGEUP 104 -#define KEY_LEFT 105 -#define KEY_RIGHT 106 -#define KEY_END 107 -#define KEY_DOWN 108 -#define KEY_PAGEDOWN 109 -#define KEY_INSERT 110 -#define KEY_DELETE 111 -#define KEY_MACRO 112 -#define KEY_MUTE 113 -#define KEY_VOLUMEDOWN 114 -#define KEY_VOLUMEUP 115 -#define KEY_POWER 116 -#define KEY_KPEQUAL 117 -#define KEY_KPPLUSMINUS 118 -#define KEY_PAUSE 119 -#define KEY_F21 120 -#define KEY_F22 121 -#define KEY_F23 122 -#define KEY_F24 123 -#define KEY_KPCOMMA 124 -#define KEY_LEFTMETA 125 -#define KEY_RIGHTMETA 126 -#define KEY_COMPOSE 127 - -#define KEY_STOP 128 -#define KEY_AGAIN 129 -#define KEY_PROPS 130 -#define KEY_UNDO 131 -#define KEY_FRONT 132 -#define KEY_COPY 133 -#define KEY_OPEN 134 -#define KEY_PASTE 135 -#define KEY_FIND 136 -#define KEY_CUT 137 -#define KEY_HELP 138 -#define KEY_MENU 139 -#define KEY_CALC 140 -#define KEY_SETUP 141 -#define KEY_SLEEP 142 -#define KEY_WAKEUP 143 -#define KEY_FILE 144 -#define KEY_SENDFILE 145 -#define KEY_DELETEFILE 146 -#define KEY_XFER 147 -#define KEY_PROG1 148 -#define KEY_PROG2 149 -#define KEY_WWW 150 -#define KEY_MSDOS 151 -#define KEY_COFFEE 152 -#define KEY_DIRECTION 153 -#define KEY_CYCLEWINDOWS 154 -#define KEY_MAIL 155 -#define KEY_BOOKMARKS 156 -#define KEY_COMPUTER 157 -#define KEY_BACK 158 -#define KEY_FORWARD 159 -#define KEY_CLOSECD 160 -#define KEY_EJECTCD 161 -#define KEY_EJECTCLOSECD 162 -#define KEY_NEXTSONG 163 -#define KEY_PLAYPAUSE 164 -#define KEY_PREVIOUSSONG 165 -#define KEY_STOPCD 166 -#define KEY_RECORD 167 -#define KEY_REWIND 168 -#define KEY_PHONE 169 -#define KEY_ISO 170 -#define KEY_CONFIG 171 -#define KEY_HOMEPAGE 172 -#define KEY_REFRESH 173 -#define KEY_EXIT 174 -#define KEY_MOVE 175 -#define KEY_EDIT 176 -#define KEY_SCROLLUP 177 -#define KEY_SCROLLDOWN 178 -#define KEY_KPLEFTPAREN 179 -#define KEY_KPRIGHTPAREN 180 - -#define KEY_INTL1 181 -#define KEY_INTL2 182 -#define KEY_INTL3 183 -#define KEY_INTL4 184 -#define KEY_INTL5 185 -#define KEY_INTL6 186 -#define KEY_INTL7 187 -#define KEY_INTL8 188 -#define KEY_INTL9 189 -#define KEY_LANG1 190 -#define KEY_LANG2 191 -#define KEY_LANG3 192 -#define KEY_LANG4 193 -#define KEY_LANG5 194 -#define KEY_LANG6 195 -#define KEY_LANG7 196 -#define KEY_LANG8 197 -#define KEY_LANG9 198 - -#define KEY_PLAYCD 200 -#define KEY_PAUSECD 201 -#define KEY_PROG3 202 -#define KEY_PROG4 203 -#define KEY_SUSPEND 205 -#define KEY_CLOSE 206 -#define KEY_PLAY 207 -#define KEY_FAST_FORWARD 208 - -#define KEY_UNKNOWN 220 - -#define KEY_BRIGHTNESSDOWN 224 -#define KEY_BRIGHTNESSUP 225 - -#define BTN_MISC 0x100 -#define BTN_0 0x100 -#define BTN_1 0x101 -#define BTN_2 0x102 -#define BTN_3 0x103 -#define BTN_4 0x104 -#define BTN_5 0x105 -#define BTN_6 0x106 -#define BTN_7 0x107 -#define BTN_8 0x108 -#define BTN_9 0x109 - -#define BTN_MOUSE 0x110 -#define BTN_LEFT 0x110 -#define BTN_RIGHT 0x111 -#define BTN_MIDDLE 0x112 -#define BTN_SIDE 0x113 -#define BTN_EXTRA 0x114 -#define BTN_FORWARD 0x115 -#define BTN_BACK 0x116 -#define BTN_TASK 0x117 - -#define BTN_JOYSTICK 0x120 -#define BTN_TRIGGER 0x120 -#define BTN_THUMB 0x121 -#define BTN_THUMB2 0x122 -#define BTN_TOP 0x123 -#define BTN_TOP2 0x124 -#define BTN_PINKIE 0x125 -#define BTN_BASE 0x126 -#define BTN_BASE2 0x127 -#define BTN_BASE3 0x128 -#define BTN_BASE4 0x129 -#define BTN_BASE5 0x12a -#define BTN_BASE6 0x12b -#define BTN_DEAD 0x12f - -#define BTN_GAMEPAD 0x130 -#define BTN_A 0x130 -#define BTN_B 0x131 -#define BTN_C 0x132 -#define BTN_X 0x133 -#define BTN_Y 0x134 -#define BTN_Z 0x135 -#define BTN_TL 0x136 -#define BTN_TR 0x137 -#define BTN_TL2 0x138 -#define BTN_TR2 0x139 -#define BTN_SELECT 0x13a -#define BTN_START 0x13b -#define BTN_MODE 0x13c -#define BTN_THUMBL 0x13d -#define BTN_THUMBR 0x13e - -#define BTN_DIGI 0x140 -#define BTN_TOOL_PEN 0x140 -#define BTN_TOOL_RUBBER 0x141 -#define BTN_TOOL_BRUSH 0x142 -#define BTN_TOOL_PENCIL 0x143 -#define BTN_TOOL_AIRBRUSH 0x144 -#define BTN_TOOL_FINGER 0x145 -#define BTN_TOOL_MOUSE 0x146 -#define BTN_TOOL_LENS 0x147 -#define BTN_TOUCH 0x14a -#define BTN_STYLUS 0x14b -#define BTN_STYLUS2 0x14c -#define BTN_TOOL_DOUBLETAP 0x14d -#define BTN_TOOL_TRIPLETAP 0x14e - -#define BTN_WHEEL 0x150 -#define BTN_GEAR_DOWN 0x150 -#define BTN_GEAR_UP 0x151 - -#define KEY_OK 0x160 -#define KEY_SELECT 0x161 -#define KEY_GOTO 0x162 -#define KEY_CLEAR 0x163 -#define KEY_POWER2 0x164 -#define KEY_OPTION 0x165 -#define KEY_INFO 0x166 -#define KEY_TIME 0x167 -#define KEY_VENDOR 0x168 -#define KEY_ARCHIVE 0x169 -#define KEY_PROGRAM 0x16a -#define KEY_CHANNEL 0x16b -#define KEY_FAVORITES 0x16c -#define KEY_EPG 0x16d -#define KEY_PVR 0x16e -#define KEY_MHP 0x16f -#define KEY_LANGUAGE 0x170 -#define KEY_TITLE 0x171 -#define KEY_SUBTITLE 0x172 -#define KEY_ANGLE 0x173 -#define KEY_ZOOM 0x174 -#define KEY_MODE 0x175 -#define KEY_KEYBOARD 0x176 -#define KEY_SCREEN 0x177 -#define KEY_PC 0x178 -#define KEY_TV 0x179 -#define KEY_TV2 0x17a -#define KEY_VCR 0x17b -#define KEY_VCR2 0x17c -#define KEY_SAT 0x17d -#define KEY_SAT2 0x17e -#define KEY_CD 0x17f -#define KEY_TAPE 0x180 -#define KEY_RADIO 0x181 -#define KEY_TUNER 0x182 -#define KEY_PLAYER 0x183 -#define KEY_TEXT 0x184 -#define KEY_DVD 0x185 -#define KEY_AUX 0x186 -#define KEY_MP3 0x187 -#define KEY_AUDIO 0x188 -#define KEY_VIDEO 0x189 -#define KEY_DIRECTORY 0x18a -#define KEY_LIST 0x18b -#define KEY_MEMO 0x18c -#define KEY_CALENDAR 0x18d -#define KEY_RED 0x18e -#define KEY_GREEN 0x18f -#define KEY_YELLOW 0x190 -#define KEY_BLUE 0x191 -#define KEY_CHANNELUP 0x192 -#define KEY_CHANNELDOWN 0x193 -#define KEY_FIRST 0x194 -#define KEY_LAST 0x195 -#define KEY_AB 0x196 -#define KEY_NEXT 0x197 -#define KEY_RESTART 0x198 -#define KEY_SLOW 0x199 -#define KEY_SHUFFLE 0x19a -#define KEY_BREAK 0x19b -#define KEY_PREVIOUS 0x19c -#define KEY_DIGITS 0x19d -#define KEY_TEEN 0x19e -#define KEY_TWEN 0x19f - -#define KEY_FRAMEBACK 0x1b2 -#define KEY_FRAMEFORWARD 0x1b3 -#define KEY_CONTEXT_MENU 0x1fb - -#define KEY_MAX 0x1ff - -/* Relative axes */ - -#define REL_X 0x00 -#define REL_Y 0x01 -#define REL_Z 0x02 -#define REL_RX 0x03 -#define REL_RY 0x04 -#define REL_RZ 0x05 -#define REL_HWHEEL 0x06 -#define REL_DIAL 0x07 -#define REL_WHEEL 0x08 -#define REL_MISC 0x09 -#define REL_MAX 0x0f - -/* Absolute axes */ - -#define ABS_X 0x00 -#define ABS_Y 0x01 -#define ABS_Z 0x02 -#define ABS_RX 0x03 -#define ABS_RY 0x04 -#define ABS_RZ 0x05 -#define ABS_THROTTLE 0x06 -#define ABS_RUDDER 0x07 -#define ABS_WHEEL 0x08 -#define ABS_GAS 0x09 -#define ABS_BRAKE 0x0a -#define ABS_HAT0X 0x10 -#define ABS_HAT0Y 0x11 -#define ABS_HAT1X 0x12 -#define ABS_HAT1Y 0x13 -#define ABS_HAT2X 0x14 -#define ABS_HAT2Y 0x15 -#define ABS_HAT3X 0x16 -#define ABS_HAT3Y 0x17 -#define ABS_PRESSURE 0x18 -#define ABS_DISTANCE 0x19 -#define ABS_TILT_X 0x1a -#define ABS_TILT_Y 0x1b -#define ABS_TOOL_WIDTH 0x1c -#define ABS_VOLUME 0x20 -#define ABS_MISC 0x28 -#define ABS_MAX 0x3f - -/* Switch events */ - -#define SW_0 0x00 -#define SW_1 0x01 -#define SW_2 0x02 -#define SW_3 0x03 -#define SW_4 0x04 -#define SW_5 0x05 -#define SW_6 0x06 -#define SW_7 0x07 -#define SW_MAX 0x0f - -/* Misc events */ - -#define MSC_SERIAL 0x00 -#define MSC_PULSELED 0x01 -#define MSC_GESTURE 0x02 -#define MSC_RAW 0x03 -#define MSC_SCAN 0x04 -#define MSC_MAX 0x07 - -/* LEDs */ - -#define LED_NUML 0x00 -#define LED_CAPSL 0x01 -#define LED_SCROLLL 0x02 -#define LED_COMPOSE 0x03 -#define LED_KANA 0x04 -#define LED_SLEEP 0x05 -#define LED_SUSPEND 0x06 -#define LED_MUTE 0x07 -#define LED_MISC 0x08 -#define LED_MAIL 0x09 -#define LED_CHARGING 0x0a -#define LED_MAX 0x0f - -/* Autorepeat values */ - -#define REP_DELAY 0x00 -#define REP_PERIOD 0x01 -#define REP_MAX 0x01 - -/* Sounds */ - -#define SND_CLICK 0x00 -#define SND_BELL 0x01 -#define SND_TONE 0x02 -#define SND_MAX 0x07 - -/* Identifiers */ - -#define ID_BUS 0 -#define ID_VENDOR 1 -#define ID_PRODUCT 2 -#define ID_VERSION 3 - -#define BUS_PCI 0x01 -#define BUS_ISAPNP 0x02 -#define BUS_USB 0x03 -#define BUS_HIL 0x04 -#define BUS_BLUETOOTH 0x05 - -#define BUS_ISA 0x10 -#define BUS_I8042 0x11 -#define BUS_XTKBD 0x12 -#define BUS_RS232 0x13 -#define BUS_GAMEPORT 0x14 -#define BUS_PARPORT 0x15 -#define BUS_AMIGA 0x16 -#define BUS_ADB 0x17 -#define BUS_I2C 0x18 -#define BUS_HOST 0x19 -#define BUS_GSC 0x1A - -/* User input interface */ -#if UINPUT_INCLUDED -#define UINPUT_IOCTL_BASE 'U' - -#define UI_DEV_CREATE _IO(UINPUT_IOCTL_BASE, 1) -#define UI_DEV_DESTROY _IO(UINPUT_IOCTL_BASE, 2) - -#define UI_SET_EVBIT _IOW(UINPUT_IOCTL_BASE, 100, int) -#define UI_SET_KEYBIT _IOW(UINPUT_IOCTL_BASE, 101, int) -#define UI_SET_RELBIT _IOW(UINPUT_IOCTL_BASE, 102, int) -#define UI_SET_ABSBIT _IOW(UINPUT_IOCTL_BASE, 103, int) -#define UI_SET_MSCBIT _IOW(UINPUT_IOCTL_BASE, 104, int) -#define UI_SET_LEDBIT _IOW(UINPUT_IOCTL_BASE, 105, int) -#define UI_SET_SNDBIT _IOW(UINPUT_IOCTL_BASE, 106, int) -#define UI_SET_FFBIT _IOW(UINPUT_IOCTL_BASE, 107, int) -#define UI_SET_PHYS _IOW(UINPUT_IOCTL_BASE, 108, char*) -#define UI_SET_SWBIT _IOW(UINPUT_IOCTL_BASE, 109, int) - -#endif /* UINPUT_INCLUDED */ - -#ifndef NBITS -#define NBITS(x) ((((x) - 1) / (sizeof(long) * 8)) + 1) -#endif - -#define UINPUT_MAX_NAME_SIZE 80 - - -/******************************************************************************* -** Type definitions and return values -********************************************************************************/ - -struct uinput_id { - uint16_t bustype; - uint16_t vendor; - uint16_t product; - uint16_t version; -}; - -struct uinput_dev { - char name[UINPUT_MAX_NAME_SIZE]; - struct uinput_id id; - int ff_effects_max; - int absmax[ABS_MAX + 1]; - int absmin[ABS_MAX + 1]; - int absfuzz[ABS_MAX + 1]; - int absflat[ABS_MAX + 1]; -}; - -struct uinput_event { - // struct timeval time; // temporarily remove this part; - uint16_t type; - uint16_t code; - int32_t value; -}; - -#ifdef __cplusplus -} -#endif - -#endif /* __UINPUT_H */ -