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