Devin Heitmueller | cbddcba | 2010-03-13 17:53:58 -0300 | [diff] [blame] | 1 | /* |
| 2 | * ngene-cards.c: nGene PCIe bridge driver - card specific info |
| 3 | * |
| 4 | * Copyright (C) 2005-2007 Micronas |
| 5 | * |
| 6 | * Copyright (C) 2008-2009 Ralph Metzler <rjkm@metzlerbros.de> |
| 7 | * Modifications for new nGene firmware, |
| 8 | * support for EEPROM-copying, |
| 9 | * support for new dual DVB-S2 card prototype |
| 10 | * |
| 11 | * |
| 12 | * This program is free software; you can redistribute it and/or |
| 13 | * modify it under the terms of the GNU General Public License |
| 14 | * version 2 only, as published by the Free Software Foundation. |
| 15 | * |
| 16 | * |
| 17 | * This program is distributed in the hope that it will be useful, |
| 18 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 20 | * GNU General Public License for more details. |
| 21 | * |
| 22 | * |
| 23 | * You should have received a copy of the GNU General Public License |
| 24 | * along with this program; if not, write to the Free Software |
| 25 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA |
| 26 | * 02110-1301, USA |
| 27 | * Or, point your browser to http://www.gnu.org/copyleft/gpl.html |
| 28 | */ |
| 29 | |
| 30 | #include <linux/module.h> |
| 31 | #include <linux/init.h> |
| 32 | #include <linux/pci.h> |
| 33 | #include <linux/pci_ids.h> |
| 34 | |
| 35 | #include "ngene.h" |
| 36 | |
| 37 | /* demods/tuners */ |
| 38 | #include "stv6110x.h" |
| 39 | #include "stv090x.h" |
| 40 | #include "lnbh24.h" |
| 41 | #include "lgdt330x.h" |
| 42 | #include "mt2131.h" |
Ralph Metzler | 9ca9efb | 2011-07-03 13:55:06 -0300 | [diff] [blame^] | 43 | #include "drxk.h" |
Devin Heitmueller | cbddcba | 2010-03-13 17:53:58 -0300 | [diff] [blame] | 44 | |
| 45 | |
| 46 | /****************************************************************************/ |
| 47 | /* Demod/tuner attachment ***************************************************/ |
| 48 | /****************************************************************************/ |
| 49 | |
| 50 | static int tuner_attach_stv6110(struct ngene_channel *chan) |
| 51 | { |
Oliver Endriss | 5fec185 | 2011-01-10 06:36:13 -0300 | [diff] [blame] | 52 | struct i2c_adapter *i2c; |
Devin Heitmueller | cbddcba | 2010-03-13 17:53:58 -0300 | [diff] [blame] | 53 | struct stv090x_config *feconf = (struct stv090x_config *) |
| 54 | chan->dev->card_info->fe_config[chan->number]; |
| 55 | struct stv6110x_config *tunerconf = (struct stv6110x_config *) |
| 56 | chan->dev->card_info->tuner_config[chan->number]; |
| 57 | struct stv6110x_devctl *ctl; |
| 58 | |
Oliver Endriss | 5fec185 | 2011-01-10 06:36:13 -0300 | [diff] [blame] | 59 | /* tuner 1+2: i2c adapter #0, tuner 3+4: i2c adapter #1 */ |
| 60 | if (chan->number < 2) |
| 61 | i2c = &chan->dev->channel[0].i2c_adapter; |
| 62 | else |
| 63 | i2c = &chan->dev->channel[1].i2c_adapter; |
| 64 | |
| 65 | ctl = dvb_attach(stv6110x_attach, chan->fe, tunerconf, i2c); |
Devin Heitmueller | cbddcba | 2010-03-13 17:53:58 -0300 | [diff] [blame] | 66 | if (ctl == NULL) { |
| 67 | printk(KERN_ERR DEVICE_NAME ": No STV6110X found!\n"); |
| 68 | return -ENODEV; |
| 69 | } |
| 70 | |
| 71 | feconf->tuner_init = ctl->tuner_init; |
Oliver Endriss | 5fec185 | 2011-01-10 06:36:13 -0300 | [diff] [blame] | 72 | feconf->tuner_sleep = ctl->tuner_sleep; |
Devin Heitmueller | cbddcba | 2010-03-13 17:53:58 -0300 | [diff] [blame] | 73 | feconf->tuner_set_mode = ctl->tuner_set_mode; |
| 74 | feconf->tuner_set_frequency = ctl->tuner_set_frequency; |
| 75 | feconf->tuner_get_frequency = ctl->tuner_get_frequency; |
| 76 | feconf->tuner_set_bandwidth = ctl->tuner_set_bandwidth; |
| 77 | feconf->tuner_get_bandwidth = ctl->tuner_get_bandwidth; |
| 78 | feconf->tuner_set_bbgain = ctl->tuner_set_bbgain; |
| 79 | feconf->tuner_get_bbgain = ctl->tuner_get_bbgain; |
| 80 | feconf->tuner_set_refclk = ctl->tuner_set_refclk; |
| 81 | feconf->tuner_get_status = ctl->tuner_get_status; |
| 82 | |
| 83 | return 0; |
| 84 | } |
| 85 | |
| 86 | |
Ralph Metzler | 9ca9efb | 2011-07-03 13:55:06 -0300 | [diff] [blame^] | 87 | static int drxk_gate_ctrl(struct dvb_frontend *fe, int enable) |
| 88 | { |
| 89 | struct ngene_channel *chan = fe->sec_priv; |
| 90 | int status; |
| 91 | |
| 92 | if (enable) { |
| 93 | down(&chan->dev->pll_mutex); |
| 94 | status = chan->gate_ctrl(fe, 1); |
| 95 | } else { |
| 96 | status = chan->gate_ctrl(fe, 0); |
| 97 | up(&chan->dev->pll_mutex); |
| 98 | } |
| 99 | return status; |
| 100 | } |
| 101 | |
| 102 | struct dvb_frontend *tda18271c2dd_attach(struct dvb_frontend *fe, |
| 103 | struct i2c_adapter *i2c, u8 adr); |
| 104 | |
| 105 | static int tuner_attach_tda18271(struct ngene_channel *chan) |
| 106 | { |
| 107 | struct i2c_adapter *i2c; |
| 108 | struct dvb_frontend *fe; |
| 109 | |
| 110 | i2c = &chan->dev->channel[0].i2c_adapter; |
| 111 | if (chan->fe->ops.i2c_gate_ctrl) |
| 112 | chan->fe->ops.i2c_gate_ctrl(chan->fe, 1); |
| 113 | fe = dvb_attach(tda18271c2dd_attach, chan->fe, i2c, 0x60); |
| 114 | if (chan->fe->ops.i2c_gate_ctrl) |
| 115 | chan->fe->ops.i2c_gate_ctrl(chan->fe, 0); |
| 116 | if (!fe) { |
| 117 | printk("No TDA18271 found!\n"); |
| 118 | return -ENODEV; |
| 119 | } |
| 120 | |
| 121 | return 0; |
| 122 | } |
| 123 | |
| 124 | static int tuner_attach_probe(struct ngene_channel *chan) |
| 125 | { |
| 126 | if (chan->demod_type == 0) |
| 127 | return tuner_attach_stv6110(chan); |
| 128 | if (chan->demod_type == 1) |
| 129 | return tuner_attach_tda18271(chan); |
| 130 | return -EINVAL; |
| 131 | } |
| 132 | |
Devin Heitmueller | cbddcba | 2010-03-13 17:53:58 -0300 | [diff] [blame] | 133 | static int demod_attach_stv0900(struct ngene_channel *chan) |
| 134 | { |
Oliver Endriss | 5fec185 | 2011-01-10 06:36:13 -0300 | [diff] [blame] | 135 | struct i2c_adapter *i2c; |
Devin Heitmueller | cbddcba | 2010-03-13 17:53:58 -0300 | [diff] [blame] | 136 | struct stv090x_config *feconf = (struct stv090x_config *) |
| 137 | chan->dev->card_info->fe_config[chan->number]; |
| 138 | |
Oliver Endriss | 5fec185 | 2011-01-10 06:36:13 -0300 | [diff] [blame] | 139 | /* tuner 1+2: i2c adapter #0, tuner 3+4: i2c adapter #1 */ |
| 140 | /* Note: Both adapters share the same i2c bus, but the demod */ |
| 141 | /* driver requires that each demod has its own i2c adapter */ |
| 142 | if (chan->number < 2) |
| 143 | i2c = &chan->dev->channel[0].i2c_adapter; |
| 144 | else |
| 145 | i2c = &chan->dev->channel[1].i2c_adapter; |
| 146 | |
| 147 | chan->fe = dvb_attach(stv090x_attach, feconf, i2c, |
| 148 | (chan->number & 1) == 0 ? STV090x_DEMODULATOR_0 |
| 149 | : STV090x_DEMODULATOR_1); |
Devin Heitmueller | cbddcba | 2010-03-13 17:53:58 -0300 | [diff] [blame] | 150 | if (chan->fe == NULL) { |
| 151 | printk(KERN_ERR DEVICE_NAME ": No STV0900 found!\n"); |
| 152 | return -ENODEV; |
| 153 | } |
| 154 | |
Oliver Endriss | 5fec185 | 2011-01-10 06:36:13 -0300 | [diff] [blame] | 155 | /* store channel info */ |
| 156 | if (feconf->tuner_i2c_lock) |
| 157 | chan->fe->analog_demod_priv = chan; |
| 158 | |
| 159 | if (!dvb_attach(lnbh24_attach, chan->fe, i2c, 0, |
Devin Heitmueller | cbddcba | 2010-03-13 17:53:58 -0300 | [diff] [blame] | 160 | 0, chan->dev->card_info->lnb[chan->number])) { |
| 161 | printk(KERN_ERR DEVICE_NAME ": No LNBH24 found!\n"); |
| 162 | dvb_frontend_detach(chan->fe); |
Oliver Endriss | 8a48471 | 2011-01-10 06:36:14 -0300 | [diff] [blame] | 163 | chan->fe = NULL; |
Devin Heitmueller | cbddcba | 2010-03-13 17:53:58 -0300 | [diff] [blame] | 164 | return -ENODEV; |
| 165 | } |
| 166 | |
| 167 | return 0; |
| 168 | } |
| 169 | |
Oliver Endriss | 5fec185 | 2011-01-10 06:36:13 -0300 | [diff] [blame] | 170 | static void cineS2_tuner_i2c_lock(struct dvb_frontend *fe, int lock) |
| 171 | { |
| 172 | struct ngene_channel *chan = fe->analog_demod_priv; |
| 173 | |
| 174 | if (lock) |
| 175 | down(&chan->dev->pll_mutex); |
| 176 | else |
| 177 | up(&chan->dev->pll_mutex); |
| 178 | } |
| 179 | |
Ralph Metzler | 9ca9efb | 2011-07-03 13:55:06 -0300 | [diff] [blame^] | 180 | static int i2c_read(struct i2c_adapter *adapter, u8 adr, u8 *val) |
| 181 | { |
| 182 | struct i2c_msg msgs[1] = {{.addr = adr, .flags = I2C_M_RD, |
| 183 | .buf = val, .len = 1 }}; |
| 184 | return (i2c_transfer(adapter, msgs, 1) == 1) ? 0 : -1; |
| 185 | } |
| 186 | |
| 187 | static int i2c_read_reg16(struct i2c_adapter *adapter, u8 adr, |
| 188 | u16 reg, u8 *val) |
| 189 | { |
| 190 | u8 msg[2] = {reg>>8, reg&0xff}; |
| 191 | struct i2c_msg msgs[2] = {{.addr = adr, .flags = 0, |
| 192 | .buf = msg, .len = 2}, |
| 193 | {.addr = adr, .flags = I2C_M_RD, |
| 194 | .buf = val, .len = 1}}; |
| 195 | return (i2c_transfer(adapter, msgs, 2) == 2) ? 0 : -1; |
| 196 | } |
| 197 | |
| 198 | static int port_has_stv0900(struct i2c_adapter *i2c, int port) |
| 199 | { |
| 200 | u8 val; |
| 201 | if (i2c_read_reg16(i2c, 0x68+port/2, 0xf100, &val) < 0) |
| 202 | return 0; |
| 203 | return 1; |
| 204 | } |
| 205 | |
| 206 | static int port_has_drxk(struct i2c_adapter *i2c, int port) |
| 207 | { |
| 208 | u8 val; |
| 209 | |
| 210 | if (i2c_read(i2c, 0x29+port, &val) < 0) |
| 211 | return 0; |
| 212 | printk("DRXK@%02x\n", 0x29+port); |
| 213 | return 1; |
| 214 | } |
| 215 | |
| 216 | static int demod_attach_drxk(struct ngene_channel *chan, |
| 217 | struct i2c_adapter *i2c) |
| 218 | { |
| 219 | struct dvb_frontend *fe; |
| 220 | |
| 221 | chan->fe = fe = dvb_attach(drxk_attach, |
| 222 | i2c, 0x29 + (chan->number^2), |
| 223 | &chan->fe2); |
| 224 | if (!chan->fe) { |
| 225 | printk("No DRXK found!\n"); |
| 226 | return -ENODEV; |
| 227 | } |
| 228 | fe->sec_priv = chan; |
| 229 | chan->gate_ctrl = fe->ops.i2c_gate_ctrl; |
| 230 | fe->ops.i2c_gate_ctrl = drxk_gate_ctrl; |
| 231 | return 0; |
| 232 | } |
| 233 | |
Oliver Endriss | 5fec185 | 2011-01-10 06:36:13 -0300 | [diff] [blame] | 234 | static int cineS2_probe(struct ngene_channel *chan) |
| 235 | { |
| 236 | struct i2c_adapter *i2c; |
| 237 | struct stv090x_config *fe_conf; |
| 238 | u8 buf[3]; |
| 239 | struct i2c_msg i2c_msg = { .flags = 0, .buf = buf }; |
| 240 | int rc; |
| 241 | |
| 242 | /* tuner 1+2: i2c adapter #0, tuner 3+4: i2c adapter #1 */ |
| 243 | if (chan->number < 2) |
| 244 | i2c = &chan->dev->channel[0].i2c_adapter; |
| 245 | else |
| 246 | i2c = &chan->dev->channel[1].i2c_adapter; |
| 247 | |
Ralph Metzler | 9ca9efb | 2011-07-03 13:55:06 -0300 | [diff] [blame^] | 248 | if (port_has_stv0900(i2c, chan->number)) { |
| 249 | chan->demod_type=0; |
| 250 | fe_conf = chan->dev->card_info->fe_config[chan->number]; |
| 251 | /* demod found, attach it */ |
| 252 | rc = demod_attach_stv0900(chan); |
| 253 | if (rc < 0 || chan->number < 2) |
| 254 | return rc; |
| 255 | |
| 256 | /* demod #2: reprogram outputs DPN1 & DPN2 */ |
| 257 | i2c_msg.addr = fe_conf->address; |
| 258 | i2c_msg.len = 3; |
| 259 | buf[0] = 0xf1; |
| 260 | switch (chan->number) |
| 261 | { |
| 262 | case 2: |
| 263 | buf[1] = 0x5c; |
| 264 | buf[2] = 0xc2; |
| 265 | break; |
| 266 | case 3: |
| 267 | buf[1] = 0x61; |
| 268 | buf[2] = 0xcc; |
| 269 | break; |
| 270 | default: |
| 271 | return -ENODEV; |
| 272 | } |
| 273 | rc = i2c_transfer(i2c, &i2c_msg, 1); |
| 274 | if (rc != 1) { |
| 275 | printk(KERN_ERR DEVICE_NAME ": could not setup DPNx\n"); |
| 276 | return -EIO; |
| 277 | } |
| 278 | } else if (port_has_drxk(i2c, chan->number^2)) { |
| 279 | chan->demod_type=1; |
| 280 | demod_attach_drxk(chan, i2c); |
| 281 | } else { |
| 282 | printk("No demod found on chan %d\n", chan->number); |
Oliver Endriss | 5fec185 | 2011-01-10 06:36:13 -0300 | [diff] [blame] | 283 | } |
Oliver Endriss | 5fec185 | 2011-01-10 06:36:13 -0300 | [diff] [blame] | 284 | return 0; |
| 285 | } |
| 286 | |
| 287 | |
Devin Heitmueller | cbddcba | 2010-03-13 17:53:58 -0300 | [diff] [blame] | 288 | static struct lgdt330x_config aver_m780 = { |
| 289 | .demod_address = 0xb2 >> 1, |
| 290 | .demod_chip = LGDT3303, |
| 291 | .serial_mpeg = 0x00, /* PARALLEL */ |
| 292 | .clock_polarity_flip = 1, |
| 293 | }; |
| 294 | |
| 295 | static struct mt2131_config m780_tunerconfig = { |
| 296 | 0xc0 >> 1 |
| 297 | }; |
| 298 | |
| 299 | /* A single func to attach the demo and tuner, rather than |
| 300 | * use two sep funcs like the current design mandates. |
| 301 | */ |
| 302 | static int demod_attach_lg330x(struct ngene_channel *chan) |
| 303 | { |
| 304 | chan->fe = dvb_attach(lgdt330x_attach, &aver_m780, &chan->i2c_adapter); |
| 305 | if (chan->fe == NULL) { |
| 306 | printk(KERN_ERR DEVICE_NAME ": No LGDT330x found!\n"); |
| 307 | return -ENODEV; |
| 308 | } |
| 309 | |
| 310 | dvb_attach(mt2131_attach, chan->fe, &chan->i2c_adapter, |
| 311 | &m780_tunerconfig, 0); |
| 312 | |
| 313 | return (chan->fe) ? 0 : -ENODEV; |
| 314 | } |
| 315 | |
| 316 | /****************************************************************************/ |
| 317 | /* Switch control (I2C gates, etc.) *****************************************/ |
| 318 | /****************************************************************************/ |
| 319 | |
| 320 | |
| 321 | static struct stv090x_config fe_cineS2 = { |
| 322 | .device = STV0900, |
| 323 | .demod_mode = STV090x_DUAL, |
| 324 | .clk_mode = STV090x_CLK_EXT, |
| 325 | |
| 326 | .xtal = 27000000, |
| 327 | .address = 0x68, |
| 328 | |
| 329 | .ts1_mode = STV090x_TSMODE_SERIAL_PUNCTURED, |
| 330 | .ts2_mode = STV090x_TSMODE_SERIAL_PUNCTURED, |
| 331 | |
| 332 | .repeater_level = STV090x_RPTLEVEL_16, |
| 333 | |
| 334 | .adc1_range = STV090x_ADC_1Vpp, |
| 335 | .adc2_range = STV090x_ADC_1Vpp, |
| 336 | |
| 337 | .diseqc_envelope_mode = true, |
Oliver Endriss | 5fec185 | 2011-01-10 06:36:13 -0300 | [diff] [blame] | 338 | |
| 339 | .tuner_i2c_lock = cineS2_tuner_i2c_lock, |
| 340 | }; |
| 341 | |
| 342 | static struct stv090x_config fe_cineS2_2 = { |
| 343 | .device = STV0900, |
| 344 | .demod_mode = STV090x_DUAL, |
| 345 | .clk_mode = STV090x_CLK_EXT, |
| 346 | |
| 347 | .xtal = 27000000, |
| 348 | .address = 0x69, |
| 349 | |
| 350 | .ts1_mode = STV090x_TSMODE_SERIAL_PUNCTURED, |
| 351 | .ts2_mode = STV090x_TSMODE_SERIAL_PUNCTURED, |
| 352 | |
| 353 | .repeater_level = STV090x_RPTLEVEL_16, |
| 354 | |
| 355 | .adc1_range = STV090x_ADC_1Vpp, |
| 356 | .adc2_range = STV090x_ADC_1Vpp, |
| 357 | |
| 358 | .diseqc_envelope_mode = true, |
| 359 | |
| 360 | .tuner_i2c_lock = cineS2_tuner_i2c_lock, |
Devin Heitmueller | cbddcba | 2010-03-13 17:53:58 -0300 | [diff] [blame] | 361 | }; |
| 362 | |
| 363 | static struct stv6110x_config tuner_cineS2_0 = { |
| 364 | .addr = 0x60, |
| 365 | .refclk = 27000000, |
| 366 | .clk_div = 1, |
| 367 | }; |
| 368 | |
| 369 | static struct stv6110x_config tuner_cineS2_1 = { |
| 370 | .addr = 0x63, |
| 371 | .refclk = 27000000, |
| 372 | .clk_div = 1, |
| 373 | }; |
| 374 | |
| 375 | static struct ngene_info ngene_info_cineS2 = { |
| 376 | .type = NGENE_SIDEWINDER, |
| 377 | .name = "Linux4Media cineS2 DVB-S2 Twin Tuner", |
| 378 | .io_type = {NGENE_IO_TSIN, NGENE_IO_TSIN}, |
| 379 | .demod_attach = {demod_attach_stv0900, demod_attach_stv0900}, |
| 380 | .tuner_attach = {tuner_attach_stv6110, tuner_attach_stv6110}, |
| 381 | .fe_config = {&fe_cineS2, &fe_cineS2}, |
| 382 | .tuner_config = {&tuner_cineS2_0, &tuner_cineS2_1}, |
| 383 | .lnb = {0x0b, 0x08}, |
| 384 | .tsf = {3, 3}, |
Oliver Endriss | 5fec185 | 2011-01-10 06:36:13 -0300 | [diff] [blame] | 385 | .fw_version = 18, |
| 386 | .msi_supported = true, |
Devin Heitmueller | cbddcba | 2010-03-13 17:53:58 -0300 | [diff] [blame] | 387 | }; |
| 388 | |
| 389 | static struct ngene_info ngene_info_satixS2 = { |
| 390 | .type = NGENE_SIDEWINDER, |
| 391 | .name = "Mystique SaTiX-S2 Dual", |
| 392 | .io_type = {NGENE_IO_TSIN, NGENE_IO_TSIN}, |
| 393 | .demod_attach = {demod_attach_stv0900, demod_attach_stv0900}, |
| 394 | .tuner_attach = {tuner_attach_stv6110, tuner_attach_stv6110}, |
| 395 | .fe_config = {&fe_cineS2, &fe_cineS2}, |
| 396 | .tuner_config = {&tuner_cineS2_0, &tuner_cineS2_1}, |
| 397 | .lnb = {0x0b, 0x08}, |
| 398 | .tsf = {3, 3}, |
Oliver Endriss | 5fec185 | 2011-01-10 06:36:13 -0300 | [diff] [blame] | 399 | .fw_version = 18, |
| 400 | .msi_supported = true, |
Devin Heitmueller | cbddcba | 2010-03-13 17:53:58 -0300 | [diff] [blame] | 401 | }; |
| 402 | |
| 403 | static struct ngene_info ngene_info_satixS2v2 = { |
| 404 | .type = NGENE_SIDEWINDER, |
| 405 | .name = "Mystique SaTiX-S2 Dual (v2)", |
Oliver Endriss | f164396 | 2011-01-10 06:36:18 -0300 | [diff] [blame] | 406 | .io_type = {NGENE_IO_TSIN, NGENE_IO_TSIN, NGENE_IO_TSIN, NGENE_IO_TSIN, |
| 407 | NGENE_IO_TSOUT}, |
Oliver Endriss | 5fec185 | 2011-01-10 06:36:13 -0300 | [diff] [blame] | 408 | .demod_attach = {demod_attach_stv0900, demod_attach_stv0900, cineS2_probe, cineS2_probe}, |
| 409 | .tuner_attach = {tuner_attach_stv6110, tuner_attach_stv6110, tuner_attach_stv6110, tuner_attach_stv6110}, |
| 410 | .fe_config = {&fe_cineS2, &fe_cineS2, &fe_cineS2_2, &fe_cineS2_2}, |
| 411 | .tuner_config = {&tuner_cineS2_0, &tuner_cineS2_1, &tuner_cineS2_0, &tuner_cineS2_1}, |
| 412 | .lnb = {0x0a, 0x08, 0x0b, 0x09}, |
Devin Heitmueller | cbddcba | 2010-03-13 17:53:58 -0300 | [diff] [blame] | 413 | .tsf = {3, 3}, |
Oliver Endriss | 5fec185 | 2011-01-10 06:36:13 -0300 | [diff] [blame] | 414 | .fw_version = 18, |
| 415 | .msi_supported = true, |
Devin Heitmueller | cbddcba | 2010-03-13 17:53:58 -0300 | [diff] [blame] | 416 | }; |
| 417 | |
| 418 | static struct ngene_info ngene_info_cineS2v5 = { |
| 419 | .type = NGENE_SIDEWINDER, |
| 420 | .name = "Linux4Media cineS2 DVB-S2 Twin Tuner (v5)", |
Ralph Metzler | 0f0b270 | 2011-01-10 06:36:15 -0300 | [diff] [blame] | 421 | .io_type = {NGENE_IO_TSIN, NGENE_IO_TSIN, NGENE_IO_TSIN, NGENE_IO_TSIN, |
| 422 | NGENE_IO_TSOUT}, |
Oliver Endriss | 5fec185 | 2011-01-10 06:36:13 -0300 | [diff] [blame] | 423 | .demod_attach = {demod_attach_stv0900, demod_attach_stv0900, cineS2_probe, cineS2_probe}, |
| 424 | .tuner_attach = {tuner_attach_stv6110, tuner_attach_stv6110, tuner_attach_stv6110, tuner_attach_stv6110}, |
| 425 | .fe_config = {&fe_cineS2, &fe_cineS2, &fe_cineS2_2, &fe_cineS2_2}, |
| 426 | .tuner_config = {&tuner_cineS2_0, &tuner_cineS2_1, &tuner_cineS2_0, &tuner_cineS2_1}, |
| 427 | .lnb = {0x0a, 0x08, 0x0b, 0x09}, |
Devin Heitmueller | cbddcba | 2010-03-13 17:53:58 -0300 | [diff] [blame] | 428 | .tsf = {3, 3}, |
Oliver Endriss | 5fec185 | 2011-01-10 06:36:13 -0300 | [diff] [blame] | 429 | .fw_version = 18, |
| 430 | .msi_supported = true, |
Devin Heitmueller | cbddcba | 2010-03-13 17:53:58 -0300 | [diff] [blame] | 431 | }; |
| 432 | |
Oliver Endriss | 5fec185 | 2011-01-10 06:36:13 -0300 | [diff] [blame] | 433 | |
Oliver Endriss | 9d78f46 | 2010-05-16 05:08:49 -0300 | [diff] [blame] | 434 | static struct ngene_info ngene_info_duoFlexS2 = { |
| 435 | .type = NGENE_SIDEWINDER, |
| 436 | .name = "Digital Devices DuoFlex S2 miniPCIe", |
Ralph Metzler | 0f0b270 | 2011-01-10 06:36:15 -0300 | [diff] [blame] | 437 | .io_type = {NGENE_IO_TSIN, NGENE_IO_TSIN, NGENE_IO_TSIN, NGENE_IO_TSIN, |
| 438 | NGENE_IO_TSOUT}, |
Oliver Endriss | 5fec185 | 2011-01-10 06:36:13 -0300 | [diff] [blame] | 439 | .demod_attach = {cineS2_probe, cineS2_probe, cineS2_probe, cineS2_probe}, |
Ralph Metzler | 9ca9efb | 2011-07-03 13:55:06 -0300 | [diff] [blame^] | 440 | .tuner_attach = {tuner_attach_probe, tuner_attach_probe, tuner_attach_probe, tuner_attach_probe}, |
Oliver Endriss | 5fec185 | 2011-01-10 06:36:13 -0300 | [diff] [blame] | 441 | .fe_config = {&fe_cineS2, &fe_cineS2, &fe_cineS2_2, &fe_cineS2_2}, |
| 442 | .tuner_config = {&tuner_cineS2_0, &tuner_cineS2_1, &tuner_cineS2_0, &tuner_cineS2_1}, |
| 443 | .lnb = {0x0a, 0x08, 0x0b, 0x09}, |
Oliver Endriss | 9d78f46 | 2010-05-16 05:08:49 -0300 | [diff] [blame] | 444 | .tsf = {3, 3}, |
Oliver Endriss | 5fec185 | 2011-01-10 06:36:13 -0300 | [diff] [blame] | 445 | .fw_version = 18, |
| 446 | .msi_supported = true, |
Oliver Endriss | 9d78f46 | 2010-05-16 05:08:49 -0300 | [diff] [blame] | 447 | }; |
| 448 | |
Devin Heitmueller | cbddcba | 2010-03-13 17:53:58 -0300 | [diff] [blame] | 449 | static struct ngene_info ngene_info_m780 = { |
| 450 | .type = NGENE_APP, |
| 451 | .name = "Aver M780 ATSC/QAM-B", |
| 452 | |
| 453 | /* Channel 0 is analog, which is currently unsupported */ |
| 454 | .io_type = { NGENE_IO_NONE, NGENE_IO_TSIN }, |
| 455 | .demod_attach = { NULL, demod_attach_lg330x }, |
| 456 | |
| 457 | /* Ensure these are NULL else the frame will call them (as funcs) */ |
| 458 | .tuner_attach = { 0, 0, 0, 0 }, |
| 459 | .fe_config = { NULL, &aver_m780 }, |
| 460 | .avf = { 0 }, |
| 461 | |
| 462 | /* A custom electrical interface config for the demod to bridge */ |
| 463 | .tsf = { 4, 4 }, |
| 464 | .fw_version = 15, |
| 465 | }; |
| 466 | |
| 467 | /****************************************************************************/ |
| 468 | |
| 469 | |
| 470 | |
| 471 | /****************************************************************************/ |
| 472 | /* PCI Subsystem ID *********************************************************/ |
| 473 | /****************************************************************************/ |
| 474 | |
| 475 | #define NGENE_ID(_subvend, _subdev, _driverdata) { \ |
| 476 | .vendor = NGENE_VID, .device = NGENE_PID, \ |
| 477 | .subvendor = _subvend, .subdevice = _subdev, \ |
| 478 | .driver_data = (unsigned long) &_driverdata } |
| 479 | |
| 480 | /****************************************************************************/ |
| 481 | |
| 482 | static const struct pci_device_id ngene_id_tbl[] __devinitdata = { |
| 483 | NGENE_ID(0x18c3, 0xabc3, ngene_info_cineS2), |
| 484 | NGENE_ID(0x18c3, 0xabc4, ngene_info_cineS2), |
| 485 | NGENE_ID(0x18c3, 0xdb01, ngene_info_satixS2), |
| 486 | NGENE_ID(0x18c3, 0xdb02, ngene_info_satixS2v2), |
| 487 | NGENE_ID(0x18c3, 0xdd00, ngene_info_cineS2v5), |
Oliver Endriss | 9d78f46 | 2010-05-16 05:08:49 -0300 | [diff] [blame] | 488 | NGENE_ID(0x18c3, 0xdd10, ngene_info_duoFlexS2), |
| 489 | NGENE_ID(0x18c3, 0xdd20, ngene_info_duoFlexS2), |
Devin Heitmueller | cbddcba | 2010-03-13 17:53:58 -0300 | [diff] [blame] | 490 | NGENE_ID(0x1461, 0x062e, ngene_info_m780), |
| 491 | {0} |
| 492 | }; |
| 493 | MODULE_DEVICE_TABLE(pci, ngene_id_tbl); |
| 494 | |
| 495 | /****************************************************************************/ |
| 496 | /* Init/Exit ****************************************************************/ |
| 497 | /****************************************************************************/ |
| 498 | |
| 499 | static pci_ers_result_t ngene_error_detected(struct pci_dev *dev, |
Ralph Metzler | 9ca9efb | 2011-07-03 13:55:06 -0300 | [diff] [blame^] | 500 | enum pci_channel_state state) |
Devin Heitmueller | cbddcba | 2010-03-13 17:53:58 -0300 | [diff] [blame] | 501 | { |
| 502 | printk(KERN_ERR DEVICE_NAME ": PCI error\n"); |
| 503 | if (state == pci_channel_io_perm_failure) |
| 504 | return PCI_ERS_RESULT_DISCONNECT; |
| 505 | if (state == pci_channel_io_frozen) |
| 506 | return PCI_ERS_RESULT_NEED_RESET; |
| 507 | return PCI_ERS_RESULT_CAN_RECOVER; |
| 508 | } |
| 509 | |
| 510 | static pci_ers_result_t ngene_link_reset(struct pci_dev *dev) |
| 511 | { |
| 512 | printk(KERN_INFO DEVICE_NAME ": link reset\n"); |
| 513 | return 0; |
| 514 | } |
| 515 | |
| 516 | static pci_ers_result_t ngene_slot_reset(struct pci_dev *dev) |
| 517 | { |
| 518 | printk(KERN_INFO DEVICE_NAME ": slot reset\n"); |
| 519 | return 0; |
| 520 | } |
| 521 | |
| 522 | static void ngene_resume(struct pci_dev *dev) |
| 523 | { |
| 524 | printk(KERN_INFO DEVICE_NAME ": resume\n"); |
| 525 | } |
| 526 | |
| 527 | static struct pci_error_handlers ngene_errors = { |
| 528 | .error_detected = ngene_error_detected, |
| 529 | .link_reset = ngene_link_reset, |
| 530 | .slot_reset = ngene_slot_reset, |
| 531 | .resume = ngene_resume, |
| 532 | }; |
| 533 | |
| 534 | static struct pci_driver ngene_pci_driver = { |
| 535 | .name = "ngene", |
| 536 | .id_table = ngene_id_tbl, |
| 537 | .probe = ngene_probe, |
| 538 | .remove = __devexit_p(ngene_remove), |
| 539 | .err_handler = &ngene_errors, |
Ralph Metzler | 1b7c41e | 2011-01-10 06:36:16 -0300 | [diff] [blame] | 540 | .shutdown = ngene_shutdown, |
Devin Heitmueller | cbddcba | 2010-03-13 17:53:58 -0300 | [diff] [blame] | 541 | }; |
| 542 | |
| 543 | static __init int module_init_ngene(void) |
| 544 | { |
| 545 | printk(KERN_INFO |
| 546 | "nGene PCIE bridge driver, Copyright (C) 2005-2007 Micronas\n"); |
| 547 | return pci_register_driver(&ngene_pci_driver); |
| 548 | } |
| 549 | |
| 550 | static __exit void module_exit_ngene(void) |
| 551 | { |
| 552 | pci_unregister_driver(&ngene_pci_driver); |
| 553 | } |
| 554 | |
| 555 | module_init(module_init_ngene); |
| 556 | module_exit(module_exit_ngene); |
| 557 | |
| 558 | MODULE_DESCRIPTION("nGene"); |
| 559 | MODULE_AUTHOR("Micronas, Ralph Metzler, Manfred Voelkel"); |
| 560 | MODULE_LICENSE("GPL"); |