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" |
| 44 | #include "isl6421.h" |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 45 | MODULE_AUTHOR("Gerd Knorr <kraxel@bytesex.org> [SuSE Labs]"); |
| 46 | MODULE_LICENSE("GPL"); |
| 47 | |
| 48 | static unsigned int antenna_pwr = 0; |
Mauro Carvalho Chehab | 86ddd96 | 2005-07-12 13:58:47 -0700 | [diff] [blame] | 49 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 50 | module_param(antenna_pwr, int, 0444); |
| 51 | MODULE_PARM_DESC(antenna_pwr,"enable antenna power (Pinnacle 300i)"); |
| 52 | |
| 53 | /* ------------------------------------------------------------------ */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 54 | static int pinnacle_antenna_pwr(struct saa7134_dev *dev, int on) |
| 55 | { |
| 56 | u32 ok; |
| 57 | |
| 58 | if (!on) { |
| 59 | saa_setl(SAA7134_GPIO_GPMODE0 >> 2, (1 << 26)); |
| 60 | saa_clearl(SAA7134_GPIO_GPSTATUS0 >> 2, (1 << 26)); |
| 61 | return 0; |
| 62 | } |
| 63 | |
| 64 | saa_setl(SAA7134_GPIO_GPMODE0 >> 2, (1 << 26)); |
| 65 | saa_setl(SAA7134_GPIO_GPSTATUS0 >> 2, (1 << 26)); |
| 66 | udelay(10); |
| 67 | |
| 68 | saa_setl(SAA7134_GPIO_GPMODE0 >> 2, (1 << 28)); |
| 69 | saa_clearl(SAA7134_GPIO_GPSTATUS0 >> 2, (1 << 28)); |
| 70 | udelay(10); |
| 71 | saa_setl(SAA7134_GPIO_GPSTATUS0 >> 2, (1 << 28)); |
| 72 | udelay(10); |
| 73 | ok = saa_readl(SAA7134_GPIO_GPSTATUS0) & (1 << 27); |
| 74 | printk("%s: %s %s\n", dev->name, __FUNCTION__, |
| 75 | ok ? "on" : "off"); |
| 76 | |
| 77 | if (!ok) |
| 78 | saa_clearl(SAA7134_GPIO_GPSTATUS0 >> 2, (1 << 26)); |
| 79 | return ok; |
| 80 | } |
| 81 | |
| 82 | static int mt352_pinnacle_init(struct dvb_frontend* fe) |
| 83 | { |
| 84 | static u8 clock_config [] = { CLOCK_CTL, 0x3d, 0x28 }; |
| 85 | static u8 reset [] = { RESET, 0x80 }; |
| 86 | static u8 adc_ctl_1_cfg [] = { ADC_CTL_1, 0x40 }; |
| 87 | static u8 agc_cfg [] = { AGC_TARGET, 0x28, 0xa0 }; |
| 88 | static u8 capt_range_cfg[] = { CAPT_RANGE, 0x31 }; |
| 89 | static u8 fsm_ctl_cfg[] = { 0x7b, 0x04 }; |
| 90 | static u8 gpp_ctl_cfg [] = { GPP_CTL, 0x0f }; |
| 91 | static u8 scan_ctl_cfg [] = { SCAN_CTL, 0x0d }; |
| 92 | static u8 irq_cfg [] = { INTERRUPT_EN_0, 0x00, 0x00, 0x00, 0x00 }; |
| 93 | struct saa7134_dev *dev= fe->dvb->priv; |
| 94 | |
| 95 | printk("%s: %s called\n",dev->name,__FUNCTION__); |
| 96 | |
| 97 | mt352_write(fe, clock_config, sizeof(clock_config)); |
| 98 | udelay(200); |
| 99 | mt352_write(fe, reset, sizeof(reset)); |
| 100 | mt352_write(fe, adc_ctl_1_cfg, sizeof(adc_ctl_1_cfg)); |
| 101 | mt352_write(fe, agc_cfg, sizeof(agc_cfg)); |
| 102 | mt352_write(fe, capt_range_cfg, sizeof(capt_range_cfg)); |
| 103 | mt352_write(fe, gpp_ctl_cfg, sizeof(gpp_ctl_cfg)); |
| 104 | |
| 105 | mt352_write(fe, fsm_ctl_cfg, sizeof(fsm_ctl_cfg)); |
| 106 | mt352_write(fe, scan_ctl_cfg, sizeof(scan_ctl_cfg)); |
| 107 | mt352_write(fe, irq_cfg, sizeof(irq_cfg)); |
Hartmut Hackmann | df8cf70 | 2006-03-03 12:09:26 -0300 | [diff] [blame] | 108 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 109 | return 0; |
| 110 | } |
| 111 | |
Jose Alberto Reguero | a78d0bf | 2006-02-07 06:25:14 -0200 | [diff] [blame] | 112 | static int mt352_aver777_init(struct dvb_frontend* fe) |
| 113 | { |
| 114 | static u8 clock_config [] = { CLOCK_CTL, 0x38, 0x2d }; |
| 115 | static u8 reset [] = { RESET, 0x80 }; |
| 116 | static u8 adc_ctl_1_cfg [] = { ADC_CTL_1, 0x40 }; |
| 117 | static u8 agc_cfg [] = { AGC_TARGET, 0x28, 0xa0 }; |
| 118 | static u8 capt_range_cfg[] = { CAPT_RANGE, 0x33 }; |
| 119 | |
| 120 | mt352_write(fe, clock_config, sizeof(clock_config)); |
| 121 | udelay(200); |
| 122 | mt352_write(fe, reset, sizeof(reset)); |
| 123 | mt352_write(fe, adc_ctl_1_cfg, sizeof(adc_ctl_1_cfg)); |
| 124 | mt352_write(fe, agc_cfg, sizeof(agc_cfg)); |
| 125 | mt352_write(fe, capt_range_cfg, sizeof(capt_range_cfg)); |
| 126 | |
| 127 | return 0; |
| 128 | } |
| 129 | |
Andrew de Quincey | 0463f12 | 2006-05-16 17:22:02 -0300 | [diff] [blame] | 130 | static int mt352_pinnacle_tuner_set_params(struct dvb_frontend* fe, |
| 131 | struct dvb_frontend_parameters* params) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 132 | { |
Hartmut Hackmann | df8cf70 | 2006-03-03 12:09:26 -0300 | [diff] [blame] | 133 | u8 off[] = { 0x00, 0xf1}; |
| 134 | u8 on[] = { 0x00, 0x71}; |
| 135 | struct i2c_msg msg = {.addr=0x43, .flags=0, .buf=off, .len = sizeof(off)}; |
| 136 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 137 | struct saa7134_dev *dev = fe->dvb->priv; |
| 138 | struct v4l2_frequency f; |
| 139 | |
| 140 | /* set frequency (mt2050) */ |
| 141 | f.tuner = 0; |
| 142 | f.type = V4L2_TUNER_DIGITAL_TV; |
| 143 | f.frequency = params->frequency / 1000 * 16 / 1000; |
Patrick Boettcher | dea7486 | 2006-05-14 05:01:31 -0300 | [diff] [blame] | 144 | if (fe->ops.i2c_gate_ctrl) |
| 145 | fe->ops.i2c_gate_ctrl(fe, 1); |
Hartmut Hackmann | df8cf70 | 2006-03-03 12:09:26 -0300 | [diff] [blame] | 146 | i2c_transfer(&dev->i2c_adap, &msg, 1); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 147 | saa7134_i2c_call_clients(dev,VIDIOC_S_FREQUENCY,&f); |
Hartmut Hackmann | df8cf70 | 2006-03-03 12:09:26 -0300 | [diff] [blame] | 148 | msg.buf = on; |
Patrick Boettcher | dea7486 | 2006-05-14 05:01:31 -0300 | [diff] [blame] | 149 | if (fe->ops.i2c_gate_ctrl) |
| 150 | fe->ops.i2c_gate_ctrl(fe, 1); |
Hartmut Hackmann | df8cf70 | 2006-03-03 12:09:26 -0300 | [diff] [blame] | 151 | i2c_transfer(&dev->i2c_adap, &msg, 1); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 152 | |
| 153 | pinnacle_antenna_pwr(dev, antenna_pwr); |
| 154 | |
| 155 | /* mt352 setup */ |
Andrew de Quincey | 0463f12 | 2006-05-16 17:22:02 -0300 | [diff] [blame] | 156 | return mt352_pinnacle_init(fe); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 157 | } |
| 158 | |
Andrew de Quincey | bd4956b | 2006-04-18 21:38:49 -0300 | [diff] [blame] | 159 | 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] | 160 | { |
Andrew de Quincey | a79ddae | 2006-04-18 17:47:11 -0300 | [diff] [blame] | 161 | if (buf_len < 5) |
| 162 | return -EINVAL; |
| 163 | |
| 164 | pllbuf[0] = 0x61; |
Jose Alberto Reguero | a78d0bf | 2006-02-07 06:25:14 -0200 | [diff] [blame] | 165 | dvb_pll_configure(&dvb_pll_philips_td1316, pllbuf+1, |
| 166 | params->frequency, |
| 167 | params->u.ofdm.bandwidth); |
Andrew de Quincey | a79ddae | 2006-04-18 17:47:11 -0300 | [diff] [blame] | 168 | return 5; |
Jose Alberto Reguero | a78d0bf | 2006-02-07 06:25:14 -0200 | [diff] [blame] | 169 | } |
| 170 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 171 | static struct mt352_config pinnacle_300i = { |
| 172 | .demod_address = 0x3c >> 1, |
| 173 | .adc_clock = 20333, |
| 174 | .if2 = 36150, |
| 175 | .no_tuner = 1, |
| 176 | .demod_init = mt352_pinnacle_init, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 177 | }; |
Jose Alberto Reguero | a78d0bf | 2006-02-07 06:25:14 -0200 | [diff] [blame] | 178 | |
| 179 | static struct mt352_config avermedia_777 = { |
| 180 | .demod_address = 0xf, |
| 181 | .demod_init = mt352_aver777_init, |
Jose Alberto Reguero | a78d0bf | 2006-02-07 06:25:14 -0200 | [diff] [blame] | 182 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 183 | |
| 184 | /* ------------------------------------------------------------------ */ |
Hartmut Hackmann | 2cf36ac | 2005-11-08 21:36:32 -0800 | [diff] [blame] | 185 | static int philips_tda6651_pll_set(u8 addr, struct dvb_frontend *fe, struct dvb_frontend_parameters *params) |
Mauro Carvalho Chehab | 86ddd96 | 2005-07-12 13:58:47 -0700 | [diff] [blame] | 186 | { |
| 187 | struct saa7134_dev *dev = fe->dvb->priv; |
| 188 | u8 tuner_buf[4]; |
Hartmut Hackmann | 2cf36ac | 2005-11-08 21:36:32 -0800 | [diff] [blame] | 189 | 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] | 190 | sizeof(tuner_buf) }; |
| 191 | int tuner_frequency = 0; |
| 192 | u8 band, cp, filter; |
| 193 | |
| 194 | /* determine charge pump */ |
| 195 | tuner_frequency = params->frequency + 36166000; |
| 196 | if (tuner_frequency < 87000000) |
| 197 | return -EINVAL; |
| 198 | else if (tuner_frequency < 130000000) |
| 199 | cp = 3; |
| 200 | else if (tuner_frequency < 160000000) |
| 201 | cp = 5; |
| 202 | else if (tuner_frequency < 200000000) |
| 203 | cp = 6; |
| 204 | else if (tuner_frequency < 290000000) |
| 205 | cp = 3; |
| 206 | else if (tuner_frequency < 420000000) |
| 207 | cp = 5; |
| 208 | else if (tuner_frequency < 480000000) |
| 209 | cp = 6; |
| 210 | else if (tuner_frequency < 620000000) |
| 211 | cp = 3; |
| 212 | else if (tuner_frequency < 830000000) |
| 213 | cp = 5; |
| 214 | else if (tuner_frequency < 895000000) |
| 215 | cp = 7; |
| 216 | else |
| 217 | return -EINVAL; |
| 218 | |
| 219 | /* determine band */ |
| 220 | if (params->frequency < 49000000) |
| 221 | return -EINVAL; |
| 222 | else if (params->frequency < 161000000) |
| 223 | band = 1; |
| 224 | else if (params->frequency < 444000000) |
| 225 | band = 2; |
| 226 | else if (params->frequency < 861000000) |
| 227 | band = 4; |
| 228 | else |
| 229 | return -EINVAL; |
| 230 | |
| 231 | /* setup PLL filter */ |
| 232 | switch (params->u.ofdm.bandwidth) { |
| 233 | case BANDWIDTH_6_MHZ: |
| 234 | filter = 0; |
| 235 | break; |
| 236 | |
| 237 | case BANDWIDTH_7_MHZ: |
| 238 | filter = 0; |
| 239 | break; |
| 240 | |
| 241 | case BANDWIDTH_8_MHZ: |
| 242 | filter = 1; |
| 243 | break; |
| 244 | |
| 245 | default: |
| 246 | return -EINVAL; |
| 247 | } |
| 248 | |
| 249 | /* calculate divisor |
| 250 | * ((36166000+((1000000/6)/2)) + Finput)/(1000000/6) |
| 251 | */ |
| 252 | tuner_frequency = (((params->frequency / 1000) * 6) + 217496) / 1000; |
| 253 | |
| 254 | /* setup tuner buffer */ |
| 255 | tuner_buf[0] = (tuner_frequency >> 8) & 0x7f; |
| 256 | tuner_buf[1] = tuner_frequency & 0xff; |
| 257 | tuner_buf[2] = 0xca; |
| 258 | tuner_buf[3] = (cp << 5) | (filter << 3) | band; |
| 259 | |
Patrick Boettcher | dea7486 | 2006-05-14 05:01:31 -0300 | [diff] [blame] | 260 | if (fe->ops.i2c_gate_ctrl) |
| 261 | fe->ops.i2c_gate_ctrl(fe, 1); |
Mauro Carvalho Chehab | 86ddd96 | 2005-07-12 13:58:47 -0700 | [diff] [blame] | 262 | if (i2c_transfer(&dev->i2c_adap, &tuner_msg, 1) != 1) |
| 263 | return -EIO; |
Mauro Carvalho Chehab | 86ddd96 | 2005-07-12 13:58:47 -0700 | [diff] [blame] | 264 | msleep(1); |
| 265 | return 0; |
| 266 | } |
| 267 | |
Hartmut Hackmann | 2cf36ac | 2005-11-08 21:36:32 -0800 | [diff] [blame] | 268 | static int philips_tda6651_pll_init(u8 addr, struct dvb_frontend *fe) |
| 269 | { |
| 270 | struct saa7134_dev *dev = fe->dvb->priv; |
| 271 | static u8 tu1216_init[] = { 0x0b, 0xf5, 0x85, 0xab }; |
| 272 | struct i2c_msg tuner_msg = {.addr = addr,.flags = 0,.buf = tu1216_init,.len = sizeof(tu1216_init) }; |
| 273 | |
| 274 | /* setup PLL configuration */ |
Patrick Boettcher | dea7486 | 2006-05-14 05:01:31 -0300 | [diff] [blame] | 275 | if (fe->ops.i2c_gate_ctrl) |
| 276 | fe->ops.i2c_gate_ctrl(fe, 1); |
Hartmut Hackmann | 2cf36ac | 2005-11-08 21:36:32 -0800 | [diff] [blame] | 277 | if (i2c_transfer(&dev->i2c_adap, &tuner_msg, 1) != 1) |
| 278 | return -EIO; |
| 279 | msleep(1); |
| 280 | |
| 281 | return 0; |
| 282 | } |
| 283 | |
| 284 | /* ------------------------------------------------------------------ */ |
| 285 | |
Andrew de Quincey | a79ddae | 2006-04-18 17:47:11 -0300 | [diff] [blame] | 286 | static int philips_tu1216_tuner_60_init(struct dvb_frontend *fe) |
Hartmut Hackmann | 2cf36ac | 2005-11-08 21:36:32 -0800 | [diff] [blame] | 287 | { |
| 288 | return philips_tda6651_pll_init(0x60, fe); |
| 289 | } |
| 290 | |
Andrew de Quincey | a79ddae | 2006-04-18 17:47:11 -0300 | [diff] [blame] | 291 | static int philips_tu1216_tuner_60_set_params(struct dvb_frontend *fe, struct dvb_frontend_parameters *params) |
Hartmut Hackmann | 2cf36ac | 2005-11-08 21:36:32 -0800 | [diff] [blame] | 292 | { |
| 293 | return philips_tda6651_pll_set(0x60, fe, params); |
| 294 | } |
| 295 | |
Mauro Carvalho Chehab | 86ddd96 | 2005-07-12 13:58:47 -0700 | [diff] [blame] | 296 | static int philips_tu1216_request_firmware(struct dvb_frontend *fe, |
| 297 | const struct firmware **fw, char *name) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 298 | { |
| 299 | struct saa7134_dev *dev = fe->dvb->priv; |
| 300 | return request_firmware(fw, name, &dev->pci->dev); |
| 301 | } |
| 302 | |
Hartmut Hackmann | 2cf36ac | 2005-11-08 21:36:32 -0800 | [diff] [blame] | 303 | static struct tda1004x_config philips_tu1216_60_config = { |
Mauro Carvalho Chehab | 86ddd96 | 2005-07-12 13:58:47 -0700 | [diff] [blame] | 304 | |
| 305 | .demod_address = 0x8, |
| 306 | .invert = 1, |
Hartmut Hackmann | 2cf36ac | 2005-11-08 21:36:32 -0800 | [diff] [blame] | 307 | .invert_oclk = 0, |
Mauro Carvalho Chehab | 86ddd96 | 2005-07-12 13:58:47 -0700 | [diff] [blame] | 308 | .xtal_freq = TDA10046_XTAL_4M, |
| 309 | .agc_config = TDA10046_AGC_DEFAULT, |
| 310 | .if_freq = TDA10046_FREQ_3617, |
Mauro Carvalho Chehab | 86ddd96 | 2005-07-12 13:58:47 -0700 | [diff] [blame] | 311 | .request_firmware = philips_tu1216_request_firmware, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 312 | }; |
| 313 | |
| 314 | /* ------------------------------------------------------------------ */ |
| 315 | |
Andrew de Quincey | a79ddae | 2006-04-18 17:47:11 -0300 | [diff] [blame] | 316 | static int philips_tu1216_tuner_61_init(struct dvb_frontend *fe) |
Hartmut Hackmann | 2cf36ac | 2005-11-08 21:36:32 -0800 | [diff] [blame] | 317 | { |
| 318 | return philips_tda6651_pll_init(0x61, fe); |
| 319 | } |
| 320 | |
Andrew de Quincey | a79ddae | 2006-04-18 17:47:11 -0300 | [diff] [blame] | 321 | static int philips_tu1216_tuner_61_set_params(struct dvb_frontend *fe, struct dvb_frontend_parameters *params) |
Hartmut Hackmann | 2cf36ac | 2005-11-08 21:36:32 -0800 | [diff] [blame] | 322 | { |
| 323 | return philips_tda6651_pll_set(0x61, fe, params); |
| 324 | } |
| 325 | |
| 326 | static struct tda1004x_config philips_tu1216_61_config = { |
| 327 | |
| 328 | .demod_address = 0x8, |
| 329 | .invert = 1, |
| 330 | .invert_oclk = 0, |
| 331 | .xtal_freq = TDA10046_XTAL_4M, |
| 332 | .agc_config = TDA10046_AGC_DEFAULT, |
| 333 | .if_freq = TDA10046_FREQ_3617, |
Hartmut Hackmann | 2cf36ac | 2005-11-08 21:36:32 -0800 | [diff] [blame] | 334 | .request_firmware = philips_tu1216_request_firmware, |
| 335 | }; |
| 336 | |
| 337 | /* ------------------------------------------------------------------ */ |
| 338 | |
Andrew de Quincey | a79ddae | 2006-04-18 17:47:11 -0300 | [diff] [blame] | 339 | static int philips_europa_tuner_init(struct dvb_frontend *fe) |
Hartmut Hackmann | 2cf36ac | 2005-11-08 21:36:32 -0800 | [diff] [blame] | 340 | { |
| 341 | struct saa7134_dev *dev = fe->dvb->priv; |
| 342 | static u8 msg[] = { 0x0b, 0xf5, 0x86, 0xab }; |
| 343 | struct i2c_msg init_msg = {.addr = 0x61,.flags = 0,.buf = msg,.len = sizeof(msg) }; |
| 344 | |
| 345 | /* setup PLL configuration */ |
Patrick Boettcher | dea7486 | 2006-05-14 05:01:31 -0300 | [diff] [blame] | 346 | if (fe->ops.i2c_gate_ctrl) |
| 347 | fe->ops.i2c_gate_ctrl(fe, 1); |
Hartmut Hackmann | 2cf36ac | 2005-11-08 21:36:32 -0800 | [diff] [blame] | 348 | if (i2c_transfer(&dev->i2c_adap, &init_msg, 1) != 1) |
| 349 | return -EIO; |
| 350 | msleep(1); |
| 351 | |
| 352 | /* switch the board to dvb mode */ |
| 353 | init_msg.addr = 0x43; |
| 354 | init_msg.len = 0x02; |
| 355 | msg[0] = 0x00; |
| 356 | msg[1] = 0x40; |
Patrick Boettcher | dea7486 | 2006-05-14 05:01:31 -0300 | [diff] [blame] | 357 | if (fe->ops.i2c_gate_ctrl) |
| 358 | fe->ops.i2c_gate_ctrl(fe, 1); |
Hartmut Hackmann | 2cf36ac | 2005-11-08 21:36:32 -0800 | [diff] [blame] | 359 | if (i2c_transfer(&dev->i2c_adap, &init_msg, 1) != 1) |
| 360 | return -EIO; |
| 361 | |
| 362 | return 0; |
| 363 | } |
| 364 | |
Andrew de Quincey | a79ddae | 2006-04-18 17:47:11 -0300 | [diff] [blame] | 365 | 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] | 366 | { |
| 367 | return philips_tda6651_pll_set(0x61, fe, params); |
| 368 | } |
| 369 | |
Andrew de Quincey | a79ddae | 2006-04-18 17:47:11 -0300 | [diff] [blame] | 370 | static int philips_europa_tuner_sleep(struct dvb_frontend *fe) |
Hartmut Hackmann | 2cf36ac | 2005-11-08 21:36:32 -0800 | [diff] [blame] | 371 | { |
| 372 | struct saa7134_dev *dev = fe->dvb->priv; |
| 373 | /* this message actually turns the tuner back to analog mode */ |
| 374 | static u8 msg[] = { 0x0b, 0xdc, 0x86, 0xa4 }; |
| 375 | struct i2c_msg analog_msg = {.addr = 0x61,.flags = 0,.buf = msg,.len = sizeof(msg) }; |
| 376 | |
| 377 | i2c_transfer(&dev->i2c_adap, &analog_msg, 1); |
| 378 | msleep(1); |
| 379 | |
| 380 | /* switch the board to analog mode */ |
| 381 | analog_msg.addr = 0x43; |
| 382 | analog_msg.len = 0x02; |
| 383 | msg[0] = 0x00; |
| 384 | msg[1] = 0x14; |
Patrick Boettcher | dea7486 | 2006-05-14 05:01:31 -0300 | [diff] [blame] | 385 | if (fe->ops.i2c_gate_ctrl) |
| 386 | fe->ops.i2c_gate_ctrl(fe, 1); |
Hartmut Hackmann | 2cf36ac | 2005-11-08 21:36:32 -0800 | [diff] [blame] | 387 | i2c_transfer(&dev->i2c_adap, &analog_msg, 1); |
Andrew de Quincey | a79ddae | 2006-04-18 17:47:11 -0300 | [diff] [blame] | 388 | return 0; |
| 389 | } |
| 390 | |
| 391 | static int philips_europa_demod_sleep(struct dvb_frontend *fe) |
| 392 | { |
| 393 | struct saa7134_dev *dev = fe->dvb->priv; |
| 394 | |
| 395 | if (dev->original_demod_sleep) |
| 396 | dev->original_demod_sleep(fe); |
Patrick Boettcher | dea7486 | 2006-05-14 05:01:31 -0300 | [diff] [blame] | 397 | fe->ops.i2c_gate_ctrl(fe, 1); |
Andrew de Quincey | a79ddae | 2006-04-18 17:47:11 -0300 | [diff] [blame] | 398 | return 0; |
Hartmut Hackmann | 2cf36ac | 2005-11-08 21:36:32 -0800 | [diff] [blame] | 399 | } |
| 400 | |
| 401 | static struct tda1004x_config philips_europa_config = { |
| 402 | |
| 403 | .demod_address = 0x8, |
| 404 | .invert = 0, |
| 405 | .invert_oclk = 0, |
| 406 | .xtal_freq = TDA10046_XTAL_4M, |
| 407 | .agc_config = TDA10046_AGC_IFO_AUTO_POS, |
| 408 | .if_freq = TDA10046_FREQ_052, |
Hartmut Hackmann | 2cf36ac | 2005-11-08 21:36:32 -0800 | [diff] [blame] | 409 | .request_firmware = NULL, |
| 410 | }; |
| 411 | |
| 412 | /* ------------------------------------------------------------------ */ |
Mauro Carvalho Chehab | 86ddd96 | 2005-07-12 13:58:47 -0700 | [diff] [blame] | 413 | |
Andrew de Quincey | a79ddae | 2006-04-18 17:47:11 -0300 | [diff] [blame] | 414 | static int philips_fmd1216_tuner_init(struct dvb_frontend *fe) |
Mauro Carvalho Chehab | 86ddd96 | 2005-07-12 13:58:47 -0700 | [diff] [blame] | 415 | { |
| 416 | struct saa7134_dev *dev = fe->dvb->priv; |
| 417 | /* this message is to set up ATC and ALC */ |
| 418 | static u8 fmd1216_init[] = { 0x0b, 0xdc, 0x9c, 0xa0 }; |
| 419 | struct i2c_msg tuner_msg = {.addr = 0x61,.flags = 0,.buf = fmd1216_init,.len = sizeof(fmd1216_init) }; |
| 420 | |
Patrick Boettcher | dea7486 | 2006-05-14 05:01:31 -0300 | [diff] [blame] | 421 | if (fe->ops.i2c_gate_ctrl) |
| 422 | fe->ops.i2c_gate_ctrl(fe, 1); |
Mauro Carvalho Chehab | 86ddd96 | 2005-07-12 13:58:47 -0700 | [diff] [blame] | 423 | if (i2c_transfer(&dev->i2c_adap, &tuner_msg, 1) != 1) |
| 424 | return -EIO; |
| 425 | msleep(1); |
| 426 | |
| 427 | return 0; |
| 428 | } |
| 429 | |
Andrew de Quincey | a79ddae | 2006-04-18 17:47:11 -0300 | [diff] [blame] | 430 | static int philips_fmd1216_tuner_sleep(struct dvb_frontend *fe) |
Mauro Carvalho Chehab | 86ddd96 | 2005-07-12 13:58:47 -0700 | [diff] [blame] | 431 | { |
| 432 | struct saa7134_dev *dev = fe->dvb->priv; |
| 433 | /* this message actually turns the tuner back to analog mode */ |
| 434 | static u8 fmd1216_init[] = { 0x0b, 0xdc, 0x9c, 0x60 }; |
| 435 | struct i2c_msg tuner_msg = {.addr = 0x61,.flags = 0,.buf = fmd1216_init,.len = sizeof(fmd1216_init) }; |
| 436 | |
Patrick Boettcher | dea7486 | 2006-05-14 05:01:31 -0300 | [diff] [blame] | 437 | if (fe->ops.i2c_gate_ctrl) |
| 438 | fe->ops.i2c_gate_ctrl(fe, 1); |
Mauro Carvalho Chehab | 86ddd96 | 2005-07-12 13:58:47 -0700 | [diff] [blame] | 439 | i2c_transfer(&dev->i2c_adap, &tuner_msg, 1); |
| 440 | msleep(1); |
| 441 | fmd1216_init[2] = 0x86; |
| 442 | fmd1216_init[3] = 0x54; |
Patrick Boettcher | dea7486 | 2006-05-14 05:01:31 -0300 | [diff] [blame] | 443 | if (fe->ops.i2c_gate_ctrl) |
| 444 | fe->ops.i2c_gate_ctrl(fe, 1); |
Mauro Carvalho Chehab | 86ddd96 | 2005-07-12 13:58:47 -0700 | [diff] [blame] | 445 | i2c_transfer(&dev->i2c_adap, &tuner_msg, 1); |
| 446 | msleep(1); |
Andrew de Quincey | a79ddae | 2006-04-18 17:47:11 -0300 | [diff] [blame] | 447 | return 0; |
Mauro Carvalho Chehab | 86ddd96 | 2005-07-12 13:58:47 -0700 | [diff] [blame] | 448 | } |
| 449 | |
Andrew de Quincey | a79ddae | 2006-04-18 17:47:11 -0300 | [diff] [blame] | 450 | 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] | 451 | { |
| 452 | struct saa7134_dev *dev = fe->dvb->priv; |
| 453 | u8 tuner_buf[4]; |
| 454 | struct i2c_msg tuner_msg = {.addr = 0x61,.flags = 0,.buf = tuner_buf,.len = |
| 455 | sizeof(tuner_buf) }; |
| 456 | int tuner_frequency = 0; |
| 457 | int divider = 0; |
| 458 | u8 band, mode, cp; |
| 459 | |
| 460 | /* determine charge pump */ |
| 461 | tuner_frequency = params->frequency + 36130000; |
| 462 | if (tuner_frequency < 87000000) |
| 463 | return -EINVAL; |
| 464 | /* low band */ |
| 465 | else if (tuner_frequency < 180000000) { |
| 466 | band = 1; |
| 467 | mode = 7; |
| 468 | cp = 0; |
| 469 | } else if (tuner_frequency < 195000000) { |
| 470 | band = 1; |
| 471 | mode = 6; |
| 472 | cp = 1; |
| 473 | /* mid band */ |
| 474 | } else if (tuner_frequency < 366000000) { |
| 475 | if (params->u.ofdm.bandwidth == BANDWIDTH_8_MHZ) { |
| 476 | band = 10; |
| 477 | } else { |
| 478 | band = 2; |
| 479 | } |
| 480 | mode = 7; |
| 481 | cp = 0; |
| 482 | } else if (tuner_frequency < 478000000) { |
| 483 | if (params->u.ofdm.bandwidth == BANDWIDTH_8_MHZ) { |
| 484 | band = 10; |
| 485 | } else { |
| 486 | band = 2; |
| 487 | } |
| 488 | mode = 6; |
| 489 | cp = 1; |
| 490 | /* high band */ |
| 491 | } else if (tuner_frequency < 662000000) { |
| 492 | if (params->u.ofdm.bandwidth == BANDWIDTH_8_MHZ) { |
| 493 | band = 12; |
| 494 | } else { |
| 495 | band = 4; |
| 496 | } |
| 497 | mode = 7; |
| 498 | cp = 0; |
| 499 | } else if (tuner_frequency < 840000000) { |
| 500 | if (params->u.ofdm.bandwidth == BANDWIDTH_8_MHZ) { |
| 501 | band = 12; |
| 502 | } else { |
| 503 | band = 4; |
| 504 | } |
| 505 | mode = 6; |
| 506 | cp = 1; |
| 507 | } else { |
| 508 | if (params->u.ofdm.bandwidth == BANDWIDTH_8_MHZ) { |
| 509 | band = 12; |
| 510 | } else { |
| 511 | band = 4; |
| 512 | } |
| 513 | mode = 7; |
| 514 | cp = 1; |
| 515 | |
| 516 | } |
| 517 | /* calculate divisor */ |
| 518 | /* ((36166000 + Finput) / 166666) rounded! */ |
| 519 | divider = (tuner_frequency + 83333) / 166667; |
| 520 | |
| 521 | /* setup tuner buffer */ |
| 522 | tuner_buf[0] = (divider >> 8) & 0x7f; |
| 523 | tuner_buf[1] = divider & 0xff; |
| 524 | tuner_buf[2] = 0x80 | (cp << 6) | (mode << 3) | 4; |
| 525 | tuner_buf[3] = 0x40 | band; |
| 526 | |
Patrick Boettcher | dea7486 | 2006-05-14 05:01:31 -0300 | [diff] [blame] | 527 | if (fe->ops.i2c_gate_ctrl) |
| 528 | fe->ops.i2c_gate_ctrl(fe, 1); |
Mauro Carvalho Chehab | 86ddd96 | 2005-07-12 13:58:47 -0700 | [diff] [blame] | 529 | if (i2c_transfer(&dev->i2c_adap, &tuner_msg, 1) != 1) |
| 530 | return -EIO; |
| 531 | return 0; |
| 532 | } |
| 533 | |
Mauro Carvalho Chehab | 86ddd96 | 2005-07-12 13:58:47 -0700 | [diff] [blame] | 534 | static struct tda1004x_config medion_cardbus = { |
| 535 | .demod_address = 0x08, |
| 536 | .invert = 1, |
| 537 | .invert_oclk = 0, |
| 538 | .xtal_freq = TDA10046_XTAL_16M, |
| 539 | .agc_config = TDA10046_AGC_IFO_AUTO_NEG, |
| 540 | .if_freq = TDA10046_FREQ_3613, |
Mauro Carvalho Chehab | 86ddd96 | 2005-07-12 13:58:47 -0700 | [diff] [blame] | 541 | .request_firmware = NULL, |
| 542 | }; |
| 543 | |
| 544 | /* ------------------------------------------------------------------ */ |
| 545 | |
| 546 | struct tda827x_data { |
| 547 | u32 lomax; |
| 548 | u8 spd; |
| 549 | u8 bs; |
| 550 | u8 bp; |
| 551 | u8 cp; |
| 552 | u8 gc3; |
| 553 | u8 div1p5; |
| 554 | }; |
| 555 | |
| 556 | static struct tda827x_data tda827x_dvbt[] = { |
| 557 | { .lomax = 62000000, .spd = 3, .bs = 2, .bp = 0, .cp = 0, .gc3 = 3, .div1p5 = 1}, |
| 558 | { .lomax = 66000000, .spd = 3, .bs = 3, .bp = 0, .cp = 0, .gc3 = 3, .div1p5 = 1}, |
| 559 | { .lomax = 76000000, .spd = 3, .bs = 1, .bp = 0, .cp = 0, .gc3 = 3, .div1p5 = 0}, |
| 560 | { .lomax = 84000000, .spd = 3, .bs = 2, .bp = 0, .cp = 0, .gc3 = 3, .div1p5 = 0}, |
| 561 | { .lomax = 93000000, .spd = 3, .bs = 2, .bp = 0, .cp = 0, .gc3 = 1, .div1p5 = 0}, |
| 562 | { .lomax = 98000000, .spd = 3, .bs = 3, .bp = 0, .cp = 0, .gc3 = 1, .div1p5 = 0}, |
| 563 | { .lomax = 109000000, .spd = 3, .bs = 3, .bp = 1, .cp = 0, .gc3 = 1, .div1p5 = 0}, |
| 564 | { .lomax = 123000000, .spd = 2, .bs = 2, .bp = 1, .cp = 0, .gc3 = 1, .div1p5 = 1}, |
| 565 | { .lomax = 133000000, .spd = 2, .bs = 3, .bp = 1, .cp = 0, .gc3 = 1, .div1p5 = 1}, |
| 566 | { .lomax = 151000000, .spd = 2, .bs = 1, .bp = 1, .cp = 0, .gc3 = 1, .div1p5 = 0}, |
| 567 | { .lomax = 154000000, .spd = 2, .bs = 2, .bp = 1, .cp = 0, .gc3 = 1, .div1p5 = 0}, |
| 568 | { .lomax = 181000000, .spd = 2, .bs = 2, .bp = 1, .cp = 0, .gc3 = 0, .div1p5 = 0}, |
| 569 | { .lomax = 185000000, .spd = 2, .bs = 2, .bp = 2, .cp = 0, .gc3 = 1, .div1p5 = 0}, |
| 570 | { .lomax = 217000000, .spd = 2, .bs = 3, .bp = 2, .cp = 0, .gc3 = 1, .div1p5 = 0}, |
| 571 | { .lomax = 244000000, .spd = 1, .bs = 2, .bp = 2, .cp = 0, .gc3 = 1, .div1p5 = 1}, |
| 572 | { .lomax = 265000000, .spd = 1, .bs = 3, .bp = 2, .cp = 0, .gc3 = 1, .div1p5 = 1}, |
| 573 | { .lomax = 302000000, .spd = 1, .bs = 1, .bp = 2, .cp = 0, .gc3 = 1, .div1p5 = 0}, |
| 574 | { .lomax = 324000000, .spd = 1, .bs = 2, .bp = 2, .cp = 0, .gc3 = 1, .div1p5 = 0}, |
| 575 | { .lomax = 370000000, .spd = 1, .bs = 2, .bp = 3, .cp = 0, .gc3 = 1, .div1p5 = 0}, |
| 576 | { .lomax = 454000000, .spd = 1, .bs = 3, .bp = 3, .cp = 0, .gc3 = 1, .div1p5 = 0}, |
| 577 | { .lomax = 493000000, .spd = 0, .bs = 2, .bp = 3, .cp = 0, .gc3 = 1, .div1p5 = 1}, |
| 578 | { .lomax = 530000000, .spd = 0, .bs = 3, .bp = 3, .cp = 0, .gc3 = 1, .div1p5 = 1}, |
| 579 | { .lomax = 554000000, .spd = 0, .bs = 1, .bp = 3, .cp = 0, .gc3 = 1, .div1p5 = 0}, |
| 580 | { .lomax = 604000000, .spd = 0, .bs = 1, .bp = 4, .cp = 0, .gc3 = 0, .div1p5 = 0}, |
| 581 | { .lomax = 696000000, .spd = 0, .bs = 2, .bp = 4, .cp = 0, .gc3 = 0, .div1p5 = 0}, |
| 582 | { .lomax = 740000000, .spd = 0, .bs = 2, .bp = 4, .cp = 1, .gc3 = 0, .div1p5 = 0}, |
| 583 | { .lomax = 820000000, .spd = 0, .bs = 3, .bp = 4, .cp = 0, .gc3 = 0, .div1p5 = 0}, |
| 584 | { .lomax = 865000000, .spd = 0, .bs = 3, .bp = 4, .cp = 1, .gc3 = 0, .div1p5 = 0}, |
| 585 | { .lomax = 0, .spd = 0, .bs = 0, .bp = 0, .cp = 0, .gc3 = 0, .div1p5 = 0} |
| 586 | }; |
| 587 | |
Andrew de Quincey | a79ddae | 2006-04-18 17:47:11 -0300 | [diff] [blame] | 588 | static int philips_tda827x_tuner_init(struct dvb_frontend *fe) |
Mauro Carvalho Chehab | 86ddd96 | 2005-07-12 13:58:47 -0700 | [diff] [blame] | 589 | { |
| 590 | return 0; |
| 591 | } |
| 592 | |
Andrew de Quincey | a79ddae | 2006-04-18 17:47:11 -0300 | [diff] [blame] | 593 | static int philips_tda827x_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] | 594 | { |
| 595 | struct saa7134_dev *dev = fe->dvb->priv; |
| 596 | u8 tuner_buf[14]; |
| 597 | |
| 598 | struct i2c_msg tuner_msg = {.addr = 0x60,.flags = 0,.buf = tuner_buf, |
Mauro Carvalho Chehab | f2421ca | 2005-11-08 21:37:45 -0800 | [diff] [blame] | 599 | .len = sizeof(tuner_buf) }; |
Mauro Carvalho Chehab | 86ddd96 | 2005-07-12 13:58:47 -0700 | [diff] [blame] | 600 | int i, tuner_freq, if_freq; |
| 601 | u32 N; |
| 602 | switch (params->u.ofdm.bandwidth) { |
| 603 | case BANDWIDTH_6_MHZ: |
| 604 | if_freq = 4000000; |
| 605 | break; |
| 606 | case BANDWIDTH_7_MHZ: |
| 607 | if_freq = 4500000; |
| 608 | break; |
| 609 | default: /* 8 MHz or Auto */ |
| 610 | if_freq = 5000000; |
| 611 | break; |
| 612 | } |
| 613 | tuner_freq = params->frequency + if_freq; |
| 614 | |
| 615 | i = 0; |
| 616 | while (tda827x_dvbt[i].lomax < tuner_freq) { |
| 617 | if(tda827x_dvbt[i + 1].lomax == 0) |
| 618 | break; |
| 619 | i++; |
| 620 | } |
| 621 | |
| 622 | N = ((tuner_freq + 125000) / 250000) << (tda827x_dvbt[i].spd + 2); |
| 623 | tuner_buf[0] = 0; |
| 624 | tuner_buf[1] = (N>>8) | 0x40; |
| 625 | tuner_buf[2] = N & 0xff; |
| 626 | tuner_buf[3] = 0; |
| 627 | tuner_buf[4] = 0x52; |
| 628 | tuner_buf[5] = (tda827x_dvbt[i].spd << 6) + (tda827x_dvbt[i].div1p5 << 5) + |
| 629 | (tda827x_dvbt[i].bs << 3) + tda827x_dvbt[i].bp; |
| 630 | tuner_buf[6] = (tda827x_dvbt[i].gc3 << 4) + 0x8f; |
| 631 | tuner_buf[7] = 0xbf; |
| 632 | tuner_buf[8] = 0x2a; |
| 633 | tuner_buf[9] = 0x05; |
| 634 | tuner_buf[10] = 0xff; |
| 635 | tuner_buf[11] = 0x00; |
| 636 | tuner_buf[12] = 0x00; |
| 637 | tuner_buf[13] = 0x40; |
| 638 | |
| 639 | tuner_msg.len = 14; |
Patrick Boettcher | dea7486 | 2006-05-14 05:01:31 -0300 | [diff] [blame] | 640 | if (fe->ops.i2c_gate_ctrl) |
| 641 | fe->ops.i2c_gate_ctrl(fe, 1); |
Mauro Carvalho Chehab | 86ddd96 | 2005-07-12 13:58:47 -0700 | [diff] [blame] | 642 | if (i2c_transfer(&dev->i2c_adap, &tuner_msg, 1) != 1) |
| 643 | return -EIO; |
| 644 | |
| 645 | msleep(500); |
| 646 | /* correct CP value */ |
| 647 | tuner_buf[0] = 0x30; |
| 648 | tuner_buf[1] = 0x50 + tda827x_dvbt[i].cp; |
| 649 | tuner_msg.len = 2; |
Patrick Boettcher | dea7486 | 2006-05-14 05:01:31 -0300 | [diff] [blame] | 650 | if (fe->ops.i2c_gate_ctrl) |
| 651 | fe->ops.i2c_gate_ctrl(fe, 1); |
Mauro Carvalho Chehab | 86ddd96 | 2005-07-12 13:58:47 -0700 | [diff] [blame] | 652 | i2c_transfer(&dev->i2c_adap, &tuner_msg, 1); |
| 653 | |
| 654 | return 0; |
| 655 | } |
| 656 | |
Andrew de Quincey | a79ddae | 2006-04-18 17:47:11 -0300 | [diff] [blame] | 657 | static int philips_tda827x_tuner_sleep(struct dvb_frontend *fe) |
Mauro Carvalho Chehab | 86ddd96 | 2005-07-12 13:58:47 -0700 | [diff] [blame] | 658 | { |
| 659 | struct saa7134_dev *dev = fe->dvb->priv; |
| 660 | static u8 tda827x_sleep[] = { 0x30, 0xd0}; |
| 661 | struct i2c_msg tuner_msg = {.addr = 0x60,.flags = 0,.buf = tda827x_sleep, |
Mauro Carvalho Chehab | f2421ca | 2005-11-08 21:37:45 -0800 | [diff] [blame] | 662 | .len = sizeof(tda827x_sleep) }; |
Patrick Boettcher | dea7486 | 2006-05-14 05:01:31 -0300 | [diff] [blame] | 663 | if (fe->ops.i2c_gate_ctrl) |
| 664 | fe->ops.i2c_gate_ctrl(fe, 1); |
Mauro Carvalho Chehab | 86ddd96 | 2005-07-12 13:58:47 -0700 | [diff] [blame] | 665 | i2c_transfer(&dev->i2c_adap, &tuner_msg, 1); |
Andrew de Quincey | a79ddae | 2006-04-18 17:47:11 -0300 | [diff] [blame] | 666 | return 0; |
Mauro Carvalho Chehab | 86ddd96 | 2005-07-12 13:58:47 -0700 | [diff] [blame] | 667 | } |
| 668 | |
| 669 | static struct tda1004x_config tda827x_lifeview_config = { |
| 670 | .demod_address = 0x08, |
| 671 | .invert = 1, |
| 672 | .invert_oclk = 0, |
| 673 | .xtal_freq = TDA10046_XTAL_16M, |
| 674 | .agc_config = TDA10046_AGC_TDA827X, |
| 675 | .if_freq = TDA10046_FREQ_045, |
Mauro Carvalho Chehab | 86ddd96 | 2005-07-12 13:58:47 -0700 | [diff] [blame] | 676 | .request_firmware = NULL, |
| 677 | }; |
Hartmut Hackmann | 90e9df7 | 2005-11-08 21:38:42 -0800 | [diff] [blame] | 678 | |
| 679 | /* ------------------------------------------------------------------ */ |
| 680 | |
| 681 | struct tda827xa_data { |
| 682 | u32 lomax; |
| 683 | u8 svco; |
| 684 | u8 spd; |
| 685 | u8 scr; |
| 686 | u8 sbs; |
| 687 | u8 gc3; |
| 688 | }; |
| 689 | |
| 690 | static struct tda827xa_data tda827xa_dvbt[] = { |
| 691 | { .lomax = 56875000, .svco = 3, .spd = 4, .scr = 0, .sbs = 0, .gc3 = 1}, |
| 692 | { .lomax = 67250000, .svco = 0, .spd = 3, .scr = 0, .sbs = 0, .gc3 = 1}, |
| 693 | { .lomax = 81250000, .svco = 1, .spd = 3, .scr = 0, .sbs = 0, .gc3 = 1}, |
| 694 | { .lomax = 97500000, .svco = 2, .spd = 3, .scr = 0, .sbs = 0, .gc3 = 1}, |
| 695 | { .lomax = 113750000, .svco = 3, .spd = 3, .scr = 0, .sbs = 1, .gc3 = 1}, |
| 696 | { .lomax = 134500000, .svco = 0, .spd = 2, .scr = 0, .sbs = 1, .gc3 = 1}, |
| 697 | { .lomax = 154000000, .svco = 1, .spd = 2, .scr = 0, .sbs = 1, .gc3 = 1}, |
| 698 | { .lomax = 162500000, .svco = 1, .spd = 2, .scr = 0, .sbs = 1, .gc3 = 1}, |
| 699 | { .lomax = 183000000, .svco = 2, .spd = 2, .scr = 0, .sbs = 1, .gc3 = 1}, |
| 700 | { .lomax = 195000000, .svco = 2, .spd = 2, .scr = 0, .sbs = 2, .gc3 = 1}, |
| 701 | { .lomax = 227500000, .svco = 3, .spd = 2, .scr = 0, .sbs = 2, .gc3 = 1}, |
| 702 | { .lomax = 269000000, .svco = 0, .spd = 1, .scr = 0, .sbs = 2, .gc3 = 1}, |
| 703 | { .lomax = 290000000, .svco = 1, .spd = 1, .scr = 0, .sbs = 2, .gc3 = 1}, |
| 704 | { .lomax = 325000000, .svco = 1, .spd = 1, .scr = 0, .sbs = 3, .gc3 = 1}, |
| 705 | { .lomax = 390000000, .svco = 2, .spd = 1, .scr = 0, .sbs = 3, .gc3 = 1}, |
| 706 | { .lomax = 455000000, .svco = 3, .spd = 1, .scr = 0, .sbs = 3, .gc3 = 1}, |
| 707 | { .lomax = 520000000, .svco = 0, .spd = 0, .scr = 0, .sbs = 3, .gc3 = 1}, |
| 708 | { .lomax = 538000000, .svco = 0, .spd = 0, .scr = 1, .sbs = 3, .gc3 = 1}, |
| 709 | { .lomax = 550000000, .svco = 1, .spd = 0, .scr = 0, .sbs = 3, .gc3 = 1}, |
| 710 | { .lomax = 620000000, .svco = 1, .spd = 0, .scr = 0, .sbs = 4, .gc3 = 0}, |
| 711 | { .lomax = 650000000, .svco = 1, .spd = 0, .scr = 1, .sbs = 4, .gc3 = 0}, |
| 712 | { .lomax = 700000000, .svco = 2, .spd = 0, .scr = 0, .sbs = 4, .gc3 = 0}, |
| 713 | { .lomax = 780000000, .svco = 2, .spd = 0, .scr = 1, .sbs = 4, .gc3 = 0}, |
| 714 | { .lomax = 820000000, .svco = 3, .spd = 0, .scr = 0, .sbs = 4, .gc3 = 0}, |
| 715 | { .lomax = 870000000, .svco = 3, .spd = 0, .scr = 1, .sbs = 4, .gc3 = 0}, |
| 716 | { .lomax = 911000000, .svco = 3, .spd = 0, .scr = 2, .sbs = 4, .gc3 = 0}, |
| 717 | { .lomax = 0, .svco = 0, .spd = 0, .scr = 0, .sbs = 0, .gc3 = 0}}; |
| 718 | |
| 719 | |
| 720 | static int philips_tda827xa_pll_set(u8 addr, struct dvb_frontend *fe, struct dvb_frontend_parameters *params) |
| 721 | { |
| 722 | struct saa7134_dev *dev = fe->dvb->priv; |
| 723 | u8 tuner_buf[14]; |
| 724 | unsigned char reg2[2]; |
| 725 | |
| 726 | struct i2c_msg msg = {.addr = addr,.flags = 0,.buf = tuner_buf}; |
| 727 | int i, tuner_freq, if_freq; |
| 728 | u32 N; |
| 729 | |
| 730 | switch (params->u.ofdm.bandwidth) { |
| 731 | case BANDWIDTH_6_MHZ: |
| 732 | if_freq = 4000000; |
| 733 | break; |
| 734 | case BANDWIDTH_7_MHZ: |
| 735 | if_freq = 4500000; |
| 736 | break; |
| 737 | default: /* 8 MHz or Auto */ |
| 738 | if_freq = 5000000; |
| 739 | break; |
| 740 | } |
| 741 | tuner_freq = params->frequency + if_freq; |
| 742 | |
| 743 | i = 0; |
| 744 | while (tda827xa_dvbt[i].lomax < tuner_freq) { |
| 745 | if(tda827xa_dvbt[i + 1].lomax == 0) |
| 746 | break; |
| 747 | i++; |
| 748 | } |
| 749 | |
| 750 | N = ((tuner_freq + 31250) / 62500) << tda827xa_dvbt[i].spd; |
| 751 | tuner_buf[0] = 0; // subaddress |
| 752 | tuner_buf[1] = N >> 8; |
| 753 | tuner_buf[2] = N & 0xff; |
| 754 | tuner_buf[3] = 0; |
| 755 | tuner_buf[4] = 0x16; |
| 756 | tuner_buf[5] = (tda827xa_dvbt[i].spd << 5) + (tda827xa_dvbt[i].svco << 3) + |
| 757 | tda827xa_dvbt[i].sbs; |
| 758 | tuner_buf[6] = 0x4b + (tda827xa_dvbt[i].gc3 << 4); |
| 759 | tuner_buf[7] = 0x0c; |
| 760 | tuner_buf[8] = 0x06; |
| 761 | tuner_buf[9] = 0x24; |
| 762 | tuner_buf[10] = 0xff; |
| 763 | tuner_buf[11] = 0x60; |
| 764 | tuner_buf[12] = 0x00; |
| 765 | tuner_buf[13] = 0x39; // lpsel |
| 766 | msg.len = 14; |
Patrick Boettcher | dea7486 | 2006-05-14 05:01:31 -0300 | [diff] [blame] | 767 | if (fe->ops.i2c_gate_ctrl) |
| 768 | fe->ops.i2c_gate_ctrl(fe, 1); |
Hartmut Hackmann | 90e9df7 | 2005-11-08 21:38:42 -0800 | [diff] [blame] | 769 | if (i2c_transfer(&dev->i2c_adap, &msg, 1) != 1) |
| 770 | return -EIO; |
| 771 | |
| 772 | msg.buf= reg2; |
| 773 | msg.len = 2; |
| 774 | reg2[0] = 0x60; |
| 775 | reg2[1] = 0x3c; |
Patrick Boettcher | dea7486 | 2006-05-14 05:01:31 -0300 | [diff] [blame] | 776 | if (fe->ops.i2c_gate_ctrl) |
| 777 | fe->ops.i2c_gate_ctrl(fe, 1); |
Hartmut Hackmann | 90e9df7 | 2005-11-08 21:38:42 -0800 | [diff] [blame] | 778 | i2c_transfer(&dev->i2c_adap, &msg, 1); |
| 779 | |
| 780 | reg2[0] = 0xa0; |
| 781 | reg2[1] = 0x40; |
Patrick Boettcher | dea7486 | 2006-05-14 05:01:31 -0300 | [diff] [blame] | 782 | if (fe->ops.i2c_gate_ctrl) |
| 783 | fe->ops.i2c_gate_ctrl(fe, 1); |
Hartmut Hackmann | 90e9df7 | 2005-11-08 21:38:42 -0800 | [diff] [blame] | 784 | i2c_transfer(&dev->i2c_adap, &msg, 1); |
| 785 | |
| 786 | msleep(2); |
| 787 | /* correct CP value */ |
| 788 | reg2[0] = 0x30; |
| 789 | reg2[1] = 0x10 + tda827xa_dvbt[i].scr; |
| 790 | msg.len = 2; |
Patrick Boettcher | dea7486 | 2006-05-14 05:01:31 -0300 | [diff] [blame] | 791 | if (fe->ops.i2c_gate_ctrl) |
| 792 | fe->ops.i2c_gate_ctrl(fe, 1); |
Hartmut Hackmann | 90e9df7 | 2005-11-08 21:38:42 -0800 | [diff] [blame] | 793 | i2c_transfer(&dev->i2c_adap, &msg, 1); |
| 794 | |
| 795 | msleep(550); |
| 796 | reg2[0] = 0x50; |
| 797 | reg2[1] = 0x4f + (tda827xa_dvbt[i].gc3 << 4); |
Patrick Boettcher | dea7486 | 2006-05-14 05:01:31 -0300 | [diff] [blame] | 798 | if (fe->ops.i2c_gate_ctrl) |
| 799 | fe->ops.i2c_gate_ctrl(fe, 1); |
Hartmut Hackmann | 90e9df7 | 2005-11-08 21:38:42 -0800 | [diff] [blame] | 800 | i2c_transfer(&dev->i2c_adap, &msg, 1); |
| 801 | |
| 802 | return 0; |
| 803 | |
| 804 | } |
| 805 | |
Andrew de Quincey | a79ddae | 2006-04-18 17:47:11 -0300 | [diff] [blame] | 806 | static int philips_tda827xa_tuner_sleep(u8 addr, struct dvb_frontend *fe) |
Hartmut Hackmann | 90e9df7 | 2005-11-08 21:38:42 -0800 | [diff] [blame] | 807 | { |
| 808 | struct saa7134_dev *dev = fe->dvb->priv; |
| 809 | static u8 tda827xa_sleep[] = { 0x30, 0x90}; |
| 810 | struct i2c_msg tuner_msg = {.addr = addr,.flags = 0,.buf = tda827xa_sleep, |
Tyler Trafford | f1bcef8 | 2005-11-08 21:38:46 -0800 | [diff] [blame] | 811 | .len = sizeof(tda827xa_sleep) }; |
Patrick Boettcher | dea7486 | 2006-05-14 05:01:31 -0300 | [diff] [blame] | 812 | if (fe->ops.i2c_gate_ctrl) |
| 813 | fe->ops.i2c_gate_ctrl(fe, 1); |
Hartmut Hackmann | 90e9df7 | 2005-11-08 21:38:42 -0800 | [diff] [blame] | 814 | i2c_transfer(&dev->i2c_adap, &tuner_msg, 1); |
Andrew de Quincey | a79ddae | 2006-04-18 17:47:11 -0300 | [diff] [blame] | 815 | return 0; |
Hartmut Hackmann | 90e9df7 | 2005-11-08 21:38:42 -0800 | [diff] [blame] | 816 | } |
| 817 | |
| 818 | /* ------------------------------------------------------------------ */ |
| 819 | |
Andrew de Quincey | a79ddae | 2006-04-18 17:47:11 -0300 | [diff] [blame] | 820 | static int philips_tiger_tuner_set_params(struct dvb_frontend *fe, struct dvb_frontend_parameters *params) |
Hartmut Hackmann | 90e9df7 | 2005-11-08 21:38:42 -0800 | [diff] [blame] | 821 | { |
| 822 | int ret; |
| 823 | struct saa7134_dev *dev = fe->dvb->priv; |
| 824 | static u8 tda8290_close[] = { 0x21, 0xc0}; |
| 825 | static u8 tda8290_open[] = { 0x21, 0x80}; |
| 826 | struct i2c_msg tda8290_msg = {.addr = 0x4b,.flags = 0, .len = 2}; |
Andrew de Quincey | a79ddae | 2006-04-18 17:47:11 -0300 | [diff] [blame] | 827 | |
Hartmut Hackmann | 90e9df7 | 2005-11-08 21:38:42 -0800 | [diff] [blame] | 828 | /* close tda8290 i2c bridge */ |
| 829 | tda8290_msg.buf = tda8290_close; |
| 830 | ret = i2c_transfer(&dev->i2c_adap, &tda8290_msg, 1); |
| 831 | if (ret != 1) |
| 832 | return -EIO; |
| 833 | msleep(20); |
| 834 | ret = philips_tda827xa_pll_set(0x61, fe, params); |
| 835 | if (ret != 0) |
| 836 | return ret; |
| 837 | /* open tda8290 i2c bridge */ |
| 838 | tda8290_msg.buf = tda8290_open; |
| 839 | i2c_transfer(&dev->i2c_adap, &tda8290_msg, 1); |
| 840 | return ret; |
Hartmut Hackmann | 2d6b5f6 | 2006-02-27 21:14:36 -0300 | [diff] [blame] | 841 | } |
Hartmut Hackmann | 90e9df7 | 2005-11-08 21:38:42 -0800 | [diff] [blame] | 842 | |
Andrew de Quincey | a79ddae | 2006-04-18 17:47:11 -0300 | [diff] [blame] | 843 | static int philips_tiger_tuner_init(struct dvb_frontend *fe) |
Hartmut Hackmann | 90e9df7 | 2005-11-08 21:38:42 -0800 | [diff] [blame] | 844 | { |
| 845 | struct saa7134_dev *dev = fe->dvb->priv; |
| 846 | static u8 data[] = { 0x3c, 0x33, 0x6a}; |
| 847 | struct i2c_msg msg = {.addr=0x08, .flags=0, .buf=data, .len = sizeof(data)}; |
| 848 | |
| 849 | if (i2c_transfer(&dev->i2c_adap, &msg, 1) != 1) |
| 850 | return -EIO; |
| 851 | return 0; |
| 852 | } |
| 853 | |
Andrew de Quincey | a79ddae | 2006-04-18 17:47:11 -0300 | [diff] [blame] | 854 | static int philips_tiger_tuner_sleep(struct dvb_frontend *fe) |
Hartmut Hackmann | 90e9df7 | 2005-11-08 21:38:42 -0800 | [diff] [blame] | 855 | { |
| 856 | struct saa7134_dev *dev = fe->dvb->priv; |
| 857 | static u8 data[] = { 0x3c, 0x33, 0x68}; |
| 858 | struct i2c_msg msg = {.addr=0x08, .flags=0, .buf=data, .len = sizeof(data)}; |
| 859 | |
| 860 | i2c_transfer(&dev->i2c_adap, &msg, 1); |
Andrew de Quincey | a79ddae | 2006-04-18 17:47:11 -0300 | [diff] [blame] | 861 | philips_tda827xa_tuner_sleep( 0x61, fe); |
| 862 | return 0; |
Hartmut Hackmann | 90e9df7 | 2005-11-08 21:38:42 -0800 | [diff] [blame] | 863 | } |
| 864 | |
| 865 | static struct tda1004x_config philips_tiger_config = { |
| 866 | .demod_address = 0x08, |
| 867 | .invert = 1, |
| 868 | .invert_oclk = 0, |
| 869 | .xtal_freq = TDA10046_XTAL_16M, |
| 870 | .agc_config = TDA10046_AGC_TDA827X, |
| 871 | .if_freq = TDA10046_FREQ_045, |
Hartmut Hackmann | 90e9df7 | 2005-11-08 21:38:42 -0800 | [diff] [blame] | 872 | .request_firmware = NULL, |
| 873 | }; |
| 874 | |
Hartmut Hackmann | df42eaf | 2006-02-07 06:49:10 -0200 | [diff] [blame] | 875 | /* ------------------------------------------------------------------ */ |
| 876 | |
Hermann Pitton | 6b14ff9 | 2006-10-02 20:18:26 -0300 | [diff] [blame] | 877 | static int asus_p7131_dual_tuner_init(struct dvb_frontend *fe) |
| 878 | { |
| 879 | struct saa7134_dev *dev = fe->dvb->priv; |
| 880 | static u8 data[] = { 0x3c, 0x33, 0x6a}; |
| 881 | struct i2c_msg msg = {.addr=0x08, .flags=0, .buf=data, .len = sizeof(data)}; |
| 882 | |
| 883 | if (i2c_transfer(&dev->i2c_adap, &msg, 1) != 1) |
| 884 | return -EIO; |
| 885 | /* make sure the DVB-T antenna input is set */ |
| 886 | saa_setl(SAA7134_GPIO_GPSTATUS0 >> 2, 0x0200000); |
| 887 | return 0; |
| 888 | } |
| 889 | |
| 890 | static int asus_p7131_dual_tuner_sleep(struct dvb_frontend *fe) |
| 891 | { |
| 892 | struct saa7134_dev *dev = fe->dvb->priv; |
| 893 | static u8 data[] = { 0x3c, 0x33, 0x68}; |
| 894 | struct i2c_msg msg = {.addr=0x08, .flags=0, .buf=data, .len = sizeof(data)}; |
| 895 | |
| 896 | i2c_transfer(&dev->i2c_adap, &msg, 1); |
| 897 | philips_tda827xa_tuner_sleep( 0x61, fe); |
| 898 | /* reset antenna inputs for analog usage */ |
| 899 | saa_clearl(SAA7134_GPIO_GPSTATUS0 >> 2, 0x0200000); |
| 900 | return 0; |
| 901 | } |
| 902 | |
| 903 | /* ------------------------------------------------------------------ */ |
| 904 | |
Andrew de Quincey | a79ddae | 2006-04-18 17:47:11 -0300 | [diff] [blame] | 905 | static int lifeview_trio_tuner_set_params(struct dvb_frontend *fe, struct dvb_frontend_parameters *params) |
Nico Sabbi | 420f32f | 2006-03-03 12:11:28 -0300 | [diff] [blame] | 906 | { |
| 907 | int ret; |
| 908 | |
| 909 | ret = philips_tda827xa_pll_set(0x60, fe, params); |
| 910 | return ret; |
| 911 | } |
| 912 | |
Andrew de Quincey | a79ddae | 2006-04-18 17:47:11 -0300 | [diff] [blame] | 913 | static int lifeview_trio_tuner_sleep(struct dvb_frontend *fe) |
Nico Sabbi | 420f32f | 2006-03-03 12:11:28 -0300 | [diff] [blame] | 914 | { |
Andrew de Quincey | a79ddae | 2006-04-18 17:47:11 -0300 | [diff] [blame] | 915 | philips_tda827xa_tuner_sleep(0x60, fe); |
Nico Sabbi | 420f32f | 2006-03-03 12:11:28 -0300 | [diff] [blame] | 916 | return 0; |
| 917 | } |
| 918 | |
Nico Sabbi | 420f32f | 2006-03-03 12:11:28 -0300 | [diff] [blame] | 919 | static struct tda1004x_config lifeview_trio_config = { |
| 920 | .demod_address = 0x09, |
| 921 | .invert = 1, |
| 922 | .invert_oclk = 0, |
| 923 | .xtal_freq = TDA10046_XTAL_16M, |
| 924 | .agc_config = TDA10046_AGC_TDA827X_GPL, |
| 925 | .if_freq = TDA10046_FREQ_045, |
Nico Sabbi | 420f32f | 2006-03-03 12:11:28 -0300 | [diff] [blame] | 926 | .request_firmware = NULL, |
| 927 | }; |
| 928 | |
| 929 | /* ------------------------------------------------------------------ */ |
| 930 | |
Andrew de Quincey | a79ddae | 2006-04-18 17:47:11 -0300 | [diff] [blame] | 931 | static int ads_duo_tuner_set_params(struct dvb_frontend *fe, struct dvb_frontend_parameters *params) |
Hartmut Hackmann | df42eaf | 2006-02-07 06:49:10 -0200 | [diff] [blame] | 932 | { |
| 933 | int ret; |
| 934 | |
| 935 | ret = philips_tda827xa_pll_set(0x61, fe, params); |
| 936 | return ret; |
Hartmut Hackmann | 2d6b5f6 | 2006-02-27 21:14:36 -0300 | [diff] [blame] | 937 | } |
Hartmut Hackmann | df42eaf | 2006-02-07 06:49:10 -0200 | [diff] [blame] | 938 | |
Andrew de Quincey | a79ddae | 2006-04-18 17:47:11 -0300 | [diff] [blame] | 939 | static int ads_duo_tuner_init(struct dvb_frontend *fe) |
Hartmut Hackmann | df42eaf | 2006-02-07 06:49:10 -0200 | [diff] [blame] | 940 | { |
| 941 | struct saa7134_dev *dev = fe->dvb->priv; |
| 942 | /* route TDA8275a AGC input to the channel decoder */ |
| 943 | saa_writeb(SAA7134_GPIO_GPSTATUS2, 0x60); |
| 944 | return 0; |
| 945 | } |
| 946 | |
Andrew de Quincey | a79ddae | 2006-04-18 17:47:11 -0300 | [diff] [blame] | 947 | static int ads_duo_tuner_sleep(struct dvb_frontend *fe) |
Hartmut Hackmann | df42eaf | 2006-02-07 06:49:10 -0200 | [diff] [blame] | 948 | { |
| 949 | struct saa7134_dev *dev = fe->dvb->priv; |
| 950 | /* route TDA8275a AGC input to the analog IF chip*/ |
| 951 | saa_writeb(SAA7134_GPIO_GPSTATUS2, 0x20); |
Andrew de Quincey | a79ddae | 2006-04-18 17:47:11 -0300 | [diff] [blame] | 952 | philips_tda827xa_tuner_sleep( 0x61, fe); |
| 953 | return 0; |
Hartmut Hackmann | df42eaf | 2006-02-07 06:49:10 -0200 | [diff] [blame] | 954 | } |
| 955 | |
| 956 | static struct tda1004x_config ads_tech_duo_config = { |
| 957 | .demod_address = 0x08, |
| 958 | .invert = 1, |
| 959 | .invert_oclk = 0, |
| 960 | .xtal_freq = TDA10046_XTAL_16M, |
| 961 | .agc_config = TDA10046_AGC_TDA827X_GPL, |
| 962 | .if_freq = TDA10046_FREQ_045, |
Hartmut Hackmann | df42eaf | 2006-02-07 06:49:10 -0200 | [diff] [blame] | 963 | .request_firmware = NULL, |
| 964 | }; |
| 965 | |
Peter Hartshorn | 3dfb729 | 2006-02-07 06:49:13 -0200 | [diff] [blame] | 966 | /* ------------------------------------------------------------------ */ |
| 967 | |
Andrew de Quincey | a79ddae | 2006-04-18 17:47:11 -0300 | [diff] [blame] | 968 | static int tevion_dvb220rf_tuner_set_params(struct dvb_frontend *fe, struct dvb_frontend_parameters *params) |
Peter Hartshorn | 3dfb729 | 2006-02-07 06:49:13 -0200 | [diff] [blame] | 969 | { |
| 970 | int ret; |
| 971 | ret = philips_tda827xa_pll_set(0x60, fe, params); |
| 972 | return ret; |
| 973 | } |
| 974 | |
Andrew de Quincey | a79ddae | 2006-04-18 17:47:11 -0300 | [diff] [blame] | 975 | static int tevion_dvb220rf_tuner_sleep(struct dvb_frontend *fe) |
Peter Hartshorn | 3dfb729 | 2006-02-07 06:49:13 -0200 | [diff] [blame] | 976 | { |
Andrew de Quincey | a79ddae | 2006-04-18 17:47:11 -0300 | [diff] [blame] | 977 | philips_tda827xa_tuner_sleep( 0x61, fe); |
Peter Hartshorn | 3dfb729 | 2006-02-07 06:49:13 -0200 | [diff] [blame] | 978 | return 0; |
| 979 | } |
| 980 | |
Peter Hartshorn | 3dfb729 | 2006-02-07 06:49:13 -0200 | [diff] [blame] | 981 | static struct tda1004x_config tevion_dvbt220rf_config = { |
| 982 | .demod_address = 0x08, |
| 983 | .invert = 1, |
| 984 | .invert_oclk = 0, |
| 985 | .xtal_freq = TDA10046_XTAL_16M, |
| 986 | .agc_config = TDA10046_AGC_TDA827X, |
| 987 | .if_freq = TDA10046_FREQ_045, |
Peter Hartshorn | 3dfb729 | 2006-02-07 06:49:13 -0200 | [diff] [blame] | 988 | .request_firmware = NULL, |
| 989 | }; |
| 990 | |
Hartmut Hackmann | 5eda227 | 2006-08-07 14:03:32 -0300 | [diff] [blame] | 991 | /* ------------------------------------------------------------------ */ |
| 992 | |
| 993 | static int md8800_dvbt_analog_mode(struct dvb_frontend *fe) |
| 994 | { |
| 995 | struct saa7134_dev *dev = fe->dvb->priv; |
| 996 | static u8 data[] = { 0x3c, 0x33, 0x68}; |
| 997 | struct i2c_msg msg = {.addr=0x08, .flags=0, .buf=data, .len = sizeof(data)}; |
| 998 | |
| 999 | i2c_transfer(&dev->i2c_adap, &msg, 1); |
| 1000 | philips_tda827xa_tuner_sleep( 0x61, fe); |
| 1001 | return 0; |
| 1002 | } |
| 1003 | |
| 1004 | static int md8800_dvbt_pll_set(struct dvb_frontend *fe, struct dvb_frontend_parameters *params) |
| 1005 | { |
| 1006 | int ret; |
| 1007 | struct saa7134_dev *dev = fe->dvb->priv; |
| 1008 | static u8 tda8290_close[] = { 0x21, 0xc0}; |
| 1009 | static u8 tda8290_open[] = { 0x21, 0x80}; |
| 1010 | struct i2c_msg tda8290_msg = {.addr = 0x4b,.flags = 0, .len = 2}; |
| 1011 | /* close tda8290 i2c bridge */ |
| 1012 | tda8290_msg.buf = tda8290_close; |
| 1013 | ret = i2c_transfer(&dev->i2c_adap, &tda8290_msg, 1); |
| 1014 | if (ret != 1) |
| 1015 | return -EIO; |
| 1016 | msleep(20); |
| 1017 | ret = philips_tda827xa_pll_set(0x60, fe, params); |
| 1018 | if (ret != 0) |
| 1019 | return ret; |
| 1020 | /* open tda8290 i2c bridge */ |
| 1021 | tda8290_msg.buf = tda8290_open; |
| 1022 | i2c_transfer(&dev->i2c_adap, &tda8290_msg, 1); |
| 1023 | return ret; |
| 1024 | } |
| 1025 | |
| 1026 | static struct tda1004x_config md8800_dvbt_config = { |
| 1027 | .demod_address = 0x08, |
| 1028 | .invert = 1, |
| 1029 | .invert_oclk = 0, |
| 1030 | .xtal_freq = TDA10046_XTAL_16M, |
| 1031 | .agc_config = TDA10046_AGC_TDA827X, |
| 1032 | .if_freq = TDA10046_FREQ_045, |
| 1033 | .request_firmware = NULL, |
| 1034 | }; |
| 1035 | |
Igor M. Liplianin | e2ac28f | 2006-08-08 09:10:10 -0300 | [diff] [blame] | 1036 | static struct tda10086_config flydvbs = { |
| 1037 | .demod_address = 0x0e, |
| 1038 | .invert = 0, |
| 1039 | }; |
| 1040 | |
Hartmut Hackmann | 90e9df7 | 2005-11-08 21:38:42 -0800 | [diff] [blame] | 1041 | /* ------------------------------------------------------------------ */ |
| 1042 | |
Michael Krufky | 3b64e8e | 2005-11-08 21:38:20 -0800 | [diff] [blame] | 1043 | static struct nxt200x_config avertvhda180 = { |
| 1044 | .demod_address = 0x0a, |
Michael Krufky | 3b64e8e | 2005-11-08 21:38:20 -0800 | [diff] [blame] | 1045 | }; |
Andrew Burri | 3e1410a | 2006-02-27 00:08:23 -0300 | [diff] [blame] | 1046 | |
Curt Meyers | fbc81c0 | 2006-02-27 00:08:27 -0300 | [diff] [blame] | 1047 | static int nxt200x_set_pll_input(u8 *buf, int input) |
| 1048 | { |
| 1049 | if (input) |
| 1050 | buf[3] |= 0x08; |
| 1051 | else |
| 1052 | buf[3] &= ~0x08; |
| 1053 | return 0; |
| 1054 | } |
| 1055 | |
Andrew Burri | 3e1410a | 2006-02-27 00:08:23 -0300 | [diff] [blame] | 1056 | static struct nxt200x_config kworldatsc110 = { |
| 1057 | .demod_address = 0x0a, |
Curt Meyers | fbc81c0 | 2006-02-27 00:08:27 -0300 | [diff] [blame] | 1058 | .set_pll_input = nxt200x_set_pll_input, |
Andrew Burri | 3e1410a | 2006-02-27 00:08:23 -0300 | [diff] [blame] | 1059 | }; |
Michael Krufky | 3b64e8e | 2005-11-08 21:38:20 -0800 | [diff] [blame] | 1060 | |
Mauro Carvalho Chehab | 86ddd96 | 2005-07-12 13:58:47 -0700 | [diff] [blame] | 1061 | /* ------------------------------------------------------------------ */ |
| 1062 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1063 | static int dvb_init(struct saa7134_dev *dev) |
| 1064 | { |
| 1065 | /* init struct videobuf_dvb */ |
| 1066 | dev->ts.nr_bufs = 32; |
| 1067 | dev->ts.nr_packets = 32*4; |
| 1068 | dev->dvb.name = dev->name; |
| 1069 | videobuf_queue_init(&dev->dvb.dvbq, &saa7134_ts_qops, |
| 1070 | dev->pci, &dev->slock, |
| 1071 | V4L2_BUF_TYPE_VIDEO_CAPTURE, |
| 1072 | V4L2_FIELD_ALTERNATE, |
| 1073 | sizeof(struct saa7134_buf), |
| 1074 | dev); |
| 1075 | |
| 1076 | switch (dev->board) { |
| 1077 | case SAA7134_BOARD_PINNACLE_300I_DVBT_PAL: |
| 1078 | printk("%s: pinnacle 300i dvb setup\n",dev->name); |
Andrew de Quincey | 2bfe031 | 2006-08-08 09:10:08 -0300 | [diff] [blame] | 1079 | dev->dvb.frontend = dvb_attach(mt352_attach, &pinnacle_300i, |
Michael Krufky | f7b54b1 | 2006-08-08 15:48:08 -0300 | [diff] [blame] | 1080 | &dev->i2c_adap); |
Andrew de Quincey | 6b3ccab | 2006-04-20 12:01:47 -0300 | [diff] [blame] | 1081 | if (dev->dvb.frontend) { |
Patrick Boettcher | dea7486 | 2006-05-14 05:01:31 -0300 | [diff] [blame] | 1082 | 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] | 1083 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1084 | break; |
Jose Alberto Reguero | a78d0bf | 2006-02-07 06:25:14 -0200 | [diff] [blame] | 1085 | case SAA7134_BOARD_AVERMEDIA_777: |
Petr Baudis | 515c208 | 2006-09-26 16:53:53 -0300 | [diff] [blame] | 1086 | case SAA7134_BOARD_AVERMEDIA_A16AR: |
Jose Alberto Reguero | a78d0bf | 2006-02-07 06:25:14 -0200 | [diff] [blame] | 1087 | printk("%s: avertv 777 dvb setup\n",dev->name); |
Andrew de Quincey | 2bfe031 | 2006-08-08 09:10:08 -0300 | [diff] [blame] | 1088 | dev->dvb.frontend = dvb_attach(mt352_attach, &avermedia_777, |
Michael Krufky | f7b54b1 | 2006-08-08 15:48:08 -0300 | [diff] [blame] | 1089 | &dev->i2c_adap); |
Andrew de Quincey | 6b3ccab | 2006-04-20 12:01:47 -0300 | [diff] [blame] | 1090 | if (dev->dvb.frontend) { |
Patrick Boettcher | dea7486 | 2006-05-14 05:01:31 -0300 | [diff] [blame] | 1091 | 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] | 1092 | } |
Jose Alberto Reguero | a78d0bf | 2006-02-07 06:25:14 -0200 | [diff] [blame] | 1093 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1094 | case SAA7134_BOARD_MD7134: |
Michael Krufky | f7b54b1 | 2006-08-08 15:48:08 -0300 | [diff] [blame] | 1095 | dev->dvb.frontend = dvb_attach(tda10046_attach, |
| 1096 | &medion_cardbus, |
| 1097 | &dev->i2c_adap); |
Andrew de Quincey | 6b3ccab | 2006-04-20 12:01:47 -0300 | [diff] [blame] | 1098 | if (dev->dvb.frontend) { |
Patrick Boettcher | dea7486 | 2006-05-14 05:01:31 -0300 | [diff] [blame] | 1099 | dev->dvb.frontend->ops.tuner_ops.init = philips_fmd1216_tuner_init; |
| 1100 | dev->dvb.frontend->ops.tuner_ops.sleep = philips_fmd1216_tuner_sleep; |
| 1101 | 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] | 1102 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1103 | break; |
Mauro Carvalho Chehab | 86ddd96 | 2005-07-12 13:58:47 -0700 | [diff] [blame] | 1104 | case SAA7134_BOARD_PHILIPS_TOUGH: |
Michael Krufky | f7b54b1 | 2006-08-08 15:48:08 -0300 | [diff] [blame] | 1105 | dev->dvb.frontend = dvb_attach(tda10046_attach, |
| 1106 | &philips_tu1216_60_config, |
| 1107 | &dev->i2c_adap); |
Andrew de Quincey | 6b3ccab | 2006-04-20 12:01:47 -0300 | [diff] [blame] | 1108 | if (dev->dvb.frontend) { |
Patrick Boettcher | dea7486 | 2006-05-14 05:01:31 -0300 | [diff] [blame] | 1109 | dev->dvb.frontend->ops.tuner_ops.init = philips_tu1216_tuner_60_init; |
| 1110 | dev->dvb.frontend->ops.tuner_ops.set_params = philips_tu1216_tuner_60_set_params; |
Andrew de Quincey | 6b3ccab | 2006-04-20 12:01:47 -0300 | [diff] [blame] | 1111 | } |
Mauro Carvalho Chehab | 86ddd96 | 2005-07-12 13:58:47 -0700 | [diff] [blame] | 1112 | break; |
| 1113 | case SAA7134_BOARD_FLYDVBTDUO: |
Michael Krufky | f7b54b1 | 2006-08-08 15:48:08 -0300 | [diff] [blame] | 1114 | dev->dvb.frontend = dvb_attach(tda10046_attach, |
| 1115 | &tda827x_lifeview_config, |
| 1116 | &dev->i2c_adap); |
Andrew de Quincey | 6b3ccab | 2006-04-20 12:01:47 -0300 | [diff] [blame] | 1117 | if (dev->dvb.frontend) { |
Patrick Boettcher | dea7486 | 2006-05-14 05:01:31 -0300 | [diff] [blame] | 1118 | dev->dvb.frontend->ops.tuner_ops.init = philips_tda827x_tuner_init; |
| 1119 | dev->dvb.frontend->ops.tuner_ops.sleep = philips_tda827x_tuner_sleep; |
| 1120 | dev->dvb.frontend->ops.tuner_ops.set_params = philips_tda827x_tuner_set_params; |
Andrew de Quincey | 6b3ccab | 2006-04-20 12:01:47 -0300 | [diff] [blame] | 1121 | } |
Mauro Carvalho Chehab | 86ddd96 | 2005-07-12 13:58:47 -0700 | [diff] [blame] | 1122 | break; |
Peter Missel | 10b7a90 | 2006-01-23 17:11:06 -0200 | [diff] [blame] | 1123 | case SAA7134_BOARD_FLYDVBT_DUO_CARDBUS: |
Michael Krufky | f7b54b1 | 2006-08-08 15:48:08 -0300 | [diff] [blame] | 1124 | dev->dvb.frontend = dvb_attach(tda10046_attach, |
| 1125 | &tda827x_lifeview_config, |
| 1126 | &dev->i2c_adap); |
Andrew de Quincey | 6b3ccab | 2006-04-20 12:01:47 -0300 | [diff] [blame] | 1127 | if (dev->dvb.frontend) { |
Patrick Boettcher | dea7486 | 2006-05-14 05:01:31 -0300 | [diff] [blame] | 1128 | dev->dvb.frontend->ops.tuner_ops.init = philips_tda827x_tuner_init; |
| 1129 | dev->dvb.frontend->ops.tuner_ops.sleep = philips_tda827x_tuner_sleep; |
| 1130 | dev->dvb.frontend->ops.tuner_ops.set_params = philips_tda827x_tuner_set_params; |
Andrew de Quincey | 6b3ccab | 2006-04-20 12:01:47 -0300 | [diff] [blame] | 1131 | } |
Mauro Carvalho Chehab | 86ddd96 | 2005-07-12 13:58:47 -0700 | [diff] [blame] | 1132 | break; |
Hartmut Hackmann | 2cf36ac | 2005-11-08 21:36:32 -0800 | [diff] [blame] | 1133 | case SAA7134_BOARD_PHILIPS_EUROPA: |
Michael Krufky | f7b54b1 | 2006-08-08 15:48:08 -0300 | [diff] [blame] | 1134 | dev->dvb.frontend = dvb_attach(tda10046_attach, |
| 1135 | &philips_europa_config, |
| 1136 | &dev->i2c_adap); |
Andrew de Quincey | 6b3ccab | 2006-04-20 12:01:47 -0300 | [diff] [blame] | 1137 | if (dev->dvb.frontend) { |
Patrick Boettcher | dea7486 | 2006-05-14 05:01:31 -0300 | [diff] [blame] | 1138 | dev->original_demod_sleep = dev->dvb.frontend->ops.sleep; |
| 1139 | dev->dvb.frontend->ops.sleep = philips_europa_demod_sleep; |
| 1140 | dev->dvb.frontend->ops.tuner_ops.init = philips_europa_tuner_init; |
| 1141 | dev->dvb.frontend->ops.tuner_ops.sleep = philips_europa_tuner_sleep; |
| 1142 | 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] | 1143 | } |
Hartmut Hackmann | 2cf36ac | 2005-11-08 21:36:32 -0800 | [diff] [blame] | 1144 | break; |
| 1145 | case SAA7134_BOARD_VIDEOMATE_DVBT_300: |
Michael Krufky | f7b54b1 | 2006-08-08 15:48:08 -0300 | [diff] [blame] | 1146 | dev->dvb.frontend = dvb_attach(tda10046_attach, |
| 1147 | &philips_europa_config, |
| 1148 | &dev->i2c_adap); |
Andrew de Quincey | 6b3ccab | 2006-04-20 12:01:47 -0300 | [diff] [blame] | 1149 | if (dev->dvb.frontend) { |
Patrick Boettcher | dea7486 | 2006-05-14 05:01:31 -0300 | [diff] [blame] | 1150 | dev->dvb.frontend->ops.tuner_ops.init = philips_europa_tuner_init; |
| 1151 | dev->dvb.frontend->ops.tuner_ops.sleep = philips_europa_tuner_sleep; |
| 1152 | 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] | 1153 | } |
Hartmut Hackmann | 2cf36ac | 2005-11-08 21:36:32 -0800 | [diff] [blame] | 1154 | break; |
| 1155 | case SAA7134_BOARD_VIDEOMATE_DVBT_200: |
Michael Krufky | f7b54b1 | 2006-08-08 15:48:08 -0300 | [diff] [blame] | 1156 | dev->dvb.frontend = dvb_attach(tda10046_attach, |
| 1157 | &philips_tu1216_61_config, |
| 1158 | &dev->i2c_adap); |
Andrew de Quincey | 6b3ccab | 2006-04-20 12:01:47 -0300 | [diff] [blame] | 1159 | if (dev->dvb.frontend) { |
Patrick Boettcher | dea7486 | 2006-05-14 05:01:31 -0300 | [diff] [blame] | 1160 | dev->dvb.frontend->ops.tuner_ops.init = philips_tu1216_tuner_61_init; |
| 1161 | dev->dvb.frontend->ops.tuner_ops.set_params = philips_tu1216_tuner_61_set_params; |
Andrew de Quincey | 6b3ccab | 2006-04-20 12:01:47 -0300 | [diff] [blame] | 1162 | } |
Hartmut Hackmann | 2cf36ac | 2005-11-08 21:36:32 -0800 | [diff] [blame] | 1163 | break; |
Hartmut Hackmann | 90e9df7 | 2005-11-08 21:38:42 -0800 | [diff] [blame] | 1164 | case SAA7134_BOARD_PHILIPS_TIGER: |
Michael Krufky | f7b54b1 | 2006-08-08 15:48:08 -0300 | [diff] [blame] | 1165 | dev->dvb.frontend = dvb_attach(tda10046_attach, |
| 1166 | &philips_tiger_config, |
| 1167 | &dev->i2c_adap); |
Andrew de Quincey | 6b3ccab | 2006-04-20 12:01:47 -0300 | [diff] [blame] | 1168 | if (dev->dvb.frontend) { |
Patrick Boettcher | dea7486 | 2006-05-14 05:01:31 -0300 | [diff] [blame] | 1169 | dev->dvb.frontend->ops.tuner_ops.init = philips_tiger_tuner_init; |
| 1170 | dev->dvb.frontend->ops.tuner_ops.sleep = philips_tiger_tuner_sleep; |
| 1171 | dev->dvb.frontend->ops.tuner_ops.set_params = philips_tiger_tuner_set_params; |
Andrew de Quincey | 6b3ccab | 2006-04-20 12:01:47 -0300 | [diff] [blame] | 1172 | } |
Hartmut Hackmann | 90e9df7 | 2005-11-08 21:38:42 -0800 | [diff] [blame] | 1173 | break; |
Hartmut Hackmann | d4b0aba | 2005-11-08 21:38:44 -0800 | [diff] [blame] | 1174 | case SAA7134_BOARD_ASUSTeK_P7131_DUAL: |
Michael Krufky | f7b54b1 | 2006-08-08 15:48:08 -0300 | [diff] [blame] | 1175 | dev->dvb.frontend = dvb_attach(tda10046_attach, |
| 1176 | &philips_tiger_config, |
| 1177 | &dev->i2c_adap); |
Andrew de Quincey | 6b3ccab | 2006-04-20 12:01:47 -0300 | [diff] [blame] | 1178 | if (dev->dvb.frontend) { |
Hermann Pitton | 6b14ff9 | 2006-10-02 20:18:26 -0300 | [diff] [blame] | 1179 | dev->dvb.frontend->ops.tuner_ops.init = asus_p7131_dual_tuner_init; |
| 1180 | dev->dvb.frontend->ops.tuner_ops.sleep = asus_p7131_dual_tuner_sleep; |
Patrick Boettcher | dea7486 | 2006-05-14 05:01:31 -0300 | [diff] [blame] | 1181 | dev->dvb.frontend->ops.tuner_ops.set_params = philips_tiger_tuner_set_params; |
Andrew de Quincey | 6b3ccab | 2006-04-20 12:01:47 -0300 | [diff] [blame] | 1182 | } |
Hartmut Hackmann | d4b0aba | 2005-11-08 21:38:44 -0800 | [diff] [blame] | 1183 | break; |
Giampiero Giancipoli | 3d8466e | 2006-02-07 06:49:09 -0200 | [diff] [blame] | 1184 | case SAA7134_BOARD_FLYDVBT_LR301: |
Michael Krufky | f7b54b1 | 2006-08-08 15:48:08 -0300 | [diff] [blame] | 1185 | dev->dvb.frontend = dvb_attach(tda10046_attach, |
| 1186 | &tda827x_lifeview_config, |
| 1187 | &dev->i2c_adap); |
Andrew de Quincey | 6b3ccab | 2006-04-20 12:01:47 -0300 | [diff] [blame] | 1188 | if (dev->dvb.frontend) { |
Patrick Boettcher | dea7486 | 2006-05-14 05:01:31 -0300 | [diff] [blame] | 1189 | dev->dvb.frontend->ops.tuner_ops.init = philips_tda827x_tuner_init; |
| 1190 | dev->dvb.frontend->ops.tuner_ops.sleep = philips_tda827x_tuner_sleep; |
| 1191 | dev->dvb.frontend->ops.tuner_ops.set_params = philips_tda827x_tuner_set_params; |
Andrew de Quincey | 6b3ccab | 2006-04-20 12:01:47 -0300 | [diff] [blame] | 1192 | } |
Giampiero Giancipoli | 3d8466e | 2006-02-07 06:49:09 -0200 | [diff] [blame] | 1193 | break; |
Nico Sabbi | 420f32f | 2006-03-03 12:11:28 -0300 | [diff] [blame] | 1194 | case SAA7134_BOARD_FLYDVB_TRIO: |
Michael Krufky | f7b54b1 | 2006-08-08 15:48:08 -0300 | [diff] [blame] | 1195 | dev->dvb.frontend = dvb_attach(tda10046_attach, |
| 1196 | &lifeview_trio_config, |
| 1197 | &dev->i2c_adap); |
Andrew de Quincey | 6b3ccab | 2006-04-20 12:01:47 -0300 | [diff] [blame] | 1198 | if (dev->dvb.frontend) { |
Patrick Boettcher | dea7486 | 2006-05-14 05:01:31 -0300 | [diff] [blame] | 1199 | dev->dvb.frontend->ops.tuner_ops.sleep = lifeview_trio_tuner_sleep; |
| 1200 | dev->dvb.frontend->ops.tuner_ops.set_params = lifeview_trio_tuner_set_params; |
Andrew de Quincey | 6b3ccab | 2006-04-20 12:01:47 -0300 | [diff] [blame] | 1201 | } |
Nico Sabbi | 420f32f | 2006-03-03 12:11:28 -0300 | [diff] [blame] | 1202 | break; |
Hartmut Hackmann | df42eaf | 2006-02-07 06:49:10 -0200 | [diff] [blame] | 1203 | case SAA7134_BOARD_ADS_DUO_CARDBUS_PTV331: |
Michael Krufky | f7b54b1 | 2006-08-08 15:48:08 -0300 | [diff] [blame] | 1204 | dev->dvb.frontend = dvb_attach(tda10046_attach, |
| 1205 | &ads_tech_duo_config, |
| 1206 | &dev->i2c_adap); |
Andrew de Quincey | 6b3ccab | 2006-04-20 12:01:47 -0300 | [diff] [blame] | 1207 | if (dev->dvb.frontend) { |
Patrick Boettcher | dea7486 | 2006-05-14 05:01:31 -0300 | [diff] [blame] | 1208 | dev->dvb.frontend->ops.tuner_ops.init = ads_duo_tuner_init; |
| 1209 | dev->dvb.frontend->ops.tuner_ops.sleep = ads_duo_tuner_sleep; |
| 1210 | dev->dvb.frontend->ops.tuner_ops.set_params = ads_duo_tuner_set_params; |
Andrew de Quincey | 6b3ccab | 2006-04-20 12:01:47 -0300 | [diff] [blame] | 1211 | } |
Hartmut Hackmann | df42eaf | 2006-02-07 06:49:10 -0200 | [diff] [blame] | 1212 | break; |
Peter Hartshorn | 3dfb729 | 2006-02-07 06:49:13 -0200 | [diff] [blame] | 1213 | case SAA7134_BOARD_TEVION_DVBT_220RF: |
Michael Krufky | f7b54b1 | 2006-08-08 15:48:08 -0300 | [diff] [blame] | 1214 | dev->dvb.frontend = dvb_attach(tda10046_attach, |
| 1215 | &tevion_dvbt220rf_config, |
| 1216 | &dev->i2c_adap); |
Andrew de Quincey | 6b3ccab | 2006-04-20 12:01:47 -0300 | [diff] [blame] | 1217 | if (dev->dvb.frontend) { |
Patrick Boettcher | dea7486 | 2006-05-14 05:01:31 -0300 | [diff] [blame] | 1218 | dev->dvb.frontend->ops.tuner_ops.sleep = tevion_dvb220rf_tuner_sleep; |
| 1219 | dev->dvb.frontend->ops.tuner_ops.set_params = tevion_dvb220rf_tuner_set_params; |
Andrew de Quincey | 6b3ccab | 2006-04-20 12:01:47 -0300 | [diff] [blame] | 1220 | } |
Peter Hartshorn | 3dfb729 | 2006-02-07 06:49:13 -0200 | [diff] [blame] | 1221 | break; |
Hartmut Hackmann | d95b894 | 2006-03-27 19:39:30 -0300 | [diff] [blame] | 1222 | case SAA7134_BOARD_FLYDVBT_HYBRID_CARDBUS: |
Michael Krufky | f7b54b1 | 2006-08-08 15:48:08 -0300 | [diff] [blame] | 1223 | dev->dvb.frontend = dvb_attach(tda10046_attach, |
| 1224 | &ads_tech_duo_config, |
| 1225 | &dev->i2c_adap); |
Andrew de Quincey | 6b3ccab | 2006-04-20 12:01:47 -0300 | [diff] [blame] | 1226 | if (dev->dvb.frontend) { |
Patrick Boettcher | dea7486 | 2006-05-14 05:01:31 -0300 | [diff] [blame] | 1227 | dev->dvb.frontend->ops.tuner_ops.init = ads_duo_tuner_init; |
| 1228 | dev->dvb.frontend->ops.tuner_ops.sleep = ads_duo_tuner_sleep; |
| 1229 | dev->dvb.frontend->ops.tuner_ops.set_params = ads_duo_tuner_set_params; |
Andrew de Quincey | 6b3ccab | 2006-04-20 12:01:47 -0300 | [diff] [blame] | 1230 | } |
Hartmut Hackmann | d95b894 | 2006-03-27 19:39:30 -0300 | [diff] [blame] | 1231 | break; |
Hartmut Hackmann | 5eda227 | 2006-08-07 14:03:32 -0300 | [diff] [blame] | 1232 | case SAA7134_BOARD_MEDION_MD8800_QUADRO: |
| 1233 | dev->dvb.frontend = tda10046_attach(&md8800_dvbt_config, |
| 1234 | &dev->i2c_adap); |
| 1235 | if (dev->dvb.frontend) { |
| 1236 | dev->dvb.frontend->ops.tuner_ops.init = philips_tiger_tuner_init; |
| 1237 | dev->dvb.frontend->ops.tuner_ops.sleep = md8800_dvbt_analog_mode; |
| 1238 | dev->dvb.frontend->ops.tuner_ops.set_params = md8800_dvbt_pll_set; |
| 1239 | } |
| 1240 | break; |
Michael Krufky | 3b64e8e | 2005-11-08 21:38:20 -0800 | [diff] [blame] | 1241 | case SAA7134_BOARD_AVERMEDIA_AVERTVHD_A180: |
Michael Krufky | f7b54b1 | 2006-08-08 15:48:08 -0300 | [diff] [blame] | 1242 | dev->dvb.frontend = dvb_attach(nxt200x_attach, &avertvhda180, |
| 1243 | &dev->i2c_adap); |
Andrew de Quincey | a79ddae | 2006-04-18 17:47:11 -0300 | [diff] [blame] | 1244 | if (dev->dvb.frontend) { |
Michael Krufky | 4ad8eee5 | 2006-08-08 15:48:08 -0300 | [diff] [blame] | 1245 | dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x61, |
| 1246 | NULL, &dvb_pll_tdhu2); |
Andrew de Quincey | a79ddae | 2006-04-18 17:47:11 -0300 | [diff] [blame] | 1247 | } |
Michael Krufky | 3b64e8e | 2005-11-08 21:38:20 -0800 | [diff] [blame] | 1248 | break; |
Andrew Burri | 3e1410a | 2006-02-27 00:08:23 -0300 | [diff] [blame] | 1249 | case SAA7134_BOARD_KWORLD_ATSC110: |
Michael Krufky | f7b54b1 | 2006-08-08 15:48:08 -0300 | [diff] [blame] | 1250 | dev->dvb.frontend = dvb_attach(nxt200x_attach, &kworldatsc110, |
| 1251 | &dev->i2c_adap); |
Andrew de Quincey | a79ddae | 2006-04-18 17:47:11 -0300 | [diff] [blame] | 1252 | if (dev->dvb.frontend) { |
Michael Krufky | 4ad8eee5 | 2006-08-08 15:48:08 -0300 | [diff] [blame] | 1253 | dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x61, |
| 1254 | NULL, &dvb_pll_tuv1236d); |
Andrew de Quincey | a79ddae | 2006-04-18 17:47:11 -0300 | [diff] [blame] | 1255 | } |
Andrew Burri | 3e1410a | 2006-02-27 00:08:23 -0300 | [diff] [blame] | 1256 | break; |
Igor M. Liplianin | e2ac28f | 2006-08-08 09:10:10 -0300 | [diff] [blame] | 1257 | case SAA7134_BOARD_FLYDVBS_LR300: |
Michael Krufky | f7b54b1 | 2006-08-08 15:48:08 -0300 | [diff] [blame] | 1258 | dev->dvb.frontend = dvb_attach(tda10086_attach, &flydvbs, |
| 1259 | &dev->i2c_adap); |
Igor M. Liplianin | e2ac28f | 2006-08-08 09:10:10 -0300 | [diff] [blame] | 1260 | if (dev->dvb.frontend) { |
Michael Krufky | f7b54b1 | 2006-08-08 15:48:08 -0300 | [diff] [blame] | 1261 | if (dvb_attach(tda826x_attach, dev->dvb.frontend, 0x60, |
| 1262 | &dev->i2c_adap, 0) == NULL) { |
Igor M. Liplianin | e2ac28f | 2006-08-08 09:10:10 -0300 | [diff] [blame] | 1263 | printk("%s: No tda826x found!\n", __FUNCTION__); |
| 1264 | } |
Michael Krufky | f7b54b1 | 2006-08-08 15:48:08 -0300 | [diff] [blame] | 1265 | if (dvb_attach(isl6421_attach, dev->dvb.frontend, |
| 1266 | &dev->i2c_adap, 0x08, 0, 0) == NULL) { |
Igor M. Liplianin | e2ac28f | 2006-08-08 09:10:10 -0300 | [diff] [blame] | 1267 | printk("%s: No ISL6421 found!\n", __FUNCTION__); |
| 1268 | } |
| 1269 | } |
| 1270 | break; |
Hartmut Hackmann | cf146ca | 2006-10-02 20:49:24 -0300 | [diff] [blame^] | 1271 | case SAA7134_BOARD_ASUS_EUROPA2_HYBRID: |
| 1272 | dev->dvb.frontend = tda10046_attach(&medion_cardbus, |
| 1273 | &dev->i2c_adap); |
| 1274 | if (dev->dvb.frontend) { |
| 1275 | dev->original_demod_sleep = dev->dvb.frontend->ops.sleep; |
| 1276 | dev->dvb.frontend->ops.sleep = philips_europa_demod_sleep; |
| 1277 | dev->dvb.frontend->ops.tuner_ops.init = philips_fmd1216_tuner_init; |
| 1278 | dev->dvb.frontend->ops.tuner_ops.sleep = philips_fmd1216_tuner_sleep; |
| 1279 | dev->dvb.frontend->ops.tuner_ops.set_params = philips_fmd1216_tuner_set_params; |
| 1280 | } |
| 1281 | break; |
| 1282 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1283 | default: |
| 1284 | printk("%s: Huh? unknown DVB card?\n",dev->name); |
| 1285 | break; |
| 1286 | } |
| 1287 | |
| 1288 | if (NULL == dev->dvb.frontend) { |
| 1289 | printk("%s: frontend initialization failed\n",dev->name); |
| 1290 | return -1; |
| 1291 | } |
| 1292 | |
| 1293 | /* register everything else */ |
Andrew de Quincey | d09dbf9 | 2006-04-10 09:27:37 -0300 | [diff] [blame] | 1294 | return videobuf_dvb_register(&dev->dvb, THIS_MODULE, dev, &dev->pci->dev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1295 | } |
| 1296 | |
| 1297 | static int dvb_fini(struct saa7134_dev *dev) |
| 1298 | { |
| 1299 | static int on = TDA9887_PRESENT | TDA9887_PORT2_INACTIVE; |
| 1300 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1301 | switch (dev->board) { |
| 1302 | case SAA7134_BOARD_PINNACLE_300I_DVBT_PAL: |
| 1303 | /* otherwise we don't detect the tuner on next insmod */ |
| 1304 | saa7134_i2c_call_clients(dev,TDA9887_SET_CONFIG,&on); |
| 1305 | break; |
| 1306 | }; |
| 1307 | videobuf_dvb_unregister(&dev->dvb); |
| 1308 | return 0; |
| 1309 | } |
| 1310 | |
| 1311 | static struct saa7134_mpeg_ops dvb_ops = { |
| 1312 | .type = SAA7134_MPEG_DVB, |
| 1313 | .init = dvb_init, |
| 1314 | .fini = dvb_fini, |
| 1315 | }; |
| 1316 | |
| 1317 | static int __init dvb_register(void) |
| 1318 | { |
| 1319 | return saa7134_ts_register(&dvb_ops); |
| 1320 | } |
| 1321 | |
| 1322 | static void __exit dvb_unregister(void) |
| 1323 | { |
| 1324 | saa7134_ts_unregister(&dvb_ops); |
| 1325 | } |
| 1326 | |
| 1327 | module_init(dvb_register); |
| 1328 | module_exit(dvb_unregister); |
| 1329 | |
| 1330 | /* ------------------------------------------------------------------ */ |
| 1331 | /* |
| 1332 | * Local variables: |
| 1333 | * c-basic-offset: 8 |
| 1334 | * End: |
| 1335 | */ |