Lines Matching refs:itv
313 void ivtv_clear_irq_mask(struct ivtv *itv, u32 mask) in ivtv_clear_irq_mask() argument
315 itv->irqmask &= ~mask; in ivtv_clear_irq_mask()
316 write_reg_sync(itv->irqmask, IVTV_REG_IRQMASK); in ivtv_clear_irq_mask()
319 void ivtv_set_irq_mask(struct ivtv *itv, u32 mask) in ivtv_set_irq_mask() argument
321 itv->irqmask |= mask; in ivtv_set_irq_mask()
322 write_reg_sync(itv->irqmask, IVTV_REG_IRQMASK); in ivtv_set_irq_mask()
325 int ivtv_set_output_mode(struct ivtv *itv, int mode) in ivtv_set_output_mode() argument
329 spin_lock(&itv->lock); in ivtv_set_output_mode()
330 old_mode = itv->output_mode; in ivtv_set_output_mode()
332 itv->output_mode = old_mode = mode; in ivtv_set_output_mode()
333 spin_unlock(&itv->lock); in ivtv_set_output_mode()
337 struct ivtv_stream *ivtv_get_output_stream(struct ivtv *itv) in ivtv_get_output_stream() argument
339 switch (itv->output_mode) { in ivtv_get_output_stream()
341 return &itv->streams[IVTV_DEC_STREAM_TYPE_MPG]; in ivtv_get_output_stream()
343 return &itv->streams[IVTV_DEC_STREAM_TYPE_YUV]; in ivtv_get_output_stream()
378 static void ivtv_iounmap(struct ivtv *itv) in ivtv_iounmap() argument
380 if (itv == NULL) in ivtv_iounmap()
384 if (itv->reg_mem != NULL) { in ivtv_iounmap()
386 iounmap(itv->reg_mem); in ivtv_iounmap()
387 itv->reg_mem = NULL; in ivtv_iounmap()
390 if (itv->has_cx23415 && itv->dec_mem != NULL) { in ivtv_iounmap()
392 iounmap(itv->dec_mem); in ivtv_iounmap()
394 itv->dec_mem = NULL; in ivtv_iounmap()
397 if (itv->enc_mem != NULL) { in ivtv_iounmap()
399 iounmap(itv->enc_mem); in ivtv_iounmap()
400 itv->enc_mem = NULL; in ivtv_iounmap()
405 void ivtv_read_eeprom(struct ivtv *itv, struct tveeprom *tv) in ivtv_read_eeprom() argument
409 itv->i2c_client.addr = 0xA0 >> 1; in ivtv_read_eeprom()
410 tveeprom_read(&itv->i2c_client, eedata, sizeof(eedata)); in ivtv_read_eeprom()
411 tveeprom_hauppauge_analog(&itv->i2c_client, tv, eedata); in ivtv_read_eeprom()
414 static void ivtv_process_eeprom(struct ivtv *itv) in ivtv_process_eeprom() argument
417 int pci_slot = PCI_SLOT(itv->pdev->devfn); in ivtv_process_eeprom()
419 ivtv_read_eeprom(itv, &tv); in ivtv_process_eeprom()
431 itv->card = ivtv_get_card(IVTV_CARD_PVR_250); in ivtv_process_eeprom()
435 itv->card = ivtv_get_card(IVTV_CARD_PVR_350); in ivtv_process_eeprom()
440 itv->card = ivtv_get_card(IVTV_CARD_PVR_150); in ivtv_process_eeprom()
447 itv->card = ivtv_get_card(IVTV_CARD_PVR_150); in ivtv_process_eeprom()
455 itv->card = ivtv_get_card(IVTV_CARD_PVR_350_V1); in ivtv_process_eeprom()
461 itv->v4l2_cap = itv->card->v4l2_capabilities; in ivtv_process_eeprom()
462 itv->card_name = itv->card->name; in ivtv_process_eeprom()
463 itv->card_i2c = itv->card->i2c; in ivtv_process_eeprom()
487 itv->card_name = "WinTV PVR 500"; in ivtv_process_eeprom()
488 itv->card_i2c = &ivtv_i2c_radio; in ivtv_process_eeprom()
492 itv->card_name = is_first ? "WinTV PVR 500 (unit #1)" : in ivtv_process_eeprom()
500 IVTV_INFO("Autodetected %s\n", itv->card_name); in ivtv_process_eeprom()
506 itv->pvr150_workaround = 1; in ivtv_process_eeprom()
514 if (itv->options.tuner == -1) in ivtv_process_eeprom()
515 itv->options.tuner = tv.tuner_type; in ivtv_process_eeprom()
516 if (itv->options.radio == -1) in ivtv_process_eeprom()
517 itv->options.radio = (tv.has_radio != 0); in ivtv_process_eeprom()
519 if (itv->options.newi2c == -1 && tv.has_ir) { in ivtv_process_eeprom()
520 itv->options.newi2c = (tv.has_ir & 4) ? 1 : 0; in ivtv_process_eeprom()
521 if (itv->options.newi2c) { in ivtv_process_eeprom()
523 exit_ivtv_i2c(itv); in ivtv_process_eeprom()
524 init_ivtv_i2c(itv); in ivtv_process_eeprom()
528 if (itv->std != 0) in ivtv_process_eeprom()
535 itv->std |= V4L2_STD_PAL_BG | V4L2_STD_PAL_H; in ivtv_process_eeprom()
538 itv->std |= V4L2_STD_NTSC_M; in ivtv_process_eeprom()
541 itv->std |= V4L2_STD_SECAM_L; in ivtv_process_eeprom()
544 itv->std |= V4L2_STD_NTSC_M; in ivtv_process_eeprom()
548 static v4l2_std_id ivtv_parse_std(struct ivtv *itv) in ivtv_parse_std() argument
641 static void ivtv_process_options(struct ivtv *itv) in ivtv_process_options() argument
646 itv->options.kilobytes[IVTV_ENC_STREAM_TYPE_MPG] = enc_mpg_buffers * 1024; in ivtv_process_options()
647 itv->options.kilobytes[IVTV_ENC_STREAM_TYPE_YUV] = enc_yuv_buffers * 1024; in ivtv_process_options()
648 itv->options.kilobytes[IVTV_ENC_STREAM_TYPE_VBI] = enc_vbi_buffers * 1024; in ivtv_process_options()
649 itv->options.kilobytes[IVTV_ENC_STREAM_TYPE_PCM] = enc_pcm_buffers; in ivtv_process_options()
650 itv->options.kilobytes[IVTV_DEC_STREAM_TYPE_MPG] = dec_mpg_buffers * 1024; in ivtv_process_options()
651 itv->options.kilobytes[IVTV_DEC_STREAM_TYPE_YUV] = dec_yuv_buffers * 1024; in ivtv_process_options()
652 itv->options.kilobytes[IVTV_DEC_STREAM_TYPE_VBI] = dec_vbi_buffers; in ivtv_process_options()
653 itv->options.cardtype = cardtype[itv->instance]; in ivtv_process_options()
654 itv->options.tuner = tuner[itv->instance]; in ivtv_process_options()
655 itv->options.radio = radio[itv->instance]; in ivtv_process_options()
657 itv->options.i2c_clock_period = i2c_clock_period[itv->instance]; in ivtv_process_options()
658 if (itv->options.i2c_clock_period == -1) in ivtv_process_options()
659 itv->options.i2c_clock_period = IVTV_DEFAULT_I2C_CLOCK_PERIOD; in ivtv_process_options()
660 else if (itv->options.i2c_clock_period < 10) in ivtv_process_options()
661 itv->options.i2c_clock_period = 10; in ivtv_process_options()
662 else if (itv->options.i2c_clock_period > 4500) in ivtv_process_options()
663 itv->options.i2c_clock_period = 4500; in ivtv_process_options()
665 itv->options.newi2c = newi2c; in ivtv_process_options()
670 itv->std = ivtv_parse_std(itv); in ivtv_process_options()
671 if (itv->std == 0 && tunertype >= 0) in ivtv_process_options()
672 itv->std = tunertype ? V4L2_STD_MN : (V4L2_STD_ALL & ~V4L2_STD_MN); in ivtv_process_options()
673 itv->has_cx23415 = (itv->pdev->device == PCI_DEVICE_ID_IVTV15); in ivtv_process_options()
674 chipname = itv->has_cx23415 ? "cx23415" : "cx23416"; in ivtv_process_options()
675 if (itv->options.cardtype == -1) { in ivtv_process_options()
679 if ((itv->card = ivtv_get_card(itv->options.cardtype - 1))) { in ivtv_process_options()
681 itv->card->name, chipname); in ivtv_process_options()
682 } else if (itv->options.cardtype != 0) { in ivtv_process_options()
685 if (itv->card == NULL) { in ivtv_process_options()
686 if (itv->pdev->subsystem_vendor == IVTV_PCI_ID_HAUPPAUGE || in ivtv_process_options()
687 itv->pdev->subsystem_vendor == IVTV_PCI_ID_HAUPPAUGE_ALT1 || in ivtv_process_options()
688 itv->pdev->subsystem_vendor == IVTV_PCI_ID_HAUPPAUGE_ALT2) { in ivtv_process_options()
689 itv->card = ivtv_get_card(itv->has_cx23415 ? IVTV_CARD_PVR_350 : IVTV_CARD_PVR_150); in ivtv_process_options()
694 if (itv->card == NULL) { in ivtv_process_options()
695 for (i = 0; (itv->card = ivtv_get_card(i)); i++) { in ivtv_process_options()
696 if (itv->card->pci_list == NULL) in ivtv_process_options()
698 for (j = 0; itv->card->pci_list[j].device; j++) { in ivtv_process_options()
699 if (itv->pdev->device != in ivtv_process_options()
700 itv->card->pci_list[j].device) in ivtv_process_options()
702 if (itv->pdev->subsystem_vendor != in ivtv_process_options()
703 itv->card->pci_list[j].subsystem_vendor) in ivtv_process_options()
705 if (itv->pdev->subsystem_device != in ivtv_process_options()
706 itv->card->pci_list[j].subsystem_device) in ivtv_process_options()
709 itv->card->name, chipname); in ivtv_process_options()
716 if (itv->card == NULL) { in ivtv_process_options()
717 itv->card = ivtv_get_card(IVTV_CARD_PVR_150); in ivtv_process_options()
719 itv->pdev->vendor, itv->pdev->device); in ivtv_process_options()
721 itv->pdev->subsystem_vendor, itv->pdev->subsystem_device); in ivtv_process_options()
723 IVTV_ERR("Defaulting to %s card\n", itv->card->name); in ivtv_process_options()
728 itv->v4l2_cap = itv->card->v4l2_capabilities; in ivtv_process_options()
729 itv->card_name = itv->card->name; in ivtv_process_options()
730 itv->card_i2c = itv->card->i2c; in ivtv_process_options()
738 static int ivtv_init_struct1(struct ivtv *itv) in ivtv_init_struct1() argument
742 itv->base_addr = pci_resource_start(itv->pdev, 0); in ivtv_init_struct1()
743 itv->enc_mbox.max_mbox = 2; /* the encoder has 3 mailboxes (0-2) */ in ivtv_init_struct1()
744 itv->dec_mbox.max_mbox = 1; /* the decoder has 2 mailboxes (0-1) */ in ivtv_init_struct1()
746 mutex_init(&itv->serialize_lock); in ivtv_init_struct1()
747 mutex_init(&itv->i2c_bus_lock); in ivtv_init_struct1()
748 mutex_init(&itv->udma.lock); in ivtv_init_struct1()
750 spin_lock_init(&itv->lock); in ivtv_init_struct1()
751 spin_lock_init(&itv->dma_reg_lock); in ivtv_init_struct1()
753 init_kthread_worker(&itv->irq_worker); in ivtv_init_struct1()
754 itv->irq_worker_task = kthread_run(kthread_worker_fn, &itv->irq_worker, in ivtv_init_struct1()
755 "%s", itv->v4l2_dev.name); in ivtv_init_struct1()
756 if (IS_ERR(itv->irq_worker_task)) { in ivtv_init_struct1()
761 sched_setscheduler(itv->irq_worker_task, SCHED_FIFO, ¶m); in ivtv_init_struct1()
763 init_kthread_work(&itv->irq_work, ivtv_irq_work_handler); in ivtv_init_struct1()
766 itv->cxhdl.port = CX2341X_PORT_MEMORY; in ivtv_init_struct1()
767 itv->cxhdl.capabilities = CX2341X_CAP_HAS_SLICED_VBI; in ivtv_init_struct1()
768 init_waitqueue_head(&itv->eos_waitq); in ivtv_init_struct1()
769 init_waitqueue_head(&itv->event_waitq); in ivtv_init_struct1()
770 init_waitqueue_head(&itv->vsync_waitq); in ivtv_init_struct1()
771 init_waitqueue_head(&itv->dma_waitq); in ivtv_init_struct1()
772 init_timer(&itv->dma_timer); in ivtv_init_struct1()
773 itv->dma_timer.function = ivtv_unfinished_dma; in ivtv_init_struct1()
774 itv->dma_timer.data = (unsigned long)itv; in ivtv_init_struct1()
776 itv->cur_dma_stream = -1; in ivtv_init_struct1()
777 itv->cur_pio_stream = -1; in ivtv_init_struct1()
780 itv->speed = 1000; in ivtv_init_struct1()
783 itv->vbi.in.type = V4L2_BUF_TYPE_VBI_CAPTURE; in ivtv_init_struct1()
784 itv->vbi.sliced_in = &itv->vbi.in.fmt.sliced; in ivtv_init_struct1()
787 sg_init_table(itv->udma.SGlist, IVTV_DMA_SG_OSD_ENT); in ivtv_init_struct1()
790 itv->osd_global_alpha_state = 1; in ivtv_init_struct1()
791 itv->osd_global_alpha = 255; in ivtv_init_struct1()
794 atomic_set(&itv->yuv_info.next_dma_frame, -1); in ivtv_init_struct1()
795 itv->yuv_info.lace_mode = ivtv_yuv_mode; in ivtv_init_struct1()
796 itv->yuv_info.lace_threshold = ivtv_yuv_threshold; in ivtv_init_struct1()
797 itv->yuv_info.max_frames_buffered = 3; in ivtv_init_struct1()
798 itv->yuv_info.track_osd = 1; in ivtv_init_struct1()
804 static void ivtv_init_struct2(struct ivtv *itv) in ivtv_init_struct2() argument
809 if (itv->card->video_inputs[i].video_type == 0) in ivtv_init_struct2()
811 itv->nof_inputs = i; in ivtv_init_struct2()
813 if (itv->card->audio_inputs[i].audio_type == 0) in ivtv_init_struct2()
815 itv->nof_audio_inputs = i; in ivtv_init_struct2()
817 if (itv->card->hw_all & IVTV_HW_CX25840) { in ivtv_init_struct2()
818 itv->vbi.sliced_size = 288; /* multiple of 16, real size = 284 */ in ivtv_init_struct2()
820 itv->vbi.sliced_size = 64; /* multiple of 16, real size = 52 */ in ivtv_init_struct2()
824 for (i = 0; i < itv->nof_inputs; i++) { in ivtv_init_struct2()
825 if (itv->card->video_inputs[i].video_type == in ivtv_init_struct2()
829 if (i == itv->nof_inputs) in ivtv_init_struct2()
831 itv->active_input = i; in ivtv_init_struct2()
832 itv->audio_input = itv->card->video_inputs[i].audio_index; in ivtv_init_struct2()
835 static int ivtv_setup_pci(struct ivtv *itv, struct pci_dev *pdev, in ivtv_setup_pci() argument
851 if (!request_mem_region(itv->base_addr, IVTV_ENCODER_SIZE, "ivtv encoder")) { in ivtv_setup_pci()
856 if (!request_mem_region(itv->base_addr + IVTV_REG_OFFSET, in ivtv_setup_pci()
859 release_mem_region(itv->base_addr, IVTV_ENCODER_SIZE); in ivtv_setup_pci()
863 if (itv->has_cx23415 && in ivtv_setup_pci()
864 !request_mem_region(itv->base_addr + IVTV_DECODER_OFFSET, in ivtv_setup_pci()
867 release_mem_region(itv->base_addr, IVTV_ENCODER_SIZE); in ivtv_setup_pci()
868 release_mem_region(itv->base_addr + IVTV_REG_OFFSET, IVTV_REG_SIZE); in ivtv_setup_pci()
903 pdev->irq, pci_latency, (u64)itv->base_addr); in ivtv_setup_pci()
908 static void ivtv_load_and_init_modules(struct ivtv *itv) in ivtv_load_and_init_modules() argument
910 u32 hw = itv->card->hw_all; in ivtv_load_and_init_modules()
921 itv->hw_flags |= device; in ivtv_load_and_init_modules()
924 if (ivtv_i2c_register(itv, i) == 0) in ivtv_load_and_init_modules()
925 itv->hw_flags |= device; in ivtv_load_and_init_modules()
929 if ((itv->hw_flags & IVTV_HW_IR_ANY) == 0) in ivtv_load_and_init_modules()
930 ivtv_i2c_new_ir_legacy(itv); in ivtv_load_and_init_modules()
932 if (itv->card->hw_all & IVTV_HW_CX25840) in ivtv_load_and_init_modules()
933 itv->sd_video = ivtv_find_hw(itv, IVTV_HW_CX25840); in ivtv_load_and_init_modules()
934 else if (itv->card->hw_all & IVTV_HW_SAA717X) in ivtv_load_and_init_modules()
935 itv->sd_video = ivtv_find_hw(itv, IVTV_HW_SAA717X); in ivtv_load_and_init_modules()
936 else if (itv->card->hw_all & IVTV_HW_SAA7114) in ivtv_load_and_init_modules()
937 itv->sd_video = ivtv_find_hw(itv, IVTV_HW_SAA7114); in ivtv_load_and_init_modules()
939 itv->sd_video = ivtv_find_hw(itv, IVTV_HW_SAA7115); in ivtv_load_and_init_modules()
940 itv->sd_audio = ivtv_find_hw(itv, itv->card->hw_audio_ctrl); in ivtv_load_and_init_modules()
941 itv->sd_muxer = ivtv_find_hw(itv, itv->card->hw_muxer); in ivtv_load_and_init_modules()
943 hw = itv->hw_flags; in ivtv_load_and_init_modules()
945 if (itv->card->type == IVTV_CARD_CX23416GYC) { in ivtv_load_and_init_modules()
949 itv->card = ivtv_get_card(IVTV_CARD_CX23416GYC_NOGRYCS); in ivtv_load_and_init_modules()
951 itv->card = ivtv_get_card(IVTV_CARD_CX23416GYC_NOGR); in ivtv_load_and_init_modules()
953 else if (itv->card->type == IVTV_CARD_GV_MVPRX || in ivtv_load_and_init_modules()
954 itv->card->type == IVTV_CARD_GV_MVPRX2E) { in ivtv_load_and_init_modules()
956 v4l2_subdev_call(itv->sd_video, video, s_crystal_freq, in ivtv_load_and_init_modules()
961 itv->vbi.raw_decoder_line_size = 1444; in ivtv_load_and_init_modules()
962 itv->vbi.raw_decoder_sav_odd_field = 0x20; in ivtv_load_and_init_modules()
963 itv->vbi.raw_decoder_sav_even_field = 0x60; in ivtv_load_and_init_modules()
964 itv->vbi.sliced_decoder_line_size = 272; in ivtv_load_and_init_modules()
965 itv->vbi.sliced_decoder_sav_odd_field = 0xB0; in ivtv_load_and_init_modules()
966 itv->vbi.sliced_decoder_sav_even_field = 0xF0; in ivtv_load_and_init_modules()
971 itv->hw_flags &= ~IVTV_HW_SAA711X; in ivtv_load_and_init_modules()
973 if (strstr(itv->sd_video->name, "saa7114")) { in ivtv_load_and_init_modules()
974 itv->hw_flags |= IVTV_HW_SAA7114; in ivtv_load_and_init_modules()
976 itv->v4l2_cap &= ~(V4L2_CAP_SLICED_VBI_CAPTURE|V4L2_CAP_VBI_CAPTURE); in ivtv_load_and_init_modules()
978 itv->hw_flags |= IVTV_HW_SAA7115; in ivtv_load_and_init_modules()
980 itv->vbi.raw_decoder_line_size = 1443; in ivtv_load_and_init_modules()
981 itv->vbi.raw_decoder_sav_odd_field = 0x25; in ivtv_load_and_init_modules()
982 itv->vbi.raw_decoder_sav_even_field = 0x62; in ivtv_load_and_init_modules()
983 itv->vbi.sliced_decoder_line_size = 51; in ivtv_load_and_init_modules()
984 itv->vbi.sliced_decoder_sav_odd_field = 0xAB; in ivtv_load_and_init_modules()
985 itv->vbi.sliced_decoder_sav_even_field = 0xEC; in ivtv_load_and_init_modules()
989 itv->vbi.raw_decoder_line_size = 1443; in ivtv_load_and_init_modules()
990 itv->vbi.raw_decoder_sav_odd_field = 0x25; in ivtv_load_and_init_modules()
991 itv->vbi.raw_decoder_sav_even_field = 0x62; in ivtv_load_and_init_modules()
992 itv->vbi.sliced_decoder_line_size = 51; in ivtv_load_and_init_modules()
993 itv->vbi.sliced_decoder_sav_odd_field = 0xAB; in ivtv_load_and_init_modules()
994 itv->vbi.sliced_decoder_sav_even_field = 0xEC; in ivtv_load_and_init_modules()
1002 struct ivtv *itv; in ivtv_probe() local
1004 itv = kzalloc(sizeof(struct ivtv), GFP_ATOMIC); in ivtv_probe()
1005 if (itv == NULL) in ivtv_probe()
1007 itv->pdev = pdev; in ivtv_probe()
1008 itv->instance = v4l2_device_set_name(&itv->v4l2_dev, "ivtv", in ivtv_probe()
1011 retval = v4l2_device_register(&pdev->dev, &itv->v4l2_dev); in ivtv_probe()
1013 kfree(itv); in ivtv_probe()
1016 IVTV_INFO("Initializing card %d\n", itv->instance); in ivtv_probe()
1018 ivtv_process_options(itv); in ivtv_probe()
1019 if (itv->options.cardtype == -1) { in ivtv_probe()
1023 if (ivtv_init_struct1(itv)) { in ivtv_probe()
1027 retval = cx2341x_handler_init(&itv->cxhdl, 50); in ivtv_probe()
1030 itv->v4l2_dev.ctrl_handler = &itv->cxhdl.hdl; in ivtv_probe()
1031 itv->cxhdl.ops = &ivtv_cxhdl_ops; in ivtv_probe()
1032 itv->cxhdl.priv = itv; in ivtv_probe()
1033 itv->cxhdl.func = ivtv_api_func; in ivtv_probe()
1035 IVTV_DEBUG_INFO("base addr: 0x%llx\n", (u64)itv->base_addr); in ivtv_probe()
1038 retval = ivtv_setup_pci(itv, pdev, pci_id); in ivtv_probe()
1046 (u64)itv->base_addr + IVTV_ENCODER_OFFSET, IVTV_ENCODER_SIZE); in ivtv_probe()
1047 itv->enc_mem = ioremap_nocache(itv->base_addr + IVTV_ENCODER_OFFSET, in ivtv_probe()
1049 if (!itv->enc_mem) { in ivtv_probe()
1061 if (itv->has_cx23415) { in ivtv_probe()
1063 (u64)itv->base_addr + IVTV_DECODER_OFFSET, IVTV_DECODER_SIZE); in ivtv_probe()
1064 itv->dec_mem = ioremap_nocache(itv->base_addr + IVTV_DECODER_OFFSET, in ivtv_probe()
1066 if (!itv->dec_mem) { in ivtv_probe()
1080 itv->dec_mem = itv->enc_mem; in ivtv_probe()
1085 (u64)itv->base_addr + IVTV_REG_OFFSET, IVTV_REG_SIZE); in ivtv_probe()
1086 itv->reg_mem = in ivtv_probe()
1087 ioremap_nocache(itv->base_addr + IVTV_REG_OFFSET, IVTV_REG_SIZE); in ivtv_probe()
1088 if (!itv->reg_mem) { in ivtv_probe()
1100 retval = ivtv_gpio_init(itv); in ivtv_probe()
1106 if (init_ivtv_i2c(itv)) { in ivtv_probe()
1111 if (itv->card->hw_all & IVTV_HW_TVEEPROM) { in ivtv_probe()
1114 ivtv_process_eeprom(itv); in ivtv_probe()
1116 if (itv->card->comment) in ivtv_probe()
1117 IVTV_INFO("%s", itv->card->comment); in ivtv_probe()
1118 if (itv->card->v4l2_capabilities == 0) { in ivtv_probe()
1124 if (itv->std == 0) { in ivtv_probe()
1125 itv->std = V4L2_STD_NTSC_M; in ivtv_probe()
1128 if (itv->options.tuner == -1) { in ivtv_probe()
1132 if ((itv->std & itv->card->tuners[i].std) == 0) in ivtv_probe()
1134 itv->options.tuner = itv->card->tuners[i].tuner; in ivtv_probe()
1139 if (itv->options.tuner == -1 && itv->card->tuners[0].std) { in ivtv_probe()
1140 itv->std = itv->card->tuners[0].std; in ivtv_probe()
1141 if (itv->std & V4L2_STD_PAL) in ivtv_probe()
1142 itv->std = V4L2_STD_PAL_BG | V4L2_STD_PAL_H; in ivtv_probe()
1143 else if (itv->std & V4L2_STD_NTSC) in ivtv_probe()
1144 itv->std = V4L2_STD_NTSC_M; in ivtv_probe()
1145 else if (itv->std & V4L2_STD_SECAM) in ivtv_probe()
1146 itv->std = V4L2_STD_SECAM_L; in ivtv_probe()
1147 itv->options.tuner = itv->card->tuners[0].tuner; in ivtv_probe()
1149 if (itv->options.radio == -1) in ivtv_probe()
1150 itv->options.radio = (itv->card->radio_input.audio_type != 0); in ivtv_probe()
1154 ivtv_init_struct2(itv); in ivtv_probe()
1156 ivtv_load_and_init_modules(itv); in ivtv_probe()
1158 if (itv->std & V4L2_STD_525_60) { in ivtv_probe()
1159 itv->is_60hz = 1; in ivtv_probe()
1160 itv->is_out_60hz = 1; in ivtv_probe()
1162 itv->is_50hz = 1; in ivtv_probe()
1163 itv->is_out_50hz = 1; in ivtv_probe()
1166 itv->yuv_info.osd_full_w = 720; in ivtv_probe()
1167 itv->yuv_info.osd_full_h = itv->is_out_50hz ? 576 : 480; in ivtv_probe()
1168 itv->yuv_info.v4l2_src_w = itv->yuv_info.osd_full_w; in ivtv_probe()
1169 itv->yuv_info.v4l2_src_h = itv->yuv_info.osd_full_h; in ivtv_probe()
1171 cx2341x_handler_set_50hz(&itv->cxhdl, itv->is_50hz); in ivtv_probe()
1173 itv->stream_buf_size[IVTV_ENC_STREAM_TYPE_MPG] = 0x08000; in ivtv_probe()
1174 itv->stream_buf_size[IVTV_ENC_STREAM_TYPE_PCM] = 0x01200; in ivtv_probe()
1175 itv->stream_buf_size[IVTV_DEC_STREAM_TYPE_MPG] = 0x10000; in ivtv_probe()
1176 itv->stream_buf_size[IVTV_DEC_STREAM_TYPE_YUV] = 0x10000; in ivtv_probe()
1177 itv->stream_buf_size[IVTV_ENC_STREAM_TYPE_YUV] = 0x08000; in ivtv_probe()
1183 itv->vbi.raw_size = 1456; in ivtv_probe()
1190 vbi_buf_size = itv->vbi.raw_size * (itv->is_60hz ? 24 : 36) / 2; in ivtv_probe()
1191 itv->stream_buf_size[IVTV_ENC_STREAM_TYPE_VBI] = vbi_buf_size; in ivtv_probe()
1192 itv->stream_buf_size[IVTV_DEC_STREAM_TYPE_VBI] = sizeof(struct v4l2_sliced_vbi_data) * 36; in ivtv_probe()
1194 if (itv->options.radio > 0) in ivtv_probe()
1195 itv->v4l2_cap |= V4L2_CAP_RADIO; in ivtv_probe()
1197 if (itv->options.tuner > -1) { in ivtv_probe()
1201 setup.type = itv->options.tuner; in ivtv_probe()
1203 if (itv->options.radio > 0) in ivtv_probe()
1207 ivtv_call_all(itv, tuner, s_type_addr, &setup); in ivtv_probe()
1214 .tuner = itv->options.tuner, in ivtv_probe()
1217 ivtv_call_all(itv, tuner, s_config, &cfg); in ivtv_probe()
1223 itv->tuner_std = itv->std; in ivtv_probe()
1225 if (itv->v4l2_cap & V4L2_CAP_VIDEO_OUTPUT) { in ivtv_probe()
1226 struct v4l2_ctrl_handler *hdl = itv->v4l2_dev.ctrl_handler; in ivtv_probe()
1228 itv->ctrl_pts = v4l2_ctrl_new_std(hdl, &ivtv_hdl_out_ops, in ivtv_probe()
1230 itv->ctrl_frame = v4l2_ctrl_new_std(hdl, &ivtv_hdl_out_ops, in ivtv_probe()
1234 itv->ctrl_audio_playback = in ivtv_probe()
1240 itv->ctrl_audio_multilingual_playback = in ivtv_probe()
1250 v4l2_ctrl_cluster(2, &itv->ctrl_pts); in ivtv_probe()
1251 v4l2_ctrl_cluster(2, &itv->ctrl_audio_playback); in ivtv_probe()
1252 ivtv_call_all(itv, video, s_std_output, itv->std); in ivtv_probe()
1256 ivtv_call_hw(itv, IVTV_HW_SAA7127, video, s_stream, 0); in ivtv_probe()
1260 ivtv_set_irq_mask(itv, 0xffffffff); in ivtv_probe()
1263 retval = request_irq(itv->pdev->irq, ivtv_irq_handler, in ivtv_probe()
1264 IRQF_SHARED, itv->v4l2_dev.name, (void *)itv); in ivtv_probe()
1270 retval = ivtv_streams_setup(itv); in ivtv_probe()
1275 retval = ivtv_streams_register(itv); in ivtv_probe()
1280 IVTV_INFO("Initialized card: %s\n", itv->card_name); in ivtv_probe()
1283 request_modules(itv); in ivtv_probe()
1287 ivtv_streams_cleanup(itv); in ivtv_probe()
1289 free_irq(itv->pdev->irq, (void *)itv); in ivtv_probe()
1291 v4l2_ctrl_handler_free(&itv->cxhdl.hdl); in ivtv_probe()
1292 exit_ivtv_i2c(itv); in ivtv_probe()
1294 ivtv_iounmap(itv); in ivtv_probe()
1296 release_mem_region(itv->base_addr, IVTV_ENCODER_SIZE); in ivtv_probe()
1297 release_mem_region(itv->base_addr + IVTV_REG_OFFSET, IVTV_REG_SIZE); in ivtv_probe()
1298 if (itv->has_cx23415) in ivtv_probe()
1299 release_mem_region(itv->base_addr + IVTV_DECODER_OFFSET, IVTV_DECODER_SIZE); in ivtv_probe()
1301 kthread_stop(itv->irq_worker_task); in ivtv_probe()
1307 v4l2_device_unregister(&itv->v4l2_dev); in ivtv_probe()
1308 kfree(itv); in ivtv_probe()
1312 int ivtv_init_on_first_open(struct ivtv *itv) in ivtv_init_on_first_open() argument
1320 fh.itv = itv; in ivtv_init_on_first_open()
1323 if (test_bit(IVTV_F_I_FAILED, &itv->i_flags)) in ivtv_init_on_first_open()
1326 if (test_and_set_bit(IVTV_F_I_INITED, &itv->i_flags)) in ivtv_init_on_first_open()
1331 if (ivtv_firmware_init(itv) == 0) in ivtv_init_on_first_open()
1338 set_bit(IVTV_F_I_FAILED, &itv->i_flags); in ivtv_init_on_first_open()
1344 ivtv_firmware_versions(itv); in ivtv_init_on_first_open()
1346 if (itv->card->hw_all & IVTV_HW_CX25840) in ivtv_init_on_first_open()
1347 v4l2_subdev_call(itv->sd_video, core, load_fw); in ivtv_init_on_first_open()
1355 if (itv->std == V4L2_STD_NTSC_M_JP) { in ivtv_init_on_first_open()
1358 else if (itv->std & V4L2_STD_NTSC_M) { in ivtv_init_on_first_open()
1362 video_input = itv->active_input; in ivtv_init_on_first_open()
1363 itv->active_input++; /* Force update of input */ in ivtv_init_on_first_open()
1368 itv->std++; /* Force full standard initialization */ in ivtv_init_on_first_open()
1369 itv->std_out = itv->std; in ivtv_init_on_first_open()
1372 if (itv->card->v4l2_capabilities & V4L2_CAP_VIDEO_OUTPUT) { in ivtv_init_on_first_open()
1376 ivtv_call_hw(itv, IVTV_HW_SAA7127, video, s_stream, 1); in ivtv_init_on_first_open()
1377 ivtv_init_mpeg_decoder(itv); in ivtv_init_on_first_open()
1381 if (!itv->has_cx23415) in ivtv_init_on_first_open()
1384 ivtv_s_std_enc(itv, itv->tuner_std); in ivtv_init_on_first_open()
1391 if (itv->v4l2_cap & V4L2_CAP_VIDEO_OUTPUT) { in ivtv_init_on_first_open()
1392 ivtv_clear_irq_mask(itv, IVTV_IRQ_MASK_INIT | IVTV_IRQ_DEC_VSYNC); in ivtv_init_on_first_open()
1393 ivtv_set_osd_alpha(itv); in ivtv_init_on_first_open()
1394 ivtv_s_std_dec(itv, itv->tuner_std); in ivtv_init_on_first_open()
1396 ivtv_clear_irq_mask(itv, IVTV_IRQ_MASK_INIT); in ivtv_init_on_first_open()
1400 cx2341x_handler_setup(&itv->cxhdl); in ivtv_init_on_first_open()
1407 struct ivtv *itv = to_ivtv(v4l2_dev); in ivtv_remove() local
1412 flush_request_modules(itv); in ivtv_remove()
1414 if (test_bit(IVTV_F_I_INITED, &itv->i_flags)) { in ivtv_remove()
1417 if (atomic_read(&itv->capturing) > 0) in ivtv_remove()
1418 ivtv_stop_all_captures(itv); in ivtv_remove()
1424 if (itv->v4l2_cap & V4L2_CAP_VIDEO_OUTPUT) in ivtv_remove()
1425 ivtv_call_hw(itv, IVTV_HW_SAA7127, video, s_stream, 0); in ivtv_remove()
1426 if (atomic_read(&itv->decoding) > 0) { in ivtv_remove()
1429 if (test_bit(IVTV_F_I_DEC_YUV, &itv->i_flags)) in ivtv_remove()
1433 ivtv_stop_v4l2_decode_stream(&itv->streams[type], in ivtv_remove()
1436 ivtv_halt_firmware(itv); in ivtv_remove()
1440 ivtv_set_irq_mask(itv, 0xffffffff); in ivtv_remove()
1441 del_timer_sync(&itv->dma_timer); in ivtv_remove()
1444 flush_kthread_worker(&itv->irq_worker); in ivtv_remove()
1445 kthread_stop(itv->irq_worker_task); in ivtv_remove()
1447 ivtv_streams_cleanup(itv); in ivtv_remove()
1448 ivtv_udma_free(itv); in ivtv_remove()
1450 v4l2_ctrl_handler_free(&itv->cxhdl.hdl); in ivtv_remove()
1452 exit_ivtv_i2c(itv); in ivtv_remove()
1454 free_irq(itv->pdev->irq, (void *)itv); in ivtv_remove()
1455 ivtv_iounmap(itv); in ivtv_remove()
1457 release_mem_region(itv->base_addr, IVTV_ENCODER_SIZE); in ivtv_remove()
1458 release_mem_region(itv->base_addr + IVTV_REG_OFFSET, IVTV_REG_SIZE); in ivtv_remove()
1459 if (itv->has_cx23415) in ivtv_remove()
1460 release_mem_region(itv->base_addr + IVTV_DECODER_OFFSET, IVTV_DECODER_SIZE); in ivtv_remove()
1462 pci_disable_device(itv->pdev); in ivtv_remove()
1464 kfree(itv->vbi.sliced_mpeg_data[i]); in ivtv_remove()
1466 printk(KERN_INFO "ivtv: Removed %s\n", itv->card_name); in ivtv_remove()
1468 v4l2_device_unregister(&itv->v4l2_dev); in ivtv_remove()
1469 kfree(itv); in ivtv_remove()