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 | * device driver for Conexant 2388x based TV cards |
| 4 | * MPEG Transport Stream (DVB) routines |
| 5 | * |
Chris Pascoe | fc40b26 | 2006-01-09 15:25:35 -0200 | [diff] [blame] | 6 | * (c) 2004, 2005 Chris Pascoe <c.pascoe@itee.uq.edu.au> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7 | * (c) 2004 Gerd Knorr <kraxel@bytesex.org> [SuSE Labs] |
| 8 | * |
| 9 | * This program is free software; you can redistribute it and/or modify |
| 10 | * it under the terms of the GNU General Public License as published by |
| 11 | * the Free Software Foundation; either version 2 of the License, or |
| 12 | * (at your option) any later version. |
| 13 | * |
| 14 | * This program is distributed in the hope that it will be useful, |
| 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 17 | * GNU General Public License for more details. |
| 18 | * |
| 19 | * You should have received a copy of the GNU General Public License |
| 20 | * along with this program; if not, write to the Free Software |
| 21 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
| 22 | */ |
| 23 | |
| 24 | #include <linux/module.h> |
| 25 | #include <linux/init.h> |
| 26 | #include <linux/device.h> |
| 27 | #include <linux/fs.h> |
| 28 | #include <linux/kthread.h> |
| 29 | #include <linux/file.h> |
| 30 | #include <linux/suspend.h> |
| 31 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 32 | #include "cx88.h" |
| 33 | #include "dvb-pll.h" |
Michael Krufky | 5e453dc | 2006-01-09 15:32:31 -0200 | [diff] [blame] | 34 | #include <media/v4l2-common.h> |
Mauro Carvalho Chehab | 41ef7c1 | 2005-07-12 13:58:44 -0700 | [diff] [blame] | 35 | |
Andrew de Quincey | 1f10c7a | 2006-08-08 09:10:09 -0300 | [diff] [blame] | 36 | #include "mt352.h" |
| 37 | #include "mt352_priv.h" |
| 38 | #ifdef HAVE_VP3054_I2C |
| 39 | # include "cx88-vp3054-i2c.h" |
Mauro Carvalho Chehab | 41ef7c1 | 2005-07-12 13:58:44 -0700 | [diff] [blame] | 40 | #endif |
Andrew de Quincey | 1f10c7a | 2006-08-08 09:10:09 -0300 | [diff] [blame] | 41 | #include "zl10353.h" |
| 42 | #include "cx22702.h" |
| 43 | #include "or51132.h" |
| 44 | #include "lgdt330x.h" |
| 45 | #include "lg_h06xf.h" |
| 46 | #include "nxt200x.h" |
| 47 | #include "cx24123.h" |
Andrew de Quincey | cd20ca9 | 2006-05-12 20:31:51 -0300 | [diff] [blame] | 48 | #include "isl6421.h" |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 49 | |
| 50 | MODULE_DESCRIPTION("driver for cx2388x based DVB cards"); |
| 51 | MODULE_AUTHOR("Chris Pascoe <c.pascoe@itee.uq.edu.au>"); |
| 52 | MODULE_AUTHOR("Gerd Knorr <kraxel@bytesex.org> [SuSE Labs]"); |
| 53 | MODULE_LICENSE("GPL"); |
| 54 | |
| 55 | static unsigned int debug = 0; |
| 56 | module_param(debug, int, 0644); |
| 57 | MODULE_PARM_DESC(debug,"enable debug messages [dvb]"); |
| 58 | |
| 59 | #define dprintk(level,fmt, arg...) if (debug >= level) \ |
| 60 | printk(KERN_DEBUG "%s/2-dvb: " fmt, dev->core->name , ## arg) |
| 61 | |
| 62 | /* ------------------------------------------------------------------ */ |
| 63 | |
| 64 | static int dvb_buf_setup(struct videobuf_queue *q, |
| 65 | unsigned int *count, unsigned int *size) |
| 66 | { |
| 67 | struct cx8802_dev *dev = q->priv_data; |
| 68 | |
| 69 | dev->ts_packet_size = 188 * 4; |
| 70 | dev->ts_packet_count = 32; |
| 71 | |
| 72 | *size = dev->ts_packet_size * dev->ts_packet_count; |
| 73 | *count = 32; |
| 74 | return 0; |
| 75 | } |
| 76 | |
| 77 | static int dvb_buf_prepare(struct videobuf_queue *q, struct videobuf_buffer *vb, |
| 78 | enum v4l2_field field) |
| 79 | { |
| 80 | struct cx8802_dev *dev = q->priv_data; |
Mauro Carvalho Chehab | c7b0ac0 | 2006-03-10 12:29:15 -0300 | [diff] [blame] | 81 | return cx8802_buf_prepare(q, dev, (struct cx88_buffer*)vb,field); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 82 | } |
| 83 | |
| 84 | static void dvb_buf_queue(struct videobuf_queue *q, struct videobuf_buffer *vb) |
| 85 | { |
| 86 | struct cx8802_dev *dev = q->priv_data; |
| 87 | cx8802_buf_queue(dev, (struct cx88_buffer*)vb); |
| 88 | } |
| 89 | |
| 90 | static void dvb_buf_release(struct videobuf_queue *q, struct videobuf_buffer *vb) |
| 91 | { |
Mauro Carvalho Chehab | c7b0ac0 | 2006-03-10 12:29:15 -0300 | [diff] [blame] | 92 | cx88_free_buffer(q, (struct cx88_buffer*)vb); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 93 | } |
| 94 | |
Adrian Bunk | 408b664 | 2005-05-01 08:59:29 -0700 | [diff] [blame] | 95 | static struct videobuf_queue_ops dvb_qops = { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 96 | .buf_setup = dvb_buf_setup, |
| 97 | .buf_prepare = dvb_buf_prepare, |
| 98 | .buf_queue = dvb_buf_queue, |
| 99 | .buf_release = dvb_buf_release, |
| 100 | }; |
| 101 | |
| 102 | /* ------------------------------------------------------------------ */ |
Chris Pascoe | 3d7d027 | 2006-01-09 18:21:31 -0200 | [diff] [blame] | 103 | static int dvico_fusionhdtv_demod_init(struct dvb_frontend* fe) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 104 | { |
| 105 | static u8 clock_config [] = { CLOCK_CTL, 0x38, 0x39 }; |
| 106 | static u8 reset [] = { RESET, 0x80 }; |
| 107 | static u8 adc_ctl_1_cfg [] = { ADC_CTL_1, 0x40 }; |
| 108 | static u8 agc_cfg [] = { AGC_TARGET, 0x24, 0x20 }; |
| 109 | static u8 gpp_ctl_cfg [] = { GPP_CTL, 0x33 }; |
| 110 | static u8 capt_range_cfg[] = { CAPT_RANGE, 0x32 }; |
| 111 | |
| 112 | mt352_write(fe, clock_config, sizeof(clock_config)); |
| 113 | udelay(200); |
| 114 | mt352_write(fe, reset, sizeof(reset)); |
| 115 | mt352_write(fe, adc_ctl_1_cfg, sizeof(adc_ctl_1_cfg)); |
| 116 | |
| 117 | mt352_write(fe, agc_cfg, sizeof(agc_cfg)); |
| 118 | mt352_write(fe, gpp_ctl_cfg, sizeof(gpp_ctl_cfg)); |
| 119 | mt352_write(fe, capt_range_cfg, sizeof(capt_range_cfg)); |
| 120 | return 0; |
| 121 | } |
| 122 | |
Chris Pascoe | 43eabb4 | 2006-01-09 18:21:28 -0200 | [diff] [blame] | 123 | static int dvico_dual_demod_init(struct dvb_frontend *fe) |
| 124 | { |
| 125 | static u8 clock_config [] = { CLOCK_CTL, 0x38, 0x38 }; |
| 126 | static u8 reset [] = { RESET, 0x80 }; |
| 127 | static u8 adc_ctl_1_cfg [] = { ADC_CTL_1, 0x40 }; |
| 128 | static u8 agc_cfg [] = { AGC_TARGET, 0x28, 0x20 }; |
| 129 | static u8 gpp_ctl_cfg [] = { GPP_CTL, 0x33 }; |
| 130 | static u8 capt_range_cfg[] = { CAPT_RANGE, 0x32 }; |
| 131 | |
| 132 | mt352_write(fe, clock_config, sizeof(clock_config)); |
| 133 | udelay(200); |
| 134 | mt352_write(fe, reset, sizeof(reset)); |
| 135 | mt352_write(fe, adc_ctl_1_cfg, sizeof(adc_ctl_1_cfg)); |
| 136 | |
| 137 | mt352_write(fe, agc_cfg, sizeof(agc_cfg)); |
| 138 | mt352_write(fe, gpp_ctl_cfg, sizeof(gpp_ctl_cfg)); |
| 139 | mt352_write(fe, capt_range_cfg, sizeof(capt_range_cfg)); |
| 140 | |
| 141 | return 0; |
| 142 | } |
| 143 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 144 | static int dntv_live_dvbt_demod_init(struct dvb_frontend* fe) |
| 145 | { |
| 146 | static u8 clock_config [] = { 0x89, 0x38, 0x39 }; |
| 147 | static u8 reset [] = { 0x50, 0x80 }; |
| 148 | static u8 adc_ctl_1_cfg [] = { 0x8E, 0x40 }; |
| 149 | static u8 agc_cfg [] = { 0x67, 0x10, 0x23, 0x00, 0xFF, 0xFF, |
Mauro Carvalho Chehab | f2421ca | 2005-11-08 21:37:45 -0800 | [diff] [blame] | 150 | 0x00, 0xFF, 0x00, 0x40, 0x40 }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 151 | static u8 dntv_extra[] = { 0xB5, 0x7A }; |
| 152 | static u8 capt_range_cfg[] = { 0x75, 0x32 }; |
| 153 | |
| 154 | mt352_write(fe, clock_config, sizeof(clock_config)); |
| 155 | udelay(2000); |
| 156 | mt352_write(fe, reset, sizeof(reset)); |
| 157 | mt352_write(fe, adc_ctl_1_cfg, sizeof(adc_ctl_1_cfg)); |
| 158 | |
| 159 | mt352_write(fe, agc_cfg, sizeof(agc_cfg)); |
| 160 | udelay(2000); |
| 161 | mt352_write(fe, dntv_extra, sizeof(dntv_extra)); |
| 162 | mt352_write(fe, capt_range_cfg, sizeof(capt_range_cfg)); |
| 163 | |
| 164 | return 0; |
| 165 | } |
| 166 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 167 | static struct mt352_config dvico_fusionhdtv = { |
| 168 | .demod_address = 0x0F, |
Chris Pascoe | 3d7d027 | 2006-01-09 18:21:31 -0200 | [diff] [blame] | 169 | .demod_init = dvico_fusionhdtv_demod_init, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 170 | }; |
| 171 | |
| 172 | static struct mt352_config dntv_live_dvbt_config = { |
| 173 | .demod_address = 0x0f, |
| 174 | .demod_init = dntv_live_dvbt_demod_init, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 175 | }; |
Chris Pascoe | fc40b26 | 2006-01-09 15:25:35 -0200 | [diff] [blame] | 176 | |
Chris Pascoe | 43eabb4 | 2006-01-09 18:21:28 -0200 | [diff] [blame] | 177 | static struct mt352_config dvico_fusionhdtv_dual = { |
| 178 | .demod_address = 0x0F, |
| 179 | .demod_init = dvico_dual_demod_init, |
Chris Pascoe | 43eabb4 | 2006-01-09 18:21:28 -0200 | [diff] [blame] | 180 | }; |
| 181 | |
Chris Pascoe | fc40b26 | 2006-01-09 15:25:35 -0200 | [diff] [blame] | 182 | #ifdef HAVE_VP3054_I2C |
Chris Pascoe | 3d7d027 | 2006-01-09 18:21:31 -0200 | [diff] [blame] | 183 | static int dntv_live_dvbt_pro_demod_init(struct dvb_frontend* fe) |
| 184 | { |
| 185 | static u8 clock_config [] = { 0x89, 0x38, 0x38 }; |
| 186 | static u8 reset [] = { 0x50, 0x80 }; |
| 187 | static u8 adc_ctl_1_cfg [] = { 0x8E, 0x40 }; |
| 188 | static u8 agc_cfg [] = { 0x67, 0x10, 0x20, 0x00, 0xFF, 0xFF, |
| 189 | 0x00, 0xFF, 0x00, 0x40, 0x40 }; |
| 190 | static u8 dntv_extra[] = { 0xB5, 0x7A }; |
| 191 | static u8 capt_range_cfg[] = { 0x75, 0x32 }; |
| 192 | |
| 193 | mt352_write(fe, clock_config, sizeof(clock_config)); |
| 194 | udelay(2000); |
| 195 | mt352_write(fe, reset, sizeof(reset)); |
| 196 | mt352_write(fe, adc_ctl_1_cfg, sizeof(adc_ctl_1_cfg)); |
| 197 | |
| 198 | mt352_write(fe, agc_cfg, sizeof(agc_cfg)); |
| 199 | udelay(2000); |
| 200 | mt352_write(fe, dntv_extra, sizeof(dntv_extra)); |
| 201 | mt352_write(fe, capt_range_cfg, sizeof(capt_range_cfg)); |
| 202 | |
| 203 | return 0; |
| 204 | } |
| 205 | |
Chris Pascoe | fc40b26 | 2006-01-09 15:25:35 -0200 | [diff] [blame] | 206 | static int philips_fmd1216_pll_init(struct dvb_frontend *fe) |
| 207 | { |
| 208 | struct cx8802_dev *dev= fe->dvb->priv; |
| 209 | |
| 210 | /* this message is to set up ATC and ALC */ |
| 211 | static u8 fmd1216_init[] = { 0x0b, 0xdc, 0x9c, 0xa0 }; |
| 212 | struct i2c_msg msg = |
| 213 | { .addr = dev->core->pll_addr, .flags = 0, |
| 214 | .buf = fmd1216_init, .len = sizeof(fmd1216_init) }; |
| 215 | int err; |
| 216 | |
Patrick Boettcher | dea7486 | 2006-05-14 05:01:31 -0300 | [diff] [blame] | 217 | if (fe->ops.i2c_gate_ctrl) |
| 218 | fe->ops.i2c_gate_ctrl(fe, 1); |
Chris Pascoe | fc40b26 | 2006-01-09 15:25:35 -0200 | [diff] [blame] | 219 | if ((err = i2c_transfer(&dev->core->i2c_adap, &msg, 1)) != 1) { |
| 220 | if (err < 0) |
| 221 | return err; |
| 222 | else |
| 223 | return -EREMOTEIO; |
| 224 | } |
| 225 | |
| 226 | return 0; |
| 227 | } |
| 228 | |
Andrew de Quincey | f54376e | 2006-04-18 17:56:10 -0300 | [diff] [blame] | 229 | static int dntv_live_dvbt_pro_tuner_set_params(struct dvb_frontend* fe, |
| 230 | struct dvb_frontend_parameters* params) |
Chris Pascoe | fc40b26 | 2006-01-09 15:25:35 -0200 | [diff] [blame] | 231 | { |
| 232 | struct cx8802_dev *dev= fe->dvb->priv; |
Andrew de Quincey | f54376e | 2006-04-18 17:56:10 -0300 | [diff] [blame] | 233 | u8 buf[4]; |
Chris Pascoe | fc40b26 | 2006-01-09 15:25:35 -0200 | [diff] [blame] | 234 | struct i2c_msg msg = |
| 235 | { .addr = dev->core->pll_addr, .flags = 0, |
Andrew de Quincey | f54376e | 2006-04-18 17:56:10 -0300 | [diff] [blame] | 236 | .buf = buf, .len = 4 }; |
Chris Pascoe | fc40b26 | 2006-01-09 15:25:35 -0200 | [diff] [blame] | 237 | int err; |
| 238 | |
| 239 | /* Switch PLL to DVB mode */ |
| 240 | err = philips_fmd1216_pll_init(fe); |
| 241 | if (err) |
| 242 | return err; |
| 243 | |
| 244 | /* Tune PLL */ |
Andrew de Quincey | f54376e | 2006-04-18 17:56:10 -0300 | [diff] [blame] | 245 | dvb_pll_configure(dev->core->pll_desc, buf, |
Chris Pascoe | fc40b26 | 2006-01-09 15:25:35 -0200 | [diff] [blame] | 246 | params->frequency, |
| 247 | params->u.ofdm.bandwidth); |
Patrick Boettcher | dea7486 | 2006-05-14 05:01:31 -0300 | [diff] [blame] | 248 | if (fe->ops.i2c_gate_ctrl) |
| 249 | fe->ops.i2c_gate_ctrl(fe, 1); |
Chris Pascoe | fc40b26 | 2006-01-09 15:25:35 -0200 | [diff] [blame] | 250 | if ((err = i2c_transfer(&dev->core->i2c_adap, &msg, 1)) != 1) { |
Andrew de Quincey | f54376e | 2006-04-18 17:56:10 -0300 | [diff] [blame] | 251 | |
Chris Pascoe | fc40b26 | 2006-01-09 15:25:35 -0200 | [diff] [blame] | 252 | printk(KERN_WARNING "cx88-dvb: %s error " |
| 253 | "(addr %02x <- %02x, err = %i)\n", |
Andrew de Quincey | f54376e | 2006-04-18 17:56:10 -0300 | [diff] [blame] | 254 | __FUNCTION__, dev->core->pll_addr, buf[0], err); |
Chris Pascoe | fc40b26 | 2006-01-09 15:25:35 -0200 | [diff] [blame] | 255 | if (err < 0) |
| 256 | return err; |
| 257 | else |
| 258 | return -EREMOTEIO; |
| 259 | } |
| 260 | |
| 261 | return 0; |
| 262 | } |
| 263 | |
| 264 | static struct mt352_config dntv_live_dvbt_pro_config = { |
| 265 | .demod_address = 0x0f, |
| 266 | .no_tuner = 1, |
Chris Pascoe | 3d7d027 | 2006-01-09 18:21:31 -0200 | [diff] [blame] | 267 | .demod_init = dntv_live_dvbt_pro_demod_init, |
Chris Pascoe | fc40b26 | 2006-01-09 15:25:35 -0200 | [diff] [blame] | 268 | }; |
| 269 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 270 | |
Andrew de Quincey | f54376e | 2006-04-18 17:56:10 -0300 | [diff] [blame] | 271 | static int dvico_hybrid_tuner_set_params(struct dvb_frontend *fe, |
| 272 | struct dvb_frontend_parameters *params) |
Chris Pascoe | 780dfef | 2006-02-28 08:34:59 -0300 | [diff] [blame] | 273 | { |
Andrew de Quincey | f54376e | 2006-04-18 17:56:10 -0300 | [diff] [blame] | 274 | u8 pllbuf[4]; |
Chris Pascoe | 780dfef | 2006-02-28 08:34:59 -0300 | [diff] [blame] | 275 | struct cx8802_dev *dev= fe->dvb->priv; |
| 276 | struct i2c_msg msg = |
| 277 | { .addr = dev->core->pll_addr, .flags = 0, |
Andrew de Quincey | f54376e | 2006-04-18 17:56:10 -0300 | [diff] [blame] | 278 | .buf = pllbuf, .len = 4 }; |
Chris Pascoe | 780dfef | 2006-02-28 08:34:59 -0300 | [diff] [blame] | 279 | int err; |
| 280 | |
Andrew de Quincey | f54376e | 2006-04-18 17:56:10 -0300 | [diff] [blame] | 281 | dvb_pll_configure(dev->core->pll_desc, pllbuf, |
Chris Pascoe | 780dfef | 2006-02-28 08:34:59 -0300 | [diff] [blame] | 282 | params->frequency, |
| 283 | params->u.ofdm.bandwidth); |
| 284 | |
Patrick Boettcher | dea7486 | 2006-05-14 05:01:31 -0300 | [diff] [blame] | 285 | if (fe->ops.i2c_gate_ctrl) |
| 286 | fe->ops.i2c_gate_ctrl(fe, 1); |
Chris Pascoe | 780dfef | 2006-02-28 08:34:59 -0300 | [diff] [blame] | 287 | if ((err = i2c_transfer(&dev->core->i2c_adap, &msg, 1)) != 1) { |
| 288 | printk(KERN_WARNING "cx88-dvb: %s error " |
| 289 | "(addr %02x <- %02x, err = %i)\n", |
| 290 | __FUNCTION__, pllbuf[0], pllbuf[1], err); |
| 291 | if (err < 0) |
| 292 | return err; |
| 293 | else |
| 294 | return -EREMOTEIO; |
| 295 | } |
| 296 | |
| 297 | return 0; |
| 298 | } |
| 299 | |
| 300 | static struct zl10353_config dvico_fusionhdtv_hybrid = { |
| 301 | .demod_address = 0x0F, |
Andrew de Quincey | f54376e | 2006-04-18 17:56:10 -0300 | [diff] [blame] | 302 | .no_tuner = 1, |
Chris Pascoe | 780dfef | 2006-02-28 08:34:59 -0300 | [diff] [blame] | 303 | }; |
| 304 | |
| 305 | static struct zl10353_config dvico_fusionhdtv_plus_v1_1 = { |
| 306 | .demod_address = 0x0F, |
Chris Pascoe | 780dfef | 2006-02-28 08:34:59 -0300 | [diff] [blame] | 307 | }; |
Chris Pascoe | 780dfef | 2006-02-28 08:34:59 -0300 | [diff] [blame] | 308 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 309 | static struct cx22702_config connexant_refboard_config = { |
| 310 | .demod_address = 0x43, |
Patrick Boettcher | 38d84c3 | 2005-07-15 12:20:26 -0700 | [diff] [blame] | 311 | .output_mode = CX22702_SERIAL_OUTPUT, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 312 | }; |
| 313 | |
| 314 | static struct cx22702_config hauppauge_novat_config = { |
| 315 | .demod_address = 0x43, |
Patrick Boettcher | 38d84c3 | 2005-07-15 12:20:26 -0700 | [diff] [blame] | 316 | .output_mode = CX22702_SERIAL_OUTPUT, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 317 | }; |
Steven Toth | 611900c | 2006-01-09 15:25:12 -0200 | [diff] [blame] | 318 | static struct cx22702_config hauppauge_hvr1100_config = { |
| 319 | .demod_address = 0x63, |
| 320 | .output_mode = CX22702_SERIAL_OUTPUT, |
Steven Toth | 611900c | 2006-01-09 15:25:12 -0200 | [diff] [blame] | 321 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 322 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 323 | static int or51132_set_ts_param(struct dvb_frontend* fe, |
| 324 | int is_punctured) |
| 325 | { |
| 326 | struct cx8802_dev *dev= fe->dvb->priv; |
| 327 | dev->ts_gen_cntrl = is_punctured ? 0x04 : 0x00; |
| 328 | return 0; |
| 329 | } |
| 330 | |
Adrian Bunk | 408b664 | 2005-05-01 08:59:29 -0700 | [diff] [blame] | 331 | static struct or51132_config pchdtv_hd3000 = { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 332 | .demod_address = 0x15, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 333 | .set_ts_params = or51132_set_ts_param, |
| 334 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 335 | |
Andrew de Quincey | f54376e | 2006-04-18 17:56:10 -0300 | [diff] [blame] | 336 | static int lgdt3302_tuner_set_params(struct dvb_frontend* fe, |
Trent Piepho | 657de3c | 2006-06-20 00:30:57 -0300 | [diff] [blame] | 337 | struct dvb_frontend_parameters* params) |
Michael Krufky | b6aef07 | 2005-07-27 11:45:54 -0700 | [diff] [blame] | 338 | { |
Mauro Carvalho Chehab | e52e98a | 2005-09-09 13:03:41 -0700 | [diff] [blame] | 339 | /* FIXME make this routine use the tuner-simple code. |
| 340 | * It could probably be shared with a number of ATSC |
| 341 | * frontends. Many share the same tuner with analog TV. */ |
| 342 | |
Michael Krufky | b6aef07 | 2005-07-27 11:45:54 -0700 | [diff] [blame] | 343 | struct cx8802_dev *dev= fe->dvb->priv; |
Mauro Carvalho Chehab | e52e98a | 2005-09-09 13:03:41 -0700 | [diff] [blame] | 344 | struct cx88_core *core = dev->core; |
Michael Krufky | 1963c90 | 2005-08-08 09:22:43 -0700 | [diff] [blame] | 345 | u8 buf[4]; |
| 346 | struct i2c_msg msg = |
| 347 | { .addr = dev->core->pll_addr, .flags = 0, .buf = buf, .len = 4 }; |
| 348 | int err; |
Michael Krufky | b6aef07 | 2005-07-27 11:45:54 -0700 | [diff] [blame] | 349 | |
Mauro Carvalho Chehab | e52e98a | 2005-09-09 13:03:41 -0700 | [diff] [blame] | 350 | dvb_pll_configure(core->pll_desc, buf, params->frequency, 0); |
Michael Krufky | 1963c90 | 2005-08-08 09:22:43 -0700 | [diff] [blame] | 351 | dprintk(1, "%s: tuner at 0x%02x bytes: 0x%02x 0x%02x 0x%02x 0x%02x\n", |
| 352 | __FUNCTION__, msg.addr, buf[0],buf[1],buf[2],buf[3]); |
Andrew de Quincey | f54376e | 2006-04-18 17:56:10 -0300 | [diff] [blame] | 353 | |
Patrick Boettcher | dea7486 | 2006-05-14 05:01:31 -0300 | [diff] [blame] | 354 | if (fe->ops.i2c_gate_ctrl) |
| 355 | fe->ops.i2c_gate_ctrl(fe, 1); |
Mauro Carvalho Chehab | e52e98a | 2005-09-09 13:03:41 -0700 | [diff] [blame] | 356 | if ((err = i2c_transfer(&core->i2c_adap, &msg, 1)) != 1) { |
Michael Krufky | 1963c90 | 2005-08-08 09:22:43 -0700 | [diff] [blame] | 357 | printk(KERN_WARNING "cx88-dvb: %s error " |
| 358 | "(addr %02x <- %02x, err = %i)\n", |
| 359 | __FUNCTION__, buf[0], buf[1], err); |
| 360 | if (err < 0) |
| 361 | return err; |
| 362 | else |
| 363 | return -EREMOTEIO; |
| 364 | } |
Michael Krufky | b6aef07 | 2005-07-27 11:45:54 -0700 | [diff] [blame] | 365 | return 0; |
| 366 | } |
| 367 | |
Andrew de Quincey | f54376e | 2006-04-18 17:56:10 -0300 | [diff] [blame] | 368 | static int lgdt3303_tuner_set_params(struct dvb_frontend* fe, |
| 369 | struct dvb_frontend_parameters* params) |
Michael Krufky | 7e55774 | 2006-04-18 17:47:08 -0300 | [diff] [blame] | 370 | { |
| 371 | struct cx8802_dev *dev= fe->dvb->priv; |
| 372 | struct cx88_core *core = dev->core; |
| 373 | |
| 374 | /* Put the analog decoder in standby to keep it quiet */ |
| 375 | cx88_call_i2c_clients (dev->core, TUNER_SET_STANDBY, NULL); |
| 376 | |
| 377 | return lg_h06xf_pll_set(fe, &core->i2c_adap, params); |
| 378 | } |
| 379 | |
Michael Krufky | 6ddcc91 | 2005-07-27 11:46:00 -0700 | [diff] [blame] | 380 | static int lgdt330x_pll_rf_set(struct dvb_frontend* fe, int index) |
Michael Krufky | 0ccef6d | 2005-07-27 11:45:55 -0700 | [diff] [blame] | 381 | { |
| 382 | struct cx8802_dev *dev= fe->dvb->priv; |
| 383 | struct cx88_core *core = dev->core; |
| 384 | |
| 385 | dprintk(1, "%s: index = %d\n", __FUNCTION__, index); |
| 386 | if (index == 0) |
| 387 | cx_clear(MO_GP0_IO, 8); |
| 388 | else |
| 389 | cx_set(MO_GP0_IO, 8); |
| 390 | return 0; |
| 391 | } |
| 392 | |
Michael Krufky | 6ddcc91 | 2005-07-27 11:46:00 -0700 | [diff] [blame] | 393 | static int lgdt330x_set_ts_param(struct dvb_frontend* fe, int is_punctured) |
Michael Krufky | f179849 | 2005-07-07 17:58:39 -0700 | [diff] [blame] | 394 | { |
| 395 | struct cx8802_dev *dev= fe->dvb->priv; |
| 396 | if (is_punctured) |
| 397 | dev->ts_gen_cntrl |= 0x04; |
| 398 | else |
| 399 | dev->ts_gen_cntrl &= ~0x04; |
| 400 | return 0; |
| 401 | } |
| 402 | |
Michael Krufky | 6ddcc91 | 2005-07-27 11:46:00 -0700 | [diff] [blame] | 403 | static struct lgdt330x_config fusionhdtv_3_gold = { |
Michael Krufky | f179849 | 2005-07-07 17:58:39 -0700 | [diff] [blame] | 404 | .demod_address = 0x0e, |
Michael Krufky | 1963c90 | 2005-08-08 09:22:43 -0700 | [diff] [blame] | 405 | .demod_chip = LGDT3302, |
| 406 | .serial_mpeg = 0x04, /* TPSERIAL for 3302 in TOP_CONTROL */ |
Michael Krufky | 6ddcc91 | 2005-07-27 11:46:00 -0700 | [diff] [blame] | 407 | .set_ts_params = lgdt330x_set_ts_param, |
Michael Krufky | 0d723c0 | 2005-07-07 17:58:42 -0700 | [diff] [blame] | 408 | }; |
Mauro Carvalho Chehab | e52e98a | 2005-09-09 13:03:41 -0700 | [diff] [blame] | 409 | |
| 410 | static struct lgdt330x_config fusionhdtv_5_gold = { |
| 411 | .demod_address = 0x0e, |
| 412 | .demod_chip = LGDT3303, |
| 413 | .serial_mpeg = 0x40, /* TPSERIAL for 3303 in TOP_CONTROL */ |
Mauro Carvalho Chehab | e52e98a | 2005-09-09 13:03:41 -0700 | [diff] [blame] | 414 | .set_ts_params = lgdt330x_set_ts_param, |
| 415 | }; |
Rusty Scott | da215d2 | 2006-04-07 02:21:31 -0300 | [diff] [blame] | 416 | |
| 417 | static struct lgdt330x_config pchdtv_hd5500 = { |
| 418 | .demod_address = 0x59, |
| 419 | .demod_chip = LGDT3303, |
| 420 | .serial_mpeg = 0x40, /* TPSERIAL for 3303 in TOP_CONTROL */ |
Rusty Scott | da215d2 | 2006-04-07 02:21:31 -0300 | [diff] [blame] | 421 | .set_ts_params = lgdt330x_set_ts_param, |
| 422 | }; |
Michael Krufky | f179849 | 2005-07-07 17:58:39 -0700 | [diff] [blame] | 423 | |
Kirk Lapray | fde6d31 | 2005-11-08 21:38:18 -0800 | [diff] [blame] | 424 | static int nxt200x_set_ts_param(struct dvb_frontend* fe, |
| 425 | int is_punctured) |
| 426 | { |
| 427 | struct cx8802_dev *dev= fe->dvb->priv; |
| 428 | dev->ts_gen_cntrl = is_punctured ? 0x04 : 0x00; |
| 429 | return 0; |
| 430 | } |
| 431 | |
Kirk Lapray | d4c34aa | 2005-11-08 21:38:40 -0800 | [diff] [blame] | 432 | static int nxt200x_set_pll_input(u8* buf, int input) |
| 433 | { |
| 434 | if (input) |
| 435 | buf[3] |= 0x08; |
| 436 | else |
| 437 | buf[3] &= ~0x08; |
| 438 | return 0; |
| 439 | } |
| 440 | |
Kirk Lapray | fde6d31 | 2005-11-08 21:38:18 -0800 | [diff] [blame] | 441 | static struct nxt200x_config ati_hdtvwonder = { |
| 442 | .demod_address = 0x0a, |
Kirk Lapray | d4c34aa | 2005-11-08 21:38:40 -0800 | [diff] [blame] | 443 | .set_pll_input = nxt200x_set_pll_input, |
Kirk Lapray | fde6d31 | 2005-11-08 21:38:18 -0800 | [diff] [blame] | 444 | .set_ts_params = nxt200x_set_ts_param, |
| 445 | }; |
Kirk Lapray | fde6d31 | 2005-11-08 21:38:18 -0800 | [diff] [blame] | 446 | |
Steven Toth | 0fa14aa | 2006-01-09 15:25:02 -0200 | [diff] [blame] | 447 | static int cx24123_set_ts_param(struct dvb_frontend* fe, |
| 448 | int is_punctured) |
| 449 | { |
| 450 | struct cx8802_dev *dev= fe->dvb->priv; |
| 451 | dev->ts_gen_cntrl = 0x2; |
| 452 | return 0; |
| 453 | } |
| 454 | |
Andrew de Quincey | cd20ca9 | 2006-05-12 20:31:51 -0300 | [diff] [blame] | 455 | static int kworld_dvbs_100_set_voltage(struct dvb_frontend* fe, fe_sec_voltage_t voltage) |
Vadim Catana | 0e0351e | 2006-01-09 15:25:02 -0200 | [diff] [blame] | 456 | { |
| 457 | struct cx8802_dev *dev= fe->dvb->priv; |
| 458 | struct cx88_core *core = dev->core; |
| 459 | |
Andrew de Quincey | cd20ca9 | 2006-05-12 20:31:51 -0300 | [diff] [blame] | 460 | if (voltage == SEC_VOLTAGE_OFF) { |
Vadim Catana | 0e0351e | 2006-01-09 15:25:02 -0200 | [diff] [blame] | 461 | cx_write(MO_GP0_IO, 0x000006fB); |
Andrew de Quincey | cd20ca9 | 2006-05-12 20:31:51 -0300 | [diff] [blame] | 462 | } else { |
| 463 | cx_write(MO_GP0_IO, 0x000006f9); |
| 464 | } |
| 465 | |
| 466 | if (core->prev_set_voltage) |
| 467 | return core->prev_set_voltage(fe, voltage); |
| 468 | return 0; |
Vadim Catana | 0e0351e | 2006-01-09 15:25:02 -0200 | [diff] [blame] | 469 | } |
| 470 | |
Saqeb Akhter | c02a34f | 2006-06-29 20:29:33 -0300 | [diff] [blame] | 471 | static int geniatech_dvbs_set_voltage(struct dvb_frontend *fe, fe_sec_voltage_t voltage) |
| 472 | { |
| 473 | struct cx8802_dev *dev= fe->dvb->priv; |
| 474 | struct cx88_core *core = dev->core; |
| 475 | |
| 476 | if (voltage == SEC_VOLTAGE_OFF) { |
| 477 | dprintk(1,"LNB Voltage OFF\n"); |
| 478 | cx_write(MO_GP0_IO, 0x0000efff); |
| 479 | } |
| 480 | |
| 481 | if (core->prev_set_voltage) |
| 482 | return core->prev_set_voltage(fe, voltage); |
| 483 | return 0; |
| 484 | } |
| 485 | |
| 486 | static struct cx24123_config geniatech_dvbs_config = { |
| 487 | .demod_address = 0x55, |
| 488 | .set_ts_params = cx24123_set_ts_param, |
| 489 | }; |
| 490 | |
Steven Toth | 0fa14aa | 2006-01-09 15:25:02 -0200 | [diff] [blame] | 491 | static struct cx24123_config hauppauge_novas_config = { |
Vadim Catana | 0e0351e | 2006-01-09 15:25:02 -0200 | [diff] [blame] | 492 | .demod_address = 0x55, |
Vadim Catana | 0e0351e | 2006-01-09 15:25:02 -0200 | [diff] [blame] | 493 | .set_ts_params = cx24123_set_ts_param, |
| 494 | }; |
| 495 | |
| 496 | static struct cx24123_config kworld_dvbs_100_config = { |
| 497 | .demod_address = 0x15, |
Vadim Catana | 0e0351e | 2006-01-09 15:25:02 -0200 | [diff] [blame] | 498 | .set_ts_params = cx24123_set_ts_param, |
Steven Toth | 0fa14aa | 2006-01-09 15:25:02 -0200 | [diff] [blame] | 499 | }; |
Steven Toth | 0fa14aa | 2006-01-09 15:25:02 -0200 | [diff] [blame] | 500 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 501 | static int dvb_register(struct cx8802_dev *dev) |
| 502 | { |
| 503 | /* init struct videobuf_dvb */ |
| 504 | dev->dvb.name = dev->core->name; |
| 505 | dev->ts_gen_cntrl = 0x0c; |
| 506 | |
| 507 | /* init frontend */ |
| 508 | switch (dev->core->board) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 509 | case CX88_BOARD_HAUPPAUGE_DVB_T1: |
Andrew de Quincey | 2bfe031 | 2006-08-08 09:10:08 -0300 | [diff] [blame] | 510 | dev->dvb.frontend = dvb_attach(cx22702_attach, &hauppauge_novat_config, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 511 | &dev->core->i2c_adap); |
Andrew de Quincey | f54376e | 2006-04-18 17:56:10 -0300 | [diff] [blame] | 512 | if (dev->dvb.frontend != NULL) { |
Andrew de Quincey | 2bfe031 | 2006-08-08 09:10:08 -0300 | [diff] [blame] | 513 | dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x61, |
Michael Krufky | 0f10291 | 2006-06-12 14:18:26 -0300 | [diff] [blame] | 514 | &dev->core->i2c_adap, |
| 515 | &dvb_pll_thomson_dtt759x); |
Andrew de Quincey | f54376e | 2006-04-18 17:56:10 -0300 | [diff] [blame] | 516 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 517 | break; |
Michael Krufky | e057ee1 | 2005-07-07 17:58:40 -0700 | [diff] [blame] | 518 | case CX88_BOARD_TERRATEC_CINERGY_1400_DVB_T1: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 519 | case CX88_BOARD_CONEXANT_DVB_T1: |
Manenti Marco | f39624f | 2006-01-09 15:32:45 -0200 | [diff] [blame] | 520 | case CX88_BOARD_KWORLD_DVB_T_CX22702: |
David Shirley | 2b5200a | 2005-11-08 21:37:22 -0800 | [diff] [blame] | 521 | case CX88_BOARD_WINFAST_DTV1000: |
Andrew de Quincey | 2bfe031 | 2006-08-08 09:10:08 -0300 | [diff] [blame] | 522 | dev->dvb.frontend = dvb_attach(cx22702_attach, &connexant_refboard_config, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 523 | &dev->core->i2c_adap); |
Andrew de Quincey | f54376e | 2006-04-18 17:56:10 -0300 | [diff] [blame] | 524 | if (dev->dvb.frontend != NULL) { |
Andrew de Quincey | 2bfe031 | 2006-08-08 09:10:08 -0300 | [diff] [blame] | 525 | dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x60, |
Michael Krufky | 0f10291 | 2006-06-12 14:18:26 -0300 | [diff] [blame] | 526 | &dev->core->i2c_adap, |
| 527 | &dvb_pll_thomson_dtt7579); |
Andrew de Quincey | f54376e | 2006-04-18 17:56:10 -0300 | [diff] [blame] | 528 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 529 | break; |
Malcolm Valentine | 4bd6e9d | 2006-05-29 13:51:59 -0300 | [diff] [blame] | 530 | case CX88_BOARD_WINFAST_DTV2000H: |
Steven Toth | 611900c | 2006-01-09 15:25:12 -0200 | [diff] [blame] | 531 | case CX88_BOARD_HAUPPAUGE_HVR1100: |
| 532 | case CX88_BOARD_HAUPPAUGE_HVR1100LP: |
Andrew de Quincey | 2bfe031 | 2006-08-08 09:10:08 -0300 | [diff] [blame] | 533 | dev->dvb.frontend = dvb_attach(cx22702_attach, &hauppauge_hvr1100_config, |
Steven Toth | 611900c | 2006-01-09 15:25:12 -0200 | [diff] [blame] | 534 | &dev->core->i2c_adap); |
Andrew de Quincey | f54376e | 2006-04-18 17:56:10 -0300 | [diff] [blame] | 535 | if (dev->dvb.frontend != NULL) { |
Andrew de Quincey | 2bfe031 | 2006-08-08 09:10:08 -0300 | [diff] [blame] | 536 | dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x61, |
Michael Krufky | 0f10291 | 2006-06-12 14:18:26 -0300 | [diff] [blame] | 537 | &dev->core->i2c_adap, |
| 538 | &dvb_pll_fmd1216me); |
Andrew de Quincey | f54376e | 2006-04-18 17:56:10 -0300 | [diff] [blame] | 539 | } |
Steven Toth | 611900c | 2006-01-09 15:25:12 -0200 | [diff] [blame] | 540 | break; |
Chris Pascoe | 780dfef | 2006-02-28 08:34:59 -0300 | [diff] [blame] | 541 | case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_PLUS: |
Andrew de Quincey | 2bfe031 | 2006-08-08 09:10:08 -0300 | [diff] [blame] | 542 | dev->dvb.frontend = dvb_attach(mt352_attach, &dvico_fusionhdtv, |
Chris Pascoe | 780dfef | 2006-02-28 08:34:59 -0300 | [diff] [blame] | 543 | &dev->core->i2c_adap); |
Andrew de Quincey | f54376e | 2006-04-18 17:56:10 -0300 | [diff] [blame] | 544 | if (dev->dvb.frontend != NULL) { |
Andrew de Quincey | 2bfe031 | 2006-08-08 09:10:08 -0300 | [diff] [blame] | 545 | dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x60, |
Chris Pascoe | c162dff | 2006-08-08 15:48:08 -0300 | [diff] [blame^] | 546 | NULL, &dvb_pll_thomson_dtt7579); |
Chris Pascoe | 780dfef | 2006-02-28 08:34:59 -0300 | [diff] [blame] | 547 | break; |
Andrew de Quincey | f54376e | 2006-04-18 17:56:10 -0300 | [diff] [blame] | 548 | } |
Chris Pascoe | 780dfef | 2006-02-28 08:34:59 -0300 | [diff] [blame] | 549 | /* ZL10353 replaces MT352 on later cards */ |
Andrew de Quincey | 2bfe031 | 2006-08-08 09:10:08 -0300 | [diff] [blame] | 550 | dev->dvb.frontend = dvb_attach(zl10353_attach, &dvico_fusionhdtv_plus_v1_1, |
Chris Pascoe | 780dfef | 2006-02-28 08:34:59 -0300 | [diff] [blame] | 551 | &dev->core->i2c_adap); |
Andrew de Quincey | f54376e | 2006-04-18 17:56:10 -0300 | [diff] [blame] | 552 | if (dev->dvb.frontend != NULL) { |
Andrew de Quincey | 2bfe031 | 2006-08-08 09:10:08 -0300 | [diff] [blame] | 553 | dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x60, |
Chris Pascoe | c162dff | 2006-08-08 15:48:08 -0300 | [diff] [blame^] | 554 | NULL, &dvb_pll_thomson_dtt7579); |
Andrew de Quincey | f54376e | 2006-04-18 17:56:10 -0300 | [diff] [blame] | 555 | } |
Chris Pascoe | 780dfef | 2006-02-28 08:34:59 -0300 | [diff] [blame] | 556 | break; |
Michael Krufky | c2af3cd | 2006-06-12 14:06:22 -0300 | [diff] [blame] | 557 | case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_DUAL: |
Michael Krufky | c2af3cd | 2006-06-12 14:06:22 -0300 | [diff] [blame] | 558 | /* The tin box says DEE1601, but it seems to be DTT7579 |
| 559 | * compatible, with a slightly different MT352 AGC gain. */ |
Andrew de Quincey | 2bfe031 | 2006-08-08 09:10:08 -0300 | [diff] [blame] | 560 | dev->dvb.frontend = dvb_attach(mt352_attach, &dvico_fusionhdtv_dual, |
Michael Krufky | c2af3cd | 2006-06-12 14:06:22 -0300 | [diff] [blame] | 561 | &dev->core->i2c_adap); |
| 562 | if (dev->dvb.frontend != NULL) { |
Andrew de Quincey | 2bfe031 | 2006-08-08 09:10:08 -0300 | [diff] [blame] | 563 | dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x61, |
Chris Pascoe | c162dff | 2006-08-08 15:48:08 -0300 | [diff] [blame^] | 564 | NULL, &dvb_pll_thomson_dtt7579); |
Michael Krufky | c2af3cd | 2006-06-12 14:06:22 -0300 | [diff] [blame] | 565 | break; |
| 566 | } |
Michael Krufky | c2af3cd | 2006-06-12 14:06:22 -0300 | [diff] [blame] | 567 | /* ZL10353 replaces MT352 on later cards */ |
Andrew de Quincey | 2bfe031 | 2006-08-08 09:10:08 -0300 | [diff] [blame] | 568 | dev->dvb.frontend = dvb_attach(zl10353_attach, &dvico_fusionhdtv_plus_v1_1, |
Michael Krufky | c2af3cd | 2006-06-12 14:06:22 -0300 | [diff] [blame] | 569 | &dev->core->i2c_adap); |
| 570 | if (dev->dvb.frontend != NULL) { |
Andrew de Quincey | 2bfe031 | 2006-08-08 09:10:08 -0300 | [diff] [blame] | 571 | dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x61, |
Chris Pascoe | c162dff | 2006-08-08 15:48:08 -0300 | [diff] [blame^] | 572 | NULL, &dvb_pll_thomson_dtt7579); |
Michael Krufky | c2af3cd | 2006-06-12 14:06:22 -0300 | [diff] [blame] | 573 | } |
Michael Krufky | c2af3cd | 2006-06-12 14:06:22 -0300 | [diff] [blame] | 574 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 575 | case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T1: |
Andrew de Quincey | 2bfe031 | 2006-08-08 09:10:08 -0300 | [diff] [blame] | 576 | dev->dvb.frontend = dvb_attach(mt352_attach, &dvico_fusionhdtv, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 577 | &dev->core->i2c_adap); |
Andrew de Quincey | f54376e | 2006-04-18 17:56:10 -0300 | [diff] [blame] | 578 | if (dev->dvb.frontend != NULL) { |
Andrew de Quincey | 2bfe031 | 2006-08-08 09:10:08 -0300 | [diff] [blame] | 579 | dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x61, |
Chris Pascoe | c162dff | 2006-08-08 15:48:08 -0300 | [diff] [blame^] | 580 | NULL, &dvb_pll_lg_z201); |
Andrew de Quincey | f54376e | 2006-04-18 17:56:10 -0300 | [diff] [blame] | 581 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 582 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 583 | case CX88_BOARD_KWORLD_DVB_T: |
| 584 | case CX88_BOARD_DNTV_LIVE_DVB_T: |
Mauro Carvalho Chehab | a82decf | 2005-07-07 17:58:36 -0700 | [diff] [blame] | 585 | case CX88_BOARD_ADSTECH_DVB_T_PCI: |
Andrew de Quincey | 2bfe031 | 2006-08-08 09:10:08 -0300 | [diff] [blame] | 586 | dev->dvb.frontend = dvb_attach(mt352_attach, &dntv_live_dvbt_config, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 587 | &dev->core->i2c_adap); |
Andrew de Quincey | f54376e | 2006-04-18 17:56:10 -0300 | [diff] [blame] | 588 | if (dev->dvb.frontend != NULL) { |
Andrew de Quincey | 2bfe031 | 2006-08-08 09:10:08 -0300 | [diff] [blame] | 589 | dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x61, |
Chris Pascoe | c162dff | 2006-08-08 15:48:08 -0300 | [diff] [blame^] | 590 | NULL, &dvb_pll_unknown_1); |
Andrew de Quincey | f54376e | 2006-04-18 17:56:10 -0300 | [diff] [blame] | 591 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 592 | break; |
Chris Pascoe | fc40b26 | 2006-01-09 15:25:35 -0200 | [diff] [blame] | 593 | case CX88_BOARD_DNTV_LIVE_DVB_T_PRO: |
| 594 | #ifdef HAVE_VP3054_I2C |
| 595 | dev->core->pll_addr = 0x61; |
| 596 | dev->core->pll_desc = &dvb_pll_fmd1216me; |
Andrew de Quincey | 2bfe031 | 2006-08-08 09:10:08 -0300 | [diff] [blame] | 597 | dev->dvb.frontend = dvb_attach(mt352_attach, &dntv_live_dvbt_pro_config, |
Chris Pascoe | fc40b26 | 2006-01-09 15:25:35 -0200 | [diff] [blame] | 598 | &((struct vp3054_i2c_state *)dev->card_priv)->adap); |
Andrew de Quincey | f54376e | 2006-04-18 17:56:10 -0300 | [diff] [blame] | 599 | if (dev->dvb.frontend != NULL) { |
Patrick Boettcher | dea7486 | 2006-05-14 05:01:31 -0300 | [diff] [blame] | 600 | dev->dvb.frontend->ops.tuner_ops.set_params = dntv_live_dvbt_pro_tuner_set_params; |
Andrew de Quincey | f54376e | 2006-04-18 17:56:10 -0300 | [diff] [blame] | 601 | } |
Chris Pascoe | fc40b26 | 2006-01-09 15:25:35 -0200 | [diff] [blame] | 602 | #else |
| 603 | printk("%s: built without vp3054 support\n", dev->core->name); |
| 604 | #endif |
| 605 | break; |
Chris Pascoe | 780dfef | 2006-02-28 08:34:59 -0300 | [diff] [blame] | 606 | case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_HYBRID: |
| 607 | dev->core->pll_addr = 0x61; |
Michael Krufky | 91ae329 | 2006-03-01 00:04:42 -0300 | [diff] [blame] | 608 | dev->core->pll_desc = &dvb_pll_thomson_fe6600; |
Andrew de Quincey | 2bfe031 | 2006-08-08 09:10:08 -0300 | [diff] [blame] | 609 | dev->dvb.frontend = dvb_attach(zl10353_attach, &dvico_fusionhdtv_hybrid, |
Chris Pascoe | 780dfef | 2006-02-28 08:34:59 -0300 | [diff] [blame] | 610 | &dev->core->i2c_adap); |
Andrew de Quincey | f54376e | 2006-04-18 17:56:10 -0300 | [diff] [blame] | 611 | if (dev->dvb.frontend != NULL) { |
Patrick Boettcher | dea7486 | 2006-05-14 05:01:31 -0300 | [diff] [blame] | 612 | dev->dvb.frontend->ops.tuner_ops.set_params = dvico_hybrid_tuner_set_params; |
Andrew de Quincey | f54376e | 2006-04-18 17:56:10 -0300 | [diff] [blame] | 613 | } |
Chris Pascoe | 780dfef | 2006-02-28 08:34:59 -0300 | [diff] [blame] | 614 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 615 | case CX88_BOARD_PCHDTV_HD3000: |
Andrew de Quincey | 2bfe031 | 2006-08-08 09:10:08 -0300 | [diff] [blame] | 616 | dev->dvb.frontend = dvb_attach(or51132_attach, &pchdtv_hd3000, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 617 | &dev->core->i2c_adap); |
Andrew de Quincey | f54376e | 2006-04-18 17:56:10 -0300 | [diff] [blame] | 618 | if (dev->dvb.frontend != NULL) { |
Andrew de Quincey | 2bfe031 | 2006-08-08 09:10:08 -0300 | [diff] [blame] | 619 | dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x61, |
Michael Krufky | 0f10291 | 2006-06-12 14:18:26 -0300 | [diff] [blame] | 620 | &dev->core->i2c_adap, |
| 621 | &dvb_pll_thomson_dtt761x); |
Andrew de Quincey | f54376e | 2006-04-18 17:56:10 -0300 | [diff] [blame] | 622 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 623 | break; |
Michael Krufky | f179849 | 2005-07-07 17:58:39 -0700 | [diff] [blame] | 624 | case CX88_BOARD_DVICO_FUSIONHDTV_3_GOLD_Q: |
| 625 | dev->ts_gen_cntrl = 0x08; |
| 626 | { |
| 627 | /* Do a hardware reset of chip before using it. */ |
| 628 | struct cx88_core *core = dev->core; |
| 629 | |
| 630 | cx_clear(MO_GP0_IO, 1); |
| 631 | mdelay(100); |
Michael Krufky | 0ccef6d | 2005-07-27 11:45:55 -0700 | [diff] [blame] | 632 | cx_set(MO_GP0_IO, 1); |
Michael Krufky | f179849 | 2005-07-07 17:58:39 -0700 | [diff] [blame] | 633 | mdelay(200); |
Michael Krufky | 0ccef6d | 2005-07-27 11:45:55 -0700 | [diff] [blame] | 634 | |
| 635 | /* Select RF connector callback */ |
Michael Krufky | 6ddcc91 | 2005-07-27 11:46:00 -0700 | [diff] [blame] | 636 | fusionhdtv_3_gold.pll_rf_set = lgdt330x_pll_rf_set; |
Michael Krufky | b6aef07 | 2005-07-27 11:45:54 -0700 | [diff] [blame] | 637 | dev->core->pll_addr = 0x61; |
| 638 | dev->core->pll_desc = &dvb_pll_microtune_4042; |
Andrew de Quincey | 2bfe031 | 2006-08-08 09:10:08 -0300 | [diff] [blame] | 639 | dev->dvb.frontend = dvb_attach(lgdt330x_attach, &fusionhdtv_3_gold, |
Michael Krufky | f179849 | 2005-07-07 17:58:39 -0700 | [diff] [blame] | 640 | &dev->core->i2c_adap); |
Andrew de Quincey | f54376e | 2006-04-18 17:56:10 -0300 | [diff] [blame] | 641 | if (dev->dvb.frontend != NULL) { |
Patrick Boettcher | dea7486 | 2006-05-14 05:01:31 -0300 | [diff] [blame] | 642 | dev->dvb.frontend->ops.tuner_ops.set_params = lgdt3302_tuner_set_params; |
Andrew de Quincey | f54376e | 2006-04-18 17:56:10 -0300 | [diff] [blame] | 643 | } |
Michael Krufky | f179849 | 2005-07-07 17:58:39 -0700 | [diff] [blame] | 644 | } |
| 645 | break; |
Michael Krufky | 0d723c0 | 2005-07-07 17:58:42 -0700 | [diff] [blame] | 646 | case CX88_BOARD_DVICO_FUSIONHDTV_3_GOLD_T: |
| 647 | dev->ts_gen_cntrl = 0x08; |
| 648 | { |
| 649 | /* Do a hardware reset of chip before using it. */ |
| 650 | struct cx88_core *core = dev->core; |
| 651 | |
| 652 | cx_clear(MO_GP0_IO, 1); |
| 653 | mdelay(100); |
Michael Krufky | d975872 | 2005-07-27 11:45:56 -0700 | [diff] [blame] | 654 | cx_set(MO_GP0_IO, 9); |
Michael Krufky | 0d723c0 | 2005-07-07 17:58:42 -0700 | [diff] [blame] | 655 | mdelay(200); |
Michael Krufky | b6aef07 | 2005-07-27 11:45:54 -0700 | [diff] [blame] | 656 | dev->core->pll_addr = 0x61; |
Michael Krufky | 83ac8722 | 2006-01-09 15:25:29 -0200 | [diff] [blame] | 657 | dev->core->pll_desc = &dvb_pll_thomson_dtt761x; |
Andrew de Quincey | 2bfe031 | 2006-08-08 09:10:08 -0300 | [diff] [blame] | 658 | dev->dvb.frontend = dvb_attach(lgdt330x_attach, &fusionhdtv_3_gold, |
Michael Krufky | 0d723c0 | 2005-07-07 17:58:42 -0700 | [diff] [blame] | 659 | &dev->core->i2c_adap); |
Andrew de Quincey | f54376e | 2006-04-18 17:56:10 -0300 | [diff] [blame] | 660 | if (dev->dvb.frontend != NULL) { |
Patrick Boettcher | dea7486 | 2006-05-14 05:01:31 -0300 | [diff] [blame] | 661 | dev->dvb.frontend->ops.tuner_ops.set_params = lgdt3302_tuner_set_params; |
Andrew de Quincey | f54376e | 2006-04-18 17:56:10 -0300 | [diff] [blame] | 662 | } |
Michael Krufky | 0d723c0 | 2005-07-07 17:58:42 -0700 | [diff] [blame] | 663 | } |
| 664 | break; |
Mauro Carvalho Chehab | e52e98a | 2005-09-09 13:03:41 -0700 | [diff] [blame] | 665 | case CX88_BOARD_DVICO_FUSIONHDTV_5_GOLD: |
| 666 | dev->ts_gen_cntrl = 0x08; |
| 667 | { |
| 668 | /* Do a hardware reset of chip before using it. */ |
| 669 | struct cx88_core *core = dev->core; |
| 670 | |
| 671 | cx_clear(MO_GP0_IO, 1); |
| 672 | mdelay(100); |
| 673 | cx_set(MO_GP0_IO, 1); |
| 674 | mdelay(200); |
Andrew de Quincey | 2bfe031 | 2006-08-08 09:10:08 -0300 | [diff] [blame] | 675 | dev->dvb.frontend = dvb_attach(lgdt330x_attach, &fusionhdtv_5_gold, |
Mauro Carvalho Chehab | e52e98a | 2005-09-09 13:03:41 -0700 | [diff] [blame] | 676 | &dev->core->i2c_adap); |
Andrew de Quincey | f54376e | 2006-04-18 17:56:10 -0300 | [diff] [blame] | 677 | if (dev->dvb.frontend != NULL) { |
Patrick Boettcher | dea7486 | 2006-05-14 05:01:31 -0300 | [diff] [blame] | 678 | dev->dvb.frontend->ops.tuner_ops.set_params = lgdt3303_tuner_set_params; |
Andrew de Quincey | f54376e | 2006-04-18 17:56:10 -0300 | [diff] [blame] | 679 | } |
Mauro Carvalho Chehab | e52e98a | 2005-09-09 13:03:41 -0700 | [diff] [blame] | 680 | } |
| 681 | break; |
Rusty Scott | da215d2 | 2006-04-07 02:21:31 -0300 | [diff] [blame] | 682 | case CX88_BOARD_PCHDTV_HD5500: |
| 683 | dev->ts_gen_cntrl = 0x08; |
| 684 | { |
| 685 | /* Do a hardware reset of chip before using it. */ |
| 686 | struct cx88_core *core = dev->core; |
| 687 | |
| 688 | cx_clear(MO_GP0_IO, 1); |
| 689 | mdelay(100); |
| 690 | cx_set(MO_GP0_IO, 1); |
| 691 | mdelay(200); |
Andrew de Quincey | 2bfe031 | 2006-08-08 09:10:08 -0300 | [diff] [blame] | 692 | dev->dvb.frontend = dvb_attach(lgdt330x_attach, &pchdtv_hd5500, |
Rusty Scott | da215d2 | 2006-04-07 02:21:31 -0300 | [diff] [blame] | 693 | &dev->core->i2c_adap); |
Andrew de Quincey | f54376e | 2006-04-18 17:56:10 -0300 | [diff] [blame] | 694 | if (dev->dvb.frontend != NULL) { |
Patrick Boettcher | dea7486 | 2006-05-14 05:01:31 -0300 | [diff] [blame] | 695 | dev->dvb.frontend->ops.tuner_ops.set_params = lgdt3303_tuner_set_params; |
Andrew de Quincey | f54376e | 2006-04-18 17:56:10 -0300 | [diff] [blame] | 696 | } |
Rusty Scott | da215d2 | 2006-04-07 02:21:31 -0300 | [diff] [blame] | 697 | } |
| 698 | break; |
Kirk Lapray | fde6d31 | 2005-11-08 21:38:18 -0800 | [diff] [blame] | 699 | case CX88_BOARD_ATI_HDTVWONDER: |
Andrew de Quincey | 2bfe031 | 2006-08-08 09:10:08 -0300 | [diff] [blame] | 700 | dev->dvb.frontend = dvb_attach(nxt200x_attach, &ati_hdtvwonder, |
Kirk Lapray | fde6d31 | 2005-11-08 21:38:18 -0800 | [diff] [blame] | 701 | &dev->core->i2c_adap); |
Andrew de Quincey | f54376e | 2006-04-18 17:56:10 -0300 | [diff] [blame] | 702 | if (dev->dvb.frontend != NULL) { |
Andrew de Quincey | 2bfe031 | 2006-08-08 09:10:08 -0300 | [diff] [blame] | 703 | dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x61, |
Michael Krufky | 0f10291 | 2006-06-12 14:18:26 -0300 | [diff] [blame] | 704 | &dev->core->i2c_adap, |
| 705 | &dvb_pll_tuv1236d); |
Andrew de Quincey | f54376e | 2006-04-18 17:56:10 -0300 | [diff] [blame] | 706 | } |
Kirk Lapray | fde6d31 | 2005-11-08 21:38:18 -0800 | [diff] [blame] | 707 | break; |
Steven Toth | 0fa14aa | 2006-01-09 15:25:02 -0200 | [diff] [blame] | 708 | case CX88_BOARD_HAUPPAUGE_NOVASPLUS_S1: |
| 709 | case CX88_BOARD_HAUPPAUGE_NOVASE2_S1: |
Andrew de Quincey | 2bfe031 | 2006-08-08 09:10:08 -0300 | [diff] [blame] | 710 | dev->dvb.frontend = dvb_attach(cx24123_attach, &hauppauge_novas_config, |
Steven Toth | 0fa14aa | 2006-01-09 15:25:02 -0200 | [diff] [blame] | 711 | &dev->core->i2c_adap); |
Andrew de Quincey | cd20ca9 | 2006-05-12 20:31:51 -0300 | [diff] [blame] | 712 | if (dev->dvb.frontend) { |
Andrew de Quincey | 2bfe031 | 2006-08-08 09:10:08 -0300 | [diff] [blame] | 713 | dvb_attach(isl6421_attach, dev->dvb.frontend, &dev->core->i2c_adap, |
Michael Krufky | 0f10291 | 2006-06-12 14:18:26 -0300 | [diff] [blame] | 714 | 0x08, 0x00, 0x00); |
Andrew de Quincey | cd20ca9 | 2006-05-12 20:31:51 -0300 | [diff] [blame] | 715 | } |
Steven Toth | 0fa14aa | 2006-01-09 15:25:02 -0200 | [diff] [blame] | 716 | break; |
Vadim Catana | 0e0351e | 2006-01-09 15:25:02 -0200 | [diff] [blame] | 717 | case CX88_BOARD_KWORLD_DVBS_100: |
Andrew de Quincey | 2bfe031 | 2006-08-08 09:10:08 -0300 | [diff] [blame] | 718 | dev->dvb.frontend = dvb_attach(cx24123_attach, &kworld_dvbs_100_config, |
Vadim Catana | 0e0351e | 2006-01-09 15:25:02 -0200 | [diff] [blame] | 719 | &dev->core->i2c_adap); |
Andrew de Quincey | cd20ca9 | 2006-05-12 20:31:51 -0300 | [diff] [blame] | 720 | if (dev->dvb.frontend) { |
Patrick Boettcher | dea7486 | 2006-05-14 05:01:31 -0300 | [diff] [blame] | 721 | dev->core->prev_set_voltage = dev->dvb.frontend->ops.set_voltage; |
| 722 | dev->dvb.frontend->ops.set_voltage = kworld_dvbs_100_set_voltage; |
Andrew de Quincey | cd20ca9 | 2006-05-12 20:31:51 -0300 | [diff] [blame] | 723 | } |
Vadim Catana | 0e0351e | 2006-01-09 15:25:02 -0200 | [diff] [blame] | 724 | break; |
Saqeb Akhter | c02a34f | 2006-06-29 20:29:33 -0300 | [diff] [blame] | 725 | case CX88_BOARD_GENIATECH_DVBS: |
Andrew de Quincey | 2bfe031 | 2006-08-08 09:10:08 -0300 | [diff] [blame] | 726 | dev->dvb.frontend = dvb_attach(cx24123_attach, &geniatech_dvbs_config, |
Saqeb Akhter | c02a34f | 2006-06-29 20:29:33 -0300 | [diff] [blame] | 727 | &dev->core->i2c_adap); |
| 728 | if (dev->dvb.frontend) { |
| 729 | dev->core->prev_set_voltage = dev->dvb.frontend->ops.set_voltage; |
| 730 | dev->dvb.frontend->ops.set_voltage = geniatech_dvbs_set_voltage; |
| 731 | } |
| 732 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 733 | default: |
Gerd Knorr | 1622c3f | 2005-05-01 08:59:19 -0700 | [diff] [blame] | 734 | printk("%s: The frontend of your DVB/ATSC card isn't supported yet\n", |
| 735 | dev->core->name); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 736 | break; |
| 737 | } |
| 738 | if (NULL == dev->dvb.frontend) { |
| 739 | printk("%s: frontend initialization failed\n",dev->core->name); |
| 740 | return -1; |
| 741 | } |
| 742 | |
| 743 | if (dev->core->pll_desc) { |
Patrick Boettcher | dea7486 | 2006-05-14 05:01:31 -0300 | [diff] [blame] | 744 | dev->dvb.frontend->ops.info.frequency_min = dev->core->pll_desc->min; |
| 745 | dev->dvb.frontend->ops.info.frequency_max = dev->core->pll_desc->max; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 746 | } |
| 747 | |
Mauro Carvalho Chehab | 93352f5 | 2005-09-13 01:25:42 -0700 | [diff] [blame] | 748 | /* Put the analog decoder in standby to keep it quiet */ |
| 749 | cx88_call_i2c_clients (dev->core, TUNER_SET_STANDBY, NULL); |
| 750 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 751 | /* register everything */ |
Andrew de Quincey | d09dbf9 | 2006-04-10 09:27:37 -0300 | [diff] [blame] | 752 | return videobuf_dvb_register(&dev->dvb, THIS_MODULE, dev, &dev->pci->dev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 753 | } |
| 754 | |
| 755 | /* ----------------------------------------------------------- */ |
| 756 | |
| 757 | static int __devinit dvb_probe(struct pci_dev *pci_dev, |
| 758 | const struct pci_device_id *pci_id) |
| 759 | { |
| 760 | struct cx8802_dev *dev; |
| 761 | struct cx88_core *core; |
| 762 | int err; |
| 763 | |
| 764 | /* general setup */ |
| 765 | core = cx88_core_get(pci_dev); |
| 766 | if (NULL == core) |
| 767 | return -EINVAL; |
| 768 | |
| 769 | err = -ENODEV; |
| 770 | if (!cx88_boards[core->board].dvb) |
| 771 | goto fail_core; |
| 772 | |
| 773 | err = -ENOMEM; |
Panagiotis Issaris | 7408187 | 2006-01-11 19:40:56 -0200 | [diff] [blame] | 774 | dev = kzalloc(sizeof(*dev),GFP_KERNEL); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 775 | if (NULL == dev) |
| 776 | goto fail_core; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 777 | dev->pci = pci_dev; |
| 778 | dev->core = core; |
| 779 | |
| 780 | err = cx8802_init_common(dev); |
| 781 | if (0 != err) |
| 782 | goto fail_free; |
| 783 | |
Chris Pascoe | fc40b26 | 2006-01-09 15:25:35 -0200 | [diff] [blame] | 784 | #ifdef HAVE_VP3054_I2C |
| 785 | err = vp3054_i2c_probe(dev); |
| 786 | if (0 != err) |
| 787 | goto fail_free; |
| 788 | #endif |
| 789 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 790 | /* dvb stuff */ |
| 791 | printk("%s/2: cx2388x based dvb card\n", core->name); |
| 792 | videobuf_queue_init(&dev->dvb.dvbq, &dvb_qops, |
| 793 | dev->pci, &dev->slock, |
| 794 | V4L2_BUF_TYPE_VIDEO_CAPTURE, |
| 795 | V4L2_FIELD_TOP, |
| 796 | sizeof(struct cx88_buffer), |
| 797 | dev); |
| 798 | err = dvb_register(dev); |
| 799 | if (0 != err) |
Gerd Knorr | 1622c3f | 2005-05-01 08:59:19 -0700 | [diff] [blame] | 800 | goto fail_fini; |
Steven Toth | 611900c | 2006-01-09 15:25:12 -0200 | [diff] [blame] | 801 | |
| 802 | /* Maintain a reference to cx88-video can query the 8802 device. */ |
| 803 | core->dvbdev = dev; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 804 | return 0; |
| 805 | |
Gerd Knorr | 1622c3f | 2005-05-01 08:59:19 -0700 | [diff] [blame] | 806 | fail_fini: |
| 807 | cx8802_fini_common(dev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 808 | fail_free: |
| 809 | kfree(dev); |
| 810 | fail_core: |
| 811 | cx88_core_put(core,pci_dev); |
| 812 | return err; |
| 813 | } |
| 814 | |
| 815 | static void __devexit dvb_remove(struct pci_dev *pci_dev) |
| 816 | { |
Mauro Carvalho Chehab | 4ac9791 | 2005-11-08 21:37:43 -0800 | [diff] [blame] | 817 | struct cx8802_dev *dev = pci_get_drvdata(pci_dev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 818 | |
Steven Toth | 611900c | 2006-01-09 15:25:12 -0200 | [diff] [blame] | 819 | /* Destroy any 8802 reference. */ |
| 820 | dev->core->dvbdev = NULL; |
| 821 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 822 | /* dvb */ |
| 823 | videobuf_dvb_unregister(&dev->dvb); |
| 824 | |
Chris Pascoe | fc40b26 | 2006-01-09 15:25:35 -0200 | [diff] [blame] | 825 | #ifdef HAVE_VP3054_I2C |
| 826 | vp3054_i2c_remove(dev); |
| 827 | #endif |
| 828 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 829 | /* common */ |
| 830 | cx8802_fini_common(dev); |
| 831 | cx88_core_put(dev->core,dev->pci); |
| 832 | kfree(dev); |
| 833 | } |
| 834 | |
| 835 | static struct pci_device_id cx8802_pci_tbl[] = { |
| 836 | { |
| 837 | .vendor = 0x14f1, |
| 838 | .device = 0x8802, |
Mauro Carvalho Chehab | 4ac9791 | 2005-11-08 21:37:43 -0800 | [diff] [blame] | 839 | .subvendor = PCI_ANY_ID, |
| 840 | .subdevice = PCI_ANY_ID, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 841 | },{ |
| 842 | /* --- end of list --- */ |
| 843 | } |
| 844 | }; |
| 845 | MODULE_DEVICE_TABLE(pci, cx8802_pci_tbl); |
| 846 | |
| 847 | static struct pci_driver dvb_pci_driver = { |
Mauro Carvalho Chehab | 4ac9791 | 2005-11-08 21:37:43 -0800 | [diff] [blame] | 848 | .name = "cx88-dvb", |
| 849 | .id_table = cx8802_pci_tbl, |
| 850 | .probe = dvb_probe, |
| 851 | .remove = __devexit_p(dvb_remove), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 852 | .suspend = cx8802_suspend_common, |
| 853 | .resume = cx8802_resume_common, |
| 854 | }; |
| 855 | |
| 856 | static int dvb_init(void) |
| 857 | { |
| 858 | printk(KERN_INFO "cx2388x dvb driver version %d.%d.%d loaded\n", |
| 859 | (CX88_VERSION_CODE >> 16) & 0xff, |
| 860 | (CX88_VERSION_CODE >> 8) & 0xff, |
| 861 | CX88_VERSION_CODE & 0xff); |
| 862 | #ifdef SNAPSHOT |
| 863 | printk(KERN_INFO "cx2388x: snapshot date %04d-%02d-%02d\n", |
| 864 | SNAPSHOT/10000, (SNAPSHOT/100)%100, SNAPSHOT%100); |
| 865 | #endif |
| 866 | return pci_register_driver(&dvb_pci_driver); |
| 867 | } |
| 868 | |
| 869 | static void dvb_fini(void) |
| 870 | { |
| 871 | pci_unregister_driver(&dvb_pci_driver); |
| 872 | } |
| 873 | |
| 874 | module_init(dvb_init); |
| 875 | module_exit(dvb_fini); |
| 876 | |
| 877 | /* |
| 878 | * Local variables: |
| 879 | * c-basic-offset: 8 |
| 880 | * compile-command: "make DVB=1" |
| 881 | * End: |
| 882 | */ |