diff options
author | android-build-team Robot <android-build-team-robot@google.com> | 2017-07-12 07:31:12 +0000 |
---|---|---|
committer | android-build-team Robot <android-build-team-robot@google.com> | 2017-07-12 07:31:12 +0000 |
commit | 2af07e3194c632841a98b8d96450385c162f8911 (patch) | |
tree | 2c0439e0b75be4be6db6106b0d8e397a8975a08d | |
parent | f25aaa1cfa7e9b11323ccad9dbb904a9e76f0ca5 (diff) | |
parent | a9fced9c474e3490030b3cac446647805074132c (diff) | |
download | android_hardware_qcom_wlan-2af07e3194c632841a98b8d96450385c162f8911.tar.gz android_hardware_qcom_wlan-2af07e3194c632841a98b8d96450385c162f8911.tar.bz2 android_hardware_qcom_wlan-2af07e3194c632841a98b8d96450385c162f8911.zip |
release-request-b6f2d5b3-a3d6-410f-b58f-c85ba8187177-for-git_oc-mr1-release-4173087 snap-temp-L93200000081515229
Change-Id: I5723561f1961ed3f5c4527c7b6348015b197bd45
-rw-r--r-- | qcwcn/wifi_hal/wifi_hal.cpp | 2 | ||||
-rw-r--r-- | qcwcn/wifi_hal/wificonfig.cpp | 140 |
2 files changed, 142 insertions, 0 deletions
diff --git a/qcwcn/wifi_hal/wifi_hal.cpp b/qcwcn/wifi_hal/wifi_hal.cpp index 4145785..4dd4a67 100644 --- a/qcwcn/wifi_hal/wifi_hal.cpp +++ b/qcwcn/wifi_hal/wifi_hal.cpp @@ -411,6 +411,8 @@ wifi_error init_wifi_vendor_hal_func_table(wifi_hal_fn *fn) { fn->wifi_get_roaming_capabilities = wifi_get_roaming_capabilities; fn->wifi_configure_roaming = wifi_configure_roaming; fn->wifi_enable_firmware_roaming = wifi_enable_firmware_roaming; + fn->wifi_set_tx_power_limit = wifi_set_tx_power_limit; + fn->wifi_reset_tx_power_limit = wifi_reset_tx_power_limit; return WIFI_SUCCESS; } diff --git a/qcwcn/wifi_hal/wificonfig.cpp b/qcwcn/wifi_hal/wificonfig.cpp index 0b987b5..e8691eb 100644 --- a/qcwcn/wifi_hal/wificonfig.cpp +++ b/qcwcn/wifi_hal/wificonfig.cpp @@ -287,6 +287,146 @@ cleanup: return (wifi_error)ret; } +wifi_error wifi_set_tx_power_limit(wifi_interface_handle handle, + u32 tx_level_dbm) +{ + int ret = 0; + WiFiConfigCommand *wifiConfigCommand; + struct nlattr *nlData, *nlLimitSpec; + interface_info *ifaceInfo = getIfaceInfo(handle); + wifi_handle wifiHandle = getWifiHandle(handle); + u32 numSpecs = 1, j; + + ALOGV("%s : tx power limit:%u", __FUNCTION__, tx_level_dbm); + + wifiConfigCommand = new WiFiConfigCommand( + wifiHandle, + 1, + OUI_QCA, + QCA_NL80211_VENDOR_SUBCMD_SET_SAR_LIMITS); + if (wifiConfigCommand == NULL) { + ALOGE("%s: Error wifiConfigCommand NULL", __FUNCTION__); + return WIFI_ERROR_UNKNOWN; + } + + /* Create the NL message. */ + ret = wifiConfigCommand->create(); + if (ret < 0) { + ALOGE("wifi_set_tx_power_limit: failed to create NL msg. Error:%d", ret); + goto cleanup; + } + + /* Set the interface Id of the message. */ + ret = wifiConfigCommand->set_iface_id(ifaceInfo->name); + if (ret < 0) { + ALOGE("wifi_set_tx_power_limit: failed to set iface id. Error:%d", ret); + goto cleanup; + } + + /* Add the vendor specific attributes for the NL command. */ + nlData = wifiConfigCommand->attr_start(NL80211_ATTR_VENDOR_DATA); + if (!nlData) { + ALOGE("wifi_set_tx_power_limit: failed attr_start for VENDOR_DATA. " + "Error:%d", ret); + goto cleanup; + } + + if (wifiConfigCommand->put_u32( + QCA_WLAN_VENDOR_ATTR_SAR_LIMITS_SAR_ENABLE, + QCA_WLAN_VENDOR_ATTR_SAR_LIMITS_SELECT_USER) || + wifiConfigCommand->put_u32( + QCA_WLAN_VENDOR_ATTR_SAR_LIMITS_NUM_SPECS, numSpecs)) { + ALOGE("failed to put SAR_ENABLE or NUM_SPECS"); + goto cleanup; + } + + nlLimitSpec = + wifiConfigCommand->attr_start(QCA_WLAN_VENDOR_ATTR_SAR_LIMITS_SPEC); + + /* Add NL attributes for SAR limit specs . */ + for (j = 0; j < numSpecs; j++) { + struct nlattr *nl_sarSpec = wifiConfigCommand->attr_start(j); + + if (wifiConfigCommand->put_u32( + QCA_WLAN_VENDOR_ATTR_SAR_LIMITS_SPEC_POWER_LIMIT, tx_level_dbm)) { + ALOGE("wifi_set_tx_power_limit: failed to add vendor data."); + goto cleanup; + } + + wifiConfigCommand->attr_end(nl_sarSpec); + } + wifiConfigCommand->attr_end(nlLimitSpec); + wifiConfigCommand->attr_end(nlData); + + ret = wifiConfigCommand->requestEvent(); + if (ret != 0) { + ALOGE("wifi_set_tx_power_limit(): requestEvent Error:%d", ret); + goto cleanup; + } + +cleanup: + delete wifiConfigCommand; + return (wifi_error)ret; +} + +wifi_error wifi_reset_tx_power_limit(wifi_interface_handle handle) +{ + int ret = 0; + WiFiConfigCommand *wifiConfigCommand; + struct nlattr *nlData; + interface_info *ifaceInfo = getIfaceInfo(handle); + wifi_handle wifiHandle = getWifiHandle(handle); + + wifiConfigCommand = new WiFiConfigCommand( + wifiHandle, + 1, + OUI_QCA, + QCA_NL80211_VENDOR_SUBCMD_SET_SAR_LIMITS); + if (wifiConfigCommand == NULL) { + ALOGE("%s: Error wifiConfigCommand NULL", __FUNCTION__); + return WIFI_ERROR_UNKNOWN; + } + + /* Create the NL message. */ + ret = wifiConfigCommand->create(); + if (ret < 0) { + ALOGE("wifi_set_tx_power_limit: failed to create NL msg. Error:%d", ret); + goto cleanup; + } + + /* Set the interface Id of the message. */ + ret = wifiConfigCommand->set_iface_id(ifaceInfo->name); + if (ret < 0) { + ALOGE("wifi_set_tx_power_limit: failed to set iface id. Error:%d", ret); + goto cleanup; + } + + /* Add the vendor specific attributes for the NL command. */ + nlData = wifiConfigCommand->attr_start(NL80211_ATTR_VENDOR_DATA); + if (!nlData) { + ALOGE("wifi_set_tx_power_limit: failed attr_start for VENDOR_DATA. " + "Error:%d", ret); + goto cleanup; + } + + if (wifiConfigCommand->put_u32(QCA_WLAN_VENDOR_ATTR_SAR_LIMITS_SAR_ENABLE, + QCA_WLAN_VENDOR_ATTR_SAR_LIMITS_SELECT_NONE)) { + ALOGE("failed to put SAR_ENABLE or NUM_SPECS"); + goto cleanup; + } + wifiConfigCommand->attr_end(nlData); + + ret = wifiConfigCommand->requestEvent(); + if (ret != 0) { + ALOGE("wifi_set_tx_power_limit(): requestEvent Error:%d", ret); + goto cleanup; + } + +cleanup: + delete wifiConfigCommand; + return (wifi_error)ret; +} + WiFiConfigCommand::WiFiConfigCommand(wifi_handle handle, int id, u32 vendor_id, u32 subcmd) |