diff mbox series

media: tc358743: implement pre_streamon to put all lanes into LP-11 state

Message ID 20210923164332.18227-1-p.zabel@pengutronix.de (mailing list archive)
State New, archived
Headers show
Series media: tc358743: implement pre_streamon to put all lanes into LP-11 state | expand

Commit Message

Philipp Zabel Sept. 23, 2021, 4:43 p.m. UTC
If the connected MIPI CSI-2 RX driver uses the new pre_streamon subdev
call, we don't have to reinitialize the CSI-2 TX after streamoff.
Just put all lanes into LP-11 state during pre_streamon if requested.

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
---
 drivers/media/i2c/tc358743.c | 19 ++++++++++++++++++-
 1 file changed, 18 insertions(+), 1 deletion(-)

Comments

Michael Tretter Sept. 30, 2021, 9:14 a.m. UTC | #1
On Thu, 23 Sep 2021 18:43:32 +0200, Philipp Zabel wrote:
> If the connected MIPI CSI-2 RX driver uses the new pre_streamon subdev
> call, we don't have to reinitialize the CSI-2 TX after streamoff.
> Just put all lanes into LP-11 state during pre_streamon if requested.
> 
> Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
> ---
>  drivers/media/i2c/tc358743.c | 19 ++++++++++++++++++-
>  1 file changed, 18 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/media/i2c/tc358743.c b/drivers/media/i2c/tc358743.c
> index 3205cd8298dd..40eec67604e0 100644
> --- a/drivers/media/i2c/tc358743.c
> +++ b/drivers/media/i2c/tc358743.c
> @@ -93,6 +93,7 @@ struct tc358743_state {
>  	struct v4l2_dv_timings timings;
>  	u32 mbus_fmt_code;
>  	u8 csi_lanes_in_use;
> +	bool pre_streamon_used;

Maybe a name in the device domain instead of the driver domain would be
better. For example, "csi_in_lp11".

>  
>  	struct gpio_desc *reset_gpio;
>  
> @@ -1637,8 +1638,10 @@ static int tc358743_get_mbus_config(struct v4l2_subdev *sd,
>  
>  static int tc358743_s_stream(struct v4l2_subdev *sd, int enable)
>  {
> +	struct tc358743_state *state = to_state(sd);
> +
>  	enable_stream(sd, enable);
> -	if (!enable) {
> +	if (!enable && !state->pre_streamon_used) {
>  		/* Put all lanes in LP-11 state (STOPSTATE) */
>  		tc358743_set_csi(sd);
>  	}
> @@ -1646,6 +1649,19 @@ static int tc358743_s_stream(struct v4l2_subdev *sd, int enable)
>  	return 0;
>  }
>  
> +static int tc358743_pre_streamon(struct v4l2_subdev *sd, u32 flags)
> +{
> +	struct tc358743_state *state = to_state(sd);
> +
> +	/* Put all lanes in LP-11 state (STOPSTATE) if requested */
> +	if (flags & V4L2_SUBDEV_PRE_STREAMON_FL_MANUAL_LP)
> +		tc358743_set_csi(sd);
> +
> +	state->pre_streamon_used = true;

I think pre_streamon_used should only be set, if the MANUAL_LP flag is set.

Do we need to reset pre_streamon_used on streamoff (or maybe on streamon)?

Michael

> +
> +	return 0;
> +}
> +
>  /* --------------- PAD OPS --------------- */
>  
>  static int tc358743_enum_mbus_code(struct v4l2_subdev *sd,
> @@ -1840,6 +1856,7 @@ static const struct v4l2_subdev_video_ops tc358743_video_ops = {
>  	.g_dv_timings = tc358743_g_dv_timings,
>  	.query_dv_timings = tc358743_query_dv_timings,
>  	.s_stream = tc358743_s_stream,
> +	.pre_streamon = tc358743_pre_streamon,
>  };
>  
>  static const struct v4l2_subdev_pad_ops tc358743_pad_ops = {
> -- 
> 2.30.2
> 
>
diff mbox series

Patch

diff --git a/drivers/media/i2c/tc358743.c b/drivers/media/i2c/tc358743.c
index 3205cd8298dd..40eec67604e0 100644
--- a/drivers/media/i2c/tc358743.c
+++ b/drivers/media/i2c/tc358743.c
@@ -93,6 +93,7 @@  struct tc358743_state {
 	struct v4l2_dv_timings timings;
 	u32 mbus_fmt_code;
 	u8 csi_lanes_in_use;
+	bool pre_streamon_used;
 
 	struct gpio_desc *reset_gpio;
 
@@ -1637,8 +1638,10 @@  static int tc358743_get_mbus_config(struct v4l2_subdev *sd,
 
 static int tc358743_s_stream(struct v4l2_subdev *sd, int enable)
 {
+	struct tc358743_state *state = to_state(sd);
+
 	enable_stream(sd, enable);
-	if (!enable) {
+	if (!enable && !state->pre_streamon_used) {
 		/* Put all lanes in LP-11 state (STOPSTATE) */
 		tc358743_set_csi(sd);
 	}
@@ -1646,6 +1649,19 @@  static int tc358743_s_stream(struct v4l2_subdev *sd, int enable)
 	return 0;
 }
 
+static int tc358743_pre_streamon(struct v4l2_subdev *sd, u32 flags)
+{
+	struct tc358743_state *state = to_state(sd);
+
+	/* Put all lanes in LP-11 state (STOPSTATE) if requested */
+	if (flags & V4L2_SUBDEV_PRE_STREAMON_FL_MANUAL_LP)
+		tc358743_set_csi(sd);
+
+	state->pre_streamon_used = true;
+
+	return 0;
+}
+
 /* --------------- PAD OPS --------------- */
 
 static int tc358743_enum_mbus_code(struct v4l2_subdev *sd,
@@ -1840,6 +1856,7 @@  static const struct v4l2_subdev_video_ops tc358743_video_ops = {
 	.g_dv_timings = tc358743_g_dv_timings,
 	.query_dv_timings = tc358743_query_dv_timings,
 	.s_stream = tc358743_s_stream,
+	.pre_streamon = tc358743_pre_streamon,
 };
 
 static const struct v4l2_subdev_pad_ops tc358743_pad_ops = {