diff options
author | Rui Miguel Silva <rui.silva@linaro.org> | 2018-04-02 11:36:51 +0100 |
---|---|---|
committer | Bryan O'Donoghue <bryan.odonoghue@linaro.org> | 2019-05-01 11:51:32 +0100 |
commit | ca2b0991b8ed7a94914a649aece35c5f0af12ed7 (patch) | |
tree | 338bf2f3407e4b142e34039dc31f1e501a9fe43d | |
parent | acbe366cc9651b1e0315dc840320ef9e0cebf10b (diff) |
staging: media: imx7: stop streaming on fd release
To guarantee that all pipeline is stopped correctly at file descriptor release
operation call the streamoff function before stopping csi own resources.
Signed-off-by: Rui Miguel Silva <rui.silva@linaro.org>
-rw-r--r-- | drivers/staging/media/imx/imx7-media-csi.c | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/drivers/staging/media/imx/imx7-media-csi.c b/drivers/staging/media/imx/imx7-media-csi.c index cfc29d4adbd2..11a1cb1d8a62 100644 --- a/drivers/staging/media/imx/imx7-media-csi.c +++ b/drivers/staging/media/imx/imx7-media-csi.c @@ -276,11 +276,14 @@ struct imx7_csi_dev { struct v4l2_async_subdev *async_subdevs[2]; bool csi_mux_mipi; + bool is_streamon; const bool *rx_fifo_rst; struct imx7_csi_mux csi_mux; }; static const struct of_device_id imx7_csi_dt_ids[]; +static int imx7_vidioc_streamoff(struct file *file, void *priv, + enum v4l2_buf_type i); static int csi_read(struct imx7_csi_dev *csi, unsigned int offset) { @@ -1100,6 +1103,8 @@ static int imx7_csi_release(struct file *file) mutex_lock(&csi_dev->lock); + imx7_vidioc_streamoff(file, NULL, V4L2_BUF_TYPE_VIDEO_CAPTURE); + imx7_stop_streaming(vq); vb2_queue_release(vq); @@ -1350,6 +1355,9 @@ static int imx7_vidioc_streamon(struct file *file, void *priv, struct v4l2_subdev *sd = csi_dev->sd; int ret; + if (csi_dev->is_streamon) + return 0; + if (i != V4L2_BUF_TYPE_VIDEO_CAPTURE) return -EINVAL; @@ -1357,6 +1365,8 @@ static int imx7_vidioc_streamon(struct file *file, void *priv, if (!ret) v4l2_subdev_call(sd, video, s_stream, 1); + csi_dev->is_streamon = true; + return ret; } @@ -1366,6 +1376,9 @@ static int imx7_vidioc_streamoff(struct file *file, void *priv, struct imx7_csi_dev *csi_dev = video_drvdata(file); struct v4l2_subdev *sd = csi_dev->sd; + if (!csi_dev->is_streamon) + return 0; + if (i != V4L2_BUF_TYPE_VIDEO_CAPTURE) return -EINVAL; @@ -1377,6 +1390,8 @@ static int imx7_vidioc_streamoff(struct file *file, void *priv, v4l2_subdev_call(sd, video, s_stream, 0); + csi_dev->is_streamon = false; + return 0; } |