linux 2.6.16.38 w/ vs2.0.3-rc1
[linux-2.6.git] / drivers / media / video / cx88 / cx88-core.c
index e1092d5..3720f24 100644 (file)
@@ -146,11 +146,9 @@ int cx88_risc_buffer(struct pci_dev *pci, struct btcx_riscmem *risc,
                fields++;
 
        /* estimate risc mem: worst case is one write per page border +
-          one write per scan line + syncs + jump (all 2 dwords).  Padding
-          can cause next bpl to start close to a page border.  First DMA
-          region may be smaller than PAGE_SIZE */
-       instructions  = fields * (1 + ((bpl + padding) * lines) / PAGE_SIZE + lines);
-       instructions += 2;
+          one write per scan line + syncs + jump (all 2 dwords) */
+       instructions  = (bpl * lines * fields) / PAGE_SIZE + lines * fields;
+       instructions += 3 + 4;
        if ((rc = btcx_riscmem_alloc(pci,risc,instructions*8)) < 0)
                return rc;
 
@@ -165,7 +163,7 @@ int cx88_risc_buffer(struct pci_dev *pci, struct btcx_riscmem *risc,
 
        /* save pointer to jmp instruction address */
        risc->jmp = rp;
-       BUG_ON((risc->jmp - risc->cpu + 2) * sizeof (*risc->cpu) > risc->size);
+       BUG_ON((risc->jmp - risc->cpu + 2) / 4 > risc->size);
        return 0;
 }
 
@@ -178,11 +176,9 @@ int cx88_risc_databuffer(struct pci_dev *pci, struct btcx_riscmem *risc,
        int rc;
 
        /* estimate risc mem: worst case is one write per page border +
-          one write per scan line + syncs + jump (all 2 dwords).  Here
-          there is no padding and no sync.  First DMA region may be smaller
-          than PAGE_SIZE */
-       instructions  = 1 + (bpl * lines) / PAGE_SIZE + lines;
-       instructions += 1;
+          one write per scan line + syncs + jump (all 2 dwords) */
+       instructions  = (bpl * lines) / PAGE_SIZE + lines;
+       instructions += 3 + 4;
        if ((rc = btcx_riscmem_alloc(pci,risc,instructions*8)) < 0)
                return rc;
 
@@ -192,7 +188,7 @@ int cx88_risc_databuffer(struct pci_dev *pci, struct btcx_riscmem *risc,
 
        /* save pointer to jmp instruction address */
        risc->jmp = rp;
-       BUG_ON((risc->jmp - risc->cpu + 2) * sizeof (*risc->cpu) > risc->size);
+       BUG_ON((risc->jmp - risc->cpu + 2) / 4 > risc->size);
        return 0;
 }
 
@@ -217,13 +213,14 @@ int cx88_risc_stopper(struct pci_dev *pci, struct btcx_riscmem *risc,
 }
 
 void
-cx88_free_buffer(struct videobuf_queue *q, struct cx88_buffer *buf)
+cx88_free_buffer(struct pci_dev *pci, struct cx88_buffer *buf)
 {
-       BUG_ON(in_interrupt());
+       if (in_interrupt())
+               BUG();
        videobuf_waiton(&buf->vb,0,0);
-       videobuf_dma_unmap(q, &buf->vb.dma);
+       videobuf_dma_pci_unmap(pci, &buf->vb.dma);
        videobuf_dma_free(&buf->vb.dma);
-       btcx_riscmem_free((struct pci_dev *)q->dev, &buf->risc);
+       btcx_riscmem_free(pci, &buf->risc);
        buf->vb.state = STATE_NEEDS_INIT;
 }
 
@@ -1064,7 +1061,7 @@ struct cx88_core* cx88_core_get(struct pci_dev *pci)
        core->pci_bus  = pci->bus->number;
        core->pci_slot = PCI_SLOT(pci->devfn);
        core->pci_irqmask = 0x00fc00;
-       mutex_init(&core->lock);
+       init_MUTEX(&core->lock);
 
        core->nr = cx88_devcount++;
        sprintf(core->name,"cx88[%d]",core->nr);