Skip to content

Commit 6f28a42

Browse files
Pratyush YadavHans Verkuil
authored andcommitted
media: cadence: csi2rx: Soft reset the streams before starting capture
This resets the stream state machines and FIFOs, giving them a clean slate. On J721E if the streams are not reset before starting the capture, the captured frame gets wrapped around vertically on every run after the first. Signed-off-by: Pratyush Yadav <p.yadav@ti.com> Tested-by: Julien Massot <julien.massot@collabora.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Maxime Ripard <mripard@kernel.org> Reviewed-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com> Signed-off-by: Jai Luthra <j-luthra@ti.com> Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
1 parent a91d06f commit 6f28a42

1 file changed

Lines changed: 13 additions & 1 deletion

File tree

drivers/media/platform/cadence/cdns-csi2rx.c

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
#define CSI2RX_STREAM_BASE(n) (((n) + 1) * 0x100)
4141

4242
#define CSI2RX_STREAM_CTRL_REG(n) (CSI2RX_STREAM_BASE(n) + 0x000)
43+
#define CSI2RX_STREAM_CTRL_SOFT_RST BIT(4)
4344
#define CSI2RX_STREAM_CTRL_START BIT(0)
4445

4546
#define CSI2RX_STREAM_DATA_CFG_REG(n) (CSI2RX_STREAM_BASE(n) + 0x008)
@@ -134,12 +135,23 @@ struct csi2rx_priv *v4l2_subdev_to_csi2rx(struct v4l2_subdev *subdev)
134135

135136
static void csi2rx_reset(struct csi2rx_priv *csi2rx)
136137
{
138+
unsigned int i;
139+
140+
/* Reset module */
137141
writel(CSI2RX_SOFT_RESET_PROTOCOL | CSI2RX_SOFT_RESET_FRONT,
138142
csi2rx->base + CSI2RX_SOFT_RESET_REG);
143+
/* Reset individual streams. */
144+
for (i = 0; i < csi2rx->max_streams; i++) {
145+
writel(CSI2RX_STREAM_CTRL_SOFT_RST,
146+
csi2rx->base + CSI2RX_STREAM_CTRL_REG(i));
147+
}
139148

140-
udelay(10);
149+
usleep_range(10, 20);
141150

151+
/* Clear resets */
142152
writel(0, csi2rx->base + CSI2RX_SOFT_RESET_REG);
153+
for (i = 0; i < csi2rx->max_streams; i++)
154+
writel(0, csi2rx->base + CSI2RX_STREAM_CTRL_REG(i));
143155
}
144156

145157
static int csi2rx_configure_ext_dphy(struct csi2rx_priv *csi2rx)

0 commit comments

Comments
 (0)