int N PHY Cal RX IQ Rev3 (struct nphy_txgains target, u8 type, bool debug)
- Establish a 2-element struct nphy_iqcal_params array called params
- Establish 2-element u16 arrays named save and gain
- Establish a 2-element u8 array named best
- Read PHY Register 0x01 and save as BBconfig
- Clear bit 0x8000 in PHY Register 0x01
If PHY Revision >= 4
Set phyhang to phyhang_avoid
Set phyhang_avoid to 0
- Read an N PHY Table with ID 7, length 2, offset 0x110, width 16, and data save
- Loop 2 times with index i
Call N PHY IQ Cal Gain Params with i, target, ¶ms[i] as arguments
- Set gain[i] to params[i].cal_gain
- Write an N PHY Table with ID 7, length 2, offset 0x110, width 16, and data from gain
Call N PHY RX Core Get State and save result as state
- Loop 2 times with index i
If state & (1 << i) is not zero
- Set skip to 1
- Otherwise
- Set skip to 0
Call N PHY RX Cal PHY Setup with i as argument
Call N PHY Radio Setup with i as argument
- If (skip is zero and type is zero) or (type is 2)
Call N PHY RX Cal Gain Ctrl with i, NULL, 0 as arguments
Call N PHY TX Tone with 2000, 181, 0, type as arguments
Call N PHY Calc RX IQ Comp with i + 1 as argument
Call N PHY Stop Playback
- If type is 1 or 2
- If i is 1
- If state is 1
Call N PHY RX Core Set State with 3 as argument
Call N PHY RX Cal Gain Ctrl with i, NULL, 1 as arguments
Call N PHY RC Sweep with i, 1 as arguments - save result as best[i]
Set nphy_rccal_value to best[i]
- if state is 1
Call N PHY RX Core Set State with state as argument
- If state is 1
- If i is 1
Call N PHY RX Cal Radio Cleanup with i as argument
Call N PHY RX Cal PHY Cleanup with i as argument
Call N PHY Force RF Seq with 2 as argument
- If type is 1 or 2
- Set best[0] to best[1]
- Write best[0] | 0x80 to Radio Register 0x606B
- Loop 2 times with i as index
Set tmp1 to ((best[i] - 12) >> 1) + 10
- Set tmp2 to (best[i] - 2
If (nphy_ipa2g_on and the band is 2GHz) or (nphy_ipa5g_on and the band is 5GHz)
- If the band width is 40 MHz
- Set tmp2 to 24
- Set tmp to 0x0E
- Otherwise
- Set tmp2 to 12
- Set tmp to 0x13
- If the band width is 40 MHz
- If i is 0
- Write tmp to Radio Register 0x2078
- Otherwise
- Write tmp to Radio Register 0x3078
- Clamp tmp1 from 0 to 31
- Clamp tmp2 from 0 to 31
- If i is 0
- Write tmp1 | 0x80 to Radio Register 0x6062
- Write tmp2 | 0x80 to Radio Register 0x2069
- Otherwise
- Write tmp1 | 0x80 to Radio Register 0x7062
- Write tmp2 | 0x80 to Radio Register 0x3069
- Write BBconfig to PHY Register 0x01
Call N PHY Reset CCA
Call N PHY RF Ctrl Override with 0x1000, 0, 3, 1 as arguments
Call N PHY Force RF Seq with 2 as argument
- Write an N PHY Table with ID 7, length 2, offset 0x110, width 16, and data from save
If PHY Revision >= 4
Set phyhang_avoid to phyhang
Call N PHY Stay in Carrier Search with 0 as argument