FreeBSD/sys/dev/iwn/if_iwn.c
/*
 * Process a CALIBRATION_RESULT notification sent by the initialization
 * firmware on response to a CMD_CALIB_CONFIG command (5000 only).
 */
Process a CALIBRATION_RESULT notification sent by the initialization
firmware on response to a CMD_CALIB_CONFIG command (5000 only).
Process a CALIBRATION_RESULT notification sent by the initialization firmware on response to a CMD_CALIB_CONFIG command ( 5000 only ) .
static void
iwn5000_rx_calib_results(struct iwn_softc *sc, struct iwn_rx_desc *desc,
    struct iwn_rx_data *data)
{
	struct iwn_phy_calib *calib = (struct iwn_phy_calib *)(desc + 1);
	int len, idx = -1;
	DPRINTF(sc, IWN_DEBUG_TRACE, "->%s begin\n", __func__);
	if (sc->sc_flags & IWN_FLAG_CALIB_DONE){
		DPRINTF(sc, IWN_DEBUG_TRACE, "->%s received after clib done\n",
	    __func__);
		return;
	}
	len = (le32toh(desc->len) & 0x3fff) - 4;
	bus_dmamap_sync(sc->rxq.data_dmat, data->map, BUS_DMASYNC_POSTREAD);
	switch (calib->code) {
	case IWN5000_PHY_CALIB_DC:
		if (sc->base_params->calib_need & IWN_FLG_NEED_PHY_CALIB_DC)
			idx = 0;
		break;
	case IWN5000_PHY_CALIB_LO:
		if (sc->base_params->calib_need & IWN_FLG_NEED_PHY_CALIB_LO)
			idx = 1;
		break;
	case IWN5000_PHY_CALIB_TX_IQ:
		if (sc->base_params->calib_need & IWN_FLG_NEED_PHY_CALIB_TX_IQ)
			idx = 2;
		break;
	case IWN5000_PHY_CALIB_TX_IQ_PERIODIC:
		if (sc->base_params->calib_need & IWN_FLG_NEED_PHY_CALIB_TX_IQ_PERIODIC)
			idx = 3;
		break;
	case IWN5000_PHY_CALIB_BASE_BAND:
		if (sc->base_params->calib_need & IWN_FLG_NEED_PHY_CALIB_BASE_BAND)
			idx = 4;
		break;
	}
	if (idx == -1)	
		return;
	if (sc->calibcmd[idx].buf != NULL)
		free(sc->calibcmd[idx].buf, M_DEVBUF);
	sc->calibcmd[idx].buf = malloc(len, M_DEVBUF, M_NOWAIT);
	if (sc->calibcmd[idx].buf == NULL) {
		DPRINTF(sc, IWN_DEBUG_CALIBRATE,
		    "not enough memory for calibration result %d\n",
		    calib->code);
		return;
	}
	DPRINTF(sc, IWN_DEBUG_CALIBRATE,
	    "saving calibration result idx=%d, code=%d len=%d\n", idx, calib->code, len);
	sc->calibcmd[idx].len = len;
	memcpy(sc->calibcmd[idx].buf, calib, len);
}
static void iwn5000_rx_calib_results ( struct iwn_softc * sc , struct iwn_rx_desc * desc , struct iwn_rx_data * data ) { struct iwn_phy_calib * calib = ( struct iwn_phy_calib * ) ( desc + 1 ) ; int len , idx = -1 ; DPRINTF ( sc , IWN_DEBUG_TRACE , " \n " , __func__ ) ; if ( sc -> sc_flags & IWN_FLAG_CALIB_DONE ) { DPRINTF ( sc , IWN_DEBUG_TRACE , " \n " , __func__ ) ; return ; } len = ( le32toh ( desc -> len ) & 0x3fff ) - 4 ; bus_dmamap_sync ( sc -> rxq . data_dmat , data -> map , BUS_DMASYNC_POSTREAD ) ; switch ( calib -> code ) { case IWN5000_PHY_CALIB_DC : if ( sc -> base_params -> calib_need & IWN_FLG_NEED_PHY_CALIB_DC ) idx = 0 ; break ; case IWN5000_PHY_CALIB_LO : if ( sc -> base_params -> calib_need & IWN_FLG_NEED_PHY_CALIB_LO ) idx = 1 ; break ; case IWN5000_PHY_CALIB_TX_IQ : if ( sc -> base_params -> calib_need & IWN_FLG_NEED_PHY_CALIB_TX_IQ ) idx = 2 ; break ; case IWN5000_PHY_CALIB_TX_IQ_PERIODIC : if ( sc -> base_params -> calib_need & IWN_FLG_NEED_PHY_CALIB_TX_IQ_PERIODIC ) idx = 3 ; break ; case IWN5000_PHY_CALIB_BASE_BAND : if ( sc -> base_params -> calib_need & IWN_FLG_NEED_PHY_CALIB_BASE_BAND ) idx = 4 ; break ; } if ( idx == -1 ) return ; if ( sc -> calibcmd [ idx ] . buf != NULL ) free ( sc -> calibcmd [ idx ] . buf , M_DEVBUF ) ; sc -> calibcmd [ idx ] . buf = malloc ( len , M_DEVBUF , M_NOWAIT ) ; if ( sc -> calibcmd [ idx ] . buf == NULL ) { DPRINTF ( sc , IWN_DEBUG_CALIBRATE , " \n " , calib -> code ) ; return ; } DPRINTF ( sc , IWN_DEBUG_CALIBRATE , " \n " , idx , calib -> code , len ) ; sc -> calibcmd [ idx ] . len = len ; memcpy ( sc -> calibcmd [ idx ] . buf , calib , len ) ; }
Process a CALIBRATION_RESULT notification sent by the initialization
 firmware on response to a CMD_CALIB_CONFIG command (5000 only).
Process a CALIBRATION_RESULT notification sent by the initialization firmware on response to a CMD_CALIB_CONFIG command ( 5000 only ) .
/* Runtime firmware should not send such a notification. */ /* Ignore other results. */ /* Save calibration result. */