Skip to content

Commit

Permalink
media: i2c: imx477: Add vsync trigger_mode parameter
Browse files Browse the repository at this point in the history
trigger_mode == 0 (default) => no effect / no registers written
trigger_mode == 1           => source
trigger_mode == 2           => sink

This can be set e.g. in /boot/cmdline.txt as imx477.trigger_mode=N

Signed-off-by: Jonas Jacob <[email protected]>
  • Loading branch information
neocortex-vision authored and pelwell committed Oct 28, 2021
1 parent 581049d commit 3728690
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions drivers/media/i2c/imx477.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ static int dpc_enable = 1;
module_param(dpc_enable, int, 0644);
MODULE_PARM_DESC(dpc_enable, "Enable on-sensor DPC");

static int trigger_mode;
module_param(trigger_mode, int, 0644);
MODULE_PARM_DESC(trigger_mode, "Set vsync trigger mode: 1=source, 2=sink");

#define IMX477_REG_VALUE_08BIT 1
#define IMX477_REG_VALUE_16BIT 2

Expand Down Expand Up @@ -98,6 +102,12 @@ MODULE_PARM_DESC(dpc_enable, "Enable on-sensor DPC");
#define IMX477_TEST_PATTERN_B_DEFAULT 0
#define IMX477_TEST_PATTERN_GB_DEFAULT 0

/* Trigger mode */
#define IMX477_REG_MC_MODE 0x3f0b
#define IMX477_REG_MS_SEL 0x3041
#define IMX477_REG_XVS_IO_CTRL 0x3040
#define IMX477_REG_EXTOUT_EN 0x4b81

/* Embedded metadata stream structure */
#define IMX477_EMBEDDED_LINE_WIDTH 16384
#define IMX477_NUM_EMBEDDED_LINES 1
Expand Down Expand Up @@ -1719,6 +1729,21 @@ static int imx477_start_streaming(struct imx477 *imx477)
imx477_write_reg(imx477, 0x0b05, IMX477_REG_VALUE_08BIT, !!dpc_enable);
imx477_write_reg(imx477, 0x0b06, IMX477_REG_VALUE_08BIT, !!dpc_enable);

/* Set vsync trigger mode */
if (trigger_mode != 0) {
/* trigger_mode == 1 for source, 2 for sink */
const u32 val = (trigger_mode == 1) ? 1 : 0;

imx477_write_reg(imx477, IMX477_REG_MC_MODE,
IMX477_REG_VALUE_08BIT, 1);
imx477_write_reg(imx477, IMX477_REG_MS_SEL,
IMX477_REG_VALUE_08BIT, val);
imx477_write_reg(imx477, IMX477_REG_XVS_IO_CTRL,
IMX477_REG_VALUE_08BIT, val);
imx477_write_reg(imx477, IMX477_REG_EXTOUT_EN,
IMX477_REG_VALUE_08BIT, val);
}

/* Apply customized values from user */
ret = __v4l2_ctrl_handler_setup(imx477->sd.ctrl_handler);
if (ret)
Expand Down

1 comment on commit 3728690

@6by9
Copy link
Contributor

@6by9 6by9 commented on 3728690 Nov 21, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have a cm4. How do I specify cam0 and cam1?

Please don't make comments on individual commits - they aren't tracked by Github in any meaningful manner.
If you have a query, please use the forum - https://forums.raspberrypi.com/viewforum.php?f=43
If you have a reproducible kernel bug, then please raise an issue - https://github.com/raspberrypi/linux/issues

Please sign in to comment.