提交 717f4a5f 编写于 作者: M Marin Mitov 提交者: Greg Kroah-Hartman

staging: dt3155v4l syncronize with API changes

dt3155v4l driver, as in -rc6-next-20100506 compiles, but will
not run properly due to recent changes in the videobuf APIs.

This patch synchronizes some functions that have been copied
from drivers/media/video/videobuf-dma-contig.c (and modified)
with the recent (-rc6 -> -rc6-next-) changes in videobuf layer
especially drivers/media/video/videobuf-dma-contig.c
Signed-off-by: NMarin Mitov <mitov@issp.bas.bg>
Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
上级 0cbd8d98
/***************************************************************************
* Copyright (C) 2006-2010 by Marin Mitov *
* mitov@issp.bas.bg *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
#include <media/v4l2-dev.h> #include <media/v4l2-dev.h>
#include <media/videobuf-core.h> #include <media/videobuf-core.h>
#include <media/v4l2-ioctl.h> #include <media/v4l2-ioctl.h>
...@@ -260,9 +280,11 @@ dt3155_dma_contig_user_get(struct videobuf_dma_contig_memory *mem, ...@@ -260,9 +280,11 @@ dt3155_dma_contig_user_get(struct videobuf_dma_contig_memory *mem,
struct vm_area_struct *vma; struct vm_area_struct *vma;
unsigned long prev_pfn, this_pfn; unsigned long prev_pfn, this_pfn;
unsigned long pages_done, user_address; unsigned long pages_done, user_address;
unsigned int offset;
int ret; int ret;
mem->size = PAGE_ALIGN(vb->size); offset = vb->baddr & ~PAGE_MASK;
mem->size = PAGE_ALIGN(vb->size + offset);
mem->is_userptr = 0; mem->is_userptr = 0;
ret = -EINVAL; ret = -EINVAL;
...@@ -285,7 +307,7 @@ dt3155_dma_contig_user_get(struct videobuf_dma_contig_memory *mem, ...@@ -285,7 +307,7 @@ dt3155_dma_contig_user_get(struct videobuf_dma_contig_memory *mem,
break; break;
if (pages_done == 0) if (pages_done == 0)
mem->dma_handle = this_pfn << PAGE_SHIFT; mem->dma_handle = (this_pfn << PAGE_SHIFT) + offset;
else if (this_pfn != (prev_pfn + 1)) else if (this_pfn != (prev_pfn + 1))
ret = -EFAULT; ret = -EFAULT;
...@@ -416,14 +438,14 @@ dt3155_vm_close(struct vm_area_struct *vma) ...@@ -416,14 +438,14 @@ dt3155_vm_close(struct vm_area_struct *vma)
struct videobuf_queue *q = map->q; struct videobuf_queue *q = map->q;
int i; int i;
dev_dbg(map->q->dev, "vm_close %p [count=%u,vma=%08lx-%08lx]\n", dev_dbg(q->dev, "vm_close %p [count=%u,vma=%08lx-%08lx]\n",
map, map->count, vma->vm_start, vma->vm_end); map, map->count, vma->vm_start, vma->vm_end);
map->count--; map->count--;
if (0 == map->count) { if (0 == map->count) {
struct videobuf_dma_contig_memory *mem; struct videobuf_dma_contig_memory *mem;
dev_dbg(map->q->dev, "munmap %p q=%p\n", map, q); dev_dbg(q->dev, "munmap %p q=%p\n", map, q);
mutex_lock(&q->vb_lock); mutex_lock(&q->vb_lock);
/* We need first to cancel streams, before unmapping */ /* We need first to cancel streams, before unmapping */
...@@ -450,7 +472,7 @@ dt3155_vm_close(struct vm_area_struct *vma) ...@@ -450,7 +472,7 @@ dt3155_vm_close(struct vm_area_struct *vma)
/* vfree is not atomic - can't be /* vfree is not atomic - can't be
called with IRQ's disabled called with IRQ's disabled
*/ */
dev_dbg(map->q->dev, "buf[%d] freeing %p\n", dev_dbg(q->dev, "buf[%d] freeing %p\n",
i, mem->vaddr); i, mem->vaddr);
dt3155_free_buffer(q->dev, mem->size, dt3155_free_buffer(q->dev, mem->size,
...@@ -475,51 +497,33 @@ static const struct vm_operations_struct dt3155_vm_ops = { ...@@ -475,51 +497,33 @@ static const struct vm_operations_struct dt3155_vm_ops = {
/* same as videobuf_mmap_mapper(), but allocates from the pool */ /* same as videobuf_mmap_mapper(), but allocates from the pool */
static int static int
dt3155_mmap_mapper(struct videobuf_queue *q, struct vm_area_struct *vma) dt3155_mmap_mapper(struct videobuf_queue *q, struct videobuf_buffer *buf,
struct vm_area_struct *vma)
{ {
struct videobuf_dma_contig_memory *mem; struct videobuf_dma_contig_memory *mem;
struct videobuf_mapping *map; struct videobuf_mapping *map;
unsigned int first;
int retval; int retval;
unsigned long size, offset = vma->vm_pgoff << PAGE_SHIFT; unsigned long size;
dev_dbg(q->dev, "%s\n", __func__); dev_dbg(q->dev, "%s\n", __func__);
if (!(vma->vm_flags & VM_WRITE) || !(vma->vm_flags & VM_SHARED))
return -EINVAL;
/* look for first buffer to map */
for (first = 0; first < VIDEO_MAX_FRAME; first++) {
if (!q->bufs[first])
continue;
if (V4L2_MEMORY_MMAP != q->bufs[first]->memory)
continue;
if (q->bufs[first]->boff == offset)
break;
}
if (VIDEO_MAX_FRAME == first) {
dev_dbg(q->dev, "invalid user space offset [offset=0x%lx]\n",
offset);
return -EINVAL;
}
/* create mapping + update buffer list */ /* create mapping + update buffer list */
map = kzalloc(sizeof(struct videobuf_mapping), GFP_KERNEL); map = kzalloc(sizeof(struct videobuf_mapping), GFP_KERNEL);
if (!map) if (!map)
return -ENOMEM; return -ENOMEM;
q->bufs[first]->map = map; buf->map = map;
map->start = vma->vm_start; map->start = vma->vm_start;
map->end = vma->vm_end; map->end = vma->vm_end;
map->q = q; map->q = q;
q->bufs[first]->baddr = vma->vm_start; buf->baddr = vma->vm_start;
mem = q->bufs[first]->priv; mem = buf->priv;
BUG_ON(!mem); BUG_ON(!mem);
MAGIC_CHECK(mem->magic, MAGIC_DC_MEM); MAGIC_CHECK(mem->magic, MAGIC_DC_MEM);
mem->size = PAGE_ALIGN(q->bufs[first]->bsize); mem->size = PAGE_ALIGN(buf->bsize);
mem->vaddr = dt3155_alloc_buffer(q->dev, mem->size, mem->vaddr = dt3155_alloc_buffer(q->dev, mem->size,
&mem->dma_handle, GFP_KERNEL); &mem->dma_handle, GFP_KERNEL);
if (!mem->vaddr) { if (!mem->vaddr) {
...@@ -552,8 +556,8 @@ dt3155_mmap_mapper(struct videobuf_queue *q, struct vm_area_struct *vma) ...@@ -552,8 +556,8 @@ dt3155_mmap_mapper(struct videobuf_queue *q, struct vm_area_struct *vma)
dev_dbg(q->dev, "mmap %p: q=%p %08lx-%08lx (%lx) pgoff %08lx buf %d\n", dev_dbg(q->dev, "mmap %p: q=%p %08lx-%08lx (%lx) pgoff %08lx buf %d\n",
map, q, vma->vm_start, vma->vm_end, map, q, vma->vm_start, vma->vm_end,
(long int) q->bufs[first]->bsize, (long int)buf->bsize,
vma->vm_pgoff, first); vma->vm_pgoff, buf->i);
dt3155_vm_open(vma); dt3155_vm_open(vma);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册