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: 13842383 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 B0A98D3F29E for ; Fri, 18 Oct 2024 20:43:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Cc:To:In-Reply-To:References :Message-Id:Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date: From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=5GuU7tWYyoCMELfexr2H69ppcidX40bNWoyi/8R/8OM=; b=xF268QAQaZTP0u9dU33JJfk+s1 +WnpaTzI3QfWC9jgxL7mUb1BW2i06dUEKwjkxuCPLHoGxiDymguk84u0hi8KnyHCqU5JI9rC946ay DvdxWfBKtNO3zDwWztAHWpSIIRSTn2MMwXhyS3xG/L7njDedk7ZA+C39b7zhk72AYldss01nAjAYZ NTGJSp/vKT1qbzMeY72wY3rEYKy5uJv6DA/0B3vrt0jJcsM57RV/Tq4C78lBdOCXuW06exw0zQDs7 CWB/wcdxkSvhEevcD9L43c1V8qbTcWneN6fyC/GVpDFpgovuAsZMiPOzD9iOGyhO4OFDQwOfESm05 fKmRVhXg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1t1ton-00000001zcM-1N4y; Fri, 18 Oct 2024 20:43:29 +0000 Received: from mail-lf1-x12f.google.com ([2a00:1450:4864:20::12f]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1t1tgD-00000001xcd-0lCq for linux-arm-kernel@lists.infradead.org; Fri, 18 Oct 2024 20:34:39 +0000 Received: by mail-lf1-x12f.google.com with SMTP id 2adb3069b0e04-539f1292a9bso3323996e87.2 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.infradead.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=WWH1FtJUbp5VIIm5E/yyfQaUo49eSOkPkDwHrMtfTujCuWCSVCEdN0CkMwmXtfz1I3 sQfft0rhdJkJUEPjSZ1AKUb0808g5L6KBwX+mZDB/lRDUuQ7IE9gxaguRLm/3K2zNGcO 4HHydBFFQWYeuKudHAyHKIT/e5rJ0KnMU98GAT5c4XJtPHBc5g7K5loLUXAhCK9T4Q02 58LouNrpreiljdWt0Lg1GkBGVfo+o7gSM1PaG35ecpFjxtitBXvSyBF1sEtrw2g2w5Ef f82/mIFG45oSR7ZY6R1qy8mnUaNsmiJGNnXAwnp16AxNJHATmhmkAX7BtsoJ7L+/X271 EiVQ== 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=pMlr3J3nFLoGEwBwglNDK974gOgBLYvf3j89HGgKYJuTa5QC8obhz1P2Hvr20oSBrR t20Bq3ZUO9ga9/5mShe5emC/Ewwd20spJ+VMZOKrC8lMUHHcyTjFUWTG3rLlFVmdUT8l 7UBgvZUpig+hmoVgyxi9WGih96/L/tXHNvoBTjtS0zay6m8sSBc1wwPGLz5ZDEUHylmE F2grWV2qJTjMo+I/Sd0mzVUuJu+/tIh32DvNvhANfPUBif5RNCto6NmDCyvIiPPEjw+o gkzl5n2EoxRTG4leGrb7S6JBVM0IvKSuNZzXMzGGpuqQ7qh9H+oy7b3MAzusLHLnB6Ad BCqQ== X-Forwarded-Encrypted: i=1; AJvYcCV1w76bfCKPM7XTP94+QXv32hknUun/8LBVn/50FOkukXfriwPfSsQWQ8y4kJU1a2aJ50R76NVijOA6K2BoQoP1@lists.infradead.org X-Gm-Message-State: AOJu0YzEbdYxaKCkfBDJJFYYoL2Z7NcxcbeE29Q+vuirgKQHaZQ1vmO7 Q0DkRCiY5tYvYI2nHxXvaTtMLcF1ChC27/es3VD9ANPQH9GyToDdA4cgBGQzRs8= 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-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241018_133437_347213_3D8CCF81 X-CRM114-Status: GOOD ( 12.40 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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