upload android base code part4

This commit is contained in:
August 2018-08-08 17:00:29 +08:00
parent b9e30e05b1
commit 78ea2404cd
23455 changed files with 5250148 additions and 0 deletions

View file

@ -0,0 +1,3 @@
ifeq ($(call is-vendor-board-platform,QCOM),true)
include $(call all-named-subdir-makefiles,libbt-vendor)
endif # is-vendor-board-platform

View file

@ -0,0 +1,54 @@
# Copyright (C) 2007 The Android Open Source Project
#
# 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.
#
# If you don't need to do a full clean build but would like to touch
# a file or delete some intermediate files, add a clean step to the end
# of the list. These steps will only be run once, if they haven't been
# run before.
#
# E.g.:
# $(call add-clean-step, touch -c external/sqlite/sqlite3.h)
# $(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/STATIC_LIBRARIES/libz_intermediates)
#
# Always use "touch -c" and "rm -f" or "rm -rf" to gracefully deal with
# files that are missing or have been moved.
#
# Use $(PRODUCT_OUT) to get to the "out/target/product/blah/" directory.
# Use $(OUT_DIR) to refer to the "out" directory.
#
# If you need to re-do something that's already mentioned, just copy
# the command and add it to the bottom of the list. E.g., if a change
# that you made last week required touching a file and a change you
# made today requires touching the same file, just copy the old
# touch step and add it to the end of the list.
#
# ************************************************
# NEWER CLEAN STEPS MUST BE AT THE END OF THE LIST
# ************************************************
# For example:
#$(call add-clean-step, rm -rf $(OUT_DIR)/target/common/obj/APPS/AndroidTests_intermediates)
#$(call add-clean-step, rm -rf $(OUT_DIR)/target/common/obj/JAVA_LIBRARIES/core_intermediates)
#$(call add-clean-step, find $(OUT_DIR) -type f -name "IGTalkSession*" -print0 | xargs -0 rm -f)
#$(call add-clean-step, rm -rf $(PRODUCT_OUT)/data/*)
# ************************************************
# NEWER CLEAN STEPS MUST BE AT THE END OF THE LIST
# ************************************************
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/SHARED_LIBRARIES/libbt-vendor_intermediates)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/NOTICE_FILES/src/system/vendor/lib/libbt-vendor.so.txt)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/lib/libbt-vendor.so)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/symbols/system/vendor/lib/libbt-vendor.so)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/vendor/lib/libbt-vendor.so)

View file

@ -0,0 +1,88 @@
#
# Copyright 2012 The Android Open Source Project
#
# 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.
#
LOCAL_PATH := $(call my-dir)
ifeq ($(BOARD_HAVE_BLUETOOTH_QCOM),true)
include $(CLEAR_VARS)
LOCAL_SRC_FILES := \
src/bt_vendor_qcom.c \
src/hardware.c \
src/hci_uart.c \
src/hci_smd.c \
src/hw_rome.c \
src/hw_ar3k.c \
src/bt_vendor_persist.cpp
#Disable this flag in case if FM over UART support not needed
LOCAL_CFLAGS := -DFM_OVER_UART
ifneq (,$(filter userdebug eng,$(TARGET_BUILD_VARIANT)))
LOCAL_CFLAGS += -DPANIC_ON_SOC_CRASH
LOCAL_CFLAGS += -DENABLE_DBG_FLAGS
endif
LOCAL_C_INCLUDES += \
$(LOCAL_PATH)/include \
external/bluetooth/bluedroid/hci/include \
system/bt/hci/include \
$(TARGET_OUT_HEADERS)/bt/hci_qcomm_init \
$(TARGET_OUT_INTERMEDIATES)/KERNEL_OBJ/usr/include
LOCAL_ADDITIONAL_DEPENDENCIES += \
$(TARGET_OUT_INTERMEDIATES)/KERNEL_OBJ/usr
ifeq ($(BOARD_HAS_QCA_BT_AR3002), true)
LOCAL_C_FLAGS := \
-DBT_WAKE_VIA_PROC
endif #BOARD_HAS_QCA_BT_AR3002
ifeq ($(WIFI_BT_STATUS_SYNC), true)
LOCAL_CFLAGS += -DWIFI_BT_STATUS_SYNC
endif #WIFI_BT_STATUS_SYNC
LOCAL_SHARED_LIBRARIES := \
libcutils \
liblog \
libbtnv
LOCAL_MODULE := libbt-vendor
LOCAL_MODULE_TAGS := optional
LOCAL_MODULE_CLASS := SHARED_LIBRARIES
LOCAL_MODULE_OWNER := qcom
ifdef TARGET_2ND_ARCH
LOCAL_MODULE_PATH_32 := $(TARGET_OUT_VENDOR)/lib
LOCAL_MODULE_PATH_64 := $(TARGET_OUT_VENDOR)/lib64
else
LOCAL_MODULE_PATH := $(TARGET_OUT_VENDOR_SHARED_LIBRARIES)
endif
LOCAL_CFLAGS += -DBT_NV_SUPPORT
ifneq ($(BOARD_ANT_WIRELESS_DEVICE),)
LOCAL_CFLAGS += -DENABLE_ANT
endif
#LOCAL_CFLAGS += -DREAD_BT_ADDR_FROM_PROP
#include $(LOCAL_PATH)/vnd_buildcfg.mk
include $(BUILD_SHARED_LIBRARY)
endif # BOARD_HAVE_BLUETOOTH_QCOM

View file

@ -0,0 +1,190 @@
Copyright (c) 2005-2012, The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
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.
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS

View file

@ -0,0 +1,69 @@
/*
* Copyright (c) 2013, The Linux Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
* EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef BT_VENDOR_PERSIST_H_
#define BT_VENDOR_PERSIST_H_
#ifdef __cplusplus
extern "C"
{
#endif
#include <stdio.h>
#ifdef BT_NV_SUPPORT
#endif /* BT_NV_SUPPORT */
typedef unsigned char boolean;
/*===========================================================================
FUNCTION bt_vendor_nv_read
DESCRIPTION
Helper Routine to process the nv read command
DEPENDENCIES
NIL
RETURN VALUE
RETURN VALUE
FALSE = failure, else TRUE
SIDE EFFECTS
None
===========================================================================*/
extern uint8_t bt_vendor_nv_read
(
uint8_t nv_item,
uint8_t * rsp_buf
);
#ifdef __cplusplus
}
#endif
#endif /* BT_VENDOR_PERSIST_H_ */

View file

