software/drivers/sd8887/src/wlan/mlan/mlan_cfp.c
/**
 *  @brief This function sets region table.
 *
 *  @param pmpriv  A pointer to mlan_private structure
 *  @param region  The region code
 *  @param band    The band
 *
 *  @return        MLAN_STATUS_SUCCESS or MLAN_STATUS_FAILURE
 */
@brief This function sets region table.
@param pmpriv  A pointer to mlan_private structure
@param region  The region code
@param band    The band


@brief This function sets region table . @param pmpriv A pointer to mlan_private structure @param region The region code @param band The band
mlan_status
wlan_set_regiontable(mlan_private *pmpriv, t_u8 region, t_u8 band)
{
	mlan_adapter *pmadapter = pmpriv->adapter;
	int i = 0, j;
	chan_freq_power_t *cfp;
	int cfp_no;
	region_chan_t region_chan_old[MAX_REGION_CHANNEL_NUM];
	t_u8 cfp_code_bg = region;
	t_u8 cfp_code_a = region;
	ENTER();
	memcpy(pmadapter, region_chan_old, pmadapter->region_channel,
	       sizeof(pmadapter->region_channel));
	memset(pmadapter, pmadapter->region_channel, 0,
	       sizeof(pmadapter->region_channel));
	if (band & (BAND_B | BAND_G | BAND_GN)) {
		if (pmadapter->cfp_code_bg)
			cfp_code_bg = pmadapter->cfp_code_bg;
		PRINTM(MCMND, "wlan_set_regiontable 2.4G 0x%x\n", cfp_code_bg);
		cfp = wlan_get_region_cfp_table(pmadapter, cfp_code_bg,
						BAND_G | BAND_B | BAND_GN,
						&cfp_no);
		if (cfp) {
			pmadapter->region_channel[i].num_cfp = (t_u8)cfp_no;
			pmadapter->region_channel[i].pcfp = cfp;
		} else {
			PRINTM(MERROR, "wrong region code %#x in Band B-G\n",
			       region);
			LEAVE();
			return MLAN_STATUS_FAILURE;
		}
		pmadapter->region_channel[i].valid = MTRUE;
		pmadapter->region_channel[i].region = region;
		if (band & BAND_GN)
			pmadapter->region_channel[i].band = BAND_G;
		else
			pmadapter->region_channel[i].band =
				(band & BAND_G) ? BAND_G : BAND_B;
		for (j = 0; j < MAX_REGION_CHANNEL_NUM; j++) {
			if (region_chan_old[j].band & (BAND_B | BAND_G))
				break;
		}
		if ((j < MAX_REGION_CHANNEL_NUM) && region_chan_old[j].valid)
			wlan_cfp_copy_dynamic(pmadapter, cfp, cfp_no,
					      region_chan_old[j].pcfp,
					      region_chan_old[j].num_cfp);
		else
			wlan_cfp_copy_dynamic(pmadapter, cfp, cfp_no, MNULL, 0);
		i++;
	}
	if (band & (BAND_A | BAND_AN | BAND_AAC)) {
		if (pmadapter->cfp_code_bg)
			cfp_code_a = pmadapter->cfp_code_a;
		PRINTM(MCMND, "wlan_set_regiontable 5G 0x%x\n", cfp_code_a);
		cfp = wlan_get_region_cfp_table(pmadapter, cfp_code_a, BAND_A,
						&cfp_no);
		if (cfp) {
			pmadapter->region_channel[i].num_cfp = (t_u8)cfp_no;
			pmadapter->region_channel[i].pcfp = cfp;
		} else {
			PRINTM(MERROR, "wrong region code %#x in Band A\n",
			       region);
			LEAVE();
			return MLAN_STATUS_FAILURE;
		}
		pmadapter->region_channel[i].valid = MTRUE;
		pmadapter->region_channel[i].region = region;
		pmadapter->region_channel[i].band = BAND_A;
		for (j = 0; j < MAX_REGION_CHANNEL_NUM; j++) {
			if (region_chan_old[j].band & BAND_A)
				break;
		}
		if ((j < MAX_REGION_CHANNEL_NUM) && region_chan_old[j].valid)
			wlan_cfp_copy_dynamic(pmadapter, cfp, cfp_no,
					      region_chan_old[j].pcfp,
					      region_chan_old[j].num_cfp);
		else
			wlan_cfp_copy_dynamic(pmadapter, cfp, cfp_no, MNULL, 0);
	}
	LEAVE();
	return MLAN_STATUS_SUCCESS;
}
mlan_status wlan_set_regiontable ( mlan_private * pmpriv , t_u8 region , t_u8 band ) { mlan_adapter * pmadapter = pmpriv -> adapter ; int i = 0 , j ; chan_freq_power_t * cfp ; int cfp_no ; region_chan_t region_chan_old [ MAX_REGION_CHANNEL_NUM ] ; t_u8 cfp_code_bg = region ; t_u8 cfp_code_a = region ; ENTER ( ) ; memcpy ( pmadapter , region_chan_old , pmadapter -> region_channel , sizeof ( pmadapter -> region_channel ) ) ; memset ( pmadapter , pmadapter -> region_channel , 0 , sizeof ( pmadapter -> region_channel ) ) ; if ( band & ( BAND_B | BAND_G | BAND_GN ) ) { if ( pmadapter -> cfp_code_bg ) cfp_code_bg = pmadapter -> cfp_code_bg ; PRINTM ( MCMND , " \n " , cfp_code_bg ) ; cfp = wlan_get_region_cfp_table ( pmadapter , cfp_code_bg , BAND_G | BAND_B | BAND_GN , & cfp_no ) ; if ( cfp ) { pmadapter -> region_channel [ i ] . num_cfp = ( t_u8 ) cfp_no ; pmadapter -> region_channel [ i ] . pcfp = cfp ; } else { PRINTM ( MERROR , " \n " , region ) ; LEAVE ( ) ; return MLAN_STATUS_FAILURE ; } pmadapter -> region_channel [ i ] . valid = MTRUE ; pmadapter -> region_channel [ i ] . region = region ; if ( band & BAND_GN ) pmadapter -> region_channel [ i ] . band = BAND_G ; else pmadapter -> region_channel [ i ] . band = ( band & BAND_G ) ? BAND_G : BAND_B ; for ( j = 0 ; j < MAX_REGION_CHANNEL_NUM ; j ++ ) { if ( region_chan_old [ j ] . band & ( BAND_B | BAND_G ) ) break ; } if ( ( j < MAX_REGION_CHANNEL_NUM ) && region_chan_old [ j ] . valid ) wlan_cfp_copy_dynamic ( pmadapter , cfp , cfp_no , region_chan_old [ j ] . pcfp , region_chan_old [ j ] . num_cfp ) ; else wlan_cfp_copy_dynamic ( pmadapter , cfp , cfp_no , MNULL , 0 ) ; i ++ ; } if ( band & ( BAND_A | BAND_AN | BAND_AAC ) ) { if ( pmadapter -> cfp_code_bg ) cfp_code_a = pmadapter -> cfp_code_a ; PRINTM ( MCMND , " \n " , cfp_code_a ) ; cfp = wlan_get_region_cfp_table ( pmadapter , cfp_code_a , BAND_A , & cfp_no ) ; if ( cfp ) { pmadapter -> region_channel [ i ] . num_cfp = ( t_u8 ) cfp_no ; pmadapter -> region_channel [ i ] . pcfp = cfp ; } else { PRINTM ( MERROR , " \n " , region ) ; LEAVE ( ) ; return MLAN_STATUS_FAILURE ; } pmadapter -> region_channel [ i ] . valid = MTRUE ; pmadapter -> region_channel [ i ] . region = region ; pmadapter -> region_channel [ i ] . band = BAND_A ; for ( j = 0 ; j < MAX_REGION_CHANNEL_NUM ; j ++ ) { if ( region_chan_old [ j ] . band & BAND_A ) break ; } if ( ( j < MAX_REGION_CHANNEL_NUM ) && region_chan_old [ j ] . valid ) wlan_cfp_copy_dynamic ( pmadapter , cfp , cfp_no , region_chan_old [ j ] . pcfp , region_chan_old [ j ] . num_cfp ) ; else wlan_cfp_copy_dynamic ( pmadapter , cfp , cfp_no , MNULL , 0 ) ; } LEAVE ( ) ; return MLAN_STATUS_SUCCESS ; }
@brief This function sets region table.
@brief This function sets region table .