Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp4815254rwb; Wed, 17 Aug 2022 06:36:08 -0700 (PDT) X-Google-Smtp-Source: AA6agR4LFmIJPLaNuaYWbCBCHV9KQD0AGqHlkl97Q8Zj6uvnIunDBlT4gAtFNjjLKZK1llUPZZY3 X-Received: by 2002:a17:907:2d0c:b0:730:86ec:d536 with SMTP id gs12-20020a1709072d0c00b0073086ecd536mr16436979ejc.391.1660743367693; Wed, 17 Aug 2022 06:36:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660743367; cv=none; d=google.com; s=arc-20160816; b=wxarxAh3eebRAmVHqol6l6nL3GsnaHXV+ZBSfPaWFu4nWcAyrb7mSjF5yyZPvlzZ5Y mfEC4rJbwdq7vwROlNQY9CzibWkRbHDqTVgqVrzl4vByJEayHwKFz6mhcs2kVc5JMMN8 e5jxpWahkPpA1xLp4FMRL2H8VHhKDL8Ps2oCKWhwdXTiDh5+J6JUTOWE6OJHOIrtbKDR QN1Rv/p9UUSrvUDE9XaLLAK6rf96H3bx857wxrMjfVwXwymXoUCpouhA+ICgq6u3TMPp F6LJ3B8U0gTiYAdi32estPNdgK7Iyb6nTi4XL3RARu6sR5c93PPsgT67gOsoEwcDVFYq Znrg== 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=dUKlPZvVEL3xTGjKVzoEN6kF32lJAtnC40Q+pnqgRfw=; b=U1RiOu9AF0lhFIQXr1zqezqwEnTrL0mZlY/fFnI2cMzeI29Hg42/q1j5J01vI6AD3d eqYte8Eiocb7D8RfVhSV4d0i/dSkyAgs3uImeqfjO3BdOWqZMgcOEf3V8jIgXnXzeKhj IqA9VFWopZJk0fVEe0/Im9yt4TKMFhVDTUR0bgiKFbQTU1r4uiv5OThc6Or3dRlvsZ5a H5kwUwsiliWQpo1bI34b1Z+Z7JZRmjB9rG/Of1hjKNI+vKRYWONAjS8kquVC4mp2/t/I H9scoXQOuDpkSn44V+DQMM0U2HnSzPgcpEJ+v0UrCF7Cy9lT+gKHkjbGZ9bVf4WqvYvE kv5A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@cerno.tech header.s=fm3 header.b=IEDcwGBY; dkim=pass header.i=@messagingengine.com header.s=fm1 header.b=II19VbXx; 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 cw19-20020a170906479300b00730b9eecb2dsi15745567ejc.817.2022.08.17.06.35.41; Wed, 17 Aug 2022 06:36:07 -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=fm3 header.b=IEDcwGBY; dkim=pass header.i=@messagingengine.com header.s=fm1 header.b=II19VbXx; 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 S239647AbiHQNPo (ORCPT + 99 others); Wed, 17 Aug 2022 09:15:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44426 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239889AbiHQNPb (ORCPT ); Wed, 17 Aug 2022 09:15:31 -0400 Received: from wnew3-smtp.messagingengine.com (wnew3-smtp.messagingengine.com [64.147.123.17]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7978C6069E for ; Wed, 17 Aug 2022 06:15:04 -0700 (PDT) Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailnew.west.internal (Postfix) with ESMTP id A9A3A2B059AF; Wed, 17 Aug 2022 09:14:59 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute5.internal (MEProxy); Wed, 17 Aug 2022 09:15:01 -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=fm3; t=1660742099; x=1660749299; bh=dUKlPZvVEL 3xTGjKVzoEN6kF32lJAtnC40Q+pnqgRfw=; b=IEDcwGBYZLkANXTNyAYKOwp4p1 mgSuY+T9Ifhc4qWp7gh7XNF3Nwcc/E7l/MKv+if7WM1WotsUeuwRsetP5/OMSwuB PH8BanvT7zdMzmlSLSfsSuaUSrDeXiw89jeZ6lRE3oA7UIYAc5fEqx2TaEQGTZzg WLC95bXP/c9sNRqP/m7D1ws0NBzlE5GZaRF3DNGVQB078cbWSwrds8ulA4rRWo/c R766pDMsHsnoS/ZWZHkw+VF/E7Z1seCJRTx7fW8G4+jxyS1glP6l+lxlfcfMXFgI GfYvDrhpo+pkMvKdFfMkpktqITeAkEbKvoFy7R6eG4H70PV+26T276NDgfCA== 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= fm1; t=1660742099; x=1660749299; bh=dUKlPZvVEL3xTGjKVzoEN6kF32lJ AtnC40Q+pnqgRfw=; b=II19VbXx9+ZDrnShqimgJELk3HiJSUS/OzpEvmLv7zEC xj4Lzp/6olZ6ZnPiq+LS6ScCbzzhmd0V6Afoz/4J0BCsCaGMsV77GMQhnCENsFVR ZWk08BTTT/3eculwIl1GcYdcdVBcq05W9mLXcNbLwjrE6Uz25qcDWArenaJsJKah 6KByP9J/duC8dwJn7uCp0VmOUpNVkEO7dxiQQoYvPQ2tUlBPCnUzVtsqu1S749Cn D8jEb1S6Dti5QFi2Jb4TMNQS3CQeX3c6nqQTRTOb6bRKnL/RGK0fv0RKHIkjF4X+ FMr1CZlUtM+A1ZYRYlujzJPN+9+x14Ynnpkjul6iIw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvfedrvdehiedgiedvucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepfffhvfevuffkfhggtggujgesghdtreertddtudenucfhrhhomhepofgrgihi mhgvucftihhprghrugcuoehmrgigihhmvgestggvrhhnohdrthgvtghhqeenucggtffrrg htthgvrhhnpeevffdvudeivdffffefueejieekvdekvdelieeftedvtdegtdffieetuedt ueejgeenucffohhmrghinhepfihikhhiphgvughirgdrohhrghenucevlhhushhtvghruf hiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehmrgigihhmvgestggvrhhnohdr thgvtghh X-ME-Proxy: Feedback-ID: i8771445c:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 17 Aug 2022 09:14:57 -0400 (EDT) Date: Wed, 17 Aug 2022 15:14:54 +0200 From: Maxime Ripard To: Geert Uytterhoeven Cc: Jernej Skrabec , Martin Blumenstingl , Chen-Yu Tsai , Philipp Zabel , Jerome Brunet , Samuel Holland , Thomas Zimmermann , Daniel Vetter , Emma Anholt , David Airlie , Maarten Lankhorst , Noralf =?utf-8?Q?Tr=C3=B8nnes?= , Kevin Hilman , Neil Armstrong , linux-sunxi@lists.linux.dev, Linux Kernel Mailing List , Phil Elwell , Mateusz Kwiatkowski , Linux ARM , Dave Stevenson , "open list:ARM/Amlogic Meson..." , DRI Development , Dom Cobley Subject: Re: [PATCH v1 04/35] drm/modes: Introduce 480i and 576i modes Message-ID: <20220817131454.qcuywcuc4ts4hswm@houat> References: <20220728-rpi-analog-tv-properties-v1-0-3d53ae722097@cerno.tech> <20220728-rpi-analog-tv-properties-v1-4-3d53ae722097@cerno.tech> <20220816132636.3tmwqmrox64pu3lt@houat> <20220817075351.4xpsqdngjgtiqvob@houat> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="3k2wy2tkfns6fd4i" Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW,SPF_HELO_PASS, SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED 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 --3k2wy2tkfns6fd4i Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Wed, Aug 17, 2022 at 10:51:55AM +0200, Geert Uytterhoeven wrote: > On Wed, Aug 17, 2022 at 9:54 AM Maxime Ripard wrote: > > On Tue, Aug 16, 2022 at 05:00:38PM +0200, Geert Uytterhoeven wrote: > > > On Tue, Aug 16, 2022 at 3:26 PM Maxime Ripard wro= te: > > > > On Fri, Aug 12, 2022 at 03:18:58PM +0200, Geert Uytterhoeven wrote: > > > > > On Fri, Jul 29, 2022 at 6:35 PM Maxime Ripard = wrote: > > > > > > Multiple drivers (meson, vc4) define the analog TV 525-lines an= d 625-lines > > > > > > modes in the drivers. > > > > > > > > > > Nit: strictly speaking these are not analog modes, but the digital > > > > > variants (ITU-R BT.656 and DVD-Video D1) of NTSC and PAL, using a > > > > > 13.5 MHz sampling frequency for pixels. > > > > > > > > > > In analog modes, the only discrete values are the number of lines= , and > > > > > the frame/field rate (fixing the horizontal sync rate when combin= ed). > > > > > > > > > > The number of (in)visible pixels per line depends on the available > > > > > bandwidth. In a digital variant (which is anything generated by a > > > > > digital computer system), the latter depends on the pixel clock, = which > > > > > can wildly differ from the 13.5 MHz used in the BT.656 standard. = (e.g. > > > > > Amiga uses 7.09/14.19/28.38 MHz (PAL) or 7.16/14.32/28.64 MHz (NT= SC)). > > > > > > > > > > So I think we probably need some way to generate a PAL/NTSC-compa= tible > > > > > mode based not only on resolution, but also on pixel clock. > > > > > > > > This would also fix the comments made by Jani and Thomas, so I quite > > > > like the idea of it. > > > > > > > > I'm struggling a bit to find how would could implement this though. > > > > > > > > From what you were saying, I guess the prototype would be something= like > > > > > > > > struct drm_display_mode *drm_create_analog_mode(unsigned int pixel_= clock, > > > > unsigned int lines, > > > > unsigned int frame_= rate) > > > > > > > > But I have zero idea on what the implementation would be. Do you ha= ve > > > > some resources for this you could point me to? > > > > > > Horizontally, I think you should calculate left/right margins and > > > hsync length to yield timings that match those for the BT.656 PAL/NTSC > > > modes. I.e. when a 640x512 mode with a pixel clock of 14 MHz is > > > requested, you want to calculate left', right', and hslen' for > > > > > > | <---- left' ---> | <- 640 pixels -> | <---- right' ---> | <--- hsle= n' --> | > > > @ 14 MHz > > > > > > so they match the timings for left, right, and hslen for > > > > > > | <--- left ---> | <--- 720 pixels ---> | <--- right ---> | <--- hsle= n ---> | > > > @ 13.5 MHz > > > > > > As 640 pixels @ 14 MHz are less wide than 720 pixels @ 13.5 MHz, > > > you want to make sure to align the center of the visible part. > > > > So I guess in that example if we want to center it, left =3D=3D right a= nd > > left' =3D=3D right'? What about the sync length? >=20 > No, left and right are asymmetrical, cfr. front and back porch in > https://en.wikipedia.org/wiki/PAL#PAL_signal_details > I.e. if the pixel part is reduced, both the left and right margins > should be increased by the same amount. >=20 > From the table linked above, hslen should be ca. 4.7=B5s (fixed). each pixel taking 1 / pixel_clock seconds (assuming pixel_clock is in Hz), and thus hslen (in pixels) =3D 4.7 * 10 ^ -6 * pixel_clk, right? > > > Vertically, it's simpler, as the number of lines is discrete. > > > You do have to take into account interlace and doublescan, and > > > progressive modes with 262/312 lines. > > > > So we only have to deal with 525 and 625 lines total (without taking > > interlace and doublescan into account), right? >=20 > Yes. >=20 > > I guess we still have the same question, we probably want to center it, > > so top =3D=3D bottom, but what about the vsync length? >=20 > Unfortunately that table does not mention top and bottom margins. > But according to drivers/video/fbdev/amifb.c (see the "Broadcast > video timings" comment block and the definitions of the "ntsc-lace" > and "pal-lace" video modes), they are asymmetrical, too. >=20 > Vsync length is 0.576ms, so that's 9 scan lines (I guess I didn't > have that info when I wrote amifb, as I used 4 lines there). Thanks, that's some great info already. It's mentioned though that the settings for NTSC are "straightforward", but it's definitely not for me :) I've looked around and it looks like the entire blanking area is supposed to be 40 pixels in interlaced, but I couldn't find anywhere how it's supposed to be split between the upper and lower margins and the sync period. Thanks! Maxime --3k2wy2tkfns6fd4i Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iHUEABYKAB0WIQRcEzekXsqa64kGDp7j7w1vZxhRxQUCYvzpzgAKCRDj7w1vZxhR xaliAQCDHSUbOXnRJW+WaaBPo51qOcik941/wbzLlMyQZE7BWAD9EBh9ubEvqwGp 65TtZrmiJ6qFtpANfbFDnug7CTw2nAQ= =yOdY -----END PGP SIGNATURE----- --3k2wy2tkfns6fd4i--