]> err.no Git - linux-2.6/commitdiff
V4L/DVB (6306): Few clenups for saa7134 resume code
authorMaxim Levitsky <maximlevitsky@gmail.com>
Mon, 8 Oct 2007 15:07:35 +0000 (12:07 -0300)
committerMauro Carvalho Chehab <mchehab@infradead.org>
Wed, 10 Oct 2007 03:03:20 +0000 (00:03 -0300)
*Disable DMA explictly on suspend
*Enable DMA on resume, after all buffers were configured
*Disable overlay on resume - apps should enable it when X is resumed

Signed-off-by: Maxim Levitsky <maximlevitsky@gmail.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
drivers/media/video/saa7134/saa7134-core.c
drivers/media/video/saa7134/saa7134-tvaudio.c
drivers/media/video/saa7134/saa7134.h

index fae0bfe7939f98c12d3ecae46622f1981c25c19e..80f04f252fced35f2fe52385db4b9a127e856a0b 100644 (file)
@@ -398,29 +398,23 @@ void saa7134_buffer_timeout(unsigned long data)
 int saa7134_buffer_requeue(struct saa7134_dev *dev,
                         struct saa7134_dmaqueue *q)
 {
-       struct saa7134_buf *buf , *next;
-       unsigned long flags;
+       struct saa7134_buf *buf, *next;
 
-       spin_lock_irqsave(&dev->slock, flags);
+       assert_spin_locked(&dev->slock);
 
        buf  = q->curr;
        next = buf;
-
        dprintk("buffer_requeue\n");
 
-       if (!buf) {
-               spin_unlock_irqrestore(&dev->slock, flags);
+       if (!buf)
                return 0;
-       }
 
        dprintk("buffer_requeue : resending active buffers \n");
 
        if (!list_empty(&q->queue))
                next = list_entry(q->queue.next, struct saa7134_buf,
                                          vb.queue);
-
        buf->activate(dev, buf, next);
-       spin_unlock_irqrestore(&dev->slock, flags);
 
        return 0;
 }
@@ -435,6 +429,9 @@ int saa7134_set_dmabits(struct saa7134_dev *dev)
 
        assert_spin_locked(&dev->slock);
 
+       if (dev->inresume)
+               return 0;
+
        /* video capture -- dma 0 + video task A */
        if (dev->video_q.curr) {
                task |= 0x01;
@@ -1175,13 +1172,15 @@ static void __devexit saa7134_finidev(struct pci_dev *pci_dev)
 static int saa7134_suspend(struct pci_dev *pci_dev , pm_message_t state)
 {
 
-       /* Disable card's IRQs to prevent it from resuming computer */
-
        struct saa7134_dev *dev = pci_get_drvdata(pci_dev);
 
+       /* disable overlay - apps should enable it explicitly on resume*/
+       dev->ovenable = 0;
+
+       /* Disable interrupts, DMA, and rest of the chip*/
        saa_writel(SAA7134_IRQ1, 0);
        saa_writel(SAA7134_IRQ2, 0);
-
+       saa_writel(SAA7134_MAIN_CTRL, 0);
 
        pci_set_power_state(pci_dev, pci_choose_state(pci_dev, state));
        pci_save_state(pci_dev);
@@ -1193,6 +1192,7 @@ static int saa7134_resume(struct pci_dev *pci_dev)
 {
 
        struct saa7134_dev *dev = pci_get_drvdata(pci_dev);
+       unsigned int flags;
 
        pci_restore_state(pci_dev);
        pci_set_power_state(pci_dev, PCI_D0);
@@ -1200,6 +1200,7 @@ static int saa7134_resume(struct pci_dev *pci_dev)
        /* Do things that are done in saa7134_initdev ,
                except of initializing memory structures.*/
 
+       dev->inresume = 1;
        saa7134_board_init1(dev);
 
        if (saa7134_boards[dev->board].video_out)
@@ -1209,25 +1210,26 @@ static int saa7134_resume(struct pci_dev *pci_dev)
                saa7134_ts_init_hw(dev);
 
        saa7134_hw_enable1(dev);
-
        saa7134_set_decoder(dev);
-
        saa7134_i2c_call_clients(dev, VIDIOC_S_STD, &dev->tvnorm->id);
-
        saa7134_board_init2(dev);
        saa7134_hw_enable2(dev);
 
-       dev->force_mute_update = 1;
        saa7134_tvaudio_setmute(dev);
-       dev->force_mute_update = 0;
        saa7134_tvaudio_setvolume(dev, dev->ctl_volume);
        saa7134_enable_i2s(dev);
 
-       /*recapture unfinished buffer(s)*/
+       /*resume unfinished buffer(s)*/
+       spin_lock_irqsave(&dev->slock, flags);
        saa7134_buffer_requeue(dev, &dev->video_q);
        saa7134_buffer_requeue(dev, &dev->vbi_q);
        saa7134_buffer_requeue(dev, &dev->ts_q);
 
+       /* start DMA now*/
+       dev->inresume = 0;
+       saa7134_set_dmabits(dev);
+       spin_unlock_irqrestore(&dev->slock, flags);
+
        return 0;
 }
 
index df2dab06387d05e3fa56cbd7208aba7327a41298..1b9e39a5ea47650ea2a3688d173de3e755d2d8a2 100644 (file)
@@ -231,7 +231,7 @@ static void mute_input_7134(struct saa7134_dev *dev)
        }
 
        if (dev->hw_mute  == mute &&
-               dev->hw_input == in && !dev->force_mute_update) {
+               dev->hw_input == in && !dev->inresume) {
                dprintk("mute/input: nothing to do [mute=%d,input=%s]\n",
                        mute,in->name);
                return;
index 064f3dbe695181deb3fbb89402b7e08f785f8843..28ec6804bd5dca50b472cd40e07973d05c66beab 100644 (file)
@@ -522,9 +522,9 @@ struct saa7134_dev {
        struct saa7134_input       *input;
        struct saa7134_input       *hw_input;
        unsigned int               hw_mute;
-       unsigned int               force_mute_update;
        int                        last_carrier;
        int                        nosignal;
+       unsigned int               inresume;
 
        /* SAA7134_MPEG_* */
        struct saa7134_ts          ts;