int LP PHY RX IQ Cal (struct lpphy_rx_iqcomp *iqcomp, int iqcomp_sz, int use_noise, int tx_switch, int rx_switch, int pa, struct lpphy_txgains *tx_gain)
Note: Struct lpphy_rx_iqcomp { u8 chan; s8 c1; s8 c0;}
Struct lpphy_txgains { u16 gm_gain; u16 pga_gain; u16 pad_gain; uint16 dac_gain;}
- Initialize answer to 0, and tmp1 to 0
- Create old_gains as struct lpphy_txgains
- If iqcomp is not NULL
Loop while iqcomp_sz > 0
- Decrement iqcomp_sz
- If iqcomp[iqcomp_sz].chan equals the current channel
MaskSet PHY Register 0x49E with mask 0xFF00 and set with iqcomp[iqcomp_sz].c1
MaskSet PHY Register 0x49E with mask 0x00FF and set with iqcomp[iqcomp_sz].c0 << 8
- Set answer to 1
- Break from loop
- If answer is 0
- Warn on impossible case
- Return 0
- If use_noise is non-zero
- Set tx_switch to 1
- Set rx_switch to 0
- Set pa to 0
Call LP PHY Set Trsw Override with arguments tx_switch and rx_switch
- If the current band is 2G
- Set bit 0x0008 in PHY Register 0x44C
- If pa is non-zero
- Set bit 0x0008 in PHY Register 0x44D
- Otherwise
- Clear bit 0x0008 in PHY Register 0x44D
- Otherwise
- Set bit 0x0020 in PHY Register 0x44C
- If pa is non-zero
- Set bit 0x0020 in PHY Register 0x44D
- Otherwise
- Clear bit 0x0020 in PHY Register 0x44D
- If use_noise is not zero
Call LP PHY Set RX Gain with 0x2D5D as argument
- Otherwise
- Read PHY Register 0x43B) masked with 0x0040 and save as tmp1
- If tmp1 is not zero
Call LP PHY Get TX Gain with old_gains as argument
- If tx_gains is NULL
- Create an lpphy_txgains structure that contains zeros
Call LP PHY Set TX Gain with that structure as argument
- Otherwise
Call LP PHY Set TX Gain with tx_gain as the argument
- Mask PHY Register 0x43B with mask 0xFFFE
- Mask PHY Register 0x43C with mask 0xFFFE
- Set bit 0x0800 in PHY Register 0x44C
- Set bit 0x0800 in PHY Register 0x44D
Call LP PHY Set Deaf with 0 as argument
- If use_noise is not zero
Call LP PHY Calc RX IQ Comp with 0xFFF0 as argument, save returned value as answer
- Otherwise
Call LP PHY Start TX Tone with 4000 and 100 as arguments
Call LP PHY Calc RX IQ Comp with 0x4000 as argument, save returned value as answer
Call LP PHY Stop TX Tone
Call LP PHY Clear Deaf with 0 as argument
Clear bit 0x8 in PHY Register 0x44C
Clear bit 0x20 in PHY Register 0x44C
- If use_noise is zero
- If tmp1 is not zero
Call LP PHY Set TX Gain with &old_gains as argument
- Otherwise
Call LP PHY Set TX Gain Override with argument 0
- If tmp1 is not zero
Call LP PHY RX Gain Override Enable with argument 0
Clear bit 0x1 in PHY Register 0x43B
Clear bit 0x800 in PHY Register 0x43C
- Return answer