Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp5506356pxb; Wed, 19 Jan 2022 21:23:26 -0800 (PST) X-Google-Smtp-Source: ABdhPJxo30e7adhY9edNspGlQHvEdAFgunmToHlGCjC4HAU9eFQ+4fmf0t1Ja/+nTSFCrf2xyURT X-Received: by 2002:a17:902:dac7:b0:14a:8d4a:78c5 with SMTP id q7-20020a170902dac700b0014a8d4a78c5mr31344960plx.78.1642656206176; Wed, 19 Jan 2022 21:23:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1642656206; cv=none; d=google.com; s=arc-20160816; b=Qc0ARfVLjuJNmh+bhnLsJFpysxwiCCYvSYLG7anYM7kDHtSX7u0Yk20YW6vyH7YqTI QbR7JEXZi3i2w0+L2Fps5mvfsvZq9QHg4w1VK6FsdYvBtkQYSo2Yn2mI9aBJp9xmZdXg mHG/MzXq6qqFNZQ1iOdJcJRiWB2+xQ58RX7IkuJbDOYvInb9m4MLuacKN5eyWbQHOXMr xJwlAAAVt8yQ/y3u+rxuVhGhIL9YmwXM1q/RlBFGMTbz9J03Sh686q++MKuZ/NCXEDL1 8XDyDRmJuIU7O6kuJRlzHFdercO3TN39pxX7aXUKeDr9Rxt98/HLj/COUyIPAHur8XV5 BvTQ== 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:to:from; bh=Z/s8Pld54hYx/jr1X2h7B+xuRysnxy1n1NcfkoXCWi8=; b=xZSaRGaSGzmCDV+RhScanSukFiF6ujbJ10EXPqY8IS+2O+gwiSa8nf3Vv/TLO+il28 b4+ppWWOf0SK9jbrch3nA/lJK6wTWULSQT82yrSjdHbN51pWbtOPtQ3S9PvjNilApSRa UQ6zVh5wcXBdeicFOVVcK+v6edrr5vvEl5E2hsWxMwJeXOwT/s3Jb3xxELyOTcxWn/nG +GogRcHXoPG2hJ/0FR2ZPnCG/TCfZcFnyYugInxsdzGHZnabT46sKaF1PQKgM48Rx4nz 1P/n0xRxucuBsFfYgGyIEQEpiZcF2759gk7b6iAFCR6PmvvO5MGQzhPRZrFCGnD3AK12 hCyA== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id z19si1810291pgl.6.2022.01.19.21.23.14; Wed, 19 Jan 2022 21:23:26 -0800 (PST) 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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236673AbiARKHe (ORCPT + 99 others); Tue, 18 Jan 2022 05:07:34 -0500 Received: from twspam01.aspeedtech.com ([211.20.114.71]:35849 "EHLO twspam01.aspeedtech.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236434AbiARKHd (ORCPT ); Tue, 18 Jan 2022 05:07:33 -0500 Received: from mail.aspeedtech.com ([192.168.0.24]) by twspam01.aspeedtech.com with ESMTP id 20IA0Rb9021058; Tue, 18 Jan 2022 18:00:27 +0800 (GMT-8) (envelope-from jammy_huang@aspeedtech.com) Received: from JammyHuang-PC.aspeed.com (192.168.2.115) by TWMBX02.aspeed.com (192.168.0.24) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Tue, 18 Jan 2022 18:07:25 +0800 From: Jammy Huang To: , , , , , , , , Subject: [PATCH v4 2/2] media: aspeed: Fix unstable timing detection Date: Tue, 18 Jan 2022 18:07:29 +0800 Message-ID: <20220118100729.7651-3-jammy_huang@aspeedtech.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220118100729.7651-1-jammy_huang@aspeedtech.com> References: <20220118100729.7651-1-jammy_huang@aspeedtech.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [192.168.2.115] X-ClientProxiedBy: TWMBX02.aspeed.com (192.168.0.24) To TWMBX02.aspeed.com (192.168.0.24) X-DNSRBL: X-MAIL: twspam01.aspeedtech.com 20IA0Rb9021058 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Using stable-signal in resolution detection, and try detection again if unstable. VE_MODE_DETECT_EXTSRC_ADC: 1 if video source is from ADC output. VE_MODE_DETECT_H_STABLE: 1 if horizontal signal detection is stable. VE_MODE_DETECT_V_STABLE: 1 if vertical signal detection is stable. Signed-off-by: Jammy Huang --- drivers/media/platform/aspeed-video.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/drivers/media/platform/aspeed-video.c b/drivers/media/platform/aspeed-video.c index 5ba4d70c8dab..585ee2997d44 100644 --- a/drivers/media/platform/aspeed-video.c +++ b/drivers/media/platform/aspeed-video.c @@ -165,9 +165,14 @@ #define VE_MODE_DETECT_STATUS 0x098 #define VE_MODE_DETECT_H_PERIOD GENMASK(11, 0) +#define VE_MODE_DETECT_EXTSRC_ADC BIT(12) +#define VE_MODE_DETECT_H_STABLE BIT(13) +#define VE_MODE_DETECT_V_STABLE BIT(14) #define VE_MODE_DETECT_V_LINES GENMASK(27, 16) #define VE_MODE_DETECT_STATUS_VSYNC BIT(28) #define VE_MODE_DETECT_STATUS_HSYNC BIT(29) +#define VE_MODE_DETECT_VSYNC_RDY BIT(30) +#define VE_MODE_DETECT_HSYNC_RDY BIT(31) #define VE_SYNC_STATUS 0x09c #define VE_SYNC_STATUS_HSYNC GENMASK(11, 0) @@ -971,6 +976,13 @@ static void aspeed_video_get_resolution(struct aspeed_video *video) return; } + mds = aspeed_video_read(video, VE_MODE_DETECT_STATUS); + // try detection again if current signal isn't stable + if (!(mds & VE_MODE_DETECT_H_STABLE) || + !(mds & VE_MODE_DETECT_V_STABLE) || + (mds & VE_MODE_DETECT_EXTSRC_ADC)) + continue; + aspeed_video_check_and_set_polarity(video); aspeed_video_enable_mode_detect(video); -- 2.25.1