]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - drivers/media/video/ivtv/ivtv-driver.c
Merge branch 'linus' of master.kernel.org:/pub/scm/linux/kernel/git/perex/alsa
[linux-2.6-omap-h63xx.git] / drivers / media / video / ivtv / ivtv-driver.c
index 7058aa25ac9c5c9ce030333b7533f27f789edc9b..e29f949adf57d255a67b9967dc90d6ce01fa22e9 100644 (file)
@@ -74,7 +74,7 @@ int ivtv_first_minor = 0;
 struct ivtv *ivtv_cards[IVTV_MAX_CARDS];
 
 /* Protects ivtv_cards_active */
-spinlock_t ivtv_cards_lock = SPIN_LOCK_UNLOCKED;
+DEFINE_SPINLOCK(ivtv_cards_lock);
 
 /* add your revision and whatnot here */
 static struct pci_device_id ivtv_pci_tbl[] __devinitdata = {
@@ -116,7 +116,7 @@ static int dec_yuv_buffers = IVTV_DEFAULT_DEC_YUV_BUFFERS;
 static int dec_vbi_buffers = IVTV_DEFAULT_DEC_VBI_BUFFERS;
 
 static int ivtv_yuv_mode = 0;
-static int ivtv_yuv_threshold=480;
+static int ivtv_yuv_threshold=-1;
 static int ivtv_pci_latency = 1;
 
 int ivtv_debug = 0;
@@ -1134,46 +1134,6 @@ static int __devinit ivtv_probe(struct pci_dev *dev,
        if (itv->options.radio > 0)
                itv->v4l2_cap |= V4L2_CAP_RADIO;
 
-       retval = ivtv_streams_setup(itv);
-       if (retval) {
-               IVTV_ERR("Error %d setting up streams\n", retval);
-               goto free_i2c;
-       }
-
-       /* Start Threads */
-       IVTV_DEBUG_INFO("Starting Threads\n");
-
-       /* Decoder Thread */
-       if (itv->card->v4l2_capabilities & V4L2_CAP_VIDEO_OUTPUT) {
-               ivtv_init_mpeg_decoder(itv);
-       }
-
-       IVTV_DEBUG_IRQ("Masking interrupts\n");
-       /* clear interrupt mask, effectively disabling interrupts */
-       ivtv_set_irq_mask(itv, 0xffffffff);
-
-       /* Register IRQ */
-       retval = request_irq(itv->dev->irq, ivtv_irq_handler,
-                            IRQF_SHARED | IRQF_DISABLED, itv->name, (void *)itv);
-       if (retval) {
-               IVTV_ERR("Failed to register irq %d\n", retval);
-               goto free_streams;
-       }
-
-       /* On a cx23416 this seems to be able to enable DMA to the chip? */
-       if (!itv->has_cx23415)
-               write_reg_sync(0x03, IVTV_REG_DMACONTROL);
-
-       /* Default interrupts enabled. For the PVR350 this includes the
-          decoder VSYNC interrupt, which is always on. It is not only used
-          during decoding but also by the OSD.
-          Some old PVR250 cards had a cx23415, so testing for that is too
-          general. Instead test if the card has video output capability. */
-       if (itv->v4l2_cap & V4L2_CAP_VIDEO_OUTPUT)
-               ivtv_clear_irq_mask(itv, IVTV_IRQ_MASK_INIT | IVTV_IRQ_DEC_VSYNC);
-       else
-               ivtv_clear_irq_mask(itv, IVTV_IRQ_MASK_INIT);
-
        if (itv->options.tuner > -1) {
                struct tuner_setup setup;
 
@@ -1210,8 +1170,45 @@ static int __devinit ivtv_probe(struct pci_dev *dev,
           in one place. */
        itv->std++;             /* Force full standard initialization */
        itv->std_out = itv->std;
-       ivtv_v4l2_ioctls(itv, NULL, VIDIOC_S_STD, &itv->tuner_std);
        ivtv_v4l2_ioctls(itv, NULL, VIDIOC_S_FREQUENCY, &vf);
+
+       retval = ivtv_streams_setup(itv);
+       if (retval) {
+               IVTV_ERR("Error %d setting up streams\n", retval);
+               goto free_i2c;
+       }
+
+       if (itv->card->v4l2_capabilities & V4L2_CAP_VIDEO_OUTPUT) {
+               ivtv_init_mpeg_decoder(itv);
+       }
+       ivtv_v4l2_ioctls(itv, NULL, VIDIOC_S_STD, &itv->tuner_std);
+
+       IVTV_DEBUG_IRQ("Masking interrupts\n");
+       /* clear interrupt mask, effectively disabling interrupts */
+       ivtv_set_irq_mask(itv, 0xffffffff);
+
+       /* Register IRQ */
+       retval = request_irq(itv->dev->irq, ivtv_irq_handler,
+                            IRQF_SHARED | IRQF_DISABLED, itv->name, (void *)itv);
+       if (retval) {
+               IVTV_ERR("Failed to register irq %d\n", retval);
+               goto free_streams;
+       }
+
+       /* On a cx23416 this seems to be able to enable DMA to the chip? */
+       if (!itv->has_cx23415)
+               write_reg_sync(0x03, IVTV_REG_DMACONTROL);
+
+       /* Default interrupts enabled. For the PVR350 this includes the
+          decoder VSYNC interrupt, which is always on. It is not only used
+          during decoding but also by the OSD.
+          Some old PVR250 cards had a cx23415, so testing for that is too
+          general. Instead test if the card has video output capability. */
+       if (itv->v4l2_cap & V4L2_CAP_VIDEO_OUTPUT)
+               ivtv_clear_irq_mask(itv, IVTV_IRQ_MASK_INIT | IVTV_IRQ_DEC_VSYNC);
+       else
+               ivtv_clear_irq_mask(itv, IVTV_IRQ_MASK_INIT);
+
        if (itv->has_cx23415)
                ivtv_set_osd_alpha(itv);
 
@@ -1345,6 +1342,8 @@ static void module_cleanup(void)
 {
        int i, j;
 
+       pci_unregister_driver(&ivtv_pci_driver);
+
        for (i = 0; i < ivtv_cards_active; i++) {
                if (ivtv_cards[i] == NULL)
                        continue;
@@ -1353,7 +1352,6 @@ static void module_cleanup(void)
                }
                kfree(ivtv_cards[i]);
        }
-       pci_unregister_driver(&ivtv_pci_driver);
 }
 
 /* Note: These symbols are exported because they are used by the ivtv-fb