[RK3288][Android6.0] WiFi的HAL层加载问题

Platform: Rockchip
OS: Android 6.0
Kernel: 3.10.92

背景:

几年前做高通平台到现在,我一直认为hardware下面目录都是只跟用哪个vendor相关,比如现在用的是rk,那么就是rockchip目录有用,现在才发现broadcom也会在WiFi中被用到,还好偷懒没把此git从仓库中删除…

过程:

WiFi开启的时候会调用如下流程来加载HAL
WifiNative.startHal -> startHal -> startHalNative -> android_net_wifi_startHal

static jboolean android_net_wifi_startHal(JNIEnv* env, jclass cls) {
......
    if(init_wifi_hal_func_table(&hal_fn) != 0 ) {
        ALOGD("Can not initialize the basic function pointer table");
        return false;
    }
    wifi_error res = init_wifi_vendor_hal_func_table(&hal_fn);
    if (res != WIFI_SUCCESS) {
        ALOGD("Can not initialize the vendor function pointer table");
    return false;
    }
......
}

先调用init_wifi_hal_func_table()@com_android_server_wifi_WifiNative.cpp做一次初始化,
使用的是stub系列函数,都未实现,然后如果有的话会通过init_wifi_vendor_hal_func_table()来覆盖,
而init_wifi_vendor_hal_func_table()会用哪个呢? 来看Android.mk
frameworks/opt/net/wifi/service/Android.mk

LIB_WIFI_HAL := libwifi-hal
ifeq ($(BOARD_WLAN_DEVICE), bcmdhd)
  LIB_WIFI_HAL := libwifi-hal-bcm
else ifeq ($(BOARD_WLAN_DEVICE), qcwcn)
  LIB_WIFI_HAL := libwifi-hal-qcom
else ifeq ($(BOARD_WLAN_DEVICE), mrvl)
  # this is commented because none of the nexus devices
  # that sport Marvell's wifi have support for HAL
  # LIB_WIFI_HAL := libwifi-hal-mrvl
else ifeq ($(BOARD_WLAN_DEVICE), MediaTek)
  # support MTK WIFI HAL
  LIB_WIFI_HAL := libwifi-hal-mt66xx
endif
......
LOCAL_STATIC_LIBRARIES += $(LIB_WIFI_HAL)

LIB_WIFI_HAL会根据$(BOARD_WLAN_DEVICE)的值来选择不同的库,那么BOARD_WLAN_DEVICE在哪里定义?
device/rockchip/common/wifi_bt_common.mk
BOARD_WLAN_DEVICE := bcmdhd
印象中看到过rk文档说wifi_bt_common.mk用不到了,貌似这里也被用上了。
那么就会加载libwifi-hal-bcm,此库正是在hardware/broadcom/wlan/bcmdhd/wifi_hal路径下生成的!

你可能感兴趣的:(子类__WiFi)