Linux kernel & device driver programming

Cross-Referenced Linux and Device Driver Code

[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ]
Version: [ 2.6.11.8 ] [ 2.6.25 ] [ 2.6.25.8 ] [ 2.6.31.13 ] Architecture: [ i386 ]

Diff markup

Differences between /linux/drivers/media/video/saa7134/saa7134-dvb.c (Version 2.6.31.13) and /linux/drivers/media/video/saa7134/saa7134-dvb.c (Version 2.6.25)


  1 /*                                                  1 /*
  2  *                                                  2  *
  3  * (c) 2004 Gerd Knorr <kraxel@bytesex.org> [S      3  * (c) 2004 Gerd Knorr <kraxel@bytesex.org> [SuSE Labs]
  4  *                                                  4  *
  5  *  Extended 3 / 2005 by Hartmut Hackmann to s      5  *  Extended 3 / 2005 by Hartmut Hackmann to support various
  6  *  cards with the tda10046 DVB-T channel deco      6  *  cards with the tda10046 DVB-T channel decoder
  7  *                                                  7  *
  8  *  This program is free software; you can red      8  *  This program is free software; you can redistribute it and/or modify
  9  *  it under the terms of the GNU General Publ      9  *  it under the terms of the GNU General Public License as published by
 10  *  the Free Software Foundation; either versi     10  *  the Free Software Foundation; either version 2 of the License, or
 11  *  (at your option) any later version.            11  *  (at your option) any later version.
 12  *                                                 12  *
 13  *  This program is distributed in the hope th     13  *  This program is distributed in the hope that it will be useful,
 14  *  but WITHOUT ANY WARRANTY; without even the     14  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 15  *  MERCHANTABILITY or FITNESS FOR A PARTICULA     15  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 16  *  GNU General Public License for more detail     16  *  GNU General Public License for more details.
 17  *                                                 17  *
 18  *  You should have received a copy of the GNU     18  *  You should have received a copy of the GNU General Public License
 19  *  along with this program; if not, write to      19  *  along with this program; if not, write to the Free Software
 20  *  Foundation, Inc., 675 Mass Ave, Cambridge,     20  *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 21  */                                                21  */
 22                                                    22 
 23 #include <linux/init.h>                            23 #include <linux/init.h>
 24 #include <linux/list.h>                            24 #include <linux/list.h>
 25 #include <linux/module.h>                          25 #include <linux/module.h>
 26 #include <linux/kernel.h>                          26 #include <linux/kernel.h>
 27 #include <linux/slab.h>                            27 #include <linux/slab.h>
 28 #include <linux/delay.h>                           28 #include <linux/delay.h>
 29 #include <linux/kthread.h>                         29 #include <linux/kthread.h>
 30 #include <linux/suspend.h>                         30 #include <linux/suspend.h>
 31                                                    31 
 32 #include "saa7134-reg.h"                           32 #include "saa7134-reg.h"
 33 #include "saa7134.h"                               33 #include "saa7134.h"
 34 #include <media/v4l2-common.h>                     34 #include <media/v4l2-common.h>
 35 #include "dvb-pll.h"                               35 #include "dvb-pll.h"
 36 #include <dvb_frontend.h>                      << 
 37                                                    36 
 38 #include "mt352.h"                                 37 #include "mt352.h"
 39 #include "mt352_priv.h" /* FIXME */                38 #include "mt352_priv.h" /* FIXME */
 40 #include "tda1004x.h"                              39 #include "tda1004x.h"
 41 #include "nxt200x.h"                               40 #include "nxt200x.h"
 42 #include "tuner-xc2028.h"                      << 
 43                                                    41 
 44 #include "tda10086.h"                              42 #include "tda10086.h"
 45 #include "tda826x.h"                               43 #include "tda826x.h"
 46 #include "tda827x.h"                               44 #include "tda827x.h"
 47 #include "isl6421.h"                               45 #include "isl6421.h"
 48 #include "isl6405.h"                           << 
 49 #include "lnbp21.h"                            << 
 50 #include "tuner-simple.h"                      << 
 51 #include "tda10048.h"                          << 
 52 #include "tda18271.h"                          << 
 53 #include "lgdt3305.h"                          << 
 54 #include "tda8290.h"                           << 
 55                                                << 
 56 #include "zl10353.h"                           << 
 57                                                << 
 58 #include "zl10036.h"                           << 
 59 #include "mt312.h"                             << 
 60                                                    46 
 61 MODULE_AUTHOR("Gerd Knorr <kraxel@bytesex.org>     47 MODULE_AUTHOR("Gerd Knorr <kraxel@bytesex.org> [SuSE Labs]");
 62 MODULE_LICENSE("GPL");                             48 MODULE_LICENSE("GPL");
 63                                                    49 
 64 static unsigned int antenna_pwr;               !!  50 static unsigned int antenna_pwr = 0;
 65                                                    51 
 66 module_param(antenna_pwr, int, 0444);              52 module_param(antenna_pwr, int, 0444);
 67 MODULE_PARM_DESC(antenna_pwr,"enable antenna p     53 MODULE_PARM_DESC(antenna_pwr,"enable antenna power (Pinnacle 300i)");
 68                                                    54 
 69 static int use_frontend;                       !!  55 static int use_frontend = 0;
 70 module_param(use_frontend, int, 0644);             56 module_param(use_frontend, int, 0644);
 71 MODULE_PARM_DESC(use_frontend,"for cards with      57 MODULE_PARM_DESC(use_frontend,"for cards with multiple frontends (0: terrestrial, 1: satellite)");
 72                                                    58 
 73 static int debug;                              !!  59 static int debug = 0;
 74 module_param(debug, int, 0644);                    60 module_param(debug, int, 0644);
 75 MODULE_PARM_DESC(debug, "Turn on/off module de     61 MODULE_PARM_DESC(debug, "Turn on/off module debugging (default:off).");
 76                                                    62 
 77 DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr);     << 
 78                                                << 
 79 #define dprintk(fmt, arg...)    do { if (debug     63 #define dprintk(fmt, arg...)    do { if (debug) \
 80         printk(KERN_DEBUG "%s/dvb: " fmt, dev-     64         printk(KERN_DEBUG "%s/dvb: " fmt, dev->name , ## arg); } while(0)
 81                                                    65 
 82 /* Print a warning */                              66 /* Print a warning */
 83 #define wprintk(fmt, arg...) \                     67 #define wprintk(fmt, arg...) \
 84         printk(KERN_WARNING "%s/dvb: " fmt, de     68         printk(KERN_WARNING "%s/dvb: " fmt, dev->name, ## arg)
 85                                                    69 
 86 /* -------------------------------------------     70 /* ------------------------------------------------------------------
 87  * mt352 based DVB-T cards                         71  * mt352 based DVB-T cards
 88  */                                                72  */
 89                                                    73 
 90 static int pinnacle_antenna_pwr(struct saa7134     74 static int pinnacle_antenna_pwr(struct saa7134_dev *dev, int on)
 91 {                                                  75 {
 92         u32 ok;                                    76         u32 ok;
 93                                                    77 
 94         if (!on) {                                 78         if (!on) {
 95                 saa_setl(SAA7134_GPIO_GPMODE0      79                 saa_setl(SAA7134_GPIO_GPMODE0 >> 2,     (1 << 26));
 96                 saa_clearl(SAA7134_GPIO_GPSTAT     80                 saa_clearl(SAA7134_GPIO_GPSTATUS0 >> 2, (1 << 26));
 97                 return 0;                          81                 return 0;
 98         }                                          82         }
 99                                                    83 
100         saa_setl(SAA7134_GPIO_GPMODE0 >> 2,        84         saa_setl(SAA7134_GPIO_GPMODE0 >> 2,     (1 << 26));
101         saa_setl(SAA7134_GPIO_GPSTATUS0 >> 2,      85         saa_setl(SAA7134_GPIO_GPSTATUS0 >> 2,   (1 << 26));
102         udelay(10);                                86         udelay(10);
103                                                    87 
104         saa_setl(SAA7134_GPIO_GPMODE0 >> 2,        88         saa_setl(SAA7134_GPIO_GPMODE0 >> 2,     (1 << 28));
105         saa_clearl(SAA7134_GPIO_GPSTATUS0 >> 2     89         saa_clearl(SAA7134_GPIO_GPSTATUS0 >> 2, (1 << 28));
106         udelay(10);                                90         udelay(10);
107         saa_setl(SAA7134_GPIO_GPSTATUS0 >> 2,      91         saa_setl(SAA7134_GPIO_GPSTATUS0 >> 2,   (1 << 28));
108         udelay(10);                                92         udelay(10);
109         ok = saa_readl(SAA7134_GPIO_GPSTATUS0)     93         ok = saa_readl(SAA7134_GPIO_GPSTATUS0) & (1 << 27);
110         dprintk("%s %s\n", __func__, ok ? "on" !!  94         dprintk("%s %s\n", __FUNCTION__, ok ? "on" : "off");
111                                                    95 
112         if (!ok)                                   96         if (!ok)
113                 saa_clearl(SAA7134_GPIO_GPSTAT     97                 saa_clearl(SAA7134_GPIO_GPSTATUS0 >> 2,   (1 << 26));
114         return ok;                                 98         return ok;
115 }                                                  99 }
116                                                   100 
117 static int mt352_pinnacle_init(struct dvb_fron    101 static int mt352_pinnacle_init(struct dvb_frontend* fe)
118 {                                                 102 {
119         static u8 clock_config []  = { CLOCK_C    103         static u8 clock_config []  = { CLOCK_CTL,  0x3d, 0x28 };
120         static u8 reset []         = { RESET,     104         static u8 reset []         = { RESET,      0x80 };
121         static u8 adc_ctl_1_cfg [] = { ADC_CTL    105         static u8 adc_ctl_1_cfg [] = { ADC_CTL_1,  0x40 };
122         static u8 agc_cfg []       = { AGC_TAR    106         static u8 agc_cfg []       = { AGC_TARGET, 0x28, 0xa0 };
123         static u8 capt_range_cfg[] = { CAPT_RA    107         static u8 capt_range_cfg[] = { CAPT_RANGE, 0x31 };
124         static u8 fsm_ctl_cfg[]    = { 0x7b,      108         static u8 fsm_ctl_cfg[]    = { 0x7b,       0x04 };
125         static u8 gpp_ctl_cfg []   = { GPP_CTL    109         static u8 gpp_ctl_cfg []   = { GPP_CTL,    0x0f };
126         static u8 scan_ctl_cfg []  = { SCAN_CT    110         static u8 scan_ctl_cfg []  = { SCAN_CTL,   0x0d };
127         static u8 irq_cfg []       = { INTERRU    111         static u8 irq_cfg []       = { INTERRUPT_EN_0, 0x00, 0x00, 0x00, 0x00 };
128         struct saa7134_dev *dev= fe->dvb->priv    112         struct saa7134_dev *dev= fe->dvb->priv;
129                                                   113 
130         dprintk("%s called\n", __func__);      !! 114         dprintk("%s called\n", __FUNCTION__);
131                                                   115 
132         mt352_write(fe, clock_config,   sizeof    116         mt352_write(fe, clock_config,   sizeof(clock_config));
133         udelay(200);                              117         udelay(200);
134         mt352_write(fe, reset,          sizeof    118         mt352_write(fe, reset,          sizeof(reset));
135         mt352_write(fe, adc_ctl_1_cfg,  sizeof    119         mt352_write(fe, adc_ctl_1_cfg,  sizeof(adc_ctl_1_cfg));
136         mt352_write(fe, agc_cfg,        sizeof    120         mt352_write(fe, agc_cfg,        sizeof(agc_cfg));
137         mt352_write(fe, capt_range_cfg, sizeof    121         mt352_write(fe, capt_range_cfg, sizeof(capt_range_cfg));
138         mt352_write(fe, gpp_ctl_cfg,    sizeof    122         mt352_write(fe, gpp_ctl_cfg,    sizeof(gpp_ctl_cfg));
139                                                   123 
140         mt352_write(fe, fsm_ctl_cfg,    sizeof    124         mt352_write(fe, fsm_ctl_cfg,    sizeof(fsm_ctl_cfg));
141         mt352_write(fe, scan_ctl_cfg,   sizeof    125         mt352_write(fe, scan_ctl_cfg,   sizeof(scan_ctl_cfg));
142         mt352_write(fe, irq_cfg,        sizeof    126         mt352_write(fe, irq_cfg,        sizeof(irq_cfg));
143                                                   127 
144         return 0;                                 128         return 0;
145 }                                                 129 }
146                                                   130 
147 static int mt352_aver777_init(struct dvb_front    131 static int mt352_aver777_init(struct dvb_frontend* fe)
148 {                                                 132 {
149         static u8 clock_config []  = { CLOCK_C    133         static u8 clock_config []  = { CLOCK_CTL,  0x38, 0x2d };
150         static u8 reset []         = { RESET,     134         static u8 reset []         = { RESET,      0x80 };
151         static u8 adc_ctl_1_cfg [] = { ADC_CTL    135         static u8 adc_ctl_1_cfg [] = { ADC_CTL_1,  0x40 };
152         static u8 agc_cfg []       = { AGC_TAR    136         static u8 agc_cfg []       = { AGC_TARGET, 0x28, 0xa0 };
153         static u8 capt_range_cfg[] = { CAPT_RA    137         static u8 capt_range_cfg[] = { CAPT_RANGE, 0x33 };
154                                                   138 
155         mt352_write(fe, clock_config,   sizeof    139         mt352_write(fe, clock_config,   sizeof(clock_config));
156         udelay(200);                              140         udelay(200);
157         mt352_write(fe, reset,          sizeof    141         mt352_write(fe, reset,          sizeof(reset));
158         mt352_write(fe, adc_ctl_1_cfg,  sizeof    142         mt352_write(fe, adc_ctl_1_cfg,  sizeof(adc_ctl_1_cfg));
159         mt352_write(fe, agc_cfg,        sizeof    143         mt352_write(fe, agc_cfg,        sizeof(agc_cfg));
160         mt352_write(fe, capt_range_cfg, sizeof    144         mt352_write(fe, capt_range_cfg, sizeof(capt_range_cfg));
161                                                   145 
162         return 0;                                 146         return 0;
163 }                                                 147 }
164                                                   148 
165 static int mt352_avermedia_xc3028_init(struct  << 
166 {                                              << 
167         static u8 clock_config []  = { CLOCK_C << 
168         static u8 reset []         = { RESET,  << 
169         static u8 adc_ctl_1_cfg [] = { ADC_CTL << 
170         static u8 agc_cfg []       = { AGC_TAR << 
171         static u8 capt_range_cfg[] = { CAPT_RA << 
172                                                << 
173         mt352_write(fe, clock_config,   sizeof << 
174         udelay(200);                           << 
175         mt352_write(fe, reset,          sizeof << 
176         mt352_write(fe, adc_ctl_1_cfg,  sizeof << 
177         mt352_write(fe, agc_cfg,        sizeof << 
178         mt352_write(fe, capt_range_cfg, sizeof << 
179         return 0;                              << 
180 }                                              << 
181                                                << 
182 static int mt352_pinnacle_tuner_set_params(str    149 static int mt352_pinnacle_tuner_set_params(struct dvb_frontend* fe,
183                                            str    150                                            struct dvb_frontend_parameters* params)
184 {                                                 151 {
185         u8 off[] = { 0x00, 0xf1};                 152         u8 off[] = { 0x00, 0xf1};
186         u8 on[]  = { 0x00, 0x71};                 153         u8 on[]  = { 0x00, 0x71};
187         struct i2c_msg msg = {.addr=0x43, .fla    154         struct i2c_msg msg = {.addr=0x43, .flags=0, .buf=off, .len = sizeof(off)};
188                                                   155 
189         struct saa7134_dev *dev = fe->dvb->pri    156         struct saa7134_dev *dev = fe->dvb->priv;
190         struct v4l2_frequency f;                  157         struct v4l2_frequency f;
191                                                   158 
192         /* set frequency (mt2050) */              159         /* set frequency (mt2050) */
193         f.tuner     = 0;                          160         f.tuner     = 0;
194         f.type      = V4L2_TUNER_DIGITAL_TV;      161         f.type      = V4L2_TUNER_DIGITAL_TV;
195         f.frequency = params->frequency / 1000    162         f.frequency = params->frequency / 1000 * 16 / 1000;
196         if (fe->ops.i2c_gate_ctrl)                163         if (fe->ops.i2c_gate_ctrl)
197                 fe->ops.i2c_gate_ctrl(fe, 1);     164                 fe->ops.i2c_gate_ctrl(fe, 1);
198         i2c_transfer(&dev->i2c_adap, &msg, 1);    165         i2c_transfer(&dev->i2c_adap, &msg, 1);
199         saa_call_all(dev, tuner, s_frequency,  !! 166         saa7134_i2c_call_clients(dev,VIDIOC_S_FREQUENCY,&f);
200         msg.buf = on;                             167         msg.buf = on;
201         if (fe->ops.i2c_gate_ctrl)                168         if (fe->ops.i2c_gate_ctrl)
202                 fe->ops.i2c_gate_ctrl(fe, 1);     169                 fe->ops.i2c_gate_ctrl(fe, 1);
203         i2c_transfer(&dev->i2c_adap, &msg, 1);    170         i2c_transfer(&dev->i2c_adap, &msg, 1);
204                                                   171 
205         pinnacle_antenna_pwr(dev, antenna_pwr)    172         pinnacle_antenna_pwr(dev, antenna_pwr);
206                                                   173 
207         /* mt352 setup */                         174         /* mt352 setup */
208         return mt352_pinnacle_init(fe);           175         return mt352_pinnacle_init(fe);
209 }                                                 176 }
210                                                   177 
211 static struct mt352_config pinnacle_300i = {      178 static struct mt352_config pinnacle_300i = {
212         .demod_address = 0x3c >> 1,               179         .demod_address = 0x3c >> 1,
213         .adc_clock     = 20333,                   180         .adc_clock     = 20333,
214         .if2           = 36150,                   181         .if2           = 36150,
215         .no_tuner      = 1,                       182         .no_tuner      = 1,
216         .demod_init    = mt352_pinnacle_init,     183         .demod_init    = mt352_pinnacle_init,
217 };                                                184 };
218                                                   185 
219 static struct mt352_config avermedia_777 = {      186 static struct mt352_config avermedia_777 = {
220         .demod_address = 0xf,                     187         .demod_address = 0xf,
221         .demod_init    = mt352_aver777_init,      188         .demod_init    = mt352_aver777_init,
222 };                                                189 };
223                                                   190 
224 static struct mt352_config avermedia_xc3028_mt << 
225         .demod_address   = (0x1e >> 1),        << 
226         .no_tuner        = 1,                  << 
227         .demod_init      = mt352_avermedia_xc3 << 
228 };                                             << 
229                                                << 
230 /* ===========================================    191 /* ==================================================================
231  * tda1004x based DVB-T cards, helper function    192  * tda1004x based DVB-T cards, helper functions
232  */                                               193  */
233                                                   194 
234 static int philips_tda1004x_request_firmware(s    195 static int philips_tda1004x_request_firmware(struct dvb_frontend *fe,
235                                            con    196                                            const struct firmware **fw, char *name)
236 {                                                 197 {
237         struct saa7134_dev *dev = fe->dvb->pri    198         struct saa7134_dev *dev = fe->dvb->priv;
238         return request_firmware(fw, name, &dev    199         return request_firmware(fw, name, &dev->pci->dev);
239 }                                                 200 }
240                                                   201 
241 /* -------------------------------------------    202 /* ------------------------------------------------------------------
242  * these tuners are tu1216, td1316(a)             203  * these tuners are tu1216, td1316(a)
243  */                                               204  */
244                                                   205 
245 static int philips_tda6651_pll_set(struct dvb_    206 static int philips_tda6651_pll_set(struct dvb_frontend *fe, struct dvb_frontend_parameters *params)
246 {                                                 207 {
247         struct saa7134_dev *dev = fe->dvb->pri    208         struct saa7134_dev *dev = fe->dvb->priv;
248         struct tda1004x_state *state = fe->dem    209         struct tda1004x_state *state = fe->demodulator_priv;
249         u8 addr = state->config->tuner_address    210         u8 addr = state->config->tuner_address;
250         u8 tuner_buf[4];                          211         u8 tuner_buf[4];
251         struct i2c_msg tuner_msg = {.addr = ad    212         struct i2c_msg tuner_msg = {.addr = addr,.flags = 0,.buf = tuner_buf,.len =
252                         sizeof(tuner_buf) };      213                         sizeof(tuner_buf) };
253         int tuner_frequency = 0;                  214         int tuner_frequency = 0;
254         u8 band, cp, filter;                      215         u8 band, cp, filter;
255                                                   216 
256         /* determine charge pump */               217         /* determine charge pump */
257         tuner_frequency = params->frequency +     218         tuner_frequency = params->frequency + 36166000;
258         if (tuner_frequency < 87000000)           219         if (tuner_frequency < 87000000)
259                 return -EINVAL;                   220                 return -EINVAL;
260         else if (tuner_frequency < 130000000)     221         else if (tuner_frequency < 130000000)
261                 cp = 3;                           222                 cp = 3;
262         else if (tuner_frequency < 160000000)     223         else if (tuner_frequency < 160000000)
263                 cp = 5;                           224                 cp = 5;
264         else if (tuner_frequency < 200000000)     225         else if (tuner_frequency < 200000000)
265                 cp = 6;                           226                 cp = 6;
266         else if (tuner_frequency < 290000000)     227         else if (tuner_frequency < 290000000)
267                 cp = 3;                           228                 cp = 3;
268         else if (tuner_frequency < 420000000)     229         else if (tuner_frequency < 420000000)
269                 cp = 5;                           230                 cp = 5;
270         else if (tuner_frequency < 480000000)     231         else if (tuner_frequency < 480000000)
271                 cp = 6;                           232                 cp = 6;
272         else if (tuner_frequency < 620000000)     233         else if (tuner_frequency < 620000000)
273                 cp = 3;                           234                 cp = 3;
274         else if (tuner_frequency < 830000000)     235         else if (tuner_frequency < 830000000)
275                 cp = 5;                           236                 cp = 5;
276         else if (tuner_frequency < 895000000)     237         else if (tuner_frequency < 895000000)
277                 cp = 7;                           238                 cp = 7;
278         else                                      239         else
279                 return -EINVAL;                   240                 return -EINVAL;
280                                                   241 
281         /* determine band */                      242         /* determine band */
282         if (params->frequency < 49000000)         243         if (params->frequency < 49000000)
283                 return -EINVAL;                   244                 return -EINVAL;
284         else if (params->frequency < 161000000    245         else if (params->frequency < 161000000)
285                 band = 1;                         246                 band = 1;
286         else if (params->frequency < 444000000    247         else if (params->frequency < 444000000)
287                 band = 2;                         248                 band = 2;
288         else if (params->frequency < 861000000    249         else if (params->frequency < 861000000)
289                 band = 4;                         250                 band = 4;
290         else                                      251         else
291                 return -EINVAL;                   252                 return -EINVAL;
292                                                   253 
293         /* setup PLL filter */                    254         /* setup PLL filter */
294         switch (params->u.ofdm.bandwidth) {       255         switch (params->u.ofdm.bandwidth) {
295         case BANDWIDTH_6_MHZ:                     256         case BANDWIDTH_6_MHZ:
296                 filter = 0;                       257                 filter = 0;
297                 break;                            258                 break;
298                                                   259 
299         case BANDWIDTH_7_MHZ:                     260         case BANDWIDTH_7_MHZ:
300                 filter = 0;                       261                 filter = 0;
301                 break;                            262                 break;
302                                                   263 
303         case BANDWIDTH_8_MHZ:                     264         case BANDWIDTH_8_MHZ:
304                 filter = 1;                       265                 filter = 1;
305                 break;                            266                 break;
306                                                   267 
307         default:                                  268         default:
308                 return -EINVAL;                   269                 return -EINVAL;
309         }                                         270         }
310                                                   271 
311         /* calculate divisor                      272         /* calculate divisor
312          * ((36166000+((1000000/6)/2)) + Finpu    273          * ((36166000+((1000000/6)/2)) + Finput)/(1000000/6)
313          */                                       274          */
314         tuner_frequency = (((params->frequency    275         tuner_frequency = (((params->frequency / 1000) * 6) + 217496) / 1000;
315                                                   276 
316         /* setup tuner buffer */                  277         /* setup tuner buffer */
317         tuner_buf[0] = (tuner_frequency >> 8)     278         tuner_buf[0] = (tuner_frequency >> 8) & 0x7f;
318         tuner_buf[1] = tuner_frequency & 0xff;    279         tuner_buf[1] = tuner_frequency & 0xff;
319         tuner_buf[2] = 0xca;                      280         tuner_buf[2] = 0xca;
320         tuner_buf[3] = (cp << 5) | (filter <<     281         tuner_buf[3] = (cp << 5) | (filter << 3) | band;
321                                                   282 
322         if (fe->ops.i2c_gate_ctrl)                283         if (fe->ops.i2c_gate_ctrl)
323                 fe->ops.i2c_gate_ctrl(fe, 1);     284                 fe->ops.i2c_gate_ctrl(fe, 1);
324         if (i2c_transfer(&dev->i2c_adap, &tune    285         if (i2c_transfer(&dev->i2c_adap, &tuner_msg, 1) != 1) {
325                 wprintk("could not write to tu    286                 wprintk("could not write to tuner at addr: 0x%02x\n",
326                         addr << 1);               287                         addr << 1);
327                 return -EIO;                      288                 return -EIO;
328         }                                         289         }
329         msleep(1);                                290         msleep(1);
330         return 0;                                 291         return 0;
331 }                                                 292 }
332                                                   293 
333 static int philips_tu1216_init(struct dvb_fron    294 static int philips_tu1216_init(struct dvb_frontend *fe)
334 {                                                 295 {
335         struct saa7134_dev *dev = fe->dvb->pri    296         struct saa7134_dev *dev = fe->dvb->priv;
336         struct tda1004x_state *state = fe->dem    297         struct tda1004x_state *state = fe->demodulator_priv;
337         u8 addr = state->config->tuner_address    298         u8 addr = state->config->tuner_address;
338         static u8 tu1216_init[] = { 0x0b, 0xf5    299         static u8 tu1216_init[] = { 0x0b, 0xf5, 0x85, 0xab };
339         struct i2c_msg tuner_msg = {.addr = ad    300         struct i2c_msg tuner_msg = {.addr = addr,.flags = 0,.buf = tu1216_init,.len = sizeof(tu1216_init) };
340                                                   301 
341         /* setup PLL configuration */             302         /* setup PLL configuration */
342         if (fe->ops.i2c_gate_ctrl)                303         if (fe->ops.i2c_gate_ctrl)
343                 fe->ops.i2c_gate_ctrl(fe, 1);     304                 fe->ops.i2c_gate_ctrl(fe, 1);
344         if (i2c_transfer(&dev->i2c_adap, &tune    305         if (i2c_transfer(&dev->i2c_adap, &tuner_msg, 1) != 1)
345                 return -EIO;                      306                 return -EIO;
346         msleep(1);                                307         msleep(1);
347                                                   308 
348         return 0;                                 309         return 0;
349 }                                                 310 }
350                                                   311 
351 /* -------------------------------------------    312 /* ------------------------------------------------------------------ */
352                                                   313 
353 static struct tda1004x_config philips_tu1216_6    314 static struct tda1004x_config philips_tu1216_60_config = {
354         .demod_address = 0x8,                     315         .demod_address = 0x8,
355         .invert        = 1,                       316         .invert        = 1,
356         .invert_oclk   = 0,                       317         .invert_oclk   = 0,
357         .xtal_freq     = TDA10046_XTAL_4M,        318         .xtal_freq     = TDA10046_XTAL_4M,
358         .agc_config    = TDA10046_AGC_DEFAULT,    319         .agc_config    = TDA10046_AGC_DEFAULT,
359         .if_freq       = TDA10046_FREQ_3617,      320         .if_freq       = TDA10046_FREQ_3617,
360         .tuner_address = 0x60,                    321         .tuner_address = 0x60,
361         .request_firmware = philips_tda1004x_r    322         .request_firmware = philips_tda1004x_request_firmware
362 };                                                323 };
363                                                   324 
364 static struct tda1004x_config philips_tu1216_6    325 static struct tda1004x_config philips_tu1216_61_config = {
365                                                   326 
366         .demod_address = 0x8,                     327         .demod_address = 0x8,
367         .invert        = 1,                       328         .invert        = 1,
368         .invert_oclk   = 0,                       329         .invert_oclk   = 0,
369         .xtal_freq     = TDA10046_XTAL_4M,        330         .xtal_freq     = TDA10046_XTAL_4M,
370         .agc_config    = TDA10046_AGC_DEFAULT,    331         .agc_config    = TDA10046_AGC_DEFAULT,
371         .if_freq       = TDA10046_FREQ_3617,      332         .if_freq       = TDA10046_FREQ_3617,
372         .tuner_address = 0x61,                    333         .tuner_address = 0x61,
373         .request_firmware = philips_tda1004x_r    334         .request_firmware = philips_tda1004x_request_firmware
374 };                                                335 };
375                                                   336 
376 /* -------------------------------------------    337 /* ------------------------------------------------------------------ */
377                                                   338 
378 static int philips_td1316_tuner_init(struct dv    339 static int philips_td1316_tuner_init(struct dvb_frontend *fe)
379 {                                                 340 {
380         struct saa7134_dev *dev = fe->dvb->pri    341         struct saa7134_dev *dev = fe->dvb->priv;
381         struct tda1004x_state *state = fe->dem    342         struct tda1004x_state *state = fe->demodulator_priv;
382         u8 addr = state->config->tuner_address    343         u8 addr = state->config->tuner_address;
383         static u8 msg[] = { 0x0b, 0xf5, 0x86,     344         static u8 msg[] = { 0x0b, 0xf5, 0x86, 0xab };
384         struct i2c_msg init_msg = {.addr = add    345         struct i2c_msg init_msg = {.addr = addr,.flags = 0,.buf = msg,.len = sizeof(msg) };
385                                                   346 
386         /* setup PLL configuration */             347         /* setup PLL configuration */
387         if (fe->ops.i2c_gate_ctrl)                348         if (fe->ops.i2c_gate_ctrl)
388                 fe->ops.i2c_gate_ctrl(fe, 1);     349                 fe->ops.i2c_gate_ctrl(fe, 1);
389         if (i2c_transfer(&dev->i2c_adap, &init    350         if (i2c_transfer(&dev->i2c_adap, &init_msg, 1) != 1)
390                 return -EIO;                      351                 return -EIO;
391         return 0;                                 352         return 0;
392 }                                                 353 }
393                                                   354 
394 static int philips_td1316_tuner_set_params(str    355 static int philips_td1316_tuner_set_params(struct dvb_frontend *fe, struct dvb_frontend_parameters *params)
395 {                                                 356 {
396         return philips_tda6651_pll_set(fe, par    357         return philips_tda6651_pll_set(fe, params);
397 }                                                 358 }
398                                                   359 
399 static int philips_td1316_tuner_sleep(struct d    360 static int philips_td1316_tuner_sleep(struct dvb_frontend *fe)
400 {                                                 361 {
401         struct saa7134_dev *dev = fe->dvb->pri    362         struct saa7134_dev *dev = fe->dvb->priv;
402         struct tda1004x_state *state = fe->dem    363         struct tda1004x_state *state = fe->demodulator_priv;
403         u8 addr = state->config->tuner_address    364         u8 addr = state->config->tuner_address;
404         static u8 msg[] = { 0x0b, 0xdc, 0x86,     365         static u8 msg[] = { 0x0b, 0xdc, 0x86, 0xa4 };
405         struct i2c_msg analog_msg = {.addr = a    366         struct i2c_msg analog_msg = {.addr = addr,.flags = 0,.buf = msg,.len = sizeof(msg) };
406                                                   367 
407         /* switch the tuner to analog mode */     368         /* switch the tuner to analog mode */
408         if (fe->ops.i2c_gate_ctrl)                369         if (fe->ops.i2c_gate_ctrl)
409                 fe->ops.i2c_gate_ctrl(fe, 1);     370                 fe->ops.i2c_gate_ctrl(fe, 1);
410         if (i2c_transfer(&dev->i2c_adap, &anal    371         if (i2c_transfer(&dev->i2c_adap, &analog_msg, 1) != 1)
411                 return -EIO;                      372                 return -EIO;
412         return 0;                                 373         return 0;
413 }                                                 374 }
414                                                   375 
415 /* -------------------------------------------    376 /* ------------------------------------------------------------------ */
416                                                   377 
417 static int philips_europa_tuner_init(struct dv    378 static int philips_europa_tuner_init(struct dvb_frontend *fe)
418 {                                                 379 {
419         struct saa7134_dev *dev = fe->dvb->pri    380         struct saa7134_dev *dev = fe->dvb->priv;
420         static u8 msg[] = { 0x00, 0x40};          381         static u8 msg[] = { 0x00, 0x40};
421         struct i2c_msg init_msg = {.addr = 0x4    382         struct i2c_msg init_msg = {.addr = 0x43,.flags = 0,.buf = msg,.len = sizeof(msg) };
422                                                   383 
423                                                   384 
424         if (philips_td1316_tuner_init(fe))        385         if (philips_td1316_tuner_init(fe))
425                 return -EIO;                      386                 return -EIO;
426         msleep(1);                                387         msleep(1);
427         if (i2c_transfer(&dev->i2c_adap, &init    388         if (i2c_transfer(&dev->i2c_adap, &init_msg, 1) != 1)
428                 return -EIO;                      389                 return -EIO;
429                                                   390 
430         return 0;                                 391         return 0;
431 }                                                 392 }
432                                                   393 
433 static int philips_europa_tuner_sleep(struct d    394 static int philips_europa_tuner_sleep(struct dvb_frontend *fe)
434 {                                                 395 {
435         struct saa7134_dev *dev = fe->dvb->pri    396         struct saa7134_dev *dev = fe->dvb->priv;
436                                                   397 
437         static u8 msg[] = { 0x00, 0x14 };         398         static u8 msg[] = { 0x00, 0x14 };
438         struct i2c_msg analog_msg = {.addr = 0    399         struct i2c_msg analog_msg = {.addr = 0x43,.flags = 0,.buf = msg,.len = sizeof(msg) };
439                                                   400 
440         if (philips_td1316_tuner_sleep(fe))       401         if (philips_td1316_tuner_sleep(fe))
441                 return -EIO;                      402                 return -EIO;
442                                                   403 
443         /* switch the board to analog mode */     404         /* switch the board to analog mode */
444         if (fe->ops.i2c_gate_ctrl)                405         if (fe->ops.i2c_gate_ctrl)
445                 fe->ops.i2c_gate_ctrl(fe, 1);     406                 fe->ops.i2c_gate_ctrl(fe, 1);
446         i2c_transfer(&dev->i2c_adap, &analog_m    407         i2c_transfer(&dev->i2c_adap, &analog_msg, 1);
447         return 0;                                 408         return 0;
448 }                                                 409 }
449                                                   410 
450 static int philips_europa_demod_sleep(struct d    411 static int philips_europa_demod_sleep(struct dvb_frontend *fe)
451 {                                                 412 {
452         struct saa7134_dev *dev = fe->dvb->pri    413         struct saa7134_dev *dev = fe->dvb->priv;
453                                                   414 
454         if (dev->original_demod_sleep)            415         if (dev->original_demod_sleep)
455                 dev->original_demod_sleep(fe);    416                 dev->original_demod_sleep(fe);
456         fe->ops.i2c_gate_ctrl(fe, 1);             417         fe->ops.i2c_gate_ctrl(fe, 1);
457         return 0;                                 418         return 0;
458 }                                                 419 }
459                                                   420 
460 static struct tda1004x_config philips_europa_c    421 static struct tda1004x_config philips_europa_config = {
461                                                   422 
462         .demod_address = 0x8,                     423         .demod_address = 0x8,
463         .invert        = 0,                       424         .invert        = 0,
464         .invert_oclk   = 0,                       425         .invert_oclk   = 0,
465         .xtal_freq     = TDA10046_XTAL_4M,        426         .xtal_freq     = TDA10046_XTAL_4M,
466         .agc_config    = TDA10046_AGC_IFO_AUTO    427         .agc_config    = TDA10046_AGC_IFO_AUTO_POS,
467         .if_freq       = TDA10046_FREQ_052,       428         .if_freq       = TDA10046_FREQ_052,
468         .tuner_address = 0x61,                    429         .tuner_address = 0x61,
469         .request_firmware = philips_tda1004x_r    430         .request_firmware = philips_tda1004x_request_firmware
470 };                                                431 };
471                                                   432 
                                                   >> 433 /* ------------------------------------------------------------------ */
                                                   >> 434 
472 static struct tda1004x_config medion_cardbus =    435 static struct tda1004x_config medion_cardbus = {
473         .demod_address = 0x08,                    436         .demod_address = 0x08,
474         .invert        = 1,                       437         .invert        = 1,
475         .invert_oclk   = 0,                       438         .invert_oclk   = 0,
476         .xtal_freq     = TDA10046_XTAL_16M,       439         .xtal_freq     = TDA10046_XTAL_16M,
477         .agc_config    = TDA10046_AGC_IFO_AUTO    440         .agc_config    = TDA10046_AGC_IFO_AUTO_NEG,
478         .if_freq       = TDA10046_FREQ_3613,      441         .if_freq       = TDA10046_FREQ_3613,
479         .tuner_address = 0x61,                    442         .tuner_address = 0x61,
480         .request_firmware = philips_tda1004x_r    443         .request_firmware = philips_tda1004x_request_firmware
481 };                                                444 };
482                                                   445 
483 /* -------------------------------------------    446 /* ------------------------------------------------------------------
484  * tda 1004x based cards with philips silicon     447  * tda 1004x based cards with philips silicon tuner
485  */                                               448  */
486                                                   449 
                                                   >> 450 static void philips_tda827x_lna_gain(struct dvb_frontend *fe, int high)
                                                   >> 451 {
                                                   >> 452         struct saa7134_dev *dev = fe->dvb->priv;
                                                   >> 453         struct tda1004x_state *state = fe->demodulator_priv;
                                                   >> 454         u8 addr = state->config->i2c_gate;
                                                   >> 455         u8 config = state->config->tuner_config;
                                                   >> 456         u8 GP00_CF[] = {0x20, 0x01};
                                                   >> 457         u8 GP00_LEV[] = {0x22, 0x00};
                                                   >> 458 
                                                   >> 459         struct i2c_msg msg = {.addr = addr,.flags = 0,.buf = GP00_CF, .len = 2};
                                                   >> 460         if (config) {
                                                   >> 461                 if (high) {
                                                   >> 462                         dprintk("setting LNA to high gain\n");
                                                   >> 463                 } else {
                                                   >> 464                         dprintk("setting LNA to low gain\n");
                                                   >> 465                 }
                                                   >> 466         }
                                                   >> 467         switch (config) {
                                                   >> 468         case 0: /* no LNA */
                                                   >> 469                 break;
                                                   >> 470         case 1: /* switch is GPIO 0 of tda8290 */
                                                   >> 471         case 2:
                                                   >> 472                 /* turn Vsync off */
                                                   >> 473                 saa7134_set_gpio(dev, 22, 0);
                                                   >> 474                 GP00_LEV[1] = high ? 0 : 1;
                                                   >> 475                 if (i2c_transfer(&dev->i2c_adap, &msg, 1) != 1) {
                                                   >> 476                         wprintk("could not access tda8290 at addr: 0x%02x\n",
                                                   >> 477                                 addr << 1);
                                                   >> 478                         return;
                                                   >> 479                 }
                                                   >> 480                 msg.buf = GP00_LEV;
                                                   >> 481                 if (config == 2)
                                                   >> 482                         GP00_LEV[1] = high ? 1 : 0;
                                                   >> 483                 i2c_transfer(&dev->i2c_adap, &msg, 1);
                                                   >> 484                 break;
                                                   >> 485         case 3: /* switch with GPIO of saa713x */
                                                   >> 486                 saa7134_set_gpio(dev, 22, high);
                                                   >> 487                 break;
                                                   >> 488         }
                                                   >> 489 }
                                                   >> 490 
487 static int tda8290_i2c_gate_ctrl( struct dvb_f    491 static int tda8290_i2c_gate_ctrl( struct dvb_frontend* fe, int enable)
488 {                                                 492 {
489         struct tda1004x_state *state = fe->dem    493         struct tda1004x_state *state = fe->demodulator_priv;
490                                                   494 
491         u8 addr = state->config->i2c_gate;        495         u8 addr = state->config->i2c_gate;
492         static u8 tda8290_close[] = { 0x21, 0x    496         static u8 tda8290_close[] = { 0x21, 0xc0};
493         static u8 tda8290_open[]  = { 0x21, 0x    497         static u8 tda8290_open[]  = { 0x21, 0x80};
494         struct i2c_msg tda8290_msg = {.addr =     498         struct i2c_msg tda8290_msg = {.addr = addr,.flags = 0, .len = 2};
495         if (enable) {                             499         if (enable) {
496                 tda8290_msg.buf = tda8290_clos    500                 tda8290_msg.buf = tda8290_close;
497         } else {                                  501         } else {
498                 tda8290_msg.buf = tda8290_open    502                 tda8290_msg.buf = tda8290_open;
499         }                                         503         }
500         if (i2c_transfer(state->i2c, &tda8290_    504         if (i2c_transfer(state->i2c, &tda8290_msg, 1) != 1) {
501                 struct saa7134_dev *dev = fe->    505                 struct saa7134_dev *dev = fe->dvb->priv;
502                 wprintk("could not access tda8    506                 wprintk("could not access tda8290 I2C gate\n");
503                 return -EIO;                      507                 return -EIO;
504         }                                         508         }
505         msleep(20);                               509         msleep(20);
506         return 0;                                 510         return 0;
507 }                                                 511 }
508                                                   512 
                                                   >> 513 /* ------------------------------------------------------------------ */
                                                   >> 514 
509 static int philips_tda827x_tuner_init(struct d    515 static int philips_tda827x_tuner_init(struct dvb_frontend *fe)
510 {                                                 516 {
511         struct saa7134_dev *dev = fe->dvb->pri    517         struct saa7134_dev *dev = fe->dvb->priv;
512         struct tda1004x_state *state = fe->dem    518         struct tda1004x_state *state = fe->demodulator_priv;
513                                                   519 
514         switch (state->config->antenna_switch)    520         switch (state->config->antenna_switch) {
515         case 0: break;                            521         case 0: break;
516         case 1: dprintk("setting GPIO21 to 0 (    522         case 1: dprintk("setting GPIO21 to 0 (TV antenna?)\n");
517                 saa7134_set_gpio(dev, 21, 0);     523                 saa7134_set_gpio(dev, 21, 0);
518                 break;                            524                 break;
519         case 2: dprintk("setting GPIO21 to 1 (    525         case 2: dprintk("setting GPIO21 to 1 (Radio antenna?)\n");
520                 saa7134_set_gpio(dev, 21, 1);     526                 saa7134_set_gpio(dev, 21, 1);
521                 break;                            527                 break;
522         }                                         528         }
523         return 0;                                 529         return 0;
524 }                                                 530 }
525                                                   531 
526 static int philips_tda827x_tuner_sleep(struct     532 static int philips_tda827x_tuner_sleep(struct dvb_frontend *fe)
527 {                                                 533 {
528         struct saa7134_dev *dev = fe->dvb->pri    534         struct saa7134_dev *dev = fe->dvb->priv;
529         struct tda1004x_state *state = fe->dem    535         struct tda1004x_state *state = fe->demodulator_priv;
530                                                   536 
531         switch (state->config->antenna_switch)    537         switch (state->config->antenna_switch) {
532         case 0: break;                            538         case 0: break;
533         case 1: dprintk("setting GPIO21 to 1 (    539         case 1: dprintk("setting GPIO21 to 1 (Radio antenna?)\n");
534                 saa7134_set_gpio(dev, 21, 1);     540                 saa7134_set_gpio(dev, 21, 1);
535                 break;                            541                 break;
536         case 2: dprintk("setting GPIO21 to 0 (    542         case 2: dprintk("setting GPIO21 to 0 (TV antenna?)\n");
537                 saa7134_set_gpio(dev, 21, 0);     543                 saa7134_set_gpio(dev, 21, 0);
538                 break;                            544                 break;
539         }                                         545         }
540         return 0;                                 546         return 0;
541 }                                                 547 }
542                                                   548 
543 static int configure_tda827x_fe(struct saa7134 !! 549 static struct tda827x_config tda827x_cfg = {
544                                 struct tda1004 !! 550         .lna_gain = philips_tda827x_lna_gain,
545                                 struct tda827x << 
546 {                                              << 
547         struct videobuf_dvb_frontend *fe0;     << 
548                                                << 
549         /* Get the first frontend */           << 
550         fe0 = videobuf_dvb_get_frontend(&dev-> << 
551                                                << 
552         fe0->dvb.frontend = dvb_attach(tda1004 << 
553         if (fe0->dvb.frontend) {               << 
554                 if (cdec_conf->i2c_gate)       << 
555                         fe0->dvb.frontend->ops << 
556                 if (dvb_attach(tda827x_attach, << 
557                                cdec_conf->tune << 
558                                &dev->i2c_adap, << 
559                         return 0;              << 
560                                                << 
561                 wprintk("no tda827x tuner foun << 
562                                 cdec_conf->tun << 
563         }                                      << 
564         return -EINVAL;                        << 
565 }                                              << 
566                                                << 
567 /* ------------------------------------------- << 
568                                                << 
569 static struct tda827x_config tda827x_cfg_0 = { << 
570         .init = philips_tda827x_tuner_init,    << 
571         .sleep = philips_tda827x_tuner_sleep,  << 
572         .config = 0,                           << 
573         .switch_addr = 0                       << 
574 };                                             << 
575                                                << 
576 static struct tda827x_config tda827x_cfg_1 = { << 
577         .init = philips_tda827x_tuner_init,    << 
578         .sleep = philips_tda827x_tuner_sleep,  << 
579         .config = 1,                           << 
580         .switch_addr = 0x4b                    << 
581 };                                             << 
582                                                << 
583 static struct tda827x_config tda827x_cfg_2 = { << 
584         .init = philips_tda827x_tuner_init,       551         .init = philips_tda827x_tuner_init,
585         .sleep = philips_tda827x_tuner_sleep,  !! 552         .sleep = philips_tda827x_tuner_sleep
586         .config = 2,                           << 
587         .switch_addr = 0x4b                    << 
588 };                                                553 };
589                                                   554 
590 static struct tda827x_config tda827x_cfg_2_sw4 !! 555 static void configure_tda827x_fe(struct saa7134_dev *dev, struct tda1004x_config *tda_conf)
591         .init = philips_tda827x_tuner_init,    !! 556 {
592         .sleep = philips_tda827x_tuner_sleep,  !! 557         dev->dvb.frontend = dvb_attach(tda10046_attach, tda_conf, &dev->i2c_adap);
593         .config = 2,                           !! 558         if (dev->dvb.frontend) {
594         .switch_addr = 0x42                    !! 559                 if (tda_conf->i2c_gate)
595 };                                             !! 560                         dev->dvb.frontend->ops.i2c_gate_ctrl = tda8290_i2c_gate_ctrl;
                                                   >> 561                 if (dvb_attach(tda827x_attach, dev->dvb.frontend, tda_conf->tuner_address,
                                                   >> 562                                                 &dev->i2c_adap,&tda827x_cfg) == NULL) {
                                                   >> 563                         wprintk("no tda827x tuner found at addr: %02x\n",
                                                   >> 564                                 tda_conf->tuner_address);
                                                   >> 565                 }
                                                   >> 566         }
                                                   >> 567 }
596                                                   568 
597 /* -------------------------------------------    569 /* ------------------------------------------------------------------ */
598                                                   570 
599 static struct tda1004x_config tda827x_lifeview    571 static struct tda1004x_config tda827x_lifeview_config = {
600         .demod_address = 0x08,                    572         .demod_address = 0x08,
601         .invert        = 1,                       573         .invert        = 1,
602         .invert_oclk   = 0,                       574         .invert_oclk   = 0,
603         .xtal_freq     = TDA10046_XTAL_16M,       575         .xtal_freq     = TDA10046_XTAL_16M,
604         .agc_config    = TDA10046_AGC_TDA827X,    576         .agc_config    = TDA10046_AGC_TDA827X,
605         .gpio_config   = TDA10046_GP11_I,         577         .gpio_config   = TDA10046_GP11_I,
606         .if_freq       = TDA10046_FREQ_045,       578         .if_freq       = TDA10046_FREQ_045,
607         .tuner_address = 0x60,                    579         .tuner_address = 0x60,
608         .request_firmware = philips_tda1004x_r    580         .request_firmware = philips_tda1004x_request_firmware
609 };                                                581 };
610                                                   582 
611 static struct tda1004x_config philips_tiger_co    583 static struct tda1004x_config philips_tiger_config = {
612         .demod_address = 0x08,                    584         .demod_address = 0x08,
613         .invert        = 1,                       585         .invert        = 1,
614         .invert_oclk   = 0,                       586         .invert_oclk   = 0,
615         .xtal_freq     = TDA10046_XTAL_16M,       587         .xtal_freq     = TDA10046_XTAL_16M,
616         .agc_config    = TDA10046_AGC_TDA827X,    588         .agc_config    = TDA10046_AGC_TDA827X,
617         .gpio_config   = TDA10046_GP11_I,         589         .gpio_config   = TDA10046_GP11_I,
618         .if_freq       = TDA10046_FREQ_045,       590         .if_freq       = TDA10046_FREQ_045,
619         .i2c_gate      = 0x4b,                    591         .i2c_gate      = 0x4b,
620         .tuner_address = 0x61,                    592         .tuner_address = 0x61,
                                                   >> 593         .tuner_config  = 0,
621         .antenna_switch= 1,                       594         .antenna_switch= 1,
622         .request_firmware = philips_tda1004x_r    595         .request_firmware = philips_tda1004x_request_firmware
623 };                                                596 };
624                                                   597 
625 static struct tda1004x_config cinergy_ht_confi    598 static struct tda1004x_config cinergy_ht_config = {
626         .demod_address = 0x08,                    599         .demod_address = 0x08,
627         .invert        = 1,                       600         .invert        = 1,
628         .invert_oclk   = 0,                       601         .invert_oclk   = 0,
629         .xtal_freq     = TDA10046_XTAL_16M,       602         .xtal_freq     = TDA10046_XTAL_16M,
630         .agc_config    = TDA10046_AGC_TDA827X,    603         .agc_config    = TDA10046_AGC_TDA827X,
631         .gpio_config   = TDA10046_GP01_I,         604         .gpio_config   = TDA10046_GP01_I,
632         .if_freq       = TDA10046_FREQ_045,       605         .if_freq       = TDA10046_FREQ_045,
633         .i2c_gate      = 0x4b,                    606         .i2c_gate      = 0x4b,
634         .tuner_address = 0x61,                    607         .tuner_address = 0x61,
                                                   >> 608         .tuner_config  = 0,
635         .request_firmware = philips_tda1004x_r    609         .request_firmware = philips_tda1004x_request_firmware
636 };                                                610 };
637                                                   611 
638 static struct tda1004x_config cinergy_ht_pci_c    612 static struct tda1004x_config cinergy_ht_pci_config = {
639         .demod_address = 0x08,                    613         .demod_address = 0x08,
640         .invert        = 1,                       614         .invert        = 1,
641         .invert_oclk   = 0,                       615         .invert_oclk   = 0,
642         .xtal_freq     = TDA10046_XTAL_16M,       616         .xtal_freq     = TDA10046_XTAL_16M,
643         .agc_config    = TDA10046_AGC_TDA827X,    617         .agc_config    = TDA10046_AGC_TDA827X,
644         .gpio_config   = TDA10046_GP01_I,         618         .gpio_config   = TDA10046_GP01_I,
645         .if_freq       = TDA10046_FREQ_045,       619         .if_freq       = TDA10046_FREQ_045,
646         .i2c_gate      = 0x4b,                    620         .i2c_gate      = 0x4b,
647         .tuner_address = 0x60,                    621         .tuner_address = 0x60,
                                                   >> 622         .tuner_config  = 0,
648         .request_firmware = philips_tda1004x_r    623         .request_firmware = philips_tda1004x_request_firmware
649 };                                                624 };
650                                                   625 
651 static struct tda1004x_config philips_tiger_s_    626 static struct tda1004x_config philips_tiger_s_config = {
652         .demod_address = 0x08,                    627         .demod_address = 0x08,
653         .invert        = 1,                       628         .invert        = 1,
654         .invert_oclk   = 0,                       629         .invert_oclk   = 0,
655         .xtal_freq     = TDA10046_XTAL_16M,       630         .xtal_freq     = TDA10046_XTAL_16M,
656         .agc_config    = TDA10046_AGC_TDA827X,    631         .agc_config    = TDA10046_AGC_TDA827X,
657         .gpio_config   = TDA10046_GP01_I,         632         .gpio_config   = TDA10046_GP01_I,
658         .if_freq       = TDA10046_FREQ_045,       633         .if_freq       = TDA10046_FREQ_045,
659         .i2c_gate      = 0x4b,                    634         .i2c_gate      = 0x4b,
660         .tuner_address = 0x61,                    635         .tuner_address = 0x61,
                                                   >> 636         .tuner_config  = 2,
661         .antenna_switch= 1,                       637         .antenna_switch= 1,
662         .request_firmware = philips_tda1004x_r    638         .request_firmware = philips_tda1004x_request_firmware
663 };                                                639 };
664                                                   640 
665 static struct tda1004x_config pinnacle_pctv_31    641 static struct tda1004x_config pinnacle_pctv_310i_config = {
666         .demod_address = 0x08,                    642         .demod_address = 0x08,
667         .invert        = 1,                       643         .invert        = 1,
668         .invert_oclk   = 0,                       644         .invert_oclk   = 0,
669         .xtal_freq     = TDA10046_XTAL_16M,       645         .xtal_freq     = TDA10046_XTAL_16M,
670         .agc_config    = TDA10046_AGC_TDA827X,    646         .agc_config    = TDA10046_AGC_TDA827X,
671         .gpio_config   = TDA10046_GP11_I,         647         .gpio_config   = TDA10046_GP11_I,
672         .if_freq       = TDA10046_FREQ_045,       648         .if_freq       = TDA10046_FREQ_045,
673         .i2c_gate      = 0x4b,                    649         .i2c_gate      = 0x4b,
674         .tuner_address = 0x61,                    650         .tuner_address = 0x61,
                                                   >> 651         .tuner_config  = 1,
675         .request_firmware = philips_tda1004x_r    652         .request_firmware = philips_tda1004x_request_firmware
676 };                                                653 };
677                                                   654 
678 static struct tda1004x_config hauppauge_hvr_11    655 static struct tda1004x_config hauppauge_hvr_1110_config = {
679         .demod_address = 0x08,                    656         .demod_address = 0x08,
680         .invert        = 1,                       657         .invert        = 1,
681         .invert_oclk   = 0,                       658         .invert_oclk   = 0,
682         .xtal_freq     = TDA10046_XTAL_16M,       659         .xtal_freq     = TDA10046_XTAL_16M,
683         .agc_config    = TDA10046_AGC_TDA827X,    660         .agc_config    = TDA10046_AGC_TDA827X,
684         .gpio_config   = TDA10046_GP11_I,         661         .gpio_config   = TDA10046_GP11_I,
685         .if_freq       = TDA10046_FREQ_045,       662         .if_freq       = TDA10046_FREQ_045,
686         .i2c_gate      = 0x4b,                    663         .i2c_gate      = 0x4b,
687         .tuner_address = 0x61,                    664         .tuner_address = 0x61,
                                                   >> 665         .tuner_config  = 1,
688         .request_firmware = philips_tda1004x_r    666         .request_firmware = philips_tda1004x_request_firmware
689 };                                                667 };
690                                                   668 
691 static struct tda1004x_config asus_p7131_dual_    669 static struct tda1004x_config asus_p7131_dual_config = {
692         .demod_address = 0x08,                    670         .demod_address = 0x08,
693         .invert        = 1,                       671         .invert        = 1,
694         .invert_oclk   = 0,                       672         .invert_oclk   = 0,
695         .xtal_freq     = TDA10046_XTAL_16M,       673         .xtal_freq     = TDA10046_XTAL_16M,
696         .agc_config    = TDA10046_AGC_TDA827X,    674         .agc_config    = TDA10046_AGC_TDA827X,
697         .gpio_config   = TDA10046_GP11_I,         675         .gpio_config   = TDA10046_GP11_I,
698         .if_freq       = TDA10046_FREQ_045,       676         .if_freq       = TDA10046_FREQ_045,
699         .i2c_gate      = 0x4b,                    677         .i2c_gate      = 0x4b,
700         .tuner_address = 0x61,                    678         .tuner_address = 0x61,
                                                   >> 679         .tuner_config  = 0,
701         .antenna_switch= 2,                       680         .antenna_switch= 2,
702         .request_firmware = philips_tda1004x_r    681         .request_firmware = philips_tda1004x_request_firmware
703 };                                                682 };
704                                                   683 
705 static struct tda1004x_config lifeview_trio_co    684 static struct tda1004x_config lifeview_trio_config = {
706         .demod_address = 0x09,                    685         .demod_address = 0x09,
707         .invert        = 1,                       686         .invert        = 1,
708         .invert_oclk   = 0,                       687         .invert_oclk   = 0,
709         .xtal_freq     = TDA10046_XTAL_16M,       688         .xtal_freq     = TDA10046_XTAL_16M,
710         .agc_config    = TDA10046_AGC_TDA827X,    689         .agc_config    = TDA10046_AGC_TDA827X,
711         .gpio_config   = TDA10046_GP00_I,         690         .gpio_config   = TDA10046_GP00_I,
712         .if_freq       = TDA10046_FREQ_045,       691         .if_freq       = TDA10046_FREQ_045,
713         .tuner_address = 0x60,                    692         .tuner_address = 0x60,
714         .request_firmware = philips_tda1004x_r    693         .request_firmware = philips_tda1004x_request_firmware
715 };                                                694 };
716                                                   695 
717 static struct tda1004x_config tevion_dvbt220rf    696 static struct tda1004x_config tevion_dvbt220rf_config = {
718         .demod_address = 0x08,                    697         .demod_address = 0x08,
719         .invert        = 1,                       698         .invert        = 1,
720         .invert_oclk   = 0,                       699         .invert_oclk   = 0,
721         .xtal_freq     = TDA10046_XTAL_16M,       700         .xtal_freq     = TDA10046_XTAL_16M,
722         .agc_config    = TDA10046_AGC_TDA827X,    701         .agc_config    = TDA10046_AGC_TDA827X,
723         .gpio_config   = TDA10046_GP11_I,         702         .gpio_config   = TDA10046_GP11_I,
724         .if_freq       = TDA10046_FREQ_045,       703         .if_freq       = TDA10046_FREQ_045,
725         .tuner_address = 0x60,                    704         .tuner_address = 0x60,
726         .request_firmware = philips_tda1004x_r    705         .request_firmware = philips_tda1004x_request_firmware
727 };                                                706 };
728                                                   707 
729 static struct tda1004x_config md8800_dvbt_conf    708 static struct tda1004x_config md8800_dvbt_config = {
730         .demod_address = 0x08,                    709         .demod_address = 0x08,
731         .invert        = 1,                       710         .invert        = 1,
732         .invert_oclk   = 0,                       711         .invert_oclk   = 0,
733         .xtal_freq     = TDA10046_XTAL_16M,       712         .xtal_freq     = TDA10046_XTAL_16M,
734         .agc_config    = TDA10046_AGC_TDA827X,    713         .agc_config    = TDA10046_AGC_TDA827X,
735         .gpio_config   = TDA10046_GP01_I,         714         .gpio_config   = TDA10046_GP01_I,
736         .if_freq       = TDA10046_FREQ_045,       715         .if_freq       = TDA10046_FREQ_045,
737         .i2c_gate      = 0x4b,                    716         .i2c_gate      = 0x4b,
738         .tuner_address = 0x60,                    717         .tuner_address = 0x60,
                                                   >> 718         .tuner_config  = 0,
739         .request_firmware = philips_tda1004x_r    719         .request_firmware = philips_tda1004x_request_firmware
740 };                                                720 };
741                                                   721 
742 static struct tda1004x_config asus_p7131_4871_    722 static struct tda1004x_config asus_p7131_4871_config = {
743         .demod_address = 0x08,                    723         .demod_address = 0x08,
744         .invert        = 1,                       724         .invert        = 1,
745         .invert_oclk   = 0,                       725         .invert_oclk   = 0,
746         .xtal_freq     = TDA10046_XTAL_16M,       726         .xtal_freq     = TDA10046_XTAL_16M,
747         .agc_config    = TDA10046_AGC_TDA827X,    727         .agc_config    = TDA10046_AGC_TDA827X,
748         .gpio_config   = TDA10046_GP01_I,         728         .gpio_config   = TDA10046_GP01_I,
749         .if_freq       = TDA10046_FREQ_045,       729         .if_freq       = TDA10046_FREQ_045,
750         .i2c_gate      = 0x4b,                    730         .i2c_gate      = 0x4b,
751         .tuner_address = 0x61,                    731         .tuner_address = 0x61,
                                                   >> 732         .tuner_config  = 2,
752         .antenna_switch= 2,                       733         .antenna_switch= 2,
753         .request_firmware = philips_tda1004x_r    734         .request_firmware = philips_tda1004x_request_firmware
754 };                                                735 };
755                                                   736 
756 static struct tda1004x_config asus_p7131_hybri    737 static struct tda1004x_config asus_p7131_hybrid_lna_config = {
757         .demod_address = 0x08,                    738         .demod_address = 0x08,
758         .invert        = 1,                       739         .invert        = 1,
759         .invert_oclk   = 0,                       740         .invert_oclk   = 0,
760         .xtal_freq     = TDA10046_XTAL_16M,       741         .xtal_freq     = TDA10046_XTAL_16M,
761         .agc_config    = TDA10046_AGC_TDA827X,    742         .agc_config    = TDA10046_AGC_TDA827X,
762         .gpio_config   = TDA10046_GP11_I,         743         .gpio_config   = TDA10046_GP11_I,
763         .if_freq       = TDA10046_FREQ_045,       744         .if_freq       = TDA10046_FREQ_045,
764         .i2c_gate      = 0x4b,                    745         .i2c_gate      = 0x4b,
765         .tuner_address = 0x61,                    746         .tuner_address = 0x61,
                                                   >> 747         .tuner_config  = 2,
766         .antenna_switch= 2,                       748         .antenna_switch= 2,
767         .request_firmware = philips_tda1004x_r    749         .request_firmware = philips_tda1004x_request_firmware
768 };                                                750 };
769                                                   751 
770 static struct tda1004x_config kworld_dvb_t_210    752 static struct tda1004x_config kworld_dvb_t_210_config = {
771         .demod_address = 0x08,                    753         .demod_address = 0x08,
772         .invert        = 1,                       754         .invert        = 1,
773         .invert_oclk   = 0,                       755         .invert_oclk   = 0,
774         .xtal_freq     = TDA10046_XTAL_16M,       756         .xtal_freq     = TDA10046_XTAL_16M,
775         .agc_config    = TDA10046_AGC_TDA827X,    757         .agc_config    = TDA10046_AGC_TDA827X,
776         .gpio_config   = TDA10046_GP11_I,         758         .gpio_config   = TDA10046_GP11_I,
777         .if_freq       = TDA10046_FREQ_045,       759         .if_freq       = TDA10046_FREQ_045,
778         .i2c_gate      = 0x4b,                    760         .i2c_gate      = 0x4b,
779         .tuner_address = 0x61,                    761         .tuner_address = 0x61,
                                                   >> 762         .tuner_config  = 2,
780         .antenna_switch= 1,                       763         .antenna_switch= 1,
781         .request_firmware = philips_tda1004x_r    764         .request_firmware = philips_tda1004x_request_firmware
782 };                                                765 };
783                                                   766 
784 static struct tda1004x_config avermedia_super_    767 static struct tda1004x_config avermedia_super_007_config = {
785         .demod_address = 0x08,                    768         .demod_address = 0x08,
786         .invert        = 1,                       769         .invert        = 1,
787         .invert_oclk   = 0,                       770         .invert_oclk   = 0,
788         .xtal_freq     = TDA10046_XTAL_16M,       771         .xtal_freq     = TDA10046_XTAL_16M,
789         .agc_config    = TDA10046_AGC_TDA827X,    772         .agc_config    = TDA10046_AGC_TDA827X,
790         .gpio_config   = TDA10046_GP01_I,         773         .gpio_config   = TDA10046_GP01_I,
791         .if_freq       = TDA10046_FREQ_045,       774         .if_freq       = TDA10046_FREQ_045,
792         .i2c_gate      = 0x4b,                    775         .i2c_gate      = 0x4b,
793         .tuner_address = 0x60,                    776         .tuner_address = 0x60,
                                                   >> 777         .tuner_config  = 0,
794         .antenna_switch= 1,                       778         .antenna_switch= 1,
795         .request_firmware = philips_tda1004x_r    779         .request_firmware = philips_tda1004x_request_firmware
796 };                                                780 };
797                                                   781 
798 static struct tda1004x_config twinhan_dtv_dvb_    782 static struct tda1004x_config twinhan_dtv_dvb_3056_config = {
799         .demod_address = 0x08,                    783         .demod_address = 0x08,
800         .invert        = 1,                       784         .invert        = 1,
801         .invert_oclk   = 0,                       785         .invert_oclk   = 0,
802         .xtal_freq     = TDA10046_XTAL_16M,       786         .xtal_freq     = TDA10046_XTAL_16M,
803         .agc_config    = TDA10046_AGC_TDA827X,    787         .agc_config    = TDA10046_AGC_TDA827X,
804         .gpio_config   = TDA10046_GP01_I,         788         .gpio_config   = TDA10046_GP01_I,
805         .if_freq       = TDA10046_FREQ_045,       789         .if_freq       = TDA10046_FREQ_045,
806         .i2c_gate      = 0x42,                    790         .i2c_gate      = 0x42,
807         .tuner_address = 0x61,                    791         .tuner_address = 0x61,
808         .antenna_switch = 1,                   !! 792         .tuner_config  = 2,
809         .request_firmware = philips_tda1004x_r << 
810 };                                             << 
811                                                << 
812 static struct tda1004x_config asus_tiger_3in1_ << 
813         .demod_address = 0x0b,                 << 
814         .invert        = 1,                    << 
815         .invert_oclk   = 0,                    << 
816         .xtal_freq     = TDA10046_XTAL_16M,    << 
817         .agc_config    = TDA10046_AGC_TDA827X, << 
818         .gpio_config   = TDA10046_GP11_I,      << 
819         .if_freq       = TDA10046_FREQ_045,    << 
820         .i2c_gate      = 0x4b,                 << 
821         .tuner_address = 0x61,                 << 
822         .antenna_switch = 1,                      793         .antenna_switch = 1,
823         .request_firmware = philips_tda1004x_r    794         .request_firmware = philips_tda1004x_request_firmware
824 };                                                795 };
825                                                   796 
826 /* -------------------------------------------    797 /* ------------------------------------------------------------------
827  * special case: this card uses saa713x GPIO22    798  * special case: this card uses saa713x GPIO22 for the mode switch
828  */                                               799  */
829                                                   800 
830 static int ads_duo_tuner_init(struct dvb_front    801 static int ads_duo_tuner_init(struct dvb_frontend *fe)
831 {                                                 802 {
832         struct saa7134_dev *dev = fe->dvb->pri    803         struct saa7134_dev *dev = fe->dvb->priv;
833         philips_tda827x_tuner_init(fe);           804         philips_tda827x_tuner_init(fe);
834         /* route TDA8275a AGC input to the cha    805         /* route TDA8275a AGC input to the channel decoder */
835         saa7134_set_gpio(dev, 22, 1);             806         saa7134_set_gpio(dev, 22, 1);
836         return 0;                                 807         return 0;
837 }                                                 808 }
838                                                   809 
839 static int ads_duo_tuner_sleep(struct dvb_fron    810 static int ads_duo_tuner_sleep(struct dvb_frontend *fe)
840 {                                                 811 {
841         struct saa7134_dev *dev = fe->dvb->pri    812         struct saa7134_dev *dev = fe->dvb->priv;
842         /* route TDA8275a AGC input to the ana    813         /* route TDA8275a AGC input to the analog IF chip*/
843         saa7134_set_gpio(dev, 22, 0);             814         saa7134_set_gpio(dev, 22, 0);
844         philips_tda827x_tuner_sleep(fe);          815         philips_tda827x_tuner_sleep(fe);
845         return 0;                                 816         return 0;
846 }                                                 817 }
847                                                   818 
848 static struct tda827x_config ads_duo_cfg = {      819 static struct tda827x_config ads_duo_cfg = {
                                                   >> 820         .lna_gain = philips_tda827x_lna_gain,
849         .init = ads_duo_tuner_init,               821         .init = ads_duo_tuner_init,
850         .sleep = ads_duo_tuner_sleep,          !! 822         .sleep = ads_duo_tuner_sleep
851         .config = 0                            << 
852 };                                                823 };
853                                                   824 
854 static struct tda1004x_config ads_tech_duo_con    825 static struct tda1004x_config ads_tech_duo_config = {
855         .demod_address = 0x08,                    826         .demod_address = 0x08,
856         .invert        = 1,                       827         .invert        = 1,
857         .invert_oclk   = 0,                       828         .invert_oclk   = 0,
858         .xtal_freq     = TDA10046_XTAL_16M,       829         .xtal_freq     = TDA10046_XTAL_16M,
859         .agc_config    = TDA10046_AGC_TDA827X,    830         .agc_config    = TDA10046_AGC_TDA827X,
860         .gpio_config   = TDA10046_GP00_I,         831         .gpio_config   = TDA10046_GP00_I,
861         .if_freq       = TDA10046_FREQ_045,       832         .if_freq       = TDA10046_FREQ_045,
862         .tuner_address = 0x61,                    833         .tuner_address = 0x61,
863         .request_firmware = philips_tda1004x_r    834         .request_firmware = philips_tda1004x_request_firmware
864 };                                                835 };
865                                                   836 
866 static struct zl10353_config behold_h6_config  << 
867         .demod_address = 0x1e>>1,              << 
868         .no_tuner      = 1,                    << 
869         .parallel_ts   = 1,                    << 
870         .disable_i2c_gate_ctrl = 1,            << 
871 };                                             << 
872                                                << 
873 /* ===========================================    837 /* ==================================================================
874  * tda10086 based DVB-S cards, helper function    838  * tda10086 based DVB-S cards, helper functions
875  */                                               839  */
876                                                   840 
877 static struct tda10086_config flydvbs = {         841 static struct tda10086_config flydvbs = {
878         .demod_address = 0x0e,                    842         .demod_address = 0x0e,
879         .invert = 0,                              843         .invert = 0,
880         .diseqc_tone = 0,                         844         .diseqc_tone = 0,
881         .xtal_freq = TDA10086_XTAL_16M,        << 
882 };                                             << 
883                                                << 
884 static struct tda10086_config sd1878_4m = {    << 
885         .demod_address = 0x0e,                 << 
886         .invert = 0,                           << 
887         .diseqc_tone = 0,                      << 
888         .xtal_freq = TDA10086_XTAL_4M,         << 
889 };                                             << 
890                                                << 
891 /* ------------------------------------------- << 
892  * special case: lnb supply is connected to th << 
893  */                                            << 
894                                                << 
895 static int md8800_set_voltage(struct dvb_front << 
896 {                                              << 
897         int res = -EIO;                        << 
898         struct saa7134_dev *dev = fe->dvb->pri << 
899         if (fe->ops.i2c_gate_ctrl) {           << 
900                 fe->ops.i2c_gate_ctrl(fe, 1);  << 
901                 if (dev->original_set_voltage) << 
902                         res = dev->original_se << 
903                 fe->ops.i2c_gate_ctrl(fe, 0);  << 
904         }                                      << 
905         return res;                            << 
906 };                                             << 
907                                                << 
908 static int md8800_set_high_voltage(struct dvb_ << 
909 {                                              << 
910         int res = -EIO;                        << 
911         struct saa7134_dev *dev = fe->dvb->pri << 
912         if (fe->ops.i2c_gate_ctrl) {           << 
913                 fe->ops.i2c_gate_ctrl(fe, 1);  << 
914                 if (dev->original_set_high_vol << 
915                         res = dev->original_se << 
916                 fe->ops.i2c_gate_ctrl(fe, 0);  << 
917         }                                      << 
918         return res;                            << 
919 };                                                845 };
920                                                   846 
921 static int md8800_set_voltage2(struct dvb_fron << 
922 {                                              << 
923         struct saa7134_dev *dev = fe->dvb->pri << 
924         u8 wbuf[2] = { 0x1f, 00 };             << 
925         u8 rbuf;                               << 
926         struct i2c_msg msg[] = { { .addr = 0x0 << 
927                                  { .addr = 0x0 << 
928                                                << 
929         if (i2c_transfer(&dev->i2c_adap, msg,  << 
930                 return -EIO;                   << 
931         /* NOTE: this assumes that gpo1 is use << 
932         if (voltage == SEC_VOLTAGE_18)         << 
933                 wbuf[1] = rbuf | 0x10;         << 
934         else                                   << 
935                 wbuf[1] = rbuf & 0xef;         << 
936         msg[0].len = 2;                        << 
937         i2c_transfer(&dev->i2c_adap, msg, 1);  << 
938         return 0;                              << 
939 }                                              << 
940                                                << 
941 static int md8800_set_high_voltage2(struct dvb << 
942 {                                              << 
943         struct saa7134_dev *dev = fe->dvb->pri << 
944         wprintk("%s: sorry can't set high LNB  << 
945         return -EIO;                           << 
946 }                                              << 
947                                                << 
948 /* ===========================================    847 /* ==================================================================
949  * nxt200x based ATSC cards, helper functions     848  * nxt200x based ATSC cards, helper functions
950  */                                               849  */
951                                                   850 
952 static struct nxt200x_config avertvhda180 = {     851 static struct nxt200x_config avertvhda180 = {
953         .demod_address    = 0x0a,                 852         .demod_address    = 0x0a,
954 };                                                853 };
955                                                   854 
956 static struct nxt200x_config kworldatsc110 = {    855 static struct nxt200x_config kworldatsc110 = {
957         .demod_address    = 0x0a,                 856         .demod_address    = 0x0a,
958 };                                                857 };
959                                                   858 
960 /* ------------------------------------------- << 
961                                                << 
962 static struct mt312_config avertv_a700_mt312 = << 
963         .demod_address = 0x0e,                 << 
964         .voltage_inverted = 1,                 << 
965 };                                             << 
966                                                << 
967 static struct zl10036_config avertv_a700_tuner << 
968         .tuner_address = 0x60,                 << 
969 };                                             << 
970                                                << 
971 static struct lgdt3305_config hcw_lgdt3305_con << 
972         .i2c_addr           = 0x0e,            << 
973         .mpeg_mode          = LGDT3305_MPEG_SE << 
974         .tpclk_edge         = LGDT3305_TPCLK_R << 
975         .tpvalid_polarity   = LGDT3305_TP_VALI << 
976         .deny_i2c_rptr      = 1,               << 
977         .spectral_inversion = 1,               << 
978         .qam_if_khz         = 4000,            << 
979         .vsb_if_khz         = 3250,            << 
980 };                                             << 
981                                                << 
982 static struct tda10048_config hcw_tda10048_con << 
983         .demod_address    = 0x10 >> 1,         << 
984         .output_mode      = TDA10048_SERIAL_OU << 
985         .fwbulkwritelen   = TDA10048_BULKWRITE << 
986         .inversion        = TDA10048_INVERSION << 
987         .dtv6_if_freq_khz = TDA10048_IF_3300,  << 
988         .dtv7_if_freq_khz = TDA10048_IF_3500,  << 
989         .dtv8_if_freq_khz = TDA10048_IF_4000,  << 
990         .clk_freq_khz     = TDA10048_CLK_16000 << 
991         .disable_gate_access = 1,              << 
992 };                                             << 
993                                                << 
994 static struct tda18271_std_map hauppauge_tda18 << 
995         .atsc_6   = { .if_freq = 3250, .agc_mo << 
996                       .if_lvl = 1, .rfagc_top  << 
997         .qam_6    = { .if_freq = 4000, .agc_mo << 
998                       .if_lvl = 1, .rfagc_top  << 
999 };                                             << 
1000                                               << 
1001 static struct tda18271_config hcw_tda18271_co << 
1002         .std_map = &hauppauge_tda18271_std_ma << 
1003         .gate    = TDA18271_GATE_ANALOG,      << 
1004         .config  = 3,                         << 
1005 };                                            << 
1006                                               << 
1007 static struct tda829x_config tda829x_no_probe << 
1008         .probe_tuner = TDA829X_DONT_PROBE,    << 
1009 };                                            << 
1010                                               << 
1011 /* ==========================================    859 /* ==================================================================
1012  * Core code                                     860  * Core code
1013  */                                              861  */
1014                                                  862 
1015 static int dvb_init(struct saa7134_dev *dev)     863 static int dvb_init(struct saa7134_dev *dev)
1016 {                                                864 {
1017         int ret;                                 865         int ret;
1018         int attach_xc3028 = 0;                << 
1019         struct videobuf_dvb_frontend *fe0;    << 
1020                                               << 
1021         /* FIXME: add support for multi-front << 
1022         mutex_init(&dev->frontends.lock);     << 
1023         INIT_LIST_HEAD(&dev->frontends.felist << 
1024                                               << 
1025         printk(KERN_INFO "%s() allocating 1 f << 
1026         fe0 = videobuf_dvb_alloc_frontend(&de << 
1027         if (!fe0) {                           << 
1028                 printk(KERN_ERR "%s() failed  << 
1029                 return -ENOMEM;               << 
1030         }                                     << 
1031                                               << 
1032         /* init struct videobuf_dvb */           866         /* init struct videobuf_dvb */
1033         dev->ts.nr_bufs    = 32;                 867         dev->ts.nr_bufs    = 32;
1034         dev->ts.nr_packets = 32*4;               868         dev->ts.nr_packets = 32*4;
1035         fe0->dvb.name = dev->name;            !! 869         dev->dvb.name = dev->name;
1036         videobuf_queue_sg_init(&fe0->dvb.dvbq !! 870         videobuf_queue_pci_init(&dev->dvb.dvbq, &saa7134_ts_qops,
1037                             &dev->pci->dev, & !! 871                             dev->pci, &dev->slock,
1038                             V4L2_BUF_TYPE_VID    872                             V4L2_BUF_TYPE_VIDEO_CAPTURE,
1039                             V4L2_FIELD_ALTERN    873                             V4L2_FIELD_ALTERNATE,
1040                             sizeof(struct saa    874                             sizeof(struct saa7134_buf),
1041                             dev);                875                             dev);
1042                                                  876 
1043         switch (dev->board) {                    877         switch (dev->board) {
1044         case SAA7134_BOARD_PINNACLE_300I_DVBT    878         case SAA7134_BOARD_PINNACLE_300I_DVBT_PAL:
1045                 dprintk("pinnacle 300i dvb se    879                 dprintk("pinnacle 300i dvb setup\n");
1046                 fe0->dvb.frontend = dvb_attac !! 880                 dev->dvb.frontend = dvb_attach(mt352_attach, &pinnacle_300i,
1047                                                  881                                                &dev->i2c_adap);
1048                 if (fe0->dvb.frontend) {      !! 882                 if (dev->dvb.frontend) {
1049                         fe0->dvb.frontend->op !! 883                         dev->dvb.frontend->ops.tuner_ops.set_params = mt352_pinnacle_tuner_set_params;
1050                 }                                884                 }
1051                 break;                           885                 break;
1052         case SAA7134_BOARD_AVERMEDIA_777:        886         case SAA7134_BOARD_AVERMEDIA_777:
1053         case SAA7134_BOARD_AVERMEDIA_A16AR:      887         case SAA7134_BOARD_AVERMEDIA_A16AR:
1054                 dprintk("avertv 777 dvb setup    888                 dprintk("avertv 777 dvb setup\n");
1055                 fe0->dvb.frontend = dvb_attac !! 889                 dev->dvb.frontend = dvb_attach(mt352_attach, &avermedia_777,
1056                                                  890                                                &dev->i2c_adap);
1057                 if (fe0->dvb.frontend) {      !! 891                 if (dev->dvb.frontend) {
1058                         dvb_attach(simple_tun !! 892                         dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x61,
1059                                    &dev->i2c_ !! 893                                    NULL, DVB_PLL_PHILIPS_TD1316);
1060                                    TUNER_PHIL << 
1061                 }                                894                 }
1062                 break;                           895                 break;
1063         case SAA7134_BOARD_AVERMEDIA_A16D:    << 
1064                 dprintk("AverMedia A16D dvb s << 
1065                 fe0->dvb.frontend = dvb_attac << 
1066                                               << 
1067                                               << 
1068                 attach_xc3028 = 1;            << 
1069                 break;                        << 
1070         case SAA7134_BOARD_MD7134:               896         case SAA7134_BOARD_MD7134:
1071                 fe0->dvb.frontend = dvb_attac !! 897                 dev->dvb.frontend = dvb_attach(tda10046_attach,
1072                                                  898                                                &medion_cardbus,
1073                                                  899                                                &dev->i2c_adap);
1074                 if (fe0->dvb.frontend) {      !! 900                 if (dev->dvb.frontend) {
1075                         dvb_attach(simple_tun !! 901                         dvb_attach(dvb_pll_attach, dev->dvb.frontend, medion_cardbus.tuner_address,
1076                                    &dev->i2c_ !! 902                                    &dev->i2c_adap, DVB_PLL_FMD1216ME);
1077                                    TUNER_PHIL << 
1078                 }                                903                 }
1079                 break;                           904                 break;
1080         case SAA7134_BOARD_PHILIPS_TOUGH:        905         case SAA7134_BOARD_PHILIPS_TOUGH:
1081                 fe0->dvb.frontend = dvb_attac !! 906                 dev->dvb.frontend = dvb_attach(tda10046_attach,
1082                                                  907                                                &philips_tu1216_60_config,
1083                                                  908                                                &dev->i2c_adap);
1084                 if (fe0->dvb.frontend) {      !! 909                 if (dev->dvb.frontend) {
1085                         fe0->dvb.frontend->op !! 910                         dev->dvb.frontend->ops.tuner_ops.init = philips_tu1216_init;
1086                         fe0->dvb.frontend->op !! 911                         dev->dvb.frontend->ops.tuner_ops.set_params = philips_tda6651_pll_set;
1087                 }                                912                 }
1088                 break;                           913                 break;
1089         case SAA7134_BOARD_FLYDVBTDUO:           914         case SAA7134_BOARD_FLYDVBTDUO:
1090         case SAA7134_BOARD_FLYDVBT_DUO_CARDBU    915         case SAA7134_BOARD_FLYDVBT_DUO_CARDBUS:
1091                 if (configure_tda827x_fe(dev, !! 916                 configure_tda827x_fe(dev, &tda827x_lifeview_config);
1092                                          &tda << 
1093                         goto dettach_frontend << 
1094                 break;                           917                 break;
1095         case SAA7134_BOARD_PHILIPS_EUROPA:       918         case SAA7134_BOARD_PHILIPS_EUROPA:
1096         case SAA7134_BOARD_VIDEOMATE_DVBT_300    919         case SAA7134_BOARD_VIDEOMATE_DVBT_300:
1097                 fe0->dvb.frontend = dvb_attac !! 920                 dev->dvb.frontend = dvb_attach(tda10046_attach,
1098                                                  921                                                &philips_europa_config,
1099                                                  922                                                &dev->i2c_adap);
1100                 if (fe0->dvb.frontend) {      !! 923                 if (dev->dvb.frontend) {
1101                         dev->original_demod_s !! 924                         dev->original_demod_sleep = dev->dvb.frontend->ops.sleep;
1102                         fe0->dvb.frontend->op !! 925                         dev->dvb.frontend->ops.sleep = philips_europa_demod_sleep;
1103                         fe0->dvb.frontend->op !! 926                         dev->dvb.frontend->ops.tuner_ops.init = philips_europa_tuner_init;
1104                         fe0->dvb.frontend->op !! 927                         dev->dvb.frontend->ops.tuner_ops.sleep = philips_europa_tuner_sleep;
1105                         fe0->dvb.frontend->op !! 928                         dev->dvb.frontend->ops.tuner_ops.set_params = philips_td1316_tuner_set_params;
1106                 }                                929                 }
1107                 break;                           930                 break;
1108         case SAA7134_BOARD_VIDEOMATE_DVBT_200    931         case SAA7134_BOARD_VIDEOMATE_DVBT_200:
1109                 fe0->dvb.frontend = dvb_attac !! 932                 dev->dvb.frontend = dvb_attach(tda10046_attach,
1110                                                  933                                                &philips_tu1216_61_config,
1111                                                  934                                                &dev->i2c_adap);
1112                 if (fe0->dvb.frontend) {      !! 935                 if (dev->dvb.frontend) {
1113                         fe0->dvb.frontend->op !! 936                         dev->dvb.frontend->ops.tuner_ops.init = philips_tu1216_init;
1114                         fe0->dvb.frontend->op !! 937                         dev->dvb.frontend->ops.tuner_ops.set_params = philips_tda6651_pll_set;
1115                 }                                938                 }
1116                 break;                           939                 break;
1117         case SAA7134_BOARD_KWORLD_DVBT_210:      940         case SAA7134_BOARD_KWORLD_DVBT_210:
1118                 if (configure_tda827x_fe(dev, !! 941                 configure_tda827x_fe(dev, &kworld_dvb_t_210_config);
1119                                          &tda << 
1120                         goto dettach_frontend << 
1121                 break;                        << 
1122         case SAA7134_BOARD_HAUPPAUGE_HVR1120: << 
1123                 fe0->dvb.frontend = dvb_attac << 
1124                                               << 
1125                                               << 
1126                 if (fe0->dvb.frontend != NULL << 
1127                         dvb_attach(tda829x_at << 
1128                                    &dev->i2c_ << 
1129                                    &tda829x_n << 
1130                         dvb_attach(tda18271_a << 
1131                                    0x60, &dev << 
1132                                    &hcw_tda18 << 
1133                 }                             << 
1134                 break;                           942                 break;
1135         case SAA7134_BOARD_PHILIPS_TIGER:        943         case SAA7134_BOARD_PHILIPS_TIGER:
1136                 if (configure_tda827x_fe(dev, !! 944                 configure_tda827x_fe(dev, &philips_tiger_config);
1137                                          &tda << 
1138                         goto dettach_frontend << 
1139                 break;                           945                 break;
1140         case SAA7134_BOARD_PINNACLE_PCTV_310i    946         case SAA7134_BOARD_PINNACLE_PCTV_310i:
1141                 if (configure_tda827x_fe(dev, !! 947                 configure_tda827x_fe(dev, &pinnacle_pctv_310i_config);
1142                                          &tda << 
1143                         goto dettach_frontend << 
1144                 break;                           948                 break;
1145         case SAA7134_BOARD_HAUPPAUGE_HVR1110:    949         case SAA7134_BOARD_HAUPPAUGE_HVR1110:
1146                 if (configure_tda827x_fe(dev, !! 950                 configure_tda827x_fe(dev, &hauppauge_hvr_1110_config);
1147                                          &tda << 
1148                         goto dettach_frontend << 
1149                 break;                        << 
1150         case SAA7134_BOARD_HAUPPAUGE_HVR1150: << 
1151                 fe0->dvb.frontend = dvb_attac << 
1152                                               << 
1153                                               << 
1154                 if (fe0->dvb.frontend) {      << 
1155                         dvb_attach(tda829x_at << 
1156                                    &dev->i2c_ << 
1157                                    &tda829x_n << 
1158                         dvb_attach(tda18271_a << 
1159                                    0x60, &dev << 
1160                                    &hcw_tda18 << 
1161                 }                             << 
1162                 break;                           951                 break;
1163         case SAA7134_BOARD_ASUSTeK_P7131_DUAL    952         case SAA7134_BOARD_ASUSTeK_P7131_DUAL:
1164                 if (configure_tda827x_fe(dev, !! 953                 configure_tda827x_fe(dev, &asus_p7131_dual_config);
1165                                          &tda << 
1166                         goto dettach_frontend << 
1167                 break;                           954                 break;
1168         case SAA7134_BOARD_FLYDVBT_LR301:        955         case SAA7134_BOARD_FLYDVBT_LR301:
1169                 if (configure_tda827x_fe(dev, !! 956                 configure_tda827x_fe(dev, &tda827x_lifeview_config);
1170                                          &tda << 
1171                         goto dettach_frontend << 
1172                 break;                           957                 break;
1173         case SAA7134_BOARD_FLYDVB_TRIO:          958         case SAA7134_BOARD_FLYDVB_TRIO:
1174                 if (!use_frontend) {    /* te !! 959                 if(! use_frontend) {    /* terrestrial */
1175                         if (configure_tda827x !! 960                         configure_tda827x_fe(dev, &lifeview_trio_config);
1176                                               !! 961                 } else {                /* satellite */
1177                                 goto dettach_ !! 962                         dev->dvb.frontend = dvb_attach(tda10086_attach, &flydvbs, &dev->i2c_adap);
1178                 } else {                /* sa !! 963                         if (dev->dvb.frontend) {
1179                         fe0->dvb.frontend = d !! 964                                 if (dvb_attach(tda826x_attach, dev->dvb.frontend, 0x63,
1180                         if (fe0->dvb.frontend << 
1181                                 if (dvb_attac << 
1182                                                  965                                                                         &dev->i2c_adap, 0) == NULL) {
1183                                         wprin !! 966                                         wprintk("%s: Lifeview Trio, No tda826x found!\n", __FUNCTION__);
1184                                         goto  << 
1185                                 }                967                                 }
1186                                 if (dvb_attac !! 968                                 if (dvb_attach(isl6421_attach, dev->dvb.frontend, &dev->i2c_adap,
1187                                                  969                                                                                 0x08, 0, 0) == NULL) {
1188                                         wprin !! 970                                         wprintk("%s: Lifeview Trio, No ISL6421 found!\n", __FUNCTION__);
1189                                         goto  << 
1190                                 }                971                                 }
1191                         }                        972                         }
1192                 }                                973                 }
1193                 break;                           974                 break;
1194         case SAA7134_BOARD_ADS_DUO_CARDBUS_PT    975         case SAA7134_BOARD_ADS_DUO_CARDBUS_PTV331:
1195         case SAA7134_BOARD_FLYDVBT_HYBRID_CAR    976         case SAA7134_BOARD_FLYDVBT_HYBRID_CARDBUS:
1196                 fe0->dvb.frontend = dvb_attac !! 977                 dev->dvb.frontend = dvb_attach(tda10046_attach,
1197                                                  978                                                &ads_tech_duo_config,
1198                                                  979                                                &dev->i2c_adap);
1199                 if (fe0->dvb.frontend) {      !! 980                 if (dev->dvb.frontend) {
1200                         if (dvb_attach(tda827 !! 981                         if (dvb_attach(tda827x_attach,dev->dvb.frontend,
1201                                    ads_tech_d !! 982                                    ads_tech_duo_config.tuner_address,
1202                                               !! 983                                    &dev->i2c_adap,&ads_duo_cfg) == NULL) {
1203                                 wprintk("no t    984                                 wprintk("no tda827x tuner found at addr: %02x\n",
1204                                         ads_t    985                                         ads_tech_duo_config.tuner_address);
1205                                 goto dettach_ << 
1206                         }                        986                         }
1207                 } else                        !! 987                 }
1208                         wprintk("failed to at << 
1209                 break;                           988                 break;
1210         case SAA7134_BOARD_TEVION_DVBT_220RF:    989         case SAA7134_BOARD_TEVION_DVBT_220RF:
1211                 if (configure_tda827x_fe(dev, !! 990                 configure_tda827x_fe(dev, &tevion_dvbt220rf_config);
1212                                          &tda << 
1213                         goto dettach_frontend << 
1214                 break;                           991                 break;
1215         case SAA7134_BOARD_MEDION_MD8800_QUAD    992         case SAA7134_BOARD_MEDION_MD8800_QUADRO:
1216                 if (!use_frontend) {     /* t !! 993                 configure_tda827x_fe(dev, &md8800_dvbt_config);
1217                         if (configure_tda827x << 
1218                                               << 
1219                                 goto dettach_ << 
1220                 } else {        /* satellite  << 
1221                         fe0->dvb.frontend = d << 
1222                                               << 
1223                         if (fe0->dvb.frontend << 
1224                                 struct dvb_fr << 
1225                                 u8 dev_id = d << 
1226                                 u8 data = 0xc << 
1227                                 struct i2c_ms << 
1228                                               << 
1229                                 if (dvb_attac << 
1230                                               << 
1231                                         wprin << 
1232                                               << 
1233                                         goto  << 
1234                                 }             << 
1235                                 if (dev_id != << 
1236                                         /* we << 
1237                                         fe->o << 
1238                                         if (d << 
1239                                               << 
1240                                               << 
1241                                               << 
1242                                               << 
1243                                         }     << 
1244                                         if (d << 
1245                                               << 
1246                                               << 
1247                                               << 
1248                                               << 
1249                                         }     << 
1250                                         fe->o << 
1251                                         dev-> << 
1252                                         fe->o << 
1253                                         dev-> << 
1254                                         fe->o << 
1255                                 } else {      << 
1256                                         fe->o << 
1257                                         fe->o << 
1258                                 }             << 
1259                         }                     << 
1260                 }                             << 
1261                 break;                           994                 break;
1262         case SAA7134_BOARD_AVERMEDIA_AVERTVHD    995         case SAA7134_BOARD_AVERMEDIA_AVERTVHD_A180:
1263                 fe0->dvb.frontend = dvb_attac !! 996                 dev->dvb.frontend = dvb_attach(nxt200x_attach, &avertvhda180,
1264                                                  997                                                &dev->i2c_adap);
1265                 if (fe0->dvb.frontend)        !! 998                 if (dev->dvb.frontend) {
1266                         dvb_attach(dvb_pll_at !! 999                         dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x61,
1267                                    NULL, DVB_    1000                                    NULL, DVB_PLL_TDHU2);
                                                   >> 1001                 }
1268                 break;                           1002                 break;
1269         case SAA7134_BOARD_ADS_INSTANT_HDTV_P << 
1270         case SAA7134_BOARD_KWORLD_ATSC110:       1003         case SAA7134_BOARD_KWORLD_ATSC110:
1271                 fe0->dvb.frontend = dvb_attac !! 1004                 dev->dvb.frontend = dvb_attach(nxt200x_attach, &kworldatsc110,
1272                                                  1005                                                &dev->i2c_adap);
1273                 if (fe0->dvb.frontend)        !! 1006                 if (dev->dvb.frontend) {
1274                         dvb_attach(simple_tun !! 1007                         dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x61,
1275                                    &dev->i2c_ !! 1008                                    NULL, DVB_PLL_TUV1236D);
1276                                    TUNER_PHIL !! 1009                 }
1277                 break;                           1010                 break;
1278         case SAA7134_BOARD_FLYDVBS_LR300:        1011         case SAA7134_BOARD_FLYDVBS_LR300:
1279                 fe0->dvb.frontend = dvb_attac !! 1012                 dev->dvb.frontend = dvb_attach(tda10086_attach, &flydvbs,
1280                                                  1013                                                &dev->i2c_adap);
1281                 if (fe0->dvb.frontend) {      !! 1014                 if (dev->dvb.frontend) {
1282                         if (dvb_attach(tda826 !! 1015                         if (dvb_attach(tda826x_attach, dev->dvb.frontend, 0x60,
1283                                        &dev->    1016                                        &dev->i2c_adap, 0) == NULL) {
1284                                 wprintk("%s:  !! 1017                                 wprintk("%s: No tda826x found!\n", __FUNCTION__);
1285                                 goto dettach_ << 
1286                         }                        1018                         }
1287                         if (dvb_attach(isl642 !! 1019                         if (dvb_attach(isl6421_attach, dev->dvb.frontend,
1288                                        &dev->    1020                                        &dev->i2c_adap, 0x08, 0, 0) == NULL) {
1289                                 wprintk("%s:  !! 1021                                 wprintk("%s: No ISL6421 found!\n", __FUNCTION__);
1290                                 goto dettach_ << 
1291                         }                        1022                         }
1292                 }                                1023                 }
1293                 break;                           1024                 break;
1294         case SAA7134_BOARD_ASUS_EUROPA2_HYBRI    1025         case SAA7134_BOARD_ASUS_EUROPA2_HYBRID:
1295                 fe0->dvb.frontend = dvb_attac !! 1026                 dev->dvb.frontend = dvb_attach(tda10046_attach,
1296                                                  1027                                                &medion_cardbus,
1297                                                  1028                                                &dev->i2c_adap);
1298                 if (fe0->dvb.frontend) {      !! 1029                 if (dev->dvb.frontend) {
1299                         dev->original_demod_s !! 1030                         dev->original_demod_sleep = dev->dvb.frontend->ops.sleep;
1300                         fe0->dvb.frontend->op !! 1031                         dev->dvb.frontend->ops.sleep = philips_europa_demod_sleep;
1301                                               !! 1032 
1302                         dvb_attach(simple_tun !! 1033                         dvb_attach(dvb_pll_attach, dev->dvb.frontend, medion_cardbus.tuner_address,
1303                                    &dev->i2c_ !! 1034                                    &dev->i2c_adap, DVB_PLL_FMD1216ME);
1304                                    TUNER_PHIL << 
1305                 }                                1035                 }
1306                 break;                           1036                 break;
1307         case SAA7134_BOARD_VIDEOMATE_DVBT_200    1037         case SAA7134_BOARD_VIDEOMATE_DVBT_200A:
1308                 fe0->dvb.frontend = dvb_attac !! 1038                 dev->dvb.frontend = dvb_attach(tda10046_attach,
1309                                 &philips_euro    1039                                 &philips_europa_config,
1310                                 &dev->i2c_ada    1040                                 &dev->i2c_adap);
1311                 if (fe0->dvb.frontend) {      !! 1041                 if (dev->dvb.frontend) {
1312                         fe0->dvb.frontend->op !! 1042                         dev->dvb.frontend->ops.tuner_ops.init = philips_td1316_tuner_init;
1313                         fe0->dvb.frontend->op !! 1043                         dev->dvb.frontend->ops.tuner_ops.set_params = philips_td1316_tuner_set_params;
1314                 }                                1044                 }
1315                 break;                           1045                 break;
1316         case SAA7134_BOARD_CINERGY_HT_PCMCIA:    1046         case SAA7134_BOARD_CINERGY_HT_PCMCIA:
1317                 if (configure_tda827x_fe(dev, !! 1047                 configure_tda827x_fe(dev, &cinergy_ht_config);
1318                                          &tda << 
1319                         goto dettach_frontend << 
1320                 break;                           1048                 break;
1321         case SAA7134_BOARD_CINERGY_HT_PCI:       1049         case SAA7134_BOARD_CINERGY_HT_PCI:
1322                 if (configure_tda827x_fe(dev, !! 1050                 configure_tda827x_fe(dev, &cinergy_ht_pci_config);
1323                                          &tda << 
1324                         goto dettach_frontend << 
1325                 break;                           1051                 break;
1326         case SAA7134_BOARD_PHILIPS_TIGER_S:      1052         case SAA7134_BOARD_PHILIPS_TIGER_S:
1327                 if (configure_tda827x_fe(dev, !! 1053                 configure_tda827x_fe(dev, &philips_tiger_s_config);
1328                                          &tda << 
1329                         goto dettach_frontend << 
1330                 break;                           1054                 break;
1331         case SAA7134_BOARD_ASUS_P7131_4871:      1055         case SAA7134_BOARD_ASUS_P7131_4871:
1332                 if (configure_tda827x_fe(dev, !! 1056                 configure_tda827x_fe(dev, &asus_p7131_4871_config);
1333                                          &tda << 
1334                         goto dettach_frontend << 
1335                 break;                           1057                 break;
1336         case SAA7134_BOARD_ASUSTeK_P7131_HYBR    1058         case SAA7134_BOARD_ASUSTeK_P7131_HYBRID_LNA:
1337                 if (configure_tda827x_fe(dev, !! 1059                 configure_tda827x_fe(dev, &asus_p7131_hybrid_lna_config);
1338                                          &tda << 
1339                         goto dettach_frontend << 
1340                 break;                           1060                 break;
1341         case SAA7134_BOARD_AVERMEDIA_SUPER_00    1061         case SAA7134_BOARD_AVERMEDIA_SUPER_007:
1342                 if (configure_tda827x_fe(dev, !! 1062                 configure_tda827x_fe(dev, &avermedia_super_007_config);
1343                                          &tda << 
1344                         goto dettach_frontend << 
1345                 break;                           1063                 break;
1346         case SAA7134_BOARD_TWINHAN_DTV_DVB_30    1064         case SAA7134_BOARD_TWINHAN_DTV_DVB_3056:
1347                 if (configure_tda827x_fe(dev, !! 1065                 configure_tda827x_fe(dev, &twinhan_dtv_dvb_3056_config);
1348                                          &tda << 
1349                         goto dettach_frontend << 
1350                 break;                        << 
1351         case SAA7134_BOARD_PHILIPS_SNAKE:     << 
1352                 fe0->dvb.frontend = dvb_attac << 
1353                                               << 
1354                 if (fe0->dvb.frontend) {      << 
1355                         if (dvb_attach(tda826 << 
1356                                         &dev- << 
1357                                 wprintk("%s:  << 
1358                                 goto dettach_ << 
1359                         }                     << 
1360                         if (dvb_attach(lnbp21 << 
1361                                         &dev- << 
1362                                 wprintk("%s:  << 
1363                                 goto dettach_ << 
1364                         }                     << 
1365                 }                             << 
1366                 break;                        << 
1367         case SAA7134_BOARD_CREATIX_CTX953:    << 
1368                 if (configure_tda827x_fe(dev, << 
1369                                          &tda << 
1370                         goto dettach_frontend << 
1371                 break;                        << 
1372         case SAA7134_BOARD_MSI_TVANYWHERE_AD1 << 
1373                 if (configure_tda827x_fe(dev, << 
1374                                          &tda << 
1375                         goto dettach_frontend << 
1376                 break;                        << 
1377         case SAA7134_BOARD_AVERMEDIA_CARDBUS_ << 
1378                 dprintk("AverMedia E506R dvb  << 
1379                 saa7134_set_gpio(dev, 25, 0); << 
1380                 msleep(10);                   << 
1381                 saa7134_set_gpio(dev, 25, 1); << 
1382                 fe0->dvb.frontend = dvb_attac << 
1383                                               << 
1384                                               << 
1385                 attach_xc3028 = 1;            << 
1386                 break;                        << 
1387         case SAA7134_BOARD_MD7134_BRIDGE_2:   << 
1388                 fe0->dvb.frontend = dvb_attac << 
1389                                               << 
1390                 if (fe0->dvb.frontend) {      << 
1391                         struct dvb_frontend * << 
1392                         if (dvb_attach(dvb_pl << 
1393                                   &dev->i2c_a << 
1394                                 wprintk("%s:  << 
1395                                         "foun << 
1396                                 goto dettach_ << 
1397                         }                     << 
1398                         /* we need to open th << 
1399                         fe = fe0->dvb.fronten << 
1400                         fe->ops.i2c_gate_ctrl << 
1401                         if (dvb_attach(isl640 << 
1402                                         &dev- << 
1403                                 wprintk("%s:  << 
1404                                         "foun << 
1405                                 goto dettach_ << 
1406                         }                     << 
1407                         fe->ops.i2c_gate_ctrl << 
1408                         dev->original_set_vol << 
1409                         fe->ops.set_voltage = << 
1410                         dev->original_set_hig << 
1411                         fe->ops.enable_high_l << 
1412                 }                             << 
1413                 break;                        << 
1414         case SAA7134_BOARD_AVERMEDIA_M103:    << 
1415                 saa7134_set_gpio(dev, 25, 0); << 
1416                 msleep(10);                   << 
1417                 saa7134_set_gpio(dev, 25, 1); << 
1418                 fe0->dvb.frontend = dvb_attac << 
1419                                               << 
1420                                               << 
1421                 attach_xc3028 = 1;            << 
1422                 break;                        << 
1423         case SAA7134_BOARD_ASUSTeK_TIGER_3IN1 << 
1424                 if (!use_frontend) {     /* t << 
1425                         if (configure_tda827x << 
1426                                               << 
1427                                 goto dettach_ << 
1428                 } else {                /* sa << 
1429                         fe0->dvb.frontend = d << 
1430                                               << 
1431                         if (fe0->dvb.frontend << 
1432                                 if (dvb_attac << 
1433                                               << 
1434                                               << 
1435                                         wprin << 
1436                                               << 
1437                                         goto  << 
1438                                 }             << 
1439                                 if (dvb_attac << 
1440                                               << 
1441                                         wprin << 
1442                                               << 
1443                                         goto  << 
1444                                 }             << 
1445                         }                     << 
1446                 }                             << 
1447                 break;                        << 
1448         case SAA7134_BOARD_ASUSTeK_TIGER:     << 
1449                 if (configure_tda827x_fe(dev, << 
1450                                          &tda << 
1451                         goto dettach_frontend << 
1452                 break;                        << 
1453         case SAA7134_BOARD_BEHOLD_H6:         << 
1454                 fe0->dvb.frontend = dvb_attac << 
1455                                               << 
1456                                               << 
1457                 if (fe0->dvb.frontend) {      << 
1458                         dvb_attach(simple_tun << 
1459                                    &dev->i2c_ << 
1460                                    TUNER_PHIL << 
1461                 }                             << 
1462                 break;                        << 
1463         case SAA7134_BOARD_AVERMEDIA_A700_PRO << 
1464         case SAA7134_BOARD_AVERMEDIA_A700_HYB << 
1465                 /* Zarlink ZL10313 */         << 
1466                 fe0->dvb.frontend = dvb_attac << 
1467                         &avertv_a700_mt312, & << 
1468                 if (fe0->dvb.frontend) {      << 
1469                         if (dvb_attach(zl1003 << 
1470                                         &aver << 
1471                                 wprintk("%s:  << 
1472                                         __fun << 
1473                         }                     << 
1474                 }                             << 
1475                 break;                           1066                 break;
1476         default:                                 1067         default:
1477                 wprintk("Huh? unknown DVB car    1068                 wprintk("Huh? unknown DVB card?\n");
1478                 break;                           1069                 break;
1479         }                                        1070         }
1480                                                  1071 
1481         if (attach_xc3028) {                  !! 1072         if (NULL == dev->dvb.frontend) {
1482                 struct dvb_frontend *fe;      << 
1483                 struct xc2028_config cfg = {  << 
1484                         .i2c_adap  = &dev->i2 << 
1485                         .i2c_addr  = 0x61,    << 
1486                 };                            << 
1487                                               << 
1488                 if (!fe0->dvb.frontend)       << 
1489                         goto dettach_frontend << 
1490                                               << 
1491                 fe = dvb_attach(xc2028_attach << 
1492                 if (!fe) {                    << 
1493                         printk(KERN_ERR "%s/2 << 
1494                                dev->name);    << 
1495                         goto dettach_frontend << 
1496                 }                             << 
1497         }                                     << 
1498                                               << 
1499         if (NULL == fe0->dvb.frontend) {      << 
1500                 printk(KERN_ERR "%s/dvb: fron    1073                 printk(KERN_ERR "%s/dvb: frontend initialization failed\n", dev->name);
1501                 goto dettach_frontend;        !! 1074                 return -1;
1502         }                                        1075         }
1503         /* define general-purpose callback po << 
1504         fe0->dvb.frontend->callback = saa7134 << 
1505                                                  1076 
1506         /* register everything else */           1077         /* register everything else */
1507         ret = videobuf_dvb_register_bus(&dev- !! 1078         ret = videobuf_dvb_register(&dev->dvb, THIS_MODULE, dev, &dev->pci->dev);
1508                 &dev->pci->dev, adapter_nr, 0 << 
1509                                                  1079 
1510         /* this sequence is necessary to make    1080         /* this sequence is necessary to make the tda1004x load its firmware
1511          * and to enter analog mode of hybrid    1081          * and to enter analog mode of hybrid boards
1512          */                                      1082          */
1513         if (!ret) {                              1083         if (!ret) {
1514                 if (fe0->dvb.frontend->ops.in !! 1084                 if (dev->dvb.frontend->ops.init)
1515                         fe0->dvb.frontend->op !! 1085                         dev->dvb.frontend->ops.init(dev->dvb.frontend);
1516                 if (fe0->dvb.frontend->ops.sl !! 1086                 if (dev->dvb.frontend->ops.sleep)
1517                         fe0->dvb.frontend->op !! 1087                         dev->dvb.frontend->ops.sleep(dev->dvb.frontend);
1518                 if (fe0->dvb.frontend->ops.tu !! 1088                 if (dev->dvb.frontend->ops.tuner_ops.sleep)
1519                         fe0->dvb.frontend->op !! 1089                         dev->dvb.frontend->ops.tuner_ops.sleep(dev->dvb.frontend);
1520         }                                        1090         }
1521         return ret;                              1091         return ret;
1522                                               << 
1523 dettach_frontend:                             << 
1524         videobuf_dvb_dealloc_frontends(&dev-> << 
1525         return -EINVAL;                       << 
1526 }                                                1092 }
1527                                                  1093 
1528 static int dvb_fini(struct saa7134_dev *dev)     1094 static int dvb_fini(struct saa7134_dev *dev)
1529 {                                                1095 {
1530         struct videobuf_dvb_frontend *fe0;    << 
1531                                               << 
1532         /* Get the first frontend */          << 
1533         fe0 = videobuf_dvb_get_frontend(&dev- << 
1534         if (!fe0)                             << 
1535                 return -EINVAL;               << 
1536                                               << 
1537         /* FIXME: I suspect that this code is    1096         /* FIXME: I suspect that this code is bogus, since the entry for
1538            Pinnacle 300I DVB-T PAL already de    1097            Pinnacle 300I DVB-T PAL already defines the proper init to allow
1539            the detection of mt2032 (TDA9887_P    1098            the detection of mt2032 (TDA9887_PORT2_INACTIVE)
1540          */                                      1099          */
1541         if (dev->board == SAA7134_BOARD_PINNA    1100         if (dev->board == SAA7134_BOARD_PINNACLE_300I_DVBT_PAL) {
1542                 struct v4l2_priv_tun_config t    1101                 struct v4l2_priv_tun_config tda9887_cfg;
1543                 static int on  = TDA9887_PRES    1102                 static int on  = TDA9887_PRESENT | TDA9887_PORT2_INACTIVE;
1544                                                  1103 
1545                 tda9887_cfg.tuner = TUNER_TDA    1104                 tda9887_cfg.tuner = TUNER_TDA9887;
1546                 tda9887_cfg.priv  = &on;         1105                 tda9887_cfg.priv  = &on;
1547                                                  1106 
1548                 /* otherwise we don't detect     1107                 /* otherwise we don't detect the tuner on next insmod */
1549                 saa_call_all(dev, tuner, s_co !! 1108                 saa7134_i2c_call_clients(dev, TUNER_SET_CONFIG, &tda9887_cfg);
1550         } else if (dev->board == SAA7134_BOAR << 
1551                 if ((dev->eedata[2] == 0x07)  << 
1552                         /* turn off the 2nd l << 
1553                         u8 data = 0x80;       << 
1554                         struct i2c_msg msg =  << 
1555                         struct dvb_frontend * << 
1556                         fe = fe0->dvb.fronten << 
1557                         if (fe->ops.i2c_gate_ << 
1558                                 fe->ops.i2c_g << 
1559                                 i2c_transfer( << 
1560                                 fe->ops.i2c_g << 
1561                         }                     << 
1562                 }                             << 
1563         }                                        1109         }
1564         videobuf_dvb_unregister_bus(&dev->fro !! 1110 
                                                   >> 1111         videobuf_dvb_unregister(&dev->dvb);
1565         return 0;                                1112         return 0;
1566 }                                                1113 }
1567                                                  1114 
1568 static struct saa7134_mpeg_ops dvb_ops = {       1115 static struct saa7134_mpeg_ops dvb_ops = {
1569         .type          = SAA7134_MPEG_DVB,       1116         .type          = SAA7134_MPEG_DVB,
1570         .init          = dvb_init,               1117         .init          = dvb_init,
1571         .fini          = dvb_fini,               1118         .fini          = dvb_fini,
1572 };                                               1119 };
1573                                                  1120 
1574 static int __init dvb_register(void)             1121 static int __init dvb_register(void)
1575 {                                                1122 {
1576         return saa7134_ts_register(&dvb_ops);    1123         return saa7134_ts_register(&dvb_ops);
1577 }                                                1124 }
1578                                                  1125 
1579 static void __exit dvb_unregister(void)          1126 static void __exit dvb_unregister(void)
1580 {                                                1127 {
1581         saa7134_ts_unregister(&dvb_ops);         1128         saa7134_ts_unregister(&dvb_ops);
1582 }                                                1129 }
1583                                                  1130 
1584 module_init(dvb_register);                       1131 module_init(dvb_register);
1585 module_exit(dvb_unregister);                     1132 module_exit(dvb_unregister);
1586                                                  1133 
1587 /* ------------------------------------------    1134 /* ------------------------------------------------------------------ */
1588 /*                                               1135 /*
1589  * Local variables:                              1136  * Local variables:
1590  * c-basic-offset: 8                             1137  * c-basic-offset: 8
1591  * End:                                          1138  * End:
1592  */                                              1139  */
1593                                                  1140 
  This page was automatically generated by the LXR engine.