Lines Matching refs:itv

310 void ivtv_clear_irq_mask(struct ivtv *itv, u32 mask)  in ivtv_clear_irq_mask()  argument
312 itv->irqmask &= ~mask; in ivtv_clear_irq_mask()
313 write_reg_sync(itv->irqmask, IVTV_REG_IRQMASK); in ivtv_clear_irq_mask()
316 void ivtv_set_irq_mask(struct ivtv *itv, u32 mask) in ivtv_set_irq_mask() argument
318 itv->irqmask |= mask; in ivtv_set_irq_mask()
319 write_reg_sync(itv->irqmask, IVTV_REG_IRQMASK); in ivtv_set_irq_mask()
322 int ivtv_set_output_mode(struct ivtv *itv, int mode) in ivtv_set_output_mode() argument
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()
334 struct ivtv_stream *ivtv_get_output_stream(struct ivtv *itv) in ivtv_get_output_stream() argument
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()
375 static void ivtv_iounmap(struct ivtv *itv) in ivtv_iounmap() argument
377 if (itv == NULL) in ivtv_iounmap()
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()
402 void ivtv_read_eeprom(struct ivtv *itv, struct tveeprom *tv) in ivtv_read_eeprom() argument
406 itv->i2c_client.addr = 0xA0 >> 1; in ivtv_read_eeprom()
407 tveeprom_read(&itv->i2c_client, eedata, sizeof(eedata)); in ivtv_read_eeprom()
411 static void ivtv_process_eeprom(struct ivtv *itv) in ivtv_process_eeprom() argument
414 int pci_slot = PCI_SLOT(itv->pdev->devfn); in ivtv_process_eeprom()
416 ivtv_read_eeprom(itv, &tv); 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()
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()
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()
520 exit_ivtv_i2c(itv); in ivtv_process_eeprom()
521 init_ivtv_i2c(itv); 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()
541 itv->std |= V4L2_STD_NTSC_M; in ivtv_process_eeprom()
545 static v4l2_std_id ivtv_parse_std(struct ivtv *itv) in ivtv_parse_std() argument
638 static void ivtv_process_options(struct ivtv *itv) in ivtv_process_options() argument
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()
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()
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()
735 static int ivtv_init_struct1(struct ivtv *itv) in ivtv_init_struct1() argument
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()
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()
797 static void ivtv_init_struct2(struct ivtv *itv) in ivtv_init_struct2() argument
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()
828 static int ivtv_setup_pci(struct ivtv *itv, struct pci_dev *pdev, in ivtv_setup_pci() argument
844 if (!request_mem_region(itv->base_addr, IVTV_ENCODER_SIZE, "ivtv encoder")) { 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()
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()
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()
900 pdev->irq, pci_latency, (u64)itv->base_addr); in ivtv_setup_pci()
905 static void ivtv_load_and_init_modules(struct ivtv *itv) in ivtv_load_and_init_modules() argument
907 u32 hw = itv->card->hw_all; in ivtv_load_and_init_modules()
918 itv->hw_flags |= device; in ivtv_load_and_init_modules()
921 if (ivtv_i2c_register(itv, i) == 0) 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()
927 ivtv_i2c_new_ir_legacy(itv); 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()
999 struct ivtv *itv; in ivtv_probe() local
1001 itv = kzalloc(sizeof(struct ivtv), GFP_KERNEL); in ivtv_probe()
1002 if (itv == NULL) 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()
1010 kfree(itv); in ivtv_probe()
1013 IVTV_INFO("Initializing card %d\n", itv->instance); in ivtv_probe()
1015 ivtv_process_options(itv); in ivtv_probe()
1016 if (itv->options.cardtype == -1) { in ivtv_probe()
1020 if (ivtv_init_struct1(itv)) { 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()
1035 retval = ivtv_setup_pci(itv, pdev, pci_id); 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()
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()
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()
1087 retval = ivtv_gpio_init(itv); in ivtv_probe()
1093 if (init_ivtv_i2c(itv)) { in ivtv_probe()
1098 if (itv->card->hw_all & IVTV_HW_TVEEPROM) { in ivtv_probe()
1101 ivtv_process_eeprom(itv); 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()
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()
1141 ivtv_init_struct2(itv); in ivtv_probe()
1143 ivtv_load_and_init_modules(itv); 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()
1194 ivtv_call_all(itv, tuner, s_type_addr, &setup); in ivtv_probe()
1201 .tuner = itv->options.tuner, in ivtv_probe()
1204 ivtv_call_all(itv, tuner, s_config, &cfg); 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()
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()
1243 ivtv_call_hw(itv, IVTV_HW_SAA7127, video, s_stream, 0); in ivtv_probe()
1247 ivtv_set_irq_mask(itv, 0xffffffff); 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()
1257 retval = ivtv_streams_setup(itv); in ivtv_probe()
1262 retval = ivtv_streams_register(itv); in ivtv_probe()
1267 IVTV_INFO("Initialized card: %s\n", itv->card_name); in ivtv_probe()
1270 request_modules(itv); in ivtv_probe()
1274 ivtv_streams_cleanup(itv); 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()
1279 exit_ivtv_i2c(itv); in ivtv_probe()
1281 ivtv_iounmap(itv); 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()
1294 v4l2_device_unregister(&itv->v4l2_dev); in ivtv_probe()
1295 kfree(itv); in ivtv_probe()
1299 int ivtv_init_on_first_open(struct ivtv *itv) in ivtv_init_on_first_open() argument
1307 fh.itv = itv; in ivtv_init_on_first_open()
1310 if (test_bit(IVTV_F_I_FAILED, &itv->i_flags)) 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()
1318 if (ivtv_firmware_init(itv) == 0) in ivtv_init_on_first_open()
1325 set_bit(IVTV_F_I_FAILED, &itv->i_flags); in ivtv_init_on_first_open()
1331 ivtv_firmware_versions(itv); 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()
1363 ivtv_call_hw(itv, IVTV_HW_SAA7127, video, s_stream, 1); in ivtv_init_on_first_open()
1364 ivtv_init_mpeg_decoder(itv); 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()
1379 ivtv_clear_irq_mask(itv, IVTV_IRQ_MASK_INIT | IVTV_IRQ_DEC_VSYNC); in ivtv_init_on_first_open()
1380 ivtv_set_osd_alpha(itv); in ivtv_init_on_first_open()
1381 ivtv_s_std_dec(itv, itv->tuner_std); in ivtv_init_on_first_open()
1383 ivtv_clear_irq_mask(itv, IVTV_IRQ_MASK_INIT); in ivtv_init_on_first_open()
1387 cx2341x_handler_setup(&itv->cxhdl); in ivtv_init_on_first_open()
1394 struct ivtv *itv = to_ivtv(v4l2_dev); in ivtv_remove() local
1399 flush_request_modules(itv); in ivtv_remove()
1401 if (test_bit(IVTV_F_I_INITED, &itv->i_flags)) { in ivtv_remove()
1404 if (atomic_read(&itv->capturing) > 0) in ivtv_remove()
1405 ivtv_stop_all_captures(itv); in ivtv_remove()
1411 if (itv->v4l2_cap & V4L2_CAP_VIDEO_OUTPUT) in ivtv_remove()
1412 ivtv_call_hw(itv, IVTV_HW_SAA7127, video, s_stream, 0); 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()
1423 ivtv_halt_firmware(itv); in ivtv_remove()
1427 ivtv_set_irq_mask(itv, 0xffffffff); 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()
1434 ivtv_streams_cleanup(itv); in ivtv_remove()
1435 ivtv_udma_free(itv); in ivtv_remove()
1437 v4l2_ctrl_handler_free(&itv->cxhdl.hdl); in ivtv_remove()
1439 exit_ivtv_i2c(itv); in ivtv_remove()
1441 free_irq(itv->pdev->irq, (void *)itv); in ivtv_remove()
1442 ivtv_iounmap(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()
1456 kfree(itv); in ivtv_remove()