Commit fbd36bce authored by Laurent Pinchart's avatar Laurent Pinchart Committed by Mauro Carvalho Chehab

media: imx: imx7-media-csi: Move (de)init from link setup to .s_stream()

There's no need to initialize the CSI every time a link is enabled (and
de-initialize it when a link is disabled). Move initialization to
.s_stream() instead.
Signed-off-by: default avatarLaurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: default avatarRui Miguel Silva <rmfrfs@gmail.com>
Signed-off-by: default avatarHans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+huawei@kernel.org>
parent dbeecb11
......@@ -184,7 +184,6 @@ struct imx7_csi {
u32 frame_sequence;
bool last_eof;
bool is_init;
bool is_streaming;
bool is_csi2;
......@@ -402,9 +401,6 @@ static int imx7_csi_init(struct imx7_csi *csi)
{
int ret;
if (csi->is_init)
return 0;
ret = clk_prepare_enable(csi->mclk);
if (ret < 0)
return ret;
......@@ -412,22 +408,15 @@ static int imx7_csi_init(struct imx7_csi *csi)
imx7_csi_init_interface(csi);
imx7_csi_dmareq_rff_enable(csi);
csi->is_init = true;
return 0;
}
static void imx7_csi_deinit(struct imx7_csi *csi)
{
if (!csi->is_init)
return;
imx7_csi_hw_reset(csi);
imx7_csi_init_interface(csi);
imx7_csi_dmareq_rff_disable(csi);
clk_disable_unprepare(csi->mclk);
csi->is_init = false;
}
static int imx7_csi_link_setup(struct media_entity *entity,
......@@ -462,7 +451,7 @@ static int imx7_csi_link_setup(struct media_entity *entity,
csi->src_sd = NULL;
}
goto init;
goto unlock;
}
/* source pad */
......@@ -476,12 +465,6 @@ static int imx7_csi_link_setup(struct media_entity *entity,
csi->sink = NULL;
}
init:
if (csi->sink || csi->src_sd)
ret = imx7_csi_init(csi);
else
imx7_csi_deinit(csi);
unlock:
mutex_unlock(&csi->lock);
......@@ -868,19 +851,28 @@ static int imx7_csi_s_stream(struct v4l2_subdev *sd, int enable)
goto out_unlock;
if (enable) {
ret = v4l2_subdev_call(csi->src_sd, video, s_stream, 1);
ret = imx7_csi_init(csi);
if (ret < 0)
goto out_unlock;
ret = v4l2_subdev_call(csi->src_sd, video, s_stream, 1);
if (ret < 0) {
imx7_csi_deinit(csi);
goto out_unlock;
}
ret = imx7_csi_streaming_start(csi);
if (ret < 0) {
v4l2_subdev_call(csi->src_sd, video, s_stream, 0);
imx7_csi_deinit(csi);
goto out_unlock;
}
} else {
imx7_csi_streaming_stop(csi);
v4l2_subdev_call(csi->src_sd, video, s_stream, 0);
imx7_csi_deinit(csi);
}
csi->is_streaming = !!enable;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment