Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp3539760rwi; Sun, 16 Oct 2022 13:01:48 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5FFVOoQU7al8l6klQazX/mCNWc5UhidgE0DdBFsFeKR/ZeM+cooPqruCGymif575oJfQ4v X-Received: by 2002:a17:906:99c2:b0:78d:b5cf:419e with SMTP id s2-20020a17090699c200b0078db5cf419emr6281536ejn.673.1665950508381; Sun, 16 Oct 2022 13:01:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665950508; cv=none; d=google.com; s=arc-20160816; b=Z3L3RLO4LIzEq4E5lnZUajJYe6V/s4JHW93FURVZ8EUE3lYVQeSA1CV8AoslFzcfvL BsmAcWJBpmR1ttAPHQrfwPhshRs7G9xsjRonYrdxB40zTAQZj5j/Iotr4fLqc6K2v341 lVWlUOyj+rtAVQ8YB4NcDdcfDsJsNei/p4GDKE4B5aH/n04Lyol8t2Wmf0Vf+pmbVgDM MZD3ixdidk7xgymd8JuhCXszqflQ5kS5ye1qt6dB6Vn8gRmPon6SK+gb8uSp20F5ouoE A2p2xmKFnLje3kRI2TzPYu0U9yh4igEmwNm6QJIDY7zuEeuZByfLyCuwZp9LFtWV6ZbK NDKQ== 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 :content-language:references:cc:to:reply-to:subject:user-agent :mime-version:date:message-id:from:dkim-signature; bh=rdVj1UN0o7hBjGsw3GcLX/7HhNhpR9GEsvnCZKA7nWc=; b=VRcHilGog2zM38yvhi/kUPFLKnR+WAYr95OGfHjYkoTY9K2Mw+HRyQ4gKe2Tl/MbR2 dJwKsDTHque2KqyoD9oDr+IpbCjZX6fXsQhToE67g/CgwW0QeBVbJ60/MsCdGeTQxEI5 hm6U8liYVM1ENaijhwFFUt8MUSMwpjUOT01ieAMupoXJIqrwQkMxJuL024gGKHOXmG1H KK0efTjiNaQaKhyPYLwj8nELWlB6qWbc9JIsvdAyI9HrxtFCEPxcYKfQqHRoU6yYI/z7 XZywFLKr//juWy6aeIvdyKDKSp4otpCQVzp+hd0cuQt3I5gnLUtuwdkQ/lpV7a6FAZwy cXEw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=eVN1P5+2; 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 qk41-20020a1709077fa900b0078a9b8764besi955678ejc.951.2022.10.16.13.01.21; Sun, 16 Oct 2022 13:01:48 -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=eVN1P5+2; 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 S229790AbiJPTq6 (ORCPT + 99 others); Sun, 16 Oct 2022 15:46:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53404 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229754AbiJPTqz (ORCPT ); Sun, 16 Oct 2022 15:46:55 -0400 Received: from mail-lj1-x234.google.com (mail-lj1-x234.google.com [IPv6:2a00:1450:4864:20::234]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 383E125EA2 for ; Sun, 16 Oct 2022 12:46:54 -0700 (PDT) Received: by mail-lj1-x234.google.com with SMTP id a6so11728908ljq.5 for ; Sun, 16 Oct 2022 12:46:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:in-reply-to:content-language:references :cc:to:reply-to:subject:user-agent:mime-version:date:message-id:from :from:to:cc:subject:date:message-id:reply-to; bh=rdVj1UN0o7hBjGsw3GcLX/7HhNhpR9GEsvnCZKA7nWc=; b=eVN1P5+2pEF2Kv5B+7kulfpYcRS0ij67wC56op/K7MTJ9oxjts1NiTMiIXhKUDDNWi pClfrmUFwjCqFPiUh9t2aylgpS617BHukulA8IRkFt9jDfyhzBKacR80dEuWIW7uIlru /7BkEkGFXjpHuS1qNFxkES8QosHRpMbXUy57JWaDtK7v16WG53LkwTEneJfdabTIa/BN tiKFs3N7vSqtH+nQdskgF32wMLK/xbHFx7HwRH0BnJoukpb40vsXARUD3MnEbG+bDYhz DATYteNjfpgFflZS3rzy15d+9+CYLsfO1pfLasECYyV6UjYiuhHDXbmsrtY0P6dvd6aq O6Bw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:content-language:references :cc:to:reply-to:subject:user-agent:mime-version:date:message-id:from :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=rdVj1UN0o7hBjGsw3GcLX/7HhNhpR9GEsvnCZKA7nWc=; b=I7yfYxP0wJpWV/SjrywSKFYKQhWniAuaQ/rWUkgM1bTKfD/IgFhV/UQO1FlzvYUiVZ 4ZbLMxHlWqmIGqgA9g1tYORRq+akymF26osMXxx/+0nZ7cxz48uHEm876RwNetvaZgzH AeRMqsD4pQTgaYHlQaOdPTl7TViIprhj/saWxcF5ROey+KUuhce4EFWNV5CFYG0JNrdV ZQBaVK/az/QyrVk3eOkiBowmn3BXNGgMLL1+l8HkMkStAmHPYCQMjujuViNKcvfVnK3H bEzE7er88MQ5ZQXjnrZJkDi+Na68mttNH+wHX4dX0RYE2cCobmQq6WzZ5JUZ5e1Fbujy YOvg== X-Gm-Message-State: ACrzQf2FGaULSvWzXC0L+SryoisuMHhgtSoTmbjAQxqYpHm6C88vubl8 Ura/Z4k+qih09EhVnpMur3U= X-Received: by 2002:a05:651c:198a:b0:26f:b54d:e239 with SMTP id bx10-20020a05651c198a00b0026fb54de239mr2691447ljb.421.1665949612500; Sun, 16 Oct 2022 12:46:52 -0700 (PDT) Received: from ?IPV6:2a02:a31a:a240:1700:64bb:87df:aad7:a9f0? ([2a02:a31a:a240:1700:64bb:87df:aad7:a9f0]) by smtp.googlemail.com with ESMTPSA id k14-20020ac2456e000000b004948378080csm1141576lfm.290.2022.10.16.12.46.50 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 16 Oct 2022 12:46:51 -0700 (PDT) From: Mateusz Kwiatkowski X-Google-Original-From: Mateusz Kwiatkowski Message-ID: <93bf9fcc-c645-b042-011f-8f1fc957af48@gmail.com> Date: Sun, 16 Oct 2022 21:46:49 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.3.3 Subject: [PATCH] drm/vc4: vec: Add support for PAL-60 Reply-To: kfyatek+publicgit@gmail.com To: Maxime Ripard , Karol Herbst , Jani Nikula , Tvrtko Ursulin , Daniel Vetter , Maarten Lankhorst , David Airlie , Joonas Lahtinen , Lyude Paul , Maxime Ripard , Emma Anholt , Chen-Yu Tsai , Samuel Holland , Ben Skeggs , Thomas Zimmermann , Rodrigo Vivi , Jernej Skrabec Cc: Dom Cobley , linux-sunxi@lists.linux.dev, Dave Stevenson , =?UTF-8?Q?Noralf_Tr=c3=b8nnes?= , intel-gfx@lists.freedesktop.org, linux-kernel@vger.kernel.org, nouveau@lists.freedesktop.org, Geert Uytterhoeven , linux-arm-kernel@lists.infradead.org, dri-devel@lists.freedesktop.org, Hans de Goede , Phil Elwell References: <20220728-rpi-analog-tv-properties-v5-0-d841cc64fe4b@cerno.tech> <20220728-rpi-analog-tv-properties-v5-21-d841cc64fe4b@cerno.tech> Content-Language: pl In-Reply-To: <20220728-rpi-analog-tv-properties-v5-21-d841cc64fe4b@cerno.tech> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-1.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,FREEMAIL_REPLYTO, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=no 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 Add support for the PAL-60 mode. Because there is no separate TV mode property value for PAL-60, this requires matching the settings based on the modeline in addition to just that property alone. Signed-off-by: Mateusz Kwiatkowski --- This patch depends on patch '[PATCH v5 21/22] drm/vc4: vec: Add support for more analog TV standards' submitted by Maxime Ripard (https://lore.kernel.org/dri-devel/20220728-rpi-analog-tv-properties-v5-21-d841cc64fe4b@cerno.tech/). To Maxime: if you decide to post v6, feel free to include this in your patchset instead if you want. --- drivers/gpu/drm/vc4/vc4_vec.c | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/vc4/vc4_vec.c b/drivers/gpu/drm/vc4/vc4_vec.c index 88b4330bfa39..bbc41e502cc3 100644 --- a/drivers/gpu/drm/vc4/vc4_vec.c +++ b/drivers/gpu/drm/vc4/vc4_vec.c @@ -235,6 +235,7 @@ enum vc4_vec_tv_mode_id { struct vc4_vec_tv_mode { unsigned int mode; + u16 expected_htotal; u32 config0; u32 config1; u32 custom_freq; @@ -270,37 +271,52 @@ static const struct debugfs_reg32 vec_regs[] = { static const struct vc4_vec_tv_mode vc4_vec_tv_modes[] = { { .mode = DRM_MODE_TV_MODE_NTSC, + .expected_htotal = 858, .config0 = VEC_CONFIG0_NTSC_STD | VEC_CONFIG0_PDEN, .config1 = VEC_CONFIG1_C_CVBS_CVBS, }, { .mode = DRM_MODE_TV_MODE_NTSC_443, + .expected_htotal = 858, .config0 = VEC_CONFIG0_NTSC_STD, .config1 = VEC_CONFIG1_C_CVBS_CVBS | VEC_CONFIG1_CUSTOM_FREQ, .custom_freq = 0x2a098acb, }, { .mode = DRM_MODE_TV_MODE_NTSC_J, + .expected_htotal = 858, .config0 = VEC_CONFIG0_NTSC_STD, .config1 = VEC_CONFIG1_C_CVBS_CVBS, }, { .mode = DRM_MODE_TV_MODE_PAL, + .expected_htotal = 864, .config0 = VEC_CONFIG0_PAL_BDGHI_STD, .config1 = VEC_CONFIG1_C_CVBS_CVBS, }, + { + /* PAL-60 */ + .mode = DRM_MODE_TV_MODE_PAL, + .expected_htotal = 858, + .config0 = VEC_CONFIG0_PAL_M_STD, + .config1 = VEC_CONFIG1_C_CVBS_CVBS | VEC_CONFIG1_CUSTOM_FREQ, + .custom_freq = 0x2a098acb, + }, { .mode = DRM_MODE_TV_MODE_PAL_M, + .expected_htotal = 858, .config0 = VEC_CONFIG0_PAL_M_STD, .config1 = VEC_CONFIG1_C_CVBS_CVBS, }, { .mode = DRM_MODE_TV_MODE_PAL_N, + .expected_htotal = 864, .config0 = VEC_CONFIG0_PAL_N_STD, .config1 = VEC_CONFIG1_C_CVBS_CVBS, }, { .mode = DRM_MODE_TV_MODE_SECAM, + .expected_htotal = 864, .config0 = VEC_CONFIG0_SECAM_STD, .config1 = VEC_CONFIG1_C_CVBS_CVBS, .custom_freq = 0x29c71c72, @@ -308,14 +324,15 @@ static const struct vc4_vec_tv_mode vc4_vec_tv_modes[] = { }; static inline const struct vc4_vec_tv_mode * -vc4_vec_tv_mode_lookup(unsigned int mode) +vc4_vec_tv_mode_lookup(unsigned int mode, u16 htotal) { unsigned int i; for (i = 0; i < ARRAY_SIZE(vc4_vec_tv_modes); i++) { const struct vc4_vec_tv_mode *tv_mode = &vc4_vec_tv_modes[i]; - if (tv_mode->mode == mode) + if (tv_mode->mode == mode && + tv_mode->expected_htotal == htotal) return tv_mode; } @@ -394,6 +411,7 @@ vc4_vec_connector_set_property(struct drm_connector *connector, break; case VC4_VEC_TV_MODE_PAL: + case VC4_VEC_TV_MODE_PAL_60: state->tv.mode = DRM_MODE_TV_MODE_PAL; break; @@ -551,13 +569,16 @@ static void vc4_vec_encoder_enable(struct drm_encoder *encoder, struct drm_connector *connector = &vec->connector; struct drm_connector_state *conn_state = drm_atomic_get_new_connector_state(state, connector); + struct drm_display_mode *adjusted_mode = + &encoder->crtc->state->adjusted_mode; const struct vc4_vec_tv_mode *tv_mode; int idx, ret; if (!drm_dev_enter(drm, &idx)) return; - tv_mode = vc4_vec_tv_mode_lookup(conn_state->tv.mode); + tv_mode = vc4_vec_tv_mode_lookup(conn_state->tv.mode, + adjusted_mode->htotal); if (!tv_mode) goto err_dev_exit; base-commit: e16415e3ddae9abb14a00793554a162403f9af6d -- 2.34.1