Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp2706472pxv; Sun, 11 Jul 2021 23:19:55 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzKKn6Od6hDzWPzwDoSS72LkxIzgHJb//pux50Ne0JXjG8kmiUgn3pof6koQTUAH9IM5G4a X-Received: by 2002:a92:d946:: with SMTP id l6mr22665458ilq.162.1626070795216; Sun, 11 Jul 2021 23:19:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626070795; cv=none; d=google.com; s=arc-20160816; b=ibByDazC6rEIuPEEIufv6gVhX7zbe4VD7hei2A7LbeA0hp6fBUTf6dREynQtUMRJLG YyDAlcWs8fArnqXmTUdUzjmOHzIf1ahYHtXA4b4TC8das/BfGEb/WcVSLe64qaTyQCDM RaOWROVZ2x2h9BDPYCCTo4nBQimc6j7wcb4serSmsN60M3ZRV9VGP9QEYy028mgHyZcU FR5/gtZnE2kKp1axZ5yS7ZcUty8EJhxTpXJ3HFBK2wYw9YmPh0vHPBuXsiC9QmJrbdwA 35sJF0tTuBmGmdpHon/deKQF6/2831hNJl15+vSosEf6jFbMjCNkl0YZCSmoCZR7eqn8 xy5g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=Ddx6oQB497tw83zZeVAoP8XsAUw5Kz0vyDp/r2JuErI=; b=vieQ0vhrkYp3jxCA/IVJqghgBgZTEL/Wzj2eUEuo2t2omWYXQ01J96DkH8RO3tT9/B l1YYpSxjqSr7E/KhfgDdjDW9amnfc0AXC/ezHDjVpOwsnl4wjmEMAZdMx6lmBtIbDOzD 2GHYwG2FUhTxr2tvpJlMY1zW8VE59fJwEm7JuY9ad1OYk+MqgYg0c1SEAzZ59hdVrOzl 6FVSyDv4hwveLWhauNXFDHrPcGOWJyRJ/i9DfCYLphlkTK7hkN52FzhgDHLy/pAdGlyB VnTYnFINSPwZ2vIYjQBtv528K6v/+5ZcMsGI5pn9/EOwdEQDLeq3cANybIyIfEP/P6M1 7C/g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=BDhwLsjm; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id v1si15985783iot.7.2021.07.11.23.19.43; Sun, 11 Jul 2021 23:19:55 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=BDhwLsjm; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234517AbhGLGWF (ORCPT + 99 others); Mon, 12 Jul 2021 02:22:05 -0400 Received: from mail.kernel.org ([198.145.29.99]:39364 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233516AbhGLGVD (ORCPT ); Mon, 12 Jul 2021 02:21:03 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 4EA1A61108; Mon, 12 Jul 2021 06:18:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1626070689; bh=yZeK2PHdhWLxEJf19CVm0B48b2I+k0hbQWpLDwrWCfk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BDhwLsjmRR7oCxk1DtliopTXqBZDJmK3Nxsr8l9TaT+FVWjJLbGRkUfOUWzImbSaj pHLx3XUBwiJA/Yc1pzPTVICpBliLvehURGtL71iJ3Wo67bHyUepPXiqEro1NxWrqub OdpbmoSYMk6JcaOEv1NQOhQo/cU3/TLQ6OEt7LL0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Steve Longerbeam , Fabio Estevam , Tim Harvey , Hans Verkuil , Mauro Carvalho Chehab , Sasha Levin Subject: [PATCH 5.4 098/348] media: imx-csi: Skip first few frames from a BT.656 source Date: Mon, 12 Jul 2021 08:08:02 +0200 Message-Id: <20210712060714.683368722@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210712060659.886176320@linuxfoundation.org> References: <20210712060659.886176320@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Steve Longerbeam [ Upstream commit e198be37e52551bb863d07d2edc535d0932a3c4f ] 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. [fabio: fixed checkpatch warning and increased the frame skipping to 20] Signed-off-by: Steve Longerbeam Signed-off-by: Fabio Estevam Reviewed-by: Tim Harvey Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab Signed-off-by: Sasha Levin --- 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 367e39f5b382..40b7e60f4a47 100644 --- a/drivers/staging/media/imx/imx-media-csi.c +++ b/drivers/staging/media/imx/imx-media-csi.c @@ -753,9 +753,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 */ @@ -764,6 +765,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.30.2