From 02c9fd4f01ce8b0c3725ee993c44dc64920da404 Mon Sep 17 00:00:00 2001
From: Nick Hollinghurst <nick.hollinghurst@raspberrypi.com>
Date: Wed, 6 Dec 2023 14:27:57 +0000
Subject: [PATCH] drivers: media: i2c: imx296: Configure tigger_mode every time

Don't assume the camera has been reset each time we start streaming,
but always write registers relating to trigger_mode, even in mode 0.

IMX477: Stop driving XVS on stop streaming, to avoid spurious pulses.

Signed-off-by: Nick Hollinghurst <nick.hollinghurst@raspberrypi.com>
---
 drivers/media/i2c/imx296.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

--- a/drivers/media/i2c/imx296.c
+++ b/drivers/media/i2c/imx296.c
@@ -583,10 +583,11 @@ static int imx296_stream_on(struct imx29
 	imx296_write(sensor, IMX296_CTRL00, 0, &ret);
 	usleep_range(2000, 5000);
 
-	if (trigger_mode == 1) {
-		imx296_write(sensor, IMX296_CTRL0B, IMX296_CTRL0B_TRIGEN, &ret);
-		imx296_write(sensor, IMX296_LOWLAGTRG,  IMX296_LOWLAGTRG_FAST, &ret);
-	}
+	/* external trigger mode: 0=normal, 1=triggered */
+	imx296_write(sensor, IMX296_CTRL0B,
+		     (trigger_mode == 1) ? IMX296_CTRL0B_TRIGEN : 0, &ret);
+	imx296_write(sensor, IMX296_LOWLAGTRG,
+		     (trigger_mode == 1) ? IMX296_LOWLAGTRG_FAST : 0, &ret);
 
 	imx296_write(sensor, IMX296_CTRL0A, 0, &ret);
 
