[Mod] 增加lunch支持

This commit is contained in:
2023-06-04 14:36:45 +00:00
parent 26dd495427
commit 6307e9a3b0
1662 changed files with 190495 additions and 0 deletions

View File

@ -0,0 +1,49 @@
# 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
# ************************************************

View File

@ -0,0 +1,51 @@
LOCAL_PATH := $(call my-dir)
ifeq ($(strip $(BOARD_HAVE_BLUETOOTH_BCM)), true)
include $(CLEAR_VARS)
BDROID_DIR := $(TOP_DIR)external/bluetooth/bluedroid
LOCAL_SRC_FILES := \
src/bt_vendor_brcm.c \
src/hardware.c \
src/userial_vendor.c \
src/upio.c \
src/conf.c
LOCAL_C_INCLUDES += \
$(LOCAL_PATH)/include \
$(BDROID_DIR)/hci/include
LOCAL_SHARED_LIBRARIES := \
libcutils \
liblog \
libhardware_legacy
LOCAL_MODULE := libbt-vendor
LOCAL_MODULE_TAGS := optional
LOCAL_MODULE_CLASS := SHARED_LIBRARIES
LOCAL_MODULE_OWNER := broadcom
LOCAL_PROPRIETARY_MODULE := true
include $(LOCAL_PATH)/vnd_buildcfg.mk
include $(BUILD_SHARED_LIBRARY)
ifeq ($(TARGET_PRODUCT), full_maguro)
include $(LOCAL_PATH)/conf/samsung/maguro/Android.mk
endif
ifeq ($(TARGET_PRODUCT), full_crespo)
include $(LOCAL_PATH)/conf/samsung/crespo/Android.mk
endif
ifeq ($(TARGET_PRODUCT), full_crespo4g)
include $(LOCAL_PATH)/conf/samsung/crespo4g/Android.mk
endif
ifeq ($(TARGET_PRODUCT), full_wingray)
include $(LOCAL_PATH)/conf/moto/wingray/Android.mk
endif
#ifeq ($(strip $(TARGET_PRODUCT)), rk30sdk)
include $(LOCAL_PATH)/conf/rockchip/rk30sdk/Android.mk
#endif
endif # BOARD_HAVE_BLUETOOTH_BCM

View File

@ -0,0 +1,14 @@
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := bt_vendor.conf
LOCAL_MODULE_CLASS := ETC
LOCAL_MODULE_PATH := $(TARGET_OUT)/etc/bluetooth
LOCAL_MODULE_TAGS := eng
LOCAL_SRC_FILES := $(LOCAL_MODULE)
include $(BUILD_PREBUILT)

View File

@ -0,0 +1,5 @@
# UART device port where Bluetooth controller is attached
UartPort = /dev/ttyHS2
# Firmware patch file location
FwPatchFilePath = /etc/firmware/

View File

@ -0,0 +1,14 @@
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := bt_vendor.conf
LOCAL_MODULE_CLASS := ETC
LOCAL_MODULE_PATH := $(TARGET_OUT)/etc/bluetooth
LOCAL_MODULE_TAGS := eng
LOCAL_SRC_FILES := $(LOCAL_MODULE)
include $(BUILD_PREBUILT)

View File

@ -0,0 +1,5 @@
# UART device port where Bluetooth controller is attached
UartPort = /dev/ttyHS2
# Firmware patch file location
FwPatchFilePath = /etc/firmware/

View File

@ -0,0 +1,14 @@
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := bt_vendor.conf
LOCAL_MODULE_CLASS := ETC
LOCAL_MODULE_PATH := $(TARGET_OUT)/etc/bluetooth
LOCAL_MODULE_TAGS := optional
LOCAL_SRC_FILES := $(LOCAL_MODULE)
include $(BUILD_PREBUILT)

View File

@ -0,0 +1,5 @@
# UART device port where Bluetooth controller is attached
UartPort = /dev/ttyS0
# Firmware patch file location
FwPatchFilePath = /vendor/firmware/

View File

@ -0,0 +1,14 @@
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := bt_vendor.conf
LOCAL_MODULE_CLASS := ETC
LOCAL_MODULE_PATH := $(TARGET_OUT)/etc/bluetooth
LOCAL_MODULE_TAGS := eng
LOCAL_SRC_FILES := $(LOCAL_MODULE)
include $(BUILD_PREBUILT)

View File

@ -0,0 +1,5 @@
# UART device port where Bluetooth controller is attached
UartPort = /dev/s3c2410_serial0
# Firmware patch file location
FwPatchFilePath = /vendor/firmware/

View File

@ -0,0 +1,14 @@
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := bt_vendor.conf
LOCAL_MODULE_CLASS := ETC
LOCAL_MODULE_PATH := $(TARGET_OUT)/etc/bluetooth
LOCAL_MODULE_TAGS := eng
LOCAL_SRC_FILES := $(LOCAL_MODULE)
include $(BUILD_PREBUILT)

View File

@ -0,0 +1,5 @@
# UART device port where Bluetooth controller is attached
UartPort = /dev/s3c2410_serial0
# Firmware patch file location
FwPatchFilePath = /vendor/firmware/

View File

@ -0,0 +1,14 @@
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := bt_vendor.conf
LOCAL_MODULE_CLASS := ETC
LOCAL_MODULE_PATH := $(TARGET_OUT)/etc/bluetooth
LOCAL_MODULE_TAGS := eng
LOCAL_SRC_FILES := $(LOCAL_MODULE)
include $(BUILD_PREBUILT)

View File

@ -0,0 +1,5 @@
# UART device port where Bluetooth controller is attached
UartPort = /dev/ttyO1
# Firmware patch file location
FwPatchFilePath = /vendor/firmware/

View File

@ -0,0 +1,430 @@
/******************************************************************************
*
* 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: bt_vendor_brcm.h
*
* Description: A wrapper header file of bt_vendor_lib.h
*
* Contains definitions specific for interfacing with Broadcom
* Bluetooth chipsets
*
******************************************************************************/
#ifndef BT_VENDOR_BRCM_H
#define BT_VENDOR_BRCM_H
#include "bt_vendor_lib.h"
#include "vnd_buildcfg.h"
/******************************************************************************
** Constants & Macros
******************************************************************************/
#ifndef FALSE
#define FALSE 0
#endif
#ifndef TRUE
#define TRUE (!FALSE)
#endif
#ifndef VENDOR_LIB_RUNTIME_TUNING_ENABLED
#define VENDOR_LIB_RUNTIME_TUNING_ENABLED FALSE
#endif
/* Run-time configuration file */
#ifndef VENDOR_LIB_CONF_FILE
#define VENDOR_LIB_CONF_FILE "/etc/bluetooth/bt_vendor.conf"
#endif
/* Device port name where Bluetooth controller attached */
#ifndef BLUETOOTH_UART_DEVICE_PORT
#define BLUETOOTH_UART_DEVICE_PORT "/dev/ttyO1" /* maguro */
#endif
/* Location of firmware patch files */
#ifndef FW_PATCHFILE_LOCATION
#define FW_PATCHFILE_LOCATION "/vendor/firmware/" /* maguro */
#endif
#ifndef UART_TARGET_BAUD_RATE
#define UART_TARGET_BAUD_RATE 3000000
#endif
/* The millisecond delay pauses on HCI transport after firmware patches
* were downloaded. This gives some time for firmware to restart with
* patches before host attempts to send down any HCI commands.
*
* Note: It has been discovered that BCM43241B0 needs at least 200ms
* settlement delay in here. Without the delay, a Hardware Error event
* from BCM43241B0 had been seen in HCI upstream path right after the
* host sent the HCI_VSC_SET_BDADDR commad to the controller at higher
* baud.
*/
#ifndef FW_PATCH_SETTLEMENT_DELAY_MS
#define FW_PATCH_SETTLEMENT_DELAY_MS 0
#endif
/* The Bluetooth Device Aaddress source switch:
*
* -FALSE- (default value)
* Get the factory BDADDR from device's file system. Normally the BDADDR is
* stored in the location pointed by the PROPERTY_BT_BDADDR_PATH (defined in
* btif_common.h file) property.
*
* -TRUE-
* If the Bluetooth Controller has equipped with a non-volatile memory (such
* as BCM4330's OTP memory), the factory BDADDR can be stored in there and
* retrieved by the stack while enabling BT.
* !!! WARNING !!! Make sure that the OTP feature has been enabled in the
* firmware patchram (.hcd) file.
*/
#ifndef USE_CONTROLLER_BDADDR
#define USE_CONTROLLER_BDADDR FALSE
#endif
/* sleep mode
0: disable
1: UART with Host wake/BT wake out of band signals
*/
#ifndef LPM_SLEEP_MODE
#define LPM_SLEEP_MODE 1
#endif
/* Host Stack Idle Threshold in 300ms or 25ms
In sleep mode 1, this is the number of firmware loops executed with no
activity before the Host wake line is deasserted. Activity includes HCI
traffic excluding certain sleep mode commands and the presence of SCO
connections if the "Allow Host Sleep During SCO" flag is not set to 1.
Each count of this parameter is roughly equivalent to 300ms or 25ms.
*/
#ifndef LPM_IDLE_THRESHOLD
#define LPM_IDLE_THRESHOLD 1
#endif
/* Host Controller Idle Threshold in 300ms or 25ms
This is the number of firmware loops executed with no activity before the
HC is considered idle. Depending on the mode, HC may then attempt to sleep.
Activity includes HCI traffic excluding certain sleep mode commands and
the presence of ACL/SCO connections.
*/
#ifndef LPM_HC_IDLE_THRESHOLD
#define LPM_HC_IDLE_THRESHOLD 1
#endif
/* BT_WAKE Polarity - 0=Active Low, 1= Active High */
#ifndef LPM_BT_WAKE_POLARITY
#define LPM_BT_WAKE_POLARITY 1 /* maguro */
#endif
/* HOST_WAKE Polarity - 0=Active Low, 1= Active High */
#ifndef LPM_HOST_WAKE_POLARITY
#define LPM_HOST_WAKE_POLARITY 1 /* maguro */
#endif
/* LPM_ALLOW_HOST_SLEEP_DURING_SCO
When this flag is set to 0, the host is not allowed to sleep while
an SCO is active. In sleep mode 1, the device will keep the host
wake line asserted while an SCO is active.
When this flag is set to 1, the host can sleep while an SCO is active.
This flag should only be set to 1 if SCO traffic is directed to the PCM
interface.
*/
#ifndef LPM_ALLOW_HOST_SLEEP_DURING_SCO
#define LPM_ALLOW_HOST_SLEEP_DURING_SCO 1
#endif
/* LPM_COMBINE_SLEEP_MODE_AND_LPM
In Mode 0, always set byte 7 to 0. In sleep mode 1, device always
requires permission to sleep between scans / periodic inquiries regardless
of the setting of this byte. In sleep mode 1, if byte is set, device must
have "permission" to sleep during the low power modes of sniff, hold, and
park. If byte is not set, device can sleep without permission during these
modes. Permission to sleep in Mode 1 is obtained if the BT_WAKE signal is
not asserted.
*/
#ifndef LPM_COMBINE_SLEEP_MODE_AND_LPM
#define LPM_COMBINE_SLEEP_MODE_AND_LPM 1
#endif
/* LPM_ENABLE_UART_TXD_TRI_STATE
When set to 0, the device will not tristate its UART TX line before going
to sleep.
When set to 1, the device will tristate its UART TX line before going to
sleep.
*/
#ifndef LPM_ENABLE_UART_TXD_TRI_STATE
#define LPM_ENABLE_UART_TXD_TRI_STATE 0
#endif
/* LPM_PULSED_HOST_WAKE
*/
#ifndef LPM_PULSED_HOST_WAKE
#define LPM_PULSED_HOST_WAKE 0
#endif
/* LPM_IDLE_TIMEOUT_MULTIPLE
The multiple factor of host stack idle threshold in 300ms/25ms
*/
#ifndef LPM_IDLE_TIMEOUT_MULTIPLE
#define LPM_IDLE_TIMEOUT_MULTIPLE 10
#endif
/* BT_WAKE_VIA_USERIAL_IOCTL
Use userial ioctl function to control BT_WAKE signal
*/
#ifndef BT_WAKE_VIA_USERIAL_IOCTL
#define BT_WAKE_VIA_USERIAL_IOCTL FALSE
#endif
/* BT_WAKE_USERIAL_LDISC
Use line discipline if the BT_WAKE control is in line discipline
*/
#ifndef BT_WAKE_USERIAL_LDISC
#define BT_WAKE_USERIAL_LDISC FALSE
#endif
/* BT_WAKE_VIA_PROC
LPM & BT_WAKE control through PROC nodes
*/
#ifndef BT_WAKE_VIA_PROC
#define BT_WAKE_VIA_PROC FALSE
#endif
#ifndef BT_WAKE_VIA_PROC_NOTIFY_DEASSERT
#define BT_WAKE_VIA_PROC_NOTIFY_DEASSERT FALSE
#endif
/* N_BRCM_HCI
UART ioctl line discipline
*/
#ifndef N_BRCM_HCI
#define N_BRCM_HCI 25
#endif
/* SCO_CFG_INCLUDED
Do SCO configuration by default. If the firmware patch had been embedded
with desired SCO configuration, set this FALSE to bypass configuration
from host software.
*/
#ifndef SCO_CFG_INCLUDED
#define SCO_CFG_INCLUDED TRUE
#endif
#ifndef SCO_USE_I2S_INTERFACE
#define SCO_USE_I2S_INTERFACE FALSE
#endif
#define SCO_I2SPCM_PARAM_SIZE 4
/* SCO_WBS_SAMPLE_RATE
0 : 8K
1 : 16K
2 : 4K
This macro is used for setting WBS sampling rate for a SCO connection
If the mobile network supports WBS, we need to use 16KHz as default
but if the platform doesn't support 16KHz, the sample rate can be
overriden to 8KHz by setting this to 0.
*/
#ifndef SCO_WBS_SAMPLE_RATE
#define SCO_WBS_SAMPLE_RATE 1
#endif
/* SCO_I2SPCM_IF_MODE - 0=Disable, 1=Enable */
#ifndef SCO_I2SPCM_IF_MODE
#define SCO_I2SPCM_IF_MODE 1
#endif
/* SCO_I2SPCM_IF_ROLE - 0=Slave, 1=Master */
#ifndef SCO_I2SPCM_IF_ROLE
#define SCO_I2SPCM_IF_ROLE 1
#endif
/* SCO_I2SPCM_IF_SAMPLE_RATE
0 : 8K
1 : 16K
2 : 4K
*/
#ifndef SCO_I2SPCM_IF_SAMPLE_RATE
#define SCO_I2SPCM_IF_SAMPLE_RATE 0
#endif
/* SCO_I2SPCM_IF_CLOCK_RATE
0 : 128K
1 : 256K
2 : 512K
3 : 1024K
4 : 2048K
*/
#ifndef SCO_I2SPCM_IF_CLOCK_RATE
#define SCO_I2SPCM_IF_CLOCK_RATE 1
#endif
/* SCO_I2SPCM_IF_CLOCK_RATE4WBS
0 : 128K
1 : 256K
2 : 512K
3 : 1024K
4 : 2048K
*/
#ifndef SCO_I2SPCM_IF_CLOCK_RATE4WBS
#define SCO_I2SPCM_IF_CLOCK_RATE4WBS 2
#endif
#define SCO_PCM_PARAM_SIZE 5
/* SCO_PCM_ROUTING
0 : PCM
1 : Transport
2 : Codec
3 : I2S
*/
#ifndef SCO_PCM_ROUTING
#define SCO_PCM_ROUTING 0
#endif
/* SCO_PCM_IF_CLOCK_RATE
NOTICE: suggested to be consistent with SCO_I2SPCM_IF_CLOCK_RATE
0 : 128K
1 : 256K
2 : 512K
3 : 1024K
4 : 2048K
*/
#ifndef SCO_PCM_IF_CLOCK_RATE
#define SCO_PCM_IF_CLOCK_RATE 4
#endif
/* SCO_PCM_IF_FRAME_TYPE - 0=Short, 1=Long */
#ifndef SCO_PCM_IF_FRAME_TYPE
#define SCO_PCM_IF_FRAME_TYPE 0
#endif
/* SCO_PCM_IF_SYNC_MODE
NOTICE: in most usage cases the value will be the same as
SCO_PCM_IF_CLOCK_MODE setting
0 : Slave
1 : Master
*/
#ifndef SCO_PCM_IF_SYNC_MODE
#define SCO_PCM_IF_SYNC_MODE 0
#endif
/* SCO_PCM_IF_CLOCK_MODE
NOTICE: suggested to be consistent with SCO_I2SPCM_IF_ROLE
0 : Slave
1 : Master
*/
#ifndef SCO_PCM_IF_CLOCK_MODE
#define SCO_PCM_IF_CLOCK_MODE 0
#endif
#define PCM_DATA_FORMAT_PARAM_SIZE 5
/* PCM_DATA_FMT_SHIFT_MODE
0 : MSB first
1 : LSB first
*/
#ifndef PCM_DATA_FMT_SHIFT_MODE
#define PCM_DATA_FMT_SHIFT_MODE 0
#endif
/* PCM_DATA_FMT_FILL_BITS
Specifies the value with which to fill unused bits
if Fill_Method is set to programmable
*/
#ifndef PCM_DATA_FMT_FILL_BITS
#define PCM_DATA_FMT_FILL_BITS 0
#endif
/* PCM_DATA_FMT_FILL_METHOD
0 : 0's
1 : 1's
2 : Signed
3 : Programmable
*/
#ifndef PCM_DATA_FMT_FILL_METHOD
#define PCM_DATA_FMT_FILL_METHOD 3
#endif
/* PCM_DATA_FMT_FILL_NUM
Specifies the number of bits to be filled
*/
#ifndef PCM_DATA_FMT_FILL_NUM
#define PCM_DATA_FMT_FILL_NUM 3
#endif
/* PCM_DATA_FMT_JUSTIFY_MODE
0 : Left justify (fill data shifted out last)
1 : Right justify (fill data shifted out first)
*/
#ifndef PCM_DATA_FMT_JUSTIFY_MODE
#define PCM_DATA_FMT_JUSTIFY_MODE 0
#endif
/* HW_END_WITH_HCI_RESET
Sample 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.
*/
#ifndef HW_END_WITH_HCI_RESET
#define HW_END_WITH_HCI_RESET TRUE
#endif
/******************************************************************************
** Extern variables and functions
******************************************************************************/
extern bt_vendor_callbacks_t *bt_vendor_cbacks;
extern int hw_set_audio_state(bt_vendor_op_audio_state_t *p_state);
#endif /* BT_VENDOR_BRCM_H */

