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()
379 itv->i2c_client.addr = 0xA0 >> 1; in ivtv_read_eeprom()
380 tveeprom_read(&itv->i2c_client, eedata, sizeof(eedata)); in ivtv_read_eeprom()
387 int pci_slot = PCI_SLOT(itv->pdev->devfn); in ivtv_process_eeprom()
401 itv->card = ivtv_get_card(IVTV_CARD_PVR_250); in ivtv_process_eeprom()
405 itv->card = ivtv_get_card(IVTV_CARD_PVR_350); in ivtv_process_eeprom()
410 itv->card = ivtv_get_card(IVTV_CARD_PVR_150); in ivtv_process_eeprom()
416 IVTV_ERR("Unknown model %d, defaulting to PVR-150\n", tv.model); in ivtv_process_eeprom()
417 itv->card = ivtv_get_card(IVTV_CARD_PVR_150); in ivtv_process_eeprom()
425 itv->card = ivtv_get_card(IVTV_CARD_PVR_350_V1); in ivtv_process_eeprom()
431 itv->v4l2_cap = itv->card->v4l2_capabilities; in ivtv_process_eeprom()
432 itv->card_name = itv->card->name; in ivtv_process_eeprom()
433 itv->card_i2c = itv->card->i2c; in ivtv_process_eeprom()
446 is that the card presents itself with a non-working radio device. in ivtv_process_eeprom()
457 itv->card_name = "WinTV PVR 500"; in ivtv_process_eeprom()
458 itv->card_i2c = &ivtv_i2c_radio; in ivtv_process_eeprom()
462 itv->card_name = is_first ? "WinTV PVR 500 (unit #1)" : in ivtv_process_eeprom()
470 IVTV_INFO("Autodetected %s\n", itv->card_name); in ivtv_process_eeprom()
476 itv->pvr150_workaround = 1; in ivtv_process_eeprom()
484 if (itv->options.tuner == -1) in ivtv_process_eeprom()
485 itv->options.tuner = tv.tuner_type; in ivtv_process_eeprom()
486 if (itv->options.radio == -1) in ivtv_process_eeprom()
487 itv->options.radio = (tv.has_radio != 0); in ivtv_process_eeprom()
489 if (itv->options.newi2c == -1 && tv.has_ir) { in ivtv_process_eeprom()
490 itv->options.newi2c = (tv.has_ir & 4) ? 1 : 0; in ivtv_process_eeprom()
491 if (itv->options.newi2c) { in ivtv_process_eeprom()
492 IVTV_INFO("Reopen i2c bus for IR-blaster support\n"); in ivtv_process_eeprom()
498 if (itv->std != 0) in ivtv_process_eeprom()
505 itv->std |= V4L2_STD_PAL_BG | V4L2_STD_PAL_H; in ivtv_process_eeprom()
508 itv->std |= V4L2_STD_NTSC_M; in ivtv_process_eeprom()
511 itv->std |= V4L2_STD_SECAM_L; in ivtv_process_eeprom()
513 IVTV_INFO("No tuner detected, default to NTSC-M\n"); in ivtv_process_eeprom()
514 itv->std |= V4L2_STD_NTSC_M; in ivtv_process_eeprom()
552 case '-': in ivtv_parse_std()
580 case '-': in ivtv_parse_std()
600 case '-': in ivtv_parse_std()
616 itv->options.kilobytes[IVTV_ENC_STREAM_TYPE_MPG] = enc_mpg_buffers * 1024; in ivtv_process_options()
617 itv->options.kilobytes[IVTV_ENC_STREAM_TYPE_YUV] = enc_yuv_buffers * 1024; in ivtv_process_options()
618 itv->options.kilobytes[IVTV_ENC_STREAM_TYPE_VBI] = enc_vbi_buffers * 1024; in ivtv_process_options()
619 itv->options.kilobytes[IVTV_ENC_STREAM_TYPE_PCM] = enc_pcm_buffers; in ivtv_process_options()
620 itv->options.kilobytes[IVTV_DEC_STREAM_TYPE_MPG] = dec_mpg_buffers * 1024; in ivtv_process_options()
621 itv->options.kilobytes[IVTV_DEC_STREAM_TYPE_YUV] = dec_yuv_buffers * 1024; in ivtv_process_options()
622 itv->options.kilobytes[IVTV_DEC_STREAM_TYPE_VBI] = dec_vbi_buffers; in ivtv_process_options()
623 itv->options.cardtype = cardtype[itv->instance]; in ivtv_process_options()
624 itv->options.tuner = tuner[itv->instance]; in ivtv_process_options()
625 itv->options.radio = radio[itv->instance]; in ivtv_process_options()
627 itv->options.i2c_clock_period = i2c_clock_period[itv->instance]; in ivtv_process_options()
628 if (itv->options.i2c_clock_period == -1) in ivtv_process_options()
629 itv->options.i2c_clock_period = IVTV_DEFAULT_I2C_CLOCK_PERIOD; in ivtv_process_options()
630 else if (itv->options.i2c_clock_period < 10) in ivtv_process_options()
631 itv->options.i2c_clock_period = 10; in ivtv_process_options()
632 else if (itv->options.i2c_clock_period > 4500) in ivtv_process_options()
633 itv->options.i2c_clock_period = 4500; in ivtv_process_options()
635 itv->options.newi2c = newi2c; in ivtv_process_options()
636 if (tunertype < -1 || tunertype > 1) { in ivtv_process_options()
638 tunertype = -1; in ivtv_process_options()
640 itv->std = ivtv_parse_std(itv); in ivtv_process_options()
641 if (itv->std == 0 && tunertype >= 0) in ivtv_process_options()
642 itv->std = tunertype ? V4L2_STD_MN : (V4L2_STD_ALL & ~V4L2_STD_MN); in ivtv_process_options()
643 itv->has_cx23415 = (itv->pdev->device == PCI_DEVICE_ID_IVTV15); in ivtv_process_options()
644 chipname = itv->has_cx23415 ? "cx23415" : "cx23416"; in ivtv_process_options()
645 if (itv->options.cardtype == -1) { in ivtv_process_options()
649 if ((itv->card = ivtv_get_card(itv->options.cardtype - 1))) { in ivtv_process_options()
651 itv->card->name, chipname); in ivtv_process_options()
652 } else if (itv->options.cardtype != 0) { in ivtv_process_options()
655 if (itv->card == NULL) { in ivtv_process_options()
656 if (itv->pdev->subsystem_vendor == IVTV_PCI_ID_HAUPPAUGE || in ivtv_process_options()
657 itv->pdev->subsystem_vendor == IVTV_PCI_ID_HAUPPAUGE_ALT1 || in ivtv_process_options()
658 itv->pdev->subsystem_vendor == IVTV_PCI_ID_HAUPPAUGE_ALT2) { in ivtv_process_options()
659 itv->card = ivtv_get_card(itv->has_cx23415 ? IVTV_CARD_PVR_350 : IVTV_CARD_PVR_150); in ivtv_process_options()
664 if (itv->card == NULL) { in ivtv_process_options()
665 for (i = 0; (itv->card = ivtv_get_card(i)); i++) { in ivtv_process_options()
666 if (itv->card->pci_list == NULL) in ivtv_process_options()
668 for (j = 0; itv->card->pci_list[j].device; j++) { in ivtv_process_options()
669 if (itv->pdev->device != in ivtv_process_options()
670 itv->card->pci_list[j].device) in ivtv_process_options()
672 if (itv->pdev->subsystem_vendor != in ivtv_process_options()
673 itv->card->pci_list[j].subsystem_vendor) in ivtv_process_options()
675 if (itv->pdev->subsystem_device != in ivtv_process_options()
676 itv->card->pci_list[j].subsystem_device) in ivtv_process_options()
679 itv->card->name, chipname); in ivtv_process_options()
686 if (itv->card == NULL) { in ivtv_process_options()
687 itv->card = ivtv_get_card(IVTV_CARD_PVR_150); in ivtv_process_options()
689 itv->pdev->vendor, itv->pdev->device); in ivtv_process_options()
691 itv->pdev->subsystem_vendor, itv->pdev->subsystem_device); in ivtv_process_options()
693 IVTV_ERR("Defaulting to %s card\n", itv->card->name); in ivtv_process_options()
695 IVTV_ERR("card you have to the linux-media mailinglist (www.linuxtv.org)\n"); in ivtv_process_options()
698 itv->v4l2_cap = itv->card->v4l2_capabilities; in ivtv_process_options()
699 itv->card_name = itv->card->name; in ivtv_process_options()
700 itv->card_i2c = itv->card->i2c; in ivtv_process_options()
703 /* Precondition: the ivtv structure has been memset to 0. Only
710 itv->base_addr = pci_resource_start(itv->pdev, 0); in ivtv_init_struct1()
711 itv->enc_mbox.max_mbox = 2; /* the encoder has 3 mailboxes (0-2) */ in ivtv_init_struct1()
712 itv->dec_mbox.max_mbox = 1; /* the decoder has 2 mailboxes (0-1) */ in ivtv_init_struct1()
714 mutex_init(&itv->serialize_lock); in ivtv_init_struct1()
715 mutex_init(&itv->i2c_bus_lock); in ivtv_init_struct1()
716 mutex_init(&itv->udma.lock); in ivtv_init_struct1()
718 spin_lock_init(&itv->lock); in ivtv_init_struct1()
719 spin_lock_init(&itv->dma_reg_lock); in ivtv_init_struct1()
721 kthread_init_worker(&itv->irq_worker); in ivtv_init_struct1()
722 itv->irq_worker_task = kthread_run(kthread_worker_fn, &itv->irq_worker, in ivtv_init_struct1()
723 "%s", itv->v4l2_dev.name); in ivtv_init_struct1()
724 if (IS_ERR(itv->irq_worker_task)) { in ivtv_init_struct1()
726 return -1; in ivtv_init_struct1()
729 sched_set_fifo(itv->irq_worker_task); in ivtv_init_struct1()
731 kthread_init_work(&itv->irq_work, ivtv_irq_work_handler); in ivtv_init_struct1()
734 itv->cxhdl.port = CX2341X_PORT_MEMORY; in ivtv_init_struct1()
735 itv->cxhdl.capabilities = CX2341X_CAP_HAS_SLICED_VBI; in ivtv_init_struct1()
736 init_waitqueue_head(&itv->eos_waitq); in ivtv_init_struct1()
737 init_waitqueue_head(&itv->event_waitq); in ivtv_init_struct1()
738 init_waitqueue_head(&itv->vsync_waitq); in ivtv_init_struct1()
739 init_waitqueue_head(&itv->dma_waitq); in ivtv_init_struct1()
740 timer_setup(&itv->dma_timer, ivtv_unfinished_dma, 0); in ivtv_init_struct1()
742 itv->cur_dma_stream = -1; in ivtv_init_struct1()
743 itv->cur_pio_stream = -1; in ivtv_init_struct1()
746 itv->speed = 1000; in ivtv_init_struct1()
749 itv->vbi.in.type = V4L2_BUF_TYPE_VBI_CAPTURE; in ivtv_init_struct1()
750 itv->vbi.sliced_in = &itv->vbi.in.fmt.sliced; in ivtv_init_struct1()
753 sg_init_table(itv->udma.SGlist, IVTV_DMA_SG_OSD_ENT); in ivtv_init_struct1()
756 itv->osd_global_alpha_state = 1; in ivtv_init_struct1()
757 itv->osd_global_alpha = 255; in ivtv_init_struct1()
760 atomic_set(&itv->yuv_info.next_dma_frame, -1); in ivtv_init_struct1()
761 itv->yuv_info.lace_mode = ivtv_yuv_mode; in ivtv_init_struct1()
762 itv->yuv_info.lace_threshold = ivtv_yuv_threshold; in ivtv_init_struct1()
763 itv->yuv_info.max_frames_buffered = 3; in ivtv_init_struct1()
764 itv->yuv_info.track_osd = 1; in ivtv_init_struct1()
775 if (itv->card->video_inputs[i].video_type == 0) in ivtv_init_struct2()
777 itv->nof_inputs = i; in ivtv_init_struct2()
779 if (itv->card->audio_inputs[i].audio_type == 0) in ivtv_init_struct2()
781 itv->nof_audio_inputs = i; in ivtv_init_struct2()
783 if (itv->card->hw_all & IVTV_HW_CX25840) { in ivtv_init_struct2()
784 itv->vbi.sliced_size = 288; /* multiple of 16, real size = 284 */ in ivtv_init_struct2()
786 itv->vbi.sliced_size = 64; /* multiple of 16, real size = 52 */ in ivtv_init_struct2()
790 for (i = 0; i < itv->nof_inputs; i++) { in ivtv_init_struct2()
791 if (itv->card->video_inputs[i].video_type == in ivtv_init_struct2()
795 if (i >= itv->nof_inputs) in ivtv_init_struct2()
797 itv->active_input = i; in ivtv_init_struct2()
798 itv->audio_input = itv->card->video_inputs[i].audio_index; in ivtv_init_struct2()
811 return -EIO; in ivtv_setup_pci()
813 if (dma_set_mask(&pdev->dev, DMA_BIT_MASK(32))) { in ivtv_setup_pci()
815 return -EIO; in ivtv_setup_pci()
817 if (!devm_request_mem_region(&pdev->dev, itv->base_addr, in ivtv_setup_pci()
820 return -EIO; in ivtv_setup_pci()
823 if (!devm_request_mem_region(&pdev->dev, in ivtv_setup_pci()
824 itv->base_addr + IVTV_REG_OFFSET, in ivtv_setup_pci()
827 return -EIO; in ivtv_setup_pci()
830 if (itv->has_cx23415 && in ivtv_setup_pci()
831 !devm_request_mem_region(&pdev->dev, in ivtv_setup_pci()
832 itv->base_addr + IVTV_DECODER_OFFSET, in ivtv_setup_pci()
835 return -EIO; in ivtv_setup_pci()
846 return -ENXIO; in ivtv_setup_pci()
866 pdev->device, pdev->revision, pdev->bus->number, in ivtv_setup_pci()
867 PCI_SLOT(pdev->devfn), PCI_FUNC(pdev->devfn), in ivtv_setup_pci()
868 pdev->irq, pci_latency, (u64)itv->base_addr); in ivtv_setup_pci()
875 u32 hw = itv->card->hw_all; in ivtv_load_and_init_modules()
886 itv->hw_flags |= device; in ivtv_load_and_init_modules()
890 itv->hw_flags |= device; in ivtv_load_and_init_modules()
894 if ((itv->hw_flags & IVTV_HW_IR_ANY) == 0) in ivtv_load_and_init_modules()
897 if (itv->card->hw_all & IVTV_HW_CX25840) in ivtv_load_and_init_modules()
898 itv->sd_video = ivtv_find_hw(itv, IVTV_HW_CX25840); in ivtv_load_and_init_modules()
899 else if (itv->card->hw_all & IVTV_HW_SAA717X) in ivtv_load_and_init_modules()
900 itv->sd_video = ivtv_find_hw(itv, IVTV_HW_SAA717X); in ivtv_load_and_init_modules()
901 else if (itv->card->hw_all & IVTV_HW_SAA7114) in ivtv_load_and_init_modules()
902 itv->sd_video = ivtv_find_hw(itv, IVTV_HW_SAA7114); in ivtv_load_and_init_modules()
904 itv->sd_video = ivtv_find_hw(itv, IVTV_HW_SAA7115); in ivtv_load_and_init_modules()
905 itv->sd_audio = ivtv_find_hw(itv, itv->card->hw_audio_ctrl); in ivtv_load_and_init_modules()
906 itv->sd_muxer = ivtv_find_hw(itv, itv->card->hw_muxer); in ivtv_load_and_init_modules()
908 hw = itv->hw_flags; in ivtv_load_and_init_modules()
910 if (itv->card->type == IVTV_CARD_CX23416GYC) { in ivtv_load_and_init_modules()
914 itv->card = ivtv_get_card(IVTV_CARD_CX23416GYC_NOGRYCS); in ivtv_load_and_init_modules()
916 itv->card = ivtv_get_card(IVTV_CARD_CX23416GYC_NOGR); in ivtv_load_and_init_modules()
918 else if (itv->card->type == IVTV_CARD_GV_MVPRX || in ivtv_load_and_init_modules()
919 itv->card->type == IVTV_CARD_GV_MVPRX2E) { in ivtv_load_and_init_modules()
921 v4l2_subdev_call(itv->sd_video, video, s_crystal_freq, in ivtv_load_and_init_modules()
926 itv->vbi.raw_decoder_line_size = 1444; in ivtv_load_and_init_modules()
927 itv->vbi.raw_decoder_sav_odd_field = 0x20; in ivtv_load_and_init_modules()
928 itv->vbi.raw_decoder_sav_even_field = 0x60; in ivtv_load_and_init_modules()
929 itv->vbi.sliced_decoder_line_size = 272; in ivtv_load_and_init_modules()
930 itv->vbi.sliced_decoder_sav_odd_field = 0xB0; in ivtv_load_and_init_modules()
931 itv->vbi.sliced_decoder_sav_even_field = 0xF0; in ivtv_load_and_init_modules()
936 itv->hw_flags &= ~IVTV_HW_SAA711X; in ivtv_load_and_init_modules()
938 if (strstr(itv->sd_video->name, "saa7114")) { in ivtv_load_and_init_modules()
939 itv->hw_flags |= IVTV_HW_SAA7114; in ivtv_load_and_init_modules()
941 itv->v4l2_cap &= ~(V4L2_CAP_SLICED_VBI_CAPTURE|V4L2_CAP_VBI_CAPTURE); in ivtv_load_and_init_modules()
943 itv->hw_flags |= IVTV_HW_SAA7115; in ivtv_load_and_init_modules()
945 itv->vbi.raw_decoder_line_size = 1443; in ivtv_load_and_init_modules()
946 itv->vbi.raw_decoder_sav_odd_field = 0x25; in ivtv_load_and_init_modules()
947 itv->vbi.raw_decoder_sav_even_field = 0x62; in ivtv_load_and_init_modules()
948 itv->vbi.sliced_decoder_line_size = 51; in ivtv_load_and_init_modules()
949 itv->vbi.sliced_decoder_sav_odd_field = 0xAB; in ivtv_load_and_init_modules()
950 itv->vbi.sliced_decoder_sav_even_field = 0xEC; in ivtv_load_and_init_modules()
954 itv->vbi.raw_decoder_line_size = 1443; in ivtv_load_and_init_modules()
955 itv->vbi.raw_decoder_sav_odd_field = 0x25; in ivtv_load_and_init_modules()
956 itv->vbi.raw_decoder_sav_even_field = 0x62; in ivtv_load_and_init_modules()
957 itv->vbi.sliced_decoder_line_size = 51; in ivtv_load_and_init_modules()
958 itv->vbi.sliced_decoder_sav_odd_field = 0xAB; in ivtv_load_and_init_modules()
959 itv->vbi.sliced_decoder_sav_even_field = 0xEC; in ivtv_load_and_init_modules()
971 return -ENOMEM; in ivtv_probe()
972 itv->pdev = pdev; in ivtv_probe()
973 itv->instance = v4l2_device_set_name(&itv->v4l2_dev, "ivtv", in ivtv_probe()
976 retval = v4l2_device_register(&pdev->dev, &itv->v4l2_dev); in ivtv_probe()
981 IVTV_INFO("Initializing card %d\n", itv->instance); in ivtv_probe()
984 if (itv->options.cardtype == -1) { in ivtv_probe()
985 retval = -ENODEV; in ivtv_probe()
989 retval = -ENOMEM; in ivtv_probe()
992 retval = cx2341x_handler_init(&itv->cxhdl, 50); in ivtv_probe()
995 itv->v4l2_dev.ctrl_handler = &itv->cxhdl.hdl; in ivtv_probe()
996 itv->cxhdl.ops = &ivtv_cxhdl_ops; in ivtv_probe()
997 itv->cxhdl.priv = itv; in ivtv_probe()
998 itv->cxhdl.func = ivtv_api_func; in ivtv_probe()
1000 IVTV_DEBUG_INFO("base addr: 0x%llx\n", (u64)itv->base_addr); in ivtv_probe()
1004 if (retval == -EIO || retval == -ENXIO) in ivtv_probe()
1009 (u64)itv->base_addr + IVTV_ENCODER_OFFSET, IVTV_ENCODER_SIZE); in ivtv_probe()
1010 itv->enc_mem = devm_ioremap(&pdev->dev, in ivtv_probe()
1011 itv->base_addr + IVTV_ENCODER_OFFSET, in ivtv_probe()
1013 if (!itv->enc_mem) { in ivtv_probe()
1018 retval = -ENOMEM; in ivtv_probe()
1022 if (itv->has_cx23415) { in ivtv_probe()
1024 (u64)itv->base_addr + IVTV_DECODER_OFFSET, IVTV_DECODER_SIZE); in ivtv_probe()
1025 itv->dec_mem = devm_ioremap(&pdev->dev, in ivtv_probe()
1026 itv->base_addr + IVTV_DECODER_OFFSET, in ivtv_probe()
1028 if (!itv->dec_mem) { in ivtv_probe()
1033 retval = -ENOMEM; in ivtv_probe()
1038 itv->dec_mem = itv->enc_mem; in ivtv_probe()
1043 (u64)itv->base_addr + IVTV_REG_OFFSET, IVTV_REG_SIZE); in ivtv_probe()
1044 itv->reg_mem = devm_ioremap(&pdev->dev, in ivtv_probe()
1045 itv->base_addr + IVTV_REG_OFFSET, in ivtv_probe()
1047 if (!itv->reg_mem) { in ivtv_probe()
1052 retval = -ENOMEM; in ivtv_probe()
1067 if (itv->card->hw_all & IVTV_HW_TVEEPROM) { in ivtv_probe()
1072 if (itv->card->comment) in ivtv_probe()
1073 IVTV_INFO("%s", itv->card->comment); in ivtv_probe()
1074 if (itv->card->v4l2_capabilities == 0) { in ivtv_probe()
1076 retval = -ENODEV; in ivtv_probe()
1080 if (itv->std == 0) { in ivtv_probe()
1081 itv->std = V4L2_STD_NTSC_M; in ivtv_probe()
1084 if (itv->options.tuner == -1) { in ivtv_probe()
1088 if ((itv->std & itv->card->tuners[i].std) == 0) in ivtv_probe()
1090 itv->options.tuner = itv->card->tuners[i].tuner; in ivtv_probe()
1095 if (itv->options.tuner == -1 && itv->card->tuners[0].std) { in ivtv_probe()
1096 itv->std = itv->card->tuners[0].std; in ivtv_probe()
1097 if (itv->std & V4L2_STD_PAL) in ivtv_probe()
1098 itv->std = V4L2_STD_PAL_BG | V4L2_STD_PAL_H; in ivtv_probe()
1099 else if (itv->std & V4L2_STD_NTSC) in ivtv_probe()
1100 itv->std = V4L2_STD_NTSC_M; in ivtv_probe()
1101 else if (itv->std & V4L2_STD_SECAM) in ivtv_probe()
1102 itv->std = V4L2_STD_SECAM_L; in ivtv_probe()
1103 itv->options.tuner = itv->card->tuners[0].tuner; in ivtv_probe()
1105 if (itv->options.radio == -1) in ivtv_probe()
1106 itv->options.radio = (itv->card->radio_input.audio_type != 0); in ivtv_probe()
1108 /* The card is now fully identified, continue with card-specific in ivtv_probe()
1114 if (itv->std & V4L2_STD_525_60) { in ivtv_probe()
1115 itv->is_60hz = 1; in ivtv_probe()
1116 itv->is_out_60hz = 1; in ivtv_probe()
1118 itv->is_50hz = 1; in ivtv_probe()
1119 itv->is_out_50hz = 1; in ivtv_probe()
1122 itv->yuv_info.osd_full_w = 720; in ivtv_probe()
1123 itv->yuv_info.osd_full_h = itv->is_out_50hz ? 576 : 480; in ivtv_probe()
1124 itv->yuv_info.v4l2_src_w = itv->yuv_info.osd_full_w; in ivtv_probe()
1125 itv->yuv_info.v4l2_src_h = itv->yuv_info.osd_full_h; in ivtv_probe()
1127 cx2341x_handler_set_50hz(&itv->cxhdl, itv->is_50hz); in ivtv_probe()
1129 itv->stream_buf_size[IVTV_ENC_STREAM_TYPE_MPG] = 0x08000; in ivtv_probe()
1130 itv->stream_buf_size[IVTV_ENC_STREAM_TYPE_PCM] = 0x01200; in ivtv_probe()
1131 itv->stream_buf_size[IVTV_DEC_STREAM_TYPE_MPG] = 0x10000; in ivtv_probe()
1132 itv->stream_buf_size[IVTV_DEC_STREAM_TYPE_YUV] = 0x10000; in ivtv_probe()
1133 itv->stream_buf_size[IVTV_ENC_STREAM_TYPE_YUV] = 0x08000; in ivtv_probe()
1139 itv->vbi.raw_size = 1456; in ivtv_probe()
1146 vbi_buf_size = itv->vbi.raw_size * (itv->is_60hz ? 24 : 36) / 2; in ivtv_probe()
1147 itv->stream_buf_size[IVTV_ENC_STREAM_TYPE_VBI] = vbi_buf_size; in ivtv_probe()
1148 itv->stream_buf_size[IVTV_DEC_STREAM_TYPE_VBI] = sizeof(struct v4l2_sliced_vbi_data) * 36; in ivtv_probe()
1150 if (itv->options.radio > 0) in ivtv_probe()
1151 itv->v4l2_cap |= V4L2_CAP_RADIO; in ivtv_probe()
1153 if (itv->options.tuner > -1) { in ivtv_probe()
1157 setup.type = itv->options.tuner; in ivtv_probe()
1159 if (itv->options.radio > 0) in ivtv_probe()
1170 .tuner = itv->options.tuner, in ivtv_probe()
1177 /* The tuner is fixed to the standard. The other inputs (e.g. S-Video) in ivtv_probe()
1179 itv->tuner_std = itv->std; in ivtv_probe()
1181 if (itv->v4l2_cap & V4L2_CAP_VIDEO_OUTPUT) { in ivtv_probe()
1182 struct v4l2_ctrl_handler *hdl = itv->v4l2_dev.ctrl_handler; in ivtv_probe()
1184 itv->ctrl_pts = v4l2_ctrl_new_std(hdl, &ivtv_hdl_out_ops, in ivtv_probe()
1186 itv->ctrl_frame = v4l2_ctrl_new_std(hdl, &ivtv_hdl_out_ops, in ivtv_probe()
1190 itv->ctrl_audio_playback = in ivtv_probe()
1196 itv->ctrl_audio_multilingual_playback = in ivtv_probe()
1202 if (hdl->error) { in ivtv_probe()
1203 retval = hdl->error; in ivtv_probe()
1206 v4l2_ctrl_cluster(2, &itv->ctrl_pts); in ivtv_probe()
1207 v4l2_ctrl_cluster(2, &itv->ctrl_audio_playback); in ivtv_probe()
1208 ivtv_call_all(itv, video, s_std_output, itv->std); in ivtv_probe()
1219 retval = request_irq(itv->pdev->irq, ivtv_irq_handler, in ivtv_probe()
1220 IRQF_SHARED, itv->v4l2_dev.name, (void *)itv); in ivtv_probe()
1236 IVTV_INFO("Initialized card: %s\n", itv->card_name); in ivtv_probe()
1238 /* Load ivtv submodules (ivtv-alsa) */ in ivtv_probe()
1245 free_irq(itv->pdev->irq, (void *)itv); in ivtv_probe()
1247 v4l2_ctrl_handler_free(&itv->cxhdl.hdl); in ivtv_probe()
1250 kthread_stop(itv->irq_worker_task); in ivtv_probe()
1253 retval = -ENODEV; in ivtv_probe()
1256 v4l2_device_unregister(&itv->v4l2_dev); in ivtv_probe()
1272 if (test_bit(IVTV_F_I_FAILED, &itv->i_flags)) in ivtv_init_on_first_open()
1273 return -ENXIO; in ivtv_init_on_first_open()
1275 if (test_and_set_bit(IVTV_F_I_INITED, &itv->i_flags)) in ivtv_init_on_first_open()
1278 while (--fw_retry_count > 0) { in ivtv_init_on_first_open()
1287 set_bit(IVTV_F_I_FAILED, &itv->i_flags); in ivtv_init_on_first_open()
1288 return -ENXIO; in ivtv_init_on_first_open()
1295 if (itv->card->hw_all & IVTV_HW_CX25840) in ivtv_init_on_first_open()
1296 v4l2_subdev_call(itv->sd_video, core, load_fw); in ivtv_init_on_first_open()
1304 if (itv->std == V4L2_STD_NTSC_M_JP) { in ivtv_init_on_first_open()
1307 else if (itv->std & V4L2_STD_NTSC_M) { in ivtv_init_on_first_open()
1311 video_input = itv->active_input; in ivtv_init_on_first_open()
1312 itv->active_input++; /* Force update of input */ in ivtv_init_on_first_open()
1317 itv->std++; /* Force full standard initialization */ in ivtv_init_on_first_open()
1318 itv->std_out = itv->std; in ivtv_init_on_first_open()
1321 if (itv->card->v4l2_capabilities & V4L2_CAP_VIDEO_OUTPUT) { in ivtv_init_on_first_open()
1322 /* Turn on the TV-out: ivtv_init_mpeg_decoder() initializes in ivtv_init_on_first_open()
1330 if (!itv->has_cx23415) in ivtv_init_on_first_open()
1333 ivtv_s_std_enc(itv, itv->tuner_std); in ivtv_init_on_first_open()
1340 if (itv->v4l2_cap & V4L2_CAP_VIDEO_OUTPUT) { in ivtv_init_on_first_open()
1343 ivtv_s_std_dec(itv, itv->tuner_std); in ivtv_init_on_first_open()
1349 cx2341x_handler_setup(&itv->cxhdl); in ivtv_init_on_first_open()
1363 if (test_bit(IVTV_F_I_INITED, &itv->i_flags)) { in ivtv_remove()
1366 if (atomic_read(&itv->capturing) > 0) in ivtv_remove()
1372 /* Turn off the TV-out */ in ivtv_remove()
1373 if (itv->v4l2_cap & V4L2_CAP_VIDEO_OUTPUT) in ivtv_remove()
1375 if (atomic_read(&itv->decoding) > 0) { in ivtv_remove()
1378 if (test_bit(IVTV_F_I_DEC_YUV, &itv->i_flags)) in ivtv_remove()
1382 ivtv_stop_v4l2_decode_stream(&itv->streams[type], in ivtv_remove()
1390 timer_shutdown_sync(&itv->dma_timer); in ivtv_remove()
1393 kthread_flush_worker(&itv->irq_worker); in ivtv_remove()
1394 kthread_stop(itv->irq_worker_task); in ivtv_remove()
1399 v4l2_ctrl_handler_free(&itv->cxhdl.hdl); in ivtv_remove()
1403 free_irq(itv->pdev->irq, (void *)itv); in ivtv_remove()
1406 kfree(itv->vbi.sliced_mpeg_data[i]); in ivtv_remove()
1408 pr_info("Removed %s\n", itv->card_name); in ivtv_remove()
1410 v4l2_device_unregister(&itv->v4l2_dev); in ivtv_remove()
1429 IVTV_MAX_CARDS - 1); in module_start()
1430 return -1; in module_start()
1440 return -ENODEV; in module_start()
1452 framebuffer module and an infrared module for the IR-blaster. */