msmb: Improve implementation of msm_vb2

Fix camera preview by including vb2_streamon/vb2_streamoff
in camera_v4l2_streamon/camera_v4l2_streamoff, and fixing
buffer cirulation in the vb2 queue.

Change-Id: Ibbd12941b9b774376cc86712e3ca660942550c68
Signed-off-by: Mingcheng Zhu <mingchen@codeaurora.org>
This commit is contained in:
Mingcheng Zhu
2012-12-29 20:11:58 -08:00
committed by Iliyan Malchev
parent 2ef669253a
commit 6e8f6c51ff
2 changed files with 19 additions and 10 deletions

View File

@@ -173,7 +173,6 @@ static int camera_v4l2_s_ctrl(struct file *filep, void *fh,
{
int rc = 0;
struct v4l2_event event;
if (ctrl->id >= V4L2_CID_PRIVATE_BASE) {
camera_pack_event(filep, MSM_CAMERA_SET_PARM, ctrl->id, &event);
@@ -222,7 +221,9 @@ static int camera_v4l2_streamon(struct file *filep, void *fh,
{
struct v4l2_event event;
int rc;
struct camera_v4l2_private *sp = fh_to_private(fh);
rc = vb2_streamon(&sp->vb2_q, buf_type);
camera_pack_event(filep, MSM_CAMERA_SET_PARM,
MSM_CAMERA_PRIV_STREAM_ON, &event);
@@ -231,7 +232,6 @@ static int camera_v4l2_streamon(struct file *filep, void *fh,
return rc;
rc = camera_check_event_status(&event);
return rc;
}
@@ -240,6 +240,7 @@ static int camera_v4l2_streamoff(struct file *filep, void *fh,
{
struct v4l2_event event;
int rc;
struct camera_v4l2_private *sp = fh_to_private(fh);
camera_pack_event(filep, MSM_CAMERA_SET_PARM,
MSM_CAMERA_PRIV_STREAM_OFF, &event);
@@ -249,7 +250,7 @@ static int camera_v4l2_streamoff(struct file *filep, void *fh,
return rc;
rc = camera_check_event_status(&event);
vb2_streamoff(&sp->vb2_q, buf_type);
return rc;
}
@@ -278,8 +279,10 @@ static int camera_v4l2_s_fmt_cap_private(struct file *filep, void *fh,
struct v4l2_format *pfmt)
{
int rc = 0;
int i = 0;
struct v4l2_event event;
struct camera_v4l2_private *sp = fh_to_private(fh);
struct msm_v4l2_format_data *user_fmt;
if (pfmt->type == V4L2_BUF_TYPE_PRIVATE) {
@@ -288,6 +291,13 @@ static int camera_v4l2_s_fmt_cap_private(struct file *filep, void *fh,
memcpy(sp->vb2_q.drv_priv, pfmt->fmt.raw_data,
sizeof(struct msm_v4l2_format_data));
user_fmt = (struct msm_v4l2_format_data *)sp->vb2_q.drv_priv;
pr_debug("%s: num planes :%c\n", __func__,
user_fmt->num_planes);
for (i = 0; i < user_fmt->num_planes; i++)
pr_debug("%s: plane size[%d]\n", __func__,
user_fmt->plane_sizes[i]);
camera_pack_event(filep, MSM_CAMERA_SET_PARM,
MSM_CAMERA_PRIV_S_FMT, &event);
@@ -574,12 +584,11 @@ static int camera_v4l2_close(struct file *filep)
msm_destroy_session(pvdev->vdev->num);
} else {
camera_pack_event(filep, MSM_CAMERA_SET_PARM,
MSM_CAMERA_PRIV_DEL_STREAM, &event);
/* Donot wait, imaging server may have crashed */
msm_post_event(&event, -1);
msm_post_event(&event, MSM_POST_EVT_TIMEOUT);
msm_delete_command_ack_q(pvdev->vdev->num,
sp->stream_id);

View File

@@ -119,8 +119,7 @@ static struct vb2_buffer *msm_vb2_get_buf(int session_id,
list_for_each_entry(vb2_buf, &(q->queued_list),
queued_entry) {
if (vb2_buf->v4l2_buf.flags != V4L2_BUF_FLAG_QUEUED)
if (vb2_buf->state != VB2_BUF_STATE_ACTIVE)
continue;
msm_vb2 = container_of(vb2_buf, struct msm_vb2_buffer, vb2_buf);
@@ -130,6 +129,7 @@ static struct vb2_buffer *msm_vb2_get_buf(int session_id,
msm_vb2->in_freeq = 1;
goto end;
}
vb2_buf = NULL;
end:
spin_unlock_irqrestore(&vb2_buf_lock, flags);
return vb2_buf;
@@ -140,7 +140,7 @@ static int msm_vb2_put_buf(struct vb2_buffer *vb)
struct msm_vb2_buffer *msm_vb2;
int rc = 0;
if (!vb) {
if (vb) {
msm_vb2 =
container_of(vb, struct msm_vb2_buffer, vb2_buf);
if (msm_vb2->in_freeq) {
@@ -162,11 +162,11 @@ static int msm_vb2_buf_done(struct vb2_buffer *vb)
int rc = 0;
spin_lock_irqsave(&vb2_buf_lock, flags);
if (!vb) {
if (vb) {
msm_vb2 =
container_of(vb, struct msm_vb2_buffer, vb2_buf);
/* put buf before buf done */
if (!msm_vb2->in_freeq) {
if (msm_vb2->in_freeq) {
vb2_buffer_done(vb, VB2_BUF_STATE_DONE);
rc = 0;
} else