aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/dvb/frontends/cx24116.c
diff options
context:
space:
mode:
authorSteven Toth <stoth@linuxtv.org>2008-10-06 20:20:21 -0400
committerMauro Carvalho Chehab <mchehab@redhat.com>2008-10-13 10:27:31 -0400
commit8953db793d5bdeea5ac92c9e97f57d3ff8a7dccf (patch)
tree02749412a9e8556886a8194c8e772dd85c24a8b5 /drivers/media/dvb/frontends/cx24116.c
parent0a6393ae21d58e85882185ce1e6b0fe28ff2dfa6 (diff)
V4L/DVB (9178): cx24116: Add module parameter to return SNR as ESNO.
I've retained the older percentage code after discussing this with Darron Broad, but made the ESNO option default. Signed-off-by: Steven Toth <stoth@linuxtv.org> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/dvb/frontends/cx24116.c')
-rw-r--r--drivers/media/dvb/frontends/cx24116.c39
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 */
117static int toneburst = 1; 118static int toneburst = 1;
118 119
120/* SNR measurements */
121static int esno_snr = 1;
122
119enum cmds 123enum 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 */
706static int cx24116_read_snr(struct dvb_frontend* fe, u16* snr) 710static 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 */
739static 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
753static 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
731static int cx24116_read_ucblocks(struct dvb_frontend* fe, u32* ucblocks) 761static 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)");
1383module_param(toneburst, int, 0644); 1413module_param(toneburst, int, 0644);
1384MODULE_PARM_DESC(toneburst, "DiSEqC toneburst 0=OFF, 1=TONE CACHE, 2=MESSAGE CACHE (default:1)"); 1414MODULE_PARM_DESC(toneburst, "DiSEqC toneburst 0=OFF, 1=TONE CACHE, 2=MESSAGE CACHE (default:1)");
1385 1415
1416module_param(esno_snr, int, 0644);
1417MODULE_PARM_DESC(debug, "SNR return units, 0=PERCENTAGE 0-100, 1=ESNO(db * 10) (default:1)");
1418
1386MODULE_DESCRIPTION("DVB Frontend module for Conexant cx24116/cx24118 hardware"); 1419MODULE_DESCRIPTION("DVB Frontend module for Conexant cx24116/cx24118 hardware");
1387MODULE_AUTHOR("Steven Toth"); 1420MODULE_AUTHOR("Steven Toth");
1388MODULE_LICENSE("GPL"); 1421MODULE_LICENSE("GPL");