Skip to content

Commit

Permalink
media: v4l2-mem2mem: add try_en/decoder_cmd ioctl helpers
Browse files Browse the repository at this point in the history
Most if not all codecs will need to implement these ioctls and
it is expected to be the same for all codecs. So add this to
the core v4l2-mem2mem framework so that this code can easily be
reused.

Signed-off-by: Hans Verkuil <[email protected]>
Signed-off-by: Mauro Carvalho Chehab <[email protected]>
  • Loading branch information
Hans Verkuil authored and mchehab committed Jun 5, 2019
1 parent ad2220a commit ef732d5
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
29 changes: 29 additions & 0 deletions drivers/media/v4l2-core/v4l2-mem2mem.c
Original file line number Diff line number Diff line change
Expand Up @@ -1122,6 +1122,35 @@ int v4l2_m2m_ioctl_streamoff(struct file *file, void *priv,
}
EXPORT_SYMBOL_GPL(v4l2_m2m_ioctl_streamoff);

int v4l2_m2m_ioctl_try_encoder_cmd(struct file *file, void *fh,
struct v4l2_encoder_cmd *ec)
{
if (ec->cmd != V4L2_ENC_CMD_STOP && ec->cmd != V4L2_ENC_CMD_START)
return -EINVAL;

ec->flags = 0;
return 0;
}
EXPORT_SYMBOL_GPL(v4l2_m2m_ioctl_try_encoder_cmd);

int v4l2_m2m_ioctl_try_decoder_cmd(struct file *file, void *fh,
struct v4l2_decoder_cmd *dc)
{
if (dc->cmd != V4L2_DEC_CMD_STOP && dc->cmd != V4L2_DEC_CMD_START)
return -EINVAL;

dc->flags = 0;

if (dc->cmd == V4L2_DEC_CMD_STOP) {
dc->stop.pts = 0;
} else if (dc->cmd == V4L2_DEC_CMD_START) {
dc->start.speed = 0;
dc->start.format = V4L2_DEC_START_FMT_NONE;
}
return 0;
}
EXPORT_SYMBOL_GPL(v4l2_m2m_ioctl_try_decoder_cmd);

/*
* v4l2_file_operations helpers. It is assumed here same lock is used
* for the output and the capture buffer queue.
Expand Down
4 changes: 4 additions & 0 deletions include/media/v4l2-mem2mem.h
Original file line number Diff line number Diff line change
Expand Up @@ -672,6 +672,10 @@ int v4l2_m2m_ioctl_streamon(struct file *file, void *fh,
enum v4l2_buf_type type);
int v4l2_m2m_ioctl_streamoff(struct file *file, void *fh,
enum v4l2_buf_type type);
int v4l2_m2m_ioctl_try_encoder_cmd(struct file *file, void *fh,
struct v4l2_encoder_cmd *ec);
int v4l2_m2m_ioctl_try_decoder_cmd(struct file *file, void *fh,
struct v4l2_decoder_cmd *dc);
int v4l2_m2m_fop_mmap(struct file *file, struct vm_area_struct *vma);
__poll_t v4l2_m2m_fop_poll(struct file *file, poll_table *wait);

Expand Down

0 comments on commit ef732d5

Please sign in to comment.