forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-05-10 cde9070d9970eef1f7ec2360586c802a16230ad8
kernel/drivers/media/v4l2-core/videobuf-core.c
....@@ -1,3 +1,4 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * generic helper functions for handling video4linux capture buffers
34 *
....@@ -7,10 +8,6 @@
78 * (c) 2001,02 Gerd Knorr <kraxel@bytesex.org>
89 * (c) 2006 Mauro Carvalho Chehab, <mchehab@kernel.org>
910 * (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
1411 */
1512
1613 #include <linux/init.h>
....@@ -22,6 +19,7 @@
2219 #include <linux/interrupt.h>
2320
2421 #include <media/videobuf-core.h>
22
+#include <media/v4l2-common.h>
2523
2624 #define MAGIC_BUFFER 0x20070728
2725 #define MAGIC_CHECK(is, should) \
....@@ -214,7 +212,7 @@
214212 return 1;
215213 }
216214 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);
218216 return 1;
219217 }
220218 }
....@@ -356,7 +354,7 @@
356354 break;
357355 case VIDEOBUF_ERROR:
358356 b->flags |= V4L2_BUF_FLAG_ERROR;
359
- /* fall through */
357
+ fallthrough;
360358 case VIDEOBUF_DONE:
361359 b->flags |= V4L2_BUF_FLAG_DONE;
362360 break;
....@@ -367,7 +365,7 @@
367365 }
368366
369367 b->field = vb->field;
370
- b->timestamp = vb->ts;
368
+ v4l2_buffer_set_timestamp(b, vb->ts);
371369 b->bytesused = vb->size;
372370 b->sequence = vb->field_count >> 1;
373371 }
....@@ -537,7 +535,7 @@
537535 MAGIC_CHECK(q->int_ops->magic, MAGIC_QTYPE_OPS);
538536
539537 if (b->memory == V4L2_MEMORY_MMAP)
540
- down_read(&current->mm->mmap_sem);
538
+ mmap_read_lock(current->mm);
541539
542540 videobuf_queue_lock(q);
543541 retval = -EBUSY;
....@@ -581,7 +579,7 @@
581579 || q->type == V4L2_BUF_TYPE_SDR_OUTPUT) {
582580 buf->size = b->bytesused;
583581 buf->field = b->field;
584
- buf->ts = b->timestamp;
582
+ buf->ts = v4l2_buffer_get_timestamp(b);
585583 }
586584 break;
587585 case V4L2_MEMORY_USERPTR:
....@@ -624,7 +622,7 @@
624622 videobuf_queue_unlock(q);
625623
626624 if (b->memory == V4L2_MEMORY_MMAP)
627
- up_read(&current->mm->mmap_sem);
625
+ mmap_read_unlock(current->mm);
628626
629627 return retval;
630628 }
....@@ -1119,8 +1117,8 @@
11191117 EXPORT_SYMBOL_GPL(videobuf_read_stream);
11201118
11211119 __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)
11241122 {
11251123 __poll_t req_events = poll_requested_events(wait);
11261124 struct videobuf_buffer *buf = NULL;
....@@ -1145,11 +1143,12 @@
11451143 }
11461144 buf = q->read_buf;
11471145 }
1148
- if (!buf)
1146
+ if (buf)
1147
+ poll_wait(file, &buf->done, wait);
1148
+ else
11491149 rc = EPOLLERR;
11501150
11511151 if (0 == rc) {
1152
- poll_wait(file, &buf->done, wait);
11531152 if (buf->state == VIDEOBUF_DONE ||
11541153 buf->state == VIDEOBUF_ERROR) {
11551154 switch (q->type) {