Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 1 | /* |
| 2 | * generic helper functions for handling video4linux capture buffers |
| 3 | * |
| 4 | * (c) 2007 Mauro Carvalho Chehab, <mchehab@infradead.org> |
| 5 | * |
| 6 | * Highly based on video-buf written originally by: |
| 7 | * (c) 2001,02 Gerd Knorr <kraxel@bytesex.org> |
| 8 | * (c) 2006 Mauro Carvalho Chehab, <mchehab@infradead.org> |
| 9 | * (c) 2006 Ted Walther and John Sokol |
| 10 | * |
| 11 | * This program is free software; you can redistribute it and/or modify |
| 12 | * it under the terms of the GNU General Public License as published by |
| 13 | * the Free Software Foundation; either version 2 |
| 14 | */ |
| 15 | |
| 16 | #include <linux/init.h> |
| 17 | #include <linux/module.h> |
| 18 | #include <linux/moduleparam.h> |
Andrea Righi | 27ac792 | 2008-07-23 21:28:13 -0700 | [diff] [blame] | 19 | #include <linux/mm.h> |
Alexey Dobriyan | d43c36d | 2009-10-07 17:09:06 +0400 | [diff] [blame] | 20 | #include <linux/sched.h> |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 21 | #include <linux/slab.h> |
| 22 | #include <linux/interrupt.h> |
| 23 | |
| 24 | #include <media/videobuf-core.h> |
| 25 | |
| 26 | #define MAGIC_BUFFER 0x20070728 |
Mauro Carvalho Chehab | e2c7731 | 2007-12-10 10:53:20 -0300 | [diff] [blame] | 27 | #define MAGIC_CHECK(is, should) do { \ |
| 28 | if (unlikely((is) != (should))) { \ |
| 29 | printk(KERN_ERR "magic mismatch: %x (expected %x)\n", is, should); \ |
| 30 | BUG(); } } while (0) |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 31 | |
Mauro Carvalho Chehab | e2c7731 | 2007-12-10 10:53:20 -0300 | [diff] [blame] | 32 | static int debug; |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 33 | module_param(debug, int, 0644); |
| 34 | |
| 35 | MODULE_DESCRIPTION("helper module to manage video4linux buffers"); |
| 36 | MODULE_AUTHOR("Mauro Carvalho Chehab <mchehab@infradead.org>"); |
| 37 | MODULE_LICENSE("GPL"); |
| 38 | |
Mauro Carvalho Chehab | e2c7731 | 2007-12-10 10:53:20 -0300 | [diff] [blame] | 39 | #define dprintk(level, fmt, arg...) do { \ |
| 40 | if (debug >= level) \ |
| 41 | printk(KERN_DEBUG "vbuf: " fmt , ## arg); } while (0) |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 42 | |
| 43 | /* --------------------------------------------------------------------- */ |
| 44 | |
| 45 | #define CALL(q, f, arg...) \ |
Mauro Carvalho Chehab | e2c7731 | 2007-12-10 10:53:20 -0300 | [diff] [blame] | 46 | ((q->int_ops->f) ? q->int_ops->f(arg) : 0) |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 47 | |
Mauro Carvalho Chehab | e2c7731 | 2007-12-10 10:53:20 -0300 | [diff] [blame] | 48 | void *videobuf_alloc(struct videobuf_queue *q) |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 49 | { |
| 50 | struct videobuf_buffer *vb; |
| 51 | |
Mauro Carvalho Chehab | e2c7731 | 2007-12-10 10:53:20 -0300 | [diff] [blame] | 52 | BUG_ON(q->msize < sizeof(*vb)); |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 53 | |
| 54 | if (!q->int_ops || !q->int_ops->alloc) { |
| 55 | printk(KERN_ERR "No specific ops defined!\n"); |
| 56 | BUG(); |
| 57 | } |
| 58 | |
| 59 | vb = q->int_ops->alloc(q->msize); |
| 60 | |
| 61 | if (NULL != vb) { |
| 62 | init_waitqueue_head(&vb->done); |
| 63 | vb->magic = MAGIC_BUFFER; |
| 64 | } |
| 65 | |
| 66 | return vb; |
| 67 | } |
| 68 | |
Brandon Philips | 009a905 | 2008-04-02 18:10:59 -0300 | [diff] [blame] | 69 | #define WAITON_CONDITION (vb->state != VIDEOBUF_ACTIVE &&\ |
| 70 | vb->state != VIDEOBUF_QUEUED) |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 71 | int videobuf_waiton(struct videobuf_buffer *vb, int non_blocking, int intr) |
| 72 | { |
Mauro Carvalho Chehab | e2c7731 | 2007-12-10 10:53:20 -0300 | [diff] [blame] | 73 | MAGIC_CHECK(vb->magic, MAGIC_BUFFER); |
Brandon Philips | 009a905 | 2008-04-02 18:10:59 -0300 | [diff] [blame] | 74 | |
| 75 | if (non_blocking) { |
| 76 | if (WAITON_CONDITION) |
| 77 | return 0; |
| 78 | else |
| 79 | return -EAGAIN; |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 80 | } |
Brandon Philips | 009a905 | 2008-04-02 18:10:59 -0300 | [diff] [blame] | 81 | |
| 82 | if (intr) |
| 83 | return wait_event_interruptible(vb->done, WAITON_CONDITION); |
| 84 | else |
| 85 | wait_event(vb->done, WAITON_CONDITION); |
| 86 | |
| 87 | return 0; |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 88 | } |
| 89 | |
Mauro Carvalho Chehab | e2c7731 | 2007-12-10 10:53:20 -0300 | [diff] [blame] | 90 | int videobuf_iolock(struct videobuf_queue *q, struct videobuf_buffer *vb, |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 91 | struct v4l2_framebuffer *fbuf) |
| 92 | { |
Mauro Carvalho Chehab | e2c7731 | 2007-12-10 10:53:20 -0300 | [diff] [blame] | 93 | MAGIC_CHECK(vb->magic, MAGIC_BUFFER); |
| 94 | MAGIC_CHECK(q->int_ops->magic, MAGIC_QTYPE_OPS); |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 95 | |
Mauro Carvalho Chehab | e2c7731 | 2007-12-10 10:53:20 -0300 | [diff] [blame] | 96 | return CALL(q, iolock, q, vb, fbuf); |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 97 | } |
| 98 | |
Mauro Carvalho Chehab | 59d3448 | 2008-04-13 15:10:00 -0300 | [diff] [blame] | 99 | void *videobuf_queue_to_vmalloc (struct videobuf_queue *q, |
| 100 | struct videobuf_buffer *buf) |
| 101 | { |
Harvey Harrison | a6a3a17 | 2008-04-28 16:50:03 -0700 | [diff] [blame] | 102 | if (q->int_ops->vmalloc) |
| 103 | return q->int_ops->vmalloc(buf); |
| 104 | else |
| 105 | return NULL; |
Mauro Carvalho Chehab | 59d3448 | 2008-04-13 15:10:00 -0300 | [diff] [blame] | 106 | } |
| 107 | EXPORT_SYMBOL_GPL(videobuf_queue_to_vmalloc); |
| 108 | |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 109 | /* --------------------------------------------------------------------- */ |
| 110 | |
| 111 | |
Mauro Carvalho Chehab | e2c7731 | 2007-12-10 10:53:20 -0300 | [diff] [blame] | 112 | void videobuf_queue_core_init(struct videobuf_queue *q, |
Jonathan Corbet | 38a54f3 | 2009-11-17 19:43:41 -0300 | [diff] [blame^] | 113 | const struct videobuf_queue_ops *ops, |
Guennadi Liakhovetski | e9bcf66 | 2008-04-22 14:46:02 -0300 | [diff] [blame] | 114 | struct device *dev, |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 115 | spinlock_t *irqlock, |
| 116 | enum v4l2_buf_type type, |
| 117 | enum v4l2_field field, |
| 118 | unsigned int msize, |
Mauro Carvalho Chehab | d4cae5a | 2007-10-08 12:20:02 -0300 | [diff] [blame] | 119 | void *priv, |
| 120 | struct videobuf_qtype_ops *int_ops) |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 121 | { |
Figo.zhang | 96ceea2 | 2009-06-02 23:01:04 -0300 | [diff] [blame] | 122 | BUG_ON(!q); |
Mauro Carvalho Chehab | e2c7731 | 2007-12-10 10:53:20 -0300 | [diff] [blame] | 123 | memset(q, 0, sizeof(*q)); |
Mauro Carvalho Chehab | d4cae5a | 2007-10-08 12:20:02 -0300 | [diff] [blame] | 124 | q->irqlock = irqlock; |
| 125 | q->dev = dev; |
| 126 | q->type = type; |
| 127 | q->field = field; |
| 128 | q->msize = msize; |
| 129 | q->ops = ops; |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 130 | q->priv_data = priv; |
Mauro Carvalho Chehab | d4cae5a | 2007-10-08 12:20:02 -0300 | [diff] [blame] | 131 | q->int_ops = int_ops; |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 132 | |
| 133 | /* All buffer operations are mandatory */ |
Mauro Carvalho Chehab | e2c7731 | 2007-12-10 10:53:20 -0300 | [diff] [blame] | 134 | BUG_ON(!q->ops->buf_setup); |
| 135 | BUG_ON(!q->ops->buf_prepare); |
| 136 | BUG_ON(!q->ops->buf_queue); |
| 137 | BUG_ON(!q->ops->buf_release); |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 138 | |
Brandon Philips | 0cf4dae | 2008-03-28 10:18:33 -0700 | [diff] [blame] | 139 | /* Lock is mandatory for queue_cancel to work */ |
| 140 | BUG_ON(!irqlock); |
| 141 | |
Mauro Carvalho Chehab | d4cae5a | 2007-10-08 12:20:02 -0300 | [diff] [blame] | 142 | /* Having implementations for abstract methods are mandatory */ |
Mauro Carvalho Chehab | e2c7731 | 2007-12-10 10:53:20 -0300 | [diff] [blame] | 143 | BUG_ON(!q->int_ops); |
Mauro Carvalho Chehab | d4cae5a | 2007-10-08 12:20:02 -0300 | [diff] [blame] | 144 | |
Mauro Carvalho Chehab | 64f9477 | 2008-01-31 13:57:53 -0300 | [diff] [blame] | 145 | mutex_init(&q->vb_lock); |
Brandon Philips | 137d1cb | 2008-04-02 18:10:59 -0300 | [diff] [blame] | 146 | init_waitqueue_head(&q->wait); |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 147 | INIT_LIST_HEAD(&q->stream); |
| 148 | } |
| 149 | |
Brandon Philips | 19bc513 | 2007-11-13 20:05:38 -0300 | [diff] [blame] | 150 | /* Locking: Only usage in bttv unsafe find way to remove */ |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 151 | int videobuf_queue_is_busy(struct videobuf_queue *q) |
| 152 | { |
| 153 | int i; |
| 154 | |
Mauro Carvalho Chehab | e2c7731 | 2007-12-10 10:53:20 -0300 | [diff] [blame] | 155 | MAGIC_CHECK(q->int_ops->magic, MAGIC_QTYPE_OPS); |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 156 | |
| 157 | if (q->streaming) { |
Mauro Carvalho Chehab | e2c7731 | 2007-12-10 10:53:20 -0300 | [diff] [blame] | 158 | dprintk(1, "busy: streaming active\n"); |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 159 | return 1; |
| 160 | } |
| 161 | if (q->reading) { |
Mauro Carvalho Chehab | e2c7731 | 2007-12-10 10:53:20 -0300 | [diff] [blame] | 162 | dprintk(1, "busy: pending read #1\n"); |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 163 | return 1; |
| 164 | } |
| 165 | if (q->read_buf) { |
Mauro Carvalho Chehab | e2c7731 | 2007-12-10 10:53:20 -0300 | [diff] [blame] | 166 | dprintk(1, "busy: pending read #2\n"); |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 167 | return 1; |
| 168 | } |
| 169 | for (i = 0; i < VIDEO_MAX_FRAME; i++) { |
| 170 | if (NULL == q->bufs[i]) |
| 171 | continue; |
Mauro Carvalho Chehab | 851c0c9 | 2007-09-27 18:25:44 -0300 | [diff] [blame] | 172 | if (q->bufs[i]->map) { |
Mauro Carvalho Chehab | e2c7731 | 2007-12-10 10:53:20 -0300 | [diff] [blame] | 173 | dprintk(1, "busy: buffer #%d mapped\n", i); |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 174 | return 1; |
| 175 | } |
Brandon Philips | 0fc0686 | 2007-11-06 20:02:36 -0300 | [diff] [blame] | 176 | if (q->bufs[i]->state == VIDEOBUF_QUEUED) { |
Mauro Carvalho Chehab | e2c7731 | 2007-12-10 10:53:20 -0300 | [diff] [blame] | 177 | dprintk(1, "busy: buffer #%d queued\n", i); |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 178 | return 1; |
| 179 | } |
Brandon Philips | 0fc0686 | 2007-11-06 20:02:36 -0300 | [diff] [blame] | 180 | if (q->bufs[i]->state == VIDEOBUF_ACTIVE) { |
Mauro Carvalho Chehab | e2c7731 | 2007-12-10 10:53:20 -0300 | [diff] [blame] | 181 | dprintk(1, "busy: buffer #%d avtive\n", i); |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 182 | return 1; |
| 183 | } |
| 184 | } |
| 185 | return 0; |
| 186 | } |
| 187 | |
Mauro Carvalho Chehab | 64f9477 | 2008-01-31 13:57:53 -0300 | [diff] [blame] | 188 | /* Locking: Caller holds q->vb_lock */ |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 189 | void videobuf_queue_cancel(struct videobuf_queue *q) |
| 190 | { |
Mauro Carvalho Chehab | e2c7731 | 2007-12-10 10:53:20 -0300 | [diff] [blame] | 191 | unsigned long flags = 0; |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 192 | int i; |
| 193 | |
Brandon Philips | 137d1cb | 2008-04-02 18:10:59 -0300 | [diff] [blame] | 194 | q->streaming = 0; |
| 195 | q->reading = 0; |
| 196 | wake_up_interruptible_sync(&q->wait); |
| 197 | |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 198 | /* remove queued buffers from list */ |
Brandon Philips | 0cf4dae | 2008-03-28 10:18:33 -0700 | [diff] [blame] | 199 | spin_lock_irqsave(q->irqlock, flags); |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 200 | for (i = 0; i < VIDEO_MAX_FRAME; i++) { |
| 201 | if (NULL == q->bufs[i]) |
| 202 | continue; |
Brandon Philips | 0fc0686 | 2007-11-06 20:02:36 -0300 | [diff] [blame] | 203 | if (q->bufs[i]->state == VIDEOBUF_QUEUED) { |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 204 | list_del(&q->bufs[i]->queue); |
Brandon Philips | 0fc0686 | 2007-11-06 20:02:36 -0300 | [diff] [blame] | 205 | q->bufs[i]->state = VIDEOBUF_ERROR; |
Brandon Philips | b608f43 | 2008-04-02 18:10:57 -0300 | [diff] [blame] | 206 | wake_up_all(&q->bufs[i]->done); |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 207 | } |
| 208 | } |
Brandon Philips | 0cf4dae | 2008-03-28 10:18:33 -0700 | [diff] [blame] | 209 | spin_unlock_irqrestore(q->irqlock, flags); |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 210 | |
| 211 | /* free all buffers + clear queue */ |
| 212 | for (i = 0; i < VIDEO_MAX_FRAME; i++) { |
| 213 | if (NULL == q->bufs[i]) |
| 214 | continue; |
Mauro Carvalho Chehab | e2c7731 | 2007-12-10 10:53:20 -0300 | [diff] [blame] | 215 | q->ops->buf_release(q, q->bufs[i]); |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 216 | } |
| 217 | INIT_LIST_HEAD(&q->stream); |
| 218 | } |
| 219 | |
| 220 | /* --------------------------------------------------------------------- */ |
| 221 | |
Mauro Carvalho Chehab | 64f9477 | 2008-01-31 13:57:53 -0300 | [diff] [blame] | 222 | /* Locking: Caller holds q->vb_lock */ |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 223 | enum v4l2_field videobuf_next_field(struct videobuf_queue *q) |
| 224 | { |
| 225 | enum v4l2_field field = q->field; |
| 226 | |
| 227 | BUG_ON(V4L2_FIELD_ANY == field); |
| 228 | |
| 229 | if (V4L2_FIELD_ALTERNATE == field) { |
| 230 | if (V4L2_FIELD_TOP == q->last) { |
| 231 | field = V4L2_FIELD_BOTTOM; |
| 232 | q->last = V4L2_FIELD_BOTTOM; |
| 233 | } else { |
| 234 | field = V4L2_FIELD_TOP; |
| 235 | q->last = V4L2_FIELD_TOP; |
| 236 | } |
| 237 | } |
| 238 | return field; |
| 239 | } |
| 240 | |
Mauro Carvalho Chehab | 64f9477 | 2008-01-31 13:57:53 -0300 | [diff] [blame] | 241 | /* Locking: Caller holds q->vb_lock */ |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 242 | static void videobuf_status(struct videobuf_queue *q, struct v4l2_buffer *b, |
| 243 | struct videobuf_buffer *vb, enum v4l2_buf_type type) |
| 244 | { |
Mauro Carvalho Chehab | e2c7731 | 2007-12-10 10:53:20 -0300 | [diff] [blame] | 245 | MAGIC_CHECK(vb->magic, MAGIC_BUFFER); |
| 246 | MAGIC_CHECK(q->int_ops->magic, MAGIC_QTYPE_OPS); |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 247 | |
| 248 | b->index = vb->i; |
| 249 | b->type = type; |
| 250 | |
| 251 | b->memory = vb->memory; |
| 252 | switch (b->memory) { |
| 253 | case V4L2_MEMORY_MMAP: |
| 254 | b->m.offset = vb->boff; |
| 255 | b->length = vb->bsize; |
| 256 | break; |
| 257 | case V4L2_MEMORY_USERPTR: |
| 258 | b->m.userptr = vb->baddr; |
| 259 | b->length = vb->bsize; |
| 260 | break; |
| 261 | case V4L2_MEMORY_OVERLAY: |
| 262 | b->m.offset = vb->boff; |
| 263 | break; |
| 264 | } |
| 265 | |
| 266 | b->flags = 0; |
Mauro Carvalho Chehab | 851c0c9 | 2007-09-27 18:25:44 -0300 | [diff] [blame] | 267 | if (vb->map) |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 268 | b->flags |= V4L2_BUF_FLAG_MAPPED; |
| 269 | |
| 270 | switch (vb->state) { |
Brandon Philips | 0fc0686 | 2007-11-06 20:02:36 -0300 | [diff] [blame] | 271 | case VIDEOBUF_PREPARED: |
| 272 | case VIDEOBUF_QUEUED: |
| 273 | case VIDEOBUF_ACTIVE: |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 274 | b->flags |= V4L2_BUF_FLAG_QUEUED; |
| 275 | break; |
Brandon Philips | 0fc0686 | 2007-11-06 20:02:36 -0300 | [diff] [blame] | 276 | case VIDEOBUF_DONE: |
| 277 | case VIDEOBUF_ERROR: |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 278 | b->flags |= V4L2_BUF_FLAG_DONE; |
| 279 | break; |
Brandon Philips | 0fc0686 | 2007-11-06 20:02:36 -0300 | [diff] [blame] | 280 | case VIDEOBUF_NEEDS_INIT: |
| 281 | case VIDEOBUF_IDLE: |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 282 | /* nothing */ |
| 283 | break; |
| 284 | } |
| 285 | |
| 286 | if (vb->input != UNSET) { |
| 287 | b->flags |= V4L2_BUF_FLAG_INPUT; |
| 288 | b->input = vb->input; |
| 289 | } |
| 290 | |
| 291 | b->field = vb->field; |
| 292 | b->timestamp = vb->ts; |
| 293 | b->bytesused = vb->size; |
| 294 | b->sequence = vb->field_count >> 1; |
| 295 | } |
| 296 | |
Mauro Carvalho Chehab | 64f9477 | 2008-01-31 13:57:53 -0300 | [diff] [blame] | 297 | /* Locking: Caller holds q->vb_lock */ |
Brandon Philips | 19bc513 | 2007-11-13 20:05:38 -0300 | [diff] [blame] | 298 | static int __videobuf_mmap_free(struct videobuf_queue *q) |
| 299 | { |
| 300 | int i; |
| 301 | int rc; |
| 302 | |
| 303 | if (!q) |
| 304 | return 0; |
| 305 | |
Mauro Carvalho Chehab | e2c7731 | 2007-12-10 10:53:20 -0300 | [diff] [blame] | 306 | MAGIC_CHECK(q->int_ops->magic, MAGIC_QTYPE_OPS); |
Brandon Philips | 19bc513 | 2007-11-13 20:05:38 -0300 | [diff] [blame] | 307 | |
Mauro Carvalho Chehab | d05051c | 2008-01-10 07:33:03 -0300 | [diff] [blame] | 308 | |
Mauro Carvalho Chehab | e2c7731 | 2007-12-10 10:53:20 -0300 | [diff] [blame] | 309 | rc = CALL(q, mmap_free, q); |
Mauro Carvalho Chehab | d05051c | 2008-01-10 07:33:03 -0300 | [diff] [blame] | 310 | |
| 311 | q->is_mmapped = 0; |
| 312 | |
Mauro Carvalho Chehab | e2c7731 | 2007-12-10 10:53:20 -0300 | [diff] [blame] | 313 | if (rc < 0) |
Brandon Philips | 19bc513 | 2007-11-13 20:05:38 -0300 | [diff] [blame] | 314 | return rc; |
| 315 | |
| 316 | for (i = 0; i < VIDEO_MAX_FRAME; i++) { |
| 317 | if (NULL == q->bufs[i]) |
| 318 | continue; |
Mauro Carvalho Chehab | e2c7731 | 2007-12-10 10:53:20 -0300 | [diff] [blame] | 319 | q->ops->buf_release(q, q->bufs[i]); |
Brandon Philips | 19bc513 | 2007-11-13 20:05:38 -0300 | [diff] [blame] | 320 | kfree(q->bufs[i]); |
| 321 | q->bufs[i] = NULL; |
| 322 | } |
| 323 | |
| 324 | return rc; |
| 325 | } |
| 326 | |
| 327 | int videobuf_mmap_free(struct videobuf_queue *q) |
| 328 | { |
| 329 | int ret; |
Mauro Carvalho Chehab | 64f9477 | 2008-01-31 13:57:53 -0300 | [diff] [blame] | 330 | mutex_lock(&q->vb_lock); |
Brandon Philips | 19bc513 | 2007-11-13 20:05:38 -0300 | [diff] [blame] | 331 | ret = __videobuf_mmap_free(q); |
Mauro Carvalho Chehab | 64f9477 | 2008-01-31 13:57:53 -0300 | [diff] [blame] | 332 | mutex_unlock(&q->vb_lock); |
Brandon Philips | 19bc513 | 2007-11-13 20:05:38 -0300 | [diff] [blame] | 333 | return ret; |
| 334 | } |
| 335 | |
Mauro Carvalho Chehab | 64f9477 | 2008-01-31 13:57:53 -0300 | [diff] [blame] | 336 | /* Locking: Caller holds q->vb_lock */ |
Arjan van de Ven | 81b2dbc | 2008-05-20 09:53:52 -0700 | [diff] [blame] | 337 | int __videobuf_mmap_setup(struct videobuf_queue *q, |
Brandon Philips | 19bc513 | 2007-11-13 20:05:38 -0300 | [diff] [blame] | 338 | unsigned int bcount, unsigned int bsize, |
| 339 | enum v4l2_memory memory) |
| 340 | { |
| 341 | unsigned int i; |
| 342 | int err; |
| 343 | |
Mauro Carvalho Chehab | e2c7731 | 2007-12-10 10:53:20 -0300 | [diff] [blame] | 344 | MAGIC_CHECK(q->int_ops->magic, MAGIC_QTYPE_OPS); |
Brandon Philips | 19bc513 | 2007-11-13 20:05:38 -0300 | [diff] [blame] | 345 | |
| 346 | err = __videobuf_mmap_free(q); |
| 347 | if (0 != err) |
| 348 | return err; |
| 349 | |
| 350 | /* Allocate and initialize buffers */ |
| 351 | for (i = 0; i < bcount; i++) { |
| 352 | q->bufs[i] = videobuf_alloc(q); |
| 353 | |
| 354 | if (q->bufs[i] == NULL) |
| 355 | break; |
| 356 | |
| 357 | q->bufs[i]->i = i; |
| 358 | q->bufs[i]->input = UNSET; |
| 359 | q->bufs[i]->memory = memory; |
| 360 | q->bufs[i]->bsize = bsize; |
| 361 | switch (memory) { |
| 362 | case V4L2_MEMORY_MMAP: |
Tuukka Toivonen | 7cbefad | 2009-07-23 10:56:25 -0300 | [diff] [blame] | 363 | q->bufs[i]->boff = PAGE_ALIGN(bsize) * i; |
Brandon Philips | 19bc513 | 2007-11-13 20:05:38 -0300 | [diff] [blame] | 364 | break; |
| 365 | case V4L2_MEMORY_USERPTR: |
| 366 | case V4L2_MEMORY_OVERLAY: |
| 367 | /* nothing */ |
| 368 | break; |
| 369 | } |
| 370 | } |
| 371 | |
| 372 | if (!i) |
| 373 | return -ENOMEM; |
| 374 | |
Mauro Carvalho Chehab | e2c7731 | 2007-12-10 10:53:20 -0300 | [diff] [blame] | 375 | dprintk(1, "mmap setup: %d buffers, %d bytes each\n", |
Brandon Philips | 19bc513 | 2007-11-13 20:05:38 -0300 | [diff] [blame] | 376 | i, bsize); |
| 377 | |
| 378 | return i; |
| 379 | } |
| 380 | |
| 381 | int videobuf_mmap_setup(struct videobuf_queue *q, |
| 382 | unsigned int bcount, unsigned int bsize, |
| 383 | enum v4l2_memory memory) |
| 384 | { |
| 385 | int ret; |
Mauro Carvalho Chehab | 64f9477 | 2008-01-31 13:57:53 -0300 | [diff] [blame] | 386 | mutex_lock(&q->vb_lock); |
Brandon Philips | 19bc513 | 2007-11-13 20:05:38 -0300 | [diff] [blame] | 387 | ret = __videobuf_mmap_setup(q, bcount, bsize, memory); |
Mauro Carvalho Chehab | 64f9477 | 2008-01-31 13:57:53 -0300 | [diff] [blame] | 388 | mutex_unlock(&q->vb_lock); |
Brandon Philips | 19bc513 | 2007-11-13 20:05:38 -0300 | [diff] [blame] | 389 | return ret; |
| 390 | } |
| 391 | |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 392 | int videobuf_reqbufs(struct videobuf_queue *q, |
| 393 | struct v4l2_requestbuffers *req) |
| 394 | { |
Mauro Carvalho Chehab | e2c7731 | 2007-12-10 10:53:20 -0300 | [diff] [blame] | 395 | unsigned int size, count; |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 396 | int retval; |
| 397 | |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 398 | if (req->count < 1) { |
Mauro Carvalho Chehab | e2c7731 | 2007-12-10 10:53:20 -0300 | [diff] [blame] | 399 | dprintk(1, "reqbufs: count invalid (%d)\n", req->count); |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 400 | return -EINVAL; |
| 401 | } |
Brandon Philips | 19bc513 | 2007-11-13 20:05:38 -0300 | [diff] [blame] | 402 | |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 403 | if (req->memory != V4L2_MEMORY_MMAP && |
| 404 | req->memory != V4L2_MEMORY_USERPTR && |
| 405 | req->memory != V4L2_MEMORY_OVERLAY) { |
Mauro Carvalho Chehab | e2c7731 | 2007-12-10 10:53:20 -0300 | [diff] [blame] | 406 | dprintk(1, "reqbufs: memory type invalid\n"); |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 407 | return -EINVAL; |
| 408 | } |
| 409 | |
Mauro Carvalho Chehab | 64f9477 | 2008-01-31 13:57:53 -0300 | [diff] [blame] | 410 | mutex_lock(&q->vb_lock); |
Brandon Philips | 19bc513 | 2007-11-13 20:05:38 -0300 | [diff] [blame] | 411 | if (req->type != q->type) { |
Mauro Carvalho Chehab | e2c7731 | 2007-12-10 10:53:20 -0300 | [diff] [blame] | 412 | dprintk(1, "reqbufs: queue type invalid\n"); |
Brandon Philips | 19bc513 | 2007-11-13 20:05:38 -0300 | [diff] [blame] | 413 | retval = -EINVAL; |
| 414 | goto done; |
| 415 | } |
| 416 | |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 417 | if (q->streaming) { |
Mauro Carvalho Chehab | e2c7731 | 2007-12-10 10:53:20 -0300 | [diff] [blame] | 418 | dprintk(1, "reqbufs: streaming already exists\n"); |
Brandon Philips | 00f98d0 | 2007-09-27 20:55:28 -0300 | [diff] [blame] | 419 | retval = -EBUSY; |
| 420 | goto done; |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 421 | } |
| 422 | if (!list_empty(&q->stream)) { |
Mauro Carvalho Chehab | e2c7731 | 2007-12-10 10:53:20 -0300 | [diff] [blame] | 423 | dprintk(1, "reqbufs: stream running\n"); |
Brandon Philips | 00f98d0 | 2007-09-27 20:55:28 -0300 | [diff] [blame] | 424 | retval = -EBUSY; |
| 425 | goto done; |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 426 | } |
| 427 | |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 428 | count = req->count; |
| 429 | if (count > VIDEO_MAX_FRAME) |
| 430 | count = VIDEO_MAX_FRAME; |
| 431 | size = 0; |
Mauro Carvalho Chehab | e2c7731 | 2007-12-10 10:53:20 -0300 | [diff] [blame] | 432 | q->ops->buf_setup(q, &count, &size); |
Mauro Carvalho Chehab | e2c7731 | 2007-12-10 10:53:20 -0300 | [diff] [blame] | 433 | dprintk(1, "reqbufs: bufs=%d, size=0x%x [%d pages total]\n", |
Tuukka Toivonen | 7cbefad | 2009-07-23 10:56:25 -0300 | [diff] [blame] | 434 | count, size, (count*PAGE_ALIGN(size))>>PAGE_SHIFT); |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 435 | |
Mauro Carvalho Chehab | e2c7731 | 2007-12-10 10:53:20 -0300 | [diff] [blame] | 436 | retval = __videobuf_mmap_setup(q, count, size, req->memory); |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 437 | if (retval < 0) { |
Mauro Carvalho Chehab | e2c7731 | 2007-12-10 10:53:20 -0300 | [diff] [blame] | 438 | dprintk(1, "reqbufs: mmap setup returned %d\n", retval); |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 439 | goto done; |
| 440 | } |
| 441 | |
Brandon Philips | 49ee718 | 2007-10-05 16:26:27 -0300 | [diff] [blame] | 442 | req->count = retval; |
Németh Márton | 925d74a | 2009-04-29 15:57:24 -0300 | [diff] [blame] | 443 | retval = 0; |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 444 | |
| 445 | done: |
Mauro Carvalho Chehab | 64f9477 | 2008-01-31 13:57:53 -0300 | [diff] [blame] | 446 | mutex_unlock(&q->vb_lock); |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 447 | return retval; |
| 448 | } |
| 449 | |
| 450 | int videobuf_querybuf(struct videobuf_queue *q, struct v4l2_buffer *b) |
| 451 | { |
Brandon Philips | 19bc513 | 2007-11-13 20:05:38 -0300 | [diff] [blame] | 452 | int ret = -EINVAL; |
| 453 | |
Mauro Carvalho Chehab | 64f9477 | 2008-01-31 13:57:53 -0300 | [diff] [blame] | 454 | mutex_lock(&q->vb_lock); |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 455 | if (unlikely(b->type != q->type)) { |
Mauro Carvalho Chehab | e2c7731 | 2007-12-10 10:53:20 -0300 | [diff] [blame] | 456 | dprintk(1, "querybuf: Wrong type.\n"); |
Brandon Philips | 19bc513 | 2007-11-13 20:05:38 -0300 | [diff] [blame] | 457 | goto done; |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 458 | } |
Roel Kluin | 223ffe5 | 2009-05-02 16:38:47 -0300 | [diff] [blame] | 459 | if (unlikely(b->index >= VIDEO_MAX_FRAME)) { |
Mauro Carvalho Chehab | e2c7731 | 2007-12-10 10:53:20 -0300 | [diff] [blame] | 460 | dprintk(1, "querybuf: index out of range.\n"); |
Brandon Philips | 19bc513 | 2007-11-13 20:05:38 -0300 | [diff] [blame] | 461 | goto done; |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 462 | } |
| 463 | if (unlikely(NULL == q->bufs[b->index])) { |
Mauro Carvalho Chehab | e2c7731 | 2007-12-10 10:53:20 -0300 | [diff] [blame] | 464 | dprintk(1, "querybuf: buffer is null.\n"); |
Brandon Philips | 19bc513 | 2007-11-13 20:05:38 -0300 | [diff] [blame] | 465 | goto done; |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 466 | } |
Brandon Philips | 19bc513 | 2007-11-13 20:05:38 -0300 | [diff] [blame] | 467 | |
Mauro Carvalho Chehab | e2c7731 | 2007-12-10 10:53:20 -0300 | [diff] [blame] | 468 | videobuf_status(q, b, q->bufs[b->index], q->type); |
Brandon Philips | 19bc513 | 2007-11-13 20:05:38 -0300 | [diff] [blame] | 469 | |
| 470 | ret = 0; |
| 471 | done: |
Mauro Carvalho Chehab | 64f9477 | 2008-01-31 13:57:53 -0300 | [diff] [blame] | 472 | mutex_unlock(&q->vb_lock); |
Brandon Philips | 19bc513 | 2007-11-13 20:05:38 -0300 | [diff] [blame] | 473 | return ret; |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 474 | } |
| 475 | |
| 476 | int videobuf_qbuf(struct videobuf_queue *q, |
| 477 | struct v4l2_buffer *b) |
| 478 | { |
| 479 | struct videobuf_buffer *buf; |
| 480 | enum v4l2_field field; |
Mauro Carvalho Chehab | e2c7731 | 2007-12-10 10:53:20 -0300 | [diff] [blame] | 481 | unsigned long flags = 0; |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 482 | int retval; |
| 483 | |
Mauro Carvalho Chehab | e2c7731 | 2007-12-10 10:53:20 -0300 | [diff] [blame] | 484 | MAGIC_CHECK(q->int_ops->magic, MAGIC_QTYPE_OPS); |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 485 | |
Maxim Levitsky | 9900132 | 2007-09-27 20:34:09 -0300 | [diff] [blame] | 486 | if (b->memory == V4L2_MEMORY_MMAP) |
| 487 | down_read(¤t->mm->mmap_sem); |
| 488 | |
Mauro Carvalho Chehab | 64f9477 | 2008-01-31 13:57:53 -0300 | [diff] [blame] | 489 | mutex_lock(&q->vb_lock); |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 490 | retval = -EBUSY; |
| 491 | if (q->reading) { |
Mauro Carvalho Chehab | e2c7731 | 2007-12-10 10:53:20 -0300 | [diff] [blame] | 492 | dprintk(1, "qbuf: Reading running...\n"); |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 493 | goto done; |
| 494 | } |
| 495 | retval = -EINVAL; |
| 496 | if (b->type != q->type) { |
Mauro Carvalho Chehab | e2c7731 | 2007-12-10 10:53:20 -0300 | [diff] [blame] | 497 | dprintk(1, "qbuf: Wrong type.\n"); |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 498 | goto done; |
| 499 | } |
Roel Kluin | 223ffe5 | 2009-05-02 16:38:47 -0300 | [diff] [blame] | 500 | if (b->index >= VIDEO_MAX_FRAME) { |
Mauro Carvalho Chehab | e2c7731 | 2007-12-10 10:53:20 -0300 | [diff] [blame] | 501 | dprintk(1, "qbuf: index out of range.\n"); |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 502 | goto done; |
| 503 | } |
| 504 | buf = q->bufs[b->index]; |
| 505 | if (NULL == buf) { |
Mauro Carvalho Chehab | e2c7731 | 2007-12-10 10:53:20 -0300 | [diff] [blame] | 506 | dprintk(1, "qbuf: buffer is null.\n"); |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 507 | goto done; |
| 508 | } |
Mauro Carvalho Chehab | e2c7731 | 2007-12-10 10:53:20 -0300 | [diff] [blame] | 509 | MAGIC_CHECK(buf->magic, MAGIC_BUFFER); |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 510 | if (buf->memory != b->memory) { |
Mauro Carvalho Chehab | e2c7731 | 2007-12-10 10:53:20 -0300 | [diff] [blame] | 511 | dprintk(1, "qbuf: memory type is wrong.\n"); |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 512 | goto done; |
| 513 | } |
Brandon Philips | 0fc0686 | 2007-11-06 20:02:36 -0300 | [diff] [blame] | 514 | if (buf->state != VIDEOBUF_NEEDS_INIT && buf->state != VIDEOBUF_IDLE) { |
Mauro Carvalho Chehab | e2c7731 | 2007-12-10 10:53:20 -0300 | [diff] [blame] | 515 | dprintk(1, "qbuf: buffer is already queued or active.\n"); |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 516 | goto done; |
| 517 | } |
| 518 | |
| 519 | if (b->flags & V4L2_BUF_FLAG_INPUT) { |
| 520 | if (b->input >= q->inputs) { |
Mauro Carvalho Chehab | e2c7731 | 2007-12-10 10:53:20 -0300 | [diff] [blame] | 521 | dprintk(1, "qbuf: wrong input.\n"); |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 522 | goto done; |
| 523 | } |
| 524 | buf->input = b->input; |
| 525 | } else { |
| 526 | buf->input = UNSET; |
| 527 | } |
| 528 | |
| 529 | switch (b->memory) { |
| 530 | case V4L2_MEMORY_MMAP: |
| 531 | if (0 == buf->baddr) { |
Mauro Carvalho Chehab | e2c7731 | 2007-12-10 10:53:20 -0300 | [diff] [blame] | 532 | dprintk(1, "qbuf: mmap requested " |
| 533 | "but buffer addr is zero!\n"); |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 534 | goto done; |
| 535 | } |
| 536 | break; |
| 537 | case V4L2_MEMORY_USERPTR: |
| 538 | if (b->length < buf->bsize) { |
Mauro Carvalho Chehab | e2c7731 | 2007-12-10 10:53:20 -0300 | [diff] [blame] | 539 | dprintk(1, "qbuf: buffer length is not enough\n"); |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 540 | goto done; |
| 541 | } |
Mauro Carvalho Chehab | e2c7731 | 2007-12-10 10:53:20 -0300 | [diff] [blame] | 542 | if (VIDEOBUF_NEEDS_INIT != buf->state && |
| 543 | buf->baddr != b->m.userptr) |
| 544 | q->ops->buf_release(q, buf); |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 545 | buf->baddr = b->m.userptr; |
| 546 | break; |
| 547 | case V4L2_MEMORY_OVERLAY: |
| 548 | buf->boff = b->m.offset; |
| 549 | break; |
| 550 | default: |
Mauro Carvalho Chehab | e2c7731 | 2007-12-10 10:53:20 -0300 | [diff] [blame] | 551 | dprintk(1, "qbuf: wrong memory type\n"); |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 552 | goto done; |
| 553 | } |
| 554 | |
Mauro Carvalho Chehab | e2c7731 | 2007-12-10 10:53:20 -0300 | [diff] [blame] | 555 | dprintk(1, "qbuf: requesting next field\n"); |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 556 | field = videobuf_next_field(q); |
Mauro Carvalho Chehab | e2c7731 | 2007-12-10 10:53:20 -0300 | [diff] [blame] | 557 | retval = q->ops->buf_prepare(q, buf, field); |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 558 | if (0 != retval) { |
Mauro Carvalho Chehab | e2c7731 | 2007-12-10 10:53:20 -0300 | [diff] [blame] | 559 | dprintk(1, "qbuf: buffer_prepare returned %d\n", retval); |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 560 | goto done; |
| 561 | } |
| 562 | |
Mauro Carvalho Chehab | e2c7731 | 2007-12-10 10:53:20 -0300 | [diff] [blame] | 563 | list_add_tail(&buf->stream, &q->stream); |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 564 | if (q->streaming) { |
Brandon Philips | 0cf4dae | 2008-03-28 10:18:33 -0700 | [diff] [blame] | 565 | spin_lock_irqsave(q->irqlock, flags); |
Mauro Carvalho Chehab | e2c7731 | 2007-12-10 10:53:20 -0300 | [diff] [blame] | 566 | q->ops->buf_queue(q, buf); |
Brandon Philips | 0cf4dae | 2008-03-28 10:18:33 -0700 | [diff] [blame] | 567 | spin_unlock_irqrestore(q->irqlock, flags); |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 568 | } |
Mauro Carvalho Chehab | e2c7731 | 2007-12-10 10:53:20 -0300 | [diff] [blame] | 569 | dprintk(1, "qbuf: succeded\n"); |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 570 | retval = 0; |
Brandon Philips | 137d1cb | 2008-04-02 18:10:59 -0300 | [diff] [blame] | 571 | wake_up_interruptible_sync(&q->wait); |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 572 | |
| 573 | done: |
Mauro Carvalho Chehab | 64f9477 | 2008-01-31 13:57:53 -0300 | [diff] [blame] | 574 | mutex_unlock(&q->vb_lock); |
Maxim Levitsky | 9900132 | 2007-09-27 20:34:09 -0300 | [diff] [blame] | 575 | |
| 576 | if (b->memory == V4L2_MEMORY_MMAP) |
| 577 | up_read(¤t->mm->mmap_sem); |
| 578 | |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 579 | return retval; |
| 580 | } |
| 581 | |
Brandon Philips | 137d1cb | 2008-04-02 18:10:59 -0300 | [diff] [blame] | 582 | |
| 583 | /* Locking: Caller holds q->vb_lock */ |
| 584 | static int stream_next_buffer_check_queue(struct videobuf_queue *q, int noblock) |
| 585 | { |
| 586 | int retval; |
| 587 | |
| 588 | checks: |
| 589 | if (!q->streaming) { |
| 590 | dprintk(1, "next_buffer: Not streaming\n"); |
| 591 | retval = -EINVAL; |
| 592 | goto done; |
| 593 | } |
| 594 | |
| 595 | if (list_empty(&q->stream)) { |
| 596 | if (noblock) { |
| 597 | retval = -EAGAIN; |
| 598 | dprintk(2, "next_buffer: no buffers to dequeue\n"); |
| 599 | goto done; |
| 600 | } else { |
| 601 | dprintk(2, "next_buffer: waiting on buffer\n"); |
| 602 | |
| 603 | /* Drop lock to avoid deadlock with qbuf */ |
| 604 | mutex_unlock(&q->vb_lock); |
| 605 | |
| 606 | /* Checking list_empty and streaming is safe without |
| 607 | * locks because we goto checks to validate while |
| 608 | * holding locks before proceeding */ |
| 609 | retval = wait_event_interruptible(q->wait, |
| 610 | !list_empty(&q->stream) || !q->streaming); |
| 611 | mutex_lock(&q->vb_lock); |
| 612 | |
| 613 | if (retval) |
| 614 | goto done; |
| 615 | |
| 616 | goto checks; |
| 617 | } |
| 618 | } |
| 619 | |
| 620 | retval = 0; |
| 621 | |
| 622 | done: |
| 623 | return retval; |
| 624 | } |
| 625 | |
| 626 | |
| 627 | /* Locking: Caller holds q->vb_lock */ |
| 628 | static int stream_next_buffer(struct videobuf_queue *q, |
| 629 | struct videobuf_buffer **vb, int nonblocking) |
| 630 | { |
| 631 | int retval; |
| 632 | struct videobuf_buffer *buf = NULL; |
| 633 | |
| 634 | retval = stream_next_buffer_check_queue(q, nonblocking); |
| 635 | if (retval) |
| 636 | goto done; |
| 637 | |
| 638 | buf = list_entry(q->stream.next, struct videobuf_buffer, stream); |
| 639 | retval = videobuf_waiton(buf, nonblocking, 1); |
| 640 | if (retval < 0) |
| 641 | goto done; |
| 642 | |
| 643 | *vb = buf; |
| 644 | done: |
| 645 | return retval; |
| 646 | } |
| 647 | |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 648 | int videobuf_dqbuf(struct videobuf_queue *q, |
| 649 | struct v4l2_buffer *b, int nonblocking) |
| 650 | { |
Brandon Philips | 137d1cb | 2008-04-02 18:10:59 -0300 | [diff] [blame] | 651 | struct videobuf_buffer *buf = NULL; |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 652 | int retval; |
| 653 | |
Mauro Carvalho Chehab | e2c7731 | 2007-12-10 10:53:20 -0300 | [diff] [blame] | 654 | MAGIC_CHECK(q->int_ops->magic, MAGIC_QTYPE_OPS); |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 655 | |
Mauro Carvalho Chehab | 64f9477 | 2008-01-31 13:57:53 -0300 | [diff] [blame] | 656 | mutex_lock(&q->vb_lock); |
Brandon Philips | 137d1cb | 2008-04-02 18:10:59 -0300 | [diff] [blame] | 657 | |
| 658 | retval = stream_next_buffer(q, &buf, nonblocking); |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 659 | if (retval < 0) { |
Brandon Philips | 137d1cb | 2008-04-02 18:10:59 -0300 | [diff] [blame] | 660 | dprintk(1, "dqbuf: next_buffer error: %i\n", retval); |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 661 | goto done; |
| 662 | } |
Brandon Philips | 137d1cb | 2008-04-02 18:10:59 -0300 | [diff] [blame] | 663 | |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 664 | switch (buf->state) { |
Brandon Philips | 0fc0686 | 2007-11-06 20:02:36 -0300 | [diff] [blame] | 665 | case VIDEOBUF_ERROR: |
Mauro Carvalho Chehab | e2c7731 | 2007-12-10 10:53:20 -0300 | [diff] [blame] | 666 | dprintk(1, "dqbuf: state is error\n"); |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 667 | retval = -EIO; |
Mauro Carvalho Chehab | e2c7731 | 2007-12-10 10:53:20 -0300 | [diff] [blame] | 668 | CALL(q, sync, q, buf); |
Brandon Philips | 0fc0686 | 2007-11-06 20:02:36 -0300 | [diff] [blame] | 669 | buf->state = VIDEOBUF_IDLE; |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 670 | break; |
Brandon Philips | 0fc0686 | 2007-11-06 20:02:36 -0300 | [diff] [blame] | 671 | case VIDEOBUF_DONE: |
Mauro Carvalho Chehab | e2c7731 | 2007-12-10 10:53:20 -0300 | [diff] [blame] | 672 | dprintk(1, "dqbuf: state is done\n"); |
| 673 | CALL(q, sync, q, buf); |
Brandon Philips | 0fc0686 | 2007-11-06 20:02:36 -0300 | [diff] [blame] | 674 | buf->state = VIDEOBUF_IDLE; |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 675 | break; |
| 676 | default: |
Mauro Carvalho Chehab | e2c7731 | 2007-12-10 10:53:20 -0300 | [diff] [blame] | 677 | dprintk(1, "dqbuf: state invalid\n"); |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 678 | retval = -EINVAL; |
| 679 | goto done; |
| 680 | } |
| 681 | list_del(&buf->stream); |
Mauro Carvalho Chehab | e2c7731 | 2007-12-10 10:53:20 -0300 | [diff] [blame] | 682 | memset(b, 0, sizeof(*b)); |
| 683 | videobuf_status(q, b, buf, q->type); |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 684 | |
| 685 | done: |
Mauro Carvalho Chehab | 64f9477 | 2008-01-31 13:57:53 -0300 | [diff] [blame] | 686 | mutex_unlock(&q->vb_lock); |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 687 | return retval; |
| 688 | } |
| 689 | |
| 690 | int videobuf_streamon(struct videobuf_queue *q) |
| 691 | { |
| 692 | struct videobuf_buffer *buf; |
Mauro Carvalho Chehab | e2c7731 | 2007-12-10 10:53:20 -0300 | [diff] [blame] | 693 | unsigned long flags = 0; |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 694 | int retval; |
| 695 | |
Mauro Carvalho Chehab | 64f9477 | 2008-01-31 13:57:53 -0300 | [diff] [blame] | 696 | mutex_lock(&q->vb_lock); |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 697 | retval = -EBUSY; |
| 698 | if (q->reading) |
| 699 | goto done; |
| 700 | retval = 0; |
| 701 | if (q->streaming) |
| 702 | goto done; |
| 703 | q->streaming = 1; |
Brandon Philips | 0cf4dae | 2008-03-28 10:18:33 -0700 | [diff] [blame] | 704 | spin_lock_irqsave(q->irqlock, flags); |
Trent Piepho | a991f44 | 2007-10-10 05:37:43 -0300 | [diff] [blame] | 705 | list_for_each_entry(buf, &q->stream, stream) |
Brandon Philips | 0fc0686 | 2007-11-06 20:02:36 -0300 | [diff] [blame] | 706 | if (buf->state == VIDEOBUF_PREPARED) |
Mauro Carvalho Chehab | e2c7731 | 2007-12-10 10:53:20 -0300 | [diff] [blame] | 707 | q->ops->buf_queue(q, buf); |
Brandon Philips | 0cf4dae | 2008-03-28 10:18:33 -0700 | [diff] [blame] | 708 | spin_unlock_irqrestore(q->irqlock, flags); |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 709 | |
Brandon Philips | 137d1cb | 2008-04-02 18:10:59 -0300 | [diff] [blame] | 710 | wake_up_interruptible_sync(&q->wait); |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 711 | done: |
Mauro Carvalho Chehab | 64f9477 | 2008-01-31 13:57:53 -0300 | [diff] [blame] | 712 | mutex_unlock(&q->vb_lock); |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 713 | return retval; |
| 714 | } |
| 715 | |
Mauro Carvalho Chehab | 64f9477 | 2008-01-31 13:57:53 -0300 | [diff] [blame] | 716 | /* Locking: Caller holds q->vb_lock */ |
Brandon Philips | 19bc513 | 2007-11-13 20:05:38 -0300 | [diff] [blame] | 717 | static int __videobuf_streamoff(struct videobuf_queue *q) |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 718 | { |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 719 | if (!q->streaming) |
Brandon Philips | 19bc513 | 2007-11-13 20:05:38 -0300 | [diff] [blame] | 720 | return -EINVAL; |
| 721 | |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 722 | videobuf_queue_cancel(q); |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 723 | |
Brandon Philips | 19bc513 | 2007-11-13 20:05:38 -0300 | [diff] [blame] | 724 | return 0; |
| 725 | } |
| 726 | |
| 727 | int videobuf_streamoff(struct videobuf_queue *q) |
| 728 | { |
| 729 | int retval; |
| 730 | |
Mauro Carvalho Chehab | 64f9477 | 2008-01-31 13:57:53 -0300 | [diff] [blame] | 731 | mutex_lock(&q->vb_lock); |
Brandon Philips | 19bc513 | 2007-11-13 20:05:38 -0300 | [diff] [blame] | 732 | retval = __videobuf_streamoff(q); |
Mauro Carvalho Chehab | 64f9477 | 2008-01-31 13:57:53 -0300 | [diff] [blame] | 733 | mutex_unlock(&q->vb_lock); |
Brandon Philips | 19bc513 | 2007-11-13 20:05:38 -0300 | [diff] [blame] | 734 | |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 735 | return retval; |
| 736 | } |
| 737 | |
Mauro Carvalho Chehab | 64f9477 | 2008-01-31 13:57:53 -0300 | [diff] [blame] | 738 | /* Locking: Caller holds q->vb_lock */ |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 739 | static ssize_t videobuf_read_zerocopy(struct videobuf_queue *q, |
| 740 | char __user *data, |
| 741 | size_t count, loff_t *ppos) |
| 742 | { |
| 743 | enum v4l2_field field; |
Mauro Carvalho Chehab | e2c7731 | 2007-12-10 10:53:20 -0300 | [diff] [blame] | 744 | unsigned long flags = 0; |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 745 | int retval; |
| 746 | |
Mauro Carvalho Chehab | e2c7731 | 2007-12-10 10:53:20 -0300 | [diff] [blame] | 747 | MAGIC_CHECK(q->int_ops->magic, MAGIC_QTYPE_OPS); |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 748 | |
| 749 | /* setup stuff */ |
| 750 | q->read_buf = videobuf_alloc(q); |
| 751 | if (NULL == q->read_buf) |
| 752 | return -ENOMEM; |
| 753 | |
| 754 | q->read_buf->memory = V4L2_MEMORY_USERPTR; |
| 755 | q->read_buf->baddr = (unsigned long)data; |
| 756 | q->read_buf->bsize = count; |
| 757 | |
| 758 | field = videobuf_next_field(q); |
Mauro Carvalho Chehab | e2c7731 | 2007-12-10 10:53:20 -0300 | [diff] [blame] | 759 | retval = q->ops->buf_prepare(q, q->read_buf, field); |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 760 | if (0 != retval) |
| 761 | goto done; |
| 762 | |
| 763 | /* start capture & wait */ |
Brandon Philips | 0cf4dae | 2008-03-28 10:18:33 -0700 | [diff] [blame] | 764 | spin_lock_irqsave(q->irqlock, flags); |
Mauro Carvalho Chehab | e2c7731 | 2007-12-10 10:53:20 -0300 | [diff] [blame] | 765 | q->ops->buf_queue(q, q->read_buf); |
Brandon Philips | 0cf4dae | 2008-03-28 10:18:33 -0700 | [diff] [blame] | 766 | spin_unlock_irqrestore(q->irqlock, flags); |
Mauro Carvalho Chehab | e2c7731 | 2007-12-10 10:53:20 -0300 | [diff] [blame] | 767 | retval = videobuf_waiton(q->read_buf, 0, 0); |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 768 | if (0 == retval) { |
Mauro Carvalho Chehab | e2c7731 | 2007-12-10 10:53:20 -0300 | [diff] [blame] | 769 | CALL(q, sync, q, q->read_buf); |
Brandon Philips | 0fc0686 | 2007-11-06 20:02:36 -0300 | [diff] [blame] | 770 | if (VIDEOBUF_ERROR == q->read_buf->state) |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 771 | retval = -EIO; |
| 772 | else |
| 773 | retval = q->read_buf->size; |
| 774 | } |
| 775 | |
| 776 | done: |
| 777 | /* cleanup */ |
Mauro Carvalho Chehab | e2c7731 | 2007-12-10 10:53:20 -0300 | [diff] [blame] | 778 | q->ops->buf_release(q, q->read_buf); |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 779 | kfree(q->read_buf); |
| 780 | q->read_buf = NULL; |
| 781 | return retval; |
| 782 | } |
| 783 | |
| 784 | ssize_t videobuf_read_one(struct videobuf_queue *q, |
| 785 | char __user *data, size_t count, loff_t *ppos, |
| 786 | int nonblocking) |
| 787 | { |
| 788 | enum v4l2_field field; |
Mauro Carvalho Chehab | e2c7731 | 2007-12-10 10:53:20 -0300 | [diff] [blame] | 789 | unsigned long flags = 0; |
Guennadi Liakhovetski | 7daa4a8 | 2008-04-22 14:46:03 -0300 | [diff] [blame] | 790 | unsigned size = 0, nbufs = 1; |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 791 | int retval; |
| 792 | |
Mauro Carvalho Chehab | e2c7731 | 2007-12-10 10:53:20 -0300 | [diff] [blame] | 793 | MAGIC_CHECK(q->int_ops->magic, MAGIC_QTYPE_OPS); |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 794 | |
Mauro Carvalho Chehab | 64f9477 | 2008-01-31 13:57:53 -0300 | [diff] [blame] | 795 | mutex_lock(&q->vb_lock); |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 796 | |
Mauro Carvalho Chehab | e2c7731 | 2007-12-10 10:53:20 -0300 | [diff] [blame] | 797 | q->ops->buf_setup(q, &nbufs, &size); |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 798 | |
| 799 | if (NULL == q->read_buf && |
| 800 | count >= size && |
| 801 | !nonblocking) { |
Mauro Carvalho Chehab | e2c7731 | 2007-12-10 10:53:20 -0300 | [diff] [blame] | 802 | retval = videobuf_read_zerocopy(q, data, count, ppos); |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 803 | if (retval >= 0 || retval == -EIO) |
| 804 | /* ok, all done */ |
| 805 | goto done; |
| 806 | /* fallback to kernel bounce buffer on failures */ |
| 807 | } |
| 808 | |
| 809 | if (NULL == q->read_buf) { |
| 810 | /* need to capture a new frame */ |
| 811 | retval = -ENOMEM; |
| 812 | q->read_buf = videobuf_alloc(q); |
| 813 | |
Mauro Carvalho Chehab | e2c7731 | 2007-12-10 10:53:20 -0300 | [diff] [blame] | 814 | dprintk(1, "video alloc=0x%p\n", q->read_buf); |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 815 | if (NULL == q->read_buf) |
| 816 | goto done; |
| 817 | q->read_buf->memory = V4L2_MEMORY_USERPTR; |
| 818 | q->read_buf->bsize = count; /* preferred size */ |
| 819 | field = videobuf_next_field(q); |
Mauro Carvalho Chehab | e2c7731 | 2007-12-10 10:53:20 -0300 | [diff] [blame] | 820 | retval = q->ops->buf_prepare(q, q->read_buf, field); |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 821 | |
| 822 | if (0 != retval) { |
Mauro Carvalho Chehab | e2c7731 | 2007-12-10 10:53:20 -0300 | [diff] [blame] | 823 | kfree(q->read_buf); |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 824 | q->read_buf = NULL; |
| 825 | goto done; |
| 826 | } |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 827 | |
Brandon Philips | 0cf4dae | 2008-03-28 10:18:33 -0700 | [diff] [blame] | 828 | spin_lock_irqsave(q->irqlock, flags); |
Mauro Carvalho Chehab | e2c7731 | 2007-12-10 10:53:20 -0300 | [diff] [blame] | 829 | q->ops->buf_queue(q, q->read_buf); |
Brandon Philips | 0cf4dae | 2008-03-28 10:18:33 -0700 | [diff] [blame] | 830 | spin_unlock_irqrestore(q->irqlock, flags); |
| 831 | |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 832 | q->read_off = 0; |
| 833 | } |
| 834 | |
| 835 | /* wait until capture is done */ |
| 836 | retval = videobuf_waiton(q->read_buf, nonblocking, 1); |
| 837 | if (0 != retval) |
| 838 | goto done; |
| 839 | |
Mauro Carvalho Chehab | e2c7731 | 2007-12-10 10:53:20 -0300 | [diff] [blame] | 840 | CALL(q, sync, q, q->read_buf); |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 841 | |
Brandon Philips | 0fc0686 | 2007-11-06 20:02:36 -0300 | [diff] [blame] | 842 | if (VIDEOBUF_ERROR == q->read_buf->state) { |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 843 | /* catch I/O errors */ |
Mauro Carvalho Chehab | e2c7731 | 2007-12-10 10:53:20 -0300 | [diff] [blame] | 844 | q->ops->buf_release(q, q->read_buf); |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 845 | kfree(q->read_buf); |
| 846 | q->read_buf = NULL; |
| 847 | retval = -EIO; |
| 848 | goto done; |
| 849 | } |
| 850 | |
| 851 | /* Copy to userspace */ |
Mauro Carvalho Chehab | e2c7731 | 2007-12-10 10:53:20 -0300 | [diff] [blame] | 852 | retval = CALL(q, video_copy_to_user, q, data, count, nonblocking); |
| 853 | if (retval < 0) |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 854 | goto done; |
| 855 | |
| 856 | q->read_off += retval; |
| 857 | if (q->read_off == q->read_buf->size) { |
| 858 | /* all data copied, cleanup */ |
Mauro Carvalho Chehab | e2c7731 | 2007-12-10 10:53:20 -0300 | [diff] [blame] | 859 | q->ops->buf_release(q, q->read_buf); |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 860 | kfree(q->read_buf); |
| 861 | q->read_buf = NULL; |
| 862 | } |
| 863 | |
| 864 | done: |
Mauro Carvalho Chehab | 64f9477 | 2008-01-31 13:57:53 -0300 | [diff] [blame] | 865 | mutex_unlock(&q->vb_lock); |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 866 | return retval; |
| 867 | } |
| 868 | |
Mauro Carvalho Chehab | 64f9477 | 2008-01-31 13:57:53 -0300 | [diff] [blame] | 869 | /* Locking: Caller holds q->vb_lock */ |
Mauro Carvalho Chehab | 225ba90 | 2007-12-12 21:46:26 -0300 | [diff] [blame] | 870 | static int __videobuf_read_start(struct videobuf_queue *q) |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 871 | { |
| 872 | enum v4l2_field field; |
Mauro Carvalho Chehab | e2c7731 | 2007-12-10 10:53:20 -0300 | [diff] [blame] | 873 | unsigned long flags = 0; |
Brandon Philips | 49ee718 | 2007-10-05 16:26:27 -0300 | [diff] [blame] | 874 | unsigned int count = 0, size = 0; |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 875 | int err, i; |
| 876 | |
Mauro Carvalho Chehab | e2c7731 | 2007-12-10 10:53:20 -0300 | [diff] [blame] | 877 | q->ops->buf_setup(q, &count, &size); |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 878 | if (count < 2) |
| 879 | count = 2; |
| 880 | if (count > VIDEO_MAX_FRAME) |
| 881 | count = VIDEO_MAX_FRAME; |
| 882 | size = PAGE_ALIGN(size); |
| 883 | |
Brandon Philips | 19bc513 | 2007-11-13 20:05:38 -0300 | [diff] [blame] | 884 | err = __videobuf_mmap_setup(q, count, size, V4L2_MEMORY_USERPTR); |
Brandon Philips | 49ee718 | 2007-10-05 16:26:27 -0300 | [diff] [blame] | 885 | if (err < 0) |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 886 | return err; |
| 887 | |
Brandon Philips | 49ee718 | 2007-10-05 16:26:27 -0300 | [diff] [blame] | 888 | count = err; |
| 889 | |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 890 | for (i = 0; i < count; i++) { |
| 891 | field = videobuf_next_field(q); |
Mauro Carvalho Chehab | e2c7731 | 2007-12-10 10:53:20 -0300 | [diff] [blame] | 892 | err = q->ops->buf_prepare(q, q->bufs[i], field); |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 893 | if (err) |
| 894 | return err; |
| 895 | list_add_tail(&q->bufs[i]->stream, &q->stream); |
| 896 | } |
Brandon Philips | 0cf4dae | 2008-03-28 10:18:33 -0700 | [diff] [blame] | 897 | spin_lock_irqsave(q->irqlock, flags); |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 898 | for (i = 0; i < count; i++) |
Mauro Carvalho Chehab | e2c7731 | 2007-12-10 10:53:20 -0300 | [diff] [blame] | 899 | q->ops->buf_queue(q, q->bufs[i]); |
Brandon Philips | 0cf4dae | 2008-03-28 10:18:33 -0700 | [diff] [blame] | 900 | spin_unlock_irqrestore(q->irqlock, flags); |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 901 | q->reading = 1; |
| 902 | return 0; |
| 903 | } |
| 904 | |
Brandon Philips | 19bc513 | 2007-11-13 20:05:38 -0300 | [diff] [blame] | 905 | static void __videobuf_read_stop(struct videobuf_queue *q) |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 906 | { |
| 907 | int i; |
| 908 | |
| 909 | videobuf_queue_cancel(q); |
Brandon Philips | 19bc513 | 2007-11-13 20:05:38 -0300 | [diff] [blame] | 910 | __videobuf_mmap_free(q); |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 911 | INIT_LIST_HEAD(&q->stream); |
| 912 | for (i = 0; i < VIDEO_MAX_FRAME; i++) { |
| 913 | if (NULL == q->bufs[i]) |
| 914 | continue; |
| 915 | kfree(q->bufs[i]); |
| 916 | q->bufs[i] = NULL; |
| 917 | } |
| 918 | q->read_buf = NULL; |
Mauro Carvalho Chehab | e2c7731 | 2007-12-10 10:53:20 -0300 | [diff] [blame] | 919 | |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 920 | } |
| 921 | |
Mauro Carvalho Chehab | 19fb14579 | 2007-11-15 23:09:30 -0300 | [diff] [blame] | 922 | int videobuf_read_start(struct videobuf_queue *q) |
| 923 | { |
| 924 | int rc; |
| 925 | |
Mauro Carvalho Chehab | 64f9477 | 2008-01-31 13:57:53 -0300 | [diff] [blame] | 926 | mutex_lock(&q->vb_lock); |
Mauro Carvalho Chehab | 19fb14579 | 2007-11-15 23:09:30 -0300 | [diff] [blame] | 927 | rc = __videobuf_read_start(q); |
Mauro Carvalho Chehab | 64f9477 | 2008-01-31 13:57:53 -0300 | [diff] [blame] | 928 | mutex_unlock(&q->vb_lock); |
Mauro Carvalho Chehab | 19fb14579 | 2007-11-15 23:09:30 -0300 | [diff] [blame] | 929 | |
| 930 | return rc; |
| 931 | } |
| 932 | |
Brandon Philips | 19bc513 | 2007-11-13 20:05:38 -0300 | [diff] [blame] | 933 | void videobuf_read_stop(struct videobuf_queue *q) |
| 934 | { |
Mauro Carvalho Chehab | 64f9477 | 2008-01-31 13:57:53 -0300 | [diff] [blame] | 935 | mutex_lock(&q->vb_lock); |
Brandon Philips | 19bc513 | 2007-11-13 20:05:38 -0300 | [diff] [blame] | 936 | __videobuf_read_stop(q); |
Mauro Carvalho Chehab | 64f9477 | 2008-01-31 13:57:53 -0300 | [diff] [blame] | 937 | mutex_unlock(&q->vb_lock); |
Brandon Philips | 19bc513 | 2007-11-13 20:05:38 -0300 | [diff] [blame] | 938 | } |
| 939 | |
| 940 | void videobuf_stop(struct videobuf_queue *q) |
| 941 | { |
Mauro Carvalho Chehab | 64f9477 | 2008-01-31 13:57:53 -0300 | [diff] [blame] | 942 | mutex_lock(&q->vb_lock); |
Brandon Philips | 19bc513 | 2007-11-13 20:05:38 -0300 | [diff] [blame] | 943 | |
| 944 | if (q->streaming) |
| 945 | __videobuf_streamoff(q); |
| 946 | |
| 947 | if (q->reading) |
| 948 | __videobuf_read_stop(q); |
| 949 | |
Mauro Carvalho Chehab | 64f9477 | 2008-01-31 13:57:53 -0300 | [diff] [blame] | 950 | mutex_unlock(&q->vb_lock); |
Brandon Philips | 19bc513 | 2007-11-13 20:05:38 -0300 | [diff] [blame] | 951 | } |
| 952 | |
| 953 | |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 954 | ssize_t videobuf_read_stream(struct videobuf_queue *q, |
| 955 | char __user *data, size_t count, loff_t *ppos, |
| 956 | int vbihack, int nonblocking) |
| 957 | { |
| 958 | int rc, retval; |
Mauro Carvalho Chehab | e2c7731 | 2007-12-10 10:53:20 -0300 | [diff] [blame] | 959 | unsigned long flags = 0; |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 960 | |
Mauro Carvalho Chehab | e2c7731 | 2007-12-10 10:53:20 -0300 | [diff] [blame] | 961 | MAGIC_CHECK(q->int_ops->magic, MAGIC_QTYPE_OPS); |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 962 | |
Harvey Harrison | 7e28adb | 2008-04-08 23:20:00 -0300 | [diff] [blame] | 963 | dprintk(2, "%s\n", __func__); |
Mauro Carvalho Chehab | 64f9477 | 2008-01-31 13:57:53 -0300 | [diff] [blame] | 964 | mutex_lock(&q->vb_lock); |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 965 | retval = -EBUSY; |
| 966 | if (q->streaming) |
| 967 | goto done; |
| 968 | if (!q->reading) { |
Adrian Bunk | 3f84307 | 2007-12-12 16:44:54 -0300 | [diff] [blame] | 969 | retval = __videobuf_read_start(q); |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 970 | if (retval < 0) |
| 971 | goto done; |
| 972 | } |
| 973 | |
| 974 | retval = 0; |
| 975 | while (count > 0) { |
| 976 | /* get / wait for data */ |
| 977 | if (NULL == q->read_buf) { |
| 978 | q->read_buf = list_entry(q->stream.next, |
| 979 | struct videobuf_buffer, |
| 980 | stream); |
| 981 | list_del(&q->read_buf->stream); |
| 982 | q->read_off = 0; |
| 983 | } |
| 984 | rc = videobuf_waiton(q->read_buf, nonblocking, 1); |
| 985 | if (rc < 0) { |
| 986 | if (0 == retval) |
| 987 | retval = rc; |
| 988 | break; |
| 989 | } |
| 990 | |
Brandon Philips | 0fc0686 | 2007-11-06 20:02:36 -0300 | [diff] [blame] | 991 | if (q->read_buf->state == VIDEOBUF_DONE) { |
Mauro Carvalho Chehab | e2c7731 | 2007-12-10 10:53:20 -0300 | [diff] [blame] | 992 | rc = CALL(q, copy_stream, q, data + retval, count, |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 993 | retval, vbihack, nonblocking); |
| 994 | if (rc < 0) { |
| 995 | retval = rc; |
| 996 | break; |
| 997 | } |
| 998 | retval += rc; |
| 999 | count -= rc; |
| 1000 | q->read_off += rc; |
| 1001 | } else { |
| 1002 | /* some error */ |
| 1003 | q->read_off = q->read_buf->size; |
| 1004 | if (0 == retval) |
| 1005 | retval = -EIO; |
| 1006 | } |
| 1007 | |
| 1008 | /* requeue buffer when done with copying */ |
| 1009 | if (q->read_off == q->read_buf->size) { |
| 1010 | list_add_tail(&q->read_buf->stream, |
| 1011 | &q->stream); |
Brandon Philips | 0cf4dae | 2008-03-28 10:18:33 -0700 | [diff] [blame] | 1012 | spin_lock_irqsave(q->irqlock, flags); |
Mauro Carvalho Chehab | e2c7731 | 2007-12-10 10:53:20 -0300 | [diff] [blame] | 1013 | q->ops->buf_queue(q, q->read_buf); |
Brandon Philips | 0cf4dae | 2008-03-28 10:18:33 -0700 | [diff] [blame] | 1014 | spin_unlock_irqrestore(q->irqlock, flags); |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 1015 | q->read_buf = NULL; |
| 1016 | } |
| 1017 | if (retval < 0) |
| 1018 | break; |
| 1019 | } |
| 1020 | |
| 1021 | done: |
Mauro Carvalho Chehab | 64f9477 | 2008-01-31 13:57:53 -0300 | [diff] [blame] | 1022 | mutex_unlock(&q->vb_lock); |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 1023 | return retval; |
| 1024 | } |
| 1025 | |
| 1026 | unsigned int videobuf_poll_stream(struct file *file, |
| 1027 | struct videobuf_queue *q, |
| 1028 | poll_table *wait) |
| 1029 | { |
| 1030 | struct videobuf_buffer *buf = NULL; |
| 1031 | unsigned int rc = 0; |
| 1032 | |
Mauro Carvalho Chehab | 64f9477 | 2008-01-31 13:57:53 -0300 | [diff] [blame] | 1033 | mutex_lock(&q->vb_lock); |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 1034 | if (q->streaming) { |
| 1035 | if (!list_empty(&q->stream)) |
| 1036 | buf = list_entry(q->stream.next, |
| 1037 | struct videobuf_buffer, stream); |
| 1038 | } else { |
| 1039 | if (!q->reading) |
Adrian Bunk | 3f84307 | 2007-12-12 16:44:54 -0300 | [diff] [blame] | 1040 | __videobuf_read_start(q); |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 1041 | if (!q->reading) { |
| 1042 | rc = POLLERR; |
| 1043 | } else if (NULL == q->read_buf) { |
| 1044 | q->read_buf = list_entry(q->stream.next, |
| 1045 | struct videobuf_buffer, |
| 1046 | stream); |
| 1047 | list_del(&q->read_buf->stream); |
| 1048 | q->read_off = 0; |
| 1049 | } |
| 1050 | buf = q->read_buf; |
| 1051 | } |
| 1052 | if (!buf) |
| 1053 | rc = POLLERR; |
| 1054 | |
| 1055 | if (0 == rc) { |
| 1056 | poll_wait(file, &buf->done, wait); |
Brandon Philips | 0fc0686 | 2007-11-06 20:02:36 -0300 | [diff] [blame] | 1057 | if (buf->state == VIDEOBUF_DONE || |
| 1058 | buf->state == VIDEOBUF_ERROR) |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 1059 | rc = POLLIN|POLLRDNORM; |
| 1060 | } |
Mauro Carvalho Chehab | 64f9477 | 2008-01-31 13:57:53 -0300 | [diff] [blame] | 1061 | mutex_unlock(&q->vb_lock); |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 1062 | return rc; |
| 1063 | } |
| 1064 | |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 1065 | int videobuf_mmap_mapper(struct videobuf_queue *q, |
| 1066 | struct vm_area_struct *vma) |
| 1067 | { |
| 1068 | int retval; |
| 1069 | |
Mauro Carvalho Chehab | e2c7731 | 2007-12-10 10:53:20 -0300 | [diff] [blame] | 1070 | MAGIC_CHECK(q->int_ops->magic, MAGIC_QTYPE_OPS); |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 1071 | |
Mauro Carvalho Chehab | 64f9477 | 2008-01-31 13:57:53 -0300 | [diff] [blame] | 1072 | mutex_lock(&q->vb_lock); |
Mauro Carvalho Chehab | e2c7731 | 2007-12-10 10:53:20 -0300 | [diff] [blame] | 1073 | retval = CALL(q, mmap_mapper, q, vma); |
Mauro Carvalho Chehab | d05051c | 2008-01-10 07:33:03 -0300 | [diff] [blame] | 1074 | q->is_mmapped = 1; |
Mauro Carvalho Chehab | 64f9477 | 2008-01-31 13:57:53 -0300 | [diff] [blame] | 1075 | mutex_unlock(&q->vb_lock); |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 1076 | |
| 1077 | return retval; |
| 1078 | } |
| 1079 | |
| 1080 | #ifdef CONFIG_VIDEO_V4L1_COMPAT |
| 1081 | int videobuf_cgmbuf(struct videobuf_queue *q, |
| 1082 | struct video_mbuf *mbuf, int count) |
| 1083 | { |
| 1084 | struct v4l2_requestbuffers req; |
Mauro Carvalho Chehab | e2c7731 | 2007-12-10 10:53:20 -0300 | [diff] [blame] | 1085 | int rc, i; |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 1086 | |
Mauro Carvalho Chehab | e2c7731 | 2007-12-10 10:53:20 -0300 | [diff] [blame] | 1087 | MAGIC_CHECK(q->int_ops->magic, MAGIC_QTYPE_OPS); |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 1088 | |
Mauro Carvalho Chehab | e2c7731 | 2007-12-10 10:53:20 -0300 | [diff] [blame] | 1089 | memset(&req, 0, sizeof(req)); |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 1090 | req.type = q->type; |
| 1091 | req.count = count; |
| 1092 | req.memory = V4L2_MEMORY_MMAP; |
Mauro Carvalho Chehab | e2c7731 | 2007-12-10 10:53:20 -0300 | [diff] [blame] | 1093 | rc = videobuf_reqbufs(q, &req); |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 1094 | if (rc < 0) |
| 1095 | return rc; |
| 1096 | |
| 1097 | mbuf->frames = req.count; |
| 1098 | mbuf->size = 0; |
| 1099 | for (i = 0; i < mbuf->frames; i++) { |
| 1100 | mbuf->offsets[i] = q->bufs[i]->boff; |
Tuukka Toivonen | 7cbefad | 2009-07-23 10:56:25 -0300 | [diff] [blame] | 1101 | mbuf->size += PAGE_ALIGN(q->bufs[i]->bsize); |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 1102 | } |
| 1103 | |
| 1104 | return 0; |
| 1105 | } |
Pekka Enberg | a13625c | 2007-10-13 05:54:54 -0300 | [diff] [blame] | 1106 | EXPORT_SYMBOL_GPL(videobuf_cgmbuf); |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 1107 | #endif |
| 1108 | |
| 1109 | /* --------------------------------------------------------------------- */ |
| 1110 | |
| 1111 | EXPORT_SYMBOL_GPL(videobuf_waiton); |
| 1112 | EXPORT_SYMBOL_GPL(videobuf_iolock); |
| 1113 | |
| 1114 | EXPORT_SYMBOL_GPL(videobuf_alloc); |
| 1115 | |
Mauro Carvalho Chehab | d4cae5a | 2007-10-08 12:20:02 -0300 | [diff] [blame] | 1116 | EXPORT_SYMBOL_GPL(videobuf_queue_core_init); |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 1117 | EXPORT_SYMBOL_GPL(videobuf_queue_cancel); |
| 1118 | EXPORT_SYMBOL_GPL(videobuf_queue_is_busy); |
| 1119 | |
| 1120 | EXPORT_SYMBOL_GPL(videobuf_next_field); |
| 1121 | EXPORT_SYMBOL_GPL(videobuf_reqbufs); |
| 1122 | EXPORT_SYMBOL_GPL(videobuf_querybuf); |
| 1123 | EXPORT_SYMBOL_GPL(videobuf_qbuf); |
| 1124 | EXPORT_SYMBOL_GPL(videobuf_dqbuf); |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 1125 | EXPORT_SYMBOL_GPL(videobuf_streamon); |
| 1126 | EXPORT_SYMBOL_GPL(videobuf_streamoff); |
| 1127 | |
Mauro Carvalho Chehab | 19fb14579 | 2007-11-15 23:09:30 -0300 | [diff] [blame] | 1128 | EXPORT_SYMBOL_GPL(videobuf_read_start); |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 1129 | EXPORT_SYMBOL_GPL(videobuf_read_stop); |
Brandon Philips | 19bc513 | 2007-11-13 20:05:38 -0300 | [diff] [blame] | 1130 | EXPORT_SYMBOL_GPL(videobuf_stop); |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 1131 | EXPORT_SYMBOL_GPL(videobuf_read_stream); |
| 1132 | EXPORT_SYMBOL_GPL(videobuf_read_one); |
| 1133 | EXPORT_SYMBOL_GPL(videobuf_poll_stream); |
| 1134 | |
Arjan van de Ven | 81b2dbc | 2008-05-20 09:53:52 -0700 | [diff] [blame] | 1135 | EXPORT_SYMBOL_GPL(__videobuf_mmap_setup); |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 1136 | EXPORT_SYMBOL_GPL(videobuf_mmap_setup); |
| 1137 | EXPORT_SYMBOL_GPL(videobuf_mmap_free); |
| 1138 | EXPORT_SYMBOL_GPL(videobuf_mmap_mapper); |