Received: by 2002:a05:6358:489b:b0:bb:da1:e618 with SMTP id x27csp2056097rwn; Fri, 9 Sep 2022 07:58:26 -0700 (PDT) X-Google-Smtp-Source: AA6agR4RCMRAAzjMwkYiLn2N/wotSBwYdD2ipA0q+m4+hpWvEKEvr053b6pA3dIMuQH0ARATv4AD X-Received: by 2002:a17:907:60c7:b0:731:2be4:f72d with SMTP id hv7-20020a17090760c700b007312be4f72dmr10222854ejc.639.1662735505670; Fri, 09 Sep 2022 07:58:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662735505; cv=none; d=google.com; s=arc-20160816; b=QqH6kh2C6TYFMbLpJt1p9c1B3wA6y4bkiQiD0VH/pNPCOHj4OxT6Ca2xiLBHWcW0wg afY6rHj1ujHaaRV3e2RTUKQaRlse/OpxbH09ByNbf5o5KJNfHURLTkVlw5MHzCKQzysG bRtDG0KKc+w3FrEMM8pbPb9DHIO2LcTEi9KKainEv69RxySVVzRqaYqcM8V5EQy7rzee Xe0kRuQaXnvQFpQ7VrDyZNnqZmIEd9U5poe/WUC83ZVVFfMtJyRuQ4YBS/6iTPoweoB4 Sa8r6wXNZJbTAvDY8DflhtN/OUBw2sz58uLLcmau+BBqRogiQ7+mvIrfs8A2uuEb6KwS d0WA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:feedback-id :dkim-signature:dkim-signature; bh=twsyF+dYRjXjnnGW4P2FrhcauKzDn/tda3IgcxV76Lc=; b=QEY75Rexw2zkF4GUe5qbztV11X77bI0T6bxqK6rbeA0PbVxfZlM9lNkUMLsrZpNxkr eE5mfmjpTX98LPJCXHLm/rGIIrIXDdcaZOZhtgx5vhxwHyw8pAhdNflDIAuwTCHBCc+H gvK3cN8TwQR4NgLplymfYHFpgU/9Ao72NYmbrAeK1iHc6v0ivG/yWdc7H6+EMSqHdtB+ AV0eeQIe/MhF/KgoMKlzaldK5bcbMGf/y/l8/GAOp9MgXtx5E6nfIxrdLaWZ5m/I5LQ4 PeA1zsefA/CrSraT8w+YeuEalRbLbqQVt+ZsjV4TUCpNdNYoFK2yve2rcpNiyBRKAu1G ro0w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@cerno.tech header.s=fm2 header.b=K8t4cEw2; dkim=pass header.i=@messagingengine.com header.s=fm2 header.b=RtBk1llT; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=cerno.tech Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id n8-20020a1709067b4800b0077771b6d988si564250ejo.558.2022.09.09.07.58.00; Fri, 09 Sep 2022 07:58:25 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@cerno.tech header.s=fm2 header.b=K8t4cEw2; dkim=pass header.i=@messagingengine.com header.s=fm2 header.b=RtBk1llT; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=cerno.tech Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229616AbiIINzq (ORCPT + 99 others); Fri, 9 Sep 2022 09:55:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43778 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231617AbiIINzJ (ORCPT ); Fri, 9 Sep 2022 09:55:09 -0400 Received: from wnew4-smtp.messagingengine.com (wnew4-smtp.messagingengine.com [64.147.123.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9B6104507B for ; Fri, 9 Sep 2022 06:54:55 -0700 (PDT) Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailnew.west.internal (Postfix) with ESMTP id 11AC82B059E3; Fri, 9 Sep 2022 09:54:48 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute3.internal (MEProxy); Fri, 09 Sep 2022 09:54:51 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cerno.tech; h=cc :cc:content-type:date:date:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:sender:subject :subject:to:to; s=fm2; t=1662731688; x=1662738888; bh=twsyF+dYRj XjnnGW4P2FrhcauKzDn/tda3IgcxV76Lc=; b=K8t4cEw2S1jTGUeOlMJf8kslEo QJyj678Lu8Kob+/9eWZagC2oRLjkSTAc0jeY16K+jwvEyPq60b7YpNsaRMptdInB HoJX2gz4TupUnyw1F5YdO8sItHXGsFBsUduHDRXFLN/2np2/yyd7PYvY0FVwwVit j3wL/7WNski567FQCYDMqTBdiIQwVqR8VPkz4UW/NqKLrjkY/qtE1LmNN7N3HRsP zRQsA0TJjJ8mADyZVvJIalbriX4DKPJeDthVRHRJNCgAtW7IMF3xN67/o6EthDv+ s6gXj5TxpVtV7vZt8LM4Vt8UmWhu5zUx0uH8eR3tConKHPNbzjCftYF4MIrA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:date:date:feedback-id :feedback-id:from:from:in-reply-to:in-reply-to:message-id :mime-version:references:reply-to:sender:subject:subject:to:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm2; t=1662731688; x=1662738888; bh=twsyF+dYRjXjnnGW4P2FrhcauKzD n/tda3IgcxV76Lc=; b=RtBk1llT4lqeInj5g2sNFdZ2HVb6sArX5J8FMtXnYtZy 6yIaShdwuTNh2CM7A3cxA6V81Laj8JF+AX9cgKHnwWhNFUfLtEf65m7QYt10l0DY ylhdn3JUl3zMfzz/fD+brQ9bhJUStZayX64p1pQyLXO3IGPK/wv2WRGpZB7VIzIN A+MsChORQ3n2DJYL+5IAkYTGs254ytq/smndyfQwCnx9png80n0uJIOwdtg+lzgI kkaS/f1QqyJdXEWreIsNU5HNUCK9jk9ZXnERNgZIK80BB+mduATiEQOAlg7BW/2p MqXeV+J8UFus2OTkVCke3KT1zcpbKW2NNwc32MuRnA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvfedrfedthedgjeduucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepfffhvfevuffkfhggtggujgesghdtreertddtudenucfhrhhomhepofgrgihi mhgvucftihhprghrugcuoehmrgigihhmvgestggvrhhnohdrthgvtghhqeenucggtffrrg htthgvrhhnpedtffetudfgleeukeevveevveeggfeliefhffeivdekfeeijeelledvueek tdfhteenucffohhmrghinhepihhtuhdrihhnthdpsghmvgdrhhhunecuvehluhhsthgvrh fuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepmhgrgihimhgvsegtvghrnhho rdhtvggthh X-ME-Proxy: Feedback-ID: i8771445c:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 9 Sep 2022 09:54:46 -0400 (EDT) Date: Fri, 9 Sep 2022 15:54:44 +0200 From: Maxime Ripard To: Mateusz Kwiatkowski Cc: Ben Skeggs , David Airlie , Chen-Yu Tsai , Thomas Zimmermann , Jani Nikula , Lyude Paul , Philipp Zabel , Maarten Lankhorst , Rodrigo Vivi , Tvrtko Ursulin , Jernej Skrabec , Samuel Holland , Karol Herbst , Noralf =?utf-8?Q?Tr=C3=B8nnes?= , Emma Anholt , Daniel Vetter , Joonas Lahtinen , Hans de Goede , linux-arm-kernel@lists.infradead.org, Phil Elwell , intel-gfx@lists.freedesktop.org, Dave Stevenson , dri-devel@lists.freedesktop.org, Dom Cobley , linux-kernel@vger.kernel.org, nouveau@lists.freedesktop.org, linux-sunxi@lists.linux.dev, Geert Uytterhoeven Subject: Re: [PATCH v2 10/41] drm/modes: Add a function to generate analog display modes Message-ID: <20220909135444.5oi6oh6nqwuke3jl@houat> References: <20220728-rpi-analog-tv-properties-v2-0-459522d653a7@cerno.tech> <20220728-rpi-analog-tv-properties-v2-10-459522d653a7@cerno.tech> <242d272b-5b79-986c-9aaf-64e62f6b37ff@gmail.com> <20220905133755.gcmmntg3wnecyqjq@houat> <10ce686a-d7c8-9ce4-3979-735ad8eab3b5@gmail.com> <20220907143421.4iopqwhp3yfircsh@houat> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="exp3fcsdo7vrdnhl" Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_LOW,SPF_HELO_PASS,T_SCC_BODY_TEXT_LINE, T_SPF_TEMPERROR autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --exp3fcsdo7vrdnhl Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Hi, On Wed, Sep 07, 2022 at 11:31:21PM +0200, Mateusz Kwiatkowski wrote: > W dniu 7.09.2022 o 16:34, Maxime Ripard pisze: > > On Mon, Sep 05, 2022 at 06:44:42PM +0200, Mateusz Kwiatkowski wrote: > >> Hi Maxime, > >> > >> W dniu 5.09.2022 o 15:37, Maxime Ripard pisze: > >>>>> +=A0=A0=A0 vfp =3D vfp_min + (porches_rem / 2); > >>>>> +=A0=A0=A0 vbp =3D porches - vfp; > >>>> > >>>> Relative position of the vertical sync within the VBI effectively mo= ves the > >>>> image up and down. Adding that (porches_rem / 2) moves the image up = off center > >>>> by that many pixels. I'd keep the VFP always at minimum to keep the = image > >>>> centered. > >>> > >>> And you would increase the back porch only then? > >> > >> Well, increasing vbp only gives a centered image with the default 480i= /576i > >> resolutions. However, only ever changing vbp will cause the image to b= e always > >> at the bottom of the screen when the active line count is decreased (e= =2Eg. > >> setting the resolution to 720x480 but for 50Hz "PAL" - like many game = consoles > >> did back in the day). > >> > >> I believe that the perfect solution would: > >> > >> - Use the canonical / standard-defined blanking line counts for the st= andard > >>=A0=A0 vertical resolutions (480/486/576) > >> - Increase vfp and vbp from there by the same number if a smaller numb= er of > >>=A0=A0 active lines is specified, so that the resulting image is center= ed > >> - Likewise, decrease vfp and vbp by the same number if the active line= number > >>=A0=A0 is larger and there is still leeway (this should allow for seaml= ess handling > >>=A0=A0 of 480i vs. 486i for 60 Hz "NTSC") > > > > I'm not sure I understand how that's any different than the code you > > initially commented on. > > > > I would start by taking the entire blanking area, remove the sync > > period. We only have the two porches now, and I'm starting from the > > minimum, adding as many pixels in both (unless it's not an even number, > > in which case the backporch will have the extra pixel). > > > > Isn't it the same thing? > > [...] > > Unless you only want me to consider the front porch maximum? >=20 > I think you're confusing the "post-equalizing pulses" with the "vertical = back > porch" a little bit. The "vertical back porch" includes both the post-equ= alizing > pulses and the entire rest of the VBI period, for the standard resolution= s at > least. >=20 > The "canonical" modelines (at least for vc4's VEC, see the notes below): >=20 > - (vfp=3D=3D4, vsync=3D=3D6, vbp=3D=3D39) for 576i > - (vfp=3D=3D7, vsync=3D=3D6, vbp=3D=3D32) for 480i > - (vfp=3D=3D5, vsync=3D=3D6, vbp=3D=3D28) for 486i (full frame NTSC as or= iginally specified) >=20 > The numbers for vfp don't exactly match the theoretical values, because: >=20 > - VEC actually adds a half-line pulse on top of VFP_ODD, and in the 625-l= ine > =A0 mode also on top of VFP_EVEN (not always, but let's not dwell too muc= h) > - Conversely, VEC subtracts the half-line pulse from VSYNC_ODD and VSYNC_= EVEN > =A0 in the 625-line mode > - SMPTE S170M (see https://www.itu.int/rec/R-REC-BT.1700-0-200502-I/en) d= efines > =A0 that active picture for NTSC is on lines 21-263 and 283-525; 263 and = 283 are > =A0 half-lines that are represented as full lines in the "486i" spec It's going to be a bit difficult to match that into a drm_display_mode, since as far I understand it, all the timings are the sum of the timings of both fields in interlaced. I guess we'll have to be close enough. > - SMPTE 314M, which is the spec for DV, defines the 480 active lines as l= ines > =A0 23-262 and 285-524; see Table 20 on page 26 in > =A0 https://last.hit.bme.hu/download/firtha/video/SMPTE/SMPTE-314M%20DV25= -50.pdf; > =A0 this means that the standard 480i frame shaves off four topmost and t= wo > =A0 bottommost lines (2 and 1 per field) of the 486i full frame I'm still struggling a bit to match that into front porch, sync period and back porch. I guess the sync period is easy since it's pretty much fixed. That line 0-23 is the entire blanking area though, right? > Note that the half-line pulses in vfp/vsync may be generated in a differe= nt way > on encoders other than vc4's VEC. Maybe we should define some concrete > semantics for vfp/vsync in analog TV modes, and compensate for that in the > drivers. But anyway, that's a separate issue. >=20 > My point is that, to get a centered image, you can then proportionately a= dd > values to those "canonical" vfp/vbp values. For example if someone specif= ies > 720x480 frame, but 50 Hz PAL, you should set (vfp=3D=3D52, vsync=3D=3D6, = vbp=3D=3D87). In this case, you add 48 both front porches, right? How is that proportionate? > Those extra vbp lines will be treated as a black bar at the top of the fr= ame, > and extra vfp lines will be at the bottom of the frame. >=20 > However if someone specifies e.g. 720x604, there's nothing more you could > remove from vfp, so your only option is to reduce vbp compared to the sta= ndard > mode, so you'll end up with (vfp=3D=3D4, vsync=3D=3D6, vbp=3D=3D11). The = image will not be > centered, the topmost lines will get cropped out, but that's the best we = can do > and if someone is requesting such resolution, they most likely want to ac= tually > access the VBI to e.g. emit teletext. >=20 > Your current code always starts at (vfp=3D=3D5 or 6, vsync=3D6, vbp=3D=3D= 6) and then > increases both vfp and vbp proportionately. This puts vsync dead center i= n the > VBI, which is not how it's supposed to be - and that in turn causes the i= mage > to be significantly shifted upwards. >=20 > I hope this makes more sense to you now. I'm really struggling with this, so thanks for explaining this further (and patiently ;)) If I get this right, what you'd like to change is this part of the calculus (simplified a bit, and using PAL, 576i): vfp_min =3D params->vfp_lines.even + params->vfp_lines.odd; // 5 vbp_min =3D params->vbp_lines.even + params->vbp_lines.odd; // 6 vslen =3D params->vslen_lines.even + params->vslen_lines.odd; // 6 porches =3D params->num_lines - vactive - vslen; // 43 porches_rem =3D porches - vfp_min - vbp_min; // 32 vfp =3D vfp_min + (porches_rem / 2); // 21 vbp =3D porches - vfp; // 22 Which is indeed having sync centered. I initially changed it to: vfp =3D vfp_min; // 6 vbp =3D num_lines - vactive - vslen - vfp; // 38 Which is close enough for 576i, but at 480i/50Hz would end up with 134, so still fairly far off. I guess your suggestion would be along the line of: vfp_min =3D params->vfp_lines.even + params->vfp_lines.odd; // 5 vbp_min =3D params->vbp_lines.even + params->vbp_lines.odd; // 38 vslen =3D params->vslen_lines.even + params->vslen_lines.odd; // 6 porches =3D params->num_lines - vactive - vslen; // 0 porches_rem =3D porches - vfp_min - vbp_min; // 0 vfp =3D vfp_min + (porches_rem / 2); // 5 vbp =3D porches - vfp; // 38 Which is still close enough for 576i, but for 480i would end up with: porches =3D params->num_lines - vactive - vslen; // 139 porches_rem =3D porches - vfp_min - vbp_min; // 96 vfp =3D vfp_min + (porches_rem / 2); // 53 vbp =3D porches - vfp; // 86 Right? Maxime --exp3fcsdo7vrdnhl Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iHUEABYKAB0WIQRcEzekXsqa64kGDp7j7w1vZxhRxQUCYxtFpAAKCRDj7w1vZxhR xQthAP48zJ8g779BqSdxUbioH+WvlR067prjIQRN+Yc036muGAD/R7i4n/1FakDa JQXyYQwjZa0/ToIqQHeTfHP+kWLvFAM= =rFHL -----END PGP SIGNATURE----- --exp3fcsdo7vrdnhl--