View File

@ -0,0 +1,107 @@
/******************************************************************************
*
* 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: upio.h
*
* Description: Contains definitions used for I/O controls
*
******************************************************************************/
#ifndef UPIO_H
#define UPIO_H
/******************************************************************************
** Constants & Macros
******************************************************************************/
#define UPIO_BT_POWER_OFF 0
#define UPIO_BT_POWER_ON 1
/* 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
};
/******************************************************************************
** Extern variables and functions
******************************************************************************/
/******************************************************************************
** Functions
******************************************************************************/
/*******************************************************************************
**
** Function upio_init
**
** Description Initialization
**
** Returns None
**
*******************************************************************************/
void upio_init(void);
/*******************************************************************************
**
** Function upio_cleanup
**
** Description Clean up
**
** Returns None
**
*******************************************************************************/
void upio_cleanup(void);
/*******************************************************************************
**
** Function upio_set_bluetooth_power
**
** Description Interact with low layer driver to set Bluetooth power
** on/off.
**
** Returns 0 : SUCCESS or Not-Applicable
** <0 : ERROR
**
*******************************************************************************/
int upio_set_bluetooth_power(int on);
/*******************************************************************************
**
** Function upio_set
**
** Description Set i/o based on polarity
**
** Returns None
**
*******************************************************************************/
void upio_set(uint8_t pio, uint8_t action, uint8_t polarity);
#endif /* UPIO_H */

View File

@ -0,0 +1,175 @@
/******************************************************************************
*
* 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: userial_vendor.h
*
* Description: Contains vendor-specific definitions used in serial port
* controls
*
******************************************************************************/
#ifndef USERIAL_VENDOR_H
#define USERIAL_VENDOR_H
#include "bt_vendor_brcm.h"
#include "userial.h"
/******************************************************************************
** Constants & Macros
******************************************************************************/
/**** 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)
#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)
/******************************************************************************
** 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_NOP,
} userial_vendor_ioctl_op_t;
/******************************************************************************
** Extern variables and functions
******************************************************************************/
/******************************************************************************
** Functions
******************************************************************************/
/*******************************************************************************
**
** 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 None
**
*******************************************************************************/
void userial_vendor_ioctl(userial_vendor_ioctl_op_t op, void *p_data);
#endif /* USERIAL_VENDOR_H */

View File

@ -0,0 +1,10 @@
BLUETOOTH_UART_DEVICE_PORT = "/dev/ttyHS0"
FW_PATCHFILE_LOCATION = "/system/etc/firmware/bt"
UART_TARGET_BAUD_RATE = 3000000
LPM_IDLE_TIMEOUT_MULTIPLE = 5
BTVND_DBG = FALSE
BTHW_DBG = FALSE
VNDUSERIAL_DBG = FALSE
UPIO_DBG = FALSE
BT_WAKE_VIA_PROC = TRUE
PROC_BTWRITE_TIMER_TIMEOUT_MS = 2000

View File

@ -0,0 +1,8 @@
BLUETOOTH_UART_DEVICE_PORT = "/dev/s3c2410_serial0"
FW_PATCHFILE_LOCATION = "/vendor/firmware/"
LPM_IDLE_TIMEOUT_MULTIPLE = 5
SCO_PCM_IF_CLOCK_RATE = 0
BTVND_DBG = FALSE
BTHW_DBG = TRUE
VNDUSERIAL_DBG = FALSE
UPIO_DBG = FALSE

View File

@ -0,0 +1,8 @@
BLUETOOTH_UART_DEVICE_PORT = "/dev/s3c2410_serial0"
FW_PATCHFILE_LOCATION = "/vendor/firmware/"
LPM_IDLE_TIMEOUT_MULTIPLE = 5
SCO_PCM_IF_CLOCK_RATE = 0
BTVND_DBG = FALSE
BTHW_DBG = TRUE
VNDUSERIAL_DBG = FALSE
UPIO_DBG = FALSE

View File

@ -0,0 +1,14 @@
BLUETOOTH_UART_DEVICE_PORT = "/dev/ttyHS99"
FW_PATCHFILE_LOCATION = "/vendor/firmware/"
BT_WAKE_VIA_PROC = TRUE
UART_TARGET_BAUD_RATE = 3000000
LPM_IDLE_TIMEOUT_MULTIPLE = 5
LPM_BT_WAKE_POLARITY = 0
LPM_HOST_WAKE_POLARITY = 0
PROC_BTWRITE_TIMER_TIMEOUT_MS = 0
SCO_USE_I2S_INTERFACE = FALSE
SCO_I2SPCM_IF_ROLE = 0
BTVND_DBG = FALSE
BTHW_DBG = TRUE
VNDUSERIAL_DBG = FALSE
UPIO_DBG = FALSE

View File

@ -0,0 +1,10 @@
VENDOR_BTWRITE_PROC_NODE = "/proc/bluetooth/sleep/lpm"
LPM_IDLE_TIMEOUT_MULTIPLE = 5
SCO_USE_I2S_INTERFACE = FALSE
SCO_PCM_IF_CLOCK_RATE = 3
BTVND_DBG = FALSE
BTHW_DBG = TRUE
VNDUSERIAL_DBG = FALSE
BT_WAKE_VIA_PROC_NOTIFY_DEASSERT = TRUE
BT_WAKE_VIA_PROC = TRUE
UPIO_DBG = FALSE

View File

@ -0,0 +1,10 @@
VENDOR_BTWRITE_PROC_NODE = "/proc/bluetooth/sleep/lpm"
LPM_IDLE_TIMEOUT_MULTIPLE = 5
SCO_USE_I2S_INTERFACE = FALSE
SCO_PCM_IF_CLOCK_RATE = 3
BTVND_DBG = FALSE
BTHW_DBG = TRUE
VNDUSERIAL_DBG = FALSE
BT_WAKE_VIA_PROC_NOTIFY_DEASSERT = TRUE
BT_WAKE_VIA_PROC = TRUE
UPIO_DBG = FALSE

View File

@ -0,0 +1,10 @@
VENDOR_BTWRITE_PROC_NODE = "/proc/bluetooth/sleep/lpm"
LPM_IDLE_TIMEOUT_MULTIPLE = 5
SCO_USE_I2S_INTERFACE = FALSE
SCO_PCM_IF_CLOCK_RATE = 3
BTVND_DBG = FALSE
BTHW_DBG = TRUE
VNDUSERIAL_DBG = FALSE
BT_WAKE_VIA_PROC_NOTIFY_DEASSERT = TRUE
BT_WAKE_VIA_PROC = TRUE
UPIO_DBG = FALSE

View File

@ -0,0 +1,11 @@
BLUETOOTH_UART_DEVICE_PORT = "/dev/ttyMFD0"
FW_PATCHFILE_LOCATION = "/vendor/firmware/"
BT_WAKE_VIA_PROC = FALSE
BT_WAKE_VIA_USERIAL_IOCTL = FALSE
LPM_IDLE_TIMEOUT_MULTIPLE = 5
BTVND_DBG = FALSE
BTHW_DBG = TRUE
VNDUSERIAL_DBG = FALSE
UPIO_DBG = FALSE
SCO_PCM_IF_CLOCK_RATE = 2
USE_CONTROLLER_BDADDR = FALSE

View File

@ -0,0 +1,8 @@
BLUETOOTH_UART_DEVICE_PORT = "/dev/ttyO1"
FW_PATCHFILE_LOCATION = "/vendor/firmware/"
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,8 @@
BLUETOOTH_UART_DEVICE_PORT = "/dev/ttyO1"
FW_PATCHFILE_LOCATION = "/vendor/firmware/"
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,10 @@
BLUETOOTH_UART_DEVICE_PORT = "/dev/ttyHS2"
FW_PATCHFILE_LOCATION = "/etc/firmware/"
BT_WAKE_VIA_PROC = TRUE
LPM_IDLE_TIMEOUT_MULTIPLE = 5
BTVND_DBG = FALSE
BTHW_DBG = TRUE
VNDUSERIAL_DBG = FALSE
UPIO_DBG = FALSE
SCO_PCM_IF_CLOCK_RATE = 2
USE_CONTROLLER_BDADDR = TRUE

View File

@ -0,0 +1,15 @@
BLUETOOTH_UART_DEVICE_PORT = "/dev/ttyHS99"
FW_PATCHFILE_LOCATION = "/vendor/firmware/"
BT_WAKE_VIA_PROC = TRUE
PROC_BTWRITE_TIMER_TIMEOUT_MS = 4000
UART_TARGET_BAUD_RATE = 4000000
LPM_IDLE_TIMEOUT_MULTIPLE = 5
LPM_BT_WAKE_POLARITY = 0
LPM_HOST_WAKE_POLARITY = 0
SCO_USE_I2S_INTERFACE = FALSE
SCO_WBS_SAMPLE_RATE = 0
SCO_I2SPCM_IF_ROLE = 0
BTVND_DBG = FALSE
BTHW_DBG = TRUE
VNDUSERIAL_DBG = FALSE
UPIO_DBG = FALSE

View File

@ -0,0 +1,16 @@
BLUETOOTH_UART_DEVICE_PORT = "/dev/ttyHS99"
FW_PATCHFILE_LOCATION = "/vendor/firmware/"
BT_WAKE_VIA_PROC = TRUE
UART_TARGET_BAUD_RATE = 3000000
LPM_IDLE_TIMEOUT_MULTIPLE = 5
LPM_BT_WAKE_POLARITY = 0
LPM_HOST_WAKE_POLARITY = 0
LPM_IDLE_THRESHOLD = 10
LPM_HC_IDLE_THRESHOLD = 10
PROC_BTWRITE_TIMER_TIMEOUT_MS = 0
SCO_USE_I2S_INTERFACE = FALSE
SCO_I2SPCM_IF_ROLE = 0
BTVND_DBG = FALSE
BTHW_DBG = TRUE
VNDUSERIAL_DBG = FALSE
UPIO_DBG = FALSE

View File

@ -0,0 +1,8 @@
BLUETOOTH_UART_DEVICE_PORT = "/dev/ttyO1"
FW_PATCHFILE_LOCATION = "/vendor/firmware/"
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,8 @@
BLUETOOTH_UART_DEVICE_PORT = "/dev/ttyO1"
FW_PATCHFILE_LOCATION = "/vendor/firmware/"
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,10 @@
BLUETOOTH_UART_DEVICE_PORT = "/dev/ttySAC0"
FW_PATCHFILE_LOCATION = "/vendor/firmware/"
UART_TARGET_BAUD_RATE = 921600
LPM_IDLE_TIMEOUT_MULTIPLE = 5
SCO_USE_I2S_INTERFACE = TRUE
SCO_I2SPCM_IF_ROLE = 0
BTVND_DBG = FALSE
BTHW_DBG = TRUE
VNDUSERIAL_DBG = FALSE
UPIO_DBG = FALSE

View File

@ -0,0 +1,8 @@
BLUETOOTH_UART_DEVICE_PORT = "/dev/ttyO1"
FW_PATCHFILE_LOCATION = "/vendor/firmware/"
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,19 @@
BLUETOOTH_UART_DEVICE_PORT = "/dev/ttyS0"
FW_PATCHFILE_LOCATION = "/vendor/firmware/"
UART_TARGET_BAUD_RATE = 1500000
LPM_IDLE_TIMEOUT_MULTIPLE = 5
BTVND_DBG = FALSE
BTHW_DBG = TRUE
VNDUSERIAL_DBG = FALSE
UPIO_DBG = FALSE
BT_WAKE_VIA_PROC = TRUE
SCO_PCM_ROUTING = 0
SCO_PCM_IF_CLOCK_RATE = 1
SCO_PCM_IF_FRAME_TYPE = 0
SCO_PCM_IF_SYNC_MODE = 1
SCO_PCM_IF_CLOCK_MODE = 1
PCM_DATA_FMT_SHIFT_MODE = 0
PCM_DATA_FMT_FILL_BITS = 0
PCM_DATA_FMT_FILL_METHOD = 0
PCM_DATA_FMT_FILL_NUM = 0
PCM_DATA_FMT_JUSTIFY_MODE = 0

View File

@ -0,0 +1,14 @@
BLUETOOTH_UART_DEVICE_PORT = "/dev/ttyHS0"
FW_PATCHFILE_LOCATION = "/vendor/firmware/"
BT_WAKE_VIA_PROC = TRUE
PROC_BTWRITE_TIMER_TIMEOUT_MS = 4000
UART_TARGET_BAUD_RATE = 3000000
LPM_IDLE_TIMEOUT_MULTIPLE = 5
LPM_BT_WAKE_POLARITY = 0
LPM_HOST_WAKE_POLARITY = 0
SCO_USE_I2S_INTERFACE = FALSE
SCO_I2SPCM_IF_ROLE = 0
BTVND_DBG = FALSE
BTHW_DBG = TRUE
VNDUSERIAL_DBG = FALSE
UPIO_DBG = FALSE

View File

@ -0,0 +1,21 @@
BLUETOOTH_UART_DEVICE_PORT = "/dev/ttyHS0"
FW_PATCHFILE_LOCATION = "/vendor/firmware/"
UART_TARGET_BAUD_RATE = 3000000
LPM_IDLE_TIMEOUT_MULTIPLE = 5
SCO_USE_I2S_INTERFACE = FALSE
SCO_I2SPCM_IF_MODE = 0
SCO_I2SPCM_IF_ROLE = 0
SCO_I2SPCM_IF_SAMPLE_RATE = 0
SCO_I2SPCM_IF_CLOCK_RATE = 4
SCO_I2SPCM_IF_CLOCK_RATE4WBS = 4
SCO_PCM_ROUTING = 0
SCO_PCM_IF_CLOCK_RATE = 4
SCO_PCM_IF_FRAME_TYPE = 0
SCO_PCM_IF_SYNC_MODE = 0
SCO_PCM_IF_CLOCK_MODE = 0
BTVND_DBG = FALSE
BTHW_DBG = FALSE
VNDUSERIAL_DBG = FALSE
UPIO_DBG = FALSE
BT_WAKE_VIA_PROC = TRUE
PROC_BTWRITE_TIMER_TIMEOUT_MS = 700

View File

