import exynos 7570 bsp
* source taken from https://github.com/TO21Consortium/SGSWPlatform
Change-Id: I7501b551daeeb5bfeaf44ebe93155272fd8be23a
diff --git a/Android.mk b/Android.mk
new file mode 100644
index 0000000..30fabbc
--- /dev/null
+++ b/Android.mk
@@ -0,0 +1,59 @@
+#############################################################################
+#
+# Copyright (c) 2012 - 2013 Samsung Electronics Co., Ltd
+#
+#############################################################################
+LOCAL_PATH := $(call my-dir)
+
+ifneq ($(BOARD_HAVE_BLUETOOTH_SLSI),)
+
+include $(CLEAR_VARS)
+
+# Setup bdroid local make variables for handling configuration
+ifneq ($(BOARD_BLUETOOTH_BDROID_BUILDCFG_INCLUDE_DIR),)
+ bdroid_C_INCLUDES := $(BOARD_BLUETOOTH_BDROID_BUILDCFG_INCLUDE_DIR)
+ bdroid_CFLAGS := -DHAS_BDROID_BUILDCFG
+else
+ $(warning NO BOARD_BLUETOOTH_BDROID_BUILDCFG_INCLUDE_DIR, using only generic configuration)
+ bdroid_C_INCLUDES :=
+ bdroid_CFLAGS := -DHAS_NO_BDROID_BUILDCFG
+endif
+
+BDROID_DIR := $(TOP_DIR)system/bt
+
+LOCAL_SRC_FILES := \
+ src/bt_vendor_slsi.c
+
+LOCAL_C_INCLUDES += \
+ $(BDROID_DIR)/hci/include \
+ $(BDROID_DIR)/stack/include \
+ $(BDROID_DIR)/include \
+ $(LOCAL_DIR)/include \
+ $(BDROID_DIR) \
+ $(LOCAL_DIR)/include \
+ $(BOARD_BLUETOOTH_BDROID_BUILDCFG_INCLUDE_DIR)
+
+LOCAL_CFLAGS += $(bdroid_CFLAGS)
+
+ifneq ($(TARGET_BUILD_VARIANT),user)
+LOCAL_CFLAGS += -DBTVENDOR_DBG=TRUE
+endif
+
+ifeq ($(CONFIG_SAMSUNG_SCSC_WIFIBT),true)
+# Enable BT/WIFI related code changes in Android source files
+LOCAL_CFLAGS += -DCONFIG_SAMSUNG_SCSC_WIFIBT
+endif
+
+LOCAL_SHARED_LIBRARIES := \
+ libcutils
+
+LOCAL_MODULE := libbt-vendor
+LOCAL_MODULE_OWNER := samsung
+LOCAL_MODULE_TAGS := optional
+
+LOCAL_MODULE_CLASS := SHARED_LIBRARIES
+LOCAL_MODULE_PATH := $(TARGET_OUT_VENDOR_SHARED_LIBRARIES)
+
+include $(BUILD_SHARED_LIBRARY)
+
+endif # BOARD_HAVE_BLUETOOTH_SLSI
diff --git a/conf/bt_did.conf b/conf/bt_did.conf
new file mode 100644
index 0000000..7f6dc08
--- /dev/null
+++ b/conf/bt_did.conf
@@ -0,0 +1,18 @@
+# Device ID (DID) configuration
+[DID1]
+
+# Primary Record - true or false (default)
+# There can be only one primary record
+primaryRecord = true
+
+# Vendor ID '0xFFFF' indicates no Device ID Service Record is present in the device
+# 0x0075 = Samsung Electronics Co. Ltd.
+vendorId = 0x0075
+
+# Product ID & Product Version
+# Per spec DID v1.3 0xJJMN for version is interpreted as JJ.M.N
+# JJ: major version number, M: minor version number, N: sub-minor version number
+# For example: 1200, v14.3.6
+productId = 0x1200
+version = 0x1436
+
diff --git a/conf/bt_vendor.conf b/conf/bt_vendor.conf
new file mode 100644
index 0000000..ca5cc73
--- /dev/null
+++ b/conf/bt_vendor.conf
@@ -0,0 +1,13 @@
+#############################################################################
+#
+# Copyright (c) 2012 - 2014 Samsung Electronics Co., Ltd
+#
+#############################################################################
+# Configuration of which bus to use for handling digital audio data. Valid values are PCM or I2S
+audioBusConfig=I2S
+
+# Configuration of H4 device path
+h4_file=/dev/scsc_h4_0
+
+# Platform codec configuration: 1 route audio between ear-jack and BT for eSCO
+audio_sco_jack=1
\ No newline at end of file
diff --git a/conf/bt_vendor_hammerhead_scsc.conf b/conf/bt_vendor_hammerhead_scsc.conf
new file mode 100644
index 0000000..d7cdafc
--- /dev/null
+++ b/conf/bt_vendor_hammerhead_scsc.conf
@@ -0,0 +1,13 @@
+#############################################################################
+#
+# Copyright (c) 2012 - 2014 Samsung Electronics Co., Ltd
+#
+#############################################################################
+# Configuration of which bus to use for handling digital audio data. Valid values are PCM or I2S
+# audioBusConfig=I2S
+
+# Configuration of H4 device path
+h4_file=/dev/scsc_h4_0
+
+# Platform codec configuration: 1 route audio between ear-jack and BT for eSCO
+# audio_sco_jack=1
diff --git a/include/bdroid_buildcfg.h b/include/bdroid_buildcfg.h
new file mode 100644
index 0000000..90b4cbb
--- /dev/null
+++ b/include/bdroid_buildcfg.h
@@ -0,0 +1,78 @@
+/*
+ * 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 "SLSI S5E7570"
+/**
+ * SD-3510 Increase page timeout value when A2dp is streaming
+ * During A2DP streaming, BT sometimes fails to connect
+ * because of PAGE_TIMEOUT.
+ * BTA_DM_PAGE_TIMEOUT is originally defined in bta_dm_cfg.c
+ */
+#define BTA_DM_PAGE_TIMEOUT 8192
+
+/**
+ * SD-996 Increase MAX_L2CAP_CHANNELS
+ * L2CAP: MAX_L2CAP_CHANNELS is now defined to 20 in order to be able
+ * to connect to 7 HID devices or 5 HID devices and a Stereo Headset
+ * which support AV, AVRCP and HFG
+ * Originally defined in bt_target.h
+ */
+#define MAX_L2CAP_CHANNELS (20)
+
+/**
+ * SD-1101 Optimize RX SPP throughput
+ * Optimize RX SPP throughput by making sure that
+ * the Peer device do not run out of rfcomm credits
+ * Originally defined in bt_target.h
+ * SSB-5680: Re-optimize for OPP throughput
+ */
+#define PORT_RX_BUF_LOW_WM (20)
+#define PORT_RX_BUF_HIGH_WM (40)
+#define PORT_RX_BUF_CRITICAL_WM (45)
+
+/**
+ * SD-2893 Optimize MTU used by the RFCOMM socket
+ * Optimize the MTU used by the RFCOMM socket by
+ * defining a MTU that can be sent in one l2cap packet
+ * Originally defined in bta_jv_api.h
+ */
+#define BTA_JV_DEF_RFC_MTU (1011)
+
+/*
+ * SSB-213 New extension channel needed for Android-defined vendor specific commands.
+ * Toggles support for vendor specific extensions such as RPA offloading,
+ * feature discovery, multi-adv etc.
+ */
+#define BLE_VND_INCLUDED TRUE
+
+/**
+ * SSB-4621 Change number of credits allocated for Bluetooth LE data in the Android host
+ * Based in investigations initiated by MTK-86 it is recommended to change the number of
+ * credits allocated for BLE data from 1 (default) to 2.
+ */
+#define L2C_DEF_NUM_BLE_BUF_SHARED 2
+
+/**
+ * SSB-582 Improve data scheduling to HCI when A2DP is involved
+ * Ensure that A2DP data is scheduled in a way that suits the scheduling in Coex and BT-only scenarios
+ */
+#define L2CAP_HIGH_PRI_MIN_XMIT_QUOTA 13
+#define MIN_NUMBER_A2DP_SDUS 3
+
+#endif
diff --git a/include/bt_vendor_slsi.h b/include/bt_vendor_slsi.h
new file mode 100644
index 0000000..a8107eb
--- /dev/null
+++ b/include/bt_vendor_slsi.h
@@ -0,0 +1,37 @@
+/****************************************************************************
+ *
+ * Copyright (c) 2012 - 2013 Samsung Electronics Co., Ltd
+ *
+ ****************************************************************************/
+#ifndef BT_VENDOR_SLSI_H__
+#define BT_VENDOR_SLSI_H__
+
+#ifndef CONFIG_SAMSUNG_SCSC_WIFIBT
+#error "CONFIG_SAMSUNG_SCSC_WIFIBT not defined"
+#endif
+
+#include <cutils/log.h>
+
+#include "bt_types.h"
+#include "btm_api.h"
+
+#ifndef BTVENDOR_DBG
+#define BTVENDOR_DBG FALSE
+#endif
+
+#define BTVENDORE(param, ...) { ALOGE(param, ## __VA_ARGS__); }
+
+#if (BTVENDOR_DBG == TRUE)
+#define BTVENDORD(param, ...) { ALOGD(param, ## __VA_ARGS__); }
+#define BTVENDORI(param, ...) { ALOGI(param, ## __VA_ARGS__); }
+#define BTVENDORV(param, ...) { ALOGV(param, ## __VA_ARGS__); }
+#define BTVENDORW(param, ...) { ALOGW(param, ## __VA_ARGS__); }
+#else
+#define BTVENDORD(param, ...) {}
+#define BTVENDORI(param, ...) {}
+#define BTVENDORV(param, ...) {}
+#define BTVENDORW(param, ...) {}
+#endif
+#define SCSC_UNUSED(x) (void)(x)
+
+#endif
diff --git a/src/bt_vendor_slsi.c b/src/bt_vendor_slsi.c
new file mode 100644
index 0000000..4e93300
--- /dev/null
+++ b/src/bt_vendor_slsi.c
@@ -0,0 +1,292 @@
+/****************************************************************************
+ *
+ * Copyright (c) 2012 - 2013 Samsung Electronics Co., Ltd
+ *
+ ****************************************************************************/
+#ifndef _BSD_SOURCE
+#define _BSD_SOURCE
+#endif
+
+#define LOG_TAG "BT_VENDOR"
+
+#include <endian.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <string.h>
+#include <sys/param.h>
+
+#include "bt_vendor_lib.h"
+
+#include "bt_vendor_slsi.h"
+
+/**
+ * SSB-5242 Route HCI I/F over ABD to driver on PC.
+ */
+#ifndef ENABLE_HCI_TUNNELLING
+#define ENABLE_HCI_TUNNELLING FALSE
+#endif /* !ENABLE_HCI_TUNNELLING */
+#if defined(ENABLE_HCI_TUNNELLING) && (ENABLE_HCI_TUNNELLING == TRUE)
+#include <netinet/in.h>
+#include <netdb.h>
+#endif
+
+#define BLUETOOTH_ADDRESS_FILE "/sys/module/scsc_bt/parameters/bluetooth_address"
+
+/**
+ * SSB-5242 Route HCI I/F over ABD to driver on PC.
+ */
+#if defined(ENABLE_HCI_TUNNELLING) && (ENABLE_HCI_TUNNELLING == TRUE)
+static int hci_tunnelling_port_num = 10157;
+#endif
+
+static const bt_vendor_callbacks_t *vcb;
+static unsigned long long bt_addr;
+
+static char h4_file[MAXPATHLEN] = "/dev/scsc_h4_0";
+static int hci_fd = -1;
+
+/*
+ * Internal helpers
+ */
+
+static void set_bluetooth_address(unsigned long long value)
+{
+ BTVENDORI("Setting Bluetooth address");
+ if (!access(BLUETOOTH_ADDRESS_FILE, W_OK))
+ {
+ int bt_fd = open(BLUETOOTH_ADDRESS_FILE, O_RDWR);
+ if (bt_fd != -1)
+ {
+ char buf[15];
+ ssize_t res;
+
+ res = sprintf(buf, "0x%llx", value);
+ if (res != write(bt_fd, buf, res))
+ {
+ BTVENDORW("Unable setiting Bluetooth address (%s)", strerror(errno));
+ }
+ close(bt_fd);
+ }
+ else
+ {
+ BTVENDORW("Opening file: " BLUETOOTH_ADDRESS_FILE " - failed with: %s", strerror(errno));
+ }
+ }
+ else
+ {
+ BTVENDORW("Unable to access: " BLUETOOTH_ADDRESS_FILE " - error: %s", strerror(errno));
+ }
+}
+
+/*
+ * Internal interface
+ */
+
+/**
+ * SSB-5242 Route HCI I/F over ABD to driver on PC.
+ */
+#if defined(ENABLE_HCI_TUNNELLING) && (ENABLE_HCI_TUNNELLING == TRUE)
+static int socket_open_client(int port_num)
+{
+ struct sockaddr_in serv_addr;
+ struct hostent *server;
+ int fd = -1;
+
+ BTVENDORI("HCI Tunnelling: socket_open_client(): port: 0x%08x.", port_num);
+
+ fd = socket(AF_INET, SOCK_STREAM, 0);
+
+ if (fd < 0)
+ {
+ BTVENDORE("HCI Tunnelling: socket_open_client(): error from socket(), errno:0x%08x:%s.", errno, strerror(errno));
+ fd = -1;
+ return fd;
+ }
+
+ BTVENDORI("HCI Tunnelling: socket_open_client(): port: 0x%08x, fd: 0x%08x.", port_num, fd);
+
+ server = gethostbyname("localhost");
+
+ if (server == NULL)
+ {
+ BTVENDORE("HCI Tunnelling: socket_open_client(): error from gethostbyname(), errno:0x%08x:%s, fd: 0x%08x.", errno, strerror(errno), fd);
+ fd = -1;
+ return fd;
+ }
+
+ bzero((char *) &serv_addr, sizeof(serv_addr));
+ serv_addr.sin_family = AF_INET;
+ bcopy((char *) server->h_addr, (char *) &serv_addr.sin_addr.s_addr, server->h_length);
+ serv_addr.sin_port = htons(port_num);
+
+ if (connect(fd, (struct sockaddr *) &serv_addr, sizeof(serv_addr)) < 0)
+ {
+ BTVENDORE("HCI Tunnelling: socket_open_client(): error from connect(), errno:0x%08x:%s, fd: 0x%08x.", errno, strerror(errno), fd);
+ fd = -1;
+ return fd;
+ }
+
+ BTVENDORI("HCI Tunnelling: socket_open_client(): OK, fd:0x%08x.", fd);
+
+ return fd;
+}
+#endif
+
+static int hci_open(int *fds)
+{
+ int h4_fd;
+
+ BTVENDORI("HCI open");
+
+/**
+ * SSB-5242 Route HCI I/F over ADB to driver on PC.
+ */
+#if defined(ENABLE_HCI_TUNNELLING) && (ENABLE_HCI_TUNNELLING == TRUE)
+ h4_fd = socket_open_client(hci_tunnelling_port_num);
+#else
+ if (bt_addr != 0)
+ {
+ set_bluetooth_address(bt_addr);
+ }
+
+ BTVENDORI("Opening h4 device %s", h4_file);
+ h4_fd = open(h4_file, O_RDWR);
+#endif
+ if (h4_fd == -1)
+ {
+ BTVENDORE("Open h4 device failed: %s (%d)", strerror(errno), errno);
+ return -1;
+ }
+
+ BTVENDORI("Open h4 device %s succeded", h4_file);
+
+ hci_fd = h4_fd;
+ *fds = h4_fd;
+
+ return 1;
+}
+
+static int hci_close(void)
+{
+ int fd = hci_fd;
+
+ if (bt_addr != 0)
+ {
+ set_bluetooth_address(0);
+ }
+
+ hci_fd = -1;
+ return close(fd);
+}
+
+static int init(const bt_vendor_callbacks_t *p_cb, unsigned char *local_bdaddr)
+{
+ /* Sanity check */
+ if (p_cb == NULL)
+ {
+ ALOGE("init failed with no user callbacks!");
+ return -1;
+ }
+
+ /* Store a reference to user callbacks */
+ vcb = (bt_vendor_callbacks_t *) p_cb;
+
+ /* Store the Bluetooth address */
+ bt_addr = (((unsigned long long) local_bdaddr[0]) << 40) |
+ (((unsigned long long) local_bdaddr[1]) << 32) |
+ (((unsigned long long) local_bdaddr[2]) << 24) |
+ (((unsigned long long) local_bdaddr[3]) << 16) |
+ (((unsigned long long) local_bdaddr[4]) << 8) |
+ ((unsigned long long) local_bdaddr[5]);
+
+ return 0;
+}
+
+static int op(bt_vendor_opcode_t opcode, void *param)
+{
+ int retval = 0;
+
+ switch (opcode)
+ {
+ case BT_VND_OP_POWER_CTRL:
+ {
+ break;
+ }
+ case BT_VND_OP_FW_CFG:
+ {
+ vcb->fwcfg_cb(BT_VND_OP_RESULT_SUCCESS);
+ break;
+ }
+ case BT_VND_OP_SCO_CFG:
+ {
+ vcb->scocfg_cb(BT_VND_OP_RESULT_SUCCESS);
+ break;
+ }
+ case BT_VND_OP_USERIAL_OPEN:
+ {
+ retval = hci_open((int *) param);
+ BTVENDORD("hci_open returns: %d", retval);
+ break;
+ }
+ case BT_VND_OP_USERIAL_CLOSE:
+ {
+ retval = hci_close();
+ BTVENDORD("hci_close returns: %d", retval);
+ break;
+ }
+ case BT_VND_OP_GET_LPM_IDLE_TIMEOUT:
+ {
+ uint32_t *timeout_ms = (uint32_t *) param;
+ *timeout_ms = 3000; /* 3 Seconds delay until the idle alarm is fired */
+ break;
+ }
+ case BT_VND_OP_LPM_SET_MODE:
+ {
+ /* LPM not required on SoC solutions - return fail to disable it */
+ vcb->lpm_cb(BT_VND_OP_RESULT_FAIL);
+ break;
+ }
+ case BT_VND_OP_LPM_WAKE_SET_STATE:
+ {
+ break;
+ }
+ case BT_VND_OP_EPILOG:
+ {
+ vcb->epilog_cb(BT_VND_OP_RESULT_SUCCESS);
+ break;
+ }
+ case BT_VND_OP_SET_AUDIO_STATE:
+ {
+ /* Unhandled - just ignore */
+ BTVENDORE("BT_VND_OP_SET_AUDIO_STATE - ignoring");
+ break;
+ }
+ default:
+ {
+ BTVENDORW("Hit default with opcode:0x%02X", opcode);
+ retval = -1;
+ break;
+ }
+ }
+
+ return retval;
+}
+
+static void cleanup(void)
+{
+ if (hci_fd != -1)
+ {
+ int fd = hci_fd;
+ hci_fd = -1;
+ (void) close(fd);
+ }
+
+ return;
+}
+
+const bt_vendor_interface_t BLUETOOTH_VENDOR_LIB_INTERFACE = {
+ sizeof(bt_vendor_interface_t),
+ init,
+ op,
+ cleanup,
+};