Skip to content

Commit b0323a1

Browse files
committed
media: i2c: imx477: Add control of FSTROBE via module parameters
Copy the firmware's handling of FSTROBE, but using module parameters instead of config.txt entries. Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
1 parent e89e765 commit b0323a1

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

drivers/media/i2c/imx477.c

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,22 @@ static int trigger_mode;
2929
module_param(trigger_mode, int, 0644);
3030
MODULE_PARM_DESC(trigger_mode, "Set vsync trigger mode: 1=source, 2=sink");
3131

32+
static int fstrobe_enable;
33+
module_param(fstrobe_enable, int, 0644);
34+
MODULE_PARM_DESC(fstrobe_enable, "Enable fstrobe signal");
35+
36+
static int fstrobe_cont_trig;
37+
module_param(fstrobe_cont_trig, int, 0644);
38+
MODULE_PARM_DESC(fstrobe_cont_trig, "Configure fstrobe to be one-shot (0) or continuous (1)");
39+
40+
static int fstrobe_width = 1;
41+
module_param(fstrobe_width, int, 0644);
42+
MODULE_PARM_DESC(fstrobe_width, "Set fstrobe pulse width in units of INCK");
43+
44+
static int fstrobe_delay;
45+
module_param(fstrobe_delay, int, 0644);
46+
MODULE_PARM_DESC(fstrobe_delay, "Set fstrobe delay from end all lines starting to expose and the start of the strobe pulse");
47+
3248
#define IMX477_REG_VALUE_08BIT 1
3349
#define IMX477_REG_VALUE_16BIT 2
3450

@@ -1733,6 +1749,29 @@ static int imx477_start_streaming(struct imx477 *imx477)
17331749
return ret;
17341750
}
17351751

1752+
unsigned int fstrobe_width = max(fstrobe_width, 1);
1753+
unsigned int fstrobe_mult = 1;
1754+
1755+
while (fstrobe_width / fstrobe_mult > 0xffff && fstrobe_mult < 255)
1756+
fstrobe_mult++;
1757+
1758+
fstrobe_width /= fstrobe_mult;
1759+
1760+
// FLASH_MD_RS
1761+
imx477_write_reg(imx477, 0x0c1A, IMX477_REG_VALUE_08BIT,
1762+
((fstrobe_cont_trig ? 1 : 0) << 0) | (1 << 1));
1763+
// FLASH_STRB_WIDTH
1764+
imx477_write_reg(imx477, 0x0c18, IMX477_REG_VALUE_16BIT, fstrobe_width);
1765+
// FLASH_STRB_WIDTH adjust
1766+
imx477_write_reg(imx477, 0x0c12, IMX477_REG_VALUE_08BIT, fstrobe_mult);
1767+
// FLASH_STRB_START_POINT
1768+
imx477_write_reg(imx477, 0x0c14, IMX477_REG_VALUE_16BIT, fstrobe_delay);
1769+
// FLASH_STRB_DLY_RS
1770+
imx477_write_reg(imx477, 0x0c16, IMX477_REG_VALUE_16BIT, 0);
1771+
// FLASH_TRIG_RS
1772+
imx477_write_reg(imx477, 0x0c1B, IMX477_REG_VALUE_08BIT,
1773+
fstrobe_enable ? 1 : 0);
1774+
17361775
/* Set on-sensor DPC. */
17371776
imx477_write_reg(imx477, 0x0b05, IMX477_REG_VALUE_08BIT, !!dpc_enable);
17381777
imx477_write_reg(imx477, 0x0b06, IMX477_REG_VALUE_08BIT, !!dpc_enable);

0 commit comments

Comments
 (0)