* [PATCH v3] media: imx-csi: Skip first few frames from a BT.656 source
@ 2021-05-17 14:29 Fabio Estevam
2021-05-27 16:39 ` Tim Harvey
0 siblings, 1 reply; 2+ messages in thread
From: Fabio Estevam @ 2021-05-17 14:29 UTC (permalink / raw)
To: hverkuil-cisco
Cc: slongerbeam, p.zabel, frieder.schrempf, tharvey, linux-media,
Fabio Estevam
From: Steve Longerbeam <slongerbeam@gmail.com>
Some BT.656 sensors (e.g. ADV718x) transmit frames with unstable BT.656
sync codes after initial power on. This confuses the imx CSI,resulting
in vertical and/or horizontal sync issues. Skip the first 20 frames
to avoid the unstable sync codes.
Signed-off-by: Steve Longerbeam <slongerbeam@gmail.com>
[fabio: fixed checkpatch warning and increased the frame skipping to 20]
Signed-off-by: Fabio Estevam <festevam@gmail.com>
---
Changes since v2:
- Increase 'bad_frames' to 20 as 10 was not enough to avoid
the problem when using an NTSC camera.
drivers/staging/media/imx/imx-media-csi.c | 14 +++++++++++++-
1 file changed, 13 insertions(+), 1 deletion(-)
diff --git a/drivers/staging/media/imx/imx-media-csi.c b/drivers/staging/media/imx/imx-media-csi.c
index e3bfd635a89a..6a94fff49bf6 100644
--- a/drivers/staging/media/imx/imx-media-csi.c
+++ b/drivers/staging/media/imx/imx-media-csi.c
@@ -750,9 +750,10 @@ static int csi_setup(struct csi_priv *priv)
static int csi_start(struct csi_priv *priv)
{
- struct v4l2_fract *output_fi;
+ struct v4l2_fract *input_fi, *output_fi;
int ret;
+ input_fi = &priv->frame_interval[CSI_SINK_PAD];
output_fi = &priv->frame_interval[priv->active_output_pad];
/* start upstream */
@@ -761,6 +762,17 @@ static int csi_start(struct csi_priv *priv)
if (ret)
return ret;
+ /* Skip first few frames from a BT.656 source */
+ if (priv->upstream_ep.bus_type == V4L2_MBUS_BT656) {
+ u32 delay_usec, bad_frames = 20;
+
+ delay_usec = DIV_ROUND_UP_ULL((u64)USEC_PER_SEC *
+ input_fi->numerator * bad_frames,
+ input_fi->denominator);
+
+ usleep_range(delay_usec, delay_usec + 1000);
+ }
+
if (priv->dest == IPU_CSI_DEST_IDMAC) {
ret = csi_idmac_start(priv);
if (ret)
--
2.25.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH v3] media: imx-csi: Skip first few frames from a BT.656 source
2021-05-17 14:29 [PATCH v3] media: imx-csi: Skip first few frames from a BT.656 source Fabio Estevam
@ 2021-05-27 16:39 ` Tim Harvey
0 siblings, 0 replies; 2+ messages in thread
From: Tim Harvey @ 2021-05-27 16:39 UTC (permalink / raw)
To: Fabio Estevam
Cc: Hans Verkuil, Steve Longerbeam, Philipp Zabel, Schrempf Frieder,
linux-media
On Mon, May 17, 2021 at 7:29 AM Fabio Estevam <festevam@gmail.com> wrote:
>
> From: Steve Longerbeam <slongerbeam@gmail.com>
>
> Some BT.656 sensors (e.g. ADV718x) transmit frames with unstable BT.656
> sync codes after initial power on. This confuses the imx CSI,resulting
> in vertical and/or horizontal sync issues. Skip the first 20 frames
> to avoid the unstable sync codes.
>
> Signed-off-by: Steve Longerbeam <slongerbeam@gmail.com>
> [fabio: fixed checkpatch warning and increased the frame skipping to 20]
> Signed-off-by: Fabio Estevam <festevam@gmail.com>
> ---
> Changes since v2:
> - Increase 'bad_frames' to 20 as 10 was not enough to avoid
> the problem when using an NTSC camera.
>
> drivers/staging/media/imx/imx-media-csi.c | 14 +++++++++++++-
> 1 file changed, 13 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/staging/media/imx/imx-media-csi.c b/drivers/staging/media/imx/imx-media-csi.c
> index e3bfd635a89a..6a94fff49bf6 100644
> --- a/drivers/staging/media/imx/imx-media-csi.c
> +++ b/drivers/staging/media/imx/imx-media-csi.c
> @@ -750,9 +750,10 @@ static int csi_setup(struct csi_priv *priv)
>
> static int csi_start(struct csi_priv *priv)
> {
> - struct v4l2_fract *output_fi;
> + struct v4l2_fract *input_fi, *output_fi;
> int ret;
>
> + input_fi = &priv->frame_interval[CSI_SINK_PAD];
> output_fi = &priv->frame_interval[priv->active_output_pad];
>
> /* start upstream */
> @@ -761,6 +762,17 @@ static int csi_start(struct csi_priv *priv)
> if (ret)
> return ret;
>
> + /* Skip first few frames from a BT.656 source */
> + if (priv->upstream_ep.bus_type == V4L2_MBUS_BT656) {
> + u32 delay_usec, bad_frames = 20;
> +
> + delay_usec = DIV_ROUND_UP_ULL((u64)USEC_PER_SEC *
> + input_fi->numerator * bad_frames,
> + input_fi->denominator);
> +
> + usleep_range(delay_usec, delay_usec + 1000);
> + }
> +
> if (priv->dest == IPU_CSI_DEST_IDMAC) {
> ret = csi_idmac_start(priv);
> if (ret)
> --
> 2.25.1
>
Reviewed-By: Tim Harvey <tharvey@gateworks.com>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-05-27 16:40 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-17 14:29 [PATCH v3] media: imx-csi: Skip first few frames from a BT.656 source Fabio Estevam
2021-05-27 16:39 ` Tim Harvey
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).