Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp3345917pxv; Sun, 4 Jul 2021 16:10:06 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzt2MA2JqVUaiJQSx/XiXWUqg8sVnXtaJM3M8FXs0e5WwBCQHfticqH4fkzmZ6UK4W6VBxJ X-Received: by 2002:a92:c952:: with SMTP id i18mr8433917ilq.218.1625440205875; Sun, 04 Jul 2021 16:10:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1625440205; cv=none; d=google.com; s=arc-20160816; b=nIbbFkD9oBsA/sGxwDl0WnFAPoaS/kZ0bmdEbPO/9V33I8PzzEfVYepnShNlaEqnNy QMNhtfflit3N1m1vdtGJmx2AQQ13UTUK9Cagb4ZE/KEGsZCG06dCRJ7ML5CCCitwh5eE 1I9QD7aMxeOHcUOl6bXrpTg0JJ35nS3r87EV373F1ckaVRnHSWrCStKj8VvMcvF38dja w7JVvWH+cKq8a/icW1eAIN39j1CfKpBkynzgopTFkmuaNNpUXesY5iWZDNYVzO1LDo7K EWtYCnqsYOTcP3WaKJnO2Y5hC6SBT5iI7VUYMHBCBAmzfonBhxBXe+EYK/HKJ/sIOUYl cVoA== 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=AWjSbzANdYWxlicvDOvQi2/w0hPAasVRGBRdzrJwxH4=; b=MgHTqKvwIMksurBHDWLNceV99FOh89sjomGrccK8+SphX3j6pBGKPj3JU8eoEwRm/L 7kTj0VenEW7nuGAb/PGD3HK5GIUyreMfXXQVU3+EwQlJRZN5pxJ7Tl1ZYdqRH4ZF6Hpc ZIuPuWRGDJ5KdHH5BuArzwfooGbR4dMp4FOmTxLc+abDyUkN5NnbtvK8I14LfhFmub0c C/JnkxohjhUZ5gxIy0JSSpwjjc7u+NKezPxMVnrzSDx8IIxoBC7yzATrMvi0AgseME2u 7mhEgrtsVBunWSW8Z67N0Sk2mlZdOVT5VcfoQYg0gat9KbPH2QXX3nhYp9FVHSOJyA93 6vpg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=P9x+NT3k; 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 m19si13802922jav.63.2021.07.04.16.09.54; Sun, 04 Jul 2021 16:10:05 -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=P9x+NT3k; 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 S229893AbhGDXLx (ORCPT + 99 others); Sun, 4 Jul 2021 19:11:53 -0400 Received: from mail.kernel.org ([198.145.29.99]:49270 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232371AbhGDXKL (ORCPT ); Sun, 4 Jul 2021 19:10:11 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id B7DC7613F7; Sun, 4 Jul 2021 23:07:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1625440055; bh=zFz17kTz0q/RoXuxwTOaqF4XgovTxUeA4x4QhxkyBZQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=P9x+NT3k4FH1R1s61o+jt8XwqwUVoeERXvqrqxVBMILYmgnbglkSg+o9WpqmKxnnY BRNRO80I1bDCRKQqqjCrVKgN70uUZjz4Bh8g8222Yxj5mmmIbkL/h72ynhj49nJVn0 gm0xZSQzUjd3cV+g21ife2ERPCPm+b2MtY8AuskZW2SrPU2oPnQkvdQChnyk9iYSbg neJM6C4A+kxs8o32GvPioRFpJUmOupWvVyHtgHoA5DkVxHq4h43+x5pNgJ6gwbe6nf 97SWlHhjPB4CaOjPvt99hhWgn0YlfldsxNVW9ihV1hblWlCybTdrZ+MjYWMKhxvzGR SKrzbw8qJXMNA== 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.12 59/80] media: imx-csi: Skip first few frames from a BT.656 source Date: Sun, 4 Jul 2021 19:05:55 -0400 Message-Id: <20210704230616.1489200-59-sashal@kernel.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210704230616.1489200-1-sashal@kernel.org> References: <20210704230616.1489200-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 ef5add079774..7f4b967646d9 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