static u16 channel_id_to_txp(struct iwl_phy_db *phy_db, u16 ch_id) { struct iwl_phy_db_chg_txp *txp_chg; int i; u8 ch_index = ch_id_to_ch_index(ch_id); if (ch_index == 0xff) return 0xff; for (i = 0; i < IWL_NUM_TXP_CH_GROUPS; i++) { txp_chg = (void *)phy_db->calib_ch_group_txp[i].data; if (!txp_chg) return 0xff; /* * Looking for the first channel group that its max channel is * higher then wanted channel. */ if (le16_to_cpu(txp_chg->max_channel_idx) >= ch_index) return i; } return 0xff; }
int iwl_phy_db_get_section_data(struct iwl_phy_db *phy_db, enum iwl_phy_db_section_type type, u8 **data, u16 *size, u16 ch_id) { struct iwl_phy_db_entry *entry; u32 channel_num; u32 channel_size; u16 ch_group_id = 0; u16 index; if (!phy_db) return -EINVAL; /* find wanted channel group */ if (type == IWL_PHY_DB_CALIB_CHG_PAPD) ch_group_id = channel_id_to_papd(ch_id); else if (type == IWL_PHY_DB_CALIB_CHG_TXP) ch_group_id = channel_id_to_txp(phy_db, ch_id); entry = iwl_phy_db_get_section(phy_db, type, ch_group_id); if (!entry) return -EINVAL; if (type == IWL_PHY_DB_CALIB_CH) { index = ch_id_to_ch_index(ch_id); channel_num = phy_db->channel_num; channel_size = phy_db->channel_size; if (index >= channel_num) { IWL_ERR(phy_db, "Wrong channel number %d", ch_id); return -EINVAL; } *data = entry->data + CHANNEL_NUM_SIZE + index * channel_size; *size = channel_size; } else { *data = entry->data; *size = entry->size; } return 0; }
static uint16_t channel_id_to_txp(struct iwm_phy_db *phy_db, uint16_t ch_id) { struct iwm_phy_db_chg_txp *txp_chg; int i; uint8_t ch_index = ch_id_to_ch_index(ch_id); if (ch_index == 0xff) return 0xff; for (i = 0; i < phy_db->n_group_txp; i++) { txp_chg = (void *)phy_db->calib_ch_group_txp[i].data; if (!txp_chg) return 0xff; /* * Looking for the first channel group that its max channel is * higher then wanted channel. */ if (le16toh(txp_chg->max_channel_idx) >= ch_index) return i; } return 0xff; }