wifi(hidl): Modify the SAR power levels interface
Modifying the interface used to lower the tx power level for meeting SAR
requirements based on recommendation from the nexus hardware team. The
previous interface passed in a single power value in dBm for meeting SAR
requirements. However, the SAR requirements are more complex than that.
Based on the connection mode (802.11 a,b,g,n,ac) and the number of
streams that are active (MIMO), the SAR power levels are very
different. Using the previous interface would mean that we will have to
use the lowest power level among all the connection modes to meet the SAR
requirements. This would however result in us lowering the power much
more than needed (~2 dBm) for many connection modes.
Instead, we're switching to a more generic interface where the framework
informs the wifi chip that we're entering a special tx power mode scenario
(today, there is only 1 for voice call). The chip can then lookup the
extensive table of power levels for different connection modes which are
pre-populated by the OEM's in the BDF file to set the power level (depending
on the scenario framework sends and the active connection mode).
Bug: 62437848
Test: Manual tests
Change-Id: I5ee3f0d2c130958dbeb352e3b5ad9407f432624f
diff --git a/wifi/1.1/default/hidl_struct_util.cpp b/wifi/1.1/default/hidl_struct_util.cpp
index 6b93b9e..c53cdc5 100644
--- a/wifi/1.1/default/hidl_struct_util.cpp
+++ b/wifi/1.1/default/hidl_struct_util.cpp
@@ -17,9 +17,6 @@
#include <android-base/logging.h>
#include <utils/SystemClock.h>
-#include <android/hardware/wifi/1.0/IWifiChip.h>
-#include <android/hardware/wifi/1.1/IWifiChip.h>
-
#include "hidl_struct_util.h"
namespace android {
@@ -260,6 +257,15 @@
return true;
}
+legacy_hal::wifi_power_scenario convertHidlTxPowerScenarioToLegacy(
+ V1_1::IWifiChip::TxPowerScenario hidl_scenario) {
+ switch (hidl_scenario) {
+ case V1_1::IWifiChip::TxPowerScenario::VOICE_CALL:
+ return legacy_hal::WIFI_POWER_SCENARIO_VOICE_CALL;
+ };
+ CHECK(false);
+}
+
bool convertLegacyFeaturesToHidlStaCapabilities(
uint32_t legacy_feature_set,
uint32_t legacy_logger_feature_set,
diff --git a/wifi/1.1/default/hidl_struct_util.h b/wifi/1.1/default/hidl_struct_util.h
index 7a840f9..747fd2f 100644
--- a/wifi/1.1/default/hidl_struct_util.h
+++ b/wifi/1.1/default/hidl_struct_util.h
@@ -20,6 +20,8 @@
#include <vector>
#include <android/hardware/wifi/1.0/types.h>
+#include <android/hardware/wifi/1.0/IWifiChip.h>
+#include <android/hardware/wifi/1.1/IWifiChip.h>
#include "wifi_legacy_hal.h"
@@ -51,6 +53,8 @@
bool convertLegacyWakeReasonStatsToHidl(
const legacy_hal::WakeReasonStats& legacy_stats,
WifiDebugHostWakeReasonStats* hidl_stats);
+legacy_hal::wifi_power_scenario convertHidlTxPowerScenarioToLegacy(
+ V1_1::IWifiChip::TxPowerScenario hidl_scenario);
// STA iface conversion methods.
bool convertLegacyFeaturesToHidlStaCapabilities(
diff --git a/wifi/1.1/default/wifi_chip.cpp b/wifi/1.1/default/wifi_chip.cpp
index 2beac26..2f40234 100644
--- a/wifi/1.1/default/wifi_chip.cpp
+++ b/wifi/1.1/default/wifi_chip.cpp
@@ -343,20 +343,20 @@
enable);
}
-Return<void> WifiChip::setTxPowerLimit(
- int32_t powerInDbm, setTxPowerLimit_cb hidl_status_cb) {
+Return<void> WifiChip::selectTxPowerScenario(
+ TxPowerScenario scenario, selectTxPowerScenario_cb hidl_status_cb) {
return validateAndCall(this,
WifiStatusCode::ERROR_WIFI_CHIP_INVALID,
- &WifiChip::setTxPowerLimitInternal,
+ &WifiChip::selectTxPowerScenarioInternal,
hidl_status_cb,
- powerInDbm);
+ scenario);
}
-Return<void> WifiChip::resetTxPowerLimit(
- resetTxPowerLimit_cb hidl_status_cb) {
+Return<void> WifiChip::resetTxPowerScenario(
+ resetTxPowerScenario_cb hidl_status_cb) {
return validateAndCall(this,
WifiStatusCode::ERROR_WIFI_CHIP_INVALID,
- &WifiChip::resetTxPowerLimitInternal,
+ &WifiChip::resetTxPowerScenarioInternal,
hidl_status_cb);
}
@@ -824,13 +824,14 @@
return createWifiStatusFromLegacyError(legacy_status);
}
-WifiStatus WifiChip::setTxPowerLimitInternal(int32_t powerInDbm) {
- auto legacy_status = legacy_hal_.lock()->setTxPowerLimit(powerInDbm);
+WifiStatus WifiChip::selectTxPowerScenarioInternal(TxPowerScenario scenario) {
+ auto legacy_status = legacy_hal_.lock()->selectTxPowerScenario(
+ hidl_struct_util::convertHidlTxPowerScenarioToLegacy(scenario));
return createWifiStatusFromLegacyError(legacy_status);
}
-WifiStatus WifiChip::resetTxPowerLimitInternal() {
- auto legacy_status = legacy_hal_.lock()->resetTxPowerLimit();
+WifiStatus WifiChip::resetTxPowerScenarioInternal() {
+ auto legacy_status = legacy_hal_.lock()->resetTxPowerScenario();
return createWifiStatusFromLegacyError(legacy_status);
}
diff --git a/wifi/1.1/default/wifi_chip.h b/wifi/1.1/default/wifi_chip.h
index b7dde50..e88100b 100644
--- a/wifi/1.1/default/wifi_chip.h
+++ b/wifi/1.1/default/wifi_chip.h
@@ -126,9 +126,11 @@
getDebugHostWakeReasonStats_cb hidl_status_cb) override;
Return<void> enableDebugErrorAlerts(
bool enable, enableDebugErrorAlerts_cb hidl_status_cb) override;
- Return<void> setTxPowerLimit(
- int32_t powerInDbm, setTxPowerLimit_cb hidl_status_cb) override;
- Return<void> resetTxPowerLimit(resetTxPowerLimit_cb hidl_status_cb) override;
+ Return<void> selectTxPowerScenario(
+ TxPowerScenario scenario,
+ selectTxPowerScenario_cb hidl_status_cb) override;
+ Return<void> resetTxPowerScenario(
+ resetTxPowerScenario_cb hidl_status_cb) override;
private:
void invalidateAndRemoveAllIfaces();
@@ -180,8 +182,8 @@
std::pair<WifiStatus, WifiDebugHostWakeReasonStats>
getDebugHostWakeReasonStatsInternal();
WifiStatus enableDebugErrorAlertsInternal(bool enable);
- WifiStatus setTxPowerLimitInternal(int32_t powerInDbm);
- WifiStatus resetTxPowerLimitInternal();
+ WifiStatus selectTxPowerScenarioInternal(TxPowerScenario scenario);
+ WifiStatus resetTxPowerScenarioInternal();
WifiStatus handleChipConfiguration(ChipModeId mode_id);
WifiStatus registerDebugRingBufferCallback();
diff --git a/wifi/1.1/default/wifi_legacy_hal.cpp b/wifi/1.1/default/wifi_legacy_hal.cpp
index 052aafb..7d683d3 100644
--- a/wifi/1.1/default/wifi_legacy_hal.cpp
+++ b/wifi/1.1/default/wifi_legacy_hal.cpp
@@ -752,13 +752,13 @@
oui_internal.data());
}
-wifi_error WifiLegacyHal::setTxPowerLimit(int32_t tx_level_dbm) {
- return global_func_table_.wifi_set_tx_power_limit(wlan_interface_handle_,
- tx_level_dbm);
+wifi_error WifiLegacyHal::selectTxPowerScenario(wifi_power_scenario scenario) {
+ return global_func_table_.wifi_select_tx_power_scenario(
+ wlan_interface_handle_, scenario);
}
-wifi_error WifiLegacyHal::resetTxPowerLimit() {
- return global_func_table_.wifi_reset_tx_power_limit(wlan_interface_handle_);
+wifi_error WifiLegacyHal::resetTxPowerScenario() {
+ return global_func_table_.wifi_reset_tx_power_scenario(wlan_interface_handle_);
}
std::pair<wifi_error, uint32_t> WifiLegacyHal::getLoggerSupportedFeatureSet() {
diff --git a/wifi/1.1/default/wifi_legacy_hal.h b/wifi/1.1/default/wifi_legacy_hal.h
index 8d9144d..caa1bd5 100644
--- a/wifi/1.1/default/wifi_legacy_hal.h
+++ b/wifi/1.1/default/wifi_legacy_hal.h
@@ -205,8 +205,8 @@
uint32_t period_in_ms);
wifi_error stopSendingOffloadedPacket(uint32_t cmd_id);
wifi_error setScanningMacOui(const std::array<uint8_t, 3>& oui);
- wifi_error setTxPowerLimit(int32_t tx_level_dbm);
- wifi_error resetTxPowerLimit();
+ wifi_error selectTxPowerScenario(wifi_power_scenario scenario);
+ wifi_error resetTxPowerScenario();
// Logger/debug functions.
std::pair<wifi_error, uint32_t> getLoggerSupportedFeatureSet();
wifi_error startPktFateMonitoring();
diff --git a/wifi/1.1/default/wifi_legacy_hal_stubs.cpp b/wifi/1.1/default/wifi_legacy_hal_stubs.cpp
index 24ed548..c02e3ba 100644
--- a/wifi/1.1/default/wifi_legacy_hal_stubs.cpp
+++ b/wifi/1.1/default/wifi_legacy_hal_stubs.cpp
@@ -132,8 +132,8 @@
populateStubFor(&hal_fn->wifi_get_roaming_capabilities);
populateStubFor(&hal_fn->wifi_enable_firmware_roaming);
populateStubFor(&hal_fn->wifi_configure_roaming);
- populateStubFor(&hal_fn->wifi_set_tx_power_limit);
- populateStubFor(&hal_fn->wifi_reset_tx_power_limit);
+ populateStubFor(&hal_fn->wifi_select_tx_power_scenario);
+ populateStubFor(&hal_fn->wifi_reset_tx_power_scenario);
return true;
}
} // namespace legacy_hal