From patchwork Thu Dec 14 15:39:12 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felix Fietkau X-Patchwork-Id: 10112569 X-Patchwork-Delegate: kvalo@adurom.com Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 1EE056019C for ; Thu, 14 Dec 2017 15:39:43 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 102E828210 for ; Thu, 14 Dec 2017 15:39:43 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 05541293A1; Thu, 14 Dec 2017 15:39:43 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AB2BC28210 for ; Thu, 14 Dec 2017 15:39:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753399AbdLNPjl (ORCPT ); Thu, 14 Dec 2017 10:39:41 -0500 Received: from nbd.name ([46.4.11.11]:45532 "EHLO nbd.name" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753292AbdLNPjV (ORCPT ); Thu, 14 Dec 2017 10:39:21 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=nbd.name; s=20160729; h=References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Sender:Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=J0j7vDiVYL0L9TuN4e0fFMC/mTGPzIo1v24+oQ0JN7k=; b=DM/FjuUGgpd30C/v1fFdGlyciT H3P+fdvGqXJWZQYccDCxY3cYe3yNWcsN4liKxnH7vLF1wNS6O5nZOgPqSdi3cvgFEobJ7jMgOTq9i P2XI0yHypya78f/GowMdux+UNLnscpv3ngdMaCegKPdyUSda4jKyeSKY/GhDLKR/ulrQ=; Received: by maeck.local (Postfix, from userid 501) id 0C99D94D120; Thu, 14 Dec 2017 16:39:18 +0100 (CET) From: Felix Fietkau To: linux-wireless@vger.kernel.org Cc: kvalo@codeaurora.org Subject: [PATCH 08/14] mt76x2: convert between per-chain tx power and combined output Date: Thu, 14 Dec 2017 16:39:12 +0100 Message-Id: <20171214153918.43774-9-nbd@nbd.name> X-Mailer: git-send-email 2.14.2 In-Reply-To: <20171214153918.43774-1-nbd@nbd.name> References: <20171214153918.43774-1-nbd@nbd.name> Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Using both chains adds max. 3 dBm. A similar worst-case calculation is being used in ath9k as well to ensure that the hardware stays within regulatory limits Signed-off-by: Felix Fietkau --- drivers/net/wireless/mediatek/mt76/mt76x2_init.c | 3 +++ drivers/net/wireless/mediatek/mt76/mt76x2_main.c | 7 +++++++ 2 files changed, 10 insertions(+) diff --git a/drivers/net/wireless/mediatek/mt76/mt76x2_init.c b/drivers/net/wireless/mediatek/mt76/mt76x2_init.c index 0755b451829e..3e3a01b6f2ce 100644 --- a/drivers/net/wireless/mediatek/mt76/mt76x2_init.c +++ b/drivers/net/wireless/mediatek/mt76/mt76x2_init.c @@ -785,6 +785,9 @@ mt76x2_init_txpower(struct mt76x2_dev *dev, chan->max_power = mt76x2_get_max_rate_power(&t) + target_power; chan->max_power /= 2; + + /* convert to combined output power on 2x2 devices */ + chan->max_power += 3; } } diff --git a/drivers/net/wireless/mediatek/mt76/mt76x2_main.c b/drivers/net/wireless/mediatek/mt76/mt76x2_main.c index 02dd2cafa52f..8098a2b82c5b 100644 --- a/drivers/net/wireless/mediatek/mt76/mt76x2_main.c +++ b/drivers/net/wireless/mediatek/mt76/mt76x2_main.c @@ -155,6 +155,9 @@ mt76x2_config(struct ieee80211_hw *hw, u32 changed) if (changed & IEEE80211_CONF_CHANGE_POWER) { dev->txpower_conf = hw->conf.power_level * 2; + /* convert to per-chain power for 2x2 devices */ + dev->txpower_conf -= 6; + if (test_bit(MT76_STATE_RUNNING, &dev->mt76.state)) { mt76x2_phy_set_txpower(dev); mt76x2_tx_set_txpwr_auto(dev, dev->txpower_conf); @@ -443,6 +446,10 @@ mt76x2_get_txpower(struct ieee80211_hw *hw, struct ieee80211_vif *vif, int *dbm) struct mt76x2_dev *dev = hw->priv; *dbm = dev->txpower_cur / 2; + + /* convert from per-chain power to combined output on 2x2 devices */ + *dbm += 3; + return 0; }