diff options
| -rw-r--r-- | drivers/media/dvb/frontends/cx24116.c | 39 |
1 files changed, 36 insertions, 3 deletions
diff --git a/drivers/media/dvb/frontends/cx24116.c b/drivers/media/dvb/frontends/cx24116.c index 30f82cb0928b..b8acc7b74c33 100644 --- a/drivers/media/dvb/frontends/cx24116.c +++ b/drivers/media/dvb/frontends/cx24116.c | |||
| @@ -57,8 +57,9 @@ static int debug = 0; | |||
| 57 | #define CX24116_REG_RESET (0x20) /* reset status > 0 */ | 57 | #define CX24116_REG_RESET (0x20) /* reset status > 0 */ |
| 58 | #define CX24116_REG_SIGNAL (0x9e) /* signal low */ | 58 | #define CX24116_REG_SIGNAL (0x9e) /* signal low */ |
| 59 | #define CX24116_REG_SSTATUS (0x9d) /* signal high / status */ | 59 | #define CX24116_REG_SSTATUS (0x9d) /* signal high / status */ |
| 60 | #define CX24116_REG_QUALITY8 (0xa3) | ||
| 60 | #define CX24116_REG_QSTATUS (0xbc) | 61 | #define CX24116_REG_QSTATUS (0xbc) |
| 61 | #define CX24116_REG_QUALITY (0xd5) | 62 | #define CX24116_REG_QUALITY0 (0xd5) |
| 62 | #define CX24116_REG_BER0 (0xc9) | 63 | #define CX24116_REG_BER0 (0xc9) |
| 63 | #define CX24116_REG_BER8 (0xc8) | 64 | #define CX24116_REG_BER8 (0xc8) |
| 64 | #define CX24116_REG_BER16 (0xc7) | 65 | #define CX24116_REG_BER16 (0xc7) |
| @@ -116,6 +117,9 @@ static int debug = 0; | |||
| 116 | /* DiSEqC tone burst */ | 117 | /* DiSEqC tone burst */ |
| 117 | static int toneburst = 1; | 118 | static int toneburst = 1; |
| 118 | 119 | ||
| 120 | /* SNR measurements */ | ||
| 121 | static int esno_snr = 1; | ||
| 122 | |||
| 119 | enum cmds | 123 | enum cmds |
| 120 | { | 124 | { |
| 121 | CMD_SET_VCO = 0x10, | 125 | CMD_SET_VCO = 0x10, |
| @@ -703,7 +707,7 @@ static int cx24116_read_signal_strength(struct dvb_frontend* fe, u16* signal_str | |||
| 703 | } | 707 | } |
| 704 | 708 | ||
| 705 | /* SNR (0..100)% = (sig & 0xf0) * 10 + (sig & 0x0f) * 10 / 16 */ | 709 | /* SNR (0..100)% = (sig & 0xf0) * 10 + (sig & 0x0f) * 10 / 16 */ |
| 706 | static int cx24116_read_snr(struct dvb_frontend* fe, u16* snr) | 710 | static int cx24116_read_snr_pct(struct dvb_frontend* fe, u16* snr) |
| 707 | { | 711 | { |
| 708 | struct cx24116_state *state = fe->demodulator_priv; | 712 | struct cx24116_state *state = fe->demodulator_priv; |
| 709 | u8 snr_reading; | 713 | u8 snr_reading; |
| @@ -714,7 +718,7 @@ static int cx24116_read_snr(struct dvb_frontend* fe, u16* snr) | |||
| 714 | 718 | ||
| 715 | dprintk("%s()\n", __func__); | 719 | dprintk("%s()\n", __func__); |
| 716 | 720 | ||
| 717 | snr_reading = cx24116_readreg(state, CX24116_REG_QUALITY); | 721 | snr_reading = cx24116_readreg(state, CX24116_REG_QUALITY0); |
| 718 | 722 | ||
| 719 | if(snr_reading >= 0xa0 /* 100% */) | 723 | if(snr_reading >= 0xa0 /* 100% */) |
| 720 | *snr = 0xffff; | 724 | *snr = 0xffff; |
| @@ -728,6 +732,32 @@ static int cx24116_read_snr(struct dvb_frontend* fe, u16* snr) | |||
| 728 | return 0; | 732 | return 0; |
| 729 | } | 733 | } |
| 730 | 734 | ||
| 735 | /* The reelbox patches show the value in the registers represents | ||
| 736 | * ESNO, from 0->30db (values 0->300). We provide this value by | ||
| 737 | * default. | ||
| 738 | */ | ||
| 739 | static int cx24116_read_snr_esno(struct dvb_frontend* fe, u16* snr) | ||
| 740 | { | ||
| 741 | struct cx24116_state *state = fe->demodulator_priv; | ||
| 742 | |||
| 743 | dprintk("%s()\n", __func__); | ||
| 744 | |||
| 745 | *snr = cx24116_readreg(state, CX24116_REG_QUALITY8) << 8 | | ||
| 746 | cx24116_readreg(state, CX24116_REG_QUALITY0); | ||
| 747 | |||
| 748 | dprintk("%s: raw 0x%04x\n", __func__, *snr); | ||
| 749 | |||
| 750 | return 0; | ||
| 751 | } | ||
| 752 | |||
| 753 | static int cx24116_read_snr(struct dvb_frontend* fe, u16* snr) | ||
| 754 | { | ||
| 755 | if (esno_snr == 1) | ||
| 756 | return cx24116_read_snr_esno(fe, snr); | ||
| 757 | else | ||
| 758 | return cx24116_read_snr_pct(fe, snr); | ||
| 759 | } | ||
| 760 | |||
| 731 | static int cx24116_read_ucblocks(struct dvb_frontend* fe, u32* ucblocks) | 761 | static int cx24116_read_ucblocks(struct dvb_frontend* fe, u32* ucblocks) |
| 732 | { | 762 | { |
| 733 | struct cx24116_state *state = fe->demodulator_priv; | 763 | struct cx24116_state *state = fe->demodulator_priv; |
| @@ -1383,6 +1413,9 @@ MODULE_PARM_DESC(debug, "Activates frontend debugging (default:0)"); | |||
| 1383 | module_param(toneburst, int, 0644); | 1413 | module_param(toneburst, int, 0644); |
| 1384 | MODULE_PARM_DESC(toneburst, "DiSEqC toneburst 0=OFF, 1=TONE CACHE, 2=MESSAGE CACHE (default:1)"); | 1414 | MODULE_PARM_DESC(toneburst, "DiSEqC toneburst 0=OFF, 1=TONE CACHE, 2=MESSAGE CACHE (default:1)"); |
| 1385 | 1415 | ||
| 1416 | module_param(esno_snr, int, 0644); | ||
| 1417 | MODULE_PARM_DESC(debug, "SNR return units, 0=PERCENTAGE 0-100, 1=ESNO(db * 10) (default:1)"); | ||
| 1418 | |||
| 1386 | MODULE_DESCRIPTION("DVB Frontend module for Conexant cx24116/cx24118 hardware"); | 1419 | MODULE_DESCRIPTION("DVB Frontend module for Conexant cx24116/cx24118 hardware"); |
| 1387 | MODULE_AUTHOR("Steven Toth"); | 1420 | MODULE_AUTHOR("Steven Toth"); |
| 1388 | MODULE_LICENSE("GPL"); | 1421 | MODULE_LICENSE("GPL"); |
