Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp3344685pxv; Sun, 4 Jul 2021 16:07:45 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz3IXotQBYEWvMKtw0f9G0CuVeL88LTbmvmNUL1HuZ6l04EgPtke7DIp9OvKl4EZZbspRZE X-Received: by 2002:a05:6e02:1010:: with SMTP id n16mr8613136ilj.146.1625440065437; Sun, 04 Jul 2021 16:07:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1625440065; cv=none; d=google.com; s=arc-20160816; b=q9LgA4lHnHc7D1Cuv3CbCZLtmUh80nUsjM0vZPhhkgc+JnAUb1RVuwoQFJv/ul1qzc oPcxqrCB0CAcXWtj/eHPH8/6kiDq5cyT/3GUXRDYPhZRrBd+lvYMy5t2TSYHTVWvWSex Ygb8vj7SCaEqX8KKHaarOrZkO2Tx+ioDQj9uDzcuR10CaGruCQE/m4G43Edkpp/2lbS6 Qjc8KJ0u5zIKWJmlS30byXmwYbCKOO0oAKQBWlKmptE7+Yw7MSHRKqANu0QNW5xAHpS1 tnEnaHVK58uo0yxORZ3ZOKqEiRqrir7eORwVucULRSSwX2GkaMZMOg0VQ5JUPt0liZRb 1osw== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=YAOTclFi2yp7QrUSH+6k4WDHQpEoo+hIpxsixnS7lLM=; b=tDCMDmvFUonJBYD9drONGLHlJafHm4CuvBX8QlvJB9AqBYR8RX46Oc4YpAnXYV51Ph 9bO21SbTMApeAqYcZnS6kv5b25GSu3ALMUPjw71KbV+wx0u+7fBlaBL0VIasIHMY0BWI aRms/Jmn9qqdqNaVeKkhViiukjcy6GozeSk0qwQWURTSOscUVU9oKMaNwWh5EH9giarB Y6RFfT7hC2KV+14YwkF4arrj6P51ahCHsUcybcz4NtU0jrNGuMlqaavAC3bYiYCv/W2F CXo2+mVTYPDRU9Os/uj3ikccoCdTa5pWD/qZdItxiUIwaXkyHmLC8ZCmgOgQeqSXkYrT nl/g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=LdsL5Cwp; 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id k1si8108981ilu.84.2021.07.04.16.07.33; Sun, 04 Jul 2021 16:07:45 -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=@kernel.org header.s=k20201202 header.b=LdsL5Cwp; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230264AbhGDXJJ (ORCPT + 99 others); Sun, 4 Jul 2021 19:09:09 -0400 Received: from mail.kernel.org ([198.145.29.99]:47378 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230326AbhGDXIV (ORCPT ); Sun, 4 Jul 2021 19:08:21 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 602F5613F9; Sun, 4 Jul 2021 23:05:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1625439945; bh=RYCFuk0gjAJbRTFBZJX1SMMBhtn4qiRdhnSjSELTouQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LdsL5CwpkK+5Rk8GUHsfUhkt7tnlMsmDGQ+PfGx2KI2Fs4xJ5fU0k276q+VVdd7un 80x4Srcq7ByQXvWkTGVI/WiXhnScK0oxfaOdOMtXqjWcqN2ueB0CCTXk26B8m2yQTv MC/3UStyKqfXmpTp0gSJUYgPWg0g6vMGg+gMfAVfdJ6ajrZcrZ5C1VXa56gAhgEawq Akiv1fFB4PwbqZ+t1UpuRDIxdBpQDAJJvil4dI1CCiCnEobQNy5BSU7L+vaWENLfHb fAU7Ibe4m3h/XrGJWkNIyLt8mvWWrbVUsNjuMK07ObMi6rX/572UG+JTnSKDxzPQr+ u1SXhwTC1bsdw== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Steve Longerbeam , Fabio Estevam , Tim Harvey , Hans Verkuil , Mauro Carvalho Chehab , Sasha Levin , linux-media@vger.kernel.org, linux-staging@lists.linux.dev, linux-arm-kernel@lists.infradead.org Subject: [PATCH AUTOSEL 5.13 62/85] media: imx-csi: Skip first few frames from a BT.656 source Date: Sun, 4 Jul 2021 19:03:57 -0400 Message-Id: <20210704230420.1488358-62-sashal@kernel.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210704230420.1488358-1-sashal@kernel.org> References: <20210704230420.1488358-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore 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 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.30.2