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 | * |
| 6 | * (c) 2004 Chris Pascoe <c.pascoe@itee.uq.edu.au> |
| 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" |
Mauro Carvalho Chehab | 41ef7c1 | 2005-07-12 13:58:44 -0700 | [diff] [blame] | 34 | |
Michael Krufky | 29780bb | 2005-07-27 11:45:59 -0700 | [diff] [blame] | 35 | #ifdef HAVE_MT352 |
Mauro Carvalho Chehab | 41ef7c1 | 2005-07-12 13:58:44 -0700 | [diff] [blame] | 36 | # include "mt352.h" |
| 37 | # include "mt352_priv.h" |
| 38 | #endif |
Michael Krufky | 29780bb | 2005-07-27 11:45:59 -0700 | [diff] [blame] | 39 | #ifdef HAVE_CX22702 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 40 | # include "cx22702.h" |
| 41 | #endif |
Michael Krufky | 29780bb | 2005-07-27 11:45:59 -0700 | [diff] [blame] | 42 | #ifdef HAVE_OR51132 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 43 | # include "or51132.h" |
| 44 | #endif |
Michael Krufky | 6ddcc91 | 2005-07-27 11:46:00 -0700 | [diff] [blame] | 45 | #ifdef HAVE_LGDT330X |
| 46 | # include "lgdt330x.h" |
Michael Krufky | f179849 | 2005-07-07 17:58:39 -0700 | [diff] [blame] | 47 | #endif |
Kirk Lapray | fde6d31 | 2005-11-08 21:38:18 -0800 | [diff] [blame] | 48 | #ifdef HAVE_NXT200X |
| 49 | # include "nxt200x.h" |
| 50 | #endif |
Steven Toth | 0fa14aa | 2006-01-09 15:25:02 -0200 | [diff] [blame] | 51 | #ifdef HAVE_CX24123 |
| 52 | # include "cx24123.h" |
| 53 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 54 | |
| 55 | MODULE_DESCRIPTION("driver for cx2388x based DVB cards"); |
| 56 | MODULE_AUTHOR("Chris Pascoe <c.pascoe@itee.uq.edu.au>"); |
| 57 | MODULE_AUTHOR("Gerd Knorr <kraxel@bytesex.org> [SuSE Labs]"); |
| 58 | MODULE_LICENSE("GPL"); |
| 59 | |
| 60 | static unsigned int debug = 0; |
| 61 | module_param(debug, int, 0644); |
| 62 | MODULE_PARM_DESC(debug,"enable debug messages [dvb]"); |
| 63 | |
| 64 | #define dprintk(level,fmt, arg...) if (debug >= level) \ |
| 65 | printk(KERN_DEBUG "%s/2-dvb: " fmt, dev->core->name , ## arg) |
| 66 | |
| 67 | /* ------------------------------------------------------------------ */ |
| 68 | |
| 69 | static int dvb_buf_setup(struct videobuf_queue *q, |
| 70 | unsigned int *count, unsigned int *size) |
| 71 | { |
| 72 | struct cx8802_dev *dev = q->priv_data; |
| 73 | |
| 74 | dev->ts_packet_size = 188 * 4; |
| 75 | dev->ts_packet_count = 32; |
| 76 | |
| 77 | *size = dev->ts_packet_size * dev->ts_packet_count; |
| 78 | *count = 32; |
| 79 | return 0; |
| 80 | } |
| 81 | |
| 82 | static int dvb_buf_prepare(struct videobuf_queue *q, struct videobuf_buffer *vb, |
| 83 | enum v4l2_field field) |
| 84 | { |
| 85 | struct cx8802_dev *dev = q->priv_data; |
Michael Krufky | ccd7b65 | 2005-11-08 21:36:19 -0800 | [diff] [blame] | 86 | return cx8802_buf_prepare(dev, (struct cx88_buffer*)vb,field); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 87 | } |
| 88 | |
| 89 | static void dvb_buf_queue(struct videobuf_queue *q, struct videobuf_buffer *vb) |
| 90 | { |
| 91 | struct cx8802_dev *dev = q->priv_data; |
| 92 | cx8802_buf_queue(dev, (struct cx88_buffer*)vb); |
| 93 | } |
| 94 | |
| 95 | static void dvb_buf_release(struct videobuf_queue *q, struct videobuf_buffer *vb) |
| 96 | { |
| 97 | struct cx8802_dev *dev = q->priv_data; |
| 98 | cx88_free_buffer(dev->pci, (struct cx88_buffer*)vb); |
| 99 | } |
| 100 | |
Adrian Bunk | 408b664 | 2005-05-01 08:59:29 -0700 | [diff] [blame] | 101 | static struct videobuf_queue_ops dvb_qops = { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 102 | .buf_setup = dvb_buf_setup, |
| 103 | .buf_prepare = dvb_buf_prepare, |
| 104 | .buf_queue = dvb_buf_queue, |
| 105 | .buf_release = dvb_buf_release, |
| 106 | }; |
| 107 | |
| 108 | /* ------------------------------------------------------------------ */ |
| 109 | |
Michael Krufky | 29780bb | 2005-07-27 11:45:59 -0700 | [diff] [blame] | 110 | #ifdef HAVE_MT352 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 111 | static int dvico_fusionhdtv_demod_init(struct dvb_frontend* fe) |
| 112 | { |
| 113 | static u8 clock_config [] = { CLOCK_CTL, 0x38, 0x39 }; |
| 114 | static u8 reset [] = { RESET, 0x80 }; |
| 115 | static u8 adc_ctl_1_cfg [] = { ADC_CTL_1, 0x40 }; |
| 116 | static u8 agc_cfg [] = { AGC_TARGET, 0x24, 0x20 }; |
| 117 | static u8 gpp_ctl_cfg [] = { GPP_CTL, 0x33 }; |
| 118 | static u8 capt_range_cfg[] = { CAPT_RANGE, 0x32 }; |
| 119 | |
| 120 | mt352_write(fe, clock_config, sizeof(clock_config)); |
| 121 | udelay(200); |
| 122 | mt352_write(fe, reset, sizeof(reset)); |
| 123 | mt352_write(fe, adc_ctl_1_cfg, sizeof(adc_ctl_1_cfg)); |
| 124 | |
| 125 | mt352_write(fe, agc_cfg, sizeof(agc_cfg)); |
| 126 | mt352_write(fe, gpp_ctl_cfg, sizeof(gpp_ctl_cfg)); |
| 127 | mt352_write(fe, capt_range_cfg, sizeof(capt_range_cfg)); |
| 128 | return 0; |
| 129 | } |
| 130 | |
| 131 | static int dntv_live_dvbt_demod_init(struct dvb_frontend* fe) |
| 132 | { |
| 133 | static u8 clock_config [] = { 0x89, 0x38, 0x39 }; |
| 134 | static u8 reset [] = { 0x50, 0x80 }; |
| 135 | static u8 adc_ctl_1_cfg [] = { 0x8E, 0x40 }; |
| 136 | static u8 agc_cfg [] = { 0x67, 0x10, 0x23, 0x00, 0xFF, 0xFF, |
Mauro Carvalho Chehab | f2421ca | 2005-11-08 21:37:45 -0800 | [diff] [blame] | 137 | 0x00, 0xFF, 0x00, 0x40, 0x40 }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 138 | static u8 dntv_extra[] = { 0xB5, 0x7A }; |
| 139 | static u8 capt_range_cfg[] = { 0x75, 0x32 }; |
| 140 | |
| 141 | mt352_write(fe, clock_config, sizeof(clock_config)); |
| 142 | udelay(2000); |
| 143 | mt352_write(fe, reset, sizeof(reset)); |
| 144 | mt352_write(fe, adc_ctl_1_cfg, sizeof(adc_ctl_1_cfg)); |
| 145 | |
| 146 | mt352_write(fe, agc_cfg, sizeof(agc_cfg)); |
| 147 | udelay(2000); |
| 148 | mt352_write(fe, dntv_extra, sizeof(dntv_extra)); |
| 149 | mt352_write(fe, capt_range_cfg, sizeof(capt_range_cfg)); |
| 150 | |
| 151 | return 0; |
| 152 | } |
| 153 | |
| 154 | static int mt352_pll_set(struct dvb_frontend* fe, |
| 155 | struct dvb_frontend_parameters* params, |
| 156 | u8* pllbuf) |
| 157 | { |
| 158 | struct cx8802_dev *dev= fe->dvb->priv; |
| 159 | |
| 160 | pllbuf[0] = dev->core->pll_addr << 1; |
| 161 | dvb_pll_configure(dev->core->pll_desc, pllbuf+1, |
| 162 | params->frequency, |
| 163 | params->u.ofdm.bandwidth); |
| 164 | return 0; |
| 165 | } |
| 166 | |
| 167 | static struct mt352_config dvico_fusionhdtv = { |
| 168 | .demod_address = 0x0F, |
| 169 | .demod_init = dvico_fusionhdtv_demod_init, |
| 170 | .pll_set = mt352_pll_set, |
| 171 | }; |
| 172 | |
| 173 | static struct mt352_config dntv_live_dvbt_config = { |
| 174 | .demod_address = 0x0f, |
| 175 | .demod_init = dntv_live_dvbt_demod_init, |
| 176 | .pll_set = mt352_pll_set, |
| 177 | }; |
Mauro Carvalho Chehab | 41ef7c1 | 2005-07-12 13:58:44 -0700 | [diff] [blame] | 178 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 179 | |
Michael Krufky | 29780bb | 2005-07-27 11:45:59 -0700 | [diff] [blame] | 180 | #ifdef HAVE_CX22702 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 181 | static struct cx22702_config connexant_refboard_config = { |
| 182 | .demod_address = 0x43, |
Patrick Boettcher | 38d84c3 | 2005-07-15 12:20:26 -0700 | [diff] [blame] | 183 | .output_mode = CX22702_SERIAL_OUTPUT, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 184 | .pll_address = 0x60, |
| 185 | .pll_desc = &dvb_pll_thomson_dtt7579, |
| 186 | }; |
| 187 | |
| 188 | static struct cx22702_config hauppauge_novat_config = { |
| 189 | .demod_address = 0x43, |
Patrick Boettcher | 38d84c3 | 2005-07-15 12:20:26 -0700 | [diff] [blame] | 190 | .output_mode = CX22702_SERIAL_OUTPUT, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 191 | .pll_address = 0x61, |
| 192 | .pll_desc = &dvb_pll_thomson_dtt759x, |
| 193 | }; |
Steven Toth | 611900c | 2006-01-09 15:25:12 -0200 | [diff] [blame] | 194 | static struct cx22702_config hauppauge_hvr1100_config = { |
| 195 | .demod_address = 0x63, |
| 196 | .output_mode = CX22702_SERIAL_OUTPUT, |
| 197 | .pll_address = 0x61, |
| 198 | .pll_desc = &dvb_pll_fmd1216me, |
| 199 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 200 | #endif |
| 201 | |
Michael Krufky | 29780bb | 2005-07-27 11:45:59 -0700 | [diff] [blame] | 202 | #ifdef HAVE_OR51132 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 203 | static int or51132_set_ts_param(struct dvb_frontend* fe, |
| 204 | int is_punctured) |
| 205 | { |
| 206 | struct cx8802_dev *dev= fe->dvb->priv; |
| 207 | dev->ts_gen_cntrl = is_punctured ? 0x04 : 0x00; |
| 208 | return 0; |
| 209 | } |
| 210 | |
Adrian Bunk | 408b664 | 2005-05-01 08:59:29 -0700 | [diff] [blame] | 211 | static struct or51132_config pchdtv_hd3000 = { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 212 | .demod_address = 0x15, |
| 213 | .pll_address = 0x61, |
| 214 | .pll_desc = &dvb_pll_thomson_dtt7610, |
| 215 | .set_ts_params = or51132_set_ts_param, |
| 216 | }; |
| 217 | #endif |
| 218 | |
Michael Krufky | 6ddcc91 | 2005-07-27 11:46:00 -0700 | [diff] [blame] | 219 | #ifdef HAVE_LGDT330X |
| 220 | static int lgdt330x_pll_set(struct dvb_frontend* fe, |
Michael Krufky | 1963c90 | 2005-08-08 09:22:43 -0700 | [diff] [blame] | 221 | struct dvb_frontend_parameters* params) |
Michael Krufky | b6aef07 | 2005-07-27 11:45:54 -0700 | [diff] [blame] | 222 | { |
Mauro Carvalho Chehab | e52e98a | 2005-09-09 13:03:41 -0700 | [diff] [blame] | 223 | /* FIXME make this routine use the tuner-simple code. |
| 224 | * It could probably be shared with a number of ATSC |
| 225 | * frontends. Many share the same tuner with analog TV. */ |
| 226 | |
Michael Krufky | b6aef07 | 2005-07-27 11:45:54 -0700 | [diff] [blame] | 227 | struct cx8802_dev *dev= fe->dvb->priv; |
Mauro Carvalho Chehab | e52e98a | 2005-09-09 13:03:41 -0700 | [diff] [blame] | 228 | struct cx88_core *core = dev->core; |
Michael Krufky | 1963c90 | 2005-08-08 09:22:43 -0700 | [diff] [blame] | 229 | u8 buf[4]; |
| 230 | struct i2c_msg msg = |
| 231 | { .addr = dev->core->pll_addr, .flags = 0, .buf = buf, .len = 4 }; |
| 232 | int err; |
Michael Krufky | b6aef07 | 2005-07-27 11:45:54 -0700 | [diff] [blame] | 233 | |
Mauro Carvalho Chehab | e52e98a | 2005-09-09 13:03:41 -0700 | [diff] [blame] | 234 | /* Put the analog decoder in standby to keep it quiet */ |
Mauro Carvalho Chehab | 93352f5c | 2005-09-13 01:25:42 -0700 | [diff] [blame] | 235 | cx88_call_i2c_clients (dev->core, TUNER_SET_STANDBY, NULL); |
Mauro Carvalho Chehab | e52e98a | 2005-09-09 13:03:41 -0700 | [diff] [blame] | 236 | |
| 237 | dvb_pll_configure(core->pll_desc, buf, params->frequency, 0); |
Michael Krufky | 1963c90 | 2005-08-08 09:22:43 -0700 | [diff] [blame] | 238 | dprintk(1, "%s: tuner at 0x%02x bytes: 0x%02x 0x%02x 0x%02x 0x%02x\n", |
| 239 | __FUNCTION__, msg.addr, buf[0],buf[1],buf[2],buf[3]); |
Mauro Carvalho Chehab | e52e98a | 2005-09-09 13:03:41 -0700 | [diff] [blame] | 240 | if ((err = i2c_transfer(&core->i2c_adap, &msg, 1)) != 1) { |
Michael Krufky | 1963c90 | 2005-08-08 09:22:43 -0700 | [diff] [blame] | 241 | printk(KERN_WARNING "cx88-dvb: %s error " |
| 242 | "(addr %02x <- %02x, err = %i)\n", |
| 243 | __FUNCTION__, buf[0], buf[1], err); |
| 244 | if (err < 0) |
| 245 | return err; |
| 246 | else |
| 247 | return -EREMOTEIO; |
| 248 | } |
Mauro Carvalho Chehab | e52e98a | 2005-09-09 13:03:41 -0700 | [diff] [blame] | 249 | if (core->tuner_type == TUNER_LG_TDVS_H062F) { |
| 250 | /* Set the Auxiliary Byte. */ |
| 251 | buf[2] &= ~0x20; |
| 252 | buf[2] |= 0x18; |
| 253 | buf[3] = 0x50; |
| 254 | i2c_transfer(&core->i2c_adap, &msg, 1); |
| 255 | } |
Michael Krufky | b6aef07 | 2005-07-27 11:45:54 -0700 | [diff] [blame] | 256 | return 0; |
| 257 | } |
| 258 | |
Michael Krufky | 6ddcc91 | 2005-07-27 11:46:00 -0700 | [diff] [blame] | 259 | static int lgdt330x_pll_rf_set(struct dvb_frontend* fe, int index) |
Michael Krufky | 0ccef6d | 2005-07-27 11:45:55 -0700 | [diff] [blame] | 260 | { |
| 261 | struct cx8802_dev *dev= fe->dvb->priv; |
| 262 | struct cx88_core *core = dev->core; |
| 263 | |
| 264 | dprintk(1, "%s: index = %d\n", __FUNCTION__, index); |
| 265 | if (index == 0) |
| 266 | cx_clear(MO_GP0_IO, 8); |
| 267 | else |
| 268 | cx_set(MO_GP0_IO, 8); |
| 269 | return 0; |
| 270 | } |
| 271 | |
Michael Krufky | 6ddcc91 | 2005-07-27 11:46:00 -0700 | [diff] [blame] | 272 | 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] | 273 | { |
| 274 | struct cx8802_dev *dev= fe->dvb->priv; |
| 275 | if (is_punctured) |
| 276 | dev->ts_gen_cntrl |= 0x04; |
| 277 | else |
| 278 | dev->ts_gen_cntrl &= ~0x04; |
| 279 | return 0; |
| 280 | } |
| 281 | |
Michael Krufky | 6ddcc91 | 2005-07-27 11:46:00 -0700 | [diff] [blame] | 282 | static struct lgdt330x_config fusionhdtv_3_gold = { |
Michael Krufky | f179849 | 2005-07-07 17:58:39 -0700 | [diff] [blame] | 283 | .demod_address = 0x0e, |
Michael Krufky | 1963c90 | 2005-08-08 09:22:43 -0700 | [diff] [blame] | 284 | .demod_chip = LGDT3302, |
| 285 | .serial_mpeg = 0x04, /* TPSERIAL for 3302 in TOP_CONTROL */ |
Michael Krufky | 6ddcc91 | 2005-07-27 11:46:00 -0700 | [diff] [blame] | 286 | .pll_set = lgdt330x_pll_set, |
| 287 | .set_ts_params = lgdt330x_set_ts_param, |
Michael Krufky | 0d723c0 | 2005-07-07 17:58:42 -0700 | [diff] [blame] | 288 | }; |
Mauro Carvalho Chehab | e52e98a | 2005-09-09 13:03:41 -0700 | [diff] [blame] | 289 | |
| 290 | static struct lgdt330x_config fusionhdtv_5_gold = { |
| 291 | .demod_address = 0x0e, |
| 292 | .demod_chip = LGDT3303, |
| 293 | .serial_mpeg = 0x40, /* TPSERIAL for 3303 in TOP_CONTROL */ |
| 294 | .pll_set = lgdt330x_pll_set, |
| 295 | .set_ts_params = lgdt330x_set_ts_param, |
| 296 | }; |
Michael Krufky | f179849 | 2005-07-07 17:58:39 -0700 | [diff] [blame] | 297 | #endif |
| 298 | |
Kirk Lapray | fde6d31 | 2005-11-08 21:38:18 -0800 | [diff] [blame] | 299 | #ifdef HAVE_NXT200X |
| 300 | static int nxt200x_set_ts_param(struct dvb_frontend* fe, |
| 301 | int is_punctured) |
| 302 | { |
| 303 | struct cx8802_dev *dev= fe->dvb->priv; |
| 304 | dev->ts_gen_cntrl = is_punctured ? 0x04 : 0x00; |
| 305 | return 0; |
| 306 | } |
| 307 | |
Kirk Lapray | d4c34aa | 2005-11-08 21:38:40 -0800 | [diff] [blame] | 308 | static int nxt200x_set_pll_input(u8* buf, int input) |
| 309 | { |
| 310 | if (input) |
| 311 | buf[3] |= 0x08; |
| 312 | else |
| 313 | buf[3] &= ~0x08; |
| 314 | return 0; |
| 315 | } |
| 316 | |
Kirk Lapray | fde6d31 | 2005-11-08 21:38:18 -0800 | [diff] [blame] | 317 | static struct nxt200x_config ati_hdtvwonder = { |
| 318 | .demod_address = 0x0a, |
| 319 | .pll_address = 0x61, |
| 320 | .pll_desc = &dvb_pll_tuv1236d, |
Kirk Lapray | d4c34aa | 2005-11-08 21:38:40 -0800 | [diff] [blame] | 321 | .set_pll_input = nxt200x_set_pll_input, |
Kirk Lapray | fde6d31 | 2005-11-08 21:38:18 -0800 | [diff] [blame] | 322 | .set_ts_params = nxt200x_set_ts_param, |
| 323 | }; |
| 324 | #endif |
| 325 | |
Steven Toth | 0fa14aa | 2006-01-09 15:25:02 -0200 | [diff] [blame] | 326 | #ifdef HAVE_CX24123 |
| 327 | static int cx24123_set_ts_param(struct dvb_frontend* fe, |
| 328 | int is_punctured) |
| 329 | { |
| 330 | struct cx8802_dev *dev= fe->dvb->priv; |
| 331 | dev->ts_gen_cntrl = 0x2; |
| 332 | return 0; |
| 333 | } |
| 334 | |
Vadim Catana | 0e0351e | 2006-01-09 15:25:02 -0200 | [diff] [blame] | 335 | static void cx24123_enable_lnb_voltage(struct dvb_frontend* fe, int on) |
| 336 | { |
| 337 | struct cx8802_dev *dev= fe->dvb->priv; |
| 338 | struct cx88_core *core = dev->core; |
| 339 | |
| 340 | if (on) |
| 341 | cx_write(MO_GP0_IO, 0x000006f9); |
| 342 | else |
| 343 | cx_write(MO_GP0_IO, 0x000006fB); |
| 344 | } |
| 345 | |
Steven Toth | 0fa14aa | 2006-01-09 15:25:02 -0200 | [diff] [blame] | 346 | static struct cx24123_config hauppauge_novas_config = { |
Vadim Catana | 0e0351e | 2006-01-09 15:25:02 -0200 | [diff] [blame] | 347 | .demod_address = 0x55, |
| 348 | .use_isl6421 = 1, |
| 349 | .set_ts_params = cx24123_set_ts_param, |
| 350 | }; |
| 351 | |
| 352 | static struct cx24123_config kworld_dvbs_100_config = { |
| 353 | .demod_address = 0x15, |
| 354 | .use_isl6421 = 0, |
| 355 | .set_ts_params = cx24123_set_ts_param, |
| 356 | .enable_lnb_voltage = cx24123_enable_lnb_voltage, |
Steven Toth | 0fa14aa | 2006-01-09 15:25:02 -0200 | [diff] [blame] | 357 | }; |
| 358 | #endif |
| 359 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 360 | static int dvb_register(struct cx8802_dev *dev) |
| 361 | { |
| 362 | /* init struct videobuf_dvb */ |
| 363 | dev->dvb.name = dev->core->name; |
| 364 | dev->ts_gen_cntrl = 0x0c; |
| 365 | |
| 366 | /* init frontend */ |
| 367 | switch (dev->core->board) { |
Michael Krufky | 29780bb | 2005-07-27 11:45:59 -0700 | [diff] [blame] | 368 | #ifdef HAVE_CX22702 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 369 | case CX88_BOARD_HAUPPAUGE_DVB_T1: |
| 370 | dev->dvb.frontend = cx22702_attach(&hauppauge_novat_config, |
| 371 | &dev->core->i2c_adap); |
| 372 | break; |
Michael Krufky | e057ee1 | 2005-07-07 17:58:40 -0700 | [diff] [blame] | 373 | case CX88_BOARD_TERRATEC_CINERGY_1400_DVB_T1: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 374 | case CX88_BOARD_CONEXANT_DVB_T1: |
David Shirley | 2b5200a | 2005-11-08 21:37:22 -0800 | [diff] [blame] | 375 | case CX88_BOARD_WINFAST_DTV1000: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 376 | dev->dvb.frontend = cx22702_attach(&connexant_refboard_config, |
| 377 | &dev->core->i2c_adap); |
| 378 | break; |
Steven Toth | 611900c | 2006-01-09 15:25:12 -0200 | [diff] [blame] | 379 | case CX88_BOARD_HAUPPAUGE_HVR1100: |
| 380 | case CX88_BOARD_HAUPPAUGE_HVR1100LP: |
| 381 | dev->dvb.frontend = cx22702_attach(&hauppauge_hvr1100_config, |
| 382 | &dev->core->i2c_adap); |
| 383 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 384 | #endif |
Michael Krufky | 29780bb | 2005-07-27 11:45:59 -0700 | [diff] [blame] | 385 | #ifdef HAVE_MT352 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 386 | case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T1: |
| 387 | dev->core->pll_addr = 0x61; |
| 388 | dev->core->pll_desc = &dvb_pll_lg_z201; |
| 389 | dev->dvb.frontend = mt352_attach(&dvico_fusionhdtv, |
| 390 | &dev->core->i2c_adap); |
| 391 | break; |
| 392 | case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_PLUS: |
| 393 | dev->core->pll_addr = 0x60; |
| 394 | dev->core->pll_desc = &dvb_pll_thomson_dtt7579; |
| 395 | dev->dvb.frontend = mt352_attach(&dvico_fusionhdtv, |
| 396 | &dev->core->i2c_adap); |
| 397 | break; |
| 398 | case CX88_BOARD_KWORLD_DVB_T: |
| 399 | case CX88_BOARD_DNTV_LIVE_DVB_T: |
Mauro Carvalho Chehab | a82decf | 2005-07-07 17:58:36 -0700 | [diff] [blame] | 400 | case CX88_BOARD_ADSTECH_DVB_T_PCI: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 401 | dev->core->pll_addr = 0x61; |
| 402 | dev->core->pll_desc = &dvb_pll_unknown_1; |
| 403 | dev->dvb.frontend = mt352_attach(&dntv_live_dvbt_config, |
| 404 | &dev->core->i2c_adap); |
| 405 | break; |
Mauro Carvalho Chehab | 41ef7c1 | 2005-07-12 13:58:44 -0700 | [diff] [blame] | 406 | #endif |
Michael Krufky | 29780bb | 2005-07-27 11:45:59 -0700 | [diff] [blame] | 407 | #ifdef HAVE_OR51132 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 408 | case CX88_BOARD_PCHDTV_HD3000: |
| 409 | dev->dvb.frontend = or51132_attach(&pchdtv_hd3000, |
| 410 | &dev->core->i2c_adap); |
| 411 | break; |
| 412 | #endif |
Michael Krufky | 6ddcc91 | 2005-07-27 11:46:00 -0700 | [diff] [blame] | 413 | #ifdef HAVE_LGDT330X |
Michael Krufky | f179849 | 2005-07-07 17:58:39 -0700 | [diff] [blame] | 414 | case CX88_BOARD_DVICO_FUSIONHDTV_3_GOLD_Q: |
| 415 | dev->ts_gen_cntrl = 0x08; |
| 416 | { |
| 417 | /* Do a hardware reset of chip before using it. */ |
| 418 | struct cx88_core *core = dev->core; |
| 419 | |
| 420 | cx_clear(MO_GP0_IO, 1); |
| 421 | mdelay(100); |
Michael Krufky | 0ccef6d | 2005-07-27 11:45:55 -0700 | [diff] [blame] | 422 | cx_set(MO_GP0_IO, 1); |
Michael Krufky | f179849 | 2005-07-07 17:58:39 -0700 | [diff] [blame] | 423 | mdelay(200); |
Michael Krufky | 0ccef6d | 2005-07-27 11:45:55 -0700 | [diff] [blame] | 424 | |
| 425 | /* Select RF connector callback */ |
Michael Krufky | 6ddcc91 | 2005-07-27 11:46:00 -0700 | [diff] [blame] | 426 | fusionhdtv_3_gold.pll_rf_set = lgdt330x_pll_rf_set; |
Michael Krufky | b6aef07 | 2005-07-27 11:45:54 -0700 | [diff] [blame] | 427 | dev->core->pll_addr = 0x61; |
| 428 | dev->core->pll_desc = &dvb_pll_microtune_4042; |
Michael Krufky | 6ddcc91 | 2005-07-27 11:46:00 -0700 | [diff] [blame] | 429 | dev->dvb.frontend = lgdt330x_attach(&fusionhdtv_3_gold, |
Michael Krufky | f179849 | 2005-07-07 17:58:39 -0700 | [diff] [blame] | 430 | &dev->core->i2c_adap); |
| 431 | } |
| 432 | break; |
Michael Krufky | 0d723c0 | 2005-07-07 17:58:42 -0700 | [diff] [blame] | 433 | case CX88_BOARD_DVICO_FUSIONHDTV_3_GOLD_T: |
| 434 | dev->ts_gen_cntrl = 0x08; |
| 435 | { |
| 436 | /* Do a hardware reset of chip before using it. */ |
| 437 | struct cx88_core *core = dev->core; |
| 438 | |
| 439 | cx_clear(MO_GP0_IO, 1); |
| 440 | mdelay(100); |
Michael Krufky | d975872 | 2005-07-27 11:45:56 -0700 | [diff] [blame] | 441 | cx_set(MO_GP0_IO, 9); |
Michael Krufky | 0d723c0 | 2005-07-07 17:58:42 -0700 | [diff] [blame] | 442 | mdelay(200); |
Michael Krufky | b6aef07 | 2005-07-27 11:45:54 -0700 | [diff] [blame] | 443 | dev->core->pll_addr = 0x61; |
Michael Krufky | 83ac8722 | 2006-01-09 15:25:29 -0200 | [diff] [blame^] | 444 | dev->core->pll_desc = &dvb_pll_thomson_dtt761x; |
Michael Krufky | 6ddcc91 | 2005-07-27 11:46:00 -0700 | [diff] [blame] | 445 | dev->dvb.frontend = lgdt330x_attach(&fusionhdtv_3_gold, |
Michael Krufky | 0d723c0 | 2005-07-07 17:58:42 -0700 | [diff] [blame] | 446 | &dev->core->i2c_adap); |
| 447 | } |
| 448 | break; |
Mauro Carvalho Chehab | e52e98a | 2005-09-09 13:03:41 -0700 | [diff] [blame] | 449 | case CX88_BOARD_DVICO_FUSIONHDTV_5_GOLD: |
| 450 | dev->ts_gen_cntrl = 0x08; |
| 451 | { |
| 452 | /* Do a hardware reset of chip before using it. */ |
| 453 | struct cx88_core *core = dev->core; |
| 454 | |
| 455 | cx_clear(MO_GP0_IO, 1); |
| 456 | mdelay(100); |
| 457 | cx_set(MO_GP0_IO, 1); |
| 458 | mdelay(200); |
| 459 | dev->core->pll_addr = 0x61; |
| 460 | dev->core->pll_desc = &dvb_pll_tdvs_tua6034; |
| 461 | dev->dvb.frontend = lgdt330x_attach(&fusionhdtv_5_gold, |
| 462 | &dev->core->i2c_adap); |
| 463 | } |
| 464 | break; |
Michael Krufky | f179849 | 2005-07-07 17:58:39 -0700 | [diff] [blame] | 465 | #endif |
Kirk Lapray | fde6d31 | 2005-11-08 21:38:18 -0800 | [diff] [blame] | 466 | #ifdef HAVE_NXT200X |
| 467 | case CX88_BOARD_ATI_HDTVWONDER: |
| 468 | dev->dvb.frontend = nxt200x_attach(&ati_hdtvwonder, |
| 469 | &dev->core->i2c_adap); |
| 470 | break; |
| 471 | #endif |
Steven Toth | 0fa14aa | 2006-01-09 15:25:02 -0200 | [diff] [blame] | 472 | #ifdef HAVE_CX24123 |
| 473 | case CX88_BOARD_HAUPPAUGE_NOVASPLUS_S1: |
| 474 | case CX88_BOARD_HAUPPAUGE_NOVASE2_S1: |
| 475 | dev->dvb.frontend = cx24123_attach(&hauppauge_novas_config, |
| 476 | &dev->core->i2c_adap); |
| 477 | break; |
Vadim Catana | 0e0351e | 2006-01-09 15:25:02 -0200 | [diff] [blame] | 478 | case CX88_BOARD_KWORLD_DVBS_100: |
| 479 | dev->dvb.frontend = cx24123_attach(&kworld_dvbs_100_config, |
| 480 | &dev->core->i2c_adap); |
| 481 | break; |
Steven Toth | 0fa14aa | 2006-01-09 15:25:02 -0200 | [diff] [blame] | 482 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 483 | default: |
Gerd Knorr | 1622c3f | 2005-05-01 08:59:19 -0700 | [diff] [blame] | 484 | printk("%s: The frontend of your DVB/ATSC card isn't supported yet\n", |
| 485 | dev->core->name); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 486 | break; |
| 487 | } |
| 488 | if (NULL == dev->dvb.frontend) { |
| 489 | printk("%s: frontend initialization failed\n",dev->core->name); |
| 490 | return -1; |
| 491 | } |
| 492 | |
| 493 | if (dev->core->pll_desc) { |
| 494 | dev->dvb.frontend->ops->info.frequency_min = dev->core->pll_desc->min; |
| 495 | dev->dvb.frontend->ops->info.frequency_max = dev->core->pll_desc->max; |
| 496 | } |
| 497 | |
Mauro Carvalho Chehab | 93352f5c | 2005-09-13 01:25:42 -0700 | [diff] [blame] | 498 | /* Put the analog decoder in standby to keep it quiet */ |
| 499 | cx88_call_i2c_clients (dev->core, TUNER_SET_STANDBY, NULL); |
| 500 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 501 | /* register everything */ |
| 502 | return videobuf_dvb_register(&dev->dvb, THIS_MODULE, dev); |
| 503 | } |
| 504 | |
| 505 | /* ----------------------------------------------------------- */ |
| 506 | |
| 507 | static int __devinit dvb_probe(struct pci_dev *pci_dev, |
| 508 | const struct pci_device_id *pci_id) |
| 509 | { |
| 510 | struct cx8802_dev *dev; |
| 511 | struct cx88_core *core; |
| 512 | int err; |
| 513 | |
| 514 | /* general setup */ |
| 515 | core = cx88_core_get(pci_dev); |
| 516 | if (NULL == core) |
| 517 | return -EINVAL; |
| 518 | |
| 519 | err = -ENODEV; |
| 520 | if (!cx88_boards[core->board].dvb) |
| 521 | goto fail_core; |
| 522 | |
| 523 | err = -ENOMEM; |
| 524 | dev = kmalloc(sizeof(*dev),GFP_KERNEL); |
| 525 | if (NULL == dev) |
| 526 | goto fail_core; |
| 527 | memset(dev,0,sizeof(*dev)); |
| 528 | dev->pci = pci_dev; |
| 529 | dev->core = core; |
| 530 | |
| 531 | err = cx8802_init_common(dev); |
| 532 | if (0 != err) |
| 533 | goto fail_free; |
| 534 | |
| 535 | /* dvb stuff */ |
| 536 | printk("%s/2: cx2388x based dvb card\n", core->name); |
| 537 | videobuf_queue_init(&dev->dvb.dvbq, &dvb_qops, |
| 538 | dev->pci, &dev->slock, |
| 539 | V4L2_BUF_TYPE_VIDEO_CAPTURE, |
| 540 | V4L2_FIELD_TOP, |
| 541 | sizeof(struct cx88_buffer), |
| 542 | dev); |
| 543 | err = dvb_register(dev); |
| 544 | if (0 != err) |
Gerd Knorr | 1622c3f | 2005-05-01 08:59:19 -0700 | [diff] [blame] | 545 | goto fail_fini; |
Steven Toth | 611900c | 2006-01-09 15:25:12 -0200 | [diff] [blame] | 546 | |
| 547 | /* Maintain a reference to cx88-video can query the 8802 device. */ |
| 548 | core->dvbdev = dev; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 549 | return 0; |
| 550 | |
Gerd Knorr | 1622c3f | 2005-05-01 08:59:19 -0700 | [diff] [blame] | 551 | fail_fini: |
| 552 | cx8802_fini_common(dev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 553 | fail_free: |
| 554 | kfree(dev); |
| 555 | fail_core: |
| 556 | cx88_core_put(core,pci_dev); |
| 557 | return err; |
| 558 | } |
| 559 | |
| 560 | static void __devexit dvb_remove(struct pci_dev *pci_dev) |
| 561 | { |
Mauro Carvalho Chehab | 4ac9791 | 2005-11-08 21:37:43 -0800 | [diff] [blame] | 562 | struct cx8802_dev *dev = pci_get_drvdata(pci_dev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 563 | |
Steven Toth | 611900c | 2006-01-09 15:25:12 -0200 | [diff] [blame] | 564 | /* Destroy any 8802 reference. */ |
| 565 | dev->core->dvbdev = NULL; |
| 566 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 567 | /* dvb */ |
| 568 | videobuf_dvb_unregister(&dev->dvb); |
| 569 | |
| 570 | /* common */ |
| 571 | cx8802_fini_common(dev); |
| 572 | cx88_core_put(dev->core,dev->pci); |
| 573 | kfree(dev); |
| 574 | } |
| 575 | |
| 576 | static struct pci_device_id cx8802_pci_tbl[] = { |
| 577 | { |
| 578 | .vendor = 0x14f1, |
| 579 | .device = 0x8802, |
Mauro Carvalho Chehab | 4ac9791 | 2005-11-08 21:37:43 -0800 | [diff] [blame] | 580 | .subvendor = PCI_ANY_ID, |
| 581 | .subdevice = PCI_ANY_ID, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 582 | },{ |
| 583 | /* --- end of list --- */ |
| 584 | } |
| 585 | }; |
| 586 | MODULE_DEVICE_TABLE(pci, cx8802_pci_tbl); |
| 587 | |
| 588 | static struct pci_driver dvb_pci_driver = { |
Mauro Carvalho Chehab | 4ac9791 | 2005-11-08 21:37:43 -0800 | [diff] [blame] | 589 | .name = "cx88-dvb", |
| 590 | .id_table = cx8802_pci_tbl, |
| 591 | .probe = dvb_probe, |
| 592 | .remove = __devexit_p(dvb_remove), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 593 | .suspend = cx8802_suspend_common, |
| 594 | .resume = cx8802_resume_common, |
| 595 | }; |
| 596 | |
| 597 | static int dvb_init(void) |
| 598 | { |
| 599 | printk(KERN_INFO "cx2388x dvb driver version %d.%d.%d loaded\n", |
| 600 | (CX88_VERSION_CODE >> 16) & 0xff, |
| 601 | (CX88_VERSION_CODE >> 8) & 0xff, |
| 602 | CX88_VERSION_CODE & 0xff); |
| 603 | #ifdef SNAPSHOT |
| 604 | printk(KERN_INFO "cx2388x: snapshot date %04d-%02d-%02d\n", |
| 605 | SNAPSHOT/10000, (SNAPSHOT/100)%100, SNAPSHOT%100); |
| 606 | #endif |
| 607 | return pci_register_driver(&dvb_pci_driver); |
| 608 | } |
| 609 | |
| 610 | static void dvb_fini(void) |
| 611 | { |
| 612 | pci_unregister_driver(&dvb_pci_driver); |
| 613 | } |
| 614 | |
| 615 | module_init(dvb_init); |
| 616 | module_exit(dvb_fini); |
| 617 | |
| 618 | /* |
| 619 | * Local variables: |
| 620 | * c-basic-offset: 8 |
| 621 | * compile-command: "make DVB=1" |
| 622 | * End: |
| 623 | */ |