From patchwork Sun Oct 16 19:46:49 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mateusz Kwiatkowski X-Patchwork-Id: 3147 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp1135992wrs; Sun, 16 Oct 2022 13:00:55 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7OHoNh0tb/FQ51IvLb3zXQcO8DF5kBM1AldWWtunz8v360mvShu7FD12F/QDloe2a8F+yk X-Received: by 2002:a17:907:708:b0:77e:ff47:34b1 with SMTP id xb8-20020a170907070800b0077eff4734b1mr5958462ejb.493.1665950455327; Sun, 16 Oct 2022 13:00:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665950455; cv=none; d=google.com; s=arc-20160816; b=TA5B/M1qcIxg6/WeSx7dD7D/1ppzeEBj1cEHp0ppnhn3RZXdVXQQeebDO6OC1HsfHy tvx1aHBQ5pM/a8IpUCVim+YpM/RvWjPJSFdhVjGUDKncOSKKvUl5jCWcwAQLR28bqp3j gBgoOz/edMEk22kYPmtRTJ2KC8B3ZW3iSNAY48haMcXbMe7lvsims66c/ieoKyl6HFqV AFO3/kT78M5lnra5WvBc9kxcGu2oq+CzlDx31KGlp1Cqx+144D6n7cVl28nco9xj4SA5 hm9bhCd2CwB9aMdw4WEEGy5t30u2eJ4rqAsDwzEKvDOiLN929bmc88FtzIGq9NQAD4ao xVgQ== 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 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.00.25; Sun, 16 Oct 2022 13:00:55 -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=B8n?= =?utf-8?q?nes?= , 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> 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1746875664639828965?= X-GMAIL-MSGID: =?utf-8?q?1746875664639828965?= 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(-) base-commit: e16415e3ddae9abb14a00793554a162403f9af6d 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;