Lines Matching +full:precondition +full:- +full:timeout
1 // SPDX-License-Identifier: GPL-2.0-or-later
5 * Derived from ivtv-driver.c
11 #include "cx18-driver.h"
12 #include "cx18-io.h"
13 #include "cx18-version.h"
14 #include "cx18-cards.h"
15 #include "cx18-i2c.h"
16 #include "cx18-irq.h"
17 #include "cx18-gpio.h"
18 #include "cx18-firmware.h"
19 #include "cx18-queue.h"
20 #include "cx18-streams.h"
21 #include "cx18-av-core.h"
22 #include "cx18-scb.h"
23 #include "cx18-mailbox.h"
24 #include "cx18-ioctl.h"
25 #include "cx18-controls.h"
26 #include "tuner-xc2028.h"
27 #include <linux/dma-mapping.h>
54 static int tuner[CX18_MAX_CARDS] = { -1, -1, -1, -1, -1, -1, -1, -1,
55 -1, -1, -1, -1, -1, -1, -1, -1,
56 -1, -1, -1, -1, -1, -1, -1, -1,
57 -1, -1, -1, -1, -1, -1, -1, -1 };
58 static int radio[CX18_MAX_CARDS] = { -1, -1, -1, -1, -1, -1, -1, -1,
59 -1, -1, -1, -1, -1, -1, -1, -1,
60 -1, -1, -1, -1, -1, -1, -1, -1,
61 -1, -1, -1, -1, -1, -1, -1, -1 };
65 static char pal[] = "--";
66 static char secam[] = "--";
67 static char ntsc[] = "-";
83 static int enc_ts_bufs = -1;
84 static int enc_mpg_bufs = -1;
86 static int enc_yuv_bufs = -1;
87 static int enc_vbi_bufs = -1;
88 static int enc_pcm_bufs = -1;
143 "\t\t\t 6 = Toshiba Qosmio DVB-T/Analog\n"
149 "\t\t\t-1 = Ignore this card\n\t\t");
245 /* Make sure cx18-alsa module is loaded */ in request_module_async()
246 request_module("cx18-alsa"); in request_module_async()
248 /* Initialize cx18-alsa for this instance of the cx18 device */ in request_module_async()
255 INIT_WORK(&dev->request_module_wk, request_module_async); in request_modules()
256 schedule_work(&dev->request_module_wk); in request_modules()
261 flush_work(&dev->request_module_wk); in flush_request_modules()
271 long int timeout = msecs_to_jiffies(msecs); in cx18_msleep_timeout() local
276 timeout = schedule_timeout(timeout); in cx18_msleep_timeout()
278 } while (!sig && timeout); in cx18_msleep_timeout()
289 if (cx->enc_mem) { in cx18_iounmap()
291 iounmap(cx->enc_mem); in cx18_iounmap()
292 cx->enc_mem = NULL; in cx18_iounmap()
322 strscpy(c->name, "cx18 tveeprom tmp", sizeof(c->name)); in cx18_read_eeprom()
323 c->adapter = &cx->i2c_adap[0]; in cx18_read_eeprom()
324 c->addr = 0xa0 >> 1; in cx18_read_eeprom()
329 switch (cx->card->type) { in cx18_read_eeprom()
337 tv->model = 0x718; in cx18_read_eeprom()
343 tv->model = 0xffffffff; in cx18_read_eeprom()
369 cx->card = cx18_get_card(CX18_CARD_HVR_1600_S5H1411); in cx18_process_eeprom()
383 cx->card = cx18_get_card(CX18_CARD_HVR_1600_ESMT); in cx18_process_eeprom()
394 CX18_ERR("Unknown model %d, defaulting to original HVR-1600 (cardtype=1)\n", in cx18_process_eeprom()
396 cx->card = cx18_get_card(CX18_CARD_HVR_1600_ESMT); in cx18_process_eeprom()
400 cx->v4l2_cap = cx->card->v4l2_capabilities; in cx18_process_eeprom()
401 cx->card_name = cx->card->name; in cx18_process_eeprom()
402 cx->card_i2c = cx->card->i2c; in cx18_process_eeprom()
404 CX18_INFO("Autodetected %s\n", cx->card_name); in cx18_process_eeprom()
409 if (cx->options.tuner == -1) in cx18_process_eeprom()
410 cx->options.tuner = tv.tuner_type; in cx18_process_eeprom()
411 if (cx->options.radio == -1) in cx18_process_eeprom()
412 cx->options.radio = (tv.has_radio != 0); in cx18_process_eeprom()
414 if (cx->std != 0) in cx18_process_eeprom()
427 cx->std = V4L2_STD_ALL; in cx18_process_eeprom()
430 cx->std |= V4L2_STD_PAL_BG | V4L2_STD_PAL_H; in cx18_process_eeprom()
433 cx->std |= V4L2_STD_NTSC_M; in cx18_process_eeprom()
436 cx->std |= V4L2_STD_SECAM_L; in cx18_process_eeprom()
438 CX18_INFO("No tuner detected, default to NTSC-M\n"); in cx18_process_eeprom()
439 cx->std |= V4L2_STD_NTSC_M; in cx18_process_eeprom()
472 case '-': in cx18_parse_std()
497 case '-': in cx18_parse_std()
514 case '-': in cx18_parse_std()
529 cx->options.megabytes[CX18_ENC_STREAM_TYPE_TS] = enc_ts_buffers; in cx18_process_options()
530 cx->options.megabytes[CX18_ENC_STREAM_TYPE_MPG] = enc_mpg_buffers; in cx18_process_options()
531 cx->options.megabytes[CX18_ENC_STREAM_TYPE_IDX] = enc_idx_buffers; in cx18_process_options()
532 cx->options.megabytes[CX18_ENC_STREAM_TYPE_YUV] = enc_yuv_buffers; in cx18_process_options()
533 cx->options.megabytes[CX18_ENC_STREAM_TYPE_VBI] = enc_vbi_buffers; in cx18_process_options()
534 cx->options.megabytes[CX18_ENC_STREAM_TYPE_PCM] = enc_pcm_buffers; in cx18_process_options()
535 cx->options.megabytes[CX18_ENC_STREAM_TYPE_RAD] = 0; /* control only */ in cx18_process_options()
537 cx->stream_buffers[CX18_ENC_STREAM_TYPE_TS] = enc_ts_bufs; in cx18_process_options()
538 cx->stream_buffers[CX18_ENC_STREAM_TYPE_MPG] = enc_mpg_bufs; in cx18_process_options()
539 cx->stream_buffers[CX18_ENC_STREAM_TYPE_IDX] = enc_idx_bufs; in cx18_process_options()
540 cx->stream_buffers[CX18_ENC_STREAM_TYPE_YUV] = enc_yuv_bufs; in cx18_process_options()
541 cx->stream_buffers[CX18_ENC_STREAM_TYPE_VBI] = enc_vbi_bufs; in cx18_process_options()
542 cx->stream_buffers[CX18_ENC_STREAM_TYPE_PCM] = enc_pcm_bufs; in cx18_process_options()
543 cx->stream_buffers[CX18_ENC_STREAM_TYPE_RAD] = 0; /* control, no data */ in cx18_process_options()
545 cx->stream_buf_size[CX18_ENC_STREAM_TYPE_TS] = enc_ts_bufsize; in cx18_process_options()
546 cx->stream_buf_size[CX18_ENC_STREAM_TYPE_MPG] = enc_mpg_bufsize; in cx18_process_options()
547 cx->stream_buf_size[CX18_ENC_STREAM_TYPE_IDX] = enc_idx_bufsize; in cx18_process_options()
548 cx->stream_buf_size[CX18_ENC_STREAM_TYPE_YUV] = enc_yuv_bufsize; in cx18_process_options()
549 cx->stream_buf_size[CX18_ENC_STREAM_TYPE_VBI] = VBI_ACTIVE_SAMPLES * 36; in cx18_process_options()
550 cx->stream_buf_size[CX18_ENC_STREAM_TYPE_PCM] = enc_pcm_bufsize; in cx18_process_options()
551 cx->stream_buf_size[CX18_ENC_STREAM_TYPE_RAD] = 0; /* control no data */ in cx18_process_options()
555 if (cx->stream_buffers[i] == 0 || /* User said 0 buffers */ in cx18_process_options()
556 cx->options.megabytes[i] <= 0 || /* User said 0 MB total */ in cx18_process_options()
557 cx->stream_buf_size[i] <= 0) { /* User said buf size 0 */ in cx18_process_options()
558 cx->options.megabytes[i] = 0; in cx18_process_options()
559 cx->stream_buffers[i] = 0; in cx18_process_options()
560 cx->stream_buf_size[i] = 0; in cx18_process_options()
574 cx->stream_buf_size[i] *= 1024; in cx18_process_options()
575 cx->stream_buf_size[i] -= in cx18_process_options()
576 (cx->stream_buf_size[i] % CX18_UNIT_ENC_YUV_BUFSIZE); in cx18_process_options()
578 if (cx->stream_buf_size[i] < CX18_UNIT_ENC_YUV_BUFSIZE) in cx18_process_options()
579 cx->stream_buf_size[i] = in cx18_process_options()
582 cx->stream_buf_size[i] *= 1024; in cx18_process_options()
583 cx->stream_buf_size[i] -= in cx18_process_options()
584 (cx->stream_buf_size[i] % CX18_UNIT_ENC_IDX_BUFSIZE); in cx18_process_options()
586 if (cx->stream_buf_size[i] < CX18_UNIT_ENC_IDX_BUFSIZE) in cx18_process_options()
587 cx->stream_buf_size[i] = in cx18_process_options()
599 if (cx->stream_buffers[i] < 0) { in cx18_process_options()
600 cx->stream_buffers[i] = in cx18_process_options()
601 cx->options.megabytes[i] * 1024 * 1024 in cx18_process_options()
602 / cx->stream_buf_size[i]; in cx18_process_options()
605 cx->options.megabytes[i] = in cx18_process_options()
606 cx->stream_buffers[i] in cx18_process_options()
607 * cx->stream_buf_size[i]/(1024 * 1024); in cx18_process_options()
611 if (cx->stream_buffers[i] < 0) { in cx18_process_options()
612 cx->stream_buffers[i] = in cx18_process_options()
613 cx->options.megabytes[i] * 1024 in cx18_process_options()
614 / cx->stream_buf_size[i]; in cx18_process_options()
617 cx->options.megabytes[i] = in cx18_process_options()
618 cx->stream_buffers[i] in cx18_process_options()
619 * cx->stream_buf_size[i] / 1024; in cx18_process_options()
622 cx->stream_buf_size[i] *= 1024; in cx18_process_options()
625 i, cx->options.megabytes[i], in cx18_process_options()
626 cx->stream_buffers[i], cx->stream_buf_size[i]); in cx18_process_options()
629 cx->options.cardtype = cardtype[cx->instance]; in cx18_process_options()
630 cx->options.tuner = tuner[cx->instance]; in cx18_process_options()
631 cx->options.radio = radio[cx->instance]; in cx18_process_options()
633 cx->std = cx18_parse_std(cx); in cx18_process_options()
634 if (cx->options.cardtype == -1) { in cx18_process_options()
638 cx->card = cx18_get_card(cx->options.cardtype - 1); in cx18_process_options()
639 if (cx->card) in cx18_process_options()
640 CX18_INFO("User specified %s card\n", cx->card->name); in cx18_process_options()
641 else if (cx->options.cardtype != 0) in cx18_process_options()
643 if (!cx->card) { in cx18_process_options()
644 if (cx->pci_dev->subsystem_vendor == CX18_PCI_ID_HAUPPAUGE) { in cx18_process_options()
645 cx->card = cx18_get_card(CX18_CARD_HVR_1600_ESMT); in cx18_process_options()
649 if (!cx->card) { in cx18_process_options()
650 for (i = 0; (cx->card = cx18_get_card(i)); i++) { in cx18_process_options()
651 if (!cx->card->pci_list) in cx18_process_options()
653 for (j = 0; cx->card->pci_list[j].device; j++) { in cx18_process_options()
654 if (cx->pci_dev->device != in cx18_process_options()
655 cx->card->pci_list[j].device) in cx18_process_options()
657 if (cx->pci_dev->subsystem_vendor != in cx18_process_options()
658 cx->card->pci_list[j].subsystem_vendor) in cx18_process_options()
660 if (cx->pci_dev->subsystem_device != in cx18_process_options()
661 cx->card->pci_list[j].subsystem_device) in cx18_process_options()
663 CX18_INFO("Autodetected %s card\n", cx->card->name); in cx18_process_options()
670 if (!cx->card) { in cx18_process_options()
671 cx->card = cx18_get_card(CX18_CARD_HVR_1600_ESMT); in cx18_process_options()
673 cx->pci_dev->vendor, cx->pci_dev->device); in cx18_process_options()
675 cx->pci_dev->subsystem_vendor, in cx18_process_options()
676 cx->pci_dev->subsystem_device); in cx18_process_options()
677 CX18_ERR("Defaulting to %s card\n", cx->card->name); in cx18_process_options()
679 CX18_ERR("card you have to the linux-media mailinglist (www.linuxtv.org)\n"); in cx18_process_options()
682 cx->v4l2_cap = cx->card->v4l2_capabilities; in cx18_process_options()
683 cx->card_name = cx->card->name; in cx18_process_options()
684 cx->card_i2c = cx->card->i2c; in cx18_process_options()
689 snprintf(cx->in_workq_name, sizeof(cx->in_workq_name), "%s-in", in cx18_create_in_workq()
690 cx->v4l2_dev.name); in cx18_create_in_workq()
691 cx->in_work_queue = alloc_ordered_workqueue("%s", 0, cx->in_workq_name); in cx18_create_in_workq()
692 if (!cx->in_work_queue) { in cx18_create_in_workq()
694 return -ENOMEM; in cx18_create_in_workq()
703 cx->in_work_order[i].cx = cx; in cx18_init_in_work_orders()
704 cx->in_work_order[i].str = cx->epu_debug_str; in cx18_init_in_work_orders()
705 INIT_WORK(&cx->in_work_order[i].work, cx18_in_work_handler); in cx18_init_in_work_orders()
709 /* Precondition: the cx18 structure has been memset to 0. Only
718 cx->base_addr = pci_resource_start(cx->pci_dev, 0); in cx18_init_struct1()
720 mutex_init(&cx->serialize_lock); in cx18_init_struct1()
721 mutex_init(&cx->gpio_lock); in cx18_init_struct1()
722 mutex_init(&cx->epu2apu_mb_lock); in cx18_init_struct1()
723 mutex_init(&cx->epu2cpu_mb_lock); in cx18_init_struct1()
732 cx->open_id = 1; in cx18_init_struct1()
735 cx->cxhdl.port = CX2341X_PORT_MEMORY; in cx18_init_struct1()
736 cx->cxhdl.capabilities = CX2341X_CAP_HAS_TS | CX2341X_CAP_HAS_SLICED_VBI; in cx18_init_struct1()
737 cx->cxhdl.ops = &cx18_cxhdl_ops; in cx18_init_struct1()
738 cx->cxhdl.func = cx18_api_func; in cx18_init_struct1()
739 cx->cxhdl.priv = &cx->streams[CX18_ENC_STREAM_TYPE_MPG]; in cx18_init_struct1()
740 ret = cx2341x_handler_init(&cx->cxhdl, 50); in cx18_init_struct1()
743 cx->v4l2_dev.ctrl_handler = &cx->cxhdl.hdl; in cx18_init_struct1()
745 cx->temporal_strength = cx->cxhdl.video_temporal_filter->cur.val; in cx18_init_struct1()
746 cx->spatial_strength = cx->cxhdl.video_spatial_filter->cur.val; in cx18_init_struct1()
747 cx->filter_mode = cx->cxhdl.video_spatial_filter_mode->cur.val | in cx18_init_struct1()
748 (cx->cxhdl.video_temporal_filter_mode->cur.val << 1) | in cx18_init_struct1()
749 (cx->cxhdl.video_median_filter_type->cur.val << 2); in cx18_init_struct1()
751 init_waitqueue_head(&cx->cap_w); in cx18_init_struct1()
752 init_waitqueue_head(&cx->mb_apu_waitq); in cx18_init_struct1()
753 init_waitqueue_head(&cx->mb_cpu_waitq); in cx18_init_struct1()
754 init_waitqueue_head(&cx->dma_waitq); in cx18_init_struct1()
757 cx->vbi.in.type = V4L2_BUF_TYPE_VBI_CAPTURE; in cx18_init_struct1()
758 cx->vbi.sliced_in = &cx->vbi.in.fmt.sliced; in cx18_init_struct1()
761 INIT_LIST_HEAD(&cx->vbi.sliced_mpeg_buf.list); in cx18_init_struct1()
762 INIT_LIST_HEAD(&cx->vbi.sliced_mpeg_mdl.list); in cx18_init_struct1()
763 INIT_LIST_HEAD(&cx->vbi.sliced_mpeg_mdl.buf_list); in cx18_init_struct1()
764 list_add(&cx->vbi.sliced_mpeg_buf.list, in cx18_init_struct1()
765 &cx->vbi.sliced_mpeg_mdl.buf_list); in cx18_init_struct1()
775 for (i = 0; i < CX18_CARD_MAX_VIDEO_INPUTS - 1; i++) in cx18_init_struct2()
776 if (cx->card->video_inputs[i].video_type == 0) in cx18_init_struct2()
778 cx->nof_inputs = i; in cx18_init_struct2()
779 for (i = 0; i < CX18_CARD_MAX_AUDIO_INPUTS - 1; i++) in cx18_init_struct2()
780 if (cx->card->audio_inputs[i].audio_type == 0) in cx18_init_struct2()
782 cx->nof_audio_inputs = i; in cx18_init_struct2()
785 for (i = 0; i < cx->nof_inputs; i++) { in cx18_init_struct2()
786 if (cx->card->video_inputs[i].video_type == in cx18_init_struct2()
790 if (i == cx->nof_inputs) in cx18_init_struct2()
792 cx->active_input = i; in cx18_init_struct2()
793 cx->audio_input = cx->card->video_inputs[i].audio_index; in cx18_init_struct2()
805 CX18_ERR("Can't enable device %d!\n", cx->instance); in cx18_setup_pci()
806 return -EIO; in cx18_setup_pci()
809 CX18_ERR("No suitable DMA available, card %d\n", cx->instance); in cx18_setup_pci()
810 return -EIO; in cx18_setup_pci()
812 if (!request_mem_region(cx->base_addr, CX18_MEM_SIZE, "cx18 encoder")) { in cx18_setup_pci()
814 cx->instance); in cx18_setup_pci()
815 return -EIO; in cx18_setup_pci()
823 cx->card_rev = pci_dev->revision; in cx18_setup_pci()
834 cx->pci_dev->device, cx->card_rev, pci_dev->bus->number, in cx18_setup_pci()
835 PCI_SLOT(pci_dev->devfn), PCI_FUNC(pci_dev->devfn), in cx18_setup_pci()
836 cx->pci_dev->irq, pci_latency, (u64)cx->base_addr); in cx18_setup_pci()
843 u32 hw = cx->card->hw_all; in cx18_init_subdevs()
856 cx->hw_flags |= device; in cx18_init_subdevs()
861 cx->hw_flags |= device; in cx18_init_subdevs()
871 cx->hw_flags |= device; in cx18_init_subdevs()
875 cx->hw_flags |= device; in cx18_init_subdevs()
880 if (cx->hw_flags & CX18_HW_418_AV) in cx18_init_subdevs()
881 cx->sd_av = cx18_find_hw(cx, CX18_HW_418_AV); in cx18_init_subdevs()
883 if (cx->card->hw_muxer != 0) in cx18_init_subdevs()
884 cx->sd_extmux = cx18_find_hw(cx, cx->card->hw_muxer); in cx18_init_subdevs()
895 /* FIXME - module parameter arrays constrain max instances */ in cx18_probe()
896 i = atomic_inc_return(&cx18_instance) - 1; in cx18_probe()
898 printk(KERN_ERR "cx18: cannot manage card %d, driver has a limit of 0 - %d\n", in cx18_probe()
899 i, CX18_MAX_CARDS - 1); in cx18_probe()
900 return -ENOMEM; in cx18_probe()
905 return -ENOMEM; in cx18_probe()
907 cx->pci_dev = pci_dev; in cx18_probe()
908 cx->instance = i; in cx18_probe()
910 retval = v4l2_device_register(&pci_dev->dev, &cx->v4l2_dev); in cx18_probe()
913 cx->instance); in cx18_probe()
917 snprintf(cx->v4l2_dev.name, sizeof(cx->v4l2_dev.name), "cx18-%d", in cx18_probe()
918 cx->instance); in cx18_probe()
919 CX18_INFO("Initializing card %d\n", cx->instance); in cx18_probe()
922 if (cx->options.cardtype == -1) { in cx18_probe()
923 retval = -ENODEV; in cx18_probe()
931 CX18_DEBUG_INFO("base addr: 0x%llx\n", (u64)cx->base_addr); in cx18_probe()
940 (u64)cx->base_addr + CX18_MEM_OFFSET, CX18_MEM_SIZE); in cx18_probe()
941 cx->enc_mem = ioremap(cx->base_addr + CX18_MEM_OFFSET, in cx18_probe()
943 if (!cx->enc_mem) { in cx18_probe()
948 retval = -ENOMEM; in cx18_probe()
951 cx->reg_mem = cx->enc_mem + CX18_REG_OFFSET; in cx18_probe()
968 cx->scb = (struct cx18_scb __iomem *)(cx->enc_mem + SCB_OFFSET); in cx18_probe()
981 if (cx->card->hw_all & CX18_HW_GPIO_RESET_CTRL) { in cx18_probe()
985 cx->hw_flags |= CX18_HW_GPIO_RESET_CTRL; in cx18_probe()
996 if (cx->card->hw_all & CX18_HW_TVEEPROM) { in cx18_probe()
999 const struct cx18_card *orig_card = cx->card; in cx18_probe()
1002 if (cx->card != orig_card) { in cx18_probe()
1003 /* Changed the cardtype; re-reset the I2C chips */ in cx18_probe()
1009 if (cx->card->comment) in cx18_probe()
1010 CX18_INFO("%s", cx->card->comment); in cx18_probe()
1011 if (cx->card->v4l2_capabilities == 0) { in cx18_probe()
1012 retval = -ENODEV; in cx18_probe()
1019 retval = request_irq(cx->pci_dev->irq, cx18_irq_handler, in cx18_probe()
1020 IRQF_SHARED, cx->v4l2_dev.name, (void *)cx); in cx18_probe()
1026 if (cx->std == 0) in cx18_probe()
1027 cx->std = V4L2_STD_NTSC_M; in cx18_probe()
1029 if (cx->options.tuner == -1) { in cx18_probe()
1031 if ((cx->std & cx->card->tuners[i].std) == 0) in cx18_probe()
1033 cx->options.tuner = cx->card->tuners[i].tuner; in cx18_probe()
1038 if (cx->options.tuner == -1 && cx->card->tuners[0].std) { in cx18_probe()
1039 cx->std = cx->card->tuners[0].std; in cx18_probe()
1040 if (cx->std & V4L2_STD_PAL) in cx18_probe()
1041 cx->std = V4L2_STD_PAL_BG | V4L2_STD_PAL_H; in cx18_probe()
1042 else if (cx->std & V4L2_STD_NTSC) in cx18_probe()
1043 cx->std = V4L2_STD_NTSC_M; in cx18_probe()
1044 else if (cx->std & V4L2_STD_SECAM) in cx18_probe()
1045 cx->std = V4L2_STD_SECAM_L; in cx18_probe()
1046 cx->options.tuner = cx->card->tuners[0].tuner; in cx18_probe()
1048 if (cx->options.radio == -1) in cx18_probe()
1049 cx->options.radio = (cx->card->radio_input.audio_type != 0); in cx18_probe()
1051 /* The card is now fully identified, continue with card-specific in cx18_probe()
1057 if (cx->std & V4L2_STD_525_60) in cx18_probe()
1058 cx->is_60hz = 1; in cx18_probe()
1060 cx->is_50hz = 1; in cx18_probe()
1062 cx2341x_handler_set_50hz(&cx->cxhdl, !cx->is_60hz); in cx18_probe()
1064 if (cx->options.radio > 0) in cx18_probe()
1065 cx->v4l2_cap |= V4L2_CAP_RADIO; in cx18_probe()
1067 if (cx->options.tuner > -1) { in cx18_probe()
1071 setup.type = cx->options.tuner; in cx18_probe()
1074 if (cx->options.radio > 0) in cx18_probe()
1085 .tuner = cx->options.tuner, in cx18_probe()
1092 /* The tuner is fixed to the standard. The other inputs (e.g. S-Video) in cx18_probe()
1094 cx->tuner_std = cx->std; in cx18_probe()
1095 if (cx->std == V4L2_STD_ALL) in cx18_probe()
1096 cx->std = V4L2_STD_NTSC_M; in cx18_probe()
1109 CX18_INFO("Initialized card: %s\n", cx->card_name); in cx18_probe()
1111 /* Load cx18 submodules (cx18-alsa) */ in cx18_probe()
1118 free_irq(cx->pci_dev->irq, (void *)cx); in cx18_probe()
1124 release_mem_region(cx->base_addr, CX18_MEM_SIZE); in cx18_probe()
1126 destroy_workqueue(cx->in_work_queue); in cx18_probe()
1130 v4l2_device_unregister(&cx->v4l2_dev); in cx18_probe()
1145 if (test_bit(CX18_F_I_FAILED, &cx->i_flags)) in cx18_init_on_first_open()
1146 return -ENXIO; in cx18_init_on_first_open()
1148 if (test_and_set_bit(CX18_F_I_INITED, &cx->i_flags)) in cx18_init_on_first_open()
1151 while (--fw_retry_count > 0) { in cx18_init_on_first_open()
1160 set_bit(CX18_F_I_FAILED, &cx->i_flags); in cx18_init_on_first_open()
1161 return -ENXIO; in cx18_init_on_first_open()
1163 set_bit(CX18_F_I_LOADED_FW, &cx->i_flags); in cx18_init_on_first_open()
1182 while (--fw_retry_count > 0) { in cx18_init_on_first_open()
1191 set_bit(CX18_F_I_FAILED, &cx->i_flags); in cx18_init_on_first_open()
1192 return -ENXIO; in cx18_init_on_first_open()
1209 v4l2_subdev_call(cx->sd_av, core, load_fw); in cx18_init_on_first_open()
1217 if (cx->std == V4L2_STD_NTSC_M_JP) in cx18_init_on_first_open()
1219 else if (cx->std & V4L2_STD_NTSC_M) in cx18_init_on_first_open()
1222 video_input = cx->active_input; in cx18_init_on_first_open()
1223 cx->active_input++; /* Force update of input */ in cx18_init_on_first_open()
1228 cx->std++; /* Force full standard initialization */ in cx18_init_on_first_open()
1229 std = (cx->tuner_std == V4L2_STD_ALL) ? V4L2_STD_NTSC_M : cx->tuner_std; in cx18_init_on_first_open()
1239 cancel_work_sync(&cx->in_work_order[i].work); in cx18_cancel_in_work_orders()
1246 if (cx->streams[i].video_dev.v4l2_dev) in cx18_cancel_out_work_orders()
1247 cancel_work_sync(&cx->streams[i].out_work_order); in cx18_cancel_out_work_orders()
1262 if (atomic_read(&cx->tot_capturing) > 0) in cx18_remove()
1277 destroy_workqueue(cx->in_work_queue); in cx18_remove()
1283 free_irq(cx->pci_dev->irq, (void *)cx); in cx18_remove()
1287 release_mem_region(cx->base_addr, CX18_MEM_SIZE); in cx18_remove()
1289 pci_disable_device(cx->pci_dev); in cx18_remove()
1291 if (cx->vbi.sliced_mpeg_data[0]) in cx18_remove()
1293 kfree(cx->vbi.sliced_mpeg_data[i]); in cx18_remove()
1295 v4l2_ctrl_handler_free(&cx->av_state.hdl); in cx18_remove()
1297 CX18_INFO("Removed %s\n", cx->card_name); in cx18_remove()
1320 CX18_MAX_CARDS - 1); in module_start()
1321 return -1; in module_start()
1331 return -ENODEV; in module_start()