static int camera_v4l2_reqbufs(struct file *filep, void *fh, struct v4l2_requestbuffers *req) { int ret; struct msm_session *session; struct camera_v4l2_private *sp = fh_to_private(fh); struct msm_video_device *pvdev = video_drvdata(filep); unsigned int session_id = pvdev->vdev->num; session = msm_session_find(session_id); if (WARN_ON(!session)) return -EIO; mutex_lock(&session->lock); ret = vb2_reqbufs(&sp->vb2_q, req); mutex_unlock(&session->lock); return ret; }
static int camera_v4l2_dqbuf(struct file *filep, void *fh, struct v4l2_buffer *pb) { int ret; struct msm_session *session; struct camera_v4l2_private *sp = fh_to_private(fh); struct msm_video_device *pvdev = video_drvdata(filep); unsigned int session_id = pvdev->vdev->num; session = msm_session_find(session_id); if (WARN_ON(!session)) return -EIO; mutex_lock(&session->lock); ret = vb2_dqbuf(&sp->vb2_q, pb, filep->f_flags & O_NONBLOCK); mutex_unlock(&session->lock); return ret; }
static int camera_v4l2_close(struct file *filep) { int rc = 0; struct v4l2_event event; struct msm_video_device *pvdev = video_drvdata(filep); struct camera_v4l2_private *sp = fh_to_private(filep->private_data); unsigned int opn_idx, mask; struct msm_session *session; BUG_ON(!pvdev); session = msm_session_find(pvdev->vdev->num); if (WARN_ON(!session)) return -EIO; opn_idx = atomic_read(&pvdev->opened); pr_info("[CAM]%s: close stream_id=%d +\n", __func__, sp->stream_id); pr_debug("%s: close stream_id=%d\n", __func__, sp->stream_id); mask = (1 << sp->stream_id); opn_idx &= ~mask; atomic_set(&pvdev->opened, opn_idx); if (atomic_read(&pvdev->opened) == 0) { mutex_lock(&session->close_lock); camera_pack_event(filep, MSM_CAMERA_SET_PARM, MSM_CAMERA_PRIV_DEL_STREAM, -1, &event); pr_info("[CAM]%s: + MSM_CAMERA_PRIV_DEL_STREAM 1\n", __func__); msm_post_event(&event, MSM_POST_EVT_TIMEOUT); pr_info("[CAM]%s: -\n", __func__); camera_pack_event(filep, MSM_CAMERA_DEL_SESSION, 0, -1, &event); pr_info("[CAM]%s: + MSM_CAMERA_DEL_SESSION 2\n", __func__); msm_post_event(&event, MSM_POST_EVT_TIMEOUT); pr_info("[CAM]%s: -\n", __func__); msm_delete_command_ack_q(pvdev->vdev->num, 0); mutex_unlock(&session->close_lock); pr_info("[CAM]%s: msm_delete_command_ack_q done\n", __func__); camera_v4l2_vb2_q_release(filep); pr_info("[CAM]%s: camera_v4l2_vb2_q_release done\n", __func__); msm_destroy_session(pvdev->vdev->num); pr_info("[CAM]%s: msm_destroy_session done\n", __func__); pm_relax(&pvdev->vdev->dev); pr_info("[CAM]%s: pm_relax done\n", __func__); } else { mutex_lock(&session->close_lock); camera_pack_event(filep, MSM_CAMERA_SET_PARM, MSM_CAMERA_PRIV_DEL_STREAM, -1, &event); pr_info("[CAM]%s: + MSM_CAMERA_PRIV_DEL_STREAM\n", __func__); msm_post_event(&event, MSM_POST_EVT_TIMEOUT); pr_info("[CAM]%s: -\n", __func__); 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); mutex_unlock(&session->close_lock); } camera_v4l2_fh_release(filep); pr_info("[CAM]%s: close -\n", __func__); return rc; }