@ -0,0 +1,8 @@
BLUETOOTH_UART_DEVICE_PORT = "/dev/ttyHS2"
FW_PATCHFILE_LOCATION = "/etc/firmware/"
LPM_IDLE_TIMEOUT_MULTIPLE = 5
BTVND_DBG = FALSE
BTHW_DBG = TRUE
VNDUSERIAL_DBG = FALSE
UPIO_DBG = FALSE
SCO_PCM_IF_CLOCK_RATE = 2

View File

@ -0,0 +1,15 @@
BT_WAKE_VIA_USERIAL_IOCTL = TRUE
BT_WAKE_USERIAL_LDISC = TRUE
LPM_BT_WAKE_POLARITY = 0
LPM_HOST_WAKE_POLARITY = 0
LPM_IDLE_TIMEOUT_MULTIPLE = 5
LPM_IDLE_THRESHOLD = 2
LPM_HC_IDLE_THRESHOLD = 2
SCO_I2SPCM_IF_ROLE = 0
SCO_I2SPCM_IF_CLOCK_RATE = 0
SCO_PCM_IF_CLOCK_RATE = 0
SCO_I2SPCM_IF_CLOCK_RATE4WBS = 1
BTVND_DBG = FALSE
BTHW_DBG = FALSE
VNDUSERIAL_DBG = FALSE
UPIO_DBG = FALSE

View File

@ -0,0 +1,10 @@
BLUETOOTH_UART_DEVICE_PORT = "/dev/ttyHS2"
FW_PATCHFILE_LOCATION = "/etc/firmware/"
BT_WAKE_VIA_PROC = TRUE
LPM_IDLE_TIMEOUT_MULTIPLE = 5
BTVND_DBG = FALSE
BTHW_DBG = TRUE
VNDUSERIAL_DBG = FALSE
UPIO_DBG = FALSE
SCO_PCM_IF_CLOCK_RATE = 2
USE_CONTROLLER_BDADDR = TRUE

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/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,8 @@
BLUETOOTH_UART_DEVICE_PORT = "/dev/ttyHS2"
FW_PATCHFILE_LOCATION = "/etc/firmware/"
LPM_IDLE_TIMEOUT_MULTIPLE = 5
BTVND_DBG = FALSE
BTHW_DBG = TRUE
VNDUSERIAL_DBG = FALSE
UPIO_DBG = FALSE
SCO_PCM_IF_CLOCK_RATE = 2

View File

