Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp375481pxj; Fri, 7 May 2021 10:29:20 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwQhiz6NXZCIiT5Gx1bLxPaBB/MfvQIRoLP/3NcUcs7e46DZxgQAbTdikgvFj34Ikvf3vwW X-Received: by 2002:a17:906:c14c:: with SMTP id dp12mr11048265ejc.312.1620408560251; Fri, 07 May 2021 10:29:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620408560; cv=none; d=google.com; s=arc-20160816; b=u7AaGrXLz95V/xfaZR46XsNV+gv26CJnY5WbqNtIntYmNrUSBjz5yvEGR/bLkN3tFZ nZ+OMdC6erOXQsAD1glri1QV5n5KQTfTJMB3CW+mnfr4XBWjKxjt13Xp+5eV8qGyPD8w zckIgE33yp3u99do5c+DVeowZmLzan0lvimzgMHjkSit1SLASnKth1oK/xu0QC6hAALa d8sn1WaGRwSUxAI1yQWEvASKQZqOz7kHUTJ6f16vMLKk97MSxWI/HEoFeycyg9L0gL0t Ah/nqHfJcTzi0C0sDRO2vzUSrpvFeKB4VyuvoiywnRRkGRz4BJl3WcYl4u1CZMEFSqIx B/iA== 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 :dkim-signature:dkim-signature; bh=JyD5t6WMst8BqzCSoV9Z3JsakQ2ZIXpXMQ4jgAIt2oQ=; b=pnqE83WM8TXU4ebqcZ5crALedOYtfDzqJ4WhhGCM90lOaBDDYJQ24Vpmse16YCMS2W GKxBY+Koj0zVNDIEHN5+lAz2CS/nFOxWhEIfurnD444213XeAYrrl5PXcM7JVxQXiRhJ lOejpVmcGCst8a9eOCQEiryx8VSgE3ioDWALT1FTDcfDmoX7LEiZ3+kpqutZp2CO4kGA m7tdL80i9sXlzoTw/47JNqxvqcnvbZOf/v3//nrxmoVvSyyMyJHO1hjCP/H+ArBwgHQb euAvYICQ+iJlB/b8ux6nJva3XWlZC7DsvqRs4ZcGnw/50kFpnO/3rfKNwl/QQ1dfUvh2 uZEQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@cerno.tech header.s=fm2 header.b="YzIWYS/7"; dkim=pass header.i=@messagingengine.com header.s=fm2 header.b=gLNOBXp4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id e9si5504944edc.514.2021.05.07.10.28.55; Fri, 07 May 2021 10:29:20 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@cerno.tech header.s=fm2 header.b="YzIWYS/7"; dkim=pass header.i=@messagingengine.com header.s=fm2 header.b=gLNOBXp4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S237894AbhEGPHk (ORCPT + 99 others); Fri, 7 May 2021 11:07:40 -0400 Received: from wnew4-smtp.messagingengine.com ([64.147.123.18]:44371 "EHLO wnew4-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237835AbhEGPHK (ORCPT ); Fri, 7 May 2021 11:07:10 -0400 Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailnew.west.internal (Postfix) with ESMTP id 6FCA513F4; Fri, 7 May 2021 11:06:09 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute1.internal (MEProxy); Fri, 07 May 2021 11:06:10 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cerno.tech; h= from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; s=fm2; bh=JyD5t6WMst8Bq zCSoV9Z3JsakQ2ZIXpXMQ4jgAIt2oQ=; b=YzIWYS/7nsIMbwYecrk5YfEX+hIxk kk2AJomAFymwIqmEGkgto/a5dN0qu5s1sBEvqgoqJNIqgNWyhA3SuE9OTKrz0cyw rOk2tgfe3LKurHsAdomo+Dvql1+JfhzLQ3dY8tO+mcfLdv5mF47ZWMEB/oaKfKwt JSeicsLRO29PJ+6NjY6fSseC9ax0ouhDywj0nWk1h3Qx3xA6024KLfmk6wwnc+RL t4XImxCHv6OEot1Aq8gWikchZ+yplsfcGWwXATYC1El1kkzDtm65PZ3pzAHhjIgA RPInU6gpnVGqx9w12Oe27dOictsMMjqC+6P5JmAxOWiK8pTrnKSiIdC0w== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:date:from :in-reply-to:message-id:mime-version:references:subject:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm2; bh=JyD5t6WMst8BqzCSoV9Z3JsakQ2ZIXpXMQ4jgAIt2oQ=; b=gLNOBXp4 6PELVWvfDslU4mLUkLiIuq9OhHnhMNScaoeLjq9SO3PFYoI6OZHtUk94n7iAz6VO +buw0uUK1EGkvY6eOsmnHTwPT78ncxkpeU6gAJbCOJuKy7NAhmJAeUujIuFZS+ts d1OqWy0TK4La5NbFHBtwIu2ZXmNOwAsXuJ7fKxWThWKhAcrEtWVfh5ifyIcXrLDl g539NQdvOz1KmGLHgEYO9MKoWgtRyDxwEmpIaCQS6Dz8M8O66aLkXGFEttqUQsSw 04Dbphe1GsmJQ0cse5Ay7Ramo7n+vXKSNZH494lwbqNVg0444CZftYAOqf+U0VqU 918nVIqNTcMifg== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduledrvdegvddgkeegucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvufffkffojghfggfgsedtkeertdertddtnecuhfhrohhmpeforgigihhm vgcutfhiphgrrhguuceomhgrgihimhgvsegtvghrnhhordhtvggthheqnecuggftrfgrth htvghrnhepvdekleevfeffkeejhfffueelteelfeduieefheduudfggffhhfffheevveeh hedvnecukfhppeeltddrkeelrdeikedrjeeinecuvehluhhsthgvrhfuihiivgepgeenuc frrghrrghmpehmrghilhhfrhhomhepmhgrgihimhgvsegtvghrnhhordhtvggthh X-ME-Proxy: Received: from localhost (lfbn-tou-1-1502-76.w90-89.abo.wanadoo.fr [90.89.68.76]) by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 7 May 2021 11:06:06 -0400 (EDT) From: Maxime Ripard To: Maarten Lankhorst , Thomas Zimmermann , Maxime Ripard , dri-devel@lists.freedesktop.org, Daniel Vetter , David Airlie Cc: Eric Anholt , Nicolas Saenz Julienne , bcm-kernel-feedback-list@broadcom.com, linux-rpi-kernel@lists.infradead.org, Dave Stevenson , Phil Elwell , Tim Gover , Dom Cobley , linux-kernel@vger.kernel.org Subject: [PATCH v4 09/12] drm/vc4: hdmi: Check and warn if we can't reach 4kp60 frequencies Date: Fri, 7 May 2021 17:05:12 +0200 Message-Id: <20210507150515.257424-10-maxime@cerno.tech> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210507150515.257424-1-maxime@cerno.tech> References: <20210507150515.257424-1-maxime@cerno.tech> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In order to reach the frequencies needed to output at 594MHz, the firmware needs to be configured with the appropriate parameters in the config.txt file (enable_hdmi_4kp60 and force_turbo). Let's detect it at bind time, warn the user if we can't, and filter out the relevant modes. Acked-by: Thomas Zimmermann Reviewed-by: Dave Stevenson Signed-off-by: Maxime Ripard --- drivers/gpu/drm/vc4/vc4_hdmi.c | 31 +++++++++++++++++++++++++++++++ drivers/gpu/drm/vc4/vc4_hdmi.h | 8 ++++++++ 2 files changed, 39 insertions(+) diff --git a/drivers/gpu/drm/vc4/vc4_hdmi.c b/drivers/gpu/drm/vc4/vc4_hdmi.c index c50dc5a59b2f..01d24ce8a795 100644 --- a/drivers/gpu/drm/vc4/vc4_hdmi.c +++ b/drivers/gpu/drm/vc4/vc4_hdmi.c @@ -94,6 +94,11 @@ #define HDMI_14_MAX_TMDS_CLK (340 * 1000 * 1000) +static bool vc4_hdmi_mode_needs_scrambling(const struct drm_display_mode *mode) +{ + return (mode->clock * 1000) > HDMI_14_MAX_TMDS_CLK; +} + static int vc4_hdmi_debugfs_regs(struct seq_file *m, void *unused) { struct drm_info_node *node = (struct drm_info_node *)m->private; @@ -210,6 +215,18 @@ static int vc4_hdmi_connector_get_modes(struct drm_connector *connector) ret = drm_add_edid_modes(connector, edid); kfree(edid); + if (vc4_hdmi->disable_4kp60) { + struct drm_device *drm = connector->dev; + struct drm_display_mode *mode; + + list_for_each_entry(mode, &connector->probed_modes, head) { + if (vc4_hdmi_mode_needs_scrambling(mode)) { + drm_warn_once(drm, "The core clock cannot reach frequencies high enough to support 4k @ 60Hz."); + drm_warn_once(drm, "Please change your config.txt file to add hdmi_enable_4kp60."); + } + } + } + return ret; } @@ -959,6 +976,9 @@ static int vc4_hdmi_encoder_atomic_check(struct drm_encoder *encoder, if (pixel_rate > vc4_hdmi->variant->max_pixel_clock) return -EINVAL; + if (vc4_hdmi->disable_4kp60 && (pixel_rate > HDMI_14_MAX_TMDS_CLK)) + return -EINVAL; + vc4_state->pixel_rate = pixel_rate; return 0; @@ -978,6 +998,9 @@ vc4_hdmi_encoder_mode_valid(struct drm_encoder *encoder, if ((mode->clock * 1000) > vc4_hdmi->variant->max_pixel_clock) return MODE_CLOCK_HIGH; + if (vc4_hdmi->disable_4kp60 && vc4_hdmi_mode_needs_scrambling(mode)) + return MODE_CLOCK_HIGH; + return MODE_OK; } @@ -1993,6 +2016,14 @@ static int vc4_hdmi_bind(struct device *dev, struct device *master, void *data) vc4_hdmi->disable_wifi_frequencies = of_property_read_bool(dev->of_node, "wifi-2.4ghz-coexistence"); + if (variant->max_pixel_clock == 600000000) { + struct vc4_dev *vc4 = to_vc4_dev(drm); + long max_rate = clk_round_rate(vc4->hvs->core_clk, 550000000); + + if (max_rate < 550000000) + vc4_hdmi->disable_4kp60 = true; + } + if (vc4_hdmi->variant->reset) vc4_hdmi->variant->reset(vc4_hdmi); diff --git a/drivers/gpu/drm/vc4/vc4_hdmi.h b/drivers/gpu/drm/vc4/vc4_hdmi.h index 3cebd1fd00fc..3cd021136402 100644 --- a/drivers/gpu/drm/vc4/vc4_hdmi.h +++ b/drivers/gpu/drm/vc4/vc4_hdmi.h @@ -154,6 +154,14 @@ struct vc4_hdmi { */ bool disable_wifi_frequencies; + /* + * Even if HDMI0 on the RPi4 can output modes requiring a pixel + * rate higher than 297MHz, it needs some adjustments in the + * config.txt file to be able to do so and thus won't always be + * available. + */ + bool disable_4kp60; + struct cec_adapter *cec_adap; struct cec_msg cec_rx_msg; bool cec_tx_ok; -- 2.31.1