sys/dev/netif/ath/hal/ath_hal/ar5416/ar5416_cal.c
HAL_BOOL
ar5416PerCalibrationN(struct ath_hal *ah, struct ieee80211_channel *chan,
	u_int rxchainmask, HAL_BOOL longcal, HAL_BOOL *isCalDone)
{
	struct ar5416PerCal *cal = &AH5416(ah)->ah_cal;
	HAL_CAL_LIST *currCal = cal->cal_curr;
	HAL_CHANNEL_INTERNAL *ichan;

	OS_MARK(ah, AH_MARK_PERCAL, chan->ic_freq);

	*isCalDone = AH_TRUE;

	/*
	 * Since ath_hal calls the PerCal method with rxchainmask=0x1;
	 * override it with the current chainmask. The upper levels currently
	 * doesn't know about the chainmask.
	 */
	rxchainmask = AH5416(ah)->ah_rx_chainmask;

	/* Invalid channel check */
	ichan = ath_hal_checkchannel(ah, chan);
	if (ichan == AH_NULL) {
		HALDEBUG(ah, HAL_DEBUG_ANY,
		    "%s: invalid channel %u/0x%x; no mapping\n",
		    __func__, chan->ic_freq, chan->ic_flags);
		return AH_FALSE;
	}

	/*
	 * For given calibration:
	 * 1. Call generic cal routine
	 * 2. When this cal is done (isCalDone) if we have more cals waiting
	 *    (eg after reset), mask this to upper layers by not propagating
	 *    isCalDone if it is set to TRUE.
	 *    Instead, change isCalDone to FALSE and setup the waiting cal(s)
	 *    to be run.
	 */
	if (currCal != AH_NULL &&
	    (currCal->calState == CAL_RUNNING ||
	     currCal->calState == CAL_WAITING)) {
		ar5416DoCalibration(ah, ichan, rxchainmask, currCal, isCalDone);
		if (*isCalDone == AH_TRUE) {
			cal->cal_curr = currCal = currCal->calNext;
			if (currCal->calState == CAL_WAITING) {
				*isCalDone = AH_FALSE;
				ar5416ResetMeasurement(ah, currCal);
			}
		}
	}

	/* Do NF cal only at longer intervals */
	if (longcal) {
		/*
		 * Get the value from the previous NF cal
		 * and update the history buffer.
		 */
		ar5416GetNf(ah, chan);

		/* 
		 * Load the NF from history buffer of the current channel.
		 * NF is slow time-variant, so it is OK to use a
		 * historical value.
		 */
		ar5416LoadNF(ah, AH_PRIVATE(ah)->ah_curchan);

		/* start NF calibration, without updating BB NF register*/
		ar5416StartNFCal(ah);
	}
	return AH_TRUE;
}
/*
 * Internal interface to schedule periodic calibration work.
 */
Internal interface to schedule periodic calibration work.
Internal interface to schedule periodic calibration work .
HAL_BOOL
ar5416PerCalibrationN(struct ath_hal *ah, struct ieee80211_channel *chan,
	u_int rxchainmask, HAL_BOOL longcal, HAL_BOOL *isCalDone)
{
	struct ar5416PerCal *cal = &AH5416(ah)->ah_cal;
	HAL_CAL_LIST *currCal = cal->cal_curr;
	HAL_CHANNEL_INTERNAL *ichan;
	OS_MARK(ah, AH_MARK_PERCAL, chan->ic_freq);
	*isCalDone = AH_TRUE;
	rxchainmask = AH5416(ah)->ah_rx_chainmask;
	ichan = ath_hal_checkchannel(ah, chan);
	if (ichan == AH_NULL) {
		HALDEBUG(ah, HAL_DEBUG_ANY,
		    "%s: invalid channel %u/0x%x; no mapping\n",
		    __func__, chan->ic_freq, chan->ic_flags);
		return AH_FALSE;
	}
	if (currCal != AH_NULL &&
	    (currCal->calState == CAL_RUNNING ||
	     currCal->calState == CAL_WAITING)) {
		ar5416DoCalibration(ah, ichan, rxchainmask, currCal, isCalDone);
		if (*isCalDone == AH_TRUE) {
			cal->cal_curr = currCal = currCal->calNext;
			if (currCal->calState == CAL_WAITING) {
				*isCalDone = AH_FALSE;
				ar5416ResetMeasurement(ah, currCal);
			}
		}
	}
	if (longcal) {
		ar5416GetNf(ah, chan);
		ar5416LoadNF(ah, AH_PRIVATE(ah)->ah_curchan);
		ar5416StartNFCal(ah);
	}
	return AH_TRUE;
}
HAL_BOOL ar5416PerCalibrationN ( struct ath_hal * ah , struct ieee80211_channel * chan , u_int rxchainmask , HAL_BOOL longcal , HAL_BOOL * isCalDone ) { struct ar5416PerCal * cal = & AH5416 ( ah ) -> ah_cal ; HAL_CAL_LIST * currCal = cal -> cal_curr ; HAL_CHANNEL_INTERNAL * ichan ; OS_MARK ( ah , AH_MARK_PERCAL , chan -> ic_freq ) ; * isCalDone = AH_TRUE ; rxchainmask = AH5416 ( ah ) -> ah_rx_chainmask ; ichan = ath_hal_checkchannel ( ah , chan ) ; if ( ichan == AH_NULL ) { HALDEBUG ( ah , HAL_DEBUG_ANY , " \n " , __func__ , chan -> ic_freq , chan -> ic_flags ) ; return AH_FALSE ; } if ( currCal != AH_NULL && ( currCal -> calState == CAL_RUNNING || currCal -> calState == CAL_WAITING ) ) { ar5416DoCalibration ( ah , ichan , rxchainmask , currCal , isCalDone ) ; if ( * isCalDone == AH_TRUE ) { cal -> cal_curr = currCal = currCal -> calNext ; if ( currCal -> calState == CAL_WAITING ) { * isCalDone = AH_FALSE ; ar5416ResetMeasurement ( ah , currCal ) ; } } } if ( longcal ) { ar5416GetNf ( ah , chan ) ; ar5416LoadNF ( ah , AH_PRIVATE ( ah ) -> ah_curchan ) ; ar5416StartNFCal ( ah ) ; } return AH_TRUE ; }
Internal interface to schedule periodic calibration work.
Internal interface to schedule periodic calibration work .
/*
	 * Since ath_hal calls the PerCal method with rxchainmask=0x1;
	 * override it with the current chainmask. The upper levels currently
	 * doesn't know about the chainmask.
	 */ /* Invalid channel check */ /*
	 * For given calibration:
	 * 1. Call generic cal routine
	 * 2. When this cal is done (isCalDone) if we have more cals waiting
	 *    (eg after reset), mask this to upper layers by not propagating
	 *    isCalDone if it is set to TRUE.
	 *    Instead, change isCalDone to FALSE and setup the waiting cal(s)
	 *    to be run.
	 */ /* Do NF cal only at longer intervals */ /*
		 * Get the value from the previous NF cal
		 * and update the history buffer.
		 */ /* 
		 * Load the NF from history buffer of the current channel.
		 * NF is slow time-variant, so it is OK to use a
		 * historical value.
		 */ /* start NF calibration, without updating BB NF register*/