summaryrefslogtreecommitdiffstats
path: root/btif/include
diff options
context:
space:
mode:
Diffstat (limited to 'btif/include')
-rw-r--r--btif/include/btif_api.h328
-rw-r--r--btif/include/btif_av.h116
-rw-r--r--btif/include/btif_av_api.h210
-rw-r--r--btif/include/btif_av_co.h173
-rw-r--r--btif/include/btif_common.h183
-rw-r--r--btif/include/btif_config.h77
-rw-r--r--btif/include/btif_config_util.h62
-rw-r--r--btif/include/btif_dm.h49
-rw-r--r--btif/include/btif_hh.h102
-rw-r--r--btif/include/btif_hl.h366
-rw-r--r--btif/include/btif_media.h248
-rw-r--r--btif/include/btif_pan.h36
-rw-r--r--btif/include/btif_pan_internal.h118
-rw-r--r--btif/include/btif_profile_queue.h37
-rw-r--r--btif/include/btif_sm.h118
-rw-r--r--btif/include/btif_sock.h36
-rw-r--r--btif/include/btif_sock_rfc.h38
-rw-r--r--btif/include/btif_sock_sdp.h39
-rw-r--r--btif/include/btif_sock_thread.h49
-rw-r--r--btif/include/btif_sock_util.h65
-rw-r--r--btif/include/btif_storage.h313
-rw-r--r--btif/include/btif_util.h73
-rw-r--r--btif/include/uinput.h590
23 files changed, 3426 insertions, 0 deletions
diff --git a/btif/include/btif_api.h b/btif/include/btif_api.h
new file mode 100644
index 0000000..c787bec
--- /dev/null
+++ b/btif/include/btif_api.h
@@ -0,0 +1,328 @@
+/******************************************************************************
+ *
+ * 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.
+ *
+ ******************************************************************************/
+
+/*******************************************************************************
+ *
+ * Filename: btif_api.h
+ *
+ * Description: Main API header file for all BTIF functions accessed
+ * from main bluetooth HAL. All HAL extensions will not
+ * require headerfiles as they would be accessed through
+ * callout/callins.
+ *
+ *******************************************************************************/
+
+#ifndef BTIF_API_H
+#define BTIF_API_H
+
+#include "btif_common.h"
+#include "btif_dm.h"
+
+/*******************************************************************************
+** BTIF CORE API
+********************************************************************************/
+
+/*******************************************************************************
+**
+** Function btif_init_bluetooth
+**
+** Description Creates BTIF task and prepares BT scheduler for startup
+**
+** Returns bt_status_t
+**
+*******************************************************************************/
+bt_status_t btif_init_bluetooth(void);
+
+/*******************************************************************************
+**
+** Function btif_enable_bluetooth
+**
+** Description Performs chip power on and kickstarts OS scheduler
+**
+** Returns bt_status_t
+**
+*******************************************************************************/
+bt_status_t btif_enable_bluetooth(void);
+
+/*******************************************************************************
+**
+** Function btif_disable_bluetooth
+**
+** Description Inititates shutdown of Bluetooth system.
+** Any active links will be dropped and device entering
+** non connectable/discoverable mode
+**
+** Returns void
+**
+*******************************************************************************/
+bt_status_t btif_disable_bluetooth(void);
+
+/*******************************************************************************
+**
+** Function btif_shutdown_bluetooth
+**
+** Description Finalizes BT scheduler shutdown and terminates BTIF
+** task.
+**
+**
+** Returns void
+**
+*******************************************************************************/
+bt_status_t btif_shutdown_bluetooth(void);
+
+/*******************************************************************************
+**
+** Function btif_get_adapter_properties
+**
+** Description Fetches all local adapter properties
+**
+** Returns bt_status_t
+**
+*******************************************************************************/
+bt_status_t btif_get_adapter_properties(void);
+
+/*******************************************************************************
+**
+** Function btif_get_adapter_property
+**
+** Description Fetches property value from local cache
+**
+** Returns bt_status_t
+**
+*******************************************************************************/
+bt_status_t btif_get_adapter_property( bt_property_type_t type);
+
+/*******************************************************************************
+**
+** Function btif_set_adapter_property
+**
+** Description Updates core stack with property value and stores it in
+** local cache
+**
+** Returns bt_status_t
+**
+*******************************************************************************/
+bt_status_t btif_set_adapter_property( const bt_property_t *property);
+
+/*******************************************************************************
+**
+** Function btif_get_remote_device_property
+**
+** Description Fetches the remote device property from the NVRAM
+**
+** Returns bt_status_t
+**
+*******************************************************************************/
+bt_status_t btif_get_remote_device_property( bt_bdaddr_t *remote_addr,
+ bt_property_type_t type);
+
+/*******************************************************************************
+**
+** Function btif_get_remote_device_properties
+**
+** Description Fetches all the remote device properties from NVRAM
+**
+** Returns bt_status_t
+**
+*******************************************************************************/
+bt_status_t btif_get_remote_device_properties( bt_bdaddr_t *remote_addr);
+
+/*******************************************************************************
+**
+** Function btif_set_remote_device_property
+**
+** Description Writes the remote device property to NVRAM.
+** Currently, BT_PROPERTY_REMOTE_FRIENDLY_NAME is the only
+** remote device property that can be set
+**
+** Returns bt_status_t
+**
+*******************************************************************************/
+bt_status_t btif_set_remote_device_property( bt_bdaddr_t *remote_addr,
+ const bt_property_t *property);
+
+/*******************************************************************************
+**
+** Function btif_get_remote_service_record
+**
+** Description Looks up the service matching uuid on the remote device
+** and fetches the SCN and service_name if the UUID is found
+**
+** Returns bt_status_t
+**
+*******************************************************************************/
+bt_status_t btif_get_remote_service_record( bt_bdaddr_t *remote_addr,
+ bt_uuid_t *uuid);
+
+
+/*******************************************************************************
+** BTIF DM API
+********************************************************************************/
+
+/*******************************************************************************
+**
+** Function btif_dm_start_discovery
+**
+** Description Start device discovery/inquiry
+**
+**
+** Returns bt_status_t
+**
+*******************************************************************************/
+bt_status_t btif_dm_start_discovery(void);
+
+/*******************************************************************************
+**
+** Function btif_dm_cancel_discovery
+**
+** Description Cancels search
+**
+** Returns bt_status_t
+**
+*******************************************************************************/
+bt_status_t btif_dm_cancel_discovery(void);
+
+/*******************************************************************************
+**
+** Function btif_dm_create_bond
+**
+** Description Initiate bonding with the specified device
+**
+** Returns bt_status_t
+**
+*******************************************************************************/
+bt_status_t btif_dm_create_bond(const bt_bdaddr_t *bd_addr);
+
+/*******************************************************************************
+**
+** Function btif_dm_cancel_bond
+**
+** Description Initiate bonding with the specified device
+**
+** Returns bt_status_t
+**
+*******************************************************************************/
+bt_status_t btif_dm_cancel_bond(const bt_bdaddr_t *bd_addr);
+
+/*******************************************************************************
+**
+** Function btif_dm_remove_bond
+**
+** Description Removes bonding with the specified device
+**
+** Returns bt_status_t
+**
+*******************************************************************************/
+bt_status_t btif_dm_remove_bond(const bt_bdaddr_t *bd_addr);
+
+/*******************************************************************************
+**
+** Function btif_dm_pin_reply
+**
+** Description BT legacy pairing - PIN code reply
+**
+** Returns bt_status_t
+**
+*******************************************************************************/
+bt_status_t btif_dm_pin_reply( const bt_bdaddr_t *bd_addr, uint8_t accept,
+ uint8_t pin_len, bt_pin_code_t *pin_code);
+
+/*******************************************************************************
+**
+** Function btif_dm_passkey_reply
+**
+** Description BT SSP passkey reply
+**
+** Returns bt_status_t
+**
+*******************************************************************************/
+bt_status_t btif_dm_passkey_reply( const bt_bdaddr_t *bd_addr,
+ uint8_t accept, uint32_t passkey);
+
+/*******************************************************************************
+**
+** Function btif_dm_ssp_reply
+**
+** Description BT SSP Reply - Just Works, Numeric Comparison & Passkey Entry
+**
+** Returns bt_status_t
+**
+*******************************************************************************/
+bt_status_t btif_dm_ssp_reply( const bt_bdaddr_t *bd_addr,
+ bt_ssp_variant_t variant, uint8_t accept,
+ uint32_t passkey);
+
+/*******************************************************************************
+**
+** Function btif_dm_get_adapter_property
+**
+** Description Queries the BTA for the adapter property
+**
+** Returns bt_status_t
+**
+*******************************************************************************/
+bt_status_t btif_dm_get_adapter_property(bt_property_t *prop);
+
+/*******************************************************************************
+**
+** Function btif_dm_get_remote_services
+**
+** Description Start SDP to get remote services
+**
+** Returns bt_status_t
+**
+*******************************************************************************/
+bt_status_t btif_dm_get_remote_service_record(bt_bdaddr_t *remote_addr,
+ bt_uuid_t *uuid);
+
+
+/*******************************************************************************
+**
+** Function btif_dm_get_remote_services
+**
+** Description Start SDP to get remote services
+**
+** Returns bt_status_t
+**
+*******************************************************************************/
+bt_status_t btif_dm_get_remote_services(bt_bdaddr_t *remote_addr);
+
+/*******************************************************************************
+**
+** Function btif_dut_mode_configure
+**
+** Description Configure Test Mode - 'enable' to 1 puts the device in test mode and 0 exits
+** test mode
+**
+** Returns BT_STATUS_SUCCESS on success
+**
+*******************************************************************************/
+bt_status_t btif_dut_mode_configure(uint8_t enable);
+
+/*******************************************************************************
+**
+** Function btif_dut_mode_send
+**
+** Description Sends a HCI Vendor specific command to the controller
+**
+** Returns BT_STATUS_SUCCESS on success
+**
+*******************************************************************************/
+bt_status_t btif_dut_mode_send(uint16_t opcode, uint8_t *buf, uint8_t len);
+
+#endif /* BTIF_API_H */
diff --git a/btif/include/btif_av.h b/btif/include/btif_av.h
new file mode 100644
index 0000000..c6bd20a
--- /dev/null
+++ b/btif/include/btif_av.h
@@ -0,0 +1,116 @@
+/******************************************************************************
+ *
+ * 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.
+ *
+ ******************************************************************************/
+
+/*******************************************************************************
+ *
+ * Filename: btif_av.h
+ *
+ * Description: Main API header file for all BTIF AV functions accessed
+ * from internal stack.
+ *
+ *******************************************************************************/
+
+#ifndef BTIF_AV_H
+#define BTIF_AV_H
+
+#include "btif_common.h"
+#include "btif_sm.h"
+#include "bta_av_api.h"
+
+
+/*******************************************************************************
+** Type definitions for callback functions
+********************************************************************************/
+
+typedef enum {
+ /* Reuse BTA_AV_XXX_EVT - No need to redefine them here */
+ BTIF_AV_CONNECT_REQ_EVT = BTA_AV_MAX_EVT,
+ BTIF_AV_DISCONNECT_REQ_EVT,
+ BTIF_AV_START_STREAM_REQ_EVT,
+ BTIF_AV_STOP_STREAM_REQ_EVT,
+ BTIF_AV_SUSPEND_STREAM_REQ_EVT,
+ BTIF_AV_RECONFIGURE_REQ_EVT,
+} btif_av_sm_event_t;
+
+
+/*******************************************************************************
+** BTIF AV API
+********************************************************************************/
+
+/*******************************************************************************
+**
+** Function btif_av_get_sm_handle
+**
+** Description Fetches current av SM handle
+**
+** Returns None
+**
+*******************************************************************************/
+
+btif_sm_handle_t btif_av_get_sm_handle(void);
+
+/*******************************************************************************
+**
+** Function btif_av_stream_ready
+**
+** Description Checks whether AV is ready for starting a stream
+**
+** Returns None
+**
+*******************************************************************************/
+
+BOOLEAN btif_av_stream_ready(void);
+
+/*******************************************************************************
+**
+** Function btif_av_stream_started_ready
+**
+** Description Checks whether AV ready for media start in streaming state
+**
+** Returns None
+**
+*******************************************************************************/
+
+BOOLEAN btif_av_stream_started_ready(void);
+
+/*******************************************************************************
+**
+** Function btif_dispatch_sm_event
+**
+** Description Send event to AV statemachine
+**
+** Returns None
+**
+*******************************************************************************/
+
+/* used to pass events to AV statemachine from other tasks */
+void btif_dispatch_sm_event(btif_av_sm_event_t event, void *p_data, int len);
+
+/*******************************************************************************
+**
+** Function btif_av_init
+**
+** Description Initializes btif AV if not already done
+**
+** Returns bt_status_t
+**
+*******************************************************************************/
+
+bt_status_t btif_av_init(void);
+
+#endif /* BTIF_AV_H */
diff --git a/btif/include/btif_av_api.h b/btif/include/btif_av_api.h
new file mode 100644
index 0000000..86cd40b
--- /dev/null
+++ b/btif/include/btif_av_api.h
@@ -0,0 +1,210 @@
+/******************************************************************************
+ *
+ * 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.
+ *
+ ******************************************************************************/
+
+/*****************************************************************************
+ **
+ ** Name: btif_av_api.h
+ **
+ ** Description: This is the public interface file for the advanced
+ ** audio/video streaming (AV) subsystem of BTIF, Broadcom's
+ ** Bluetooth application layer for mobile phones.
+ **
+ *****************************************************************************/
+
+#ifndef BTIF_AV_API_H
+#define BTIF_AV_API_H
+
+#include "bt_target.h"
+#include "bta_av_api.h"
+#include "uipc.h"
+
+#include "btif_media.h"
+#include "a2d_api.h"
+#include "a2d_sbc.h"
+
+
+/*****************************************************************************
+ ** Constants and data types
+ *****************************************************************************/
+
+/* Codec type */
+#define BTIF_AV_CODEC_NONE 0xFF
+#define BTIF_AV_CODEC_SBC A2D_MEDIA_CT_SBC /* SBC media codec type */
+
+#define BTIF_AV_CODEC_PCM 0x5 /* Raw PCM */
+
+typedef UINT8 tBTIF_AV_CODEC_ID;
+
+/* AV features masks */
+#define BTIF_AV_FEAT_RCTG BTA_AV_FEAT_RCTG /* remote control target */
+#define BTIF_AV_FEAT_RCCT BTA_AV_FEAT_RCCT /* remote control controller */
+#define BTIF_AV_FEAT_METADATA BTA_AV_FEAT_METADATA /* remote control Metadata Transfer command/response */
+
+typedef UINT16 tBTIF_AV_FEAT;
+
+/* AV channel values */
+#define BTIF_AV_CHNL_MSK BTA_AV_CHNL_MSK
+#define BTIF_AV_CHNL_AUDIO BTA_AV_CHNL_AUDIO /* audio channel */
+#define BTIF_AV_CHNL_VIDEO BTA_AV_CHNL_VIDEO /* video channel */
+typedef UINT8 tBTIF_AV_CHNL;
+
+typedef UINT8 tBTIF_AV_HNDL;
+
+/* Operation id list for BTIF_AvRemoteCmd */
+#define BTIF_AV_ID_SELECT 0x00 /* select */
+#define BTIF_AV_ID_UP 0x01 /* up */
+#define BTIF_AV_ID_DOWN 0x02 /* down */
+#define BTIF_AV_ID_LEFT 0x03 /* left */
+#define BTIF_AV_ID_RIGHT 0x04 /* right */
+#define BTIF_AV_ID_RIGHT_UP 0x05 /* right-up */
+#define BTIF_AV_ID_RIGHT_DOWN 0x06 /* right-down */
+#define BTIF_AV_ID_LEFT_UP 0x07 /* left-up */
+#define BTIF_AV_ID_LEFT_DOWN 0x08 /* left-down */
+#define BTIF_AV_ID_ROOT_MENU 0x09 /* root menu */
+#define BTIF_AV_ID_SETUP_MENU 0x0A /* setup menu */
+#define BTIF_AV_ID_CONT_MENU 0x0B /* contents menu */
+#define BTIF_AV_ID_FAV_MENU 0x0C /* favorite menu */
+#define BTIF_AV_ID_EXIT 0x0D /* exit */
+#define BTIF_AV_ID_0 0x20 /* 0 */
+#define BTIF_AV_ID_1 0x21 /* 1 */
+#define BTIF_AV_ID_2 0x22 /* 2 */
+#define BTIF_AV_ID_3 0x23 /* 3 */
+#define BTIF_AV_ID_4 0x24 /* 4 */
+#define BTIF_AV_ID_5 0x25 /* 5 */
+#define BTIF_AV_ID_6 0x26 /* 6 */
+#define BTIF_AV_ID_7 0x27 /* 7 */
+#define BTIF_AV_ID_8 0x28 /* 8 */
+#define BTIF_AV_ID_9 0x29 /* 9 */
+#define BTIF_AV_ID_DOT 0x2A /* dot */
+#define BTIF_AV_ID_ENTER 0x2B /* enter */
+#define BTIF_AV_ID_CLEAR 0x2C /* clear */
+#define BTIF_AV_ID_CHAN_UP 0x30 /* channel up */
+#define BTIF_AV_ID_CHAN_DOWN 0x31 /* channel down */
+#define BTIF_AV_ID_PREV_CHAN 0x32 /* previous channel */
+#define BTIF_AV_ID_SOUND_SEL 0x33 /* sound select */
+#define BTIF_AV_ID_INPUT_SEL 0x34 /* input select */
+#define BTIF_AV_ID_DISP_INFO 0x35 /* display information */
+#define BTIF_AV_ID_HELP 0x36 /* help */
+#define BTIF_AV_ID_PAGE_UP 0x37 /* page up */
+#define BTIF_AV_ID_PAGE_DOWN 0x38 /* page down */
+#define BTIF_AV_ID_POWER 0x40 /* power */
+#define BTIF_AV_ID_VOL_UP 0x41 /* volume up */
+#define BTIF_AV_ID_VOL_DOWN 0x42 /* volume down */
+#define BTIF_AV_ID_MUTE 0x43 /* mute */
+#define BTIF_AV_ID_PLAY 0x44 /* play */
+#define BTIF_AV_ID_STOP 0x45 /* stop */
+#define BTIF_AV_ID_PAUSE 0x46 /* pause */
+#define BTIF_AV_ID_RECORD 0x47 /* record */
+#define BTIF_AV_ID_REWIND 0x48 /* rewind */
+#define BTIF_AV_ID_FAST_FOR 0x49 /* fast forward */
+#define BTIF_AV_ID_EJECT 0x4A /* eject */
+#define BTIF_AV_ID_FORWARD 0x4B /* forward */
+#define BTIF_AV_ID_BACKWARD 0x4C /* backward */
+#define BTIF_AV_ID_ANGLE 0x50 /* angle */
+#define BTIF_AV_ID_SUBPICT 0x51 /* subpicture */
+#define BTIF_AV_ID_F1 0x71 /* F1 */
+#define BTIF_AV_ID_F2 0x72 /* F2 */
+#define BTIF_AV_ID_F3 0x73 /* F3 */
+#define BTIF_AV_ID_F4 0x74 /* F4 */
+#define BTIF_AV_ID_F5 0x75 /* F5 */
+#define BTIF_AV_ID_VENDOR 0x7E /* vendor unique */
+#define BTIF_AV_KEYPRESSED_RELEASE 0x80
+
+typedef UINT8 tBTIF_AV_RC;
+
+/* State flag for pass through command */
+#define BTIF_AV_STATE_PRESS 0 /* key pressed */
+#define BTIF_AV_STATE_RELEASE 1 /* key released */
+
+typedef UINT8 tBTIF_AV_STATE;
+
+typedef UINT8 tBTIF_AV_RC_HNDL;
+
+/* Command codes for BTIF_AvVendorCmd */
+#define BTIF_AV_CMD_CTRL 0
+#define BTIF_AV_CMD_STATUS 1
+#define BTIF_AV_CMD_SPEC_INQ 2
+#define BTIF_AV_CMD_NOTIF 3
+#define BTIF_AV_CMD_GEN_INQ 4
+
+typedef UINT8 tBTIF_AV_CMD;
+
+/* AV callback events */
+#define BTIF_AV_OPEN_EVT 0 /* connection opened */
+#define BTIF_AV_CLOSE_EVT 1 /* connection closed */
+#define BTIF_AV_START_EVT 2 /* stream data transfer started */
+#define BTIF_AV_STOP_EVT 3 /* stream data transfer stopped */
+#define BTIF_AV_RC_OPEN_EVT 4 /* remote control channel open */
+#define BTIF_AV_RC_CLOSE_EVT 5 /* remote control channel closed */
+#define BTIF_AV_REMOTE_CMD_EVT 6 /* remote control command */
+#define BTIF_AV_REMOTE_RSP_EVT 7 /* remote control response */
+#define BTIF_AV_META_MSG_EVT 8 /* metadata messages */
+
+typedef UINT8 tBTIF_AV_EVT;
+
+#define BTIF_AV_FEEDING_ASYNCHRONOUS 0 /* asynchronous feeding, use tx av timer */
+#define BTIF_AV_FEEDING_SYNCHRONOUS 1 /* synchronous feeding, no av tx timer */
+
+#define BTIF_AV_MAX_SYNCHRONOUS_LATENCY 80 /* max latency in ms for BTIF_AV_FEEDING_SYNCHRONOUS */
+#define BTIF_AV_MIN_SYNCHRONOUS_LATENCY 4 /* min latency in ms for BTIF_AV_FEEDING_SYNCHRONOUS */
+
+typedef UINT8 tBTIF_AV_FEEDING_MODE;
+
+#define BTIF_AV_CHANNEL_MODE_MONO A2D_SBC_IE_CH_MD_MONO
+#define BTIF_AV_CHANNEL_MODE_STEREO A2D_SBC_IE_CH_MD_STEREO
+#define BTIF_AV_CHANNEL_MODE_JOINT A2D_SBC_IE_CH_MD_JOINT
+#define BTIF_AV_CHANNEL_MODE_DUAL A2D_SBC_IE_CH_MD_DUAL
+
+typedef UINT8 tBTIF_AV_CHANNEL_MODE;
+
+/**
+ * Structure used to configure the AV codec capabilities/config
+ */
+typedef struct
+{
+ tBTIF_AV_CODEC_ID id; /* Codec ID (in terms of BTIF) */
+ UINT8 info[AVDT_CODEC_SIZE]; /* Codec info (can be config or capabilities) */
+} tBTIF_AV_CODEC_INFO;
+
+/**
+ * Structure used to configure the AV media feeding
+ */
+typedef struct
+{
+ UINT16 sampling_freq; /* 44100, 48000 etc */
+ UINT16 num_channel; /* 1 for mono or 2 stereo */
+ UINT8 bit_per_sample; /* Number of bits per sample (8, 16) */
+} tBTIF_AV_MEDIA_FEED_CFG_PCM;
+
+typedef union
+{
+ tBTIF_AV_MEDIA_FEED_CFG_PCM pcm; /* Raw PCM feeding format */
+}tBTIF_AV_MEDIA_FEED_CFG;
+
+typedef struct
+{
+ tBTIF_AV_CODEC_ID format; /* Media codec identifier */
+ tBTIF_AV_MEDIA_FEED_CFG cfg; /* Media codec configuration */
+} tBTIF_AV_MEDIA_FEEDINGS;
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* BTIF_AV_API_H */
diff --git a/btif/include/btif_av_co.h b/btif/include/btif_av_co.h
new file mode 100644
index 0000000..20e9a1e
--- /dev/null
+++ b/btif/include/btif_av_co.h
@@ -0,0 +1,173 @@
+/******************************************************************************
+ *
+ * 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 BTIF_AV_CO_H
+#define BTIF_AV_CO_H
+
+#include "btif_media.h"
+
+/*******************************************************************************
+** Constants & Macros
+********************************************************************************/
+
+enum
+{
+ BTIF_SV_AV_AA_SBC_INDEX = 0,
+ BTIF_SV_AV_AA_SEP_INDEX /* Last index */
+};
+
+
+/*******************************************************************************
+** Functions
+********************************************************************************/
+
+/*******************************************************************************
+ **
+ ** Function bta_av_co_cp_is_active
+ **
+ ** Description Get the current configuration of content protection
+ **
+ ** Returns TRUE if the current streaming has CP, FALSE otherwise
+ **
+ *******************************************************************************/
+BOOLEAN bta_av_co_cp_is_active(void);
+
+/*******************************************************************************
+ **
+ ** Function bta_av_co_cp_get_flag
+ **
+ ** Description Get content protection flag
+ ** BTA_AV_CP_SCMS_COPY_NEVER
+ ** BTA_AV_CP_SCMS_COPY_ONCE
+ ** BTA_AV_CP_SCMS_COPY_FREE
+ **
+ ** Returns The current flag value
+ **
+ *******************************************************************************/
+UINT8 bta_av_co_cp_get_flag(void);
+
+/*******************************************************************************
+ **
+ ** Function bta_av_co_cp_set_flag
+ **
+ ** Description Set content protection flag
+ ** BTA_AV_CP_SCMS_COPY_NEVER
+ ** BTA_AV_CP_SCMS_COPY_ONCE
+ ** BTA_AV_CP_SCMS_COPY_FREE
+ **
+ ** Returns TRUE if setting the SCMS flag is supported else FALSE
+ **
+ *******************************************************************************/
+BOOLEAN bta_av_co_cp_set_flag(UINT8 cp_flag);
+
+/*******************************************************************************
+ **
+ ** Function bta_av_co_audio_codec_reset
+ **
+ ** Description Reset the current codec configuration
+ **
+ ** Returns void
+ **
+ *******************************************************************************/
+void bta_av_co_audio_codec_reset(void);
+
+/*******************************************************************************
+ **
+ ** Function bta_av_co_audio_codec_supported
+ **
+ ** Description Check if all opened connections are compatible with a codec
+ ** configuration
+ **
+ ** Returns TRUE if all opened devices support this codec, FALSE otherwise
+ **
+ *******************************************************************************/
+BOOLEAN bta_av_co_audio_codec_supported(tBTIF_STATUS *p_status);
+
+/*******************************************************************************
+ **
+ ** Function bta_av_co_audio_set_codec
+ **
+ ** Description Set the current codec configuration from the feeding type.
+ ** This function is starting to modify the configuration, it
+ ** should be protected.
+ **
+ ** Returns TRUE if successful, FALSE otherwise
+ **
+ *******************************************************************************/
+BOOLEAN bta_av_co_audio_set_codec(const tBTIF_AV_MEDIA_FEEDINGS *p_feeding, tBTIF_STATUS *p_status);
+
+/*******************************************************************************
+ **
+ ** Function bta_av_co_audio_get_sbc_config
+ **
+ ** Description Retrieves the SBC codec configuration. If the codec in use
+ ** is not SBC, return the default SBC codec configuration.
+ **
+ ** Returns TRUE if codec is SBC, FALSE otherwise
+ **
+ *******************************************************************************/
+BOOLEAN bta_av_co_audio_get_sbc_config(tA2D_SBC_CIE *p_sbc_config, UINT16 *p_minmtu);
+
+/*******************************************************************************
+ **
+ ** Function bta_av_co_audio_discard_config
+ **
+ ** Description Discard the codec configuration of a connection
+ **
+ ** Returns Nothing
+ **
+ *******************************************************************************/
+void bta_av_co_audio_discard_config(tBTA_AV_HNDL hndl);
+
+/*******************************************************************************
+ **
+ ** Function bta_av_co_init
+ **
+ ** Description Initialization
+ **
+ ** Returns Nothing
+ **
+ *******************************************************************************/
+void bta_av_co_init(void);
+
+
+/*******************************************************************************
+ **
+ ** Function bta_av_co_peer_cp_supported
+ **
+ ** Description Checks if the peer supports CP
+ **
+ ** Returns TRUE if the peer supports CP
+ **
+ *******************************************************************************/
+BOOLEAN bta_av_co_peer_cp_supported(tBTA_AV_HNDL hndl);
+
+/*******************************************************************************
+ **
+ ** Function bta_av_co_get_remote_bitpool_pref
+ **
+ ** Description Check if remote side did a setconfig within the limits
+ ** of our exported bitpool range. If set we will set the
+ ** remote preference.
+ **
+ ** Returns TRUE if config set, FALSE otherwize
+ **
+ *******************************************************************************/
+BOOLEAN bta_av_co_get_remote_bitpool_pref(UINT8 *min, UINT8 *max);
+
+#endif
diff --git a/btif/include/btif_common.h b/btif/include/btif_common.h
new file mode 100644
index 0000000..7f3b039
--- /dev/null
+++ b/btif/include/btif_common.h
@@ -0,0 +1,183 @@
+/******************************************************************************
+ *
+ * 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 BTIF_COMMON_H
+#define BTIF_COMMON_H
+
+#include "data_types.h"
+#include "bt_types.h"
+#include "bta_api.h"
+
+#ifndef LOG_TAG
+#error "LOG_TAG not defined, please add in .c file prior to including bt_common.h"
+#endif
+
+#include <utils/Log.h>
+
+/*******************************************************************************
+** Constants & Macros
+********************************************************************************/
+
+#define ASSERTC(cond, msg, val) if (!(cond)) { ALOGE( \
+ "### ASSERT : %s line %d %s (%d) ###", __FILE__, __LINE__, msg, val);}
+
+/* Calculate start of event enumeration; id is top 8 bits of event */
+#define BTIF_SIG_START(id) ((id) << 8)
+
+/* For upstream the MSB bit is always SET */
+#define BTIF_SIG_CB_BIT (0x8000)
+#define BTIF_SIG_CB_START(id) (((id) << 8) | BTIF_SIG_CB_BIT)
+
+/* BTIF sub-systems */
+#define BTIF_CORE 0
+#define BTIF_DM 1
+#define BTIF_HFP 2
+#define BTIF_AV 3
+#define BTIF_PAN 4
+
+extern bt_callbacks_t *bt_hal_cbacks;
+
+#define HAL_CBACK(P_CB, P_CBACK, ...)\
+ if (P_CB && P_CB->P_CBACK) { \
+ ALOGD("HAL %s->%s", #P_CB, #P_CBACK); \
+ P_CB->P_CBACK(__VA_ARGS__); \
+ } \
+ else { \
+ ASSERTC(0, "Callback is NULL", 0); \
+ }
+
+/**
+ * BTIF events for requests that require context switch to btif task
+ * on downstreams path
+ */
+enum
+{
+ BTIF_CORE_API_START = BTIF_SIG_START(BTIF_CORE),
+ BTIF_CORE_STORAGE_NO_ACTION,
+ BTIF_CORE_STORAGE_ADAPTER_WRITE,
+ BTIF_CORE_STORAGE_ADAPTER_READ,
+ BTIF_CORE_STORAGE_ADAPTER_READ_ALL,
+ BTIF_CORE_STORAGE_REMOTE_WRITE,
+ BTIF_CORE_STORAGE_REMOTE_READ,
+ BTIF_CORE_STORAGE_REMOTE_READ_ALL,
+ BTIF_CORE_STORAGE_READ_ALL,
+ BTIF_CORE_STORAGE_NOTIFY_STATUS,
+ /* add here */
+
+ BTIF_DM_API_START = BTIF_SIG_START(BTIF_DM),
+ BTIF_DM_ENABLE_SERVICE,
+ BTIF_DM_DISABLE_SERVICE,
+ /* add here */
+
+ BTIF_HFP_API_START = BTIF_SIG_START(BTIF_HFP),
+ /* add here */
+
+ BTIF_AV_API_START = BTIF_SIG_START(BTIF_AV),
+ /* add here */
+};
+
+/**
+ * BTIF events for callbacks that require context switch to btif task
+ * on upstream path - Typically these would be non-BTA events
+ * that are generated by the BTIF layer.
+ */
+enum
+{
+ BTIF_CORE_CB_START = BTIF_SIG_CB_START(BTIF_CORE),
+ /* add here */
+
+ BTIF_DM_CB_START = BTIF_SIG_CB_START(BTIF_DM),
+ BTIF_DM_CB_DISCOVERY_STARTED, /* Discovery has started */
+ BTIF_DM_CB_CREATE_BOND, /* Create bond */
+ BTIF_DM_CB_REMOVE_BOND, /*Remove bond */
+ BTIF_DM_CB_HID_REMOTE_NAME, /* Remote name callback for HID device */
+ BTIF_DM_CB_BOND_STATE_BONDING,
+
+ BTIF_HFP_CB_START = BTIF_SIG_CB_START(BTIF_HFP),
+ BTIF_HFP_CB_AUDIO_CONNECTING, /* HF AUDIO connect has been sent to BTA successfully */
+
+ BTIF_PAN_CB_START = BTIF_SIG_CB_START(BTIF_PAN),
+ BTIF_PAN_CB_DISCONNECTING, /* PAN Disconnect has been sent to BTA successfully */
+};
+
+/* Macro definitions for BD ADDR persistence */
+
+/**
+ * PROPERTY_BT_BDADDR_PATH
+ * The property key stores the storage location of Bluetooth Device Address
+ */
+#ifndef PROPERTY_BT_BDADDR_PATH
+#define PROPERTY_BT_BDADDR_PATH "ro.bt.bdaddr_path"
+#endif
+
+/**
+ * PERSIST_BDADDR_PROPERTY
+ * If there is no valid bdaddr available from PROPERTY_BT_BDADDR_PATH,
+ * generating a random BDADDR and keeping it in the PERSIST_BDADDR_DROP.
+ */
+#ifndef PERSIST_BDADDR_PROPERTY
+#define PERSIST_BDADDR_PROPERTY "persist.service.bdroid.bdaddr"
+#endif
+
+#define FACTORY_BT_BDADDR_STORAGE_LEN 17
+
+
+/*******************************************************************************
+** Type definitions for callback functions
+********************************************************************************/
+
+typedef void (tBTIF_CBACK) (UINT16 event, char *p_param);
+typedef void (tBTIF_COPY_CBACK) (UINT16 event, char *p_dest, char *p_src);
+
+
+/*******************************************************************************
+** Type definitions and return values
+********************************************************************************/
+
+/* this type handles all btif context switches between BTU and HAL */
+typedef struct
+{
+ BT_HDR hdr;
+ tBTIF_CBACK* p_cb; /* context switch callback */
+
+ /* parameters passed to callback */
+ UINT16 event; /* message event id */
+ char p_param[0]; /* parameter area needs to be last */
+} tBTIF_CONTEXT_SWITCH_CBACK;
+
+
+/*******************************************************************************
+** Functions
+********************************************************************************/
+
+bt_status_t btif_transfer_context (tBTIF_CBACK *p_cback, UINT16 event, char* p_params,
+ int param_len, tBTIF_COPY_CBACK *p_copy_cback);
+tBTA_SERVICE_MASK btif_get_enabled_services_mask(void);
+bt_status_t btif_enable_service(tBTA_SERVICE_ID service_id);
+bt_status_t btif_disable_service(tBTA_SERVICE_ID service_id);
+int btif_is_enabled(void);
+
+/**
+ * BTIF_Events
+ */
+void btif_enable_bluetooth_evt(tBTA_STATUS status, BD_ADDR local_bd);
+void btif_disable_bluetooth_evt(void);
+void btif_adapter_properties_evt(bt_status_t status, uint32_t num_props, bt_property_t *p_props);
+void btif_remote_properties_evt(bt_status_t status, bt_bdaddr_t *remote_addr,
+ uint32_t num_props, bt_property_t *p_props);
+#endif /* BTIF_COMMON_H */
diff --git a/btif/include/btif_config.h b/btif/include/btif_config.h
new file mode 100644
index 0000000..8fc9eb2
--- /dev/null
+++ b/btif/include/btif_config.h
@@ -0,0 +1,77 @@
+/******************************************************************************
+ *
+ * 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.
+ *
+ ******************************************************************************/
+
+/*******************************************************************************
+ *
+ * Filename: btif_config.h
+ *
+ * Description: Bluetooth configuration Interface
+ *
+ *******************************************************************************/
+
+#ifndef BTIF_CONFIG_H
+#define BTIF_CONFIG_H
+
+#ifdef __cplusplus
+#include <stdint.h>
+extern "C" {
+#endif
+
+/*******************************************************************************
+** Constants & Macros
+********************************************************************************/
+
+#define BTIF_CFG_TYPE_INVALID 0
+#define BTIF_CFG_TYPE_STR 1
+#define BTIF_CFG_TYPE_INT (1 << 1)
+#define BTIF_CFG_TYPE_BIN (1 << 2)
+#define BTIF_CFG_TYPE_VOLATILE (1 << 15)
+
+
+/*******************************************************************************
+** Functions
+********************************************************************************/
+
+int btif_config_init();
+
+int btif_config_exist(const char* section, const char* key, const char* name);
+int btif_config_get_int(const char* section, const char* key, const char* name, int* value);
+int btif_config_set_int(const char* section, const char* key, const char* name, int value);
+int btif_config_get_str(const char* section, const char* key, const char* name, char* value, int* bytes);
+int btif_config_set_str(const char* section, const char* key, const char* name, const char* value);
+
+int btif_config_get(const char* section, const char* key, const char* name, char* value, int* bytes, int* type);
+int btif_config_set(const char* section, const char* key, const char* name, const char* value, int bytes, int type);
+
+int btif_config_remove(const char* section, const char* key, const char* name);
+
+short btif_config_next_key(short current_key_pos, const char* section, char * key_name, int* key_name_bytes);
+short btif_config_next_value(short pos, const char* section, const char* key, char* value_name, int* value_name_bytes);
+
+typedef void (*btif_config_enum_callback)(void* user_data, const char* section, const char* key, const char* name,
+ const char* value, int bytes, int type);
+int btif_config_enum(btif_config_enum_callback cb, void* user_data);
+
+int btif_config_save();
+void btif_config_flush();
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/btif/include/btif_config_util.h b/btif/include/btif_config_util.h
new file mode 100644
index 0000000..3a2f53e
--- /dev/null
+++ b/btif/include/btif_config_util.h
@@ -0,0 +1,62 @@
+/******************************************************************************
+ *
+ * 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.
+ *
+ ******************************************************************************/
+
+/************************************************************************************
+ *
+ * Filename: btif_config_util.h
+ *
+ * Description: Bluetooth configuration utility api
+ *
+ ***********************************************************************************/
+
+#ifndef BTIF_CONFIG_UTIL_H
+#define BTIF_CONFIG_UTIL_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*******************************************************************************
+** Constants & Macros
+********************************************************************************/
+
+#define BLUEZ_PATH "/data/misc/bluetoothd/"
+#define BLUEZ_PATH_BAK "/data/misc/bluetoothd_bak"
+#define BLUEZ_LINKKEY "linkkeys"
+#define BLUEZ_NAMES "names"
+#define BLUEZ_PROFILES "profiles"
+#define BLUEZ_CLASSES "classes"
+#define BLUEZ_TYPES "types"
+#define BLUEZ_CONFIG "config"
+#define BLUEZ_ALIASES "aliases"
+
+
+/*******************************************************************************
+** Functions
+********************************************************************************/
+
+int btif_config_save_file(const char* file_name);
+int btif_config_load_file(const char* file_name);
+int load_bluez_adapter_info(char* adapter_path, int size);
+int load_bluez_linkkeys(const char* adapter_path);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/btif/include/btif_dm.h b/btif/include/btif_dm.h
new file mode 100644
index 0000000..2d73c45
--- /dev/null
+++ b/btif/include/btif_dm.h
@@ -0,0 +1,49 @@
+/******************************************************************************
+ *
+ * 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 BTIF_DM_H
+#define BTIF_DM_H
+
+/*******************************************************************************
+** Functions
+********************************************************************************/
+
+/**
+ * BTIF callback to switch context from bte to btif
+ */
+void bte_dm_evt(tBTA_DM_SEC_EVT event, tBTA_DM_SEC *p_data);
+
+/**
+ * Notify BT disable being initiated. DM may chose to abort
+ * pending commands, like pairing
+ */
+void btif_dm_on_disable(void);
+
+/**
+ * Out-of-band functions
+ */
+#if (BTM_OOB_INCLUDED == TRUE)
+void btif_dm_set_oob_for_io_req(tBTA_OOB_DATA *p_oob_data);
+#ifdef BTIF_DM_OOB_TEST
+void btif_dm_load_local_oob(void);
+void btif_dm_proc_loc_oob(BOOLEAN valid, BT_OCTET16 c, BT_OCTET16 r);
+BOOLEAN btif_dm_proc_rmt_oob(BD_ADDR bd_addr, BT_OCTET16 p_c, BT_OCTET16 p_r);
+#endif /* BTIF_DM_OOB_TEST */
+#endif /* BTM_OOB_INCLUDED */
+
+#endif
diff --git a/btif/include/btif_hh.h b/btif/include/btif_hh.h
new file mode 100644
index 0000000..4f31002
--- /dev/null
+++ b/btif/include/btif_hh.h
@@ -0,0 +1,102 @@
+/******************************************************************************
+ *
+ * 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 BTIF_HH_H
+#define BTIF_HH_H
+
+#include <hardware/bluetooth.h>
+#include <hardware/bt_hh.h>
+#include <stdint.h>
+#include "bta_hh_api.h"
+
+/*******************************************************************************
+** Constants & Macros
+********************************************************************************/
+
+#define BTIF_HH_MAX_HID 8
+#define BTIF_HH_MAX_ADDED_DEV 32
+
+#define BTIF_HH_MAX_KEYSTATES 3
+#define BTIF_HH_KEYSTATE_MASK_NUMLOCK 0x01
+#define BTIF_HH_KEYSTATE_MASK_CAPSLOCK 0x02
+#define BTIF_HH_KEYSTATE_MASK_SCROLLLOCK 0x04
+
+
+/*******************************************************************************
+** Type definitions and return values
+********************************************************************************/
+
+typedef enum
+{
+ BTIF_HH_DISABLED = 0,
+ BTIF_HH_ENABLED,
+ BTIF_HH_DISABLING,
+ BTIF_HH_DEV_UNKNOWN,
+ BTIF_HH_DEV_CONNECTING,
+ BTIF_HH_DEV_CONNECTED,
+ BTIF_HH_DEV_DISCONNECTED
+} BTIF_HH_STATUS;
+
+typedef struct
+{
+ bthh_connection_state_t dev_status;
+ UINT8 dev_handle;
+ bt_bdaddr_t bd_addr;
+ tBTA_HH_ATTR_MASK attr_mask;
+ UINT8 sub_class;
+ UINT8 app_id;
+ int fd;
+ BT_HDR *p_buf;
+} btif_hh_device_t;
+
+/* Control block to maintain properties of devices */
+typedef struct
+{
+ UINT8 dev_handle;
+ bt_bdaddr_t bd_addr;
+ tBTA_HH_ATTR_MASK attr_mask;
+} btif_hh_added_device_t;
+
+/**
+ * BTIF-HH control block to maintain added devices and currently
+ * connected hid devices
+ */
+typedef struct
+{
+ BTIF_HH_STATUS status;
+ btif_hh_device_t devices[BTIF_HH_MAX_HID];
+ UINT32 device_num;
+ btif_hh_added_device_t added_devices[BTIF_HH_MAX_ADDED_DEV];
+ btif_hh_device_t *p_curr_dev;
+} btif_hh_cb_t;
+
+
+/*******************************************************************************
+** Functions
+********************************************************************************/
+
+extern btif_hh_cb_t btif_hh_cb;
+
+extern btif_hh_device_t *btif_hh_find_connected_dev_by_handle(UINT8 handle);
+extern void btif_hh_remove_device(bt_bdaddr_t bd_addr);
+extern bt_status_t btif_hh_virtual_unplug(bt_bdaddr_t *bd_addr);
+extern void btif_hh_disconnect(bt_bdaddr_t *bd_addr);
+
+BOOLEAN btif_hh_add_added_dev(bt_bdaddr_t bd_addr, tBTA_HH_ATTR_MASK attr_mask);
+
+#endif
diff --git a/btif/include/btif_hl.h b/btif/include/btif_hl.h
new file mode 100644
index 0000000..0573082
--- /dev/null
+++ b/btif/include/btif_hl.h
@@ -0,0 +1,366 @@
+/******************************************************************************
+ *
+ * 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 BTIF_HL_H
+#define BTIF_HL_H
+
+/*******************************************************************************
+** Constants & Macros
+********************************************************************************/
+
+#define BTIF_HL_DATA_TYPE_NONE 0x0000
+#define BTIF_HL_DATA_TYPE_PULSE_OXIMETER 0x1004 /* from BT assigned number */
+#define BTIF_HL_DATA_TYPE_BLOOD_PRESSURE_MON 0x1007
+#define BTIF_HL_DATA_TYPE_BODY_THERMOMETER 0x1008
+#define BTIF_HL_DATA_TYPE_BODY_WEIGHT_SCALE 0x100F
+#define BTIF_HL_DATA_TYPE_GLUCOSE_METER 0x1011
+#define BTIF_HL_DATA_TYPE_STEP_COUNTER 0x1068
+
+#define BTIF_HL_CCH_NUM_FILTER_ELEMS 3
+#define BTIF_HL_APPLICATION_NAME_LEN 512
+
+#define BTIF_HL_NV_MAX_APPS 16
+
+
+/*******************************************************************************
+** Type definitions and return values
+********************************************************************************/
+
+typedef enum
+{
+ BTIF_HL_SOC_STATE_IDLE,
+ BTIF_HL_SOC_STATE_W4_ADD,
+ BTIF_HL_SOC_STATE_W4_CONN,
+ BTIF_HL_SOC_STATE_W4_READ,
+ BTIF_HL_SOC_STATE_W4_REL
+} btif_hl_soc_state_t;
+
+typedef enum
+{
+ BTIF_HL_STATE_DISABLED,
+ BTIF_HL_STATE_DISABLING,
+ BTIF_HL_STATE_ENABLED,
+ BTIF_HL_STATE_ENABLING,
+} btif_hl_state_t;
+
+typedef enum
+{
+ BTIF_HL_CCH_OP_NONE,
+ BTIF_HL_CCH_OP_MDEP_FILTERING,
+ BTIF_HL_CCH_OP_MATCHED_CTRL_PSM,
+ BTIF_HL_CCH_OP_DCH_OPEN,
+ BTIF_HL_CCH_OP_DCH_RECONNECT,
+ BTIF_HL_CCH_OP_DCH_ECHO_TEST
+} btif_hl_cch_op_t;
+
+typedef enum
+{
+ BTIF_HL_PEND_DCH_OP_NONE,
+ BTIF_HL_PEND_DCH_OP_DELETE_MDL,
+ BTIF_HL_PEND_DCH_OP_OPEN,
+ BTIF_HL_PEND_DCH_OP_RECONNECT
+} btif_hl_pend_dch_op_t;
+
+typedef enum
+{
+ BTIF_HL_DCH_OP_NONE,
+ BTIF_HL_DCH_OP_DISC
+} btif_hl_dch_op_t;
+
+typedef enum
+{
+ BTIF_HL_CHAN_CB_STATE_NONE,
+ BTIF_HL_CHAN_CB_STATE_CONNECTING_PENDING,
+ BTIF_HL_CHAN_CB_STATE_CONNECTED_PENDING,
+
+ BTIF_HL_CHAN_CB_STATE_DISCONNECTING_PENDING,
+ BTIF_HL_CHAN_CB_STATE_DISCONNECTED_PENDING,
+ BTIF_HL_CHAN_CB_STATE_DESTROYED_PENDING,
+} btif_hl_chan_cb_state_t;
+
+enum
+{
+ BTIF_HL_SEND_CONNECTED_CB,
+ BTIF_HL_SEND_DISCONNECTED_CB,
+ BTIF_HL_REG_APP,
+ BTIF_HL_UNREG_APP,
+ BTIF_HL_UPDATE_MDL,
+};
+
+typedef struct
+{
+ UINT8 mdep_cfg_idx;
+ int data_type;
+ tBTA_HL_MDEP_ID peer_mdep_id;
+} btif_hl_extra_mdl_cfg_t;
+
+typedef struct
+{
+ tBTA_HL_MDL_CFG base;
+ btif_hl_extra_mdl_cfg_t extra;
+} btif_hl_mdl_cfg_t;
+
+typedef struct
+{
+ btif_hl_mdl_cfg_t mdl_cfg[BTA_HL_NUM_MDL_CFGS];
+} btif_hl_nv_mdl_data_t;
+
+typedef struct
+{
+ tBTA_HL_SUP_FEATURE sup_feature;
+ tBTA_HL_DCH_CFG channel_type[BTA_HL_NUM_MDEPS];
+ char srv_name[BTA_SERVICE_NAME_LEN +1];
+ char srv_desp[BTA_SERVICE_DESP_LEN +1];
+ char provider_name[BTA_PROVIDER_NAME_LEN +1];
+ char application_name[BTIF_HL_APPLICATION_NAME_LEN +1];
+} btif_hl_nv_app_data_t;
+
+typedef struct
+{
+ BOOLEAN in_use;
+ UINT16 use_freq;
+} btif_hl_nv_app_t;
+
+typedef struct
+{
+ btif_hl_nv_app_t app[BTIF_HL_NV_MAX_APPS];
+} btif_hl_nv_app_cb_t;
+
+typedef struct
+{
+ UINT8 app_nv_idx;
+ BOOLEAN active;
+ UINT8 app_idx;
+ btif_hl_nv_app_data_t app_data;
+} btif_hl_app_data_t;
+
+typedef struct
+{
+ BOOLEAN is_app_read;
+ btif_hl_nv_app_cb_t app_cb;
+ BUFFER_Q app_queue;
+} btif_hl_nv_cb_t;
+
+typedef struct
+{
+ int channel_id;
+ BD_ADDR bd_addr;
+ UINT8 mdep_cfg_idx;
+ int max_s;
+ int socket_id[2];
+ UINT8 app_idx;
+ UINT8 mcl_idx;
+ UINT8 mdl_idx;
+ btif_hl_soc_state_t state;
+}btif_hl_soc_cb_t;
+
+typedef struct
+{
+ UINT16 data_type;
+ UINT16 max_tx_apdu_size;
+ UINT16 max_rx_apdu_size;
+} btif_hl_data_type_cfg_t;
+
+typedef struct
+{
+ UINT16 data_type;
+ tBTA_HL_MDEP_ROLE peer_mdep_role;
+} btif_hl_filter_elem_t;
+
+typedef struct
+{
+ UINT8 num_elems;
+ btif_hl_filter_elem_t elem[BTIF_HL_CCH_NUM_FILTER_ELEMS];
+} btif_hl_cch_filter_t;
+
+typedef struct
+{
+ BOOLEAN in_use;
+ UINT16 mdl_id;
+ tBTA_HL_MDL_HANDLE mdl_handle;
+ btif_hl_dch_op_t dch_oper;
+ tBTA_HL_MDEP_ID local_mdep_id;
+ UINT8 local_mdep_cfg_idx;
+ tBTA_HL_DCH_CFG local_cfg;
+ tBTA_HL_MDEP_ID peer_mdep_id;
+ UINT16 peer_data_type;
+ tBTA_HL_MDEP_ROLE peer_mdep_role;
+ tBTA_HL_DCH_MODE dch_mode;
+ tBTA_SEC sec_mask;
+ BOOLEAN is_the_first_reliable;
+ BOOLEAN delete_mdl;
+ UINT16 mtu;
+ tMCA_CHNL_CFG chnl_cfg;
+ UINT16 tx_size;
+ UINT8 *p_tx_pkt;
+ UINT8 *p_rx_pkt;
+ BOOLEAN cong;
+ btif_hl_soc_cb_t *p_scb;
+ int channel_id;
+} btif_hl_mdl_cb_t;
+
+typedef struct
+{
+ int channel_id;
+ int mdep_cfg_idx;
+ BOOLEAN in_use;
+ btif_hl_chan_cb_state_t cb_state;
+ btif_hl_pend_dch_op_t op;
+ BD_ADDR bd_addr;
+ BOOLEAN abort_pending;
+} btif_hl_pending_chan_cb_t;
+
+typedef struct
+{
+ btif_hl_mdl_cb_t mdl[BTA_HL_NUM_MDLS_PER_MCL];
+ BOOLEAN in_use;
+ BOOLEAN is_connected;
+ UINT16 req_ctrl_psm;
+ UINT16 ctrl_psm;
+ UINT16 data_psm;
+ BD_ADDR bd_addr;
+ UINT16 cch_mtu;
+ tBTA_SEC sec_mask;
+ tBTA_HL_MCL_HANDLE mcl_handle;
+ btif_hl_pending_chan_cb_t pcb;
+ BOOLEAN valid_sdp_idx;
+ UINT8 sdp_idx;
+ tBTA_HL_SDP sdp;
+ btif_hl_cch_op_t cch_oper;
+ BOOLEAN cch_timer_active;
+ TIMER_LIST_ENT cch_timer;
+} btif_hl_mcl_cb_t;
+
+typedef struct
+{
+ BOOLEAN active;
+ UINT16 mdl_id;
+ UINT8 mdep_cfg_idx;
+ BD_ADDR bd_addr;
+ int channel_id;
+} btif_hl_delete_mdl_t;
+
+typedef struct
+{
+ btif_hl_mcl_cb_t mcb[BTA_HL_NUM_MCLS]; /* application Control Blocks */
+ BOOLEAN in_use; /* this CB is in use*/
+ BOOLEAN reg_pending;
+ BOOLEAN is_new_app;
+ UINT8 app_nv_idx;
+ UINT8 app_id;
+
+ tBTA_HL_SUP_FEATURE sup_feature;
+ tBTA_HL_DCH_CFG channel_type[BTA_HL_NUM_MDEPS];
+ tBTA_HL_SDP_INFO_IND sdp_info_ind;
+ btif_hl_cch_filter_t filter;
+
+ btif_hl_mdl_cfg_t mdl_cfg[BTA_HL_NUM_MDL_CFGS];
+ int mdl_cfg_channel_id[BTA_HL_NUM_MDL_CFGS];
+
+ btif_hl_delete_mdl_t delete_mdl;
+ tBTA_HL_DEVICE_TYPE dev_type;
+ tBTA_HL_APP_HANDLE app_handle;
+ UINT16 sec_mask; /* Security mask for BTM_SetSecurityLevel() */
+ char srv_name[BTA_SERVICE_NAME_LEN +1]; /* service name to be used in the SDP; null terminated*/
+ char srv_desp[BTA_SERVICE_DESP_LEN +1]; /* service description to be used in the SDP; null terminated */
+ char provider_name[BTA_PROVIDER_NAME_LEN +1]; /* provide name to be used in the SDP; null terminated */
+ char application_name[BTIF_HL_APPLICATION_NAME_LEN +1]; /* applicaiton name */
+} btif_hl_app_cb_t;
+
+typedef struct
+{
+ BOOLEAN in_use;
+ UINT8 app_idx;
+} btif_hl_pending_reg_cb_t;
+
+/* BTIF-HL control block */
+typedef struct
+{
+ btif_hl_app_cb_t acb[BTA_HL_NUM_APPS]; /* HL Control Blocks */
+ tBTA_HL_CTRL_CBACK *p_ctrl_cback; /* pointer to control callback function */
+ UINT8 next_app_id;
+ UINT16 next_channel_id;
+ btif_hl_state_t state;
+ btif_hl_nv_cb_t ncb;
+} btif_hl_cb_t;
+
+typedef UINT8 btif_hl_evt_t;
+
+typedef struct
+{
+ int app_id;
+ BD_ADDR bd_addr;
+ int mdep_cfg_index;
+ int channel_id;
+ btif_hl_chan_cb_state_t cb_state;
+ int fd;
+} btif_hl_send_chan_state_cb_t;
+
+
+typedef struct
+{
+ UINT8 app_idx;
+} btif_hl_reg_t;
+
+typedef btif_hl_reg_t btif_hl_unreg_t;
+typedef btif_hl_reg_t btif_hl_update_mdl_t;
+
+typedef union
+{
+ btif_hl_send_chan_state_cb_t chan_cb;
+ btif_hl_reg_t reg;
+ btif_hl_unreg_t unreg;
+ btif_hl_update_mdl_t update_mdl;
+} btif_hl_evt_cb_t;
+
+
+/*******************************************************************************
+** Functions
+********************************************************************************/
+
+#define BTIF_HL_GET_CB_PTR() &(btif_hl_cb)
+#define BTIF_HL_GET_APP_CB_PTR(app_idx) &(btif_hl_cb.acb[(app_idx)])
+#define BTIF_HL_GET_MCL_CB_PTR(app_idx, mcl_idx) &(btif_hl_cb.acb[(app_idx)].mcb[(mcl_idx)])
+#define BTIF_HL_GET_MDL_CB_PTR(app_idx, mcl_idx, mdl_idx) &(btif_hl_cb.acb[(app_idx)].mcb[(mcl_idx)].mdl[mdl_idx])
+#define BTIF_HL_GET_PCB_PTR(app_idx, mcl_idx) &(btif_hl_cb.acb[app_idx].mcb[mcl_idx].pcb)
+#define BTIF_HL_GET_MDL_CFG_PTR(app_idx, item_idx) &(btif_hl_cb.acb[(app_idx)].mdl_cfg[(item_idx)])
+#define BTIF_HL_GET_MDL_CFG_CHANNEL_ID_PTR(app_idx, item_idx) &(btif_hl_cb.acb[(app_idx)].mdl_cfg_channel_id[(item_idx)])
+
+extern btif_hl_cb_t btif_hl_cb;
+extern btif_hl_cb_t *p_btif_hl_cb;
+extern btif_hl_nv_cb_t *p_ncb;
+
+extern BOOLEAN btif_hl_find_mcl_idx(UINT8 app_idx, BD_ADDR p_bd_addr, UINT8 *p_mcl_idx);
+extern BOOLEAN btif_hl_find_app_idx(UINT8 app_id, UINT8 *p_app_idx);
+extern BOOLEAN btif_hl_find_avail_mcl_idx(UINT8 app_idx, UINT8 *p_mcl_idx);
+extern BOOLEAN btif_hl_find_avail_mdl_idx(UINT8 app_idx, UINT8 mcl_idx,
+ UINT8 *p_mdl_idx);
+extern BOOLEAN btif_hl_find_mcl_idx_using_handle( tBTA_HL_MCL_HANDLE mcl_handle,
+ UINT8 *p_app_idx, UINT8 *p_mcl_idx);
+extern BOOLEAN btif_hl_save_mdl_cfg(UINT8 app_id, UINT8 item_idx, tBTA_HL_MDL_CFG *p_mdl_cfg);
+extern BOOLEAN btif_hl_delete_mdl_cfg(UINT8 app_id, UINT8 item_idx);
+extern void * btif_hl_get_buf(UINT16 size);
+extern void btif_hl_free_buf(void **p);
+extern BOOLEAN btif_hl_find_mdl_idx_using_handle(tBTA_HL_MDL_HANDLE mdl_handle,
+ UINT8 *p_app_idx,UINT8 *p_mcl_idx,
+ UINT8 *p_mdl_idx);
+extern void btif_hl_abort_pending_chan_setup(UINT8 app_idx, UINT8 mcl_idx);
+extern BOOLEAN btif_hl_proc_pending_op(UINT8 app_idx, UINT8 mcl_idx);
+extern BOOLEAN btif_hl_load_mdl_config (UINT8 app_id, UINT8 buffer_size,
+ tBTA_HL_MDL_CFG *p_mdl_buf );
+#endif
diff --git a/btif/include/btif_media.h b/btif/include/btif_media.h
new file mode 100644
index 0000000..b3b72e7
--- /dev/null
+++ b/btif/include/btif_media.h
@@ -0,0 +1,248 @@
+/******************************************************************************
+ *
+ * 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.
+ *
+ ******************************************************************************/
+
+/*******************************************************************************
+ *
+ * Filename: btif_media.h
+ *
+ * Description: This is the audio module for the BTIF system.
+ *
+ *******************************************************************************/
+
+#ifndef BTIF_MEDIA_H
+#define BTIF_MEDIA_H
+
+#include "bta_api.h"
+#include "bd.h"
+#include "gki.h"
+#include "btif_av_api.h"
+#include "audio_a2dp_hw.h"
+
+/*******************************************************************************
+ ** Constants
+ *******************************************************************************/
+
+/* Generic part */
+#define BTIF_SUCCESS 0
+
+/**
+ * AV (Audio Video source) Errors
+ */
+#define BTIF_ERROR_SRV_AV_NOT_ENABLED 700 /* AV is not enabled */
+#define BTIF_ERROR_SRV_AV_FEEDING_NOT_SUPPORTED 701 /* Requested Feeding not supported */
+#define BTIF_ERROR_SRV_AV_BUSY 702 /* Another operation ongoing */
+#define BTIF_ERROR_SRV_AV_NOT_OPENED 703 /* No AV link opened */
+#define BTIF_ERROR_SRV_AV_NOT_STARTED 704 /* AV is not started */
+#define BTIF_ERROR_SRV_AV_CP_NOT_SUPPORTED 705 /* Content protection is not supported by all headsets */
+
+/* Transcoding definition for TxTranscoding and RxTranscoding */
+#define BTIF_MEDIA_TRSCD_OFF 0
+#define BTIF_MEDIA_TRSCD_PCM_2_SBC 1 /* Tx */
+
+
+/*******************************************************************************
+ ** Data types
+ *******************************************************************************/
+
+typedef int tBTIF_STATUS;
+
+/* tBTIF_MEDIA_INIT_AUDIO msg structure */
+typedef struct
+{
+ BT_HDR hdr;
+ UINT16 SamplingFreq; /* 16k, 32k, 44.1k or 48k*/
+ UINT8 ChannelMode; /* mono, dual, stereo or joint stereo*/
+ UINT8 NumOfSubBands; /* 4 or 8 */
+ UINT8 NumOfBlocks; /* 4, 8, 12 or 16*/
+ UINT8 AllocationMethod; /* loudness or SNR*/
+ UINT16 MtuSize; /* peer mtu size */
+} tBTIF_MEDIA_INIT_AUDIO;
+
+#if (BTA_AV_INCLUDED == TRUE)
+/* tBTIF_MEDIA_UPDATE_AUDIO msg structure */
+typedef struct
+{
+ BT_HDR hdr;
+ UINT16 MinMtuSize; /* Minimum peer mtu size */
+ UINT8 MaxBitPool; /* Maximum peer bitpool */
+ UINT8 MinBitPool; /* Minimum peer bitpool */
+} tBTIF_MEDIA_UPDATE_AUDIO;
+
+/* tBTIF_MEDIA_INIT_AUDIO_FEEDING msg structure */
+typedef struct
+{
+ BT_HDR hdr;
+ tBTIF_AV_FEEDING_MODE feeding_mode;
+ tBTIF_AV_MEDIA_FEEDINGS feeding;
+} tBTIF_MEDIA_INIT_AUDIO_FEEDING;
+#endif
+
+
+/*******************************************************************************
+ ** Public functions
+ *******************************************************************************/
+
+/*******************************************************************************
+ **
+ ** Function btif_av_task
+ **
+ ** Description
+ **
+ ** Returns void
+ **
+ *******************************************************************************/
+extern int btif_media_task(void *p);
+
+/*******************************************************************************
+ **
+ ** Function btif_media_task_enc_init_req
+ **
+ ** Description Request to initialize the media task encoder
+ **
+ ** Returns TRUE is success
+ **
+ *******************************************************************************/
+extern BOOLEAN btif_media_task_enc_init_req(tBTIF_MEDIA_INIT_AUDIO * p_msg);
+
+/*******************************************************************************
+ **
+ ** Function btif_media_task_enc_update_req
+ **
+ ** Description Request to update the media task encoder
+ **
+ ** Returns TRUE is success
+ **
+ *******************************************************************************/
+#if (BTA_AV_INCLUDED == TRUE)
+extern BOOLEAN btif_media_task_enc_update_req(tBTIF_MEDIA_UPDATE_AUDIO * p_msg);
+#endif
+
+/*******************************************************************************
+ **
+ ** Function btif_media_task_start_aa_req
+ **
+ ** Description Request to start audio encoding task
+ **
+ ** Returns TRUE is success
+ **
+ *******************************************************************************/
+extern BOOLEAN btif_media_task_start_aa_req(void);
+
+/*******************************************************************************
+ **
+ ** Function btif_media_task_stop_aa_req
+ **
+ ** Description Request to stop audio encoding task
+ **
+ ** Returns TRUE is success
+ **
+ *******************************************************************************/
+extern BOOLEAN btif_media_task_stop_aa_req(void);
+
+
+/*******************************************************************************
+ **
+ ** Function btif_media_task_aa_tx_flush_req
+ **
+ ** Description Request to flush audio encoding pipe
+ **
+ ** Returns TRUE is success
+ **
+ *******************************************************************************/
+extern BOOLEAN btif_media_task_aa_tx_flush_req(void);
+
+/*******************************************************************************
+ **
+ ** Function btif_media_aa_readbuf
+ **
+ ** Description Read an audio GKI buffer from the BTIF media TX queue
+ **
+ ** Returns pointer on a GKI aa buffer ready to send
+ **
+ *******************************************************************************/
+extern BT_HDR *btif_media_aa_readbuf(void);
+
+/*******************************************************************************
+ **
+ ** Function btif_media_aa_writebuf
+ **
+ ** Description Enqueue a Advance Audio media GKI buffer to be processed by btif media task.
+ **
+ ** Returns TRUE is success
+ **
+ *******************************************************************************/
+extern void btif_media_aa_writebuf(BT_HDR *pBuf, UINT32 timestamp, UINT16 seq_num);
+
+/*******************************************************************************
+ **
+ ** Function btif_media_av_writebuf
+ **
+ ** Description Enqueue a video media GKI buffer to be processed by btif media task.
+ **
+ ** Returns TRUE is success
+ **
+ *******************************************************************************/
+extern BOOLEAN btif_media_av_writebuf(UINT8 *p_media, UINT32 media_len,
+ UINT32 timestamp, UINT16 seq_num);
+
+#if (BTA_AV_INCLUDED == TRUE)
+/*******************************************************************************
+ **
+ ** Function btif_media_task_audio_feeding_init_req
+ **
+ ** Description Request to initialize audio feeding
+ **
+ ** Returns TRUE is success
+ **
+ *******************************************************************************/
+
+extern BOOLEAN btif_media_task_audio_feeding_init_req(tBTIF_MEDIA_INIT_AUDIO_FEEDING *p_msg);
+#endif
+
+/*******************************************************************************
+ **
+ ** Function dump_codec_info
+ **
+ ** Description Decode and display codec_info (for debug)
+ **
+ ** Returns void
+ **
+ *******************************************************************************/
+extern void dump_codec_info(unsigned char *p_codec);
+
+/**
+ * Local adaptation helper functions between btif and media task
+ */
+
+int btif_a2dp_start_media_task(void);
+void btif_a2dp_stop_media_task(void);
+
+void btif_a2dp_on_init(void);
+void btif_a2dp_setup_codec(void);
+void btif_a2dp_on_idle(void);
+void btif_a2dp_on_open(void);
+void btif_a2dp_on_started(tBTA_AV_START *p_av);
+void btif_a2dp_on_stop_req(void);
+void btif_a2dp_on_stopped(tBTA_AV_SUSPEND *p_av);
+void btif_a2dp_on_suspend(void);
+void btif_a2dp_on_suspended(tBTA_AV_SUSPEND *p_av);
+void btif_a2dp_set_tx_flush(BOOLEAN enable);
+
+void btif_media_check_iop_exceptions(UINT8 *peer_bda);
+
+#endif
diff --git a/btif/include/btif_pan.h b/btif/include/btif_pan.h
new file mode 100644
index 0000000..d9ecb2e
--- /dev/null
+++ b/btif/include/btif_pan.h
@@ -0,0 +1,36 @@
+/******************************************************************************
+ *
+ * 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.
+ *
+ ******************************************************************************/
+
+/*******************************************************************************
+ *
+ * Filename: btif_pan.h
+ *
+ * Description: Bluetooth pan Interface
+ *
+ *******************************************************************************/
+
+#ifndef BTIF_PAN_H
+#define BTIF_PAN_H
+
+#include <hardware/bt_pan.h>
+
+btpan_interface_t *btif_pan_interface();
+void btif_pan_init();
+void btif_pan_cleanup();
+
+#endif
diff --git a/btif/include/btif_pan_internal.h b/btif/include/btif_pan_internal.h
new file mode 100644
index 0000000..d697ac8
--- /dev/null
+++ b/btif/include/btif_pan_internal.h
@@ -0,0 +1,118 @@
+/******************************************************************************
+ *
+ * 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.
+ *
+ ******************************************************************************/
+
+/*******************************************************************************
+ *
+ * Filename: btif_pan_internal.h
+ *
+ * Description: Bluetooth pan internal
+ *
+ *******************************************************************************/
+
+#ifndef BTIF_PAN_INTERNAL_H
+#define BTIF_PAN_INTERNAL_H
+
+#include "btif_pan.h"
+#include "bt_types.h"
+
+/*******************************************************************************
+** Constants & Macros
+********************************************************************************/
+
+#define PAN_NAP_SERVICE_NAME "Android Network Access Point"
+#define PANU_SERVICE_NAME "Android Network User"
+#define TAP_IF_NAME "bt-pan"
+#define ETH_ADDR_LEN 6
+#ifndef PAN_SECURITY
+#define PAN_SECURITY (BTM_SEC_IN_AUTHENTICATE | BTM_SEC_OUT_AUTHENTICATE | BTM_SEC_IN_ENCRYPT | BTM_SEC_OUT_ENCRYPT)
+#endif
+
+#define PAN_STATE_UNKNOWN 0
+#define PAN_STATE_OPEN 1
+#define PAN_STATE_CLOSE 2
+#ifndef PAN_ROLE_INACTIVE
+#define PAN_ROLE_INACTIVE 0
+#endif
+
+
+/*******************************************************************************
+** Type definitions and return values
+********************************************************************************/
+
+typedef struct eth_hdr
+{
+ unsigned char h_dest[ETH_ADDR_LEN];
+ unsigned char h_src[ETH_ADDR_LEN];
+ short h_proto;
+} tETH_HDR;
+
+typedef struct
+{
+ int handle;
+ int state;
+ UINT16 protocol;
+ BD_ADDR peer;
+ int local_role;
+ int remote_role;
+ unsigned char eth_addr[ETH_ADDR_LEN];
+} btpan_conn_t;
+
+typedef struct
+{
+ int btl_if_handle;
+ int btl_if_handle_panu;
+ int tap_fd;
+ int enabled;
+ int open_count;
+ btpan_conn_t conns[MAX_PAN_CONNS];
+} btpan_cb_t;
+
+
+/*******************************************************************************
+** Functions
+********************************************************************************/
+
+extern btpan_cb_t btpan_cb;
+btpan_conn_t *btpan_new_conn(int handle, const BD_ADDR addr, int local_role, int peer_role);
+btpan_conn_t *btpan_find_conn_addr(const BD_ADDR addr);
+btpan_conn_t *btpan_find_conn_handle(UINT16 handle);
+int btpan_get_connected_count(void);
+int btpan_tap_open(void);
+void create_tap_read_thread(int tap_fd);
+void destroy_tap_read_thread(void);
+int btpan_tap_close(int tap_fd);
+int btpan_tap_send(int tap_fd, const BD_ADDR src, const BD_ADDR dst, UINT16 protocol,
+ const char* buff, UINT16 size, BOOLEAN ext, BOOLEAN forward);
+
+static inline int is_empty_eth_addr(const BD_ADDR addr)
+{
+ int i;
+ for(i = 0; i < BD_ADDR_LEN; i++)
+ if(addr[i] != 0)
+ return 0;
+ return 1;
+}
+
+static inline int is_valid_bt_eth_addr(const BD_ADDR addr)
+{
+ if(is_empty_eth_addr(addr))
+ return 0;
+ return addr[0] & 1 ? 0 : 1; /* Cannot be multicasting address */
+}
+
+#endif
diff --git a/btif/include/btif_profile_queue.h b/btif/include/btif_profile_queue.h
new file mode 100644
index 0000000..931f457
--- /dev/null
+++ b/btif/include/btif_profile_queue.h
@@ -0,0 +1,37 @@
+/******************************************************************************
+ *
+ * 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.
+ *
+ ******************************************************************************/
+
+/*******************************************************************************
+ *
+ * Filename: btif_profile_queue.h
+ *
+ * Description: Bluetooth remote device connection queuing
+ *
+ *******************************************************************************/
+
+#ifndef BTIF_PROFILE_QUEUE_H
+#define BTIF_PROFILE_QUEUE_H
+
+typedef bt_status_t (btif_connect_cb_t) (bt_bdaddr_t *bda);
+
+bt_status_t btif_queue_connect(uint16_t uuid, const bt_bdaddr_t *bda,
+ btif_connect_cb_t *connect_cb);
+void btif_queue_advance();
+void btif_queue_release();
+
+#endif
diff --git a/btif/include/btif_sm.h b/btif/include/btif_sm.h
new file mode 100644
index 0000000..baad0d9
--- /dev/null
+++ b/btif/include/btif_sm.h
@@ -0,0 +1,118 @@
+/******************************************************************************
+ *
+ * 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.
+ *
+ ******************************************************************************/
+
+/*****************************************************************************
+ *
+ * Filename: btif_sm.h
+ *
+ * Description: Generic BTIF state machine API
+ *
+ *****************************************************************************/
+
+#ifndef BTIF_SM_H
+#define BTIF_SM_H
+
+/*****************************************************************************
+** Constants & Macros
+******************************************************************************/
+
+/* Generic Enter/Exit state machine events */
+#define BTIF_SM_ENTER_EVT 0xFFFF
+#define BTIF_SM_EXIT_EVT 0xFFFE
+
+
+/*****************************************************************************
+** Type definitions and return values
+******************************************************************************/
+typedef UINT32 btif_sm_state_t;
+typedef UINT32 btif_sm_event_t;
+typedef void* btif_sm_handle_t;
+typedef BOOLEAN(*btif_sm_handler_t)(btif_sm_event_t event, void *data);
+
+
+/*****************************************************************************
+** Functions
+**
+** NOTE: THESE APIs SHOULD BE INVOKED ONLY IN THE BTIF CONTEXT
+**
+******************************************************************************/
+
+/*****************************************************************************
+**
+** Function btif_sm_init
+**
+** Description Initializes the state machine with the state handlers
+** The caller should ensure that the table and the corresponding
+** states match. The location that 'p_handlers' points to shall
+** be available until the btif_sm_shutdown API is invoked.
+**
+** Returns Returns a pointer to the initialized state machine handle.
+**
+******************************************************************************/
+btif_sm_handle_t btif_sm_init(const btif_sm_handler_t *p_handlers,
+ btif_sm_state_t initial_state);
+
+/*****************************************************************************
+**
+** Function btif_sm_shutdown
+**
+** Description Tears down the state machine
+**
+** Returns None
+**
+******************************************************************************/
+void btif_sm_shutdown(btif_sm_handle_t handle);
+
+/*****************************************************************************
+**
+** Function btif_sm_get_state
+**
+** Description Fetches the current state of the state machine
+**
+** Returns Current state
+**
+******************************************************************************/
+btif_sm_state_t btif_sm_get_state(btif_sm_handle_t handle);
+
+/*****************************************************************************
+**
+** Function btif_sm_dispatch
+**
+** Description Dispatches the 'event' along with 'data' to the current state handler
+**
+** Returns Returns BT_STATUS_OK on success, BT_STATUS_FAIL otherwise
+**
+******************************************************************************/
+bt_status_t btif_sm_dispatch(btif_sm_handle_t handle, btif_sm_event_t event,
+ void *data);
+
+/*****************************************************************************
+**
+** Function btif_sm_change_state
+**
+** Description Make a transition to the new 'state'. The 'BTIF_SM_EXIT_EVT'
+** shall be invoked before exiting the current state. The
+** 'BTIF_SM_ENTER_EVT' shall be invoked before entering the new state
+**
+**
+** Returns Returns BT_STATUS_OK on success, BT_STATUS_FAIL otherwise
+**
+******************************************************************************/
+bt_status_t btif_sm_change_state(btif_sm_handle_t handle, btif_sm_state_t state);
+
+#endif /* BTIF_SM_H */
diff --git a/btif/include/btif_sock.h b/btif/include/btif_sock.h
new file mode 100644
index 0000000..ad2c71d
--- /dev/null
+++ b/btif/include/btif_sock.h
@@ -0,0 +1,36 @@
+/******************************************************************************
+ *
+ * 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.
+ *
+ ******************************************************************************/
+
+/*******************************************************************************
+ *
+ * Filename: btif_sock.h
+ *
+ * Description: Bluetooth socket Interface
+ *
+ *******************************************************************************/
+
+#ifndef BTIF_SOCK_H
+#define BTIF_SOCK_H
+
+#include <hardware/bt_sock.h>
+
+bt_status_t btif_sock_init();
+btsock_interface_t *btif_sock_get_interface();
+void btif_sock_cleanup();
+
+#endif
diff --git a/btif/include/btif_sock_rfc.h b/btif/include/btif_sock_rfc.h
new file mode 100644
index 0000000..b36ec1f
--- /dev/null
+++ b/btif/include/btif_sock_rfc.h
@@ -0,0 +1,38 @@
+/******************************************************************************
+ *
+ * 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.
+ *
+ ******************************************************************************/
+
+/*******************************************************************************
+ *
+ * Filename: btif_sock.h
+ *
+ * Description: Bluetooth socket Interface
+ *
+ *******************************************************************************/
+
+#ifndef BTIF_SOCK_RFC_H
+#define BTIF_SOCK_RFC_H
+
+bt_status_t btsock_rfc_init(int handle);
+bt_status_t btsock_rfc_cleanup();
+bt_status_t btsock_rfc_listen(const char* name, const uint8_t* uuid, int channel,
+ int* sock_fd, int flags);
+bt_status_t btsock_rfc_connect(const bt_bdaddr_t *bd_addr, const uint8_t* uuid,
+ int channel, int* sock_fd, int flags);
+void btsock_rfc_signaled(int fd, int flags, uint32_t user_id);
+
+#endif
diff --git a/btif/include/btif_sock_sdp.h b/btif/include/btif_sock_sdp.h
new file mode 100644
index 0000000..9fe4768
--- /dev/null
+++ b/btif/include/btif_sock_sdp.h
@@ -0,0 +1,39 @@
+/******************************************************************************
+ *
+ * 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 BTIF_SOCK_SDP_H
+#define BTIF_SOCK_SDP_H
+static const UINT8 UUID_OBEX_OBJECT_PUSH[] = {0x00, 0x00, 0x11, 0x05, 0x00, 0x00, 0x10, 0x00,
+ 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB};
+static const UINT8 UUID_PBAP_PSE[] = {0x00, 0x00, 0x11, 0x2F, 0x00, 0x00, 0x10, 0x00,
+ 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB};
+static const UINT8 UUID_SPP[] = {0x00, 0x00, 0x11, 0x01, 0x00, 0x00, 0x10, 0x00,
+ 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB};
+
+static inline BOOLEAN is_uuid_empty(const uint8_t* uuid)
+{
+ static uint8_t empty_uuid[16];
+ return uuid == NULL || memcmp(uuid, empty_uuid, sizeof(empty_uuid)) == 0;
+}
+
+int add_rfc_sdp_rec(const char* name, const uint8_t* uuid, int scn);
+void del_rfc_sdp_rec(int handle);
+BOOLEAN is_reserved_rfc_channel(int channel);
+int get_reserved_rfc_channel(const uint8_t* uuid);
+
+#endif
diff --git a/btif/include/btif_sock_thread.h b/btif/include/btif_sock_thread.h
new file mode 100644
index 0000000..9b12f56
--- /dev/null
+++ b/btif/include/btif_sock_thread.h
@@ -0,0 +1,49 @@
+/******************************************************************************
+ *
+ * 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 BTIF_SOCK_THREAD_H
+#define BTIF_SOCK_THREAD_H
+
+#include <hardware/bt_sock.h>
+
+/*******************************************************************************
+** Constants & Macros
+********************************************************************************/
+
+#define SOCK_THREAD_FD_RD 1 /* BT socket read signal */
+#define SOCK_THREAD_FD_WR (1 << 1) /* BT socket write signal */
+#define SOCK_THREAD_FD_EXCEPTION (1 << 2) /* BT socket exception singal */
+#define SOCK_THREAD_ADD_FD_SYNC (1 << 3) /* Add BT socket fd in current socket
+ poll thread context immediately */
+
+/*******************************************************************************
+** Functions
+********************************************************************************/
+
+typedef void (*btsock_signaled_cb)(int fd, int type, int flags, uint32_t user_id);
+typedef void (*btsock_cmd_cb)(int cmd_fd, int type, int size, uint32_t user_id);
+
+int btsock_thread_init();
+int btsock_thread_add_fd(int handle, int fd, int type, int flags, uint32_t user_id);
+int btsock_thread_wakeup(int handle);
+int btsock_thread_post_cmd(int handle, int cmd_type, const unsigned char* cmd_data,
+ int data_size, uint32_t user_id);
+int btsock_thread_create(btsock_signaled_cb callback, btsock_cmd_cb cmd_callback);
+int btsock_thread_exit(int handle);
+
+#endif
diff --git a/btif/include/btif_sock_util.h b/btif/include/btif_sock_util.h
new file mode 100644
index 0000000..e0f7066
--- /dev/null
+++ b/btif/include/btif_sock_util.h
@@ -0,0 +1,65 @@
+/******************************************************************************
+ *
+ * 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.
+ *
+ ******************************************************************************/
+
+/*******************************************************************************
+ *
+ * Filename: btif_sock_util.h
+ *
+ * Description: Bluetooth socket Interface Helper functions
+ *
+ *******************************************************************************/
+
+#ifndef BTIF_SOCK_UTIL_H
+#define BTIF_SOCK_UTIL_H
+
+#include <pthread.h>
+#include <cutils/log.h>
+
+/*******************************************************************************
+** Functions
+********************************************************************************/
+
+static inline void init_slot_lock( pthread_mutex_t* mutex)
+{
+ pthread_mutexattr_t attr;
+ pthread_mutexattr_init(&attr);
+ pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE_NP);
+ pthread_mutex_init(mutex, &attr);
+}
+
+static inline void lock_slot(pthread_mutex_t* mutex)
+{
+ if(mutex->value)
+ pthread_mutex_lock(mutex);
+ else ALOGE("mutex: %p is not initialized", mutex);
+}
+
+static inline void unlock_slot(pthread_mutex_t* mutex)
+{
+ if(mutex->value)
+ pthread_mutex_unlock(mutex);
+ else ALOGE("mutex: %p is not initialized", mutex);
+}
+
+void dump_bin(const char* title, const char* data, int size);
+
+int sock_send_fd(int sock_fd, const uint8_t* buffer, int len, int send_fd);
+int sock_send_all(int sock_fd, const uint8_t* buf, int len);
+int sock_recv_all(int sock_fd, uint8_t* buf, int len);
+
+#endif
diff --git a/btif/include/btif_storage.h b/btif/include/btif_storage.h
new file mode 100644
index 0000000..87dec3b
--- /dev/null
+++ b/btif/include/btif_storage.h
@@ -0,0 +1,313 @@
+/******************************************************************************
+ *
+ * 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 BTIF_STORAGE_H
+#define BTIF_STORAGE_H
+
+#include "data_types.h"
+#include "bt_types.h"
+
+#include <utils/Log.h>
+
+/*******************************************************************************
+** Constants & Macros
+********************************************************************************/
+#define BTIF_STORAGE_FILL_PROPERTY(p_prop, t, l, p_v) \
+ (p_prop)->type = t;(p_prop)->len = l; (p_prop)->val = (p_v);
+
+
+/*******************************************************************************
+** Functions
+********************************************************************************/
+
+/*******************************************************************************
+**
+** Function btif_storage_get_adapter_property
+**
+** Description BTIF storage API - Fetches the adapter property->type
+** from NVRAM and fills property->val.
+** Caller should provide memory for property->val and
+** set the property->val
+**
+** Returns BT_STATUS_SUCCESS if the fetch was successful,
+** BT_STATUS_FAIL otherwise
+**
+*******************************************************************************/
+bt_status_t btif_storage_get_adapter_property(bt_property_t *property);
+
+/*******************************************************************************
+**
+** Function btif_storage_set_adapter_property
+**
+** Description BTIF storage API - Stores the adapter property
+** to NVRAM
+**
+** Returns BT_STATUS_SUCCESS if the store was successful,
+** BT_STATUS_FAIL otherwise
+**
+*******************************************************************************/
+bt_status_t btif_storage_set_adapter_property(bt_property_t *property);
+
+/*******************************************************************************
+**
+** Function btif_storage_get_remote_device_property
+**
+** Description BTIF storage API - Fetches the remote device property->type
+** from NVRAM and fills property->val.
+** Caller should provide memory for property->val and
+** set the property->val
+**
+** Returns BT_STATUS_SUCCESS if the fetch was successful,
+** BT_STATUS_FAIL otherwise
+**
+*******************************************************************************/
+bt_status_t btif_storage_get_remote_device_property(bt_bdaddr_t *remote_bd_addr,
+ bt_property_t *property);
+
+/*******************************************************************************
+**
+** Function btif_storage_set_remote_device_property
+**
+** Description BTIF storage API - Stores the remote device property
+** to NVRAM
+**
+** Returns BT_STATUS_SUCCESS if the store was successful,
+** BT_STATUS_FAIL otherwise
+**
+*******************************************************************************/
+bt_status_t btif_storage_set_remote_device_property(bt_bdaddr_t *remote_bd_addr,
+ bt_property_t *property);
+
+/*******************************************************************************
+**
+** Function btif_storage_add_remote_device
+**
+** Description BTIF storage API - Adds a newly discovered device to NVRAM
+** along with the timestamp. Also, stores the various
+** properties - RSSI, BDADDR, NAME (if found in EIR)
+**
+** Returns BT_STATUS_SUCCESS if the store was successful,
+** BT_STATUS_FAIL otherwise
+**
+*******************************************************************************/
+bt_status_t btif_storage_add_remote_device(bt_bdaddr_t *remote_bdaddr,
+ uint32_t num_properties,
+ bt_property_t *properties);
+
+/*******************************************************************************
+**
+** Function btif_storage_add_bonded_device
+**
+** Description BTIF storage API - Adds the newly bonded device to NVRAM
+** along with the link-key, Key type and Pin key length
+**
+** Returns BT_STATUS_SUCCESS if the store was successful,
+** BT_STATUS_FAIL otherwise
+**
+*******************************************************************************/
+bt_status_t btif_storage_add_bonded_device(bt_bdaddr_t *remote_bd_addr,
+ LINK_KEY link_key,
+ uint8_t key_type,
+ uint8_t pin_length);
+
+/*******************************************************************************
+**
+** Function btif_storage_remove_bonded_device
+**
+** Description BTIF storage API - Deletes the bonded device from NVRAM
+**
+** Returns BT_STATUS_SUCCESS if the deletion was successful,
+** BT_STATUS_FAIL otherwise
+**
+*******************************************************************************/
+bt_status_t btif_storage_remove_bonded_device(bt_bdaddr_t *remote_bd_addr);
+
+/*******************************************************************************
+**
+** Function btif_storage_remove_bonded_device
+**
+** Description BTIF storage API - Deletes the bonded device from NVRAM
+**
+** Returns BT_STATUS_SUCCESS if the deletion was successful,
+** BT_STATUS_FAIL otherwise
+**
+*******************************************************************************/
+bt_status_t btif_storage_load_bonded_devices(void);
+
+/*******************************************************************************
+**
+** Function btif_storage_read_hl_apps_cb
+**
+** Description BTIF storage API - Read HL application control block from NVRAM
+**
+** Returns BT_STATUS_SUCCESS if the operation was successful,
+** BT_STATUS_FAIL otherwise
+**
+*******************************************************************************/
+bt_status_t btif_storage_read_hl_apps_cb(char *value, int value_size);
+
+/*******************************************************************************
+**
+** Function btif_storage_write_hl_apps_cb
+**
+** Description BTIF storage API - Write HL application control block to NVRAM
+**
+** Returns BT_STATUS_SUCCESS if the operation was successful,
+** BT_STATUS_FAIL otherwise
+**
+*******************************************************************************/
+bt_status_t btif_storage_write_hl_apps_cb(char *value, int value_size);
+
+/*******************************************************************************
+**
+** Function btif_storage_read_hl_apps_cb
+**
+** Description BTIF storage API - Read HL application configuration from NVRAM
+**
+** Returns BT_STATUS_SUCCESS if the operation was successful,
+** BT_STATUS_FAIL otherwise
+**
+*******************************************************************************/
+bt_status_t btif_storage_read_hl_app_data(UINT8 app_idx, char *value, int value_size);
+
+/*******************************************************************************
+**
+** Function btif_storage_write_hl_app_data
+**
+** Description BTIF storage API - Write HL application configuration to NVRAM
+**
+** Returns BT_STATUS_SUCCESS if the operation was successful,
+** BT_STATUS_FAIL otherwise
+**
+*******************************************************************************/
+bt_status_t btif_storage_write_hl_app_data(UINT8 app_idx, char *value, int value_size);
+
+/*******************************************************************************
+**
+** Function btif_storage_read_hl_mdl_data
+**
+** Description BTIF storage API - Read HL application MDL configuration from NVRAM
+**
+** Returns BT_STATUS_SUCCESS if the operation was successful,
+** BT_STATUS_FAIL otherwise
+**
+*******************************************************************************/
+bt_status_t btif_storage_read_hl_mdl_data(UINT8 app_idx, char *value, int value_size);
+
+/*******************************************************************************
+**
+** Function btif_storage_write_hl_mdl_data
+**
+** Description BTIF storage API - Write HL application MDL configuration from NVRAM
+**
+** Returns BT_STATUS_SUCCESS if the operation was successful,
+** BT_STATUS_FAIL otherwise
+**
+*******************************************************************************/
+bt_status_t btif_storage_write_hl_mdl_data(UINT8 app_idx, char *value, int value_size);
+
+/*******************************************************************************
+**
+** Function btif_storage_add_hid_device_info
+**
+** Description BTIF storage API - Adds the hid information of bonded hid devices-to NVRAM
+**
+** Returns BT_STATUS_SUCCESS if the store was successful,
+** BT_STATUS_FAIL otherwise
+**
+*******************************************************************************/
+bt_status_t btif_storage_add_hid_device_info(bt_bdaddr_t *remote_bd_addr,
+ UINT16 attr_mask, UINT8 sub_class,
+ UINT8 app_id, UINT16 vendor_id,
+ UINT16 product_id, UINT16 version,
+ UINT8 ctry_code, UINT16 dl_len,
+ UINT8 *dsc_list);
+
+/*******************************************************************************
+**
+** Function btif_storage_load_bonded_hid_info
+**
+** Description BTIF storage API - Loads hid info for all the bonded devices
+** from NVRAM and adds those devices to the BTA_HH.
+**
+** Returns BT_STATUS_SUCCESS if successful, BT_STATUS_FAIL otherwise
+**
+*******************************************************************************/
+bt_status_t btif_storage_load_bonded_hid_info(void);
+
+/*******************************************************************************
+**
+** Function btif_storage_remove_hid_info
+**
+** Description BTIF storage API - Deletes the bonded hid device info from NVRAM
+**
+** Returns BT_STATUS_SUCCESS if the deletion was successful,
+** BT_STATUS_FAIL otherwise
+**
+*******************************************************************************/
+bt_status_t btif_storage_remove_hid_info(bt_bdaddr_t *remote_bd_addr);
+
+/*******************************************************************************
+**
+** Function btif_storage_load_autopair_device_list
+**
+** Description BTIF storage API - Populates auto pair device list
+**
+** Returns BT_STATUS_SUCCESS if the auto pair blacklist is successfully populated
+** BT_STATUS_FAIL otherwise
+**
+*******************************************************************************/
+bt_status_t btif_storage_load_autopair_device_list();
+
+/*******************************************************************************
+**
+** Function btif_storage_is_device_autopair_blacklisted
+**
+** Description BTIF storage API Checks if the given device is blacklisted for auto pairing
+**
+** Returns TRUE if the device is found in the auto pair blacklist
+** FALSE otherwise
+**
+*******************************************************************************/
+BOOLEAN btif_storage_is_device_autopair_blacklisted(bt_bdaddr_t *remote_dev_addr);
+
+/*******************************************************************************
+**
+** Function btif_storage_add_device_to_autopair_blacklist
+**
+** Description BTIF storage API - Add a remote device to the auto pairing blacklist
+**
+** Returns BT_STATUS_SUCCESS if the device is successfully added to the auto pair blacklist
+** BT_STATUS_FAIL otherwise
+**
+*******************************************************************************/
+bt_status_t btif_storage_add_device_to_autopair_blacklist(bt_bdaddr_t *remote_dev_addr);
+
+/*******************************************************************************
+**
+** Function btif_storage_is_fixed_pin_zeros_keyboard
+**
+** Description BTIF storage API - checks if this device has fixed PIN key device list
+**
+** Returns TRUE if the device is found in the fixed pin keyboard device list
+** FALSE otherwise
+**
+*******************************************************************************/
+BOOLEAN btif_storage_is_fixed_pin_zeros_keyboard(bt_bdaddr_t *remote_dev_addr);
+
+#endif /* BTIF_STORAGE_H */
diff --git a/btif/include/btif_util.h b/btif/include/btif_util.h
new file mode 100644
index 0000000..09dae6e
--- /dev/null
+++ b/btif/include/btif_util.h
@@ -0,0 +1,73 @@
+/******************************************************************************
+ *
+ * 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 BTIF_UTIL_H
+#define BTIF_UTIL_H
+
+#include <hardware/bluetooth.h>
+#include <hardware/bt_hf.h>
+#include <utils/Log.h>
+
+#include "data_types.h"
+#include "bt_types.h"
+
+/*******************************************************************************
+** Constants & Macros
+********************************************************************************/
+
+#define CASE_RETURN_STR(const) case const: return #const;
+
+
+/*******************************************************************************
+** Type definitions for callback functions
+********************************************************************************/
+
+typedef char bdstr_t[18];
+
+
+/*******************************************************************************
+** Functions
+********************************************************************************/
+
+const char* dump_bt_status(bt_status_t status);
+const char* dump_dm_search_event(UINT16 event);
+const char* dump_dm_event(UINT16 event);
+const char* dump_hf_event(UINT16 event);
+const char* dump_hh_event(UINT16 event);
+const char* dump_hf_conn_state(UINT16 event);
+const char* dump_hf_call_state(bthf_call_state_t call_state);
+const char* dump_property_type(bt_property_type_t type);
+const char* dump_hf_audio_state(UINT16 event);
+const char* dump_adapter_scan_mode(bt_scan_mode_t mode);
+const char* dump_thread_evt(bt_cb_thread_evt evt);
+
+const char* dump_av_conn_state(UINT16 event);
+const char* dump_av_audio_state(UINT16 event);
+
+int str2bd(char *str, bt_bdaddr_t *addr);
+char *bd2str(bt_bdaddr_t *addr, bdstr_t *bdstr);
+
+UINT32 devclass2uint(DEV_CLASS dev_class);
+void uint2devclass(UINT32 dev, DEV_CLASS dev_class);
+void uuid16_to_uuid128(uint16_t uuid16, bt_uuid_t* uuid128);
+
+void uuid_to_string(bt_uuid_t *p_uuid, char *str);
+void string_to_uuid(char *str, bt_uuid_t *p_uuid);
+int ascii_2_hex (char *p_ascii, int len, UINT8 *p_hex);
+
+#endif /* BTIF_UTIL_H */
diff --git a/btif/include/uinput.h b/btif/include/uinput.h
new file mode 100644
index 0000000..5925703
--- /dev/null
+++ b/btif/include/uinput.h
@@ -0,0 +1,590 @@
+/******************************************************************************
+ *
+ * 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 <stdint.h>
+#include <sys/time.h>
+#include <sys/ioctl.h>
+
+/*******************************************************************************
+** 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_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 */
+
+#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)
+
+#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;
+ uint16_t type;
+ uint16_t code;
+ int32_t value;
+};
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __UINPUT_H */