@ -0,0 +1,265 @@
/******************************************************************************
*
* 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: bt_vendor_brcm.c
*
* Description: Broadcom vendor specific library implementation
*
******************************************************************************/
#define LOG_TAG "bt_vendor"
#include <utils/Log.h>
#include "bt_vendor_brcm.h"
#include "upio.h"
#include "userial_vendor.h"
#ifndef BTVND_DBG
#define BTVND_DBG FALSE
#endif
#if (BTVND_DBG == TRUE)
#define BTVNDDBG(param, ...) {ALOGD(param, ## __VA_ARGS__);}
#else
#define BTVNDDBG(param, ...) {}
#endif
/******************************************************************************
** Externs
******************************************************************************/
void hw_config_start(void);
uint8_t hw_lpm_enable(uint8_t turn_on);
uint32_t hw_lpm_get_idle_timeout(void);
void hw_lpm_set_wake_state(uint8_t wake_assert);
#if (SCO_CFG_INCLUDED == TRUE)
void hw_pcm2_config(void);
void hw_sco_config(void);
#endif
void vnd_load_conf(const char *p_path);
#if (HW_END_WITH_HCI_RESET == TRUE)
void hw_epilog_process(void);
#endif
int is2076();
/******************************************************************************
** Variables
******************************************************************************/
bt_vendor_callbacks_t *bt_vendor_cbacks = NULL;
uint8_t vnd_local_bd_addr[6]={0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
/******************************************************************************
** Local type definitions
******************************************************************************/
/******************************************************************************
** Static Variables
******************************************************************************/
static const tUSERIAL_CFG userial_init_cfg =
{
(USERIAL_DATABITS_8 | USERIAL_PARITY_NONE | USERIAL_STOPBITS_1),
USERIAL_BAUD_115200
};
/******************************************************************************
** Functions
******************************************************************************/
/*****************************************************************************
**
** BLUETOOTH VENDOR INTERFACE LIBRARY FUNCTIONS
**
*****************************************************************************/
static int init(const bt_vendor_callbacks_t* p_cb, unsigned char *local_bdaddr)
{
ALOGI("init");
if (p_cb == NULL)
{
ALOGE("init failed with no user callbacks!");
return -1;
}
#if (VENDOR_LIB_RUNTIME_TUNING_ENABLED == TRUE)
ALOGW("*****************************************************************");
ALOGW("*****************************************************************");
ALOGW("** Warning - BT Vendor Lib is loaded in debug tuning mode!");
ALOGW("**");
ALOGW("** If this is not intentional, rebuild libbt-vendor.so ");
ALOGW("** with VENDOR_LIB_RUNTIME_TUNING_ENABLED=FALSE and ");
ALOGW("** check if any run-time tuning parameters needed to be");
ALOGW("** carried to the build-time configuration accordingly.");
ALOGW("*****************************************************************");
ALOGW("*****************************************************************");
#endif
userial_vendor_init();
upio_init();
vnd_load_conf(VENDOR_LIB_CONF_FILE);
/* store reference to user callbacks */
bt_vendor_cbacks = (bt_vendor_callbacks_t *) p_cb;
/* This is handed over from the stack */
memcpy(vnd_local_bd_addr, local_bdaddr, 6);
return 0;
}
/** Requested operations */
static int op(bt_vendor_opcode_t opcode, void *param)
{
int retval = 0;
BTVNDDBG("op for %d", opcode);
switch(opcode)
{
case BT_VND_OP_POWER_CTRL:
{
int *state = (int *) param;
if (*state == BT_VND_PWR_OFF)
upio_set_bluetooth_power(UPIO_BT_POWER_OFF);
else if (*state == BT_VND_PWR_ON)
{
upio_set_bluetooth_power(UPIO_BT_POWER_ON);
BTVNDDBG("Delay for a while after BT power on");
usleep(200000);
}
}
break;
case BT_VND_OP_FW_CFG:
{
hw_config_start();
}
break;
case BT_VND_OP_SCO_CFG:
{
#if (SCO_CFG_INCLUDED == TRUE)
if (is2076())
{
ALOGD("PCM2 Settings for AP6476(BCM2076)");
hw_pcm2_config();
}
else
{
ALOGD("SCO config");
hw_sco_config();
}
#else
retval = -1;
#endif
}
break;
case BT_VND_OP_USERIAL_OPEN:
{
int (*fd_array)[] = (int (*)[]) param;
int fd, idx;
fd = userial_vendor_open((tUSERIAL_CFG *) &userial_init_cfg);
if (fd != -1)
{
for (idx=0; idx < CH_MAX; idx++)
(*fd_array)[idx] = fd;
retval = 1;
}
/* retval contains numbers of open fd of HCI channels */
}
break;
case BT_VND_OP_USERIAL_CLOSE:
{
userial_vendor_close();
}
break;
case BT_VND_OP_GET_LPM_IDLE_TIMEOUT:
{
uint32_t *timeout_ms = (uint32_t *) param;
*timeout_ms = hw_lpm_get_idle_timeout();
}
break;
case BT_VND_OP_LPM_SET_MODE:
{
uint8_t *mode = (uint8_t *) param;
retval = hw_lpm_enable(*mode);
}
break;
case BT_VND_OP_LPM_WAKE_SET_STATE:
{
uint8_t *state = (uint8_t *) param;
uint8_t wake_assert = (*state == BT_VND_LPM_WAKE_ASSERT) ? \
TRUE : FALSE;
hw_lpm_set_wake_state(wake_assert);
}
break;
case BT_VND_OP_SET_AUDIO_STATE:
{
retval = hw_set_audio_state((bt_vendor_op_audio_state_t *)param);
}
break;
case BT_VND_OP_EPILOG:
{
#if (HW_END_WITH_HCI_RESET == FALSE)
if (bt_vendor_cbacks)
{
bt_vendor_cbacks->epilog_cb(BT_VND_OP_RESULT_SUCCESS);
}
#else
hw_epilog_process();
#endif
}
break;
}
return retval;
}
/** Closes the interface */
static void cleanup( void )
{
BTVNDDBG("cleanup");
upio_cleanup();
bt_vendor_cbacks = NULL;
}
// Entry point of DLib
const bt_vendor_interface_t BLUETOOTH_VENDOR_LIB_INTERFACE = {
sizeof(bt_vendor_interface_t),
init,
op,
cleanup
};

View File

@ -0,0 +1,148 @@
/******************************************************************************
*
* 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: conf.c
*
* Description: Contains functions to conduct run-time module configuration
* based on entries present in the .conf file
*
******************************************************************************/
#define LOG_TAG "bt_vnd_conf"
#include <utils/Log.h>
#include <string.h>
#include "bt_vendor_brcm.h"
/******************************************************************************
** Externs
******************************************************************************/
int userial_set_port(char *p_conf_name, char *p_conf_value, int param);
int hw_set_patch_file_path(char *p_conf_name, char *p_conf_value, int param);
int hw_set_patch_file_name(char *p_conf_name, char *p_conf_value, int param);
#if (VENDOR_LIB_RUNTIME_TUNING_ENABLED == TRUE)
int hw_set_patch_settlement_delay(char *p_conf_name, char *p_conf_value, int param);
#endif
int get_pcm2_settings(char *p_conf_name, char *p_conf_value, int param);
/******************************************************************************
** Local type definitions
******************************************************************************/
#define CONF_COMMENT '#'
#define CONF_DELIMITERS " =\n\r\t"
#define CONF_VALUES_DELIMITERS "=\n\r\t"
#define CONF_MAX_LINE_LEN 255
typedef int (conf_action_t)(char *p_conf_name, char *p_conf_value, int param);
typedef struct {
const char *conf_entry;
conf_action_t *p_action;
int param;
} conf_entry_t;
/******************************************************************************
** Static variables
******************************************************************************/
/*
* Current supported entries and corresponding action functions
*/
static const conf_entry_t conf_table[] = {
{"UartPort", userial_set_port, 0},
{"FwPatchFilePath", hw_set_patch_file_path, 0},
{"FwPatchFileName", hw_set_patch_file_name, 0},
#if (VENDOR_LIB_RUNTIME_TUNING_ENABLED == TRUE)
{"FwPatchSettlementDelay", hw_set_patch_settlement_delay, 0},
#endif
{"AP6476_PCM2_Setup", get_pcm2_settings, 0 },
{(const char *) NULL, NULL, 0}
};
/*****************************************************************************
** CONF INTERFACE FUNCTIONS
*****************************************************************************/
/*******************************************************************************
**
** Function vnd_load_conf
**
** Description Read conf entry from p_path file one by one and call
** the corresponding config function
**
** Returns None
**
*******************************************************************************/
void vnd_load_conf(const char *p_path)
{
FILE *p_file;
char *p_name;
char *p_value;
conf_entry_t *p_entry;
char line[CONF_MAX_LINE_LEN+1]; /* add 1 for \0 char */
ALOGI("Attempt to load conf from %s", p_path);
if ((p_file = fopen(p_path, "r")) != NULL)
{
/* read line by line */
while (fgets(line, CONF_MAX_LINE_LEN+1, p_file) != NULL)
{
if (line[0] == CONF_COMMENT)
continue;
p_name = strtok(line, CONF_DELIMITERS);
if (NULL == p_name)
{
continue;
}
p_value = strtok(NULL, CONF_DELIMITERS);
if (NULL == p_value)
{
ALOGW("vnd_load_conf: missing value for name: %s", p_name);
continue;
}
p_entry = (conf_entry_t *)conf_table;
while (p_entry->conf_entry != NULL)
{
if (strcmp(p_entry->conf_entry, (const char *)p_name) == 0)
{
p_entry->p_action(p_name, p_value, p_entry->param);
break;
}
p_entry++;
}
}
fclose(p_file);
}
else
{
ALOGI( "vnd_load_conf file >%s< not found", p_path);
}
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,537 @@
/******************************************************************************
*
* 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: upio.c
*
* Description: Contains I/O functions, like
* rfkill control
* BT_WAKE/HOST_WAKE control
*
******************************************************************************/
#define LOG_TAG "bt_upio"
#include <utils/Log.h>
#include <fcntl.h>
#include <errno.h>
#include <cutils/properties.h>
#include "bt_vendor_brcm.h"
#include "upio.h"
#include "userial_vendor.h"
/******************************************************************************
** Constants & Macros
******************************************************************************/
#ifndef UPIO_DBG
#define UPIO_DBG FALSE
#endif
#if (UPIO_DBG == TRUE)
#define UPIODBG(param, ...) {ALOGD(param, ## __VA_ARGS__);}
#else
#define UPIODBG(param, ...) {}
#endif
/******************************************************************************
** Local type definitions
******************************************************************************/
#if (BT_WAKE_VIA_PROC == TRUE)
/* proc fs node for enable/disable lpm mode */
#ifndef VENDOR_LPM_PROC_NODE
#define VENDOR_LPM_PROC_NODE "/proc/bluetooth/sleep/lpm"
#endif
/* proc fs node for notifying write request */
#ifndef VENDOR_BTWRITE_PROC_NODE
#define VENDOR_BTWRITE_PROC_NODE "/proc/bluetooth/sleep/btwrite"
#endif
/*
* Maximum btwrite assertion holding time without consecutive btwrite kicking.
* This value is correlative(shorter) to the in-activity timeout period set in
* the bluesleep LPM code. The current value used in bluesleep is 10sec.
*/
#ifndef PROC_BTWRITE_TIMER_TIMEOUT_MS
#define PROC_BTWRITE_TIMER_TIMEOUT_MS 8000
#endif
/* lpm proc control block */
typedef struct
{
uint8_t btwrite_active;
uint8_t timer_created;
timer_t timer_id;
uint32_t timeout_ms;
} vnd_lpm_proc_cb_t;
static vnd_lpm_proc_cb_t lpm_proc_cb;
#endif
/******************************************************************************
** Static variables
******************************************************************************/
static uint8_t upio_state[UPIO_MAX_COUNT];
static int rfkill_id = -1;
static int bt_emul_enable = 0;
static char *rfkill_state_path = NULL;
/******************************************************************************
** Static functions
******************************************************************************/
/* for friendly debugging outpout string */
static char *lpm_mode[] = {
"UNKNOWN",
"disabled",
"enabled"
};
static char *lpm_state[] = {
"UNKNOWN",
"de-asserted",
"asserted"
};
/*****************************************************************************
** Bluetooth On/Off Static Functions
*****************************************************************************/
static int is_emulator_context(void)
{
char value[PROPERTY_VALUE_MAX];
property_get("ro.kernel.qemu", value, "0");
UPIODBG("is_emulator_context : %s", value);
if (strcmp(value, "1") == 0) {
return 1;
}
return 0;
}
static int is_rfkill_disabled(void)
{
char value[PROPERTY_VALUE_MAX];
property_get("ro.rfkilldisabled", value, "0");
UPIODBG("is_rfkill_disabled ? [%s]", value);
if (strcmp(value, "1") == 0) {
return UPIO_BT_POWER_ON;
}
return UPIO_BT_POWER_OFF;
}
static int init_rfkill()
{
char path[64];
char buf[16];
int fd, sz, id;
if (is_rfkill_disabled())
return -1;
for (id = 0; ; id++)
{
snprintf(path, sizeof(path), "/sys/class/rfkill/rfkill%d/type", id);
fd = open(path, O_RDONLY);
if (fd < 0)
{
ALOGE("init_rfkill : open(%s) failed: %s (%d)\n", \
path, strerror(errno), errno);
return -1;
}
sz = read(fd, &buf, sizeof(buf));
close(fd);
if (sz >= 9 && memcmp(buf, "bluetooth", 9) == 0)
{
rfkill_id = id;
break;
}
}
asprintf(&rfkill_state_path, "/sys/class/rfkill/rfkill%d/state", rfkill_id);
return 0;
}
// cmy@20121128: get bt module name from rfkill
int bt_get_chipname(char* name, int len)
{
int ret = -1;
int fd = -1;
int sz = 0;
char* rfkill_name_path = NULL;
if (rfkill_id == -1) {
if (init_rfkill()) goto out;
}
asprintf(&rfkill_name_path, "/sys/class/rfkill/rfkill%d/name", rfkill_id);
fd = open(rfkill_name_path, O_RDONLY);
if (fd < 0) {
ALOGE("open(%s) failed: %s (%d)", rfkill_name_path, strerror(errno),
errno);
goto out;
}
sz = read(fd, name, len);
if (sz <= 0) {
ALOGE("read(%s) failed: %s (%d)", rfkill_name_path, strerror(errno),
errno);
goto out;
}
name[sz] = '\0';
if (name[sz-1]=='\n')
name[sz-1] = '\0';
ret = 0;
out:
if (fd >= 0) close(fd);
return ret;
}
/*****************************************************************************
** LPM Static Functions
*****************************************************************************/
#if (BT_WAKE_VIA_PROC == TRUE)
/*******************************************************************************
**
** Function proc_btwrite_timeout
**
** Description Timeout thread of proc/.../btwrite assertion holding timer
**
** Returns None
**
*******************************************************************************/
static void proc_btwrite_timeout(union sigval arg)
{
UPIODBG("..%s..", __FUNCTION__);
lpm_proc_cb.btwrite_active = FALSE;
}
#endif
/*****************************************************************************
** UPIO Interface Functions
*****************************************************************************/
/*******************************************************************************
**
** Function upio_init
**
** Description Initialization
**
** Returns None
**
*******************************************************************************/
void upio_init(void)
{
memset(upio_state, UPIO_UNKNOWN, UPIO_MAX_COUNT);
#if (BT_WAKE_VIA_PROC == TRUE)
memset(&lpm_proc_cb, 0, sizeof(vnd_lpm_proc_cb_t));
#endif
}
/*******************************************************************************
**
** Function upio_cleanup
**
** Description Clean up
**
** Returns None
**
*******************************************************************************/
void upio_cleanup(void)
{
#if (BT_WAKE_VIA_PROC == TRUE)
if (lpm_proc_cb.timer_created == TRUE)
timer_delete(lpm_proc_cb.timer_id);
lpm_proc_cb.timer_created = FALSE;
#endif
}
/*******************************************************************************
**
** Function upio_set_bluetooth_power
**
** Description Interact with low layer driver to set Bluetooth power
** on/off.
**
** Returns 0 : SUCCESS or Not-Applicable
** <0 : ERROR
**
*******************************************************************************/
int upio_set_bluetooth_power(int on)
{
int sz;
int fd = -1;
int ret = -1;
char buffer = '0';
switch(on)
{
case UPIO_BT_POWER_OFF:
buffer = '0';
break;
case UPIO_BT_POWER_ON:
buffer = '1';
break;
}
if (is_emulator_context())
{
/* if new value is same as current, return -1 */
if (bt_emul_enable == on)
return ret;
UPIODBG("set_bluetooth_power [emul] %d", on);
bt_emul_enable = on;
return 0;
}
/* check if we have rfkill interface */
if (is_rfkill_disabled())
return 0;
if (rfkill_id == -1)
{
if (init_rfkill())
return ret;
}
fd = open(rfkill_state_path, O_WRONLY);
if (fd < 0)
{
ALOGE("set_bluetooth_power : open(%s) for write failed: %s (%d)",
rfkill_state_path, strerror(errno), errno);
return ret;
}
sz = write(fd, &buffer, 1);
if (sz < 0) {
ALOGE("set_bluetooth_power : write(%s) failed: %s (%d)",
rfkill_state_path, strerror(errno),errno);
}
else {
ret = 0;
ALOGD("Delay 500ms for bluetooth power up");
usleep(500*1000);
}
if (fd >= 0)
close(fd);
return ret;
}
/*******************************************************************************
**
** Function upio_set
**
** Description Set i/o based on polarity
**
** Returns None
**
*******************************************************************************/
void upio_set(uint8_t pio, uint8_t action, uint8_t polarity)
{
int rc;
#if (BT_WAKE_VIA_PROC == TRUE)
int fd = -1;
char buffer;
#endif
switch (pio)
{
case UPIO_LPM_MODE:
if (upio_state[UPIO_LPM_MODE] == action)
{
UPIODBG("LPM is %s already", lpm_mode[action]);
return;
}
upio_state[UPIO_LPM_MODE] = action;
#if (BT_WAKE_VIA_PROC == TRUE)
fd = open(VENDOR_LPM_PROC_NODE, O_WRONLY);
if (fd < 0)
{
ALOGE("upio_set : open(%s) for write failed: %s (%d)",
VENDOR_LPM_PROC_NODE, strerror(errno), errno);
return;
}
if (action == UPIO_ASSERT)
{
buffer = '1';
}
else
{
buffer = '0';
// delete btwrite assertion holding timer
if (lpm_proc_cb.timer_created == TRUE)
{
timer_delete(lpm_proc_cb.timer_id);
lpm_proc_cb.timer_created = FALSE;
}
}
if (write(fd, &buffer, 1) < 0)
{
ALOGE("upio_set : write(%s) failed: %s (%d)",
VENDOR_LPM_PROC_NODE, strerror(errno),errno);
}
#if (PROC_BTWRITE_TIMER_TIMEOUT_MS != 0)
else
{
if (action == UPIO_ASSERT)
{
// create btwrite assertion holding timer
if (lpm_proc_cb.timer_created == FALSE)
{
int status;
struct sigevent se;
se.sigev_notify = SIGEV_THREAD;
se.sigev_value.sival_ptr = &lpm_proc_cb.timer_id;
se.sigev_notify_function = proc_btwrite_timeout;
se.sigev_notify_attributes = NULL;
status = timer_create(CLOCK_MONOTONIC, &se,
&lpm_proc_cb.timer_id);
if (status == 0)
lpm_proc_cb.timer_created = TRUE;
}
}
}
#endif
if (fd >= 0)
close(fd);
#endif
break;
case UPIO_BT_WAKE:
if (upio_state[UPIO_BT_WAKE] == action)
{
UPIODBG("BT_WAKE is %s already", lpm_state[action]);
#if (BT_WAKE_VIA_PROC == TRUE)
if (lpm_proc_cb.btwrite_active == TRUE)
/*
* The proc btwrite node could have not been updated for
* certain time already due to heavy downstream path flow.
* In this case, we want to explicity touch proc btwrite
* node to keep the bt_wake assertion in the LPM kernel
* driver. The current kernel bluesleep LPM code starts
* a 10sec internal in-activity timeout timer before it
* attempts to deassert BT_WAKE line.
*/
#endif
return;
}
upio_state[UPIO_BT_WAKE] = action;
#if (BT_WAKE_VIA_USERIAL_IOCTL == TRUE)
userial_vendor_ioctl( ( (action==UPIO_ASSERT) ? \
USERIAL_OP_ASSERT_BT_WAKE : USERIAL_OP_DEASSERT_BT_WAKE),\
NULL);
#elif (BT_WAKE_VIA_PROC == TRUE)
/*
* Kick proc btwrite node only at UPIO_ASSERT
*/
#if (BT_WAKE_VIA_PROC_NOTIFY_DEASSERT == FALSE)
if (action == UPIO_DEASSERT)
return;
#endif
fd = open(VENDOR_BTWRITE_PROC_NODE, O_WRONLY);
if (fd < 0)
{
ALOGE("upio_set : open(%s) for write failed: %s (%d)",
VENDOR_BTWRITE_PROC_NODE, strerror(errno), errno);
return;
}
#if (BT_WAKE_VIA_PROC_NOTIFY_DEASSERT == TRUE)
if (action == UPIO_DEASSERT)
buffer = '0';
else
#endif
buffer = '1';
if (write(fd, &buffer, 1) < 0)
{
ALOGE("upio_set : write(%s) failed: %s (%d)",
VENDOR_BTWRITE_PROC_NODE, strerror(errno),errno);
}
#if (PROC_BTWRITE_TIMER_TIMEOUT_MS != 0)
else
{
lpm_proc_cb.btwrite_active = TRUE;
if (lpm_proc_cb.timer_created == TRUE)
{
struct itimerspec ts;
ts.it_value.tv_sec = PROC_BTWRITE_TIMER_TIMEOUT_MS/1000;
ts.it_value.tv_nsec = 1000000*(PROC_BTWRITE_TIMER_TIMEOUT_MS%1000);
ts.it_interval.tv_sec = 0;
ts.it_interval.tv_nsec = 0;
timer_settime(lpm_proc_cb.timer_id, 0, &ts, 0);
}
}
#endif
UPIODBG("proc btwrite assertion");
if (fd >= 0)
close(fd);
#endif
break;
case UPIO_HOST_WAKE:
UPIODBG("upio_set: UPIO_HOST_WAKE");
break;
}
}

View File

@ -0,0 +1,379 @@
/******************************************************************************
*
* 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: userial_vendor.c
*
* Description: Contains vendor-specific userial functions
*
******************************************************************************/
#define LOG_TAG "bt_userial_vendor"
#include <utils/Log.h>
#include <termios.h>
#include <fcntl.h>
#include <errno.h>
#include <stdio.h>
#include "bt_vendor_brcm.h"
#include "userial.h"
#include "userial_vendor.h"
/******************************************************************************
** Constants & Macros
******************************************************************************/
#ifndef VNDUSERIAL_DBG
#define VNDUSERIAL_DBG FALSE
#endif
#if (VNDUSERIAL_DBG == TRUE)
#define VNDUSERIALDBG(param, ...) {ALOGD(param, ## __VA_ARGS__);}
#else
#define VNDUSERIALDBG(param, ...) {}
#endif
#define VND_PORT_NAME_MAXLEN 256
/******************************************************************************
** Local type definitions
******************************************************************************/
/* 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;
/******************************************************************************
** Static variables
******************************************************************************/
static vnd_userial_cb_t vnd_userial;
/*****************************************************************************
** Helper 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_1_5M)
*baud = B1500000;
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;
}
#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;
#if (BT_WAKE_USERIAL_LDISC==TRUE)
int ldisc = N_BRCM_HCI; /* brcm sleep mode support line discipline */
/* attempt to load enable discipline driver */
if (ioctl(vnd_userial.fd, TIOCSETD, &ldisc) < 0)
{
VNDUSERIALDBG("USERIAL_Open():fd %d, TIOCSETD failed: error %d for ldisc: %d",
fd, errno, ldisc);
}
#endif
/* 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", \
BLUETOOTH_UART_DEVICE_PORT);
}
/*******************************************************************************
**
** 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)) == -1)
{
ALOGE("userial vendor open: unable to open %s", vnd_userial.port_name);
return -1;
}
tcflush(vnd_userial.fd, TCIOFLUSH);
tcgetattr(vnd_userial.fd, &vnd_userial.termios);
cfmakeraw(&vnd_userial.termios);
vnd_userial.termios.c_cflag |= (CRTSCTS | stop_bits);
tcsetattr(vnd_userial.fd, TCSANOW, &vnd_userial.termios);
tcflush(vnd_userial.fd, TCIOFLUSH);
tcsetattr(vnd_userial.fd, TCSANOW, &vnd_userial.termios);
tcflush(vnd_userial.fd, TCIOFLUSH);
tcflush(vnd_userial.fd, TCIOFLUSH);
/* set input/output baudrate */
cfsetospeed(&vnd_userial.termios, baud);
cfsetispeed(&vnd_userial.termios, baud);
tcsetattr(vnd_userial.fd, TCSANOW, &vnd_userial.termios);
#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);
// flush Tx before close to make sure no chars in buffer
tcflush(vnd_userial.fd, TCIOFLUSH);
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;
usleep(200000); // solve ap6335 bt open fail in rk3366
userial_to_tcio_baud(userial_baud, &tcio_baud);
cfsetospeed(&vnd_userial.termios, tcio_baud);
cfsetispeed(&vnd_userial.termios, tcio_baud);
tcsetattr(vnd_userial.fd, TCSANOW, &vnd_userial.termios);
}
/*******************************************************************************
**
** Function userial_vendor_ioctl
**
** Description ioctl inteface
**
** Returns None
**
*******************************************************************************/
void userial_vendor_ioctl(userial_vendor_ioctl_op_t op, void *p_data)
{
switch(op)
{
#if (BT_WAKE_VIA_USERIAL_IOCTL==TRUE)
case USERIAL_OP_ASSERT_BT_WAKE:
VNDUSERIALDBG("## userial_vendor_ioctl: Asserting BT_Wake ##");
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 ##");
ioctl(vnd_userial.fd, USERIAL_IOCTL_BT_WAKE_DEASSERT, NULL);
break;
case USERIAL_OP_GET_BT_WAKE_STATE:
ioctl(vnd_userial.fd, USERIAL_IOCTL_BT_WAKE_GET_ST, p_data);
break;
#endif // (BT_WAKE_VIA_USERIAL_IOCTL==TRUE)
default:
break;
}
}
/*******************************************************************************
**
** 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)
{
strcpy(vnd_userial.port_name, p_conf_value);
return 0;
}

View File

@ -0,0 +1,17 @@
generated_sources := $(local-generated-sources-dir)
#SRC := $(call my-dir)/include/$(addprefix vnd_, $(addsuffix .txt,$(basename $(TARGET_DEVICE))))
SRC := $(call my-dir)/include/vnd_rk30sdk.txt
ifeq (,$(wildcard $(SRC)))
# configuration file does not exist. Use default one
SRC := $(call my-dir)/include/vnd_generic.txt
endif
GEN := $(generated_sources)/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)

View File

@ -0,0 +1,41 @@
LOCAL_PATH := $(call my-dir)
#ifeq ($(strip $(BOARD_CONNECTIVITY_MODULE)), rtl8723bs)
include $(CLEAR_VARS)
BDROID_DIR := $(TOP_DIR)external/bluetooth/bluedroid
LOCAL_SRC_FILES := \
src/bt_vendor_rtk.c \
src/hardware.c \
src/userial_vendor.c \
src/upio.c
LOCAL_C_INCLUDES += \
$(LOCAL_PATH)/include \
$(BDROID_DIR)/hci/include
LOCAL_SHARED_LIBRARIES := \
libcutils \
libhardware_legacy
LOCAL_MODULE := libbt-vendor-rtl8723bs
LOCAL_MODULE_TAGS := optional
LOCAL_MODULE_CLASS := SHARED_LIBRARIES
LOCAL_MODULE_OWNER := realtek
ifneq (1,$(strip $(shell expr $(PLATFORM_VERSION) \>= 5.0)))
LOCAL_MODULE_PATH := $(TARGET_OUT_VENDOR_SHARED_LIBRARIES)
else
ifneq ($(strip $(TARGET_2ND_ARCH)), )
LOCAL_MULTILIB := both
endif
LOCAL_MODULE_RELATIVE_PATH :=
endif
#include $(LOCAL_PATH)/vnd_buildcfg.mk
include $(BUILD_SHARED_LIBRARY)
#endif # BOARD_CONNECTIVITY_MODULE

View File

@ -0,0 +1,29 @@
/*
* Copyright (C) 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 _BDROID_BUILDCFG_H
#define _BDROID_BUILDCFG_H
#define BTM_DEF_LOCAL_NAME "rk30sdk"
// SERVICE_CLASS:0x5A (Bit17 -Networking,Bit19 - Capturing,Bit20 -Object Transfer,Bit22 -Telephony)
// MAJOR CLASS: COMPUTER
// MINOR CLASS: TABLET
#define BTA_DM_COD {0x1A, 0x01, 0x10}
#define BTIF_HF_SERVICES (BTA_HSP_SERVICE_MASK)
#define BTIF_HF_SERVICE_NAMES { BTIF_HSAG_SERVICE_NAME }
#endif

View File

@ -0,0 +1,211 @@
/******************************************************************************
*
* Copyright (C) 2009-2012 Realtek 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: bt_vendor_rtk.h
*
* Description: A wrapper header file of bt_vendor_lib.h
*
* Contains definitions specific for interfacing with Realtek
* Bluetooth chipsets
*
******************************************************************************/
#ifndef BT_VENDOR_RTK_H
#define BT_VENDOR_RTK_H
#include "bt_vendor_lib.h"
#include "vnd_buildcfg.h"
/******************************************************************************
** Constants & Macros
******************************************************************************/
#ifndef FALSE
#define FALSE 0
#endif
#ifndef TRUE
#define TRUE (!FALSE)
#endif
/* Device port name where Bluetooth controller attached */
#ifndef BLUETOOTH_UART_DEVICE_PORT
//#define BLUETOOTH_UART_DEVICE_PORT "/dev/ttyO1" /* maguro */
#define BLUETOOTH_UART_DEVICE_PORT "/dev/ttyS0" /* rk3x */
#endif
/* Location of firmware patch files */
#ifndef FW_PATCHFILE_LOCATION
#define FW_PATCHFILE_LOCATION "/vendor/firmware/" /* maguro */
#endif
#ifndef UART_TARGET_BAUD_RATE
#define UART_TARGET_BAUD_RATE 3000000
#endif
/* The Bluetooth Device Aaddress source switch:
*
* -FALSE- (default value)
* Get the factory BDADDR from device's file system. Normally the BDADDR is
* stored in the location pointed by the PROPERTY_BT_BDADDR_PATH (defined in
* btif_common.h file) property.
*
* -TRUE-
* If the Bluetooth Controller has equipped with a non-volatile memory (such
* as BCM4330's OTP memory), the factory BDADDR can be stored in there and
* retrieved by the stack while enabling BT.
* !!! WARNING !!! Make sure that the OTP feature has been enabled in the
* firmware patchram (.hcd) file.
*/
#ifndef USE_CONTROLLER_BDADDR
#define USE_CONTROLLER_BDADDR FALSE
#endif
/* sleep mode
0: disable
1: UART with Host wake/BT wake out of band signals
*/
#ifndef LPM_SLEEP_MODE
#define LPM_SLEEP_MODE 1
#endif
/* Host Stack Idle Threshold in 300ms or 25ms
In sleep mode 1, this is the number of firmware loops executed with no
activity before the Host wake line is deasserted. Activity includes HCI
traffic excluding certain sleep mode commands and the presence of SCO
connections if the "Allow Host Sleep During SCO" flag is not set to 1.
Each count of this parameter is roughly equivalent to 300ms or 25ms.
*/
#ifndef LPM_IDLE_THRESHOLD
#define LPM_IDLE_THRESHOLD 1
#endif
/* Host Controller Idle Threshold in 300ms or 25ms
This is the number of firmware loops executed with no activity before the
HC is considered idle. Depending on the mode, HC may then attempt to sleep.
Activity includes HCI traffic excluding certain sleep mode commands and
the presence of ACL/SCO connections.
*/
#ifndef LPM_HC_IDLE_THRESHOLD
#define LPM_HC_IDLE_THRESHOLD 1
#endif
/* BT_WAKE Polarity - 0=Active Low, 1= Active High */
#ifndef LPM_BT_WAKE_POLARITY
#define LPM_BT_WAKE_POLARITY 1 /* maguro */
#endif
/* HOST_WAKE Polarity - 0=Active Low, 1= Active High */
#ifndef LPM_HOST_WAKE_POLARITY
#define LPM_HOST_WAKE_POLARITY 1 /* maguro */
#endif
/* LPM_ALLOW_HOST_SLEEP_DURING_SCO
When this flag is set to 0, the host is not allowed to sleep while
an SCO is active. In sleep mode 1, the device will keep the host
wake line asserted while an SCO is active.
When this flag is set to 1, the host can sleep while an SCO is active.
This flag should only be set to 1 if SCO traffic is directed to the PCM
interface.
*/
#ifndef LPM_ALLOW_HOST_SLEEP_DURING_SCO
#define LPM_ALLOW_HOST_SLEEP_DURING_SCO 1
#endif
/* LPM_COMBINE_SLEEP_MODE_AND_LPM
In Mode 0, always set byte 7 to 0. In sleep mode 1, device always
requires permission to sleep between scans / periodic inquiries regardless
of the setting of this byte. In sleep mode 1, if byte is set, device must
have "permission" to sleep during the low power modes of sniff, hold, and
park. If byte is not set, device can sleep without permission during these
modes. Permission to sleep in Mode 1 is obtained if the BT_WAKE signal is
not asserted.
*/
#ifndef LPM_COMBINE_SLEEP_MODE_AND_LPM
#define LPM_COMBINE_SLEEP_MODE_AND_LPM 1
#endif
/* LPM_ENABLE_UART_TXD_TRI_STATE
When set to 0, the device will not tristate its UART TX line before going
to sleep.
When set to 1, the device will tristate its UART TX line before going to
sleep.
*/
#ifndef LPM_ENABLE_UART_TXD_TRI_STATE
#define LPM_ENABLE_UART_TXD_TRI_STATE 0
#endif
/* LPM_PULSED_HOST_WAKE
*/
#ifndef LPM_PULSED_HOST_WAKE
#define LPM_PULSED_HOST_WAKE 0
#endif
/* LPM_IDLE_TIMEOUT_MULTIPLE
The multiple factor of host stack idle threshold in 300ms/25ms
*/
#ifndef LPM_IDLE_TIMEOUT_MULTIPLE
#define LPM_IDLE_TIMEOUT_MULTIPLE 10
#endif
/* BT_WAKE_VIA_USERIAL_IOCTL
Use userial ioctl function to control BT_WAKE signal
*/
#ifndef BT_WAKE_VIA_USERIAL_IOCTL
#define BT_WAKE_VIA_USERIAL_IOCTL FALSE
#endif
/* BT_WAKE_VIA_PROC
LPM & BT_WAKE control through PROC nodes
*/
#ifndef BT_WAKE_VIA_PROC
#define BT_WAKE_VIA_PROC FALSE
#endif
/* HW_END_WITH_HCI_RESET
Sample 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.
*/
#ifndef HW_END_WITH_HCI_RESET
#define HW_END_WITH_HCI_RESET FALSE
#endif
/******************************************************************************
** Extern variables and functions
******************************************************************************/
extern bt_vendor_callbacks_t *bt_vendor_cbacks;
#endif /* BT_VENDOR_RTK_H */

View File

@ -0,0 +1,107 @@
/******************************************************************************
*
* Copyright (C) 2009-2012 Realtek 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: upio.h
*
* Description: Contains definitions used for I/O controls
*
******************************************************************************/
#ifndef UPIO_H
#define UPIO_H
/******************************************************************************
** Constants & Macros
******************************************************************************/
#define UPIO_BT_POWER_OFF 0
#define UPIO_BT_POWER_ON 1
/* 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
};
/******************************************************************************
** Extern variables and functions
******************************************************************************/
/******************************************************************************
** Functions
******************************************************************************/
/*******************************************************************************
**
** Function upio_init
**
** Description Initialization
**
** Returns None
**
*******************************************************************************/
void upio_init(void);
/*******************************************************************************
**
** Function upio_cleanup
**
** Description Clean up
**
** Returns None
**
*******************************************************************************/
void upio_cleanup(void);
/*******************************************************************************
**
** Function upio_set_bluetooth_power
**
** Description Interact with low layer driver to set Bluetooth power
** on/off.
**
** Returns 0 : SUCCESS or Not-Applicable
** <0 : ERROR
**
*******************************************************************************/
int upio_set_bluetooth_power(int on);
/*******************************************************************************
**
** Function upio_set
**
** Description Set i/o based on polarity
**
** Returns None
**
*******************************************************************************/
void upio_set(uint8_t pio, uint8_t action, uint8_t polarity);
#endif /* UPIO_H */

View File

@ -0,0 +1,182 @@
/******************************************************************************
*
* Copyright (C) 2009-2012 Realtek 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: userial_vendor.h
*
* Description: Contains vendor-specific definitions used in serial port
* controls
*
******************************************************************************/
#ifndef USERIAL_VENDOR_H
#define USERIAL_VENDOR_H
#include "bt_vendor_rtk.h"
#include "userial.h"
/******************************************************************************
** Constants & Macros
******************************************************************************/
/**** 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)
#define USERIAL_HW_FLOW_CTRL_OFF 0
#define USERIAL_HW_FLOW_CTRL_ON 1
#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)
/******************************************************************************
** Type definitions
******************************************************************************/
/* Structure used to configure serial port during open */
typedef struct
{
uint16_t fmt; /* Data format */
uint8_t baud; /* Baud rate */
uint8_t hw_fctrl; /*hardware flowcontrol*/
} 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_NOP,
} userial_vendor_ioctl_op_t;
/******************************************************************************
** Extern variables and functions
******************************************************************************/
/******************************************************************************
** Functions
******************************************************************************/
/*******************************************************************************
**
** 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 None
**
*******************************************************************************/
void userial_vendor_ioctl(userial_vendor_ioctl_op_t op, void *p_data);
void userial_vendor_set_hw_fctrl(uint8_t hw_fctrl);
#endif /* USERIAL_VENDOR_H */

