1 /*
2 * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
3 * Use is subject to license terms.
4 */
5
6 /*
7 * Copyright (c) 2007, 2008
8 * Damien Bergamini <damien.bergamini@free.fr>
9 *
10 * Permission to use, copy, modify, and distribute this software for any
11 * purpose with or without fee is hereby granted, provided that the above
12 * copyright notice and this permission notice appear in all copies.
13 *
14 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
15 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
16 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
17 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
18 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
19 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
20 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
21 */
499 sc->txpow1[i] = 5;
500 if (sc->txpow2[i] < 0 || sc->txpow2[i] > 31)
501 sc->txpow2[i] = 5;
502 RWN_DEBUG(RT2860_DBG_EEPROM, "rwn: rt2860_read_eeprom(): "
503 "chan %d: power1=%d, power2=%d\n",
504 rt2860_rf2850[i].chan, sc->txpow1[i], sc->txpow2[i]);
505 }
506 /* read power settings for 5GHz channels */
507 for (i = 0; i < 36; i += 2) {
508 val = rt2860_eeprom_read(sc,
509 RT2860_EEPROM_PWR5GHZ_BASE1 + i / 2);
510 sc->txpow1[i + 14] = (int8_t)(val & 0xff);
511 sc->txpow1[i + 15] = (int8_t)(val >> 8);
512
513 val = rt2860_eeprom_read(sc,
514 RT2860_EEPROM_PWR5GHZ_BASE2 + i / 2);
515 sc->txpow2[i + 14] = (int8_t)(val & 0xff);
516 sc->txpow2[i + 15] = (int8_t)(val >> 8);
517 }
518 /* fix broken Tx power entries */
519 for (i = 0; i < 36; i++) {
520 if (sc->txpow1[14 + i] < -7 || sc->txpow1[14 + i] > 15)
521 sc->txpow1[14 + i] = 5;
522 if (sc->txpow2[14 + i] < -7 || sc->txpow2[14 + i] > 15)
523 sc->txpow2[14 + i] = 5;
524 RWN_DEBUG(RT2860_DBG_EEPROM, "rwn: rt2860_read_eeprom(): "
525 "chan %d: power1=%d, power2=%d\n",
526 rt2860_rf2850[14 + i].chan, sc->txpow1[14 + i],
527 sc->txpow2[14 + i]);
528 }
529
530 /* read Tx power compensation for each Tx rate */
531 val = rt2860_eeprom_read(sc, RT2860_EEPROM_DELTAPWR);
532 delta_2ghz = delta_5ghz = 0;
533 if ((val & 0xff) != 0xff && (val & 0x80)) {
534 delta_2ghz = val & 0xf;
535 if (!(val & 0x40)) /* negative number */
536 delta_2ghz = -delta_2ghz;
537 }
538 val >>= 8;
539 if ((val & 0xff) != 0xff && (val & 0x80)) {
|
1 /*
2 * Copyright 2017 Gary Mills
3 * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
4 * Use is subject to license terms.
5 */
6
7 /*
8 * Copyright (c) 2007, 2008
9 * Damien Bergamini <damien.bergamini@free.fr>
10 *
11 * Permission to use, copy, modify, and distribute this software for any
12 * purpose with or without fee is hereby granted, provided that the above
13 * copyright notice and this permission notice appear in all copies.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
16 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
17 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
18 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
19 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
20 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
21 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
22 */
500 sc->txpow1[i] = 5;
501 if (sc->txpow2[i] < 0 || sc->txpow2[i] > 31)
502 sc->txpow2[i] = 5;
503 RWN_DEBUG(RT2860_DBG_EEPROM, "rwn: rt2860_read_eeprom(): "
504 "chan %d: power1=%d, power2=%d\n",
505 rt2860_rf2850[i].chan, sc->txpow1[i], sc->txpow2[i]);
506 }
507 /* read power settings for 5GHz channels */
508 for (i = 0; i < 36; i += 2) {
509 val = rt2860_eeprom_read(sc,
510 RT2860_EEPROM_PWR5GHZ_BASE1 + i / 2);
511 sc->txpow1[i + 14] = (int8_t)(val & 0xff);
512 sc->txpow1[i + 15] = (int8_t)(val >> 8);
513
514 val = rt2860_eeprom_read(sc,
515 RT2860_EEPROM_PWR5GHZ_BASE2 + i / 2);
516 sc->txpow2[i + 14] = (int8_t)(val & 0xff);
517 sc->txpow2[i + 15] = (int8_t)(val >> 8);
518 }
519 /* fix broken Tx power entries */
520 for (i = 0; i < 35; i++) {
521 if (sc->txpow1[14 + i] < -7 || sc->txpow1[14 + i] > 15)
522 sc->txpow1[14 + i] = 5;
523 if (sc->txpow2[14 + i] < -7 || sc->txpow2[14 + i] > 15)
524 sc->txpow2[14 + i] = 5;
525 RWN_DEBUG(RT2860_DBG_EEPROM, "rwn: rt2860_read_eeprom(): "
526 "chan %d: power1=%d, power2=%d\n",
527 rt2860_rf2850[14 + i].chan, sc->txpow1[14 + i],
528 sc->txpow2[14 + i]);
529 }
530
531 /* read Tx power compensation for each Tx rate */
532 val = rt2860_eeprom_read(sc, RT2860_EEPROM_DELTAPWR);
533 delta_2ghz = delta_5ghz = 0;
534 if ((val & 0xff) != 0xff && (val & 0x80)) {
535 delta_2ghz = val & 0xf;
536 if (!(val & 0x40)) /* negative number */
537 delta_2ghz = -delta_2ghz;
538 }
539 val >>= 8;
540 if ((val & 0xff) != 0xff && (val & 0x80)) {
|