1 From 9524eae5a46285e574b869879fb0228fb4424a5f Mon Sep 17 00:00:00 2001
2 From: Dave Stevenson <dave.stevenson@raspberrypi.com>
3 Date: Thu, 1 Dec 2022 13:54:49 +0000
4 Subject: [PATCH] media: i2c: ov7251: Add module param to select ext
7 As there isn't currently a defined mechanism for selecting an
8 external trigger mode on image sensors, copy the imx477
9 approach of using a module parameter to enable ext trig.
11 Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
13 drivers/media/i2c/ov7251.c | 35 ++++++++++++++++++++++++++++++++---
14 1 file changed, 32 insertions(+), 3 deletions(-)
16 --- a/drivers/media/i2c/ov7251.c
17 +++ b/drivers/media/i2c/ov7251.c
19 #include <media/v4l2-fwnode.h>
20 #include <media/v4l2-subdev.h>
22 +static int trigger_mode;
23 +module_param(trigger_mode, int, 0644);
24 +MODULE_PARM_DESC(trigger_mode, "Set vsync trigger mode: 0=standalone, (1=source - not implemented), 2=sink");
26 #define OV7251_SC_MODE_SELECT 0x0100
27 #define OV7251_SC_MODE_SELECT_SW_STANDBY 0x0
28 #define OV7251_SC_MODE_SELECT_STREAMING 0x1
29 @@ -525,7 +529,6 @@ static const struct reg_value ov7251_set
37 @@ -592,9 +595,8 @@ static const struct reg_value ov7251_set
48 @@ -624,6 +626,16 @@ static const struct reg_value ov7251_set
52 +static const struct reg_value ov7251_ext_trig_on[] = {
57 +static const struct reg_value ov7251_ext_trig_off[] = {
62 static const unsigned long supported_xclk_rates[] = {
63 [OV7251_19_2_MHZ] = 19200000,
64 [OV7251_24_MHZ] = 24000000,
65 @@ -1372,6 +1384,23 @@ static int ov7251_s_stream(struct v4l2_s
66 dev_err(ov7251->dev, "could not sync v4l2 controls\n");
70 + /* Set vsync trigger mode */
71 + switch (trigger_mode) {
73 + ov7251_set_register_array(ov7251,
75 + ARRAY_SIZE(ov7251_ext_trig_on));
79 + /* case 1 for ext trig source currently not implemented */
80 + ov7251_set_register_array(ov7251,
81 + ov7251_ext_trig_off,
82 + ARRAY_SIZE(ov7251_ext_trig_off));
86 ret = ov7251_write_reg(ov7251, OV7251_SC_MODE_SELECT,
87 OV7251_SC_MODE_SELECT_STREAMING);