On Fri, Apr 22, 2011 at 2:20 AM, Rajkumar Manoharan <rmanoharan@xxxxxxxxxxx> wrote: > On AR9003 chips, doing three IQ calibrations will possibly cause chip > in stuck state. In noisy environment, chip could receive > a packet during the middle of three calibrations and it causes > the conflict of HW access and the eventual failure. It also > causes IQ calibration outliers which results in poor Tx EVM. [...] > + /* 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; > + } else if (mp_coeff[i] < mp_min) { > + mp_min = mp_coeff[i]; > + min_idx = i; > + } > + } > > - if (diff[0] <= diff[1] && diff[0] <= diff[2]) > - *mp_avg = (mp_coeff[0] + mp_coeff[1]) / 2; > - else if (diff[1] <= diff[2]) > - *mp_avg = (mp_coeff[1] + mp_coeff[2]) / 2; > - else > - *mp_avg = (mp_coeff[2] + mp_coeff[0]) / 2; > + /* 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))) Doesn't this potentially throw away more than one potential sample from your mp_avg sum if more than one value has the same (maximal absolute) value? You don't account for it below since you divide by (nmeasurement - 1) so your average can get arbitrarily smaller than you intended, which may false-trigger your outlier detection. > + mp_avg += mp_coeff[i]; > + } > + mp_avg /= (nmeasurement - 1); > > - return true; > + /* detect outlier */ > + if (abs(mp_max - mp_min) > max_delta) { > + if (abs(mp_max - mp_avg) > abs(mp_min - mp_avg)) > + outlier_idx = max_idx; > + else > + outlier_idx = min_idx; > + } > + mp_coeff[outlier_idx] = mp_avg; > } -- To unsubscribe from this list: send the line "unsubscribe linux-wireless" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html