.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
---|
1 | 2 | /* |
---|
2 | 3 | * generic helper functions for handling video4linux capture buffers |
---|
3 | 4 | * |
---|
.. | .. |
---|
7 | 8 | * (c) 2001,02 Gerd Knorr <kraxel@bytesex.org> |
---|
8 | 9 | * (c) 2006 Mauro Carvalho Chehab, <mchehab@kernel.org> |
---|
9 | 10 | * (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 | 11 | */ |
---|
15 | 12 | |
---|
16 | 13 | #include <linux/init.h> |
---|
.. | .. |
---|
22 | 19 | #include <linux/interrupt.h> |
---|
23 | 20 | |
---|
24 | 21 | #include <media/videobuf-core.h> |
---|
| 22 | +#include <media/v4l2-common.h> |
---|
25 | 23 | |
---|
26 | 24 | #define MAGIC_BUFFER 0x20070728 |
---|
27 | 25 | #define MAGIC_CHECK(is, should) \ |
---|
.. | .. |
---|
214 | 212 | return 1; |
---|
215 | 213 | } |
---|
216 | 214 | if (q->bufs[i]->state == VIDEOBUF_ACTIVE) { |
---|
217 | | - dprintk(1, "busy: buffer #%d avtive\n", i); |
---|
| 215 | + dprintk(1, "busy: buffer #%d active\n", i); |
---|
218 | 216 | return 1; |
---|
219 | 217 | } |
---|
220 | 218 | } |
---|
.. | .. |
---|
356 | 354 | break; |
---|
357 | 355 | case VIDEOBUF_ERROR: |
---|
358 | 356 | b->flags |= V4L2_BUF_FLAG_ERROR; |
---|
359 | | - /* fall through */ |
---|
| 357 | + fallthrough; |
---|
360 | 358 | case VIDEOBUF_DONE: |
---|
361 | 359 | b->flags |= V4L2_BUF_FLAG_DONE; |
---|
362 | 360 | break; |
---|
.. | .. |
---|
367 | 365 | } |
---|
368 | 366 | |
---|
369 | 367 | b->field = vb->field; |
---|
370 | | - b->timestamp = vb->ts; |
---|
| 368 | + v4l2_buffer_set_timestamp(b, vb->ts); |
---|
371 | 369 | b->bytesused = vb->size; |
---|
372 | 370 | b->sequence = vb->field_count >> 1; |
---|
373 | 371 | } |
---|
.. | .. |
---|
537 | 535 | MAGIC_CHECK(q->int_ops->magic, MAGIC_QTYPE_OPS); |
---|
538 | 536 | |
---|
539 | 537 | if (b->memory == V4L2_MEMORY_MMAP) |
---|
540 | | - down_read(¤t->mm->mmap_sem); |
---|
| 538 | + mmap_read_lock(current->mm); |
---|
541 | 539 | |
---|
542 | 540 | videobuf_queue_lock(q); |
---|
543 | 541 | retval = -EBUSY; |
---|
.. | .. |
---|
581 | 579 | || q->type == V4L2_BUF_TYPE_SDR_OUTPUT) { |
---|
582 | 580 | buf->size = b->bytesused; |
---|
583 | 581 | buf->field = b->field; |
---|
584 | | - buf->ts = b->timestamp; |
---|
| 582 | + buf->ts = v4l2_buffer_get_timestamp(b); |
---|
585 | 583 | } |
---|
586 | 584 | break; |
---|
587 | 585 | case V4L2_MEMORY_USERPTR: |
---|
.. | .. |
---|
624 | 622 | videobuf_queue_unlock(q); |
---|
625 | 623 | |
---|
626 | 624 | if (b->memory == V4L2_MEMORY_MMAP) |
---|
627 | | - up_read(¤t->mm->mmap_sem); |
---|
| 625 | + mmap_read_unlock(current->mm); |
---|
628 | 626 | |
---|
629 | 627 | return retval; |
---|
630 | 628 | } |
---|
.. | .. |
---|
1119 | 1117 | EXPORT_SYMBOL_GPL(videobuf_read_stream); |
---|
1120 | 1118 | |
---|
1121 | 1119 | __poll_t videobuf_poll_stream(struct file *file, |
---|
1122 | | - struct videobuf_queue *q, |
---|
1123 | | - poll_table *wait) |
---|
| 1120 | + struct videobuf_queue *q, |
---|
| 1121 | + poll_table *wait) |
---|
1124 | 1122 | { |
---|
1125 | 1123 | __poll_t req_events = poll_requested_events(wait); |
---|
1126 | 1124 | struct videobuf_buffer *buf = NULL; |
---|
.. | .. |
---|
1145 | 1143 | } |
---|
1146 | 1144 | buf = q->read_buf; |
---|
1147 | 1145 | } |
---|
1148 | | - if (!buf) |
---|
| 1146 | + if (buf) |
---|
| 1147 | + poll_wait(file, &buf->done, wait); |
---|
| 1148 | + else |
---|
1149 | 1149 | rc = EPOLLERR; |
---|
1150 | 1150 | |
---|
1151 | 1151 | if (0 == rc) { |
---|
1152 | | - poll_wait(file, &buf->done, wait); |
---|
1153 | 1152 | if (buf->state == VIDEOBUF_DONE || |
---|
1154 | 1153 | buf->state == VIDEOBUF_ERROR) { |
---|
1155 | 1154 | switch (q->type) { |
---|