diff options
author | Mauro Carvalho Chehab <mchehab@infradead.org> | 2006-03-10 10:29:15 -0500 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@infradead.org> | 2006-03-24 14:26:49 -0500 |
commit | c7b0ac0546985fc6361a8d92cf808d46da797677 (patch) | |
tree | 2147eb2f6dd7b2b82e0d7b4b9a26e12ef5193252 /include/media/video-buf.h | |
parent | b2fd16b4ff2508ac16ae994f4bcd941f97754c00 (diff) |
V4L/DVB (3516): Make video_buf more generic
Video_buf were concerned to allow PCI devices to be used as
video capture devices. This patch extends video_buf features
by virtualizing pci-dependent functions and allowing other
type of devices to use it.
It is still DMA centric, although it may be used also by
devices that emulates scatter/gather behavior or a DMA device
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
Diffstat (limited to 'include/media/video-buf.h')
-rw-r--r-- | include/media/video-buf.h | 56 |
1 files changed, 41 insertions, 15 deletions
diff --git a/include/media/video-buf.h b/include/media/video-buf.h index d90dec5484ee..fff3fd0fbf94 100644 --- a/include/media/video-buf.h +++ b/include/media/video-buf.h | |||
@@ -1,15 +1,20 @@ | |||
1 | /* | 1 | /* |
2 | * | 2 | * |
3 | * generic helper functions for video4linux capture buffers, to handle | 3 | * generic helper functions for video4linux capture buffers, to handle |
4 | * memory management and PCI DMA. Right now bttv + saa7134 use it. | 4 | * memory management and PCI DMA. |
5 | * Right now, bttv, saa7134, saa7146 and cx88 use it. | ||
5 | * | 6 | * |
6 | * The functions expect the hardware being able to scatter gatter | 7 | * The functions expect the hardware being able to scatter gatter |
7 | * (i.e. the buffers are not linear in physical memory, but fragmented | 8 | * (i.e. the buffers are not linear in physical memory, but fragmented |
8 | * into PAGE_SIZE chunks). They also assume the driver does not need | 9 | * into PAGE_SIZE chunks). They also assume the driver does not need |
9 | * to touch the video data (thus it is probably not useful for USB as | 10 | * to touch the video data. |
10 | * data often must be uncompressed by the drivers). | 11 | * |
12 | * device specific map/unmap/sync stuff now are mapped as file operations | ||
13 | * to allow its usage by USB and virtual devices. | ||
11 | * | 14 | * |
12 | * (c) 2001,02 Gerd Knorr <kraxel@bytesex.org> | 15 | * (c) 2001,02 Gerd Knorr <kraxel@bytesex.org> |
16 | * (c) 2006 Mauro Carvalho Chehab, <mchehab@infradead.org> | ||
17 | * (c) 2006 Ted Walther and John Sokol | ||
13 | * | 18 | * |
14 | * This program is free software; you can redistribute it and/or modify | 19 | * This program is free software; you can redistribute it and/or modify |
15 | * it under the terms of the GNU General Public License as published by | 20 | * it under the terms of the GNU General Public License as published by |
@@ -38,6 +43,9 @@ struct scatterlist* videobuf_vmalloc_to_sg(unsigned char *virt, int nr_pages); | |||
38 | struct scatterlist* videobuf_pages_to_sg(struct page **pages, int nr_pages, | 43 | struct scatterlist* videobuf_pages_to_sg(struct page **pages, int nr_pages, |
39 | int offset); | 44 | int offset); |
40 | 45 | ||
46 | struct videobuf_buffer; | ||
47 | struct videobuf_queue; | ||
48 | |||
41 | /* --------------------------------------------------------------------- */ | 49 | /* --------------------------------------------------------------------- */ |
42 | 50 | ||
43 | /* | 51 | /* |
@@ -49,7 +57,7 @@ struct scatterlist* videobuf_pages_to_sg(struct page **pages, int nr_pages, | |||
49 | * pointer + length. The kernel version just wants the size and | 57 | * pointer + length. The kernel version just wants the size and |
50 | * does memory allocation too using vmalloc_32(). | 58 | * does memory allocation too using vmalloc_32(). |
51 | * | 59 | * |
52 | * videobuf_dma_pci_*() | 60 | * videobuf_dma_*() |
53 | * see Documentation/DMA-mapping.txt, these functions to | 61 | * see Documentation/DMA-mapping.txt, these functions to |
54 | * basically the same. The map function does also build a | 62 | * basically the same. The map function does also build a |
55 | * scatterlist for the buffer (and unmap frees it ...) | 63 | * scatterlist for the buffer (and unmap frees it ...) |
@@ -86,12 +94,18 @@ int videobuf_dma_init_kernel(struct videobuf_dmabuf *dma, int direction, | |||
86 | int nr_pages); | 94 | int nr_pages); |
87 | int videobuf_dma_init_overlay(struct videobuf_dmabuf *dma, int direction, | 95 | int videobuf_dma_init_overlay(struct videobuf_dmabuf *dma, int direction, |
88 | dma_addr_t addr, int nr_pages); | 96 | dma_addr_t addr, int nr_pages); |
89 | int videobuf_dma_pci_map(struct pci_dev *dev, struct videobuf_dmabuf *dma); | ||
90 | int videobuf_dma_pci_sync(struct pci_dev *dev, | ||
91 | struct videobuf_dmabuf *dma); | ||
92 | int videobuf_dma_pci_unmap(struct pci_dev *dev, struct videobuf_dmabuf *dma); | ||
93 | int videobuf_dma_free(struct videobuf_dmabuf *dma); | 97 | int videobuf_dma_free(struct videobuf_dmabuf *dma); |
94 | 98 | ||
99 | int videobuf_dma_map(struct videobuf_queue* q,struct videobuf_dmabuf *dma); | ||
100 | int videobuf_dma_sync(struct videobuf_queue* q,struct videobuf_dmabuf *dma); | ||
101 | int videobuf_dma_unmap(struct videobuf_queue* q,struct videobuf_dmabuf *dma); | ||
102 | |||
103 | /*FIXME: these variants are used only on *-alsa code, where videobuf is | ||
104 | * used without queue | ||
105 | */ | ||
106 | int videobuf_pci_dma_map(struct pci_dev *pci,struct videobuf_dmabuf *dma); | ||
107 | int videobuf_pci_dma_unmap(struct pci_dev *pci,struct videobuf_dmabuf *dma); | ||
108 | |||
95 | /* --------------------------------------------------------------------- */ | 109 | /* --------------------------------------------------------------------- */ |
96 | 110 | ||
97 | /* | 111 | /* |
@@ -115,9 +129,6 @@ int videobuf_dma_free(struct videobuf_dmabuf *dma); | |||
115 | * | 129 | * |
116 | */ | 130 | */ |
117 | 131 | ||
118 | struct videobuf_buffer; | ||
119 | struct videobuf_queue; | ||
120 | |||
121 | struct videobuf_mapping { | 132 | struct videobuf_mapping { |
122 | unsigned int count; | 133 | unsigned int count; |
123 | unsigned long start; | 134 | unsigned long start; |
@@ -164,6 +175,10 @@ struct videobuf_buffer { | |||
164 | struct timeval ts; | 175 | struct timeval ts; |
165 | }; | 176 | }; |
166 | 177 | ||
178 | typedef int (vb_map_sg_t)(void *dev,struct scatterlist *sglist,int nr_pages, | ||
179 | int direction); | ||
180 | |||
181 | |||
167 | struct videobuf_queue_ops { | 182 | struct videobuf_queue_ops { |
168 | int (*buf_setup)(struct videobuf_queue *q, | 183 | int (*buf_setup)(struct videobuf_queue *q, |
169 | unsigned int *count, unsigned int *size); | 184 | unsigned int *count, unsigned int *size); |
@@ -174,12 +189,20 @@ struct videobuf_queue_ops { | |||
174 | struct videobuf_buffer *vb); | 189 | struct videobuf_buffer *vb); |
175 | void (*buf_release)(struct videobuf_queue *q, | 190 | void (*buf_release)(struct videobuf_queue *q, |
176 | struct videobuf_buffer *vb); | 191 | struct videobuf_buffer *vb); |
192 | |||
193 | /* Helper operations - device dependent. | ||
194 | * If null, videobuf_init defaults all to PCI handling | ||
195 | */ | ||
196 | |||
197 | vb_map_sg_t *vb_map_sg; | ||
198 | vb_map_sg_t *vb_dma_sync_sg; | ||
199 | vb_map_sg_t *vb_unmap_sg; | ||
177 | }; | 200 | }; |
178 | 201 | ||
179 | struct videobuf_queue { | 202 | struct videobuf_queue { |
180 | struct mutex lock; | 203 | struct mutex lock; |
181 | spinlock_t *irqlock; | 204 | spinlock_t *irqlock; |
182 | struct pci_dev *pci; | 205 | void *dev; /* on pci, points to struct pci_dev */ |
183 | 206 | ||
184 | enum v4l2_buf_type type; | 207 | enum v4l2_buf_type type; |
185 | unsigned int inputs; /* for V4L2_BUF_FLAG_INPUT */ | 208 | unsigned int inputs; /* for V4L2_BUF_FLAG_INPUT */ |
@@ -204,12 +227,15 @@ struct videobuf_queue { | |||
204 | 227 | ||
205 | void* videobuf_alloc(unsigned int size); | 228 | void* videobuf_alloc(unsigned int size); |
206 | int videobuf_waiton(struct videobuf_buffer *vb, int non_blocking, int intr); | 229 | int videobuf_waiton(struct videobuf_buffer *vb, int non_blocking, int intr); |
207 | int videobuf_iolock(struct pci_dev *pci, struct videobuf_buffer *vb, | 230 | int videobuf_iolock(struct videobuf_queue* q, struct videobuf_buffer *vb, |
208 | struct v4l2_framebuffer *fbuf); | 231 | struct v4l2_framebuffer *fbuf); |
232 | |||
233 | /* Maps fops to PCI stuff */ | ||
234 | void videobuf_queue_pci(struct videobuf_queue* q); | ||
209 | 235 | ||
210 | void videobuf_queue_init(struct videobuf_queue *q, | 236 | void videobuf_queue_init(struct videobuf_queue *q, |
211 | struct videobuf_queue_ops *ops, | 237 | struct videobuf_queue_ops *ops, |
212 | struct pci_dev *pci, | 238 | void *dev, |
213 | spinlock_t *irqlock, | 239 | spinlock_t *irqlock, |
214 | enum v4l2_buf_type type, | 240 | enum v4l2_buf_type type, |
215 | enum v4l2_field field, | 241 | enum v4l2_field field, |