Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 474fab75 authored by Lakshmi Narayana Kalavala's avatar Lakshmi Narayana Kalavala Committed by Gerrit - the friendly Code Review server
Browse files

msm: camera: Cleanup the buffers before stream close



Need to release all the buffers enqueued to the
driver when stream is turned off or stream is closed.
This ensures the proper clean up of stream queues
avoiding any stale entries in the queues.

Change-Id: Ic967ce61236f2e170aa8f4b4f861cb0677b082a3
Signed-off-by: default avatarLakshmi Narayana Kalavala <lkalaval@codeaurora.org>
parent 37bc52a5
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -681,6 +681,7 @@ static int camera_v4l2_close(struct file *filep)

		/* This should take care of both normal close
		 * and application crashes */
		camera_v4l2_vb2_q_release(filep);
		msm_destroy_session(pvdev->vdev->num);
		pm_relax(&pvdev->vdev->dev);
	} else {
@@ -692,10 +693,10 @@ static int camera_v4l2_close(struct file *filep)
		msm_delete_command_ack_q(pvdev->vdev->num,
			sp->stream_id);

		camera_v4l2_vb2_q_release(filep);
		msm_delete_stream(pvdev->vdev->num, sp->stream_id);
	}

	camera_v4l2_vb2_q_release(filep);
	camera_v4l2_fh_release(filep);

	return rc;
+31 −0
Original line number Diff line number Diff line
@@ -112,6 +112,36 @@ static void msm_vb2_buf_finish(struct vb2_buffer *vb)
	return;
}

static void msm_vb2_stop_stream(struct vb2_queue *q)
{
	struct msm_vb2_buffer *msm_vb2, *temp;
	struct msm_stream *stream;
	unsigned long flags;
	struct vb2_buffer *vb2_buf;

	stream = msm_get_stream_from_vb2q(q);
	if (!stream) {
		pr_err("%s:%d] NULL stream", __func__, __LINE__);
		return;
	}

	/*
	 * Release all the buffers enqueued to driver
	 * when streamoff is issued
	 */

	spin_lock_irqsave(&stream->stream_lock, flags);
	list_for_each_entry_safe(msm_vb2, temp, &(stream->queued_list),
		list) {
			vb2_buf = &(msm_vb2->vb2_buf);
			if (vb2_buf->state == VB2_BUF_STATE_DONE)
				continue;
			vb2_buffer_done(vb2_buf, VB2_BUF_STATE_DONE);
			msm_vb2->in_freeq = 0;
		}
	spin_unlock_irqrestore(&stream->stream_lock, flags);
}

static void msm_vb2_buf_cleanup(struct vb2_buffer *vb)
{
	struct msm_vb2_buffer *msm_vb2;
@@ -142,6 +172,7 @@ static struct vb2_ops msm_vb2_get_q_op = {
	.buf_queue	= msm_vb2_buf_queue,
	.buf_cleanup	= msm_vb2_buf_cleanup,
	.buf_finish	= msm_vb2_buf_finish,
	.stop_streaming = msm_vb2_stop_stream,
};