iwlwifi: phy db channel to tx power channel group
authorDavid Spinadel <david.spinadel@intel.com>
Thu, 15 Mar 2012 09:22:31 +0000 (11:22 +0200)
committerWey-Yi Guy <wey-yi.w.guy@intel.com>
Mon, 16 Apr 2012 21:36:54 +0000 (14:36 -0700)
Implement mapping of channel to TX power channel group,
for sending channel specific data before add context.

Signed-off-by: David Spinadel <david.spinadel@intel.com>
Signed-off-by: Wey-Yi Guy <wey-yi.w.guy@intel.com>
drivers/net/wireless/iwlwifi/iwl-phy-db.c
drivers/net/wireless/iwlwifi/iwl-phy-db.h

index d65305d08ebf327c8524ccb5df379ff587e0a013..1a791af82d155d232f1668433b93741fcfd8dbcb 100644 (file)
@@ -228,8 +228,24 @@ static u16 channel_id_to_papd(u16 ch_id)
 
 static u16 channel_id_to_txp(struct iwl_phy_db *phy_db, u16 ch_id)
 {
-       /* TODO David*/
-       return 0;
+       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,
index ba91a8b28398097709ffac6e9598bb4f89b77b45..5e86305de66aef96491ca2b8af931c5cbd4565b5 100644 (file)
@@ -108,6 +108,12 @@ enum iwl_phy_db_section_type {
        IWL_PHY_DB_MAX
 };
 
+/* for parsing of tx power channel group data that comes from the firmware*/
+struct iwl_phy_db_chg_txp {
+       __le32 space;
+       __le16 max_channel_idx;
+} __packed;
+
 struct iwl_phy_db *iwl_phy_db_init(struct iwl_shared *shrd);
 
 void iwl_phy_db_free(struct iwl_phy_db *phy_db);