[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>
This commit is contained in:
parent
be8e58d93f
commit
06e7a9b638
@ -2760,7 +2760,8 @@ struct vb2_fileio_data {
|
|||||||
unsigned int initial_index;
|
unsigned int initial_index;
|
||||||
unsigned int q_count;
|
unsigned int q_count;
|
||||||
unsigned int dq_count;
|
unsigned int dq_count;
|
||||||
unsigned int flags;
|
unsigned read_once:1;
|
||||||
|
unsigned write_immediately:1;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -2798,14 +2799,16 @@ static int __vb2_init_fileio(struct vb2_queue *q, int read)
|
|||||||
*/
|
*/
|
||||||
count = 1;
|
count = 1;
|
||||||
|
|
||||||
dprintk(3, "setting up file io: mode %s, count %d, flags %08x\n",
|
dprintk(3, "setting up file io: mode %s, count %d, read_once %d, write_immediately %d\n",
|
||||||
(read) ? "read" : "write", count, q->io_flags);
|
(read) ? "read" : "write", count, q->fileio_read_once,
|
||||||
|
q->fileio_write_immediately);
|
||||||
|
|
||||||
fileio = kzalloc(sizeof(struct vb2_fileio_data), GFP_KERNEL);
|
fileio = kzalloc(sizeof(struct vb2_fileio_data), GFP_KERNEL);
|
||||||
if (fileio == NULL)
|
if (fileio == NULL)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
fileio->flags = q->io_flags;
|
fileio->read_once = q->fileio_read_once;
|
||||||
|
fileio->write_immediately = q->fileio_write_immediately;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Request buffers and use MMAP type to force driver
|
* 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_
|
|||||||
/*
|
/*
|
||||||
* Queue next buffer if required.
|
* Queue next buffer if required.
|
||||||
*/
|
*/
|
||||||
if (buf->pos == buf->size ||
|
if (buf->pos == buf->size || (!read && fileio->write_immediately)) {
|
||||||
(!read && (fileio->flags & VB2_FILEIO_WRITE_IMMEDIATELY))) {
|
|
||||||
/*
|
/*
|
||||||
* Check if this is the last buffer to read.
|
* Check if this is the last buffer to read.
|
||||||
*/
|
*/
|
||||||
if (read && (fileio->flags & VB2_FILEIO_READ_ONCE) &&
|
if (read && fileio->read_once && fileio->dq_count == 1) {
|
||||||
fileio->dq_count == 1) {
|
|
||||||
dprintk(3, "read limit reached\n");
|
dprintk(3, "read limit reached\n");
|
||||||
return __vb2_cleanup_fileio(q);
|
return __vb2_cleanup_fileio(q);
|
||||||
}
|
}
|
||||||
|
@ -133,17 +133,6 @@ enum vb2_io_modes {
|
|||||||
VB2_DMABUF = (1 << 4),
|
VB2_DMABUF = (1 << 4),
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
|
||||||
* enum vb2_fileio_flags - flags for selecting a mode of the file io emulator,
|
|
||||||
* by default the 'streaming' style is used by the file io emulator
|
|
||||||
* @VB2_FILEIO_READ_ONCE: report EOF after reading the first buffer
|
|
||||||
* @VB2_FILEIO_WRITE_IMMEDIATELY: queue buffer after each write() call
|
|
||||||
*/
|
|
||||||
enum vb2_fileio_flags {
|
|
||||||
VB2_FILEIO_READ_ONCE = (1 << 0),
|
|
||||||
VB2_FILEIO_WRITE_IMMEDIATELY = (1 << 1),
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* enum vb2_buffer_state - current video buffer state
|
* enum vb2_buffer_state - current video buffer state
|
||||||
* @VB2_BUF_STATE_DEQUEUED: buffer under userspace control
|
* @VB2_BUF_STATE_DEQUEUED: buffer under userspace control
|
||||||
@ -346,7 +335,8 @@ struct v4l2_fh;
|
|||||||
*
|
*
|
||||||
* @type: queue type (see V4L2_BUF_TYPE_* in linux/videodev2.h
|
* @type: queue type (see V4L2_BUF_TYPE_* in linux/videodev2.h
|
||||||
* @io_modes: supported io methods (see vb2_io_modes enum)
|
* @io_modes: supported io methods (see vb2_io_modes enum)
|
||||||
* @io_flags: additional io flags (see vb2_fileio_flags enum)
|
* @fileio_read_once: report EOF after reading the first buffer
|
||||||
|
* @fileio_write_immediately: queue buffer after each write() call
|
||||||
* @lock: pointer to a mutex that protects the vb2_queue struct. The
|
* @lock: pointer to a mutex that protects the vb2_queue struct. The
|
||||||
* driver can set this to a mutex to let the v4l2 core serialize
|
* driver can set this to a mutex to let the v4l2 core serialize
|
||||||
* the queuing ioctls. If the driver wants to handle locking
|
* the queuing ioctls. If the driver wants to handle locking
|
||||||
@ -396,7 +386,9 @@ struct v4l2_fh;
|
|||||||
struct vb2_queue {
|
struct vb2_queue {
|
||||||
enum v4l2_buf_type type;
|
enum v4l2_buf_type type;
|
||||||
unsigned int io_modes;
|
unsigned int io_modes;
|
||||||
unsigned int io_flags;
|
unsigned fileio_read_once:1;
|
||||||
|
unsigned fileio_write_immediately:1;
|
||||||
|
|
||||||
struct mutex *lock;
|
struct mutex *lock;
|
||||||
struct v4l2_fh *owner;
|
struct v4l2_fh *owner;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user