Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 211337
b: refs/heads/master
c: 2fc1153
h: refs/heads/master
i:
  211335: 78ec173
v: v3
  • Loading branch information
Hans Verkuil authored and Mauro Carvalho Chehab committed Sep 28, 2010
1 parent a519bd9 commit f998fe4
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: c10469c637602c2385e2993d8c730cc44fd47d23
refs/heads/master: 2fc11536cf5c0b8eb4eb7e01a2a672a189e9280f
11 changes: 7 additions & 4 deletions trunk/drivers/media/video/videobuf-dma-sg.c
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ static struct scatterlist *videobuf_vmalloc_to_sg(unsigned char *virt,
* must free the memory.
*/
static struct scatterlist *videobuf_pages_to_sg(struct page **pages,
int nr_pages, int offset)
int nr_pages, int offset, size_t size)
{
struct scatterlist *sglist;
int i;
Expand All @@ -110,12 +110,14 @@ static struct scatterlist *videobuf_pages_to_sg(struct page **pages,
/* DMA to highmem pages might not work */
goto highmem;
sg_set_page(&sglist[0], pages[0], PAGE_SIZE - offset, offset);
size -= PAGE_SIZE - offset;
for (i = 1; i < nr_pages; i++) {
if (NULL == pages[i])
goto nopage;
if (PageHighMem(pages[i]))
goto highmem;
sg_set_page(&sglist[i], pages[i], PAGE_SIZE, 0);
sg_set_page(&sglist[i], pages[i], min(PAGE_SIZE, size), 0);
size -= min(PAGE_SIZE, size);
}
return sglist;

Expand Down Expand Up @@ -170,7 +172,8 @@ static int videobuf_dma_init_user_locked(struct videobuf_dmabuf *dma,

first = (data & PAGE_MASK) >> PAGE_SHIFT;
last = ((data+size-1) & PAGE_MASK) >> PAGE_SHIFT;
dma->offset = data & ~PAGE_MASK;
dma->offset = data & ~PAGE_MASK;
dma->size = size;
dma->nr_pages = last-first+1;
dma->pages = kmalloc(dma->nr_pages * sizeof(struct page *), GFP_KERNEL);
if (NULL == dma->pages)
Expand Down Expand Up @@ -252,7 +255,7 @@ int videobuf_dma_map(struct device *dev, struct videobuf_dmabuf *dma)

if (dma->pages) {
dma->sglist = videobuf_pages_to_sg(dma->pages, dma->nr_pages,
dma->offset);
dma->offset, dma->size);
}
if (dma->vaddr) {
dma->sglist = videobuf_vmalloc_to_sg(dma->vaddr,
Expand Down
1 change: 1 addition & 0 deletions trunk/include/media/videobuf-dma-sg.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ struct videobuf_dmabuf {

/* for userland buffer */
int offset;
size_t size;
struct page **pages;

/* for kernel buffers */
Expand Down

0 comments on commit f998fe4

Please sign in to comment.