Skip to content

Commit 62c38c0

Browse files
committed
media: i2c: imx477: Add selection of (non)continuous clock mode
The register set was always selecting continuous clock mode, even though all our overlays were saying it should be non-continuous. Read the configuration from fwnode and configure the sensor accordingly. Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
1 parent 751565c commit 62c38c0

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

drivers/media/i2c/imx477.c

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,8 @@ MODULE_PARM_DESC(trigger_mode, "Set vsync trigger mode: 1=source, 2=sink");
112112
#define IMX477_REG_XVS_IO_CTRL 0x3040
113113
#define IMX477_REG_EXTOUT_EN 0x4b81
114114

115+
#define IMX477_REG_FRAME_BLANKSTOP_CLK 0xE000
116+
115117
/* Embedded metadata stream structure */
116118
#define IMX477_EMBEDDED_LINE_WIDTH 16384
117119
#define IMX477_NUM_EMBEDDED_LINES 1
@@ -169,7 +171,6 @@ static const struct imx477_reg mode_common_regs[] = {
169171
{0x0136, 0x18},
170172
{0x0137, 0x00},
171173
{0x0138, 0x01},
172-
{0xe000, 0x00},
173174
{0xe07a, 0x01},
174175
{0x0808, 0x02},
175176
{0x4ae9, 0x18},
@@ -963,6 +964,11 @@ struct imx477 {
963964
/* Streaming on/off */
964965
bool streaming;
965966

967+
/* Flags field from parsing the endpoint - used for (non)continuous
968+
* clock mode
969+
*/
970+
unsigned int csi2_flags;
971+
966972
/* Rewrite common registers on stream on? */
967973
bool common_regs_written;
968974

@@ -1556,6 +1562,12 @@ static int imx477_start_streaming(struct imx477 *imx477)
15561562
__func__);
15571563
return ret;
15581564
}
1565+
1566+
imx477_write_reg(imx477, IMX477_REG_FRAME_BLANKSTOP_CLK,
1567+
IMX477_REG_VALUE_08BIT,
1568+
imx477->csi2_flags & V4L2_MBUS_CSI2_NONCONTINUOUS_CLOCK ?
1569+
1 : 0);
1570+
15591571
imx477->common_regs_written = true;
15601572
}
15611573

@@ -1936,7 +1948,7 @@ static void imx477_free_controls(struct imx477 *imx477)
19361948
mutex_destroy(&imx477->mutex);
19371949
}
19381950

1939-
static int imx477_check_hwcfg(struct device *dev)
1951+
static int imx477_check_hwcfg(struct device *dev, struct imx477 *imx477)
19401952
{
19411953
struct fwnode_handle *endpoint;
19421954
struct v4l2_fwnode_endpoint ep_cfg = {
@@ -1974,6 +1986,8 @@ static int imx477_check_hwcfg(struct device *dev)
19741986
goto error_out;
19751987
}
19761988

1989+
imx477->csi2_flags = ep_cfg.bus.mipi_csi2.flags;
1990+
19771991
ret = 0;
19781992

19791993
error_out:
@@ -2032,7 +2046,7 @@ static int imx477_probe(struct i2c_client *client)
20322046
(const struct imx477_compatible_data *)match->data;
20332047

20342048
/* Check the hardware configuration in device tree */
2035-
if (imx477_check_hwcfg(dev))
2049+
if (imx477_check_hwcfg(dev, imx477))
20362050
return -EINVAL;
20372051

20382052
/* Default the trigger mode from OF to -1, which means invalid */

0 commit comments

Comments
 (0)