diff options
author | Ulrich Kunitz <kune@deine-taler.de> | 2006-08-29 18:50:29 -0400 |
---|---|---|
committer | John W. Linville <linville@tuxdriver.com> | 2006-09-11 16:11:08 -0400 |
commit | db888aed7e83559d61cff04bf002d0fb80ecbfa7 (patch) | |
tree | 4c8795f5924ce440ddc79cf0e2d7ae25d633d5ad /drivers/net/wireless/zd1211rw/zd_chip.c | |
parent | 38f5745c5a90641079fd5b48600ae63f7ab6edcd (diff) |
[PATCH] zd1211rw: Fix of signal strength and quality measurement
Caused by a documentation issue I mixed up fields of the zd_status
structure. This patch fixes it and improves also the average
computation, which is now using only measurements of packets sent
by the access point.
Signed-off-by: Ulrich Kunitz <kune@deine-taler.de>
Signed-off-by: Daniel Drake <dsd@gentoo.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net/wireless/zd1211rw/zd_chip.c')
-rw-r--r-- | drivers/net/wireless/zd1211rw/zd_chip.c | 61 |
1 files changed, 46 insertions, 15 deletions
diff --git a/drivers/net/wireless/zd1211rw/zd_chip.c b/drivers/net/wireless/zd1211rw/zd_chip.c index da9d06bdb818..aa792821854e 100644 --- a/drivers/net/wireless/zd1211rw/zd_chip.c +++ b/drivers/net/wireless/zd1211rw/zd_chip.c | |||
@@ -1430,9 +1430,43 @@ static int ofdm_qual_db(u8 status_quality, u8 rate, unsigned int size) | |||
1430 | break; | 1430 | break; |
1431 | } | 1431 | } |
1432 | 1432 | ||
1433 | switch (rate) { | ||
1434 | case ZD_OFDM_RATE_6M: | ||
1435 | case ZD_OFDM_RATE_9M: | ||
1436 | i += 3; | ||
1437 | break; | ||
1438 | case ZD_OFDM_RATE_12M: | ||
1439 | case ZD_OFDM_RATE_18M: | ||
1440 | i += 5; | ||
1441 | break; | ||
1442 | case ZD_OFDM_RATE_24M: | ||
1443 | case ZD_OFDM_RATE_36M: | ||
1444 | i += 9; | ||
1445 | break; | ||
1446 | case ZD_OFDM_RATE_48M: | ||
1447 | case ZD_OFDM_RATE_54M: | ||
1448 | i += 15; | ||
1449 | break; | ||
1450 | default: | ||
1451 | return -EINVAL; | ||
1452 | } | ||
1453 | |||
1433 | return i; | 1454 | return i; |
1434 | } | 1455 | } |
1435 | 1456 | ||
1457 | static int ofdm_qual_percent(u8 status_quality, u8 rate, unsigned int size) | ||
1458 | { | ||
1459 | int r; | ||
1460 | |||
1461 | r = ofdm_qual_db(status_quality, rate, size); | ||
1462 | ZD_ASSERT(r >= 0); | ||
1463 | if (r < 0) | ||
1464 | r = 0; | ||
1465 | |||
1466 | r = (r * 100)/29; | ||
1467 | return r <= 100 ? r : 100; | ||
1468 | } | ||
1469 | |||
1436 | static unsigned int log10times100(unsigned int x) | 1470 | static unsigned int log10times100(unsigned int x) |
1437 | { | 1471 | { |
1438 | static const u8 log10[] = { | 1472 | static const u8 log10[] = { |
@@ -1476,31 +1510,28 @@ static int cck_snr_db(u8 status_quality) | |||
1476 | return r; | 1510 | return r; |
1477 | } | 1511 | } |
1478 | 1512 | ||
1479 | static int rx_qual_db(const void *rx_frame, unsigned int size, | 1513 | static int cck_qual_percent(u8 status_quality) |
1480 | const struct rx_status *status) | ||
1481 | { | 1514 | { |
1482 | return (status->frame_status&ZD_RX_OFDM) ? | 1515 | int r; |
1483 | ofdm_qual_db(status->signal_quality_ofdm, | 1516 | |
1484 | zd_ofdm_plcp_header_rate(rx_frame), | 1517 | r = cck_snr_db(status_quality); |
1485 | size) : | 1518 | r = (100*r)/17; |
1486 | cck_snr_db(status->signal_quality_cck); | 1519 | return r <= 100 ? r : 100; |
1487 | } | 1520 | } |
1488 | 1521 | ||
1489 | u8 zd_rx_qual_percent(const void *rx_frame, unsigned int size, | 1522 | u8 zd_rx_qual_percent(const void *rx_frame, unsigned int size, |
1490 | const struct rx_status *status) | 1523 | const struct rx_status *status) |
1491 | { | 1524 | { |
1492 | int r = rx_qual_db(rx_frame, size, status); | 1525 | return (status->frame_status&ZD_RX_OFDM) ? |
1493 | if (r < 0) | 1526 | ofdm_qual_percent(status->signal_quality_ofdm, |
1494 | r = 0; | 1527 | zd_ofdm_plcp_header_rate(rx_frame), |
1495 | r = (r * 100) / 14; | 1528 | size) : |
1496 | if (r > 100) | 1529 | cck_qual_percent(status->signal_quality_cck); |
1497 | r = 100; | ||
1498 | return r; | ||
1499 | } | 1530 | } |
1500 | 1531 | ||
1501 | u8 zd_rx_strength_percent(u8 rssi) | 1532 | u8 zd_rx_strength_percent(u8 rssi) |
1502 | { | 1533 | { |
1503 | int r = (rssi*100) / 30; | 1534 | int r = (rssi*100) / 41; |
1504 | if (r > 100) | 1535 | if (r > 100) |
1505 | r = 100; | 1536 | r = 100; |
1506 | return (u8) r; | 1537 | return (u8) r; |