Merge changes I5f1a954d,Ibeaac890,Id9f9dfc5 am: deee9bafec am: 86b6dd30be am: 6bc6f57e2f am: 84219d366d
Original change: https://android-review.googlesource.com/c/device/linaro/hikey/+/1770546
Change-Id: I31e3daba8b019eb1455f20e193340f3888c328b8
diff --git a/bluetooth/Android.bp b/bluetooth/Android.bp
deleted file mode 100644
index 79fbcfb..0000000
--- a/bluetooth/Android.bp
+++ /dev/null
@@ -1,54 +0,0 @@
-//
-// Copyright (C) 2017 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.
-
-package {
- // See: http://go/android-license-faq
- // A large-scale-change added 'default_applicable_licenses' to import
- // all of the 'license_kinds' from "device_linaro_hikey_license"
- // to get the below license kinds:
- // SPDX-license-identifier-Apache-2.0
- default_applicable_licenses: ["device_linaro_hikey_license"],
-}
-
-cc_binary {
- name: "android.hardware.bluetooth@1.0-service.hikey",
- proprietary: true,
- relative_install_path: "hw",
- srcs: [
- "async_fd_watcher.cc",
- "bluetooth_hci.cc",
- "h4_protocol.cc",
- "hci_packetizer.cc",
- "hci_protocol.cc",
- "service.cc",
- ],
- cflags: [
- "-Wall",
- "-Werror",
- "-Wno-error=unused-const-variable",
- "-Wno-error=unused-function",
- "-Wno-error=unused-lambda-capture",
- ],
- shared_libs: [
- "android.hardware.bluetooth@1.0",
- "libbase",
- "libcutils",
- "libhardware",
- "libhidlbase",
- "liblog",
- "libutils",
- ],
- init_rc: ["android.hardware.bluetooth@1.0-service.hikey.rc"],
-}
diff --git a/bluetooth/android.hardware.bluetooth@1.0-service.hikey.rc b/bluetooth/android.hardware.bluetooth@1.0-service.hikey.rc
deleted file mode 100644
index 6f31efd..0000000
--- a/bluetooth/android.hardware.bluetooth@1.0-service.hikey.rc
+++ /dev/null
@@ -1,4 +0,0 @@
-service bluetooth-1-0 /vendor/bin/hw/android.hardware.bluetooth@1.0-service.hikey
- class hal
- user bluetooth
- group bluetooth
diff --git a/bluetooth/async_fd_watcher.cc b/bluetooth/async_fd_watcher.cc
deleted file mode 100644
index c4470d0..0000000
--- a/bluetooth/async_fd_watcher.cc
+++ /dev/null
@@ -1,181 +0,0 @@
-//
-// Copyright 2016 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.
-//
-
-#include "async_fd_watcher.h"
-
-#include <algorithm>
-#include <atomic>
-#include <condition_variable>
-#include <map>
-#include <mutex>
-#include <thread>
-#include <vector>
-#include "fcntl.h"
-#include "sys/select.h"
-#include "unistd.h"
-
-static const int INVALID_FD = -1;
-
-namespace android {
-namespace hardware {
-namespace bluetooth {
-namespace async {
-
-int AsyncFdWatcher::WatchFdForNonBlockingReads(
- int file_descriptor, const ReadCallback& on_read_fd_ready_callback) {
- // Add file descriptor and callback
- {
- std::unique_lock<std::mutex> guard(internal_mutex_);
- watched_fds_[file_descriptor] = on_read_fd_ready_callback;
- }
-
- // Start the thread if not started yet
- return tryStartThread();
-}
-
-int AsyncFdWatcher::ConfigureTimeout(
- const std::chrono::milliseconds timeout,
- const TimeoutCallback& on_timeout_callback) {
- // Add timeout and callback
- {
- std::unique_lock<std::mutex> guard(timeout_mutex_);
- timeout_cb_ = on_timeout_callback;
- timeout_ms_ = timeout;
- }
-
- notifyThread();
- return 0;
-}
-
-void AsyncFdWatcher::StopWatchingFileDescriptors() { stopThread(); }
-
-AsyncFdWatcher::~AsyncFdWatcher() {}
-
-// Make sure to call this with at least one file descriptor ready to be
-// watched upon or the thread routine will return immediately
-int AsyncFdWatcher::tryStartThread() {
- if (std::atomic_exchange(&running_, true)) return 0;
-
- // Set up the communication channel
- int pipe_fds[2];
- if (pipe2(pipe_fds, O_NONBLOCK)) return -1;
-
- notification_listen_fd_ = pipe_fds[0];
- notification_write_fd_ = pipe_fds[1];
-
- thread_ = std::thread([this]() { ThreadRoutine(); });
- if (!thread_.joinable()) return -1;
-
- return 0;
-}
-
-int AsyncFdWatcher::stopThread() {
- if (!std::atomic_exchange(&running_, false)) return 0;
-
- notifyThread();
- if (std::this_thread::get_id() != thread_.get_id()) {
- thread_.join();
- }
-
- {
- std::unique_lock<std::mutex> guard(internal_mutex_);
- watched_fds_.clear();
- }
-
- {
- std::unique_lock<std::mutex> guard(timeout_mutex_);
- timeout_cb_ = nullptr;
- }
-
- return 0;
-}
-
-int AsyncFdWatcher::notifyThread() {
- uint8_t buffer[] = {0};
- if (TEMP_FAILURE_RETRY(write(notification_write_fd_, &buffer, 1)) < 0) {
- return -1;
- }
- return 0;
-}
-
-void AsyncFdWatcher::ThreadRoutine() {
- while (running_) {
- fd_set read_fds;
- FD_ZERO(&read_fds);
- FD_SET(notification_listen_fd_, &read_fds);
- int max_read_fd = INVALID_FD;
- for (auto& it : watched_fds_) {
- FD_SET(it.first, &read_fds);
- max_read_fd = std::max(max_read_fd, it.first);
- }
-
- struct timeval timeout;
- struct timeval* timeout_ptr = NULL;
- if (timeout_ms_ > std::chrono::milliseconds(0)) {
- timeout.tv_sec = timeout_ms_.count() / 1000;
- timeout.tv_usec = (timeout_ms_.count() % 1000) * 1000;
- timeout_ptr = &timeout;
- }
-
- // Wait until there is data available to read on some FD.
- int nfds = std::max(notification_listen_fd_, max_read_fd);
- int retval = select(nfds + 1, &read_fds, NULL, NULL, timeout_ptr);
-
- // There was some error.
- if (retval < 0) continue;
-
- // Timeout.
- if (retval == 0) {
- // Allow the timeout callback to modify the timeout.
- TimeoutCallback saved_cb;
- {
- std::unique_lock<std::mutex> guard(timeout_mutex_);
- if (timeout_ms_ > std::chrono::milliseconds(0)) saved_cb = timeout_cb_;
- }
- if (saved_cb != nullptr) saved_cb();
- continue;
- }
-
- // Read data from the notification FD.
- if (FD_ISSET(notification_listen_fd_, &read_fds)) {
- char buffer[] = {0};
- TEMP_FAILURE_RETRY(read(notification_listen_fd_, buffer, 1));
- continue;
- }
-
- // Invoke the data ready callbacks if appropriate.
- std::vector<decltype(watched_fds_)::value_type> saved_callbacks;
- {
- std::unique_lock<std::mutex> guard(internal_mutex_);
- for (auto& it : watched_fds_) {
- if (FD_ISSET(it.first, &read_fds)) {
- saved_callbacks.push_back(it);
- }
- }
- }
-
- for (auto& it : saved_callbacks) {
- if (it.second) {
- it.second(it.first);
- }
- }
- }
-}
-
-} // namespace async
-} // namespace bluetooth
-} // namespace hardware
-} // namespace android
diff --git a/bluetooth/async_fd_watcher.h b/bluetooth/async_fd_watcher.h
deleted file mode 100644
index b51f921..0000000
--- a/bluetooth/async_fd_watcher.h
+++ /dev/null
@@ -1,66 +0,0 @@
-//
-// Copyright 2016 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.
-//
-
-#pragma once
-
-#include <map>
-#include <mutex>
-#include <thread>
-
-namespace android {
-namespace hardware {
-namespace bluetooth {
-namespace async {
-
-using ReadCallback = std::function<void(int)>;
-using TimeoutCallback = std::function<void(void)>;
-
-class AsyncFdWatcher {
- public:
- AsyncFdWatcher() = default;
- ~AsyncFdWatcher();
-
- int WatchFdForNonBlockingReads(int file_descriptor,
- const ReadCallback& on_read_fd_ready_callback);
- int ConfigureTimeout(const std::chrono::milliseconds timeout,
- const TimeoutCallback& on_timeout_callback);
- void StopWatchingFileDescriptors();
-
- private:
- AsyncFdWatcher(const AsyncFdWatcher&) = delete;
- AsyncFdWatcher& operator=(const AsyncFdWatcher&) = delete;
-
- int tryStartThread();
- int stopThread();
- int notifyThread();
- void ThreadRoutine();
-
- std::atomic_bool running_{false};
- std::thread thread_;
- std::mutex internal_mutex_;
- std::mutex timeout_mutex_;
-
- std::map<int, ReadCallback> watched_fds_;
- int notification_listen_fd_;
- int notification_write_fd_;
- TimeoutCallback timeout_cb_;
- std::chrono::milliseconds timeout_ms_;
-};
-
-} // namespace async
-} // namespace bluetooth
-} // namespace hardware
-} // namespace android
diff --git a/bluetooth/bluetooth_hci.cc b/bluetooth/bluetooth_hci.cc
deleted file mode 100644
index fe2b782..0000000
--- a/bluetooth/bluetooth_hci.cc
+++ /dev/null
@@ -1,124 +0,0 @@
-//
-// Copyright 2016 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.
-//
-
-#define LOG_TAG "android.hardware.bluetooth@1.0.hikey"
-
-#include "bluetooth_hci.h"
-
-#include <android-base/logging.h>
-#include <sys/ioctl.h>
-#include <sys/socket.h>
-#include <unistd.h>
-#include <utils/Log.h>
-
-namespace android {
-namespace hardware {
-namespace bluetooth {
-namespace V1_0 {
-namespace hikey {
-
-using android::hardware::hidl_vec;
-
-BluetoothHci::BluetoothHci()
- : deathRecipient(new BluetoothDeathRecipient(this)) {}
-
-Return<void> BluetoothHci::initialize(
- const ::android::sp<IBluetoothHciCallbacks>& cb) {
- ALOGI("BluetoothHci::initialize()");
-
- hci_tty_fd_ = open("/dev/hci_tty", O_RDWR);
- if (hci_tty_fd_ < 0) {
- ALOGE("%s: Can't open hci_tty (%s)", __func__, strerror(errno));
- cb->initializationComplete(Status::INITIALIZATION_ERROR);
- return Void();
- }
-
- event_cb_ = cb;
- event_cb_->linkToDeath(deathRecipient, 0);
-
- hci_ = new hci::H4Protocol(
- hci_tty_fd_,
- [cb](const hidl_vec<uint8_t>& packet) { cb->hciEventReceived(packet); },
- [cb](const hidl_vec<uint8_t>& packet) { cb->aclDataReceived(packet); },
- [cb](const hidl_vec<uint8_t>& packet) { cb->scoDataReceived(packet); });
-
- // Use a socket pair to enforce the TI FIONREAD requirement.
- int sockfd[2];
- socketpair(AF_LOCAL, SOCK_STREAM, 0, sockfd);
- int shim_fd = sockfd[0];
- int for_hci = sockfd[1];
-
- fd_watcher_.WatchFdForNonBlockingReads(hci_tty_fd_, [this, shim_fd](int fd) {
- int tty_bytes = 0;
- if (TEMP_FAILURE_RETRY(ioctl(fd, FIONREAD, &tty_bytes)))
- ALOGE("%s:FIONREAD %s", __func__, strerror(errno));
- ALOGV("%s:tty_bytes = %d", __func__, tty_bytes);
-
- uint8_t* tmp_buffer = new uint8_t[tty_bytes];
- size_t bytes_read = TEMP_FAILURE_RETRY(read(fd, tmp_buffer, tty_bytes));
- CHECK(static_cast<int>(bytes_read) == tty_bytes);
- size_t bytes_written =
- TEMP_FAILURE_RETRY(write(shim_fd, tmp_buffer, tty_bytes));
- CHECK(static_cast<int>(bytes_written) == tty_bytes);
- delete[] tmp_buffer;
- });
-
- fd_watcher_.WatchFdForNonBlockingReads(
- for_hci, [this](int fd) { hci_->OnDataReady(fd); });
-
- cb->initializationComplete(Status::SUCCESS);
- return Void();
-}
-
-Return<void> BluetoothHci::close() {
- ALOGI("BluetoothHci::close()");
-
- if (hci_tty_fd_ >= 0) {
- fd_watcher_.StopWatchingFileDescriptors();
- ::close(hci_tty_fd_);
- hci_tty_fd_ = -1;
- }
-
- event_cb_->unlinkToDeath(deathRecipient);
-
- if (hci_ != nullptr) {
- delete hci_;
- hci_ = nullptr;
- }
-
- return Void();
-}
-
-Return<void> BluetoothHci::sendHciCommand(const hidl_vec<uint8_t>& packet) {
- hci_->Send(HCI_PACKET_TYPE_COMMAND, packet.data(), packet.size());
- return Void();
-}
-
-Return<void> BluetoothHci::sendAclData(const hidl_vec<uint8_t>& packet) {
- hci_->Send(HCI_PACKET_TYPE_ACL_DATA, packet.data(), packet.size());
- return Void();
-}
-
-Return<void> BluetoothHci::sendScoData(const hidl_vec<uint8_t>& packet) {
- hci_->Send(HCI_PACKET_TYPE_SCO_DATA, packet.data(), packet.size());
- return Void();
-}
-
-} // namespace hikey
-} // namespace V1_0
-} // namespace bluetooth
-} // namespace hardware
-} // namespace android
diff --git a/bluetooth/bluetooth_hci.h b/bluetooth/bluetooth_hci.h
deleted file mode 100644
index 2f1015a..0000000
--- a/bluetooth/bluetooth_hci.h
+++ /dev/null
@@ -1,73 +0,0 @@
-//
-// Copyright 2017 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.
-//
-
-#pragma once
-
-#include <android/hardware/bluetooth/1.0/IBluetoothHci.h>
-
-#include <hidl/MQDescriptor.h>
-
-#include "async_fd_watcher.h"
-#include "h4_protocol.h"
-
-namespace android {
-namespace hardware {
-namespace bluetooth {
-namespace V1_0 {
-namespace hikey {
-
-using ::android::hardware::Return;
-using ::android::hardware::hidl_vec;
-
-struct BluetoothDeathRecipient : hidl_death_recipient {
- BluetoothDeathRecipient(const sp<IBluetoothHci> hci) : mHci(hci) {}
-
- virtual void serviceDied(
- uint64_t /*cookie*/,
- const wp<::android::hidl::base::V1_0::IBase>& /*who*/) {
- mHci->close();
- }
- sp<IBluetoothHci> mHci;
-};
-
-class BluetoothHci : public IBluetoothHci {
- public:
- BluetoothHci();
- Return<void> initialize(
- const ::android::sp<IBluetoothHciCallbacks>& cb) override;
- Return<void> sendHciCommand(const hidl_vec<uint8_t>& packet) override;
- Return<void> sendAclData(const hidl_vec<uint8_t>& packet) override;
- Return<void> sendScoData(const hidl_vec<uint8_t>& packet) override;
- Return<void> close() override;
-
- static void OnPacketReady();
-
- private:
- ::android::sp<IBluetoothHciCallbacks> event_cb_;
- int hci_tty_fd_;
-
- async::AsyncFdWatcher fd_watcher_;
-
- hci::H4Protocol* hci_;
-
- ::android::sp<BluetoothDeathRecipient> deathRecipient;
-};
-
-} // namespace hikey
-} // namespace V1_0
-} // namespace bluetooth
-} // namespace hardware
-} // namespace android
diff --git a/bluetooth/h4_protocol.cc b/bluetooth/h4_protocol.cc
deleted file mode 100644
index 8f24b5e..0000000
--- a/bluetooth/h4_protocol.cc
+++ /dev/null
@@ -1,71 +0,0 @@
-//
-// Copyright 2017 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.
-//
-
-#include "h4_protocol.h"
-
-#define LOG_TAG "android.hardware.bluetooth-hci-h4"
-#include <android-base/logging.h>
-#include <assert.h>
-#include <fcntl.h>
-
-namespace android {
-namespace hardware {
-namespace bluetooth {
-namespace hci {
-
-size_t H4Protocol::Send(uint8_t type, const uint8_t* data, size_t length) {
- int rv = WriteSafely(uart_fd_, &type, sizeof(type));
- if (rv == sizeof(type)) {
- rv = WriteSafely(uart_fd_, data, length);
- }
- return rv;
-}
-
-void H4Protocol::OnPacketReady() {
- switch (hci_packet_type_) {
- case HCI_PACKET_TYPE_EVENT:
- event_cb_(hci_packetizer_.GetPacket());
- break;
- case HCI_PACKET_TYPE_ACL_DATA:
- acl_cb_(hci_packetizer_.GetPacket());
- break;
- case HCI_PACKET_TYPE_SCO_DATA:
- sco_cb_(hci_packetizer_.GetPacket());
- break;
- default: {
- bool bad_packet_type = true;
- CHECK(!bad_packet_type);
- }
- }
- // Get ready for the next type byte.
- hci_packet_type_ = HCI_PACKET_TYPE_UNKNOWN;
-}
-
-void H4Protocol::OnDataReady(int fd) {
- if (hci_packet_type_ == HCI_PACKET_TYPE_UNKNOWN) {
- uint8_t buffer[1] = {0};
- size_t bytes_read = TEMP_FAILURE_RETRY(read(fd, buffer, 1));
- CHECK(bytes_read == 1);
- hci_packet_type_ = static_cast<HciPacketType>(buffer[0]);
- } else {
- hci_packetizer_.OnDataReady(fd, hci_packet_type_);
- }
-}
-
-} // namespace hci
-} // namespace bluetooth
-} // namespace hardware
-} // namespace android
diff --git a/bluetooth/h4_protocol.h b/bluetooth/h4_protocol.h
deleted file mode 100644
index 67e2b03..0000000
--- a/bluetooth/h4_protocol.h
+++ /dev/null
@@ -1,60 +0,0 @@
-//
-// Copyright 2017 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.
-//
-
-#pragma once
-
-#include <hidl/HidlSupport.h>
-
-#include "async_fd_watcher.h"
-#include "hci_internals.h"
-#include "hci_protocol.h"
-
-namespace android {
-namespace hardware {
-namespace bluetooth {
-namespace hci {
-
-class H4Protocol : public HciProtocol {
- public:
- H4Protocol(int fd, PacketReadCallback event_cb, PacketReadCallback acl_cb,
- PacketReadCallback sco_cb)
- : uart_fd_(fd),
- event_cb_(event_cb),
- acl_cb_(acl_cb),
- sco_cb_(sco_cb),
- hci_packetizer_([this]() { OnPacketReady(); }) {}
-
- size_t Send(uint8_t type, const uint8_t* data, size_t length);
-
- void OnPacketReady();
-
- void OnDataReady(int fd);
-
- private:
- int uart_fd_;
-
- PacketReadCallback event_cb_;
- PacketReadCallback acl_cb_;
- PacketReadCallback sco_cb_;
-
- HciPacketType hci_packet_type_{HCI_PACKET_TYPE_UNKNOWN};
- hci::HciPacketizer hci_packetizer_;
-};
-
-} // namespace hci
-} // namespace bluetooth
-} // namespace hardware
-} // namespace android
diff --git a/bluetooth/hci_internals.h b/bluetooth/hci_internals.h
deleted file mode 100644
index 1e1f300..0000000
--- a/bluetooth/hci_internals.h
+++ /dev/null
@@ -1,49 +0,0 @@
-//
-// Copyright 2016 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.
-//
-
-#pragma once
-
-#include <stdlib.h>
-
-// HCI UART transport packet types (Volume 4, Part A, 2)
-enum HciPacketType {
- HCI_PACKET_TYPE_UNKNOWN = 0,
- HCI_PACKET_TYPE_COMMAND = 1,
- HCI_PACKET_TYPE_ACL_DATA = 2,
- HCI_PACKET_TYPE_SCO_DATA = 3,
- HCI_PACKET_TYPE_EVENT = 4
-};
-
-// 2 bytes for opcode, 1 byte for parameter length (Volume 2, Part E, 5.4.1)
-const size_t HCI_COMMAND_PREAMBLE_SIZE = 3;
-const size_t HCI_LENGTH_OFFSET_CMD = 2;
-
-// 2 bytes for handle, 2 bytes for data length (Volume 2, Part E, 5.4.2)
-const size_t HCI_ACL_PREAMBLE_SIZE = 4;
-const size_t HCI_LENGTH_OFFSET_ACL = 2;
-
-// 2 bytes for handle, 1 byte for data length (Volume 2, Part E, 5.4.3)
-const size_t HCI_SCO_PREAMBLE_SIZE = 3;
-const size_t HCI_LENGTH_OFFSET_SCO = 2;
-
-// 1 byte for event code, 1 byte for parameter length (Volume 2, Part E, 5.4.4)
-const size_t HCI_EVENT_PREAMBLE_SIZE = 2;
-const size_t HCI_LENGTH_OFFSET_EVT = 1;
-
-const size_t HCI_PREAMBLE_SIZE_MAX = HCI_ACL_PREAMBLE_SIZE;
-
-// Event codes (Volume 2, Part E, 7.7.14)
-const uint8_t HCI_COMMAND_COMPLETE_EVENT = 0x0E;
diff --git a/bluetooth/hci_packetizer.cc b/bluetooth/hci_packetizer.cc
deleted file mode 100644
index 9549858..0000000
--- a/bluetooth/hci_packetizer.cc
+++ /dev/null
@@ -1,91 +0,0 @@
-//
-// Copyright 2017 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.
-//
-
-#include "hci_packetizer.h"
-
-#define LOG_TAG "android.hardware.bluetooth.hci_packetizer"
-#include <android-base/logging.h>
-#include <utils/Log.h>
-
-#include <dlfcn.h>
-#include <fcntl.h>
-
-namespace {
-
-const size_t preamble_size_for_type[] = {
- 0, HCI_COMMAND_PREAMBLE_SIZE, HCI_ACL_PREAMBLE_SIZE, HCI_SCO_PREAMBLE_SIZE,
- HCI_EVENT_PREAMBLE_SIZE};
-const size_t packet_length_offset_for_type[] = {
- 0, HCI_LENGTH_OFFSET_CMD, HCI_LENGTH_OFFSET_ACL, HCI_LENGTH_OFFSET_SCO,
- HCI_LENGTH_OFFSET_EVT};
-
-size_t HciGetPacketLengthForType(HciPacketType type, const uint8_t* preamble) {
- size_t offset = packet_length_offset_for_type[type];
- if (type != HCI_PACKET_TYPE_ACL_DATA) return preamble[offset];
- return (((preamble[offset + 1]) << 8) | preamble[offset]);
-}
-
-} // namespace
-
-namespace android {
-namespace hardware {
-namespace bluetooth {
-namespace hci {
-
-const hidl_vec<uint8_t>& HciPacketizer::GetPacket() const { return packet_; }
-
-void HciPacketizer::OnDataReady(int fd, HciPacketType packet_type) {
- switch (state_) {
- case HCI_PREAMBLE: {
- size_t bytes_read = TEMP_FAILURE_RETRY(
- read(fd, preamble_ + bytes_read_,
- preamble_size_for_type[packet_type] - bytes_read_));
- CHECK(bytes_read > 0);
- bytes_read_ += bytes_read;
- if (bytes_read_ == preamble_size_for_type[packet_type]) {
- size_t packet_length =
- HciGetPacketLengthForType(packet_type, preamble_);
- packet_.resize(preamble_size_for_type[packet_type] + packet_length);
- memcpy(packet_.data(), preamble_, preamble_size_for_type[packet_type]);
- bytes_remaining_ = packet_length;
- state_ = HCI_PAYLOAD;
- bytes_read_ = 0;
- }
- break;
- }
-
- case HCI_PAYLOAD: {
- size_t bytes_read = TEMP_FAILURE_RETRY(read(
- fd,
- packet_.data() + preamble_size_for_type[packet_type] + bytes_read_,
- bytes_remaining_));
- CHECK(bytes_read > 0);
- bytes_remaining_ -= bytes_read;
- bytes_read_ += bytes_read;
- if (bytes_remaining_ == 0) {
- packet_ready_cb_();
- state_ = HCI_PREAMBLE;
- bytes_read_ = 0;
- }
- break;
- }
- }
-}
-
-} // namespace hci
-} // namespace bluetooth
-} // namespace hardware
-} // namespace android
diff --git a/bluetooth/hci_packetizer.h b/bluetooth/hci_packetizer.h
deleted file mode 100644
index 90579bd..0000000
--- a/bluetooth/hci_packetizer.h
+++ /dev/null
@@ -1,53 +0,0 @@
-//
-// Copyright 2017 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.
-//
-
-#pragma once
-
-#include <functional>
-
-#include <hidl/HidlSupport.h>
-
-#include "hci_internals.h"
-
-namespace android {
-namespace hardware {
-namespace bluetooth {
-namespace hci {
-
-using ::android::hardware::hidl_vec;
-using HciPacketReadyCallback = std::function<void(void)>;
-
-class HciPacketizer {
- public:
- HciPacketizer(HciPacketReadyCallback packet_cb)
- : packet_ready_cb_(packet_cb){};
- void OnDataReady(int fd, HciPacketType packet_type);
- const hidl_vec<uint8_t>& GetPacket() const;
-
- protected:
- enum State { HCI_PREAMBLE, HCI_PAYLOAD };
- State state_{HCI_PREAMBLE};
- uint8_t preamble_[HCI_PREAMBLE_SIZE_MAX];
- hidl_vec<uint8_t> packet_;
- size_t bytes_remaining_{0};
- size_t bytes_read_{0};
- HciPacketReadyCallback packet_ready_cb_;
-};
-
-} // namespace hci
-} // namespace bluetooth
-} // namespace hardware
-} // namespace android
diff --git a/bluetooth/hci_protocol.cc b/bluetooth/hci_protocol.cc
deleted file mode 100644
index cd709b4..0000000
--- a/bluetooth/hci_protocol.cc
+++ /dev/null
@@ -1,74 +0,0 @@
-//
-// Copyright 2017 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.
-//
-
-#include "hci_protocol.h"
-
-#define LOG_TAG "android.hardware.bluetooth-hci-hci_protocol"
-#include <android-base/logging.h>
-#include <assert.h>
-#include <fcntl.h>
-#include <utils/Log.h>
-
-namespace {
-
-const size_t preamble_size_for_type[] = {
- 0, HCI_COMMAND_PREAMBLE_SIZE, HCI_ACL_PREAMBLE_SIZE, HCI_SCO_PREAMBLE_SIZE,
- HCI_EVENT_PREAMBLE_SIZE};
-const size_t packet_length_offset_for_type[] = {
- 0, HCI_LENGTH_OFFSET_CMD, HCI_LENGTH_OFFSET_ACL, HCI_LENGTH_OFFSET_SCO,
- HCI_LENGTH_OFFSET_EVT};
-
-size_t HciGetPacketLengthForType(HciPacketType type, const uint8_t* preamble) {
- size_t offset = packet_length_offset_for_type[type];
- if (type != HCI_PACKET_TYPE_ACL_DATA) return preamble[offset];
- return (((preamble[offset + 1]) << 8) | preamble[offset]);
-}
-
-} // namespace
-
-namespace android {
-namespace hardware {
-namespace bluetooth {
-namespace hci {
-
-size_t HciProtocol::WriteSafely(int fd, const uint8_t* data, size_t length) {
- size_t transmitted_length = 0;
- while (length > 0) {
- ssize_t ret =
- TEMP_FAILURE_RETRY(write(fd, data + transmitted_length, length));
-
- if (ret == -1) {
- if (errno == EAGAIN) continue;
- ALOGE("%s error writing to UART (%s)", __func__, strerror(errno));
- break;
-
- } else if (ret == 0) {
- // Nothing written :(
- ALOGE("%s zero bytes written - something went wrong...", __func__);
- break;
- }
-
- transmitted_length += ret;
- length -= ret;
- }
-
- return transmitted_length;
-}
-
-} // namespace hci
-} // namespace bluetooth
-} // namespace hardware
-} // namespace android
diff --git a/bluetooth/hci_protocol.h b/bluetooth/hci_protocol.h
deleted file mode 100644
index f76cddf..0000000
--- a/bluetooth/hci_protocol.h
+++ /dev/null
@@ -1,48 +0,0 @@
-//
-// Copyright 2017 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.
-//
-
-#pragma once
-
-#include <hidl/HidlSupport.h>
-
-#include "hci_internals.h"
-#include "hci_packetizer.h"
-
-namespace android {
-namespace hardware {
-namespace bluetooth {
-namespace hci {
-
-using ::android::hardware::hidl_vec;
-using PacketReadCallback = std::function<void(const hidl_vec<uint8_t>&)>;
-
-// Implementation of HCI protocol bits common to different transports
-class HciProtocol {
- public:
- HciProtocol() = default;
- virtual ~HciProtocol(){};
-
- // Protocol-specific implementation of sending packets.
- virtual size_t Send(uint8_t type, const uint8_t* data, size_t length) = 0;
-
- protected:
- static size_t WriteSafely(int fd, const uint8_t* data, size_t length);
-};
-
-} // namespace hci
-} // namespace bluetooth
-} // namespace hardware
-} // namespace android
diff --git a/bluetooth/service.cc b/bluetooth/service.cc
deleted file mode 100644
index 05920ed..0000000
--- a/bluetooth/service.cc
+++ /dev/null
@@ -1,40 +0,0 @@
-//
-// Copyright 2017 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.
-//
-
-#define LOG_TAG "android.hardware.bluetooth@1.0-service.hikey"
-
-#include <android/hardware/bluetooth/1.0/IBluetoothHci.h>
-#include <hidl/HidlSupport.h>
-#include <hidl/HidlTransportSupport.h>
-#include <utils/Log.h>
-
-#include "bluetooth_hci.h"
-
-using ::android::hardware::configureRpcThreadpool;
-using ::android::hardware::bluetooth::V1_0::IBluetoothHci;
-using ::android::hardware::bluetooth::V1_0::hikey::BluetoothHci;
-using ::android::hardware::joinRpcThreadpool;
-using ::android::sp;
-
-int main(int /* argc */, char** /* argv */) {
- sp<IBluetoothHci> bluetooth = new BluetoothHci;
- configureRpcThreadpool(1, true);
- android::status_t status = bluetooth->registerAsService();
- if (status == android::OK)
- joinRpcThreadpool();
- else
- ALOGE("Could not register as a service!");
-}
diff --git a/device-common.mk b/device-common.mk
index e5506ec..61e5024 100644
--- a/device-common.mk
+++ b/device-common.mk
@@ -97,11 +97,7 @@
android.hardware.graphics.composer@2.1-service \
android.hardware.graphics.mapper@2.0-impl-2.1 \
-ifeq ($(HIKEY_USE_LEGACY_TI_BLUETOOTH), true)
-PRODUCT_PACKAGES += android.hardware.bluetooth@1.0-service.hikey uim
-else
PRODUCT_PACKAGES += android.hardware.bluetooth@1.1-service.btlinux
-endif
#
# Power HAL
@@ -215,9 +211,6 @@
frameworks/native/data/etc/android.hardware.usb.host.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/android.hardware.usb.host.xml \
frameworks/native/data/etc/android.software.device_admin.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/android.software.device_admin.xml
-# Include BT modules
-$(call inherit-product, device/linaro/hikey/wpan/ti-wpan-products.mk)
-
PRODUCT_COPY_FILES += \
frameworks/native/data/etc/android.hardware.wifi.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/android.hardware.wifi.xml \
frameworks/native/data/etc/android.hardware.wifi.direct.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/android.hardware.wifi.direct.xml \
diff --git a/gralloc/Android.mk b/gralloc/Android.mk
index 20b8f66..947a184 100644
--- a/gralloc/Android.mk
+++ b/gralloc/Android.mk
@@ -54,8 +54,6 @@
#LOCAL_CFLAGS+= -DMALI_VSYNC_EVENT_REPORT_ENABLE
-ifeq ($(HIKEY_USE_DRM_HWCOMPOSER), true)
LOCAL_CFLAGS += -DDISABLE_FRAMEBUFFER_HAL
-endif
include $(BUILD_SHARED_LIBRARY)
diff --git a/gralloc960/Android.hikey960.mk b/gralloc960/Android.hikey960.mk
index 8b0b1be..57b4f3e 100644
--- a/gralloc960/Android.hikey960.mk
+++ b/gralloc960/Android.hikey960.mk
@@ -52,8 +52,6 @@
# Vsync backend(not used)
GRALLOC_VSYNC_BACKEND=default
-ifeq ($(HIKEY_USE_DRM_HWCOMPOSER), true)
- GRALLOC_USE_ION_DMA_HEAP=1
- GRALLOC_DISABLE_FRAMEBUFFER_HAL=1
-endif
+GRALLOC_USE_ION_DMA_HEAP=1
+GRALLOC_DISABLE_FRAMEBUFFER_HAL=1
diff --git a/hikey-common.mk b/hikey-common.mk
index 3df9ba7..bf3bd24 100644
--- a/hikey-common.mk
+++ b/hikey-common.mk
@@ -2,20 +2,12 @@
TARGET_KERNEL_USE=4.19
endif
-HIKEY_USE_DRM_HWCOMPOSER := false
-
LOCAL_KERNEL_HOME ?= device/linaro/hikey-kernel/hikey/$(TARGET_KERNEL_USE)
TARGET_PREBUILT_KERNEL := $(LOCAL_KERNEL_HOME)/Image.gz-dtb
TARGET_PREBUILT_DTB := $(LOCAL_KERNEL_HOME)/hi6220-hikey.dtb
PRODUCT_ENFORCE_VINTF_MANIFEST_OVERRIDE := true
-ifeq ($(TARGET_KERNEL_USE), 4.4)
- HIKEY_USE_LEGACY_TI_BLUETOOTH := true
-else
- HIKEY_USE_LEGACY_TI_BLUETOOTH := false
- HIKEY_USE_DRM_HWCOMPOSER := true
-endif
TARGET_FSTAB := fstab.hikey
$(call inherit-product, device/linaro/hikey/hikey/device-hikey.mk)
diff --git a/hikey/device-hikey.mk b/hikey/device-hikey.mk
index cec2e6f..aa202b3 100644
--- a/hikey/device-hikey.mk
+++ b/hikey/device-hikey.mk
@@ -51,9 +51,7 @@
# Sensors HAL
PRODUCT_PACKAGES += sensors.hikey
-ifeq ($(HIKEY_USE_DRM_HWCOMPOSER), true)
- PRODUCT_PACKAGES += hwcomposer.drm_hikey
-endif
+PRODUCT_PACKAGES += hwcomposer.drm_hikey
# Include mali blobs from ARM
PRODUCT_PACKAGES += libGLES_mali.so END_USER_LICENCE_AGREEMENT.txt
diff --git a/hikey960.mk b/hikey960.mk
index 243b002..b300bfa 100644
--- a/hikey960.mk
+++ b/hikey960.mk
@@ -5,18 +5,6 @@
TARGET_PREBUILT_KERNEL := $(LOCAL_KERNEL_HOME)/Image.gz-dtb
TARGET_PREBUILT_DTB := $(LOCAL_KERNEL_HOME)/hi3660-hikey960.dtb
-ifeq ($(TARGET_KERNEL_USE), 4.4)
- HIKEY_USE_DRM_HWCOMPOSER := false
- HIKEY_USE_LEGACY_TI_BLUETOOTH := true
-else
- ifeq ($(TARGET_KERNEL_USE), 4.9)
- HIKEY_USE_DRM_HWCOMPOSER := false
- else
- HIKEY_USE_DRM_HWCOMPOSER := true
- endif
- HIKEY_USE_LEGACY_TI_BLUETOOTH := false
-endif
-
ifndef HIKEY_USES_GKI
ifeq ($(TARGET_KERNEL_USE), 5.4)
HIKEY_USES_GKI := true
diff --git a/hikey960/BoardConfig.mk b/hikey960/BoardConfig.mk
index 515cce6..f7deb4c 100644
--- a/hikey960/BoardConfig.mk
+++ b/hikey960/BoardConfig.mk
@@ -16,24 +16,6 @@
BOARD_KERNEL_CMDLINE += drm_kms_helper.edid_firmware=edid/1920x1080.bin
endif
-# On kernels before 4.19, enable dtb fstab. On kernels >= 4.19, both dtb
-# fstab and android-verity are deprecated, so until we have avb2 support
-# in the bootloader, don't enable either feature. The ramdisk fstab
-# needed for the new mechanism will be installed unconditionally; if dtb
-# fstab is present, it will override it automatically.
-ifneq ($(TARGET_KERNEL_USE),4.19)
-# Enable treble dtb fstab with verity
-ifneq ($(TARGET_ANDROID_VERITY),)
-BOARD_KERNEL_CMDLINE += overlay_mgr.overlay_dt_entry=hardware_cfg_enable_android_fstab_v2
-BOARD_KERNEL_CMDLINE += rootwait ro root=/dev/dm-0
-BOARD_KERNEL_CMDLINE += dm=\"system none ro,0 1 android-verity 8:58\"
-BOARD_BUILD_SYSTEM_ROOT_IMAGE := true
-else
-# Enable treble dtb fstab without verity
-BOARD_KERNEL_CMDLINE += overlay_mgr.overlay_dt_entry=hardware_cfg_enable_android_fstab
-endif
-endif
-
ifneq ($(TARGET_SENSOR_MEZZANINE),)
BOARD_KERNEL_CMDLINE += overlay_mgr.overlay_dt_entry=hardware_cfg_$(TARGET_SENSOR_MEZZANINE)
endif
diff --git a/hikey960/device-hikey960.mk b/hikey960/device-hikey960.mk
index 46ffbe7..d34dc31 100644
--- a/hikey960/device-hikey960.mk
+++ b/hikey960/device-hikey960.mk
@@ -92,9 +92,7 @@
PRODUCT_PACKAGES += sensors.hikey960
-ifeq ($(HIKEY_USE_DRM_HWCOMPOSER), true)
- PRODUCT_PACKAGES += hwcomposer.drm_hikey960
-endif
+PRODUCT_PACKAGES += hwcomposer.drm_hikey960
ifneq ($(TARGET_NO_RECOVERY),true)
PRODUCT_COPY_FILES += \
diff --git a/wpan/Android.mk b/wpan/Android.mk
deleted file mode 100644
index edb7b6f..0000000
--- a/wpan/Android.mk
+++ /dev/null
@@ -1 +0,0 @@
-include $(call first-makefiles-under,$(call my-dir))
diff --git a/wpan/README b/wpan/README
deleted file mode 100644
index 3b45293..0000000
--- a/wpan/README
+++ /dev/null
@@ -1,18 +0,0 @@
-wpan.git contains the Bluetooth, FM code by Texas Instruments for
-WiLink connectivity chipsets on OMAP Platforms
-
-Android.mk - Root Makefile calling all subdir makefiles
-bt_sco_app - Command line application to send PCM configuruations to WL12xx chip(optional)
-and connect to BT headset via SCO.
-bt_voice_call_set - Derived from bt_sco_app for Modem purposes.
-fmradio - Stack and Command line application for FM on WiLink chipsets
-fmradio_omap3 - Derived from fmradio (older version) on OMAP3 platforms
-README - This file
-ti_st -
- kfmapp/ - V4L2 FM application to be used with V4L2 drivers for FM on WL.
- uim/ - User-Space Initilization Manager for TI Shared Transport Drivers (to be
- used with kernel version 2.6.32 and below drivers)
- uim-rfkill/ - Derived from uim/ to be used with K32 and above TI ST drivers.
- uim-sysfs/ - User-Space Init Manager for TI Shared Transport Drivers (per kernel.org)
-tools -
- BluetoothSCOApp/ - BT SCO UI App for connect to BT headset via SCO
diff --git a/wpan/ti-wpan-products.mk b/wpan/ti-wpan-products.mk
deleted file mode 100644
index 8e720fb..0000000
--- a/wpan/ti-wpan-products.mk
+++ /dev/null
@@ -1,4 +0,0 @@
-# This file lists the firmware, software that are specific to
-# WiLink connectivity chip on OMAPx platforms.
-
-PRODUCT_PACKAGES += uim
diff --git a/wpan/uim/Android.mk b/wpan/uim/Android.mk
deleted file mode 100644
index a91abdd..0000000
--- a/wpan/uim/Android.mk
+++ /dev/null
@@ -1,15 +0,0 @@
-#Android makefile for uim
-LOCAL_PATH := $(call my-dir)
-
-include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES:= uim.c
-
-LOCAL_C_INCLUDES := $(LOCAL_PATH)/
-
-LOCAL_MODULE := uim
-LOCAL_LICENSE_KINDS := SPDX-license-identifier-GPL-2.0
-LOCAL_LICENSE_CONDITIONS := restricted
-LOCAL_PROPRIETARY_MODULE := true
-
-include $(BUILD_EXECUTABLE)
diff --git a/wpan/uim/Makefile b/wpan/uim/Makefile
deleted file mode 100644
index 2790e79..0000000
--- a/wpan/uim/Makefile
+++ /dev/null
@@ -1,46 +0,0 @@
-MAKEFLAGS += --no-print-directory
-
-PREFIX ?= /usr
-SBINDIR ?= $(PREFIX)/sbin
-MANDIR ?= $(PREFIX)/share/man
-
-MKDIR ?= mkdir -p
-INSTALL ?= install
-CC ?= "gcc"
-
-CFLAGS ?= -O2 -g
-CFLAGS += -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs -fno-strict-aliasing -fno-common -Werror-implicit-function-declaration
-
-OBJS = uim.o
-ALL = uim
-
-ifeq ($(V),1)
-Q=
-NQ=true
-else
-Q=@
-NQ=echo
-endif
-
-all: $(ALL)
-
-VERSION_OBJS := $(filter-out version.o, $(OBJS))
-
-%.o: %.c uim.h
- @$(NQ) ' CC ' $@
- $(Q)$(CC) $(CFLAGS) -c -o $@ $<
-
-uim: $(OBJS)
- @$(NQ) ' CC ' uim
- $(Q)$(CC) $(LDFLAGS) $(OBJS) $(LIBS) -o uim
-
-check:
- $(Q)$(MAKE) all CC="REAL_CC=$(CC) CHECK=\"sparse -Wall\" cgcc"
-
-install: uim
- @$(NQ) ' INST uim'
- $(Q)$(MKDIR) $(DESTDIR)$(SBINDIR)
- $(Q)$(INSTALL) -m 755 -t $(DESTDIR)$(SBINDIR) uim
-
-clean:
- $(Q)rm -f uim *.o *~
diff --git a/wpan/uim/uim.c b/wpan/uim/uim.c
deleted file mode 100644
index 7f78f0c..0000000
--- a/wpan/uim/uim.c
+++ /dev/null
@@ -1,562 +0,0 @@
-/*
- * User Mode Init manager - For TI shared transport
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program;if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-#include <stdio.h>
-#include <errno.h>
-#include <fcntl.h>
-#include <string.h>
-#include <signal.h>
-#include <sys/ioctl.h>
-#include <termios.h>
-#include <poll.h>
-#include <stdint.h>
-#include <stdlib.h>
-#include <sys/stat.h>
-#include <sys/utsname.h>
-
-#include <unistd.h>
-#include <time.h>
-
-#include "uim.h"
-
-/* Maintains the exit state of UIM*/
-static int exiting;
-static int line_discipline;
-static int dev_fd;
-
-/* BD address as string and a pointer to array of hex bytes */
-char uim_bd_address[BD_ADDR_LEN];
-bdaddr_t *bd_addr;
-
-/* kim Sysfs path */
-static char *sysfs_install_entry = INSTALL_SYSFS_ENTRY;
-static char *sysfs_dev_name = DEV_NAME_SYSFS;
-static char *sysfs_baud_rate = BAUD_RATE_SYSFS;
-static char *sysfs_flow_ctrl = FLOW_CTRL_SYSFS;
-
-/*****************************************************************************/
-#ifdef UIM_DEBUG
-/* Function to Read the firmware version
- * module into the system. Currently used for
- * debugging purpose, whenever the baud rate is changed
- */
-void read_firmware_version(int dev_fd)
-{
- int index = 0;
- char resp_buffer[20] = { 0 };
- unsigned char buffer[] = { 0x01, 0x01, 0x10, 0x00 };
-
- UIM_START_FUNC();
- UIM_VER(" wrote %d bytes", (int)write(dev_fd, buffer, 4));
- UIM_VER(" reading %d bytes", (int)read(dev_fd, resp_buffer, 15));
-
- for (index = 0; index < 15; index++)
- UIM_VER(" %x ", resp_buffer[index]);
-
- printf("\n");
-}
-#endif
-
-void sysfs_entry_fallback(void)
-{
- sysfs_install_entry = INSTALL_SYSFS_ENTRY_OLD;
- sysfs_dev_name = DEV_NAME_SYSFS_OLD;
- sysfs_baud_rate = BAUD_RATE_SYSFS_OLD;
- sysfs_flow_ctrl = FLOW_CTRL_SYSFS_OLD;
-}
-
-/*****************************************************************************/
-/* Function to read the HCI event from the given file descriptor
- *
- * This will parse the response received and returns error
- * if the required response is not received
- */
-int read_hci_event(int fd, unsigned char *buf, int size)
-{
- int remain, rd;
- int count = 0;
- int reading = 1;
- int rd_retry_count = 0;
- struct timespec tm = {0, 50*1000*1000};
-
- UIM_START_FUNC();
-
- UIM_VER(" read_hci_event");
- if (size <= 0)
- return -1;
-
- /* The first byte identifies the packet type. For HCI event packets, it
- * should be 0x04, so we read until we get to the 0x04. */
- while (reading) {
- rd = read(fd, buf, 1);
- if (rd <= 0 && rd_retry_count++ < 4) {
- nanosleep(&tm, NULL);
- continue;
- } else if (rd_retry_count >= 4) {
- return -1;
- }
-
- if (buf[0] == RESP_PREFIX) {
- break;
- }
- }
- count++;
-
- /* The next two bytes are the event code and parameter total length. */
- while (count < 3) {
- rd = read(fd, buf + count, 3 - count);
- if (rd <= 0)
- return -1;
- count += rd;
- }
-
- /* Now we read the parameters. */
- if (buf[2] < (size - 3))
- remain = buf[2];
- else
- remain = size - 3;
-
- while ((count - 3) < remain) {
- rd = read(fd, buf + count, remain - (count - 3));
- if (rd <= 0)
- return -1;
- count += rd;
- }
-
- return count;
-}
-
-/* Function to read the Command complete event
- *
- * This will read the response for the change speed
- * command that was sent to configure the UART speed
- * with the custom baud rate
- */
-static int read_command_complete(int fd, unsigned short opcode)
-{
- command_complete_t resp;
-
- UIM_START_FUNC();
-
- UIM_VER(" Command complete started");
- if (read_hci_event(fd, (unsigned char *)&resp, sizeof(resp)) < 0) {
- UIM_ERR("Invalid response");
- return -1;
- }
-
- /* Response should be an event packet */
- if (resp.uart_prefix != HCI_EVENT_PKT) {
- UIM_ERR ("Error in response: not an event packet, 0x%02x!",
- resp.uart_prefix);
- return -1;
- }
-
- /* Response should be a command complete event */
- if (resp.hci_hdr.evt != EVT_CMD_COMPLETE) {
- /* event must be event-complete */
- UIM_ERR("Error in response: not a cmd-complete event,0x%02x!",
- resp.hci_hdr.evt);
- return -1;
- }
-
- if (resp.hci_hdr.plen < 4) {
- /* plen >= 4 for EVT_CMD_COMPLETE */
- UIM_ERR("Error in response: plen is not >= 4, but 0x%02x!",
- resp.hci_hdr.plen);
- return -1;
- }
-
- if (resp.cmd_complete.opcode != (unsigned short)opcode) {
- UIM_ERR("Error in response: opcode is 0x%04x, not 0x%04x!",
- resp.cmd_complete.opcode, opcode);
- return -1;
- }
-
- UIM_DBG("Command complete done");
- return resp.status == 0 ? 0 : -1;
-}
-
-/* Function to set the default baud rate
- *
- * The default baud rate of 115200 is set to the UART from the host side
- * by making a call to this function.This function is also called before
- * making a call to set the custom baud rate
- */
-static int set_baud_rate(int dev_fd)
-{
- UIM_START_FUNC();
- struct termios ti;
-
- tcflush(dev_fd, TCIOFLUSH);
-
- /* Get the attributes of UART */
- if (tcgetattr(dev_fd, &ti) < 0) {
- UIM_ERR(" Can't get port settings");
- return -1;
- }
-
- /* Change the UART attributes before
- * setting the default baud rate*/
- cfmakeraw(&ti);
-
- ti.c_cflag |= 1;
- ti.c_cflag |= CRTSCTS;
-
- /* Set the attributes of UART after making
- * the above changes
- */
- tcsetattr(dev_fd, TCSANOW, &ti);
-
- /* Set the actual default baud rate */
- cfsetospeed(&ti, B115200);
- cfsetispeed(&ti, B115200);
- tcsetattr(dev_fd, TCSANOW, &ti);
-
- tcflush(dev_fd, TCIOFLUSH);
- UIM_DBG("set_baud_rate() done");
-
- return 0;
-}
-
-
-/* Function to set the UART custom baud rate.
- *
- * The UART baud rate has already been
- * set to default value 115200 before calling this function.
- * The baud rate is then changed to custom baud rate by this function*/
-static int set_custom_baud_rate(int dev_fd, int baud_rate, int flow_ctrl)
-{
- UIM_START_FUNC();
-
- struct termios ti;
- struct termios2 ti2;
-
- tcflush(dev_fd, TCIOFLUSH);
- /* Get the attributes of UART */
- if (tcgetattr(dev_fd, &ti) < 0) {
- UIM_ERR(" Can't get port settings");
- return -1;
- }
-
- /*Set the UART flow control */
- if (flow_ctrl)
- ti.c_cflag |= CRTSCTS;
- else
- ti.c_cflag &= ~CRTSCTS;
-
- /*
- * Set the parameters associated with the UART
- * The change will occur immediately by using TCSANOW
- */
- if (tcsetattr(dev_fd, TCSANOW, &ti) < 0) {
- UIM_ERR(" Can't set port settings");
- return -1;
- }
-
- tcflush(dev_fd, TCIOFLUSH);
-
- /*Set the actual baud rate */
- ioctl(dev_fd, TCGETS2, &ti2);
- ti2.c_cflag &= ~CBAUD;
- ti2.c_cflag |= BOTHER;
- ti2.c_ospeed = baud_rate;
- ioctl(dev_fd, TCSETS2, &ti2);
-
- return 0;
-}
-
-/* Function to configure the UART
- * on receiving a notification from the ST KIM driver to install the line
- * discipline, this function does UART configuration necessary for the STK
- */
-int st_uart_config(unsigned char install)
-{
- int ldisc, len, fd, flow_ctrl;
- unsigned char buf[UART_DEV_NAME_LEN];
- uim_speed_change_cmd cmd;
- char uart_dev_name[UART_DEV_NAME_LEN];
- unsigned int cust_baud_rate;
-
- uim_bdaddr_change_cmd addr_cmd;
-
- UIM_START_FUNC();
-
- if (install == '1') {
- memset(buf, 0, UART_DEV_NAME_LEN);
- fd = open(sysfs_dev_name, O_RDONLY);
- if (fd < 0) {
- UIM_ERR("Can't open %s", sysfs_dev_name);
- return -1;
- }
- len = read(fd, buf, UART_DEV_NAME_LEN);
- if (len < 0) {
- UIM_ERR("read err (%s)", strerror(errno));
- close(fd);
- return len;
- }
- sscanf((const char*)buf, "%s", uart_dev_name);
- close(fd);
-
- memset(buf, 0, UART_DEV_NAME_LEN);
- fd = open(sysfs_baud_rate, O_RDONLY);
- if (fd < 0) {
- UIM_ERR("Can't open %s", sysfs_baud_rate);
- return -1;
- }
- len = read(fd, buf, UART_DEV_NAME_LEN);
- if (len < 0) {
- UIM_ERR("read err (%s)", strerror(errno));
- close(fd);
- return len;
- }
- close(fd);
- sscanf((const char*)buf, "%d", &cust_baud_rate);
-
- memset(buf, 0, UART_DEV_NAME_LEN);
- fd = open(sysfs_flow_ctrl, O_RDONLY);
- if (fd < 0) {
- UIM_ERR("Can't open %s", sysfs_flow_ctrl);
- close(fd);
- return -1;
- }
- len = read(fd, buf, UART_DEV_NAME_LEN);
- if (len < 0) {
- UIM_ERR("read err (%s)", strerror(errno));
- close(fd);
- return len;
- }
- close(fd);
- sscanf((const char*)buf, "%d", &flow_ctrl);
-
- UIM_VER(" signal received, opening %s", uart_dev_name);
-
- dev_fd = open(uart_dev_name, O_RDWR);
- if (dev_fd < 0) {
- UIM_ERR("Can't open %s", uart_dev_name);
- return -1;
- }
-
- /*
- * Set only the default baud rate.
- * This will set the baud rate to default 115200
- */
- if (set_baud_rate(dev_fd) < 0) {
- UIM_ERR("set_baudrate() failed");
- close(dev_fd);
- return -1;
- }
-
- fcntl(dev_fd, F_SETFL,fcntl(dev_fd, F_GETFL) | O_NONBLOCK);
- /* Set only the custom baud rate */
- if (cust_baud_rate != 115200) {
-
- UIM_VER("Setting speed to %d", cust_baud_rate);
- /* Forming the packet for Change speed command */
- cmd.uart_prefix = HCI_COMMAND_PKT;
- cmd.hci_hdr.opcode = HCI_HDR_OPCODE;
- cmd.hci_hdr.plen = sizeof(unsigned int);
- cmd.speed = cust_baud_rate;
-
- /* Writing the change speed command to the UART
- * This will change the UART speed at the controller
- * side
- */
- len = write(dev_fd, &cmd, sizeof(cmd));
- if (len < 0) {
- UIM_ERR("Failed to write speed-set command");
- close(dev_fd);
- return -1;
- }
-
- /* Read the response for the Change speed command */
- if (read_command_complete(dev_fd, HCI_HDR_OPCODE) < 0) {
- close(dev_fd);
- return -1;
- }
-
- UIM_VER("Speed changing to %d, %d", cust_baud_rate, flow_ctrl);
- /* Set the actual custom baud rate at the host side */
- if (set_custom_baud_rate(dev_fd, cust_baud_rate, flow_ctrl) < 0) {
- UIM_ERR("set_custom_baud_rate() failed");
- close(dev_fd);
- return -1;
- }
-
- /* Set the uim BD address */
- if (uim_bd_address[0] != 0) {
-
- memset(&addr_cmd, 0, sizeof(addr_cmd));
- /* Forming the packet for change BD address command*/
- addr_cmd.uart_prefix = HCI_COMMAND_PKT;
- addr_cmd.hci_hdr.opcode = WRITE_BD_ADDR_OPCODE;
- addr_cmd.hci_hdr.plen = sizeof(bdaddr_t);
- memcpy(&addr_cmd.addr, bd_addr, sizeof(bdaddr_t));
-
- /* Writing the change BD address command to the UART
- * This will change the change BD address at the controller
- * side
- */
- len = write(dev_fd, &addr_cmd, sizeof(addr_cmd));
- if (len < 0) {
- UIM_ERR("Failed to write BD address command");
- close(dev_fd);
- return -1;
- }
-
- /* Read the response for the change BD address command */
- if (read_command_complete(dev_fd, WRITE_BD_ADDR_OPCODE) < 0) {
- close(dev_fd);
- return -1;
- }
- UIM_VER("BD address changed to %s", uim_bd_address);
- }
-#ifdef UIM_DEBUG
- read_firmware_version(dev_fd);
-#endif
- }
-
- /* After the UART speed has been changed, the IOCTL is
- * is called to set the line discipline to N_TI_WL
- */
- ldisc = N_TI_WL;
- if (ioctl(dev_fd, TIOCSETD, &ldisc) < 0) {
- UIM_ERR(" Can't set line discipline");
- close(dev_fd);
- return -1;
- }
- UIM_DBG("Installed N_TI_WL Line displine");
- }
- else {
- UIM_DBG("Un-Installed N_TI_WL Line displine");
- /* UNINSTALL_N_TI_WL - When the Signal is received from KIM */
- /* closing UART fd */
- close(dev_fd);
- }
- return 0;
-}
-
-/* Function to convert the BD address from ascii to hex value */
-bdaddr_t *strtoba(const char *str)
-{
- const char *ptr = str;
- int i;
-
- uint8_t *ba = malloc(sizeof(bdaddr_t));
- if (!ba)
- return NULL;
-
- for (i = 0; i < 6; i++) {
- ba[i] = (uint8_t) strtol(ptr, NULL, 16);
- if (i != 5 && !(ptr = strchr(ptr, ':')))
- ptr = ":00:00:00:00:00";
- ptr++;
- }
-
- return (bdaddr_t *) ba;
-}
-
-/*****************************************************************************/
-int main(int argc, char *argv[])
-{
- int st_fd, err,trials;
- unsigned char install;
- struct pollfd p;
-
- UIM_START_FUNC();
- err = 0;
- trials = 5;
-
- /* Parse the user input */
- if ((argc > 2)) {
- UIM_ERR("Invalid arguements");
- UIM_ERR("Usage: uim <bd address>");
- return -1;
- }
- if (argc == 2) {
- if (strlen(argv[2]) != BD_ADDR_LEN) {
- UIM_ERR("Usage: uim XX:XX:XX:XX:XX:XX");
- return -1;
- }
- /* BD address passed as string in xx:xx:xx:xx:xx:xx format */
- strncpy(uim_bd_address, argv[2], sizeof(uim_bd_address));
- bd_addr = strtoba(uim_bd_address);
- }
-
- line_discipline = N_TI_WL;
-
- /* sysfs entry may get populated after service is started so we retry if it fails*/
- while (trials > 0) {
- st_fd = open(sysfs_install_entry, O_RDONLY);
- if(st_fd > 0)
- break;
- if (trials == 3)
- sysfs_entry_fallback();
- else
- usleep(500000);
- --trials;
- }
- if (st_fd < 0) {
- UIM_DBG("unable to open %s(%s)", sysfs_install_entry, strerror(errno));
- return -1;
- }
-
-RE_POLL:
- /* read to start proper poll */
- err = read(st_fd, &install, 1);
- /* special case where bluetoothd starts before the UIM, and UIM
- * needs to turn on bluetooth because of that.
- */
- if ((err > 0) && install == '1') {
- UIM_DBG("install set previously...");
- st_uart_config(install);
- }
-
- UIM_DBG("begin polling...");
-
- memset(&p, 0, sizeof(p));
- p.fd = st_fd;
- p.events = POLLERR | POLLPRI;
-
- while (!exiting) {
- p.revents = 0;
- err = poll(&p, 1, -1);
- UIM_DBG("poll broke due to event %d(PRI:%d/ERR:%d)\n", p.revents, POLLPRI, POLLERR);
- if (err < 0 && errno == EINTR)
- continue;
- if (err)
- break;
- }
-
- close(st_fd);
- st_fd = open(sysfs_install_entry, O_RDONLY);
- if (st_fd < 0) {
- UIM_DBG("unable to open %s (%s)", sysfs_install_entry, strerror(errno));
- return -1;
- }
-
- if (!exiting)
- {
- err = read(st_fd, &install, 1);
- UIM_DBG("read %c from install \n", install);
- if (err > 0)
- st_uart_config(install);
- goto RE_POLL;
- }
-
- close(st_fd);
- return 0;
-}
diff --git a/wpan/uim/uim.h b/wpan/uim/uim.h
deleted file mode 100644
index dc9c5b1..0000000
--- a/wpan/uim/uim.h
+++ /dev/null
@@ -1,147 +0,0 @@
-/*
- * User Mode Init manager - For shared transport
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program;if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-#ifndef UIM_H
-#define UIM_H
-
-/* the line discipline ideally should be coming
- * from tty.h
- */
-#define N_TI_WL 22
-
-/* Paramaters to set the baud rate*/
-#define FLOW_CTL 0x0001
-#define ARM_NCCS 19
-
-#ifndef TCGETS2
-#define TCGETS2 _IOR('T',0x2A, struct termios2)
-#endif
-#ifndef TCSETS2
-#define TCSETS2 _IOW('T',0x2B, struct termios2)
-#endif
-
-/*HCI Command and Event information*/
-#define HCI_HDR_OPCODE 0xff36
-#define WRITE_BD_ADDR_OPCODE 0xFC06
-#define RESP_PREFIX 0x04
-#define MAX_TRY 10
-
-/* HCI Packet types */
-#define HCI_COMMAND_PKT 0x01
-#define HCI_EVENT_PKT 0x04
-
-/* HCI command macros*/
-#define HCI_EVENT_HDR_SIZE 2
-#define HCI_COMMAND_HDR_SIZE 3
-#define HCI_COMMAND_HDR_SIZE 3
-
-/* HCI event macros*/
-#define EVT_CMD_COMPLETE_SIZE 3
-#define EVT_CMD_STATUS_SIZE 4
-#define EVT_CMD_COMPLETE 0x0E
-#define EVT_CMD_STATUS 0x0F
-
-/* use it for string lengths and buffers */
-#define UART_DEV_NAME_LEN 32
-/* BD address length in format xx:xx:xx:xx:xx:xx */
-#define BD_ADDR_LEN 17
-
-/* the sysfs entries with device configuration set by
- * shared transport driver
- */
-#define INSTALL_SYSFS_ENTRY "/sys/devices/platform/kim/install"
-#define DEV_NAME_SYSFS "/sys/devices/platform/kim/dev_name"
-#define BAUD_RATE_SYSFS "/sys/devices/platform/kim/baud_rate"
-#define FLOW_CTRL_SYSFS "/sys/devices/platform/kim/flow_cntrl"
-
-#define INSTALL_SYSFS_ENTRY_OLD "/sys/devices/kim/install"
-#define DEV_NAME_SYSFS_OLD "/sys/devices/kim/dev_name"
-#define BAUD_RATE_SYSFS_OLD "/sys/devices/kim/baud_rate"
-#define FLOW_CTRL_SYSFS_OLD "/sys/devices/kim/flow_cntrl"
-
-#define VERBOSE
-/*Debug logs*/
-#define UIM_ERR(fmt, arg...) printf("uim:"fmt"\n" , ##arg)
-#if defined(UIM_DEBUG) /* limited debug messages */
-#define UIM_START_FUNC() printf("uim: Inside %s", __FUNCTION__)
-#define UIM_DBG(fmt, arg...) printf("uim:"fmt"\n" , ## arg)
-#define UIM_VER(fmt, arg...)
-#elif defined(VERBOSE) /* very verbose */
-#define UIM_START_FUNC() printf("uim:@ %s\n", __FUNCTION__)
-#define UIM_DBG(fmt, arg...) printf("uim:"fmt"\n" , ## arg)
-#define UIM_VER(fmt, arg...) printf("uim:"fmt"\n" , ## arg)
-#else /* error msgs only */
-#define UIM_START_FUNC()
-#define UIM_DBG(fmt, arg...)
-#define UIM_VER(fmt, arg...)
-#endif
-
-/* HCI command header*/
-typedef struct {
- uint16_t opcode; /* OCF & OGF */
- uint8_t plen;
-} __attribute__ ((packed)) hci_command_hdr;
-
-/* HCI event header*/
-typedef struct {
- uint8_t evt;
- uint8_t plen;
-} __attribute__ ((packed)) hci_event_hdr;
-
-/* HCI command complete event*/
-typedef struct {
- uint8_t ncmd;
- uint16_t opcode;
-} __attribute__ ((packed)) evt_cmd_complete;
-
-/* HCI event status*/
-typedef struct {
- uint8_t status;
- uint8_t ncmd;
- uint16_t opcode;
-} __attribute__ ((packed)) evt_cmd_status;
-
-/* HCI Event structure to set the cusrom baud rate*/
-typedef struct {
- uint8_t uart_prefix;
- hci_event_hdr hci_hdr;
- evt_cmd_complete cmd_complete;
- uint8_t status;
- uint8_t data[16];
-} __attribute__ ((packed)) command_complete_t;
-
-/* HCI Command structure to set the cusrom baud rate*/
-typedef struct {
- uint8_t uart_prefix;
- hci_command_hdr hci_hdr;
- uint32_t speed;
-} __attribute__ ((packed)) uim_speed_change_cmd;
-
-/* BD address structure to set the uim BD address*/
-typedef struct {
- unsigned char b[6];
-} __attribute__((packed)) bdaddr_t;
-
-/* HCI Command structure to set the uim BD address*/
-typedef struct {
- uint8_t uart_prefix;
- hci_command_hdr hci_hdr;
- bdaddr_t addr;
-} __attribute__ ((packed)) uim_bdaddr_change_cmd;\
-
-#endif /* UIM_H */