From patchwork Mon Aug 14 13:56:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Ripard X-Patchwork-Id: 135463 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b824:0:b0:3f2:4152:657d with SMTP id z4csp2773846vqi; Mon, 14 Aug 2023 07:14:55 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEVedpkdY7eg4OkIU63y/bUkez9Ub/Bo2XeIZ0FZDzcMbaMta1LueGOtrtucScoQYZ7O0hT X-Received: by 2002:a17:902:a407:b0:1bd:aeb0:f031 with SMTP id p7-20020a170902a40700b001bdaeb0f031mr8222637plq.42.1692022495504; Mon, 14 Aug 2023 07:14:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1692022495; cv=none; d=google.com; s=arc-20160816; b=B2IAddtPGn8W9+6A5IvWCRR+itEtEKtfpQQasaGO5mi01aZ/V1CP3Cg9ob0eOvsOip YouRRwLF8YR8u/3Ca/9evXayWKTrvXohvipblJfG0NXQSZbn6xqSung/AW8a3ykDqKsD 2z0lPDrcd/i3giK6VCAhF+S+IMxH5WIcaNW8I0Uj695tkw6z6S40ZaPqox+b+mXUN0TX YMsCz/X5NmiPFZXJjAdaCLxWKKMM05aAbgTCEDsHilzZR/S41UsNGgj7OmG0Z2j/yGKw Xy+zyfBeFuPrBx1hXd1hNoJFu+AkIt99nVl1y7D+5r8IlViKcf797mcZCX+2GaycrgDB uxtw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:in-reply-to:references:message-id :content-transfer-encoding:mime-version:subject:date:from :dkim-signature; bh=NbQZDba3p7juKXoLS2GecWA6OZFC83nq3LgoHH0IIhU=; fh=XsS7fCnS6jyV48OHq4AWazZQaFUKJmjcq7fZaQkmGOY=; b=k0SJdSMsK95v+gZJZl9WDDxPw5X70rXhTqXc/+f11UBg22gYb3Q2jEde6AVfwhATgn OyHnRk8zk3W5bIDmbarBxAXqU/WLvBekyCVYvbzI7t8tPPVJ7+Sjo0IoULjE/HU0wXeV srswVG47rzNjs4gphd5OpATiqWafWNLoeOb/ohzdC2CHvaMRXvUte20A/rJEmjBKXFpp X/H/qZyW9aAYsGmMh0iEdSsZeopnvVwxU1s8PnmeDK0ZzYPWsdhRKeO8nVNvTSYVU0Dj OKEklB6A+klEXOmFlmDhInugYz79qGFkydpFgzHP/Q69aojUCMKt5xppQDYY50uPkWn8 jntA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=jbdTAUfN; 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=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u12-20020a170902e80c00b001bb935754f0si8300624plg.444.2023.08.14.07.14.41; Mon, 14 Aug 2023 07:14: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=@kernel.org header.s=k20201202 header.b=jbdTAUfN; 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=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231682AbjHNN5V (ORCPT + 99 others); Mon, 14 Aug 2023 09:57:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56188 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231540AbjHNN4u (ORCPT ); Mon, 14 Aug 2023 09:56:50 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A8D73E6D for ; Mon, 14 Aug 2023 06:56:49 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 2F08460ECA for ; Mon, 14 Aug 2023 13:56:49 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4047FC433C9; Mon, 14 Aug 2023 13:56:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1692021408; bh=g++ofW1dWzrJFCe/PqAHGgE6yXVKaJFsc5QCbk7jsYE=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=jbdTAUfNdH0v7148wd7Q+sEg+/Y5cgdrTeFOcx6EcKK7GPttIkCW9Q3UqXsbgdRtq KFcNuhCBqaFWf2Ou7flX/RHfYkNgoPvXyxYTxNKuCPJaEKpzqYcVRkcnulwR0GqqpI RN7nEvR313fPfYvpFuiq8Re/pb5CieYSUSgaWtXeeWBkDB/C5YF6FnyXON3tpBfifg lVm7B8e895RRdjIr5XeaizcF48eJsaS457iBNDR5lz6CfT27lWpTN2T9jevD6VoDmj mkw8Jjj2jPJbdegMPA/C0+DXUlb8sJizzYrjM5dHRyfEhWxuR1j6EtEZStaRY5V458 /2x/oLYRQBjPQ== From: Maxime Ripard Date: Mon, 14 Aug 2023 15:56:20 +0200 Subject: [PATCH RFC 08/13] drm/connector: hdmi: Add custom hook to filter TMDS character rate MIME-Version: 1.0 Message-Id: <20230814-kms-hdmi-connector-state-v1-8-048054df3654@kernel.org> References: <20230814-kms-hdmi-connector-state-v1-0-048054df3654@kernel.org> In-Reply-To: <20230814-kms-hdmi-connector-state-v1-0-048054df3654@kernel.org> To: Maarten Lankhorst , Thomas Zimmermann , David Airlie , Daniel Vetter , Emma Anholt Cc: Hans Verkuil , linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, Maxime Ripard X-Mailer: b4 0.12.3 X-Developer-Signature: v=1; a=openpgp-sha256; l=4570; i=mripard@kernel.org; h=from:subject:message-id; bh=g++ofW1dWzrJFCe/PqAHGgE6yXVKaJFsc5QCbk7jsYE=; b=owGbwMvMwCX2+D1vfrpE4FHG02pJDCm3jNomvVjKu6qR09b37rmdDxt1Lnp4zz/6uuih5fGTF 57sTPxxqKOUhUGMi0FWTJElRth8SdypWa872fjmwcxhZQIZwsDFKQATcfRj+M2yUmnNFvd7U+Im TeMwmhF7MP3AOpEZh7U2XLTZ1irzizOE4X/00ezuxOAI/Z3umuvXfr+3egl/qE/YCSaGas/oebl CxewA X-Developer-Key: i=mripard@kernel.org; a=openpgp; fpr=BE5675C37E818C8B5764241C254BCFC56BF6CE8D X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS autolearn=ham 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: INBOX X-GMAIL-THRID: 1774214180402929707 X-GMAIL-MSGID: 1774214180402929707 Most of the HDMI controllers have an upper TMDS character rate limit they can't exceed. On "embedded"-grade display controllers, it will typically be lower than what high-grade monitors can provide these days, so drivers will filter the TMDS character rate based on the controller capabilities. To make that easier to handle for drivers, let's provide an optional hook to be implemented by drivers so they can tell the HDMI controller helpers if a given TMDS character rate is reachable for them or not. This will then be useful to figure out the best format and bpc count for a given mode. Signed-off-by: Maxime Ripard --- drivers/gpu/drm/drm_hdmi_connector.c | 8 ++++++++ include/drm/drm_connector.h | 30 ++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+) diff --git a/drivers/gpu/drm/drm_hdmi_connector.c b/drivers/gpu/drm/drm_hdmi_connector.c index e49782a284a5..d94ceeb6a8ef 100644 --- a/drivers/gpu/drm/drm_hdmi_connector.c +++ b/drivers/gpu/drm/drm_hdmi_connector.c @@ -263,12 +263,16 @@ drm_hdmi_connector_clock_valid(const struct drm_hdmi_connector *hdmi_connector, const struct drm_display_mode *mode, unsigned long long clock) { + const struct drm_hdmi_connector_funcs *funcs = hdmi_connector->funcs; const struct drm_connector *connector = &hdmi_connector->base; const struct drm_display_info *info = &connector->display_info; if (info->max_tmds_clock && clock > info->max_tmds_clock * 1000) return MODE_CLOCK_HIGH; + if (funcs && funcs->tmds_char_rate_valid) + return funcs->tmds_char_rate_valid(hdmi_connector, mode, clock); + return MODE_OK; } @@ -458,6 +462,7 @@ EXPORT_SYMBOL(drm_atomic_helper_hdmi_connector_print_state); * drmm_hdmi_connector_init - Init a preallocated HDMI connector * @dev: DRM device * @hdmi_connector: A pointer to the HDMI connector to init + * @funcs: callbacks for this connector * @connector_type: user visible type of the connector * @ddc: optional pointer to the associated ddc adapter * @max_bpc: Maximum bits per char the HDMI connector supports @@ -476,6 +481,7 @@ EXPORT_SYMBOL(drm_atomic_helper_hdmi_connector_print_state); int drmm_hdmi_connector_init(struct drm_device *dev, struct drm_hdmi_connector *hdmi_connector, const struct drm_connector_funcs *funcs, + const struct drm_hdmi_connector_funcs *hdmi_funcs, int connector_type, struct i2c_adapter *ddc, unsigned int max_bpc) @@ -516,6 +522,8 @@ int drmm_hdmi_connector_init(struct drm_device *dev, hdmi_connector->max_bpc = max_bpc; } + hdmi_connector->funcs = hdmi_funcs; + return 0; } EXPORT_SYMBOL(drmm_hdmi_connector_init); diff --git a/include/drm/drm_connector.h b/include/drm/drm_connector.h index 03c5af34323d..6e25a16420e4 100644 --- a/include/drm/drm_connector.h +++ b/include/drm/drm_connector.h @@ -2131,12 +2131,41 @@ bool drm_atomic_helper_hdmi_connector_is_full_range(const struct drm_hdmi_connector *hdmi_connector, const struct drm_hdmi_connector_state *hdmi_state); +/** + * struct drm_hdmi_connector_funcs - drm_hdmi_connector control functions + */ +struct drm_hdmi_connector_funcs { + /** + * @tmds_char_rate_valid: + * + * This callback is invoked at atomic_check time to figure out + * whether a particular TMDS character rate is supported by the + * driver. + * + * The @tmds_char_rate_valid callback is optional. + * + * Returns: + * + * Either &drm_mode_status.MODE_OK or one of the failure reasons + * in &enum drm_mode_status. + */ + enum drm_mode_status + (*tmds_char_rate_valid)(const struct drm_hdmi_connector *connector, + const struct drm_display_mode *mode, + unsigned long long tmds_rate); +}; + struct drm_hdmi_connector { /** * @base: Base Connector */ struct drm_connector base; + /** + * @funcs: HDMI connector Control Functions + */ + const struct drm_hdmi_connector_funcs *funcs; + /** * @max_bpc: Maximum bits per character the connector supports. */ @@ -2160,6 +2189,7 @@ drm_hdmi_connector_compute_mode_clock(const struct drm_display_mode *mode, int drmm_hdmi_connector_init(struct drm_device *dev, struct drm_hdmi_connector *hdmi_connector, const struct drm_connector_funcs *funcs, + const struct drm_hdmi_connector_funcs *hdmi_funcs, int connector_type, struct i2c_adapter *ddc, unsigned int max_bpc);