@ -0,0 +1,97 @@
/*
* Copyright 2012 The Android Open Source Project
*
* 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 BT_VENDOR_QCOM_H
#define BT_VENDOR_QCOM_H
#include <stdbool.h>
#include "bt_vendor_lib.h"
#ifndef FALSE
#define FALSE 0
#endif
#ifndef TRUE
#define TRUE (!FALSE)
#endif
#define STREAM_TO_UINT16(u16, p) {u16 = ((uint16_t)(*(p)) + (((uint16_t)(*((p) + 1))) << 8)); (p) += 2;}
#define UINT16_TO_STREAM(p, u16) {*(p)++ = (uint8_t)(u16); *(p)++ = (uint8_t)((u16) >> 8);}
#define UINT32_TO_STREAM(p, u32) {*(p)++ = (uint8_t)(u32); *(p)++ = (uint8_t)((u32) >> 8); *(p)++ = (uint8_t)((u32) >> 16); *(p)++ = (uint8_t)((u32) >> 24);}
typedef enum {
BT_SOC_DEFAULT = 0,
BT_SOC_SMD = BT_SOC_DEFAULT,
BT_SOC_AR3K,
BT_SOC_ROME,
BT_SOC_CHEROKEE,
/* Add chipset type here */
BT_SOC_RESERVED
}bt_soc_type;
typedef enum {
FM_VND_OP_POWER_CTRL = (unsigned int)BT_VND_OP_A2DP_OFFLOAD_STOP + 1,
BT_VND_OP_FM_USERIAL_OPEN,
BT_VND_OP_FM_USERIAL_CLOSE,
}bt_fm_serial;
typedef enum {
BT_VND_OP_ANT_USERIAL_OPEN = 254,
BT_VND_OP_ANT_USERIAL_CLOSE
}ant_serial;
/* HW_NEED_END_WITH_HCI_RESET
code implementation of sending a HCI_RESET command during the epilog
process. It calls back to the callers after command complete of HCI_RESET
is received.
Default TRUE .
*/
#ifndef HW_NEED_END_WITH_HCI_RESET
#define HW_NEED_END_WITH_HCI_RESET TRUE
#endif
#define HCI_RESET 0x0C03
#define HCI_CMD_PREAMBLE_SIZE 3
#define HCI_EVT_CMD_CMPL_STATUS_RET_BYTE 5
#define HCI_EVT_CMD_CMPL_OPCODE 3
#define BT_PWR_CNTRL_DEVICE "/dev/btpower"
enum {
BT_STATUS_SUCCESS = 0,
BT_STATUS_FAIL,
BT_STATUS_INVAL,
BT_STATUS_NOMEM,
BT_STATUS_PROP_FAILURE,
};
#define BT_CMD_PWR_CTRL 0xbfad
struct bt_qcom_struct {
int fd[2];
int ant_fd;
int fm_fd;
bt_vendor_callbacks_t *cb;
uint8_t bdaddr[6];
int soc_type;
int rfkill_id;
char *rfkill_state;
bool enable_extldo;
};
extern struct bt_qcom_struct *q;
extern pthread_mutex_t q_lock;
#endif /* BT_VENDOR_QCOM_H */

View file

@ -0,0 +1,37 @@
/*
* Copyright 2012 The Android Open Source Project
* Copyright (c) 2013, The Linux Foundation. All rights reserved.
* Not a Contribution.
*
* 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: hci_smd.h
*
* Description: Contains vendor-specific definitions used in smd controls
*
******************************************************************************/
#ifndef HCI_SMD_H
#define HCI_SMD_H
#define APPS_RIVA_BT_ACL_CH "/dev/smd2"
#define APPS_RIVA_BT_CMD_CH "/dev/smd3"
int bt_hci_init_transport ( int *pFd );
int bt_hci_deinit_transport(int *pFd);
#endif /* HCI_SMD_H */

View file

@ -0,0 +1,263 @@
/*
* Copyright (c) 2013, The Linux Foundation. All rights reserved.
* Not a Contribution.
* 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 HCI_UART_H
#define HCI_UART_H
#include <asm-generic/ioctls.h>
/* Variables to identify the platform */
/*BT HS UART TTY DEVICE */
#define BT_HS_UART_DEVICE "/dev/ttyHS0"
/**** baud rates ****/
#define USERIAL_BAUD_300 0
#define USERIAL_BAUD_600 1
#define USERIAL_BAUD_1200 2
#define USERIAL_BAUD_2400 3
#define USERIAL_BAUD_9600 4
#define USERIAL_BAUD_19200 5
#define USERIAL_BAUD_57600 6
#define USERIAL_BAUD_115200 7
#define USERIAL_BAUD_230400 8
#define USERIAL_BAUD_460800 9
#define USERIAL_BAUD_921600 10
#define USERIAL_BAUD_1M 11
#define USERIAL_BAUD_1_5M 12
#define USERIAL_BAUD_2M 13
#define USERIAL_BAUD_3M 14
#define USERIAL_BAUD_4M 15
#define USERIAL_BAUD_AUTO 16
/**** Data Format ****/
/* Stop Bits */
#define USERIAL_STOPBITS_1 1
#define USERIAL_STOPBITS_1_5 (1<<1)
#define USERIAL_STOPBITS_2 (1<<2)
/* Parity Bits */
#define USERIAL_PARITY_NONE (1<<3)
#define USERIAL_PARITY_EVEN (1<<4)
#define USERIAL_PARITY_ODD (1<<5)
/* Data Bits */
#define USERIAL_DATABITS_5 (1<<6)
#define USERIAL_DATABITS_6 (1<<7)
#define USERIAL_DATABITS_7 (1<<8)
#define USERIAL_DATABITS_8 (1<<9)
/* HCI Packet types */
#define HCI_COMMAND_PKT 0x01
#define HCI_ACLDATA_PKT 0x02
#define HCI_SCODATA_PKT 0x03
#define HCI_EVENT_PKT 0x04
#define HCI_VENDOR_PKT 0xff
/* HCI Command/Event Opcode */
#define HCI_RESET 0x0C03
#define EVT_CMD_COMPLETE 0x0E
/* Command opcode pack/unpack */
#define cmd_opcode_pack(ogf, ocf) (uint16_t)((ocf & 0x03ff)|(ogf << 10))
#if (BT_WAKE_VIA_USERIAL_IOCTL==TRUE)
/* These are the ioctl values used for bt_wake ioctl via UART driver. you may
* need to redefine them on you platform!
* Logically they need to be unique and not colide with existing uart ioctl's.
*/
#ifndef USERIAL_IOCTL_BT_WAKE_ASSERT
#define USERIAL_IOCTL_BT_WAKE_ASSERT 0x8003
#endif
#ifndef USERIAL_IOCTL_BT_WAKE_DEASSERT
#define USERIAL_IOCTL_BT_WAKE_DEASSERT 0x8004
#endif
#ifndef USERIAL_IOCTL_BT_WAKE_GET_ST
#define USERIAL_IOCTL_BT_WAKE_GET_ST 0x8005
#endif
#endif // (BT_WAKE_VIA_USERIAL_IOCTL==TRUE)
/* UART CLOCK IOCTLS*/
/* UART CLOCK IOCTLS*/
#define USERIAL_OP_CLK_ON TIOCPMGET /* PM get */
#define USERIAL_OP_CLK_OFF TIOCPMPUT /* PM put */
#define USERIAL_OP_CLK_STATE TIOCPMACT /* PM is active */
/******************************************************************************
** Type definitions
******************************************************************************/
/* Structure used to configure serial port during open */
typedef struct
{
uint16_t fmt; /* Data format */
uint8_t baud; /* Baud rate */
} tUSERIAL_CFG;
typedef enum {
#if (BT_WAKE_VIA_USERIAL_IOCTL==TRUE)
USERIAL_OP_ASSERT_BT_WAKE,
USERIAL_OP_DEASSERT_BT_WAKE,
USERIAL_OP_GET_BT_WAKE_STATE,
#endif
USERIAL_OP_FLOW_ON,
USERIAL_OP_FLOW_OFF,
USERIAL_OP_NOP,
} userial_vendor_ioctl_op_t;
/* UPIO signals */
enum {
UPIO_BT_WAKE = 0,
UPIO_HOST_WAKE,
UPIO_LPM_MODE,
UPIO_MAX_COUNT
};
/* UPIO assertion/deassertion */
enum {
UPIO_UNKNOWN = 0,
UPIO_DEASSERT,
UPIO_ASSERT
};
#define VND_PORT_NAME_MAXLEN 256
/* vendor serial control block */
typedef struct
{
int fd; /* fd to Bluetooth device */
struct termios termios; /* serial terminal of BT port */
char port_name[VND_PORT_NAME_MAXLEN];
} vnd_userial_cb_t;
typedef struct {
uint8_t ncmd;
uint16_t opcode;
} __attribute__ ((packed)) evt_cmd_complete;
typedef struct {
uint8_t status;
uint8_t ncmd;
uint16_t opcode;
} __attribute__ ((packed)) evt_cmd_status;
typedef struct {
uint16_t opcode;
uint8_t plen;
} __attribute__ ((packed)) hci_command_hdr;
typedef struct {
uint8_t evt;
uint8_t plen;
} __attribute__ ((packed)) hci_event_hdr;
/******************************************************************************
** Extern
******************************************************************************/
extern vnd_userial_cb_t vnd_userial;
/*******************************************************************************
**
** Function userial_vendor_init
**
** Description Initialize userial vendor-specific control block
**
** Returns None
**
*******************************************************************************/
void userial_vendor_init(void);
/*******************************************************************************
**
** Function userial_vendor_open
**
** Description Open the serial port with the given configuration
**
** Returns device fd
**
*******************************************************************************/
int userial_vendor_open(tUSERIAL_CFG *p_cfg);
/*******************************************************************************
**
** Function userial_vendor_close
**
** Description Conduct vendor-specific close work
**
** Returns None
**
*******************************************************************************/
void userial_vendor_close(void);
/*******************************************************************************
**
** Function userial_vendor_set_baud
**
** Description Set new baud rate
**
** Returns None
**
*******************************************************************************/
void userial_vendor_set_baud(uint8_t userial_baud);
/*******************************************************************************
**
** Function userial_vendor_ioctl
**
** Description ioctl inteface
**
** Returns int error
**
*******************************************************************************/
int userial_vendor_ioctl(userial_vendor_ioctl_op_t op, int *p_data);
/*******************************************************************************
**
** Function userial_to_tcio_baud
**
** Description helper function converts USERIAL baud rates into TCIO
** conforming baud rates
**
** Returns TRUE/FALSE
**
*******************************************************************************/
uint8_t userial_to_tcio_baud(uint8_t cfg_baud, uint32_t *baud);
/*******************************************************************************
**
** Function userial_to_baud_tcio
**
** Description helper function converts TCIO baud rate into integer
**
** Returns uint32_t
**
*******************************************************************************/
int userial_tcio_baud_to_int(uint32_t baud);
/*******************************************************************************
**
** Function read_hci_event
**
** Description Read HCI event during vendor initialization
**
** Returns int: size to read
**
*******************************************************************************/
int read_hci_event(int fd, unsigned char* buf, int size);
#endif /* HCI_UART_H */

