1c942fddfSThomas Gleixner // SPDX-License-Identifier: GPL-2.0-or-later
2b285192aSMauro Carvalho Chehab /*
3b285192aSMauro Carvalho Chehab *
4b285192aSMauro Carvalho Chehab * (c) 2004 Gerd Knorr <kraxel@bytesex.org> [SuSE Labs]
5b285192aSMauro Carvalho Chehab *
6b285192aSMauro Carvalho Chehab * Extended 3 / 2005 by Hartmut Hackmann to support various
7b285192aSMauro Carvalho Chehab * cards with the tda10046 DVB-T channel decoder
8b285192aSMauro Carvalho Chehab */
9b285192aSMauro Carvalho Chehab
109a12ccfcSMauro Carvalho Chehab #include "saa7134.h"
119a12ccfcSMauro Carvalho Chehab #include "saa7134-reg.h"
129a12ccfcSMauro Carvalho Chehab
13b285192aSMauro Carvalho Chehab #include <linux/init.h>
14b285192aSMauro Carvalho Chehab #include <linux/list.h>
15b285192aSMauro Carvalho Chehab #include <linux/module.h>
16b285192aSMauro Carvalho Chehab #include <linux/kernel.h>
17b285192aSMauro Carvalho Chehab #include <linux/delay.h>
18b285192aSMauro Carvalho Chehab #include <linux/kthread.h>
19b285192aSMauro Carvalho Chehab #include <linux/suspend.h>
20b285192aSMauro Carvalho Chehab
21b285192aSMauro Carvalho Chehab #include <media/v4l2-common.h>
22b285192aSMauro Carvalho Chehab #include "dvb-pll.h"
23fada1935SMauro Carvalho Chehab #include <media/dvb_frontend.h>
24b285192aSMauro Carvalho Chehab
25b285192aSMauro Carvalho Chehab #include "mt352.h"
26b285192aSMauro Carvalho Chehab #include "mt352_priv.h" /* FIXME */
27b285192aSMauro Carvalho Chehab #include "tda1004x.h"
28b285192aSMauro Carvalho Chehab #include "nxt200x.h"
29d76231e4SMauro Carvalho Chehab #include "xc2028.h"
30b285192aSMauro Carvalho Chehab #include "xc5000.h"
31b285192aSMauro Carvalho Chehab
32b285192aSMauro Carvalho Chehab #include "tda10086.h"
33b285192aSMauro Carvalho Chehab #include "tda826x.h"
34b285192aSMauro Carvalho Chehab #include "tda827x.h"
35b285192aSMauro Carvalho Chehab #include "isl6421.h"
36b285192aSMauro Carvalho Chehab #include "isl6405.h"
37b285192aSMauro Carvalho Chehab #include "lnbp21.h"
38b285192aSMauro Carvalho Chehab #include "tuner-simple.h"
39b285192aSMauro Carvalho Chehab #include "tda10048.h"
40b285192aSMauro Carvalho Chehab #include "tda18271.h"
41b285192aSMauro Carvalho Chehab #include "lgdt3305.h"
42b285192aSMauro Carvalho Chehab #include "tda8290.h"
43b285192aSMauro Carvalho Chehab #include "mb86a20s.h"
44b285192aSMauro Carvalho Chehab #include "lgs8gxx.h"
45b285192aSMauro Carvalho Chehab
46b285192aSMauro Carvalho Chehab #include "zl10353.h"
47b285192aSMauro Carvalho Chehab #include "qt1010.h"
48b285192aSMauro Carvalho Chehab
49b285192aSMauro Carvalho Chehab #include "zl10036.h"
50b285192aSMauro Carvalho Chehab #include "zl10039.h"
51b285192aSMauro Carvalho Chehab #include "mt312.h"
52b285192aSMauro Carvalho Chehab #include "s5h1411.h"
53b285192aSMauro Carvalho Chehab
54b285192aSMauro Carvalho Chehab MODULE_AUTHOR("Gerd Knorr <kraxel@bytesex.org> [SuSE Labs]");
55b285192aSMauro Carvalho Chehab MODULE_LICENSE("GPL");
56b285192aSMauro Carvalho Chehab
57b285192aSMauro Carvalho Chehab static unsigned int antenna_pwr;
58b285192aSMauro Carvalho Chehab
59b285192aSMauro Carvalho Chehab module_param(antenna_pwr, int, 0444);
60b285192aSMauro Carvalho Chehab MODULE_PARM_DESC(antenna_pwr,"enable antenna power (Pinnacle 300i)");
61b285192aSMauro Carvalho Chehab
62b285192aSMauro Carvalho Chehab static int use_frontend;
63b285192aSMauro Carvalho Chehab module_param(use_frontend, int, 0644);
64b285192aSMauro Carvalho Chehab MODULE_PARM_DESC(use_frontend,"for cards with multiple frontends (0: terrestrial, 1: satellite)");
65b285192aSMauro Carvalho Chehab
66b285192aSMauro Carvalho Chehab DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr);
67b285192aSMauro Carvalho Chehab
68b285192aSMauro Carvalho Chehab /* ------------------------------------------------------------------
69b285192aSMauro Carvalho Chehab * mt352 based DVB-T cards
70b285192aSMauro Carvalho Chehab */
71b285192aSMauro Carvalho Chehab
pinnacle_antenna_pwr(struct saa7134_dev * dev,int on)72b285192aSMauro Carvalho Chehab static int pinnacle_antenna_pwr(struct saa7134_dev *dev, int on)
73b285192aSMauro Carvalho Chehab {
74b285192aSMauro Carvalho Chehab u32 ok;
75b285192aSMauro Carvalho Chehab
76b285192aSMauro Carvalho Chehab if (!on) {
77b285192aSMauro Carvalho Chehab saa_setl(SAA7134_GPIO_GPMODE0 >> 2, (1 << 26));
78b285192aSMauro Carvalho Chehab saa_clearl(SAA7134_GPIO_GPSTATUS0 >> 2, (1 << 26));
79b285192aSMauro Carvalho Chehab return 0;
80b285192aSMauro Carvalho Chehab }
81b285192aSMauro Carvalho Chehab
82b285192aSMauro Carvalho Chehab saa_setl(SAA7134_GPIO_GPMODE0 >> 2, (1 << 26));
83b285192aSMauro Carvalho Chehab saa_setl(SAA7134_GPIO_GPSTATUS0 >> 2, (1 << 26));
84b285192aSMauro Carvalho Chehab udelay(10);
85b285192aSMauro Carvalho Chehab
86b285192aSMauro Carvalho Chehab saa_setl(SAA7134_GPIO_GPMODE0 >> 2, (1 << 28));
87b285192aSMauro Carvalho Chehab saa_clearl(SAA7134_GPIO_GPSTATUS0 >> 2, (1 << 28));
88b285192aSMauro Carvalho Chehab udelay(10);
89b285192aSMauro Carvalho Chehab saa_setl(SAA7134_GPIO_GPSTATUS0 >> 2, (1 << 28));
90b285192aSMauro Carvalho Chehab udelay(10);
91b285192aSMauro Carvalho Chehab ok = saa_readl(SAA7134_GPIO_GPSTATUS0) & (1 << 27);
927516657aSMauro Carvalho Chehab pr_debug("%s %s\n", __func__, ok ? "on" : "off");
93b285192aSMauro Carvalho Chehab
94b285192aSMauro Carvalho Chehab if (!ok)
95b285192aSMauro Carvalho Chehab saa_clearl(SAA7134_GPIO_GPSTATUS0 >> 2, (1 << 26));
96b285192aSMauro Carvalho Chehab return ok;
97b285192aSMauro Carvalho Chehab }
98b285192aSMauro Carvalho Chehab
mt352_pinnacle_init(struct dvb_frontend * fe)99b285192aSMauro Carvalho Chehab static int mt352_pinnacle_init(struct dvb_frontend* fe)
100b285192aSMauro Carvalho Chehab {
101b285192aSMauro Carvalho Chehab static u8 clock_config [] = { CLOCK_CTL, 0x3d, 0x28 };
102b285192aSMauro Carvalho Chehab static u8 reset [] = { RESET, 0x80 };
103b285192aSMauro Carvalho Chehab static u8 adc_ctl_1_cfg [] = { ADC_CTL_1, 0x40 };
104b285192aSMauro Carvalho Chehab static u8 agc_cfg [] = { AGC_TARGET, 0x28, 0xa0 };
105b285192aSMauro Carvalho Chehab static u8 capt_range_cfg[] = { CAPT_RANGE, 0x31 };
106b285192aSMauro Carvalho Chehab static u8 fsm_ctl_cfg[] = { 0x7b, 0x04 };
107b285192aSMauro Carvalho Chehab static u8 gpp_ctl_cfg [] = { GPP_CTL, 0x0f };
108b285192aSMauro Carvalho Chehab static u8 scan_ctl_cfg [] = { SCAN_CTL, 0x0d };
109b285192aSMauro Carvalho Chehab static u8 irq_cfg [] = { INTERRUPT_EN_0, 0x00, 0x00, 0x00, 0x00 };
110b285192aSMauro Carvalho Chehab
1117516657aSMauro Carvalho Chehab pr_debug("%s called\n", __func__);
112b285192aSMauro Carvalho Chehab
113b285192aSMauro Carvalho Chehab mt352_write(fe, clock_config, sizeof(clock_config));
114b285192aSMauro Carvalho Chehab udelay(200);
115b285192aSMauro Carvalho Chehab mt352_write(fe, reset, sizeof(reset));
116b285192aSMauro Carvalho Chehab mt352_write(fe, adc_ctl_1_cfg, sizeof(adc_ctl_1_cfg));
117b285192aSMauro Carvalho Chehab mt352_write(fe, agc_cfg, sizeof(agc_cfg));
118b285192aSMauro Carvalho Chehab mt352_write(fe, capt_range_cfg, sizeof(capt_range_cfg));
119b285192aSMauro Carvalho Chehab mt352_write(fe, gpp_ctl_cfg, sizeof(gpp_ctl_cfg));
120b285192aSMauro Carvalho Chehab
121b285192aSMauro Carvalho Chehab mt352_write(fe, fsm_ctl_cfg, sizeof(fsm_ctl_cfg));
122b285192aSMauro Carvalho Chehab mt352_write(fe, scan_ctl_cfg, sizeof(scan_ctl_cfg));
123b285192aSMauro Carvalho Chehab mt352_write(fe, irq_cfg, sizeof(irq_cfg));
124b285192aSMauro Carvalho Chehab
125b285192aSMauro Carvalho Chehab return 0;
126b285192aSMauro Carvalho Chehab }
127b285192aSMauro Carvalho Chehab
mt352_aver777_init(struct dvb_frontend * fe)128b285192aSMauro Carvalho Chehab static int mt352_aver777_init(struct dvb_frontend* fe)
129b285192aSMauro Carvalho Chehab {
130b285192aSMauro Carvalho Chehab static u8 clock_config [] = { CLOCK_CTL, 0x38, 0x2d };
131b285192aSMauro Carvalho Chehab static u8 reset [] = { RESET, 0x80 };
132b285192aSMauro Carvalho Chehab static u8 adc_ctl_1_cfg [] = { ADC_CTL_1, 0x40 };
133b285192aSMauro Carvalho Chehab static u8 agc_cfg [] = { AGC_TARGET, 0x28, 0xa0 };
134b285192aSMauro Carvalho Chehab static u8 capt_range_cfg[] = { CAPT_RANGE, 0x33 };
135b285192aSMauro Carvalho Chehab
136b285192aSMauro Carvalho Chehab mt352_write(fe, clock_config, sizeof(clock_config));
137b285192aSMauro Carvalho Chehab udelay(200);
138b285192aSMauro Carvalho Chehab mt352_write(fe, reset, sizeof(reset));
139b285192aSMauro Carvalho Chehab mt352_write(fe, adc_ctl_1_cfg, sizeof(adc_ctl_1_cfg));
140b285192aSMauro Carvalho Chehab mt352_write(fe, agc_cfg, sizeof(agc_cfg));
141b285192aSMauro Carvalho Chehab mt352_write(fe, capt_range_cfg, sizeof(capt_range_cfg));
142b285192aSMauro Carvalho Chehab
143b285192aSMauro Carvalho Chehab return 0;
144b285192aSMauro Carvalho Chehab }
145b285192aSMauro Carvalho Chehab
mt352_avermedia_xc3028_init(struct dvb_frontend * fe)146b285192aSMauro Carvalho Chehab static int mt352_avermedia_xc3028_init(struct dvb_frontend *fe)
147b285192aSMauro Carvalho Chehab {
148b285192aSMauro Carvalho Chehab static u8 clock_config [] = { CLOCK_CTL, 0x38, 0x2d };
149b285192aSMauro Carvalho Chehab static u8 reset [] = { RESET, 0x80 };
150b285192aSMauro Carvalho Chehab static u8 adc_ctl_1_cfg [] = { ADC_CTL_1, 0x40 };
151b285192aSMauro Carvalho Chehab static u8 agc_cfg [] = { AGC_TARGET, 0xe };
152b285192aSMauro Carvalho Chehab static u8 capt_range_cfg[] = { CAPT_RANGE, 0x33 };
153b285192aSMauro Carvalho Chehab
154b285192aSMauro Carvalho Chehab mt352_write(fe, clock_config, sizeof(clock_config));
155b285192aSMauro Carvalho Chehab udelay(200);
156b285192aSMauro Carvalho Chehab mt352_write(fe, reset, sizeof(reset));
157b285192aSMauro Carvalho Chehab mt352_write(fe, adc_ctl_1_cfg, sizeof(adc_ctl_1_cfg));
158b285192aSMauro Carvalho Chehab mt352_write(fe, agc_cfg, sizeof(agc_cfg));
159b285192aSMauro Carvalho Chehab mt352_write(fe, capt_range_cfg, sizeof(capt_range_cfg));
160b285192aSMauro Carvalho Chehab return 0;
161b285192aSMauro Carvalho Chehab }
162b285192aSMauro Carvalho Chehab
mt352_pinnacle_tuner_set_params(struct dvb_frontend * fe)163b285192aSMauro Carvalho Chehab static int mt352_pinnacle_tuner_set_params(struct dvb_frontend *fe)
164b285192aSMauro Carvalho Chehab {
165b285192aSMauro Carvalho Chehab struct dtv_frontend_properties *c = &fe->dtv_property_cache;
166b285192aSMauro Carvalho Chehab u8 off[] = { 0x00, 0xf1};
167b285192aSMauro Carvalho Chehab u8 on[] = { 0x00, 0x71};
168b285192aSMauro Carvalho Chehab struct i2c_msg msg = {.addr=0x43, .flags=0, .buf=off, .len = sizeof(off)};
169b285192aSMauro Carvalho Chehab
170b285192aSMauro Carvalho Chehab struct saa7134_dev *dev = fe->dvb->priv;
171b285192aSMauro Carvalho Chehab struct v4l2_frequency f;
172b285192aSMauro Carvalho Chehab
173b285192aSMauro Carvalho Chehab /* set frequency (mt2050) */
174b285192aSMauro Carvalho Chehab f.tuner = 0;
175b285192aSMauro Carvalho Chehab f.type = V4L2_TUNER_DIGITAL_TV;
176b285192aSMauro Carvalho Chehab f.frequency = c->frequency / 1000 * 16 / 1000;
177b285192aSMauro Carvalho Chehab if (fe->ops.i2c_gate_ctrl)
178b285192aSMauro Carvalho Chehab fe->ops.i2c_gate_ctrl(fe, 1);
179b285192aSMauro Carvalho Chehab i2c_transfer(&dev->i2c_adap, &msg, 1);
180b285192aSMauro Carvalho Chehab saa_call_all(dev, tuner, s_frequency, &f);
181b285192aSMauro Carvalho Chehab msg.buf = on;
182b285192aSMauro Carvalho Chehab if (fe->ops.i2c_gate_ctrl)
183b285192aSMauro Carvalho Chehab fe->ops.i2c_gate_ctrl(fe, 1);
184b285192aSMauro Carvalho Chehab i2c_transfer(&dev->i2c_adap, &msg, 1);
185b285192aSMauro Carvalho Chehab
186b285192aSMauro Carvalho Chehab pinnacle_antenna_pwr(dev, antenna_pwr);
187b285192aSMauro Carvalho Chehab
188b285192aSMauro Carvalho Chehab /* mt352 setup */
189b285192aSMauro Carvalho Chehab return mt352_pinnacle_init(fe);
190b285192aSMauro Carvalho Chehab }
191b285192aSMauro Carvalho Chehab
192b285192aSMauro Carvalho Chehab static struct mt352_config pinnacle_300i = {
193b285192aSMauro Carvalho Chehab .demod_address = 0x3c >> 1,
194b285192aSMauro Carvalho Chehab .adc_clock = 20333,
195b285192aSMauro Carvalho Chehab .if2 = 36150,
196b285192aSMauro Carvalho Chehab .no_tuner = 1,
197b285192aSMauro Carvalho Chehab .demod_init = mt352_pinnacle_init,
198b285192aSMauro Carvalho Chehab };
199b285192aSMauro Carvalho Chehab
200b285192aSMauro Carvalho Chehab static struct mt352_config avermedia_777 = {
201b285192aSMauro Carvalho Chehab .demod_address = 0xf,
202b285192aSMauro Carvalho Chehab .demod_init = mt352_aver777_init,
203b285192aSMauro Carvalho Chehab };
204b285192aSMauro Carvalho Chehab
205b285192aSMauro Carvalho Chehab static struct mt352_config avermedia_xc3028_mt352_dev = {
206b285192aSMauro Carvalho Chehab .demod_address = (0x1e >> 1),
207b285192aSMauro Carvalho Chehab .no_tuner = 1,
208b285192aSMauro Carvalho Chehab .demod_init = mt352_avermedia_xc3028_init,
209b285192aSMauro Carvalho Chehab };
210b285192aSMauro Carvalho Chehab
211b285192aSMauro Carvalho Chehab static struct tda18271_std_map mb86a20s_tda18271_std_map = {
212b285192aSMauro Carvalho Chehab .dvbt_6 = { .if_freq = 3300, .agc_mode = 3, .std = 4,
213b285192aSMauro Carvalho Chehab .if_lvl = 7, .rfagc_top = 0x37, },
214b285192aSMauro Carvalho Chehab };
215b285192aSMauro Carvalho Chehab
216b285192aSMauro Carvalho Chehab static struct tda18271_config kworld_tda18271_config = {
217b285192aSMauro Carvalho Chehab .std_map = &mb86a20s_tda18271_std_map,
218b285192aSMauro Carvalho Chehab .gate = TDA18271_GATE_DIGITAL,
219b285192aSMauro Carvalho Chehab .config = 3, /* Use tuner callback for AGC */
220b285192aSMauro Carvalho Chehab
221b285192aSMauro Carvalho Chehab };
222b285192aSMauro Carvalho Chehab
223b285192aSMauro Carvalho Chehab static const struct mb86a20s_config kworld_mb86a20s_config = {
224b285192aSMauro Carvalho Chehab .demod_address = 0x10,
225b285192aSMauro Carvalho Chehab };
226b285192aSMauro Carvalho Chehab
kworld_sbtvd_gate_ctrl(struct dvb_frontend * fe,int enable)227b285192aSMauro Carvalho Chehab static int kworld_sbtvd_gate_ctrl(struct dvb_frontend* fe, int enable)
228b285192aSMauro Carvalho Chehab {
229b285192aSMauro Carvalho Chehab struct saa7134_dev *dev = fe->dvb->priv;
230b285192aSMauro Carvalho Chehab
231b285192aSMauro Carvalho Chehab unsigned char initmsg[] = {0x45, 0x97};
232b285192aSMauro Carvalho Chehab unsigned char msg_enable[] = {0x45, 0xc1};
233b285192aSMauro Carvalho Chehab unsigned char msg_disable[] = {0x45, 0x81};
234b285192aSMauro Carvalho Chehab struct i2c_msg msg = {.addr = 0x4b, .flags = 0, .buf = initmsg, .len = 2};
235b285192aSMauro Carvalho Chehab
236b285192aSMauro Carvalho Chehab if (i2c_transfer(&dev->i2c_adap, &msg, 1) != 1) {
237ae618919SMauro Carvalho Chehab pr_warn("could not access the I2C gate\n");
238b285192aSMauro Carvalho Chehab return -EIO;
239b285192aSMauro Carvalho Chehab }
240b285192aSMauro Carvalho Chehab if (enable)
241b285192aSMauro Carvalho Chehab msg.buf = msg_enable;
242b285192aSMauro Carvalho Chehab else
243b285192aSMauro Carvalho Chehab msg.buf = msg_disable;
244b285192aSMauro Carvalho Chehab if (i2c_transfer(&dev->i2c_adap, &msg, 1) != 1) {
245ae618919SMauro Carvalho Chehab pr_warn("could not access the I2C gate\n");
246b285192aSMauro Carvalho Chehab return -EIO;
247b285192aSMauro Carvalho Chehab }
248b285192aSMauro Carvalho Chehab msleep(20);
249b285192aSMauro Carvalho Chehab return 0;
250b285192aSMauro Carvalho Chehab }
251b285192aSMauro Carvalho Chehab
252b285192aSMauro Carvalho Chehab /* ==================================================================
253b285192aSMauro Carvalho Chehab * tda1004x based DVB-T cards, helper functions
254b285192aSMauro Carvalho Chehab */
255b285192aSMauro Carvalho Chehab
philips_tda1004x_request_firmware(struct dvb_frontend * fe,const struct firmware ** fw,char * name)256b285192aSMauro Carvalho Chehab static int philips_tda1004x_request_firmware(struct dvb_frontend *fe,
257b285192aSMauro Carvalho Chehab const struct firmware **fw, char *name)
258b285192aSMauro Carvalho Chehab {
259b285192aSMauro Carvalho Chehab struct saa7134_dev *dev = fe->dvb->priv;
260b285192aSMauro Carvalho Chehab return request_firmware(fw, name, &dev->pci->dev);
261b285192aSMauro Carvalho Chehab }
262b285192aSMauro Carvalho Chehab
263b285192aSMauro Carvalho Chehab /* ------------------------------------------------------------------
264b285192aSMauro Carvalho Chehab * these tuners are tu1216, td1316(a)
265b285192aSMauro Carvalho Chehab */
266b285192aSMauro Carvalho Chehab
philips_tda6651_pll_set(struct dvb_frontend * fe)267b285192aSMauro Carvalho Chehab static int philips_tda6651_pll_set(struct dvb_frontend *fe)
268b285192aSMauro Carvalho Chehab {
269b285192aSMauro Carvalho Chehab struct dtv_frontend_properties *c = &fe->dtv_property_cache;
270b285192aSMauro Carvalho Chehab struct saa7134_dev *dev = fe->dvb->priv;
271b285192aSMauro Carvalho Chehab struct tda1004x_state *state = fe->demodulator_priv;
272b285192aSMauro Carvalho Chehab u8 addr = state->config->tuner_address;
273b285192aSMauro Carvalho Chehab u8 tuner_buf[4];
274b285192aSMauro Carvalho Chehab struct i2c_msg tuner_msg = {.addr = addr,.flags = 0,.buf = tuner_buf,.len =
275b285192aSMauro Carvalho Chehab sizeof(tuner_buf) };
276b285192aSMauro Carvalho Chehab int tuner_frequency = 0;
277b285192aSMauro Carvalho Chehab u8 band, cp, filter;
278b285192aSMauro Carvalho Chehab
279b285192aSMauro Carvalho Chehab /* determine charge pump */
280b285192aSMauro Carvalho Chehab tuner_frequency = c->frequency + 36166000;
281b285192aSMauro Carvalho Chehab if (tuner_frequency < 87000000)
282b285192aSMauro Carvalho Chehab return -EINVAL;
283b285192aSMauro Carvalho Chehab else if (tuner_frequency < 130000000)
284b285192aSMauro Carvalho Chehab cp = 3;
285b285192aSMauro Carvalho Chehab else if (tuner_frequency < 160000000)
286b285192aSMauro Carvalho Chehab cp = 5;
287b285192aSMauro Carvalho Chehab else if (tuner_frequency < 200000000)
288b285192aSMauro Carvalho Chehab cp = 6;
289b285192aSMauro Carvalho Chehab else if (tuner_frequency < 290000000)
290b285192aSMauro Carvalho Chehab cp = 3;
291b285192aSMauro Carvalho Chehab else if (tuner_frequency < 420000000)
292b285192aSMauro Carvalho Chehab cp = 5;
293b285192aSMauro Carvalho Chehab else if (tuner_frequency < 480000000)
294b285192aSMauro Carvalho Chehab cp = 6;
295b285192aSMauro Carvalho Chehab else if (tuner_frequency < 620000000)
296b285192aSMauro Carvalho Chehab cp = 3;
297b285192aSMauro Carvalho Chehab else if (tuner_frequency < 830000000)
298b285192aSMauro Carvalho Chehab cp = 5;
299b285192aSMauro Carvalho Chehab else if (tuner_frequency < 895000000)
300b285192aSMauro Carvalho Chehab cp = 7;
301b285192aSMauro Carvalho Chehab else
302b285192aSMauro Carvalho Chehab return -EINVAL;
303b285192aSMauro Carvalho Chehab
304b285192aSMauro Carvalho Chehab /* determine band */
305b285192aSMauro Carvalho Chehab if (c->frequency < 49000000)
306b285192aSMauro Carvalho Chehab return -EINVAL;
307b285192aSMauro Carvalho Chehab else if (c->frequency < 161000000)
308b285192aSMauro Carvalho Chehab band = 1;
309b285192aSMauro Carvalho Chehab else if (c->frequency < 444000000)
310b285192aSMauro Carvalho Chehab band = 2;
311b285192aSMauro Carvalho Chehab else if (c->frequency < 861000000)
312b285192aSMauro Carvalho Chehab band = 4;
313b285192aSMauro Carvalho Chehab else
314b285192aSMauro Carvalho Chehab return -EINVAL;
315b285192aSMauro Carvalho Chehab
316b285192aSMauro Carvalho Chehab /* setup PLL filter */
317b285192aSMauro Carvalho Chehab switch (c->bandwidth_hz) {
318b285192aSMauro Carvalho Chehab case 6000000:
319b285192aSMauro Carvalho Chehab filter = 0;
320b285192aSMauro Carvalho Chehab break;
321b285192aSMauro Carvalho Chehab
322b285192aSMauro Carvalho Chehab case 7000000:
323b285192aSMauro Carvalho Chehab filter = 0;
324b285192aSMauro Carvalho Chehab break;
325b285192aSMauro Carvalho Chehab
326b285192aSMauro Carvalho Chehab case 8000000:
327b285192aSMauro Carvalho Chehab filter = 1;
328b285192aSMauro Carvalho Chehab break;
329b285192aSMauro Carvalho Chehab
330b285192aSMauro Carvalho Chehab default:
331b285192aSMauro Carvalho Chehab return -EINVAL;
332b285192aSMauro Carvalho Chehab }
333b285192aSMauro Carvalho Chehab
334b285192aSMauro Carvalho Chehab /* calculate divisor
335b285192aSMauro Carvalho Chehab * ((36166000+((1000000/6)/2)) + Finput)/(1000000/6)
336b285192aSMauro Carvalho Chehab */
337b285192aSMauro Carvalho Chehab tuner_frequency = (((c->frequency / 1000) * 6) + 217496) / 1000;
338b285192aSMauro Carvalho Chehab
339b285192aSMauro Carvalho Chehab /* setup tuner buffer */
340b285192aSMauro Carvalho Chehab tuner_buf[0] = (tuner_frequency >> 8) & 0x7f;
341b285192aSMauro Carvalho Chehab tuner_buf[1] = tuner_frequency & 0xff;
342b285192aSMauro Carvalho Chehab tuner_buf[2] = 0xca;
343b285192aSMauro Carvalho Chehab tuner_buf[3] = (cp << 5) | (filter << 3) | band;
344b285192aSMauro Carvalho Chehab
345b285192aSMauro Carvalho Chehab if (fe->ops.i2c_gate_ctrl)
346b285192aSMauro Carvalho Chehab fe->ops.i2c_gate_ctrl(fe, 1);
347b285192aSMauro Carvalho Chehab if (i2c_transfer(&dev->i2c_adap, &tuner_msg, 1) != 1) {
348ae618919SMauro Carvalho Chehab pr_warn("could not write to tuner at addr: 0x%02x\n",
349b285192aSMauro Carvalho Chehab addr << 1);
350b285192aSMauro Carvalho Chehab return -EIO;
351b285192aSMauro Carvalho Chehab }
352b285192aSMauro Carvalho Chehab msleep(1);
353b285192aSMauro Carvalho Chehab return 0;
354b285192aSMauro Carvalho Chehab }
355b285192aSMauro Carvalho Chehab
philips_tu1216_init(struct dvb_frontend * fe)356b285192aSMauro Carvalho Chehab static int philips_tu1216_init(struct dvb_frontend *fe)
357b285192aSMauro Carvalho Chehab {
358b285192aSMauro Carvalho Chehab struct saa7134_dev *dev = fe->dvb->priv;
359b285192aSMauro Carvalho Chehab struct tda1004x_state *state = fe->demodulator_priv;
360b285192aSMauro Carvalho Chehab u8 addr = state->config->tuner_address;
361b285192aSMauro Carvalho Chehab static u8 tu1216_init[] = { 0x0b, 0xf5, 0x85, 0xab };
362b285192aSMauro Carvalho Chehab struct i2c_msg tuner_msg = {.addr = addr,.flags = 0,.buf = tu1216_init,.len = sizeof(tu1216_init) };
363b285192aSMauro Carvalho Chehab
364b285192aSMauro Carvalho Chehab /* setup PLL configuration */
365b285192aSMauro Carvalho Chehab if (fe->ops.i2c_gate_ctrl)
366b285192aSMauro Carvalho Chehab fe->ops.i2c_gate_ctrl(fe, 1);
367b285192aSMauro Carvalho Chehab if (i2c_transfer(&dev->i2c_adap, &tuner_msg, 1) != 1)
368b285192aSMauro Carvalho Chehab return -EIO;
369b285192aSMauro Carvalho Chehab msleep(1);
370b285192aSMauro Carvalho Chehab
371b285192aSMauro Carvalho Chehab return 0;
372b285192aSMauro Carvalho Chehab }
373b285192aSMauro Carvalho Chehab
374b285192aSMauro Carvalho Chehab /* ------------------------------------------------------------------ */
375b285192aSMauro Carvalho Chehab
376b285192aSMauro Carvalho Chehab static struct tda1004x_config philips_tu1216_60_config = {
377b285192aSMauro Carvalho Chehab .demod_address = 0x8,
378b285192aSMauro Carvalho Chehab .invert = 1,
379b285192aSMauro Carvalho Chehab .invert_oclk = 0,
380b285192aSMauro Carvalho Chehab .xtal_freq = TDA10046_XTAL_4M,
381b285192aSMauro Carvalho Chehab .agc_config = TDA10046_AGC_DEFAULT,
382b285192aSMauro Carvalho Chehab .if_freq = TDA10046_FREQ_3617,
383b285192aSMauro Carvalho Chehab .tuner_address = 0x60,
384b285192aSMauro Carvalho Chehab .request_firmware = philips_tda1004x_request_firmware
385b285192aSMauro Carvalho Chehab };
386b285192aSMauro Carvalho Chehab
387b285192aSMauro Carvalho Chehab static struct tda1004x_config philips_tu1216_61_config = {
388b285192aSMauro Carvalho Chehab
389b285192aSMauro Carvalho Chehab .demod_address = 0x8,
390b285192aSMauro Carvalho Chehab .invert = 1,
391b285192aSMauro Carvalho Chehab .invert_oclk = 0,
392b285192aSMauro Carvalho Chehab .xtal_freq = TDA10046_XTAL_4M,
393b285192aSMauro Carvalho Chehab .agc_config = TDA10046_AGC_DEFAULT,
394b285192aSMauro Carvalho Chehab .if_freq = TDA10046_FREQ_3617,
395b285192aSMauro Carvalho Chehab .tuner_address = 0x61,
396b285192aSMauro Carvalho Chehab .request_firmware = philips_tda1004x_request_firmware
397b285192aSMauro Carvalho Chehab };
398b285192aSMauro Carvalho Chehab
399b285192aSMauro Carvalho Chehab /* ------------------------------------------------------------------ */
400b285192aSMauro Carvalho Chehab
philips_td1316_tuner_init(struct dvb_frontend * fe)401b285192aSMauro Carvalho Chehab static int philips_td1316_tuner_init(struct dvb_frontend *fe)
402b285192aSMauro Carvalho Chehab {
403b285192aSMauro Carvalho Chehab struct saa7134_dev *dev = fe->dvb->priv;
404b285192aSMauro Carvalho Chehab struct tda1004x_state *state = fe->demodulator_priv;
405b285192aSMauro Carvalho Chehab u8 addr = state->config->tuner_address;
406b285192aSMauro Carvalho Chehab static u8 msg[] = { 0x0b, 0xf5, 0x86, 0xab };
407b285192aSMauro Carvalho Chehab struct i2c_msg init_msg = {.addr = addr,.flags = 0,.buf = msg,.len = sizeof(msg) };
408b285192aSMauro Carvalho Chehab
409b285192aSMauro Carvalho Chehab /* setup PLL configuration */
410b285192aSMauro Carvalho Chehab if (fe->ops.i2c_gate_ctrl)
411b285192aSMauro Carvalho Chehab fe->ops.i2c_gate_ctrl(fe, 1);
412b285192aSMauro Carvalho Chehab if (i2c_transfer(&dev->i2c_adap, &init_msg, 1) != 1)
413b285192aSMauro Carvalho Chehab return -EIO;
414b285192aSMauro Carvalho Chehab return 0;
415b285192aSMauro Carvalho Chehab }
416b285192aSMauro Carvalho Chehab
philips_td1316_tuner_set_params(struct dvb_frontend * fe)417b285192aSMauro Carvalho Chehab static int philips_td1316_tuner_set_params(struct dvb_frontend *fe)
418b285192aSMauro Carvalho Chehab {
419b285192aSMauro Carvalho Chehab return philips_tda6651_pll_set(fe);
420b285192aSMauro Carvalho Chehab }
421b285192aSMauro Carvalho Chehab
philips_td1316_tuner_sleep(struct dvb_frontend * fe)422b285192aSMauro Carvalho Chehab static int philips_td1316_tuner_sleep(struct dvb_frontend *fe)
423b285192aSMauro Carvalho Chehab {
424b285192aSMauro Carvalho Chehab struct saa7134_dev *dev = fe->dvb->priv;
425b285192aSMauro Carvalho Chehab struct tda1004x_state *state = fe->demodulator_priv;
426b285192aSMauro Carvalho Chehab u8 addr = state->config->tuner_address;
427b285192aSMauro Carvalho Chehab static u8 msg[] = { 0x0b, 0xdc, 0x86, 0xa4 };
428b285192aSMauro Carvalho Chehab struct i2c_msg analog_msg = {.addr = addr,.flags = 0,.buf = msg,.len = sizeof(msg) };
429b285192aSMauro Carvalho Chehab
430b285192aSMauro Carvalho Chehab /* switch the tuner to analog mode */
431b285192aSMauro Carvalho Chehab if (fe->ops.i2c_gate_ctrl)
432b285192aSMauro Carvalho Chehab fe->ops.i2c_gate_ctrl(fe, 1);
433b285192aSMauro Carvalho Chehab if (i2c_transfer(&dev->i2c_adap, &analog_msg, 1) != 1)
434b285192aSMauro Carvalho Chehab return -EIO;
435b285192aSMauro Carvalho Chehab return 0;
436b285192aSMauro Carvalho Chehab }
437b285192aSMauro Carvalho Chehab
438b285192aSMauro Carvalho Chehab /* ------------------------------------------------------------------ */
439b285192aSMauro Carvalho Chehab
philips_europa_tuner_init(struct dvb_frontend * fe)440b285192aSMauro Carvalho Chehab static int philips_europa_tuner_init(struct dvb_frontend *fe)
441b285192aSMauro Carvalho Chehab {
442b285192aSMauro Carvalho Chehab struct saa7134_dev *dev = fe->dvb->priv;
443b285192aSMauro Carvalho Chehab static u8 msg[] = { 0x00, 0x40};
444b285192aSMauro Carvalho Chehab struct i2c_msg init_msg = {.addr = 0x43,.flags = 0,.buf = msg,.len = sizeof(msg) };
445b285192aSMauro Carvalho Chehab
446b285192aSMauro Carvalho Chehab
447b285192aSMauro Carvalho Chehab if (philips_td1316_tuner_init(fe))
448b285192aSMauro Carvalho Chehab return -EIO;
449b285192aSMauro Carvalho Chehab msleep(1);
450b285192aSMauro Carvalho Chehab if (i2c_transfer(&dev->i2c_adap, &init_msg, 1) != 1)
451b285192aSMauro Carvalho Chehab return -EIO;
452b285192aSMauro Carvalho Chehab
453b285192aSMauro Carvalho Chehab return 0;
454b285192aSMauro Carvalho Chehab }
455b285192aSMauro Carvalho Chehab
philips_europa_tuner_sleep(struct dvb_frontend * fe)456b285192aSMauro Carvalho Chehab static int philips_europa_tuner_sleep(struct dvb_frontend *fe)
457b285192aSMauro Carvalho Chehab {
458b285192aSMauro Carvalho Chehab struct saa7134_dev *dev = fe->dvb->priv;
459b285192aSMauro Carvalho Chehab
460b285192aSMauro Carvalho Chehab static u8 msg[] = { 0x00, 0x14 };
461b285192aSMauro Carvalho Chehab struct i2c_msg analog_msg = {.addr = 0x43,.flags = 0,.buf = msg,.len = sizeof(msg) };
462b285192aSMauro Carvalho Chehab
463b285192aSMauro Carvalho Chehab if (philips_td1316_tuner_sleep(fe))
464b285192aSMauro Carvalho Chehab return -EIO;
465b285192aSMauro Carvalho Chehab
466b285192aSMauro Carvalho Chehab /* switch the board to analog mode */
467b285192aSMauro Carvalho Chehab if (fe->ops.i2c_gate_ctrl)
468b285192aSMauro Carvalho Chehab fe->ops.i2c_gate_ctrl(fe, 1);
469*6c1358bbSAleksandr Burakov if (i2c_transfer(&dev->i2c_adap, &analog_msg, 1) != 1)
470*6c1358bbSAleksandr Burakov return -EIO;
471*6c1358bbSAleksandr Burakov
472b285192aSMauro Carvalho Chehab return 0;
473b285192aSMauro Carvalho Chehab }
474b285192aSMauro Carvalho Chehab
philips_europa_demod_sleep(struct dvb_frontend * fe)475b285192aSMauro Carvalho Chehab static int philips_europa_demod_sleep(struct dvb_frontend *fe)
476b285192aSMauro Carvalho Chehab {
477b285192aSMauro Carvalho Chehab struct saa7134_dev *dev = fe->dvb->priv;
478b285192aSMauro Carvalho Chehab
479b285192aSMauro Carvalho Chehab if (dev->original_demod_sleep)
480b285192aSMauro Carvalho Chehab dev->original_demod_sleep(fe);
481b285192aSMauro Carvalho Chehab fe->ops.i2c_gate_ctrl(fe, 1);
482b285192aSMauro Carvalho Chehab return 0;
483b285192aSMauro Carvalho Chehab }
484b285192aSMauro Carvalho Chehab
485b285192aSMauro Carvalho Chehab static struct tda1004x_config philips_europa_config = {
486b285192aSMauro Carvalho Chehab
487b285192aSMauro Carvalho Chehab .demod_address = 0x8,
488b285192aSMauro Carvalho Chehab .invert = 0,
489b285192aSMauro Carvalho Chehab .invert_oclk = 0,
490b285192aSMauro Carvalho Chehab .xtal_freq = TDA10046_XTAL_4M,
491b285192aSMauro Carvalho Chehab .agc_config = TDA10046_AGC_IFO_AUTO_POS,
492b285192aSMauro Carvalho Chehab .if_freq = TDA10046_FREQ_052,
493b285192aSMauro Carvalho Chehab .tuner_address = 0x61,
494b285192aSMauro Carvalho Chehab .request_firmware = philips_tda1004x_request_firmware
495b285192aSMauro Carvalho Chehab };
496b285192aSMauro Carvalho Chehab
497b285192aSMauro Carvalho Chehab static struct tda1004x_config medion_cardbus = {
498b285192aSMauro Carvalho Chehab .demod_address = 0x08,
499b285192aSMauro Carvalho Chehab .invert = 1,
500b285192aSMauro Carvalho Chehab .invert_oclk = 0,
501b285192aSMauro Carvalho Chehab .xtal_freq = TDA10046_XTAL_16M,
502b285192aSMauro Carvalho Chehab .agc_config = TDA10046_AGC_IFO_AUTO_NEG,
503b285192aSMauro Carvalho Chehab .if_freq = TDA10046_FREQ_3613,
504b285192aSMauro Carvalho Chehab .tuner_address = 0x61,
505b285192aSMauro Carvalho Chehab .request_firmware = philips_tda1004x_request_firmware
506b285192aSMauro Carvalho Chehab };
507b285192aSMauro Carvalho Chehab
508b285192aSMauro Carvalho Chehab static struct tda1004x_config technotrend_budget_t3000_config = {
509b285192aSMauro Carvalho Chehab .demod_address = 0x8,
510b285192aSMauro Carvalho Chehab .invert = 1,
511b285192aSMauro Carvalho Chehab .invert_oclk = 0,
512b285192aSMauro Carvalho Chehab .xtal_freq = TDA10046_XTAL_4M,
513b285192aSMauro Carvalho Chehab .agc_config = TDA10046_AGC_DEFAULT,
514b285192aSMauro Carvalho Chehab .if_freq = TDA10046_FREQ_3617,
515b285192aSMauro Carvalho Chehab .tuner_address = 0x63,
516b285192aSMauro Carvalho Chehab .request_firmware = philips_tda1004x_request_firmware
517b285192aSMauro Carvalho Chehab };
518b285192aSMauro Carvalho Chehab
519b285192aSMauro Carvalho Chehab /* ------------------------------------------------------------------
520b285192aSMauro Carvalho Chehab * tda 1004x based cards with philips silicon tuner
521b285192aSMauro Carvalho Chehab */
522b285192aSMauro Carvalho Chehab
tda8290_i2c_gate_ctrl(struct dvb_frontend * fe,int enable)523b285192aSMauro Carvalho Chehab static int tda8290_i2c_gate_ctrl( struct dvb_frontend* fe, int enable)
524b285192aSMauro Carvalho Chehab {
525b285192aSMauro Carvalho Chehab struct tda1004x_state *state = fe->demodulator_priv;
526b285192aSMauro Carvalho Chehab
527b285192aSMauro Carvalho Chehab u8 addr = state->config->i2c_gate;
528b285192aSMauro Carvalho Chehab static u8 tda8290_close[] = { 0x21, 0xc0};
529b285192aSMauro Carvalho Chehab static u8 tda8290_open[] = { 0x21, 0x80};
530b285192aSMauro Carvalho Chehab struct i2c_msg tda8290_msg = {.addr = addr,.flags = 0, .len = 2};
531b285192aSMauro Carvalho Chehab if (enable) {
532b285192aSMauro Carvalho Chehab tda8290_msg.buf = tda8290_close;
533b285192aSMauro Carvalho Chehab } else {
534b285192aSMauro Carvalho Chehab tda8290_msg.buf = tda8290_open;
535b285192aSMauro Carvalho Chehab }
536b285192aSMauro Carvalho Chehab if (i2c_transfer(state->i2c, &tda8290_msg, 1) != 1) {
537ae618919SMauro Carvalho Chehab pr_warn("could not access tda8290 I2C gate\n");
538b285192aSMauro Carvalho Chehab return -EIO;
539b285192aSMauro Carvalho Chehab }
540b285192aSMauro Carvalho Chehab msleep(20);
541b285192aSMauro Carvalho Chehab return 0;
542b285192aSMauro Carvalho Chehab }
543b285192aSMauro Carvalho Chehab
philips_tda827x_tuner_init(struct dvb_frontend * fe)544b285192aSMauro Carvalho Chehab static int philips_tda827x_tuner_init(struct dvb_frontend *fe)
545b285192aSMauro Carvalho Chehab {
546b285192aSMauro Carvalho Chehab struct saa7134_dev *dev = fe->dvb->priv;
547b285192aSMauro Carvalho Chehab struct tda1004x_state *state = fe->demodulator_priv;
548b285192aSMauro Carvalho Chehab
549b285192aSMauro Carvalho Chehab switch (state->config->antenna_switch) {
5506139ebc6SMauro Carvalho Chehab case 0:
5516139ebc6SMauro Carvalho Chehab break;
5526139ebc6SMauro Carvalho Chehab case 1:
5536139ebc6SMauro Carvalho Chehab pr_debug("setting GPIO21 to 0 (TV antenna?)\n");
554b285192aSMauro Carvalho Chehab saa7134_set_gpio(dev, 21, 0);
555b285192aSMauro Carvalho Chehab break;
5566139ebc6SMauro Carvalho Chehab case 2:
5576139ebc6SMauro Carvalho Chehab pr_debug("setting GPIO21 to 1 (Radio antenna?)\n");
558b285192aSMauro Carvalho Chehab saa7134_set_gpio(dev, 21, 1);
559b285192aSMauro Carvalho Chehab break;
560b285192aSMauro Carvalho Chehab }
561b285192aSMauro Carvalho Chehab return 0;
562b285192aSMauro Carvalho Chehab }
563b285192aSMauro Carvalho Chehab
philips_tda827x_tuner_sleep(struct dvb_frontend * fe)564b285192aSMauro Carvalho Chehab static int philips_tda827x_tuner_sleep(struct dvb_frontend *fe)
565b285192aSMauro Carvalho Chehab {
566b285192aSMauro Carvalho Chehab struct saa7134_dev *dev = fe->dvb->priv;
567b285192aSMauro Carvalho Chehab struct tda1004x_state *state = fe->demodulator_priv;
568b285192aSMauro Carvalho Chehab
569b285192aSMauro Carvalho Chehab switch (state->config->antenna_switch) {
5706139ebc6SMauro Carvalho Chehab case 0:
5716139ebc6SMauro Carvalho Chehab break;
5726139ebc6SMauro Carvalho Chehab case 1:
5736139ebc6SMauro Carvalho Chehab pr_debug("setting GPIO21 to 1 (Radio antenna?)\n");
574b285192aSMauro Carvalho Chehab saa7134_set_gpio(dev, 21, 1);
575b285192aSMauro Carvalho Chehab break;
5766139ebc6SMauro Carvalho Chehab case 2:
5776139ebc6SMauro Carvalho Chehab pr_debug("setting GPIO21 to 0 (TV antenna?)\n");
578b285192aSMauro Carvalho Chehab saa7134_set_gpio(dev, 21, 0);
579b285192aSMauro Carvalho Chehab break;
580b285192aSMauro Carvalho Chehab }
581b285192aSMauro Carvalho Chehab return 0;
582b285192aSMauro Carvalho Chehab }
583b285192aSMauro Carvalho Chehab
configure_tda827x_fe(struct saa7134_dev * dev,struct tda1004x_config * cdec_conf,struct tda827x_config * tuner_conf)584b285192aSMauro Carvalho Chehab static int configure_tda827x_fe(struct saa7134_dev *dev,
585b285192aSMauro Carvalho Chehab struct tda1004x_config *cdec_conf,
586b285192aSMauro Carvalho Chehab struct tda827x_config *tuner_conf)
587b285192aSMauro Carvalho Chehab {
5882ada815fSHans Verkuil struct vb2_dvb_frontend *fe0;
589b285192aSMauro Carvalho Chehab
590b285192aSMauro Carvalho Chehab /* Get the first frontend */
5912ada815fSHans Verkuil fe0 = vb2_dvb_get_frontend(&dev->frontends, 1);
592b285192aSMauro Carvalho Chehab
59337e310edSPeter Senna Tschudin if (!fe0)
59437e310edSPeter Senna Tschudin return -EINVAL;
59537e310edSPeter Senna Tschudin
596b285192aSMauro Carvalho Chehab fe0->dvb.frontend = dvb_attach(tda10046_attach, cdec_conf, &dev->i2c_adap);
597b285192aSMauro Carvalho Chehab if (fe0->dvb.frontend) {
598b285192aSMauro Carvalho Chehab if (cdec_conf->i2c_gate)
599b285192aSMauro Carvalho Chehab fe0->dvb.frontend->ops.i2c_gate_ctrl = tda8290_i2c_gate_ctrl;
600b285192aSMauro Carvalho Chehab if (dvb_attach(tda827x_attach, fe0->dvb.frontend,
601b285192aSMauro Carvalho Chehab cdec_conf->tuner_address,
602b285192aSMauro Carvalho Chehab &dev->i2c_adap, tuner_conf))
603b285192aSMauro Carvalho Chehab return 0;
604b285192aSMauro Carvalho Chehab
605ae618919SMauro Carvalho Chehab pr_warn("no tda827x tuner found at addr: %02x\n",
606b285192aSMauro Carvalho Chehab cdec_conf->tuner_address);
607b285192aSMauro Carvalho Chehab }
608b285192aSMauro Carvalho Chehab return -EINVAL;
609b285192aSMauro Carvalho Chehab }
610b285192aSMauro Carvalho Chehab
611b285192aSMauro Carvalho Chehab /* ------------------------------------------------------------------ */
612b285192aSMauro Carvalho Chehab
613b285192aSMauro Carvalho Chehab static struct tda827x_config tda827x_cfg_0 = {
614b285192aSMauro Carvalho Chehab .init = philips_tda827x_tuner_init,
615b285192aSMauro Carvalho Chehab .sleep = philips_tda827x_tuner_sleep,
616b285192aSMauro Carvalho Chehab .config = 0,
617b285192aSMauro Carvalho Chehab .switch_addr = 0
618b285192aSMauro Carvalho Chehab };
619b285192aSMauro Carvalho Chehab
620b285192aSMauro Carvalho Chehab static struct tda827x_config tda827x_cfg_1 = {
621b285192aSMauro Carvalho Chehab .init = philips_tda827x_tuner_init,
622b285192aSMauro Carvalho Chehab .sleep = philips_tda827x_tuner_sleep,
623b285192aSMauro Carvalho Chehab .config = 1,
624b285192aSMauro Carvalho Chehab .switch_addr = 0x4b
625b285192aSMauro Carvalho Chehab };
626b285192aSMauro Carvalho Chehab
627b285192aSMauro Carvalho Chehab static struct tda827x_config tda827x_cfg_2 = {
628b285192aSMauro Carvalho Chehab .init = philips_tda827x_tuner_init,
629b285192aSMauro Carvalho Chehab .sleep = philips_tda827x_tuner_sleep,
630b285192aSMauro Carvalho Chehab .config = 2,
631b285192aSMauro Carvalho Chehab .switch_addr = 0x4b
632b285192aSMauro Carvalho Chehab };
633b285192aSMauro Carvalho Chehab
634b285192aSMauro Carvalho Chehab static struct tda827x_config tda827x_cfg_2_sw42 = {
635b285192aSMauro Carvalho Chehab .init = philips_tda827x_tuner_init,
636b285192aSMauro Carvalho Chehab .sleep = philips_tda827x_tuner_sleep,
637b285192aSMauro Carvalho Chehab .config = 2,
638b285192aSMauro Carvalho Chehab .switch_addr = 0x42
639b285192aSMauro Carvalho Chehab };
640b285192aSMauro Carvalho Chehab
641b285192aSMauro Carvalho Chehab /* ------------------------------------------------------------------ */
642b285192aSMauro Carvalho Chehab
643b285192aSMauro Carvalho Chehab static struct tda1004x_config tda827x_lifeview_config = {
644b285192aSMauro Carvalho Chehab .demod_address = 0x08,
645b285192aSMauro Carvalho Chehab .invert = 1,
646b285192aSMauro Carvalho Chehab .invert_oclk = 0,
647b285192aSMauro Carvalho Chehab .xtal_freq = TDA10046_XTAL_16M,
648b285192aSMauro Carvalho Chehab .agc_config = TDA10046_AGC_TDA827X,
649b285192aSMauro Carvalho Chehab .gpio_config = TDA10046_GP11_I,
650b285192aSMauro Carvalho Chehab .if_freq = TDA10046_FREQ_045,
651b285192aSMauro Carvalho Chehab .tuner_address = 0x60,
652b285192aSMauro Carvalho Chehab .request_firmware = philips_tda1004x_request_firmware
653b285192aSMauro Carvalho Chehab };
654b285192aSMauro Carvalho Chehab
655b285192aSMauro Carvalho Chehab static struct tda1004x_config philips_tiger_config = {
656b285192aSMauro Carvalho Chehab .demod_address = 0x08,
657b285192aSMauro Carvalho Chehab .invert = 1,
658b285192aSMauro Carvalho Chehab .invert_oclk = 0,
659b285192aSMauro Carvalho Chehab .xtal_freq = TDA10046_XTAL_16M,
660b285192aSMauro Carvalho Chehab .agc_config = TDA10046_AGC_TDA827X,
661b285192aSMauro Carvalho Chehab .gpio_config = TDA10046_GP11_I,
662b285192aSMauro Carvalho Chehab .if_freq = TDA10046_FREQ_045,
663b285192aSMauro Carvalho Chehab .i2c_gate = 0x4b,
664b285192aSMauro Carvalho Chehab .tuner_address = 0x61,
665b285192aSMauro Carvalho Chehab .antenna_switch= 1,
666b285192aSMauro Carvalho Chehab .request_firmware = philips_tda1004x_request_firmware
667b285192aSMauro Carvalho Chehab };
668b285192aSMauro Carvalho Chehab
669b285192aSMauro Carvalho Chehab static struct tda1004x_config cinergy_ht_config = {
670b285192aSMauro Carvalho Chehab .demod_address = 0x08,
671b285192aSMauro Carvalho Chehab .invert = 1,
672b285192aSMauro Carvalho Chehab .invert_oclk = 0,
673b285192aSMauro Carvalho Chehab .xtal_freq = TDA10046_XTAL_16M,
674b285192aSMauro Carvalho Chehab .agc_config = TDA10046_AGC_TDA827X,
675b285192aSMauro Carvalho Chehab .gpio_config = TDA10046_GP01_I,
676b285192aSMauro Carvalho Chehab .if_freq = TDA10046_FREQ_045,
677b285192aSMauro Carvalho Chehab .i2c_gate = 0x4b,
678b285192aSMauro Carvalho Chehab .tuner_address = 0x61,
679b285192aSMauro Carvalho Chehab .request_firmware = philips_tda1004x_request_firmware
680b285192aSMauro Carvalho Chehab };
681b285192aSMauro Carvalho Chehab
682b285192aSMauro Carvalho Chehab static struct tda1004x_config cinergy_ht_pci_config = {
683b285192aSMauro Carvalho Chehab .demod_address = 0x08,
684b285192aSMauro Carvalho Chehab .invert = 1,
685b285192aSMauro Carvalho Chehab .invert_oclk = 0,
686b285192aSMauro Carvalho Chehab .xtal_freq = TDA10046_XTAL_16M,
687b285192aSMauro Carvalho Chehab .agc_config = TDA10046_AGC_TDA827X,
688b285192aSMauro Carvalho Chehab .gpio_config = TDA10046_GP01_I,
689b285192aSMauro Carvalho Chehab .if_freq = TDA10046_FREQ_045,
690b285192aSMauro Carvalho Chehab .i2c_gate = 0x4b,
691b285192aSMauro Carvalho Chehab .tuner_address = 0x60,
692b285192aSMauro Carvalho Chehab .request_firmware = philips_tda1004x_request_firmware
693b285192aSMauro Carvalho Chehab };
694b285192aSMauro Carvalho Chehab
695b285192aSMauro Carvalho Chehab static struct tda1004x_config philips_tiger_s_config = {
696b285192aSMauro Carvalho Chehab .demod_address = 0x08,
697b285192aSMauro Carvalho Chehab .invert = 1,
698b285192aSMauro Carvalho Chehab .invert_oclk = 0,
699b285192aSMauro Carvalho Chehab .xtal_freq = TDA10046_XTAL_16M,
700b285192aSMauro Carvalho Chehab .agc_config = TDA10046_AGC_TDA827X,
701b285192aSMauro Carvalho Chehab .gpio_config = TDA10046_GP01_I,
702b285192aSMauro Carvalho Chehab .if_freq = TDA10046_FREQ_045,
703b285192aSMauro Carvalho Chehab .i2c_gate = 0x4b,
704b285192aSMauro Carvalho Chehab .tuner_address = 0x61,
705b285192aSMauro Carvalho Chehab .antenna_switch= 1,
706b285192aSMauro Carvalho Chehab .request_firmware = philips_tda1004x_request_firmware
707b285192aSMauro Carvalho Chehab };
708b285192aSMauro Carvalho Chehab
709b285192aSMauro Carvalho Chehab static struct tda1004x_config pinnacle_pctv_310i_config = {
710b285192aSMauro Carvalho Chehab .demod_address = 0x08,
711b285192aSMauro Carvalho Chehab .invert = 1,
712b285192aSMauro Carvalho Chehab .invert_oclk = 0,
713b285192aSMauro Carvalho Chehab .xtal_freq = TDA10046_XTAL_16M,
714b285192aSMauro Carvalho Chehab .agc_config = TDA10046_AGC_TDA827X,
715b285192aSMauro Carvalho Chehab .gpio_config = TDA10046_GP11_I,
716b285192aSMauro Carvalho Chehab .if_freq = TDA10046_FREQ_045,
717b285192aSMauro Carvalho Chehab .i2c_gate = 0x4b,
718b285192aSMauro Carvalho Chehab .tuner_address = 0x61,
719b285192aSMauro Carvalho Chehab .request_firmware = philips_tda1004x_request_firmware
720b285192aSMauro Carvalho Chehab };
721b285192aSMauro Carvalho Chehab
722b285192aSMauro Carvalho Chehab static struct tda1004x_config hauppauge_hvr_1110_config = {
723b285192aSMauro Carvalho Chehab .demod_address = 0x08,
724b285192aSMauro Carvalho Chehab .invert = 1,
725b285192aSMauro Carvalho Chehab .invert_oclk = 0,
726b285192aSMauro Carvalho Chehab .xtal_freq = TDA10046_XTAL_16M,
727b285192aSMauro Carvalho Chehab .agc_config = TDA10046_AGC_TDA827X,
728b285192aSMauro Carvalho Chehab .gpio_config = TDA10046_GP11_I,
729b285192aSMauro Carvalho Chehab .if_freq = TDA10046_FREQ_045,
730b285192aSMauro Carvalho Chehab .i2c_gate = 0x4b,
731b285192aSMauro Carvalho Chehab .tuner_address = 0x61,
732b285192aSMauro Carvalho Chehab .request_firmware = philips_tda1004x_request_firmware
733b285192aSMauro Carvalho Chehab };
734b285192aSMauro Carvalho Chehab
735b285192aSMauro Carvalho Chehab static struct tda1004x_config asus_p7131_dual_config = {
736b285192aSMauro Carvalho Chehab .demod_address = 0x08,
737b285192aSMauro Carvalho Chehab .invert = 1,
738b285192aSMauro Carvalho Chehab .invert_oclk = 0,
739b285192aSMauro Carvalho Chehab .xtal_freq = TDA10046_XTAL_16M,
740b285192aSMauro Carvalho Chehab .agc_config = TDA10046_AGC_TDA827X,
741b285192aSMauro Carvalho Chehab .gpio_config = TDA10046_GP11_I,
742b285192aSMauro Carvalho Chehab .if_freq = TDA10046_FREQ_045,
743b285192aSMauro Carvalho Chehab .i2c_gate = 0x4b,
744b285192aSMauro Carvalho Chehab .tuner_address = 0x61,
745b285192aSMauro Carvalho Chehab .antenna_switch= 2,
746b285192aSMauro Carvalho Chehab .request_firmware = philips_tda1004x_request_firmware
747b285192aSMauro Carvalho Chehab };
748b285192aSMauro Carvalho Chehab
749b285192aSMauro Carvalho Chehab static struct tda1004x_config lifeview_trio_config = {
750b285192aSMauro Carvalho Chehab .demod_address = 0x09,
751b285192aSMauro Carvalho Chehab .invert = 1,
752b285192aSMauro Carvalho Chehab .invert_oclk = 0,
753b285192aSMauro Carvalho Chehab .xtal_freq = TDA10046_XTAL_16M,
754b285192aSMauro Carvalho Chehab .agc_config = TDA10046_AGC_TDA827X,
755b285192aSMauro Carvalho Chehab .gpio_config = TDA10046_GP00_I,
756b285192aSMauro Carvalho Chehab .if_freq = TDA10046_FREQ_045,
757b285192aSMauro Carvalho Chehab .tuner_address = 0x60,
758b285192aSMauro Carvalho Chehab .request_firmware = philips_tda1004x_request_firmware
759b285192aSMauro Carvalho Chehab };
760b285192aSMauro Carvalho Chehab
761b285192aSMauro Carvalho Chehab static struct tda1004x_config tevion_dvbt220rf_config = {
762b285192aSMauro Carvalho Chehab .demod_address = 0x08,
763b285192aSMauro Carvalho Chehab .invert = 1,
764b285192aSMauro Carvalho Chehab .invert_oclk = 0,
765b285192aSMauro Carvalho Chehab .xtal_freq = TDA10046_XTAL_16M,
766b285192aSMauro Carvalho Chehab .agc_config = TDA10046_AGC_TDA827X,
767b285192aSMauro Carvalho Chehab .gpio_config = TDA10046_GP11_I,
768b285192aSMauro Carvalho Chehab .if_freq = TDA10046_FREQ_045,
769b285192aSMauro Carvalho Chehab .tuner_address = 0x60,
770b285192aSMauro Carvalho Chehab .request_firmware = philips_tda1004x_request_firmware
771b285192aSMauro Carvalho Chehab };
772b285192aSMauro Carvalho Chehab
773b285192aSMauro Carvalho Chehab static struct tda1004x_config md8800_dvbt_config = {
774b285192aSMauro Carvalho Chehab .demod_address = 0x08,
775b285192aSMauro Carvalho Chehab .invert = 1,
776b285192aSMauro Carvalho Chehab .invert_oclk = 0,
777b285192aSMauro Carvalho Chehab .xtal_freq = TDA10046_XTAL_16M,
778b285192aSMauro Carvalho Chehab .agc_config = TDA10046_AGC_TDA827X,
779b285192aSMauro Carvalho Chehab .gpio_config = TDA10046_GP01_I,
780b285192aSMauro Carvalho Chehab .if_freq = TDA10046_FREQ_045,
781b285192aSMauro Carvalho Chehab .i2c_gate = 0x4b,
782b285192aSMauro Carvalho Chehab .tuner_address = 0x60,
783b285192aSMauro Carvalho Chehab .request_firmware = philips_tda1004x_request_firmware
784b285192aSMauro Carvalho Chehab };
785b285192aSMauro Carvalho Chehab
786b285192aSMauro Carvalho Chehab static struct tda1004x_config asus_p7131_4871_config = {
787b285192aSMauro Carvalho Chehab .demod_address = 0x08,
788b285192aSMauro Carvalho Chehab .invert = 1,
789b285192aSMauro Carvalho Chehab .invert_oclk = 0,
790b285192aSMauro Carvalho Chehab .xtal_freq = TDA10046_XTAL_16M,
791b285192aSMauro Carvalho Chehab .agc_config = TDA10046_AGC_TDA827X,
792b285192aSMauro Carvalho Chehab .gpio_config = TDA10046_GP01_I,
793b285192aSMauro Carvalho Chehab .if_freq = TDA10046_FREQ_045,
794b285192aSMauro Carvalho Chehab .i2c_gate = 0x4b,
795b285192aSMauro Carvalho Chehab .tuner_address = 0x61,
796b285192aSMauro Carvalho Chehab .antenna_switch= 2,
797b285192aSMauro Carvalho Chehab .request_firmware = philips_tda1004x_request_firmware
798b285192aSMauro Carvalho Chehab };
799b285192aSMauro Carvalho Chehab
800b285192aSMauro Carvalho Chehab static struct tda1004x_config asus_p7131_hybrid_lna_config = {
801b285192aSMauro Carvalho Chehab .demod_address = 0x08,
802b285192aSMauro Carvalho Chehab .invert = 1,
803b285192aSMauro Carvalho Chehab .invert_oclk = 0,
804b285192aSMauro Carvalho Chehab .xtal_freq = TDA10046_XTAL_16M,
805b285192aSMauro Carvalho Chehab .agc_config = TDA10046_AGC_TDA827X,
806b285192aSMauro Carvalho Chehab .gpio_config = TDA10046_GP11_I,
807b285192aSMauro Carvalho Chehab .if_freq = TDA10046_FREQ_045,
808b285192aSMauro Carvalho Chehab .i2c_gate = 0x4b,
809b285192aSMauro Carvalho Chehab .tuner_address = 0x61,
810b285192aSMauro Carvalho Chehab .antenna_switch= 2,
811b285192aSMauro Carvalho Chehab .request_firmware = philips_tda1004x_request_firmware
812b285192aSMauro Carvalho Chehab };
813b285192aSMauro Carvalho Chehab
814b285192aSMauro Carvalho Chehab static struct tda1004x_config kworld_dvb_t_210_config = {
815b285192aSMauro Carvalho Chehab .demod_address = 0x08,
816b285192aSMauro Carvalho Chehab .invert = 1,
817b285192aSMauro Carvalho Chehab .invert_oclk = 0,
818b285192aSMauro Carvalho Chehab .xtal_freq = TDA10046_XTAL_16M,
819b285192aSMauro Carvalho Chehab .agc_config = TDA10046_AGC_TDA827X,
820b285192aSMauro Carvalho Chehab .gpio_config = TDA10046_GP11_I,
821b285192aSMauro Carvalho Chehab .if_freq = TDA10046_FREQ_045,
822b285192aSMauro Carvalho Chehab .i2c_gate = 0x4b,
823b285192aSMauro Carvalho Chehab .tuner_address = 0x61,
824b285192aSMauro Carvalho Chehab .antenna_switch= 1,
825b285192aSMauro Carvalho Chehab .request_firmware = philips_tda1004x_request_firmware
826b285192aSMauro Carvalho Chehab };
827b285192aSMauro Carvalho Chehab
828b285192aSMauro Carvalho Chehab static struct tda1004x_config avermedia_super_007_config = {
829b285192aSMauro Carvalho Chehab .demod_address = 0x08,
830b285192aSMauro Carvalho Chehab .invert = 1,
831b285192aSMauro Carvalho Chehab .invert_oclk = 0,
832b285192aSMauro Carvalho Chehab .xtal_freq = TDA10046_XTAL_16M,
833b285192aSMauro Carvalho Chehab .agc_config = TDA10046_AGC_TDA827X,
834b285192aSMauro Carvalho Chehab .gpio_config = TDA10046_GP01_I,
835b285192aSMauro Carvalho Chehab .if_freq = TDA10046_FREQ_045,
836b285192aSMauro Carvalho Chehab .i2c_gate = 0x4b,
837b285192aSMauro Carvalho Chehab .tuner_address = 0x60,
838b285192aSMauro Carvalho Chehab .antenna_switch= 1,
839b285192aSMauro Carvalho Chehab .request_firmware = philips_tda1004x_request_firmware
840b285192aSMauro Carvalho Chehab };
841b285192aSMauro Carvalho Chehab
842b285192aSMauro Carvalho Chehab static struct tda1004x_config twinhan_dtv_dvb_3056_config = {
843b285192aSMauro Carvalho Chehab .demod_address = 0x08,
844b285192aSMauro Carvalho Chehab .invert = 1,
845b285192aSMauro Carvalho Chehab .invert_oclk = 0,
846b285192aSMauro Carvalho Chehab .xtal_freq = TDA10046_XTAL_16M,
847b285192aSMauro Carvalho Chehab .agc_config = TDA10046_AGC_TDA827X,
848b285192aSMauro Carvalho Chehab .gpio_config = TDA10046_GP01_I,
849b285192aSMauro Carvalho Chehab .if_freq = TDA10046_FREQ_045,
850b285192aSMauro Carvalho Chehab .i2c_gate = 0x42,
851b285192aSMauro Carvalho Chehab .tuner_address = 0x61,
852b285192aSMauro Carvalho Chehab .antenna_switch = 1,
853b285192aSMauro Carvalho Chehab .request_firmware = philips_tda1004x_request_firmware
854b285192aSMauro Carvalho Chehab };
855b285192aSMauro Carvalho Chehab
856b285192aSMauro Carvalho Chehab static struct tda1004x_config asus_tiger_3in1_config = {
857b285192aSMauro Carvalho Chehab .demod_address = 0x0b,
858b285192aSMauro Carvalho Chehab .invert = 1,
859b285192aSMauro Carvalho Chehab .invert_oclk = 0,
860b285192aSMauro Carvalho Chehab .xtal_freq = TDA10046_XTAL_16M,
861b285192aSMauro Carvalho Chehab .agc_config = TDA10046_AGC_TDA827X,
862b285192aSMauro Carvalho Chehab .gpio_config = TDA10046_GP11_I,
863b285192aSMauro Carvalho Chehab .if_freq = TDA10046_FREQ_045,
864b285192aSMauro Carvalho Chehab .i2c_gate = 0x4b,
865b285192aSMauro Carvalho Chehab .tuner_address = 0x61,
866b285192aSMauro Carvalho Chehab .antenna_switch = 1,
867b285192aSMauro Carvalho Chehab .request_firmware = philips_tda1004x_request_firmware
868b285192aSMauro Carvalho Chehab };
869b285192aSMauro Carvalho Chehab
870b285192aSMauro Carvalho Chehab static struct tda1004x_config asus_ps3_100_config = {
871b285192aSMauro Carvalho Chehab .demod_address = 0x0b,
872b285192aSMauro Carvalho Chehab .invert = 1,
873b285192aSMauro Carvalho Chehab .invert_oclk = 0,
874b285192aSMauro Carvalho Chehab .xtal_freq = TDA10046_XTAL_16M,
875b285192aSMauro Carvalho Chehab .agc_config = TDA10046_AGC_TDA827X,
876b285192aSMauro Carvalho Chehab .gpio_config = TDA10046_GP11_I,
877b285192aSMauro Carvalho Chehab .if_freq = TDA10046_FREQ_045,
878b285192aSMauro Carvalho Chehab .i2c_gate = 0x4b,
879b285192aSMauro Carvalho Chehab .tuner_address = 0x61,
880b285192aSMauro Carvalho Chehab .antenna_switch = 1,
881b285192aSMauro Carvalho Chehab .request_firmware = philips_tda1004x_request_firmware
882b285192aSMauro Carvalho Chehab };
883b285192aSMauro Carvalho Chehab
884b285192aSMauro Carvalho Chehab /* ------------------------------------------------------------------
885b285192aSMauro Carvalho Chehab * special case: this card uses saa713x GPIO22 for the mode switch
886b285192aSMauro Carvalho Chehab */
887b285192aSMauro Carvalho Chehab
ads_duo_tuner_init(struct dvb_frontend * fe)888b285192aSMauro Carvalho Chehab static int ads_duo_tuner_init(struct dvb_frontend *fe)
889b285192aSMauro Carvalho Chehab {
890b285192aSMauro Carvalho Chehab struct saa7134_dev *dev = fe->dvb->priv;
891b285192aSMauro Carvalho Chehab philips_tda827x_tuner_init(fe);
892b285192aSMauro Carvalho Chehab /* route TDA8275a AGC input to the channel decoder */
893b285192aSMauro Carvalho Chehab saa7134_set_gpio(dev, 22, 1);
894b285192aSMauro Carvalho Chehab return 0;
895b285192aSMauro Carvalho Chehab }
896b285192aSMauro Carvalho Chehab
ads_duo_tuner_sleep(struct dvb_frontend * fe)897b285192aSMauro Carvalho Chehab static int ads_duo_tuner_sleep(struct dvb_frontend *fe)
898b285192aSMauro Carvalho Chehab {
899b285192aSMauro Carvalho Chehab struct saa7134_dev *dev = fe->dvb->priv;
900b285192aSMauro Carvalho Chehab /* route TDA8275a AGC input to the analog IF chip*/
901b285192aSMauro Carvalho Chehab saa7134_set_gpio(dev, 22, 0);
902b285192aSMauro Carvalho Chehab philips_tda827x_tuner_sleep(fe);
903b285192aSMauro Carvalho Chehab return 0;
904b285192aSMauro Carvalho Chehab }
905b285192aSMauro Carvalho Chehab
906b285192aSMauro Carvalho Chehab static struct tda827x_config ads_duo_cfg = {
907b285192aSMauro Carvalho Chehab .init = ads_duo_tuner_init,
908b285192aSMauro Carvalho Chehab .sleep = ads_duo_tuner_sleep,
909b285192aSMauro Carvalho Chehab .config = 0
910b285192aSMauro Carvalho Chehab };
911b285192aSMauro Carvalho Chehab
912b285192aSMauro Carvalho Chehab static struct tda1004x_config ads_tech_duo_config = {
913b285192aSMauro Carvalho Chehab .demod_address = 0x08,
914b285192aSMauro Carvalho Chehab .invert = 1,
915b285192aSMauro Carvalho Chehab .invert_oclk = 0,
916b285192aSMauro Carvalho Chehab .xtal_freq = TDA10046_XTAL_16M,
917b285192aSMauro Carvalho Chehab .agc_config = TDA10046_AGC_TDA827X,
918b285192aSMauro Carvalho Chehab .gpio_config = TDA10046_GP00_I,
919b285192aSMauro Carvalho Chehab .if_freq = TDA10046_FREQ_045,
920b285192aSMauro Carvalho Chehab .tuner_address = 0x61,
921b285192aSMauro Carvalho Chehab .request_firmware = philips_tda1004x_request_firmware
922b285192aSMauro Carvalho Chehab };
923b285192aSMauro Carvalho Chehab
924b285192aSMauro Carvalho Chehab static struct zl10353_config behold_h6_config = {
925b285192aSMauro Carvalho Chehab .demod_address = 0x1e>>1,
926b285192aSMauro Carvalho Chehab .no_tuner = 1,
927b285192aSMauro Carvalho Chehab .parallel_ts = 1,
928b285192aSMauro Carvalho Chehab .disable_i2c_gate_ctrl = 1,
929b285192aSMauro Carvalho Chehab };
930b285192aSMauro Carvalho Chehab
931b285192aSMauro Carvalho Chehab static struct xc5000_config behold_x7_tunerconfig = {
932b285192aSMauro Carvalho Chehab .i2c_address = 0xc2>>1,
933b285192aSMauro Carvalho Chehab .if_khz = 4560,
934b285192aSMauro Carvalho Chehab .radio_input = XC5000_RADIO_FM1,
935b285192aSMauro Carvalho Chehab };
936b285192aSMauro Carvalho Chehab
937b285192aSMauro Carvalho Chehab static struct zl10353_config behold_x7_config = {
938b285192aSMauro Carvalho Chehab .demod_address = 0x1e>>1,
939b285192aSMauro Carvalho Chehab .if2 = 45600,
940b285192aSMauro Carvalho Chehab .no_tuner = 1,
941b285192aSMauro Carvalho Chehab .parallel_ts = 1,
942b285192aSMauro Carvalho Chehab .disable_i2c_gate_ctrl = 1,
943b285192aSMauro Carvalho Chehab };
944b285192aSMauro Carvalho Chehab
945b285192aSMauro Carvalho Chehab static struct zl10353_config videomate_t750_zl10353_config = {
946b285192aSMauro Carvalho Chehab .demod_address = 0x0f,
947b285192aSMauro Carvalho Chehab .no_tuner = 1,
948b285192aSMauro Carvalho Chehab .parallel_ts = 1,
949b285192aSMauro Carvalho Chehab .disable_i2c_gate_ctrl = 1,
950b285192aSMauro Carvalho Chehab };
951b285192aSMauro Carvalho Chehab
952b285192aSMauro Carvalho Chehab static struct qt1010_config videomate_t750_qt1010_config = {
953b285192aSMauro Carvalho Chehab .i2c_address = 0x62
954b285192aSMauro Carvalho Chehab };
955b285192aSMauro Carvalho Chehab
956b285192aSMauro Carvalho Chehab
957b285192aSMauro Carvalho Chehab /* ==================================================================
958b285192aSMauro Carvalho Chehab * tda10086 based DVB-S cards, helper functions
959b285192aSMauro Carvalho Chehab */
960b285192aSMauro Carvalho Chehab
961b285192aSMauro Carvalho Chehab static struct tda10086_config flydvbs = {
962b285192aSMauro Carvalho Chehab .demod_address = 0x0e,
963b285192aSMauro Carvalho Chehab .invert = 0,
964b285192aSMauro Carvalho Chehab .diseqc_tone = 0,
965b285192aSMauro Carvalho Chehab .xtal_freq = TDA10086_XTAL_16M,
966b285192aSMauro Carvalho Chehab };
967b285192aSMauro Carvalho Chehab
968b285192aSMauro Carvalho Chehab static struct tda10086_config sd1878_4m = {
969b285192aSMauro Carvalho Chehab .demod_address = 0x0e,
970b285192aSMauro Carvalho Chehab .invert = 0,
971b285192aSMauro Carvalho Chehab .diseqc_tone = 0,
972b285192aSMauro Carvalho Chehab .xtal_freq = TDA10086_XTAL_4M,
973b285192aSMauro Carvalho Chehab };
974b285192aSMauro Carvalho Chehab
975b285192aSMauro Carvalho Chehab /* ------------------------------------------------------------------
976b285192aSMauro Carvalho Chehab * special case: lnb supply is connected to the gated i2c
977b285192aSMauro Carvalho Chehab */
978b285192aSMauro Carvalho Chehab
md8800_set_voltage(struct dvb_frontend * fe,enum fe_sec_voltage voltage)9790df289a2SMauro Carvalho Chehab static int md8800_set_voltage(struct dvb_frontend *fe,
9800df289a2SMauro Carvalho Chehab enum fe_sec_voltage voltage)
981b285192aSMauro Carvalho Chehab {
982b285192aSMauro Carvalho Chehab int res = -EIO;
983b285192aSMauro Carvalho Chehab struct saa7134_dev *dev = fe->dvb->priv;
984b285192aSMauro Carvalho Chehab if (fe->ops.i2c_gate_ctrl) {
985b285192aSMauro Carvalho Chehab fe->ops.i2c_gate_ctrl(fe, 1);
986b285192aSMauro Carvalho Chehab if (dev->original_set_voltage)
987b285192aSMauro Carvalho Chehab res = dev->original_set_voltage(fe, voltage);
988b285192aSMauro Carvalho Chehab fe->ops.i2c_gate_ctrl(fe, 0);
989b285192aSMauro Carvalho Chehab }
990b285192aSMauro Carvalho Chehab return res;
991b285192aSMauro Carvalho Chehab };
992b285192aSMauro Carvalho Chehab
md8800_set_high_voltage(struct dvb_frontend * fe,long arg)993b285192aSMauro Carvalho Chehab static int md8800_set_high_voltage(struct dvb_frontend *fe, long arg)
994b285192aSMauro Carvalho Chehab {
995b285192aSMauro Carvalho Chehab int res = -EIO;
996b285192aSMauro Carvalho Chehab struct saa7134_dev *dev = fe->dvb->priv;
997b285192aSMauro Carvalho Chehab if (fe->ops.i2c_gate_ctrl) {
998b285192aSMauro Carvalho Chehab fe->ops.i2c_gate_ctrl(fe, 1);
999b285192aSMauro Carvalho Chehab if (dev->original_set_high_voltage)
1000b285192aSMauro Carvalho Chehab res = dev->original_set_high_voltage(fe, arg);
1001b285192aSMauro Carvalho Chehab fe->ops.i2c_gate_ctrl(fe, 0);
1002b285192aSMauro Carvalho Chehab }
1003b285192aSMauro Carvalho Chehab return res;
1004b285192aSMauro Carvalho Chehab };
1005b285192aSMauro Carvalho Chehab
md8800_set_voltage2(struct dvb_frontend * fe,enum fe_sec_voltage voltage)10060df289a2SMauro Carvalho Chehab static int md8800_set_voltage2(struct dvb_frontend *fe,
10070df289a2SMauro Carvalho Chehab enum fe_sec_voltage voltage)
1008b285192aSMauro Carvalho Chehab {
1009b285192aSMauro Carvalho Chehab struct saa7134_dev *dev = fe->dvb->priv;
1010b285192aSMauro Carvalho Chehab u8 wbuf[2] = { 0x1f, 00 };
1011b285192aSMauro Carvalho Chehab u8 rbuf;
1012b285192aSMauro Carvalho Chehab struct i2c_msg msg[] = { { .addr = 0x08, .flags = 0, .buf = wbuf, .len = 1 },
1013b285192aSMauro Carvalho Chehab { .addr = 0x08, .flags = I2C_M_RD, .buf = &rbuf, .len = 1 } };
1014b285192aSMauro Carvalho Chehab
1015b285192aSMauro Carvalho Chehab if (i2c_transfer(&dev->i2c_adap, msg, 2) != 2)
1016b285192aSMauro Carvalho Chehab return -EIO;
1017b285192aSMauro Carvalho Chehab /* NOTE: this assumes that gpo1 is used, it might be bit 5 (gpo2) */
1018b285192aSMauro Carvalho Chehab if (voltage == SEC_VOLTAGE_18)
1019b285192aSMauro Carvalho Chehab wbuf[1] = rbuf | 0x10;
1020b285192aSMauro Carvalho Chehab else
1021b285192aSMauro Carvalho Chehab wbuf[1] = rbuf & 0xef;
1022b285192aSMauro Carvalho Chehab msg[0].len = 2;
1023*6c1358bbSAleksandr Burakov if (i2c_transfer(&dev->i2c_adap, msg, 1) != 1)
1024*6c1358bbSAleksandr Burakov return -EIO;
1025*6c1358bbSAleksandr Burakov
1026b285192aSMauro Carvalho Chehab return 0;
1027b285192aSMauro Carvalho Chehab }
1028b285192aSMauro Carvalho Chehab
md8800_set_high_voltage2(struct dvb_frontend * fe,long arg)1029b285192aSMauro Carvalho Chehab static int md8800_set_high_voltage2(struct dvb_frontend *fe, long arg)
1030b285192aSMauro Carvalho Chehab {
10316139ebc6SMauro Carvalho Chehab pr_warn("%s: sorry can't set high LNB supply voltage from here\n",
10326139ebc6SMauro Carvalho Chehab __func__);
1033b285192aSMauro Carvalho Chehab return -EIO;
1034b285192aSMauro Carvalho Chehab }
1035b285192aSMauro Carvalho Chehab
1036b285192aSMauro Carvalho Chehab /* ==================================================================
1037b285192aSMauro Carvalho Chehab * nxt200x based ATSC cards, helper functions
1038b285192aSMauro Carvalho Chehab */
1039b285192aSMauro Carvalho Chehab
1040f5584613SBhumika Goyal static const struct nxt200x_config avertvhda180 = {
1041b285192aSMauro Carvalho Chehab .demod_address = 0x0a,
1042b285192aSMauro Carvalho Chehab };
1043b285192aSMauro Carvalho Chehab
1044f5584613SBhumika Goyal static const struct nxt200x_config kworldatsc110 = {
1045b285192aSMauro Carvalho Chehab .demod_address = 0x0a,
1046b285192aSMauro Carvalho Chehab };
1047b285192aSMauro Carvalho Chehab
1048b285192aSMauro Carvalho Chehab /* ------------------------------------------------------------------ */
1049b285192aSMauro Carvalho Chehab
1050b285192aSMauro Carvalho Chehab static struct mt312_config avertv_a700_mt312 = {
1051b285192aSMauro Carvalho Chehab .demod_address = 0x0e,
1052b285192aSMauro Carvalho Chehab .voltage_inverted = 1,
1053b285192aSMauro Carvalho Chehab };
1054b285192aSMauro Carvalho Chehab
1055b285192aSMauro Carvalho Chehab static struct zl10036_config avertv_a700_tuner = {
1056b285192aSMauro Carvalho Chehab .tuner_address = 0x60,
1057b285192aSMauro Carvalho Chehab };
1058b285192aSMauro Carvalho Chehab
1059b285192aSMauro Carvalho Chehab static struct mt312_config zl10313_compro_s350_config = {
1060b285192aSMauro Carvalho Chehab .demod_address = 0x0e,
1061b285192aSMauro Carvalho Chehab };
1062b285192aSMauro Carvalho Chehab
106334fe2784SOndrej Zary static struct mt312_config zl10313_avermedia_a706_config = {
106434fe2784SOndrej Zary .demod_address = 0x0e,
106534fe2784SOndrej Zary };
106634fe2784SOndrej Zary
1067b285192aSMauro Carvalho Chehab static struct lgdt3305_config hcw_lgdt3305_config = {
1068b285192aSMauro Carvalho Chehab .i2c_addr = 0x0e,
1069b285192aSMauro Carvalho Chehab .mpeg_mode = LGDT3305_MPEG_SERIAL,
1070b285192aSMauro Carvalho Chehab .tpclk_edge = LGDT3305_TPCLK_RISING_EDGE,
1071b285192aSMauro Carvalho Chehab .tpvalid_polarity = LGDT3305_TP_VALID_HIGH,
1072b285192aSMauro Carvalho Chehab .deny_i2c_rptr = 1,
1073b285192aSMauro Carvalho Chehab .spectral_inversion = 1,
1074b285192aSMauro Carvalho Chehab .qam_if_khz = 4000,
1075b285192aSMauro Carvalho Chehab .vsb_if_khz = 3250,
1076b285192aSMauro Carvalho Chehab };
1077b285192aSMauro Carvalho Chehab
1078b285192aSMauro Carvalho Chehab static struct tda10048_config hcw_tda10048_config = {
1079b285192aSMauro Carvalho Chehab .demod_address = 0x10 >> 1,
1080b285192aSMauro Carvalho Chehab .output_mode = TDA10048_SERIAL_OUTPUT,
1081b285192aSMauro Carvalho Chehab .fwbulkwritelen = TDA10048_BULKWRITE_200,
1082b285192aSMauro Carvalho Chehab .inversion = TDA10048_INVERSION_ON,
1083b285192aSMauro Carvalho Chehab .dtv6_if_freq_khz = TDA10048_IF_3300,
1084b285192aSMauro Carvalho Chehab .dtv7_if_freq_khz = TDA10048_IF_3500,
1085b285192aSMauro Carvalho Chehab .dtv8_if_freq_khz = TDA10048_IF_4000,
1086b285192aSMauro Carvalho Chehab .clk_freq_khz = TDA10048_CLK_16000,
1087b285192aSMauro Carvalho Chehab .disable_gate_access = 1,
1088b285192aSMauro Carvalho Chehab };
1089b285192aSMauro Carvalho Chehab
1090b285192aSMauro Carvalho Chehab static struct tda18271_std_map hauppauge_tda18271_std_map = {
1091b285192aSMauro Carvalho Chehab .atsc_6 = { .if_freq = 3250, .agc_mode = 3, .std = 4,
1092b285192aSMauro Carvalho Chehab .if_lvl = 1, .rfagc_top = 0x58, },
1093b285192aSMauro Carvalho Chehab .qam_6 = { .if_freq = 4000, .agc_mode = 3, .std = 5,
1094b285192aSMauro Carvalho Chehab .if_lvl = 1, .rfagc_top = 0x58, },
1095b285192aSMauro Carvalho Chehab };
1096b285192aSMauro Carvalho Chehab
1097b285192aSMauro Carvalho Chehab static struct tda18271_config hcw_tda18271_config = {
1098b285192aSMauro Carvalho Chehab .std_map = &hauppauge_tda18271_std_map,
1099b285192aSMauro Carvalho Chehab .gate = TDA18271_GATE_ANALOG,
1100b285192aSMauro Carvalho Chehab .config = 3,
1101b285192aSMauro Carvalho Chehab .output_opt = TDA18271_OUTPUT_LT_OFF,
1102b285192aSMauro Carvalho Chehab };
1103b285192aSMauro Carvalho Chehab
1104b285192aSMauro Carvalho Chehab static struct tda829x_config tda829x_no_probe = {
1105b285192aSMauro Carvalho Chehab .probe_tuner = TDA829X_DONT_PROBE,
1106b285192aSMauro Carvalho Chehab };
1107b285192aSMauro Carvalho Chehab
1108b285192aSMauro Carvalho Chehab static struct tda10048_config zolid_tda10048_config = {
1109b285192aSMauro Carvalho Chehab .demod_address = 0x10 >> 1,
1110b285192aSMauro Carvalho Chehab .output_mode = TDA10048_PARALLEL_OUTPUT,
1111b285192aSMauro Carvalho Chehab .fwbulkwritelen = TDA10048_BULKWRITE_200,
1112b285192aSMauro Carvalho Chehab .inversion = TDA10048_INVERSION_ON,
1113b285192aSMauro Carvalho Chehab .dtv6_if_freq_khz = TDA10048_IF_3300,
1114b285192aSMauro Carvalho Chehab .dtv7_if_freq_khz = TDA10048_IF_3500,
1115b285192aSMauro Carvalho Chehab .dtv8_if_freq_khz = TDA10048_IF_4000,
1116b285192aSMauro Carvalho Chehab .clk_freq_khz = TDA10048_CLK_16000,
1117b285192aSMauro Carvalho Chehab .disable_gate_access = 1,
1118b285192aSMauro Carvalho Chehab };
1119b285192aSMauro Carvalho Chehab
1120b285192aSMauro Carvalho Chehab static struct tda18271_config zolid_tda18271_config = {
1121b285192aSMauro Carvalho Chehab .gate = TDA18271_GATE_ANALOG,
1122b285192aSMauro Carvalho Chehab };
1123b285192aSMauro Carvalho Chehab
1124b285192aSMauro Carvalho Chehab static struct tda10048_config dtv1000s_tda10048_config = {
1125b285192aSMauro Carvalho Chehab .demod_address = 0x10 >> 1,
1126b285192aSMauro Carvalho Chehab .output_mode = TDA10048_PARALLEL_OUTPUT,
1127b285192aSMauro Carvalho Chehab .fwbulkwritelen = TDA10048_BULKWRITE_200,
1128b285192aSMauro Carvalho Chehab .inversion = TDA10048_INVERSION_ON,
1129b285192aSMauro Carvalho Chehab .dtv6_if_freq_khz = TDA10048_IF_3300,
1130b285192aSMauro Carvalho Chehab .dtv7_if_freq_khz = TDA10048_IF_3800,
1131b285192aSMauro Carvalho Chehab .dtv8_if_freq_khz = TDA10048_IF_4300,
1132b285192aSMauro Carvalho Chehab .clk_freq_khz = TDA10048_CLK_16000,
1133b285192aSMauro Carvalho Chehab .disable_gate_access = 1,
1134b285192aSMauro Carvalho Chehab };
1135b285192aSMauro Carvalho Chehab
1136b285192aSMauro Carvalho Chehab static struct tda18271_std_map dtv1000s_tda18271_std_map = {
1137b285192aSMauro Carvalho Chehab .dvbt_6 = { .if_freq = 3300, .agc_mode = 3, .std = 4,
1138b285192aSMauro Carvalho Chehab .if_lvl = 1, .rfagc_top = 0x37, },
1139b285192aSMauro Carvalho Chehab .dvbt_7 = { .if_freq = 3800, .agc_mode = 3, .std = 5,
1140b285192aSMauro Carvalho Chehab .if_lvl = 1, .rfagc_top = 0x37, },
1141b285192aSMauro Carvalho Chehab .dvbt_8 = { .if_freq = 4300, .agc_mode = 3, .std = 6,
1142b285192aSMauro Carvalho Chehab .if_lvl = 1, .rfagc_top = 0x37, },
1143b285192aSMauro Carvalho Chehab };
1144b285192aSMauro Carvalho Chehab
1145b285192aSMauro Carvalho Chehab static struct tda18271_config dtv1000s_tda18271_config = {
1146b285192aSMauro Carvalho Chehab .std_map = &dtv1000s_tda18271_std_map,
1147b285192aSMauro Carvalho Chehab .gate = TDA18271_GATE_ANALOG,
1148b285192aSMauro Carvalho Chehab };
1149b285192aSMauro Carvalho Chehab
1150b285192aSMauro Carvalho Chehab static struct lgs8gxx_config prohdtv_pro2_lgs8g75_config = {
1151b285192aSMauro Carvalho Chehab .prod = LGS8GXX_PROD_LGS8G75,
1152b285192aSMauro Carvalho Chehab .demod_address = 0x1d,
1153b285192aSMauro Carvalho Chehab .serial_ts = 0,
1154b285192aSMauro Carvalho Chehab .ts_clk_pol = 1,
1155b285192aSMauro Carvalho Chehab .ts_clk_gated = 0,
1156b285192aSMauro Carvalho Chehab .if_clk_freq = 30400, /* 30.4 MHz */
1157b285192aSMauro Carvalho Chehab .if_freq = 4000, /* 4.00 MHz */
1158b285192aSMauro Carvalho Chehab .if_neg_center = 0,
1159b285192aSMauro Carvalho Chehab .ext_adc = 0,
1160b285192aSMauro Carvalho Chehab .adc_signed = 1,
1161b285192aSMauro Carvalho Chehab .adc_vpp = 3, /* 2.0 Vpp */
1162b285192aSMauro Carvalho Chehab .if_neg_edge = 1,
1163b285192aSMauro Carvalho Chehab };
1164b285192aSMauro Carvalho Chehab
1165b285192aSMauro Carvalho Chehab static struct tda18271_config prohdtv_pro2_tda18271_config = {
1166b285192aSMauro Carvalho Chehab .gate = TDA18271_GATE_ANALOG,
1167b285192aSMauro Carvalho Chehab .output_opt = TDA18271_OUTPUT_LT_OFF,
1168b285192aSMauro Carvalho Chehab };
1169b285192aSMauro Carvalho Chehab
1170b285192aSMauro Carvalho Chehab static struct tda18271_std_map kworld_tda18271_std_map = {
1171b285192aSMauro Carvalho Chehab .atsc_6 = { .if_freq = 3250, .agc_mode = 3, .std = 3,
1172b285192aSMauro Carvalho Chehab .if_lvl = 6, .rfagc_top = 0x37 },
1173b285192aSMauro Carvalho Chehab .qam_6 = { .if_freq = 4000, .agc_mode = 3, .std = 0,
1174b285192aSMauro Carvalho Chehab .if_lvl = 6, .rfagc_top = 0x37 },
1175b285192aSMauro Carvalho Chehab };
1176b285192aSMauro Carvalho Chehab
1177b285192aSMauro Carvalho Chehab static struct tda18271_config kworld_pc150u_tda18271_config = {
1178b285192aSMauro Carvalho Chehab .std_map = &kworld_tda18271_std_map,
1179b285192aSMauro Carvalho Chehab .gate = TDA18271_GATE_ANALOG,
1180b285192aSMauro Carvalho Chehab .output_opt = TDA18271_OUTPUT_LT_OFF,
1181b285192aSMauro Carvalho Chehab .config = 3, /* Use tuner callback for AGC */
1182b285192aSMauro Carvalho Chehab .rf_cal_on_startup = 1
1183b285192aSMauro Carvalho Chehab };
1184b285192aSMauro Carvalho Chehab
1185b285192aSMauro Carvalho Chehab static struct s5h1411_config kworld_s5h1411_config = {
1186b285192aSMauro Carvalho Chehab .output_mode = S5H1411_PARALLEL_OUTPUT,
1187b285192aSMauro Carvalho Chehab .gpio = S5H1411_GPIO_OFF,
1188b285192aSMauro Carvalho Chehab .qam_if = S5H1411_IF_4000,
1189b285192aSMauro Carvalho Chehab .vsb_if = S5H1411_IF_3250,
1190b285192aSMauro Carvalho Chehab .inversion = S5H1411_INVERSION_ON,
1191b285192aSMauro Carvalho Chehab .status_mode = S5H1411_DEMODLOCKING,
1192b285192aSMauro Carvalho Chehab .mpeg_timing =
1193ad05ff09SMauro Carvalho Chehab S5H1411_MPEGTIMING_CONTINUOUS_NONINVERTING_CLOCK,
1194b285192aSMauro Carvalho Chehab };
1195b285192aSMauro Carvalho Chehab
11961cab969dSScott K Logan static struct tda18271_config hdtv200h_tda18271_config = {
11971cab969dSScott K Logan .gate = TDA18271_GATE_ANALOG,
11981cab969dSScott K Logan .config = 3 /* Use tuner callback for AGC */
11991cab969dSScott K Logan };
12001cab969dSScott K Logan
12011cab969dSScott K Logan static struct s5h1411_config hdtv200h_s5h1411_config = {
12021cab969dSScott K Logan .output_mode = S5H1411_PARALLEL_OUTPUT,
12031cab969dSScott K Logan .gpio = S5H1411_GPIO_OFF,
12041cab969dSScott K Logan .qam_if = S5H1411_IF_4000,
12051cab969dSScott K Logan .vsb_if = S5H1411_IF_3250,
12061cab969dSScott K Logan .inversion = S5H1411_INVERSION_ON,
12071cab969dSScott K Logan .status_mode = S5H1411_DEMODLOCKING,
12081cab969dSScott K Logan .mpeg_timing =
12091cab969dSScott K Logan S5H1411_MPEGTIMING_CONTINUOUS_NONINVERTING_CLOCK,
12101cab969dSScott K Logan };
12111cab969dSScott K Logan
1212b285192aSMauro Carvalho Chehab
1213b285192aSMauro Carvalho Chehab /* ==================================================================
1214b285192aSMauro Carvalho Chehab * Core code
1215b285192aSMauro Carvalho Chehab */
1216b285192aSMauro Carvalho Chehab
dvb_init(struct saa7134_dev * dev)1217b285192aSMauro Carvalho Chehab static int dvb_init(struct saa7134_dev *dev)
1218b285192aSMauro Carvalho Chehab {
1219b285192aSMauro Carvalho Chehab int ret;
1220b285192aSMauro Carvalho Chehab int attach_xc3028 = 0;
12212ada815fSHans Verkuil struct vb2_dvb_frontend *fe0;
12222ada815fSHans Verkuil struct vb2_queue *q;
1223b285192aSMauro Carvalho Chehab
1224b285192aSMauro Carvalho Chehab /* FIXME: add support for multi-frontend */
1225b285192aSMauro Carvalho Chehab mutex_init(&dev->frontends.lock);
1226b285192aSMauro Carvalho Chehab INIT_LIST_HEAD(&dev->frontends.felist);
1227b285192aSMauro Carvalho Chehab
122883582009SMauro Carvalho Chehab pr_info("%s() allocating 1 frontend\n", __func__);
12292ada815fSHans Verkuil fe0 = vb2_dvb_alloc_frontend(&dev->frontends, 1);
1230b285192aSMauro Carvalho Chehab if (!fe0) {
123183582009SMauro Carvalho Chehab pr_err("%s() failed to alloc\n", __func__);
1232b285192aSMauro Carvalho Chehab return -ENOMEM;
1233b285192aSMauro Carvalho Chehab }
1234b285192aSMauro Carvalho Chehab
12352ada815fSHans Verkuil /* init struct vb2_dvb */
1236b285192aSMauro Carvalho Chehab dev->ts.nr_bufs = 32;
1237b285192aSMauro Carvalho Chehab dev->ts.nr_packets = 32*4;
1238b285192aSMauro Carvalho Chehab fe0->dvb.name = dev->name;
12392ada815fSHans Verkuil q = &fe0->dvb.dvbq;
12402ada815fSHans Verkuil q->type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
12412ada815fSHans Verkuil q->io_modes = VB2_MMAP | VB2_READ;
12422ada815fSHans Verkuil q->drv_priv = &dev->ts_q;
12432ada815fSHans Verkuil q->ops = &saa7134_ts_qops;
12442ada815fSHans Verkuil q->mem_ops = &vb2_dma_sg_memops;
12452ada815fSHans Verkuil q->buf_struct_size = sizeof(struct saa7134_buf);
12462ada815fSHans Verkuil q->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
12472ada815fSHans Verkuil q->lock = &dev->lock;
1248d8feef9bSHans Verkuil q->dev = &dev->pci->dev;
12492ada815fSHans Verkuil ret = vb2_queue_init(q);
12502ada815fSHans Verkuil if (ret) {
12512ada815fSHans Verkuil vb2_dvb_dealloc_frontends(&dev->frontends);
12522ada815fSHans Verkuil return ret;
12532ada815fSHans Verkuil }
1254b285192aSMauro Carvalho Chehab
1255b285192aSMauro Carvalho Chehab switch (dev->board) {
1256b285192aSMauro Carvalho Chehab case SAA7134_BOARD_PINNACLE_300I_DVBT_PAL:
12577516657aSMauro Carvalho Chehab pr_debug("pinnacle 300i dvb setup\n");
1258b285192aSMauro Carvalho Chehab fe0->dvb.frontend = dvb_attach(mt352_attach, &pinnacle_300i,
1259b285192aSMauro Carvalho Chehab &dev->i2c_adap);
1260b285192aSMauro Carvalho Chehab if (fe0->dvb.frontend) {
1261b285192aSMauro Carvalho Chehab fe0->dvb.frontend->ops.tuner_ops.set_params = mt352_pinnacle_tuner_set_params;
1262b285192aSMauro Carvalho Chehab }
1263b285192aSMauro Carvalho Chehab break;
1264b285192aSMauro Carvalho Chehab case SAA7134_BOARD_AVERMEDIA_777:
1265b285192aSMauro Carvalho Chehab case SAA7134_BOARD_AVERMEDIA_A16AR:
12667516657aSMauro Carvalho Chehab pr_debug("avertv 777 dvb setup\n");
1267b285192aSMauro Carvalho Chehab fe0->dvb.frontend = dvb_attach(mt352_attach, &avermedia_777,
1268b285192aSMauro Carvalho Chehab &dev->i2c_adap);
1269b285192aSMauro Carvalho Chehab if (fe0->dvb.frontend) {
1270b285192aSMauro Carvalho Chehab dvb_attach(simple_tuner_attach, fe0->dvb.frontend,
1271b285192aSMauro Carvalho Chehab &dev->i2c_adap, 0x61,
1272b285192aSMauro Carvalho Chehab TUNER_PHILIPS_TD1316);
1273b285192aSMauro Carvalho Chehab }
1274b285192aSMauro Carvalho Chehab break;
1275b285192aSMauro Carvalho Chehab case SAA7134_BOARD_AVERMEDIA_A16D:
12767516657aSMauro Carvalho Chehab pr_debug("AverMedia A16D dvb setup\n");
1277b285192aSMauro Carvalho Chehab fe0->dvb.frontend = dvb_attach(mt352_attach,
1278b285192aSMauro Carvalho Chehab &avermedia_xc3028_mt352_dev,
1279b285192aSMauro Carvalho Chehab &dev->i2c_adap);
1280b285192aSMauro Carvalho Chehab attach_xc3028 = 1;
1281b285192aSMauro Carvalho Chehab break;
1282b285192aSMauro Carvalho Chehab case SAA7134_BOARD_MD7134:
1283b285192aSMauro Carvalho Chehab fe0->dvb.frontend = dvb_attach(tda10046_attach,
1284b285192aSMauro Carvalho Chehab &medion_cardbus,
1285b285192aSMauro Carvalho Chehab &dev->i2c_adap);
1286b285192aSMauro Carvalho Chehab if (fe0->dvb.frontend) {
1287c1849372SMaciej S. Szmigiero /*
1288c1849372SMaciej S. Szmigiero * The TV tuner on this board is actually NOT
1289c1849372SMaciej S. Szmigiero * behind the demod i2c gate.
1290c1849372SMaciej S. Szmigiero * However, the demod EEPROM is indeed there and it
1291c1849372SMaciej S. Szmigiero * conflicts with the SAA7134 chip config EEPROM
1292c1849372SMaciej S. Szmigiero * if the i2c gate is open (since they have same
1293c1849372SMaciej S. Szmigiero * bus addresses) resulting in card PCI SVID / SSID
1294c1849372SMaciej S. Szmigiero * being garbage after a reboot from time to time.
1295c1849372SMaciej S. Szmigiero *
1296c1849372SMaciej S. Szmigiero * Let's just leave the gate permanently closed -
1297c1849372SMaciej S. Szmigiero * saa7134_i2c_eeprom_md7134_gate() will close it for
1298c1849372SMaciej S. Szmigiero * us at probe time if it was open for some reason.
1299c1849372SMaciej S. Szmigiero */
1300c1849372SMaciej S. Szmigiero fe0->dvb.frontend->ops.i2c_gate_ctrl = NULL;
1301b285192aSMauro Carvalho Chehab dvb_attach(simple_tuner_attach, fe0->dvb.frontend,
1302b285192aSMauro Carvalho Chehab &dev->i2c_adap, medion_cardbus.tuner_address,
1303b285192aSMauro Carvalho Chehab TUNER_PHILIPS_FMD1216ME_MK3);
1304b285192aSMauro Carvalho Chehab }
1305b285192aSMauro Carvalho Chehab break;
1306b285192aSMauro Carvalho Chehab case SAA7134_BOARD_PHILIPS_TOUGH:
1307b285192aSMauro Carvalho Chehab fe0->dvb.frontend = dvb_attach(tda10046_attach,
1308b285192aSMauro Carvalho Chehab &philips_tu1216_60_config,
1309b285192aSMauro Carvalho Chehab &dev->i2c_adap);
1310b285192aSMauro Carvalho Chehab if (fe0->dvb.frontend) {
1311b285192aSMauro Carvalho Chehab fe0->dvb.frontend->ops.tuner_ops.init = philips_tu1216_init;
1312b285192aSMauro Carvalho Chehab fe0->dvb.frontend->ops.tuner_ops.set_params = philips_tda6651_pll_set;
1313b285192aSMauro Carvalho Chehab }
1314b285192aSMauro Carvalho Chehab break;
1315b285192aSMauro Carvalho Chehab case SAA7134_BOARD_FLYDVBTDUO:
1316b285192aSMauro Carvalho Chehab case SAA7134_BOARD_FLYDVBT_DUO_CARDBUS:
1317b285192aSMauro Carvalho Chehab if (configure_tda827x_fe(dev, &tda827x_lifeview_config,
1318b285192aSMauro Carvalho Chehab &tda827x_cfg_0) < 0)
1319b285192aSMauro Carvalho Chehab goto detach_frontend;
1320b285192aSMauro Carvalho Chehab break;
1321b285192aSMauro Carvalho Chehab case SAA7134_BOARD_PHILIPS_EUROPA:
1322b285192aSMauro Carvalho Chehab case SAA7134_BOARD_VIDEOMATE_DVBT_300:
1323b285192aSMauro Carvalho Chehab case SAA7134_BOARD_ASUS_EUROPA_HYBRID:
1324b285192aSMauro Carvalho Chehab fe0->dvb.frontend = dvb_attach(tda10046_attach,
1325b285192aSMauro Carvalho Chehab &philips_europa_config,
1326b285192aSMauro Carvalho Chehab &dev->i2c_adap);
1327b285192aSMauro Carvalho Chehab if (fe0->dvb.frontend) {
1328b285192aSMauro Carvalho Chehab dev->original_demod_sleep = fe0->dvb.frontend->ops.sleep;
1329b285192aSMauro Carvalho Chehab fe0->dvb.frontend->ops.sleep = philips_europa_demod_sleep;
1330b285192aSMauro Carvalho Chehab fe0->dvb.frontend->ops.tuner_ops.init = philips_europa_tuner_init;
1331b285192aSMauro Carvalho Chehab fe0->dvb.frontend->ops.tuner_ops.sleep = philips_europa_tuner_sleep;
1332b285192aSMauro Carvalho Chehab fe0->dvb.frontend->ops.tuner_ops.set_params = philips_td1316_tuner_set_params;
1333b285192aSMauro Carvalho Chehab }
1334b285192aSMauro Carvalho Chehab break;
1335b285192aSMauro Carvalho Chehab case SAA7134_BOARD_TECHNOTREND_BUDGET_T3000:
1336b285192aSMauro Carvalho Chehab fe0->dvb.frontend = dvb_attach(tda10046_attach,
1337b285192aSMauro Carvalho Chehab &technotrend_budget_t3000_config,
1338b285192aSMauro Carvalho Chehab &dev->i2c_adap);
1339b285192aSMauro Carvalho Chehab if (fe0->dvb.frontend) {
1340b285192aSMauro Carvalho Chehab dev->original_demod_sleep = fe0->dvb.frontend->ops.sleep;
1341b285192aSMauro Carvalho Chehab fe0->dvb.frontend->ops.sleep = philips_europa_demod_sleep;
1342b285192aSMauro Carvalho Chehab fe0->dvb.frontend->ops.tuner_ops.init = philips_europa_tuner_init;
1343b285192aSMauro Carvalho Chehab fe0->dvb.frontend->ops.tuner_ops.sleep = philips_europa_tuner_sleep;
1344b285192aSMauro Carvalho Chehab fe0->dvb.frontend->ops.tuner_ops.set_params = philips_td1316_tuner_set_params;
1345b285192aSMauro Carvalho Chehab }
1346b285192aSMauro Carvalho Chehab break;
1347b285192aSMauro Carvalho Chehab case SAA7134_BOARD_VIDEOMATE_DVBT_200:
1348b285192aSMauro Carvalho Chehab fe0->dvb.frontend = dvb_attach(tda10046_attach,
1349b285192aSMauro Carvalho Chehab &philips_tu1216_61_config,
1350b285192aSMauro Carvalho Chehab &dev->i2c_adap);
1351b285192aSMauro Carvalho Chehab if (fe0->dvb.frontend) {
1352b285192aSMauro Carvalho Chehab fe0->dvb.frontend->ops.tuner_ops.init = philips_tu1216_init;
1353b285192aSMauro Carvalho Chehab fe0->dvb.frontend->ops.tuner_ops.set_params = philips_tda6651_pll_set;
1354b285192aSMauro Carvalho Chehab }
1355b285192aSMauro Carvalho Chehab break;
1356b285192aSMauro Carvalho Chehab case SAA7134_BOARD_KWORLD_DVBT_210:
1357b285192aSMauro Carvalho Chehab if (configure_tda827x_fe(dev, &kworld_dvb_t_210_config,
1358b285192aSMauro Carvalho Chehab &tda827x_cfg_2) < 0)
1359b285192aSMauro Carvalho Chehab goto detach_frontend;
1360b285192aSMauro Carvalho Chehab break;
1361b285192aSMauro Carvalho Chehab case SAA7134_BOARD_HAUPPAUGE_HVR1120:
1362b285192aSMauro Carvalho Chehab fe0->dvb.frontend = dvb_attach(tda10048_attach,
1363b285192aSMauro Carvalho Chehab &hcw_tda10048_config,
1364b285192aSMauro Carvalho Chehab &dev->i2c_adap);
1365b285192aSMauro Carvalho Chehab if (fe0->dvb.frontend != NULL) {
1366b285192aSMauro Carvalho Chehab dvb_attach(tda829x_attach, fe0->dvb.frontend,
1367b285192aSMauro Carvalho Chehab &dev->i2c_adap, 0x4b,
1368b285192aSMauro Carvalho Chehab &tda829x_no_probe);
1369b285192aSMauro Carvalho Chehab dvb_attach(tda18271_attach, fe0->dvb.frontend,
1370b285192aSMauro Carvalho Chehab 0x60, &dev->i2c_adap,
1371b285192aSMauro Carvalho Chehab &hcw_tda18271_config);
1372b285192aSMauro Carvalho Chehab }
1373b285192aSMauro Carvalho Chehab break;
1374b285192aSMauro Carvalho Chehab case SAA7134_BOARD_PHILIPS_TIGER:
1375b285192aSMauro Carvalho Chehab if (configure_tda827x_fe(dev, &philips_tiger_config,
1376b285192aSMauro Carvalho Chehab &tda827x_cfg_0) < 0)
1377b285192aSMauro Carvalho Chehab goto detach_frontend;
1378b285192aSMauro Carvalho Chehab break;
1379b285192aSMauro Carvalho Chehab case SAA7134_BOARD_PINNACLE_PCTV_310i:
1380b285192aSMauro Carvalho Chehab if (configure_tda827x_fe(dev, &pinnacle_pctv_310i_config,
1381b285192aSMauro Carvalho Chehab &tda827x_cfg_1) < 0)
1382b285192aSMauro Carvalho Chehab goto detach_frontend;
1383b285192aSMauro Carvalho Chehab break;
1384b285192aSMauro Carvalho Chehab case SAA7134_BOARD_HAUPPAUGE_HVR1110:
1385b285192aSMauro Carvalho Chehab if (configure_tda827x_fe(dev, &hauppauge_hvr_1110_config,
1386b285192aSMauro Carvalho Chehab &tda827x_cfg_1) < 0)
1387b285192aSMauro Carvalho Chehab goto detach_frontend;
1388b285192aSMauro Carvalho Chehab break;
1389b285192aSMauro Carvalho Chehab case SAA7134_BOARD_HAUPPAUGE_HVR1150:
1390b285192aSMauro Carvalho Chehab fe0->dvb.frontend = dvb_attach(lgdt3305_attach,
1391b285192aSMauro Carvalho Chehab &hcw_lgdt3305_config,
1392b285192aSMauro Carvalho Chehab &dev->i2c_adap);
1393b285192aSMauro Carvalho Chehab if (fe0->dvb.frontend) {
1394b285192aSMauro Carvalho Chehab dvb_attach(tda829x_attach, fe0->dvb.frontend,
1395b285192aSMauro Carvalho Chehab &dev->i2c_adap, 0x4b,
1396b285192aSMauro Carvalho Chehab &tda829x_no_probe);
1397b285192aSMauro Carvalho Chehab dvb_attach(tda18271_attach, fe0->dvb.frontend,
1398b285192aSMauro Carvalho Chehab 0x60, &dev->i2c_adap,
1399b285192aSMauro Carvalho Chehab &hcw_tda18271_config);
1400b285192aSMauro Carvalho Chehab }
1401b285192aSMauro Carvalho Chehab break;
1402b285192aSMauro Carvalho Chehab case SAA7134_BOARD_ASUSTeK_P7131_DUAL:
1403b285192aSMauro Carvalho Chehab if (configure_tda827x_fe(dev, &asus_p7131_dual_config,
1404b285192aSMauro Carvalho Chehab &tda827x_cfg_0) < 0)
1405b285192aSMauro Carvalho Chehab goto detach_frontend;
1406b285192aSMauro Carvalho Chehab break;
1407b285192aSMauro Carvalho Chehab case SAA7134_BOARD_FLYDVBT_LR301:
1408b285192aSMauro Carvalho Chehab if (configure_tda827x_fe(dev, &tda827x_lifeview_config,
1409b285192aSMauro Carvalho Chehab &tda827x_cfg_0) < 0)
1410b285192aSMauro Carvalho Chehab goto detach_frontend;
1411b285192aSMauro Carvalho Chehab break;
1412b285192aSMauro Carvalho Chehab case SAA7134_BOARD_FLYDVB_TRIO:
1413b285192aSMauro Carvalho Chehab if (!use_frontend) { /* terrestrial */
1414b285192aSMauro Carvalho Chehab if (configure_tda827x_fe(dev, &lifeview_trio_config,
1415b285192aSMauro Carvalho Chehab &tda827x_cfg_0) < 0)
1416b285192aSMauro Carvalho Chehab goto detach_frontend;
1417b285192aSMauro Carvalho Chehab } else { /* satellite */
1418b285192aSMauro Carvalho Chehab fe0->dvb.frontend = dvb_attach(tda10086_attach, &flydvbs, &dev->i2c_adap);
1419b285192aSMauro Carvalho Chehab if (fe0->dvb.frontend) {
1420b285192aSMauro Carvalho Chehab if (dvb_attach(tda826x_attach, fe0->dvb.frontend, 0x63,
1421b285192aSMauro Carvalho Chehab &dev->i2c_adap, 0) == NULL) {
14226139ebc6SMauro Carvalho Chehab pr_warn("%s: Lifeview Trio, No tda826x found!\n",
14236139ebc6SMauro Carvalho Chehab __func__);
1424b285192aSMauro Carvalho Chehab goto detach_frontend;
1425b285192aSMauro Carvalho Chehab }
142648a8a03bSMauro Carvalho Chehab if (dvb_attach(isl6421_attach, fe0->dvb.frontend,
142748a8a03bSMauro Carvalho Chehab &dev->i2c_adap,
142848a8a03bSMauro Carvalho Chehab 0x08, 0, 0, false) == NULL) {
14296139ebc6SMauro Carvalho Chehab pr_warn("%s: Lifeview Trio, No ISL6421 found!\n",
14306139ebc6SMauro Carvalho Chehab __func__);
1431b285192aSMauro Carvalho Chehab goto detach_frontend;
1432b285192aSMauro Carvalho Chehab }
1433b285192aSMauro Carvalho Chehab }
1434b285192aSMauro Carvalho Chehab }
1435b285192aSMauro Carvalho Chehab break;
1436b285192aSMauro Carvalho Chehab case SAA7134_BOARD_ADS_DUO_CARDBUS_PTV331:
1437b285192aSMauro Carvalho Chehab case SAA7134_BOARD_FLYDVBT_HYBRID_CARDBUS:
1438b285192aSMauro Carvalho Chehab fe0->dvb.frontend = dvb_attach(tda10046_attach,
1439b285192aSMauro Carvalho Chehab &ads_tech_duo_config,
1440b285192aSMauro Carvalho Chehab &dev->i2c_adap);
1441b285192aSMauro Carvalho Chehab if (fe0->dvb.frontend) {
1442b285192aSMauro Carvalho Chehab if (dvb_attach(tda827x_attach,fe0->dvb.frontend,
1443b285192aSMauro Carvalho Chehab ads_tech_duo_config.tuner_address, &dev->i2c_adap,
1444b285192aSMauro Carvalho Chehab &ads_duo_cfg) == NULL) {
1445ae618919SMauro Carvalho Chehab pr_warn("no tda827x tuner found at addr: %02x\n",
1446b285192aSMauro Carvalho Chehab ads_tech_duo_config.tuner_address);
1447b285192aSMauro Carvalho Chehab goto detach_frontend;
1448b285192aSMauro Carvalho Chehab }
1449b285192aSMauro Carvalho Chehab } else
1450ae618919SMauro Carvalho Chehab pr_warn("failed to attach tda10046\n");
1451b285192aSMauro Carvalho Chehab break;
1452b285192aSMauro Carvalho Chehab case SAA7134_BOARD_TEVION_DVBT_220RF:
1453b285192aSMauro Carvalho Chehab if (configure_tda827x_fe(dev, &tevion_dvbt220rf_config,
1454b285192aSMauro Carvalho Chehab &tda827x_cfg_0) < 0)
1455b285192aSMauro Carvalho Chehab goto detach_frontend;
1456b285192aSMauro Carvalho Chehab break;
1457b285192aSMauro Carvalho Chehab case SAA7134_BOARD_MEDION_MD8800_QUADRO:
1458b285192aSMauro Carvalho Chehab if (!use_frontend) { /* terrestrial */
1459b285192aSMauro Carvalho Chehab if (configure_tda827x_fe(dev, &md8800_dvbt_config,
1460b285192aSMauro Carvalho Chehab &tda827x_cfg_0) < 0)
1461b285192aSMauro Carvalho Chehab goto detach_frontend;
1462b285192aSMauro Carvalho Chehab } else { /* satellite */
1463b285192aSMauro Carvalho Chehab fe0->dvb.frontend = dvb_attach(tda10086_attach,
1464b285192aSMauro Carvalho Chehab &flydvbs, &dev->i2c_adap);
1465b285192aSMauro Carvalho Chehab if (fe0->dvb.frontend) {
1466b285192aSMauro Carvalho Chehab struct dvb_frontend *fe = fe0->dvb.frontend;
1467b285192aSMauro Carvalho Chehab u8 dev_id = dev->eedata[2];
1468b285192aSMauro Carvalho Chehab u8 data = 0xc4;
1469b285192aSMauro Carvalho Chehab struct i2c_msg msg = {.addr = 0x08, .flags = 0, .len = 1};
1470b285192aSMauro Carvalho Chehab
1471b285192aSMauro Carvalho Chehab if (dvb_attach(tda826x_attach, fe0->dvb.frontend,
1472b285192aSMauro Carvalho Chehab 0x60, &dev->i2c_adap, 0) == NULL) {
1473395eff95SMauro Carvalho Chehab pr_warn("%s: Medion Quadro, no tda826x found !\n",
1474395eff95SMauro Carvalho Chehab __func__);
1475b285192aSMauro Carvalho Chehab goto detach_frontend;
1476b285192aSMauro Carvalho Chehab }
1477b285192aSMauro Carvalho Chehab if (dev_id != 0x08) {
1478b285192aSMauro Carvalho Chehab /* we need to open the i2c gate (we know it exists) */
1479b285192aSMauro Carvalho Chehab fe->ops.i2c_gate_ctrl(fe, 1);
1480b285192aSMauro Carvalho Chehab if (dvb_attach(isl6405_attach, fe,
1481b285192aSMauro Carvalho Chehab &dev->i2c_adap, 0x08, 0, 0) == NULL) {
1482395eff95SMauro Carvalho Chehab pr_warn("%s: Medion Quadro, no ISL6405 found !\n",
1483395eff95SMauro Carvalho Chehab __func__);
1484b285192aSMauro Carvalho Chehab goto detach_frontend;
1485b285192aSMauro Carvalho Chehab }
1486b285192aSMauro Carvalho Chehab if (dev_id == 0x07) {
1487b285192aSMauro Carvalho Chehab /* fire up the 2nd section of the LNB supply since
1488b285192aSMauro Carvalho Chehab we can't do this from the other section */
1489b285192aSMauro Carvalho Chehab msg.buf = &data;
1490b285192aSMauro Carvalho Chehab i2c_transfer(&dev->i2c_adap, &msg, 1);
1491b285192aSMauro Carvalho Chehab }
1492b285192aSMauro Carvalho Chehab fe->ops.i2c_gate_ctrl(fe, 0);
1493b285192aSMauro Carvalho Chehab dev->original_set_voltage = fe->ops.set_voltage;
1494b285192aSMauro Carvalho Chehab fe->ops.set_voltage = md8800_set_voltage;
1495b285192aSMauro Carvalho Chehab dev->original_set_high_voltage = fe->ops.enable_high_lnb_voltage;
1496b285192aSMauro Carvalho Chehab fe->ops.enable_high_lnb_voltage = md8800_set_high_voltage;
1497b285192aSMauro Carvalho Chehab } else {
1498b285192aSMauro Carvalho Chehab fe->ops.set_voltage = md8800_set_voltage2;
1499b285192aSMauro Carvalho Chehab fe->ops.enable_high_lnb_voltage = md8800_set_high_voltage2;
1500b285192aSMauro Carvalho Chehab }
1501b285192aSMauro Carvalho Chehab }
1502b285192aSMauro Carvalho Chehab }
1503b285192aSMauro Carvalho Chehab break;
1504b285192aSMauro Carvalho Chehab case SAA7134_BOARD_AVERMEDIA_AVERTVHD_A180:
1505b285192aSMauro Carvalho Chehab fe0->dvb.frontend = dvb_attach(nxt200x_attach, &avertvhda180,
1506b285192aSMauro Carvalho Chehab &dev->i2c_adap);
1507b285192aSMauro Carvalho Chehab if (fe0->dvb.frontend)
1508b285192aSMauro Carvalho Chehab dvb_attach(dvb_pll_attach, fe0->dvb.frontend, 0x61,
1509b285192aSMauro Carvalho Chehab NULL, DVB_PLL_TDHU2);
1510b285192aSMauro Carvalho Chehab break;
1511b285192aSMauro Carvalho Chehab case SAA7134_BOARD_ADS_INSTANT_HDTV_PCI:
1512b285192aSMauro Carvalho Chehab case SAA7134_BOARD_KWORLD_ATSC110:
1513b285192aSMauro Carvalho Chehab fe0->dvb.frontend = dvb_attach(nxt200x_attach, &kworldatsc110,
1514b285192aSMauro Carvalho Chehab &dev->i2c_adap);
1515b285192aSMauro Carvalho Chehab if (fe0->dvb.frontend)
1516b285192aSMauro Carvalho Chehab dvb_attach(simple_tuner_attach, fe0->dvb.frontend,
1517b285192aSMauro Carvalho Chehab &dev->i2c_adap, 0x61,
1518b285192aSMauro Carvalho Chehab TUNER_PHILIPS_TUV1236D);
1519b285192aSMauro Carvalho Chehab break;
1520b285192aSMauro Carvalho Chehab case SAA7134_BOARD_KWORLD_PC150U:
1521b285192aSMauro Carvalho Chehab saa7134_set_gpio(dev, 18, 1); /* Switch to digital mode */
1522b285192aSMauro Carvalho Chehab saa7134_tuner_callback(dev, 0,
1523b285192aSMauro Carvalho Chehab TDA18271_CALLBACK_CMD_AGC_ENABLE, 1);
1524b285192aSMauro Carvalho Chehab fe0->dvb.frontend = dvb_attach(s5h1411_attach,
1525b285192aSMauro Carvalho Chehab &kworld_s5h1411_config,
1526b285192aSMauro Carvalho Chehab &dev->i2c_adap);
1527b285192aSMauro Carvalho Chehab if (fe0->dvb.frontend != NULL) {
1528b285192aSMauro Carvalho Chehab dvb_attach(tda829x_attach, fe0->dvb.frontend,
1529b285192aSMauro Carvalho Chehab &dev->i2c_adap, 0x4b,
1530b285192aSMauro Carvalho Chehab &tda829x_no_probe);
1531b285192aSMauro Carvalho Chehab dvb_attach(tda18271_attach, fe0->dvb.frontend,
1532b285192aSMauro Carvalho Chehab 0x60, &dev->i2c_adap,
1533b285192aSMauro Carvalho Chehab &kworld_pc150u_tda18271_config);
1534b285192aSMauro Carvalho Chehab }
1535b285192aSMauro Carvalho Chehab break;
1536b285192aSMauro Carvalho Chehab case SAA7134_BOARD_FLYDVBS_LR300:
1537b285192aSMauro Carvalho Chehab fe0->dvb.frontend = dvb_attach(tda10086_attach, &flydvbs,
1538b285192aSMauro Carvalho Chehab &dev->i2c_adap);
1539b285192aSMauro Carvalho Chehab if (fe0->dvb.frontend) {
1540b285192aSMauro Carvalho Chehab if (dvb_attach(tda826x_attach, fe0->dvb.frontend, 0x60,
1541b285192aSMauro Carvalho Chehab &dev->i2c_adap, 0) == NULL) {
1542ae618919SMauro Carvalho Chehab pr_warn("%s: No tda826x found!\n", __func__);
1543b285192aSMauro Carvalho Chehab goto detach_frontend;
1544b285192aSMauro Carvalho Chehab }
1545b285192aSMauro Carvalho Chehab if (dvb_attach(isl6421_attach, fe0->dvb.frontend,
154648a8a03bSMauro Carvalho Chehab &dev->i2c_adap,
154748a8a03bSMauro Carvalho Chehab 0x08, 0, 0, false) == NULL) {
1548ae618919SMauro Carvalho Chehab pr_warn("%s: No ISL6421 found!\n", __func__);
1549b285192aSMauro Carvalho Chehab goto detach_frontend;
1550b285192aSMauro Carvalho Chehab }
1551b285192aSMauro Carvalho Chehab }
1552b285192aSMauro Carvalho Chehab break;
1553b285192aSMauro Carvalho Chehab case SAA7134_BOARD_ASUS_EUROPA2_HYBRID:
1554b285192aSMauro Carvalho Chehab fe0->dvb.frontend = dvb_attach(tda10046_attach,
1555b285192aSMauro Carvalho Chehab &medion_cardbus,
1556b285192aSMauro Carvalho Chehab &dev->i2c_adap);
1557b285192aSMauro Carvalho Chehab if (fe0->dvb.frontend) {
1558b285192aSMauro Carvalho Chehab dev->original_demod_sleep = fe0->dvb.frontend->ops.sleep;
1559b285192aSMauro Carvalho Chehab fe0->dvb.frontend->ops.sleep = philips_europa_demod_sleep;
1560b285192aSMauro Carvalho Chehab
1561b285192aSMauro Carvalho Chehab dvb_attach(simple_tuner_attach, fe0->dvb.frontend,
1562b285192aSMauro Carvalho Chehab &dev->i2c_adap, medion_cardbus.tuner_address,
1563b285192aSMauro Carvalho Chehab TUNER_PHILIPS_FMD1216ME_MK3);
1564b285192aSMauro Carvalho Chehab }
1565b285192aSMauro Carvalho Chehab break;
1566b285192aSMauro Carvalho Chehab case SAA7134_BOARD_VIDEOMATE_DVBT_200A:
1567b285192aSMauro Carvalho Chehab fe0->dvb.frontend = dvb_attach(tda10046_attach,
1568b285192aSMauro Carvalho Chehab &philips_europa_config,
1569b285192aSMauro Carvalho Chehab &dev->i2c_adap);
1570b285192aSMauro Carvalho Chehab if (fe0->dvb.frontend) {
1571b285192aSMauro Carvalho Chehab fe0->dvb.frontend->ops.tuner_ops.init = philips_td1316_tuner_init;
1572b285192aSMauro Carvalho Chehab fe0->dvb.frontend->ops.tuner_ops.set_params = philips_td1316_tuner_set_params;
1573b285192aSMauro Carvalho Chehab }
1574b285192aSMauro Carvalho Chehab break;
1575b285192aSMauro Carvalho Chehab case SAA7134_BOARD_CINERGY_HT_PCMCIA:
1576b285192aSMauro Carvalho Chehab if (configure_tda827x_fe(dev, &cinergy_ht_config,
1577b285192aSMauro Carvalho Chehab &tda827x_cfg_0) < 0)
1578b285192aSMauro Carvalho Chehab goto detach_frontend;
1579b285192aSMauro Carvalho Chehab break;
1580b285192aSMauro Carvalho Chehab case SAA7134_BOARD_CINERGY_HT_PCI:
1581b285192aSMauro Carvalho Chehab if (configure_tda827x_fe(dev, &cinergy_ht_pci_config,
1582b285192aSMauro Carvalho Chehab &tda827x_cfg_0) < 0)
1583b285192aSMauro Carvalho Chehab goto detach_frontend;
1584b285192aSMauro Carvalho Chehab break;
1585b285192aSMauro Carvalho Chehab case SAA7134_BOARD_PHILIPS_TIGER_S:
1586b285192aSMauro Carvalho Chehab if (configure_tda827x_fe(dev, &philips_tiger_s_config,
1587b285192aSMauro Carvalho Chehab &tda827x_cfg_2) < 0)
1588b285192aSMauro Carvalho Chehab goto detach_frontend;
1589b285192aSMauro Carvalho Chehab break;
1590b285192aSMauro Carvalho Chehab case SAA7134_BOARD_ASUS_P7131_4871:
1591b285192aSMauro Carvalho Chehab if (configure_tda827x_fe(dev, &asus_p7131_4871_config,
1592b285192aSMauro Carvalho Chehab &tda827x_cfg_2) < 0)
1593b285192aSMauro Carvalho Chehab goto detach_frontend;
1594b285192aSMauro Carvalho Chehab break;
1595b285192aSMauro Carvalho Chehab case SAA7134_BOARD_ASUSTeK_P7131_HYBRID_LNA:
1596b285192aSMauro Carvalho Chehab if (configure_tda827x_fe(dev, &asus_p7131_hybrid_lna_config,
1597b285192aSMauro Carvalho Chehab &tda827x_cfg_2) < 0)
1598b285192aSMauro Carvalho Chehab goto detach_frontend;
1599b285192aSMauro Carvalho Chehab break;
1600b285192aSMauro Carvalho Chehab case SAA7134_BOARD_AVERMEDIA_SUPER_007:
1601b285192aSMauro Carvalho Chehab if (configure_tda827x_fe(dev, &avermedia_super_007_config,
1602b285192aSMauro Carvalho Chehab &tda827x_cfg_0) < 0)
1603b285192aSMauro Carvalho Chehab goto detach_frontend;
1604b285192aSMauro Carvalho Chehab break;
1605b285192aSMauro Carvalho Chehab case SAA7134_BOARD_TWINHAN_DTV_DVB_3056:
1606b285192aSMauro Carvalho Chehab if (configure_tda827x_fe(dev, &twinhan_dtv_dvb_3056_config,
1607b285192aSMauro Carvalho Chehab &tda827x_cfg_2_sw42) < 0)
1608b285192aSMauro Carvalho Chehab goto detach_frontend;
1609b285192aSMauro Carvalho Chehab break;
1610b285192aSMauro Carvalho Chehab case SAA7134_BOARD_PHILIPS_SNAKE:
1611b285192aSMauro Carvalho Chehab fe0->dvb.frontend = dvb_attach(tda10086_attach, &flydvbs,
1612b285192aSMauro Carvalho Chehab &dev->i2c_adap);
1613b285192aSMauro Carvalho Chehab if (fe0->dvb.frontend) {
1614b285192aSMauro Carvalho Chehab if (dvb_attach(tda826x_attach, fe0->dvb.frontend, 0x60,
1615b285192aSMauro Carvalho Chehab &dev->i2c_adap, 0) == NULL) {
1616ae618919SMauro Carvalho Chehab pr_warn("%s: No tda826x found!\n", __func__);
1617b285192aSMauro Carvalho Chehab goto detach_frontend;
1618b285192aSMauro Carvalho Chehab }
1619b285192aSMauro Carvalho Chehab if (dvb_attach(lnbp21_attach, fe0->dvb.frontend,
1620b285192aSMauro Carvalho Chehab &dev->i2c_adap, 0, 0) == NULL) {
1621ae618919SMauro Carvalho Chehab pr_warn("%s: No lnbp21 found!\n", __func__);
1622b285192aSMauro Carvalho Chehab goto detach_frontend;
1623b285192aSMauro Carvalho Chehab }
1624b285192aSMauro Carvalho Chehab }
1625b285192aSMauro Carvalho Chehab break;
1626b285192aSMauro Carvalho Chehab case SAA7134_BOARD_CREATIX_CTX953:
1627b285192aSMauro Carvalho Chehab if (configure_tda827x_fe(dev, &md8800_dvbt_config,
1628b285192aSMauro Carvalho Chehab &tda827x_cfg_0) < 0)
1629b285192aSMauro Carvalho Chehab goto detach_frontend;
1630b285192aSMauro Carvalho Chehab break;
1631b285192aSMauro Carvalho Chehab case SAA7134_BOARD_MSI_TVANYWHERE_AD11:
1632b285192aSMauro Carvalho Chehab if (configure_tda827x_fe(dev, &philips_tiger_s_config,
1633b285192aSMauro Carvalho Chehab &tda827x_cfg_2) < 0)
1634b285192aSMauro Carvalho Chehab goto detach_frontend;
1635b285192aSMauro Carvalho Chehab break;
1636b285192aSMauro Carvalho Chehab case SAA7134_BOARD_AVERMEDIA_CARDBUS_506:
16377516657aSMauro Carvalho Chehab pr_debug("AverMedia E506R dvb setup\n");
1638b285192aSMauro Carvalho Chehab saa7134_set_gpio(dev, 25, 0);
1639b285192aSMauro Carvalho Chehab msleep(10);
1640b285192aSMauro Carvalho Chehab saa7134_set_gpio(dev, 25, 1);
1641b285192aSMauro Carvalho Chehab fe0->dvb.frontend = dvb_attach(mt352_attach,
1642b285192aSMauro Carvalho Chehab &avermedia_xc3028_mt352_dev,
1643b285192aSMauro Carvalho Chehab &dev->i2c_adap);
1644b285192aSMauro Carvalho Chehab attach_xc3028 = 1;
1645b285192aSMauro Carvalho Chehab break;
1646b285192aSMauro Carvalho Chehab case SAA7134_BOARD_MD7134_BRIDGE_2:
1647b285192aSMauro Carvalho Chehab fe0->dvb.frontend = dvb_attach(tda10086_attach,
1648b285192aSMauro Carvalho Chehab &sd1878_4m, &dev->i2c_adap);
1649b285192aSMauro Carvalho Chehab if (fe0->dvb.frontend) {
1650b285192aSMauro Carvalho Chehab struct dvb_frontend *fe;
1651b285192aSMauro Carvalho Chehab if (dvb_attach(dvb_pll_attach, fe0->dvb.frontend, 0x60,
1652b285192aSMauro Carvalho Chehab &dev->i2c_adap, DVB_PLL_PHILIPS_SD1878_TDA8261) == NULL) {
1653395eff95SMauro Carvalho Chehab pr_warn("%s: MD7134 DVB-S, no SD1878 found !\n",
1654395eff95SMauro Carvalho Chehab __func__);
1655b285192aSMauro Carvalho Chehab goto detach_frontend;
1656b285192aSMauro Carvalho Chehab }
1657b285192aSMauro Carvalho Chehab /* we need to open the i2c gate (we know it exists) */
1658b285192aSMauro Carvalho Chehab fe = fe0->dvb.frontend;
1659b285192aSMauro Carvalho Chehab fe->ops.i2c_gate_ctrl(fe, 1);
1660b285192aSMauro Carvalho Chehab if (dvb_attach(isl6405_attach, fe,
1661b285192aSMauro Carvalho Chehab &dev->i2c_adap, 0x08, 0, 0) == NULL) {
1662395eff95SMauro Carvalho Chehab pr_warn("%s: MD7134 DVB-S, no ISL6405 found !\n",
1663395eff95SMauro Carvalho Chehab __func__);
1664b285192aSMauro Carvalho Chehab goto detach_frontend;
1665b285192aSMauro Carvalho Chehab }
1666b285192aSMauro Carvalho Chehab fe->ops.i2c_gate_ctrl(fe, 0);
1667b285192aSMauro Carvalho Chehab dev->original_set_voltage = fe->ops.set_voltage;
1668b285192aSMauro Carvalho Chehab fe->ops.set_voltage = md8800_set_voltage;
1669b285192aSMauro Carvalho Chehab dev->original_set_high_voltage = fe->ops.enable_high_lnb_voltage;
1670b285192aSMauro Carvalho Chehab fe->ops.enable_high_lnb_voltage = md8800_set_high_voltage;
1671b285192aSMauro Carvalho Chehab }
1672b285192aSMauro Carvalho Chehab break;
1673b285192aSMauro Carvalho Chehab case SAA7134_BOARD_AVERMEDIA_M103:
1674b285192aSMauro Carvalho Chehab saa7134_set_gpio(dev, 25, 0);
1675b285192aSMauro Carvalho Chehab msleep(10);
1676b285192aSMauro Carvalho Chehab saa7134_set_gpio(dev, 25, 1);
1677b285192aSMauro Carvalho Chehab fe0->dvb.frontend = dvb_attach(mt352_attach,
1678b285192aSMauro Carvalho Chehab &avermedia_xc3028_mt352_dev,
1679b285192aSMauro Carvalho Chehab &dev->i2c_adap);
1680b285192aSMauro Carvalho Chehab attach_xc3028 = 1;
1681b285192aSMauro Carvalho Chehab break;
1682b285192aSMauro Carvalho Chehab case SAA7134_BOARD_ASUSTeK_TIGER_3IN1:
1683b285192aSMauro Carvalho Chehab if (!use_frontend) { /* terrestrial */
1684b285192aSMauro Carvalho Chehab if (configure_tda827x_fe(dev, &asus_tiger_3in1_config,
1685b285192aSMauro Carvalho Chehab &tda827x_cfg_2) < 0)
1686b285192aSMauro Carvalho Chehab goto detach_frontend;
1687b285192aSMauro Carvalho Chehab } else { /* satellite */
1688b285192aSMauro Carvalho Chehab fe0->dvb.frontend = dvb_attach(tda10086_attach,
1689b285192aSMauro Carvalho Chehab &flydvbs, &dev->i2c_adap);
1690b285192aSMauro Carvalho Chehab if (fe0->dvb.frontend) {
1691b285192aSMauro Carvalho Chehab if (dvb_attach(tda826x_attach,
1692b285192aSMauro Carvalho Chehab fe0->dvb.frontend, 0x60,
1693b285192aSMauro Carvalho Chehab &dev->i2c_adap, 0) == NULL) {
1694395eff95SMauro Carvalho Chehab pr_warn("%s: Asus Tiger 3in1, no tda826x found!\n",
1695395eff95SMauro Carvalho Chehab __func__);
1696b285192aSMauro Carvalho Chehab goto detach_frontend;
1697b285192aSMauro Carvalho Chehab }
1698b285192aSMauro Carvalho Chehab if (dvb_attach(lnbp21_attach, fe0->dvb.frontend,
1699b285192aSMauro Carvalho Chehab &dev->i2c_adap, 0, 0) == NULL) {
1700395eff95SMauro Carvalho Chehab pr_warn("%s: Asus Tiger 3in1, no lnbp21 found!\n",
1701395eff95SMauro Carvalho Chehab __func__);
1702b285192aSMauro Carvalho Chehab goto detach_frontend;
1703b285192aSMauro Carvalho Chehab }
1704b285192aSMauro Carvalho Chehab }
1705b285192aSMauro Carvalho Chehab }
1706b285192aSMauro Carvalho Chehab break;
1707b285192aSMauro Carvalho Chehab case SAA7134_BOARD_ASUSTeK_PS3_100:
1708b285192aSMauro Carvalho Chehab if (!use_frontend) { /* terrestrial */
1709b285192aSMauro Carvalho Chehab if (configure_tda827x_fe(dev, &asus_ps3_100_config,
1710b285192aSMauro Carvalho Chehab &tda827x_cfg_2) < 0)
1711b285192aSMauro Carvalho Chehab goto detach_frontend;
1712b285192aSMauro Carvalho Chehab } else { /* satellite */
1713b285192aSMauro Carvalho Chehab fe0->dvb.frontend = dvb_attach(tda10086_attach,
1714b285192aSMauro Carvalho Chehab &flydvbs, &dev->i2c_adap);
1715b285192aSMauro Carvalho Chehab if (fe0->dvb.frontend) {
1716b285192aSMauro Carvalho Chehab if (dvb_attach(tda826x_attach,
1717b285192aSMauro Carvalho Chehab fe0->dvb.frontend, 0x60,
1718b285192aSMauro Carvalho Chehab &dev->i2c_adap, 0) == NULL) {
1719395eff95SMauro Carvalho Chehab pr_warn("%s: Asus My Cinema PS3-100, no tda826x found!\n",
1720395eff95SMauro Carvalho Chehab __func__);
1721b285192aSMauro Carvalho Chehab goto detach_frontend;
1722b285192aSMauro Carvalho Chehab }
1723b285192aSMauro Carvalho Chehab if (dvb_attach(lnbp21_attach, fe0->dvb.frontend,
1724b285192aSMauro Carvalho Chehab &dev->i2c_adap, 0, 0) == NULL) {
1725395eff95SMauro Carvalho Chehab pr_warn("%s: Asus My Cinema PS3-100, no lnbp21 found!\n",
1726395eff95SMauro Carvalho Chehab __func__);
1727b285192aSMauro Carvalho Chehab goto detach_frontend;
1728b285192aSMauro Carvalho Chehab }
1729b285192aSMauro Carvalho Chehab }
1730b285192aSMauro Carvalho Chehab }
1731b285192aSMauro Carvalho Chehab break;
1732b285192aSMauro Carvalho Chehab case SAA7134_BOARD_ASUSTeK_TIGER:
1733b285192aSMauro Carvalho Chehab if (configure_tda827x_fe(dev, &philips_tiger_config,
1734b285192aSMauro Carvalho Chehab &tda827x_cfg_0) < 0)
1735b285192aSMauro Carvalho Chehab goto detach_frontend;
1736b285192aSMauro Carvalho Chehab break;
1737b285192aSMauro Carvalho Chehab case SAA7134_BOARD_BEHOLD_H6:
1738b285192aSMauro Carvalho Chehab fe0->dvb.frontend = dvb_attach(zl10353_attach,
1739b285192aSMauro Carvalho Chehab &behold_h6_config,
1740b285192aSMauro Carvalho Chehab &dev->i2c_adap);
1741b285192aSMauro Carvalho Chehab if (fe0->dvb.frontend) {
1742b285192aSMauro Carvalho Chehab dvb_attach(simple_tuner_attach, fe0->dvb.frontend,
1743b285192aSMauro Carvalho Chehab &dev->i2c_adap, 0x61,
1744b285192aSMauro Carvalho Chehab TUNER_PHILIPS_FMD1216MEX_MK3);
1745b285192aSMauro Carvalho Chehab }
1746b285192aSMauro Carvalho Chehab break;
1747b285192aSMauro Carvalho Chehab case SAA7134_BOARD_BEHOLD_X7:
1748b285192aSMauro Carvalho Chehab fe0->dvb.frontend = dvb_attach(zl10353_attach,
1749b285192aSMauro Carvalho Chehab &behold_x7_config,
1750b285192aSMauro Carvalho Chehab &dev->i2c_adap);
1751b285192aSMauro Carvalho Chehab if (fe0->dvb.frontend) {
1752b285192aSMauro Carvalho Chehab dvb_attach(xc5000_attach, fe0->dvb.frontend,
1753b285192aSMauro Carvalho Chehab &dev->i2c_adap, &behold_x7_tunerconfig);
1754b285192aSMauro Carvalho Chehab }
1755b285192aSMauro Carvalho Chehab break;
1756b285192aSMauro Carvalho Chehab case SAA7134_BOARD_BEHOLD_H7:
1757b285192aSMauro Carvalho Chehab fe0->dvb.frontend = dvb_attach(zl10353_attach,
1758b285192aSMauro Carvalho Chehab &behold_x7_config,
1759b285192aSMauro Carvalho Chehab &dev->i2c_adap);
1760b285192aSMauro Carvalho Chehab if (fe0->dvb.frontend) {
1761b285192aSMauro Carvalho Chehab dvb_attach(xc5000_attach, fe0->dvb.frontend,
1762b285192aSMauro Carvalho Chehab &dev->i2c_adap, &behold_x7_tunerconfig);
1763b285192aSMauro Carvalho Chehab }
1764b285192aSMauro Carvalho Chehab break;
1765b285192aSMauro Carvalho Chehab case SAA7134_BOARD_AVERMEDIA_A700_PRO:
1766b285192aSMauro Carvalho Chehab case SAA7134_BOARD_AVERMEDIA_A700_HYBRID:
1767b285192aSMauro Carvalho Chehab /* Zarlink ZL10313 */
1768b285192aSMauro Carvalho Chehab fe0->dvb.frontend = dvb_attach(mt312_attach,
1769b285192aSMauro Carvalho Chehab &avertv_a700_mt312, &dev->i2c_adap);
1770b285192aSMauro Carvalho Chehab if (fe0->dvb.frontend) {
1771b285192aSMauro Carvalho Chehab if (dvb_attach(zl10036_attach, fe0->dvb.frontend,
1772b285192aSMauro Carvalho Chehab &avertv_a700_tuner, &dev->i2c_adap) == NULL) {
1773ae618919SMauro Carvalho Chehab pr_warn("%s: No zl10036 found!\n",
1774b285192aSMauro Carvalho Chehab __func__);
1775b285192aSMauro Carvalho Chehab }
1776b285192aSMauro Carvalho Chehab }
1777b285192aSMauro Carvalho Chehab break;
1778b285192aSMauro Carvalho Chehab case SAA7134_BOARD_VIDEOMATE_S350:
1779b285192aSMauro Carvalho Chehab fe0->dvb.frontend = dvb_attach(mt312_attach,
1780b285192aSMauro Carvalho Chehab &zl10313_compro_s350_config, &dev->i2c_adap);
1781b285192aSMauro Carvalho Chehab if (fe0->dvb.frontend)
1782b285192aSMauro Carvalho Chehab if (dvb_attach(zl10039_attach, fe0->dvb.frontend,
1783b285192aSMauro Carvalho Chehab 0x60, &dev->i2c_adap) == NULL)
1784ae618919SMauro Carvalho Chehab pr_warn("%s: No zl10039 found!\n",
1785b285192aSMauro Carvalho Chehab __func__);
1786b285192aSMauro Carvalho Chehab
1787b285192aSMauro Carvalho Chehab break;
1788b285192aSMauro Carvalho Chehab case SAA7134_BOARD_VIDEOMATE_T750:
1789b285192aSMauro Carvalho Chehab fe0->dvb.frontend = dvb_attach(zl10353_attach,
1790b285192aSMauro Carvalho Chehab &videomate_t750_zl10353_config,
1791b285192aSMauro Carvalho Chehab &dev->i2c_adap);
1792b285192aSMauro Carvalho Chehab if (fe0->dvb.frontend != NULL) {
1793b285192aSMauro Carvalho Chehab if (dvb_attach(qt1010_attach,
1794b285192aSMauro Carvalho Chehab fe0->dvb.frontend,
1795b285192aSMauro Carvalho Chehab &dev->i2c_adap,
1796b285192aSMauro Carvalho Chehab &videomate_t750_qt1010_config) == NULL)
1797ae618919SMauro Carvalho Chehab pr_warn("error attaching QT1010\n");
1798b285192aSMauro Carvalho Chehab }
1799b285192aSMauro Carvalho Chehab break;
1800b285192aSMauro Carvalho Chehab case SAA7134_BOARD_ZOLID_HYBRID_PCI:
1801b285192aSMauro Carvalho Chehab fe0->dvb.frontend = dvb_attach(tda10048_attach,
1802b285192aSMauro Carvalho Chehab &zolid_tda10048_config,
1803b285192aSMauro Carvalho Chehab &dev->i2c_adap);
1804b285192aSMauro Carvalho Chehab if (fe0->dvb.frontend != NULL) {
1805b285192aSMauro Carvalho Chehab dvb_attach(tda829x_attach, fe0->dvb.frontend,
1806b285192aSMauro Carvalho Chehab &dev->i2c_adap, 0x4b,
1807b285192aSMauro Carvalho Chehab &tda829x_no_probe);
1808b285192aSMauro Carvalho Chehab dvb_attach(tda18271_attach, fe0->dvb.frontend,
1809b285192aSMauro Carvalho Chehab 0x60, &dev->i2c_adap,
1810b285192aSMauro Carvalho Chehab &zolid_tda18271_config);
1811b285192aSMauro Carvalho Chehab }
1812b285192aSMauro Carvalho Chehab break;
1813b285192aSMauro Carvalho Chehab case SAA7134_BOARD_LEADTEK_WINFAST_DTV1000S:
1814b285192aSMauro Carvalho Chehab fe0->dvb.frontend = dvb_attach(tda10048_attach,
1815b285192aSMauro Carvalho Chehab &dtv1000s_tda10048_config,
1816b285192aSMauro Carvalho Chehab &dev->i2c_adap);
1817b285192aSMauro Carvalho Chehab if (fe0->dvb.frontend != NULL) {
1818b285192aSMauro Carvalho Chehab dvb_attach(tda829x_attach, fe0->dvb.frontend,
1819b285192aSMauro Carvalho Chehab &dev->i2c_adap, 0x4b,
1820b285192aSMauro Carvalho Chehab &tda829x_no_probe);
1821b285192aSMauro Carvalho Chehab dvb_attach(tda18271_attach, fe0->dvb.frontend,
1822b285192aSMauro Carvalho Chehab 0x60, &dev->i2c_adap,
1823b285192aSMauro Carvalho Chehab &dtv1000s_tda18271_config);
1824b285192aSMauro Carvalho Chehab }
1825b285192aSMauro Carvalho Chehab break;
1826b285192aSMauro Carvalho Chehab case SAA7134_BOARD_KWORLD_PCI_SBTVD_FULLSEG:
1827b285192aSMauro Carvalho Chehab /* Switch to digital mode */
1828b285192aSMauro Carvalho Chehab saa7134_tuner_callback(dev, 0,
1829b285192aSMauro Carvalho Chehab TDA18271_CALLBACK_CMD_AGC_ENABLE, 1);
1830b285192aSMauro Carvalho Chehab fe0->dvb.frontend = dvb_attach(mb86a20s_attach,
1831b285192aSMauro Carvalho Chehab &kworld_mb86a20s_config,
1832b285192aSMauro Carvalho Chehab &dev->i2c_adap);
1833b285192aSMauro Carvalho Chehab if (fe0->dvb.frontend != NULL) {
1834b285192aSMauro Carvalho Chehab dvb_attach(tda829x_attach, fe0->dvb.frontend,
1835b285192aSMauro Carvalho Chehab &dev->i2c_adap, 0x4b,
1836b285192aSMauro Carvalho Chehab &tda829x_no_probe);
1837b285192aSMauro Carvalho Chehab fe0->dvb.frontend->ops.i2c_gate_ctrl = kworld_sbtvd_gate_ctrl;
1838b285192aSMauro Carvalho Chehab dvb_attach(tda18271_attach, fe0->dvb.frontend,
1839b285192aSMauro Carvalho Chehab 0x60, &dev->i2c_adap,
1840b285192aSMauro Carvalho Chehab &kworld_tda18271_config);
1841b285192aSMauro Carvalho Chehab }
1842b285192aSMauro Carvalho Chehab
1843b285192aSMauro Carvalho Chehab /* mb86a20s need to use the I2C gateway */
1844b285192aSMauro Carvalho Chehab break;
1845b285192aSMauro Carvalho Chehab case SAA7134_BOARD_MAGICPRO_PROHDTV_PRO2:
1846b285192aSMauro Carvalho Chehab fe0->dvb.frontend = dvb_attach(lgs8gxx_attach,
1847b285192aSMauro Carvalho Chehab &prohdtv_pro2_lgs8g75_config,
1848b285192aSMauro Carvalho Chehab &dev->i2c_adap);
1849b285192aSMauro Carvalho Chehab if (fe0->dvb.frontend != NULL) {
1850b285192aSMauro Carvalho Chehab dvb_attach(tda829x_attach, fe0->dvb.frontend,
1851b285192aSMauro Carvalho Chehab &dev->i2c_adap, 0x4b,
1852b285192aSMauro Carvalho Chehab &tda829x_no_probe);
1853b285192aSMauro Carvalho Chehab dvb_attach(tda18271_attach, fe0->dvb.frontend,
1854b285192aSMauro Carvalho Chehab 0x60, &dev->i2c_adap,
1855b285192aSMauro Carvalho Chehab &prohdtv_pro2_tda18271_config);
1856b285192aSMauro Carvalho Chehab }
1857b285192aSMauro Carvalho Chehab break;
185834fe2784SOndrej Zary case SAA7134_BOARD_AVERMEDIA_A706:
185934fe2784SOndrej Zary /* Enable all DVB-S devices now */
186034fe2784SOndrej Zary /* CE5039 DVB-S tuner SLEEP pin low */
186134fe2784SOndrej Zary saa7134_set_gpio(dev, 23, 0);
186234fe2784SOndrej Zary /* CE6313 DVB-S demod SLEEP pin low */
186334fe2784SOndrej Zary saa7134_set_gpio(dev, 9, 0);
186434fe2784SOndrej Zary /* CE6313 DVB-S demod RESET# pin high */
186534fe2784SOndrej Zary saa7134_set_gpio(dev, 25, 1);
186634fe2784SOndrej Zary msleep(1);
186734fe2784SOndrej Zary fe0->dvb.frontend = dvb_attach(mt312_attach,
186834fe2784SOndrej Zary &zl10313_avermedia_a706_config, &dev->i2c_adap);
186934fe2784SOndrej Zary if (fe0->dvb.frontend) {
187034fe2784SOndrej Zary fe0->dvb.frontend->ops.i2c_gate_ctrl = NULL;
187134fe2784SOndrej Zary if (dvb_attach(zl10039_attach, fe0->dvb.frontend,
187234fe2784SOndrej Zary 0x60, &dev->i2c_adap) == NULL)
1873ae618919SMauro Carvalho Chehab pr_warn("%s: No zl10039 found!\n",
187434fe2784SOndrej Zary __func__);
187534fe2784SOndrej Zary }
187634fe2784SOndrej Zary break;
18771cab969dSScott K Logan case SAA7134_BOARD_LEADTEK_WINFAST_HDTV200_H:
18781cab969dSScott K Logan fe0->dvb.frontend = dvb_attach(s5h1411_attach,
18791cab969dSScott K Logan &hdtv200h_s5h1411_config,
18801cab969dSScott K Logan &dev->i2c_adap);
18811cab969dSScott K Logan if (fe0->dvb.frontend) {
18821cab969dSScott K Logan dvb_attach(tda829x_attach, fe0->dvb.frontend,
18831cab969dSScott K Logan &dev->i2c_adap, 0x4b,
18841cab969dSScott K Logan &tda829x_no_probe);
18851cab969dSScott K Logan dvb_attach(tda18271_attach, fe0->dvb.frontend,
18861cab969dSScott K Logan 0x60, &dev->i2c_adap,
18871cab969dSScott K Logan &hdtv200h_tda18271_config);
18881cab969dSScott K Logan }
18891cab969dSScott K Logan break;
1890b285192aSMauro Carvalho Chehab default:
1891ae618919SMauro Carvalho Chehab pr_warn("Huh? unknown DVB card?\n");
1892b285192aSMauro Carvalho Chehab break;
1893b285192aSMauro Carvalho Chehab }
1894b285192aSMauro Carvalho Chehab
1895b285192aSMauro Carvalho Chehab if (attach_xc3028) {
1896b285192aSMauro Carvalho Chehab struct dvb_frontend *fe;
1897b285192aSMauro Carvalho Chehab struct xc2028_config cfg = {
1898b285192aSMauro Carvalho Chehab .i2c_adap = &dev->i2c_adap,
1899b285192aSMauro Carvalho Chehab .i2c_addr = 0x61,
1900b285192aSMauro Carvalho Chehab };
1901b285192aSMauro Carvalho Chehab
1902b285192aSMauro Carvalho Chehab if (!fe0->dvb.frontend)
1903b285192aSMauro Carvalho Chehab goto detach_frontend;
1904b285192aSMauro Carvalho Chehab
1905b285192aSMauro Carvalho Chehab fe = dvb_attach(xc2028_attach, fe0->dvb.frontend, &cfg);
1906b285192aSMauro Carvalho Chehab if (!fe) {
190783582009SMauro Carvalho Chehab pr_err("%s/2: xc3028 attach failed\n",
1908b285192aSMauro Carvalho Chehab dev->name);
1909b285192aSMauro Carvalho Chehab goto detach_frontend;
1910b285192aSMauro Carvalho Chehab }
1911b285192aSMauro Carvalho Chehab }
1912b285192aSMauro Carvalho Chehab
1913b285192aSMauro Carvalho Chehab if (NULL == fe0->dvb.frontend) {
191483582009SMauro Carvalho Chehab pr_err("%s/dvb: frontend initialization failed\n", dev->name);
1915b285192aSMauro Carvalho Chehab goto detach_frontend;
1916b285192aSMauro Carvalho Chehab }
1917b285192aSMauro Carvalho Chehab /* define general-purpose callback pointer */
1918b285192aSMauro Carvalho Chehab fe0->dvb.frontend->callback = saa7134_tuner_callback;
1919b285192aSMauro Carvalho Chehab
1920b285192aSMauro Carvalho Chehab /* register everything else */
1921ac90aa02SMauro Carvalho Chehab #ifndef CONFIG_MEDIA_CONTROLLER_DVB
19222ada815fSHans Verkuil ret = vb2_dvb_register_bus(&dev->frontends, THIS_MODULE, dev,
1923ac90aa02SMauro Carvalho Chehab &dev->pci->dev, NULL,
1924ac90aa02SMauro Carvalho Chehab adapter_nr, 0);
1925ac90aa02SMauro Carvalho Chehab #else
1926ac90aa02SMauro Carvalho Chehab ret = vb2_dvb_register_bus(&dev->frontends, THIS_MODULE, dev,
1927ac90aa02SMauro Carvalho Chehab &dev->pci->dev, dev->media_dev,
1928ac90aa02SMauro Carvalho Chehab adapter_nr, 0);
1929ac90aa02SMauro Carvalho Chehab #endif
1930b285192aSMauro Carvalho Chehab
1931b285192aSMauro Carvalho Chehab /* this sequence is necessary to make the tda1004x load its firmware
1932b285192aSMauro Carvalho Chehab * and to enter analog mode of hybrid boards
1933b285192aSMauro Carvalho Chehab */
1934b285192aSMauro Carvalho Chehab if (!ret) {
1935b285192aSMauro Carvalho Chehab if (fe0->dvb.frontend->ops.init)
1936b285192aSMauro Carvalho Chehab fe0->dvb.frontend->ops.init(fe0->dvb.frontend);
1937b285192aSMauro Carvalho Chehab if (fe0->dvb.frontend->ops.sleep)
1938b285192aSMauro Carvalho Chehab fe0->dvb.frontend->ops.sleep(fe0->dvb.frontend);
1939b285192aSMauro Carvalho Chehab if (fe0->dvb.frontend->ops.tuner_ops.sleep)
1940b285192aSMauro Carvalho Chehab fe0->dvb.frontend->ops.tuner_ops.sleep(fe0->dvb.frontend);
1941b285192aSMauro Carvalho Chehab }
1942b285192aSMauro Carvalho Chehab return ret;
1943b285192aSMauro Carvalho Chehab
1944b285192aSMauro Carvalho Chehab detach_frontend:
19452ada815fSHans Verkuil vb2_dvb_dealloc_frontends(&dev->frontends);
19462ada815fSHans Verkuil vb2_queue_release(&fe0->dvb.dvbq);
1947b285192aSMauro Carvalho Chehab return -EINVAL;
1948b285192aSMauro Carvalho Chehab }
1949b285192aSMauro Carvalho Chehab
dvb_fini(struct saa7134_dev * dev)1950b285192aSMauro Carvalho Chehab static int dvb_fini(struct saa7134_dev *dev)
1951b285192aSMauro Carvalho Chehab {
19522ada815fSHans Verkuil struct vb2_dvb_frontend *fe0;
1953b285192aSMauro Carvalho Chehab
1954b285192aSMauro Carvalho Chehab /* Get the first frontend */
19552ada815fSHans Verkuil fe0 = vb2_dvb_get_frontend(&dev->frontends, 1);
1956b285192aSMauro Carvalho Chehab if (!fe0)
1957b285192aSMauro Carvalho Chehab return -EINVAL;
1958b285192aSMauro Carvalho Chehab
1959b285192aSMauro Carvalho Chehab /* FIXME: I suspect that this code is bogus, since the entry for
1960b285192aSMauro Carvalho Chehab Pinnacle 300I DVB-T PAL already defines the proper init to allow
1961b285192aSMauro Carvalho Chehab the detection of mt2032 (TDA9887_PORT2_INACTIVE)
1962b285192aSMauro Carvalho Chehab */
1963b285192aSMauro Carvalho Chehab if (dev->board == SAA7134_BOARD_PINNACLE_300I_DVBT_PAL) {
1964b285192aSMauro Carvalho Chehab struct v4l2_priv_tun_config tda9887_cfg;
1965b285192aSMauro Carvalho Chehab static int on = TDA9887_PRESENT | TDA9887_PORT2_INACTIVE;
1966b285192aSMauro Carvalho Chehab
1967b285192aSMauro Carvalho Chehab tda9887_cfg.tuner = TUNER_TDA9887;
1968b285192aSMauro Carvalho Chehab tda9887_cfg.priv = &on;
1969b285192aSMauro Carvalho Chehab
1970b285192aSMauro Carvalho Chehab /* otherwise we don't detect the tuner on next insmod */
1971b285192aSMauro Carvalho Chehab saa_call_all(dev, tuner, s_config, &tda9887_cfg);
1972b285192aSMauro Carvalho Chehab } else if (dev->board == SAA7134_BOARD_MEDION_MD8800_QUADRO) {
1973b285192aSMauro Carvalho Chehab if ((dev->eedata[2] == 0x07) && use_frontend) {
1974b285192aSMauro Carvalho Chehab /* turn off the 2nd lnb supply */
1975b285192aSMauro Carvalho Chehab u8 data = 0x80;
1976b285192aSMauro Carvalho Chehab struct i2c_msg msg = {.addr = 0x08, .buf = &data, .flags = 0, .len = 1};
1977b285192aSMauro Carvalho Chehab struct dvb_frontend *fe;
1978b285192aSMauro Carvalho Chehab fe = fe0->dvb.frontend;
1979b285192aSMauro Carvalho Chehab if (fe->ops.i2c_gate_ctrl) {
1980b285192aSMauro Carvalho Chehab fe->ops.i2c_gate_ctrl(fe, 1);
1981b285192aSMauro Carvalho Chehab i2c_transfer(&dev->i2c_adap, &msg, 1);
1982b285192aSMauro Carvalho Chehab fe->ops.i2c_gate_ctrl(fe, 0);
1983b285192aSMauro Carvalho Chehab }
1984b285192aSMauro Carvalho Chehab }
1985b285192aSMauro Carvalho Chehab }
19862ada815fSHans Verkuil vb2_dvb_unregister_bus(&dev->frontends);
19872ada815fSHans Verkuil vb2_queue_release(&fe0->dvb.dvbq);
1988b285192aSMauro Carvalho Chehab return 0;
1989b285192aSMauro Carvalho Chehab }
1990b285192aSMauro Carvalho Chehab
1991b285192aSMauro Carvalho Chehab static struct saa7134_mpeg_ops dvb_ops = {
1992b285192aSMauro Carvalho Chehab .type = SAA7134_MPEG_DVB,
1993b285192aSMauro Carvalho Chehab .init = dvb_init,
1994b285192aSMauro Carvalho Chehab .fini = dvb_fini,
1995b285192aSMauro Carvalho Chehab };
1996b285192aSMauro Carvalho Chehab
dvb_register(void)1997b285192aSMauro Carvalho Chehab static int __init dvb_register(void)
1998b285192aSMauro Carvalho Chehab {
1999b285192aSMauro Carvalho Chehab return saa7134_ts_register(&dvb_ops);
2000b285192aSMauro Carvalho Chehab }
2001b285192aSMauro Carvalho Chehab
dvb_unregister(void)2002b285192aSMauro Carvalho Chehab static void __exit dvb_unregister(void)
2003b285192aSMauro Carvalho Chehab {
2004b285192aSMauro Carvalho Chehab saa7134_ts_unregister(&dvb_ops);
2005b285192aSMauro Carvalho Chehab }
2006b285192aSMauro Carvalho Chehab
2007b285192aSMauro Carvalho Chehab module_init(dvb_register);
2008b285192aSMauro Carvalho Chehab module_exit(dvb_unregister);
2009