[PATCH] v4l: 800: whitespace cleanups
[pandora-kernel.git] / drivers / media / video / cx88 / cx88-mpeg.c
index c5f4c59..35e6d0c 100644 (file)
@@ -1,5 +1,4 @@
 /*
- * $Id: cx88-mpeg.c,v 1.28 2005/06/20 03:36:00 mkrufky Exp $
  *
  *  Support for the mpeg transport stream transfers
  *  PCI function #2 of the cx2388x.
@@ -55,7 +54,7 @@ static int cx8802_start_dma(struct cx8802_dev    *dev,
 {
        struct cx88_core *core = dev->core;
 
-       dprintk(0, "cx8802_start_dma %d\n", buf->vb.width);
+       dprintk(0, "cx8802_start_dma w: %d, h: %d, f: %d\n", dev->width, dev->height, buf->vb.field);
 
        /* setup fifo + format */
        cx88_sram_channel_setup(core, &cx88_sram_channels[SRAM_CH28],
@@ -64,7 +63,6 @@ static int cx8802_start_dma(struct cx8802_dev    *dev,
        /* write TS length to chip */
        cx_write(MO_TS_LNGTH, buf->vb.width);
 
-#if 1
        /* FIXME: this needs a review.
         * also: move to cx88-blackbird + cx88-dvb source files? */
 
@@ -73,12 +71,16 @@ static int cx8802_start_dma(struct cx8802_dev    *dev,
                cx_write(TS_GEN_CNTRL, 0x0040 | dev->ts_gen_cntrl);
                udelay(100);
                cx_write(MO_PINMUX_IO, 0x00);
-               if (core->board == CX88_BOARD_DVICO_FUSIONHDTV_3_GOLD_Q) {
-                       cx_write(TS_HW_SOP_CNTRL,0x47<<16 | 188<<4 | 0x00);
-                       cx_write(TS_SOP_STAT, 0<<16 | 0<<14 | 1<<13 | 0<<12);
-               } else {
-                       cx_write(TS_HW_SOP_CNTRL,47<<16|188<<4|0x00);
-                       cx_write(TS_SOP_STAT,0x00);
+               cx_write(TS_HW_SOP_CNTRL,0x47<<16|188<<4|0x01);
+               switch (core->board) {
+               case CX88_BOARD_DVICO_FUSIONHDTV_3_GOLD_Q:
+               case CX88_BOARD_DVICO_FUSIONHDTV_3_GOLD_T:
+               case CX88_BOARD_DVICO_FUSIONHDTV_5_GOLD:
+                       cx_write(TS_SOP_STAT, 1<<13);
+                       break;
+               default:
+                       cx_write(TS_SOP_STAT, 0x00);
+                       break;
                }
                cx_write(TS_GEN_CNTRL, dev->ts_gen_cntrl);
                udelay(100);
@@ -87,18 +89,15 @@ static int cx8802_start_dma(struct cx8802_dev    *dev,
        if (cx88_boards[core->board].blackbird) {
                cx_write(MO_PINMUX_IO, 0x88); /* enable MPEG parallel IO */
 
-               // cx_write(TS_F2_CMD_STAT_MM, 0x2900106); /* F2_CMD_STAT_MM defaults + master + memory space */
                cx_write(TS_GEN_CNTRL, 0x46); /* punctured clock TS & posedge driven & software reset */
                udelay(100);
 
                cx_write(TS_HW_SOP_CNTRL, 0x408); /* mpeg start byte */
-               //cx_write(TS_HW_SOP_CNTRL, 0x2F0BC0); /* mpeg start byte ts: 0x2F0BC0 ? */
                cx_write(TS_VALERR_CNTRL, 0x2000);
 
                cx_write(TS_GEN_CNTRL, 0x06); /* punctured clock TS & posedge driven */
                udelay(100);
        }
-#endif
 
        /* reset counter */
        cx_write(MO_TS_GPCNTRL, GP_COUNT_CONTROL_RESET);
@@ -108,7 +107,6 @@ static int cx8802_start_dma(struct cx8802_dev    *dev,
        dprintk( 0, "setting the interrupt mask\n" );
        cx_set(MO_PCI_INTMSK, core->pci_irqmask | 0x04);
        cx_set(MO_TS_INTMSK,  0x1f0011);
-       //cx_write(MO_TS_INTMSK,  0x0f0011);
 
        /* start dma */
        cx_set(MO_DEV_CNTRL2, (1<<5));
@@ -160,7 +158,8 @@ static int cx8802_restart_queue(struct cx8802_dev    *dev,
 
 /* ------------------------------------------------------------------ */
 
-int cx8802_buf_prepare(struct cx8802_dev *dev, struct cx88_buffer *buf)
+int cx8802_buf_prepare(struct cx8802_dev *dev, struct cx88_buffer *buf,
+                       enum v4l2_field field)
 {
        int size = dev->ts_packet_size * dev->ts_packet_count;
        int rc;
@@ -173,7 +172,7 @@ int cx8802_buf_prepare(struct cx8802_dev *dev, struct cx88_buffer *buf)
                buf->vb.width  = dev->ts_packet_size;
                buf->vb.height = dev->ts_packet_count;
                buf->vb.size   = size;
-               buf->vb.field  = V4L2_FIELD_TOP;
+               buf->vb.field  = field /*V4L2_FIELD_TOP*/;
 
                if (0 != (rc = videobuf_iolock(dev->pci,&buf->vb,NULL)))
                        goto fail;
@@ -208,7 +207,6 @@ void cx8802_buf_queue(struct cx8802_dev *dev, struct cx88_buffer *buf)
                mod_timer(&q->timeout, jiffies+BUFFER_TIMEOUT);
                dprintk(0,"[%p/%d] %s - first active\n",
                        buf, buf->vb.i, __FUNCTION__);
-               //udelay(100);
 
        } else {
                dprintk( 1, "queue is not empty - append to active\n" );
@@ -219,7 +217,6 @@ void cx8802_buf_queue(struct cx8802_dev *dev, struct cx88_buffer *buf)
                prev->risc.jmp[1] = cpu_to_le32(buf->risc.dma);
                dprintk( 1, "[%p/%d] %s - append to active\n",
                        buf, buf->vb.i, __FUNCTION__);
-               //udelay(100);
        }
 }
 
@@ -270,6 +267,15 @@ static void cx8802_timeout(unsigned long data)
        do_cancel_buffers(dev,"timeout",1);
 }
 
+static char *cx88_mpeg_irqs[32] = {
+       "ts_risci1", NULL, NULL, NULL,
+       "ts_risci2", NULL, NULL, NULL,
+       "ts_oflow",  NULL, NULL, NULL,
+       "ts_sync",   NULL, NULL, NULL,
+       "opc_err", "par_err", "rip_err", "pci_abort",
+       "ts_err?",
+};
+
 static void cx8802_mpeg_irq(struct cx8802_dev *dev)
 {
        struct cx88_core *core = dev->core;
@@ -282,10 +288,7 @@ static void cx8802_mpeg_irq(struct cx8802_dev *dev)
                return;
 
        cx_write(MO_TS_INTSTAT, status);
-#if 0
-       cx88_print_irqbits(core->name, "irq mpeg ",
-                       cx88_mpeg_irqs, status, mask);
-#endif
+
        if (debug || (status & mask & ~0xff))
                cx88_print_irqbits(core->name, "irq mpeg ",
                                   cx88_mpeg_irqs, status, mask);
@@ -313,14 +316,14 @@ static void cx8802_mpeg_irq(struct cx8802_dev *dev)
                spin_unlock(&dev->slock);
        }
 
-        /* other general errors */
-        if (status & 0x1f0100) {
+       /* other general errors */
+       if (status & 0x1f0100) {
                dprintk( 0, "general errors: 0x%08x\n", status & 0x1f0100 );
-                spin_lock(&dev->slock);
+               spin_lock(&dev->slock);
                cx8802_stop_dma(dev);
-                cx8802_restart_queue(dev,&dev->mpegq);
-                spin_unlock(&dev->slock);
-        }
+               cx8802_restart_queue(dev,&dev->mpegq);
+               spin_unlock(&dev->slock);
+       }
 }
 
 #define MAX_IRQ_LOOP 10
@@ -376,14 +379,13 @@ int cx8802_init_common(struct cx8802_dev *dev)
        }
 
        pci_read_config_byte(dev->pci, PCI_CLASS_REVISION, &dev->pci_rev);
-        pci_read_config_byte(dev->pci, PCI_LATENCY_TIMER,  &dev->pci_lat);
-        printk(KERN_INFO "%s/2: found at %s, rev: %d, irq: %d, "
+       pci_read_config_byte(dev->pci, PCI_LATENCY_TIMER,  &dev->pci_lat);
+       printk(KERN_INFO "%s/2: found at %s, rev: %d, irq: %d, "
               "latency: %d, mmio: 0x%lx\n", dev->core->name,
               pci_name(dev->pci), dev->pci_rev, dev->pci->irq,
               dev->pci_lat,pci_resource_start(dev->pci,0));
 
        /* initialize driver struct */
-        init_MUTEX(&dev->lock);
        spin_lock_init(&dev->slock);
 
        /* init dma queue */
@@ -428,7 +430,7 @@ void cx8802_fini_common(struct cx8802_dev *dev)
 
 int cx8802_suspend_common(struct pci_dev *pci_dev, pm_message_t state)
 {
-        struct cx8802_dev *dev = pci_get_drvdata(pci_dev);
+       struct cx8802_dev *dev = pci_get_drvdata(pci_dev);
        struct cx88_core *core = dev->core;
 
        /* stop mpeg dma */
@@ -441,10 +443,8 @@ int cx8802_suspend_common(struct pci_dev *pci_dev, pm_message_t state)
        }
        spin_unlock(&dev->slock);
 
-#if 1
        /* FIXME -- shutdown device */
        cx88_shutdown(dev->core);
-#endif
 
        pci_save_state(pci_dev);
        if (0 != pci_set_power_state(pci_dev, pci_choose_state(pci_dev, state))) {
@@ -456,20 +456,32 @@ int cx8802_suspend_common(struct pci_dev *pci_dev, pm_message_t state)
 
 int cx8802_resume_common(struct pci_dev *pci_dev)
 {
-        struct cx8802_dev *dev = pci_get_drvdata(pci_dev);
+       struct cx8802_dev *dev = pci_get_drvdata(pci_dev);
        struct cx88_core *core = dev->core;
+       int err;
 
        if (dev->state.disabled) {
-               pci_enable_device(pci_dev);
+               err=pci_enable_device(pci_dev);
+               if (err) {
+                       printk(KERN_ERR "%s: can't enable device\n",
+                                              dev->core->name);
+                       return err;
+               }
                dev->state.disabled = 0;
        }
-       pci_set_power_state(pci_dev, PCI_D0);
+       err=pci_set_power_state(pci_dev, PCI_D0);
+       if (err) {
+               printk(KERN_ERR "%s: can't enable device\n",
+                                              dev->core->name);
+               pci_disable_device(pci_dev);
+               dev->state.disabled = 1;
+
+               return err;
+       }
        pci_restore_state(pci_dev);
 
-#if 1
        /* FIXME: re-initialize hardware */
        cx88_reset(dev->core);
-#endif
 
        /* restart video+vbi capture */
        spin_lock(&dev->slock);