From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jammy Huang Date: Wed, 22 Dec 2021 14:10:37 +0800 Subject: [PATCH 4/4] media: aspeed: Fix timing polarity incorrect In-Reply-To: References: <20211217095403.2618-1-jammy_huang@aspeedtech.com> <20211217095403.2618-5-jammy_huang@aspeedtech.com> Message-ID: List-Id: To: linux-aspeed@lists.ozlabs.org MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Hi Joel, OK, I will update in next patch as you advised. Thanks for your review. On 2021/12/22 ?? 09:22, Joel Stanley wrote: > On Fri, 17 Dec 2021 at 09:54, Jammy Huang wrote: >> This is a workaround for polarity unstable. >> Sync value get by VR09C counts from sync's rising edge, which means >> sync's polarity is negative if sync value is bigger than total/2. >> >> Signed-off-by: Jammy Huang >> --- >> drivers/media/platform/aspeed-video.c | 18 ++++++++++++++++++ >> 1 file changed, 18 insertions(+) >> >> diff --git a/drivers/media/platform/aspeed-video.c b/drivers/media/platform/aspeed-video.c >> index 5ad3a20c5bac..f628f69bb7dd 100644 >> --- a/drivers/media/platform/aspeed-video.c >> +++ b/drivers/media/platform/aspeed-video.c >> @@ -989,6 +989,15 @@ static void aspeed_video_get_resolution(struct aspeed_video *video) >> video->frame_top = FIELD_GET(VE_SRC_TB_EDGE_DET_TOP, >> src_tb_edge); >> det->vsync = FIELD_GET(VE_SYNC_STATUS_VSYNC, sync); >> + /* >> + * Workaround for polarity detection >> + * Use sync(VR098) counts from sync's rising edge till falling >> + * edge to tell sync polarity. >> + */ >> + if (det->vsync > (FIELD_GET(VE_MODE_DETECT_V_LINES, mds) >> 1)) > Are you right shifting as this is the value / 2? I think it's clearer > to write / 2 instead of >> 1. > > Mention in the comment that this is a workaround for when the sync > value is larger than half. > >> + det->polarities &= ~V4L2_DV_VSYNC_POS_POL; >> + else >> + det->polarities |= V4L2_DV_VSYNC_POS_POL; >> if (det->polarities & V4L2_DV_VSYNC_POS_POL) { >> det->vbackporch = video->frame_top - det->vsync; >> det->vfrontporch = >> @@ -1010,6 +1019,15 @@ static void aspeed_video_get_resolution(struct aspeed_video *video) >> video->frame_left = FIELD_GET(VE_SRC_LR_EDGE_DET_LEFT, >> src_lr_edge); >> det->hsync = FIELD_GET(VE_SYNC_STATUS_HSYNC, sync); >> + /* >> + * Workaround for polarity detection >> + * Use sync(VR098) counts from sync's rising edge till falling >> + * edge to tell sync polarity. >> + */ >> + if (det->hsync > (htotal >> 1)) >> + det->polarities &= ~V4L2_DV_HSYNC_POS_POL; >> + else >> + det->polarities |= V4L2_DV_HSYNC_POS_POL; >> if (det->polarities & V4L2_DV_HSYNC_POS_POL) { >> det->hbackporch = video->frame_left - det->hsync; >> det->hfrontporch = htotal - video->frame_right; >> -- >> 2.25.1 >> -- Best Regards Jammy From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.ozlabs.org (lists.ozlabs.org [112.213.38.117]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id D8649C433F5 for ; Wed, 22 Dec 2021 06:12:03 +0000 (UTC) Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4JJjdt3hwFz2yw9 for ; Wed, 22 Dec 2021 17:12:02 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=aspeedtech.com (client-ip=211.20.114.71; helo=twspam01.aspeedtech.com; envelope-from=jammy_huang@aspeedtech.com; receiver=) Received: from twspam01.aspeedtech.com (twspam01.aspeedtech.com [211.20.114.71]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4JJjcq0gvhz2yZt; Wed, 22 Dec 2021 17:11:04 +1100 (AEDT) Received: from mail.aspeedtech.com ([192.168.0.24]) by twspam01.aspeedtech.com with ESMTP id 1BM65Bfb064928; Wed, 22 Dec 2021 14:05:11 +0800 (GMT-8) (envelope-from jammy_huang@aspeedtech.com) Received: from [192.168.2.115] (192.168.2.115) by TWMBX02.aspeed.com (192.168.0.24) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Wed, 22 Dec 2021 14:10:37 +0800 Message-ID: Date: Wed, 22 Dec 2021 14:10:37 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.4.0 Subject: Re: [PATCH 4/4] media: aspeed: Fix timing polarity incorrect Content-Language: en-US To: Joel Stanley References: <20211217095403.2618-1-jammy_huang@aspeedtech.com> <20211217095403.2618-5-jammy_huang@aspeedtech.com> From: Jammy Huang In-Reply-To: Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 8bit 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 1BM65Bfb064928 X-BeenThere: openbmc@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development list for OpenBMC List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-aspeed , Andrew Jeffery , OpenBMC Maillist , Eddie James , Linux Kernel Mailing List , Mauro Carvalho Chehab , Linux ARM , "linux-media@vger.kernel.org" Errors-To: openbmc-bounces+openbmc=archiver.kernel.org@lists.ozlabs.org Sender: "openbmc" Hi Joel, OK, I will update in next patch as you advised. Thanks for your review. On 2021/12/22 上午 09:22, Joel Stanley wrote: > On Fri, 17 Dec 2021 at 09:54, Jammy Huang wrote: >> This is a workaround for polarity unstable. >> Sync value get by VR09C counts from sync's rising edge, which means >> sync's polarity is negative if sync value is bigger than total/2. >> >> Signed-off-by: Jammy Huang >> --- >> drivers/media/platform/aspeed-video.c | 18 ++++++++++++++++++ >> 1 file changed, 18 insertions(+) >> >> diff --git a/drivers/media/platform/aspeed-video.c b/drivers/media/platform/aspeed-video.c >> index 5ad3a20c5bac..f628f69bb7dd 100644 >> --- a/drivers/media/platform/aspeed-video.c >> +++ b/drivers/media/platform/aspeed-video.c >> @@ -989,6 +989,15 @@ static void aspeed_video_get_resolution(struct aspeed_video *video) >> video->frame_top = FIELD_GET(VE_SRC_TB_EDGE_DET_TOP, >> src_tb_edge); >> det->vsync = FIELD_GET(VE_SYNC_STATUS_VSYNC, sync); >> + /* >> + * Workaround for polarity detection >> + * Use sync(VR098) counts from sync's rising edge till falling >> + * edge to tell sync polarity. >> + */ >> + if (det->vsync > (FIELD_GET(VE_MODE_DETECT_V_LINES, mds) >> 1)) > Are you right shifting as this is the value / 2? I think it's clearer > to write / 2 instead of >> 1. > > Mention in the comment that this is a workaround for when the sync > value is larger than half. > >> + det->polarities &= ~V4L2_DV_VSYNC_POS_POL; >> + else >> + det->polarities |= V4L2_DV_VSYNC_POS_POL; >> if (det->polarities & V4L2_DV_VSYNC_POS_POL) { >> det->vbackporch = video->frame_top - det->vsync; >> det->vfrontporch = >> @@ -1010,6 +1019,15 @@ static void aspeed_video_get_resolution(struct aspeed_video *video) >> video->frame_left = FIELD_GET(VE_SRC_LR_EDGE_DET_LEFT, >> src_lr_edge); >> det->hsync = FIELD_GET(VE_SYNC_STATUS_HSYNC, sync); >> + /* >> + * Workaround for polarity detection >> + * Use sync(VR098) counts from sync's rising edge till falling >> + * edge to tell sync polarity. >> + */ >> + if (det->hsync > (htotal >> 1)) >> + det->polarities &= ~V4L2_DV_HSYNC_POS_POL; >> + else >> + det->polarities |= V4L2_DV_HSYNC_POS_POL; >> if (det->polarities & V4L2_DV_HSYNC_POS_POL) { >> det->hbackporch = video->frame_left - det->hsync; >> det->hfrontporch = htotal - video->frame_right; >> -- >> 2.25.1 >> -- Best Regards Jammy From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 63440C433F5 for ; Wed, 22 Dec 2021 06:12:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:Content-Type: Content-Transfer-Encoding:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:From:References:CC:To:Subject: MIME-Version:Date:Message-ID:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=3lv9Ec2XYqK04iE3pPIF31hLQJe516sUUnacOnMEOjc=; b=HDhjIaE4p91t/O fA/E1/Xi2GaDMQsUbhb0TPYrIHK6wfbYbPT103B6vzn5J5i0wVFvh53lEu+mdY5Na1IKYQLrc7UK1 vWeWZhEzWt12b4AaGKHTHp03pdOMZFvLkdnqV6clOJ5He+6om5pBCbnGFZj64UphG/vk+/zaFMgDk UKuB4+ftbLMLHFz0FIQn5FebUcdCn3mK8cgJi3xJ64E+kQFw7WS6TYEF/OEQPUIVW5fTKCwNEHcYR 2T4DzHc0a1BaVGHD8/HdtUJ79q8onCcwYwwQwlk6xTrf12EXw467/Q1LCLOzBPf7aNlpnoQlr0nrS p898dG1EvRmqPru3678Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mzuqB-009Jo0-IQ; Wed, 22 Dec 2021 06:11:07 +0000 Received: from twspam01.aspeedtech.com ([211.20.114.71]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mzupz-009Jmv-Rm for linux-arm-kernel@lists.infradead.org; Wed, 22 Dec 2021 06:10:57 +0000 Received: from mail.aspeedtech.com ([192.168.0.24]) by twspam01.aspeedtech.com with ESMTP id 1BM65Bfb064928; Wed, 22 Dec 2021 14:05:11 +0800 (GMT-8) (envelope-from jammy_huang@aspeedtech.com) Received: from [192.168.2.115] (192.168.2.115) by TWMBX02.aspeed.com (192.168.0.24) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Wed, 22 Dec 2021 14:10:37 +0800 Message-ID: Date: Wed, 22 Dec 2021 14:10:37 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.4.0 Subject: Re: [PATCH 4/4] media: aspeed: Fix timing polarity incorrect Content-Language: en-US To: Joel Stanley CC: Eddie James , Mauro Carvalho Chehab , Andrew Jeffery , "linux-media@vger.kernel.org" , OpenBMC Maillist , Linux ARM , linux-aspeed , Linux Kernel Mailing List References: <20211217095403.2618-1-jammy_huang@aspeedtech.com> <20211217095403.2618-5-jammy_huang@aspeedtech.com> From: Jammy Huang In-Reply-To: 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 1BM65Bfb064928 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211221_221056_176227_A536DF3A X-CRM114-Status: GOOD ( 15.08 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Transfer-Encoding: base64 Content-Type: text/plain; charset="utf-8"; Format="flowed" Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org SGkgSm9lbCwKCk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Z2VyIHRoYW4gaGFsZi4KPgo+PiArICAgICAgICAgICAgICAgICAgICAg ICBkZXQtPnBvbGFyaXRpZXMgJj0gflY0TDJfRFZfVlNZTkNfUE9TX1BPTDsKPj4gKyAgICAgICAg ICAgICAgIGVsc2UKPj4gKyAgICAgICAgICAgICAgICAgICAgICAgZGV0LT5wb2xhcml0aWVzIHw9 IFY0TDJfRFZfVlNZTkNfUE9TX1BPTDsKPj4gICAgICAgICAgICAgICAgICBpZiAoZGV0LT5wb2xh cml0aWVzICYgVjRMMl9EVl9WU1lOQ19QT1NfUE9MKSB7Cj4+ICAgICAgICAgICAgICAgICAgICAg ICAgICBkZXQtPnZiYWNrcG9yY2ggPSB2aWRlby0+ZnJhbWVfdG9wIC0gZGV0LT52c3luYzsKPj4g ICAgICAgICAgICAgICAgICAgICAgICAgIGRldC0+dmZyb250cG9yY2ggPQo+PiBAQCAtMTAxMCw2 ICsxMDE5LDE1IEBAIHN0YXRpYyB2b2lkIGFzcGVlZF92aWRlb19nZXRfcmVzb2x1dGlvbihzdHJ1 Y3QgYXNwZWVkX3ZpZGVvICp2aWRlbykKPj4gICAgICAgICAgICAgICAgICB2aWRlby0+ZnJhbWVf bGVmdCA9IEZJRUxEX0dFVChWRV9TUkNfTFJfRURHRV9ERVRfTEVGVCwKPj4gICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzcmNfbHJfZWRnZSk7Cj4+ICAgICAg ICAgICAgICAgICAgZGV0LT5oc3luYyA9IEZJRUxEX0dFVChWRV9TWU5DX1NUQVRVU19IU1lOQywg c3luYyk7Cj4+ICsgICAgICAgICAgICAgICAvKgo+PiArICAgICAgICAgICAgICAgICogV29ya2Fy b3VuZCBmb3IgcG9sYXJpdHkgZGV0ZWN0aW9uCj4+ICsgICAgICAgICAgICAgICAgKiBVc2Ugc3lu YyhWUjA5OCkgY291bnRzIGZyb20gc3luYydzIHJpc2luZyBlZGdlIHRpbGwgZmFsbGluZwo+PiAr ICAgICAgICAgICAgICAgICogZWRnZSB0byB0ZWxsIHN5bmMgcG9sYXJpdHkuCj4+ICsgICAgICAg ICAgICAgICAgKi8KPj4gKyAgICAgICAgICAgICAgIGlmIChkZXQtPmhzeW5jID4gKGh0b3RhbCA+ PiAxKSkKPj4gKyAgICAgICAgICAgICAgICAgICAgICAgZGV0LT5wb2xhcml0aWVzICY9IH5WNEwy X0RWX0hTWU5DX1BPU19QT0w7Cj4+ICsgICAgICAgICAgICAgICBlbHNlCj4+ICsgICAgICAgICAg ICAgICAgICAgICAgIGRldC0+cG9sYXJpdGllcyB8PSBWNEwyX0RWX0hTWU5DX1BPU19QT0w7Cj4+ ICAgICAgICAgICAgICAgICAgaWYgKGRldC0+cG9sYXJpdGllcyAmIFY0TDJfRFZfSFNZTkNfUE9T X1BPTCkgewo+PiAgICAgICAgICAgICAgICAgICAgICAgICAgZGV0LT5oYmFja3BvcmNoID0gdmlk ZW8tPmZyYW1lX2xlZnQgLSBkZXQtPmhzeW5jOwo+PiAgICAgICAgICAgICAgICAgICAgICAgICAg ZGV0LT5oZnJvbnRwb3JjaCA9IGh0b3RhbCAtIHZpZGVvLT5mcmFtZV9yaWdodDsKPj4gLS0KPj4g Mi4yNS4xCj4+Ci0tIApCZXN0IFJlZ2FyZHMKSmFtbXkKCgpfX19fX19fX19fX19fX19fX19fX19f X19fX19fX19fX19fX19fX19fX19fX19fXwpsaW51eC1hcm0ta2VybmVsIG1haWxpbmcgbGlzdAps aW51eC1hcm0ta2VybmVsQGxpc3RzLmluZnJhZGVhZC5vcmcKaHR0cDovL2xpc3RzLmluZnJhZGVh ZC5vcmcvbWFpbG1hbi9saXN0aW5mby9saW51eC1hcm0ta2VybmVsCg== From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 44F2AC433FE for ; Wed, 22 Dec 2021 06:11:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242706AbhLVGLJ (ORCPT ); Wed, 22 Dec 2021 01:11:09 -0500 Received: from twspam01.aspeedtech.com ([211.20.114.71]:42557 "EHLO twspam01.aspeedtech.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242700AbhLVGLJ (ORCPT ); Wed, 22 Dec 2021 01:11:09 -0500 Received: from mail.aspeedtech.com ([192.168.0.24]) by twspam01.aspeedtech.com with ESMTP id 1BM65Bfb064928; Wed, 22 Dec 2021 14:05:11 +0800 (GMT-8) (envelope-from jammy_huang@aspeedtech.com) Received: from [192.168.2.115] (192.168.2.115) by TWMBX02.aspeed.com (192.168.0.24) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Wed, 22 Dec 2021 14:10:37 +0800 Message-ID: Date: Wed, 22 Dec 2021 14:10:37 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.4.0 Subject: Re: [PATCH 4/4] media: aspeed: Fix timing polarity incorrect Content-Language: en-US To: Joel Stanley CC: Eddie James , Mauro Carvalho Chehab , Andrew Jeffery , "linux-media@vger.kernel.org" , OpenBMC Maillist , Linux ARM , linux-aspeed , Linux Kernel Mailing List References: <20211217095403.2618-1-jammy_huang@aspeedtech.com> <20211217095403.2618-5-jammy_huang@aspeedtech.com> From: Jammy Huang In-Reply-To: Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 8bit 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 1BM65Bfb064928 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Hi Joel, OK, I will update in next patch as you advised. Thanks for your review. On 2021/12/22 上午 09:22, Joel Stanley wrote: > On Fri, 17 Dec 2021 at 09:54, Jammy Huang wrote: >> This is a workaround for polarity unstable. >> Sync value get by VR09C counts from sync's rising edge, which means >> sync's polarity is negative if sync value is bigger than total/2. >> >> Signed-off-by: Jammy Huang >> --- >> drivers/media/platform/aspeed-video.c | 18 ++++++++++++++++++ >> 1 file changed, 18 insertions(+) >> >> diff --git a/drivers/media/platform/aspeed-video.c b/drivers/media/platform/aspeed-video.c >> index 5ad3a20c5bac..f628f69bb7dd 100644 >> --- a/drivers/media/platform/aspeed-video.c >> +++ b/drivers/media/platform/aspeed-video.c >> @@ -989,6 +989,15 @@ static void aspeed_video_get_resolution(struct aspeed_video *video) >> video->frame_top = FIELD_GET(VE_SRC_TB_EDGE_DET_TOP, >> src_tb_edge); >> det->vsync = FIELD_GET(VE_SYNC_STATUS_VSYNC, sync); >> + /* >> + * Workaround for polarity detection >> + * Use sync(VR098) counts from sync's rising edge till falling >> + * edge to tell sync polarity. >> + */ >> + if (det->vsync > (FIELD_GET(VE_MODE_DETECT_V_LINES, mds) >> 1)) > Are you right shifting as this is the value / 2? I think it's clearer > to write / 2 instead of >> 1. > > Mention in the comment that this is a workaround for when the sync > value is larger than half. > >> + det->polarities &= ~V4L2_DV_VSYNC_POS_POL; >> + else >> + det->polarities |= V4L2_DV_VSYNC_POS_POL; >> if (det->polarities & V4L2_DV_VSYNC_POS_POL) { >> det->vbackporch = video->frame_top - det->vsync; >> det->vfrontporch = >> @@ -1010,6 +1019,15 @@ static void aspeed_video_get_resolution(struct aspeed_video *video) >> video->frame_left = FIELD_GET(VE_SRC_LR_EDGE_DET_LEFT, >> src_lr_edge); >> det->hsync = FIELD_GET(VE_SYNC_STATUS_HSYNC, sync); >> + /* >> + * Workaround for polarity detection >> + * Use sync(VR098) counts from sync's rising edge till falling >> + * edge to tell sync polarity. >> + */ >> + if (det->hsync > (htotal >> 1)) >> + det->polarities &= ~V4L2_DV_HSYNC_POS_POL; >> + else >> + det->polarities |= V4L2_DV_HSYNC_POS_POL; >> if (det->polarities & V4L2_DV_HSYNC_POS_POL) { >> det->hbackporch = video->frame_left - det->hsync; >> det->hfrontporch = htotal - video->frame_right; >> -- >> 2.25.1 >> -- Best Regards Jammy