diff options
author | Kamil Debski <k.debski@samsung.com> | 2015-02-23 07:26:16 -0500 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@osg.samsung.com> | 2015-04-10 08:44:38 -0400 |
commit | 06e7a9b638467fddf8f62ca9f07adc7754319461 (patch) | |
tree | 97d1e05d23d9b181ff5ec032ee501bef3756f466 | |
parent | be8e58d93fba531b12ef2fce4fb33c9c5fb5b69f (diff) |
[media] vb2: split the io_flags member of vb2_queue into a bit field
This patch splits the io_flags member of vb2_queue into a bit field.
Instead of an enum with flags separate bit fields were introduced.
Signed-off-by: Kamil Debski <k.debski@samsung.com>
Acked-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
-rw-r--r-- | drivers/media/v4l2-core/videobuf2-core.c | 17 | ||||
-rw-r--r-- | include/media/videobuf2-core.h | 18 |
2 files changed, 14 insertions, 21 deletions
diff --git a/drivers/media/v4l2-core/videobuf2-core.c b/drivers/media/v4l2-core/videobuf2-core.c index 167c1d93bd4c..8bc2a6e8623d 100644 --- a/drivers/media/v4l2-core/videobuf2-core.c +++ b/drivers/media/v4l2-core/videobuf2-core.c | |||
@@ -2760,7 +2760,8 @@ struct vb2_fileio_data { | |||
2760 | unsigned int initial_index; | 2760 | unsigned int initial_index; |
2761 | unsigned int q_count; | 2761 | unsigned int q_count; |
2762 | unsigned int dq_count; | 2762 | unsigned int dq_count; |
2763 | unsigned int flags; | 2763 | unsigned read_once:1; |
2764 | unsigned write_immediately:1; | ||
2764 | }; | 2765 | }; |
2765 | 2766 | ||
2766 | /** | 2767 | /** |
@@ -2798,14 +2799,16 @@ static int __vb2_init_fileio(struct vb2_queue *q, int read) | |||
2798 | */ | 2799 | */ |
2799 | count = 1; | 2800 | count = 1; |
2800 | 2801 | ||
2801 | dprintk(3, "setting up file io: mode %s, count %d, flags %08x\n", | 2802 | dprintk(3, "setting up file io: mode %s, count %d, read_once %d, write_immediately %d\n", |
2802 | (read) ? "read" : "write", count, q->io_flags); | 2803 | (read) ? "read" : "write", count, q->fileio_read_once, |
2804 | q->fileio_write_immediately); | ||
2803 | 2805 | ||
2804 | fileio = kzalloc(sizeof(struct vb2_fileio_data), GFP_KERNEL); | 2806 | fileio = kzalloc(sizeof(struct vb2_fileio_data), GFP_KERNEL); |
2805 | if (fileio == NULL) | 2807 | if (fileio == NULL) |
2806 | return -ENOMEM; | 2808 | return -ENOMEM; |
2807 | 2809 | ||
2808 | fileio->flags = q->io_flags; | 2810 | fileio->read_once = q->fileio_read_once; |
2811 | fileio->write_immediately = q->fileio_write_immediately; | ||
2809 | 2812 | ||
2810 | /* | 2813 | /* |
2811 | * Request buffers and use MMAP type to force driver | 2814 | * Request buffers and use MMAP type to force driver |
@@ -3028,13 +3031,11 @@ static size_t __vb2_perform_fileio(struct vb2_queue *q, char __user *data, size_ | |||
3028 | /* | 3031 | /* |
3029 | * Queue next buffer if required. | 3032 | * Queue next buffer if required. |
3030 | */ | 3033 | */ |
3031 | if (buf->pos == buf->size || | 3034 | if (buf->pos == buf->size || (!read && fileio->write_immediately)) { |
3032 | (!read && (fileio->flags & VB2_FILEIO_WRITE_IMMEDIATELY))) { | ||
3033 | /* | 3035 | /* |
3034 | * Check if this is the last buffer to read. | 3036 | * Check if this is the last buffer to read. |
3035 | */ | 3037 | */ |
3036 | if (read && (fileio->flags & VB2_FILEIO_READ_ONCE) && | 3038 | if (read && fileio->read_once && fileio->dq_count == 1) { |
3037 | fileio->dq_count == 1) { | ||
3038 | dprintk(3, "read limit reached\n"); | 3039 | dprintk(3, "read limit reached\n"); |
3039 | return __vb2_cleanup_fileio(q); | 3040 | return __vb2_cleanup_fileio(q); |
3040 | } | 3041 | } |
diff --git a/include/media/videobuf2-core.h b/include/media/videobuf2-core.h index bd2cec2d6c3d..e49dc6b0de81 100644 --- a/include/media/videobuf2-core.h +++ b/include/media/videobuf2-core.h | |||
@@ -134,17 +134,6 @@ enum vb2_io_modes { | |||
134 | }; | 134 | }; |
135 | 135 | ||
136 | /** | 136 | /** |
137 | * enum vb2_fileio_flags - flags for selecting a mode of the file io emulator, | ||
138 | * by default the 'streaming' style is used by the file io emulator | ||
139 | * @VB2_FILEIO_READ_ONCE: report EOF after reading the first buffer | ||
140 | * @VB2_FILEIO_WRITE_IMMEDIATELY: queue buffer after each write() call | ||
141 | */ | ||
142 | enum vb2_fileio_flags { | ||
143 | VB2_FILEIO_READ_ONCE = (1 << 0), | ||
144 | VB2_FILEIO_WRITE_IMMEDIATELY = (1 << 1), | ||
145 | }; | ||
146 | |||
147 | /** | ||
148 | * enum vb2_buffer_state - current video buffer state | 137 | * enum vb2_buffer_state - current video buffer state |
149 | * @VB2_BUF_STATE_DEQUEUED: buffer under userspace control | 138 | * @VB2_BUF_STATE_DEQUEUED: buffer under userspace control |
150 | * @VB2_BUF_STATE_PREPARING: buffer is being prepared in videobuf | 139 | * @VB2_BUF_STATE_PREPARING: buffer is being prepared in videobuf |
@@ -346,7 +335,8 @@ struct v4l2_fh; | |||
346 | * | 335 | * |
347 | * @type: queue type (see V4L2_BUF_TYPE_* in linux/videodev2.h | 336 | * @type: queue type (see V4L2_BUF_TYPE_* in linux/videodev2.h |
348 | * @io_modes: supported io methods (see vb2_io_modes enum) | 337 | * @io_modes: supported io methods (see vb2_io_modes enum) |
349 | * @io_flags: additional io flags (see vb2_fileio_flags enum) | 338 | * @fileio_read_once: report EOF after reading the first buffer |
339 | * @fileio_write_immediately: queue buffer after each write() call | ||
350 | * @lock: pointer to a mutex that protects the vb2_queue struct. The | 340 | * @lock: pointer to a mutex that protects the vb2_queue struct. The |
351 | * driver can set this to a mutex to let the v4l2 core serialize | 341 | * driver can set this to a mutex to let the v4l2 core serialize |
352 | * the queuing ioctls. If the driver wants to handle locking | 342 | * the queuing ioctls. If the driver wants to handle locking |
@@ -396,7 +386,9 @@ struct v4l2_fh; | |||
396 | struct vb2_queue { | 386 | struct vb2_queue { |
397 | enum v4l2_buf_type type; | 387 | enum v4l2_buf_type type; |
398 | unsigned int io_modes; | 388 | unsigned int io_modes; |
399 | unsigned int io_flags; | 389 | unsigned fileio_read_once:1; |
390 | unsigned fileio_write_immediately:1; | ||
391 | |||
400 | struct mutex *lock; | 392 | struct mutex *lock; |
401 | struct v4l2_fh *owner; | 393 | struct v4l2_fh *owner; |
402 | 394 | ||