View file

@ -0,0 +1,164 @@
/*
* Copyright 2012 The Android Open Source Project
* Copyright (c) 2013, The Linux Foundation. All rights reserved.
* Not a Contribution.
*
* 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 HW_AR3K_H
#define HW_AR3K_H
/******************************************************************************
** Constants & Macros
******************************************************************************/
#define MAX_CNT_RETRY 100
#define HCI_MAX_CMD_SIZE 260
#define HCI_MAX_EVENT_SIZE 260
#define HCI_CHG_BAUD_CMD_OCF 0x0C
#define HCI_VENDOR_CMD_OGF 0x3F
#define WRITE_BDADDR_CMD_LEN 14
#define WRITE_BAUD_CMD_LEN 6
#define MAX_CMD_LEN WRITE_BDADDR_CMD_LEN
#define GET_VERSION_OCF 0x1E
/* Byte order conversions */
#if __BYTE_ORDER == __LITTLE_ENDIAN
#define htobs(d) (d)
#define htobl(d) (d)
#define btohs(d) (d)
#define btohl(d) (d)
#elif __BYTE_ORDER == __BIG_ENDIAN
#define htobs(d) bswap_16(d)
#define htobl(d) bswap_32(d)
#define btohs(d) bswap_16(d)
#define btohl(d) bswap_32(d)
#else
#error "Unknown byte order"
#endif
#define FW_PATH "/system/etc/firmware/ar3k/"
#define STREAM_TO_UINT16(u16, p) \
{u16 = ((uint16_t)(*(p)) + (((uint16_t)(*((p) + 1))) << 8)); (p) += 2;}
#define UINT16_TO_STREAM(p, u16) \
{*(p)++ = (uint8_t)(u16); *(p)++ = (uint8_t)((u16) >> 8);}
#define UINT32_TO_STREAM(p, u32) \
{*(p)++ = (uint8_t)(u32); *(p)++ = (uint8_t)((u32) >> 8);\
*(p)++ = (uint8_t)((u32) >> 16); *(p)++ = (uint8_t)((u32) >> 24);}
#define MAX_TAGS 50
#define PS_HDR_LEN 4
#define HCI_VENDOR_CMD_OGF 0x3F
#define HCI_PS_CMD_OCF 0x0B
#define VERIFY_CRC 9
#define PS_REGION 1
#define PATCH_REGION 2
#define BDADDR_FILE "ar3kbdaddr.pst"
#define MAX_PATCH_CMD 244
struct patch_entry {
int16_t len;
uint8_t data[MAX_PATCH_CMD];
};
#define HCI_UART_RAW_DEVICE 0
#define HCI_COMMAND_HDR_SIZE 3
#define PS_WRITE 1
#define PS_RESET 2
#define WRITE_PATCH 8
#define ENABLE_PATCH 11
#define HCI_PS_CMD_HDR_LEN 7
#define HCI_CMD_MAX_LEN 258
#define PS_RESET_PARAM_LEN 6
#define PS_RESET_CMD_LEN (HCI_PS_CMD_HDR_LEN + PS_RESET_PARAM_LEN)
#define PS_ID_MASK 0xFF
#define LOCAL_NAME_BUFFER_LEN 32
#define DEV_REGISTER 0x4FFC
#define GET_DEV_TYPE_OCF 0x05
#define HCIDEVUP _IOW('H', 201, int)
#define OGF_VENDOR_CMD 0x3f
#define EVT_CMD_COMPLETE_SIZE 3
#define EVT_CMD_STATUS 0x0F
#define EVT_CMD_STATUS_SIZE 4
#define HCI_COMMAND_HDR_SIZE 3
#define HCI_EVENT_HDR_SIZE 2
#define HCI_EV_SUCCESS 0x00
/* HCI Socket options */
#define HCI_DATA_DIR 1
#define HCI_FILTER 2
#define HCI_TIME_STAMP 3
/* HCI CMSG flags */
#define HCI_CMSG_DIR 0x0001
#define HCI_CMSG_TSTAMP 0x0002
#ifndef VENDOR_LPM_PROC_NODE
#define VENDOR_LPM_PROC_NODE "/sys/module/hci_uart/parameters/ath_lpm"
#endif
/* proc fs node for notifying write request */
#ifndef VENDOR_BTWRITE_PROC_NODE
#define VENDOR_BTWRITE_PROC_NODE "/sys/module/hci_uart/parameters/ath_btwrite"
#endif
/******************************************************************************
** Local type definitions
******************************************************************************/
typedef struct {
uint8_t b[6];
} __attribute__((packed)) bdaddr_t;
struct sockaddr_hci {
sa_family_t hci_family;
unsigned short hci_dev;
unsigned short hci_channel;
};
struct tag_info {
unsigned section;
unsigned line_count;
unsigned char_cnt;
unsigned byte_count;
};
struct ps_cfg_entry {
uint32_t id;
uint32_t len;
uint8_t *data;
};
struct ps_entry_type {
unsigned char type;
unsigned char array;
};
struct uart_t {
char *type;
int m_id;
int p_id;
int proto;
int init_speed;
int speed;
int flags;
int pm;
char *bdaddr;
int (*init) (int fd, struct uart_t *u, struct termios *ti);
int (*post) (int fd, struct uart_t *u, struct termios *ti);
};
#endif /* HW_AR3K_H */

View file

