From patchwork Fri Jul 29 16:35:07 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Ripard X-Patchwork-Id: 12932713 X-Patchwork-Delegate: neil.armstrong@linaro.org 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 05036C00144 for ; Fri, 29 Jul 2022 17:13:33 +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-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=pa5iK5hBAy3zdoSG3VX0ObNNpxh2gs//BE9dT6cuM1Y=; b=zDKm/Pg0cNronU mD+HLCJjfSy+s8LhtO1RJpnXMEvYQjYOQ2AeKpVq5yTYJd3KyoJIKvo01jUu2DHcPc+R0XmDhl2ur S8UON6uEMJY/ofy++iYao/VxZZ/WnHuybYxh2pHeT4YLiuDNCmsYRNX5lz5hNrgpdIeekauzYw/Sw boubs/Jqyoe6HS7YYztYlFu3Wwljyj49wa7Djj43PlWvtcBudJ6gTaN9q0Byk6zD7DUC9eAfwt6ko W7Bw6WRFiPYAoHd7kcmiitg5PJdhdXJ5DcgTBjVeqwk/inmOm5/dX3aO5Nmh1vycaeJnYW6JLYcr2 wHC68WPP5hZZKngx1ofQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oHTY8-007JAW-2V; Fri, 29 Jul 2022 17:13:20 +0000 Received: from new4-smtp.messagingengine.com ([66.111.4.230]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oHSyt-006SkK-1D; Fri, 29 Jul 2022 16:36:58 +0000 Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailnew.nyi.internal (Postfix) with ESMTP id 556EF580985; Fri, 29 Jul 2022 12:36:54 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute3.internal (MEProxy); Fri, 29 Jul 2022 12:36:54 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cerno.tech; h=cc :cc:content-transfer-encoding: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=1659112614; x= 1659119814; bh=whvPVVthKbSxDiFpQbK45mdHTwISFKL9gD5bt0ROd6s=; b=l 7BGo0DX0o++A2nHPIJ6mVTn0MG/UTvhptFXCphq0bNiBXZ03Uc1/KVdSOk7b+fUL R9Sr586o2zHw7l4SG/WxpCJjay4qhQnyhprZ5q1z8Sv5BFnNi7DtZtvdgYw2N2Bx jY8sN3cnEEzePB9kNCOcP4tqdQg177i44qUhtkyl+g391yIFjCLECnhhaJ1G5AfL sCQXVSrXopfxOacx2cpfSkp8LcAuhn+Z9dhXbOKGmbNb6qoDApNzm/fgixb26N+/ VD1pU3uZqj//4ei4TZPjV+DID9rMrSAAENnGpxoeinynv197osgAnryKDjekBWGA 7E5cuzkT/OSI3SP7PukIg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :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=fm3; t=1659112614; x= 1659119814; bh=whvPVVthKbSxDiFpQbK45mdHTwISFKL9gD5bt0ROd6s=; b=v ihTe8DtYIgMO52PCo4aeX2+O7x4VMLeUtM7KJyx8x+Nh6JZVEIyRbJGzrBkE5NLL iEj8iEUDKrj0O7RQ6ySrlAaAretM0j/5fq+wJFy8eelWCpFIkO4FvTQhSoV3rwOq Q4bC2yUd2IUctlEX5HdaYoCNOHie/QUnhp9Bjwr8m3DdhZbsvbUGPT/7XDGxP/+L yCsamTiCEb7y6MFv+YH3kPgP/dXdsV3aoxfqi1mMjRmsSq7+YxXhkFx3YWDo/Fio tzxN4OrLJ+EKeuMB7NkeV2C2jdwgQta8VMbFEh2EXvk7QqWR5+YqFSalB9Q738m1 is1N8zAr3W41LPwPlYfsg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvfedrvddujedguddtgecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enucfjughrpefhvfevufffkffojghfgggtoffgsehtkeertdertdejnecuhfhrohhmpefo rgigihhmvgcutfhiphgrrhguuceomhgrgihimhgvsegtvghrnhhordhtvggthheqnecugg ftrfgrthhtvghrnhepgfffgfetffduudelhfevieffffduleevgfegkeeutefgffejheel leekjeefhfejnecuvehluhhsthgvrhfuihiivgepfeenucfrrghrrghmpehmrghilhhfrh homhepmhgrgihimhgvsegtvghrnhhordhtvggthh X-ME-Proxy: Feedback-ID: i8771445c:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 29 Jul 2022 12:36:53 -0400 (EDT) From: Maxime Ripard To: Jernej Skrabec , Martin Blumenstingl , Chen-Yu Tsai , Philipp Zabel , Jerome Brunet , Samuel Holland , Thomas Zimmermann , Daniel Vetter , Emma Anholt , David Airlie , Maarten Lankhorst , =?utf-8?q?Noralf_Tr?= =?utf-8?q?=C3=B8nnes?= , Kevin Hilman , Neil Armstrong , Maxime Ripard Cc: Maxime Ripard , linux-sunxi@lists.linux.dev, linux-kernel@vger.kernel.org, Phil Elwell , Mateusz Kwiatkowski , linux-arm-kernel@lists.infradead.org, Geert Uytterhoeven , Dave Stevenson , linux-amlogic@lists.infradead.org, dri-devel@lists.freedesktop.org, Dom Cobley Subject: [PATCH v1 24/35] drm/vc4: vec: Add support for more analog TV standards Date: Fri, 29 Jul 2022 18:35:07 +0200 Message-Id: <20220728-rpi-analog-tv-properties-v1-24-3d53ae722097@cerno.tech> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220728-rpi-analog-tv-properties-v1-0-3d53ae722097@cerno.tech> References: <20220728-rpi-analog-tv-properties-v1-0-3d53ae722097@cerno.tech> MIME-Version: 1.0 X-Mailer: b4 0.10.0-dev-49460 X-Developer-Signature: v=1; a=openpgp-sha256; l=7705; i=maxime@cerno.tech; h=from:subject:message-id; bh=dxW9mrioJsNatHiIFNrFz1iMtdbhBmkn433xG3w6uHA=; b=owGbwMvMwCHc4XzqmfnC7acZT6slMSQ94VHinWuzo+rGjBWZUyX1NGS3aVc8KWed33ar9crhF2t5 Be02d5SyMAhzMMiKKbJcF3xrxxcW5RbB82EzzBxWJpAhDFycAjCRVF2G/0kRc6JeSKg3+88ty3qvUS Hi5HDJUurWEc6LBx53/V3FVMPwT11riVGToXS0d02vlEmc6JIH385KNqY3XmBt//Za7Wd2DgA= X-Developer-Key: i=maxime@cerno.tech; a=openpgp; fpr=BE5675C37E818C8B5764241C254BCFC56BF6CE8D X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220729_093655_257507_32543BD1 X-CRM114-Status: GOOD ( 17.30 ) X-BeenThere: linux-amlogic@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-amlogic" Errors-To: linux-amlogic-bounces+linux-amlogic=archiver.kernel.org@lists.infradead.org From: Mateusz Kwiatkowski Add support for the following composite output modes (all of them are somewhat more obscure than the previously defined ones): - NTSC_443 - NTSC-style signal with the chroma subcarrier shifted to 4.43361875 MHz (the PAL subcarrier frequency). Never used for broadcasting, but sometimes used as a hack to play NTSC content in PAL regions (e.g. on VCRs). - PAL_N - PAL with alternative chroma subcarrier frequency, 3.58205625 MHz. Used as a broadcast standard in Argentina, Paraguay and Uruguay to fit 576i50 with colour in 6 MHz channel raster. - PAL60 - 480i60 signal with PAL-style color at normal European PAL frequency. Another non-standard, non-broadcast mode, used in similar contexts as NTSC_443. Some displays support one but not the other. - SECAM - French frequency-modulated analog color standard; also have been broadcast in Eastern Europe and various parts of Africa and Asia. Uses the same 576i50 timings as PAL. Also added some comments explaining color subcarrier frequency registers. Signed-off-by: Mateusz Kwiatkowski Signed-off-by: Maxime Ripard diff --git a/drivers/gpu/drm/vc4/vc4_vec.c b/drivers/gpu/drm/vc4/vc4_vec.c index e40b55de1b3c..91d343238b0f 100644 --- a/drivers/gpu/drm/vc4/vc4_vec.c +++ b/drivers/gpu/drm/vc4/vc4_vec.c @@ -46,6 +46,7 @@ #define VEC_CONFIG0_YDEL(x) ((x) << 26) #define VEC_CONFIG0_CDEL_MASK GENMASK(25, 24) #define VEC_CONFIG0_CDEL(x) ((x) << 24) +#define VEC_CONFIG0_SECAM_STD BIT(21) #define VEC_CONFIG0_PBPR_FIL BIT(18) #define VEC_CONFIG0_CHROMA_GAIN_MASK GENMASK(17, 16) #define VEC_CONFIG0_CHROMA_GAIN_UNITY (0 << 16) @@ -76,6 +77,27 @@ #define VEC_SOFT_RESET 0x10c #define VEC_CLMP0_START 0x144 #define VEC_CLMP0_END 0x148 + +/* + * These set the color subcarrier frequency + * if VEC_CONFIG1_CUSTOM_FREQ is enabled. + * + * VEC_FREQ1_0 contains the most significant 16-bit half-word, + * VEC_FREQ3_2 contains the least significant 16-bit half-word. + * 0x80000000 seems to be equivalent to the pixel clock + * (which itself is the VEC clock divided by 8). + * + * Reference values (with the default pixel clock of 13.5 MHz): + * + * NTSC (3579545.[45] Hz) - 0x21F07C1F + * PAL (4433618.75 Hz) - 0x2A098ACB + * PAL-M (3575611.[888111] Hz) - 0x21E6EFE3 + * PAL-N (3582056.25 Hz) - 0x21F69446 + * + * NOTE: For SECAM, it is used as the Dr center frequency, + * regardless of whether VEC_CONFIG1_CUSTOM_FREQ is enabled or not; + * that is specified as 4406250 Hz, which corresponds to 0x29C71C72. + */ #define VEC_FREQ3_2 0x180 #define VEC_FREQ1_0 0x184 @@ -118,6 +140,14 @@ #define VEC_INTERRUPT_CONTROL 0x190 #define VEC_INTERRUPT_STATUS 0x194 + +/* + * Db center frequency for SECAM; the clock for this is the same as for + * VEC_FREQ3_2/VEC_FREQ1_0, which is used for Dr center frequency. + * + * This is specified as 4250000 Hz, which corresponds to 0x284BDA13. + * That is also the default value, so no need to set it explicitly. + */ #define VEC_FCW_SECAM_B 0x198 #define VEC_SECAM_GAIN_VAL 0x19c @@ -194,9 +224,13 @@ connector_to_vc4_vec(struct drm_connector *connector) enum vc4_vec_tv_mode_id { VC4_VEC_TV_MODE_NTSC, + VC4_VEC_TV_MODE_NTSC_443, VC4_VEC_TV_MODE_NTSC_J, VC4_VEC_TV_MODE_PAL, + VC4_VEC_TV_MODE_PAL_60, VC4_VEC_TV_MODE_PAL_M, + VC4_VEC_TV_MODE_PAL_N, + VC4_VEC_TV_MODE_SECAM, }; struct vc4_vec_tv_mode { @@ -234,6 +268,12 @@ static const struct debugfs_reg32 vec_regs[] = { }; static const struct vc4_vec_tv_mode vc4_vec_tv_modes[] = { + { + .mode = DRM_MODE_TV_NORM_NTSC_443, + .config0 = VEC_CONFIG0_NTSC_STD, + .config1 = VEC_CONFIG1_C_CVBS_CVBS | VEC_CONFIG1_CUSTOM_FREQ, + .custom_freq = 0x2a098acb, + }, { .mode = DRM_MODE_TV_NORM_NTSC_M, .config0 = VEC_CONFIG0_NTSC_STD | VEC_CONFIG0_PDEN, @@ -244,6 +284,12 @@ static const struct vc4_vec_tv_mode vc4_vec_tv_modes[] = { .config0 = VEC_CONFIG0_NTSC_STD, .config1 = VEC_CONFIG1_C_CVBS_CVBS, }, + { + .mode = DRM_MODE_TV_NORM_PAL_60, + .config0 = VEC_CONFIG0_PAL_M_STD, + .config1 = VEC_CONFIG1_C_CVBS_CVBS | VEC_CONFIG1_CUSTOM_FREQ, + .custom_freq = 0x2a098acb, + }, { .mode = DRM_MODE_TV_NORM_PAL_B, .config0 = VEC_CONFIG0_PAL_BDGHI_STD, @@ -254,6 +300,17 @@ static const struct vc4_vec_tv_mode vc4_vec_tv_modes[] = { .config0 = VEC_CONFIG0_PAL_M_STD, .config1 = VEC_CONFIG1_C_CVBS_CVBS, }, + { + .mode = DRM_MODE_TV_NORM_PAL_N, + .config0 = VEC_CONFIG0_PAL_N_STD, + .config1 = VEC_CONFIG1_C_CVBS_CVBS, + }, + { + .mode = DRM_MODE_TV_NORM_SECAM_B, + .config0 = VEC_CONFIG0_SECAM_STD, + .config1 = VEC_CONFIG1_C_CVBS_CVBS, + .custom_freq = 0x29c71c72, + }, }; static inline const struct vc4_vec_tv_mode * @@ -273,9 +330,13 @@ vc4_vec_tv_mode_lookup(unsigned int mode) static const struct drm_prop_enum_list tv_mode_names[] = { { VC4_VEC_TV_MODE_NTSC, "NTSC", }, + { VC4_VEC_TV_MODE_NTSC_443, "NTSC-443", }, { VC4_VEC_TV_MODE_NTSC_J, "NTSC-J", }, { VC4_VEC_TV_MODE_PAL, "PAL", }, + { VC4_VEC_TV_MODE_PAL_60, "PAL-60", }, { VC4_VEC_TV_MODE_PAL_M, "PAL-M", }, + { VC4_VEC_TV_MODE_PAL_N, "PAL-N", }, + { VC4_VEC_TV_MODE_SECAM, "SECAM", }, }; static enum drm_connector_status @@ -329,6 +390,10 @@ vc4_vec_connector_set_property(struct drm_connector *connector, state->tv.norm = DRM_MODE_TV_NORM_NTSC_M; break; + case VC4_VEC_TV_MODE_NTSC_443: + state->tv.norm = DRM_MODE_TV_NORM_NTSC_443; + break; + case VC4_VEC_TV_MODE_NTSC_J: state->tv.norm = DRM_MODE_TV_NORM_NTSC_J; break; @@ -337,10 +402,22 @@ vc4_vec_connector_set_property(struct drm_connector *connector, state->tv.norm = DRM_MODE_TV_NORM_PAL_B; break; + case VC4_VEC_TV_MODE_PAL_60: + state->tv.norm = DRM_MODE_TV_NORM_PAL_60; + break; + case VC4_VEC_TV_MODE_PAL_M: state->tv.norm = DRM_MODE_TV_NORM_PAL_M; break; + case VC4_VEC_TV_MODE_PAL_N: + state->tv.norm = DRM_MODE_TV_NORM_PAL_N; + break; + + case VC4_VEC_TV_MODE_SECAM: + state->tv.norm = DRM_MODE_TV_NORM_SECAM_B; + break; + default: return -EINVAL; } @@ -360,6 +437,10 @@ vc4_vec_connector_get_property(struct drm_connector *connector, return -EINVAL; switch (state->tv.norm) { + case DRM_MODE_TV_NORM_NTSC_443: + *val = VC4_VEC_TV_MODE_NTSC_443; + break; + case DRM_MODE_TV_NORM_NTSC_J: *val = VC4_VEC_TV_MODE_NTSC_J; break; @@ -368,6 +449,10 @@ vc4_vec_connector_get_property(struct drm_connector *connector, *val = VC4_VEC_TV_MODE_NTSC; break; + case DRM_MODE_TV_NORM_PAL_60: + *val = VC4_VEC_TV_MODE_PAL_60; + break; + case DRM_MODE_TV_NORM_PAL_B: *val = VC4_VEC_TV_MODE_PAL; break; @@ -376,6 +461,14 @@ vc4_vec_connector_get_property(struct drm_connector *connector, *val = VC4_VEC_TV_MODE_PAL_M; break; + case DRM_MODE_TV_NORM_PAL_N: + *val = VC4_VEC_TV_MODE_PAL_N; + break; + + case DRM_MODE_TV_NORM_SECAM_B: + *val = VC4_VEC_TV_MODE_SECAM; + break; + default: return -EINVAL; } @@ -605,10 +698,13 @@ static int vc4_vec_bind(struct device *dev, struct device *master, void *data) int ret; ret = drm_mode_create_tv_properties(drm, + DRM_MODE_TV_NORM_NTSC_443 | DRM_MODE_TV_NORM_NTSC_J | DRM_MODE_TV_NORM_NTSC_M | DRM_MODE_TV_NORM_PAL_B | - DRM_MODE_TV_NORM_PAL_M, + DRM_MODE_TV_NORM_PAL_M | + DRM_MODE_TV_NORM_PAL_N | + DRM_MODE_TV_NORM_SECAM_B, 0, NULL); if (ret) return ret;