30 #include <linux/module.h>
32 #include <linux/pci.h>
57 chan->
dev->card_info->fe_config[chan->
number];
59 chan->
dev->card_info->tuner_config[chan->
number];
64 i2c = &chan->
dev->channel[0].i2c_adapter;
66 i2c = &chan->
dev->channel[1].i2c_adapter;
100 up(&chan->
dev->pll_mutex);
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);
114 if (chan->
fe->ops.i2c_gate_ctrl)
115 chan->
fe->ops.i2c_gate_ctrl(chan->
fe, 0);
127 return tuner_attach_stv6110(chan);
129 return tuner_attach_tda18271(chan);
137 chan->
dev->card_info->fe_config[chan->
number];
143 i2c = &chan->
dev->channel[0].i2c_adapter;
145 i2c = &chan->
dev->channel[1].i2c_adapter;
157 chan->
fe->analog_demod_priv = chan;
160 0, chan->
dev->card_info->lnb[chan->
number])) {
170 static void cineS2_tuner_i2c_lock(
struct dvb_frontend *fe,
int lock)
177 up(&chan->
dev->pll_mutex);
183 .buf =
val, .len = 1 } };
187 static int i2c_read_reg16(
struct i2c_adapter *adapter,
u8 adr,
190 u8 msg[2] = {reg>>8, reg&0xff};
191 struct i2c_msg msgs[2] = {{.
addr = adr, .flags = 0,
192 .buf =
msg, .len = 2},
194 .buf =
val, .len = 1} };
201 if (i2c_read_reg16(i2c, 0x68+port/2, 0xf100, &val) < 0)
206 static int port_has_drxk(
struct i2c_adapter *i2c,
int port)
210 if (
i2c_read(i2c, 0x29+port, &val) < 0)
221 config.microcode_name =
"drxk_a3.mc";
222 config.qam_demod_parameter_count = 4;
230 chan->
fe->sec_priv = chan;
232 chan->
fe->ops.i2c_gate_ctrl = drxk_gate_ctrl;
246 i2c = &chan->
dev->channel[0].i2c_adapter;
248 i2c = &chan->
dev->channel[1].i2c_adapter;
250 if (port_has_stv0900(i2c, chan->
number)) {
252 fe_conf = chan->
dev->card_info->fe_config[chan->
number];
254 rc = demod_attach_stv0900(chan);
279 }
else if (port_has_drxk(i2c, chan->
number^2)) {
281 demod_attach_drxk(chan, i2c);
291 .demod_address = 0xb2 >> 1,
294 .clock_polarity_flip = 1,
313 &m780_tunerconfig, 0);
322 feconf = chan->
dev->card_info->fe_config[chan->
number];
327 pr_err(
"No DRXD found!\n");
344 #define MICNG_EE_START 0x0100
345 #define MICNG_EE_END 0x0FF0
347 #define MICNG_EETAG_END0 0x0000
348 #define MICNG_EETAG_END1 0xFFFF
356 #define MICNG_EETAG_DRXD1_OSCDEVIATION 0x1000
357 #define MICNG_EETAG_DRXD2_OSCDEVIATION 0x1001
359 #define MICNG_EETAG_MT2060_1_1STIF 0x1100
360 #define MICNG_EETAG_MT2060_2_1STIF 0x1101
364 #define MICNG_EETAG_OEM_FIRST 0xC000
365 #define MICNG_EETAG_OEM_LAST 0xFFEF
367 static int i2c_write_eeprom(
struct i2c_adapter *adapter,
370 u8 m[3] = {(reg >> 8), (reg & 0xff), data};
371 struct i2c_msg msg = {.
addr = adr, .flags = 0, .buf =
m,
381 static int i2c_read_eeprom(
struct i2c_adapter *adapter,
384 u8 msg[2] = {(reg >> 8), (reg & 0xff)};
385 struct i2c_msg msgs[2] = {{.
addr = adr, .flags = 0,
386 .buf =
msg, .len = 2 },
388 .buf =
data, .len = len} };
405 if (i2c_read_eeprom(adapter, 0x50, Addr, EETag,
sizeof(EETag)))
407 tag = (EETag[0] << 8) | EETag[1];
412 Addr +=
sizeof(
u16) + 1 + EETag[2];
416 ": Reached EOEE @ Tag = %04x Length = %3d\n",
422 Length = (
u16) MaxLen;
424 Addr +=
sizeof(
u16) + 1;
425 status = i2c_read_eeprom(adapter, 0x50, Addr, data, Length);
428 if (Length < EETag[2])
435 static int WriteEEProm(
struct i2c_adapter *adapter,
445 if (i2c_read_eeprom(adapter, 0x50, Addr, EETag,
sizeof(EETag)))
447 tag = (EETag[0] << 8) | EETag[1];
452 Addr +=
sizeof(
u16) + 1 + EETag[2];
456 ": Reached EOEE @ Tag = %04x Length = %3d\n",
461 if (Length > EETag[2])
467 Addr +=
sizeof(
u16) + 1;
468 for (i = 0; i <
Length; i++, Addr++) {
469 status = i2c_write_eeprom(adapter, 0x50, Addr, data[i]);
480 status = i2c_read_eeprom(adapter, 0x50, Addr, &Tmp, 1);
485 "eeprom write error\n");
490 ": Timeout polling eeprom\n");
503 stat = ReadEEProm(adapter, tag, 2, buf, &len);
509 *data = (buf[0] << 8) | buf[1];
519 buf[1] = data & 0xff;
520 stat = WriteEEProm(adapter, tag, 2, buf);
533 data = (
u16) deviation;
536 eeprom_write_ushort(adap, 0x1000 + chan->
number, data);
538 if (eeprom_read_ushort(adap, 0x1000 + chan->
number, &data))
568 .diseqc_envelope_mode =
true,
570 .tuner_i2c_lock = cineS2_tuner_i2c_lock,
589 .diseqc_envelope_mode =
true,
591 .tuner_i2c_lock = cineS2_tuner_i2c_lock,
606 static struct ngene_info ngene_info_cineS2 = {
608 .name =
"Linux4Media cineS2 DVB-S2 Twin Tuner",
610 .demod_attach = {demod_attach_stv0900, demod_attach_stv0900},
611 .tuner_attach = {tuner_attach_stv6110, tuner_attach_stv6110},
612 .fe_config = {&fe_cineS2, &fe_cineS2},
613 .tuner_config = {&tuner_cineS2_0, &tuner_cineS2_1},
617 .msi_supported =
true,
620 static struct ngene_info ngene_info_satixS2 = {
622 .name =
"Mystique SaTiX-S2 Dual",
624 .demod_attach = {demod_attach_stv0900, demod_attach_stv0900},
625 .tuner_attach = {tuner_attach_stv6110, tuner_attach_stv6110},
626 .fe_config = {&fe_cineS2, &fe_cineS2},
627 .tuner_config = {&tuner_cineS2_0, &tuner_cineS2_1},
631 .msi_supported =
true,
634 static struct ngene_info ngene_info_satixS2v2 = {
636 .name =
"Mystique SaTiX-S2 Dual (v2)",
639 .demod_attach = {demod_attach_stv0900, demod_attach_stv0900, cineS2_probe, cineS2_probe},
640 .tuner_attach = {tuner_attach_stv6110, tuner_attach_stv6110, tuner_attach_probe, tuner_attach_probe},
641 .fe_config = {&fe_cineS2, &fe_cineS2, &fe_cineS2_2, &fe_cineS2_2},
642 .tuner_config = {&tuner_cineS2_0, &tuner_cineS2_1, &tuner_cineS2_0, &tuner_cineS2_1},
643 .lnb = {0x0a, 0x08, 0x0b, 0x09},
646 .msi_supported =
true,
649 static struct ngene_info ngene_info_cineS2v5 = {
651 .name =
"Linux4Media cineS2 DVB-S2 Twin Tuner (v5)",
654 .demod_attach = {demod_attach_stv0900, demod_attach_stv0900, cineS2_probe, cineS2_probe},
655 .tuner_attach = {tuner_attach_stv6110, tuner_attach_stv6110, tuner_attach_probe, tuner_attach_probe},
656 .fe_config = {&fe_cineS2, &fe_cineS2, &fe_cineS2_2, &fe_cineS2_2},
657 .tuner_config = {&tuner_cineS2_0, &tuner_cineS2_1, &tuner_cineS2_0, &tuner_cineS2_1},
658 .lnb = {0x0a, 0x08, 0x0b, 0x09},
661 .msi_supported =
true,
665 static struct ngene_info ngene_info_duoFlex = {
667 .name =
"Digital Devices DuoFlex PCIe or miniPCIe",
670 .demod_attach = {cineS2_probe, cineS2_probe, cineS2_probe, cineS2_probe},
671 .tuner_attach = {tuner_attach_probe, tuner_attach_probe, tuner_attach_probe, tuner_attach_probe},
672 .fe_config = {&fe_cineS2, &fe_cineS2, &fe_cineS2_2, &fe_cineS2_2},
673 .tuner_config = {&tuner_cineS2_0, &tuner_cineS2_1, &tuner_cineS2_0, &tuner_cineS2_1},
674 .lnb = {0x0a, 0x08, 0x0b, 0x09},
677 .msi_supported =
true,
682 .name =
"Aver M780 ATSC/QAM-B",
686 .demod_attach = {
NULL, demod_attach_lg330x },
689 .tuner_attach = { 0, 0, 0, 0 },
690 .fe_config = {
NULL, &aver_m780 },
700 .demod_address = 0x70,
701 .demod_revision = 0xa2,
702 .demoda_address = 0x00,
711 .demod_address = 0x71,
712 .demod_revision = 0xa2,
713 .demoda_address = 0x00,
720 static struct ngene_info ngene_info_terratec = {
722 .name =
"Terratec Integra/Cinergy2400i Dual DVB-T",
724 .demod_attach = {demod_attach_drxd, demod_attach_drxd},
725 .fe_config = {&fe_terratec_dvbt_0, &fe_terratec_dvbt_1},
737 #define NGENE_ID(_subvend, _subdev, _driverdata) { \
738 .vendor = NGENE_VID, .device = NGENE_PID, \
739 .subvendor = _subvend, .subdevice = _subdev, \
740 .driver_data = (unsigned long) &_driverdata }
745 NGENE_ID(0x18c3, 0xabc3, ngene_info_cineS2),
746 NGENE_ID(0x18c3, 0xabc4, ngene_info_cineS2),
747 NGENE_ID(0x18c3, 0xdb01, ngene_info_satixS2),
748 NGENE_ID(0x18c3, 0xdb02, ngene_info_satixS2v2),
749 NGENE_ID(0x18c3, 0xdd00, ngene_info_cineS2v5),
750 NGENE_ID(0x18c3, 0xdd10, ngene_info_duoFlex),
751 NGENE_ID(0x18c3, 0xdd20, ngene_info_duoFlex),
752 NGENE_ID(0x1461, 0x062e, ngene_info_m780),
753 NGENE_ID(0x153b, 0x1167, ngene_info_terratec),
785 static void ngene_resume(
struct pci_dev *dev)
791 .error_detected = ngene_error_detected,
792 .link_reset = ngene_link_reset,
793 .slot_reset = ngene_slot_reset,
794 .resume = ngene_resume,
799 .id_table = ngene_id_tbl,
802 .err_handler = &ngene_errors,
806 static __init int module_init_ngene(
void)
809 "nGene PCIE bridge driver, Copyright (C) 2005-2007 Micronas\n");
810 return pci_register_driver(&ngene_pci_driver);
813 static __exit void module_exit_ngene(
void)