diff -r ee9826bc7106 linux/drivers/media/video/bt8xx/bttv-driver.c --- a/linux/drivers/media/video/bt8xx/bttv-driver.c Thu Apr 29 23:31:06 2010 -0300 +++ b/linux/drivers/media/video/bt8xx/bttv-driver.c Tue Aug 03 09:09:58 2010 -0400 @@ -2403,7 +2403,7 @@ if (check_btres(fh, RESOURCE_OVERLAY)) { struct bttv_buffer *new; - new = videobuf_sg_alloc(sizeof(*new)); + new = videobuf_contig_alloc(sizeof(*new)); new->crop = btv->crop[!!fh->do_crop].rect; bttv_overlay_risc(btv, &fh->ov, fh->ovfmt, new); retval = bttv_switch_overlay(btv,fh,new); @@ -2780,7 +2780,7 @@ mutex_lock(&fh->cap.vb_lock); if (on) { fh->ov.tvnorm = btv->tvnorm; - new = videobuf_sg_alloc(sizeof(*new)); + new = videobuf_contig_alloc(sizeof(*new)); new->crop = btv->crop[!!fh->do_crop].rect; bttv_overlay_risc(btv, &fh->ov, fh->ovfmt, new); } else { @@ -2854,7 +2854,7 @@ if (check_btres(fh, RESOURCE_OVERLAY)) { struct bttv_buffer *new; - new = videobuf_sg_alloc(sizeof(*new)); + new = videobuf_contig_alloc(sizeof(*new)); new->crop = btv->crop[!!fh->do_crop].rect; bttv_overlay_risc(btv, &fh->ov, fh->ovfmt, new); retval = bttv_switch_overlay(btv, fh, new); @@ -3207,7 +3207,7 @@ /* need to capture a new frame */ if (locked_btres(fh->btv,RESOURCE_VIDEO_STREAM)) goto err; - fh->cap.read_buf = videobuf_sg_alloc(fh->cap.msize); + fh->cap.read_buf = videobuf_contig_alloc(fh->cap.msize); if (NULL == fh->cap.read_buf) goto err; fh->cap.read_buf->memory = V4L2_MEMORY_USERPTR; @@ -3270,18 +3270,18 @@ fh->ov.setup_ok = 0; v4l2_prio_open(&btv->prio,&fh->prio); - videobuf_queue_sg_init(&fh->cap, &bttv_video_qops, - &btv->c.pci->dev, &btv->s_lock, - V4L2_BUF_TYPE_VIDEO_CAPTURE, - V4L2_FIELD_INTERLACED, - sizeof(struct bttv_buffer), - fh); - videobuf_queue_sg_init(&fh->vbi, &bttv_vbi_qops, - &btv->c.pci->dev, &btv->s_lock, - V4L2_BUF_TYPE_VBI_CAPTURE, - V4L2_FIELD_SEQ_TB, - sizeof(struct bttv_buffer), - fh); + videobuf_queue_dma_contig_init(&fh->cap, &bttv_video_qops, + &btv->c.pci->dev, &btv->s_lock, + V4L2_BUF_TYPE_VIDEO_CAPTURE, + V4L2_FIELD_INTERLACED, + sizeof(struct bttv_buffer), + fh); + videobuf_queue_dma_contig_init(&fh->vbi, &bttv_vbi_qops, + &btv->c.pci->dev, &btv->s_lock, + V4L2_BUF_TYPE_VBI_CAPTURE, + V4L2_FIELD_SEQ_TB, + sizeof(struct bttv_buffer), + fh); set_tvnorm(btv,btv->tvnorm); set_input(btv, btv->input, btv->tvnorm); diff -r ee9826bc7106 linux/drivers/media/video/bt8xx/bttv-risc.c --- a/linux/drivers/media/video/bt8xx/bttv-risc.c Thu Apr 29 23:31:06 2010 -0300 +++ b/linux/drivers/media/video/bt8xx/bttv-risc.c Tue Aug 03 09:09:58 2010 -0400 @@ -582,12 +582,9 @@ void bttv_dma_free(struct videobuf_queue *q,struct bttv *btv, struct bttv_buffer *buf) { - struct videobuf_dmabuf *dma=videobuf_to_dma(&buf->vb); - BUG_ON(in_interrupt()); videobuf_waiton(&buf->vb,0,0); - videobuf_dma_unmap(q, dma); - videobuf_dma_free(dma); + videobuf_dma_contig_free(q, &buf->vb); btcx_riscmem_free(btv->c.pci,&buf->bottom); btcx_riscmem_free(btv->c.pci,&buf->top); buf->vb.state = VIDEOBUF_NEEDS_INIT; @@ -709,7 +706,16 @@ bttv_buffer_risc(struct bttv *btv, struct bttv_buffer *buf) { const struct bttv_tvnorm *tvnorm = bttv_tvnorms + buf->tvnorm; - struct videobuf_dmabuf *dma=videobuf_to_dma(&buf->vb); + struct videobuf_dma_contig_memory *dma = + videobuf_to_dma_contig_memory(&buf->vb); + struct scatterlist sglist; + + /* Create a one-entry scatter list for compatibility. */ + sglist.page = virt_to_page(dma->vaddr); + sglist.offset = 0; + sglist.length = dma->size; + sglist.dma_address = dma->dma_handle; + sglist.dma_length = dma->size; dprintk(KERN_DEBUG "bttv%d: buffer field: %s format: %s size: %dx%d\n", @@ -727,25 +733,25 @@ switch (buf->vb.field) { case V4L2_FIELD_TOP: - bttv_risc_packed(btv,&buf->top,dma->sglist, + bttv_risc_packed(btv,&buf->top,&sglist, /* offset */ 0,bpl, /* padding */ 0,/* skip_lines */ 0, buf->vb.height); break; case V4L2_FIELD_BOTTOM: - bttv_risc_packed(btv,&buf->bottom,dma->sglist, + bttv_risc_packed(btv,&buf->bottom,&sglist, 0,bpl,0,0,buf->vb.height); break; case V4L2_FIELD_INTERLACED: - bttv_risc_packed(btv,&buf->top,dma->sglist, + bttv_risc_packed(btv,&buf->top,&sglist, 0,bpl,bpl,0,buf->vb.height >> 1); - bttv_risc_packed(btv,&buf->bottom,dma->sglist, + bttv_risc_packed(btv,&buf->bottom,&sglist, bpl,bpl,bpl,0,buf->vb.height >> 1); break; case V4L2_FIELD_SEQ_TB: - bttv_risc_packed(btv,&buf->top,dma->sglist, + bttv_risc_packed(btv,&buf->top,&sglist, 0,bpl,0,0,buf->vb.height >> 1); - bttv_risc_packed(btv,&buf->bottom,dma->sglist, + bttv_risc_packed(btv,&buf->bottom,&sglist, bpf,bpl,0,0,buf->vb.height >> 1); break; default: @@ -778,7 +784,7 @@ bttv_calc_geo(btv,&buf->geo,buf->vb.width, buf->vb.height,/* both_fields */ 0, tvnorm,&buf->crop); - bttv_risc_planar(btv, &buf->top, dma->sglist, + bttv_risc_planar(btv, &buf->top, &sglist, 0,buf->vb.width,0,buf->vb.height, uoffset,voffset,buf->fmt->hshift, buf->fmt->vshift,0); @@ -787,7 +793,7 @@ bttv_calc_geo(btv,&buf->geo,buf->vb.width, buf->vb.height,0, tvnorm,&buf->crop); - bttv_risc_planar(btv, &buf->bottom, dma->sglist, + bttv_risc_planar(btv, &buf->bottom, &sglist, 0,buf->vb.width,0,buf->vb.height, uoffset,voffset,buf->fmt->hshift, buf->fmt->vshift,0); @@ -800,14 +806,14 @@ ypadding = buf->vb.width; cpadding = buf->vb.width >> buf->fmt->hshift; bttv_risc_planar(btv,&buf->top, - dma->sglist, + &sglist, 0,buf->vb.width,ypadding,lines, uoffset,voffset, buf->fmt->hshift, buf->fmt->vshift, cpadding); bttv_risc_planar(btv,&buf->bottom, - dma->sglist, + &sglist, ypadding,buf->vb.width,ypadding,lines, uoffset+cpadding, voffset+cpadding, @@ -823,7 +829,7 @@ ypadding = buf->vb.width; cpadding = buf->vb.width >> buf->fmt->hshift; bttv_risc_planar(btv,&buf->top, - dma->sglist, + &sglist, 0,buf->vb.width,0,lines, uoffset >> 1, voffset >> 1, @@ -831,7 +837,7 @@ buf->fmt->vshift, 0); bttv_risc_planar(btv,&buf->bottom, - dma->sglist, + &sglist, lines * ypadding,buf->vb.width,0,lines, lines * ypadding + (uoffset >> 1), lines * ypadding + (voffset >> 1), @@ -850,10 +856,10 @@ buf->vb.field = V4L2_FIELD_SEQ_TB; bttv_calc_geo(btv,&buf->geo,tvnorm->swidth,tvnorm->sheight, 1,tvnorm,&buf->crop); - bttv_risc_packed(btv, &buf->top, dma->sglist, + bttv_risc_packed(btv, &buf->top, &sglist, /* offset */ 0, RAW_BPL, /* padding */ 0, /* skip_lines */ 0, RAW_LINES); - bttv_risc_packed(btv, &buf->bottom, dma->sglist, + bttv_risc_packed(btv, &buf->bottom, &sglist, buf->vb.size/2 , RAW_BPL, 0, 0, RAW_LINES); } diff -r ee9826bc7106 linux/drivers/media/video/bt8xx/bttv-vbi.c --- a/linux/drivers/media/video/bt8xx/bttv-vbi.c Thu Apr 29 23:31:06 2010 -0300 +++ b/linux/drivers/media/video/bt8xx/bttv-vbi.c Tue Aug 03 09:09:58 2010 -0400 @@ -151,14 +151,23 @@ if (redo_dma_risc) { unsigned int bpl, padding, offset; - struct videobuf_dmabuf *dma=videobuf_to_dma(&buf->vb); + struct videobuf_dma_contig_memory *dma = + videobuf_to_dma_contig_memory(&buf->vb); + struct scatterlist sglist; + + /* Create a one-entry scatter list for compatibility. */ + sglist.page = virt_to_page(dma->vaddr); + sglist.offset = 0; + sglist.length = dma->size; + sglist.dma_address = dma->dma_handle; + sglist.dma_length = dma->size; bpl = 2044; /* max. vbipack */ padding = VBI_BPL - bpl; if (fh->vbi_fmt.fmt.count[0] > 0) { rc = bttv_risc_packed(btv, &buf->top, - dma->sglist, + &sglist, /* offset */ 0, bpl, padding, skip_lines0, fh->vbi_fmt.fmt.count[0]); @@ -170,7 +179,7 @@ offset = fh->vbi_fmt.fmt.count[0] * VBI_BPL; rc = bttv_risc_packed(btv, &buf->bottom, - dma->sglist, + &sglist, offset, bpl, padding, skip_lines1, fh->vbi_fmt.fmt.count[1]); diff -r ee9826bc7106 linux/drivers/media/video/bt8xx/bttvp.h --- a/linux/drivers/media/video/bt8xx/bttvp.h Thu Apr 29 23:31:06 2010 -0300 +++ b/linux/drivers/media/video/bt8xx/bttvp.h Tue Aug 03 09:09:58 2010 -0400 @@ -40,7 +40,7 @@ #include "compat.h" #include #include -#include +#include #include #include diff -r ee9826bc7106 linux/drivers/media/video/videobuf-dma-contig.c --- a/linux/drivers/media/video/videobuf-dma-contig.c Thu Apr 29 23:31:06 2010 -0300 +++ b/linux/drivers/media/video/videobuf-dma-contig.c Tue Aug 03 09:09:58 2010 -0400 @@ -23,14 +23,6 @@ #include #include "compat.h" -struct videobuf_dma_contig_memory { - u32 magic; - void *vaddr; - dma_addr_t dma_handle; - unsigned long size; - int is_userptr; -}; - #define MAGIC_DC_MEM 0x0733ac61 #define MAGIC_CHECK(is, should) \ if (unlikely((is) != (should))) { \ @@ -142,6 +134,10 @@ static int videobuf_dma_contig_user_get(struct videobuf_dma_contig_memory *mem, struct videobuf_buffer *vb) { +/* TODO: Find out equivalent of follow_pfn for kernel 2.6.18. */ +#if LINUX_VERSION_CODE <= KERNEL_VERSION(2, 6, 18) + return -EINVAL; +#else struct mm_struct *mm = current->mm; struct vm_area_struct *vma; unsigned long prev_pfn, this_pfn; @@ -192,6 +188,7 @@ up_read(¤t->mm->mmap_sem); return ret; +#endif } static void *__videobuf_alloc(size_t size) @@ -435,6 +432,33 @@ .vmalloc = __videobuf_to_vmalloc, }; +struct videobuf_dma_contig_memory * +videobuf_to_dma_contig_memory(struct videobuf_buffer *buf) +{ + struct videobuf_dma_contig_memory *mem = buf->priv; + BUG_ON(!mem); + + MAGIC_CHECK(mem->magic, MAGIC_DC_MEM); + + return mem; +} + +EXPORT_SYMBOL_GPL(videobuf_to_dma_contig_memory); + +/* This is a kludge to allocate memory without a queue object. */ +void *videobuf_contig_alloc(size_t size) +{ + struct videobuf_queue q; + + /* Required to make generic handler to call __videobuf_alloc */ + q.int_ops = &qops; + + q.msize = size; + + return videobuf_alloc(&q); +} +EXPORT_SYMBOL_GPL(videobuf_contig_alloc); + void videobuf_queue_dma_contig_init(struct videobuf_queue *q, const struct videobuf_queue_ops *ops, struct device *dev, diff -r ee9826bc7106 linux/include/media/videobuf-dma-contig.h --- a/linux/include/media/videobuf-dma-contig.h Thu Apr 29 23:31:06 2010 -0300 +++ b/linux/include/media/videobuf-dma-contig.h Tue Aug 03 09:09:58 2010 -0400 @@ -16,6 +16,17 @@ #include #include +struct videobuf_dma_contig_memory { + u32 magic; + void *vaddr; + dma_addr_t dma_handle; + unsigned long size; + int is_userptr; +}; + +struct videobuf_dma_contig_memory * +videobuf_to_dma_contig_memory(struct videobuf_buffer *buf); +void *videobuf_contig_alloc(size_t size); void videobuf_queue_dma_contig_init(struct videobuf_queue *q, const struct videobuf_queue_ops *ops, struct device *dev,