@ -0,0 +1,290 @@
/*
* Copyright 2012 The Android Open Source Project
* Copyright (c) 2013, The Linux Foundation. All rights reserved.
* Not a Contribution.
*
* 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 HW_ROME_H
#define HW_ROME_H
/******************************************************************************
** Constants & Macros
******************************************************************************/
#define HCI_MAX_CMD_SIZE 260
#define HCI_MAX_EVENT_SIZE 260
#define PRINT_BUF_SIZE ((HCI_MAX_CMD_SIZE * 3) + 2)
#define HCI_CHG_BAUD_CMD_OCF 0x0C
#define HCI_VENDOR_CMD_OGF 0x3F
#define WRITE_BDADDR_CMD_LEN 14
#define WRITE_BAUD_CMD_LEN 6
#define MAX_CMD_LEN WRITE_BDADDR_CMD_LEN
#define GET_VERSION_OCF 0x1E
#define PS_HDR_LEN 4
#define HCI_VENDOR_CMD_OGF 0x3F
#define HCI_PS_CMD_OCF 0x0B
#define HCI_COMMAND_HDR_SIZE 3
#define EVT_CMD_COMPLETE_SIZE 3
#define EVT_CMD_STATUS 0x0F
#define EVT_CMD_STATUS_SIZE 4
#define HCI_EVENT_HDR_SIZE 2
#define HCI_EV_SUCCESS 0x00
/* HCI Socket options */
#define HCI_DATA_DIR 1
#define HCI_FILTER 2
#define HCI_TIME_STAMP 3
#define P_ID_OFFSET (0)
#define HCI_CMD_IND (1)
#define EVENTCODE_OFFSET (1)
#define EVT_PLEN (2)
#define PLEN (3)
#define CMD_RSP_OFFSET (3)
#define RSP_TYPE_OFFSET (4)
#define BAUDRATE_RSP_STATUS_OFFSET (4)
#define CMD_STATUS_OFFSET (5)
#define P_ROME_VER_OFFSET (4)
#define P_BUILD_VER_OFFSET (6)
#define P_BASE_ADDR_OFFSET (8)
#define P_ENTRY_ADDR_OFFSET (12)
#define P_LEN_OFFSET (16)
#define P_CRC_OFFSET (20)
#define P_CONTROL_OFFSET (24)
#define PATCH_HDR_LEN (28)
#define MAX_DATA_PER_SEGMENT (239)
#define VSEVENT_CODE (0xFF)
#define HC_VS_MAX_CMD_EVENT (0xFF)
#define PATCH_PROD_ID_OFFSET (5)
#define PATCH_PATCH_VER_OFFSET (9)
#define PATCH_ROM_BUILD_VER_OFFSET (11)
#define PATCH_SOC_VER_OFFSET (13)
#define MAX_SIZE_PER_TLV_SEGMENT (243)
/* VS Opcode */
#define HCI_PATCH_CMD_OCF (0)
#define EDL_SET_BAUDRATE_CMD_OCF (0x48)
#define EDL_WIPOWER_VS_CMD_OCF (0x1f)
#define HCI_VS_GET_ADDON_FEATURES_SUPPORT (0x1d)
/* VS Commands */
#define VSC_SET_BAUDRATE_REQ_LEN (1)
#define EDL_PATCH_CMD_LEN (1)
#define EDL_PATCH_CMD_REQ_LEN (1)
#define EDL_WIP_QUERY_CHARGING_STATUS_LEN (0x01)
#define EDL_WIP_START_HANDOFF_TO_HOST_LEN (0x01)
#define EDL_PATCH_DLD_REQ_CMD (0x01)
#define EDL_PATCH_RST_REQ_CMD (0x05)
#define EDL_PATCH_SET_REQ_CMD (0x16)
#define EDL_PATCH_ATCH_REQ_CMD (0x17)
#define EDL_PATCH_VER_REQ_CMD (0x19)
#define EDL_GET_BUILD_INFO (0x20)
#define EDL_PATCH_TLV_REQ_CMD (0x1E)
#define EDL_WIP_QUERY_CHARGING_STATUS_CMD (0x1D)
#define EDL_WIP_START_HANDOFF_TO_HOST_CMD (0x1E)
/* VS Event */
#define EDL_CMD_REQ_RES_EVT (0x00)
#define EDL_CMD_EXE_STATUS_EVT (0x00)
#define EDL_SET_BAUDRATE_RSP_EVT (0x92)
#define EDL_PATCH_VER_RES_EVT (0x19)
#define EDL_TVL_DNLD_RES_EVT (0x04)
#define EDL_APP_VER_RES_EVT (0x02)
#define EDL_WIP_QUERY_CHARGING_STATUS_EVT (0x18)
#define EDL_WIP_START_HANDOFF_TO_HOST_EVENT (0x19)
#define HCI_VS_GET_ADDON_FEATURES_EVENT (0x1B)
#define HCI_VS_GET_BUILD_VER_EVT (0x05)
#define HCI_VS_STRAY_EVT (0x17)
/* Status Codes of HCI CMD execution*/
#define HCI_CMD_SUCCESS (0x0)
#define PATCH_LEN_ERROR (0x1)
#define PATCH_VER_ERROR (0x2)
#define PATCH_CRC_ERROR (0x3)
#define PATCH_NOT_FOUND (0x4)
#define TLV_TYPE_ERROR (0x10)
#define NVM_ACCESS_CODE (0x0B)
#define BAUDRATE_CHANGE_SUCCESS (1)
/* Wipower status codes */
#define WIPOWER_IN_EMBEDDED_MODE 0x01
#define NON_WIPOWER_MODE 0x02
/* mask to validate support for wipower */
#define ADDON_FEATURES_EVT_WIPOWER_MASK (0x01)
/* TLV_TYPE */
#define TLV_TYPE_PATCH (1)
#define TLV_TYPE_NVM (2)
/* NVM */
#define MAX_TAG_CMD 30
#define TAG_END 0xFF
#define NVM_ACCESS_SET 0x01
#define TAG_NUM_OFFSET 5
#define TAG_NUM_2 2
#define TAG_BDADDR_OFFSET 7
/* NVM Tags specifically used for ROME 1.0 */
#define ROME_1_0_100022_1 0x101000221
#define ROME_1_0_100019 0x101000190
#define ROME_1_0_6002 0x100600200
/* Default NVM Version setting for ROME 1.0 */
#define NVM_VERSION ROME_1_0_100022_1
#define LSH(val, n) ((uint32_t)(val) << (n))
#define EXTRACT_BYTE(val, pos) (char) (((val) >> (8 * (pos))) & 0xFF)
#define CALC_SEG_SIZE(len, max) ((plen) % (max))?((plen/max)+1) : ((plen) / (max))
#define ROME_FW_PATH "/system/etc/firmware/rampatch.img"
#define ROME_RAMPATCH_TLV_PATH "/system/etc/firmware/rampatch_tlv.img"
#define ROME_NVM_TLV_PATH "/system/etc/firmware/nvm_tlv.bin"
#define ROME_RAMPATCH_TLV_1_0_3_PATH "/system/etc/firmware/rampatch_tlv_1.3.tlv"
#define ROME_NVM_TLV_1_0_3_PATH "/system/etc/firmware/nvm_tlv_1.3.bin"
#define ROME_RAMPATCH_TLV_2_0_1_PATH "/system/etc/firmware/rampatch_tlv_2.1.tlv"
#define ROME_NVM_TLV_2_0_1_PATH "/system/etc/firmware/nvm_tlv_2.1.bin"
#define ROME_RAMPATCH_TLV_3_0_0_PATH "/bt_firmware/image/btfw30.tlv"
#define ROME_NVM_TLV_3_0_0_PATH "/bt_firmware/image/btnv30.bin"
#define ROME_RAMPATCH_TLV_3_0_2_PATH "/bt_firmware/image/btfw32.tlv"
#define ROME_NVM_TLV_3_0_2_PATH "/bt_firmware/image/btnv32.bin"
#define ROME_3_1_FW_SU "bprm.cnss.3.1"
#define ROME_3_2_FW_SU "btfwp.cnss.3.2"
/* Rome 3.1 FW SU release has been branched from rome 3.0 SU 224
So, rome 3.1 formula is SU = patch version -(0xE0 = 224) - 0x111 -1
*/
#define ROME_3_1_FW_SW_OFFSET 0x01F2
/* Rome 3.2 FW SU formula is SU = patch version - 0x111 -1 */
#define ROME_3_2_FW_SW_OFFSET 0x0112
/* This header value in rampatch file decides event handling mechanism in the HOST */
#define ROME_SKIP_EVT_NONE 0x00
#define ROME_SKIP_EVT_VSE 0x01
#define ROME_SKIP_EVT_CC 0x02
#define ROME_SKIP_EVT_VSE_CC 0x03
/******************************************************************************
** Local type definitions
******************************************************************************/
typedef struct {
unsigned short rom_version;
unsigned short build_version;
} __attribute__ ((packed)) patch_version;
typedef struct {
unsigned int patch_id;
patch_version patch_ver;
unsigned int patch_base_addr;
unsigned int patch_entry_addr;
unsigned short patch_length;
int patch_crc;
unsigned short patch_ctrl;
} __attribute__ ((packed)) patch_info;
typedef struct {
unsigned int tlv_data_len;
unsigned int tlv_patch_data_len;
unsigned char sign_ver;
unsigned char sign_algorithm;
unsigned char dwnd_cfg;
unsigned char reserved1;
unsigned short prod_id;
unsigned short build_ver;
unsigned short patch_ver;
unsigned short reserved2;
unsigned int patch_entry_addr;
} __attribute__ ((packed)) tlv_patch_hdr;
typedef struct {
unsigned short tag_id;
unsigned short tag_len;
unsigned int tag_ptr;
unsigned int tag_ex_flag;
} __attribute__ ((packed)) tlv_nvm_hdr;
typedef struct {
unsigned char tlv_type;
unsigned char tlv_length1;
unsigned char tlv_length2;
unsigned char tlv_length3;
union{
tlv_patch_hdr patch;
tlv_nvm_hdr nvm;
}tlv;
} __attribute__ ((packed)) tlv_patch_info;
enum{
BAUDRATE_115200 = 0x00,
BAUDRATE_57600 = 0x01,
BAUDRATE_38400 = 0x02,
BAUDRATE_19200 = 0x03,
BAUDRATE_9600 = 0x04,
BAUDRATE_230400 = 0x05,
BAUDRATE_250000 = 0x06,
BAUDRATE_460800 = 0x07,
BAUDRATE_500000 = 0x08,
BAUDRATE_720000 = 0x09,
BAUDRATE_921600 = 0x0A,
BAUDRATE_1000000 = 0x0B,
BAUDRATE_1250000 = 0x0C,
BAUDRATE_2000000 = 0x0D,
BAUDRATE_3000000 = 0x0E,
BAUDRATE_4000000 = 0x0F,
BAUDRATE_1600000 = 0x10,
BAUDRATE_3200000 = 0x11,
BAUDRATE_3500000 = 0x12,
BAUDRATE_AUTO = 0xFE,
BAUDRATE_Reserved = 0xFF
};
enum{
ROME_PATCH_VER_0100 = 0x0100,
ROME_PATCH_VER_0101 = 0x0101,
ROME_PATCH_VER_0200 = 0x0200,
ROME_PATCH_VER_0300 = 0x0300,
ROME_PATCH_VER_0302 = 0x0302
};
enum{
ROME_SOC_ID_00 = 0x00000000,
ROME_SOC_ID_11 = 0x00000011,
ROME_SOC_ID_22 = 0x00000022,
ROME_SOC_ID_44 = 0x00000044
};
enum{
ROME_VER_UNKNOWN = 0,
ROME_VER_1_0 = ((ROME_PATCH_VER_0100 << 16 ) | ROME_SOC_ID_00 ),
ROME_VER_1_1 = ((ROME_PATCH_VER_0101 << 16 ) | ROME_SOC_ID_00 ),
ROME_VER_1_3 = ((ROME_PATCH_VER_0200 << 16 ) | ROME_SOC_ID_00 ),
ROME_VER_2_1 = ((ROME_PATCH_VER_0200 << 16 ) | ROME_SOC_ID_11 ),
ROME_VER_3_0 = ((ROME_PATCH_VER_0300 << 16 ) | ROME_SOC_ID_22 ),
ROME_VER_3_2 = ((ROME_PATCH_VER_0302 << 16 ) | ROME_SOC_ID_44 )
};
//declarations
int rome_soc_init(int fd, char *bdaddr);
int check_embedded_mode(int fd);
int rome_get_addon_feature_list(int fd);
void enable_controller_log(int fd, unsigned char req);
void cherokee_shutdown_vs_cmd(int fd);
#endif /* HW_ROME_H */

