]>
Commit | Line | Data |
---|---|---|
7a7d9a89 | 1 | /* |
0705135e | 2 | * helper functions for SG DMA video4linux capture buffers |
7a7d9a89 | 3 | * |
5d6aaf50 | 4 | * The functions expect the hardware being able to scatter gather |
7a7d9a89 MCC |
5 | * (i.e. the buffers are not linear in physical memory, but fragmented |
6 | * into PAGE_SIZE chunks). They also assume the driver does not need | |
7 | * to touch the video data. | |
8 | * | |
9 | * (c) 2007 Mauro Carvalho Chehab, <[email protected]> | |
10 | * | |
11 | * Highly based on video-buf written originally by: | |
12 | * (c) 2001,02 Gerd Knorr <[email protected]> | |
13 | * (c) 2006 Mauro Carvalho Chehab, <[email protected]> | |
14 | * (c) 2006 Ted Walther and John Sokol | |
15 | * | |
16 | * This program is free software; you can redistribute it and/or modify | |
17 | * it under the terms of the GNU General Public License as published by | |
18 | * the Free Software Foundation; either version 2 | |
19 | */ | |
7a02264c PO |
20 | #ifndef _VIDEOBUF_DMA_SG_H |
21 | #define _VIDEOBUF_DMA_SG_H | |
7a7d9a89 MCC |
22 | |
23 | #include <media/videobuf-core.h> | |
24 | ||
25 | /* --------------------------------------------------------------------- */ | |
26 | ||
7a7d9a89 MCC |
27 | /* |
28 | * A small set of helper functions to manage buffers (both userland | |
29 | * and kernel) for DMA. | |
30 | * | |
31 | * videobuf_dma_init_*() | |
32 | * creates a buffer. The userland version takes a userspace | |
33 | * pointer + length. The kernel version just wants the size and | |
34 | * does memory allocation too using vmalloc_32(). | |
35 | * | |
36 | * videobuf_dma_*() | |
395cf969 | 37 | * see Documentation/DMA-API-HOWTO.txt, these functions to |
7a7d9a89 MCC |
38 | * basically the same. The map function does also build a |
39 | * scatterlist for the buffer (and unmap frees it ...) | |
40 | * | |
41 | * videobuf_dma_free() | |
42 | * no comment ... | |
43 | * | |
44 | */ | |
45 | ||
46 | struct videobuf_dmabuf { | |
47 | u32 magic; | |
48 | ||
49 | /* for userland buffer */ | |
50 | int offset; | |
2fc11536 | 51 | size_t size; |
7a7d9a89 MCC |
52 | struct page **pages; |
53 | ||
54 | /* for kernel buffers */ | |
bb6dbe74 | 55 | void *vaddr; |
7b4eeed1 JH |
56 | struct page **vaddr_pages; |
57 | dma_addr_t *dma_addr; | |
58 | struct device *dev; | |
7a7d9a89 | 59 | |
7a7d9a89 MCC |
60 | /* for overlay buffers (pci-pci dma) */ |
61 | dma_addr_t bus_addr; | |
62 | ||
63 | /* common */ | |
64 | struct scatterlist *sglist; | |
65 | int sglen; | |
66 | int nr_pages; | |
67 | int direction; | |
68 | }; | |
69 | ||
7a02264c | 70 | struct videobuf_dma_sg_memory { |
7a7d9a89 MCC |
71 | u32 magic; |
72 | ||
73 | /* for mmap'ed buffers */ | |
7a7d9a89 MCC |
74 | struct videobuf_dmabuf dma; |
75 | }; | |
76 | ||
95268403 LP |
77 | /* |
78 | * Scatter-gather DMA buffer API. | |
79 | * | |
80 | * These functions provide a simple way to create a page list and a | |
81 | * scatter-gather list from a kernel, userspace of physical address and map the | |
82 | * memory for DMA operation. | |
83 | * | |
84 | * Despite the name, this is totally unrelated to videobuf, except that | |
85 | * videobuf-dma-sg uses the same API internally. | |
86 | */ | |
7a7d9a89 MCC |
87 | int videobuf_dma_free(struct videobuf_dmabuf *dma); |
88 | ||
95268403 | 89 | int videobuf_dma_unmap(struct device *dev, struct videobuf_dmabuf *dma); |
7a02264c | 90 | struct videobuf_dmabuf *videobuf_to_dma(struct videobuf_buffer *buf); |
7a7d9a89 | 91 | |
0705135e | 92 | void *videobuf_sg_alloc(size_t size); |
7a7d9a89 | 93 | |
7a02264c | 94 | void videobuf_queue_sg_init(struct videobuf_queue *q, |
38a54f35 | 95 | const struct videobuf_queue_ops *ops, |
0705135e | 96 | struct device *dev, |
7a7d9a89 MCC |
97 | spinlock_t *irqlock, |
98 | enum v4l2_buf_type type, | |
99 | enum v4l2_field field, | |
100 | unsigned int msize, | |
08bff03e HV |
101 | void *priv, |
102 | struct mutex *ext_lock); | |
7a7d9a89 | 103 | |
7a02264c PO |
104 | #endif /* _VIDEOBUF_DMA_SG_H */ |
105 |