Lines Matching +full:precondition +full:- +full:timeout

3     Copyright (C) 2003-2004  Kevin Thayer <nufan_wfk at yahoo.com>
5 Copyright (C) 2005-2007 Hans Verkuil <hverkuil@xs4all.nl>
19 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
27 * -----
28 * MPG600/MPG160 support by T.Adachi <tadachi@tadachi-net.com>
32 * using information provided by Jiun-Kuei Jung @ AVerMedia.
34 * Kurouto Sikou CX23416GYC-STVLP tested by K.Ohta <alpha292@bremen.or.jp>
35 * using information from T.Adachi,Takeru KOMORIYA and others :-)
37 * Nagase TRANSGEAR 5000TV, Aopen VA2000MAX-STN6 and I/O data GV-MVP/RX
41 #include "ivtv-driver.h"
42 #include "ivtv-version.h"
43 #include "ivtv-fileops.h"
44 #include "ivtv-i2c.h"
45 #include "ivtv-firmware.h"
46 #include "ivtv-queue.h"
47 #include "ivtv-udma.h"
48 #include "ivtv-irq.h"
49 #include "ivtv-mailbox.h"
50 #include "ivtv-streams.h"
51 #include "ivtv-ioctl.h"
52 #include "ivtv-cards.h"
53 #include "ivtv-vbi.h"
54 #include "ivtv-routing.h"
55 #include "ivtv-controls.h"
56 #include "ivtv-gpio.h"
57 #include <linux/dma-mapping.h>
65 without radio and a PVR-350 with. Normally this would give a
90 static int tuner[IVTV_MAX_CARDS] = { -1, -1, -1, -1, -1, -1, -1, -1,
91 -1, -1, -1, -1, -1, -1, -1, -1,
92 -1, -1, -1, -1, -1, -1, -1, -1,
93 -1, -1, -1, -1, -1, -1, -1, -1 };
94 static int radio[IVTV_MAX_CARDS] = { -1, -1, -1, -1, -1, -1, -1, -1,
95 -1, -1, -1, -1, -1, -1, -1, -1,
96 -1, -1, -1, -1, -1, -1, -1, -1,
97 -1, -1, -1, -1, -1, -1, -1, -1 };
98 static int i2c_clock_period[IVTV_MAX_CARDS] = { -1, -1, -1, -1, -1, -1, -1, -1,
99 -1, -1, -1, -1, -1, -1, -1, -1,
100 -1, -1, -1, -1, -1, -1, -1, -1,
101 -1, -1, -1, -1, -1, -1, -1, -1 };
107 static char pal[] = "---";
108 static char secam[] = "--";
109 static char ntsc[] = "-";
133 static int ivtv_yuv_threshold = -1;
141 static int tunertype = -1;
142 static int newi2c = -1;
181 "\t\t\t 3 = WinTV PVR-150 or PVR-500\n"
183 "\t\t\t 5 = YUAN MPG600/Kuroutoshikou iTVC16-STVLP\n"
184 "\t\t\t 6 = YUAN MPG160/Kuroutoshikou iTVC15-STVLP\n"
185 "\t\t\t 7 = YUAN PG600/DIAMONDMM PVR-550 (CX Falcon 2)\n"
186 "\t\t\t 8 = Adaptec AVC-2410\n"
187 "\t\t\t 9 = Adaptec AVC-2010\n"
189 "\t\t\t11 = AOpen VA2000MAX-STN6\n"
190 "\t\t\t12 = YUAN MPG600GR/Kuroutoshikou CX23416GYC-STVLP\n"
191 "\t\t\t13 = I/O Data GV-MVP/RX\n"
192 "\t\t\t14 = I/O Data GV-MVP/RX2E\n"
196 "\t\t\t18 = Digital Cowboy DCT-MTVP1\n"
198 "\t\t\t20 = Club3D ZAP-TV1x01\n"
201 "\t\t\t23 = AverMedia PVR-150 Plus\n"
204 "\t\t\t26 = Buffalo PC-MV5L/PCI\n"
208 "\t\t\t-1 = Ignore this card\n\t\t");
214 "\t\t\t 0 = tuner for PAL-B/G/H/D/K/I, SECAM-B/G/H/D/K/L/Lc\n"
215 "\t\t\t 1 = tuner for NTSC-M/J/K, PAL-M/N/Nc\n"
216 "\t\t\t-1 = Autodetect (default)\n");
267 "\t\t\t-1 is autodetect, 0 is off, 1 is on\n"
287 /* Make sure ivtv-alsa module is loaded */ in request_module_async()
288 request_module("ivtv-alsa"); in request_module_async()
290 /* Initialize ivtv-alsa for this instance of the cx18 device */ in request_module_async()
297 INIT_WORK(&dev->request_module_wk, request_module_async); in request_modules()
298 schedule_work(&dev->request_module_wk); in request_modules()
303 flush_work(&dev->request_module_wk); in flush_request_modules()
312 itv->irqmask &= ~mask; in ivtv_clear_irq_mask()
313 write_reg_sync(itv->irqmask, IVTV_REG_IRQMASK); in ivtv_clear_irq_mask()
318 itv->irqmask |= mask; in ivtv_set_irq_mask()
319 write_reg_sync(itv->irqmask, IVTV_REG_IRQMASK); in ivtv_set_irq_mask()
326 spin_lock(&itv->lock); in ivtv_set_output_mode()
327 old_mode = itv->output_mode; in ivtv_set_output_mode()
329 itv->output_mode = old_mode = mode; in ivtv_set_output_mode()
330 spin_unlock(&itv->lock); in ivtv_set_output_mode()
336 switch (itv->output_mode) { in ivtv_get_output_stream()
338 return &itv->streams[IVTV_DEC_STREAM_TYPE_MPG]; in ivtv_get_output_stream()
340 return &itv->streams[IVTV_DEC_STREAM_TYPE_YUV]; in ivtv_get_output_stream()
353 return signal_pending(current) ? -EINTR : 0; in ivtv_waitq()
359 int timeout = msecs_to_jiffies(msecs); in ivtv_msleep_timeout() local
363 timeout = schedule_timeout(timeout); in ivtv_msleep_timeout()
370 } while (timeout); in ivtv_msleep_timeout()
381 if (itv->reg_mem != NULL) { in ivtv_iounmap()
383 iounmap(itv->reg_mem); in ivtv_iounmap()
384 itv->reg_mem = NULL; in ivtv_iounmap()
387 if (itv->has_cx23415 && itv->dec_mem != NULL) { in ivtv_iounmap()
389 iounmap(itv->dec_mem); in ivtv_iounmap()
391 itv->dec_mem = NULL; in ivtv_iounmap()
394 if (itv->enc_mem != NULL) { in ivtv_iounmap()
396 iounmap(itv->enc_mem); in ivtv_iounmap()
397 itv->enc_mem = NULL; in ivtv_iounmap()
406 itv->i2c_client.addr = 0xA0 >> 1; in ivtv_read_eeprom()
407 tveeprom_read(&itv->i2c_client, eedata, sizeof(eedata)); in ivtv_read_eeprom()
414 int pci_slot = PCI_SLOT(itv->pdev->devfn); in ivtv_process_eeprom()
428 itv->card = ivtv_get_card(IVTV_CARD_PVR_250); in ivtv_process_eeprom()
432 itv->card = ivtv_get_card(IVTV_CARD_PVR_350); in ivtv_process_eeprom()
437 itv->card = ivtv_get_card(IVTV_CARD_PVR_150); in ivtv_process_eeprom()
443 IVTV_ERR("Unknown model %d, defaulting to PVR-150\n", tv.model); in ivtv_process_eeprom()
444 itv->card = ivtv_get_card(IVTV_CARD_PVR_150); in ivtv_process_eeprom()
452 itv->card = ivtv_get_card(IVTV_CARD_PVR_350_V1); in ivtv_process_eeprom()
458 itv->v4l2_cap = itv->card->v4l2_capabilities; in ivtv_process_eeprom()
459 itv->card_name = itv->card->name; in ivtv_process_eeprom()
460 itv->card_i2c = itv->card->i2c; in ivtv_process_eeprom()
473 is that the card presents itself with a non-working radio device. in ivtv_process_eeprom()
484 itv->card_name = "WinTV PVR 500"; in ivtv_process_eeprom()
485 itv->card_i2c = &ivtv_i2c_radio; in ivtv_process_eeprom()
489 itv->card_name = is_first ? "WinTV PVR 500 (unit #1)" : in ivtv_process_eeprom()
497 IVTV_INFO("Autodetected %s\n", itv->card_name); in ivtv_process_eeprom()
503 itv->pvr150_workaround = 1; in ivtv_process_eeprom()
511 if (itv->options.tuner == -1) in ivtv_process_eeprom()
512 itv->options.tuner = tv.tuner_type; in ivtv_process_eeprom()
513 if (itv->options.radio == -1) in ivtv_process_eeprom()
514 itv->options.radio = (tv.has_radio != 0); in ivtv_process_eeprom()
516 if (itv->options.newi2c == -1 && tv.has_ir) { in ivtv_process_eeprom()
517 itv->options.newi2c = (tv.has_ir & 4) ? 1 : 0; in ivtv_process_eeprom()
518 if (itv->options.newi2c) { in ivtv_process_eeprom()
519 IVTV_INFO("Reopen i2c bus for IR-blaster support\n"); in ivtv_process_eeprom()
525 if (itv->std != 0) in ivtv_process_eeprom()
532 itv->std |= V4L2_STD_PAL_BG | V4L2_STD_PAL_H; in ivtv_process_eeprom()
535 itv->std |= V4L2_STD_NTSC_M; in ivtv_process_eeprom()
538 itv->std |= V4L2_STD_SECAM_L; in ivtv_process_eeprom()
540 IVTV_INFO("No tuner detected, default to NTSC-M\n"); in ivtv_process_eeprom()
541 itv->std |= V4L2_STD_NTSC_M; in ivtv_process_eeprom()
579 case '-': in ivtv_parse_std()
607 case '-': in ivtv_parse_std()
627 case '-': in ivtv_parse_std()
643 itv->options.kilobytes[IVTV_ENC_STREAM_TYPE_MPG] = enc_mpg_buffers * 1024; in ivtv_process_options()
644 itv->options.kilobytes[IVTV_ENC_STREAM_TYPE_YUV] = enc_yuv_buffers * 1024; in ivtv_process_options()
645 itv->options.kilobytes[IVTV_ENC_STREAM_TYPE_VBI] = enc_vbi_buffers * 1024; in ivtv_process_options()
646 itv->options.kilobytes[IVTV_ENC_STREAM_TYPE_PCM] = enc_pcm_buffers; in ivtv_process_options()
647 itv->options.kilobytes[IVTV_DEC_STREAM_TYPE_MPG] = dec_mpg_buffers * 1024; in ivtv_process_options()
648 itv->options.kilobytes[IVTV_DEC_STREAM_TYPE_YUV] = dec_yuv_buffers * 1024; in ivtv_process_options()
649 itv->options.kilobytes[IVTV_DEC_STREAM_TYPE_VBI] = dec_vbi_buffers; in ivtv_process_options()
650 itv->options.cardtype = cardtype[itv->instance]; in ivtv_process_options()
651 itv->options.tuner = tuner[itv->instance]; in ivtv_process_options()
652 itv->options.radio = radio[itv->instance]; in ivtv_process_options()
654 itv->options.i2c_clock_period = i2c_clock_period[itv->instance]; in ivtv_process_options()
655 if (itv->options.i2c_clock_period == -1) in ivtv_process_options()
656 itv->options.i2c_clock_period = IVTV_DEFAULT_I2C_CLOCK_PERIOD; in ivtv_process_options()
657 else if (itv->options.i2c_clock_period < 10) in ivtv_process_options()
658 itv->options.i2c_clock_period = 10; in ivtv_process_options()
659 else if (itv->options.i2c_clock_period > 4500) in ivtv_process_options()
660 itv->options.i2c_clock_period = 4500; in ivtv_process_options()
662 itv->options.newi2c = newi2c; in ivtv_process_options()
663 if (tunertype < -1 || tunertype > 1) { in ivtv_process_options()
665 tunertype = -1; in ivtv_process_options()
667 itv->std = ivtv_parse_std(itv); in ivtv_process_options()
668 if (itv->std == 0 && tunertype >= 0) in ivtv_process_options()
669 itv->std = tunertype ? V4L2_STD_MN : (V4L2_STD_ALL & ~V4L2_STD_MN); in ivtv_process_options()
670 itv->has_cx23415 = (itv->pdev->device == PCI_DEVICE_ID_IVTV15); in ivtv_process_options()
671 chipname = itv->has_cx23415 ? "cx23415" : "cx23416"; in ivtv_process_options()
672 if (itv->options.cardtype == -1) { in ivtv_process_options()
676 if ((itv->card = ivtv_get_card(itv->options.cardtype - 1))) { in ivtv_process_options()
678 itv->card->name, chipname); in ivtv_process_options()
679 } else if (itv->options.cardtype != 0) { in ivtv_process_options()
682 if (itv->card == NULL) { in ivtv_process_options()
683 if (itv->pdev->subsystem_vendor == IVTV_PCI_ID_HAUPPAUGE || in ivtv_process_options()
684 itv->pdev->subsystem_vendor == IVTV_PCI_ID_HAUPPAUGE_ALT1 || in ivtv_process_options()
685 itv->pdev->subsystem_vendor == IVTV_PCI_ID_HAUPPAUGE_ALT2) { in ivtv_process_options()
686 itv->card = ivtv_get_card(itv->has_cx23415 ? IVTV_CARD_PVR_350 : IVTV_CARD_PVR_150); in ivtv_process_options()
691 if (itv->card == NULL) { in ivtv_process_options()
692 for (i = 0; (itv->card = ivtv_get_card(i)); i++) { in ivtv_process_options()
693 if (itv->card->pci_list == NULL) in ivtv_process_options()
695 for (j = 0; itv->card->pci_list[j].device; j++) { in ivtv_process_options()
696 if (itv->pdev->device != in ivtv_process_options()
697 itv->card->pci_list[j].device) in ivtv_process_options()
699 if (itv->pdev->subsystem_vendor != in ivtv_process_options()
700 itv->card->pci_list[j].subsystem_vendor) in ivtv_process_options()
702 if (itv->pdev->subsystem_device != in ivtv_process_options()
703 itv->card->pci_list[j].subsystem_device) in ivtv_process_options()
706 itv->card->name, chipname); in ivtv_process_options()
713 if (itv->card == NULL) { in ivtv_process_options()
714 itv->card = ivtv_get_card(IVTV_CARD_PVR_150); in ivtv_process_options()
716 itv->pdev->vendor, itv->pdev->device); in ivtv_process_options()
718 itv->pdev->subsystem_vendor, itv->pdev->subsystem_device); in ivtv_process_options()
720 IVTV_ERR("Defaulting to %s card\n", itv->card->name); in ivtv_process_options()
722 IVTV_ERR("card you have to the linux-media mailinglist (www.linuxtv.org)\n"); in ivtv_process_options()
725 itv->v4l2_cap = itv->card->v4l2_capabilities; in ivtv_process_options()
726 itv->card_name = itv->card->name; in ivtv_process_options()
727 itv->card_i2c = itv->card->i2c; in ivtv_process_options()
730 /* Precondition: the ivtv structure has been memset to 0. Only
737 itv->base_addr = pci_resource_start(itv->pdev, 0); in ivtv_init_struct1()
738 itv->enc_mbox.max_mbox = 2; /* the encoder has 3 mailboxes (0-2) */ in ivtv_init_struct1()
739 itv->dec_mbox.max_mbox = 1; /* the decoder has 2 mailboxes (0-1) */ in ivtv_init_struct1()
741 mutex_init(&itv->serialize_lock); in ivtv_init_struct1()
742 mutex_init(&itv->i2c_bus_lock); in ivtv_init_struct1()
743 mutex_init(&itv->udma.lock); in ivtv_init_struct1()
745 spin_lock_init(&itv->lock); in ivtv_init_struct1()
746 spin_lock_init(&itv->dma_reg_lock); in ivtv_init_struct1()
748 kthread_init_worker(&itv->irq_worker); in ivtv_init_struct1()
749 itv->irq_worker_task = kthread_run(kthread_worker_fn, &itv->irq_worker, in ivtv_init_struct1()
750 "%s", itv->v4l2_dev.name); in ivtv_init_struct1()
751 if (IS_ERR(itv->irq_worker_task)) { in ivtv_init_struct1()
753 return -1; in ivtv_init_struct1()
756 sched_set_fifo(itv->irq_worker_task); in ivtv_init_struct1()
758 kthread_init_work(&itv->irq_work, ivtv_irq_work_handler); in ivtv_init_struct1()
761 itv->cxhdl.port = CX2341X_PORT_MEMORY; in ivtv_init_struct1()
762 itv->cxhdl.capabilities = CX2341X_CAP_HAS_SLICED_VBI; in ivtv_init_struct1()
763 init_waitqueue_head(&itv->eos_waitq); in ivtv_init_struct1()
764 init_waitqueue_head(&itv->event_waitq); in ivtv_init_struct1()
765 init_waitqueue_head(&itv->vsync_waitq); in ivtv_init_struct1()
766 init_waitqueue_head(&itv->dma_waitq); in ivtv_init_struct1()
767 timer_setup(&itv->dma_timer, ivtv_unfinished_dma, 0); in ivtv_init_struct1()
769 itv->cur_dma_stream = -1; in ivtv_init_struct1()
770 itv->cur_pio_stream = -1; in ivtv_init_struct1()
773 itv->speed = 1000; in ivtv_init_struct1()
776 itv->vbi.in.type = V4L2_BUF_TYPE_VBI_CAPTURE; in ivtv_init_struct1()
777 itv->vbi.sliced_in = &itv->vbi.in.fmt.sliced; in ivtv_init_struct1()
780 sg_init_table(itv->udma.SGlist, IVTV_DMA_SG_OSD_ENT); in ivtv_init_struct1()
783 itv->osd_global_alpha_state = 1; in ivtv_init_struct1()
784 itv->osd_global_alpha = 255; in ivtv_init_struct1()
787 atomic_set(&itv->yuv_info.next_dma_frame, -1); in ivtv_init_struct1()
788 itv->yuv_info.lace_mode = ivtv_yuv_mode; in ivtv_init_struct1()
789 itv->yuv_info.lace_threshold = ivtv_yuv_threshold; in ivtv_init_struct1()
790 itv->yuv_info.max_frames_buffered = 3; in ivtv_init_struct1()
791 itv->yuv_info.track_osd = 1; in ivtv_init_struct1()
802 if (itv->card->video_inputs[i].video_type == 0) in ivtv_init_struct2()
804 itv->nof_inputs = i; in ivtv_init_struct2()
806 if (itv->card->audio_inputs[i].audio_type == 0) in ivtv_init_struct2()
808 itv->nof_audio_inputs = i; in ivtv_init_struct2()
810 if (itv->card->hw_all & IVTV_HW_CX25840) { in ivtv_init_struct2()
811 itv->vbi.sliced_size = 288; /* multiple of 16, real size = 284 */ in ivtv_init_struct2()
813 itv->vbi.sliced_size = 64; /* multiple of 16, real size = 52 */ in ivtv_init_struct2()
817 for (i = 0; i < itv->nof_inputs; i++) { in ivtv_init_struct2()
818 if (itv->card->video_inputs[i].video_type == in ivtv_init_struct2()
822 if (i >= itv->nof_inputs) in ivtv_init_struct2()
824 itv->active_input = i; in ivtv_init_struct2()
825 itv->audio_input = itv->card->video_inputs[i].audio_index; in ivtv_init_struct2()
838 return -EIO; in ivtv_setup_pci()
840 if (dma_set_mask(&pdev->dev, DMA_BIT_MASK(32))) { in ivtv_setup_pci()
842 return -EIO; in ivtv_setup_pci()
844 if (!request_mem_region(itv->base_addr, IVTV_ENCODER_SIZE, "ivtv encoder")) { in ivtv_setup_pci()
846 return -EIO; in ivtv_setup_pci()
849 if (!request_mem_region(itv->base_addr + IVTV_REG_OFFSET, in ivtv_setup_pci()
852 release_mem_region(itv->base_addr, IVTV_ENCODER_SIZE); in ivtv_setup_pci()
853 return -EIO; in ivtv_setup_pci()
856 if (itv->has_cx23415 && in ivtv_setup_pci()
857 !request_mem_region(itv->base_addr + IVTV_DECODER_OFFSET, in ivtv_setup_pci()
860 release_mem_region(itv->base_addr, IVTV_ENCODER_SIZE); in ivtv_setup_pci()
861 release_mem_region(itv->base_addr + IVTV_REG_OFFSET, IVTV_REG_SIZE); in ivtv_setup_pci()
862 return -EIO; in ivtv_setup_pci()
873 if (itv->has_cx23415) in ivtv_setup_pci()
874 release_mem_region(itv->base_addr + IVTV_DECODER_OFFSET, in ivtv_setup_pci()
876 release_mem_region(itv->base_addr, IVTV_ENCODER_SIZE); in ivtv_setup_pci()
877 release_mem_region(itv->base_addr + IVTV_REG_OFFSET, IVTV_REG_SIZE); in ivtv_setup_pci()
878 return -ENXIO; in ivtv_setup_pci()
898 pdev->device, pdev->revision, pdev->bus->number, in ivtv_setup_pci()
899 PCI_SLOT(pdev->devfn), PCI_FUNC(pdev->devfn), in ivtv_setup_pci()
900 pdev->irq, pci_latency, (u64)itv->base_addr); in ivtv_setup_pci()
907 u32 hw = itv->card->hw_all; in ivtv_load_and_init_modules()
918 itv->hw_flags |= device; in ivtv_load_and_init_modules()
922 itv->hw_flags |= device; in ivtv_load_and_init_modules()
926 if ((itv->hw_flags & IVTV_HW_IR_ANY) == 0) in ivtv_load_and_init_modules()
929 if (itv->card->hw_all & IVTV_HW_CX25840) in ivtv_load_and_init_modules()
930 itv->sd_video = ivtv_find_hw(itv, IVTV_HW_CX25840); in ivtv_load_and_init_modules()
931 else if (itv->card->hw_all & IVTV_HW_SAA717X) in ivtv_load_and_init_modules()
932 itv->sd_video = ivtv_find_hw(itv, IVTV_HW_SAA717X); in ivtv_load_and_init_modules()
933 else if (itv->card->hw_all & IVTV_HW_SAA7114) in ivtv_load_and_init_modules()
934 itv->sd_video = ivtv_find_hw(itv, IVTV_HW_SAA7114); in ivtv_load_and_init_modules()
936 itv->sd_video = ivtv_find_hw(itv, IVTV_HW_SAA7115); in ivtv_load_and_init_modules()
937 itv->sd_audio = ivtv_find_hw(itv, itv->card->hw_audio_ctrl); in ivtv_load_and_init_modules()
938 itv->sd_muxer = ivtv_find_hw(itv, itv->card->hw_muxer); in ivtv_load_and_init_modules()
940 hw = itv->hw_flags; in ivtv_load_and_init_modules()
942 if (itv->card->type == IVTV_CARD_CX23416GYC) { in ivtv_load_and_init_modules()
946 itv->card = ivtv_get_card(IVTV_CARD_CX23416GYC_NOGRYCS); in ivtv_load_and_init_modules()
948 itv->card = ivtv_get_card(IVTV_CARD_CX23416GYC_NOGR); in ivtv_load_and_init_modules()
950 else if (itv->card->type == IVTV_CARD_GV_MVPRX || in ivtv_load_and_init_modules()
951 itv->card->type == IVTV_CARD_GV_MVPRX2E) { in ivtv_load_and_init_modules()
953 v4l2_subdev_call(itv->sd_video, video, s_crystal_freq, in ivtv_load_and_init_modules()
958 itv->vbi.raw_decoder_line_size = 1444; in ivtv_load_and_init_modules()
959 itv->vbi.raw_decoder_sav_odd_field = 0x20; in ivtv_load_and_init_modules()
960 itv->vbi.raw_decoder_sav_even_field = 0x60; in ivtv_load_and_init_modules()
961 itv->vbi.sliced_decoder_line_size = 272; in ivtv_load_and_init_modules()
962 itv->vbi.sliced_decoder_sav_odd_field = 0xB0; in ivtv_load_and_init_modules()
963 itv->vbi.sliced_decoder_sav_even_field = 0xF0; in ivtv_load_and_init_modules()
968 itv->hw_flags &= ~IVTV_HW_SAA711X; in ivtv_load_and_init_modules()
970 if (strstr(itv->sd_video->name, "saa7114")) { in ivtv_load_and_init_modules()
971 itv->hw_flags |= IVTV_HW_SAA7114; in ivtv_load_and_init_modules()
973 itv->v4l2_cap &= ~(V4L2_CAP_SLICED_VBI_CAPTURE|V4L2_CAP_VBI_CAPTURE); in ivtv_load_and_init_modules()
975 itv->hw_flags |= IVTV_HW_SAA7115; in ivtv_load_and_init_modules()
977 itv->vbi.raw_decoder_line_size = 1443; in ivtv_load_and_init_modules()
978 itv->vbi.raw_decoder_sav_odd_field = 0x25; in ivtv_load_and_init_modules()
979 itv->vbi.raw_decoder_sav_even_field = 0x62; in ivtv_load_and_init_modules()
980 itv->vbi.sliced_decoder_line_size = 51; in ivtv_load_and_init_modules()
981 itv->vbi.sliced_decoder_sav_odd_field = 0xAB; in ivtv_load_and_init_modules()
982 itv->vbi.sliced_decoder_sav_even_field = 0xEC; in ivtv_load_and_init_modules()
986 itv->vbi.raw_decoder_line_size = 1443; in ivtv_load_and_init_modules()
987 itv->vbi.raw_decoder_sav_odd_field = 0x25; in ivtv_load_and_init_modules()
988 itv->vbi.raw_decoder_sav_even_field = 0x62; in ivtv_load_and_init_modules()
989 itv->vbi.sliced_decoder_line_size = 51; in ivtv_load_and_init_modules()
990 itv->vbi.sliced_decoder_sav_odd_field = 0xAB; in ivtv_load_and_init_modules()
991 itv->vbi.sliced_decoder_sav_even_field = 0xEC; in ivtv_load_and_init_modules()
1003 return -ENOMEM; in ivtv_probe()
1004 itv->pdev = pdev; in ivtv_probe()
1005 itv->instance = v4l2_device_set_name(&itv->v4l2_dev, "ivtv", in ivtv_probe()
1008 retval = v4l2_device_register(&pdev->dev, &itv->v4l2_dev); in ivtv_probe()
1013 IVTV_INFO("Initializing card %d\n", itv->instance); in ivtv_probe()
1016 if (itv->options.cardtype == -1) { in ivtv_probe()
1017 retval = -ENODEV; in ivtv_probe()
1021 retval = -ENOMEM; in ivtv_probe()
1024 retval = cx2341x_handler_init(&itv->cxhdl, 50); in ivtv_probe()
1027 itv->v4l2_dev.ctrl_handler = &itv->cxhdl.hdl; in ivtv_probe()
1028 itv->cxhdl.ops = &ivtv_cxhdl_ops; in ivtv_probe()
1029 itv->cxhdl.priv = itv; in ivtv_probe()
1030 itv->cxhdl.func = ivtv_api_func; in ivtv_probe()
1032 IVTV_DEBUG_INFO("base addr: 0x%llx\n", (u64)itv->base_addr); in ivtv_probe()
1036 if (retval == -EIO) in ivtv_probe()
1038 if (retval == -ENXIO) in ivtv_probe()
1043 (u64)itv->base_addr + IVTV_ENCODER_OFFSET, IVTV_ENCODER_SIZE); in ivtv_probe()
1044 itv->enc_mem = ioremap(itv->base_addr + IVTV_ENCODER_OFFSET, in ivtv_probe()
1046 if (!itv->enc_mem) { in ivtv_probe()
1051 retval = -ENOMEM; in ivtv_probe()
1055 if (itv->has_cx23415) { in ivtv_probe()
1057 (u64)itv->base_addr + IVTV_DECODER_OFFSET, IVTV_DECODER_SIZE); in ivtv_probe()
1058 itv->dec_mem = ioremap(itv->base_addr + IVTV_DECODER_OFFSET, in ivtv_probe()
1060 if (!itv->dec_mem) { in ivtv_probe()
1065 retval = -ENOMEM; in ivtv_probe()
1070 itv->dec_mem = itv->enc_mem; in ivtv_probe()
1075 (u64)itv->base_addr + IVTV_REG_OFFSET, IVTV_REG_SIZE); in ivtv_probe()
1076 itv->reg_mem = in ivtv_probe()
1077 ioremap(itv->base_addr + IVTV_REG_OFFSET, IVTV_REG_SIZE); in ivtv_probe()
1078 if (!itv->reg_mem) { in ivtv_probe()
1083 retval = -ENOMEM; in ivtv_probe()
1098 if (itv->card->hw_all & IVTV_HW_TVEEPROM) { in ivtv_probe()
1103 if (itv->card->comment) in ivtv_probe()
1104 IVTV_INFO("%s", itv->card->comment); in ivtv_probe()
1105 if (itv->card->v4l2_capabilities == 0) { in ivtv_probe()
1107 retval = -ENODEV; in ivtv_probe()
1111 if (itv->std == 0) { in ivtv_probe()
1112 itv->std = V4L2_STD_NTSC_M; in ivtv_probe()
1115 if (itv->options.tuner == -1) { in ivtv_probe()
1119 if ((itv->std & itv->card->tuners[i].std) == 0) in ivtv_probe()
1121 itv->options.tuner = itv->card->tuners[i].tuner; in ivtv_probe()
1126 if (itv->options.tuner == -1 && itv->card->tuners[0].std) { in ivtv_probe()
1127 itv->std = itv->card->tuners[0].std; in ivtv_probe()
1128 if (itv->std & V4L2_STD_PAL) in ivtv_probe()
1129 itv->std = V4L2_STD_PAL_BG | V4L2_STD_PAL_H; in ivtv_probe()
1130 else if (itv->std & V4L2_STD_NTSC) in ivtv_probe()
1131 itv->std = V4L2_STD_NTSC_M; in ivtv_probe()
1132 else if (itv->std & V4L2_STD_SECAM) in ivtv_probe()
1133 itv->std = V4L2_STD_SECAM_L; in ivtv_probe()
1134 itv->options.tuner = itv->card->tuners[0].tuner; in ivtv_probe()
1136 if (itv->options.radio == -1) in ivtv_probe()
1137 itv->options.radio = (itv->card->radio_input.audio_type != 0); in ivtv_probe()
1139 /* The card is now fully identified, continue with card-specific in ivtv_probe()
1145 if (itv->std & V4L2_STD_525_60) { in ivtv_probe()
1146 itv->is_60hz = 1; in ivtv_probe()
1147 itv->is_out_60hz = 1; in ivtv_probe()
1149 itv->is_50hz = 1; in ivtv_probe()
1150 itv->is_out_50hz = 1; in ivtv_probe()
1153 itv->yuv_info.osd_full_w = 720; in ivtv_probe()
1154 itv->yuv_info.osd_full_h = itv->is_out_50hz ? 576 : 480; in ivtv_probe()
1155 itv->yuv_info.v4l2_src_w = itv->yuv_info.osd_full_w; in ivtv_probe()
1156 itv->yuv_info.v4l2_src_h = itv->yuv_info.osd_full_h; in ivtv_probe()
1158 cx2341x_handler_set_50hz(&itv->cxhdl, itv->is_50hz); in ivtv_probe()
1160 itv->stream_buf_size[IVTV_ENC_STREAM_TYPE_MPG] = 0x08000; in ivtv_probe()
1161 itv->stream_buf_size[IVTV_ENC_STREAM_TYPE_PCM] = 0x01200; in ivtv_probe()
1162 itv->stream_buf_size[IVTV_DEC_STREAM_TYPE_MPG] = 0x10000; in ivtv_probe()
1163 itv->stream_buf_size[IVTV_DEC_STREAM_TYPE_YUV] = 0x10000; in ivtv_probe()
1164 itv->stream_buf_size[IVTV_ENC_STREAM_TYPE_YUV] = 0x08000; in ivtv_probe()
1170 itv->vbi.raw_size = 1456; in ivtv_probe()
1177 vbi_buf_size = itv->vbi.raw_size * (itv->is_60hz ? 24 : 36) / 2; in ivtv_probe()
1178 itv->stream_buf_size[IVTV_ENC_STREAM_TYPE_VBI] = vbi_buf_size; in ivtv_probe()
1179 itv->stream_buf_size[IVTV_DEC_STREAM_TYPE_VBI] = sizeof(struct v4l2_sliced_vbi_data) * 36; in ivtv_probe()
1181 if (itv->options.radio > 0) in ivtv_probe()
1182 itv->v4l2_cap |= V4L2_CAP_RADIO; in ivtv_probe()
1184 if (itv->options.tuner > -1) { in ivtv_probe()
1188 setup.type = itv->options.tuner; in ivtv_probe()
1190 if (itv->options.radio > 0) in ivtv_probe()
1201 .tuner = itv->options.tuner, in ivtv_probe()
1208 /* The tuner is fixed to the standard. The other inputs (e.g. S-Video) in ivtv_probe()
1210 itv->tuner_std = itv->std; in ivtv_probe()
1212 if (itv->v4l2_cap & V4L2_CAP_VIDEO_OUTPUT) { in ivtv_probe()
1213 struct v4l2_ctrl_handler *hdl = itv->v4l2_dev.ctrl_handler; in ivtv_probe()
1215 itv->ctrl_pts = v4l2_ctrl_new_std(hdl, &ivtv_hdl_out_ops, in ivtv_probe()
1217 itv->ctrl_frame = v4l2_ctrl_new_std(hdl, &ivtv_hdl_out_ops, in ivtv_probe()
1221 itv->ctrl_audio_playback = in ivtv_probe()
1227 itv->ctrl_audio_multilingual_playback = in ivtv_probe()
1233 if (hdl->error) { in ivtv_probe()
1234 retval = hdl->error; in ivtv_probe()
1237 v4l2_ctrl_cluster(2, &itv->ctrl_pts); in ivtv_probe()
1238 v4l2_ctrl_cluster(2, &itv->ctrl_audio_playback); in ivtv_probe()
1239 ivtv_call_all(itv, video, s_std_output, itv->std); in ivtv_probe()
1250 retval = request_irq(itv->pdev->irq, ivtv_irq_handler, in ivtv_probe()
1251 IRQF_SHARED, itv->v4l2_dev.name, (void *)itv); in ivtv_probe()
1267 IVTV_INFO("Initialized card: %s\n", itv->card_name); in ivtv_probe()
1269 /* Load ivtv submodules (ivtv-alsa) */ in ivtv_probe()
1276 free_irq(itv->pdev->irq, (void *)itv); in ivtv_probe()
1278 v4l2_ctrl_handler_free(&itv->cxhdl.hdl); in ivtv_probe()
1283 release_mem_region(itv->base_addr, IVTV_ENCODER_SIZE); in ivtv_probe()
1284 release_mem_region(itv->base_addr + IVTV_REG_OFFSET, IVTV_REG_SIZE); in ivtv_probe()
1285 if (itv->has_cx23415) in ivtv_probe()
1286 release_mem_region(itv->base_addr + IVTV_DECODER_OFFSET, IVTV_DECODER_SIZE); in ivtv_probe()
1288 kthread_stop(itv->irq_worker_task); in ivtv_probe()
1291 retval = -ENODEV; in ivtv_probe()
1294 v4l2_device_unregister(&itv->v4l2_dev); in ivtv_probe()
1310 if (test_bit(IVTV_F_I_FAILED, &itv->i_flags)) in ivtv_init_on_first_open()
1311 return -ENXIO; in ivtv_init_on_first_open()
1313 if (test_and_set_bit(IVTV_F_I_INITED, &itv->i_flags)) in ivtv_init_on_first_open()
1316 while (--fw_retry_count > 0) { in ivtv_init_on_first_open()
1325 set_bit(IVTV_F_I_FAILED, &itv->i_flags); in ivtv_init_on_first_open()
1326 return -ENXIO; in ivtv_init_on_first_open()
1333 if (itv->card->hw_all & IVTV_HW_CX25840) in ivtv_init_on_first_open()
1334 v4l2_subdev_call(itv->sd_video, core, load_fw); in ivtv_init_on_first_open()
1342 if (itv->std == V4L2_STD_NTSC_M_JP) { in ivtv_init_on_first_open()
1345 else if (itv->std & V4L2_STD_NTSC_M) { in ivtv_init_on_first_open()
1349 video_input = itv->active_input; in ivtv_init_on_first_open()
1350 itv->active_input++; /* Force update of input */ in ivtv_init_on_first_open()
1355 itv->std++; /* Force full standard initialization */ in ivtv_init_on_first_open()
1356 itv->std_out = itv->std; in ivtv_init_on_first_open()
1359 if (itv->card->v4l2_capabilities & V4L2_CAP_VIDEO_OUTPUT) { in ivtv_init_on_first_open()
1360 /* Turn on the TV-out: ivtv_init_mpeg_decoder() initializes in ivtv_init_on_first_open()
1368 if (!itv->has_cx23415) in ivtv_init_on_first_open()
1371 ivtv_s_std_enc(itv, itv->tuner_std); in ivtv_init_on_first_open()
1378 if (itv->v4l2_cap & V4L2_CAP_VIDEO_OUTPUT) { in ivtv_init_on_first_open()
1381 ivtv_s_std_dec(itv, itv->tuner_std); in ivtv_init_on_first_open()
1387 cx2341x_handler_setup(&itv->cxhdl); in ivtv_init_on_first_open()
1401 if (test_bit(IVTV_F_I_INITED, &itv->i_flags)) { in ivtv_remove()
1404 if (atomic_read(&itv->capturing) > 0) in ivtv_remove()
1410 /* Turn off the TV-out */ in ivtv_remove()
1411 if (itv->v4l2_cap & V4L2_CAP_VIDEO_OUTPUT) in ivtv_remove()
1413 if (atomic_read(&itv->decoding) > 0) { in ivtv_remove()
1416 if (test_bit(IVTV_F_I_DEC_YUV, &itv->i_flags)) in ivtv_remove()
1420 ivtv_stop_v4l2_decode_stream(&itv->streams[type], in ivtv_remove()
1428 del_timer_sync(&itv->dma_timer); in ivtv_remove()
1431 kthread_flush_worker(&itv->irq_worker); in ivtv_remove()
1432 kthread_stop(itv->irq_worker_task); in ivtv_remove()
1437 v4l2_ctrl_handler_free(&itv->cxhdl.hdl); in ivtv_remove()
1441 free_irq(itv->pdev->irq, (void *)itv); in ivtv_remove()
1444 release_mem_region(itv->base_addr, IVTV_ENCODER_SIZE); in ivtv_remove()
1445 release_mem_region(itv->base_addr + IVTV_REG_OFFSET, IVTV_REG_SIZE); in ivtv_remove()
1446 if (itv->has_cx23415) in ivtv_remove()
1447 release_mem_region(itv->base_addr + IVTV_DECODER_OFFSET, IVTV_DECODER_SIZE); in ivtv_remove()
1449 pci_disable_device(itv->pdev); in ivtv_remove()
1451 kfree(itv->vbi.sliced_mpeg_data[i]); in ivtv_remove()
1453 pr_info("Removed %s\n", itv->card_name); in ivtv_remove()
1455 v4l2_device_unregister(&itv->v4l2_dev); in ivtv_remove()
1474 IVTV_MAX_CARDS - 1); in module_start()
1475 return -1; in module_start()
1485 return -ENODEV; in module_start()
1497 framebuffer module and an infrared module for the IR-blaster. */