Skip to content

Commit 35ed272

Browse files
njhollinghurstpelwell
authored andcommitted
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 <nick.hollinghurst@raspberrypi.com>
1 parent 598462f commit 35ed272

File tree

1 file changed

+19
-6
lines changed

1 file changed

+19
-6
lines changed

drivers/media/i2c/imx477.c

Lines changed: 19 additions & 6 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,18 +1836,28 @@ 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;
1836-
imx477_write_reg(imx477, IMX477_REG_MC_MODE,
1837-
IMX477_REG_VALUE_08BIT, (tm > 0) ? 1 : 0);
1839+
if (tm == 1)
1840+
imx477_write_reg(imx477, IMX477_REG_TEMP_SEN_CTL,
1841+
IMX477_REG_VALUE_08BIT, 0);
1842+
imx477_write_reg(imx477, IMX477_REG_EXTOUT_EN,
1843+
IMX477_REG_VALUE_08BIT, (tm == 1) ? 1 : 0);
18381844
imx477_write_reg(imx477, IMX477_REG_MS_SEL,
18391845
IMX477_REG_VALUE_08BIT, (tm <= 1) ? 1 : 0);
18401846
imx477_write_reg(imx477, IMX477_REG_XVS_IO_CTRL,
18411847
IMX477_REG_VALUE_08BIT, (tm == 1) ? 1 : 0);
1842-
imx477_write_reg(imx477, IMX477_REG_EXTOUT_EN,
1843-
IMX477_REG_VALUE_08BIT, (tm == 1) ? 1 : 0);
1848+
imx477_write_reg(imx477, IMX477_REG_MC_MODE,
1849+
IMX477_REG_VALUE_08BIT, (tm > 0) ? 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)