Lines Matching refs:itv

310 void ivtv_clear_irq_mask(struct ivtv *itv, u32 mask)
312 itv->irqmask &= ~mask;
313 write_reg_sync(itv->irqmask, IVTV_REG_IRQMASK);
316 void ivtv_set_irq_mask(struct ivtv *itv, u32 mask)
318 itv->irqmask |= mask;
319 write_reg_sync(itv->irqmask, IVTV_REG_IRQMASK);
322 int ivtv_set_output_mode(struct ivtv *itv, int mode)
326 spin_lock(&itv->lock);
327 old_mode = itv->output_mode;
329 itv->output_mode = old_mode = mode;
330 spin_unlock(&itv->lock);
334 struct ivtv_stream *ivtv_get_output_stream(struct ivtv *itv)
336 switch (itv->output_mode) {
338 return &itv->streams[IVTV_DEC_STREAM_TYPE_MPG];
340 return &itv->streams[IVTV_DEC_STREAM_TYPE_YUV];
375 static void ivtv_iounmap(struct ivtv *itv)
377 if (itv == NULL)
381 if (itv->reg_mem != NULL) {
383 iounmap(itv->reg_mem);
384 itv->reg_mem = NULL;
387 if (itv->has_cx23415 && itv->dec_mem != NULL) {
389 iounmap(itv->dec_mem);
391 itv->dec_mem = NULL;
394 if (itv->enc_mem != NULL) {
396 iounmap(itv->enc_mem);
397 itv->enc_mem = NULL;
402 void ivtv_read_eeprom(struct ivtv *itv, struct tveeprom *tv)
406 itv->i2c_client.addr = 0xA0 >> 1;
407 tveeprom_read(&itv->i2c_client, eedata, sizeof(eedata));
411 static void ivtv_process_eeprom(struct ivtv *itv)
414 int pci_slot = PCI_SLOT(itv->pdev->devfn);
416 ivtv_read_eeprom(itv, &tv);
428 itv->card = ivtv_get_card(IVTV_CARD_PVR_250);
432 itv->card = ivtv_get_card(IVTV_CARD_PVR_350);
437 itv->card = ivtv_get_card(IVTV_CARD_PVR_150);
444 itv->card = ivtv_get_card(IVTV_CARD_PVR_150);
452 itv->card = ivtv_get_card(IVTV_CARD_PVR_350_V1);
458 itv->v4l2_cap = itv->card->v4l2_capabilities;
459 itv->card_name = itv->card->name;
460 itv->card_i2c = itv->card->i2c;
484 itv->card_name = "WinTV PVR 500";
485 itv->card_i2c = &ivtv_i2c_radio;
489 itv->card_name = is_first ? "WinTV PVR 500 (unit #1)" :
497 IVTV_INFO("Autodetected %s\n", itv->card_name);
503 itv->pvr150_workaround = 1;
511 if (itv->options.tuner == -1)
512 itv->options.tuner = tv.tuner_type;
513 if (itv->options.radio == -1)
514 itv->options.radio = (tv.has_radio != 0);
516 if (itv->options.newi2c == -1 && tv.has_ir) {
517 itv->options.newi2c = (tv.has_ir & 4) ? 1 : 0;
518 if (itv->options.newi2c) {
520 exit_ivtv_i2c(itv);
521 init_ivtv_i2c(itv);
525 if (itv->std != 0)
532 itv->std |= V4L2_STD_PAL_BG | V4L2_STD_PAL_H;
535 itv->std |= V4L2_STD_NTSC_M;
538 itv->std |= V4L2_STD_SECAM_L;
541 itv->std |= V4L2_STD_NTSC_M;
545 static v4l2_std_id ivtv_parse_std(struct ivtv *itv)
638 static void ivtv_process_options(struct ivtv *itv)
643 itv->options.kilobytes[IVTV_ENC_STREAM_TYPE_MPG] = enc_mpg_buffers * 1024;
644 itv->options.kilobytes[IVTV_ENC_STREAM_TYPE_YUV] = enc_yuv_buffers * 1024;
645 itv->options.kilobytes[IVTV_ENC_STREAM_TYPE_VBI] = enc_vbi_buffers * 1024;
646 itv->options.kilobytes[IVTV_ENC_STREAM_TYPE_PCM] = enc_pcm_buffers;
647 itv->options.kilobytes[IVTV_DEC_STREAM_TYPE_MPG] = dec_mpg_buffers * 1024;
648 itv->options.kilobytes[IVTV_DEC_STREAM_TYPE_YUV] = dec_yuv_buffers * 1024;
649 itv->options.kilobytes[IVTV_DEC_STREAM_TYPE_VBI] = dec_vbi_buffers;
650 itv->options.cardtype = cardtype[itv->instance];
651 itv->options.tuner = tuner[itv->instance];
652 itv->options.radio = radio[itv->instance];
654 itv->options.i2c_clock_period = i2c_clock_period[itv->instance];
655 if (itv->options.i2c_clock_period == -1)
656 itv->options.i2c_clock_period = IVTV_DEFAULT_I2C_CLOCK_PERIOD;
657 else if (itv->options.i2c_clock_period < 10)
658 itv->options.i2c_clock_period = 10;
659 else if (itv->options.i2c_clock_period > 4500)
660 itv->options.i2c_clock_period = 4500;
662 itv->options.newi2c = newi2c;
667 itv->std = ivtv_parse_std(itv);
668 if (itv->std == 0 && tunertype >= 0)
669 itv->std = tunertype ? V4L2_STD_MN : (V4L2_STD_ALL & ~V4L2_STD_MN);
670 itv->has_cx23415 = (itv->pdev->device == PCI_DEVICE_ID_IVTV15);
671 chipname = itv->has_cx23415 ? "cx23415" : "cx23416";
672 if (itv->options.cardtype == -1) {
676 if ((itv->card = ivtv_get_card(itv->options.cardtype - 1))) {
678 itv->card->name, chipname);
679 } else if (itv->options.cardtype != 0) {
682 if (itv->card == NULL) {
683 if (itv->pdev->subsystem_vendor == IVTV_PCI_ID_HAUPPAUGE ||
684 itv->pdev->subsystem_vendor == IVTV_PCI_ID_HAUPPAUGE_ALT1 ||
685 itv->pdev->subsystem_vendor == IVTV_PCI_ID_HAUPPAUGE_ALT2) {
686 itv->card = ivtv_get_card(itv->has_cx23415 ? IVTV_CARD_PVR_350 : IVTV_CARD_PVR_150);
691 if (itv->card == NULL) {
692 for (i = 0; (itv->card = ivtv_get_card(i)); i++) {
693 if (itv->card->pci_list == NULL)
695 for (j = 0; itv->card->pci_list[j].device; j++) {
696 if (itv->pdev->device !=
697 itv->card->pci_list[j].device)
699 if (itv->pdev->subsystem_vendor !=
700 itv->card->pci_list[j].subsystem_vendor)
702 if (itv->pdev->subsystem_device !=
703 itv->card->pci_list[j].subsystem_device)
706 itv->card->name, chipname);
713 if (itv->card == NULL) {
714 itv->card = ivtv_get_card(IVTV_CARD_PVR_150);
716 itv->pdev->vendor, itv->pdev->device);
718 itv->pdev->subsystem_vendor, itv->pdev->subsystem_device);
720 IVTV_ERR("Defaulting to %s card\n", itv->card->name);
725 itv->v4l2_cap = itv->card->v4l2_capabilities;
726 itv->card_name = itv->card->name;
727 itv->card_i2c = itv->card->i2c;
735 static int ivtv_init_struct1(struct ivtv *itv)
737 itv->base_addr = pci_resource_start(itv->pdev, 0);
738 itv->enc_mbox.max_mbox = 2; /* the encoder has 3 mailboxes (0-2) */
739 itv->dec_mbox.max_mbox = 1; /* the decoder has 2 mailboxes (0-1) */
741 mutex_init(&itv->serialize_lock);
742 mutex_init(&itv->i2c_bus_lock);
743 mutex_init(&itv->udma.lock);
745 spin_lock_init(&itv->lock);
746 spin_lock_init(&itv->dma_reg_lock);
748 kthread_init_worker(&itv->irq_worker);
749 itv->irq_worker_task = kthread_run(kthread_worker_fn, &itv->irq_worker,
750 "%s", itv->v4l2_dev.name);
751 if (IS_ERR(itv->irq_worker_task)) {
756 sched_set_fifo(itv->irq_worker_task);
758 kthread_init_work(&itv->irq_work, ivtv_irq_work_handler);
761 itv->cxhdl.port = CX2341X_PORT_MEMORY;
762 itv->cxhdl.capabilities = CX2341X_CAP_HAS_SLICED_VBI;
763 init_waitqueue_head(&itv->eos_waitq);
764 init_waitqueue_head(&itv->event_waitq);
765 init_waitqueue_head(&itv->vsync_waitq);
766 init_waitqueue_head(&itv->dma_waitq);
767 timer_setup(&itv->dma_timer, ivtv_unfinished_dma, 0);
769 itv->cur_dma_stream = -1;
770 itv->cur_pio_stream = -1;
773 itv->speed = 1000;
776 itv->vbi.in.type = V4L2_BUF_TYPE_VBI_CAPTURE;
777 itv->vbi.sliced_in = &itv->vbi.in.fmt.sliced;
780 sg_init_table(itv->udma.SGlist, IVTV_DMA_SG_OSD_ENT);
783 itv->osd_global_alpha_state = 1;
784 itv->osd_global_alpha = 255;
787 atomic_set(&itv->yuv_info.next_dma_frame, -1);
788 itv->yuv_info.lace_mode = ivtv_yuv_mode;
789 itv->yuv_info.lace_threshold = ivtv_yuv_threshold;
790 itv->yuv_info.max_frames_buffered = 3;
791 itv->yuv_info.track_osd = 1;
797 static void ivtv_init_struct2(struct ivtv *itv)
802 if (itv->card->video_inputs[i].video_type == 0)
804 itv->nof_inputs = i;
806 if (itv->card->audio_inputs[i].audio_type == 0)
808 itv->nof_audio_inputs = i;
810 if (itv->card->hw_all & IVTV_HW_CX25840) {
811 itv->vbi.sliced_size = 288; /* multiple of 16, real size = 284 */
813 itv->vbi.sliced_size = 64; /* multiple of 16, real size = 52 */
817 for (i = 0; i < itv->nof_inputs; i++) {
818 if (itv->card->video_inputs[i].video_type ==
822 if (i >= itv->nof_inputs)
824 itv->active_input = i;
825 itv->audio_input = itv->card->video_inputs[i].audio_index;
828 static int ivtv_setup_pci(struct ivtv *itv, struct pci_dev *pdev,
844 if (!request_mem_region(itv->base_addr, IVTV_ENCODER_SIZE, "ivtv encoder")) {
849 if (!request_mem_region(itv->base_addr + IVTV_REG_OFFSET,
852 release_mem_region(itv->base_addr, IVTV_ENCODER_SIZE);
856 if (itv->has_cx23415 &&
857 !request_mem_region(itv->base_addr + IVTV_DECODER_OFFSET,
860 release_mem_region(itv->base_addr, IVTV_ENCODER_SIZE);
861 release_mem_region(itv->base_addr + IVTV_REG_OFFSET, IVTV_REG_SIZE);
873 if (itv->has_cx23415)
874 release_mem_region(itv->base_addr + IVTV_DECODER_OFFSET,
876 release_mem_region(itv->base_addr, IVTV_ENCODER_SIZE);
877 release_mem_region(itv->base_addr + IVTV_REG_OFFSET, IVTV_REG_SIZE);
900 pdev->irq, pci_latency, (u64)itv->base_addr);
905 static void ivtv_load_and_init_modules(struct ivtv *itv)
907 u32 hw = itv->card->hw_all;
918 itv->hw_flags |= device;
921 if (ivtv_i2c_register(itv, i) == 0)
922 itv->hw_flags |= device;
926 if ((itv->hw_flags & IVTV_HW_IR_ANY) == 0)
927 ivtv_i2c_new_ir_legacy(itv);
929 if (itv->card->hw_all & IVTV_HW_CX25840)
930 itv->sd_video = ivtv_find_hw(itv, IVTV_HW_CX25840);
931 else if (itv->card->hw_all & IVTV_HW_SAA717X)
932 itv->sd_video = ivtv_find_hw(itv, IVTV_HW_SAA717X);
933 else if (itv->card->hw_all & IVTV_HW_SAA7114)
934 itv->sd_video = ivtv_find_hw(itv, IVTV_HW_SAA7114);
936 itv->sd_video = ivtv_find_hw(itv, IVTV_HW_SAA7115);
937 itv->sd_audio = ivtv_find_hw(itv, itv->card->hw_audio_ctrl);
938 itv->sd_muxer = ivtv_find_hw(itv, itv->card->hw_muxer);
940 hw = itv->hw_flags;
942 if (itv->card->type == IVTV_CARD_CX23416GYC) {
946 itv->card = ivtv_get_card(IVTV_CARD_CX23416GYC_NOGRYCS);
948 itv->card = ivtv_get_card(IVTV_CARD_CX23416GYC_NOGR);
950 else if (itv->card->type == IVTV_CARD_GV_MVPRX ||
951 itv->card->type == IVTV_CARD_GV_MVPRX2E) {
953 v4l2_subdev_call(itv->sd_video, video, s_crystal_freq,
958 itv->vbi.raw_decoder_line_size = 1444;
959 itv->vbi.raw_decoder_sav_odd_field = 0x20;
960 itv->vbi.raw_decoder_sav_even_field = 0x60;
961 itv->vbi.sliced_decoder_line_size = 272;
962 itv->vbi.sliced_decoder_sav_odd_field = 0xB0;
963 itv->vbi.sliced_decoder_sav_even_field = 0xF0;
968 itv->hw_flags &= ~IVTV_HW_SAA711X;
970 if (strstr(itv->sd_video->name, "saa7114")) {
971 itv->hw_flags |= IVTV_HW_SAA7114;
973 itv->v4l2_cap &= ~(V4L2_CAP_SLICED_VBI_CAPTURE|V4L2_CAP_VBI_CAPTURE);
975 itv->hw_flags |= IVTV_HW_SAA7115;
977 itv->vbi.raw_decoder_line_size = 1443;
978 itv->vbi.raw_decoder_sav_odd_field = 0x25;
979 itv->vbi.raw_decoder_sav_even_field = 0x62;
980 itv->vbi.sliced_decoder_line_size = 51;
981 itv->vbi.sliced_decoder_sav_odd_field = 0xAB;
982 itv->vbi.sliced_decoder_sav_even_field = 0xEC;
986 itv->vbi.raw_decoder_line_size = 1443;
987 itv->vbi.raw_decoder_sav_odd_field = 0x25;
988 itv->vbi.raw_decoder_sav_even_field = 0x62;
989 itv->vbi.sliced_decoder_line_size = 51;
990 itv->vbi.sliced_decoder_sav_odd_field = 0xAB;
991 itv->vbi.sliced_decoder_sav_even_field = 0xEC;
999 struct ivtv *itv;
1001 itv = kzalloc(sizeof(struct ivtv), GFP_KERNEL);
1002 if (itv == NULL)
1004 itv->pdev = pdev;
1005 itv->instance = v4l2_device_set_name(&itv->v4l2_dev, "ivtv",
1008 retval = v4l2_device_register(&pdev->dev, &itv->v4l2_dev);
1010 kfree(itv);
1013 IVTV_INFO("Initializing card %d\n", itv->instance);
1015 ivtv_process_options(itv);
1016 if (itv->options.cardtype == -1) {
1020 if (ivtv_init_struct1(itv)) {
1024 retval = cx2341x_handler_init(&itv->cxhdl, 50);
1027 itv->v4l2_dev.ctrl_handler = &itv->cxhdl.hdl;
1028 itv->cxhdl.ops = &ivtv_cxhdl_ops;
1029 itv->cxhdl.priv = itv;
1030 itv->cxhdl.func = ivtv_api_func;
1032 IVTV_DEBUG_INFO("base addr: 0x%llx\n", (u64)itv->base_addr);
1035 retval = ivtv_setup_pci(itv, pdev, pci_id);
1043 (u64)itv->base_addr + IVTV_ENCODER_OFFSET, IVTV_ENCODER_SIZE);
1044 itv->enc_mem = ioremap(itv->base_addr + IVTV_ENCODER_OFFSET,
1046 if (!itv->enc_mem) {
1055 if (itv->has_cx23415) {
1057 (u64)itv->base_addr + IVTV_DECODER_OFFSET, IVTV_DECODER_SIZE);
1058 itv->dec_mem = ioremap(itv->base_addr + IVTV_DECODER_OFFSET,
1060 if (!itv->dec_mem) {
1070 itv->dec_mem = itv->enc_mem;
1075 (u64)itv->base_addr + IVTV_REG_OFFSET, IVTV_REG_SIZE);
1076 itv->reg_mem =
1077 ioremap(itv->base_addr + IVTV_REG_OFFSET, IVTV_REG_SIZE);
1078 if (!itv->reg_mem) {
1087 retval = ivtv_gpio_init(itv);
1093 if (init_ivtv_i2c(itv)) {
1098 if (itv->card->hw_all & IVTV_HW_TVEEPROM) {
1101 ivtv_process_eeprom(itv);
1103 if (itv->card->comment)
1104 IVTV_INFO("%s", itv->card->comment);
1105 if (itv->card->v4l2_capabilities == 0) {
1111 if (itv->std == 0) {
1112 itv->std = V4L2_STD_NTSC_M;
1115 if (itv->options.tuner == -1) {
1119 if ((itv->std & itv->card->tuners[i].std) == 0)
1121 itv->options.tuner = itv->card->tuners[i].tuner;
1126 if (itv->options.tuner == -1 && itv->card->tuners[0].std) {
1127 itv->std = itv->card->tuners[0].std;
1128 if (itv->std & V4L2_STD_PAL)
1129 itv->std = V4L2_STD_PAL_BG | V4L2_STD_PAL_H;
1130 else if (itv->std & V4L2_STD_NTSC)
1131 itv->std = V4L2_STD_NTSC_M;
1132 else if (itv->std & V4L2_STD_SECAM)
1133 itv->std = V4L2_STD_SECAM_L;
1134 itv->options.tuner = itv->card->tuners[0].tuner;
1136 if (itv->options.radio == -1)
1137 itv->options.radio = (itv->card->radio_input.audio_type != 0);
1141 ivtv_init_struct2(itv);
1143 ivtv_load_and_init_modules(itv);
1145 if (itv->std & V4L2_STD_525_60) {
1146 itv->is_60hz = 1;
1147 itv->is_out_60hz = 1;
1149 itv->is_50hz = 1;
1150 itv->is_out_50hz = 1;
1153 itv->yuv_info.osd_full_w = 720;
1154 itv->yuv_info.osd_full_h = itv->is_out_50hz ? 576 : 480;
1155 itv->yuv_info.v4l2_src_w = itv->yuv_info.osd_full_w;
1156 itv->yuv_info.v4l2_src_h = itv->yuv_info.osd_full_h;
1158 cx2341x_handler_set_50hz(&itv->cxhdl, itv->is_50hz);
1160 itv->stream_buf_size[IVTV_ENC_STREAM_TYPE_MPG] = 0x08000;
1161 itv->stream_buf_size[IVTV_ENC_STREAM_TYPE_PCM] = 0x01200;
1162 itv->stream_buf_size[IVTV_DEC_STREAM_TYPE_MPG] = 0x10000;
1163 itv->stream_buf_size[IVTV_DEC_STREAM_TYPE_YUV] = 0x10000;
1164 itv->stream_buf_size[IVTV_ENC_STREAM_TYPE_YUV] = 0x08000;
1170 itv->vbi.raw_size = 1456;
1177 vbi_buf_size = itv->vbi.raw_size * (itv->is_60hz ? 24 : 36) / 2;
1178 itv->stream_buf_size[IVTV_ENC_STREAM_TYPE_VBI] = vbi_buf_size;
1179 itv->stream_buf_size[IVTV_DEC_STREAM_TYPE_VBI] = sizeof(struct v4l2_sliced_vbi_data) * 36;
1181 if (itv->options.radio > 0)
1182 itv->v4l2_cap |= V4L2_CAP_RADIO;
1184 if (itv->options.tuner > -1) {
1188 setup.type = itv->options.tuner;
1190 if (itv->options.radio > 0)
1194 ivtv_call_all(itv, tuner, s_type_addr, &setup);
1201 .tuner = itv->options.tuner,
1204 ivtv_call_all(itv, tuner, s_config, &cfg);
1210 itv->tuner_std = itv->std;
1212 if (itv->v4l2_cap & V4L2_CAP_VIDEO_OUTPUT) {
1213 struct v4l2_ctrl_handler *hdl = itv->v4l2_dev.ctrl_handler;
1215 itv->ctrl_pts = v4l2_ctrl_new_std(hdl, &ivtv_hdl_out_ops,
1217 itv->ctrl_frame = v4l2_ctrl_new_std(hdl, &ivtv_hdl_out_ops,
1221 itv->ctrl_audio_playback =
1227 itv->ctrl_audio_multilingual_playback =
1237 v4l2_ctrl_cluster(2, &itv->ctrl_pts);
1238 v4l2_ctrl_cluster(2, &itv->ctrl_audio_playback);
1239 ivtv_call_all(itv, video, s_std_output, itv->std);
1243 ivtv_call_hw(itv, IVTV_HW_SAA7127, video, s_stream, 0);
1247 ivtv_set_irq_mask(itv, 0xffffffff);
1250 retval = request_irq(itv->pdev->irq, ivtv_irq_handler,
1251 IRQF_SHARED, itv->v4l2_dev.name, (void *)itv);
1257 retval = ivtv_streams_setup(itv);
1262 retval = ivtv_streams_register(itv);
1267 IVTV_INFO("Initialized card: %s\n", itv->card_name);
1270 request_modules(itv);
1274 ivtv_streams_cleanup(itv);
1276 free_irq(itv->pdev->irq, (void *)itv);
1278 v4l2_ctrl_handler_free(&itv->cxhdl.hdl);
1279 exit_ivtv_i2c(itv);
1281 ivtv_iounmap(itv);
1283 release_mem_region(itv->base_addr, IVTV_ENCODER_SIZE);
1284 release_mem_region(itv->base_addr + IVTV_REG_OFFSET, IVTV_REG_SIZE);
1285 if (itv->has_cx23415)
1286 release_mem_region(itv->base_addr + IVTV_DECODER_OFFSET, IVTV_DECODER_SIZE);
1288 kthread_stop(itv->irq_worker_task);
1294 v4l2_device_unregister(&itv->v4l2_dev);
1295 kfree(itv);
1299 int ivtv_init_on_first_open(struct ivtv *itv)
1307 fh.itv = itv;
1310 if (test_bit(IVTV_F_I_FAILED, &itv->i_flags))
1313 if (test_and_set_bit(IVTV_F_I_INITED, &itv->i_flags))
1318 if (ivtv_firmware_init(itv) == 0)
1325 set_bit(IVTV_F_I_FAILED, &itv->i_flags);
1331 ivtv_firmware_versions(itv);
1333 if (itv->card->hw_all & IVTV_HW_CX25840)
1334 v4l2_subdev_call(itv->sd_video, core, load_fw);
1342 if (itv->std == V4L2_STD_NTSC_M_JP) {
1345 else if (itv->std & V4L2_STD_NTSC_M) {
1349 video_input = itv->active_input;
1350 itv->active_input++; /* Force update of input */
1355 itv->std++; /* Force full standard initialization */
1356 itv->std_out = itv->std;
1359 if (itv->card->v4l2_capabilities & V4L2_CAP_VIDEO_OUTPUT) {
1363 ivtv_call_hw(itv, IVTV_HW_SAA7127, video, s_stream, 1);
1364 ivtv_init_mpeg_decoder(itv);
1368 if (!itv->has_cx23415)
1371 ivtv_s_std_enc(itv, itv->tuner_std);
1378 if (itv->v4l2_cap & V4L2_CAP_VIDEO_OUTPUT) {
1379 ivtv_clear_irq_mask(itv, IVTV_IRQ_MASK_INIT | IVTV_IRQ_DEC_VSYNC);
1380 ivtv_set_osd_alpha(itv);
1381 ivtv_s_std_dec(itv, itv->tuner_std);
1383 ivtv_clear_irq_mask(itv, IVTV_IRQ_MASK_INIT);
1387 cx2341x_handler_setup(&itv->cxhdl);
1394 struct ivtv *itv = to_ivtv(v4l2_dev);
1399 flush_request_modules(itv);
1401 if (test_bit(IVTV_F_I_INITED, &itv->i_flags)) {
1404 if (atomic_read(&itv->capturing) > 0)
1405 ivtv_stop_all_captures(itv);
1411 if (itv->v4l2_cap & V4L2_CAP_VIDEO_OUTPUT)
1412 ivtv_call_hw(itv, IVTV_HW_SAA7127, video, s_stream, 0);
1413 if (atomic_read(&itv->decoding) > 0) {
1416 if (test_bit(IVTV_F_I_DEC_YUV, &itv->i_flags))
1420 ivtv_stop_v4l2_decode_stream(&itv->streams[type],
1423 ivtv_halt_firmware(itv);
1427 ivtv_set_irq_mask(itv, 0xffffffff);
1428 timer_shutdown_sync(&itv->dma_timer);
1431 kthread_flush_worker(&itv->irq_worker);
1432 kthread_stop(itv->irq_worker_task);
1434 ivtv_streams_cleanup(itv);
1435 ivtv_udma_free(itv);
1437 v4l2_ctrl_handler_free(&itv->cxhdl.hdl);
1439 exit_ivtv_i2c(itv);
1441 free_irq(itv->pdev->irq, (void *)itv);
1442 ivtv_iounmap(itv);
1444 release_mem_region(itv->base_addr, IVTV_ENCODER_SIZE);
1445 release_mem_region(itv->base_addr + IVTV_REG_OFFSET, IVTV_REG_SIZE);
1446 if (itv->has_cx23415)
1447 release_mem_region(itv->base_addr + IVTV_DECODER_OFFSET, IVTV_DECODER_SIZE);
1449 pci_disable_device(itv->pdev);
1451 kfree(itv->vbi.sliced_mpeg_data[i]);
1453 pr_info("Removed %s\n", itv->card_name);
1455 v4l2_device_unregister(&itv->v4l2_dev);
1456 kfree(itv);