Skip to content

Commit 90d24b3

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 <[email protected]>
1 parent 82924a8 commit 90d24b3

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed

drivers/media/i2c/imx477.c

Lines changed: 41 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

@@ -1791,6 +1807,8 @@ static int imx477_start_streaming(struct imx477 *imx477)
17911807
struct i2c_client *client = v4l2_get_subdevdata(&imx477->sd);
17921808
const struct imx477_reg_list *reg_list, *freq_regs;
17931809
const struct imx477_reg_list *extra_regs;
1810+
unsigned int fst_width;
1811+
unsigned int fst_mult;
17941812
int ret, tm;
17951813

17961814
if (!imx477->common_regs_written) {
@@ -1825,6 +1843,29 @@ static int imx477_start_streaming(struct imx477 *imx477)
18251843
return ret;
18261844
}
18271845

1846+
fst_width = max((unsigned int)fstrobe_width, 1U);
1847+
fst_mult = 1;
1848+
1849+
while (fst_width / fst_mult > 0xffff && fst_mult < 255)
1850+
fst_mult++;
1851+
1852+
fst_width /= fst_mult;
1853+
1854+
// FLASH_MD_RS
1855+
imx477_write_reg(imx477, 0x0c1A, IMX477_REG_VALUE_08BIT,
1856+
((fstrobe_cont_trig ? 1 : 0) << 0) | (1 << 1));
1857+
// FLASH_STRB_WIDTH
1858+
imx477_write_reg(imx477, 0x0c18, IMX477_REG_VALUE_16BIT, fst_width);
1859+
// FLASH_STRB_WIDTH adjust
1860+
imx477_write_reg(imx477, 0x0c12, IMX477_REG_VALUE_08BIT, fst_mult);
1861+
// FLASH_STRB_START_POINT
1862+
imx477_write_reg(imx477, 0x0c14, IMX477_REG_VALUE_16BIT, fstrobe_delay);
1863+
// FLASH_STRB_DLY_RS
1864+
imx477_write_reg(imx477, 0x0c16, IMX477_REG_VALUE_16BIT, 0);
1865+
// FLASH_TRIG_RS
1866+
imx477_write_reg(imx477, 0x0c1B, IMX477_REG_VALUE_08BIT,
1867+
fstrobe_enable ? 1 : 0);
1868+
18281869
/* Set on-sensor DPC. */
18291870
imx477_write_reg(imx477, 0x0b05, IMX477_REG_VALUE_08BIT, !!dpc_enable);
18301871
imx477_write_reg(imx477, 0x0b06, IMX477_REG_VALUE_08BIT, !!dpc_enable);

0 commit comments

Comments
 (0)