View file

@ -0,0 +1,9 @@
BLUETOOTH_UART_DEVICE_PORT = "/dev/ttyO1"
FW_PATCHFILE_LOCATION = "/vendor/firmware/"
BT_WAKE_VIA_USERIAL_IOCTL = TRUE
LPM_IDLE_TIMEOUT_MULTIPLE = 5
SCO_USE_I2S_INTERFACE = TRUE
BTVND_DBG = FALSE
BTHW_DBG = TRUE
VNDUSERIAL_DBG = FALSE
UPIO_DBG = FALSE

View file

@ -0,0 +1,9 @@
BLUETOOTH_UART_DEVICE_PORT = "/dev/smd3"
FW_PATCHFILE_LOCATION = "/vendor/firmware/"
BT_WAKE_VIA_USERIAL_IOCTL = TRUE
LPM_IDLE_TIMEOUT_MULTIPLE = 5
SCO_USE_I2S_INTERFACE = TRUE
BTVND_DBG = FALSE
BTHW_DBG = TRUE
VNDUSERIAL_DBG = FALSE
UPIO_DBG = FALSE

View file

@ -0,0 +1,91 @@
/*
* Copyright (c) 2013, The Linux Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
* EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "bt_vendor_persist.h"
#ifdef BT_NV_SUPPORT
#include "bt_nv.h"
#include <utils/Log.h>
/*===========================================================================
FUNCTION bt_vendor_nv_read
DESCRIPTION
Helper Routine to process the nv read command
DEPENDENCIES
NIL
RETURN VALUE
RETURN VALUE
FALSE = failure, else TRUE
SIDE EFFECTS
None
===========================================================================*/
uint8_t bt_vendor_nv_read
(
uint8_t nv_item,
uint8_t * rsp_buf
)
{
nv_persist_item_type my_nv_item;
nv_persist_stat_enum_type cmd_result;
boolean result = FALSE;
switch(nv_item)
{
case NV_BD_ADDR_I:
cmd_result = (nv_persist_stat_enum_type)bt_nv_cmd(NV_READ_F, NV_BD_ADDR_I, &my_nv_item);
ALOGI("CMD result: %d", cmd_result);
if (NV_SUCCESS != cmd_result)
{
ALOGE("Failed to read BD_ADDR from NV");
/* Send fail response */
result = FALSE;
}
else
{
/* copy bytes */
rsp_buf[0] = my_nv_item.bd_addr[0];
rsp_buf[1] = my_nv_item.bd_addr[1];
rsp_buf[2] = my_nv_item.bd_addr[2];
rsp_buf[3] = my_nv_item.bd_addr[3];
rsp_buf[4] = my_nv_item.bd_addr[4];
rsp_buf[5] = my_nv_item.bd_addr[5];
ALOGI("BD address read for NV_BD_ADDR_I: %.2x:%.2x:%.2x:%.2x:%.2x:%.2x",
(unsigned int) my_nv_item.bd_addr[0],(unsigned int) my_nv_item.bd_addr[1],
(unsigned int) my_nv_item.bd_addr[2],(unsigned int) my_nv_item.bd_addr[3],
(unsigned int) my_nv_item.bd_addr[4],(unsigned int) my_nv_item.bd_addr[5]);
result = TRUE;
}
break;
}
return result;
}
#endif /* End of BT_NV_SUPPORT */

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,194 @@
/*
* Copyright 2012 The Android Open Source Project
*
* 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: hardware.c
*
* Description: Contains controller-specific functions, like
* firmware patch download
* low power mode operations
*
******************************************************************************/
#define LOG_TAG "bt_vendor"
#include <utils/Log.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <signal.h>
#include <time.h>
#include <errno.h>
#include <fcntl.h>
#include <dirent.h>
#include <ctype.h>
#include <cutils/properties.h>
#include <stdlib.h>
#include "bt_hci_bdroid.h"
#include "bt_vendor_qcom.h"
#include <string.h>
#define MAX_CNT_RETRY 100
int hw_config(int nState)
{
char *szState[] = {"true", "false"};
char *szReqSt = NULL;
char szBtSocStatus[PROPERTY_VALUE_MAX] = {'\0', };
if(nState == BT_VND_PWR_OFF)
szReqSt = szState[1];
else
szReqSt = szState[0];
if((property_get("bluetooth.status", szBtSocStatus, "") <= 0))
{
if(nState == BT_VND_PWR_ON ) {
ALOGW("Hw_config: First Time BT on after boot.Starting hciattach daemon BTStatus=%s",szBtSocStatus);
if (property_set("bluetooth.hciattach", szReqSt) < 0)
{
ALOGE("Hw_config: Property Setting fail");
return -1;
}
}
} else if( !(strncmp(szBtSocStatus, "on", strlen("on")))) {
//BTSOC is already on
ALOGW("Hw_config: nState = %d", nState);
} else {
ALOGW("Hw_config: trigerring hciattach");
if (property_set("bluetooth.hciattach", szReqSt) < 0)
{
ALOGE("Hw_config: Property Setting fail");
return -1;
}
}
return 0;
}
int readTrpState()
{
char szBtStatus[PROPERTY_VALUE_MAX] = {0, };
if(property_get("bluetooth.status", szBtStatus, "") < 0){
ALOGE("Fail to get bluetooth status");
return FALSE;
}
if(!strncmp(szBtStatus, "on", strlen("on"))){
ALOGI("bluetooth status is on");
return TRUE;
}
return FALSE;
}
int is_hw_ready()
{
int i=0;
char szStatus[10] = {0,};
for(i=MAX_CNT_RETRY; i>0; i--){
//TODO :: checking routine
if(readTrpState()==TRUE){
break;
}
usleep(50*1000);
}
return (i==0)? FALSE:TRUE;
}
#if (HW_NEED_END_WITH_HCI_RESET == TRUE)
/*******************************************************************************
**
** Function hw_epilog_cback
**
** Description Callback function for Command Complete Events from HCI
** commands sent in epilog process.
**
** Returns None
**
*******************************************************************************/
void hw_epilog_cback(void *p_mem)
{
HC_BT_HDR *p_evt_buf = (HC_BT_HDR *) p_mem;
char *p_name, *p_tmp;
uint8_t *p, status;
uint16_t opcode;
status = *((uint8_t *)(p_evt_buf + 1) + HCI_EVT_CMD_CMPL_STATUS_RET_BYTE);
p = (uint8_t *)(p_evt_buf + 1) + HCI_EVT_CMD_CMPL_OPCODE;
STREAM_TO_UINT16(opcode,p);
ALOGI("%s Opcode:0x%04X Status: %d", __FUNCTION__, opcode, status);
#ifdef BT_THREADLOCK_SAFE
pthread_mutex_lock(&q_lock);
#endif
if (!q) {
ALOGE("hw_epilog_cback called with NULL context");
goto out;
}
/* Must free the RX event buffer */
q->cb->dealloc(p_evt_buf);
/* Once epilog process is done, must call callback to notify caller */
q->cb->epilog_cb(BT_VND_OP_RESULT_SUCCESS);
out:
#ifdef BT_THREADLOCK_SAFE
pthread_mutex_unlock(&q_lock);
#endif
return;
}
/*******************************************************************************
**
** Function hw_epilog_process
**
** Description Sample implementation of epilog process. This process is
** called with q_lock held and q->cb is assumed to be valid.
**
** Returns None
**
*******************************************************************************/
void __hw_epilog_process(void)
{
HC_BT_HDR *p_buf = NULL;
uint8_t *p;
ALOGI("hw_epilog_process");
/* Sending a HCI_RESET */
/* Must allocate command buffer via HC's alloc API */
p_buf = (HC_BT_HDR *) q->cb->alloc(BT_HC_HDR_SIZE + HCI_CMD_PREAMBLE_SIZE);
if (p_buf)
{
p_buf->event = MSG_STACK_TO_HC_HCI_CMD;
p_buf->offset = 0;
p_buf->layer_specific = 0;
p_buf->len = HCI_CMD_PREAMBLE_SIZE;
p = (uint8_t *) (p_buf + 1);
UINT16_TO_STREAM(p, HCI_RESET);
*p = 0; /* parameter length */
/* Send command via HC's xmit_cb API */
q->cb->xmit_cb(HCI_RESET, p_buf, hw_epilog_cback);
}
else
{
ALOGE("vendor lib epilog process aborted [no buffer]");
q->cb->epilog_cb(BT_VND_OP_RESULT_FAIL);
}
}
#endif // (HW_NEED_END_WITH_HCI_RESET == TRUE)

