static int camera_v4l2_g_crop(struct file *filep, void *fh, struct v4l2_crop *crop) { int rc = 0; struct v4l2_event event; if (crop->type == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE) { camera_pack_event(filep, MSM_CAMERA_GET_PARM, MSM_CAMERA_PRIV_G_CROP, -1, &event); rc = msm_post_event(&event, MSM_POST_EVT_TIMEOUT); if (rc < 0) return rc; rc = camera_check_event_status(&event); } return rc; }
static int camera_v4l2_g_ctrl(struct file *filep, void *fh, struct v4l2_control *ctrl) { int rc = 0; struct v4l2_event event; if (ctrl->id >= V4L2_CID_PRIVATE_BASE) { camera_pack_event(filep, MSM_CAMERA_GET_PARM, ctrl->id, -1, &event); rc = msm_post_event(&event, MSM_POST_EVT_TIMEOUT); if (rc < 0) return rc; rc = camera_check_event_status(&event); } return rc; }
static int camera_v4l2_s_fmt_vid_cap_mplane(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_VIDEO_CAPTURE_MPLANE) { if (WARN_ON(!sp->vb2_q.drv_priv)) return -ENOMEM; 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); if (WARN_ON(user_fmt->num_planes > VIDEO_MAX_PLANES)) return -EINVAL; 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, -1, &event); rc = msm_post_event(&event, MSM_POST_EVT_TIMEOUT); if (rc < 0) return rc; rc = camera_check_event_status(&event); if (rc < 0) return rc; sp->is_vb2_valid = 1; } return rc; }
static int camera_v4l2_streamoff(struct file *filep, void *fh, enum v4l2_buf_type buf_type) { 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, -1, &event); pr_info("[CAM]%s: + \n", __func__); rc = msm_post_event(&event, MSM_POST_EVT_TIMEOUT); pr_info("[CAM]%s: - \n", __func__); if (rc < 0) return rc; rc = camera_check_event_status(&event); vb2_streamoff(&sp->vb2_q, buf_type); return rc; }
static int camera_v4l2_g_fmt_vid_cap_mplane(struct file *filep, void *fh, struct v4l2_format *pfmt) { int rc = -EINVAL; if (pfmt->type == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE) { struct v4l2_event event; camera_pack_event(filep, MSM_CAMERA_GET_PARM, MSM_CAMERA_PRIV_G_FMT, -1, &event); rc = msm_post_event(&event, MSM_POST_EVT_TIMEOUT); if (rc < 0) return rc; rc = camera_check_event_status(&event); } return rc; }
static int camera_v4l2_s_ctrl(struct file *filep, void *fh, struct v4l2_control *ctrl) { int rc = 0; struct v4l2_event event; struct msm_v4l2_event_data *event_data; if (ctrl->id >= V4L2_CID_PRIVATE_BASE) { camera_pack_event(filep, MSM_CAMERA_SET_PARM, ctrl->id, ctrl->value, &event); rc = msm_post_event(&event, MSM_POST_EVT_TIMEOUT); if (rc < 0) return rc; event_data = (struct msm_v4l2_event_data *)event.u.data; ctrl->value = event_data->ret_value; rc = camera_check_event_status(&event); } return rc; }
static int camera_v4l2_queryctrl(struct file *filep, void *fh, struct v4l2_queryctrl *ctrl) { int rc = 0; struct v4l2_event event; if (ctrl->type == V4L2_CTRL_TYPE_MENU) { camera_pack_event(filep, MSM_CAMERA_GET_PARM, ctrl->id, -1, &event); rc = msm_post_event(&event, MSM_POST_EVT_TIMEOUT); if (rc < 0) return rc; rc = camera_check_event_status(&event); } return rc; }
static int camera_v4l2_querycap(struct file *filep, void *fh, struct v4l2_capability *cap) { int rc; struct v4l2_event event; /* can use cap->driver to make differentiation */ camera_pack_event(filep, MSM_CAMERA_GET_PARM, MSM_CAMERA_PRIV_QUERY_CAP, -1, &event); rc = msm_post_event(&event, MSM_POST_EVT_TIMEOUT); if (rc < 0) { pr_err("%s : msm_post_event failed!", __func__); return rc; } rc = camera_check_event_status(&event); return rc; }
static int camera_v4l2_streamon(struct file *filep, void *fh, enum v4l2_buf_type buf_type) { 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, -1, &event); rc = msm_post_event(&event, MSM_POST_EVT_TIMEOUT); if (rc < 0) { pr_err("%s : msm_post_event failed!", __func__); return rc; } rc = camera_check_event_status(&event); return rc; }
static int camera_v4l2_s_parm(struct file *filep, void *fh, struct v4l2_streamparm *parm) { int rc = 0; struct v4l2_event event; struct msm_v4l2_event_data *event_data = (struct msm_v4l2_event_data *)&event.u.data[0]; struct camera_v4l2_private *sp = fh_to_private(fh); camera_pack_event(filep, MSM_CAMERA_SET_PARM, MSM_CAMERA_PRIV_NEW_STREAM, -1, &event); rc = msm_create_stream(event_data->session_id, event_data->stream_id, &sp->vb2_q); if (rc < 0) { pr_err("%s : msm_create_stream failed", __func__); return rc; } rc = msm_post_event(&event, MSM_POST_EVT_TIMEOUT); if (rc < 0) { pr_err("%s : msm_post_event failed!", __func__); goto error; } rc = camera_check_event_status(&event); if (rc < 0) { pr_err("%s : camera_check_event_status failed!", __func__); goto error; } /* use stream_id as stream index */ parm->parm.capture.extendedmode = sp->stream_id; return rc; error: msm_delete_stream(event_data->session_id, event_data->stream_id); return rc; }
static int camera_v4l2_s_crop(struct file *filep, void *fh, const struct v4l2_crop *crop) { int rc = 0; struct v4l2_event event; if (crop->type == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE) { camera_pack_event(filep, MSM_CAMERA_SET_PARM, MSM_CAMERA_PRIV_S_CROP, -1, &event); rc = msm_post_event(&event, MSM_POST_EVT_TIMEOUT); if (rc < 0) { pr_err("%s : msm_post_event failed!", __FUNCTION__); return rc; } rc = camera_check_event_status(&event); } return rc; }
static int camera_v4l2_g_ctrl(struct file *filep, void *fh, struct v4l2_control *ctrl) { int rc = 0; struct v4l2_event event; if (ctrl->id >= V4L2_CID_PRIVATE_BASE) { camera_pack_event(filep, MSM_CAMERA_GET_PARM, ctrl->id, -1, &event); rc = msm_post_event(&event, MSM_POST_EVT_TIMEOUT); /* */ if (rc < 0){ pr_err("%s:%d camera_v4l2_g_ctrl failed\n", __func__, __LINE__); return rc; } /* */ rc = camera_check_event_status(&event); } return rc; }
static int camera_v4l2_open(struct file *filep) { int rc = 0; struct v4l2_event event; struct msm_video_device *pvdev = video_drvdata(filep); BUG_ON(!pvdev); rc = camera_v4l2_fh_open(filep); if (rc < 0) { pr_err("%s : camera_v4l2_fh_open failed Line %d rc %d\n", __func__, __LINE__, rc); goto fh_open_fail; } /* every stream has a vb2 queue */ rc = camera_v4l2_vb2_q_init(filep); if (rc < 0) { pr_err("%s : vb2 queue init fails Line %d rc %d\n", __func__, __LINE__, rc); goto vb2_q_fail; } if (!atomic_read(&pvdev->opened)) { pm_stay_awake(&pvdev->vdev->dev); /* create a new session when first opened */ rc = msm_create_session(pvdev->vdev->num, pvdev->vdev); if (rc < 0) { pr_err("%s : session creation failed Line %d rc %d\n", __func__, __LINE__, rc); goto session_fail; } rc = msm_create_command_ack_q(pvdev->vdev->num, 0); if (rc < 0) { pr_err("%s : creation of command_ack queue failed\n", __func__); pr_err("%s : Line %d rc %d\n", __func__, __LINE__, rc); goto command_ack_q_fail; } camera_pack_event(filep, MSM_CAMERA_NEW_SESSION, 0, -1, &event); rc = msm_post_event(&event, MSM_POST_EVT_TIMEOUT); if (rc < 0) { pr_err("%s : posting of NEW_SESSION event failed\n", __func__); pr_err("%s : Line %d rc %d\n", __func__, __LINE__, rc); goto post_fail; } rc = camera_check_event_status(&event); if (rc < 0) { pr_err("%s : checking event status fails Line %d rc %d\n", __func__, __LINE__, rc); goto post_fail; } } else { rc = msm_create_command_ack_q(pvdev->vdev->num, atomic_read(&pvdev->stream_cnt)); if (rc < 0) { pr_err("%s : creation of command_ack queue failed Line %d rc %d\n", __func__, __LINE__, rc); goto session_fail; } } atomic_add(1, &pvdev->opened); atomic_add(1, &pvdev->stream_cnt); return rc; post_fail: msm_delete_command_ack_q(pvdev->vdev->num, 0); command_ack_q_fail: msm_destroy_session(pvdev->vdev->num); session_fail: pm_relax(&pvdev->vdev->dev); camera_v4l2_vb2_q_release(filep); vb2_q_fail: camera_v4l2_fh_release(filep); fh_open_fail: return rc; }
static int camera_v4l2_open(struct file *filep) { int rc = 0; struct v4l2_event event; struct msm_video_device *pvdev = video_drvdata(filep); unsigned int opn_idx, idx; BUG_ON(!pvdev); rc = camera_v4l2_fh_open(filep); if (rc < 0) { pr_err("%s : camera_v4l2_fh_open failed Line %d rc %d\n", __func__, __LINE__, rc); goto fh_open_fail; } opn_idx = atomic_read(&pvdev->opened); idx = opn_idx; /* every stream has a vb2 queue */ rc = camera_v4l2_vb2_q_init(filep); if (rc < 0) { pr_err("%s : vb2 queue init fails Line %d rc %d\n", __func__, __LINE__, rc); goto vb2_q_fail; } if (!atomic_read(&pvdev->opened)) { pm_stay_awake(&pvdev->vdev->dev); /* Disable power collapse latency */ msm_pm_qos_update_request(CAMERA_DISABLE_PC_LATENCY); /* create a new session when first opened */ rc = msm_create_session(pvdev->vdev->num, pvdev->vdev); if (rc < 0) { pr_err("%s : session creation failed Line %d rc %d\n", __func__, __LINE__, rc); goto session_fail; } rc = msm_create_command_ack_q(pvdev->vdev->num, find_first_zero_bit((const unsigned long *)&opn_idx, MSM_CAMERA_STREAM_CNT_BITS)); if (rc < 0) { pr_err("%s : creation of command_ack queue failed\n", __func__); pr_err("%s : Line %d rc %d\n", __func__, __LINE__, rc); goto command_ack_q_fail; } camera_pack_event(filep, MSM_CAMERA_NEW_SESSION, 0, -1, &event); rc = msm_post_event(&event, MSM_POST_EVT_TIMEOUT); if (rc < 0) { pr_err("%s : posting of NEW_SESSION event failed\n", __func__); pr_err("%s : Line %d rc %d\n", __func__, __LINE__, rc); goto post_fail; } rc = camera_check_event_status(&event); if (rc < 0) { pr_err("%s : checking event status fails Line %d rc %d\n", __func__, __LINE__, rc); goto post_fail; } } else { rc = msm_create_command_ack_q(pvdev->vdev->num, find_first_zero_bit((const unsigned long *)&opn_idx, MSM_CAMERA_STREAM_CNT_BITS)); if (rc < 0) { pr_err("%s : creation of command_ack queue failed Line %d rc %d\n", __func__, __LINE__, rc); goto session_fail; } } idx |= (1 << find_first_zero_bit((const unsigned long *)&opn_idx, MSM_CAMERA_STREAM_CNT_BITS)); atomic_cmpxchg(&pvdev->opened, opn_idx, idx); return rc; post_fail: msm_delete_command_ack_q(pvdev->vdev->num, 0); command_ack_q_fail: msm_destroy_session(pvdev->vdev->num); session_fail: pm_relax(&pvdev->vdev->dev); camera_v4l2_vb2_q_release(filep); vb2_q_fail: camera_v4l2_fh_release(filep); fh_open_fail: return rc; }
static int camera_v4l2_open(struct file *filep) { int rc = 0; struct v4l2_event event; struct msm_video_device *pvdev = video_drvdata(filep); BUG_ON(!pvdev); rc = camera_v4l2_fh_open(filep); if (rc < 0) { pr_err("%s : camera_v4l2_fh_open", __func__); goto fh_open_fail; } /* every stream has a vb2 queue */ rc = camera_v4l2_vb2_q_init(filep); if (rc < 0) { pr_err("%s : camera_v4l2_vb2_q_init", __func__); goto vb2_q_fail; } if (!atomic_read(&pvdev->opened)) { /* create a new session when first opened */ rc = msm_create_session(pvdev->vdev->num, pvdev->vdev); if (rc < 0) { pr_err("%s : msm_create_session", __func__); goto session_fail; } rc = msm_create_command_ack_q(pvdev->vdev->num, 0); if (rc < 0) { pr_err("%s : msm_create_command_ack_q", __func__); goto command_ack_q_fail; } camera_pack_event(filep, MSM_CAMERA_NEW_SESSION, 0, -1, &event); rc = msm_post_event(&event, MSM_POST_EVT_TIMEOUT); if (rc < 0) { pr_err("%s, __dbg: post fail \n", __func__); if (qdaemon_task) { if (!strncmp(qdaemon_task->comm, QDAEMON, strlen(QDAEMON))) { pr_err("%s, kill daemon", __func__); send_sig(SIGKILL, qdaemon_task, 0); pr_err("%s, kill this", __func__); send_sig(SIGKILL, current, 0); } else pr_err("%s, now (%s : %d)", __func__, qdaemon_task->comm, task_pid_nr(qdaemon_task)); } else pr_err("error!! can't look for daemon"); goto post_fail; } rc = camera_check_event_status(&event); if (rc < 0) { pr_err("%s : camera_check_event_status", __func__); goto post_fail; } } else { rc = msm_create_command_ack_q(pvdev->vdev->num, atomic_read(&pvdev->opened)); if (rc < 0) { pr_err("%s : msm_create_command_ack_q", __func__); goto session_fail; } } atomic_add(1, &pvdev->opened); return rc; post_fail: msm_delete_command_ack_q(pvdev->vdev->num, 0); command_ack_q_fail: msm_destroy_session(pvdev->vdev->num); session_fail: camera_v4l2_vb2_q_release(filep); vb2_q_fail: camera_v4l2_fh_release(filep); fh_open_fail: return rc; }