diff options
author | Chris Dearman <chris.dearman@imgtec.com> | 2016-02-02 12:02:27 -0800 |
---|---|---|
committer | Mohammed Habibulla <moch@google.com> | 2016-02-29 22:27:59 +0000 |
commit | e0b7d5afd9d378af5eb1300a065e2e107a1824e7 (patch) | |
tree | 116ba645e99a69c17507449ce31c0d7b35aac59c | |
parent | d1ab45e746c891e989b153c4d0048ce78a2624f6 (diff) | |
download | imagination-e0b7d5afd9d378af5eb1300a065e2e107a1824e7.tar.gz |
WiFi HAL for uccp420
Change-Id: I36a46cc4da7db6ae58151bd513748218fe87470d
-rw-r--r-- | peripheral/wifi/uccp420/Android.mk | 35 | ||||
-rw-r--r-- | peripheral/wifi/uccp420/peripheral.mk | 26 | ||||
-rw-r--r-- | peripheral/wifi/uccp420/uccp420.rc | 5 | ||||
-rw-r--r-- | peripheral/wifi/uccp420/wifi_driver_hal_uccp.cpp | 117 |
4 files changed, 183 insertions, 0 deletions
diff --git a/peripheral/wifi/uccp420/Android.mk b/peripheral/wifi/uccp420/Android.mk new file mode 100644 index 0000000..590659d --- /dev/null +++ b/peripheral/wifi/uccp420/Android.mk @@ -0,0 +1,35 @@ +# +# 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. + +ifeq ($(WIFI_DRIVER_HAL_PERIPHERAL),uccp420) + +LOCAL_PATH := $(call my-dir) + +include $(CLEAR_VARS) + +LOCAL_INIT_RC := uccp420.rc + +LOCAL_CFLAGS += -Wno-unused-parameter +LOCAL_C_INCLUDES += device/generic/brillo/wifi_driver_hal/include +LOCAL_SHARED_LIBRARIES := libcutils +LOCAL_CPPFLAGS += -DLOG_TAG=\"hal_uccp\" +LOCAL_SRC_FILES := wifi_driver_hal_uccp.cpp +LOCAL_MODULE := $(WIFI_DRIVER_HAL_MODULE) +LOCAL_MODULE_RELATIVE_PATH := hw +LOCAL_MODULE_TAGS := optional + +include $(BUILD_SHARED_LIBRARY) + +endif diff --git a/peripheral/wifi/uccp420/peripheral.mk b/peripheral/wifi/uccp420/peripheral.mk new file mode 100644 index 0000000..708d995 --- /dev/null +++ b/peripheral/wifi/uccp420/peripheral.mk @@ -0,0 +1,26 @@ +# +# 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. +# + +# UCCP420 WIFI Firmware +UCCP420_WIFI_FW_SRC = vendor/bsp/imagination/peripheral/wifi/uccp420_firmware +UCCP420_WIFI_FW_DST = system/vendor/firmware/img/uccp420wlan + +PRODUCT_COPY_FILES += \ + $(UCCP420_WIFI_FW_SRC)/v4_5_8/MAC_LOADER.ldr:$(UCCP420_WIFI_FW_DST)/MAC_LOADER.ldr \ + $(UCCP420_WIFI_FW_SRC)/v4_5_8/MCP_LOADER.ldr:$(UCCP420_WIFI_FW_DST)/MCP_LOADER.ldr + +WIFI_DRIVER_HAL_MODULE := wifi_driver.$(soc_name) +WIFI_DRIVER_HAL_PERIPHERAL := uccp420 diff --git a/peripheral/wifi/uccp420/uccp420.rc b/peripheral/wifi/uccp420/uccp420.rc new file mode 100644 index 0000000..fe4657c --- /dev/null +++ b/peripheral/wifi/uccp420/uccp420.rc @@ -0,0 +1,5 @@ +# bcsp configuration + +# Tell the kernel driver where to find the firmware +on early-boot + write /sys/module/firmware_class/parameters/path /vendor/firmware diff --git a/peripheral/wifi/uccp420/wifi_driver_hal_uccp.cpp b/peripheral/wifi/uccp420/wifi_driver_hal_uccp.cpp new file mode 100644 index 0000000..e39da28 --- /dev/null +++ b/peripheral/wifi/uccp420/wifi_driver_hal_uccp.cpp @@ -0,0 +1,117 @@ +/* + * 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 <fcntl.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <unistd.h> + +#include <cutils/log.h> +#include <cutils/properties.h> +#include <hardware_brillo/wifi_driver_hal.h> + +#include <string> + +#include <net/if_arp.h> +#include <net/ethernet.h> + +namespace { + +const char kDevicePathPrefix[] = "/sys/class/net/"; +const char kStationDeviceName[] = "wlan0"; + +static bool interface_exists(const char *interface_name) { + std::string interface_path = std::string(kDevicePathPrefix) + interface_name; + return access(interface_path.c_str(), F_OK) == 0; +} + +static wifi_driver_error wifi_driver_initialize_uccp(void) { + return WIFI_SUCCESS; +} + +static wifi_driver_error wifi_driver_set_mode_uccp( + wifi_driver_mode mode, char *wifi_device_name, + size_t wifi_device_name_size) { + const char *device_name = nullptr; + + switch (mode) { + case WIFI_MODE_AP: + device_name = kStationDeviceName; + break; + + case WIFI_MODE_STATION: + device_name = kStationDeviceName; + break; + + default: + ALOGE("Unknown WiFi driver mode %d", mode); + return WIFI_ERROR_INVALID_ARGS; + } + + ALOGV("%s: device_name:%s", __func__, device_name); + + strlcpy(wifi_device_name, device_name, wifi_device_name_size); + if (interface_exists(device_name)) return WIFI_SUCCESS; + + ALOGE("wifi_driver_set_mode_uccp: Failed to configure interface for %s", + device_name); + + return WIFI_ERROR_TIMED_OUT; +} + +static int close_uccp_driver(struct hw_device_t *device) { + wifi_driver_device_t *dev = reinterpret_cast<wifi_driver_device_t *>(device); + if (dev) free(dev); + return 0; +} + +static int open_uccp_driver(const struct hw_module_t *module, const char *, + struct hw_device_t **device) { + wifi_driver_device_t *dev = reinterpret_cast<wifi_driver_device_t *>( + calloc(1, sizeof(wifi_driver_device_t))); + + dev->common.tag = HARDWARE_DEVICE_TAG; + dev->common.version = WIFI_DRIVER_DEVICE_API_VERSION_0_1; + // We're forced into this cast by the existing API. This pattern is + // common among users of the HAL. + dev->common.module = const_cast<hw_module_t *>(module); + dev->common.close = close_uccp_driver; + dev->wifi_driver_initialize = wifi_driver_initialize_uccp; + dev->wifi_driver_set_mode = wifi_driver_set_mode_uccp; + + *device = &dev->common; + + return 0; +} + +static struct hw_module_methods_t uccp_driver_module_methods = { + .open = open_uccp_driver, +}; + +} // namespace {} + +hw_module_t HAL_MODULE_INFO_SYM = { + .tag = HARDWARE_MODULE_TAG, + .version_major = 1, + .version_minor = 0, + .id = WIFI_DRIVER_HARDWARE_MODULE_ID, + .name = "UCCP / Imagination", + .author = "Imagination", + .methods = &uccp_driver_module_methods, + .dso = NULL, + .reserved = {0}, +}; |