Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2 | * |
| 3 | * (c) 2004 Gerd Knorr <kraxel@bytesex.org> [SuSE Labs] |
| 4 | * |
Mauro Carvalho Chehab | 86ddd96 | 2005-07-12 13:58:47 -0700 | [diff] [blame] | 5 | * Extended 3 / 2005 by Hartmut Hackmann to support various |
| 6 | * cards with the tda10046 DVB-T channel decoder |
| 7 | * |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 8 | * This program is free software; you can redistribute it and/or modify |
| 9 | * it under the terms of the GNU General Public License as published by |
| 10 | * the Free Software Foundation; either version 2 of the License, or |
| 11 | * (at your option) any later version. |
| 12 | * |
| 13 | * This program is distributed in the hope that it will be useful, |
| 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 16 | * GNU General Public License for more details. |
| 17 | * |
| 18 | * You should have received a copy of the GNU General Public License |
| 19 | * along with this program; if not, write to the Free Software |
| 20 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
| 21 | */ |
| 22 | |
| 23 | #include <linux/init.h> |
| 24 | #include <linux/list.h> |
| 25 | #include <linux/module.h> |
| 26 | #include <linux/kernel.h> |
| 27 | #include <linux/slab.h> |
| 28 | #include <linux/delay.h> |
| 29 | #include <linux/kthread.h> |
| 30 | #include <linux/suspend.h> |
| 31 | |
| 32 | #include "saa7134-reg.h" |
| 33 | #include "saa7134.h" |
Michael Krufky | 5e453dc | 2006-01-09 15:32:31 -0200 | [diff] [blame] | 34 | #include <media/v4l2-common.h> |
Jose Alberto Reguero | a78d0bf | 2006-02-07 06:25:14 -0200 | [diff] [blame] | 35 | #include "dvb-pll.h" |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 36 | |
Andrew de Quincey | 1f10c7a | 2006-08-08 09:10:09 -0300 | [diff] [blame] | 37 | #include "mt352.h" |
| 38 | #include "mt352_priv.h" /* FIXME */ |
| 39 | #include "tda1004x.h" |
| 40 | #include "nxt200x.h" |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 41 | |
Igor M. Liplianin | e2ac28f | 2006-08-08 09:10:10 -0300 | [diff] [blame] | 42 | #include "tda10086.h" |
| 43 | #include "tda826x.h" |
Michael Krufky | 8ce47da | 2007-04-27 12:31:14 -0300 | [diff] [blame] | 44 | #include "tda827x.h" |
Igor M. Liplianin | e2ac28f | 2006-08-08 09:10:10 -0300 | [diff] [blame] | 45 | #include "isl6421.h" |
Michael Krufky | 8ce47da | 2007-04-27 12:31:14 -0300 | [diff] [blame] | 46 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 47 | MODULE_AUTHOR("Gerd Knorr <kraxel@bytesex.org> [SuSE Labs]"); |
| 48 | MODULE_LICENSE("GPL"); |
| 49 | |
| 50 | static unsigned int antenna_pwr = 0; |
Mauro Carvalho Chehab | 86ddd96 | 2005-07-12 13:58:47 -0700 | [diff] [blame] | 51 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 52 | module_param(antenna_pwr, int, 0444); |
| 53 | MODULE_PARM_DESC(antenna_pwr,"enable antenna power (Pinnacle 300i)"); |
| 54 | |
Stephan Berberig | b331daa | 2006-12-20 09:37:05 -0300 | [diff] [blame] | 55 | static int use_frontend = 0; |
| 56 | module_param(use_frontend, int, 0644); |
| 57 | MODULE_PARM_DESC(use_frontend,"for cards with multiple frontends (0: terrestrial, 1: satellite)"); |
Nico Sabbi | 1f683cd | 2006-11-15 22:06:56 -0300 | [diff] [blame] | 58 | |
Hartmut Hackmann | 58ef4f9 | 2007-04-27 12:31:12 -0300 | [diff] [blame] | 59 | static int debug = 0; |
| 60 | module_param(debug, int, 0644); |
| 61 | MODULE_PARM_DESC(debug, "Turn on/off module debugging (default:off)."); |
| 62 | |
Trent Piepho | cf3c34c | 2007-03-07 18:19:48 -0300 | [diff] [blame] | 63 | #define dprintk(fmt, arg...) do { if (debug) \ |
| 64 | printk(KERN_DEBUG "%s/dvb: " fmt, dev->name , ## arg); } while(0) |
| 65 | |
| 66 | /* Print a warning */ |
| 67 | #define wprintk(fmt, arg...) \ |
| 68 | printk(KERN_WARNING "%s/dvb: " fmt, dev->name, ## arg) |
Hartmut Hackmann | 58ef4f9 | 2007-04-27 12:31:12 -0300 | [diff] [blame] | 69 | |
| 70 | /* ------------------------------------------------------------------ |
| 71 | * mt352 based DVB-T cards |
| 72 | */ |
| 73 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 74 | static int pinnacle_antenna_pwr(struct saa7134_dev *dev, int on) |
| 75 | { |
| 76 | u32 ok; |
| 77 | |
| 78 | if (!on) { |
| 79 | saa_setl(SAA7134_GPIO_GPMODE0 >> 2, (1 << 26)); |
| 80 | saa_clearl(SAA7134_GPIO_GPSTATUS0 >> 2, (1 << 26)); |
| 81 | return 0; |
| 82 | } |
| 83 | |
| 84 | saa_setl(SAA7134_GPIO_GPMODE0 >> 2, (1 << 26)); |
| 85 | saa_setl(SAA7134_GPIO_GPSTATUS0 >> 2, (1 << 26)); |
| 86 | udelay(10); |
| 87 | |
| 88 | saa_setl(SAA7134_GPIO_GPMODE0 >> 2, (1 << 28)); |
| 89 | saa_clearl(SAA7134_GPIO_GPSTATUS0 >> 2, (1 << 28)); |
| 90 | udelay(10); |
| 91 | saa_setl(SAA7134_GPIO_GPSTATUS0 >> 2, (1 << 28)); |
| 92 | udelay(10); |
| 93 | ok = saa_readl(SAA7134_GPIO_GPSTATUS0) & (1 << 27); |
Trent Piepho | cf3c34c | 2007-03-07 18:19:48 -0300 | [diff] [blame] | 94 | dprintk("%s %s\n", __FUNCTION__, ok ? "on" : "off"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 95 | |
| 96 | if (!ok) |
| 97 | saa_clearl(SAA7134_GPIO_GPSTATUS0 >> 2, (1 << 26)); |
| 98 | return ok; |
| 99 | } |
| 100 | |
| 101 | static int mt352_pinnacle_init(struct dvb_frontend* fe) |
| 102 | { |
| 103 | static u8 clock_config [] = { CLOCK_CTL, 0x3d, 0x28 }; |
| 104 | static u8 reset [] = { RESET, 0x80 }; |
| 105 | static u8 adc_ctl_1_cfg [] = { ADC_CTL_1, 0x40 }; |
| 106 | static u8 agc_cfg [] = { AGC_TARGET, 0x28, 0xa0 }; |
| 107 | static u8 capt_range_cfg[] = { CAPT_RANGE, 0x31 }; |
| 108 | static u8 fsm_ctl_cfg[] = { 0x7b, 0x04 }; |
| 109 | static u8 gpp_ctl_cfg [] = { GPP_CTL, 0x0f }; |
| 110 | static u8 scan_ctl_cfg [] = { SCAN_CTL, 0x0d }; |
| 111 | static u8 irq_cfg [] = { INTERRUPT_EN_0, 0x00, 0x00, 0x00, 0x00 }; |
| 112 | struct saa7134_dev *dev= fe->dvb->priv; |
| 113 | |
Trent Piepho | cf3c34c | 2007-03-07 18:19:48 -0300 | [diff] [blame] | 114 | dprintk("%s called\n", __FUNCTION__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 115 | |
| 116 | mt352_write(fe, clock_config, sizeof(clock_config)); |
| 117 | udelay(200); |
| 118 | mt352_write(fe, reset, sizeof(reset)); |
| 119 | mt352_write(fe, adc_ctl_1_cfg, sizeof(adc_ctl_1_cfg)); |
| 120 | mt352_write(fe, agc_cfg, sizeof(agc_cfg)); |
| 121 | mt352_write(fe, capt_range_cfg, sizeof(capt_range_cfg)); |
| 122 | mt352_write(fe, gpp_ctl_cfg, sizeof(gpp_ctl_cfg)); |
| 123 | |
| 124 | mt352_write(fe, fsm_ctl_cfg, sizeof(fsm_ctl_cfg)); |
| 125 | mt352_write(fe, scan_ctl_cfg, sizeof(scan_ctl_cfg)); |
| 126 | mt352_write(fe, irq_cfg, sizeof(irq_cfg)); |
Hartmut Hackmann | df8cf70 | 2006-03-03 12:09:26 -0300 | [diff] [blame] | 127 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 128 | return 0; |
| 129 | } |
| 130 | |
Jose Alberto Reguero | a78d0bf | 2006-02-07 06:25:14 -0200 | [diff] [blame] | 131 | static int mt352_aver777_init(struct dvb_frontend* fe) |
| 132 | { |
| 133 | static u8 clock_config [] = { CLOCK_CTL, 0x38, 0x2d }; |
| 134 | static u8 reset [] = { RESET, 0x80 }; |
| 135 | static u8 adc_ctl_1_cfg [] = { ADC_CTL_1, 0x40 }; |
| 136 | static u8 agc_cfg [] = { AGC_TARGET, 0x28, 0xa0 }; |
| 137 | static u8 capt_range_cfg[] = { CAPT_RANGE, 0x33 }; |
| 138 | |
| 139 | mt352_write(fe, clock_config, sizeof(clock_config)); |
| 140 | udelay(200); |
| 141 | mt352_write(fe, reset, sizeof(reset)); |
| 142 | mt352_write(fe, adc_ctl_1_cfg, sizeof(adc_ctl_1_cfg)); |
| 143 | mt352_write(fe, agc_cfg, sizeof(agc_cfg)); |
| 144 | mt352_write(fe, capt_range_cfg, sizeof(capt_range_cfg)); |
| 145 | |
| 146 | return 0; |
| 147 | } |
| 148 | |
Andrew de Quincey | 0463f12 | 2006-05-16 17:22:02 -0300 | [diff] [blame] | 149 | static int mt352_pinnacle_tuner_set_params(struct dvb_frontend* fe, |
| 150 | struct dvb_frontend_parameters* params) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 151 | { |
Hartmut Hackmann | df8cf70 | 2006-03-03 12:09:26 -0300 | [diff] [blame] | 152 | u8 off[] = { 0x00, 0xf1}; |
| 153 | u8 on[] = { 0x00, 0x71}; |
| 154 | struct i2c_msg msg = {.addr=0x43, .flags=0, .buf=off, .len = sizeof(off)}; |
| 155 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 156 | struct saa7134_dev *dev = fe->dvb->priv; |
| 157 | struct v4l2_frequency f; |
| 158 | |
| 159 | /* set frequency (mt2050) */ |
| 160 | f.tuner = 0; |
| 161 | f.type = V4L2_TUNER_DIGITAL_TV; |
| 162 | f.frequency = params->frequency / 1000 * 16 / 1000; |
Patrick Boettcher | dea7486 | 2006-05-14 05:01:31 -0300 | [diff] [blame] | 163 | if (fe->ops.i2c_gate_ctrl) |
| 164 | fe->ops.i2c_gate_ctrl(fe, 1); |
Hartmut Hackmann | df8cf70 | 2006-03-03 12:09:26 -0300 | [diff] [blame] | 165 | i2c_transfer(&dev->i2c_adap, &msg, 1); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 166 | saa7134_i2c_call_clients(dev,VIDIOC_S_FREQUENCY,&f); |
Hartmut Hackmann | df8cf70 | 2006-03-03 12:09:26 -0300 | [diff] [blame] | 167 | msg.buf = on; |
Patrick Boettcher | dea7486 | 2006-05-14 05:01:31 -0300 | [diff] [blame] | 168 | if (fe->ops.i2c_gate_ctrl) |
| 169 | fe->ops.i2c_gate_ctrl(fe, 1); |
Hartmut Hackmann | df8cf70 | 2006-03-03 12:09:26 -0300 | [diff] [blame] | 170 | i2c_transfer(&dev->i2c_adap, &msg, 1); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 171 | |
| 172 | pinnacle_antenna_pwr(dev, antenna_pwr); |
| 173 | |
| 174 | /* mt352 setup */ |
Andrew de Quincey | 0463f12 | 2006-05-16 17:22:02 -0300 | [diff] [blame] | 175 | return mt352_pinnacle_init(fe); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 176 | } |
| 177 | |
Andrew de Quincey | bd4956b | 2006-04-18 21:38:49 -0300 | [diff] [blame] | 178 | static int mt352_aver777_tuner_calc_regs(struct dvb_frontend *fe, struct dvb_frontend_parameters *params, u8* pllbuf, int buf_len) |
Jose Alberto Reguero | a78d0bf | 2006-02-07 06:25:14 -0200 | [diff] [blame] | 179 | { |
Andrew de Quincey | a79ddae | 2006-04-18 17:47:11 -0300 | [diff] [blame] | 180 | if (buf_len < 5) |
| 181 | return -EINVAL; |
| 182 | |
| 183 | pllbuf[0] = 0x61; |
Jose Alberto Reguero | a78d0bf | 2006-02-07 06:25:14 -0200 | [diff] [blame] | 184 | dvb_pll_configure(&dvb_pll_philips_td1316, pllbuf+1, |
| 185 | params->frequency, |
| 186 | params->u.ofdm.bandwidth); |
Andrew de Quincey | a79ddae | 2006-04-18 17:47:11 -0300 | [diff] [blame] | 187 | return 5; |
Jose Alberto Reguero | a78d0bf | 2006-02-07 06:25:14 -0200 | [diff] [blame] | 188 | } |
| 189 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 190 | static struct mt352_config pinnacle_300i = { |
| 191 | .demod_address = 0x3c >> 1, |
| 192 | .adc_clock = 20333, |
| 193 | .if2 = 36150, |
| 194 | .no_tuner = 1, |
| 195 | .demod_init = mt352_pinnacle_init, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 196 | }; |
Jose Alberto Reguero | a78d0bf | 2006-02-07 06:25:14 -0200 | [diff] [blame] | 197 | |
| 198 | static struct mt352_config avermedia_777 = { |
| 199 | .demod_address = 0xf, |
| 200 | .demod_init = mt352_aver777_init, |
Jose Alberto Reguero | a78d0bf | 2006-02-07 06:25:14 -0200 | [diff] [blame] | 201 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 202 | |
Hartmut Hackmann | 58ef4f9 | 2007-04-27 12:31:12 -0300 | [diff] [blame] | 203 | /* ================================================================== |
| 204 | * tda1004x based DVB-T cards, helper functions |
| 205 | */ |
| 206 | |
| 207 | static int philips_tda1004x_request_firmware(struct dvb_frontend *fe, |
| 208 | const struct firmware **fw, char *name) |
Mauro Carvalho Chehab | 86ddd96 | 2005-07-12 13:58:47 -0700 | [diff] [blame] | 209 | { |
| 210 | struct saa7134_dev *dev = fe->dvb->priv; |
Hartmut Hackmann | 58ef4f9 | 2007-04-27 12:31:12 -0300 | [diff] [blame] | 211 | return request_firmware(fw, name, &dev->pci->dev); |
| 212 | } |
| 213 | |
Hartmut Hackmann | 58ef4f9 | 2007-04-27 12:31:12 -0300 | [diff] [blame] | 214 | /* ------------------------------------------------------------------ |
| 215 | * these tuners are tu1216, td1316(a) |
| 216 | */ |
| 217 | |
| 218 | static int philips_tda6651_pll_set(struct dvb_frontend *fe, struct dvb_frontend_parameters *params) |
| 219 | { |
| 220 | struct saa7134_dev *dev = fe->dvb->priv; |
| 221 | struct tda1004x_state *state = fe->demodulator_priv; |
| 222 | u8 addr = state->config->tuner_address; |
Mauro Carvalho Chehab | 86ddd96 | 2005-07-12 13:58:47 -0700 | [diff] [blame] | 223 | u8 tuner_buf[4]; |
Hartmut Hackmann | 2cf36ac | 2005-11-08 21:36:32 -0800 | [diff] [blame] | 224 | struct i2c_msg tuner_msg = {.addr = addr,.flags = 0,.buf = tuner_buf,.len = |
Mauro Carvalho Chehab | 86ddd96 | 2005-07-12 13:58:47 -0700 | [diff] [blame] | 225 | sizeof(tuner_buf) }; |
| 226 | int tuner_frequency = 0; |
| 227 | u8 band, cp, filter; |
| 228 | |
| 229 | /* determine charge pump */ |
| 230 | tuner_frequency = params->frequency + 36166000; |
| 231 | if (tuner_frequency < 87000000) |
| 232 | return -EINVAL; |
| 233 | else if (tuner_frequency < 130000000) |
| 234 | cp = 3; |
| 235 | else if (tuner_frequency < 160000000) |
| 236 | cp = 5; |
| 237 | else if (tuner_frequency < 200000000) |
| 238 | cp = 6; |
| 239 | else if (tuner_frequency < 290000000) |
| 240 | cp = 3; |
| 241 | else if (tuner_frequency < 420000000) |
| 242 | cp = 5; |
| 243 | else if (tuner_frequency < 480000000) |
| 244 | cp = 6; |
| 245 | else if (tuner_frequency < 620000000) |
| 246 | cp = 3; |
| 247 | else if (tuner_frequency < 830000000) |
| 248 | cp = 5; |
| 249 | else if (tuner_frequency < 895000000) |
| 250 | cp = 7; |
| 251 | else |
| 252 | return -EINVAL; |
| 253 | |
| 254 | /* determine band */ |
| 255 | if (params->frequency < 49000000) |
| 256 | return -EINVAL; |
| 257 | else if (params->frequency < 161000000) |
| 258 | band = 1; |
| 259 | else if (params->frequency < 444000000) |
| 260 | band = 2; |
| 261 | else if (params->frequency < 861000000) |
| 262 | band = 4; |
| 263 | else |
| 264 | return -EINVAL; |
| 265 | |
| 266 | /* setup PLL filter */ |
| 267 | switch (params->u.ofdm.bandwidth) { |
| 268 | case BANDWIDTH_6_MHZ: |
| 269 | filter = 0; |
| 270 | break; |
| 271 | |
| 272 | case BANDWIDTH_7_MHZ: |
| 273 | filter = 0; |
| 274 | break; |
| 275 | |
| 276 | case BANDWIDTH_8_MHZ: |
| 277 | filter = 1; |
| 278 | break; |
| 279 | |
| 280 | default: |
| 281 | return -EINVAL; |
| 282 | } |
| 283 | |
| 284 | /* calculate divisor |
| 285 | * ((36166000+((1000000/6)/2)) + Finput)/(1000000/6) |
| 286 | */ |
| 287 | tuner_frequency = (((params->frequency / 1000) * 6) + 217496) / 1000; |
| 288 | |
| 289 | /* setup tuner buffer */ |
| 290 | tuner_buf[0] = (tuner_frequency >> 8) & 0x7f; |
| 291 | tuner_buf[1] = tuner_frequency & 0xff; |
| 292 | tuner_buf[2] = 0xca; |
| 293 | tuner_buf[3] = (cp << 5) | (filter << 3) | band; |
| 294 | |
Patrick Boettcher | dea7486 | 2006-05-14 05:01:31 -0300 | [diff] [blame] | 295 | if (fe->ops.i2c_gate_ctrl) |
| 296 | fe->ops.i2c_gate_ctrl(fe, 1); |
Hartmut Hackmann | 58ef4f9 | 2007-04-27 12:31:12 -0300 | [diff] [blame] | 297 | if (i2c_transfer(&dev->i2c_adap, &tuner_msg, 1) != 1) { |
Trent Piepho | cf3c34c | 2007-03-07 18:19:48 -0300 | [diff] [blame] | 298 | wprintk("could not write to tuner at addr: 0x%02x\n", |
| 299 | addr << 1); |
Mauro Carvalho Chehab | 86ddd96 | 2005-07-12 13:58:47 -0700 | [diff] [blame] | 300 | return -EIO; |
Hartmut Hackmann | 58ef4f9 | 2007-04-27 12:31:12 -0300 | [diff] [blame] | 301 | } |
Mauro Carvalho Chehab | 86ddd96 | 2005-07-12 13:58:47 -0700 | [diff] [blame] | 302 | msleep(1); |
| 303 | return 0; |
| 304 | } |
| 305 | |
Hartmut Hackmann | 58ef4f9 | 2007-04-27 12:31:12 -0300 | [diff] [blame] | 306 | static int philips_tu1216_init(struct dvb_frontend *fe) |
Hartmut Hackmann | 2cf36ac | 2005-11-08 21:36:32 -0800 | [diff] [blame] | 307 | { |
| 308 | struct saa7134_dev *dev = fe->dvb->priv; |
Hartmut Hackmann | 58ef4f9 | 2007-04-27 12:31:12 -0300 | [diff] [blame] | 309 | struct tda1004x_state *state = fe->demodulator_priv; |
| 310 | u8 addr = state->config->tuner_address; |
Hartmut Hackmann | 2cf36ac | 2005-11-08 21:36:32 -0800 | [diff] [blame] | 311 | static u8 tu1216_init[] = { 0x0b, 0xf5, 0x85, 0xab }; |
| 312 | struct i2c_msg tuner_msg = {.addr = addr,.flags = 0,.buf = tu1216_init,.len = sizeof(tu1216_init) }; |
| 313 | |
| 314 | /* setup PLL configuration */ |
Patrick Boettcher | dea7486 | 2006-05-14 05:01:31 -0300 | [diff] [blame] | 315 | if (fe->ops.i2c_gate_ctrl) |
| 316 | fe->ops.i2c_gate_ctrl(fe, 1); |
Hartmut Hackmann | 2cf36ac | 2005-11-08 21:36:32 -0800 | [diff] [blame] | 317 | if (i2c_transfer(&dev->i2c_adap, &tuner_msg, 1) != 1) |
| 318 | return -EIO; |
| 319 | msleep(1); |
| 320 | |
| 321 | return 0; |
| 322 | } |
| 323 | |
| 324 | /* ------------------------------------------------------------------ */ |
| 325 | |
Hartmut Hackmann | 2cf36ac | 2005-11-08 21:36:32 -0800 | [diff] [blame] | 326 | static struct tda1004x_config philips_tu1216_60_config = { |
Mauro Carvalho Chehab | 86ddd96 | 2005-07-12 13:58:47 -0700 | [diff] [blame] | 327 | .demod_address = 0x8, |
| 328 | .invert = 1, |
Hartmut Hackmann | 2cf36ac | 2005-11-08 21:36:32 -0800 | [diff] [blame] | 329 | .invert_oclk = 0, |
Mauro Carvalho Chehab | 86ddd96 | 2005-07-12 13:58:47 -0700 | [diff] [blame] | 330 | .xtal_freq = TDA10046_XTAL_4M, |
| 331 | .agc_config = TDA10046_AGC_DEFAULT, |
| 332 | .if_freq = TDA10046_FREQ_3617, |
Hartmut Hackmann | 58ef4f9 | 2007-04-27 12:31:12 -0300 | [diff] [blame] | 333 | .tuner_address = 0x60, |
| 334 | .request_firmware = philips_tda1004x_request_firmware |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 335 | }; |
| 336 | |
Hartmut Hackmann | 2cf36ac | 2005-11-08 21:36:32 -0800 | [diff] [blame] | 337 | static struct tda1004x_config philips_tu1216_61_config = { |
| 338 | |
| 339 | .demod_address = 0x8, |
| 340 | .invert = 1, |
| 341 | .invert_oclk = 0, |
| 342 | .xtal_freq = TDA10046_XTAL_4M, |
| 343 | .agc_config = TDA10046_AGC_DEFAULT, |
| 344 | .if_freq = TDA10046_FREQ_3617, |
Hartmut Hackmann | 58ef4f9 | 2007-04-27 12:31:12 -0300 | [diff] [blame] | 345 | .tuner_address = 0x61, |
| 346 | .request_firmware = philips_tda1004x_request_firmware |
Hartmut Hackmann | 2cf36ac | 2005-11-08 21:36:32 -0800 | [diff] [blame] | 347 | }; |
| 348 | |
| 349 | /* ------------------------------------------------------------------ */ |
| 350 | |
Hartmut Hackmann | cbb9452 | 2006-10-30 20:00:16 -0300 | [diff] [blame] | 351 | static int philips_td1316_tuner_init(struct dvb_frontend *fe) |
Hartmut Hackmann | 2cf36ac | 2005-11-08 21:36:32 -0800 | [diff] [blame] | 352 | { |
| 353 | struct saa7134_dev *dev = fe->dvb->priv; |
Hartmut Hackmann | 58ef4f9 | 2007-04-27 12:31:12 -0300 | [diff] [blame] | 354 | struct tda1004x_state *state = fe->demodulator_priv; |
| 355 | u8 addr = state->config->tuner_address; |
Hartmut Hackmann | 2cf36ac | 2005-11-08 21:36:32 -0800 | [diff] [blame] | 356 | static u8 msg[] = { 0x0b, 0xf5, 0x86, 0xab }; |
Hartmut Hackmann | 58ef4f9 | 2007-04-27 12:31:12 -0300 | [diff] [blame] | 357 | struct i2c_msg init_msg = {.addr = addr,.flags = 0,.buf = msg,.len = sizeof(msg) }; |
Hartmut Hackmann | 2cf36ac | 2005-11-08 21:36:32 -0800 | [diff] [blame] | 358 | |
| 359 | /* setup PLL configuration */ |
Patrick Boettcher | dea7486 | 2006-05-14 05:01:31 -0300 | [diff] [blame] | 360 | if (fe->ops.i2c_gate_ctrl) |
| 361 | fe->ops.i2c_gate_ctrl(fe, 1); |
Hartmut Hackmann | 2cf36ac | 2005-11-08 21:36:32 -0800 | [diff] [blame] | 362 | if (i2c_transfer(&dev->i2c_adap, &init_msg, 1) != 1) |
| 363 | return -EIO; |
Hartmut Hackmann | 2cf36ac | 2005-11-08 21:36:32 -0800 | [diff] [blame] | 364 | return 0; |
| 365 | } |
| 366 | |
Andrew de Quincey | a79ddae | 2006-04-18 17:47:11 -0300 | [diff] [blame] | 367 | static int philips_td1316_tuner_set_params(struct dvb_frontend *fe, struct dvb_frontend_parameters *params) |
Hartmut Hackmann | 2cf36ac | 2005-11-08 21:36:32 -0800 | [diff] [blame] | 368 | { |
Hartmut Hackmann | 58ef4f9 | 2007-04-27 12:31:12 -0300 | [diff] [blame] | 369 | return philips_tda6651_pll_set(fe, params); |
Hartmut Hackmann | 2cf36ac | 2005-11-08 21:36:32 -0800 | [diff] [blame] | 370 | } |
| 371 | |
Hartmut Hackmann | 58ef4f9 | 2007-04-27 12:31:12 -0300 | [diff] [blame] | 372 | static int philips_td1316_tuner_sleep(struct dvb_frontend *fe) |
| 373 | { |
| 374 | struct saa7134_dev *dev = fe->dvb->priv; |
| 375 | struct tda1004x_state *state = fe->demodulator_priv; |
| 376 | u8 addr = state->config->tuner_address; |
| 377 | static u8 msg[] = { 0x0b, 0xdc, 0x86, 0xa4 }; |
| 378 | struct i2c_msg analog_msg = {.addr = addr,.flags = 0,.buf = msg,.len = sizeof(msg) }; |
| 379 | |
| 380 | /* switch the tuner to analog mode */ |
| 381 | if (fe->ops.i2c_gate_ctrl) |
| 382 | fe->ops.i2c_gate_ctrl(fe, 1); |
| 383 | if (i2c_transfer(&dev->i2c_adap, &analog_msg, 1) != 1) |
| 384 | return -EIO; |
| 385 | return 0; |
| 386 | } |
| 387 | |
| 388 | /* ------------------------------------------------------------------ */ |
| 389 | |
Hartmut Hackmann | cbb9452 | 2006-10-30 20:00:16 -0300 | [diff] [blame] | 390 | static int philips_europa_tuner_init(struct dvb_frontend *fe) |
| 391 | { |
| 392 | struct saa7134_dev *dev = fe->dvb->priv; |
| 393 | static u8 msg[] = { 0x00, 0x40}; |
| 394 | struct i2c_msg init_msg = {.addr = 0x43,.flags = 0,.buf = msg,.len = sizeof(msg) }; |
| 395 | |
| 396 | |
| 397 | if (philips_td1316_tuner_init(fe)) |
| 398 | return -EIO; |
| 399 | msleep(1); |
| 400 | if (i2c_transfer(&dev->i2c_adap, &init_msg, 1) != 1) |
| 401 | return -EIO; |
| 402 | |
| 403 | return 0; |
| 404 | } |
| 405 | |
Andrew de Quincey | a79ddae | 2006-04-18 17:47:11 -0300 | [diff] [blame] | 406 | static int philips_europa_tuner_sleep(struct dvb_frontend *fe) |
Hartmut Hackmann | 2cf36ac | 2005-11-08 21:36:32 -0800 | [diff] [blame] | 407 | { |
| 408 | struct saa7134_dev *dev = fe->dvb->priv; |
Hartmut Hackmann | 2cf36ac | 2005-11-08 21:36:32 -0800 | [diff] [blame] | 409 | |
Hartmut Hackmann | 58ef4f9 | 2007-04-27 12:31:12 -0300 | [diff] [blame] | 410 | static u8 msg[] = { 0x00, 0x14 }; |
| 411 | struct i2c_msg analog_msg = {.addr = 0x43,.flags = 0,.buf = msg,.len = sizeof(msg) }; |
| 412 | |
| 413 | if (philips_td1316_tuner_sleep(fe)) |
| 414 | return -EIO; |
Hartmut Hackmann | 2cf36ac | 2005-11-08 21:36:32 -0800 | [diff] [blame] | 415 | |
| 416 | /* switch the board to analog mode */ |
Patrick Boettcher | dea7486 | 2006-05-14 05:01:31 -0300 | [diff] [blame] | 417 | if (fe->ops.i2c_gate_ctrl) |
| 418 | fe->ops.i2c_gate_ctrl(fe, 1); |
Hartmut Hackmann | 2cf36ac | 2005-11-08 21:36:32 -0800 | [diff] [blame] | 419 | i2c_transfer(&dev->i2c_adap, &analog_msg, 1); |
Andrew de Quincey | a79ddae | 2006-04-18 17:47:11 -0300 | [diff] [blame] | 420 | return 0; |
| 421 | } |
| 422 | |
| 423 | static int philips_europa_demod_sleep(struct dvb_frontend *fe) |
| 424 | { |
| 425 | struct saa7134_dev *dev = fe->dvb->priv; |
| 426 | |
| 427 | if (dev->original_demod_sleep) |
| 428 | dev->original_demod_sleep(fe); |
Patrick Boettcher | dea7486 | 2006-05-14 05:01:31 -0300 | [diff] [blame] | 429 | fe->ops.i2c_gate_ctrl(fe, 1); |
Andrew de Quincey | a79ddae | 2006-04-18 17:47:11 -0300 | [diff] [blame] | 430 | return 0; |
Hartmut Hackmann | 2cf36ac | 2005-11-08 21:36:32 -0800 | [diff] [blame] | 431 | } |
| 432 | |
| 433 | static struct tda1004x_config philips_europa_config = { |
| 434 | |
| 435 | .demod_address = 0x8, |
| 436 | .invert = 0, |
| 437 | .invert_oclk = 0, |
| 438 | .xtal_freq = TDA10046_XTAL_4M, |
| 439 | .agc_config = TDA10046_AGC_IFO_AUTO_POS, |
| 440 | .if_freq = TDA10046_FREQ_052, |
Hartmut Hackmann | 58ef4f9 | 2007-04-27 12:31:12 -0300 | [diff] [blame] | 441 | .tuner_address = 0x61, |
| 442 | .request_firmware = philips_tda1004x_request_firmware |
Hartmut Hackmann | 2cf36ac | 2005-11-08 21:36:32 -0800 | [diff] [blame] | 443 | }; |
| 444 | |
| 445 | /* ------------------------------------------------------------------ */ |
Mauro Carvalho Chehab | 86ddd96 | 2005-07-12 13:58:47 -0700 | [diff] [blame] | 446 | |
Andrew de Quincey | a79ddae | 2006-04-18 17:47:11 -0300 | [diff] [blame] | 447 | static int philips_fmd1216_tuner_init(struct dvb_frontend *fe) |
Mauro Carvalho Chehab | 86ddd96 | 2005-07-12 13:58:47 -0700 | [diff] [blame] | 448 | { |
| 449 | struct saa7134_dev *dev = fe->dvb->priv; |
Hartmut Hackmann | 58ef4f9 | 2007-04-27 12:31:12 -0300 | [diff] [blame] | 450 | struct tda1004x_state *state = fe->demodulator_priv; |
| 451 | u8 addr = state->config->tuner_address; |
Mauro Carvalho Chehab | 86ddd96 | 2005-07-12 13:58:47 -0700 | [diff] [blame] | 452 | /* this message is to set up ATC and ALC */ |
| 453 | static u8 fmd1216_init[] = { 0x0b, 0xdc, 0x9c, 0xa0 }; |
Hartmut Hackmann | 58ef4f9 | 2007-04-27 12:31:12 -0300 | [diff] [blame] | 454 | struct i2c_msg tuner_msg = {.addr = addr,.flags = 0,.buf = fmd1216_init,.len = sizeof(fmd1216_init) }; |
Mauro Carvalho Chehab | 86ddd96 | 2005-07-12 13:58:47 -0700 | [diff] [blame] | 455 | |
Patrick Boettcher | dea7486 | 2006-05-14 05:01:31 -0300 | [diff] [blame] | 456 | if (fe->ops.i2c_gate_ctrl) |
| 457 | fe->ops.i2c_gate_ctrl(fe, 1); |
Mauro Carvalho Chehab | 86ddd96 | 2005-07-12 13:58:47 -0700 | [diff] [blame] | 458 | if (i2c_transfer(&dev->i2c_adap, &tuner_msg, 1) != 1) |
| 459 | return -EIO; |
| 460 | msleep(1); |
| 461 | |
| 462 | return 0; |
| 463 | } |
| 464 | |
Andrew de Quincey | a79ddae | 2006-04-18 17:47:11 -0300 | [diff] [blame] | 465 | static int philips_fmd1216_tuner_sleep(struct dvb_frontend *fe) |
Mauro Carvalho Chehab | 86ddd96 | 2005-07-12 13:58:47 -0700 | [diff] [blame] | 466 | { |
| 467 | struct saa7134_dev *dev = fe->dvb->priv; |
Hartmut Hackmann | 58ef4f9 | 2007-04-27 12:31:12 -0300 | [diff] [blame] | 468 | struct tda1004x_state *state = fe->demodulator_priv; |
| 469 | u8 addr = state->config->tuner_address; |
Mauro Carvalho Chehab | 86ddd96 | 2005-07-12 13:58:47 -0700 | [diff] [blame] | 470 | /* this message actually turns the tuner back to analog mode */ |
Hartmut Hackmann | cf83ac4 | 2007-03-13 20:52:35 -0300 | [diff] [blame] | 471 | u8 fmd1216_init[] = { 0x0b, 0xdc, 0x9c, 0x60 }; |
Hartmut Hackmann | 58ef4f9 | 2007-04-27 12:31:12 -0300 | [diff] [blame] | 472 | struct i2c_msg tuner_msg = {.addr = addr,.flags = 0,.buf = fmd1216_init,.len = sizeof(fmd1216_init) }; |
Mauro Carvalho Chehab | 86ddd96 | 2005-07-12 13:58:47 -0700 | [diff] [blame] | 473 | |
Patrick Boettcher | dea7486 | 2006-05-14 05:01:31 -0300 | [diff] [blame] | 474 | if (fe->ops.i2c_gate_ctrl) |
| 475 | fe->ops.i2c_gate_ctrl(fe, 1); |
Mauro Carvalho Chehab | 86ddd96 | 2005-07-12 13:58:47 -0700 | [diff] [blame] | 476 | i2c_transfer(&dev->i2c_adap, &tuner_msg, 1); |
| 477 | msleep(1); |
| 478 | fmd1216_init[2] = 0x86; |
| 479 | fmd1216_init[3] = 0x54; |
Patrick Boettcher | dea7486 | 2006-05-14 05:01:31 -0300 | [diff] [blame] | 480 | if (fe->ops.i2c_gate_ctrl) |
| 481 | fe->ops.i2c_gate_ctrl(fe, 1); |
Mauro Carvalho Chehab | 86ddd96 | 2005-07-12 13:58:47 -0700 | [diff] [blame] | 482 | i2c_transfer(&dev->i2c_adap, &tuner_msg, 1); |
| 483 | msleep(1); |
Andrew de Quincey | a79ddae | 2006-04-18 17:47:11 -0300 | [diff] [blame] | 484 | return 0; |
Mauro Carvalho Chehab | 86ddd96 | 2005-07-12 13:58:47 -0700 | [diff] [blame] | 485 | } |
| 486 | |
Andrew de Quincey | a79ddae | 2006-04-18 17:47:11 -0300 | [diff] [blame] | 487 | static int philips_fmd1216_tuner_set_params(struct dvb_frontend *fe, struct dvb_frontend_parameters *params) |
Mauro Carvalho Chehab | 86ddd96 | 2005-07-12 13:58:47 -0700 | [diff] [blame] | 488 | { |
| 489 | struct saa7134_dev *dev = fe->dvb->priv; |
Hartmut Hackmann | 58ef4f9 | 2007-04-27 12:31:12 -0300 | [diff] [blame] | 490 | struct tda1004x_state *state = fe->demodulator_priv; |
| 491 | u8 addr = state->config->tuner_address; |
Mauro Carvalho Chehab | 86ddd96 | 2005-07-12 13:58:47 -0700 | [diff] [blame] | 492 | u8 tuner_buf[4]; |
Hartmut Hackmann | 58ef4f9 | 2007-04-27 12:31:12 -0300 | [diff] [blame] | 493 | struct i2c_msg tuner_msg = {.addr = addr,.flags = 0,.buf = tuner_buf,.len = |
Mauro Carvalho Chehab | 86ddd96 | 2005-07-12 13:58:47 -0700 | [diff] [blame] | 494 | sizeof(tuner_buf) }; |
| 495 | int tuner_frequency = 0; |
| 496 | int divider = 0; |
| 497 | u8 band, mode, cp; |
| 498 | |
| 499 | /* determine charge pump */ |
| 500 | tuner_frequency = params->frequency + 36130000; |
| 501 | if (tuner_frequency < 87000000) |
| 502 | return -EINVAL; |
| 503 | /* low band */ |
| 504 | else if (tuner_frequency < 180000000) { |
| 505 | band = 1; |
| 506 | mode = 7; |
| 507 | cp = 0; |
| 508 | } else if (tuner_frequency < 195000000) { |
| 509 | band = 1; |
| 510 | mode = 6; |
| 511 | cp = 1; |
| 512 | /* mid band */ |
| 513 | } else if (tuner_frequency < 366000000) { |
| 514 | if (params->u.ofdm.bandwidth == BANDWIDTH_8_MHZ) { |
| 515 | band = 10; |
| 516 | } else { |
| 517 | band = 2; |
| 518 | } |
| 519 | mode = 7; |
| 520 | cp = 0; |
| 521 | } else if (tuner_frequency < 478000000) { |
| 522 | if (params->u.ofdm.bandwidth == BANDWIDTH_8_MHZ) { |
| 523 | band = 10; |
| 524 | } else { |
| 525 | band = 2; |
| 526 | } |
| 527 | mode = 6; |
| 528 | cp = 1; |
| 529 | /* high band */ |
| 530 | } else if (tuner_frequency < 662000000) { |
| 531 | if (params->u.ofdm.bandwidth == BANDWIDTH_8_MHZ) { |
| 532 | band = 12; |
| 533 | } else { |
| 534 | band = 4; |
| 535 | } |
| 536 | mode = 7; |
| 537 | cp = 0; |
| 538 | } else if (tuner_frequency < 840000000) { |
| 539 | if (params->u.ofdm.bandwidth == BANDWIDTH_8_MHZ) { |
| 540 | band = 12; |
| 541 | } else { |
| 542 | band = 4; |
| 543 | } |
| 544 | mode = 6; |
| 545 | cp = 1; |
| 546 | } else { |
| 547 | if (params->u.ofdm.bandwidth == BANDWIDTH_8_MHZ) { |
| 548 | band = 12; |
| 549 | } else { |
| 550 | band = 4; |
| 551 | } |
| 552 | mode = 7; |
| 553 | cp = 1; |
| 554 | |
| 555 | } |
| 556 | /* calculate divisor */ |
| 557 | /* ((36166000 + Finput) / 166666) rounded! */ |
| 558 | divider = (tuner_frequency + 83333) / 166667; |
| 559 | |
| 560 | /* setup tuner buffer */ |
| 561 | tuner_buf[0] = (divider >> 8) & 0x7f; |
| 562 | tuner_buf[1] = divider & 0xff; |
| 563 | tuner_buf[2] = 0x80 | (cp << 6) | (mode << 3) | 4; |
| 564 | tuner_buf[3] = 0x40 | band; |
| 565 | |
Patrick Boettcher | dea7486 | 2006-05-14 05:01:31 -0300 | [diff] [blame] | 566 | if (fe->ops.i2c_gate_ctrl) |
| 567 | fe->ops.i2c_gate_ctrl(fe, 1); |
Hartmut Hackmann | 58ef4f9 | 2007-04-27 12:31:12 -0300 | [diff] [blame] | 568 | if (i2c_transfer(&dev->i2c_adap, &tuner_msg, 1) != 1) { |
Trent Piepho | cf3c34c | 2007-03-07 18:19:48 -0300 | [diff] [blame] | 569 | wprintk("could not write to tuner at addr: 0x%02x\n", |
| 570 | addr << 1); |
Mauro Carvalho Chehab | 86ddd96 | 2005-07-12 13:58:47 -0700 | [diff] [blame] | 571 | return -EIO; |
Hartmut Hackmann | 58ef4f9 | 2007-04-27 12:31:12 -0300 | [diff] [blame] | 572 | } |
Mauro Carvalho Chehab | 86ddd96 | 2005-07-12 13:58:47 -0700 | [diff] [blame] | 573 | return 0; |
| 574 | } |
| 575 | |
Mauro Carvalho Chehab | 86ddd96 | 2005-07-12 13:58:47 -0700 | [diff] [blame] | 576 | static struct tda1004x_config medion_cardbus = { |
| 577 | .demod_address = 0x08, |
| 578 | .invert = 1, |
| 579 | .invert_oclk = 0, |
| 580 | .xtal_freq = TDA10046_XTAL_16M, |
| 581 | .agc_config = TDA10046_AGC_IFO_AUTO_NEG, |
| 582 | .if_freq = TDA10046_FREQ_3613, |
Hartmut Hackmann | 58ef4f9 | 2007-04-27 12:31:12 -0300 | [diff] [blame] | 583 | .tuner_address = 0x61, |
| 584 | .request_firmware = philips_tda1004x_request_firmware |
Mauro Carvalho Chehab | 86ddd96 | 2005-07-12 13:58:47 -0700 | [diff] [blame] | 585 | }; |
| 586 | |
Hartmut Hackmann | 58ef4f9 | 2007-04-27 12:31:12 -0300 | [diff] [blame] | 587 | /* ------------------------------------------------------------------ |
| 588 | * tda 1004x based cards with philips silicon tuner |
| 589 | */ |
| 590 | |
| 591 | static void philips_tda827x_lna_gain(struct dvb_frontend *fe, int high) |
| 592 | { |
| 593 | struct saa7134_dev *dev = fe->dvb->priv; |
| 594 | struct tda1004x_state *state = fe->demodulator_priv; |
| 595 | u8 addr = state->config->i2c_gate; |
| 596 | u8 config = state->config->tuner_config; |
| 597 | u8 GP00_CF[] = {0x20, 0x01}; |
| 598 | u8 GP00_LEV[] = {0x22, 0x00}; |
| 599 | |
| 600 | struct i2c_msg msg = {.addr = addr,.flags = 0,.buf = GP00_CF, .len = 2}; |
| 601 | if (config) { |
| 602 | if (high) { |
| 603 | dprintk("setting LNA to high gain\n"); |
| 604 | } else { |
| 605 | dprintk("setting LNA to low gain\n"); |
| 606 | } |
| 607 | } |
| 608 | switch (config) { |
| 609 | case 0: /* no LNA */ |
| 610 | break; |
| 611 | case 1: /* switch is GPIO 0 of tda8290 */ |
| 612 | case 2: |
| 613 | /* turn Vsync off */ |
| 614 | saa7134_set_gpio(dev, 22, 0); |
| 615 | GP00_LEV[1] = high ? 0 : 1; |
| 616 | if (i2c_transfer(&dev->i2c_adap, &msg, 1) != 1) { |
Trent Piepho | cf3c34c | 2007-03-07 18:19:48 -0300 | [diff] [blame] | 617 | wprintk("could not access tda8290 at addr: 0x%02x\n", |
| 618 | addr << 1); |
Hartmut Hackmann | 58ef4f9 | 2007-04-27 12:31:12 -0300 | [diff] [blame] | 619 | return; |
| 620 | } |
| 621 | msg.buf = GP00_LEV; |
| 622 | if (config == 2) |
| 623 | GP00_LEV[1] = high ? 1 : 0; |
| 624 | i2c_transfer(&dev->i2c_adap, &msg, 1); |
| 625 | break; |
| 626 | case 3: /* switch with GPIO of saa713x */ |
| 627 | saa7134_set_gpio(dev, 22, high); |
| 628 | break; |
| 629 | } |
| 630 | } |
| 631 | |
| 632 | static int tda8290_i2c_gate_ctrl( struct dvb_frontend* fe, int enable) |
| 633 | { |
Hartmut Hackmann | 58ef4f9 | 2007-04-27 12:31:12 -0300 | [diff] [blame] | 634 | struct tda1004x_state *state = fe->demodulator_priv; |
| 635 | |
| 636 | u8 addr = state->config->i2c_gate; |
| 637 | static u8 tda8290_close[] = { 0x21, 0xc0}; |
| 638 | static u8 tda8290_open[] = { 0x21, 0x80}; |
| 639 | struct i2c_msg tda8290_msg = {.addr = addr,.flags = 0, .len = 2}; |
| 640 | if (enable) { |
| 641 | tda8290_msg.buf = tda8290_close; |
| 642 | } else { |
| 643 | tda8290_msg.buf = tda8290_open; |
| 644 | } |
Hartmut Hackmann | 06be303 | 2007-04-27 12:31:15 -0300 | [diff] [blame] | 645 | if (i2c_transfer(state->i2c, &tda8290_msg, 1) != 1) { |
Trent Piepho | cf3c34c | 2007-03-07 18:19:48 -0300 | [diff] [blame] | 646 | struct saa7134_dev *dev = fe->dvb->priv; |
| 647 | wprintk("could not access tda8290 I2C gate\n"); |
Hartmut Hackmann | 58ef4f9 | 2007-04-27 12:31:12 -0300 | [diff] [blame] | 648 | return -EIO; |
| 649 | } |
| 650 | msleep(20); |
| 651 | return 0; |
| 652 | } |
| 653 | |
Mauro Carvalho Chehab | 86ddd96 | 2005-07-12 13:58:47 -0700 | [diff] [blame] | 654 | /* ------------------------------------------------------------------ */ |
| 655 | |
Hartmut Hackmann | 58ef4f9 | 2007-04-27 12:31:12 -0300 | [diff] [blame] | 656 | static int philips_tda827x_tuner_init(struct dvb_frontend *fe) |
Hartmut Hackmann | 587d2fd | 2006-10-06 19:13:50 -0300 | [diff] [blame] | 657 | { |
| 658 | struct saa7134_dev *dev = fe->dvb->priv; |
Hartmut Hackmann | 58ef4f9 | 2007-04-27 12:31:12 -0300 | [diff] [blame] | 659 | struct tda1004x_state *state = fe->demodulator_priv; |
Michael Krufky | 8ce47da | 2007-04-27 12:31:14 -0300 | [diff] [blame] | 660 | |
Hartmut Hackmann | 58ef4f9 | 2007-04-27 12:31:12 -0300 | [diff] [blame] | 661 | switch (state->config->antenna_switch) { |
| 662 | case 0: break; |
| 663 | case 1: dprintk("setting GPIO21 to 0 (TV antenna?)\n"); |
| 664 | saa7134_set_gpio(dev, 21, 0); |
| 665 | break; |
| 666 | case 2: dprintk("setting GPIO21 to 1 (Radio antenna?)\n"); |
| 667 | saa7134_set_gpio(dev, 21, 1); |
| 668 | break; |
| 669 | } |
Andrew de Quincey | a79ddae | 2006-04-18 17:47:11 -0300 | [diff] [blame] | 670 | return 0; |
Hartmut Hackmann | 90e9df7 | 2005-11-08 21:38:42 -0800 | [diff] [blame] | 671 | } |
| 672 | |
Hartmut Hackmann | 58ef4f9 | 2007-04-27 12:31:12 -0300 | [diff] [blame] | 673 | static int philips_tda827x_tuner_sleep(struct dvb_frontend *fe) |
| 674 | { |
| 675 | struct saa7134_dev *dev = fe->dvb->priv; |
| 676 | struct tda1004x_state *state = fe->demodulator_priv; |
Michael Krufky | 8ce47da | 2007-04-27 12:31:14 -0300 | [diff] [blame] | 677 | |
Hartmut Hackmann | 58ef4f9 | 2007-04-27 12:31:12 -0300 | [diff] [blame] | 678 | switch (state->config->antenna_switch) { |
| 679 | case 0: break; |
| 680 | case 1: dprintk("setting GPIO21 to 1 (Radio antenna?)\n"); |
| 681 | saa7134_set_gpio(dev, 21, 1); |
| 682 | break; |
| 683 | case 2: dprintk("setting GPIO21 to 0 (TV antenna?)\n"); |
| 684 | saa7134_set_gpio(dev, 21, 0); |
| 685 | break; |
| 686 | } |
| 687 | return 0; |
| 688 | } |
| 689 | |
Michael Krufky | 8ce47da | 2007-04-27 12:31:14 -0300 | [diff] [blame] | 690 | static struct tda827x_config tda827x_cfg = { |
| 691 | .lna_gain = philips_tda827x_lna_gain, |
| 692 | .init = philips_tda827x_tuner_init, |
| 693 | .sleep = philips_tda827x_tuner_sleep |
| 694 | }; |
Hartmut Hackmann | 58ef4f9 | 2007-04-27 12:31:12 -0300 | [diff] [blame] | 695 | |
Hartmut Hackmann | b8bc76d | 2007-04-27 12:31:16 -0300 | [diff] [blame] | 696 | static void configure_tda827x_fe(struct saa7134_dev *dev, struct tda1004x_config *tda_conf) |
Hartmut Hackmann | 58ef4f9 | 2007-04-27 12:31:12 -0300 | [diff] [blame] | 697 | { |
| 698 | dev->dvb.frontend = dvb_attach(tda10046_attach, tda_conf, &dev->i2c_adap); |
| 699 | if (dev->dvb.frontend) { |
| 700 | if (tda_conf->i2c_gate) |
| 701 | dev->dvb.frontend->ops.i2c_gate_ctrl = tda8290_i2c_gate_ctrl; |
Hartmut Hackmann | ede2200 | 2007-04-27 12:31:32 -0300 | [diff] [blame] | 702 | if (dvb_attach(tda827x_attach, dev->dvb.frontend, tda_conf->tuner_address, |
| 703 | &dev->i2c_adap,&tda827x_cfg) == NULL) { |
Trent Piepho | cf3c34c | 2007-03-07 18:19:48 -0300 | [diff] [blame] | 704 | wprintk("no tda827x tuner found at addr: %02x\n", |
Hartmut Hackmann | ede2200 | 2007-04-27 12:31:32 -0300 | [diff] [blame] | 705 | tda_conf->tuner_address); |
| 706 | } |
Hartmut Hackmann | 58ef4f9 | 2007-04-27 12:31:12 -0300 | [diff] [blame] | 707 | } |
Hartmut Hackmann | 58ef4f9 | 2007-04-27 12:31:12 -0300 | [diff] [blame] | 708 | } |
| 709 | |
Hartmut Hackmann | 90e9df7 | 2005-11-08 21:38:42 -0800 | [diff] [blame] | 710 | /* ------------------------------------------------------------------ */ |
Hartmut Hackmann | 58ef4f9 | 2007-04-27 12:31:12 -0300 | [diff] [blame] | 711 | static struct tda1004x_config tda827x_lifeview_config = { |
| 712 | .demod_address = 0x08, |
| 713 | .invert = 1, |
| 714 | .invert_oclk = 0, |
| 715 | .xtal_freq = TDA10046_XTAL_16M, |
| 716 | .agc_config = TDA10046_AGC_TDA827X, |
| 717 | .gpio_config = TDA10046_GP11_I, |
| 718 | .if_freq = TDA10046_FREQ_045, |
| 719 | .tuner_address = 0x60, |
| 720 | .request_firmware = philips_tda1004x_request_firmware |
| 721 | }; |
Hartmut Hackmann | 90e9df7 | 2005-11-08 21:38:42 -0800 | [diff] [blame] | 722 | |
| 723 | static struct tda1004x_config philips_tiger_config = { |
| 724 | .demod_address = 0x08, |
| 725 | .invert = 1, |
| 726 | .invert_oclk = 0, |
| 727 | .xtal_freq = TDA10046_XTAL_16M, |
Hartmut Hackmann | 1bb0e86 | 2007-04-27 12:31:10 -0300 | [diff] [blame] | 728 | .agc_config = TDA10046_AGC_TDA827X, |
| 729 | .gpio_config = TDA10046_GP11_I, |
Hartmut Hackmann | 550a9a5 | 2006-11-15 21:31:54 -0300 | [diff] [blame] | 730 | .if_freq = TDA10046_FREQ_045, |
Hartmut Hackmann | 58ef4f9 | 2007-04-27 12:31:12 -0300 | [diff] [blame] | 731 | .i2c_gate = 0x4b, |
| 732 | .tuner_address = 0x61, |
| 733 | .tuner_config = 0, |
| 734 | .antenna_switch= 1, |
| 735 | .request_firmware = philips_tda1004x_request_firmware |
Hartmut Hackmann | 550a9a5 | 2006-11-15 21:31:54 -0300 | [diff] [blame] | 736 | }; |
Hartmut Hackmann | 550a9a5 | 2006-11-15 21:31:54 -0300 | [diff] [blame] | 737 | |
| 738 | static struct tda1004x_config cinergy_ht_config = { |
| 739 | .demod_address = 0x08, |
| 740 | .invert = 1, |
| 741 | .invert_oclk = 0, |
| 742 | .xtal_freq = TDA10046_XTAL_16M, |
Hartmut Hackmann | 1bb0e86 | 2007-04-27 12:31:10 -0300 | [diff] [blame] | 743 | .agc_config = TDA10046_AGC_TDA827X, |
| 744 | .gpio_config = TDA10046_GP01_I, |
Hartmut Hackmann | 90e9df7 | 2005-11-08 21:38:42 -0800 | [diff] [blame] | 745 | .if_freq = TDA10046_FREQ_045, |
Hartmut Hackmann | 58ef4f9 | 2007-04-27 12:31:12 -0300 | [diff] [blame] | 746 | .i2c_gate = 0x4b, |
| 747 | .tuner_address = 0x61, |
| 748 | .tuner_config = 0, |
| 749 | .request_firmware = philips_tda1004x_request_firmware |
Hartmut Hackmann | 90e9df7 | 2005-11-08 21:38:42 -0800 | [diff] [blame] | 750 | }; |
| 751 | |
Hartmut Hackmann | 58ef4f9 | 2007-04-27 12:31:12 -0300 | [diff] [blame] | 752 | static struct tda1004x_config cinergy_ht_pci_config = { |
| 753 | .demod_address = 0x08, |
| 754 | .invert = 1, |
| 755 | .invert_oclk = 0, |
| 756 | .xtal_freq = TDA10046_XTAL_16M, |
| 757 | .agc_config = TDA10046_AGC_TDA827X, |
| 758 | .gpio_config = TDA10046_GP01_I, |
| 759 | .if_freq = TDA10046_FREQ_045, |
| 760 | .i2c_gate = 0x4b, |
| 761 | .tuner_address = 0x60, |
| 762 | .tuner_config = 0, |
| 763 | .request_firmware = philips_tda1004x_request_firmware |
| 764 | }; |
| 765 | |
| 766 | static struct tda1004x_config philips_tiger_s_config = { |
| 767 | .demod_address = 0x08, |
| 768 | .invert = 1, |
| 769 | .invert_oclk = 0, |
| 770 | .xtal_freq = TDA10046_XTAL_16M, |
| 771 | .agc_config = TDA10046_AGC_TDA827X, |
| 772 | .gpio_config = TDA10046_GP01_I, |
| 773 | .if_freq = TDA10046_FREQ_045, |
| 774 | .i2c_gate = 0x4b, |
| 775 | .tuner_address = 0x61, |
| 776 | .tuner_config = 2, |
| 777 | .antenna_switch= 1, |
| 778 | .request_firmware = philips_tda1004x_request_firmware |
| 779 | }; |
Hartmut Hackmann | df42eaf | 2006-02-07 06:49:10 -0200 | [diff] [blame] | 780 | |
Hartmut Hackmann | 587d2fd | 2006-10-06 19:13:50 -0300 | [diff] [blame] | 781 | static struct tda1004x_config pinnacle_pctv_310i_config = { |
| 782 | .demod_address = 0x08, |
| 783 | .invert = 1, |
| 784 | .invert_oclk = 0, |
| 785 | .xtal_freq = TDA10046_XTAL_16M, |
Hartmut Hackmann | 1bb0e86 | 2007-04-27 12:31:10 -0300 | [diff] [blame] | 786 | .agc_config = TDA10046_AGC_TDA827X, |
| 787 | .gpio_config = TDA10046_GP11_I, |
Hartmut Hackmann | 587d2fd | 2006-10-06 19:13:50 -0300 | [diff] [blame] | 788 | .if_freq = TDA10046_FREQ_045, |
Hartmut Hackmann | 58ef4f9 | 2007-04-27 12:31:12 -0300 | [diff] [blame] | 789 | .i2c_gate = 0x4b, |
| 790 | .tuner_address = 0x61, |
| 791 | .tuner_config = 1, |
| 792 | .request_firmware = philips_tda1004x_request_firmware |
Hartmut Hackmann | 587d2fd | 2006-10-06 19:13:50 -0300 | [diff] [blame] | 793 | }; |
| 794 | |
Thomas Genty | c6e53da | 2006-11-05 14:17:30 -0300 | [diff] [blame] | 795 | static struct tda1004x_config hauppauge_hvr_1110_config = { |
| 796 | .demod_address = 0x08, |
| 797 | .invert = 1, |
| 798 | .invert_oclk = 0, |
| 799 | .xtal_freq = TDA10046_XTAL_16M, |
Hartmut Hackmann | 1bb0e86 | 2007-04-27 12:31:10 -0300 | [diff] [blame] | 800 | .agc_config = TDA10046_AGC_TDA827X, |
| 801 | .gpio_config = TDA10046_GP11_I, |
Thomas Genty | c6e53da | 2006-11-05 14:17:30 -0300 | [diff] [blame] | 802 | .if_freq = TDA10046_FREQ_045, |
Hartmut Hackmann | 58ef4f9 | 2007-04-27 12:31:12 -0300 | [diff] [blame] | 803 | .i2c_gate = 0x4b, |
| 804 | .tuner_address = 0x61, |
| 805 | .request_firmware = philips_tda1004x_request_firmware |
Thomas Genty | c6e53da | 2006-11-05 14:17:30 -0300 | [diff] [blame] | 806 | }; |
| 807 | |
Hartmut Hackmann | 8364681 | 2006-10-12 20:38:51 -0300 | [diff] [blame] | 808 | static struct tda1004x_config asus_p7131_dual_config = { |
| 809 | .demod_address = 0x08, |
| 810 | .invert = 1, |
| 811 | .invert_oclk = 0, |
| 812 | .xtal_freq = TDA10046_XTAL_16M, |
Hartmut Hackmann | 1bb0e86 | 2007-04-27 12:31:10 -0300 | [diff] [blame] | 813 | .agc_config = TDA10046_AGC_TDA827X, |
| 814 | .gpio_config = TDA10046_GP11_I, |
Hartmut Hackmann | 8364681 | 2006-10-12 20:38:51 -0300 | [diff] [blame] | 815 | .if_freq = TDA10046_FREQ_045, |
Hartmut Hackmann | 58ef4f9 | 2007-04-27 12:31:12 -0300 | [diff] [blame] | 816 | .i2c_gate = 0x4b, |
| 817 | .tuner_address = 0x61, |
| 818 | .tuner_config = 0, |
| 819 | .antenna_switch= 2, |
| 820 | .request_firmware = philips_tda1004x_request_firmware |
Hartmut Hackmann | 8364681 | 2006-10-12 20:38:51 -0300 | [diff] [blame] | 821 | }; |
| 822 | |
Nico Sabbi | 420f32f | 2006-03-03 12:11:28 -0300 | [diff] [blame] | 823 | static struct tda1004x_config lifeview_trio_config = { |
| 824 | .demod_address = 0x09, |
| 825 | .invert = 1, |
| 826 | .invert_oclk = 0, |
| 827 | .xtal_freq = TDA10046_XTAL_16M, |
Hartmut Hackmann | 1bb0e86 | 2007-04-27 12:31:10 -0300 | [diff] [blame] | 828 | .agc_config = TDA10046_AGC_TDA827X, |
| 829 | .gpio_config = TDA10046_GP00_I, |
Nico Sabbi | 420f32f | 2006-03-03 12:11:28 -0300 | [diff] [blame] | 830 | .if_freq = TDA10046_FREQ_045, |
Hartmut Hackmann | 58ef4f9 | 2007-04-27 12:31:12 -0300 | [diff] [blame] | 831 | .tuner_address = 0x60, |
| 832 | .request_firmware = philips_tda1004x_request_firmware |
Nico Sabbi | 420f32f | 2006-03-03 12:11:28 -0300 | [diff] [blame] | 833 | }; |
| 834 | |
Hartmut Hackmann | 58ef4f9 | 2007-04-27 12:31:12 -0300 | [diff] [blame] | 835 | static struct tda1004x_config tevion_dvbt220rf_config = { |
| 836 | .demod_address = 0x08, |
| 837 | .invert = 1, |
| 838 | .invert_oclk = 0, |
| 839 | .xtal_freq = TDA10046_XTAL_16M, |
| 840 | .agc_config = TDA10046_AGC_TDA827X, |
| 841 | .gpio_config = TDA10046_GP11_I, |
| 842 | .if_freq = TDA10046_FREQ_045, |
| 843 | .tuner_address = 0x60, |
| 844 | .request_firmware = philips_tda1004x_request_firmware |
| 845 | }; |
Nico Sabbi | 420f32f | 2006-03-03 12:11:28 -0300 | [diff] [blame] | 846 | |
Hartmut Hackmann | 58ef4f9 | 2007-04-27 12:31:12 -0300 | [diff] [blame] | 847 | static struct tda1004x_config md8800_dvbt_config = { |
| 848 | .demod_address = 0x08, |
| 849 | .invert = 1, |
| 850 | .invert_oclk = 0, |
| 851 | .xtal_freq = TDA10046_XTAL_16M, |
| 852 | .agc_config = TDA10046_AGC_TDA827X, |
| 853 | .gpio_config = TDA10046_GP01_I, |
| 854 | .if_freq = TDA10046_FREQ_045, |
| 855 | .i2c_gate = 0x4b, |
| 856 | .tuner_address = 0x60, |
| 857 | .tuner_config = 0, |
| 858 | .request_firmware = philips_tda1004x_request_firmware |
| 859 | }; |
Hartmut Hackmann | df42eaf | 2006-02-07 06:49:10 -0200 | [diff] [blame] | 860 | |
Hartmut Hackmann | e06cea4 | 2007-03-13 20:58:29 -0300 | [diff] [blame] | 861 | static struct tda1004x_config asus_p7131_4871_config = { |
| 862 | .demod_address = 0x08, |
| 863 | .invert = 1, |
| 864 | .invert_oclk = 0, |
| 865 | .xtal_freq = TDA10046_XTAL_16M, |
| 866 | .agc_config = TDA10046_AGC_TDA827X, |
| 867 | .gpio_config = TDA10046_GP01_I, |
| 868 | .if_freq = TDA10046_FREQ_045, |
| 869 | .i2c_gate = 0x4b, |
| 870 | .tuner_address = 0x61, |
| 871 | .tuner_config = 2, |
| 872 | .antenna_switch= 2, |
| 873 | .request_firmware = philips_tda1004x_request_firmware |
| 874 | }; |
| 875 | |
Hartmut Hackmann | f3eec0c0 | 2007-03-14 20:33:55 -0300 | [diff] [blame] | 876 | static struct tda1004x_config asus_p7131_hybrid_lna_config = { |
Hartmut Hackmann | e06cea4 | 2007-03-13 20:58:29 -0300 | [diff] [blame] | 877 | .demod_address = 0x08, |
| 878 | .invert = 1, |
| 879 | .invert_oclk = 0, |
| 880 | .xtal_freq = TDA10046_XTAL_16M, |
| 881 | .agc_config = TDA10046_AGC_TDA827X, |
| 882 | .gpio_config = TDA10046_GP11_I, |
| 883 | .if_freq = TDA10046_FREQ_045, |
| 884 | .i2c_gate = 0x4b, |
| 885 | .tuner_address = 0x61, |
| 886 | .tuner_config = 2, |
| 887 | .antenna_switch= 2, |
| 888 | .request_firmware = philips_tda1004x_request_firmware |
| 889 | }; |
Hartmut Hackmann | 58ef4f9 | 2007-04-27 12:31:12 -0300 | [diff] [blame] | 890 | /* ------------------------------------------------------------------ |
| 891 | * special case: this card uses saa713x GPIO22 for the mode switch |
| 892 | */ |
Hartmut Hackmann | df42eaf | 2006-02-07 06:49:10 -0200 | [diff] [blame] | 893 | |
Andrew de Quincey | a79ddae | 2006-04-18 17:47:11 -0300 | [diff] [blame] | 894 | static int ads_duo_tuner_init(struct dvb_frontend *fe) |
Hartmut Hackmann | df42eaf | 2006-02-07 06:49:10 -0200 | [diff] [blame] | 895 | { |
| 896 | struct saa7134_dev *dev = fe->dvb->priv; |
Hartmut Hackmann | 58ef4f9 | 2007-04-27 12:31:12 -0300 | [diff] [blame] | 897 | philips_tda827x_tuner_init(fe); |
Hartmut Hackmann | df42eaf | 2006-02-07 06:49:10 -0200 | [diff] [blame] | 898 | /* route TDA8275a AGC input to the channel decoder */ |
Hartmut Hackmann | 06be303 | 2007-04-27 12:31:15 -0300 | [diff] [blame] | 899 | saa7134_set_gpio(dev, 22, 1); |
Hartmut Hackmann | df42eaf | 2006-02-07 06:49:10 -0200 | [diff] [blame] | 900 | return 0; |
| 901 | } |
| 902 | |
Andrew de Quincey | a79ddae | 2006-04-18 17:47:11 -0300 | [diff] [blame] | 903 | static int ads_duo_tuner_sleep(struct dvb_frontend *fe) |
Hartmut Hackmann | df42eaf | 2006-02-07 06:49:10 -0200 | [diff] [blame] | 904 | { |
| 905 | struct saa7134_dev *dev = fe->dvb->priv; |
| 906 | /* route TDA8275a AGC input to the analog IF chip*/ |
Hartmut Hackmann | 06be303 | 2007-04-27 12:31:15 -0300 | [diff] [blame] | 907 | saa7134_set_gpio(dev, 22, 0); |
Hartmut Hackmann | 58ef4f9 | 2007-04-27 12:31:12 -0300 | [diff] [blame] | 908 | philips_tda827x_tuner_sleep(fe); |
Andrew de Quincey | a79ddae | 2006-04-18 17:47:11 -0300 | [diff] [blame] | 909 | return 0; |
Hartmut Hackmann | df42eaf | 2006-02-07 06:49:10 -0200 | [diff] [blame] | 910 | } |
| 911 | |
Michael Krufky | 8ce47da | 2007-04-27 12:31:14 -0300 | [diff] [blame] | 912 | static struct tda827x_config ads_duo_cfg = { |
| 913 | .lna_gain = philips_tda827x_lna_gain, |
| 914 | .init = ads_duo_tuner_init, |
| 915 | .sleep = ads_duo_tuner_sleep |
| 916 | }; |
| 917 | |
Hartmut Hackmann | df42eaf | 2006-02-07 06:49:10 -0200 | [diff] [blame] | 918 | static struct tda1004x_config ads_tech_duo_config = { |
| 919 | .demod_address = 0x08, |
| 920 | .invert = 1, |
| 921 | .invert_oclk = 0, |
| 922 | .xtal_freq = TDA10046_XTAL_16M, |
Hartmut Hackmann | 1bb0e86 | 2007-04-27 12:31:10 -0300 | [diff] [blame] | 923 | .agc_config = TDA10046_AGC_TDA827X, |
| 924 | .gpio_config = TDA10046_GP00_I, |
Hartmut Hackmann | df42eaf | 2006-02-07 06:49:10 -0200 | [diff] [blame] | 925 | .if_freq = TDA10046_FREQ_045, |
Hartmut Hackmann | 58ef4f9 | 2007-04-27 12:31:12 -0300 | [diff] [blame] | 926 | .tuner_address = 0x61, |
| 927 | .request_firmware = philips_tda1004x_request_firmware |
Hartmut Hackmann | df42eaf | 2006-02-07 06:49:10 -0200 | [diff] [blame] | 928 | }; |
| 929 | |
Hartmut Hackmann | 58ef4f9 | 2007-04-27 12:31:12 -0300 | [diff] [blame] | 930 | /* ================================================================== |
| 931 | * tda10086 based DVB-S cards, helper functions |
| 932 | */ |
Hartmut Hackmann | 5eda227 | 2006-08-07 14:03:32 -0300 | [diff] [blame] | 933 | |
Igor M. Liplianin | e2ac28f | 2006-08-08 09:10:10 -0300 | [diff] [blame] | 934 | static struct tda10086_config flydvbs = { |
| 935 | .demod_address = 0x0e, |
| 936 | .invert = 0, |
| 937 | }; |
| 938 | |
Hartmut Hackmann | 58ef4f9 | 2007-04-27 12:31:12 -0300 | [diff] [blame] | 939 | /* ================================================================== |
| 940 | * nxt200x based ATSC cards, helper functions |
| 941 | */ |
Hartmut Hackmann | 90e9df7 | 2005-11-08 21:38:42 -0800 | [diff] [blame] | 942 | |
Michael Krufky | 3b64e8e | 2005-11-08 21:38:20 -0800 | [diff] [blame] | 943 | static struct nxt200x_config avertvhda180 = { |
| 944 | .demod_address = 0x0a, |
Michael Krufky | 3b64e8e | 2005-11-08 21:38:20 -0800 | [diff] [blame] | 945 | }; |
Andrew Burri | 3e1410a | 2006-02-27 00:08:23 -0300 | [diff] [blame] | 946 | |
Curt Meyers | fbc81c0 | 2006-02-27 00:08:27 -0300 | [diff] [blame] | 947 | static int nxt200x_set_pll_input(u8 *buf, int input) |
| 948 | { |
| 949 | if (input) |
| 950 | buf[3] |= 0x08; |
| 951 | else |
| 952 | buf[3] &= ~0x08; |
| 953 | return 0; |
| 954 | } |
| 955 | |
Andrew Burri | 3e1410a | 2006-02-27 00:08:23 -0300 | [diff] [blame] | 956 | static struct nxt200x_config kworldatsc110 = { |
| 957 | .demod_address = 0x0a, |
Curt Meyers | fbc81c0 | 2006-02-27 00:08:27 -0300 | [diff] [blame] | 958 | .set_pll_input = nxt200x_set_pll_input, |
Andrew Burri | 3e1410a | 2006-02-27 00:08:23 -0300 | [diff] [blame] | 959 | }; |
Michael Krufky | 3b64e8e | 2005-11-08 21:38:20 -0800 | [diff] [blame] | 960 | |
Hartmut Hackmann | 58ef4f9 | 2007-04-27 12:31:12 -0300 | [diff] [blame] | 961 | /* ================================================================== |
| 962 | * Core code |
| 963 | */ |
Mauro Carvalho Chehab | 86ddd96 | 2005-07-12 13:58:47 -0700 | [diff] [blame] | 964 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 965 | static int dvb_init(struct saa7134_dev *dev) |
| 966 | { |
Hartmut Hackmann | 1c4f76a | 2007-04-27 12:31:16 -0300 | [diff] [blame] | 967 | int ret; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 968 | /* init struct videobuf_dvb */ |
| 969 | dev->ts.nr_bufs = 32; |
| 970 | dev->ts.nr_packets = 32*4; |
| 971 | dev->dvb.name = dev->name; |
| 972 | videobuf_queue_init(&dev->dvb.dvbq, &saa7134_ts_qops, |
| 973 | dev->pci, &dev->slock, |
| 974 | V4L2_BUF_TYPE_VIDEO_CAPTURE, |
| 975 | V4L2_FIELD_ALTERNATE, |
| 976 | sizeof(struct saa7134_buf), |
| 977 | dev); |
| 978 | |
| 979 | switch (dev->board) { |
| 980 | case SAA7134_BOARD_PINNACLE_300I_DVBT_PAL: |
Trent Piepho | cf3c34c | 2007-03-07 18:19:48 -0300 | [diff] [blame] | 981 | dprintk("pinnacle 300i dvb setup\n"); |
Andrew de Quincey | 2bfe031 | 2006-08-08 09:10:08 -0300 | [diff] [blame] | 982 | dev->dvb.frontend = dvb_attach(mt352_attach, &pinnacle_300i, |
Michael Krufky | f7b54b1 | 2006-08-08 15:48:08 -0300 | [diff] [blame] | 983 | &dev->i2c_adap); |
Andrew de Quincey | 6b3ccab | 2006-04-20 12:01:47 -0300 | [diff] [blame] | 984 | if (dev->dvb.frontend) { |
Patrick Boettcher | dea7486 | 2006-05-14 05:01:31 -0300 | [diff] [blame] | 985 | dev->dvb.frontend->ops.tuner_ops.set_params = mt352_pinnacle_tuner_set_params; |
Andrew de Quincey | 6b3ccab | 2006-04-20 12:01:47 -0300 | [diff] [blame] | 986 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 987 | break; |
Jose Alberto Reguero | a78d0bf | 2006-02-07 06:25:14 -0200 | [diff] [blame] | 988 | case SAA7134_BOARD_AVERMEDIA_777: |
Petr Baudis | 515c208 | 2006-09-26 16:53:53 -0300 | [diff] [blame] | 989 | case SAA7134_BOARD_AVERMEDIA_A16AR: |
Trent Piepho | cf3c34c | 2007-03-07 18:19:48 -0300 | [diff] [blame] | 990 | dprintk("avertv 777 dvb setup\n"); |
Andrew de Quincey | 2bfe031 | 2006-08-08 09:10:08 -0300 | [diff] [blame] | 991 | dev->dvb.frontend = dvb_attach(mt352_attach, &avermedia_777, |
Michael Krufky | f7b54b1 | 2006-08-08 15:48:08 -0300 | [diff] [blame] | 992 | &dev->i2c_adap); |
Andrew de Quincey | 6b3ccab | 2006-04-20 12:01:47 -0300 | [diff] [blame] | 993 | if (dev->dvb.frontend) { |
Patrick Boettcher | dea7486 | 2006-05-14 05:01:31 -0300 | [diff] [blame] | 994 | dev->dvb.frontend->ops.tuner_ops.calc_regs = mt352_aver777_tuner_calc_regs; |
Andrew de Quincey | 6b3ccab | 2006-04-20 12:01:47 -0300 | [diff] [blame] | 995 | } |
Jose Alberto Reguero | a78d0bf | 2006-02-07 06:25:14 -0200 | [diff] [blame] | 996 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 997 | case SAA7134_BOARD_MD7134: |
Michael Krufky | f7b54b1 | 2006-08-08 15:48:08 -0300 | [diff] [blame] | 998 | dev->dvb.frontend = dvb_attach(tda10046_attach, |
| 999 | &medion_cardbus, |
| 1000 | &dev->i2c_adap); |
Andrew de Quincey | 6b3ccab | 2006-04-20 12:01:47 -0300 | [diff] [blame] | 1001 | if (dev->dvb.frontend) { |
Patrick Boettcher | dea7486 | 2006-05-14 05:01:31 -0300 | [diff] [blame] | 1002 | dev->dvb.frontend->ops.tuner_ops.init = philips_fmd1216_tuner_init; |
| 1003 | dev->dvb.frontend->ops.tuner_ops.sleep = philips_fmd1216_tuner_sleep; |
| 1004 | dev->dvb.frontend->ops.tuner_ops.set_params = philips_fmd1216_tuner_set_params; |
Andrew de Quincey | 6b3ccab | 2006-04-20 12:01:47 -0300 | [diff] [blame] | 1005 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1006 | break; |
Mauro Carvalho Chehab | 86ddd96 | 2005-07-12 13:58:47 -0700 | [diff] [blame] | 1007 | case SAA7134_BOARD_PHILIPS_TOUGH: |
Michael Krufky | f7b54b1 | 2006-08-08 15:48:08 -0300 | [diff] [blame] | 1008 | dev->dvb.frontend = dvb_attach(tda10046_attach, |
| 1009 | &philips_tu1216_60_config, |
| 1010 | &dev->i2c_adap); |
Andrew de Quincey | 6b3ccab | 2006-04-20 12:01:47 -0300 | [diff] [blame] | 1011 | if (dev->dvb.frontend) { |
Hartmut Hackmann | 58ef4f9 | 2007-04-27 12:31:12 -0300 | [diff] [blame] | 1012 | dev->dvb.frontend->ops.tuner_ops.init = philips_tu1216_init; |
| 1013 | dev->dvb.frontend->ops.tuner_ops.set_params = philips_tda6651_pll_set; |
Andrew de Quincey | 6b3ccab | 2006-04-20 12:01:47 -0300 | [diff] [blame] | 1014 | } |
Mauro Carvalho Chehab | 86ddd96 | 2005-07-12 13:58:47 -0700 | [diff] [blame] | 1015 | break; |
| 1016 | case SAA7134_BOARD_FLYDVBTDUO: |
Peter Missel | 10b7a90 | 2006-01-23 17:11:06 -0200 | [diff] [blame] | 1017 | case SAA7134_BOARD_FLYDVBT_DUO_CARDBUS: |
Hartmut Hackmann | b8bc76d | 2007-04-27 12:31:16 -0300 | [diff] [blame] | 1018 | configure_tda827x_fe(dev, &tda827x_lifeview_config); |
Mauro Carvalho Chehab | 86ddd96 | 2005-07-12 13:58:47 -0700 | [diff] [blame] | 1019 | break; |
Hartmut Hackmann | 2cf36ac | 2005-11-08 21:36:32 -0800 | [diff] [blame] | 1020 | case SAA7134_BOARD_PHILIPS_EUROPA: |
Hartmut Hackmann | 2cf36ac | 2005-11-08 21:36:32 -0800 | [diff] [blame] | 1021 | case SAA7134_BOARD_VIDEOMATE_DVBT_300: |
Michael Krufky | f7b54b1 | 2006-08-08 15:48:08 -0300 | [diff] [blame] | 1022 | dev->dvb.frontend = dvb_attach(tda10046_attach, |
| 1023 | &philips_europa_config, |
| 1024 | &dev->i2c_adap); |
Andrew de Quincey | 6b3ccab | 2006-04-20 12:01:47 -0300 | [diff] [blame] | 1025 | if (dev->dvb.frontend) { |
Hartmut Hackmann | 588f983 | 2006-10-18 17:30:42 -0300 | [diff] [blame] | 1026 | dev->original_demod_sleep = dev->dvb.frontend->ops.sleep; |
| 1027 | dev->dvb.frontend->ops.sleep = philips_europa_demod_sleep; |
Patrick Boettcher | dea7486 | 2006-05-14 05:01:31 -0300 | [diff] [blame] | 1028 | dev->dvb.frontend->ops.tuner_ops.init = philips_europa_tuner_init; |
| 1029 | dev->dvb.frontend->ops.tuner_ops.sleep = philips_europa_tuner_sleep; |
| 1030 | dev->dvb.frontend->ops.tuner_ops.set_params = philips_td1316_tuner_set_params; |
Andrew de Quincey | 6b3ccab | 2006-04-20 12:01:47 -0300 | [diff] [blame] | 1031 | } |
Hartmut Hackmann | 2cf36ac | 2005-11-08 21:36:32 -0800 | [diff] [blame] | 1032 | break; |
| 1033 | case SAA7134_BOARD_VIDEOMATE_DVBT_200: |
Michael Krufky | f7b54b1 | 2006-08-08 15:48:08 -0300 | [diff] [blame] | 1034 | dev->dvb.frontend = dvb_attach(tda10046_attach, |
| 1035 | &philips_tu1216_61_config, |
| 1036 | &dev->i2c_adap); |
Andrew de Quincey | 6b3ccab | 2006-04-20 12:01:47 -0300 | [diff] [blame] | 1037 | if (dev->dvb.frontend) { |
Hartmut Hackmann | 58ef4f9 | 2007-04-27 12:31:12 -0300 | [diff] [blame] | 1038 | dev->dvb.frontend->ops.tuner_ops.init = philips_tu1216_init; |
| 1039 | dev->dvb.frontend->ops.tuner_ops.set_params = philips_tda6651_pll_set; |
Andrew de Quincey | 6b3ccab | 2006-04-20 12:01:47 -0300 | [diff] [blame] | 1040 | } |
Hartmut Hackmann | 2cf36ac | 2005-11-08 21:36:32 -0800 | [diff] [blame] | 1041 | break; |
Hartmut Hackmann | 90e9df7 | 2005-11-08 21:38:42 -0800 | [diff] [blame] | 1042 | case SAA7134_BOARD_PHILIPS_TIGER: |
Hartmut Hackmann | b8bc76d | 2007-04-27 12:31:16 -0300 | [diff] [blame] | 1043 | configure_tda827x_fe(dev, &philips_tiger_config); |
Hartmut Hackmann | 587d2fd | 2006-10-06 19:13:50 -0300 | [diff] [blame] | 1044 | break; |
| 1045 | case SAA7134_BOARD_PINNACLE_PCTV_310i: |
Hartmut Hackmann | b8bc76d | 2007-04-27 12:31:16 -0300 | [diff] [blame] | 1046 | configure_tda827x_fe(dev, &pinnacle_pctv_310i_config); |
Hartmut Hackmann | 90e9df7 | 2005-11-08 21:38:42 -0800 | [diff] [blame] | 1047 | break; |
Thomas Genty | c6e53da | 2006-11-05 14:17:30 -0300 | [diff] [blame] | 1048 | case SAA7134_BOARD_HAUPPAUGE_HVR1110: |
Hartmut Hackmann | b8bc76d | 2007-04-27 12:31:16 -0300 | [diff] [blame] | 1049 | configure_tda827x_fe(dev, &hauppauge_hvr_1110_config); |
Thomas Genty | c6e53da | 2006-11-05 14:17:30 -0300 | [diff] [blame] | 1050 | break; |
Hartmut Hackmann | d4b0aba | 2005-11-08 21:38:44 -0800 | [diff] [blame] | 1051 | case SAA7134_BOARD_ASUSTeK_P7131_DUAL: |
Hartmut Hackmann | b8bc76d | 2007-04-27 12:31:16 -0300 | [diff] [blame] | 1052 | configure_tda827x_fe(dev, &asus_p7131_dual_config); |
Hartmut Hackmann | d4b0aba | 2005-11-08 21:38:44 -0800 | [diff] [blame] | 1053 | break; |
Giampiero Giancipoli | 3d8466e | 2006-02-07 06:49:09 -0200 | [diff] [blame] | 1054 | case SAA7134_BOARD_FLYDVBT_LR301: |
Hartmut Hackmann | b8bc76d | 2007-04-27 12:31:16 -0300 | [diff] [blame] | 1055 | configure_tda827x_fe(dev, &tda827x_lifeview_config); |
Giampiero Giancipoli | 3d8466e | 2006-02-07 06:49:09 -0200 | [diff] [blame] | 1056 | break; |
Nico Sabbi | 420f32f | 2006-03-03 12:11:28 -0300 | [diff] [blame] | 1057 | case SAA7134_BOARD_FLYDVB_TRIO: |
Stephan Berberig | b331daa | 2006-12-20 09:37:05 -0300 | [diff] [blame] | 1058 | if(! use_frontend) { //terrestrial |
Hartmut Hackmann | b8bc76d | 2007-04-27 12:31:16 -0300 | [diff] [blame] | 1059 | configure_tda827x_fe(dev, &lifeview_trio_config); |
Nico Sabbi | 1f683cd | 2006-11-15 22:06:56 -0300 | [diff] [blame] | 1060 | } else { //satellite |
| 1061 | dev->dvb.frontend = dvb_attach(tda10086_attach, &flydvbs, &dev->i2c_adap); |
| 1062 | if (dev->dvb.frontend) { |
| 1063 | if (dvb_attach(tda826x_attach, dev->dvb.frontend, 0x63, |
| 1064 | &dev->i2c_adap, 0) == NULL) { |
Trent Piepho | cf3c34c | 2007-03-07 18:19:48 -0300 | [diff] [blame] | 1065 | wprintk("%s: Lifeview Trio, No tda826x found!\n", __FUNCTION__); |
Nico Sabbi | 1f683cd | 2006-11-15 22:06:56 -0300 | [diff] [blame] | 1066 | } |
| 1067 | if (dvb_attach(isl6421_attach, dev->dvb.frontend, &dev->i2c_adap, |
| 1068 | 0x08, 0, 0) == NULL) { |
Trent Piepho | cf3c34c | 2007-03-07 18:19:48 -0300 | [diff] [blame] | 1069 | wprintk("%s: Lifeview Trio, No ISL6421 found!\n", __FUNCTION__); |
Nico Sabbi | 1f683cd | 2006-11-15 22:06:56 -0300 | [diff] [blame] | 1070 | } |
| 1071 | } |
Andrew de Quincey | 6b3ccab | 2006-04-20 12:01:47 -0300 | [diff] [blame] | 1072 | } |
Nico Sabbi | 420f32f | 2006-03-03 12:11:28 -0300 | [diff] [blame] | 1073 | break; |
Hartmut Hackmann | df42eaf | 2006-02-07 06:49:10 -0200 | [diff] [blame] | 1074 | case SAA7134_BOARD_ADS_DUO_CARDBUS_PTV331: |
Hartmut Hackmann | d95b894 | 2006-03-27 19:39:30 -0300 | [diff] [blame] | 1075 | case SAA7134_BOARD_FLYDVBT_HYBRID_CARDBUS: |
Michael Krufky | f7b54b1 | 2006-08-08 15:48:08 -0300 | [diff] [blame] | 1076 | dev->dvb.frontend = dvb_attach(tda10046_attach, |
| 1077 | &ads_tech_duo_config, |
| 1078 | &dev->i2c_adap); |
Andrew de Quincey | 6b3ccab | 2006-04-20 12:01:47 -0300 | [diff] [blame] | 1079 | if (dev->dvb.frontend) { |
Hartmut Hackmann | ede2200 | 2007-04-27 12:31:32 -0300 | [diff] [blame] | 1080 | if (dvb_attach(tda827x_attach,dev->dvb.frontend, |
Michael Krufky | 8ce47da | 2007-04-27 12:31:14 -0300 | [diff] [blame] | 1081 | ads_tech_duo_config.tuner_address, |
Hartmut Hackmann | ede2200 | 2007-04-27 12:31:32 -0300 | [diff] [blame] | 1082 | &dev->i2c_adap,&ads_duo_cfg) == NULL) { |
Trent Piepho | cf3c34c | 2007-03-07 18:19:48 -0300 | [diff] [blame] | 1083 | wprintk("no tda827x tuner found at addr: %02x\n", |
Hartmut Hackmann | ede2200 | 2007-04-27 12:31:32 -0300 | [diff] [blame] | 1084 | ads_tech_duo_config.tuner_address); |
| 1085 | } |
Andrew de Quincey | 6b3ccab | 2006-04-20 12:01:47 -0300 | [diff] [blame] | 1086 | } |
Hartmut Hackmann | d95b894 | 2006-03-27 19:39:30 -0300 | [diff] [blame] | 1087 | break; |
Hartmut Hackmann | 58ef4f9 | 2007-04-27 12:31:12 -0300 | [diff] [blame] | 1088 | case SAA7134_BOARD_TEVION_DVBT_220RF: |
Hartmut Hackmann | b8bc76d | 2007-04-27 12:31:16 -0300 | [diff] [blame] | 1089 | configure_tda827x_fe(dev, &tevion_dvbt220rf_config); |
Hartmut Hackmann | 58ef4f9 | 2007-04-27 12:31:12 -0300 | [diff] [blame] | 1090 | break; |
Hartmut Hackmann | 5eda227 | 2006-08-07 14:03:32 -0300 | [diff] [blame] | 1091 | case SAA7134_BOARD_MEDION_MD8800_QUADRO: |
Hartmut Hackmann | b8bc76d | 2007-04-27 12:31:16 -0300 | [diff] [blame] | 1092 | configure_tda827x_fe(dev, &md8800_dvbt_config); |
Hartmut Hackmann | 5eda227 | 2006-08-07 14:03:32 -0300 | [diff] [blame] | 1093 | break; |
Michael Krufky | 3b64e8e | 2005-11-08 21:38:20 -0800 | [diff] [blame] | 1094 | case SAA7134_BOARD_AVERMEDIA_AVERTVHD_A180: |
Michael Krufky | f7b54b1 | 2006-08-08 15:48:08 -0300 | [diff] [blame] | 1095 | dev->dvb.frontend = dvb_attach(nxt200x_attach, &avertvhda180, |
| 1096 | &dev->i2c_adap); |
Andrew de Quincey | a79ddae | 2006-04-18 17:47:11 -0300 | [diff] [blame] | 1097 | if (dev->dvb.frontend) { |
Michael Krufky | 4ad8eee5 | 2006-08-08 15:48:08 -0300 | [diff] [blame] | 1098 | dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x61, |
| 1099 | NULL, &dvb_pll_tdhu2); |
Andrew de Quincey | a79ddae | 2006-04-18 17:47:11 -0300 | [diff] [blame] | 1100 | } |
Michael Krufky | 3b64e8e | 2005-11-08 21:38:20 -0800 | [diff] [blame] | 1101 | break; |
Andrew Burri | 3e1410a | 2006-02-27 00:08:23 -0300 | [diff] [blame] | 1102 | case SAA7134_BOARD_KWORLD_ATSC110: |
Michael Krufky | f7b54b1 | 2006-08-08 15:48:08 -0300 | [diff] [blame] | 1103 | dev->dvb.frontend = dvb_attach(nxt200x_attach, &kworldatsc110, |
| 1104 | &dev->i2c_adap); |
Andrew de Quincey | a79ddae | 2006-04-18 17:47:11 -0300 | [diff] [blame] | 1105 | if (dev->dvb.frontend) { |
Michael Krufky | 4ad8eee5 | 2006-08-08 15:48:08 -0300 | [diff] [blame] | 1106 | dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x61, |
| 1107 | NULL, &dvb_pll_tuv1236d); |
Andrew de Quincey | a79ddae | 2006-04-18 17:47:11 -0300 | [diff] [blame] | 1108 | } |
Andrew Burri | 3e1410a | 2006-02-27 00:08:23 -0300 | [diff] [blame] | 1109 | break; |
Igor M. Liplianin | e2ac28f | 2006-08-08 09:10:10 -0300 | [diff] [blame] | 1110 | case SAA7134_BOARD_FLYDVBS_LR300: |
Michael Krufky | f7b54b1 | 2006-08-08 15:48:08 -0300 | [diff] [blame] | 1111 | dev->dvb.frontend = dvb_attach(tda10086_attach, &flydvbs, |
| 1112 | &dev->i2c_adap); |
Igor M. Liplianin | e2ac28f | 2006-08-08 09:10:10 -0300 | [diff] [blame] | 1113 | if (dev->dvb.frontend) { |
Michael Krufky | f7b54b1 | 2006-08-08 15:48:08 -0300 | [diff] [blame] | 1114 | if (dvb_attach(tda826x_attach, dev->dvb.frontend, 0x60, |
| 1115 | &dev->i2c_adap, 0) == NULL) { |
Trent Piepho | cf3c34c | 2007-03-07 18:19:48 -0300 | [diff] [blame] | 1116 | wprintk("%s: No tda826x found!\n", __FUNCTION__); |
Igor M. Liplianin | e2ac28f | 2006-08-08 09:10:10 -0300 | [diff] [blame] | 1117 | } |
Michael Krufky | f7b54b1 | 2006-08-08 15:48:08 -0300 | [diff] [blame] | 1118 | if (dvb_attach(isl6421_attach, dev->dvb.frontend, |
| 1119 | &dev->i2c_adap, 0x08, 0, 0) == NULL) { |
Trent Piepho | cf3c34c | 2007-03-07 18:19:48 -0300 | [diff] [blame] | 1120 | wprintk("%s: No ISL6421 found!\n", __FUNCTION__); |
Igor M. Liplianin | e2ac28f | 2006-08-08 09:10:10 -0300 | [diff] [blame] | 1121 | } |
| 1122 | } |
| 1123 | break; |
Hartmut Hackmann | cf146ca | 2006-10-02 20:49:24 -0300 | [diff] [blame] | 1124 | case SAA7134_BOARD_ASUS_EUROPA2_HYBRID: |
| 1125 | dev->dvb.frontend = tda10046_attach(&medion_cardbus, |
| 1126 | &dev->i2c_adap); |
| 1127 | if (dev->dvb.frontend) { |
| 1128 | dev->original_demod_sleep = dev->dvb.frontend->ops.sleep; |
| 1129 | dev->dvb.frontend->ops.sleep = philips_europa_demod_sleep; |
| 1130 | dev->dvb.frontend->ops.tuner_ops.init = philips_fmd1216_tuner_init; |
| 1131 | dev->dvb.frontend->ops.tuner_ops.sleep = philips_fmd1216_tuner_sleep; |
| 1132 | dev->dvb.frontend->ops.tuner_ops.set_params = philips_fmd1216_tuner_set_params; |
| 1133 | } |
| 1134 | break; |
Hartmut Hackmann | cbb9452 | 2006-10-30 20:00:16 -0300 | [diff] [blame] | 1135 | case SAA7134_BOARD_VIDEOMATE_DVBT_200A: |
| 1136 | dev->dvb.frontend = dvb_attach(tda10046_attach, |
| 1137 | &philips_europa_config, |
| 1138 | &dev->i2c_adap); |
| 1139 | if (dev->dvb.frontend) { |
| 1140 | dev->dvb.frontend->ops.tuner_ops.init = philips_td1316_tuner_init; |
| 1141 | dev->dvb.frontend->ops.tuner_ops.set_params = philips_td1316_tuner_set_params; |
| 1142 | } |
| 1143 | break; |
Hartmut Hackmann | 550a9a5 | 2006-11-15 21:31:54 -0300 | [diff] [blame] | 1144 | case SAA7134_BOARD_CINERGY_HT_PCMCIA: |
Hartmut Hackmann | b8bc76d | 2007-04-27 12:31:16 -0300 | [diff] [blame] | 1145 | configure_tda827x_fe(dev, &cinergy_ht_config); |
Hartmut Hackmann | 550a9a5 | 2006-11-15 21:31:54 -0300 | [diff] [blame] | 1146 | break; |
Michael Krufky | 9de271e | 2007-01-16 18:36:40 -0300 | [diff] [blame] | 1147 | case SAA7134_BOARD_CINERGY_HT_PCI: |
Hartmut Hackmann | b8bc76d | 2007-04-27 12:31:16 -0300 | [diff] [blame] | 1148 | configure_tda827x_fe(dev, &cinergy_ht_pci_config); |
Hartmut Hackmann | 58ef4f9 | 2007-04-27 12:31:12 -0300 | [diff] [blame] | 1149 | break; |
| 1150 | case SAA7134_BOARD_PHILIPS_TIGER_S: |
Hartmut Hackmann | b8bc76d | 2007-04-27 12:31:16 -0300 | [diff] [blame] | 1151 | configure_tda827x_fe(dev, &philips_tiger_s_config); |
Michael Krufky | 9de271e | 2007-01-16 18:36:40 -0300 | [diff] [blame] | 1152 | break; |
Hartmut Hackmann | e06cea4 | 2007-03-13 20:58:29 -0300 | [diff] [blame] | 1153 | case SAA7134_BOARD_ASUS_P7131_4871: |
| 1154 | configure_tda827x_fe(dev, &asus_p7131_4871_config); |
| 1155 | break; |
Hartmut Hackmann | f3eec0c0 | 2007-03-14 20:33:55 -0300 | [diff] [blame] | 1156 | case SAA7134_BOARD_ASUSTeK_P7131_HYBRID_LNA: |
| 1157 | configure_tda827x_fe(dev, &asus_p7131_hybrid_lna_config); |
Hartmut Hackmann | e06cea4 | 2007-03-13 20:58:29 -0300 | [diff] [blame] | 1158 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1159 | default: |
Trent Piepho | cf3c34c | 2007-03-07 18:19:48 -0300 | [diff] [blame] | 1160 | wprintk("Huh? unknown DVB card?\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1161 | break; |
| 1162 | } |
| 1163 | |
| 1164 | if (NULL == dev->dvb.frontend) { |
Trent Piepho | cf3c34c | 2007-03-07 18:19:48 -0300 | [diff] [blame] | 1165 | printk(KERN_ERR "%s/dvb: frontend initialization failed\n", dev->name); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1166 | return -1; |
| 1167 | } |
| 1168 | |
| 1169 | /* register everything else */ |
Hartmut Hackmann | 1c4f76a | 2007-04-27 12:31:16 -0300 | [diff] [blame] | 1170 | ret = videobuf_dvb_register(&dev->dvb, THIS_MODULE, dev, &dev->pci->dev); |
| 1171 | |
| 1172 | /* this sequence is necessary to make the tda1004x load its firmware |
| 1173 | * and to enter analog mode of hybrid boards |
| 1174 | */ |
| 1175 | if (!ret) { |
| 1176 | if (dev->dvb.frontend->ops.init) |
| 1177 | dev->dvb.frontend->ops.init(dev->dvb.frontend); |
| 1178 | if (dev->dvb.frontend->ops.sleep) |
| 1179 | dev->dvb.frontend->ops.sleep(dev->dvb.frontend); |
Hartmut Hackmann | 9971f4f | 2007-03-23 21:00:07 -0300 | [diff] [blame^] | 1180 | if (dev->dvb.frontend->ops.tuner_ops.sleep) |
| 1181 | dev->dvb.frontend->ops.tuner_ops.sleep(dev->dvb.frontend); |
Hartmut Hackmann | 1c4f76a | 2007-04-27 12:31:16 -0300 | [diff] [blame] | 1182 | } |
| 1183 | return ret; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1184 | } |
| 1185 | |
| 1186 | static int dvb_fini(struct saa7134_dev *dev) |
| 1187 | { |
| 1188 | static int on = TDA9887_PRESENT | TDA9887_PORT2_INACTIVE; |
| 1189 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1190 | switch (dev->board) { |
| 1191 | case SAA7134_BOARD_PINNACLE_300I_DVBT_PAL: |
| 1192 | /* otherwise we don't detect the tuner on next insmod */ |
| 1193 | saa7134_i2c_call_clients(dev,TDA9887_SET_CONFIG,&on); |
| 1194 | break; |
| 1195 | }; |
| 1196 | videobuf_dvb_unregister(&dev->dvb); |
| 1197 | return 0; |
| 1198 | } |
| 1199 | |
| 1200 | static struct saa7134_mpeg_ops dvb_ops = { |
| 1201 | .type = SAA7134_MPEG_DVB, |
| 1202 | .init = dvb_init, |
| 1203 | .fini = dvb_fini, |
| 1204 | }; |
| 1205 | |
| 1206 | static int __init dvb_register(void) |
| 1207 | { |
| 1208 | return saa7134_ts_register(&dvb_ops); |
| 1209 | } |
| 1210 | |
| 1211 | static void __exit dvb_unregister(void) |
| 1212 | { |
| 1213 | saa7134_ts_unregister(&dvb_ops); |
| 1214 | } |
| 1215 | |
| 1216 | module_init(dvb_register); |
| 1217 | module_exit(dvb_unregister); |
| 1218 | |
| 1219 | /* ------------------------------------------------------------------ */ |
| 1220 | /* |
| 1221 | * Local variables: |
| 1222 | * c-basic-offset: 8 |
| 1223 | * End: |
| 1224 | */ |