View file

@ -0,0 +1,161 @@
/*
* Copyright 2012 The Android Open Source Project
*
* 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: hci_smd.c
*
* Description: Contains vendor-specific userial functions
*
******************************************************************************/
#define LOG_TAG "bt_vendor"
#include <utils/Log.h>
#include <termios.h>
#include <fcntl.h>
#include <errno.h>
#include <stdio.h>
#include "bt_vendor_qcom.h"
#include "hci_smd.h"
#include <string.h>
#include <cutils/properties.h>
/*****************************************************************************
** Macros & Constants
*****************************************************************************/
#define NUM_OF_DEVS 2
static char *s_pszDevSmd[] = {
"/dev/smd3",
"/dev/smd2"
};
/******************************************************************************
** Externs
******************************************************************************/
extern int is_bt_ssr_hci;
/*****************************************************************************
** Functions
*****************************************************************************/
int bt_hci_init_transport_id (int chId )
{
struct termios term;
int fd = -1;
int retry = 0;
char ssrvalue[92]= {'\0'};
ssrvalue[0] = '0';
if(chId >= 2 || chId <0)
return -1;
fd = open(s_pszDevSmd[chId], (O_RDWR | O_NOCTTY));
while ((-1 == fd) && (retry < 7)) {
ALOGE("init_transport: Cannot open %s: %s\n. Retry after 2 seconds",
s_pszDevSmd[chId], strerror(errno));
usleep(2000000);
fd = open(s_pszDevSmd[chId], (O_RDWR | O_NOCTTY));
retry++;
}
if (-1 == fd)
{
ALOGE("init_transport: Cannot open %s: %s\n",
s_pszDevSmd[chId], strerror(errno));
return -1;
}
/* Sleep (0.5sec) added giving time for the smd port to be successfully
opened internally. Currently successful return from open doesn't
ensure the smd port is successfully opened.
TODO: Following sleep to be removed once SMD port is successfully
opened immediately on return from the aforementioned open call */
property_get("bluetooth.isSSR", ssrvalue, "");
if(ssrvalue[0] == '1')
{
/*reset the SSR flag */
if(chId == 1)
{
if(property_set("bluetooth.isSSR", "0") < 0)
{
ALOGE("SSR: hci_smd.c:SSR case : error in setting up property new\n ");
}
else
{
ALOGE("SSR: hci_smd.c:SSR case : Reset the SSr Flag new\n ");
}
}
ALOGE("hci_smd.c:IN SSR sleep for 500 msec New \n");
usleep(500000);
}
if (tcflush(fd, TCIOFLUSH) < 0)
{
ALOGE("init_uart: Cannot flush %s\n", s_pszDevSmd[chId]);
close(fd);
return -1;
}
if (tcgetattr(fd, &term) < 0)
{
ALOGE("init_uart: Error while getting attributes\n");
close(fd);
return -1;
}
cfmakeraw(&term);
/* JN: Do I need to make flow control configurable, since 4020 cannot
* disable it?
*/
term.c_cflag |= (CRTSCTS | CLOCAL);
if (tcsetattr(fd, TCSANOW, &term) < 0)
{
ALOGE("init_uart: Error while getting attributes\n");
close(fd);
return -1;
}
ALOGI("Done intiailizing UART\n");
return fd;
}
int bt_hci_init_transport(int *pFd)
{
int i = 0;
int fd;
for(i=0; i < NUM_OF_DEVS; i++){
fd = bt_hci_init_transport_id(i);
if(fd < 0 ){
return -1;
}
pFd[i] = fd;
}
return 0;
}
int bt_hci_deinit_transport(int *pFd)
{
close(pFd[0]);
close(pFd[1]);
return TRUE;
}

