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