Commit 9f2bfb33 authored by Philipp Zabel's avatar Philipp Zabel Committed by Mauro Carvalho Chehab

[media] coda: Set last buffer flag and fix EOS event

Setting the last buffer flag causes the videobuf2 core to return -EPIPE from
DQBUF calls on the capture queue after the last buffer is dequeued.
This patch also fixes the EOS event to conform to the specification. It now is
sent right after the last buffer has been decoded instead of when the last
buffer is dequeued.
Signed-off-by: default avatarPhilipp Zabel <p.zabel@pengutronix.de>
Signed-off-by: default avatarKamil Debski <k.debski@samsung.com>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@osg.samsung.com>
parent c1621840
...@@ -1305,7 +1305,7 @@ static void coda_finish_encode(struct coda_ctx *ctx) ...@@ -1305,7 +1305,7 @@ static void coda_finish_encode(struct coda_ctx *ctx)
v4l2_m2m_buf_done(src_buf, VB2_BUF_STATE_DONE); v4l2_m2m_buf_done(src_buf, VB2_BUF_STATE_DONE);
dst_buf = v4l2_m2m_dst_buf_remove(ctx->fh.m2m_ctx); dst_buf = v4l2_m2m_dst_buf_remove(ctx->fh.m2m_ctx);
v4l2_m2m_buf_done(dst_buf, VB2_BUF_STATE_DONE); coda_m2m_buf_done(ctx, dst_buf, VB2_BUF_STATE_DONE);
ctx->gopcounter--; ctx->gopcounter--;
if (ctx->gopcounter < 0) if (ctx->gopcounter < 0)
...@@ -1975,7 +1975,7 @@ static void coda_finish_decode(struct coda_ctx *ctx) ...@@ -1975,7 +1975,7 @@ static void coda_finish_decode(struct coda_ctx *ctx)
} }
vb2_set_plane_payload(dst_buf, 0, payload); vb2_set_plane_payload(dst_buf, 0, payload);
v4l2_m2m_buf_done(dst_buf, ctx->frame_errors[display_idx] ? coda_m2m_buf_done(ctx, dst_buf, ctx->frame_errors[display_idx] ?
VB2_BUF_STATE_ERROR : VB2_BUF_STATE_DONE); VB2_BUF_STATE_ERROR : VB2_BUF_STATE_DONE);
v4l2_dbg(1, coda_debug, &dev->v4l2_dev, v4l2_dbg(1, coda_debug, &dev->v4l2_dev,
......
...@@ -724,35 +724,30 @@ static int coda_qbuf(struct file *file, void *priv, ...@@ -724,35 +724,30 @@ static int coda_qbuf(struct file *file, void *priv,
} }
static bool coda_buf_is_end_of_stream(struct coda_ctx *ctx, static bool coda_buf_is_end_of_stream(struct coda_ctx *ctx,
struct v4l2_buffer *buf) struct vb2_buffer *buf)
{ {
struct vb2_queue *src_vq; struct vb2_queue *src_vq;
src_vq = v4l2_m2m_get_vq(ctx->fh.m2m_ctx, V4L2_BUF_TYPE_VIDEO_OUTPUT); src_vq = v4l2_m2m_get_vq(ctx->fh.m2m_ctx, V4L2_BUF_TYPE_VIDEO_OUTPUT);
return ((ctx->bit_stream_param & CODA_BIT_STREAM_END_FLAG) && return ((ctx->bit_stream_param & CODA_BIT_STREAM_END_FLAG) &&
(buf->sequence == (ctx->qsequence - 1))); (buf->v4l2_buf.sequence == (ctx->qsequence - 1)));
} }
static int coda_dqbuf(struct file *file, void *priv, void coda_m2m_buf_done(struct coda_ctx *ctx, struct vb2_buffer *buf,
struct v4l2_buffer *buf) enum vb2_buffer_state state)
{ {
struct coda_ctx *ctx = fh_to_ctx(priv); const struct v4l2_event eos_event = {
int ret; .type = V4L2_EVENT_EOS
};
ret = v4l2_m2m_dqbuf(file, ctx->fh.m2m_ctx, buf); if (coda_buf_is_end_of_stream(ctx, buf)) {
buf->v4l2_buf.flags |= V4L2_BUF_FLAG_LAST;
/* If this is the last capture buffer, emit an end-of-stream event */
if (buf->type == V4L2_BUF_TYPE_VIDEO_CAPTURE &&
coda_buf_is_end_of_stream(ctx, buf)) {
const struct v4l2_event eos_event = {
.type = V4L2_EVENT_EOS
};
v4l2_event_queue_fh(&ctx->fh, &eos_event); v4l2_event_queue_fh(&ctx->fh, &eos_event);
} }
return ret; v4l2_m2m_buf_done(buf, state);
} }
static int coda_g_selection(struct file *file, void *fh, static int coda_g_selection(struct file *file, void *fh,
...@@ -865,7 +860,7 @@ static const struct v4l2_ioctl_ops coda_ioctl_ops = { ...@@ -865,7 +860,7 @@ static const struct v4l2_ioctl_ops coda_ioctl_ops = {
.vidioc_qbuf = coda_qbuf, .vidioc_qbuf = coda_qbuf,
.vidioc_expbuf = v4l2_m2m_ioctl_expbuf, .vidioc_expbuf = v4l2_m2m_ioctl_expbuf,
.vidioc_dqbuf = coda_dqbuf, .vidioc_dqbuf = v4l2_m2m_ioctl_dqbuf,
.vidioc_create_bufs = v4l2_m2m_ioctl_create_bufs, .vidioc_create_bufs = v4l2_m2m_ioctl_create_bufs,
.vidioc_streamon = v4l2_m2m_ioctl_streamon, .vidioc_streamon = v4l2_m2m_ioctl_streamon,
......
...@@ -287,6 +287,9 @@ static inline unsigned int coda_get_bitstream_payload(struct coda_ctx *ctx) ...@@ -287,6 +287,9 @@ static inline unsigned int coda_get_bitstream_payload(struct coda_ctx *ctx)
void coda_bit_stream_end_flag(struct coda_ctx *ctx); void coda_bit_stream_end_flag(struct coda_ctx *ctx);
void coda_m2m_buf_done(struct coda_ctx *ctx, struct vb2_buffer *buf,
enum vb2_buffer_state state);
int coda_h264_padding(int size, char *p); int coda_h264_padding(int size, char *p);
bool coda_jpeg_check_buffer(struct coda_ctx *ctx, struct vb2_buffer *vb); bool coda_jpeg_check_buffer(struct coda_ctx *ctx, struct vb2_buffer *vb);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment