From patchwork Tue Sep 6 16:29:51 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Manoharan, Rajkumar" X-Patchwork-Id: 1126742 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.4) with ESMTP id p86GTRcW029316 for ; Tue, 6 Sep 2011 16:29:29 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751611Ab1IFQ30 (ORCPT ); Tue, 6 Sep 2011 12:29:26 -0400 Received: from wolverine02.qualcomm.com ([199.106.114.251]:9232 "EHLO wolverine02.qualcomm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751223Ab1IFQ3Z (ORCPT ); Tue, 6 Sep 2011 12:29:25 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=qca.qualcomm.com; i=rmanohar@qca.qualcomm.com; q=dns/txt; s=qcdkim; t=1315326565; x=1346862565; h=from:to:cc:subject:date:message-id:mime-version; z=From:=20Rajkumar=20Manoharan=20|To:=20|CC:=20,=20Rajkumar=20Manoharan=0D=0A=09,=20Kai=20Shi=20|Subject:=20[PATCH=20v2]=20ath9k_hw:=20Fix=20magnitude/ phase=20average=20in=20TxIQ=20Calibration|Date:=20Tue,=20 6=20Sep=202011=2021:59:51=20+0530|Message-ID:=20<13153265 91-2938-1-git-send-email-rmanohar@qca.qualcomm.com> |MIME-Version:=201.0; bh=UIirrLy0GnQAphOpRhmKqekQCITaAxmDAvDunHQS458=; b=OhlQN9Aie+D93fJHQe5alc14totTInSjdJ1VservXxoH0p8pnyXCMrxQ e4QTMrYns8oXhVPjM417n0OHOEVWUAUJ3HlHVBxgUeOMuYvxVEf0maIHW wjPm6U1+DDermAy/t6itVxKWIs/tXqNMSKJ9K0QFsFHemLx0O9KqDepki Q=; X-IronPort-AV: E=McAfee;i="5400,1158,6460"; a="115682792" Received: from ironmsg04-r.qualcomm.com ([172.30.46.18]) by wolverine02.qualcomm.com with ESMTP; 06 Sep 2011 09:29:25 -0700 X-IronPort-AV: E=Sophos;i="4.68,338,1312182000"; d="scan'208";a="131966610" Received: from nasanexhub02.na.qualcomm.com ([10.46.143.120]) by Ironmsg04-R.qualcomm.com with ESMTP/TLS/RC4-MD5; 06 Sep 2011 09:29:25 -0700 Received: from NASJOEXHC01.na.qualcomm.com (10.234.56.15) by nasanexhub02.na.qualcomm.com (10.46.143.120) with Microsoft SMTP Server (TLS) id 8.3.83.0; Tue, 6 Sep 2011 09:29:18 -0700 Received: from qcamail1.atheros.com (10.12.7.11) by qcamail1.atheros.com (10.234.56.15) with Microsoft SMTP Server (TLS) id 14.1.323.3; Tue, 6 Sep 2011 09:29:16 -0700 Received: by qcamail1.atheros.com (sSMTP sendmail emulation); Tue, 06 Sep 2011 21:59:51 +0530 From: Rajkumar Manoharan To: CC: , Rajkumar Manoharan , Kai Shi Subject: [PATCH v2] ath9k_hw: Fix magnitude/phase average in TxIQ Calibration Date: Tue, 6 Sep 2011 21:59:51 +0530 Message-ID: <1315326591-2938-1-git-send-email-rmanohar@qca.qualcomm.com> X-Mailer: git-send-email 1.7.6.1 MIME-Version: 1.0 X-Originating-IP: [10.12.7.11] Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Tue, 06 Sep 2011 16:29:29 +0000 (UTC) The commit "ath9k_hw: Fix Tx IQ Calibration hang issue in AR9003 chips" did not consider more than one potential sample while calculating magnitude/phase average if more than one sample has the same value which could affect post-processing of outlier detection that causes an undesirable Tx IQ correction value will be assigned to tx gain settings where outlier happens. Cc: Kai Shi Reported-by: Paul Stewart Signed-off-by: Rajkumar Manoharan Signed-off-by: Paul Stewart --- drivers/net/wireless/ath/ath9k/ar9003_calib.c | 17 +++++++++++++---- 1 files changed, 13 insertions(+), 4 deletions(-) diff --git a/drivers/net/wireless/ath/ath9k/ar9003_calib.c b/drivers/net/wireless/ath/ath9k/ar9003_calib.c index ee3a8a2..695d9d3 100644 --- a/drivers/net/wireless/ath/ath9k/ar9003_calib.c +++ b/drivers/net/wireless/ath/ath9k/ar9003_calib.c @@ -615,11 +615,10 @@ static void ar9003_hw_detect_outlier(int *mp_coeff, int nmeasurement, { int mp_max = -64, max_idx = 0; int mp_min = 63, min_idx = 0; - int mp_avg = 0, i, outlier_idx = 0; + int mp_avg = 0, i, outlier_idx = 0, mp_count = 0; /* find min/max mismatch across all calibrated gains */ for (i = 0; i < nmeasurement; i++) { - mp_avg += mp_coeff[i]; if (mp_coeff[i] > mp_max) { mp_max = mp_coeff[i]; max_idx = i; @@ -632,10 +631,20 @@ static void ar9003_hw_detect_outlier(int *mp_coeff, int nmeasurement, /* find average (exclude max abs value) */ for (i = 0; i < nmeasurement; i++) { if ((abs(mp_coeff[i]) < abs(mp_max)) || - (abs(mp_coeff[i]) < abs(mp_min))) + (abs(mp_coeff[i]) < abs(mp_min))) { mp_avg += mp_coeff[i]; + mp_count++; + } } - mp_avg /= (nmeasurement - 1); + + /* + * finding mean magnitude/phase if possible, otherwise + * just use the last value as the mean + */ + if (mp_count) + mp_avg /= mp_count; + else + mp_avg = mp_coeff[nmeasurement - 1]; /* detect outlier */ if (abs(mp_max - mp_min) > max_delta) {