Lines Matching defs:av7110
3 * av7110.c: initialization and demux stuff
63 #include "av7110.h"
121 static void restart_feeds(struct av7110 *av7110);
136 static void init_av7110_av(struct av7110 *av7110)
139 struct saa7146_dev *dev = av7110->dev;
142 av7110->adac_type = DVB_ADAC_TI;
143 ret = av7110_set_volume(av7110, av7110->mixer.volume_left, av7110->mixer.volume_right);
147 ret = av7110_fw_cmd(av7110, COMTYPE_ENCODER, SetMonitorType,
148 1, (u16) av7110->display_ar);
151 ret = av7110_fw_cmd(av7110, COMTYPE_ENCODER, SetPanScanType,
152 1, av7110->display_panscan);
156 ret = av7110_fw_cmd(av7110, COMTYPE_ENCODER, SetWSSConfig, 2, 2, wss_cfg_4_3);
159 ret = av7110_fw_cmd(av7110, COMTYPE_ENCODER, SetWSSConfig, 2, 3, wss_cfg_16_9);
163 ret = av7710_set_video_mode(av7110, vidmode);
169 av7110->analog_tuner_flags = 0;
170 av7110->current_input = 0;
172 av7110_fw_cmd(av7110, COMTYPE_AUDIODAC, ADSwitch, 1, 0); // SPDIF on
173 if (i2c_writereg(av7110, 0x20, 0x00, 0x00) == 1) {
175 av7110->dvb_adapter.num);
176 av7110->adac_type = DVB_ADAC_CRYSTAL;
177 i2c_writereg(av7110, 0x20, 0x01, 0xd2);
178 i2c_writereg(av7110, 0x20, 0x02, 0x49);
179 i2c_writereg(av7110, 0x20, 0x03, 0x00);
180 i2c_writereg(av7110, 0x20, 0x04, 0x00);
185 } else if (0 == av7110_init_analog_module(av7110)) {
190 av7110->dvb_adapter.num);
191 av7110->adac_type = DVB_ADAC_NONE;
194 av7110->adac_type = adac;
196 av7110->adac_type, av7110->dvb_adapter.num);
199 if (av7110->adac_type == DVB_ADAC_NONE || av7110->adac_type == DVB_ADAC_MSP34x0) {
201 ret = av7110_fw_cmd(av7110, COMTYPE_AUDIODAC, MainSwitch, 1, 0);
204 ret = av7110_fw_cmd(av7110, COMTYPE_AUDIODAC, ADSwitch, 1, 1);
208 ((av7110->dev->pci->subsystem_vendor == 0x110a) ||
209 (av7110->dev->pci->subsystem_vendor == 0x13c2)) &&
210 (av7110->dev->pci->subsystem_device == 0x0000)) {
217 av7110_fw_cmd(av7110, COMTYPE_AUDIODAC, SpdifSwitch, 1, 0); // SPDIF on
219 ret = av7110_set_volume(av7110, av7110->mixer.volume_left, av7110->mixer.volume_right);
224 static void recover_arm(struct av7110 *av7110)
226 dprintk(4, "%p\n",av7110);
228 av7110_bootarm(av7110);
231 init_av7110_av(av7110);
234 if (av7110->recover)
235 av7110->recover(av7110);
237 restart_feeds(av7110);
240 av7110_check_ir_config(av7110, true);
244 static void av7110_arm_sync(struct av7110 *av7110)
246 if (av7110->arm_thread)
247 kthread_stop(av7110->arm_thread);
249 av7110->arm_thread = NULL;
254 struct av7110 *av7110 = data;
258 dprintk(4, "%p\n",av7110);
261 timeout = wait_event_interruptible_timeout(av7110->arm_wait,
269 if (!av7110->arm_ready)
273 av7110_check_ir_config(av7110, false);
276 if (mutex_lock_interruptible(&av7110->dcomlock))
278 newloops = rdebi(av7110, DEBINOSWAP, STATUS_LOOPS, 0, 2);
279 mutex_unlock(&av7110->dcomlock);
281 if (newloops == av7110->arm_loops || av7110->arm_errors > 3) {
283 av7110->dvb_adapter.num);
285 recover_arm(av7110);
287 if (mutex_lock_interruptible(&av7110->dcomlock))
289 newloops = rdebi(av7110, DEBINOSWAP, STATUS_LOOPS, 0, 2) - 1;
290 mutex_unlock(&av7110->dcomlock);
292 av7110->arm_loops = newloops;
293 av7110->arm_errors = 0;
308 struct av7110 *av7110)
346 &av7110->p2t_filter[dvbdmxfilter->index]);
365 static inline void start_debi_dma(struct av7110 *av7110, int dir,
369 if (saa7146_wait_for_debi_done(av7110->dev, 0)) {
374 SAA7146_ISR_CLEAR(av7110->dev, MASK_19); /* for good measure */
375 SAA7146_IER_ENABLE(av7110->dev, MASK_19);
379 iwdebi(av7110, DEBISWAB, addr, 0, (len + 3) & ~3);
381 irdebi(av7110, DEBISWAB, addr, 0, len);
386 struct av7110 *av7110 = (struct av7110 *)cookie;
387 int type = av7110->debitype;
396 jiffies, saa7146_read(av7110->dev, PSR),
397 saa7146_read(av7110->dev, SSR));
400 av7110->debitype = -1;
405 dvb_dmx_swfilter_packets(&av7110->demux,
406 (const u8 *) av7110->debi_virt,
407 av7110->debilen / 188);
412 if (av7110->demux.recording)
413 av7110_record_cb(&av7110->p2t[handle],
414 (u8 *) av7110->debi_virt,
415 av7110->debilen);
422 if (av7110->handle2filter[handle])
423 DvbDmxFilterCallback((u8 *)av7110->debi_virt,
424 av7110->debilen, NULL, 0,
425 av7110->handle2filter[handle],
426 DMX_OK, av7110);
432 u8 *data = av7110->debi_virt;
440 av7110->ci_slot[data[0]].flags = flags;
442 ci_get_data(&av7110->ci_rbuffer,
443 av7110->debi_virt,
444 av7110->debilen);
450 CI_handle(av7110, (u8 *)av7110->debi_virt, av7110->debilen);
455 ((s8*)av7110->debi_virt)[Reserved_SIZE - 1] = 0;
456 printk("%s\n", (s8 *) av7110->debi_virt);
472 spin_lock(&av7110->debilock);
474 iwdebi(av7110, DEBINOSWAP, xfer, 0, 2);
475 ARM_ClearMailBox(av7110);
476 spin_unlock(&av7110->debilock);
479 /* irq from av7110 firmware writing the mailbox register in the DPRAM */
482 struct av7110 *av7110 = (struct av7110 *)cookie;
486 if (av7110->debitype != -1)
489 jiffies, saa7146_read(av7110->dev, PSR),
490 saa7146_read(av7110->dev, SSR));
492 if (saa7146_wait_for_debi_done(av7110->dev, 0)) {
497 spin_lock(&av7110->debilock);
498 ARM_ClearIrq(av7110);
500 /* see what the av7110 wants */
501 av7110->debitype = irdebi(av7110, DEBINOSWAP, IRQ_STATE, 0, 2);
502 av7110->debilen = irdebi(av7110, DEBINOSWAP, IRQ_STATE_EXT, 0, 2);
503 rxbuf = irdebi(av7110, DEBINOSWAP, RX_BUFF, 0, 2);
504 txbuf = irdebi(av7110, DEBINOSWAP, TX_BUFF, 0, 2);
505 len = (av7110->debilen + 3) & ~3;
508 dprintk(8, "GPIO0 irq 0x%04x %d\n", av7110->debitype, av7110->debilen);
510 switch (av7110->debitype & 0xff) {
521 av7110->video_size.w = irdebi(av7110, DEBINOSWAP, STATUS_MPEG_WIDTH, 0, 2);
522 h_ar = irdebi(av7110, DEBINOSWAP, STATUS_MPEG_HEIGHT_AR, 0, 2);
524 iwdebi(av7110, DEBINOSWAP, IRQ_STATE_EXT, 0, 2);
525 iwdebi(av7110, DEBINOSWAP, RX_BUFF, 0, 2);
527 av7110->video_size.h = h_ar & 0xfff;
530 event.u.size.w = av7110->video_size.w;
531 event.u.size.h = av7110->video_size.h;
535 av7110->video_size.aspect_ratio = VIDEO_FORMAT_16_9;
537 av7110->videostate.video_format = VIDEO_FORMAT_16_9;
540 av7110->video_size.aspect_ratio = VIDEO_FORMAT_221_1;
542 av7110->videostate.video_format = VIDEO_FORMAT_221_1;
545 av7110->video_size.aspect_ratio = VIDEO_FORMAT_4_3;
547 av7110->videostate.video_format = VIDEO_FORMAT_4_3;
551 av7110->video_size.w, av7110->video_size.h,
552 av7110->video_size.aspect_ratio);
554 dvb_video_add_event(av7110, &event);
561 struct dvb_ringbuffer *cibuf = &av7110->ci_wbuffer;
565 iwdebi(av7110, DEBINOSWAP, IRQ_STATE_EXT, 0, 2);
566 iwdebi(av7110, DEBINOSWAP, TX_LEN, 0, 2);
567 iwdebi(av7110, DEBINOSWAP, TX_BUFF, 0, 2);
573 iwdebi(av7110, DEBINOSWAP, IRQ_STATE_EXT, 0, 2);
574 iwdebi(av7110, DEBINOSWAP, TX_LEN, 0, 2);
575 iwdebi(av7110, DEBINOSWAP, TX_BUFF, 0, 2);
580 dvb_ringbuffer_read(cibuf, av7110->debi_virt, len);
582 iwdebi(av7110, DEBINOSWAP, TX_LEN, len, 2);
583 iwdebi(av7110, DEBINOSWAP, IRQ_STATE_EXT, len, 2);
585 start_debi_dma(av7110, DEBI_WRITE, DPRAM_BASE + txbuf, len);
586 spin_unlock(&av7110->debilock);
592 if (!av7110->playing) {
593 iwdebi(av7110, DEBINOSWAP, IRQ_STATE_EXT, 0, 2);
594 iwdebi(av7110, DEBINOSWAP, TX_LEN, 0, 2);
595 iwdebi(av7110, DEBINOSWAP, TX_BUFF, 0, 2);
599 if (av7110->debitype & 0x100) {
600 spin_lock(&av7110->aout.lock);
601 len = av7110_pes_play(av7110->debi_virt, &av7110->aout, 2048);
602 spin_unlock(&av7110->aout.lock);
604 if (len <= 0 && (av7110->debitype & 0x200)
605 &&av7110->videostate.play_state != VIDEO_FREEZED) {
606 spin_lock(&av7110->avout.lock);
607 len = av7110_pes_play(av7110->debi_virt, &av7110->avout, 2048);
608 spin_unlock(&av7110->avout.lock);
611 iwdebi(av7110, DEBINOSWAP, IRQ_STATE_EXT, 0, 2);
612 iwdebi(av7110, DEBINOSWAP, TX_LEN, 0, 2);
613 iwdebi(av7110, DEBINOSWAP, TX_BUFF, 0, 2);
617 iwdebi(av7110, DEBINOSWAP, TX_LEN, len, 2);
618 iwdebi(av7110, DEBINOSWAP, IRQ_STATE_EXT, len, 2);
620 start_debi_dma(av7110, DEBI_WRITE, DPRAM_BASE + txbuf, len);
621 spin_unlock(&av7110->debilock);
625 len = av7110->debilen;
628 av7110->bmp_state = BMP_LOADED;
629 iwdebi(av7110, DEBINOSWAP, IRQ_STATE_EXT, 0, 2);
630 iwdebi(av7110, DEBINOSWAP, TX_LEN, 0, 2);
631 iwdebi(av7110, DEBINOSWAP, TX_BUFF, 0, 2);
632 wake_up(&av7110->bmpq);
636 if (len > av7110->bmplen)
637 len = av7110->bmplen;
640 iwdebi(av7110, DEBINOSWAP, TX_LEN, len, 2);
641 iwdebi(av7110, DEBINOSWAP, IRQ_STATE_EXT, len, 2);
642 memcpy(av7110->debi_virt, av7110->bmpbuf+av7110->bmpp, len);
643 av7110->bmpp += len;
644 av7110->bmplen -= len;
646 start_debi_dma(av7110, DEBI_WRITE, DPRAM_BASE+txbuf, len);
647 spin_unlock(&av7110->debilock);
656 iwdebi(av7110, DEBINOSWAP, RX_BUFF, 0, 2);
664 start_debi_dma(av7110, DEBI_READ, DPRAM_BASE+rxbuf, len);
665 spin_unlock(&av7110->debilock);
670 iwdebi(av7110, DEBINOSWAP, RX_BUFF, 0, 2);
673 start_debi_dma(av7110, DEBI_READ, Reserved, len);
674 spin_unlock(&av7110->debilock);
678 if (av7110->ir.ir_handler)
679 av7110->ir.ir_handler(av7110,
680 swahw32(irdebi(av7110, DEBINOSWAP, Reserved, 0, 4)));
681 iwdebi(av7110, DEBINOSWAP, RX_BUFF, 0, 2);
686 av7110->debitype, av7110->debilen);
689 av7110->debitype = -1;
690 ARM_ClearMailBox(av7110);
691 spin_unlock(&av7110->debilock);
700 struct av7110 *av7110 = dvbdev->priv;
702 dprintk(4, "%p\n", av7110);
705 return av7110_osd_cmd(av7110, (osd_cmd_t *) parg);
707 return av7110_osd_capability(av7110, (osd_cap_t *) parg);
730 static inline int SetPIDs(struct av7110 *av7110, u16 vpid, u16 apid, u16 ttpid,
735 dprintk(4, "%p\n", av7110);
740 av7110->pids[DMX_PES_VIDEO] = 0;
741 av7110->pids[DMX_PES_AUDIO] = 0;
742 av7110->pids[DMX_PES_TELETEXT] = 0;
743 av7110->pids[DMX_PES_PCR] = 0;
746 if (av7110->audiostate.bypass_mode)
749 return av7110_fw_cmd(av7110, COMTYPE_PIDFILTER, MultiPID, 6,
753 int ChangePIDs(struct av7110 *av7110, u16 vpid, u16 apid, u16 ttpid,
757 dprintk(4, "%p\n", av7110);
759 if (mutex_lock_interruptible(&av7110->pid_mutex))
763 av7110->pids[DMX_PES_VIDEO] = vpid;
765 av7110->pids[DMX_PES_AUDIO] = apid;
767 av7110->pids[DMX_PES_TELETEXT] = ttpid;
769 av7110->pids[DMX_PES_PCR] = pcrpid;
771 av7110->pids[DMX_PES_SUBTITLE] = 0;
773 if (av7110->fe_synced) {
774 pcrpid = av7110->pids[DMX_PES_PCR];
775 ret = SetPIDs(av7110, vpid, apid, ttpid, subpid, pcrpid);
778 mutex_unlock(&av7110->pid_mutex);
790 struct av7110 *av7110 = dvbdmxfeed->demux->priv;
797 dprintk(4, "%p\n", av7110);
799 if (av7110->full_ts)
814 av7110_p2t_init(&av7110->p2t_filter[dvbdmxfilter->index], dvbdmxfeed);
822 ret = av7110_fw_request(av7110, buf, 20, &handle, 1);
834 av7110->handle2filter[handle] = dvbdmxfilter;
842 struct av7110 *av7110 = dvbdmxfilter->feed->demux->priv;
848 dprintk(4, "%p\n", av7110);
850 if (av7110->full_ts)
860 av7110->handle2filter[handle] = NULL;
865 ret = av7110_fw_request(av7110, buf, 3, answ, 2);
881 struct av7110 *av7110 = dvbdmx->priv;
886 dprintk(4, "%p\n", av7110);
893 ret = ChangePIDs(av7110, npids[1], npids[0], npids[2], npids[3], npids[4]);
899 ret = ChangePIDs(av7110, npids[1], npids[0], npids[2], npids[3], npids[4]);
905 if (av7110->fe_synced)
907 ret = av7110_fw_cmd(av7110, COMTYPE_PIDFILTER, Scan, 0);
912 if ((dvbdmxfeed->ts_type & TS_PACKET) && !av7110->full_ts) {
914 ret = av7110_av_start_record(av7110, RP_AUDIO, dvbdmxfeed);
916 ret = av7110_av_start_record(av7110, RP_VIDEO, dvbdmxfeed);
924 struct av7110 *av7110 = dvbdmx->priv;
930 dprintk(4, "%p\n", av7110);
933 ret = av7110_av_stop(av7110, dvbdmxfeed->pes_type ? RP_VIDEO : RP_AUDIO);
936 if (!av7110->rec_mode)
938 if (!av7110->playing)
958 ret = ChangePIDs(av7110, npids[1], npids[0], npids[2], npids[3], npids[4]);
965 struct av7110 *av7110 = demux->priv;
968 dprintk(4, "%p\n", av7110);
973 if (!av7110->full_ts && feed->pid > 0x1fff)
985 dvb_ringbuffer_flush_spinlock_wakeup(&av7110->avout);
986 dvb_ringbuffer_flush_spinlock_wakeup(&av7110->aout);
987 ret = av7110_av_start_play(av7110,RP_AV);
1002 if (av7110->full_ts) {
1033 struct av7110 *av7110 = demux->priv;
1035 dprintk(4, "%p\n", av7110);
1054 if (av7110->full_ts) {
1078 static void restart_feeds(struct av7110 *av7110)
1080 struct dvb_demux *dvbdmx = &av7110->demux;
1086 dprintk(4, "%p\n", av7110);
1088 mode = av7110->playing;
1089 av7110->playing = 0;
1090 av7110->rec_mode = 0;
1092 feeding = av7110->feeding1; /* full_ts mod */
1111 av7110->feeding1 = feeding; /* full_ts mod */
1114 av7110_av_start_play(av7110, mode);
1124 struct av7110 *av7110;
1130 av7110 = dvbdemux->priv;
1132 dprintk(4, "%p\n", av7110);
1137 ret = av7110_fw_request(av7110, &tag, 0, fwstc, 4);
1162 struct av7110* av7110 = fe->dvb->priv;
1166 return Set22K(av7110, 1);
1169 return Set22K(av7110, 0);
1179 struct av7110* av7110 = fe->dvb->priv;
1181 return av7110_diseqc_send(av7110, cmd->msg_len, cmd->msg, -1);
1187 struct av7110* av7110 = fe->dvb->priv;
1189 return av7110_diseqc_send(av7110, 0, NULL, minicmd);
1193 static int stop_ts_capture(struct av7110 *budget)
1205 static int start_ts_capture(struct av7110 *budget)
1222 struct av7110 *budget = demux->priv;
1225 dprintk(2, "av7110: %p\n", budget);
1237 struct av7110 *budget = demux->priv;
1250 struct av7110 *budget = (struct av7110 *)cookie;
1281 static int av7110_register(struct av7110 *av7110)
1284 struct dvb_demux *dvbdemux = &av7110->demux;
1285 struct dvb_demux *dvbdemux1 = &av7110->demux1;
1287 dprintk(4, "%p\n", av7110);
1289 if (av7110->registered)
1292 av7110->registered = 1;
1294 dvbdemux->priv = (void *) av7110;
1297 av7110->handle2filter[i] = NULL;
1299 dvbdemux->filternum = (av7110->full_ts) ? 256 : 32;
1300 dvbdemux->feednum = (av7110->full_ts) ? 256 : 32;
1307 dvb_dmx_init(&av7110->demux);
1308 av7110->demux.dmx.get_stc = dvb_get_stc;
1310 av7110->dmxdev.filternum = (av7110->full_ts) ? 256 : 32;
1311 av7110->dmxdev.demux = &dvbdemux->dmx;
1312 av7110->dmxdev.capabilities = 0;
1314 dvb_dmxdev_init(&av7110->dmxdev, &av7110->dvb_adapter);
1316 av7110->hw_frontend.source = DMX_FRONTEND_0;
1318 ret = dvbdemux->dmx.add_frontend(&dvbdemux->dmx, &av7110->hw_frontend);
1323 av7110->mem_frontend.source = DMX_MEMORY_FE;
1325 ret = dvbdemux->dmx.add_frontend(&dvbdemux->dmx, &av7110->mem_frontend);
1331 &av7110->hw_frontend);
1335 av7110_av_register(av7110);
1336 av7110_ca_register(av7110);
1339 dvb_register_device(&av7110->dvb_adapter, &av7110->osd_dev,
1340 &dvbdev_osd, av7110, DVB_DEVICE_OSD);
1343 dvb_net_init(&av7110->dvb_adapter, &av7110->dvb_net, &dvbdemux->dmx);
1349 dvbdemux1->priv = (void *) av7110;
1360 dvb_dmx_init(&av7110->demux1);
1362 av7110->dmxdev1.filternum = 256;
1363 av7110->dmxdev1.demux = &dvbdemux1->dmx;
1364 av7110->dmxdev1.capabilities = 0;
1366 dvb_dmxdev_init(&av7110->dmxdev1, &av7110->dvb_adapter);
1368 dvb_net_init(&av7110->dvb_adapter, &av7110->dvb_net1, &dvbdemux1->dmx);
1375 static void dvb_unregister(struct av7110 *av7110)
1377 struct dvb_demux *dvbdemux = &av7110->demux;
1378 struct dvb_demux *dvbdemux1 = &av7110->demux1;
1380 dprintk(4, "%p\n", av7110);
1382 if (!av7110->registered)
1386 dvb_net_release(&av7110->dvb_net1);
1388 dvb_dmxdev_release(&av7110->dmxdev1);
1389 dvb_dmx_release(&av7110->demux1);
1392 dvb_net_release(&av7110->dvb_net);
1395 dvbdemux->dmx.remove_frontend(&dvbdemux->dmx, &av7110->hw_frontend);
1396 dvbdemux->dmx.remove_frontend(&dvbdemux->dmx, &av7110->mem_frontend);
1398 dvb_dmxdev_release(&av7110->dmxdev);
1399 dvb_dmx_release(&av7110->demux);
1401 if (av7110->fe != NULL) {
1402 dvb_unregister_frontend(av7110->fe);
1403 dvb_frontend_detach(av7110->fe);
1405 dvb_unregister_device(av7110->osd_dev);
1406 av7110_av_unregister(av7110);
1407 av7110_ca_unregister(av7110);
1415 int i2c_writereg(struct av7110 *av7110, u8 id, u8 reg, u8 val)
1424 return i2c_transfer(&av7110->i2c_adap, &msgs, 1);
1427 u8 i2c_readreg(struct av7110 *av7110, u8 id, u8 reg)
1439 i2c_transfer(&av7110->i2c_adap, msgs, 2);
1449 static int check_firmware(struct av7110* av7110)
1455 ptr = av7110->bin_fw;
1458 printk("dvb-ttpci: this is not an av7110 firmware\n");
1476 av7110->bin_dpram = ptr;
1477 av7110->size_dpram = len;
1487 len > ((av7110->bin_fw + av7110->size_fw) - ptr)) {
1495 av7110->bin_root = ptr;
1496 av7110->size_root = len;
1500 static void put_firmware(struct av7110* av7110)
1502 vfree(av7110->bin_fw);
1505 static int get_firmware(struct av7110* av7110)
1510 /* request the av7110 firmware, this will block until someone uploads it */
1511 ret = request_firmware(&fw, "dvb-ttpci-01.fw", &av7110->dev->pci->dev);
1533 av7110->bin_fw = vmalloc(fw->size);
1534 if (NULL == av7110->bin_fw) {
1540 memcpy(av7110->bin_fw, fw->data, fw->size);
1541 av7110->size_fw = fw->size;
1542 if ((ret = check_firmware(av7110)))
1543 vfree(av7110->bin_fw);
1551 struct av7110* av7110 = fe->dvb->priv;
1574 if (i2c_transfer (&av7110->i2c_adap, &msg, 1) != 1)
1587 struct av7110* av7110 = fe->dvb->priv;
1601 if (i2c_transfer(&av7110->i2c_adap, &msg, 1) != 1)
1618 struct av7110* av7110 = fe->dvb->priv;
1631 if (i2c_transfer(&av7110->i2c_adap, &msg, 1) != 1)
1644 struct av7110* av7110 = fe->dvb->priv;
1659 if (i2c_transfer(&av7110->i2c_adap, &msg, 1) != 1)
1675 struct av7110* av7110 = fe->dvb->priv;
1694 if (i2c_transfer(&av7110->i2c_adap, &msg, 1) != 1)
1702 struct av7110* av7110 = fe->dvb->priv;
1704 return request_firmware(fw, name, &av7110->dev->pci->dev);
1812 struct av7110* av7110 = fe->dvb->priv;
1838 if (i2c_transfer(&av7110->i2c_adap, &msg, 1) != 1) {
1847 if (i2c_transfer(&av7110->i2c_adap, &readmsg, 1) == 1)
1867 struct av7110* av7110 = fe->dvb->priv;
1894 if (i2c_transfer (&av7110->i2c_adap, &msg, 1) != 1) return -EIO;
1904 static int av7110_fe_lock_fix(struct av7110* av7110, fe_status_t status)
1909 av7110->fe_status = status;
1911 if (av7110->fe_synced == synced)
1914 if (av7110->playing) {
1915 av7110->fe_synced = synced;
1919 if (mutex_lock_interruptible(&av7110->pid_mutex))
1923 ret = SetPIDs(av7110, av7110->pids[DMX_PES_VIDEO],
1924 av7110->pids[DMX_PES_AUDIO],
1925 av7110->pids[DMX_PES_TELETEXT], 0,
1926 av7110->pids[DMX_PES_PCR]);
1928 ret = av7110_fw_cmd(av7110, COMTYPE_PIDFILTER, Scan, 0);
1930 ret = SetPIDs(av7110, 0, 0, 0, 0, 0);
1932 ret = av7110_fw_cmd(av7110, COMTYPE_PID_FILTER, FlushTSQueue, 0);
1934 ret = av7110_wait_msgstate(av7110, GPMQBusy);
1939 av7110->fe_synced = synced;
1941 mutex_unlock(&av7110->pid_mutex);
1947 struct av7110* av7110 = fe->dvb->priv;
1949 int ret = av7110_fe_lock_fix(av7110, 0);
1951 av7110->saved_fe_params = *params;
1952 ret = av7110->fe_set_frontend(fe, params);
1959 struct av7110* av7110 = fe->dvb->priv;
1961 int ret = av7110_fe_lock_fix(av7110, 0);
1963 ret = av7110->fe_init(fe);
1969 struct av7110* av7110 = fe->dvb->priv;
1972 int ret = av7110->fe_read_status(fe, status);
1974 if (((*status ^ av7110->fe_status) & FE_HAS_LOCK) && (*status & FE_HAS_LOCK))
1975 ret = av7110_fe_lock_fix(av7110, *status);
1981 struct av7110* av7110 = fe->dvb->priv;
1983 int ret = av7110_fe_lock_fix(av7110, 0);
1985 ret = av7110->fe_diseqc_reset_overload(fe);
1992 struct av7110* av7110 = fe->dvb->priv;
1994 int ret = av7110_fe_lock_fix(av7110, 0);
1996 av7110->saved_master_cmd = *cmd;
1997 ret = av7110->fe_diseqc_send_master_cmd(fe, cmd);
2004 struct av7110* av7110 = fe->dvb->priv;
2006 int ret = av7110_fe_lock_fix(av7110, 0);
2008 av7110->saved_minicmd = minicmd;
2009 ret = av7110->fe_diseqc_send_burst(fe, minicmd);
2016 struct av7110* av7110 = fe->dvb->priv;
2018 int ret = av7110_fe_lock_fix(av7110, 0);
2020 av7110->saved_tone = tone;
2021 ret = av7110->fe_set_tone(fe, tone);
2028 struct av7110* av7110 = fe->dvb->priv;
2030 int ret = av7110_fe_lock_fix(av7110, 0);
2032 av7110->saved_voltage = voltage;
2033 ret = av7110->fe_set_voltage(fe, voltage);
2040 struct av7110* av7110 = fe->dvb->priv;
2042 int ret = av7110_fe_lock_fix(av7110, 0);
2044 ret = av7110->fe_dishnetwork_send_legacy_command(fe, cmd);
2048 static void dvb_s_recover(struct av7110* av7110)
2050 av7110_fe_init(av7110->fe);
2052 av7110_fe_set_voltage(av7110->fe, av7110->saved_voltage);
2053 if (av7110->saved_master_cmd.msg_len) {
2055 av7110_fe_diseqc_send_master_cmd(av7110->fe, &av7110->saved_master_cmd);
2058 av7110_fe_diseqc_send_burst(av7110->fe, av7110->saved_minicmd);
2060 av7110_fe_set_tone(av7110->fe, av7110->saved_tone);
2062 av7110_fe_set_frontend(av7110->fe, &av7110->saved_fe_params);
2065 static u8 read_pwm(struct av7110* av7110)
2072 if ((i2c_transfer(&av7110->i2c_adap, msg, 2) != 2) || (pwm == 0xff))
2078 static int frontend_init(struct av7110 *av7110)
2082 if (av7110->dev->pci->subsystem_vendor == 0x110a) {
2083 switch(av7110->dev->pci->subsystem_device) {
2085 av7110->fe = dvb_attach(ves1820_attach, &philips_cd1516_config,
2086 &av7110->i2c_adap, read_pwm(av7110));
2087 if (av7110->fe) {
2088 av7110->fe->ops.tuner_ops.set_params = philips_cd1516_tuner_set_params;
2093 } else if (av7110->dev->pci->subsystem_vendor == 0x13c2) {
2094 switch(av7110->dev->pci->subsystem_device) {
2100 av7110->fe = dvb_attach(ves1x93_attach, &alps_bsrv2_config, &av7110->i2c_adap);
2101 if (av7110->fe) {
2102 av7110->fe->ops.tuner_ops.set_params = alps_bsrv2_tuner_set_params;
2103 av7110->fe->ops.diseqc_send_master_cmd = av7110_diseqc_send_master_cmd;
2104 av7110->fe->ops.diseqc_send_burst = av7110_diseqc_send_burst;
2105 av7110->fe->ops.set_tone = av7110_set_tone;
2106 av7110->recover = dvb_s_recover;
2111 av7110->fe = dvb_attach(stv0299_attach, &alps_bsru6_config, &av7110->i2c_adap);
2112 if (av7110->fe) {
2113 av7110->fe->ops.tuner_ops.set_params = alps_bsru6_tuner_set_params;
2114 av7110->fe->tuner_priv = &av7110->i2c_adap;
2116 av7110->fe->ops.diseqc_send_master_cmd = av7110_diseqc_send_master_cmd;
2117 av7110->fe->ops.diseqc_send_burst = av7110_diseqc_send_burst;
2118 av7110->fe->ops.set_tone = av7110_set_tone;
2119 av7110->recover = dvb_s_recover;
2124 av7110->fe = dvb_attach(tda8083_attach, &grundig_29504_451_config, &av7110->i2c_adap);
2125 if (av7110->fe) {
2126 av7110->fe->ops.tuner_ops.set_params = grundig_29504_451_tuner_set_params;
2127 av7110->fe->ops.diseqc_send_master_cmd = av7110_diseqc_send_master_cmd;
2128 av7110->fe->ops.diseqc_send_burst = av7110_diseqc_send_burst;
2129 av7110->fe->ops.set_tone = av7110_set_tone;
2130 av7110->recover = dvb_s_recover;
2135 switch(av7110->dev->pci->subsystem_device) {
2138 av7110->fe = dvb_attach(ves1820_attach, &philips_cd1516_config, &av7110->i2c_adap,
2139 read_pwm(av7110));
2140 if (av7110->fe) {
2141 av7110->fe->ops.tuner_ops.set_params = philips_cd1516_tuner_set_params;
2146 av7110->fe = dvb_attach(ves1820_attach, &alps_tdbe2_config, &av7110->i2c_adap,
2147 read_pwm(av7110));
2148 if (av7110->fe) {
2149 av7110->fe->ops.tuner_ops.set_params = alps_tdbe2_tuner_set_params;
2157 av7110->fe = dvb_attach(sp8870_attach, &alps_tdlb7_config, &av7110->i2c_adap);
2158 if (av7110->fe) {
2159 av7110->fe->ops.tuner_ops.set_params = alps_tdlb7_tuner_set_params;
2166 av7110->fe = dvb_attach(l64781_attach, &grundig_29504_401_config, &av7110->i2c_adap);
2167 if (av7110->fe)
2168 av7110->fe->ops.tuner_ops.set_params = grundig_29504_401_tuner_set_params;
2173 av7110->fe = dvb_attach(ves1820_attach, &alps_tdbe2_config, &av7110->i2c_adap, read_pwm(av7110));
2174 if (av7110->fe) {
2175 av7110->fe->ops.tuner_ops.set_params = alps_tdbe2_tuner_set_params;
2181 av7110->fe = dvb_attach(ves1x93_attach, &alps_bsrv2_config, &av7110->i2c_adap);
2182 if (av7110->fe) {
2183 av7110->fe->ops.tuner_ops.set_params = alps_bsrv2_tuner_set_params;
2184 av7110->fe->ops.diseqc_send_master_cmd = av7110_diseqc_send_master_cmd;
2185 av7110->fe->ops.diseqc_send_burst = av7110_diseqc_send_burst;
2186 av7110->fe->ops.set_tone = av7110_set_tone;
2187 av7110->recover = dvb_s_recover;
2193 av7110->fe = dvb_attach(tda8083_attach, &grundig_29504_451_config, &av7110->i2c_adap);
2194 if (av7110->fe) {
2195 av7110->fe->ops.tuner_ops.set_params = grundig_29504_451_tuner_set_params;
2196 av7110->fe->ops.diseqc_send_master_cmd = av7110_diseqc_send_master_cmd;
2197 av7110->fe->ops.diseqc_send_burst = av7110_diseqc_send_burst;
2198 av7110->fe->ops.set_tone = av7110_set_tone;
2199 av7110->recover = dvb_s_recover;
2205 av7110->fe = dvb_attach(stv0297_attach, &nexusca_stv0297_config, &av7110->i2c_adap);
2206 if (av7110->fe) {
2207 av7110->fe->ops.tuner_ops.set_params = nexusca_stv0297_tuner_set_params;
2210 saa7146_setgpio(av7110->dev, 1, SAA7146_GPIO_OUTLO); // TDA9819 pin9(STD)
2211 saa7146_setgpio(av7110->dev, 3, SAA7146_GPIO_OUTLO); // TDA9819 pin30(VIF)
2214 av7110->dev->i2c_bitrate = SAA7146_I2C_BUS_BIT_RATE_240;
2221 av7110->fe = dvb_attach(stv0299_attach, &alps_bsbe1_config, &av7110->i2c_adap);
2222 if (av7110->fe) {
2223 av7110->fe->ops.tuner_ops.set_params = alps_bsbe1_tuner_set_params;
2224 av7110->fe->tuner_priv = &av7110->i2c_adap;
2226 if (dvb_attach(lnbp21_attach, av7110->fe, &av7110->i2c_adap, 0, 0) == NULL) {
2228 if (av7110->fe->ops.release)
2229 av7110->fe->ops.release(av7110->fe);
2230 av7110->fe = NULL;
2232 av7110->fe->ops.dishnetwork_send_legacy_command = NULL;
2233 av7110->recover = dvb_s_recover;
2240 if (!av7110->fe) {
2243 av7110->dev->pci->vendor,
2244 av7110->dev->pci->device,
2245 av7110->dev->pci->subsystem_vendor,
2246 av7110->dev->pci->subsystem_device);
2248 FE_FUNC_OVERRIDE(av7110->fe->ops.init, av7110->fe_init, av7110_fe_init);
2249 FE_FUNC_OVERRIDE(av7110->fe->ops.read_status, av7110->fe_read_status, av7110_fe_read_status);
2250 FE_FUNC_OVERRIDE(av7110->fe->ops.diseqc_reset_overload, av7110->fe_diseqc_reset_overload, av7110_fe_diseqc_reset_overload);
2251 FE_FUNC_OVERRIDE(av7110->fe->ops.diseqc_send_master_cmd, av7110->fe_diseqc_send_master_cmd, av7110_fe_diseqc_send_master_cmd);
2252 FE_FUNC_OVERRIDE(av7110->fe->ops.diseqc_send_burst, av7110->fe_diseqc_send_burst, av7110_fe_diseqc_send_burst);
2253 FE_FUNC_OVERRIDE(av7110->fe->ops.set_tone, av7110->fe_set_tone, av7110_fe_set_tone);
2254 FE_FUNC_OVERRIDE(av7110->fe->ops.set_voltage, av7110->fe_set_voltage, av7110_fe_set_voltage);
2255 FE_FUNC_OVERRIDE(av7110->fe->ops.dishnetwork_send_legacy_command, av7110->fe_dishnetwork_send_legacy_command, av7110_fe_dishnetwork_send_legacy_command);
2256 FE_FUNC_OVERRIDE(av7110->fe->ops.set_frontend, av7110->fe_set_frontend, av7110_fe_set_frontend);
2258 ret = dvb_register_frontend(&av7110->dvb_adapter, av7110->fe);
2260 printk("av7110: Frontend registration failed!\n");
2261 dvb_frontend_detach(av7110->fe);
2262 av7110->fe = NULL;
2338 struct av7110 *av7110;
2433 /* prepare the av7110 device struct */
2434 av7110 = kzalloc(sizeof(struct av7110), GFP_KERNEL);
2435 if (!av7110) {
2440 av7110->card_name = (char*) pci_ext->ext_priv;
2441 av7110->dev = dev;
2442 dev->ext_priv = av7110;
2444 ret = get_firmware(av7110);
2448 ret = dvb_register_adapter(&av7110->dvb_adapter, av7110->card_name,
2457 av7110->i2c_adap.class = I2C_CLASS_TV_DIGITAL;
2458 strlcpy(av7110->i2c_adap.name, pci_ext->ext_priv, sizeof(av7110->i2c_adap.name));
2460 saa7146_i2c_adapter_prepare(dev, &av7110->i2c_adap, SAA7146_I2C_BUS_BIT_RATE_120); /* 275 kHz */
2462 ret = i2c_add_adapter(&av7110->i2c_adap);
2466 ttpci_eeprom_parse_mac(&av7110->i2c_adap,
2467 av7110->dvb_adapter.proposed_mac);
2472 av7110->full_ts = true;
2475 if (i2c_readreg(av7110, 0xaa, 0) == 0x4f && i2c_readreg(av7110, 0xaa, 1) == 0x45) {
2476 u8 flags = i2c_readreg(av7110, 0xaa, 2);
2478 av7110->full_ts = true;
2481 if (av7110->full_ts) {
2483 spin_lock_init(&av7110->feedlock1);
2484 av7110->grabbing = saa7146_vmalloc_build_pgtable(pdev, length,
2485 &av7110->pt);
2486 if (!av7110->grabbing)
2504 saa7146_write(dev, BASE_PAGE3, av7110->pt.dma | ME1 | 0x90);
2508 tasklet_init(&av7110->vpe_tasklet, vpeirq, (unsigned long) av7110);
2511 spin_lock_init(&av7110->feedlock1);
2512 av7110->grabbing = saa7146_vmalloc_build_pgtable(pdev, length,
2513 &av7110->pt);
2514 if (!av7110->grabbing)
2527 saa7146_write(dev, BASE_PAGE3, av7110->pt.dma | ME1 | 0x90);
2589 tasklet_init (&av7110->vpe_tasklet, vpeirq, (unsigned long) av7110);
2604 tasklet_init (&av7110->debi_tasklet, debiirq, (unsigned long) av7110);
2605 tasklet_init (&av7110->gpio_tasklet, gpioirq, (unsigned long) av7110);
2607 mutex_init(&av7110->pid_mutex);
2610 spin_lock_init(&av7110->debilock);
2611 mutex_init(&av7110->dcomlock);
2612 av7110->debitype = -1;
2615 av7110->osdwin = 1;
2616 mutex_init(&av7110->osd_mutex);
2619 av7110->vidmode = tv_standard == 1 ? AV7110_VIDEO_MODE_NTSC
2623 init_waitqueue_head(&av7110->arm_wait);
2624 av7110->arm_thread = NULL;
2627 av7110->debi_virt = pci_alloc_consistent(pdev, 8192, &av7110->debi_bus);
2628 if (!av7110->debi_virt)
2632 av7110->iobuf = vmalloc(AVOUTLEN+AOUTLEN+BMPLEN+4*IPACKS);
2633 if (!av7110->iobuf)
2636 ret = av7110_av_init(av7110);
2641 av7110->bmpbuf = av7110->iobuf+AVOUTLEN+AOUTLEN;
2642 init_waitqueue_head(&av7110->bmpq);
2644 ret = av7110_ca_init(av7110);
2649 ret = av7110_bootarm(av7110);
2653 ret = av7110_firmversion(av7110);
2657 if (FW_VERSION(av7110->arm_app)<0x2501)
2659 "System might be unstable!\n", FW_VERSION(av7110->arm_app));
2661 thread = kthread_run(arm_thread, (void *) av7110, "arm_mon");
2666 av7110->arm_thread = thread;
2669 av7110->mixer.volume_left = volume;
2670 av7110->mixer.volume_right = volume;
2672 ret = av7110_register(av7110);
2676 init_av7110_av(av7110);
2681 ret = av7110_init_v4l(av7110);
2685 av7110->dvb_adapter.priv = av7110;
2686 ret = frontend_init(av7110);
2691 av7110_ir_init(av7110);
2693 printk(KERN_INFO "dvb-ttpci: found av7110-%d.\n", av7110_num);
2699 av7110_exit_v4l(av7110);
2701 dvb_unregister(av7110);
2703 av7110_arm_sync(av7110);
2707 av7110_ca_exit(av7110);
2709 av7110_av_exit(av7110);
2711 vfree(av7110->iobuf);
2713 pci_free_consistent(pdev, 8192, av7110->debi_virt, av7110->debi_bus);
2715 if (av7110->grabbing)
2716 saa7146_vfree_destroy_pgtable(pdev, av7110->grabbing, &av7110->pt);
2718 i2c_del_adapter(&av7110->i2c_adap);
2720 dvb_unregister_adapter(&av7110->dvb_adapter);
2722 put_firmware(av7110);
2724 kfree(av7110);
2730 struct av7110 *av7110 = saa->ext_priv;
2731 dprintk(4, "%p\n", av7110);
2734 av7110_ir_exit(av7110);
2736 if (budgetpatch || av7110->full_ts) {
2747 tasklet_kill(&av7110->vpe_tasklet);
2748 saa7146_vfree_destroy_pgtable(saa->pci, av7110->grabbing, &av7110->pt);
2750 av7110_exit_v4l(av7110);
2752 av7110_arm_sync(av7110);
2754 tasklet_kill(&av7110->debi_tasklet);
2755 tasklet_kill(&av7110->gpio_tasklet);
2757 dvb_unregister(av7110);
2762 av7110_ca_exit(av7110);
2763 av7110_av_exit(av7110);
2765 vfree(av7110->iobuf);
2766 pci_free_consistent(saa->pci, 8192, av7110->debi_virt,
2767 av7110->debi_bus);
2769 i2c_del_adapter(&av7110->i2c_adap);
2771 dvb_unregister_adapter (&av7110->dvb_adapter);
2775 put_firmware(av7110);
2777 kfree(av7110);
2787 struct av7110 *av7110 = dev->ext_priv;
2812 SAA7146_IER_DISABLE(av7110->dev, MASK_19);
2813 SAA7146_ISR_CLEAR(av7110->dev, MASK_19);
2814 tasklet_schedule(&av7110->debi_tasklet);
2819 tasklet_schedule(&av7110->gpio_tasklet);
2823 tasklet_schedule(&av7110->vpe_tasklet);