mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-08 03:40:35 +09:00
media: rockchip: isp/ispp add check for params subscribe event
Change-Id: If8b79286de5d9921abd69c96cb0b17ef297d75ef Signed-off-by: Cai YiWei <cyw@rock-chips.com>
This commit is contained in:
@@ -66,18 +66,30 @@ static int rkisp_params_querycap(struct file *file,
|
||||
static int rkisp_params_subs_evt(struct v4l2_fh *fh,
|
||||
const struct v4l2_event_subscription *sub)
|
||||
{
|
||||
struct rkisp_isp_params_vdev *params_vdev = video_get_drvdata(fh->vdev);
|
||||
|
||||
if (sub->id != 0)
|
||||
return -EINVAL;
|
||||
|
||||
switch (sub->type) {
|
||||
case CIFISP_V4L2_EVENT_STREAM_START:
|
||||
case CIFISP_V4L2_EVENT_STREAM_STOP:
|
||||
params_vdev->is_subs_evt = true;
|
||||
return v4l2_event_subscribe(fh, sub, 0, NULL);
|
||||
default:
|
||||
return -EINVAL;
|
||||
}
|
||||
}
|
||||
|
||||
static int rkisp_params_unsubs_evt(struct v4l2_fh *fh,
|
||||
const struct v4l2_event_subscription *sub)
|
||||
{
|
||||
struct rkisp_isp_params_vdev *params_vdev = video_get_drvdata(fh->vdev);
|
||||
|
||||
params_vdev->is_subs_evt = false;
|
||||
return v4l2_event_unsubscribe(fh, sub);
|
||||
}
|
||||
|
||||
/* ISP params video device IOCTLs */
|
||||
static const struct v4l2_ioctl_ops rkisp_params_ioctl = {
|
||||
.vidioc_reqbufs = vb2_ioctl_reqbufs,
|
||||
@@ -95,7 +107,7 @@ static const struct v4l2_ioctl_ops rkisp_params_ioctl = {
|
||||
.vidioc_try_fmt_meta_out = rkisp_params_g_fmt_meta_out,
|
||||
.vidioc_querycap = rkisp_params_querycap,
|
||||
.vidioc_subscribe_event = rkisp_params_subs_evt,
|
||||
.vidioc_unsubscribe_event = v4l2_event_unsubscribe
|
||||
.vidioc_unsubscribe_event = rkisp_params_unsubs_evt,
|
||||
};
|
||||
|
||||
static int rkisp_params_vb2_queue_setup(struct vb2_queue *vq,
|
||||
@@ -362,6 +374,7 @@ int rkisp_register_params_vdev(struct rkisp_isp_params_vdev *params_vdev,
|
||||
struct media_entity *source, *sink;
|
||||
|
||||
params_vdev->dev = dev;
|
||||
params_vdev->is_subs_evt = false;
|
||||
spin_lock_init(¶ms_vdev->config_lock);
|
||||
|
||||
strlcpy(vdev->name, PARAMS_NAME, sizeof(vdev->name));
|
||||
|
||||
@@ -78,6 +78,8 @@ struct rkisp_isp_params_vdev {
|
||||
struct isp21_drc_cfg cur_hdrdrc;
|
||||
struct isp2x_lsc_cfg cur_lsccfg;
|
||||
struct sensor_exposure_cfg exposure;
|
||||
|
||||
bool is_subs_evt;
|
||||
};
|
||||
|
||||
/* config params before ISP streaming */
|
||||
|
||||
@@ -847,7 +847,8 @@ static void rkisp_start_3a_run(struct rkisp_device *dev)
|
||||
};
|
||||
int ret;
|
||||
|
||||
if (!rkisp_is_need_3a(dev) || dev->isp_ver == ISP_V20)
|
||||
if (!rkisp_is_need_3a(dev) || dev->isp_ver == ISP_V20 ||
|
||||
!params_vdev->is_subs_evt)
|
||||
return;
|
||||
|
||||
v4l2_event_queue(vdev, &ev);
|
||||
@@ -874,7 +875,8 @@ static void rkisp_stop_3a_run(struct rkisp_device *dev)
|
||||
};
|
||||
int ret;
|
||||
|
||||
if (!rkisp_is_need_3a(dev) || dev->isp_ver == ISP_V20)
|
||||
if (!rkisp_is_need_3a(dev) || dev->isp_ver == ISP_V20 ||
|
||||
!params_vdev->is_subs_evt)
|
||||
return;
|
||||
|
||||
v4l2_event_queue(vdev, &ev);
|
||||
|
||||
@@ -651,20 +651,32 @@ static int rkispp_params_querycap(struct file *file,
|
||||
}
|
||||
|
||||
static int rkispp_params_subs_evt(struct v4l2_fh *fh,
|
||||
const struct v4l2_event_subscription *sub)
|
||||
const struct v4l2_event_subscription *sub)
|
||||
{
|
||||
struct rkispp_params_vdev *params_vdev = video_get_drvdata(fh->vdev);
|
||||
|
||||
if (sub->id != 0)
|
||||
return -EINVAL;
|
||||
|
||||
switch (sub->type) {
|
||||
case CIFISP_V4L2_EVENT_STREAM_START:
|
||||
case CIFISP_V4L2_EVENT_STREAM_STOP:
|
||||
params_vdev->is_subs_evt = true;
|
||||
return v4l2_event_subscribe(fh, sub, 0, NULL);
|
||||
default:
|
||||
return -EINVAL;
|
||||
}
|
||||
}
|
||||
|
||||
static int rkispp_params_unsubs_evt(struct v4l2_fh *fh,
|
||||
const struct v4l2_event_subscription *sub)
|
||||
{
|
||||
struct rkispp_params_vdev *params_vdev = video_get_drvdata(fh->vdev);
|
||||
|
||||
params_vdev->is_subs_evt = false;
|
||||
return v4l2_event_unsubscribe(fh, sub);
|
||||
}
|
||||
|
||||
static const struct v4l2_ioctl_ops rkispp_params_ioctl = {
|
||||
.vidioc_reqbufs = vb2_ioctl_reqbufs,
|
||||
.vidioc_querybuf = vb2_ioctl_querybuf,
|
||||
@@ -681,7 +693,7 @@ static const struct v4l2_ioctl_ops rkispp_params_ioctl = {
|
||||
.vidioc_try_fmt_meta_out = rkispp_params_g_fmt_meta_out,
|
||||
.vidioc_querycap = rkispp_params_querycap,
|
||||
.vidioc_subscribe_event = rkispp_params_subs_evt,
|
||||
.vidioc_unsubscribe_event = v4l2_event_unsubscribe
|
||||
.vidioc_unsubscribe_event = rkispp_params_unsubs_evt,
|
||||
};
|
||||
|
||||
static int
|
||||
@@ -1053,6 +1065,7 @@ int rkispp_register_params_vdev(struct rkispp_device *dev)
|
||||
int ret;
|
||||
|
||||
params_vdev->dev = dev;
|
||||
params_vdev->is_subs_evt = false;
|
||||
params_vdev->cur_params = vmalloc(sizeof(*params_vdev->cur_params));
|
||||
if (!params_vdev->cur_params)
|
||||
return -ENOMEM;
|
||||
|
||||
@@ -26,6 +26,7 @@ struct rkispp_params_vdev {
|
||||
struct v4l2_format vdev_fmt;
|
||||
bool streamon;
|
||||
bool first_params;
|
||||
bool is_subs_evt;
|
||||
|
||||
struct rkispp_dummy_buffer buf_fec[FEC_MESH_BUF_NUM];
|
||||
u32 buf_fec_idx;
|
||||
|
||||
@@ -1045,6 +1045,9 @@ static void rkispp_start_3a_run(struct rkispp_device *dev)
|
||||
};
|
||||
int ret;
|
||||
|
||||
if (!params_vdev->is_subs_evt)
|
||||
return;
|
||||
|
||||
v4l2_event_queue(vdev, &ev);
|
||||
ret = wait_event_timeout(dev->sync_onoff,
|
||||
params_vdev->streamon && !params_vdev->first_params,
|
||||
@@ -1066,6 +1069,9 @@ static void rkispp_stop_3a_run(struct rkispp_device *dev)
|
||||
};
|
||||
int ret;
|
||||
|
||||
if (!params_vdev->is_subs_evt)
|
||||
return;
|
||||
|
||||
v4l2_event_queue(vdev, &ev);
|
||||
ret = wait_event_timeout(dev->sync_onoff, !params_vdev->streamon,
|
||||
msecs_to_jiffies(1000));
|
||||
@@ -1095,8 +1101,7 @@ static int config_modules(struct rkispp_device *dev)
|
||||
{
|
||||
int ret;
|
||||
|
||||
if (dev->inp == INP_ISP)
|
||||
rkispp_start_3a_run(dev);
|
||||
rkispp_start_3a_run(dev);
|
||||
|
||||
v4l2_dbg(1, rkispp_debug, &dev->v4l2_dev,
|
||||
"stream module ens:0x%x\n", dev->stream_vdev.module_ens);
|
||||
@@ -1562,8 +1567,7 @@ static void rkispp_stream_stop(struct rkispp_stream *stream)
|
||||
stream->stopping = true;
|
||||
if (atomic_read(&dev->stream_vdev.refcnt) == 1) {
|
||||
v4l2_subdev_call(&dev->ispp_sdev.sd, video, s_stream, false);
|
||||
if (dev->inp == INP_ISP)
|
||||
rkispp_stop_3a_run(dev);
|
||||
rkispp_stop_3a_run(dev);
|
||||
if (dev->stream_vdev.fec.is_end &&
|
||||
(dev->dev_id != dev->hw_dev->cur_dev_id || dev->hw_dev->is_idle))
|
||||
is_wait = false;
|
||||
|
||||
Reference in New Issue
Block a user