linux 2.6.16.38 w/ vs2.0.3-rc1
[linux-2.6.git] / drivers / media / video / bttv-risc.c
similarity index 96%
rename from drivers/media/video/bt8xx/bttv-risc.c
rename to drivers/media/video/bttv-risc.c
index afcfe71..b40e973 100644 (file)
@@ -51,10 +51,8 @@ bttv_risc_packed(struct bttv *btv, struct btcx_riscmem *risc,
        int rc;
 
        /* estimate risc mem: worst case is one write per page border +
-          one write per scan line + sync + 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  = 1 + ((bpl + padding) * lines) / PAGE_SIZE + lines;
+          one write per scan line + sync + jump (all 2 dwords) */
+       instructions  = (bpl * lines) / PAGE_SIZE + lines;
        instructions += 2;
        if ((rc = btcx_riscmem_alloc(btv->c.pci,risc,instructions*8)) < 0)
                return rc;
@@ -106,7 +104,7 @@ bttv_risc_packed(struct bttv *btv, 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;
 }
 
@@ -224,7 +222,7 @@ bttv_risc_planar(struct bttv *btv, 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;
 }
 
@@ -233,7 +231,7 @@ bttv_risc_overlay(struct bttv *btv, struct btcx_riscmem *risc,
                  const struct bttv_format *fmt, struct bttv_overlay *ov,
                  int skip_even, int skip_odd)
 {
-       int dwords,rc,line,maxy,start,end,skip,nskips;
+       int instructions,rc,line,maxy,start,end,skip,nskips;
        struct btcx_skiplist *skips;
        u32 *rp,ri,ra;
        u32 addr;
@@ -242,12 +240,12 @@ bttv_risc_overlay(struct bttv *btv, struct btcx_riscmem *risc,
        if (NULL == (skips = kmalloc(sizeof(*skips) * ov->nclips,GFP_KERNEL)))
                return -ENOMEM;
 
-       /* estimate risc mem: worst case is (1.5*clip+1) * lines instructions
+       /* estimate risc mem: worst case is (clip+1) * lines instructions
           + sync + jump (all 2 dwords) */
-       dwords  = (3 * ov->nclips + 2) *
-               ((skip_even || skip_odd) ? (ov->w.height+1)>>1 :  ov->w.height);
-       dwords += 4;
-       if ((rc = btcx_riscmem_alloc(btv->c.pci,risc,dwords*4)) < 0) {
+       instructions  = (ov->nclips + 1) *
+               ((skip_even || skip_odd) ? ov->w.height>>1 :  ov->w.height);
+       instructions += 2;
+       if ((rc = btcx_riscmem_alloc(btv->c.pci,risc,instructions*8)) < 0) {
                kfree(skips);
                return rc;
        }
@@ -309,7 +307,7 @@ bttv_risc_overlay(struct bttv *btv, 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);
        kfree(skips);
        return 0;
 }
@@ -507,11 +505,12 @@ bttv_risc_hook(struct bttv *btv, int slot, struct btcx_riscmem *risc,
 }
 
 void
-bttv_dma_free(struct videobuf_queue *q,struct bttv *btv, struct bttv_buffer *buf)
+bttv_dma_free(struct bttv *btv, struct bttv_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(btv->c.pci, &buf->vb.dma);
        videobuf_dma_free(&buf->vb.dma);
        btcx_riscmem_free(btv->c.pci,&buf->bottom);
        btcx_riscmem_free(btv->c.pci,&buf->top);