Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3505140pxb; Mon, 24 Jan 2022 10:58:34 -0800 (PST) X-Google-Smtp-Source: ABdhPJyv1QQU8x1dmc1nu7dQFid4W6BmXoNhmeaESarBqiSsyiLX74vf/Cp4wrvc+WGTiM91nnnL X-Received: by 2002:a05:6a00:114f:b0:4c5:72f6:d0b5 with SMTP id b15-20020a056a00114f00b004c572f6d0b5mr14973450pfm.61.1643050714553; Mon, 24 Jan 2022 10:58:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643050714; cv=none; d=google.com; s=arc-20160816; b=f404xNpnKOzSDwqxQNNvwJ0hZBzgaqSI1lgKYO1bpII6AZoDIFhrzo6XhfEIvhz64J /0qf18a24yWIPnm3moV/N0b4z5JZBwfB9MY+UaE771wLq9/68J13C5rqZ/8Dr0U/V7LJ 0XgqGYDz9BuzmvDYSFu4r/vDrEqWYsGKM5b+fFcSOTVJiLgINsz4ULlOWRspkIG7Eogk dDKopAVcZj5h5+99TeUBrRG3Bn9uVTR82zaIE9beBN/yKsn7Oq8nAHDNy9BI87k2ut8I cSIycdybfkKb6bgCASqAvdw46pjTdcU0b5N+/SyhtVnanCfDiUBNU0bPkqsjs0VUslXP pXEg== 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=hCOxd4DLa00wej+u38KBupvx+1Z/Vhurmc+l+9D8GBM=; b=RmImVNJzO9YVEL4VXziEI2lMdQIz3+IcVY/JZjeiVumn/eWAcZl/2afHBz4RB3e+s3 vL46bNR1AVHo9H2fC0y66A2XwGLY50n/4cSJPZ5HJpTrzRNc9zhbDvYVWKuxwbjMKqkt 6vGvItIUtREKpTAHUHP/WR8wlXMaVb0+SymgeFXsOyJ9/EBcZC9nPq3PxaBxKk9q/nHp rJO/xlRscgr7V8C3z8mXE4f1GUSSAvQ3qUbHV4uVcMNDyYlUuQVR84aez1G8R4BsJ0G5 1UAbDtoNFNIQ3nWqfMGNiIkOj8eejq8ubgT3kynPJaIaOH2uyOcFcWStwmXU45EIUy96 7Hgg== 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 d17si14257417pgj.369.2022.01.24.10.58.22; Mon, 24 Jan 2022 10:58:34 -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 S234353AbiAXJeL (ORCPT + 99 others); Mon, 24 Jan 2022 04:34:11 -0500 Received: from twspam01.aspeedtech.com ([211.20.114.71]:42326 "EHLO twspam01.aspeedtech.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234343AbiAXJeB (ORCPT ); Mon, 24 Jan 2022 04:34:01 -0500 Received: from mail.aspeedtech.com ([192.168.0.24]) by twspam01.aspeedtech.com with ESMTP id 20O9QVlT054148; Mon, 24 Jan 2022 17:26:31 +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; Mon, 24 Jan 2022 17:33:48 +0800 From: Jammy Huang To: , , , , , , , , Subject: [PATCH v3 4/4] media: aspeed: Fix timing polarity incorrect Date: Mon, 24 Jan 2022 17:33:45 +0800 Message-ID: <20220124093345.3935-5-jammy_huang@aspeedtech.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220124093345.3935-1-jammy_huang@aspeedtech.com> References: <20220124093345.3935-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 20O9QVlT054148 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This is a workaround for polarity detection unstable. Because h/v sync polarity got from VR098 could be wrong, we try to use ast SoC's characteristic to confirm sync polarity. In ast SoC's design, sync value got by VR09C counts from sync's rising edge, which means sync value = bp + active + fp if negative polarity. Thus, sync value would be larger than de if negative. Ex. 1920x1200@60 VR098: c4d3efff, VR09C: 04cc001f v-total = 0x4D3 (VR098[27:16]) = 1235 v-sync = 0x4CC (VR09C[27:16]) = 1228 Signed-off-by: Jammy Huang --- v3: - Use active rather than 'total/2' as critera for workaround v2: - Use 'total/2' rather than 'total<<1' - Update comment --- drivers/media/platform/aspeed-video.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/drivers/media/platform/aspeed-video.c b/drivers/media/platform/aspeed-video.c index 7e988cd05161..a135a31b4234 100644 --- a/drivers/media/platform/aspeed-video.c +++ b/drivers/media/platform/aspeed-video.c @@ -985,6 +985,20 @@ static void aspeed_video_get_timings(struct aspeed_video *v, vsync = FIELD_GET(VE_SYNC_STATUS_VSYNC, sync); hsync = FIELD_GET(VE_SYNC_STATUS_HSYNC, sync); + /* + * This is a workaround for polarity detection. + * Because ast-soc counts sync from sync's rising edge, the reg value + * of sync would be larger than video's active area if negative. + */ + if (vsync > det->height) + det->polarities &= ~V4L2_DV_VSYNC_POS_POL; + else + det->polarities |= V4L2_DV_VSYNC_POS_POL; + if (hsync > det->width) + det->polarities &= ~V4L2_DV_HSYNC_POS_POL; + else + det->polarities |= V4L2_DV_HSYNC_POS_POL; + if (det->polarities & V4L2_DV_VSYNC_POS_POL) { det->vbackporch = v->frame_top - vsync; det->vfrontporch = vtotal - v->frame_bottom; -- 2.25.1