View File

@ -0,0 +1,12 @@
/* Auto-generated from device/common/bluetooth/libbt_rtk8723bs/include/vnd_generic.txt on Wed Mar 4 09:06:21 CST 2015 */
#ifndef _VND_BUILDCFG_H
#define _VND_BUILDCFG_H
#define BLUETOOTH_UART_DEVICE_PORT "/dev/ttyS0"
#define FW_PATCHFILE_LOCATION "/system/etc/firmware/rtlbt/"
#define LPM_IDLE_TIMEOUT_MULTIPLE 5
#define SCO_USE_I2S_INTERFACE TRUE
#define BTVND_DBG TRUE
#define BTHW_DBG TRUE
#define VNDUSERIAL_DBG TRUE
#define UPIO_DBG TRUE
#endif

View File

@ -0,0 +1,222 @@
/******************************************************************************
*
* Copyright (C) 2009-2012 Realtek 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: bt_vendor_rtk.c
*
* Description: Realtek vendor specific library implementation
*
******************************************************************************/
#undef NDEBUG
#define LOG_TAG "bt_vendor"
#include <utils/Log.h>
#include "bt_vendor_rtk.h"
#include "upio.h"
#include "userial_vendor.h"
#ifndef BTVND_DBG
#define BTVND_DBG TRUE
#endif
#if (BTVND_DBG == TRUE)
#define BTVNDDBG(param, ...) {ALOGD(param, ## __VA_ARGS__);}
#else
#define BTVNDDBG(param, ...) {}
#endif
/******************************************************************************
** Externs
******************************************************************************/
void hw_config_start(void);
#if (HW_END_WITH_HCI_RESET == TRUE)
void hw_epilog_process(void);
#endif
/******************************************************************************
** Variables
******************************************************************************/
bt_vendor_callbacks_t *bt_vendor_cbacks = NULL;
uint8_t vnd_local_bd_addr[6]={0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
/******************************************************************************
** Local type definitions
******************************************************************************/
/******************************************************************************
** Static Variables
******************************************************************************/
static const tUSERIAL_CFG userial_init_cfg =
{
(USERIAL_DATABITS_8 | USERIAL_PARITY_EVEN | USERIAL_STOPBITS_1),
USERIAL_BAUD_115200,
USERIAL_HW_FLOW_CTRL_OFF
};
/******************************************************************************
** Functions
******************************************************************************/
/*****************************************************************************
**
** BLUETOOTH VENDOR INTERFACE LIBRARY FUNCTIONS
**
*****************************************************************************/
static int init(const bt_vendor_callbacks_t* p_cb, unsigned char *local_bdaddr)
{
ALOGI("init");
if (p_cb == NULL)
{
ALOGE("init failed with no user callbacks!");
return -1;
}
userial_vendor_init();
upio_init();
/* store reference to user callbacks */
bt_vendor_cbacks = (bt_vendor_callbacks_t *) p_cb;
/* This is handed over from the stack */
memcpy(vnd_local_bd_addr, local_bdaddr, 6);
return 0;
}
/** Requested operations */
static int op(bt_vendor_opcode_t opcode, void *param)
{
int retval = 0;
BTVNDDBG("op for %d", opcode);
switch(opcode)
{
case BT_VND_OP_POWER_CTRL:
{
int *state = (int *) param;
if (*state == BT_VND_PWR_OFF)
{
upio_set_bluetooth_power(UPIO_BT_POWER_OFF);
usleep(200000);
BTVNDDBG("set power off and delay 200ms");
}
else if (*state == BT_VND_PWR_ON)
{
upio_set_bluetooth_power(UPIO_BT_POWER_ON);
usleep(500000);
BTVNDDBG("set power on and delay 500ms");
}
}
break;
case BT_VND_OP_FW_CFG:
{
hw_config_start();
}
break;
case BT_VND_OP_SCO_CFG:
{
retval = -1;
}
break;
case BT_VND_OP_USERIAL_OPEN:
{
int (*fd_array)[] = (int (*)[]) param;
int fd, idx;
fd = userial_vendor_open((tUSERIAL_CFG *) &userial_init_cfg);
if (fd != -1)
{
for (idx=0; idx < CH_MAX; idx++)
(*fd_array)[idx] = fd;
retval = 1;
}
/* retval contains numbers of open fd of HCI channels */
}
break;
case BT_VND_OP_USERIAL_CLOSE:
{
userial_vendor_close();
}
break;
case BT_VND_OP_GET_LPM_IDLE_TIMEOUT:
{
}
break;
case BT_VND_OP_LPM_SET_MODE:
{
}
break;
case BT_VND_OP_LPM_WAKE_SET_STATE:
{
}
break;
case BT_VND_OP_EPILOG:
{
#if (HW_END_WITH_HCI_RESET == FALSE)
if (bt_vendor_cbacks)
{
bt_vendor_cbacks->epilog_cb(BT_VND_OP_RESULT_SUCCESS);
}
#else
hw_epilog_process();
#endif
}
break;
}
return retval;
}
/** Closes the interface */
static void cleanup( void )
{
BTVNDDBG("cleanup");
upio_cleanup();
bt_vendor_cbacks = NULL;
}
// Entry point of DLib
const bt_vendor_interface_t BLUETOOTH_VENDOR_LIB_INTERFACE = {
sizeof(bt_vendor_interface_t),
init,
op,
cleanup
};

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,487 @@
/******************************************************************************
*
* Copyright (C) 2009-2012 Realtek 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: upio.c
*
* Description: Contains I/O functions, like
* rfkill control
* BT_WAKE/HOST_WAKE control
*
******************************************************************************/
#define LOG_TAG "bt_upio"
#include <utils/Log.h>
#include <fcntl.h>
#include <errno.h>
#include <cutils/properties.h>
#include "bt_vendor_rtk.h"
#include "upio.h"
#include "userial_vendor.h"
/******************************************************************************
** Constants & Macros
******************************************************************************/
#ifndef UPIO_DBG
#define UPIO_DBG FALSE
#endif
#if (UPIO_DBG == TRUE)
#define UPIODBG(param, ...) {ALOGD(param, ## __VA_ARGS__);}
#else
#define UPIODBG(param, ...) {}
#endif
/******************************************************************************
** Local type definitions
******************************************************************************/
#if (BT_WAKE_VIA_PROC == TRUE)
/* proc fs node for enable/disable lpm mode */
#ifndef VENDOR_LPM_PROC_NODE
#define VENDOR_LPM_PROC_NODE "/proc/bluetooth/sleep/lpm"
#endif
/* proc fs node for notifying write request */
#ifndef VENDOR_BTWRITE_PROC_NODE
#define VENDOR_BTWRITE_PROC_NODE "/proc/bluetooth/sleep/btwrite"
#endif
/*
* Maximum btwrite assertion holding time without consecutive btwrite kicking.
* This value is correlative(shorter) to the in-activity timeout period set in
* the bluesleep LPM code. The current value used in bluesleep is 10sec.
*/
#ifndef PROC_BTWRITE_TIMER_TIMEOUT_MS
#define PROC_BTWRITE_TIMER_TIMEOUT_MS 8000
#endif
/* lpm proc control block */
typedef struct
{
uint8_t btwrite_active;
uint8_t timer_created;
timer_t timer_id;
uint32_t timeout_ms;
} vnd_lpm_proc_cb_t;
static vnd_lpm_proc_cb_t lpm_proc_cb;
#endif
/******************************************************************************
** Static variables
******************************************************************************/
static uint8_t upio_state[UPIO_MAX_COUNT];
static int rfkill_id = -1;
static int bt_emul_enable = 0;
static char *rfkill_state_path = NULL;
/******************************************************************************
** Static functions
******************************************************************************/
/* for friendly debugging outpout string */
static char *lpm_mode[] = {
"UNKNOWN",
"disabled",
"enabled"
};
static char *lpm_state[] = {
"UNKNOWN",
"de-asserted",
"asserted"
};
/*****************************************************************************
** Bluetooth On/Off Static Functions
*****************************************************************************/
static int is_emulator_context(void)
{
char value[PROPERTY_VALUE_MAX];
property_get("ro.kernel.qemu", value, "0");
UPIODBG("is_emulator_context : %s", value);
if (strcmp(value, "1") == 0) {
return 1;
}
return 0;
}
static int is_rfkill_disabled(void)
{
char value[PROPERTY_VALUE_MAX];
property_get("ro.rfkilldisabled", value, "0");
UPIODBG("is_rfkill_disabled ? [%s]", value);
if (strcmp(value, "1") == 0) {
return UPIO_BT_POWER_ON;
}
return UPIO_BT_POWER_OFF;
}
static int init_rfkill()
{
char path[64];
char buf[16];
int fd, sz, id;
if (is_rfkill_disabled())
return -1;
for (id = 0; ; id++)
{
snprintf(path, sizeof(path), "/sys/class/rfkill/rfkill%d/type", id);
fd = open(path, O_RDONLY);
if (fd < 0)
{
ALOGE("init_rfkill : open(%s) failed: %s (%d)\n", \
path, strerror(errno), errno);
return -1;
}
sz = read(fd, &buf, sizeof(buf));
close(fd);
if (sz >= 9 && memcmp(buf, "bluetooth", 9) == 0)
{
rfkill_id = id;
break;
}
}
asprintf(&rfkill_state_path, "/sys/class/rfkill/rfkill%d/state", rfkill_id);
return 0;
}
/*****************************************************************************
** LPM Static Functions
*****************************************************************************/
#if (BT_WAKE_VIA_PROC == TRUE)
/*******************************************************************************
**
** Function proc_btwrite_timeout
**
** Description Timeout thread of proc/.../btwrite assertion holding timer
**
** Returns None
**
*******************************************************************************/
static void proc_btwrite_timeout(union sigval arg)
{
UPIODBG("..%s..", __FUNCTION__);
lpm_proc_cb.btwrite_active = FALSE;
}
#endif
/*****************************************************************************
** UPIO Interface Functions
*****************************************************************************/
/*******************************************************************************
**
** Function upio_init
**
** Description Initialization
**
** Returns None
**
*******************************************************************************/
void upio_init(void)
{
memset(upio_state, UPIO_UNKNOWN, UPIO_MAX_COUNT);
#if (BT_WAKE_VIA_PROC == TRUE)
memset(&lpm_proc_cb, 0, sizeof(vnd_lpm_proc_cb_t));
#endif
}
/*******************************************************************************
**
** Function upio_cleanup
**
** Description Clean up
**
** Returns None
**
*******************************************************************************/
void upio_cleanup(void)
{
#if (BT_WAKE_VIA_PROC == TRUE)
if (lpm_proc_cb.timer_created == TRUE)
timer_delete(lpm_proc_cb.timer_id);
lpm_proc_cb.timer_created = FALSE;
#endif
}
/*******************************************************************************
**
** Function upio_set_bluetooth_power
**
** Description Interact with low layer driver to set Bluetooth power
** on/off.
**
** Returns 0 : SUCCESS or Not-Applicable
** <0 : ERROR
**
*******************************************************************************/
int upio_set_bluetooth_power(int on)
{
int sz;
int fd = -1;
int ret = -1;
char buffer = '0';
switch(on)
{
case UPIO_BT_POWER_OFF:
buffer = '0';
break;
case UPIO_BT_POWER_ON:
buffer = '1';
break;
}
if (is_emulator_context())
{
/* if new value is same as current, return -1 */
if (bt_emul_enable == on)
return ret;
UPIODBG("set_bluetooth_power [emul] %d", on);
bt_emul_enable = on;
return 0;
}
/* check if we have rfkill interface */
if (is_rfkill_disabled())
return 0;
if (rfkill_id == -1)
{
if (init_rfkill())
return ret;
}
fd = open(rfkill_state_path, O_WRONLY);
if (fd < 0)
{
ALOGE("set_bluetooth_power : open(%s) for write failed: %s (%d)",
rfkill_state_path, strerror(errno), errno);
return ret;
}
sz = write(fd, &buffer, 1);
if (sz < 0) {
ALOGE("set_bluetooth_power : write(%s) failed: %s (%d)",
rfkill_state_path, strerror(errno),errno);
}
else
ret = 0;
if (fd >= 0)
close(fd);
return ret;
}
/*******************************************************************************
**
** Function upio_set
**
** Description Set i/o based on polarity
**
** Returns None
**
*******************************************************************************/
void upio_set(uint8_t pio, uint8_t action, uint8_t polarity)
{
int rc;
#if (BT_WAKE_VIA_PROC == TRUE)
int fd = -1;
char buffer;
#endif
switch (pio)
{
case UPIO_LPM_MODE:
if (upio_state[UPIO_LPM_MODE] == action)
{
UPIODBG("LPM is %s already", lpm_mode[action]);
return;
}
upio_state[UPIO_LPM_MODE] = action;
#if (BT_WAKE_VIA_PROC == TRUE)
fd = open(VENDOR_LPM_PROC_NODE, O_WRONLY);
if (fd < 0)
{
ALOGE("upio_set : open(%s) for write failed: %s (%d)",
VENDOR_LPM_PROC_NODE, strerror(errno), errno);
return;
}
if (action == UPIO_ASSERT)
{
buffer = '1';
}
else
{
buffer = '0';
// delete btwrite assertion holding timer
if (lpm_proc_cb.timer_created == TRUE)
{
timer_delete(lpm_proc_cb.timer_id);
lpm_proc_cb.timer_created = FALSE;
}
}
if (write(fd, &buffer, 1) < 0)
{
ALOGE("upio_set : write(%s) failed: %s (%d)",
VENDOR_LPM_PROC_NODE, strerror(errno),errno);
}
else
{
if (action == UPIO_ASSERT)
{
// create btwrite assertion holding timer
if (lpm_proc_cb.timer_created == FALSE)
{
int status;
struct sigevent se;
se.sigev_notify = SIGEV_THREAD;
se.sigev_value.sival_ptr = &lpm_proc_cb.timer_id;
se.sigev_notify_function = proc_btwrite_timeout;
se.sigev_notify_attributes = NULL;
status = timer_create(CLOCK_MONOTONIC, &se,
&lpm_proc_cb.timer_id);
if (status == 0)
lpm_proc_cb.timer_created = TRUE;
}
}
}
if (fd >= 0)
close(fd);
#endif
break;
case UPIO_BT_WAKE:
if (upio_state[UPIO_BT_WAKE] == action)
{
UPIODBG("BT_WAKE is %s already", lpm_state[action]);
#if (BT_WAKE_VIA_PROC == TRUE)
if (lpm_proc_cb.btwrite_active == TRUE)
/*
* The proc btwrite node could have not been updated for
* certain time already due to heavy downstream path flow.
* In this case, we want to explicity touch proc btwrite
* node to keep the bt_wake assertion in the LPM kernel
* driver. The current kernel bluesleep LPM code starts
* a 10sec internal in-activity timeout timer before it
* attempts to deassert BT_WAKE line.
*/
#endif
return;
}
upio_state[UPIO_BT_WAKE] = action;
#if (BT_WAKE_VIA_USERIAL_IOCTL == TRUE)
userial_vendor_ioctl( ( (action==UPIO_ASSERT) ? \
USERIAL_OP_ASSERT_BT_WAKE : USERIAL_OP_DEASSERT_BT_WAKE),\
NULL);
#elif (BT_WAKE_VIA_PROC == TRUE)
/*
* Kick proc btwrite node only at UPIO_ASSERT
*/
if (action == UPIO_DEASSERT)
return;
fd = open(VENDOR_BTWRITE_PROC_NODE, O_WRONLY);
if (fd < 0)
{
ALOGE("upio_set : open(%s) for write failed: %s (%d)",
VENDOR_BTWRITE_PROC_NODE, strerror(errno), errno);
return;
}
buffer = '1';
if (write(fd, &buffer, 1) < 0)
{
ALOGE("upio_set : write(%s) failed: %s (%d)",
VENDOR_BTWRITE_PROC_NODE, strerror(errno),errno);
}
else
{
lpm_proc_cb.btwrite_active = TRUE;
if (lpm_proc_cb.timer_created == TRUE)
{
struct itimerspec ts;
ts.it_value.tv_sec = PROC_BTWRITE_TIMER_TIMEOUT_MS/1000;
ts.it_value.tv_nsec = 1000*(PROC_BTWRITE_TIMER_TIMEOUT_MS%1000);
ts.it_interval.tv_sec = 0;
ts.it_interval.tv_nsec = 0;
timer_settime(lpm_proc_cb.timer_id, 0, &ts, 0);
}
}
UPIODBG("proc btwrite assertion");
if (fd >= 0)
close(fd);
#endif
break;
case UPIO_HOST_WAKE:
UPIODBG("upio_set: UPIO_HOST_WAKE");
break;
}
}

View File

@ -0,0 +1,445 @@
/******************************************************************************
*
* Copyright (C) 2009-2012 Realtek 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: userial_vendor.c
*
* Description: Contains vendor-specific userial functions
*
******************************************************************************/
#undef NDEBUG
#define LOG_TAG "bt_userial_vendor"
#include <utils/Log.h>
#include <termios.h>
#include <fcntl.h>
#include <errno.h>
#include <stdio.h>
#include "bt_vendor_rtk.h"
#include "userial.h"
#include "userial_vendor.h"
/******************************************************************************
** Constants & Macros
******************************************************************************/
#ifndef VNDUSERIAL_DBG
#define VNDUSERIAL_DBG TRUE
#endif
#if (VNDUSERIAL_DBG == TRUE)
#define VNDUSERIALDBG(param, ...) {ALOGD(param, ## __VA_ARGS__);}
#else
#define VNDUSERIALDBG(param, ...) {}
#endif
#define VND_PORT_NAME_MAXLEN 256
#ifndef BT_CHIP_HW_FLOW_CTRL_ON
#define BT_CHIP_HW_FLOW_CTRL_ON TRUE
#endif
/******************************************************************************
** Local type definitions
******************************************************************************/
/* 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;
/******************************************************************************
** Static variables
******************************************************************************/
static vnd_userial_cb_t vnd_userial;
/*****************************************************************************
** Helper 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_1_5M)
*baud = B1500000;
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;
}
#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", \
BLUETOOTH_UART_DEVICE_PORT);
}
/*******************************************************************************
**
** 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)) == -1)
{
ALOGE("userial vendor open: unable to open %s", vnd_userial.port_name);
return -1;
}
tcflush(vnd_userial.fd, TCIOFLUSH);
tcgetattr(vnd_userial.fd, &vnd_userial.termios);
cfmakeraw(&vnd_userial.termios);
if(p_cfg->hw_fctrl == USERIAL_HW_FLOW_CTRL_ON)
{
ALOGI("userial vendor open: with HW flowctrl ON");
vnd_userial.termios.c_cflag |= (CRTSCTS | stop_bits| parity);
}
else
{
ALOGI("userial vendor open: with HW flowctrl OFF");
vnd_userial.termios.c_cflag &= ~CRTSCTS;
vnd_userial.termios.c_cflag |= (stop_bits| parity);
}
tcsetattr(vnd_userial.fd, TCSANOW, &vnd_userial.termios);
tcflush(vnd_userial.fd, TCIOFLUSH);
tcsetattr(vnd_userial.fd, TCSANOW, &vnd_userial.termios);
tcflush(vnd_userial.fd, TCIOFLUSH);
tcflush(vnd_userial.fd, TCIOFLUSH);
/* set input/output baudrate */
cfsetospeed(&vnd_userial.termios, baud);
cfsetispeed(&vnd_userial.termios, baud);
tcsetattr(vnd_userial.fd, TCSANOW, &vnd_userial.termios);
#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;
ALOGI("userial_vendor_set_baud++");
userial_to_tcio_baud(userial_baud, &tcio_baud);
if(cfsetospeed(&vnd_userial.termios, tcio_baud)<0)
ALOGE("cfsetospeed fail");
if(cfsetispeed(&vnd_userial.termios, tcio_baud)<0)
ALOGE("cfsetispeed fail");
if(tcsetattr(vnd_userial.fd, TCSANOW, &vnd_userial.termios)<0)
ALOGE("tcsetattr fail ");
tcflush(vnd_userial.fd, TCIOFLUSH);
ALOGI("userial_vendor_set_baud--");
}
/*******************************************************************************
**
** Function userial_vendor_ioctl
**
** Description ioctl inteface
**
** Returns None
**
*******************************************************************************/
void userial_vendor_ioctl(userial_vendor_ioctl_op_t op, void *p_data)
{
switch(op)
{
#if (BT_WAKE_VIA_USERIAL_IOCTL==TRUE)
case USERIAL_OP_ASSERT_BT_WAKE:
VNDUSERIALDBG("## userial_vendor_ioctl: Asserting BT_Wake ##");
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 ##");
ioctl(vnd_userial.fd, USERIAL_IOCTL_BT_WAKE_DEASSERT, NULL);
break;
case USERIAL_OP_GET_BT_WAKE_STATE:
ioctl(vnd_userial.fd, USERIAL_IOCTL_BT_WAKE_GET_ST, p_data);
break;
#endif // (BT_WAKE_VIA_USERIAL_IOCTL==TRUE)
default:
break;
}
}
/*******************************************************************************
**
** 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)
{
strcpy(vnd_userial.port_name, p_conf_value);
return 0;
}
/*******************************************************************************
**
** Function userial_vendor_set_hw_fctrl
**
** Description Conduct vendor-specific close work
**
** Returns None
**
*******************************************************************************/
void userial_vendor_set_hw_fctrl(uint8_t hw_fctrl)
{
struct termios termios_old;
if (vnd_userial.fd == -1)
{
ALOGE("vnd_userial.fd is -1");
return;
}
tcgetattr(vnd_userial.fd, &termios_old);
if(hw_fctrl)
{
ALOGI("Set HW FlowControl On");
if(termios_old.c_cflag & CRTSCTS)
{
ALOGI("userial_vendor_set_hw_fctrl already hw flowcontrol on");
return;
}
else
{
termios_old.c_cflag |= CRTSCTS;
tcsetattr(vnd_userial.fd, TCSANOW, &termios_old);
ALOGI("userial_vendor_set_hw_fctrl set hw flowcontrol on");
}
}
else
{
ALOGI("Set HW FlowControl Off");
if(termios_old.c_cflag & CRTSCTS)
{
termios_old.c_cflag &= ~CRTSCTS;
tcsetattr(vnd_userial.fd, TCSANOW, &termios_old);
return;
}
else
{
ALOGI("userial_vendor_set_hw_fctrl set hw flowcontrol off");
return;
}
}
}

