Received: by 2002:ac0:e350:0:0:0:0:0 with SMTP id g16csp395542imn; Fri, 29 Jul 2022 10:07:22 -0700 (PDT) X-Google-Smtp-Source: AA6agR5mkTY3hh7sCpboY5t/ph132Nkd6rGFMcGw4TFh8pgVDNgtWm7TD8X34JGE4KrAWeBXdmfI X-Received: by 2002:a17:902:ea0b:b0:16d:d268:e4c5 with SMTP id s11-20020a170902ea0b00b0016dd268e4c5mr3898840plg.152.1659114442538; Fri, 29 Jul 2022 10:07:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1659114442; cv=none; d=google.com; s=arc-20160816; b=Nyyjzrt047keMmVYn87uxhqR77ll+Z80tIxZYs9Aaf0NdNCeyZqKJU7h4cGR8K89o4 1mgH8brRi69cLk2E9u1NJZFSdpZTWr558PUCaaJ5ySW3fizlL3X4eXJd3I0WtkRbpAU0 mW6ZL473eirdKO40Iy6FeFU7rqusfFBgVRask5ZMUPjIeZruRsXirkvtnpzclJ+HgqLc GY02Xw15b3s9XIz86+jr/MXyEExu1gLSuF/kKK5Gz+78MB1GesxQ7rjfHSMjM0pzG/n6 HGeVii79JmlmHIyZWRACxSiMVtgtDAKX3RJvvN/okFlLPfpMff4oH8d9CVCdKbNAhWXq wBkg== 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:cc:to:from :feedback-id:dkim-signature:dkim-signature; bh=whvPVVthKbSxDiFpQbK45mdHTwISFKL9gD5bt0ROd6s=; b=yJoOYGgCDLE9Tt2CEKUCP3jD/V/TNh0JMZBScbEaDE+cBYMjissC/3Zxt/ExzMWOZ9 fobGKj9MA1ddpNcqDKiZPJnDEahEnNyAZX1ogWhI+nhfrwkGYrwv8rMOKLduIg7wVqkM GBUrxX9shk1LS8fXekwl8lZTP9arpY/bfjiqNMjqfC+2iA+UgcyCknazRUy8SVXBYsnF 3FHZuMtIePbOQFTlBmADEzn9H0+XWFTHRNFeUIL+l0IABeBkE+tO2yI/UBaz1qhvAfzz ZS16H9VUb7cXZVlvSkXoqfrMTmjPKmbpwTmcziSBHtNmdWlw9a9Jj+2jrF3xCbJ8JtJT R9Rg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@cerno.tech header.s=fm2 header.b=l7BGo0DX; dkim=pass header.i=@messagingengine.com header.s=fm3 header.b=vihTe8Dt; 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 u10-20020a17090a2b8a00b001e858081883si8412690pjd.64.2022.07.29.10.07.07; Fri, 29 Jul 2022 10:07:22 -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=l7BGo0DX; dkim=pass header.i=@messagingengine.com header.s=fm3 header.b=vihTe8Dt; 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 S237397AbiG2QhR (ORCPT + 99 others); Fri, 29 Jul 2022 12:37:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53422 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237051AbiG2Qgz (ORCPT ); Fri, 29 Jul 2022 12:36:55 -0400 Received: from new4-smtp.messagingengine.com (new4-smtp.messagingengine.com [66.111.4.230]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 08C2F823BB for ; Fri, 29 Jul 2022 09:36:54 -0700 (PDT) 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=20Tr=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 Content-Type: text/plain; charset="utf-8" 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 Content-Transfer-Encoding: 8bit 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 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 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; -- b4 0.10.0-dev-49460