Skip to content

Commit f1b9630

Browse files
media: i2c: imx477: Disable temperature sensor when enabling XVS
On IMX477 it appears that the on-chip temperature sensor causes XVS (external sync out) to pulse every ~2ms when not streaming. So now we do a little dance: Temperature sensor is enabled during common register setup, giving it time to warm up (almost literally; otherwise the first frame's reading might be 0C), disabled before enabling sync out, then enabled again once the camera is streaming. We already took care to disable XVS output in stop_streaming() (though previously it wasn't understood why this was needed). Signed-off-by: Nick Hollinghurst <[email protected]>
1 parent c8c70b6 commit f1b9630

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

drivers/media/i2c/imx477.c

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,9 @@ MODULE_PARM_DESC(trigger_mode, "Set vsync trigger mode: 1=source, 2=sink");
112112
#define IMX477_REG_XVS_IO_CTRL 0x3040
113113
#define IMX477_REG_EXTOUT_EN 0x4b81
114114

115+
/* Temperature sensor */
116+
#define IMX477_REG_TEMP_SEN_CTL 0x0138
117+
115118
/* Embedded metadata stream structure */
116119
#define IMX477_EMBEDDED_LINE_WIDTH 16384
117120
#define IMX477_NUM_EMBEDDED_LINES 1
@@ -1833,6 +1836,9 @@ static int imx477_start_streaming(struct imx477 *imx477)
18331836

18341837
/* Set vsync trigger mode: 0=standalone, 1=source, 2=sink */
18351838
tm = (imx477->trigger_mode_of >= 0) ? imx477->trigger_mode_of : trigger_mode;
1839+
if (tm == 1)
1840+
imx477_write_reg(imx477, IMX477_REG_TEMP_SEN_CTL,
1841+
IMX477_REG_VALUE_08BIT, 0);
18361842
imx477_write_reg(imx477, IMX477_REG_MC_MODE,
18371843
IMX477_REG_VALUE_08BIT, (tm > 0) ? 1 : 0);
18381844
imx477_write_reg(imx477, IMX477_REG_MS_SEL,
@@ -1843,8 +1849,15 @@ static int imx477_start_streaming(struct imx477 *imx477)
18431849
IMX477_REG_VALUE_08BIT, (tm == 1) ? 1 : 0);
18441850

18451851
/* set stream on register */
1846-
return imx477_write_reg(imx477, IMX477_REG_MODE_SELECT,
1847-
IMX477_REG_VALUE_08BIT, IMX477_MODE_STREAMING);
1852+
ret = imx477_write_reg(imx477, IMX477_REG_MODE_SELECT,
1853+
IMX477_REG_VALUE_08BIT, IMX477_MODE_STREAMING);
1854+
1855+
/* now it's safe to re-enable temp sensor without glitching XVS */
1856+
if (tm == 1)
1857+
imx477_write_reg(imx477, IMX477_REG_TEMP_SEN_CTL,
1858+
IMX477_REG_VALUE_08BIT, 1);
1859+
1860+
return ret;
18481861
}
18491862

18501863
/* Stop streaming */

0 commit comments

Comments
 (0)