View file

@ -0,0 +1,526 @@
/*
* Copyright (c) 2013, The Linux Foundation. All rights reserved.
* Not a Contribution.
* Copyright 2012 The Android Open Source Project
*
* 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: userial_vendor.c
*
* Description: Contains vendor-specific userial functions
*
******************************************************************************/
#define LOG_TAG "bt_vendor"
#include <utils/Log.h>
#include <termios.h>
#include <fcntl.h>
#include <errno.h>
#include <stdio.h>
#include "bt_vendor_qcom.h"
#include "hci_uart.h"
#include <string.h>
/******************************************************************************
** Constants & Macros
******************************************************************************/
#ifndef VNDUSERIAL_DBG
#define VNDUSERIAL_DBG TRUE
#endif
#if (VNDUSERIAL_DBG == TRUE)
#define VNDUSERIALDBG(param, ...) {ALOGI(param, ## __VA_ARGS__);}
#else
#define VNDUSERIALDBG(param, ...) {}
#endif
#define RESERVED(p) if(p) ALOGI( "%s: reserved param", __FUNCTION__);
/******************************************************************************
** Global variables
******************************************************************************/
vnd_userial_cb_t vnd_userial;
/*****************************************************************************
** Functions
*****************************************************************************/
/*******************************************************************************
**
** Function userial_to_tcio_baud
**
** Description helper function converts USERIAL baud rates into TCIO
** conforming baud rates
**
** Returns TRUE/FALSE
**
*******************************************************************************/
uint8_t userial_to_tcio_baud(uint8_t cfg_baud, uint32_t *baud)
{
if (cfg_baud == USERIAL_BAUD_115200)
*baud = B115200;
else if (cfg_baud == USERIAL_BAUD_4M)
*baud = B4000000;
else if (cfg_baud == USERIAL_BAUD_3M)
*baud = B3000000;
else if (cfg_baud == USERIAL_BAUD_2M)
*baud = B2000000;
else if (cfg_baud == USERIAL_BAUD_1M)
*baud = B1000000;
else if (cfg_baud == USERIAL_BAUD_921600)
*baud = B921600;
else if (cfg_baud == USERIAL_BAUD_460800)
*baud = B460800;
else if (cfg_baud == USERIAL_BAUD_230400)
*baud = B230400;
else if (cfg_baud == USERIAL_BAUD_57600)
*baud = B57600;
else if (cfg_baud == USERIAL_BAUD_19200)
*baud = B19200;
else if (cfg_baud == USERIAL_BAUD_9600)
*baud = B9600;
else if (cfg_baud == USERIAL_BAUD_1200)
*baud = B1200;
else if (cfg_baud == USERIAL_BAUD_600)
*baud = B600;
else
{
ALOGE( "userial vendor open: unsupported baud idx %i", cfg_baud);
*baud = B115200;
return FALSE;
}
return TRUE;
}
/*******************************************************************************
**
** Function userial_to_baud_tcio
**
** Description helper function converts TCIO baud rate into integer
**
** Returns uint32_t
**
*******************************************************************************/
int userial_tcio_baud_to_int(uint32_t baud)
{
int baud_rate =0;
switch (baud)
{
case B600:
baud_rate = 600;
break;
case B1200:
baud_rate = 1200;
break;
case B9600:
baud_rate = 9600;
break;
case B19200:
baud_rate = 19200;
break;
case B57600:
baud_rate = 57600;
break;
case B115200:
baud_rate = 115200;
break;
case B230400:
baud_rate = 230400;
break;
case B460800:
baud_rate = 460800;
break;
case B921600:
baud_rate = 921600;
break;
case B1000000:
baud_rate = 1000000;
break;
case B2000000:
baud_rate = 2000000;
break;
case B3000000:
baud_rate = 3000000;
break;
case B4000000:
baud_rate = 4000000;
break;
default:
ALOGE( "%s: unsupported baud %d", __FUNCTION__, baud);
break;
}
ALOGI( "%s: Current Baudrate = %d bps", __FUNCTION__, baud_rate);
return baud_rate;
}
#if (BT_WAKE_VIA_USERIAL_IOCTL==TRUE)
/*******************************************************************************
**
** Function userial_ioctl_init_bt_wake
**
** Description helper function to set the open state of the bt_wake if ioctl
** is used. it should not hurt in the rfkill case but it might
** be better to compile it out.
**
** Returns none
**
*******************************************************************************/
void userial_ioctl_init_bt_wake(int fd)
{
uint32_t bt_wake_state;
/* assert BT_WAKE through ioctl */
ioctl(fd, USERIAL_IOCTL_BT_WAKE_ASSERT, NULL);
ioctl(fd, USERIAL_IOCTL_BT_WAKE_GET_ST, &bt_wake_state);
VNDUSERIALDBG("userial_ioctl_init_bt_wake read back BT_WAKE state=%i", \
bt_wake_state);
}
#endif // (BT_WAKE_VIA_USERIAL_IOCTL==TRUE)
/*****************************************************************************
** Userial Vendor API Functions
*****************************************************************************/
/*******************************************************************************
**
** Function userial_vendor_init
**
** Description Initialize userial vendor-specific control block
**
** Returns None
**
*******************************************************************************/
void userial_vendor_init(void)
{
vnd_userial.fd = -1;
snprintf(vnd_userial.port_name, VND_PORT_NAME_MAXLEN, "%s", BT_HS_UART_DEVICE);
}
/*******************************************************************************
**
** Function userial_vendor_open
**
** Description Open the serial port with the given configuration
**
** Returns device fd
**
*******************************************************************************/
int userial_vendor_open(tUSERIAL_CFG *p_cfg)
{
uint32_t baud;
uint8_t data_bits;
uint16_t parity;
uint8_t stop_bits;
vnd_userial.fd = -1;
if (!userial_to_tcio_baud(p_cfg->baud, &baud))
{
return -1;
}
if(p_cfg->fmt & USERIAL_DATABITS_8)
data_bits = CS8;
else if(p_cfg->fmt & USERIAL_DATABITS_7)
data_bits = CS7;
else if(p_cfg->fmt & USERIAL_DATABITS_6)
data_bits = CS6;
else if(p_cfg->fmt & USERIAL_DATABITS_5)
data_bits = CS5;
else
{
ALOGE("userial vendor open: unsupported data bits");
return -1;
}
if(p_cfg->fmt & USERIAL_PARITY_NONE)
parity = 0;
else if(p_cfg->fmt & USERIAL_PARITY_EVEN)
parity = PARENB;
else if(p_cfg->fmt & USERIAL_PARITY_ODD)
parity = (PARENB | PARODD);
else
{
ALOGE("userial vendor open: unsupported parity bit mode");
return -1;
}
if(p_cfg->fmt & USERIAL_STOPBITS_1)
stop_bits = 0;
else if(p_cfg->fmt & USERIAL_STOPBITS_2)
stop_bits = CSTOPB;
else
{
ALOGE("userial vendor open: unsupported stop bits");
return -1;
}
ALOGI("userial vendor open: opening %s", vnd_userial.port_name);
if ((vnd_userial.fd = open(vnd_userial.port_name, O_RDWR|O_NOCTTY)) == -1)
{
ALOGE("userial vendor open: unable to open %s: %s(%d)", vnd_userial.port_name,
strerror(errno), errno);
return -1;
}
tcflush(vnd_userial.fd, TCIOFLUSH);
tcgetattr(vnd_userial.fd, &vnd_userial.termios);
cfmakeraw(&vnd_userial.termios);
/* Set UART Control Modes */
vnd_userial.termios.c_cflag |= CLOCAL;
vnd_userial.termios.c_cflag |= (CRTSCTS | stop_bits);
tcsetattr(vnd_userial.fd, TCSANOW, &vnd_userial.termios);
/* set input/output baudrate */
cfsetospeed(&vnd_userial.termios, baud);
cfsetispeed(&vnd_userial.termios, baud);
tcsetattr(vnd_userial.fd, TCSANOW, &vnd_userial.termios);
tcflush(vnd_userial.fd, TCIOFLUSH);
#if (BT_WAKE_VIA_USERIAL_IOCTL==TRUE)
userial_ioctl_init_bt_wake(vnd_userial.fd);
#endif
ALOGI("device fd = %d open", vnd_userial.fd);
return vnd_userial.fd;
}
/*******************************************************************************
**
** Function userial_vendor_close
**
** Description Conduct vendor-specific close work
**
** Returns None
**
*******************************************************************************/
void userial_vendor_close(void)
{
int result;
if (vnd_userial.fd == -1)
return;
#if (BT_WAKE_VIA_USERIAL_IOCTL==TRUE)
/* de-assert bt_wake BEFORE closing port */
ioctl(vnd_userial.fd, USERIAL_IOCTL_BT_WAKE_DEASSERT, NULL);
#endif
ALOGI("device fd = %d close", vnd_userial.fd);
if ((result = close(vnd_userial.fd)) < 0)
ALOGE( "close(fd:%d) FAILED result:%d", vnd_userial.fd, result);
vnd_userial.fd = -1;
}
/*******************************************************************************
**
** Function userial_vendor_set_baud
**
** Description Set new baud rate
**
** Returns None
**
*******************************************************************************/
void userial_vendor_set_baud(uint8_t userial_baud)
{
uint32_t tcio_baud;
VNDUSERIALDBG("## userial_vendor_set_baud: %d", userial_baud);
userial_to_tcio_baud(userial_baud, &tcio_baud);
cfsetospeed(&vnd_userial.termios, tcio_baud);
cfsetispeed(&vnd_userial.termios, tcio_baud);
tcsetattr(vnd_userial.fd, TCSADRAIN, &vnd_userial.termios); /* don't change speed until last write done */
// tcflush(vnd_userial.fd, TCIOFLUSH);
}
/*******************************************************************************
**
** Function userial_vendor_get_baud
**
** Description Get current baud rate
**
** Returns int
**
*******************************************************************************/
int userial_vendor_get_baud(void)
{
if (vnd_userial.fd == -1)
{
ALOGE( "%s: uart port(%s) has not been opened", __FUNCTION__, BT_HS_UART_DEVICE );
return -1;
}
return userial_tcio_baud_to_int(cfgetispeed(&vnd_userial.termios));
}
/*******************************************************************************
**
** Function userial_vendor_ioctl
**
** Description ioctl inteface
**
** Returns None
**
*******************************************************************************/
int userial_vendor_ioctl(userial_vendor_ioctl_op_t op, int *p_data)
{
int err = -1;
switch(op)
{
#if (BT_WAKE_VIA_USERIAL_IOCTL==TRUE)
case USERIAL_OP_ASSERT_BT_WAKE:
VNDUSERIALDBG("## userial_vendor_ioctl: Asserting BT_Wake ##");
err = ioctl(vnd_userial.fd, USERIAL_IOCTL_BT_WAKE_ASSERT, NULL);
break;
case USERIAL_OP_DEASSERT_BT_WAKE:
VNDUSERIALDBG("## userial_vendor_ioctl: De-asserting BT_Wake ##");
err = ioctl(vnd_userial.fd, USERIAL_IOCTL_BT_WAKE_DEASSERT, NULL);
break;
case USERIAL_OP_GET_BT_WAKE_STATE:
err = ioctl(vnd_userial.fd, USERIAL_IOCTL_BT_WAKE_GET_ST, p_data);
break;
#endif // (BT_WAKE_VIA_USERIAL_IOCTL==TRUE)
case USERIAL_OP_FLOW_ON:
ALOGI("## userial_vendor_ioctl: UART Flow On ");
*p_data |=TIOCM_RTS;
err = ioctl(vnd_userial.fd, TIOCMSET, p_data);
break;
case USERIAL_OP_FLOW_OFF:
ALOGI("## userial_vendor_ioctl: UART Flow Off ");
ioctl(vnd_userial.fd, TIOCMGET, p_data);
*p_data &= ~TIOCM_RTS;
err = ioctl(vnd_userial.fd, TIOCMSET, p_data);
break;
default:
break;
}
return err;
}
/*******************************************************************************
**
** Function userial_set_port
**
** Description Configure UART port name
**
** Returns 0 : Success
** Otherwise : Fail
**
*******************************************************************************/
int userial_set_port(char *p_conf_name, char *p_conf_value, int param)
{
RESERVED(p_conf_name);
RESERVED(param);
strlcpy(vnd_userial.port_name, p_conf_value, VND_PORT_NAME_MAXLEN);
return 0;
}
/*******************************************************************************
**
** Function read_hci_event
**
** Description Read HCI event during vendor initialization
**
** Returns int: size to read
**
*******************************************************************************/
int read_hci_event(int fd, unsigned char* buf, int size)
{
int remain, r;
int count = 0;
if (size <= 0) {
ALOGE("Invalid size arguement!");
return -1;
}
ALOGI("%s: Wait for Command Compete Event from SOC", __FUNCTION__);
/* The first byte identifies the packet type. For HCI event packets, it
* should be 0x04, so we read until we get to the 0x04. */
while (1) {
r = read(fd, buf, 1);
if (r <= 0)
return -1;
if (buf[0] == 0x04)
break;
}
count++;
/* The next two bytes are the event code and parameter total length. */
while (count < 3) {
r = read(fd, buf + count, 3 - count);
if (r <= 0)
return -1;
count += r;
}
/* Now we read the parameters. */
if (buf[2] < (size - 3))
remain = buf[2];
else
remain = size - 3;
while ((count - 3) < remain) {
r = read(fd, buf + count, remain - (count - 3));
if (r <= 0)
return -1;
count += r;
}
return count;
}
int userial_clock_operation(int fd, int cmd)
{
int ret = 0;
switch (cmd)
{
case USERIAL_OP_CLK_ON:
case USERIAL_OP_CLK_OFF:
ioctl(fd, cmd);
break;
case USERIAL_OP_CLK_STATE:
ret = ioctl(fd, cmd);
break;
}
return ret;
}

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,32 @@
#
# Copyright 2012 The Android Open Source Project
#
# 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.
#
intermediates := $(local-intermediates-dir)
SRC := $(call my-dir)/include/$(addprefix vnd_, $(addsuffix .txt,$(basename $(TARGET_DEVICE))))
ifeq (,$(wildcard $(SRC)))
# configuration file does not exist. Use default one
SRC := $(call my-dir)/include/vnd_generic.txt
endif
GEN := $(intermediates)/vnd_buildcfg.h
TOOL := $(TOP_DIR)external/bluetooth/bluedroid/tools/gen-buildcfg.sh
$(GEN): PRIVATE_PATH := $(call my-dir)
$(GEN): PRIVATE_CUSTOM_TOOL = $(TOOL) $< $@
$(GEN): $(SRC) $(TOOL)
$(transform-generated-source)
LOCAL_GENERATED_SOURCES += $(GEN)