View File

@ -0,0 +1,16 @@
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)

View File

@ -0,0 +1,38 @@
LOCAL_PATH := $(call my-dir)
#ifeq ($(strip $(BOARD_CONNECTIVITY_MODULE)),\
# $(filter $(BOARD_CONNECTIVITY_MODULE), rtl8723au rtl8723bu rtl8761auv))
include $(CLEAR_VARS)
BDROID_DIR := $(TOP_DIR)external/bluetooth/bluedroid
LOCAL_SRC_FILES := \
src/bt_vendor_rtk.c
LOCAL_C_INCLUDES += \
$(LOCAL_PATH)/include \
$(BDROID_DIR)/hci/include
LOCAL_SHARED_LIBRARIES := \
libcutils
LOCAL_MODULE := libbt-vendor-rtl8723bu
LOCAL_MODULE_TAGS := optional
LOCAL_MODULE_CLASS := SHARED_LIBRARIES
LOCAL_MODULE_OWNER := realtek
ifneq (1,$(strip $(shell expr $(PLATFORM_VERSION) \>= 5.0)))
LOCAL_MODULE_PATH := $(TARGET_OUT_VENDOR_SHARED_LIBRARIES)
else
ifneq ($(strip $(TARGET_2ND_ARCH)), )
LOCAL_MULTILIB := both
endif
LOCAL_MODULE_RELATIVE_PATH :=
endif
#include $(LOCAL_PATH)/vnd_buildcfg.mk
include $(BUILD_SHARED_LIBRARY)
#endif # BOARD_CONNECTIVITY_MODULE

View File

@ -0,0 +1,63 @@
/******************************************************************************
*
* 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: bt_vendor_rtk.h
*
* Description: A wrapper header file of bt_vendor_lib.h
*
* Contains definitions specific for interfacing with Broadcom
* Bluetooth chipsets
*
******************************************************************************/
#ifndef BT_VENDOR_RTK_H
#define BT_VENDOR_RTK_H
#include "bt_vendor_lib.h"
#include "vnd_buildcfg.h"
/******************************************************************************
** Constants & Macros
******************************************************************************/
#ifndef FALSE
#define FALSE 0
#endif
#ifndef TRUE
#define TRUE (!FALSE)
#endif
/* Device port name where Bluetooth controller attached */
#ifndef BLUETOOTH_UART_DEVICE_PORT
#define BLUETOOTH_UART_DEVICE_PORT "/dev/rtk_btusb"
#endif
/******************************************************************************
** Extern variables and functions
******************************************************************************/
void userial_vendor_init(void);
int userial_vendor_open(void);
void userial_vendor_close(void);
extern bt_vendor_callbacks_t *bt_vendor_cbacks;
#endif /* BT_VENDOR_RTK_H */

