diff mbox series

[15/21] media: i2c: imx258: Issue reset before starting streaming

Message ID 20230530173000.3060865-16-dave.stevenson@raspberrypi.com
State Accepted
Commit 185025977c3e7ba37d26af24c3648f3b52f62580
Headers show
Series [01/21] media: i2c: imx258: Remove unused defines | expand

Commit Message

Dave Stevenson May 30, 2023, 5:29 p.m. UTC
Whilst not documented, register 0x0103 bit 0 is the soft
reset for the sensor, so send it before trying to configure
the sensor.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
---
 drivers/media/i2c/imx258.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

Comments

Jacopo Mondi June 2, 2023, 1:42 p.m. UTC | #1
Hi Dave

On Tue, May 30, 2023 at 06:29:54PM +0100, Dave Stevenson wrote:
> Whilst not documented, register 0x0103 bit 0 is the soft
> reset for the sensor, so send it before trying to configure
> the sensor.
>
> Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
> ---
>  drivers/media/i2c/imx258.c | 10 ++++++++++
>  1 file changed, 10 insertions(+)
>
> diff --git a/drivers/media/i2c/imx258.c b/drivers/media/i2c/imx258.c
> index 1e424058fcb9..7d6528f9ca4d 100644
> --- a/drivers/media/i2c/imx258.c
> +++ b/drivers/media/i2c/imx258.c
> @@ -20,6 +20,8 @@
>  #define IMX258_MODE_STANDBY		0x00
>  #define IMX258_MODE_STREAMING		0x01
>
> +#define IMX258_REG_RESET		0x0103
> +
>  /* Chip ID */
>  #define IMX258_REG_CHIP_ID		0x0016
>  #define IMX258_CHIP_ID			0x0258
> @@ -1084,6 +1086,14 @@ static int imx258_start_streaming(struct imx258 *imx258)
>  	const struct imx258_link_freq_config *link_freq_cfg;
>  	int ret, link_freq_index;
>
> +	ret = imx258_write_reg(imx258, IMX258_REG_RESET, IMX258_REG_VALUE_08BIT,
> +			       0x01);
> +	if (ret) {
> +		dev_err(&client->dev, "%s failed to reset sensor\n", __func__);
> +		return ret;
> +	}
> +	usleep_range(10000, 15000);

Is the reset delay documented as well ?

up to 15msec seems a long time. Also, you can use fsleep() if you
don't have very precise constraints..

> +
>  	/* Setup PLL */
>  	link_freq_index = imx258->cur_mode->link_freq_index;
>  	link_freq_cfg = &imx258->link_freq_configs[link_freq_index];
> --
> 2.25.1
>
diff mbox series

Patch

diff --git a/drivers/media/i2c/imx258.c b/drivers/media/i2c/imx258.c
index 1e424058fcb9..7d6528f9ca4d 100644
--- a/drivers/media/i2c/imx258.c
+++ b/drivers/media/i2c/imx258.c
@@ -20,6 +20,8 @@ 
 #define IMX258_MODE_STANDBY		0x00
 #define IMX258_MODE_STREAMING		0x01
 
+#define IMX258_REG_RESET		0x0103
+
 /* Chip ID */
 #define IMX258_REG_CHIP_ID		0x0016
 #define IMX258_CHIP_ID			0x0258
@@ -1084,6 +1086,14 @@  static int imx258_start_streaming(struct imx258 *imx258)
 	const struct imx258_link_freq_config *link_freq_cfg;
 	int ret, link_freq_index;
 
+	ret = imx258_write_reg(imx258, IMX258_REG_RESET, IMX258_REG_VALUE_08BIT,
+			       0x01);
+	if (ret) {
+		dev_err(&client->dev, "%s failed to reset sensor\n", __func__);
+		return ret;
+	}
+	usleep_range(10000, 15000);
+
 	/* Setup PLL */
 	link_freq_index = imx258->cur_mode->link_freq_index;
 	link_freq_cfg = &imx258->link_freq_configs[link_freq_index];