Received: by 2002:ac0:e350:0:0:0:0:0 with SMTP id g16csp440081imn; Fri, 29 Jul 2022 11:36:30 -0700 (PDT) X-Google-Smtp-Source: AGRyM1vu746AbjngnLfsoeqUeuw9tSXXArXUnlxaLwYeXzKeLTzF+n0/EDMf5CW1dv3D9tAZW6+3 X-Received: by 2002:a17:907:9803:b0:72e:ec55:b2a5 with SMTP id ji3-20020a170907980300b0072eec55b2a5mr3824276ejc.347.1659119789781; Fri, 29 Jul 2022 11:36:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1659119789; cv=none; d=google.com; s=arc-20160816; b=N2cIeXVclASgYrirYDD9u7LtEceS6GIKGnVAi1sDpnwG1RbAKnfCzi0QdHyqCqGjOi FnwO6yykBt+Ys1/fSzWM6j90tkFZAoKG+MYwoAQEddX1O6oZ/dZpy5XUdHp9xKaL9XGJ QdQliI4pRYKzEhQ8rKfJmj2WSJMBGzBvrJw0JoucvoMxObILQI5F2ZKD7FRK5pJZ9VfA rvMyckGmxo7/w/hzhY88iFR2zk0fP/Bs6KUgzYtpaGa+5dbFHyGTsBu/zAPc215ooD0O 8ln1lM1JWwVsjh7wDsaUJq8E9a9jz9ATuekKZtUYn51PLgGh8XoODqJjENtwDjkmoX8/ Bb/A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:references :cc:to:content-language:subject:user-agent:mime-version:date :message-id:from:dkim-signature; bh=3hZoGcnHaEkT19lBYfPsFJqwMI5QsjzTbPWXqwhHM3E=; b=VuxNFsRdkGI0mor07q8IsMNuXyfvAwnCkxp4raDtJ2xzIzVMtlyVMjDunoDWBQ9thN TSXXydH+5429Hp/TWD+HFcxfk36hf+akbmfwmVQjKaj+sLJyYKFkHFNVwWUZWdIQh3SU DLNTwzU6/vsxzoYMxCQkP3/VXewgTs2NcmejCfM1HZzVavCXVIcuKAhtG74EHelhQiTm DwWHwnrqBtR1rtTavNQ8IWNPq2rYErUIzjDzN1TB6IJAmmf25ksiMzuHYztl45Rf6ViA rbEH+dxKiqcT39FRtR41EY5U6U5GxQgjF/vWhiWCIDwgG61L6JNROMSdhVQ4jIUxB5Ao M1nA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=E70UUusX; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id e16-20020a056402191000b0043bc38b99a2si4493300edz.199.2022.07.29.11.36.04; Fri, 29 Jul 2022 11:36:29 -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=@gmail.com header.s=20210112 header.b=E70UUusX; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238435AbiG2Rzm (ORCPT + 99 others); Fri, 29 Jul 2022 13:55:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35930 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238394AbiG2Rzi (ORCPT ); Fri, 29 Jul 2022 13:55:38 -0400 Received: from mail-lf1-x12b.google.com (mail-lf1-x12b.google.com [IPv6:2a00:1450:4864:20::12b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0B7F17B1DE for ; Fri, 29 Jul 2022 10:55:37 -0700 (PDT) Received: by mail-lf1-x12b.google.com with SMTP id c7so3726012lfr.12 for ; Fri, 29 Jul 2022 10:55:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:message-id:date:mime-version:user-agent:subject :content-language:to:cc:references:in-reply-to :content-transfer-encoding; bh=3hZoGcnHaEkT19lBYfPsFJqwMI5QsjzTbPWXqwhHM3E=; b=E70UUusXp0IxJmxxMTw9fUL//Arj/3xoFgMx9YrcdAFabC9DoAAKfTXe6O+ub88Xf0 XDFA3aD1noc5bsW149fUO8zQLnUACJ+lkVq0I5XgtUL+rxd41g6yYiwq4BouVyduNNPG PBz9xwmtwhsWL4VPFVQbiMpp8AlokIot68yc6gAI33IhzUioDBCPKE9BZjhXspQyceG2 qxTy5FNGPlV925pMrKwIIaz9NHtneW4phjFnDk0dAT2FY+4rbq/uLDKMV9+M7oCprW0R TClGWoj75pYZTnbQNhzqsEoAjRGP1XrrcGAvr9Mg6sTwB31Z9/Bo1tO84UURjDkv6AXW Z1CQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:message-id:date:mime-version:user-agent :subject:content-language:to:cc:references:in-reply-to :content-transfer-encoding; bh=3hZoGcnHaEkT19lBYfPsFJqwMI5QsjzTbPWXqwhHM3E=; b=lYN3Lq2eDxFhsItDHcQ2poeAwxK75Ccqg9DgxCHZ1yOcg+lFbqtvUeDwY1V/7kAFLZ dyny5eWSZHvSXtS+UaVCIP7aLhaWFiE7ZdQxi6RxIYiKBT7ALqYfLyDcQ3N30M9mIGYD FS+I9Z+4xB+LurOS3+o3bJWHgR3aLpWgnVhvMgNnpery/aB1JYIYXEpAIYnDRPhdUXmn wCTUHwqcuIvsTQWOWUk80ilPPH+P9xtQ7kIaBPOzszHN2imDsZck12Zr0CZFM47obv0Z NxTnFRJXe0PnzEWoYVVoQkR3iRlwGpm5B8EXB3DncI/cjWLVsoSCbSCtXjpTmVTGkM2R Jhxg== X-Gm-Message-State: AJIora+ab/+l7kP9EWyR4bN4+TCT4/aaRt7ZlRJawfM2JjX4Vx7JF1dl wUCdSbnXzpuvkTKunXQ9wsU= X-Received: by 2002:a05:6512:1054:b0:48a:a4ef:257b with SMTP id c20-20020a056512105400b0048aa4ef257bmr1554975lfb.425.1659117335148; Fri, 29 Jul 2022 10:55:35 -0700 (PDT) Received: from [192.168.177.6] (public-gprs370360.centertel.pl. [37.47.77.249]) by smtp.googlemail.com with ESMTPSA id x5-20020a19e005000000b0048ad0ca34cdsm540546lfg.187.2022.07.29.10.55.31 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 29 Jul 2022 10:55:34 -0700 (PDT) From: Mateusz Kwiatkowski X-Google-Original-From: Mateusz Kwiatkowski Message-ID: <0e7bebe2-3f45-0a1b-a4b6-bb783f8de7b6@gmail.com> Date: Fri, 29 Jul 2022 19:55:30 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.1.0 Subject: Re: [PATCH v1 24/35] drm/vc4: vec: Add support for more analog TV standards Content-Language: pl To: Maxime Ripard , 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=c3=b8nnes?= , Kevin Hilman , Neil Armstrong , Maxime Ripard Cc: linux-sunxi@lists.linux.dev, linux-kernel@vger.kernel.org, Phil Elwell , linux-arm-kernel@lists.infradead.org, Geert Uytterhoeven , Dave Stevenson , linux-amlogic@lists.infradead.org, dri-devel@lists.freedesktop.org, Dom Cobley References: <20220728-rpi-analog-tv-properties-v1-0-3d53ae722097@cerno.tech> <20220728-rpi-analog-tv-properties-v1-24-3d53ae722097@cerno.tech> In-Reply-To: <20220728-rpi-analog-tv-properties-v1-24-3d53ae722097@cerno.tech> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,NICE_REPLY_A, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,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 Hi Maxime, I think that declaring PAL-B and SECAM-B as the only supported 576i norms is a bit random. Norms B, D, G, H, I, K, K1 and L (for both PAL and SECAM) are essentially identical if we're talking about baseband signals, AFAIK they only differ when those are modulated as RF signals. I'm not sure if there's a point to differentiating those (that's more about patch 05/35) unless we need to deal with some device that actually features an RF modulator. But if we do want to have all those norms separate, then I'd say that VC4 should declare support for all of those, and all should map to the same VEC settings. Some users from e.g. the UK might think that they won't get proper picture if PAL-I is not on the list of supported norms. Same goes for e.g. SECAM-D/K in the former Soviet territories, and so on. Best regards, Mateusz Kwiatkowski W dniu 29.07.2022 o 18:35, Maxime Ripard pisze: > 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; >