diff options
author | Michael Krufky <mkrufky@linuxtv.org> | 2008-04-10 03:24:56 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@infradead.org> | 2008-04-24 13:09:43 -0400 |
commit | 0daa5de740c65de7c9554071eec84c6731370065 (patch) | |
tree | bb7c8810b85209746a23e17188d4c0585438b145 | |
parent | f01699b482875bf224a907a45d58e8e3739d554b (diff) |
V4L/DVB (7633): au8522: consolidate mse2snr_lookup functions
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>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
-rw-r--r-- | drivers/media/dvb/frontends/au8522.c | 76 |
1 files changed, 23 insertions, 53 deletions
diff --git a/drivers/media/dvb/frontends/au8522.c b/drivers/media/dvb/frontends/au8522.c index fa3e6abdfa6e..394fb90bdcb0 100644 --- a/drivers/media/dvb/frontends/au8522.c +++ b/drivers/media/dvb/frontends/au8522.c | |||
@@ -96,11 +96,13 @@ static int au8522_i2c_gate_ctrl(struct dvb_frontend *fe, int enable) | |||
96 | return au8522_writereg(state, 0x106, 0); | 96 | return au8522_writereg(state, 0x106, 0); |
97 | } | 97 | } |
98 | 98 | ||
99 | /* VSB SNR lookup table */ | 99 | struct mse2snr_tab { |
100 | static struct { | ||
101 | u16 val; | 100 | u16 val; |
102 | u16 data; | 101 | u16 data; |
103 | } vsb_mse2snr_tab[] = { | 102 | }; |
103 | |||
104 | /* VSB SNR lookup table */ | ||
105 | static struct mse2snr_tab vsb_mse2snr_tab[] = { | ||
104 | { 0, 270 }, | 106 | { 0, 270 }, |
105 | { 2, 250 }, | 107 | { 2, 250 }, |
106 | { 3, 240 }, | 108 | { 3, 240 }, |
@@ -134,10 +136,7 @@ static struct { | |||
134 | }; | 136 | }; |
135 | 137 | ||
136 | /* QAM64 SNR lookup table */ | 138 | /* QAM64 SNR lookup table */ |
137 | static struct { | 139 | static struct mse2snr_tab qam64_mse2snr_tab[] = { |
138 | u16 val; | ||
139 | u16 data; | ||
140 | } qam64_mse2snr_tab[] = { | ||
141 | { 15, 0 }, | 140 | { 15, 0 }, |
142 | { 16, 290 }, | 141 | { 16, 290 }, |
143 | { 17, 288 }, | 142 | { 17, 288 }, |
@@ -218,10 +217,7 @@ static struct { | |||
218 | }; | 217 | }; |
219 | 218 | ||
220 | /* QAM256 SNR lookup table */ | 219 | /* QAM256 SNR lookup table */ |
221 | static struct { | 220 | static struct mse2snr_tab qam256_mse2snr_tab[] = { |
222 | u16 val; | ||
223 | u16 data; | ||
224 | } qam256_mse2snr_tab[] = { | ||
225 | { 16, 0 }, | 221 | { 16, 0 }, |
226 | { 17, 400 }, | 222 | { 17, 400 }, |
227 | { 18, 398 }, | 223 | { 18, 398 }, |
@@ -288,46 +284,14 @@ static struct { | |||
288 | { 256, 280 }, | 284 | { 256, 280 }, |
289 | }; | 285 | }; |
290 | 286 | ||
291 | static int au8522_vsb_mse2snr_lookup(int mse, u16 *snr) | 287 | static int au8522_mse2snr_lookup(struct mse2snr_tab *tab, int sz, int mse, u16 *snr) |
292 | { | ||
293 | int i, ret = -EINVAL; | ||
294 | dprintk("%s()\n", __func__); | ||
295 | |||
296 | for (i = 0; i < ARRAY_SIZE(vsb_mse2snr_tab); i++) { | ||
297 | if (mse < vsb_mse2snr_tab[i].val) { | ||
298 | *snr = vsb_mse2snr_tab[i].data; | ||
299 | ret = 0; | ||
300 | break; | ||
301 | } | ||
302 | } | ||
303 | dprintk("%s() snr=%d\n", __func__, *snr); | ||
304 | return ret; | ||
305 | } | ||
306 | |||
307 | static int au8522_qam64_mse2snr_lookup(int mse, u16 *snr) | ||
308 | { | ||
309 | int i, ret = -EINVAL; | ||
310 | dprintk("%s()\n", __func__); | ||
311 | |||
312 | for (i = 0; i < ARRAY_SIZE(qam64_mse2snr_tab); i++) { | ||
313 | if (mse < qam64_mse2snr_tab[i].val) { | ||
314 | *snr = qam64_mse2snr_tab[i].data; | ||
315 | ret = 0; | ||
316 | break; | ||
317 | } | ||
318 | } | ||
319 | dprintk("%s() snr=%d\n", __func__, *snr); | ||
320 | return ret; | ||
321 | } | ||
322 | |||
323 | static int au8522_qam256_mse2snr_lookup(int mse, u16 *snr) | ||
324 | { | 288 | { |
325 | int i, ret = -EINVAL; | 289 | int i, ret = -EINVAL; |
326 | dprintk("%s()\n", __func__); | 290 | dprintk("%s()\n", __func__); |
327 | 291 | ||
328 | for (i = 0; i < ARRAY_SIZE(qam256_mse2snr_tab); i++) { | 292 | for (i = 0; i < sz; i++) { |
329 | if (mse < qam256_mse2snr_tab[i].val) { | 293 | if (mse < tab[i].val) { |
330 | *snr = qam256_mse2snr_tab[i].data; | 294 | *snr = tab[i].data; |
331 | ret = 0; | 295 | ret = 0; |
332 | break; | 296 | break; |
333 | } | 297 | } |
@@ -588,14 +552,20 @@ static int au8522_read_snr(struct dvb_frontend *fe, u16 *snr) | |||
588 | dprintk("%s()\n", __func__); | 552 | dprintk("%s()\n", __func__); |
589 | 553 | ||
590 | if (state->current_modulation == QAM_256) | 554 | if (state->current_modulation == QAM_256) |
591 | ret = au8522_qam256_mse2snr_lookup( | 555 | ret = au8522_mse2snr_lookup(qam256_mse2snr_tab, |
592 | au8522_readreg(state, 0x4522), snr); | 556 | ARRAY_SIZE(qam256_mse2snr_tab), |
557 | au8522_readreg(state, 0x4522), | ||
558 | snr); | ||
593 | else if (state->current_modulation == QAM_64) | 559 | else if (state->current_modulation == QAM_64) |
594 | ret = au8522_qam64_mse2snr_lookup( | 560 | ret = au8522_mse2snr_lookup(qam64_mse2snr_tab, |
595 | au8522_readreg(state, 0x4522), snr); | 561 | ARRAY_SIZE(qam64_mse2snr_tab), |
562 | au8522_readreg(state, 0x4522), | ||
563 | snr); | ||
596 | else /* VSB_8 */ | 564 | else /* VSB_8 */ |
597 | ret = au8522_vsb_mse2snr_lookup( | 565 | ret = au8522_mse2snr_lookup(vsb_mse2snr_tab, |
598 | au8522_readreg(state, 0x4311), snr); | 566 | ARRAY_SIZE(vsb_mse2snr_tab), |
567 | au8522_readreg(state, 0x4311), | ||
568 | snr); | ||
599 | 569 | ||
600 | return ret; | 570 | return ret; |
601 | } | 571 | } |