diff options
author | Matthias Schwarzott <zzam@gentoo.org> | 2008-04-12 14:04:49 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@infradead.org> | 2008-04-24 13:09:40 -0400 |
commit | 6a5cbd591c703491b62892682adc124ece67f3a9 (patch) | |
tree | a0cab980ffc9483ba10602a17f6e117c84117dc7 | |
parent | 111221fb676176dc90638d6004f1c26164ddd5ae (diff) |
V4L/DVB (7574): mt312: Add support for zl10313 demod
Add zl10313 support to mt312 driver.
zl10313 uses 10.111MHz xtal.
Signed-off-by: Matthias Schwarzott <zzam@gentoo.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
-rw-r--r-- | drivers/media/dvb/frontends/mt312.c | 90 | ||||
-rw-r--r-- | drivers/media/dvb/frontends/mt312_priv.h | 5 |
2 files changed, 86 insertions, 9 deletions
diff --git a/drivers/media/dvb/frontends/mt312.c b/drivers/media/dvb/frontends/mt312.c index 1f478c8c0d4a..e17a36180f9c 100644 --- a/drivers/media/dvb/frontends/mt312.c +++ b/drivers/media/dvb/frontends/mt312.c | |||
@@ -1,7 +1,8 @@ | |||
1 | /* | 1 | /* |
2 | Driver for Zarlink VP310/MT312 Satellite Channel Decoder | 2 | Driver for Zarlink VP310/MT312/ZL10313 Satellite Channel Decoder |
3 | 3 | ||
4 | Copyright (C) 2003 Andreas Oberritter <obi@linuxtv.org> | 4 | Copyright (C) 2003 Andreas Oberritter <obi@linuxtv.org> |
5 | Copyright (C) 2008 Matthias Schwarzott <zzam@gentoo.org> | ||
5 | 6 | ||
6 | This program is free software; you can redistribute it and/or modify | 7 | This program is free software; you can redistribute it and/or modify |
7 | it under the terms of the GNU General Public License as published by | 8 | it under the terms of the GNU General Public License as published by |
@@ -55,6 +56,7 @@ static int debug; | |||
55 | } while (0) | 56 | } while (0) |
56 | 57 | ||
57 | #define MT312_PLL_CLK 10000000UL /* 10 MHz */ | 58 | #define MT312_PLL_CLK 10000000UL /* 10 MHz */ |
59 | #define MT312_PLL_CLK_10_111 10111000UL /* 10.111 MHz */ | ||
58 | 60 | ||
59 | static int mt312_read(struct mt312_state *state, const enum mt312_reg_addr reg, | 61 | static int mt312_read(struct mt312_state *state, const enum mt312_reg_addr reg, |
60 | u8 *buf, const size_t count) | 62 | u8 *buf, const size_t count) |
@@ -264,6 +266,32 @@ static int mt312_initfe(struct dvb_frontend *fe) | |||
264 | return ret; | 266 | return ret; |
265 | } | 267 | } |
266 | 268 | ||
269 | switch (state->id) { | ||
270 | case ID_ZL10313: | ||
271 | /* enable ADC */ | ||
272 | ret = mt312_writereg(state, GPP_CTRL, 0x80); | ||
273 | if (ret < 0) | ||
274 | return ret; | ||
275 | |||
276 | /* configure ZL10313 for optimal ADC performance */ | ||
277 | buf[0] = 0x80; | ||
278 | buf[1] = 0xB0; | ||
279 | ret = mt312_write(state, HW_CTRL, buf, 2); | ||
280 | if (ret < 0) | ||
281 | return ret; | ||
282 | |||
283 | /* enable MPEG output and ADCs */ | ||
284 | ret = mt312_writereg(state, HW_CTRL, 0x00); | ||
285 | if (ret < 0) | ||
286 | return ret; | ||
287 | |||
288 | ret = mt312_writereg(state, MPEG_CTRL, 0x00); | ||
289 | if (ret < 0) | ||
290 | return ret; | ||
291 | |||
292 | break; | ||
293 | } | ||
294 | |||
267 | /* SYS_CLK */ | 295 | /* SYS_CLK */ |
268 | buf[0] = mt312_div(state->xtal * state->freq_mult * 2, 1000000); | 296 | buf[0] = mt312_div(state->xtal * state->freq_mult * 2, 1000000); |
269 | 297 | ||
@@ -278,7 +306,17 @@ static int mt312_initfe(struct dvb_frontend *fe) | |||
278 | if (ret < 0) | 306 | if (ret < 0) |
279 | return ret; | 307 | return ret; |
280 | 308 | ||
281 | ret = mt312_writereg(state, OP_CTRL, 0x53); | 309 | /* different MOCLK polarity */ |
310 | switch (state->id) { | ||
311 | case ID_ZL10313: | ||
312 | buf[0] = 0x33; | ||
313 | break; | ||
314 | default: | ||
315 | buf[0] = 0x53; | ||
316 | break; | ||
317 | } | ||
318 | |||
319 | ret = mt312_writereg(state, OP_CTRL, buf[0]); | ||
282 | if (ret < 0) | 320 | if (ret < 0) |
283 | return ret; | 321 | return ret; |
284 | 322 | ||
@@ -552,6 +590,7 @@ static int mt312_set_frontend(struct dvb_frontend *fe, | |||
552 | break; | 590 | break; |
553 | 591 | ||
554 | case ID_MT312: | 592 | case ID_MT312: |
593 | case ID_ZL10313: | ||
555 | break; | 594 | break; |
556 | 595 | ||
557 | default: | 596 | default: |
@@ -617,11 +656,29 @@ static int mt312_i2c_gate_ctrl(struct dvb_frontend *fe, int enable) | |||
617 | { | 656 | { |
618 | struct mt312_state *state = fe->demodulator_priv; | 657 | struct mt312_state *state = fe->demodulator_priv; |
619 | 658 | ||
620 | if (enable) { | 659 | u8 val = 0x00; |
621 | return mt312_writereg(state, GPP_CTRL, 0x40); | 660 | int ret; |
622 | } else { | 661 | |
623 | return mt312_writereg(state, GPP_CTRL, 0x00); | 662 | switch (state->id) { |
663 | case ID_ZL10313: | ||
664 | ret = mt312_readreg(state, GPP_CTRL, &val); | ||
665 | if (ret < 0) | ||
666 | goto error; | ||
667 | |||
668 | /* preserve this bit to not accidently shutdown ADC */ | ||
669 | val &= 0x80; | ||
670 | break; | ||
624 | } | 671 | } |
672 | |||
673 | if (enable) | ||
674 | val |= 0x40; | ||
675 | else | ||
676 | val &= ~0x40; | ||
677 | |||
678 | ret = mt312_writereg(state, GPP_CTRL, val); | ||
679 | |||
680 | error: | ||
681 | return ret; | ||
625 | } | 682 | } |
626 | 683 | ||
627 | static int mt312_sleep(struct dvb_frontend *fe) | 684 | static int mt312_sleep(struct dvb_frontend *fe) |
@@ -635,6 +692,18 @@ static int mt312_sleep(struct dvb_frontend *fe) | |||
635 | if (ret < 0) | 692 | if (ret < 0) |
636 | return ret; | 693 | return ret; |
637 | 694 | ||
695 | if (state->id == ID_ZL10313) { | ||
696 | /* reset ADC */ | ||
697 | ret = mt312_writereg(state, GPP_CTRL, 0x00); | ||
698 | if (ret < 0) | ||
699 | return ret; | ||
700 | |||
701 | /* full shutdown of ADCs, mpeg bus tristated */ | ||
702 | ret = mt312_writereg(state, HW_CTRL, 0x0d); | ||
703 | if (ret < 0) | ||
704 | return ret; | ||
705 | } | ||
706 | |||
638 | ret = mt312_readreg(state, CONFIG, &config); | 707 | ret = mt312_readreg(state, CONFIG, &config); |
639 | if (ret < 0) | 708 | if (ret < 0) |
640 | return ret; | 709 | return ret; |
@@ -736,8 +805,13 @@ struct dvb_frontend *vp310_mt312_attach(const struct mt312_config *config, | |||
736 | state->xtal = MT312_PLL_CLK; | 805 | state->xtal = MT312_PLL_CLK; |
737 | state->freq_mult = 6; | 806 | state->freq_mult = 6; |
738 | break; | 807 | break; |
808 | case ID_ZL10313: | ||
809 | strcpy(state->frontend.ops.info.name, "Zarlink ZL10313 DVB-S"); | ||
810 | state->xtal = MT312_PLL_CLK_10_111; | ||
811 | state->freq_mult = 9; | ||
812 | break; | ||
739 | default: | 813 | default: |
740 | printk(KERN_WARNING "Only Zarlink VP310/MT312" | 814 | printk(KERN_WARNING "Only Zarlink VP310/MT312/ZL10313" |
741 | " are supported chips.\n"); | 815 | " are supported chips.\n"); |
742 | goto error; | 816 | goto error; |
743 | } | 817 | } |
@@ -753,7 +827,7 @@ EXPORT_SYMBOL(vp310_mt312_attach); | |||
753 | module_param(debug, int, 0644); | 827 | module_param(debug, int, 0644); |
754 | MODULE_PARM_DESC(debug, "Turn on/off frontend debugging (default:off)."); | 828 | MODULE_PARM_DESC(debug, "Turn on/off frontend debugging (default:off)."); |
755 | 829 | ||
756 | MODULE_DESCRIPTION("Zarlink VP310/MT312 DVB-S Demodulator driver"); | 830 | MODULE_DESCRIPTION("Zarlink VP310/MT312/ZL10313 DVB-S Demodulator driver"); |
757 | MODULE_AUTHOR("Andreas Oberritter <obi@linuxtv.org>"); | 831 | MODULE_AUTHOR("Andreas Oberritter <obi@linuxtv.org>"); |
758 | MODULE_LICENSE("GPL"); | 832 | MODULE_LICENSE("GPL"); |
759 | 833 | ||
diff --git a/drivers/media/dvb/frontends/mt312_priv.h b/drivers/media/dvb/frontends/mt312_priv.h index 5e0b95b5337b..a3959f94d639 100644 --- a/drivers/media/dvb/frontends/mt312_priv.h +++ b/drivers/media/dvb/frontends/mt312_priv.h | |||
@@ -110,6 +110,8 @@ enum mt312_reg_addr { | |||
110 | VIT_ERRPER_H = 83, | 110 | VIT_ERRPER_H = 83, |
111 | VIT_ERRPER_M = 84, | 111 | VIT_ERRPER_M = 84, |
112 | VIT_ERRPER_L = 85, | 112 | VIT_ERRPER_L = 85, |
113 | HW_CTRL = 84, /* ZL10313 only */ | ||
114 | MPEG_CTRL = 85, /* ZL10313 only */ | ||
113 | VIT_SETUP = 86, | 115 | VIT_SETUP = 86, |
114 | VIT_REF0 = 87, | 116 | VIT_REF0 = 87, |
115 | VIT_REF1 = 88, | 117 | VIT_REF1 = 88, |
@@ -156,7 +158,8 @@ enum mt312_reg_addr { | |||
156 | 158 | ||
157 | enum mt312_model_id { | 159 | enum mt312_model_id { |
158 | ID_VP310 = 1, | 160 | ID_VP310 = 1, |
159 | ID_MT312 = 3 | 161 | ID_MT312 = 3, |
162 | ID_ZL10313 = 5, | ||
160 | }; | 163 | }; |
161 | 164 | ||
162 | #endif /* DVB_FRONTENDS_MT312_PRIV */ | 165 | #endif /* DVB_FRONTENDS_MT312_PRIV */ |