Lines Matching full:cx
292 static void cx18_iounmap(struct cx18 *cx) in cx18_iounmap() argument
294 if (!cx) in cx18_iounmap()
298 if (cx->enc_mem) { in cx18_iounmap()
300 iounmap(cx->enc_mem); in cx18_iounmap()
301 cx->enc_mem = NULL; in cx18_iounmap()
305 static void cx18_eeprom_dump(struct cx18 *cx, unsigned char *eedata, int len) in cx18_eeprom_dump() argument
320 void cx18_read_eeprom(struct cx18 *cx, struct tveeprom *tv) in cx18_read_eeprom() argument
332 c->adapter = &cx->i2c_adap[0]; in cx18_read_eeprom()
338 switch (cx->card->type) { in cx18_read_eeprom()
347 cx18_eeprom_dump(cx, eedata, sizeof(eedata)); in cx18_read_eeprom()
353 cx18_eeprom_dump(cx, eedata, sizeof(eedata)); in cx18_read_eeprom()
361 static void cx18_process_eeprom(struct cx18 *cx) in cx18_process_eeprom() argument
365 cx18_read_eeprom(cx, &tv); in cx18_process_eeprom()
378 cx->card = cx18_get_card(CX18_CARD_HVR_1600_S5H1411); in cx18_process_eeprom()
392 cx->card = cx18_get_card(CX18_CARD_HVR_1600_ESMT); in cx18_process_eeprom()
405 cx->card = cx18_get_card(CX18_CARD_HVR_1600_ESMT); in cx18_process_eeprom()
409 cx->v4l2_cap = cx->card->v4l2_capabilities; in cx18_process_eeprom()
410 cx->card_name = cx->card->name; in cx18_process_eeprom()
411 cx->card_i2c = cx->card->i2c; in cx18_process_eeprom()
413 CX18_INFO("Autodetected %s\n", cx->card_name); in cx18_process_eeprom()
418 if (cx->options.tuner == -1) in cx18_process_eeprom()
419 cx->options.tuner = tv.tuner_type; in cx18_process_eeprom()
420 if (cx->options.radio == -1) in cx18_process_eeprom()
421 cx->options.radio = (tv.has_radio != 0); in cx18_process_eeprom()
423 if (cx->std != 0) in cx18_process_eeprom()
436 cx->std = V4L2_STD_ALL; in cx18_process_eeprom()
439 cx->std |= V4L2_STD_PAL_BG | V4L2_STD_PAL_H; in cx18_process_eeprom()
442 cx->std |= V4L2_STD_NTSC_M; in cx18_process_eeprom()
445 cx->std |= V4L2_STD_SECAM_L; in cx18_process_eeprom()
448 cx->std |= V4L2_STD_NTSC_M; in cx18_process_eeprom()
452 static v4l2_std_id cx18_parse_std(struct cx18 *cx) in cx18_parse_std() argument
534 static void cx18_process_options(struct cx18 *cx) in cx18_process_options() argument
538 cx->options.megabytes[CX18_ENC_STREAM_TYPE_TS] = enc_ts_buffers; in cx18_process_options()
539 cx->options.megabytes[CX18_ENC_STREAM_TYPE_MPG] = enc_mpg_buffers; in cx18_process_options()
540 cx->options.megabytes[CX18_ENC_STREAM_TYPE_IDX] = enc_idx_buffers; in cx18_process_options()
541 cx->options.megabytes[CX18_ENC_STREAM_TYPE_YUV] = enc_yuv_buffers; in cx18_process_options()
542 cx->options.megabytes[CX18_ENC_STREAM_TYPE_VBI] = enc_vbi_buffers; in cx18_process_options()
543 cx->options.megabytes[CX18_ENC_STREAM_TYPE_PCM] = enc_pcm_buffers; in cx18_process_options()
544 cx->options.megabytes[CX18_ENC_STREAM_TYPE_RAD] = 0; /* control only */ in cx18_process_options()
546 cx->stream_buffers[CX18_ENC_STREAM_TYPE_TS] = enc_ts_bufs; in cx18_process_options()
547 cx->stream_buffers[CX18_ENC_STREAM_TYPE_MPG] = enc_mpg_bufs; in cx18_process_options()
548 cx->stream_buffers[CX18_ENC_STREAM_TYPE_IDX] = enc_idx_bufs; in cx18_process_options()
549 cx->stream_buffers[CX18_ENC_STREAM_TYPE_YUV] = enc_yuv_bufs; in cx18_process_options()
550 cx->stream_buffers[CX18_ENC_STREAM_TYPE_VBI] = enc_vbi_bufs; in cx18_process_options()
551 cx->stream_buffers[CX18_ENC_STREAM_TYPE_PCM] = enc_pcm_bufs; in cx18_process_options()
552 cx->stream_buffers[CX18_ENC_STREAM_TYPE_RAD] = 0; /* control, no data */ in cx18_process_options()
554 cx->stream_buf_size[CX18_ENC_STREAM_TYPE_TS] = enc_ts_bufsize; in cx18_process_options()
555 cx->stream_buf_size[CX18_ENC_STREAM_TYPE_MPG] = enc_mpg_bufsize; in cx18_process_options()
556 cx->stream_buf_size[CX18_ENC_STREAM_TYPE_IDX] = enc_idx_bufsize; in cx18_process_options()
557 cx->stream_buf_size[CX18_ENC_STREAM_TYPE_YUV] = enc_yuv_bufsize; in cx18_process_options()
558 cx->stream_buf_size[CX18_ENC_STREAM_TYPE_VBI] = VBI_ACTIVE_SAMPLES * 36; in cx18_process_options()
559 cx->stream_buf_size[CX18_ENC_STREAM_TYPE_PCM] = enc_pcm_bufsize; in cx18_process_options()
560 cx->stream_buf_size[CX18_ENC_STREAM_TYPE_RAD] = 0; /* control no data */ in cx18_process_options()
564 if (cx->stream_buffers[i] == 0 || /* User said 0 buffers */ in cx18_process_options()
565 cx->options.megabytes[i] <= 0 || /* User said 0 MB total */ in cx18_process_options()
566 cx->stream_buf_size[i] <= 0) { /* User said buf size 0 */ in cx18_process_options()
567 cx->options.megabytes[i] = 0; in cx18_process_options()
568 cx->stream_buffers[i] = 0; in cx18_process_options()
569 cx->stream_buf_size[i] = 0; in cx18_process_options()
583 cx->stream_buf_size[i] *= 1024; in cx18_process_options()
584 cx->stream_buf_size[i] -= in cx18_process_options()
585 (cx->stream_buf_size[i] % CX18_UNIT_ENC_YUV_BUFSIZE); in cx18_process_options()
587 if (cx->stream_buf_size[i] < CX18_UNIT_ENC_YUV_BUFSIZE) in cx18_process_options()
588 cx->stream_buf_size[i] = in cx18_process_options()
591 cx->stream_buf_size[i] *= 1024; in cx18_process_options()
592 cx->stream_buf_size[i] -= in cx18_process_options()
593 (cx->stream_buf_size[i] % CX18_UNIT_ENC_IDX_BUFSIZE); in cx18_process_options()
595 if (cx->stream_buf_size[i] < CX18_UNIT_ENC_IDX_BUFSIZE) in cx18_process_options()
596 cx->stream_buf_size[i] = in cx18_process_options()
608 if (cx->stream_buffers[i] < 0) { in cx18_process_options()
609 cx->stream_buffers[i] = in cx18_process_options()
610 cx->options.megabytes[i] * 1024 * 1024 in cx18_process_options()
611 / cx->stream_buf_size[i]; in cx18_process_options()
614 cx->options.megabytes[i] = in cx18_process_options()
615 cx->stream_buffers[i] in cx18_process_options()
616 * cx->stream_buf_size[i]/(1024 * 1024); in cx18_process_options()
620 if (cx->stream_buffers[i] < 0) { in cx18_process_options()
621 cx->stream_buffers[i] = in cx18_process_options()
622 cx->options.megabytes[i] * 1024 in cx18_process_options()
623 / cx->stream_buf_size[i]; in cx18_process_options()
626 cx->options.megabytes[i] = in cx18_process_options()
627 cx->stream_buffers[i] in cx18_process_options()
628 * cx->stream_buf_size[i] / 1024; in cx18_process_options()
631 cx->stream_buf_size[i] *= 1024; in cx18_process_options()
634 i, cx->options.megabytes[i], in cx18_process_options()
635 cx->stream_buffers[i], cx->stream_buf_size[i]); in cx18_process_options()
638 cx->options.cardtype = cardtype[cx->instance]; in cx18_process_options()
639 cx->options.tuner = tuner[cx->instance]; in cx18_process_options()
640 cx->options.radio = radio[cx->instance]; in cx18_process_options()
642 cx->std = cx18_parse_std(cx); in cx18_process_options()
643 if (cx->options.cardtype == -1) { in cx18_process_options()
647 cx->card = cx18_get_card(cx->options.cardtype - 1); in cx18_process_options()
648 if (cx->card) in cx18_process_options()
649 CX18_INFO("User specified %s card\n", cx->card->name); in cx18_process_options()
650 else if (cx->options.cardtype != 0) in cx18_process_options()
652 if (!cx->card) { in cx18_process_options()
653 if (cx->pci_dev->subsystem_vendor == CX18_PCI_ID_HAUPPAUGE) { in cx18_process_options()
654 cx->card = cx18_get_card(CX18_CARD_HVR_1600_ESMT); in cx18_process_options()
658 if (!cx->card) { in cx18_process_options()
659 for (i = 0; (cx->card = cx18_get_card(i)); i++) { in cx18_process_options()
660 if (!cx->card->pci_list) in cx18_process_options()
662 for (j = 0; cx->card->pci_list[j].device; j++) { in cx18_process_options()
663 if (cx->pci_dev->device != in cx18_process_options()
664 cx->card->pci_list[j].device) in cx18_process_options()
666 if (cx->pci_dev->subsystem_vendor != in cx18_process_options()
667 cx->card->pci_list[j].subsystem_vendor) in cx18_process_options()
669 if (cx->pci_dev->subsystem_device != in cx18_process_options()
670 cx->card->pci_list[j].subsystem_device) in cx18_process_options()
672 CX18_INFO("Autodetected %s card\n", cx->card->name); in cx18_process_options()
679 if (!cx->card) { in cx18_process_options()
680 cx->card = cx18_get_card(CX18_CARD_HVR_1600_ESMT); in cx18_process_options()
682 cx->pci_dev->vendor, cx->pci_dev->device); in cx18_process_options()
684 cx->pci_dev->subsystem_vendor, in cx18_process_options()
685 cx->pci_dev->subsystem_device); in cx18_process_options()
686 CX18_ERR("Defaulting to %s card\n", cx->card->name); in cx18_process_options()
691 cx->v4l2_cap = cx->card->v4l2_capabilities; in cx18_process_options()
692 cx->card_name = cx->card->name; in cx18_process_options()
693 cx->card_i2c = cx->card->i2c; in cx18_process_options()
696 static int cx18_create_in_workq(struct cx18 *cx) in cx18_create_in_workq() argument
698 snprintf(cx->in_workq_name, sizeof(cx->in_workq_name), "%s-in", in cx18_create_in_workq()
699 cx->v4l2_dev.name); in cx18_create_in_workq()
700 cx->in_work_queue = alloc_ordered_workqueue("%s", 0, cx->in_workq_name); in cx18_create_in_workq()
701 if (!cx->in_work_queue) { in cx18_create_in_workq()
708 static void cx18_init_in_work_orders(struct cx18 *cx) in cx18_init_in_work_orders() argument
712 cx->in_work_order[i].cx = cx; in cx18_init_in_work_orders()
713 cx->in_work_order[i].str = cx->epu_debug_str; in cx18_init_in_work_orders()
714 INIT_WORK(&cx->in_work_order[i].work, cx18_in_work_handler); in cx18_init_in_work_orders()
723 static int cx18_init_struct1(struct cx18 *cx) in cx18_init_struct1() argument
727 cx->base_addr = pci_resource_start(cx->pci_dev, 0); in cx18_init_struct1()
729 mutex_init(&cx->serialize_lock); in cx18_init_struct1()
730 mutex_init(&cx->gpio_lock); in cx18_init_struct1()
731 mutex_init(&cx->epu2apu_mb_lock); in cx18_init_struct1()
732 mutex_init(&cx->epu2cpu_mb_lock); in cx18_init_struct1()
734 ret = cx18_create_in_workq(cx); in cx18_init_struct1()
738 cx18_init_in_work_orders(cx); in cx18_init_struct1()
741 cx->open_id = 1; in cx18_init_struct1()
744 cx->cxhdl.port = CX2341X_PORT_MEMORY; in cx18_init_struct1()
745 cx->cxhdl.capabilities = CX2341X_CAP_HAS_TS | CX2341X_CAP_HAS_SLICED_VBI; in cx18_init_struct1()
746 cx->cxhdl.ops = &cx18_cxhdl_ops; in cx18_init_struct1()
747 cx->cxhdl.func = cx18_api_func; in cx18_init_struct1()
748 cx->cxhdl.priv = &cx->streams[CX18_ENC_STREAM_TYPE_MPG]; in cx18_init_struct1()
749 ret = cx2341x_handler_init(&cx->cxhdl, 50); in cx18_init_struct1()
752 cx->v4l2_dev.ctrl_handler = &cx->cxhdl.hdl; in cx18_init_struct1()
754 cx->temporal_strength = cx->cxhdl.video_temporal_filter->cur.val; in cx18_init_struct1()
755 cx->spatial_strength = cx->cxhdl.video_spatial_filter->cur.val; in cx18_init_struct1()
756 cx->filter_mode = cx->cxhdl.video_spatial_filter_mode->cur.val | in cx18_init_struct1()
757 (cx->cxhdl.video_temporal_filter_mode->cur.val << 1) | in cx18_init_struct1()
758 (cx->cxhdl.video_median_filter_type->cur.val << 2); in cx18_init_struct1()
760 init_waitqueue_head(&cx->cap_w); in cx18_init_struct1()
761 init_waitqueue_head(&cx->mb_apu_waitq); in cx18_init_struct1()
762 init_waitqueue_head(&cx->mb_cpu_waitq); in cx18_init_struct1()
763 init_waitqueue_head(&cx->dma_waitq); in cx18_init_struct1()
766 cx->vbi.in.type = V4L2_BUF_TYPE_VBI_CAPTURE; in cx18_init_struct1()
767 cx->vbi.sliced_in = &cx->vbi.in.fmt.sliced; in cx18_init_struct1()
770 INIT_LIST_HEAD(&cx->vbi.sliced_mpeg_buf.list); in cx18_init_struct1()
771 INIT_LIST_HEAD(&cx->vbi.sliced_mpeg_mdl.list); in cx18_init_struct1()
772 INIT_LIST_HEAD(&cx->vbi.sliced_mpeg_mdl.buf_list); in cx18_init_struct1()
773 list_add(&cx->vbi.sliced_mpeg_buf.list, in cx18_init_struct1()
774 &cx->vbi.sliced_mpeg_mdl.buf_list); in cx18_init_struct1()
780 static void cx18_init_struct2(struct cx18 *cx) in cx18_init_struct2() argument
785 if (cx->card->video_inputs[i].video_type == 0) in cx18_init_struct2()
787 cx->nof_inputs = i; in cx18_init_struct2()
789 if (cx->card->audio_inputs[i].audio_type == 0) in cx18_init_struct2()
791 cx->nof_audio_inputs = i; in cx18_init_struct2()
794 for (i = 0; i < cx->nof_inputs; i++) { in cx18_init_struct2()
795 if (cx->card->video_inputs[i].video_type == in cx18_init_struct2()
799 if (i == cx->nof_inputs) in cx18_init_struct2()
801 cx->active_input = i; in cx18_init_struct2()
802 cx->audio_input = cx->card->video_inputs[i].audio_index; in cx18_init_struct2()
805 static int cx18_setup_pci(struct cx18 *cx, struct pci_dev *pci_dev, in cx18_setup_pci() argument
814 CX18_ERR("Can't enable device %d!\n", cx->instance); in cx18_setup_pci()
818 CX18_ERR("No suitable DMA available, card %d\n", cx->instance); in cx18_setup_pci()
821 if (!request_mem_region(cx->base_addr, CX18_MEM_SIZE, "cx18 encoder")) { in cx18_setup_pci()
823 cx->instance); in cx18_setup_pci()
832 cx->card_rev = pci_dev->revision; in cx18_setup_pci()
842 CX18_DEBUG_INFO("cx%d (rev %d) at %02x:%02x.%x, irq: %d, latency: %d, memory: 0x%llx\n", in cx18_setup_pci()
843 cx->pci_dev->device, cx->card_rev, pci_dev->bus->number, in cx18_setup_pci()
845 cx->pci_dev->irq, pci_latency, (u64)cx->base_addr); in cx18_setup_pci()
850 static void cx18_init_subdevs(struct cx18 *cx) in cx18_init_subdevs() argument
852 u32 hw = cx->card->hw_all; in cx18_init_subdevs()
865 cx->hw_flags |= device; in cx18_init_subdevs()
870 cx->hw_flags |= device; in cx18_init_subdevs()
879 if (cx18_gpio_register(cx, device) == 0) in cx18_init_subdevs()
880 cx->hw_flags |= device; in cx18_init_subdevs()
883 if (cx18_i2c_register(cx, i) == 0) in cx18_init_subdevs()
884 cx->hw_flags |= device; in cx18_init_subdevs()
889 if (cx->hw_flags & CX18_HW_418_AV) in cx18_init_subdevs()
890 cx->sd_av = cx18_find_hw(cx, CX18_HW_418_AV); in cx18_init_subdevs()
892 if (cx->card->hw_muxer != 0) in cx18_init_subdevs()
893 cx->sd_extmux = cx18_find_hw(cx, cx->card->hw_muxer); in cx18_init_subdevs()
902 struct cx18 *cx; in cx18_probe() local
912 cx = kzalloc(sizeof(*cx), GFP_ATOMIC); in cx18_probe()
913 if (!cx) in cx18_probe()
916 cx->pci_dev = pci_dev; in cx18_probe()
917 cx->instance = i; in cx18_probe()
919 retval = v4l2_device_register(&pci_dev->dev, &cx->v4l2_dev); in cx18_probe()
922 cx->instance); in cx18_probe()
923 kfree(cx); in cx18_probe()
926 snprintf(cx->v4l2_dev.name, sizeof(cx->v4l2_dev.name), "cx18-%d", in cx18_probe()
927 cx->instance); in cx18_probe()
928 CX18_INFO("Initializing card %d\n", cx->instance); in cx18_probe()
930 cx18_process_options(cx); in cx18_probe()
931 if (cx->options.cardtype == -1) { in cx18_probe()
936 retval = cx18_init_struct1(cx); in cx18_probe()
940 CX18_DEBUG_INFO("base addr: 0x%llx\n", (u64)cx->base_addr); in cx18_probe()
943 retval = cx18_setup_pci(cx, pci_dev, pci_id); in cx18_probe()
949 (u64)cx->base_addr + CX18_MEM_OFFSET, CX18_MEM_SIZE); in cx18_probe()
950 cx->enc_mem = ioremap_nocache(cx->base_addr + CX18_MEM_OFFSET, in cx18_probe()
952 if (!cx->enc_mem) { in cx18_probe()
960 cx->reg_mem = cx->enc_mem + CX18_REG_OFFSET; in cx18_probe()
961 devtype = cx18_read_reg(cx, 0xC72028); in cx18_probe()
974 cx18_init_power(cx, 1); in cx18_probe()
975 cx18_init_memory(cx); in cx18_probe()
977 cx->scb = (struct cx18_scb __iomem *)(cx->enc_mem + SCB_OFFSET); in cx18_probe()
978 cx18_init_scb(cx); in cx18_probe()
980 cx18_gpio_init(cx); in cx18_probe()
983 retval = cx18_av_probe(cx); in cx18_probe()
990 if (cx->card->hw_all & CX18_HW_GPIO_RESET_CTRL) { in cx18_probe()
991 if (cx18_gpio_register(cx, CX18_HW_GPIO_RESET_CTRL) != 0) in cx18_probe()
994 cx->hw_flags |= CX18_HW_GPIO_RESET_CTRL; in cx18_probe()
999 retval = init_cx18_i2c(cx); in cx18_probe()
1005 if (cx->card->hw_all & CX18_HW_TVEEPROM) { in cx18_probe()
1008 const struct cx18_card *orig_card = cx->card; in cx18_probe()
1009 cx18_process_eeprom(cx); in cx18_probe()
1011 if (cx->card != orig_card) { in cx18_probe()
1013 cx18_gpio_init(cx); in cx18_probe()
1014 cx18_call_hw(cx, CX18_HW_GPIO_RESET_CTRL, in cx18_probe()
1018 if (cx->card->comment) in cx18_probe()
1019 CX18_INFO("%s", cx->card->comment); in cx18_probe()
1020 if (cx->card->v4l2_capabilities == 0) { in cx18_probe()
1024 cx18_init_memory(cx); in cx18_probe()
1025 cx18_init_scb(cx); in cx18_probe()
1028 retval = request_irq(cx->pci_dev->irq, cx18_irq_handler, in cx18_probe()
1029 IRQF_SHARED, cx->v4l2_dev.name, (void *)cx); in cx18_probe()
1035 if (cx->std == 0) in cx18_probe()
1036 cx->std = V4L2_STD_NTSC_M; in cx18_probe()
1038 if (cx->options.tuner == -1) { in cx18_probe()
1040 if ((cx->std & cx->card->tuners[i].std) == 0) in cx18_probe()
1042 cx->options.tuner = cx->card->tuners[i].tuner; in cx18_probe()
1047 if (cx->options.tuner == -1 && cx->card->tuners[0].std) { in cx18_probe()
1048 cx->std = cx->card->tuners[0].std; in cx18_probe()
1049 if (cx->std & V4L2_STD_PAL) in cx18_probe()
1050 cx->std = V4L2_STD_PAL_BG | V4L2_STD_PAL_H; in cx18_probe()
1051 else if (cx->std & V4L2_STD_NTSC) in cx18_probe()
1052 cx->std = V4L2_STD_NTSC_M; in cx18_probe()
1053 else if (cx->std & V4L2_STD_SECAM) in cx18_probe()
1054 cx->std = V4L2_STD_SECAM_L; in cx18_probe()
1055 cx->options.tuner = cx->card->tuners[0].tuner; in cx18_probe()
1057 if (cx->options.radio == -1) in cx18_probe()
1058 cx->options.radio = (cx->card->radio_input.audio_type != 0); in cx18_probe()
1062 cx18_init_struct2(cx); in cx18_probe()
1064 cx18_init_subdevs(cx); in cx18_probe()
1066 if (cx->std & V4L2_STD_525_60) in cx18_probe()
1067 cx->is_60hz = 1; in cx18_probe()
1069 cx->is_50hz = 1; in cx18_probe()
1071 cx2341x_handler_set_50hz(&cx->cxhdl, !cx->is_60hz); in cx18_probe()
1073 if (cx->options.radio > 0) in cx18_probe()
1074 cx->v4l2_cap |= V4L2_CAP_RADIO; in cx18_probe()
1076 if (cx->options.tuner > -1) { in cx18_probe()
1080 setup.type = cx->options.tuner; in cx18_probe()
1083 if (cx->options.radio > 0) in cx18_probe()
1087 cx18_call_all(cx, tuner, s_type_addr, &setup); in cx18_probe()
1094 .tuner = cx->options.tuner, in cx18_probe()
1097 cx18_call_all(cx, tuner, s_config, &cfg); in cx18_probe()
1103 cx->tuner_std = cx->std; in cx18_probe()
1104 if (cx->std == V4L2_STD_ALL) in cx18_probe()
1105 cx->std = V4L2_STD_NTSC_M; in cx18_probe()
1107 retval = cx18_streams_setup(cx); in cx18_probe()
1112 retval = cx18_streams_register(cx); in cx18_probe()
1118 CX18_INFO("Initialized card: %s\n", cx->card_name); in cx18_probe()
1121 request_modules(cx); in cx18_probe()
1125 cx18_streams_cleanup(cx, 1); in cx18_probe()
1127 free_irq(cx->pci_dev->irq, (void *)cx); in cx18_probe()
1129 exit_cx18_i2c(cx); in cx18_probe()
1131 cx18_iounmap(cx); in cx18_probe()
1133 release_mem_region(cx->base_addr, CX18_MEM_SIZE); in cx18_probe()
1135 destroy_workqueue(cx->in_work_queue); in cx18_probe()
1139 v4l2_device_unregister(&cx->v4l2_dev); in cx18_probe()
1140 kfree(cx); in cx18_probe()
1144 int cx18_init_on_first_open(struct cx18 *cx) in cx18_init_on_first_open() argument
1152 fh.cx = cx; in cx18_init_on_first_open()
1154 if (test_bit(CX18_F_I_FAILED, &cx->i_flags)) in cx18_init_on_first_open()
1157 if (test_and_set_bit(CX18_F_I_INITED, &cx->i_flags)) in cx18_init_on_first_open()
1162 if (cx18_firmware_init(cx) == 0) in cx18_init_on_first_open()
1169 set_bit(CX18_F_I_FAILED, &cx->i_flags); in cx18_init_on_first_open()
1172 set_bit(CX18_F_I_LOADED_FW, &cx->i_flags); in cx18_init_on_first_open()
1186 cx18_vapi(cx, CX18_APU_START, 2, CX18_APU_ENCODING_METHOD_MPEG|0xb9, 0); in cx18_init_on_first_open()
1187 cx18_vapi(cx, CX18_APU_RESETAI, 0); in cx18_init_on_first_open()
1188 cx18_vapi(cx, CX18_APU_STOP, 1, CX18_APU_ENCODING_METHOD_MPEG); in cx18_init_on_first_open()
1193 if (cx18_firmware_init(cx) == 0) in cx18_init_on_first_open()
1200 set_bit(CX18_F_I_FAILED, &cx->i_flags); in cx18_init_on_first_open()
1213 cx18_vapi(cx, CX18_APU_START, 2, CX18_APU_ENCODING_METHOD_MPEG|0xb9, 0); in cx18_init_on_first_open()
1214 cx18_vapi(cx, CX18_APU_RESETAI, 0); in cx18_init_on_first_open()
1215 cx18_vapi(cx, CX18_APU_STOP, 1, CX18_APU_ENCODING_METHOD_MPEG); in cx18_init_on_first_open()
1218 v4l2_subdev_call(cx->sd_av, core, load_fw); in cx18_init_on_first_open()
1226 if (cx->std == V4L2_STD_NTSC_M_JP) in cx18_init_on_first_open()
1228 else if (cx->std & V4L2_STD_NTSC_M) in cx18_init_on_first_open()
1231 video_input = cx->active_input; in cx18_init_on_first_open()
1232 cx->active_input++; /* Force update of input */ in cx18_init_on_first_open()
1237 cx->std++; /* Force full standard initialization */ in cx18_init_on_first_open()
1238 std = (cx->tuner_std == V4L2_STD_ALL) ? V4L2_STD_NTSC_M : cx->tuner_std; in cx18_init_on_first_open()
1244 static void cx18_cancel_in_work_orders(struct cx18 *cx) in cx18_cancel_in_work_orders() argument
1248 cancel_work_sync(&cx->in_work_order[i].work); in cx18_cancel_in_work_orders()
1251 static void cx18_cancel_out_work_orders(struct cx18 *cx) in cx18_cancel_out_work_orders() argument
1255 if (cx->streams[i].video_dev.v4l2_dev) in cx18_cancel_out_work_orders()
1256 cancel_work_sync(&cx->streams[i].out_work_order); in cx18_cancel_out_work_orders()
1262 struct cx18 *cx = to_cx18(v4l2_dev); in cx18_remove() local
1267 flush_request_modules(cx); in cx18_remove()
1271 if (atomic_read(&cx->tot_capturing) > 0) in cx18_remove()
1272 cx18_stop_all_captures(cx); in cx18_remove()
1275 cx18_sw1_irq_disable(cx, IRQ_CPU_TO_EPU | IRQ_APU_TO_EPU); in cx18_remove()
1278 cx18_cancel_in_work_orders(cx); in cx18_remove()
1279 cx18_cancel_out_work_orders(cx); in cx18_remove()
1282 cx18_sw2_irq_disable(cx, IRQ_CPU_TO_EPU_ACK | IRQ_APU_TO_EPU_ACK); in cx18_remove()
1284 cx18_halt_firmware(cx); in cx18_remove()
1286 destroy_workqueue(cx->in_work_queue); in cx18_remove()
1288 cx18_streams_cleanup(cx, 1); in cx18_remove()
1290 exit_cx18_i2c(cx); in cx18_remove()
1292 free_irq(cx->pci_dev->irq, (void *)cx); in cx18_remove()
1294 cx18_iounmap(cx); in cx18_remove()
1296 release_mem_region(cx->base_addr, CX18_MEM_SIZE); in cx18_remove()
1298 pci_disable_device(cx->pci_dev); in cx18_remove()
1300 if (cx->vbi.sliced_mpeg_data[0]) in cx18_remove()
1302 kfree(cx->vbi.sliced_mpeg_data[i]); in cx18_remove()
1304 v4l2_ctrl_handler_free(&cx->av_state.hdl); in cx18_remove()
1306 CX18_INFO("Removed %s\n", cx->card_name); in cx18_remove()
1309 kfree(cx); in cx18_remove()