Skip to content

Commit f4102d3

Browse files
erikbotonjhollinghurst
authored andcommitted
imx477: make trigger-mode more configurable
Allow trigger-mode to be overridden using device tree so that it can be set per camera. Previously the mode could only be changed using a module parameter, which would then affect all cameras. Signed-off-by: Erik Botö <[email protected]>
1 parent 5d1972f commit f4102d3

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

drivers/media/i2c/imx477.c

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1124,6 +1124,9 @@ struct imx477 {
11241124
/* Current mode */
11251125
const struct imx477_mode *mode;
11261126

1127+
/* Trigger mode */
1128+
int trigger_mode_of;
1129+
11271130
/*
11281131
* Mutex for serialized access:
11291132
* Protect sensor module set pad format and start/stop streaming safely.
@@ -1711,7 +1714,7 @@ static int imx477_start_streaming(struct imx477 *imx477)
17111714
struct i2c_client *client = v4l2_get_subdevdata(&imx477->sd);
17121715
const struct imx477_reg_list *reg_list;
17131716
const struct imx477_reg_list *extra_regs;
1714-
int ret;
1717+
int ret, tm;
17151718

17161719
if (!imx477->common_regs_written) {
17171720
ret = imx477_write_regs(imx477, mode_common_regs,
@@ -1748,14 +1751,15 @@ static int imx477_start_streaming(struct imx477 *imx477)
17481751
return ret;
17491752

17501753
/* Set vsync trigger mode: 0=standalone, 1=source, 2=sink */
1754+
tm = (imx477->trigger_mode_of >= 0) ? imx477->trigger_mode_of : trigger_mode;
17511755
imx477_write_reg(imx477, IMX477_REG_MC_MODE,
1752-
IMX477_REG_VALUE_08BIT, (trigger_mode > 0) ? 1 : 0);
1756+
IMX477_REG_VALUE_08BIT, (tm > 0) ? 1 : 0);
17531757
imx477_write_reg(imx477, IMX477_REG_MS_SEL,
1754-
IMX477_REG_VALUE_08BIT, (trigger_mode <= 1) ? 1 : 0);
1758+
IMX477_REG_VALUE_08BIT, (tm <= 1) ? 1 : 0);
17551759
imx477_write_reg(imx477, IMX477_REG_XVS_IO_CTRL,
1756-
IMX477_REG_VALUE_08BIT, (trigger_mode == 1) ? 1 : 0);
1760+
IMX477_REG_VALUE_08BIT, (tm == 1) ? 1 : 0);
17571761
imx477_write_reg(imx477, IMX477_REG_EXTOUT_EN,
1758-
IMX477_REG_VALUE_08BIT, (trigger_mode == 1) ? 1 : 0);
1762+
IMX477_REG_VALUE_08BIT, (tm == 1) ? 1 : 0);
17591763

17601764
/* set stream on register */
17611765
return imx477_write_reg(imx477, IMX477_REG_MODE_SELECT,
@@ -2187,6 +2191,7 @@ static int imx477_probe(struct i2c_client *client)
21872191
struct imx477 *imx477;
21882192
const struct of_device_id *match;
21892193
int ret;
2194+
u32 tm_of;
21902195

21912196
imx477 = devm_kzalloc(&client->dev, sizeof(*imx477), GFP_KERNEL);
21922197
if (!imx477)
@@ -2204,6 +2209,10 @@ static int imx477_probe(struct i2c_client *client)
22042209
if (imx477_check_hwcfg(dev))
22052210
return -EINVAL;
22062211

2212+
/* Default the trigger mode from OF to -1, which means invalid */
2213+
ret = of_property_read_u32(dev->of_node, "trigger-mode", &tm_of);
2214+
imx477->trigger_mode_of = (ret == 0) ? tm_of : -1;
2215+
22072216
/* Get system clock (xclk) */
22082217
imx477->xclk = devm_clk_get(dev, NULL);
22092218
if (IS_ERR(imx477->xclk)) {

0 commit comments

Comments
 (0)