Commit a26be06d authored by Dave Stevenson's avatar Dave Stevenson Committed by Greg Kroah-Hartman

staging: bcm2835-camera: Handle empty EOS buffers whilst streaming

The change to mapping V4L2 to MMAL buffers 1:1 didn't handle
the condition we get with raw pixel buffers (eg YUV and RGB)
direct from the camera's stills port. That sends the pixel buffer
and then an empty buffer with the EOS flag set. The EOS buffer
wasn't handled and returned an error up the stack.

Handle the condition correctly by returning it to the component
if streaming, or returning with an error if stopping streaming.

Fixes: 93841670 ("staging: bcm2835-camera: Remove V4L2/MMAL buffer remapping")
Signed-off-by: default avatarDave Stevenson <dave.stevenson@raspberrypi.org>
Signed-off-by: default avatarStefan Wahren <wahrenst@gmx.net>
Acked-by: default avatarHans Verkuil <hverkuil-cisco@xs4all.nl>
Acked-by: default avatarMauro Carvalho Chehab <mchehab+samsung@kernel.org>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent bb8e9700
...@@ -339,16 +339,13 @@ static void buffer_cb(struct vchiq_mmal_instance *instance, ...@@ -339,16 +339,13 @@ static void buffer_cb(struct vchiq_mmal_instance *instance,
if (length == 0) { if (length == 0) {
/* stream ended */ /* stream ended */
if (buf) { if (dev->capture.frame_count) {
/* this should only ever happen if the port is /* empty buffer whilst capturing - expected to be an
* disabled and there are buffers still queued * EOS, so grab another frame
*/ */
vb2_buffer_done(&buf->vb.vb2_buf, VB2_BUF_STATE_ERROR);
pr_debug("Empty buffer");
} else if (dev->capture.frame_count) {
/* grab another frame */
if (is_capturing(dev)) { if (is_capturing(dev)) {
pr_debug("Grab another frame"); v4l2_dbg(1, bcm2835_v4l2_debug, &dev->v4l2_dev,
"Grab another frame");
vchiq_mmal_port_parameter_set( vchiq_mmal_port_parameter_set(
instance, instance,
dev->capture.camera_port, dev->capture.camera_port,
...@@ -356,8 +353,14 @@ static void buffer_cb(struct vchiq_mmal_instance *instance, ...@@ -356,8 +353,14 @@ static void buffer_cb(struct vchiq_mmal_instance *instance,
&dev->capture.frame_count, &dev->capture.frame_count,
sizeof(dev->capture.frame_count)); sizeof(dev->capture.frame_count));
} }
if (vchiq_mmal_submit_buffer(instance, port, buf))
v4l2_dbg(1, bcm2835_v4l2_debug, &dev->v4l2_dev,
"Failed to return EOS buffer");
} else { } else {
/* signal frame completion */ /* stopping streaming.
* return buffer, and signal frame completion
*/
vb2_buffer_done(&buf->vb.vb2_buf, VB2_BUF_STATE_ERROR);
complete(&dev->capture.frame_cmplt); complete(&dev->capture.frame_cmplt);
} }
return; return;
......
...@@ -332,8 +332,6 @@ static int bulk_receive(struct vchiq_mmal_instance *instance, ...@@ -332,8 +332,6 @@ static int bulk_receive(struct vchiq_mmal_instance *instance,
/* store length */ /* store length */
msg_context->u.bulk.buffer_used = rd_len; msg_context->u.bulk.buffer_used = rd_len;
msg_context->u.bulk.mmal_flags =
msg->u.buffer_from_host.buffer_header.flags;
msg_context->u.bulk.dts = msg->u.buffer_from_host.buffer_header.dts; msg_context->u.bulk.dts = msg->u.buffer_from_host.buffer_header.dts;
msg_context->u.bulk.pts = msg->u.buffer_from_host.buffer_header.pts; msg_context->u.bulk.pts = msg->u.buffer_from_host.buffer_header.pts;
...@@ -461,6 +459,9 @@ static void buffer_to_host_cb(struct vchiq_mmal_instance *instance, ...@@ -461,6 +459,9 @@ static void buffer_to_host_cb(struct vchiq_mmal_instance *instance,
return; return;
} }
msg_context->u.bulk.mmal_flags =
msg->u.buffer_from_host.buffer_header.flags;
if (msg->h.status != MMAL_MSG_STATUS_SUCCESS) { if (msg->h.status != MMAL_MSG_STATUS_SUCCESS) {
/* message reception had an error */ /* message reception had an error */
pr_warn("error %d in reply\n", msg->h.status); pr_warn("error %d in reply\n", msg->h.status);
......
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