View File

@ -0,0 +1,12 @@
/* Auto-generated from device/common/bluetooth/libbt_rtk_usb/include/vnd_generic.txt on Tue Mar 3 11:42:41 CST 2015 */
#ifndef _VND_BUILDCFG_H
#define _VND_BUILDCFG_H
#define BLUETOOTH_UART_DEVICE_PORT "/dev/rtk_btusb"
#define FW_PATCHFILE_LOCATION "/etc/firmware/"
#define LPM_IDLE_TIMEOUT_MULTIPLE 5
#define SCO_USE_I2S_INTERFACE TRUE
#define BTVND_DBG FALSE
#define BTHW_DBG TRUE
#define VNDUSERIAL_DBG FALSE
#define UPIO_DBG FALSE
#endif

View File

@ -0,0 +1,240 @@
/******************************************************************************
*
* 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: bt_vendor_rtk.c
*
* Description: Broadcom vendor specific library implementation
*
******************************************************************************/
#define LOG_TAG "bt_vendor"
#include <fcntl.h>
#include <errno.h>
#include <utils/Log.h>
#include "bt_vendor_rtk.h"
#ifndef BTVND_DBG
#define BTVND_DBG FALSE
#endif
#if (BTVND_DBG == TRUE)
#define BTVNDDBG(param, ...) {ALOGD(param, ## __VA_ARGS__);}
#else
#define BTVNDDBG(param, ...) {}
#endif
/******************************************************************************
** Local type definitions
******************************************************************************/
#define VND_PORT_NAME_MAXLEN 256
/* vendor serial control block */
typedef struct
{
int fd; /* fd to Bluetooth device */
uint16_t dev_id;
char port_name[VND_PORT_NAME_MAXLEN];
} vnd_userial_cb_t;
/******************************************************************************
** Variables
******************************************************************************/
bt_vendor_callbacks_t *bt_vendor_cbacks = NULL;
uint8_t vnd_local_bd_addr[6]={0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
static vnd_userial_cb_t vnd_userial;
/*****************************************************************************
**
** BLUETOOTH VENDOR INTERFACE LIBRARY FUNCTIONS
**
*****************************************************************************/
static int init(const bt_vendor_callbacks_t* p_cb, unsigned char *local_bdaddr)
{
ALOGI("init");
if (p_cb == NULL)
{
ALOGE("init failed with no user callbacks!");
return -1;
}
userial_vendor_init();
/* store reference to user callbacks */
bt_vendor_cbacks = (bt_vendor_callbacks_t *) p_cb;
/* This is handed over from the stack */
memcpy(vnd_local_bd_addr, local_bdaddr, 6);
return 0;
}
/** Requested operations */
static int op(bt_vendor_opcode_t opcode, void *param)
{
int retval = 0;
BTVNDDBG("op for %d", opcode);
switch(opcode)
{
case BT_VND_OP_POWER_CTRL:
{
return 0;
}
break;
case BT_VND_OP_FW_CFG:
{
bt_vendor_cbacks->fwcfg_cb(BT_VND_OP_RESULT_SUCCESS);
}
break;
case BT_VND_OP_SCO_CFG:
{
retval = -1;
}
break;
case BT_VND_OP_USERIAL_OPEN:
{
int (*fd_array)[] = (int (*)[]) param;
int fd, idx;
fd = userial_vendor_open();
if (fd != -1)
{
for (idx=0; idx < CH_MAX; idx++)
(*fd_array)[idx] = fd;
retval = 1;
}
/* retval contains numbers of open fd of HCI channels */
}
break;
case BT_VND_OP_USERIAL_CLOSE:
{
userial_vendor_close();
}
break;
case BT_VND_OP_GET_LPM_IDLE_TIMEOUT:
{
uint32_t *timeout_ms = (uint32_t *) param;
*timeout_ms = 250;
}
break;
case BT_VND_OP_LPM_SET_MODE:
{
if (bt_vendor_cbacks)
bt_vendor_cbacks->lpm_cb(BT_VND_OP_RESULT_SUCCESS);
}
break;
case BT_VND_OP_LPM_WAKE_SET_STATE:
break;
}
return retval;
}
/*******************************************************************************
**
** Function userial_vendor_init
**
** Description Initialize userial vendor-specific control block
**
** Returns None
**
*******************************************************************************/
void userial_vendor_init(void)
{
vnd_userial.fd = -1;
vnd_userial.dev_id = 0;
snprintf(vnd_userial.port_name, VND_PORT_NAME_MAXLEN, "%s", \
BLUETOOTH_UART_DEVICE_PORT);
}
/*******************************************************************************
**
** Function userial_vendor_open
**
** Description Open the serial port with the given configuration
**
** Returns device fd
**
*******************************************************************************/
int userial_vendor_open(void)
{
ALOGI("userial vendor open: opening %s", vnd_userial.port_name);
if ((vnd_userial.fd = open(vnd_userial.port_name, O_RDWR)) == -1)
{
ALOGE("userial vendor open: unable to open %s: %s", vnd_userial.port_name, strerror(errno));
return -1;
}
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;
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;
}
/** Closes the interface */
static void cleanup( void )
{
BTVNDDBG("cleanup");
bt_vendor_cbacks = NULL;
}
// Entry point of DLib
const bt_vendor_interface_t BLUETOOTH_VENDOR_LIB_INTERFACE = {
sizeof(bt_vendor_interface_t),
init,
op,
cleanup
};

View File

@ -0,0 +1,16 @@
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)

View File

@ -0,0 +1,34 @@
# 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.
unset BOOTLOADER
unset BOOTLOADERFILE
unset BOOTLOADERSRC
unset BUILD
unset CDMARADIO
unset CDMARADIOFILE
unset DEVICE
unset ERASE
unset PRODUCT
unset RADIO
unset RADIOFILE
unset RADIOSRC
unset RADIOFILE
unset SLEEPDURATION
unset SRCPREFIX
unset UNLOCKBOOTLOADER
unset VERSION
unset TWINBOOTLOADERS
unset XLOADER
unset XLOADERSRC

View File

@ -0,0 +1,146 @@
#!/usr/bin/env bash
# Copyright (C) 2010 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.
# This script auto-generates the lists of proprietary blobs necessary to build
# the Android Open-Source Project code for a variety of hardware targets.
# It needs to be run from the root of a source tree that can repo sync,
# runs builds with and without the vendor tree, and uses the difference
# to generate the lists.
# It can optionally upload the results to a Gerrit server for review.
# WARNING: It destroys the source tree. Don't leave anything precious there.
# Caveat: this script does many full builds (2 per device). It takes a while
# to run. It's best # suited for overnight runs on multi-CPU machines
# with a lot of RAM.
# Syntax: device/common/generate-blob-lists.sh -f|--force [<server> <branch>]
#
# If the server and branch paramters are both present, the script will upload
# new files (if there's been any change) to the mentioned Gerrit server,
# in the specified branch.
if test "$1" != "-f" -a "$1" != "--force"
then
echo This script must be run with the --force option
exit 1
fi
shift
repo sync -j32 -n
repo sync -j32 -n
repo sync -j2 -l
DEVICES=$(for i in device/*/*/proprietary-blobs.txt ; do basename $(dirname $i) ; done)
export LC_ALL=C
ARCHIVEDIR=archive-$(date +%s)
if test -d archive-ref
then
cp -R archive-ref $ARCHIVEDIR
else
mkdir $ARCHIVEDIR
. build/envsetup.sh
for DEVICENAME in $DEVICES
do
rm -rf out
lunch aosp_$DEVICENAME-user
make -j64
cat out/target/product/$DEVICENAME/installed-files.txt |
cut -b 15- |
sort -f > $ARCHIVEDIR/$DEVICENAME-with.txt
done
rm -rf vendor
rm -rf hardware/qcom/gps
for DEVICENAME in $DEVICES
do
rm -rf out
lunch aosp_$DEVICENAME-user
make -j64
cat out/target/product/$DEVICENAME/installed-files.txt |
cut -b 15- |
sort -f > $ARCHIVEDIR/$DEVICENAME-without.txt
done
fi
for DEVICENAME in $DEVICES
do
MANUFACTURERNAME=$( find device -type d | grep ^[^/]\*/[^/]\*/$DEVICENAME\$ | cut -f 2 -d / )
if test $(wc -l < $ARCHIVEDIR/$DEVICENAME-without.txt) != 0 -a $(wc -l < $ARCHIVEDIR/$DEVICENAME-with.txt) != 0
then
(
echo '# Copyright (C) 2011 The Android Open Source Project'
echo '#'
echo '# Licensed under the Apache License, Version 2.0 (the "License");'
echo '# you may not use this file except in compliance with the License.'
echo '# You may obtain a copy of the License at'
echo '#'
echo '# http://www.apache.org/licenses/LICENSE-2.0'
echo '#'
echo '# Unless required by applicable law or agreed to in writing, software'
echo '# distributed under the License is distributed on an "AS IS" BASIS,'
echo '# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.'
echo '# See the License for the specific language governing permissions and'
echo '# limitations under the License.'
echo
echo '# This file is generated by device/common/generate-blob-lists.sh - DO NOT EDIT'
echo
diff $ARCHIVEDIR/$DEVICENAME-without.txt $ARCHIVEDIR/$DEVICENAME-with.txt |
grep -v '\.odex$' |
grep '>' |
cut -b 3-
) > $ARCHIVEDIR/$DEVICENAME-proprietary-blobs.txt
cp $ARCHIVEDIR/$DEVICENAME-proprietary-blobs.txt device/$MANUFACTURERNAME/$DEVICENAME/proprietary-blobs.txt
(
cd device/$MANUFACTURERNAME/$DEVICENAME
git add .
git commit -m "$(echo -e 'auto-generated blob list for '$DEVICENAME'\n\nBug: 4295425')"
if test "$1" != "" -a "$2" != ""
then
echo uploading to server $1 branch $2
git push $1/device/$MANUFACTURERNAME/$DEVICENAME.git HEAD:refs/for/$2/autoblobs
fi
)
else
(
cd device/$MANUFACTURERNAME/$DEVICENAME
git commit --allow-empty -m "$(echo -e 'DO NOT SUBMIT - BROKEN BUILD\n\nBug: 4295425')"
if test "$1" != "" -a "$2" != ""
then
echo uploading to server $1 branch $2
git push $1/device/$MANUFACTURERNAME/$DEVICENAME.git HEAD:refs/for/$2/autoblobs
fi
)
fi
done
if true
then
rm -rf out/
elif ! test -d archive-ref
then
echo * device/* |
tr \ \\n |
grep -v ^archive- |
grep -v ^device$ |
grep -v ^device/common$ |
xargs rm -rf
fi

View File

@ -0,0 +1,300 @@
# Copyright 2011 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.
# Use the default values if they weren't explicitly set
if test "$XLOADERSRC" = ""
then
XLOADERSRC=xloader.img
fi
if test "$BOOTLOADERSRC" = ""
then
BOOTLOADERSRC=bootloader.img
fi
if test "$RADIOSRC" = ""
then
RADIOSRC=radio.img
fi
if test "$SLEEPDURATION" = ""
then
SLEEPDURATION=5
fi
# Prepare the staging directory
rm -rf tmp
mkdir -p tmp/$PRODUCT-$VERSION
# Extract the bootloader(s) and radio(s) as necessary
if test "$XLOADER" != ""
then
unzip -d tmp ${SRCPREFIX}$PRODUCT-target_files-$BUILD.zip RADIO/$XLOADERSRC
fi
if test "$BOOTLOADERFILE" = ""
then
unzip -d tmp ${SRCPREFIX}$PRODUCT-target_files-$BUILD.zip RADIO/$BOOTLOADERSRC
fi
if test "$RADIO" != "" -a "$RADIOFILE" = ""
then
unzip -d tmp ${SRCPREFIX}$PRODUCT-target_files-$BUILD.zip RADIO/$RADIOSRC
fi
if test "$CDMARADIO" != "" -a "$CDMARADIOFILE" = ""
then
unzip -d tmp ${SRCPREFIX}$PRODUCT-target_files-$BUILD.zip RADIO/radio-cdma.img
fi
# Copy the various images in their staging location
cp ${SRCPREFIX}$PRODUCT-img-$BUILD.zip tmp/$PRODUCT-$VERSION/image-$PRODUCT-$VERSION.zip
if test "$XLOADER" != ""
then
cp tmp/RADIO/$XLOADERSRC tmp/$PRODUCT-$VERSION/xloader-$DEVICE-$XLOADER.img
fi
if test "$BOOTLOADERFILE" = ""
then
cp tmp/RADIO/$BOOTLOADERSRC tmp/$PRODUCT-$VERSION/bootloader-$DEVICE-$BOOTLOADER.img
else
cp $BOOTLOADERFILE tmp/$PRODUCT-$VERSION/bootloader-$DEVICE-$BOOTLOADER.img
fi
if test "$RADIO" != ""
then
if test "$RADIOFILE" = ""
then
cp tmp/RADIO/$RADIOSRC tmp/$PRODUCT-$VERSION/radio-$DEVICE-$RADIO.img
else
cp $RADIOFILE tmp/$PRODUCT-$VERSION/radio-$DEVICE-$RADIO.img
fi
fi
if test "$CDMARADIO" != ""
then
if test "$CDMARADIOFILE" = ""
then
cp tmp/RADIO/radio-cdma.img tmp/$PRODUCT-$VERSION/radio-cdma-$DEVICE-$CDMARADIO.img
else
cp $CDMARADIOFILE tmp/$PRODUCT-$VERSION/radio-cdma-$DEVICE-$CDMARADIO.img
fi
fi
# Write flash-all.sh
cat > tmp/$PRODUCT-$VERSION/flash-all.sh << EOF
#!/bin/sh
# 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.
EOF
if test "$UNLOCKBOOTLOADER" = "true"
then
cat >> tmp/$PRODUCT-$VERSION/flash-all.sh << EOF
fastboot oem unlock
EOF
fi
if test "$ERASEALL" = "true"
then
cat >> tmp/$PRODUCT-$VERSION/flash-all.sh << EOF
fastboot erase boot
fastboot erase cache
fastboot erase recovery
fastboot erase system
fastboot erase userdata
EOF
fi
if test "$XLOADER" != ""
then
cat >> tmp/$PRODUCT-$VERSION/flash-all.sh << EOF
fastboot flash xloader xloader-$DEVICE-$XLOADER.img
EOF
fi
cat >> tmp/$PRODUCT-$VERSION/flash-all.sh << EOF
fastboot flash bootloader bootloader-$DEVICE-$BOOTLOADER.img
EOF
if test "$TWINBOOTLOADERS" = "true"
then
cat >> tmp/$PRODUCT-$VERSION/flash-all.sh << EOF
fastboot flash bootloader2 bootloader-$DEVICE-$BOOTLOADER.img
EOF
fi
cat >> tmp/$PRODUCT-$VERSION/flash-all.sh << EOF
fastboot reboot-bootloader
sleep $SLEEPDURATION
EOF
if test "$RADIO" != ""
then
cat >> tmp/$PRODUCT-$VERSION/flash-all.sh << EOF
fastboot flash radio radio-$DEVICE-$RADIO.img
fastboot reboot-bootloader
sleep $SLEEPDURATION
EOF
fi
if test "$CDMARADIO" != ""
then
cat >> tmp/$PRODUCT-$VERSION/flash-all.sh << EOF
fastboot flash radio-cdma radio-cdma-$DEVICE-$CDMARADIO.img
fastboot reboot-bootloader
sleep $SLEEPDURATION
EOF
fi
cat >> tmp/$PRODUCT-$VERSION/flash-all.sh << EOF
fastboot -w update image-$PRODUCT-$VERSION.zip
EOF
chmod a+x tmp/$PRODUCT-$VERSION/flash-all.sh
# Write flash-all.bat
cat > tmp/$PRODUCT-$VERSION/flash-all.bat << EOF
@ECHO OFF
:: 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.
PATH=%PATH%;"%SYSTEMROOT%\System32"
EOF
if test "$UNLOCKBOOTLOADER" = "true"
then
cat >> tmp/$PRODUCT-$VERSION/flash-all.bat << EOF
fastboot oem unlock
EOF
fi
if test "$ERASEALL" = "true"
then
cat >> tmp/$PRODUCT-$VERSION/flash-all.bat << EOF
fastboot erase boot
fastboot erase cache
fastboot erase recovery
fastboot erase system
fastboot erase userdata
EOF
fi
if test "$XLOADER" != ""
then
cat >> tmp/$PRODUCT-$VERSION/flash-all.bat << EOF
fastboot flash xloader xloader-$DEVICE-$XLOADER.img
EOF
fi
cat >> tmp/$PRODUCT-$VERSION/flash-all.bat << EOF
fastboot flash bootloader bootloader-$DEVICE-$BOOTLOADER.img
EOF
if test "$TWINBOOTLOADERS" = "true"
then
cat >> tmp/$PRODUCT-$VERSION/flash-all.bat << EOF
fastboot flash bootloader2 bootloader-$DEVICE-$BOOTLOADER.img
EOF
fi
cat >> tmp/$PRODUCT-$VERSION/flash-all.bat << EOF
fastboot reboot-bootloader
ping -n $SLEEPDURATION 127.0.0.1 >nul
EOF
if test "$RADIO" != ""
then
cat >> tmp/$PRODUCT-$VERSION/flash-all.bat << EOF
fastboot flash radio radio-$DEVICE-$RADIO.img
fastboot reboot-bootloader
ping -n $SLEEPDURATION 127.0.0.1 >nul
EOF
fi
if test "$CDMARADIO" != ""
then
cat >> tmp/$PRODUCT-$VERSION/flash-all.bat << EOF
fastboot flash radio-cdma radio-cdma-$DEVICE-$CDMARADIO.img
fastboot reboot-bootloader
ping -n $SLEEPDURATION 127.0.0.1 >nul
EOF
fi
cat >> tmp/$PRODUCT-$VERSION/flash-all.bat << EOF
fastboot -w update image-$PRODUCT-$VERSION.zip
echo Press any key to exit...
pause >nul
exit
EOF
# Write flash-base.sh
cat > tmp/$PRODUCT-$VERSION/flash-base.sh << EOF
#!/bin/sh
# 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.
EOF
if test "$XLOADER" != ""
then
cat >> tmp/$PRODUCT-$VERSION/flash-base.sh << EOF
fastboot flash xloader xloader-$DEVICE-$XLOADER.img
EOF
fi
cat >> tmp/$PRODUCT-$VERSION/flash-base.sh << EOF
fastboot flash bootloader bootloader-$DEVICE-$BOOTLOADER.img
EOF
if test "$TWINBOOTLOADERS" = "true"
then
cat >> tmp/$PRODUCT-$VERSION/flash-base.sh << EOF
fastboot flash bootloader2 bootloader-$DEVICE-$BOOTLOADER.img
EOF
fi
cat >> tmp/$PRODUCT-$VERSION/flash-base.sh << EOF
fastboot reboot-bootloader
sleep $SLEEPDURATION
EOF
if test "$RADIO" != ""
then
cat >> tmp/$PRODUCT-$VERSION/flash-base.sh << EOF
fastboot flash radio radio-$DEVICE-$RADIO.img
fastboot reboot-bootloader
sleep $SLEEPDURATION
EOF
fi
if test "$CDMARADIO" != ""
then
cat >> tmp/$PRODUCT-$VERSION/flash-base.sh << EOF
fastboot flash radio-cdma radio-cdma-$DEVICE-$CDMARADIO.img
fastboot reboot-bootloader
sleep $SLEEPDURATION
EOF
fi
chmod a+x tmp/$PRODUCT-$VERSION/flash-base.sh
# Create the distributable package
(cd tmp ; tar zcvf ../$PRODUCT-$VERSION-factory.tgz $PRODUCT-$VERSION)
mv $PRODUCT-$VERSION-factory.tgz $PRODUCT-$VERSION-factory-$(sha1sum < $PRODUCT-$VERSION-factory.tgz | cut -b -8).tgz
# Clean up
rm -rf tmp

View File

@ -0,0 +1,133 @@
#!/bin/sh
# 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.
if [ $# != 6 ]
then
echo Usage: $0 BUILD_ID BUILD ROOTDEVICE DEVICE MANUFACTURER PRODUCT
echo Example: $0 1075408 KOT49Y mako mako lge occam
fi
ZIP_TYPE=target_files # ota | target_files
ZIP=$6-$ZIP_TYPE-$1.zip
BUILD=$2
ROOTDEVICE=$3
DEVICE=$4
MANUFACTURER=$5
cd ../$MANUFACTURER/$ROOTDEVICE/self-extractors || echo Error change dir
EXTRACT_LIST_FILENAME=extract-lists.txt
for COMPANY in `grep "[a-z|A-Z])" $EXTRACT_LIST_FILENAME | cut -f1 -d')'`
do
echo Processing files from $COMPANY
rm -rf tmp
FILEDIR=tmp/vendor/$COMPANY/$DEVICE/proprietary
mkdir -p $FILEDIR
mkdir -p tmp/vendor/$MANUFACTURER/$ROOTDEVICE
TO_EXTRACT=`sed -n -e '/'" $COMPANY"'/,/;;/ p' $EXTRACT_LIST_FILENAME | tail -n+3 | head -n-2 | sed -e 's/\\\//g'`
# Check if TO_EXTRACT list has any APK files
if [[ ${TO_EXTRACT} == *.apk* ]]
then
APK_MAKEFILE=${FILEDIR}/Android.mk
echo "LOCAL_PATH := \$(call my-dir)" > ${APK_MAKEFILE}
echo "" >> ${APK_MAKEFILE}
fi
echo \ \ Extracting files from OTA package
for ONE_FILE in $TO_EXTRACT
do
if test ${ZIP_TYPE} = target_files
then
ONE_FILE=`echo $ONE_FILE | sed 's/system\//SYSTEM\//g'`
fi
if [[ $ONE_FILE == */lib64/* ]]
then
FILEDIR_NEW=$FILEDIR/lib64
else
FILEDIR_NEW=$FILEDIR
fi
# apk makefile
if [[ ${ONE_FILE} == *.apk ]]
then
TMP_ONE_FILE_NAME=$(basename ${ONE_FILE} | sed 's/.apk//g')
echo "include \$(CLEAR_VARS)" >> ${APK_MAKEFILE}
echo "LOCAL_MODULE_SUFFIX := \$(COMMON_ANDROID_PACKAGE_SUFFIX)" >> ${APK_MAKEFILE}
echo "LOCAL_MODULE := ${TMP_ONE_FILE_NAME}" >> ${APK_MAKEFILE}
echo "LOCAL_MODULE_TAGS := optional" >> ${APK_MAKEFILE}
echo "LOCAL_BUILT_MODULE_STEM := package.apk" >> ${APK_MAKEFILE}
echo "LOCAL_MODULE_OWNER := ${COMPANY}" >> ${APK_MAKEFILE}
echo "LOCAL_MODULE_CLASS := APPS" >> ${APK_MAKEFILE}
echo "LOCAL_SRC_FILES := \$(LOCAL_MODULE).apk" >> ${APK_MAKEFILE}
echo "LOCAL_CERTIFICATE := PRESIGNED" >> ${APK_MAKEFILE}
if [[ ${TMP_ONE_FILE_NAME} == "LeanbackLauncher" ]]
then
echo "LOCAL_OVERRIDES_PACKAGES := Launcher2" >> ${APK_MAKEFILE}
fi
echo "include \$(BUILD_PREBUILT)" >> ${APK_MAKEFILE}
echo "" >> ${APK_MAKEFILE}
fi
echo \ \ \ \ Extracting $ONE_FILE
unzip -j -o $ZIP $ONE_FILE -d $FILEDIR_NEW> /dev/null || echo \ \ \ \ Error extracting $ONE_FILE
if test ${ONE_FILE,,} = system/vendor/bin/gpsd -o ${ONE_FILE,,} = system/vendor/bin/pvrsrvinit -o ${ONE_FILE,,} = system/bin/fRom
then
chmod a+x $FILEDIR_NEW/$(basename $ONE_FILE) || echo \ \ \ \ Error chmoding $ONE_FILE
fi
ONE_FILE_BASE=$(basename $ONE_FILE)
if [[ $ONE_FILE_BASE == *atmel-a432-*-shamu-p1.tdat ]]
then
ATMEL_FILE=$(ls $FILEDIR_NEW/$ONE_FILE_BASE | cut -f6 -d'/')
sed -i "s/$ONE_FILE_BASE/$ATMEL_FILE/" moto/staging/device-partial.mk
elif [[ $ONE_FILE_BASE == *atmel-a432-*-shamu.tdat ]]
then
ATMEL_FILE=$(ls $FILEDIR_NEW/$ONE_FILE_BASE | cut -f6 -d'/')
sed -i "s/$ONE_FILE_BASE/$ATMEL_FILE/" moto/staging/device-partial.mk
fi
done
echo \ \ Setting up $COMPANY-specific makefiles
cp -R $COMPANY/staging/* tmp/vendor/$COMPANY/$DEVICE || echo \ \ \ \ Error copying makefiles
echo \ \ Setting up shared makefiles
cp -R root/* tmp/vendor/$MANUFACTURER/$ROOTDEVICE || echo \ \ \ \ Error copying makefiles
echo \ \ Generating self-extracting script
SCRIPT=extract-$COMPANY-$DEVICE.sh
cat PROLOGUE > tmp/$SCRIPT || echo \ \ \ \ Error generating script
cat $COMPANY/COPYRIGHT >> tmp/$SCRIPT || echo \ \ \ \ Error generating script
cat PART1 >> tmp/$SCRIPT || echo \ \ \ \ Error generating script
cat $COMPANY/LICENSE >> tmp/$SCRIPT || echo \ \ \ \ Error generating script
cat PART2 >> tmp/$SCRIPT || echo \ \ \ \ Error generating script
echo tail -n +$(expr 2 + $(cat PROLOGUE $COMPANY/COPYRIGHT PART1 $COMPANY/LICENSE PART2 PART3 | wc -l)) \$0 \| tar zxv >> tmp/$SCRIPT || echo \ \ \ \ Error generating script
cat PART3 >> tmp/$SCRIPT || echo \ \ \ \ Error generating script
(cd tmp ; tar zc --owner=root --group=root vendor/ >> $SCRIPT || echo \ \ \ \ Error generating embedded tgz)
chmod a+x tmp/$SCRIPT || echo \ \ \ \ Error generating script
ARCHIVE=$COMPANY-$DEVICE-$BUILD-$(md5sum < tmp/$SCRIPT | cut -b -8 | tr -d \\n).tgz
rm -f $ARCHIVE
echo \ \ Generating final archive
(cd tmp ; tar --owner=root --group=root -z -c -f ../$ARCHIVE $SCRIPT || echo \ \ \ \ Error archiving script)
rm -rf tmp
done

View File

@ -0,0 +1,3 @@
XTRA_SERVER_1=http://xtra1.gpsonextra.net/xtra.bin
XTRA_SERVER_2=http://xtra2.gpsonextra.net/xtra.bin
XTRA_SERVER_3=http://xtra3.gpsonextra.net/xtra.bin

View File

@ -0,0 +1,5 @@
XTRA_SERVER_1=http://xtra1.gpsonextra.net/xtra.bin
XTRA_SERVER_2=http://xtra2.gpsonextra.net/xtra.bin
XTRA_SERVER_3=http://xtra3.gpsonextra.net/xtra.bin
SUPL_HOST=supl.google.com
SUPL_PORT=7276

View File

@ -0,0 +1,3 @@
XTRA_SERVER_1=http://xtra1.gpsonextra.net/xtra.bin
XTRA_SERVER_2=http://xtra2.gpsonextra.net/xtra.bin
XTRA_SERVER_3=http://xtra3.gpsonextra.net/xtra.bin

View File

@ -0,0 +1,5 @@
XTRA_SERVER_1=http://xtra1.gpsonextra.net/xtra.bin
XTRA_SERVER_2=http://xtra2.gpsonextra.net/xtra.bin
XTRA_SERVER_3=http://xtra3.gpsonextra.net/xtra.bin
SUPL_HOST=supl.google.com
SUPL_PORT=7276

View File

@ -0,0 +1,3 @@
XTRA_SERVER_1=http://xtra1.gpsonextra.net/xtra.bin
XTRA_SERVER_2=http://xtra2.gpsonextra.net/xtra.bin
XTRA_SERVER_3=http://xtra3.gpsonextra.net/xtra.bin

View File

@ -0,0 +1,5 @@
XTRA_SERVER_1=http://xtra1.gpsonextra.net/xtra.bin
XTRA_SERVER_2=http://xtra2.gpsonextra.net/xtra.bin
XTRA_SERVER_3=http://xtra3.gpsonextra.net/xtra.bin
SUPL_HOST=supl.google.com
SUPL_PORT=7276

View File

@ -0,0 +1,18 @@
#
# Copyright (C) 2008 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.
#
PRODUCT_COPY_FILES := \
device/common/gps/gps.conf_AS:system/etc/gps.conf

View File

@ -0,0 +1,18 @@
#
# Copyright (C) 2008 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.
#
PRODUCT_COPY_FILES := \
device/common/gps/gps.conf_AS_SUPL:system/etc/gps.conf

View File

@ -0,0 +1,18 @@
#
# Copyright (C) 2008 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.
#
PRODUCT_COPY_FILES := \
device/common/gps/gps.conf_EU:system/etc/gps.conf

View File

@ -0,0 +1,18 @@
#
# Copyright (C) 2008 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.
#
PRODUCT_COPY_FILES := \
device/common/gps/gps.conf_EU_SUPL:system/etc/gps.conf

View File

@ -0,0 +1,18 @@
#
# Copyright (C) 2008 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.
#
PRODUCT_COPY_FILES := \
device/common/gps/gps.conf_US:system/etc/gps.conf

View File

@ -0,0 +1,18 @@
#
# Copyright (C) 2008 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.
#
PRODUCT_COPY_FILES := \
device/common/gps/gps.conf_US_SUPL:system/etc/gps.conf

View File

@ -0,0 +1,186 @@
#!/usr/bin/env bash
# Copyright 2014 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 test "$1" = "" -o "$2" = ""
then
echo "Need a manufacturer name and a device name"
exit 1
fi
mkdir -p device/$1/$2
mkdir -p device/$1/$2-kernel
mkdir -p vendor/$1/$2
cat > device/$1/$2/vendorsetup.sh << EOF
#
# Copyright 2014 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.
#
add_lunch_combo full_$2-userdebug
EOF
cat > device/$1/$2/AndroidProducts.mk << EOF
#
# Copyright 2014 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.
#
PRODUCT_MAKEFILES := \$(LOCAL_DIR)/full_$2.mk
EOF
cat > device/$1/$2/full_$2.mk << EOF
#
# Copyright 2014 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.
#
\$(call inherit-product, \$(SRC_TARGET_DIR)/product/full_base.mk)
\$(call inherit-product, device/$1/$2/device.mk)
PRODUCT_NAME := full_$2
PRODUCT_DEVICE := $2
PRODUCT_BRAND := Android
PRODUCT_MODEL := $2
PRODUCT_MANUFACTURER := $1
EOF
cat > device/$1/$2/device.mk << EOF
#
# Copyright 2014 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.
#
ifeq (\$(TARGET_PREBUILT_KERNEL),)
LOCAL_KERNEL := device/$1/$2-kernel/kernel
else
LOCAL_KERNEL := \$(TARGET_PREBUILT_KERNEL)
endif
PRODUCT_COPY_FILES := \\
\$(LOCAL_KERNEL):kernel
\$(call inherit-product-if-exists, vendor/$1/$2/device-vendor.mk)
EOF
cat > device/$1/$2/BoardConfig.mk << EOF
#
# Copyright 2014 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.
#
# Use the non-open-source parts, if they're present
-include vendor/$1/$2/BoardConfigVendor.mk
TARGET_ARCH := arm
TARGET_ARCH_VARIANT := armv7-a-neon
TARGET_CPU_ABI := armeabi-v7a
TARGET_CPU_ABI2 := armeabi
EOF
touch device/$1/$2-kernel/kernel
touch device/$1/$2-kernel/MODULE_LICENSE_GPL
cat > vendor/$1/$2/device-vendor.mk << EOF
#
# Copyright 2014 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.
#
EOF
cat > vendor/$1/$2/BoardConfigVendor.mk << EOF
#
# Copyright 2014 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.
#
EOF