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> |
| 19 | #include <linux/slab.h> |
| 20 | #include <linux/interrupt.h> |
| 21 | |
| 22 | #include <media/videobuf-core.h> |
| 23 | |
| 24 | #define MAGIC_BUFFER 0x20070728 |
Mauro Carvalho Chehab | e2c7731 | 2007-12-10 10:53:20 -0300 | [diff] [blame] | 25 | #define MAGIC_CHECK(is, should) do { \ |
| 26 | if (unlikely((is) != (should))) { \ |
| 27 | printk(KERN_ERR "magic mismatch: %x (expected %x)\n", is, should); \ |
| 28 | BUG(); } } while (0) |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 29 | |
Mauro Carvalho Chehab | e2c7731 | 2007-12-10 10:53:20 -0300 | [diff] [blame] | 30 | static int debug; |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 31 | module_param(debug, int, 0644); |
| 32 | |
| 33 | MODULE_DESCRIPTION("helper module to manage video4linux buffers"); |
| 34 | MODULE_AUTHOR("Mauro Carvalho Chehab <mchehab@infradead.org>"); |
| 35 | MODULE_LICENSE("GPL"); |
| 36 | |
Mauro Carvalho Chehab | e2c7731 | 2007-12-10 10:53:20 -0300 | [diff] [blame] | 37 | #define dprintk(level, fmt, arg...) do { \ |
| 38 | if (debug >= level) \ |
| 39 | printk(KERN_DEBUG "vbuf: " fmt , ## arg); } while (0) |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 40 | |
| 41 | /* --------------------------------------------------------------------- */ |
| 42 | |
| 43 | #define CALL(q, f, arg...) \ |
Mauro Carvalho Chehab | e2c7731 | 2007-12-10 10:53:20 -0300 | [diff] [blame] | 44 | ((q->int_ops->f) ? q->int_ops->f(arg) : 0) |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 45 | |
Mauro Carvalho Chehab | e2c7731 | 2007-12-10 10:53:20 -0300 | [diff] [blame] | 46 | void *videobuf_alloc(struct videobuf_queue *q) |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 47 | { |
| 48 | struct videobuf_buffer *vb; |
| 49 | |
Mauro Carvalho Chehab | e2c7731 | 2007-12-10 10:53:20 -0300 | [diff] [blame] | 50 | BUG_ON(q->msize < sizeof(*vb)); |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 51 | |
| 52 | if (!q->int_ops || !q->int_ops->alloc) { |
| 53 | printk(KERN_ERR "No specific ops defined!\n"); |
| 54 | BUG(); |
| 55 | } |
| 56 | |
| 57 | vb = q->int_ops->alloc(q->msize); |
| 58 | |
| 59 | if (NULL != vb) { |
| 60 | init_waitqueue_head(&vb->done); |
| 61 | vb->magic = MAGIC_BUFFER; |
| 62 | } |
| 63 | |
| 64 | return vb; |
| 65 | } |
| 66 | |
Brandon Philips | 009a905 | 2008-04-02 18:10:59 -0300 | [diff] [blame] | 67 | #define WAITON_CONDITION (vb->state != VIDEOBUF_ACTIVE &&\ |
| 68 | vb->state != VIDEOBUF_QUEUED) |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 69 | int videobuf_waiton(struct videobuf_buffer *vb, int non_blocking, int intr) |
| 70 | { |
Mauro Carvalho Chehab | e2c7731 | 2007-12-10 10:53:20 -0300 | [diff] [blame] | 71 | MAGIC_CHECK(vb->magic, MAGIC_BUFFER); |
Brandon Philips | 009a905 | 2008-04-02 18:10:59 -0300 | [diff] [blame] | 72 | |
| 73 | if (non_blocking) { |
| 74 | if (WAITON_CONDITION) |
| 75 | return 0; |
| 76 | else |
| 77 | return -EAGAIN; |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 78 | } |
Brandon Philips | 009a905 | 2008-04-02 18:10:59 -0300 | [diff] [blame] | 79 | |
| 80 | if (intr) |
| 81 | return wait_event_interruptible(vb->done, WAITON_CONDITION); |
| 82 | else |
| 83 | wait_event(vb->done, WAITON_CONDITION); |
| 84 | |
| 85 | return 0; |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 86 | } |
| 87 | |
Mauro Carvalho Chehab | e2c7731 | 2007-12-10 10:53:20 -0300 | [diff] [blame] | 88 | int videobuf_iolock(struct videobuf_queue *q, struct videobuf_buffer *vb, |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 89 | struct v4l2_framebuffer *fbuf) |
| 90 | { |
Mauro Carvalho Chehab | e2c7731 | 2007-12-10 10:53:20 -0300 | [diff] [blame] | 91 | MAGIC_CHECK(vb->magic, MAGIC_BUFFER); |
| 92 | MAGIC_CHECK(q->int_ops->magic, MAGIC_QTYPE_OPS); |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 93 | |
Mauro Carvalho Chehab | d05051c | 2008-01-10 07:33:03 -0300 | [diff] [blame] | 94 | /* This is required to avoid OOPS on some cases, |
Mauro Carvalho Chehab | e2c7731 | 2007-12-10 10:53:20 -0300 | [diff] [blame] | 95 | since mmap_mapper() method should be called before _iolock. |
Mauro Carvalho Chehab | d5f1b01 | 2007-10-08 11:48:57 -0300 | [diff] [blame] | 96 | On some cases, the mmap_mapper() is called only after scheduling. |
Mauro Carvalho Chehab | d5f1b01 | 2007-10-08 11:48:57 -0300 | [diff] [blame] | 97 | */ |
Mauro Carvalho Chehab | 1f8d300 | 2008-01-13 19:40:30 -0300 | [diff] [blame] | 98 | if (vb->memory == V4L2_MEMORY_MMAP) { |
| 99 | wait_event_timeout(vb->done, q->is_mmapped, |
| 100 | msecs_to_jiffies(100)); |
| 101 | if (!q->is_mmapped) { |
| 102 | printk(KERN_ERR |
| 103 | "Error: mmap_mapper() never called!\n"); |
| 104 | return -EINVAL; |
| 105 | } |
Mauro Carvalho Chehab | d05051c | 2008-01-10 07:33:03 -0300 | [diff] [blame] | 106 | } |
Mauro Carvalho Chehab | d5f1b01 | 2007-10-08 11:48:57 -0300 | [diff] [blame] | 107 | |
Mauro Carvalho Chehab | e2c7731 | 2007-12-10 10:53:20 -0300 | [diff] [blame] | 108 | return CALL(q, iolock, q, vb, fbuf); |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 109 | } |
| 110 | |
| 111 | /* --------------------------------------------------------------------- */ |
| 112 | |
| 113 | |
Mauro Carvalho Chehab | e2c7731 | 2007-12-10 10:53:20 -0300 | [diff] [blame] | 114 | void videobuf_queue_core_init(struct videobuf_queue *q, |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 115 | struct videobuf_queue_ops *ops, |
Guennadi Liakhovetski | e9bcf66 | 2008-04-22 14:46:02 -0300 | [diff] [blame] | 116 | struct device *dev, |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 117 | spinlock_t *irqlock, |
| 118 | enum v4l2_buf_type type, |
| 119 | enum v4l2_field field, |
| 120 | unsigned int msize, |
Mauro Carvalho Chehab | d4cae5a | 2007-10-08 12:20:02 -0300 | [diff] [blame] | 121 | void *priv, |
| 122 | struct videobuf_qtype_ops *int_ops) |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 123 | { |
Mauro Carvalho Chehab | e2c7731 | 2007-12-10 10:53:20 -0300 | [diff] [blame] | 124 | memset(q, 0, sizeof(*q)); |
Mauro Carvalho Chehab | d4cae5a | 2007-10-08 12:20:02 -0300 | [diff] [blame] | 125 | q->irqlock = irqlock; |
| 126 | q->dev = dev; |
| 127 | q->type = type; |
| 128 | q->field = field; |
| 129 | q->msize = msize; |
| 130 | q->ops = ops; |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 131 | q->priv_data = priv; |
Mauro Carvalho Chehab | d4cae5a | 2007-10-08 12:20:02 -0300 | [diff] [blame] | 132 | q->int_ops = int_ops; |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 133 | |
| 134 | /* All buffer operations are mandatory */ |
Mauro Carvalho Chehab | e2c7731 | 2007-12-10 10:53:20 -0300 | [diff] [blame] | 135 | BUG_ON(!q->ops->buf_setup); |
| 136 | BUG_ON(!q->ops->buf_prepare); |
| 137 | BUG_ON(!q->ops->buf_queue); |
| 138 | BUG_ON(!q->ops->buf_release); |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 139 | |
Mauro Carvalho Chehab | d4cae5a | 2007-10-08 12:20:02 -0300 | [diff] [blame] | 140 | /* Having implementations for abstract methods are mandatory */ |
Mauro Carvalho Chehab | e2c7731 | 2007-12-10 10:53:20 -0300 | [diff] [blame] | 141 | BUG_ON(!q->int_ops); |
Mauro Carvalho Chehab | d4cae5a | 2007-10-08 12:20:02 -0300 | [diff] [blame] | 142 | |
Mauro Carvalho Chehab | 64f9477 | 2008-01-31 13:57:53 -0300 | [diff] [blame] | 143 | mutex_init(&q->vb_lock); |
Brandon Philips | 137d1cb | 2008-04-02 18:10:59 -0300 | [diff] [blame] | 144 | init_waitqueue_head(&q->wait); |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 145 | INIT_LIST_HEAD(&q->stream); |
| 146 | } |
| 147 | |
Brandon Philips | 19bc513 | 2007-11-13 20:05:38 -0300 | [diff] [blame] | 148 | /* Locking: Only usage in bttv unsafe find way to remove */ |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 149 | int videobuf_queue_is_busy(struct videobuf_queue *q) |
| 150 | { |
| 151 | int i; |
| 152 | |
Mauro Carvalho Chehab | e2c7731 | 2007-12-10 10:53:20 -0300 | [diff] [blame] | 153 | MAGIC_CHECK(q->int_ops->magic, MAGIC_QTYPE_OPS); |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 154 | |
| 155 | if (q->streaming) { |
Mauro Carvalho Chehab | e2c7731 | 2007-12-10 10:53:20 -0300 | [diff] [blame] | 156 | dprintk(1, "busy: streaming active\n"); |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 157 | return 1; |
| 158 | } |
| 159 | if (q->reading) { |
Mauro Carvalho Chehab | e2c7731 | 2007-12-10 10:53:20 -0300 | [diff] [blame] | 160 | dprintk(1, "busy: pending read #1\n"); |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 161 | return 1; |
| 162 | } |
| 163 | if (q->read_buf) { |
Mauro Carvalho Chehab | e2c7731 | 2007-12-10 10:53:20 -0300 | [diff] [blame] | 164 | dprintk(1, "busy: pending read #2\n"); |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 165 | return 1; |
| 166 | } |
| 167 | for (i = 0; i < VIDEO_MAX_FRAME; i++) { |
| 168 | if (NULL == q->bufs[i]) |
| 169 | continue; |
Mauro Carvalho Chehab | 851c0c9 | 2007-09-27 18:25:44 -0300 | [diff] [blame] | 170 | if (q->bufs[i]->map) { |
Mauro Carvalho Chehab | e2c7731 | 2007-12-10 10:53:20 -0300 | [diff] [blame] | 171 | dprintk(1, "busy: buffer #%d mapped\n", i); |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 172 | return 1; |
| 173 | } |
Brandon Philips | 0fc0686 | 2007-11-06 20:02:36 -0300 | [diff] [blame] | 174 | if (q->bufs[i]->state == VIDEOBUF_QUEUED) { |
Mauro Carvalho Chehab | e2c7731 | 2007-12-10 10:53:20 -0300 | [diff] [blame] | 175 | dprintk(1, "busy: buffer #%d queued\n", i); |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 176 | return 1; |
| 177 | } |
Brandon Philips | 0fc0686 | 2007-11-06 20:02:36 -0300 | [diff] [blame] | 178 | if (q->bufs[i]->state == VIDEOBUF_ACTIVE) { |
Mauro Carvalho Chehab | e2c7731 | 2007-12-10 10:53:20 -0300 | [diff] [blame] | 179 | dprintk(1, "busy: buffer #%d avtive\n", i); |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 180 | return 1; |
| 181 | } |
| 182 | } |
| 183 | return 0; |
| 184 | } |
| 185 | |
Mauro Carvalho Chehab | 64f9477 | 2008-01-31 13:57:53 -0300 | [diff] [blame] | 186 | /* Locking: Caller holds q->vb_lock */ |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 187 | void videobuf_queue_cancel(struct videobuf_queue *q) |
| 188 | { |
Mauro Carvalho Chehab | e2c7731 | 2007-12-10 10:53:20 -0300 | [diff] [blame] | 189 | unsigned long flags = 0; |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 190 | int i; |
| 191 | |
Brandon Philips | 137d1cb | 2008-04-02 18:10:59 -0300 | [diff] [blame] | 192 | q->streaming = 0; |
| 193 | q->reading = 0; |
| 194 | wake_up_interruptible_sync(&q->wait); |
| 195 | |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 196 | /* remove queued buffers from list */ |
| 197 | if (q->irqlock) |
Mauro Carvalho Chehab | e2c7731 | 2007-12-10 10:53:20 -0300 | [diff] [blame] | 198 | spin_lock_irqsave(q->irqlock, flags); |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 199 | for (i = 0; i < VIDEO_MAX_FRAME; i++) { |
| 200 | if (NULL == q->bufs[i]) |
| 201 | continue; |
Brandon Philips | 0fc0686 | 2007-11-06 20:02:36 -0300 | [diff] [blame] | 202 | if (q->bufs[i]->state == VIDEOBUF_QUEUED) { |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 203 | list_del(&q->bufs[i]->queue); |
Brandon Philips | 0fc0686 | 2007-11-06 20:02:36 -0300 | [diff] [blame] | 204 | q->bufs[i]->state = VIDEOBUF_ERROR; |
Brandon Philips | b608f43 | 2008-04-02 18:10:57 -0300 | [diff] [blame] | 205 | wake_up_all(&q->bufs[i]->done); |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 206 | } |
| 207 | } |
| 208 | if (q->irqlock) |
Mauro Carvalho Chehab | e2c7731 | 2007-12-10 10:53:20 -0300 | [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 */ |
Brandon Philips | 19bc513 | 2007-11-13 20:05:38 -0300 | [diff] [blame] | 337 | static int __videobuf_mmap_setup(struct videobuf_queue *q, |
| 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: |
| 363 | q->bufs[i]->boff = bsize * i; |
| 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 | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 433 | size = PAGE_ALIGN(size); |
Mauro Carvalho Chehab | e2c7731 | 2007-12-10 10:53:20 -0300 | [diff] [blame] | 434 | dprintk(1, "reqbufs: bufs=%d, size=0x%x [%d pages total]\n", |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 435 | count, size, (count*size)>>PAGE_SHIFT); |
| 436 | |
Mauro Carvalho Chehab | e2c7731 | 2007-12-10 10:53:20 -0300 | [diff] [blame] | 437 | retval = __videobuf_mmap_setup(q, count, size, req->memory); |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 438 | if (retval < 0) { |
Mauro Carvalho Chehab | e2c7731 | 2007-12-10 10:53:20 -0300 | [diff] [blame] | 439 | dprintk(1, "reqbufs: mmap setup returned %d\n", retval); |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 440 | goto done; |
| 441 | } |
| 442 | |
Brandon Philips | 49ee718 | 2007-10-05 16:26:27 -0300 | [diff] [blame] | 443 | req->count = retval; |
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 | } |
| 459 | if (unlikely(b->index < 0 || 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 | } |
| 500 | if (b->index < 0 || 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) { |
| 565 | if (q->irqlock) |
Mauro Carvalho Chehab | e2c7731 | 2007-12-10 10:53:20 -0300 | [diff] [blame] | 566 | spin_lock_irqsave(q->irqlock, flags); |
| 567 | q->ops->buf_queue(q, buf); |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 568 | if (q->irqlock) |
Mauro Carvalho Chehab | e2c7731 | 2007-12-10 10:53:20 -0300 | [diff] [blame] | 569 | spin_unlock_irqrestore(q->irqlock, flags); |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 570 | } |
Mauro Carvalho Chehab | e2c7731 | 2007-12-10 10:53:20 -0300 | [diff] [blame] | 571 | dprintk(1, "qbuf: succeded\n"); |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 572 | retval = 0; |
Brandon Philips | 137d1cb | 2008-04-02 18:10:59 -0300 | [diff] [blame] | 573 | wake_up_interruptible_sync(&q->wait); |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 574 | |
| 575 | done: |
Mauro Carvalho Chehab | 64f9477 | 2008-01-31 13:57:53 -0300 | [diff] [blame] | 576 | mutex_unlock(&q->vb_lock); |
Maxim Levitsky | 9900132 | 2007-09-27 20:34:09 -0300 | [diff] [blame] | 577 | |
| 578 | if (b->memory == V4L2_MEMORY_MMAP) |
| 579 | up_read(¤t->mm->mmap_sem); |
| 580 | |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 581 | return retval; |
| 582 | } |
| 583 | |
Brandon Philips | 137d1cb | 2008-04-02 18:10:59 -0300 | [diff] [blame] | 584 | |
| 585 | /* Locking: Caller holds q->vb_lock */ |
| 586 | static int stream_next_buffer_check_queue(struct videobuf_queue *q, int noblock) |
| 587 | { |
| 588 | int retval; |
| 589 | |
| 590 | checks: |
| 591 | if (!q->streaming) { |
| 592 | dprintk(1, "next_buffer: Not streaming\n"); |
| 593 | retval = -EINVAL; |
| 594 | goto done; |
| 595 | } |
| 596 | |
| 597 | if (list_empty(&q->stream)) { |
| 598 | if (noblock) { |
| 599 | retval = -EAGAIN; |
| 600 | dprintk(2, "next_buffer: no buffers to dequeue\n"); |
| 601 | goto done; |
| 602 | } else { |
| 603 | dprintk(2, "next_buffer: waiting on buffer\n"); |
| 604 | |
| 605 | /* Drop lock to avoid deadlock with qbuf */ |
| 606 | mutex_unlock(&q->vb_lock); |
| 607 | |
| 608 | /* Checking list_empty and streaming is safe without |
| 609 | * locks because we goto checks to validate while |
| 610 | * holding locks before proceeding */ |
| 611 | retval = wait_event_interruptible(q->wait, |
| 612 | !list_empty(&q->stream) || !q->streaming); |
| 613 | mutex_lock(&q->vb_lock); |
| 614 | |
| 615 | if (retval) |
| 616 | goto done; |
| 617 | |
| 618 | goto checks; |
| 619 | } |
| 620 | } |
| 621 | |
| 622 | retval = 0; |
| 623 | |
| 624 | done: |
| 625 | return retval; |
| 626 | } |
| 627 | |
| 628 | |
| 629 | /* Locking: Caller holds q->vb_lock */ |
| 630 | static int stream_next_buffer(struct videobuf_queue *q, |
| 631 | struct videobuf_buffer **vb, int nonblocking) |
| 632 | { |
| 633 | int retval; |
| 634 | struct videobuf_buffer *buf = NULL; |
| 635 | |
| 636 | retval = stream_next_buffer_check_queue(q, nonblocking); |
| 637 | if (retval) |
| 638 | goto done; |
| 639 | |
| 640 | buf = list_entry(q->stream.next, struct videobuf_buffer, stream); |
| 641 | retval = videobuf_waiton(buf, nonblocking, 1); |
| 642 | if (retval < 0) |
| 643 | goto done; |
| 644 | |
| 645 | *vb = buf; |
| 646 | done: |
| 647 | return retval; |
| 648 | } |
| 649 | |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 650 | int videobuf_dqbuf(struct videobuf_queue *q, |
| 651 | struct v4l2_buffer *b, int nonblocking) |
| 652 | { |
Brandon Philips | 137d1cb | 2008-04-02 18:10:59 -0300 | [diff] [blame] | 653 | struct videobuf_buffer *buf = NULL; |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 654 | int retval; |
| 655 | |
Mauro Carvalho Chehab | e2c7731 | 2007-12-10 10:53:20 -0300 | [diff] [blame] | 656 | MAGIC_CHECK(q->int_ops->magic, MAGIC_QTYPE_OPS); |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 657 | |
Mauro Carvalho Chehab | 64f9477 | 2008-01-31 13:57:53 -0300 | [diff] [blame] | 658 | mutex_lock(&q->vb_lock); |
Brandon Philips | 137d1cb | 2008-04-02 18:10:59 -0300 | [diff] [blame] | 659 | |
| 660 | retval = stream_next_buffer(q, &buf, nonblocking); |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 661 | if (retval < 0) { |
Brandon Philips | 137d1cb | 2008-04-02 18:10:59 -0300 | [diff] [blame] | 662 | dprintk(1, "dqbuf: next_buffer error: %i\n", retval); |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 663 | goto done; |
| 664 | } |
Brandon Philips | 137d1cb | 2008-04-02 18:10:59 -0300 | [diff] [blame] | 665 | |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 666 | switch (buf->state) { |
Brandon Philips | 0fc0686 | 2007-11-06 20:02:36 -0300 | [diff] [blame] | 667 | case VIDEOBUF_ERROR: |
Mauro Carvalho Chehab | e2c7731 | 2007-12-10 10:53:20 -0300 | [diff] [blame] | 668 | dprintk(1, "dqbuf: state is error\n"); |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 669 | retval = -EIO; |
Mauro Carvalho Chehab | e2c7731 | 2007-12-10 10:53:20 -0300 | [diff] [blame] | 670 | CALL(q, sync, q, buf); |
Brandon Philips | 0fc0686 | 2007-11-06 20:02:36 -0300 | [diff] [blame] | 671 | buf->state = VIDEOBUF_IDLE; |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 672 | break; |
Brandon Philips | 0fc0686 | 2007-11-06 20:02:36 -0300 | [diff] [blame] | 673 | case VIDEOBUF_DONE: |
Mauro Carvalho Chehab | e2c7731 | 2007-12-10 10:53:20 -0300 | [diff] [blame] | 674 | dprintk(1, "dqbuf: state is done\n"); |
| 675 | CALL(q, sync, q, buf); |
Brandon Philips | 0fc0686 | 2007-11-06 20:02:36 -0300 | [diff] [blame] | 676 | buf->state = VIDEOBUF_IDLE; |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 677 | break; |
| 678 | default: |
Mauro Carvalho Chehab | e2c7731 | 2007-12-10 10:53:20 -0300 | [diff] [blame] | 679 | dprintk(1, "dqbuf: state invalid\n"); |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 680 | retval = -EINVAL; |
| 681 | goto done; |
| 682 | } |
| 683 | list_del(&buf->stream); |
Mauro Carvalho Chehab | e2c7731 | 2007-12-10 10:53:20 -0300 | [diff] [blame] | 684 | memset(b, 0, sizeof(*b)); |
| 685 | videobuf_status(q, b, buf, q->type); |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 686 | |
| 687 | done: |
Mauro Carvalho Chehab | 64f9477 | 2008-01-31 13:57:53 -0300 | [diff] [blame] | 688 | mutex_unlock(&q->vb_lock); |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 689 | return retval; |
| 690 | } |
| 691 | |
| 692 | int videobuf_streamon(struct videobuf_queue *q) |
| 693 | { |
| 694 | struct videobuf_buffer *buf; |
Mauro Carvalho Chehab | e2c7731 | 2007-12-10 10:53:20 -0300 | [diff] [blame] | 695 | unsigned long flags = 0; |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 696 | int retval; |
| 697 | |
Mauro Carvalho Chehab | 64f9477 | 2008-01-31 13:57:53 -0300 | [diff] [blame] | 698 | mutex_lock(&q->vb_lock); |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 699 | retval = -EBUSY; |
| 700 | if (q->reading) |
| 701 | goto done; |
| 702 | retval = 0; |
| 703 | if (q->streaming) |
| 704 | goto done; |
| 705 | q->streaming = 1; |
| 706 | if (q->irqlock) |
Mauro Carvalho Chehab | e2c7731 | 2007-12-10 10:53:20 -0300 | [diff] [blame] | 707 | spin_lock_irqsave(q->irqlock, flags); |
Trent Piepho | a991f44 | 2007-10-10 05:37:43 -0300 | [diff] [blame] | 708 | list_for_each_entry(buf, &q->stream, stream) |
Brandon Philips | 0fc0686 | 2007-11-06 20:02:36 -0300 | [diff] [blame] | 709 | if (buf->state == VIDEOBUF_PREPARED) |
Mauro Carvalho Chehab | e2c7731 | 2007-12-10 10:53:20 -0300 | [diff] [blame] | 710 | q->ops->buf_queue(q, buf); |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 711 | if (q->irqlock) |
Mauro Carvalho Chehab | e2c7731 | 2007-12-10 10:53:20 -0300 | [diff] [blame] | 712 | spin_unlock_irqrestore(q->irqlock, flags); |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 713 | |
Brandon Philips | 137d1cb | 2008-04-02 18:10:59 -0300 | [diff] [blame] | 714 | wake_up_interruptible_sync(&q->wait); |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 715 | done: |
Mauro Carvalho Chehab | 64f9477 | 2008-01-31 13:57:53 -0300 | [diff] [blame] | 716 | mutex_unlock(&q->vb_lock); |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 717 | return retval; |
| 718 | } |
| 719 | |
Mauro Carvalho Chehab | 64f9477 | 2008-01-31 13:57:53 -0300 | [diff] [blame] | 720 | /* Locking: Caller holds q->vb_lock */ |
Brandon Philips | 19bc513 | 2007-11-13 20:05:38 -0300 | [diff] [blame] | 721 | static int __videobuf_streamoff(struct videobuf_queue *q) |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 722 | { |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 723 | if (!q->streaming) |
Brandon Philips | 19bc513 | 2007-11-13 20:05:38 -0300 | [diff] [blame] | 724 | return -EINVAL; |
| 725 | |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 726 | videobuf_queue_cancel(q); |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 727 | |
Brandon Philips | 19bc513 | 2007-11-13 20:05:38 -0300 | [diff] [blame] | 728 | return 0; |
| 729 | } |
| 730 | |
| 731 | int videobuf_streamoff(struct videobuf_queue *q) |
| 732 | { |
| 733 | int retval; |
| 734 | |
Mauro Carvalho Chehab | 64f9477 | 2008-01-31 13:57:53 -0300 | [diff] [blame] | 735 | mutex_lock(&q->vb_lock); |
Brandon Philips | 19bc513 | 2007-11-13 20:05:38 -0300 | [diff] [blame] | 736 | retval = __videobuf_streamoff(q); |
Mauro Carvalho Chehab | 64f9477 | 2008-01-31 13:57:53 -0300 | [diff] [blame] | 737 | mutex_unlock(&q->vb_lock); |
Brandon Philips | 19bc513 | 2007-11-13 20:05:38 -0300 | [diff] [blame] | 738 | |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 739 | return retval; |
| 740 | } |
| 741 | |
Mauro Carvalho Chehab | 64f9477 | 2008-01-31 13:57:53 -0300 | [diff] [blame] | 742 | /* Locking: Caller holds q->vb_lock */ |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 743 | static ssize_t videobuf_read_zerocopy(struct videobuf_queue *q, |
| 744 | char __user *data, |
| 745 | size_t count, loff_t *ppos) |
| 746 | { |
| 747 | enum v4l2_field field; |
Mauro Carvalho Chehab | e2c7731 | 2007-12-10 10:53:20 -0300 | [diff] [blame] | 748 | unsigned long flags = 0; |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 749 | int retval; |
| 750 | |
Mauro Carvalho Chehab | e2c7731 | 2007-12-10 10:53:20 -0300 | [diff] [blame] | 751 | MAGIC_CHECK(q->int_ops->magic, MAGIC_QTYPE_OPS); |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 752 | |
| 753 | /* setup stuff */ |
| 754 | q->read_buf = videobuf_alloc(q); |
| 755 | if (NULL == q->read_buf) |
| 756 | return -ENOMEM; |
| 757 | |
| 758 | q->read_buf->memory = V4L2_MEMORY_USERPTR; |
| 759 | q->read_buf->baddr = (unsigned long)data; |
| 760 | q->read_buf->bsize = count; |
| 761 | |
| 762 | field = videobuf_next_field(q); |
Mauro Carvalho Chehab | e2c7731 | 2007-12-10 10:53:20 -0300 | [diff] [blame] | 763 | retval = q->ops->buf_prepare(q, q->read_buf, field); |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 764 | if (0 != retval) |
| 765 | goto done; |
| 766 | |
| 767 | /* start capture & wait */ |
| 768 | if (q->irqlock) |
Mauro Carvalho Chehab | e2c7731 | 2007-12-10 10:53:20 -0300 | [diff] [blame] | 769 | spin_lock_irqsave(q->irqlock, flags); |
| 770 | q->ops->buf_queue(q, q->read_buf); |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 771 | if (q->irqlock) |
Mauro Carvalho Chehab | e2c7731 | 2007-12-10 10:53:20 -0300 | [diff] [blame] | 772 | spin_unlock_irqrestore(q->irqlock, flags); |
| 773 | retval = videobuf_waiton(q->read_buf, 0, 0); |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 774 | if (0 == retval) { |
Mauro Carvalho Chehab | e2c7731 | 2007-12-10 10:53:20 -0300 | [diff] [blame] | 775 | CALL(q, sync, q, q->read_buf); |
Brandon Philips | 0fc0686 | 2007-11-06 20:02:36 -0300 | [diff] [blame] | 776 | if (VIDEOBUF_ERROR == q->read_buf->state) |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 777 | retval = -EIO; |
| 778 | else |
| 779 | retval = q->read_buf->size; |
| 780 | } |
| 781 | |
| 782 | done: |
| 783 | /* cleanup */ |
Mauro Carvalho Chehab | e2c7731 | 2007-12-10 10:53:20 -0300 | [diff] [blame] | 784 | q->ops->buf_release(q, q->read_buf); |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 785 | kfree(q->read_buf); |
| 786 | q->read_buf = NULL; |
| 787 | return retval; |
| 788 | } |
| 789 | |
| 790 | ssize_t videobuf_read_one(struct videobuf_queue *q, |
| 791 | char __user *data, size_t count, loff_t *ppos, |
| 792 | int nonblocking) |
| 793 | { |
| 794 | enum v4l2_field field; |
Mauro Carvalho Chehab | e2c7731 | 2007-12-10 10:53:20 -0300 | [diff] [blame] | 795 | unsigned long flags = 0; |
Guennadi Liakhovetski | 7daa4a8 | 2008-04-22 14:46:03 -0300 | [diff] [blame] | 796 | unsigned size = 0, nbufs = 1; |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 797 | int retval; |
| 798 | |
Mauro Carvalho Chehab | e2c7731 | 2007-12-10 10:53:20 -0300 | [diff] [blame] | 799 | MAGIC_CHECK(q->int_ops->magic, MAGIC_QTYPE_OPS); |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 800 | |
Mauro Carvalho Chehab | 64f9477 | 2008-01-31 13:57:53 -0300 | [diff] [blame] | 801 | mutex_lock(&q->vb_lock); |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 802 | |
Mauro Carvalho Chehab | e2c7731 | 2007-12-10 10:53:20 -0300 | [diff] [blame] | 803 | q->ops->buf_setup(q, &nbufs, &size); |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 804 | |
| 805 | if (NULL == q->read_buf && |
| 806 | count >= size && |
| 807 | !nonblocking) { |
Mauro Carvalho Chehab | e2c7731 | 2007-12-10 10:53:20 -0300 | [diff] [blame] | 808 | retval = videobuf_read_zerocopy(q, data, count, ppos); |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 809 | if (retval >= 0 || retval == -EIO) |
| 810 | /* ok, all done */ |
| 811 | goto done; |
| 812 | /* fallback to kernel bounce buffer on failures */ |
| 813 | } |
| 814 | |
| 815 | if (NULL == q->read_buf) { |
| 816 | /* need to capture a new frame */ |
| 817 | retval = -ENOMEM; |
| 818 | q->read_buf = videobuf_alloc(q); |
| 819 | |
Mauro Carvalho Chehab | e2c7731 | 2007-12-10 10:53:20 -0300 | [diff] [blame] | 820 | dprintk(1, "video alloc=0x%p\n", q->read_buf); |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 821 | if (NULL == q->read_buf) |
| 822 | goto done; |
| 823 | q->read_buf->memory = V4L2_MEMORY_USERPTR; |
| 824 | q->read_buf->bsize = count; /* preferred size */ |
| 825 | field = videobuf_next_field(q); |
Mauro Carvalho Chehab | e2c7731 | 2007-12-10 10:53:20 -0300 | [diff] [blame] | 826 | retval = q->ops->buf_prepare(q, q->read_buf, field); |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 827 | |
| 828 | if (0 != retval) { |
Mauro Carvalho Chehab | e2c7731 | 2007-12-10 10:53:20 -0300 | [diff] [blame] | 829 | kfree(q->read_buf); |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 830 | q->read_buf = NULL; |
| 831 | goto done; |
| 832 | } |
| 833 | if (q->irqlock) |
Mauro Carvalho Chehab | e2c7731 | 2007-12-10 10:53:20 -0300 | [diff] [blame] | 834 | spin_lock_irqsave(q->irqlock, flags); |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 835 | |
Mauro Carvalho Chehab | e2c7731 | 2007-12-10 10:53:20 -0300 | [diff] [blame] | 836 | q->ops->buf_queue(q, q->read_buf); |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 837 | if (q->irqlock) |
Mauro Carvalho Chehab | e2c7731 | 2007-12-10 10:53:20 -0300 | [diff] [blame] | 838 | spin_unlock_irqrestore(q->irqlock, flags); |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 839 | q->read_off = 0; |
| 840 | } |
| 841 | |
| 842 | /* wait until capture is done */ |
| 843 | retval = videobuf_waiton(q->read_buf, nonblocking, 1); |
| 844 | if (0 != retval) |
| 845 | goto done; |
| 846 | |
Mauro Carvalho Chehab | e2c7731 | 2007-12-10 10:53:20 -0300 | [diff] [blame] | 847 | CALL(q, sync, q, q->read_buf); |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 848 | |
Brandon Philips | 0fc0686 | 2007-11-06 20:02:36 -0300 | [diff] [blame] | 849 | if (VIDEOBUF_ERROR == q->read_buf->state) { |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 850 | /* catch I/O errors */ |
Mauro Carvalho Chehab | e2c7731 | 2007-12-10 10:53:20 -0300 | [diff] [blame] | 851 | q->ops->buf_release(q, q->read_buf); |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 852 | kfree(q->read_buf); |
| 853 | q->read_buf = NULL; |
| 854 | retval = -EIO; |
| 855 | goto done; |
| 856 | } |
| 857 | |
| 858 | /* Copy to userspace */ |
Mauro Carvalho Chehab | e2c7731 | 2007-12-10 10:53:20 -0300 | [diff] [blame] | 859 | retval = CALL(q, video_copy_to_user, q, data, count, nonblocking); |
| 860 | if (retval < 0) |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 861 | goto done; |
| 862 | |
| 863 | q->read_off += retval; |
| 864 | if (q->read_off == q->read_buf->size) { |
| 865 | /* all data copied, cleanup */ |
Mauro Carvalho Chehab | e2c7731 | 2007-12-10 10:53:20 -0300 | [diff] [blame] | 866 | q->ops->buf_release(q, q->read_buf); |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 867 | kfree(q->read_buf); |
| 868 | q->read_buf = NULL; |
| 869 | } |
| 870 | |
| 871 | done: |
Mauro Carvalho Chehab | 64f9477 | 2008-01-31 13:57:53 -0300 | [diff] [blame] | 872 | mutex_unlock(&q->vb_lock); |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 873 | return retval; |
| 874 | } |
| 875 | |
Mauro Carvalho Chehab | 64f9477 | 2008-01-31 13:57:53 -0300 | [diff] [blame] | 876 | /* Locking: Caller holds q->vb_lock */ |
Mauro Carvalho Chehab | 225ba90 | 2007-12-12 21:46:26 -0300 | [diff] [blame] | 877 | static int __videobuf_read_start(struct videobuf_queue *q) |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 878 | { |
| 879 | enum v4l2_field field; |
Mauro Carvalho Chehab | e2c7731 | 2007-12-10 10:53:20 -0300 | [diff] [blame] | 880 | unsigned long flags = 0; |
Brandon Philips | 49ee718 | 2007-10-05 16:26:27 -0300 | [diff] [blame] | 881 | unsigned int count = 0, size = 0; |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 882 | int err, i; |
| 883 | |
Mauro Carvalho Chehab | e2c7731 | 2007-12-10 10:53:20 -0300 | [diff] [blame] | 884 | q->ops->buf_setup(q, &count, &size); |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 885 | if (count < 2) |
| 886 | count = 2; |
| 887 | if (count > VIDEO_MAX_FRAME) |
| 888 | count = VIDEO_MAX_FRAME; |
| 889 | size = PAGE_ALIGN(size); |
| 890 | |
Brandon Philips | 19bc513 | 2007-11-13 20:05:38 -0300 | [diff] [blame] | 891 | err = __videobuf_mmap_setup(q, count, size, V4L2_MEMORY_USERPTR); |
Brandon Philips | 49ee718 | 2007-10-05 16:26:27 -0300 | [diff] [blame] | 892 | if (err < 0) |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 893 | return err; |
| 894 | |
Brandon Philips | 49ee718 | 2007-10-05 16:26:27 -0300 | [diff] [blame] | 895 | count = err; |
| 896 | |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 897 | for (i = 0; i < count; i++) { |
| 898 | field = videobuf_next_field(q); |
Mauro Carvalho Chehab | e2c7731 | 2007-12-10 10:53:20 -0300 | [diff] [blame] | 899 | err = q->ops->buf_prepare(q, q->bufs[i], field); |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 900 | if (err) |
| 901 | return err; |
| 902 | list_add_tail(&q->bufs[i]->stream, &q->stream); |
| 903 | } |
| 904 | if (q->irqlock) |
Mauro Carvalho Chehab | e2c7731 | 2007-12-10 10:53:20 -0300 | [diff] [blame] | 905 | spin_lock_irqsave(q->irqlock, flags); |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 906 | for (i = 0; i < count; i++) |
Mauro Carvalho Chehab | e2c7731 | 2007-12-10 10:53:20 -0300 | [diff] [blame] | 907 | q->ops->buf_queue(q, q->bufs[i]); |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 908 | if (q->irqlock) |
Mauro Carvalho Chehab | e2c7731 | 2007-12-10 10:53:20 -0300 | [diff] [blame] | 909 | spin_unlock_irqrestore(q->irqlock, flags); |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 910 | q->reading = 1; |
| 911 | return 0; |
| 912 | } |
| 913 | |
Brandon Philips | 19bc513 | 2007-11-13 20:05:38 -0300 | [diff] [blame] | 914 | static void __videobuf_read_stop(struct videobuf_queue *q) |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 915 | { |
| 916 | int i; |
| 917 | |
Brandon Philips | 19bc513 | 2007-11-13 20:05:38 -0300 | [diff] [blame] | 918 | |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 919 | videobuf_queue_cancel(q); |
Brandon Philips | 19bc513 | 2007-11-13 20:05:38 -0300 | [diff] [blame] | 920 | __videobuf_mmap_free(q); |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 921 | INIT_LIST_HEAD(&q->stream); |
| 922 | for (i = 0; i < VIDEO_MAX_FRAME; i++) { |
| 923 | if (NULL == q->bufs[i]) |
| 924 | continue; |
| 925 | kfree(q->bufs[i]); |
| 926 | q->bufs[i] = NULL; |
| 927 | } |
| 928 | q->read_buf = NULL; |
Mauro Carvalho Chehab | e2c7731 | 2007-12-10 10:53:20 -0300 | [diff] [blame] | 929 | |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 930 | } |
| 931 | |
Mauro Carvalho Chehab | 19fb14579 | 2007-11-15 23:09:30 -0300 | [diff] [blame] | 932 | int videobuf_read_start(struct videobuf_queue *q) |
| 933 | { |
| 934 | int rc; |
| 935 | |
Mauro Carvalho Chehab | 64f9477 | 2008-01-31 13:57:53 -0300 | [diff] [blame] | 936 | mutex_lock(&q->vb_lock); |
Mauro Carvalho Chehab | 19fb14579 | 2007-11-15 23:09:30 -0300 | [diff] [blame] | 937 | rc = __videobuf_read_start(q); |
Mauro Carvalho Chehab | 64f9477 | 2008-01-31 13:57:53 -0300 | [diff] [blame] | 938 | mutex_unlock(&q->vb_lock); |
Mauro Carvalho Chehab | 19fb14579 | 2007-11-15 23:09:30 -0300 | [diff] [blame] | 939 | |
| 940 | return rc; |
| 941 | } |
| 942 | |
Brandon Philips | 19bc513 | 2007-11-13 20:05:38 -0300 | [diff] [blame] | 943 | void videobuf_read_stop(struct videobuf_queue *q) |
| 944 | { |
Mauro Carvalho Chehab | 64f9477 | 2008-01-31 13:57:53 -0300 | [diff] [blame] | 945 | mutex_lock(&q->vb_lock); |
Brandon Philips | 19bc513 | 2007-11-13 20:05:38 -0300 | [diff] [blame] | 946 | __videobuf_read_stop(q); |
Mauro Carvalho Chehab | 64f9477 | 2008-01-31 13:57:53 -0300 | [diff] [blame] | 947 | mutex_unlock(&q->vb_lock); |
Brandon Philips | 19bc513 | 2007-11-13 20:05:38 -0300 | [diff] [blame] | 948 | } |
| 949 | |
| 950 | void videobuf_stop(struct videobuf_queue *q) |
| 951 | { |
Mauro Carvalho Chehab | 64f9477 | 2008-01-31 13:57:53 -0300 | [diff] [blame] | 952 | mutex_lock(&q->vb_lock); |
Brandon Philips | 19bc513 | 2007-11-13 20:05:38 -0300 | [diff] [blame] | 953 | |
| 954 | if (q->streaming) |
| 955 | __videobuf_streamoff(q); |
| 956 | |
| 957 | if (q->reading) |
| 958 | __videobuf_read_stop(q); |
| 959 | |
Mauro Carvalho Chehab | 64f9477 | 2008-01-31 13:57:53 -0300 | [diff] [blame] | 960 | mutex_unlock(&q->vb_lock); |
Brandon Philips | 19bc513 | 2007-11-13 20:05:38 -0300 | [diff] [blame] | 961 | } |
| 962 | |
| 963 | |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 964 | ssize_t videobuf_read_stream(struct videobuf_queue *q, |
| 965 | char __user *data, size_t count, loff_t *ppos, |
| 966 | int vbihack, int nonblocking) |
| 967 | { |
| 968 | int rc, retval; |
Mauro Carvalho Chehab | e2c7731 | 2007-12-10 10:53:20 -0300 | [diff] [blame] | 969 | unsigned long flags = 0; |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 970 | |
Mauro Carvalho Chehab | e2c7731 | 2007-12-10 10:53:20 -0300 | [diff] [blame] | 971 | MAGIC_CHECK(q->int_ops->magic, MAGIC_QTYPE_OPS); |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 972 | |
Harvey Harrison | 7e28adb | 2008-04-08 23:20:00 -0300 | [diff] [blame^] | 973 | dprintk(2, "%s\n", __func__); |
Mauro Carvalho Chehab | 64f9477 | 2008-01-31 13:57:53 -0300 | [diff] [blame] | 974 | mutex_lock(&q->vb_lock); |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 975 | retval = -EBUSY; |
| 976 | if (q->streaming) |
| 977 | goto done; |
| 978 | if (!q->reading) { |
Adrian Bunk | 3f84307 | 2007-12-12 16:44:54 -0300 | [diff] [blame] | 979 | retval = __videobuf_read_start(q); |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 980 | if (retval < 0) |
| 981 | goto done; |
| 982 | } |
| 983 | |
| 984 | retval = 0; |
| 985 | while (count > 0) { |
| 986 | /* get / wait for data */ |
| 987 | if (NULL == q->read_buf) { |
| 988 | q->read_buf = list_entry(q->stream.next, |
| 989 | struct videobuf_buffer, |
| 990 | stream); |
| 991 | list_del(&q->read_buf->stream); |
| 992 | q->read_off = 0; |
| 993 | } |
| 994 | rc = videobuf_waiton(q->read_buf, nonblocking, 1); |
| 995 | if (rc < 0) { |
| 996 | if (0 == retval) |
| 997 | retval = rc; |
| 998 | break; |
| 999 | } |
| 1000 | |
Brandon Philips | 0fc0686 | 2007-11-06 20:02:36 -0300 | [diff] [blame] | 1001 | if (q->read_buf->state == VIDEOBUF_DONE) { |
Mauro Carvalho Chehab | e2c7731 | 2007-12-10 10:53:20 -0300 | [diff] [blame] | 1002 | rc = CALL(q, copy_stream, q, data + retval, count, |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 1003 | retval, vbihack, nonblocking); |
| 1004 | if (rc < 0) { |
| 1005 | retval = rc; |
| 1006 | break; |
| 1007 | } |
| 1008 | retval += rc; |
| 1009 | count -= rc; |
| 1010 | q->read_off += rc; |
| 1011 | } else { |
| 1012 | /* some error */ |
| 1013 | q->read_off = q->read_buf->size; |
| 1014 | if (0 == retval) |
| 1015 | retval = -EIO; |
| 1016 | } |
| 1017 | |
| 1018 | /* requeue buffer when done with copying */ |
| 1019 | if (q->read_off == q->read_buf->size) { |
| 1020 | list_add_tail(&q->read_buf->stream, |
| 1021 | &q->stream); |
| 1022 | if (q->irqlock) |
Mauro Carvalho Chehab | e2c7731 | 2007-12-10 10:53:20 -0300 | [diff] [blame] | 1023 | spin_lock_irqsave(q->irqlock, flags); |
| 1024 | q->ops->buf_queue(q, q->read_buf); |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 1025 | if (q->irqlock) |
Mauro Carvalho Chehab | e2c7731 | 2007-12-10 10:53:20 -0300 | [diff] [blame] | 1026 | spin_unlock_irqrestore(q->irqlock, flags); |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 1027 | q->read_buf = NULL; |
| 1028 | } |
| 1029 | if (retval < 0) |
| 1030 | break; |
| 1031 | } |
| 1032 | |
| 1033 | done: |
Mauro Carvalho Chehab | 64f9477 | 2008-01-31 13:57:53 -0300 | [diff] [blame] | 1034 | mutex_unlock(&q->vb_lock); |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 1035 | return retval; |
| 1036 | } |
| 1037 | |
| 1038 | unsigned int videobuf_poll_stream(struct file *file, |
| 1039 | struct videobuf_queue *q, |
| 1040 | poll_table *wait) |
| 1041 | { |
| 1042 | struct videobuf_buffer *buf = NULL; |
| 1043 | unsigned int rc = 0; |
| 1044 | |
Mauro Carvalho Chehab | 64f9477 | 2008-01-31 13:57:53 -0300 | [diff] [blame] | 1045 | mutex_lock(&q->vb_lock); |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 1046 | if (q->streaming) { |
| 1047 | if (!list_empty(&q->stream)) |
| 1048 | buf = list_entry(q->stream.next, |
| 1049 | struct videobuf_buffer, stream); |
| 1050 | } else { |
| 1051 | if (!q->reading) |
Adrian Bunk | 3f84307 | 2007-12-12 16:44:54 -0300 | [diff] [blame] | 1052 | __videobuf_read_start(q); |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 1053 | if (!q->reading) { |
| 1054 | rc = POLLERR; |
| 1055 | } else if (NULL == q->read_buf) { |
| 1056 | q->read_buf = list_entry(q->stream.next, |
| 1057 | struct videobuf_buffer, |
| 1058 | stream); |
| 1059 | list_del(&q->read_buf->stream); |
| 1060 | q->read_off = 0; |
| 1061 | } |
| 1062 | buf = q->read_buf; |
| 1063 | } |
| 1064 | if (!buf) |
| 1065 | rc = POLLERR; |
| 1066 | |
| 1067 | if (0 == rc) { |
| 1068 | poll_wait(file, &buf->done, wait); |
Brandon Philips | 0fc0686 | 2007-11-06 20:02:36 -0300 | [diff] [blame] | 1069 | if (buf->state == VIDEOBUF_DONE || |
| 1070 | buf->state == VIDEOBUF_ERROR) |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 1071 | rc = POLLIN|POLLRDNORM; |
| 1072 | } |
Mauro Carvalho Chehab | 64f9477 | 2008-01-31 13:57:53 -0300 | [diff] [blame] | 1073 | mutex_unlock(&q->vb_lock); |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 1074 | return rc; |
| 1075 | } |
| 1076 | |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 1077 | int videobuf_mmap_mapper(struct videobuf_queue *q, |
| 1078 | struct vm_area_struct *vma) |
| 1079 | { |
| 1080 | int retval; |
| 1081 | |
Mauro Carvalho Chehab | e2c7731 | 2007-12-10 10:53:20 -0300 | [diff] [blame] | 1082 | MAGIC_CHECK(q->int_ops->magic, MAGIC_QTYPE_OPS); |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 1083 | |
Mauro Carvalho Chehab | 64f9477 | 2008-01-31 13:57:53 -0300 | [diff] [blame] | 1084 | mutex_lock(&q->vb_lock); |
Mauro Carvalho Chehab | e2c7731 | 2007-12-10 10:53:20 -0300 | [diff] [blame] | 1085 | retval = CALL(q, mmap_mapper, q, vma); |
Mauro Carvalho Chehab | d05051c | 2008-01-10 07:33:03 -0300 | [diff] [blame] | 1086 | q->is_mmapped = 1; |
Mauro Carvalho Chehab | 64f9477 | 2008-01-31 13:57:53 -0300 | [diff] [blame] | 1087 | mutex_unlock(&q->vb_lock); |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 1088 | |
| 1089 | return retval; |
| 1090 | } |
| 1091 | |
| 1092 | #ifdef CONFIG_VIDEO_V4L1_COMPAT |
| 1093 | int videobuf_cgmbuf(struct videobuf_queue *q, |
| 1094 | struct video_mbuf *mbuf, int count) |
| 1095 | { |
| 1096 | struct v4l2_requestbuffers req; |
Mauro Carvalho Chehab | e2c7731 | 2007-12-10 10:53:20 -0300 | [diff] [blame] | 1097 | int rc, i; |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 1098 | |
Mauro Carvalho Chehab | e2c7731 | 2007-12-10 10:53:20 -0300 | [diff] [blame] | 1099 | MAGIC_CHECK(q->int_ops->magic, MAGIC_QTYPE_OPS); |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 1100 | |
Mauro Carvalho Chehab | e2c7731 | 2007-12-10 10:53:20 -0300 | [diff] [blame] | 1101 | memset(&req, 0, sizeof(req)); |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 1102 | req.type = q->type; |
| 1103 | req.count = count; |
| 1104 | req.memory = V4L2_MEMORY_MMAP; |
Mauro Carvalho Chehab | e2c7731 | 2007-12-10 10:53:20 -0300 | [diff] [blame] | 1105 | rc = videobuf_reqbufs(q, &req); |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 1106 | if (rc < 0) |
| 1107 | return rc; |
| 1108 | |
| 1109 | mbuf->frames = req.count; |
| 1110 | mbuf->size = 0; |
| 1111 | for (i = 0; i < mbuf->frames; i++) { |
| 1112 | mbuf->offsets[i] = q->bufs[i]->boff; |
| 1113 | mbuf->size += q->bufs[i]->bsize; |
| 1114 | } |
| 1115 | |
| 1116 | return 0; |
| 1117 | } |
Pekka Enberg | a13625c | 2007-10-13 05:54:54 -0300 | [diff] [blame] | 1118 | EXPORT_SYMBOL_GPL(videobuf_cgmbuf); |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 1119 | #endif |
| 1120 | |
| 1121 | /* --------------------------------------------------------------------- */ |
| 1122 | |
| 1123 | EXPORT_SYMBOL_GPL(videobuf_waiton); |
| 1124 | EXPORT_SYMBOL_GPL(videobuf_iolock); |
| 1125 | |
| 1126 | EXPORT_SYMBOL_GPL(videobuf_alloc); |
| 1127 | |
Mauro Carvalho Chehab | d4cae5a | 2007-10-08 12:20:02 -0300 | [diff] [blame] | 1128 | EXPORT_SYMBOL_GPL(videobuf_queue_core_init); |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 1129 | EXPORT_SYMBOL_GPL(videobuf_queue_cancel); |
| 1130 | EXPORT_SYMBOL_GPL(videobuf_queue_is_busy); |
| 1131 | |
| 1132 | EXPORT_SYMBOL_GPL(videobuf_next_field); |
| 1133 | EXPORT_SYMBOL_GPL(videobuf_reqbufs); |
| 1134 | EXPORT_SYMBOL_GPL(videobuf_querybuf); |
| 1135 | EXPORT_SYMBOL_GPL(videobuf_qbuf); |
| 1136 | EXPORT_SYMBOL_GPL(videobuf_dqbuf); |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 1137 | EXPORT_SYMBOL_GPL(videobuf_streamon); |
| 1138 | EXPORT_SYMBOL_GPL(videobuf_streamoff); |
| 1139 | |
Mauro Carvalho Chehab | 19fb14579 | 2007-11-15 23:09:30 -0300 | [diff] [blame] | 1140 | EXPORT_SYMBOL_GPL(videobuf_read_start); |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 1141 | EXPORT_SYMBOL_GPL(videobuf_read_stop); |
Brandon Philips | 19bc513 | 2007-11-13 20:05:38 -0300 | [diff] [blame] | 1142 | EXPORT_SYMBOL_GPL(videobuf_stop); |
Mauro Carvalho Chehab | 7a7d9a8 | 2007-08-23 16:26:14 -0300 | [diff] [blame] | 1143 | EXPORT_SYMBOL_GPL(videobuf_read_stream); |
| 1144 | EXPORT_SYMBOL_GPL(videobuf_read_one); |
| 1145 | EXPORT_SYMBOL_GPL(videobuf_poll_stream); |
| 1146 | |
| 1147 | EXPORT_SYMBOL_GPL(videobuf_mmap_setup); |
| 1148 | EXPORT_SYMBOL_GPL(videobuf_mmap_free); |
| 1149 | EXPORT_SYMBOL_GPL(videobuf_mmap_mapper); |