[rt2x00-users] [PATCH 1/3] rt2x00: Fix rt2800 txpower setting to correct value

RA-Jay Hung Jay_Hung at ralinktech.com
Tue Jan 18 19:59:00 EST 2011


Hi Helmut,

> What about storing a band_comp, a bw_comp and a temp_comp
> value globally in rt2x00dev. band_comp and bw_comp get
> calculated on channel change (and stored) while temp_comp
> gets calculated periodically (and stored). If either value
> changes we can just call rt2800_config_txpower with the new
> compensation values.
>
> Even if we run that periodically this should be no
> performance bottleneck and also the calculations are not as
> expensive as the register writes, and these need to be done
> in every case.
>
> So, I'm in favour of calculating the compensation values on
> the fly on each of these events:
> - channel change
> - regulatory change
> - periodic temperature compensation
>
> And to reduce the amount of work to do periodically we can
> ignore txpower config calls if none of the compensation
> values changed.

Currently, seems I use the same way as your description except I use
some defualt tx_power_cfg array for different band and bandwidth without
recalculating bw compesation value upon bandwidth or band change.

For reducing array memory and code readability,
I can recalculating the bw_comp upon band or bandwidth change
and keep it into rt2x00 and code will change as below.

static void rt2800_config_txpower(struct rt2x00dev *rt2x00dev, int alc_comp)

for (i = 0; i < EEPROM_TXPOWER_BYRATE_SIZE; i += 2) {
                /* just to be safe */
                if (offset > TX_PWR_CFG_4)
                        break;

                rt2800_register_read(rt2x00dev, offset, &reg);

                /* read the next four txpower values */
                rt2x00_eeprom_read(rt2x00dev, EEPROM_TXPOWER_BYRATE + i,
                                   &eeprom);

                /* TX_PWR_CFG_0: 1MBS, TX_PWR_CFG_1: 24MBS,
                 * TX_PWR_CFG_2: MCS4, TX_PWR_CFG_3: MCS12,
                 * TX_PWR_CFG_4: unknown */
                txpower = rt2x00_get_field16(eeprom,
                                             EEPROM_TXPOWER_BYRATE_RATE0);

                txpower += bw_comp + alc_comp;
                eirp_txpower = eirp_txpower_criterion + txpower - criterion;
                reg_delta = (eirp_txpower > txpower_limit) ? (eirp_txpower - txpower_limit) : 0;
                txpower -= reg_delta;

                rt2x00_set_field32(&reg, TX_PWR_CFG_RATE0,
                                   txpower);

and apply to each rate set, Is it ok for your concern?

BR,
Jay
CONFIDENTIALITY STATEMENT : The information, attachments and any rights attaching in this e-mail are confidential and privileged; it is intended only for the individual or entity named as the recipient hereof.Any disclosure, copying, distribution, dissemination or use of the contents of this e-mail by persons other than the intended recipient is STRICTLY PROHIBITED and may violate applicable laws.If you have received this e-mail in error, please delete the original message and notify us by return email or collect call immediately. Thank you.



More information about the users mailing list