X-Git-Url: http://pilppa.org/gitweb/gitweb.cgi?a=blobdiff_plain;f=drivers%2Fmedia%2Fvideo%2Fcx18%2Fcx18-driver.c;h=210c68aaae00ede73af85a4804b156e246a8fe6c;hb=15f7176eb1cccec0a332541285ee752b935c1c85;hp=0f13fdd890a452b1a7a26ad0178c78d7481dbaf7;hpb=6ce9ee539c42291475c1fd7b374a10c1fe00ea33;p=linux-2.6-omap-h63xx.git diff --git a/drivers/media/video/cx18/cx18-driver.c b/drivers/media/video/cx18/cx18-driver.c index 0f13fdd890a..210c68aaae0 100644 --- a/drivers/media/video/cx18/cx18-driver.c +++ b/drivers/media/video/cx18/cx18-driver.c @@ -39,10 +39,6 @@ #include - -/* var to keep track of the number of array elements in use */ -int cx18_cards_active; - /* If you have already X v4l cards, then set this to X. This way the device numbers stay matched. Example: you have a WinTV card without radio and a Compro H900 with. Normally this would give a @@ -50,12 +46,6 @@ int cx18_cards_active; setting this to 1 you ensure that radio0 is now also radio1. */ int cx18_first_minor; -/* Master variable for all cx18 info */ -struct cx18 *cx18_cards[CX18_MAX_CARDS]; - -/* Protects cx18_cards_active */ -DEFINE_SPINLOCK(cx18_cards_lock); - /* add your revision and whatnot here */ static struct pci_device_id cx18_pci_tbl[] __devinitdata = { {PCI_VENDOR_ID_CX, PCI_DEVICE_ID_CX23418, @@ -65,6 +55,8 @@ static struct pci_device_id cx18_pci_tbl[] __devinitdata = { MODULE_DEVICE_TABLE(pci, cx18_pci_tbl); +static atomic_t cx18_instance = ATOMIC_INIT(0); + /* Parameter declarations */ static int cardtype[CX18_MAX_CARDS]; static int tuner[CX18_MAX_CARDS] = { -1, -1, -1, -1, -1, -1, -1, -1, @@ -277,11 +269,16 @@ static void cx18_iounmap(struct cx18 *cx) /* Hauppauge card? get values from tveeprom */ void cx18_read_eeprom(struct cx18 *cx, struct tveeprom *tv) { + struct i2c_client c; u8 eedata[256]; - cx->i2c_client[0].addr = 0xA0 >> 1; - tveeprom_read(&cx->i2c_client[0], eedata, sizeof(eedata)); - tveeprom_hauppauge_analog(&cx->i2c_client[0], tv, eedata); + memset(&c, 0, sizeof(c)); + strlcpy(c.name, "cx18 tveeprom tmp", sizeof(c.name)); + c.adapter = &cx->i2c_adap[0]; + c.addr = 0xA0 >> 1; + + tveeprom_read(&c, eedata, sizeof(eedata)); + tveeprom_hauppauge_analog(&c, tv, eedata); } static void cx18_process_eeprom(struct cx18 *cx) @@ -448,34 +445,38 @@ static void cx18_process_options(struct cx18 *cx) cx->stream_buf_size[CX18_ENC_STREAM_TYPE_MPG] = enc_mpg_bufsize; cx->stream_buf_size[CX18_ENC_STREAM_TYPE_IDX] = enc_idx_bufsize; cx->stream_buf_size[CX18_ENC_STREAM_TYPE_YUV] = enc_yuv_bufsize; - cx->stream_buf_size[CX18_ENC_STREAM_TYPE_VBI] = 0; /* computed later */ + cx->stream_buf_size[CX18_ENC_STREAM_TYPE_VBI] = vbi_active_samples * 36; cx->stream_buf_size[CX18_ENC_STREAM_TYPE_PCM] = enc_pcm_bufsize; cx->stream_buf_size[CX18_ENC_STREAM_TYPE_RAD] = 0; /* control no data */ - /* Except for VBI ensure stream_buffers & stream_buf_size are valid */ + /* Ensure stream_buffers & stream_buf_size are valid */ for (i = 0; i < CX18_MAX_STREAMS; i++) { - /* User said to use 0 buffers */ - if (cx->stream_buffers[i] == 0) { - cx->options.megabytes[i] = 0; - cx->stream_buf_size[i] = 0; - continue; - } - /* User said to use 0 MB total */ - if (cx->options.megabytes[i] <= 0) { + if (cx->stream_buffers[i] == 0 || /* User said 0 buffers */ + cx->options.megabytes[i] <= 0 || /* User said 0 MB total */ + cx->stream_buf_size[i] <= 0) { /* User said buf size 0 */ cx->options.megabytes[i] = 0; cx->stream_buffers[i] = 0; cx->stream_buf_size[i] = 0; continue; } - /* VBI is computed later or user said buffer has size 0 */ - if (cx->stream_buf_size[i] <= 0) { - if (i != CX18_ENC_STREAM_TYPE_VBI) { - cx->options.megabytes[i] = 0; - cx->stream_buffers[i] = 0; - cx->stream_buf_size[i] = 0; + /* + * VBI is a special case where the stream_buf_size is fixed + * and already in bytes + */ + if (i == CX18_ENC_STREAM_TYPE_VBI) { + if (cx->stream_buffers[i] < 0) { + cx->stream_buffers[i] = + cx->options.megabytes[i] * 1024 * 1024 + / cx->stream_buf_size[i]; + } else { + /* N.B. This might round down to 0 */ + cx->options.megabytes[i] = + cx->stream_buffers[i] + * cx->stream_buf_size[i]/(1024 * 1024); } continue; } + /* All other streams have stream_buf_size in kB at this point */ if (cx->stream_buffers[i] < 0) { cx->stream_buffers[i] = cx->options.megabytes[i] * 1024 / cx->stream_buf_size[i]; @@ -487,9 +488,9 @@ static void cx18_process_options(struct cx18 *cx) cx->stream_buf_size[i] *= 1024; /* convert from kB to bytes */ } - cx->options.cardtype = cardtype[cx->num]; - cx->options.tuner = tuner[cx->num]; - cx->options.radio = radio[cx->num]; + cx->options.cardtype = cardtype[cx->instance]; + cx->options.tuner = tuner[cx->instance]; + cx->options.radio = radio[cx->instance]; cx->std = cx18_parse_std(cx); if (cx->options.cardtype == -1) { @@ -546,7 +547,7 @@ done: } /* Precondition: the cx18 structure has been memset to 0. Only - the dev and num fields have been filled in. + the dev and instance fields have been filled in. No assumptions on the card type may be made here (see cx18_init_struct2 for that). */ @@ -557,15 +558,11 @@ static int __devinit cx18_init_struct1(struct cx18 *cx) cx->base_addr = pci_resource_start(cx->pci_dev, 0); mutex_init(&cx->serialize_lock); - mutex_init(&cx->i2c_bus_lock[0]); - mutex_init(&cx->i2c_bus_lock[1]); mutex_init(&cx->gpio_lock); mutex_init(&cx->epu2apu_mb_lock); mutex_init(&cx->epu2cpu_mb_lock); - spin_lock_init(&cx->lock); - - cx->work_queue = create_singlethread_workqueue(cx->name); + cx->work_queue = create_singlethread_workqueue(cx->v4l2_dev.name); if (cx->work_queue == NULL) { CX18_ERR("Unable to create work hander thread\n"); return -ENOMEM; @@ -588,7 +585,8 @@ static int __devinit cx18_init_struct1(struct cx18 *cx) (cx->params.video_temporal_filter_mode << 1) | (cx->params.video_median_filter_type << 2); cx->params.port = CX2341X_PORT_MEMORY; - cx->params.capabilities = CX2341X_CAP_HAS_TS | CX2341X_CAP_HAS_AC3; + cx->params.capabilities = + CX2341X_CAP_HAS_TS | CX2341X_CAP_HAS_SLICED_VBI; init_waitqueue_head(&cx->cap_w); init_waitqueue_head(&cx->mb_apu_waitq); init_waitqueue_head(&cx->mb_cpu_waitq); @@ -598,49 +596,6 @@ static int __devinit cx18_init_struct1(struct cx18 *cx) cx->vbi.in.type = V4L2_BUF_TYPE_VBI_CAPTURE; cx->vbi.sliced_in = &cx->vbi.in.fmt.sliced; - /* - * The VBI line sizes depend on the pixel clock and the horiz rate - * - * (1/Fh)*(2*Fp) = Samples/line - * = 4 bytes EAV + Anc data in hblank + 4 bytes SAV + active samples - * - * Sliced VBI is sent as ancillary data during horizontal blanking - * Raw VBI is sent as active video samples during vertcal blanking - * - * We use a BT.656 pxiel clock of 13.5 MHz and a BT.656 active line - * length of 720 pixels @ 4:2:2 sampling. Thus... - * - * For systems that use a 15.734 kHz horizontal rate, such as - * NTSC-M, PAL-M, PAL-60, and other 60 Hz/525 line systems, we have: - * - * (1/15.734 kHz) * 2 * 13.5 MHz = 1716 samples/line = - * 4 bytes SAV + 268 bytes anc data + 4 bytes SAV + 1440 active samples - * - * For systems that use a 15.625 kHz horizontal rate, such as - * PAL-B/G/H, PAL-I, SECAM-L and other 50 Hz/625 line systems, we have: - * - * (1/15.625 kHz) * 2 * 13.5 MHz = 1728 samples/line = - * 4 bytes SAV + 280 bytes anc data + 4 bytes SAV + 1440 active samples - * - */ - - /* FIXME: init these based on tuner std & modify when std changes */ - /* CX18-AV-Core number of VBI samples output per horizontal line */ - cx->vbi.raw_decoder_line_size = 1444; /* 4 byte SAV + 2 * 720 */ - cx->vbi.sliced_decoder_line_size = 272; /* 60 Hz: 268+4, 50 Hz: 280+4 */ - - /* CX18-AV-Core VBI samples/line possibly rounded up */ - cx->vbi.raw_size = 1444; /* Real max size is 1444 */ - cx->vbi.sliced_size = 284; /* Real max size is 284 */ - - /* - * CX18-AV-Core SAV/EAV RP codes in VIP 1.x mode - * Task Field VerticalBlank HorizontalBlank 0 0 0 0 - */ - cx->vbi.raw_decoder_sav_odd_field = 0x20; /* V */ - cx->vbi.raw_decoder_sav_even_field = 0x60; /* FV */ - cx->vbi.sliced_decoder_sav_odd_field = 0xB0; /* T VH - actually EAV */ - cx->vbi.sliced_decoder_sav_even_field = 0xF0; /* TFVH - actually EAV */ return 0; } @@ -669,12 +624,6 @@ static void __devinit cx18_init_struct2(struct cx18 *cx) i = 0; cx->active_input = i; cx->audio_input = cx->card->video_inputs[i].audio_index; - cx->av_state.vid_input = CX18_AV_COMPOSITE7; - cx->av_state.aud_input = CX18_AV_AUDIO8; - cx->av_state.audclk_freq = 48000; - cx->av_state.audmode = V4L2_TUNER_MODE_LANG1; - /* FIXME - 8 is NTSC value, investigate */ - cx->av_state.vbi_line_offset = 8; } static int cx18_setup_pci(struct cx18 *cx, struct pci_dev *pci_dev, @@ -686,15 +635,16 @@ static int cx18_setup_pci(struct cx18 *cx, struct pci_dev *pci_dev, CX18_DEBUG_INFO("Enabling pci device\n"); if (pci_enable_device(pci_dev)) { - CX18_ERR("Can't enable device %d!\n", cx->num); + CX18_ERR("Can't enable device %d!\n", cx->instance); return -EIO; } if (pci_set_dma_mask(pci_dev, 0xffffffff)) { - CX18_ERR("No suitable DMA available on card %d.\n", cx->num); + CX18_ERR("No suitable DMA available, card %d\n", cx->instance); return -EIO; } if (!request_mem_region(cx->base_addr, CX18_MEM_SIZE, "cx18 encoder")) { - CX18_ERR("Cannot request encoder memory region on card %d.\n", cx->num); + CX18_ERR("Cannot request encoder memory region, card %d\n", + cx->instance); return -EIO; } @@ -722,54 +672,50 @@ static int cx18_setup_pci(struct cx18 *cx, struct pci_dev *pci_dev, return 0; } -#ifdef MODULE -static u32 cx18_request_module(struct cx18 *cx, u32 hw, - const char *name, u32 id) -{ - if ((hw & id) == 0) - return hw; - if (request_module("%s", name) != 0) { - CX18_ERR("Failed to load module %s\n", name); - return hw & ~id; - } - CX18_DEBUG_INFO("Loaded module %s\n", name); - return hw; -} -#endif - -static void cx18_load_and_init_modules(struct cx18 *cx) +static void cx18_init_subdevs(struct cx18 *cx) { u32 hw = cx->card->hw_all; + u32 device; int i; -#ifdef MODULE - /* load modules */ -#ifdef CONFIG_MEDIA_TUNER_MODULE - hw = cx18_request_module(cx, hw, "tuner", CX18_HW_TUNER); -#endif -#ifdef CONFIG_VIDEO_CS5345_MODULE - hw = cx18_request_module(cx, hw, "cs5345", CX18_HW_CS5345); -#endif -#endif - - /* check which i2c devices are actually found */ - for (i = 0; i < 32; i++) { - u32 device = 1 << i; + for (i = 0, device = 1; i < 32; i++, device <<= 1) { if (!(device & hw)) continue; - if (device == CX18_HW_GPIO || device == CX18_HW_TVEEPROM || - device == CX18_HW_CX23418 || device == CX18_HW_DVB) { - /* These 'devices' do not use i2c probing */ + + switch (device) { + case CX18_HW_DVB: + case CX18_HW_TVEEPROM: + /* These subordinate devices do not use probing */ cx->hw_flags |= device; - continue; - } - cx18_i2c_register(cx, i); - if (cx18_i2c_hw_addr(cx, device) > 0) + break; + case CX18_HW_418_AV: + /* The A/V decoder gets probed earlier to set PLLs */ + /* Just note that the card uses it (i.e. has analog) */ cx->hw_flags |= device; + break; + case CX18_HW_GPIO_RESET_CTRL: + /* + * The Reset Controller gets probed and added to + * hw_flags earlier for i2c adapter/bus initialization + */ + break; + case CX18_HW_GPIO_MUX: + if (cx18_gpio_register(cx, device) == 0) + cx->hw_flags |= device; + break; + default: + if (cx18_i2c_register(cx, i) == 0) + cx->hw_flags |= device; + break; + } } - hw = cx->hw_flags; + if (cx->hw_flags & CX18_HW_418_AV) + cx->sd_av = cx18_find_hw(cx, CX18_HW_418_AV); + + if (cx->card->hw_muxer != 0) + cx->sd_extmux = cx18_find_hw(cx, cx->card->hw_muxer); } static int __devinit cx18_probe(struct pci_dev *pci_dev, @@ -777,48 +723,45 @@ static int __devinit cx18_probe(struct pci_dev *pci_dev, { int retval = 0; int i; - int vbi_buf_size; u32 devtype; struct cx18 *cx; - spin_lock(&cx18_cards_lock); - - /* Make sure we've got a place for this card */ - if (cx18_cards_active == CX18_MAX_CARDS) { - printk(KERN_ERR "cx18: Maximum number of cards detected (%d).\n", - cx18_cards_active); - spin_unlock(&cx18_cards_lock); + /* FIXME - module parameter arrays constrain max instances */ + i = atomic_inc_return(&cx18_instance) - 1; + if (i >= CX18_MAX_CARDS) { + printk(KERN_ERR "cx18: cannot manage card %d, driver has a " + "limit of 0 - %d\n", i, CX18_MAX_CARDS - 1); return -ENOMEM; } cx = kzalloc(sizeof(struct cx18), GFP_ATOMIC); - if (!cx) { - spin_unlock(&cx18_cards_lock); + if (cx == NULL) { + printk(KERN_ERR "cx18: cannot manage card %d, out of memory\n", + i); return -ENOMEM; } - cx18_cards[cx18_cards_active] = cx; - cx->num = cx18_cards_active++; - snprintf(cx->name, sizeof(cx->name), "cx18-%d", cx->num); - CX18_INFO("Initializing card #%d\n", cx->num); - - spin_unlock(&cx18_cards_lock); - cx->pci_dev = pci_dev; + cx->instance = i; + retval = v4l2_device_register(&pci_dev->dev, &cx->v4l2_dev); if (retval) { - CX18_ERR("Call to v4l2_device_register() failed\n"); - goto err; + printk(KERN_ERR "cx18: v4l2_device_register of card %d failed" + "\n", cx->instance); + kfree(cx); + return retval; } - CX18_DEBUG_INFO("registered v4l2_device name: %s\n", cx->v4l2_dev.name); + snprintf(cx->v4l2_dev.name, sizeof(cx->v4l2_dev.name), "cx18-%d", + cx->instance); + CX18_INFO("Initializing card %d\n", cx->instance); cx18_process_options(cx); if (cx->options.cardtype == -1) { retval = -ENODEV; - goto unregister_v4l2; + goto err; } if (cx18_init_struct1(cx)) { retval = -ENOMEM; - goto unregister_v4l2; + goto err; } CX18_DEBUG_INFO("base addr: 0x%08x\n", cx->base_addr); @@ -861,6 +804,23 @@ static int __devinit cx18_probe(struct pci_dev *pci_dev, cx18_gpio_init(cx); + /* Initialize integrated A/V decoder early to set PLLs, just in case */ + retval = cx18_av_probe(cx); + if (retval) { + CX18_ERR("Could not register A/V decoder subdevice\n"); + goto free_map; + } + cx18_call_hw(cx, CX18_HW_418_AV, core, init, (u32) CX18_AV_INIT_PLLS); + + /* Initialize GPIO Reset Controller to do chip resets during i2c init */ + if (cx->card->hw_all & CX18_HW_GPIO_RESET_CTRL) { + if (cx18_gpio_register(cx, CX18_HW_GPIO_RESET_CTRL) != 0) + CX18_WARN("Could not register GPIO reset controller" + "subdevice; proceeding anyway.\n"); + else + cx->hw_flags |= CX18_HW_GPIO_RESET_CTRL; + } + /* active i2c */ CX18_DEBUG_INFO("activating i2c...\n"); retval = init_cx18_i2c(cx); @@ -869,8 +829,6 @@ static int __devinit cx18_probe(struct pci_dev *pci_dev, goto free_map; } - CX18_DEBUG_INFO("Active card count: %d.\n", cx18_cards_active); - if (cx->card->hw_all & CX18_HW_TVEEPROM) { /* Based on the model number the cardtype may be changed. The PCI IDs are not always reliable. */ @@ -887,7 +845,8 @@ static int __devinit cx18_probe(struct pci_dev *pci_dev, /* Register IRQ */ retval = request_irq(cx->pci_dev->irq, cx18_irq_handler, - IRQF_SHARED | IRQF_DISABLED, cx->name, (void *)cx); + IRQF_SHARED | IRQF_DISABLED, + cx->v4l2_dev.name, (void *)cx); if (retval) { CX18_ERR("Failed to register irq %d\n", retval); goto free_i2c; @@ -922,33 +881,14 @@ static int __devinit cx18_probe(struct pci_dev *pci_dev, initialization. */ cx18_init_struct2(cx); - cx18_load_and_init_modules(cx); + cx18_init_subdevs(cx); - if (cx->std & V4L2_STD_525_60) { + if (cx->std & V4L2_STD_525_60) cx->is_60hz = 1; - cx->is_out_60hz = 1; - } else { + else cx->is_50hz = 1; - cx->is_out_50hz = 1; - } - cx->params.video_gop_size = cx->is_60hz ? 15 : 12; - /* - * FIXME: setting the buffer size based on the tuner standard is - * suboptimal, as the CVBS and SVideo inputs could use a different std - * and the buffer could end up being too small in that case. - */ - vbi_buf_size = cx->vbi.raw_size * (cx->is_60hz ? 24 : 36) / 2; - cx->stream_buf_size[CX18_ENC_STREAM_TYPE_VBI] = vbi_buf_size; - - if (cx->stream_buffers[CX18_ENC_STREAM_TYPE_VBI] < 0) - cx->stream_buffers[CX18_ENC_STREAM_TYPE_VBI] = - cx->options.megabytes[CX18_ENC_STREAM_TYPE_VBI] * 1024 * 1024 - / vbi_buf_size; - else - cx->options.megabytes[CX18_ENC_STREAM_TYPE_VBI] = - cx->stream_buffers[CX18_ENC_STREAM_TYPE_VBI] * vbi_buf_size - / (1024 * 1024); + cx->params.video_gop_size = cx->is_60hz ? 15 : 12; if (cx->options.radio > 0) cx->v4l2_cap |= V4L2_CAP_RADIO; @@ -961,7 +901,7 @@ static int __devinit cx18_probe(struct pci_dev *pci_dev, setup.mode_mask = T_ANALOG_TV; /* matches TV tuners */ setup.tuner_callback = (setup.type == TUNER_XC2028) ? cx18_reset_tuner_gpio : NULL; - cx18_call_i2c_clients(cx, TUNER_SET_TYPE_ADDR, &setup); + cx18_call_all(cx, tuner, s_type_addr, &setup); if (setup.type == TUNER_XC2028) { static struct xc2028_ctrl ctrl = { .fname = XC2028_DEFAULT_FIRMWARE, @@ -971,7 +911,7 @@ static int __devinit cx18_probe(struct pci_dev *pci_dev, .tuner = cx->options.tuner, .priv = &ctrl, }; - cx18_call_i2c_clients(cx, TUNER_SET_CONFIG, &cfg); + cx18_call_all(cx, tuner, s_config, &cfg); } } @@ -990,8 +930,7 @@ static int __devinit cx18_probe(struct pci_dev *pci_dev, goto free_streams; } - CX18_INFO("Initialized card #%d: %s\n", cx->num, cx->card_name); - + CX18_INFO("Initialized card: %s\n", cx->card_name); return 0; free_streams: @@ -1006,18 +945,13 @@ free_mem: release_mem_region(cx->base_addr, CX18_MEM_SIZE); free_workqueue: destroy_workqueue(cx->work_queue); -unregister_v4l2: - v4l2_device_unregister(&cx->v4l2_dev); err: if (retval == 0) retval = -ENODEV; CX18_ERR("Error %d on initialization\n", retval); - i = cx->num; - spin_lock(&cx18_cards_lock); - kfree(cx18_cards[i]); - cx18_cards[i] = NULL; - spin_unlock(&cx18_cards_lock); + v4l2_device_unregister(&cx->v4l2_dev); + kfree(cx); return retval; } @@ -1080,6 +1014,22 @@ int cx18_init_on_first_open(struct cx18 *cx) return -ENXIO; } + /* + * The second firmware load requires us to normalize the APU state, + * or the audio for the first analog capture will be badly incorrect. + * + * I can't seem to call APU_RESETAI and have it succeed without the + * APU capturing audio, so we start and stop it here to do the reset + */ + + /* MPEG Encoding, 224 kbps, MPEG Layer II, 48 ksps */ + cx18_vapi(cx, CX18_APU_START, 2, CX18_APU_ENCODING_METHOD_MPEG|0xb9, 0); + cx18_vapi(cx, CX18_APU_RESETAI, 0); + cx18_vapi(cx, CX18_APU_STOP, 1, CX18_APU_ENCODING_METHOD_MPEG); + + /* Init the A/V decoder, if it hasn't been already */ + v4l2_subdev_call(cx->sd_av, core, init, (u32) CX18_AV_INIT_NORMAL); + vf.tuner = 0; vf.type = V4L2_TUNER_ANALOG_TV; vf.frequency = 6400; /* the tuner 'baseline' frequency */ @@ -1113,9 +1063,10 @@ static void cx18_cancel_epu_work_orders(struct cx18 *cx) static void cx18_remove(struct pci_dev *pci_dev) { struct v4l2_device *v4l2_dev = pci_get_drvdata(pci_dev); - struct cx18 *cx = container_of(v4l2_dev, struct cx18, v4l2_dev); + struct cx18 *cx = to_cx18(v4l2_dev); + int i; - CX18_DEBUG_INFO("Removing Card #%d\n", cx->num); + CX18_DEBUG_INFO("Removing Card\n"); /* Stop all captures */ CX18_DEBUG_INFO("Stopping all streams\n"); @@ -1144,9 +1095,14 @@ static void cx18_remove(struct pci_dev *pci_dev) pci_disable_device(cx->pci_dev); - v4l2_device_unregister(v4l2_dev); + if (cx->vbi.sliced_mpeg_data[0] != NULL) + for (i = 0; i < CX18_VBI_FRAMES; i++) + kfree(cx->vbi.sliced_mpeg_data[i]); + + CX18_INFO("Removed %s\n", cx->card_name); - CX18_INFO("Removed %s, card #%d\n", cx->card_name, cx->num); + v4l2_device_unregister(v4l2_dev); + kfree(cx); } /* define a pci_driver for card detection */ @@ -1161,8 +1117,6 @@ static int module_start(void) { printk(KERN_INFO "cx18: Start initialization, version %s\n", CX18_VERSION); - memset(cx18_cards, 0, sizeof(cx18_cards)); - /* Validate parameters */ if (cx18_first_minor < 0 || cx18_first_minor >= CX18_MAX_CARDS) { printk(KERN_ERR "cx18: Exiting, cx18_first_minor must be between 0 and %d\n", @@ -1185,16 +1139,7 @@ static int module_start(void) static void module_cleanup(void) { - int i; - pci_unregister_driver(&cx18_pci_driver); - - for (i = 0; i < cx18_cards_active; i++) { - if (cx18_cards[i] == NULL) - continue; - kfree(cx18_cards[i]); - } - } module_init(module_start);