From patchwork Fri Oct 18 20:34:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Baryshkov X-Patchwork-Id: 13842343 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 85895D3F299 for ; Fri, 18 Oct 2024 20:34:38 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 00B2A10E986; Fri, 18 Oct 2024 20:34:37 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="tRQbtDav"; dkim-atps=neutral Received: from mail-lf1-f41.google.com (mail-lf1-f41.google.com [209.85.167.41]) by gabe.freedesktop.org (Postfix) with ESMTPS id 8A05F10E984 for ; Fri, 18 Oct 2024 20:34:35 +0000 (UTC) Received: by mail-lf1-f41.google.com with SMTP id 2adb3069b0e04-539e8607c2aso2907132e87.3 for ; Fri, 18 Oct 2024 13:34:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1729283674; x=1729888474; darn=lists.freedesktop.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=5GuU7tWYyoCMELfexr2H69ppcidX40bNWoyi/8R/8OM=; b=tRQbtDavKiaYVE4DQH22jmtDyk5j2qPh/1dPecQWPeSC0T3OnfMph4GZETOSL8hx9/ NdFz/GyMToER7PnKOmtIKKppJhx5Omq5U10JC2jY3B1P1MhwRypH4xF3GL6XeIJA6gxv Tmx98hRuHDroAdBqBl2kgxlTRyixAS6RzT4WY8EZ2crG5+tE9luJWqbYe1o+6A24Z0s8 m2Ws9uxi6WP44UvZFwk/1KIhO8GPNQaqzUTSVtHGeTNEOwWc1AS/i6XCe9kCmswx6cyL 0xsgBDkjLTtsjisdVVdJ1m97u04DsBS3az7QClXcSFBDrmzKwdyjWRDxwIZdQAj1QC9T usvA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729283674; x=1729888474; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=5GuU7tWYyoCMELfexr2H69ppcidX40bNWoyi/8R/8OM=; b=P+jVmkuuE8Q0sP2itZXD+1u7J/vY5pxQnr3iROrrx0Xik7YKveETMufClHsrC2u/Aw hNwAIKtm5+pXtZigQUmvHMxxAbZPcX50wWuQf3Qg7XPaQnTpoNL+w4DSbdSqEkvMkKGJ WkR1PH9hNhL3yBlorMYaMhgMCFaNrT5wHes9V/G3EbrrYxftpGssmqm92+HX/ZEYWvIY +M2LP3fjLTKvVGwrk8XrsAGzp2d2+7MXs77DAdWmnFM7BQd1lxm/GRi0niGS/Vkhqvoe WbJyKkpnvNegweLcIOKARNjMKVueUeAvuPtQ0iw6h0ipit63C9h46mVwSzONp39mqr1m wiQQ== X-Gm-Message-State: AOJu0Yyx8ZrgdlOMQm83uVJaIg8AteIekjrUze+BAqxh8RXikrjPY4jr wp2De2ORh4+Q1D+QxwRtsUqWRciAhcTb+JYat8KpXKO8E6i5dDt7Rn7xYC0q3wo= X-Google-Smtp-Source: AGHT+IGloZ6wDijqUZKKkUYLuvbutQRKOF6lHGzo2l2n81Zd1WUUiZf9hJGMWBZ06a2NX4wdB4qK8g== X-Received: by 2002:a05:6512:10c9:b0:539:fc86:ce21 with SMTP id 2adb3069b0e04-53a154d8042mr2295837e87.56.1729283673599; Fri, 18 Oct 2024 13:34:33 -0700 (PDT) Received: from umbar.lan ([192.130.178.90]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-53a151f0e09sm314047e87.146.2024.10.18.13.34.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Oct 2024 13:34:33 -0700 (PDT) From: Dmitry Baryshkov Date: Fri, 18 Oct 2024 23:34:19 +0300 Subject: [PATCH 1/6] drm/display: hdmi: add generic mode_valid helper MIME-Version: 1.0 Message-Id: <20241018-hdmi-mode-valid-v1-1-6e49ae4801f7@linaro.org> References: <20241018-hdmi-mode-valid-v1-0-6e49ae4801f7@linaro.org> In-Reply-To: <20241018-hdmi-mode-valid-v1-0-6e49ae4801f7@linaro.org> To: Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Simona Vetter , Chen-Yu Tsai , Jernej Skrabec , Samuel Holland , Dave Stevenson , =?utf-8?q?Ma=C3=ADra_Cana?= =?utf-8?q?l?= , Raspberry Pi Kernel Maintenance , Andrzej Hajda , Neil Armstrong , Robert Foss , Laurent Pinchart , Jonas Karlman Cc: dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev X-Mailer: b4 0.14.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=2159; i=dmitry.baryshkov@linaro.org; h=from:subject:message-id; bh=05eR0rzcMjCSZr+JFEQ+hv6PM74BY2KccFSMBu6VpEs=; b=owEBbQGS/pANAwAKAYs8ij4CKSjVAcsmYgBnEsZW3m5IznuxEQtNTc9EWw3cd2bY+FbRHbpPY 9wot4vemb6JATMEAAEKAB0WIQRMcISVXLJjVvC4lX+LPIo+Aiko1QUCZxLGVgAKCRCLPIo+Aiko 1dF9CACWov/QNo6bt82KZcmQvzsADQbKiFLhhwfiZhK1hr3xE441Mf4iqjWBfQz1bZdyHfWCMFI tAggG16qjyRzCbqHkzPpuiIRfln/5K81YATrsU3yYi7L3SjUPPs4M0wVfavvW12Ik7wKvNmivj9 QbRyNQGuDxBtxyCmF2vZLDRlO+fbavhc7nDWytINEAJwoiaL7LIC0eAiWF/T4eT+GqDIFNoQbbK 1K1IgQZcPkjYG7SvqcX5oQobue+Do6pxmPaaHEnDNkhPc/IWI35+cIpWOtrKJazzxhccgFjDgJl 9nJTVPbVYR771G0S2xuCXsvfYTuJbNVfnaGTPVEcqpzPPXMn X-Developer-Key: i=dmitry.baryshkov@linaro.org; a=openpgp; fpr=8F88381DD5C873E4AE487DA5199BF1243632046A X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Add drm_hdmi_connector_mode_valid(), generic helper for HDMI connectors. It can be either used directly or as a part of the .mode_valid callback. Signed-off-by: Dmitry Baryshkov --- drivers/gpu/drm/display/drm_hdmi_helper.c | 25 +++++++++++++++++++++++++ include/drm/display/drm_hdmi_helper.h | 4 ++++ 2 files changed, 29 insertions(+) diff --git a/drivers/gpu/drm/display/drm_hdmi_helper.c b/drivers/gpu/drm/display/drm_hdmi_helper.c index 74dd4d01dd9b..0ac5cb000ee2 100644 --- a/drivers/gpu/drm/display/drm_hdmi_helper.c +++ b/drivers/gpu/drm/display/drm_hdmi_helper.c @@ -256,3 +256,28 @@ drm_hdmi_compute_mode_clock(const struct drm_display_mode *mode, return DIV_ROUND_CLOSEST_ULL(clock * bpc, 8); } EXPORT_SYMBOL(drm_hdmi_compute_mode_clock); + +/** + * drm_hdmi_connector_mode_valid() - Check if mode is valid for HDMI connector + * @connector: DRM connector to validate the mode + * @mode: Display mode to validate + * + * Generic .mode_valid implementation for HDMI connectors. + */ +enum drm_mode_status +drm_hdmi_connector_mode_valid(const struct drm_connector *connector, + const struct drm_display_mode *mode) +{ + const struct drm_connector_hdmi_funcs *funcs = connector->hdmi.funcs; + unsigned long long rate; + + rate = drm_hdmi_compute_mode_clock(mode, 8, HDMI_COLORSPACE_RGB); + if (!rate) + return MODE_ERROR; + + if (!funcs || !funcs->tmds_char_rate_valid) + return MODE_OK; + + return funcs->tmds_char_rate_valid(connector, mode, rate); +} +EXPORT_SYMBOL(drm_hdmi_connector_mode_valid); diff --git a/include/drm/display/drm_hdmi_helper.h b/include/drm/display/drm_hdmi_helper.h index 57e3b18c15ec..e38b62df59f3 100644 --- a/include/drm/display/drm_hdmi_helper.h +++ b/include/drm/display/drm_hdmi_helper.h @@ -28,4 +28,8 @@ unsigned long long drm_hdmi_compute_mode_clock(const struct drm_display_mode *mode, unsigned int bpc, enum hdmi_colorspace fmt); +enum drm_mode_status +drm_hdmi_connector_mode_valid(const struct drm_connector *connector, + const struct drm_display_mode *mode); + #endif