qcacld-3.0: Fix power units in wlan_hdd_cfg80211_set_txpower()
wlan_hdd_cfg80211_set_txpower() currently expects the input power to be in units of dBm. However cfg80211 specifies the set_tx_power() method will pass the power in mBm, and that to get dBm the driver should use MBM_TO_DBM(). The userspace tool "iw" also expects the power to be in mBm. In order to comply with the definition of cfg80211, change the implementation of wlan_hdd_cfg80211_set_txpower() to expect the power in mBm and use MBM_TO_DBM() to convert the power to dBm. But for backward compatibility with userspace entities which are expecting the current implementation, if the converted power is 0 then assume the input power is already in dBm and use it without conversion. Change-Id: I7c64f7ac14249a307357c91f8bea4dad8d59ff28 CRs-Fixed: 2331003
This commit is contained in:
@@ -1954,14 +1954,14 @@ int wlan_hdd_cfg80211_set_power_mgmt(struct wiphy *wiphy,
|
|||||||
* @wiphy: Pointer to wiphy
|
* @wiphy: Pointer to wiphy
|
||||||
* @wdev: Pointer to network device
|
* @wdev: Pointer to network device
|
||||||
* @type: TX power setting type
|
* @type: TX power setting type
|
||||||
* @dbm: TX power in dbm
|
* @mbm: TX power in mBm
|
||||||
*
|
*
|
||||||
* Return: 0 for success, non-zero for failure
|
* Return: 0 for success, non-zero for failure
|
||||||
*/
|
*/
|
||||||
static int __wlan_hdd_cfg80211_set_txpower(struct wiphy *wiphy,
|
static int __wlan_hdd_cfg80211_set_txpower(struct wiphy *wiphy,
|
||||||
struct wireless_dev *wdev,
|
struct wireless_dev *wdev,
|
||||||
enum nl80211_tx_power_setting type,
|
enum nl80211_tx_power_setting type,
|
||||||
int dbm)
|
int mbm)
|
||||||
{
|
{
|
||||||
struct hdd_context *hdd_ctx = (struct hdd_context *) wiphy_priv(wiphy);
|
struct hdd_context *hdd_ctx = (struct hdd_context *) wiphy_priv(wiphy);
|
||||||
mac_handle_t mac_handle;
|
mac_handle_t mac_handle;
|
||||||
@@ -1969,6 +1969,7 @@ static int __wlan_hdd_cfg80211_set_txpower(struct wiphy *wiphy,
|
|||||||
struct qdf_mac_addr selfMac = QDF_MAC_ADDR_BCAST_INIT;
|
struct qdf_mac_addr selfMac = QDF_MAC_ADDR_BCAST_INIT;
|
||||||
QDF_STATUS status;
|
QDF_STATUS status;
|
||||||
int errno;
|
int errno;
|
||||||
|
int dbm;
|
||||||
|
|
||||||
hdd_enter();
|
hdd_enter();
|
||||||
|
|
||||||
@@ -1987,6 +1988,16 @@ static int __wlan_hdd_cfg80211_set_txpower(struct wiphy *wiphy,
|
|||||||
|
|
||||||
mac_handle = hdd_ctx->mac_handle;
|
mac_handle = hdd_ctx->mac_handle;
|
||||||
|
|
||||||
|
dbm = MBM_TO_DBM(mbm);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* the original implementation of this function expected power
|
||||||
|
* values in dBm instead of mBm. If the conversion from mBm to
|
||||||
|
* dBm is zero, then assume dBm was passed.
|
||||||
|
*/
|
||||||
|
if (!dbm)
|
||||||
|
dbm = mbm;
|
||||||
|
|
||||||
status = sme_cfg_set_int(mac_handle, WNI_CFG_CURRENT_TX_POWER_LEVEL,
|
status = sme_cfg_set_int(mac_handle, WNI_CFG_CURRENT_TX_POWER_LEVEL,
|
||||||
dbm);
|
dbm);
|
||||||
if (QDF_IS_STATUS_ERROR(status)) {
|
if (QDF_IS_STATUS_ERROR(status)) {
|
||||||
@@ -2026,14 +2037,14 @@ static int __wlan_hdd_cfg80211_set_txpower(struct wiphy *wiphy,
|
|||||||
int wlan_hdd_cfg80211_set_txpower(struct wiphy *wiphy,
|
int wlan_hdd_cfg80211_set_txpower(struct wiphy *wiphy,
|
||||||
struct wireless_dev *wdev,
|
struct wireless_dev *wdev,
|
||||||
enum nl80211_tx_power_setting type,
|
enum nl80211_tx_power_setting type,
|
||||||
int dbm)
|
int mbm)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
cds_ssr_protect(__func__);
|
cds_ssr_protect(__func__);
|
||||||
ret = __wlan_hdd_cfg80211_set_txpower(wiphy,
|
ret = __wlan_hdd_cfg80211_set_txpower(wiphy,
|
||||||
wdev,
|
wdev,
|
||||||
type, dbm);
|
type, mbm);
|
||||||
cds_ssr_unprotect(__func__);
|
cds_ssr_unprotect(__func__);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
Reference in New Issue
Block a user