diff options
author | Michael Krufky <mkrufky@linuxtv.org> | 2008-04-10 00:24:56 -0400 |
---|---|---|
committer | Michael Krufky <mkrufky@linuxtv.org> | 2008-04-10 00:24:56 -0400 |
commit | c66482edaa7064dafbf88c1dd33e7516fa45edcd (patch) | |
tree | 1833f7896a84322c030688b317970a05638a1133 /linux/drivers/media/dvb/frontends/au8522.c | |
parent | 7d46ed07cd35e6395fffe9bd10d349e462431f07 (diff) | |
download | mediapointer-dvb-s2-c66482edaa7064dafbf88c1dd33e7516fa45edcd.tar.gz mediapointer-dvb-s2-c66482edaa7064dafbf88c1dd33e7516fa45edcd.tar.bz2 |
au8522: consolidate mse2snr_lookup functions
From: Michael Krufky <mkrufky@linuxtv.org>
consolidate au8522_qam256_mse2snr_lookup, au8522_qam64_mse2snr_lookup and
au8522_vsb_mse2snr_lookup into a single function, au8522_mse2snr_lookup.
Pass the mse2snr table into au8522_mse2snr_lookup depending on the
modulation type.
Signed-off-by: Michael Krufky <mkrufky@linuxtv.org>
Diffstat (limited to 'linux/drivers/media/dvb/frontends/au8522.c')
-rw-r--r-- | linux/drivers/media/dvb/frontends/au8522.c | 76 |
1 files changed, 23 insertions, 53 deletions
diff --git a/linux/drivers/media/dvb/frontends/au8522.c b/linux/drivers/media/dvb/frontends/au8522.c index d4c7024f1..33f560d7f 100644 --- a/linux/drivers/media/dvb/frontends/au8522.c +++ b/linux/drivers/media/dvb/frontends/au8522.c @@ -96,11 +96,13 @@ static int au8522_i2c_gate_ctrl(struct dvb_frontend *fe, int enable) return au8522_writereg(state, 0x106, 0); } -/* VSB SNR lookup table */ -static struct { +struct mse2snr_tab { u16 val; u16 data; -} vsb_mse2snr_tab[] = { +}; + +/* VSB SNR lookup table */ +static struct mse2snr_tab vsb_mse2snr_tab[] = { { 0, 270 }, { 2, 250 }, { 3, 240 }, @@ -134,10 +136,7 @@ static struct { }; /* QAM64 SNR lookup table */ -static struct { - u16 val; - u16 data; -} qam64_mse2snr_tab[] = { +static struct mse2snr_tab qam64_mse2snr_tab[] = { { 15, 0 }, { 16, 290 }, { 17, 288 }, @@ -218,10 +217,7 @@ static struct { }; /* QAM256 SNR lookup table */ -static struct { - u16 val; - u16 data; -} qam256_mse2snr_tab[] = { +static struct mse2snr_tab qam256_mse2snr_tab[] = { { 16, 0 }, { 17, 400 }, { 18, 398 }, @@ -288,46 +284,14 @@ static struct { { 256, 280 }, }; -static int au8522_vsb_mse2snr_lookup(int mse, u16 *snr) -{ - int i, ret = -EINVAL; - dprintk("%s()\n", __func__); - - for (i = 0; i < ARRAY_SIZE(vsb_mse2snr_tab); i++) { - if (mse < vsb_mse2snr_tab[i].val) { - *snr = vsb_mse2snr_tab[i].data; - ret = 0; - break; - } - } - dprintk("%s() snr=%d\n", __func__, *snr); - return ret; -} - -static int au8522_qam64_mse2snr_lookup(int mse, u16 *snr) -{ - int i, ret = -EINVAL; - dprintk("%s()\n", __func__); - - for (i = 0; i < ARRAY_SIZE(qam64_mse2snr_tab); i++) { - if (mse < qam64_mse2snr_tab[i].val) { - *snr = qam64_mse2snr_tab[i].data; - ret = 0; - break; - } - } - dprintk("%s() snr=%d\n", __func__, *snr); - return ret; -} - -static int au8522_qam256_mse2snr_lookup(int mse, u16 *snr) +static int au8522_mse2snr_lookup(struct mse2snr_tab *tab, int sz, int mse, u16 *snr) { int i, ret = -EINVAL; dprintk("%s()\n", __func__); - for (i = 0; i < ARRAY_SIZE(qam256_mse2snr_tab); i++) { - if (mse < qam256_mse2snr_tab[i].val) { - *snr = qam256_mse2snr_tab[i].data; + for (i = 0; i < sz; i++) { + if (mse < tab[i].val) { + *snr = tab[i].data; ret = 0; break; } @@ -588,14 +552,20 @@ static int au8522_read_snr(struct dvb_frontend *fe, u16 *snr) dprintk("%s()\n", __func__); if (state->current_modulation == QAM_256) - ret = au8522_qam256_mse2snr_lookup( - au8522_readreg(state, 0x4522), snr); + ret = au8522_mse2snr_lookup(qam256_mse2snr_tab, + ARRAY_SIZE(qam256_mse2snr_tab), + au8522_readreg(state, 0x4522), + snr); else if (state->current_modulation == QAM_64) - ret = au8522_qam64_mse2snr_lookup( - au8522_readreg(state, 0x4522), snr); + ret = au8522_mse2snr_lookup(qam64_mse2snr_tab, + ARRAY_SIZE(qam64_mse2snr_tab), + au8522_readreg(state, 0x4522), + snr); else /* VSB_8 */ - ret = au8522_vsb_mse2snr_lookup( - au8522_readreg(state, 0x4311), snr); + ret = au8522_mse2snr_lookup(vsb_mse2snr_tab, + ARRAY_SIZE(vsb_mse2snr_tab), + au8522_readreg(state, 0x4311), + snr); return ret; } |