From patchwork Tue May 21 10:13:34 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Ripard X-Patchwork-Id: 13669192 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 5FA38C25B74 for ; Tue, 21 May 2024 10:14:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Cc:To:In-Reply-To:References:Message-Id :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=r6Q4FKYu2Wz8Z8j3BZX8N6jZaFFumSayNF83WkOXezs=; b=H3Nqa8FrEEBogn l5F1T4fpiPbuYDsethaNSAoARIVMfWEQQvayScmLildAUfyW0nURXYaEJWjtn1yEsmsJMoF/t+n19 IptEUOcq0HVWKHuphbHsQ7XAkaGAiBMUA6uVhjOBmjyIOYrW56V8+T6FLkJU9U6c4NiKCZg7gg3YX 1+PQ/1r1wARrNksO/X8dsu57Bu++ot0kJ/ydDPF/3V4SLzIU5B6U6LjINkwXyux4ta9jwAWvfC/kN j4zSWXONxxQj7nP5oMcs96MaHPcjVB+JOTeHzBjSdbU50K5tIqA1VOcyaeW9bSRjKEQGGAEmG+Z9I 9YaFB2S+dNLcrfspQmpw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1s9MVR-0000000H1LQ-0qg1; Tue, 21 May 2024 10:14:05 +0000 Received: from dfw.source.kernel.org ([139.178.84.217]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1s9MVI-0000000H1G4-2wpr; Tue, 21 May 2024 10:13:58 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 9DFFC620F6; Tue, 21 May 2024 10:13:55 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 02083C4AF07; Tue, 21 May 2024 10:13:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1716286435; bh=mip2dTposQAfd+SqycxyXVPYbKW0NKtrqBLWMYUsIvY=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=kiCXBoXCM1x2Kibir7F6UpR3jZg2Bwr9Vyts63hwl/VN4e3h30QDeyINSJJXaVctD Z094C1VMObOKa3KDYGsafE50uCRWO1wPw14x1PPHf0faFDK2r/4EyYIA8s/26dl9Bd li2oaZfGOT3/mYPKLdM1aG9BY7SNoQRH/YKZCYxl1PEiXhnS4grfuohzjjgkbDMNxl 4ieyzL7cJ1N3d2mfnq9fXdoESU+rZEIyQvqEf8roCrsK9a1E90GJjxyB2HhjB9jAWi Z2lAuZeBQFyUNUIEhF7HAIvbet8+sz/MAZ5GXDKTXPyDNJdCcmHs5Rg7S/fONUuCOT s+VF8C16ZBIUA== From: Maxime Ripard Date: Tue, 21 May 2024 12:13:34 +0200 Subject: [PATCH v14 01/28] drm/connector: Introduce an HDMI connector initialization function MIME-Version: 1.0 Message-Id: <20240521-kms-hdmi-connector-state-v14-1-51950db4fedb@kernel.org> References: <20240521-kms-hdmi-connector-state-v14-0-51950db4fedb@kernel.org> In-Reply-To: <20240521-kms-hdmi-connector-state-v14-0-51950db4fedb@kernel.org> To: Maarten Lankhorst , Thomas Zimmermann , David Airlie , Daniel Vetter , Jonathan Corbet , Sandy Huang , =?utf-8?q?Heiko_St=C3=BCbner?= , Chen-Yu Tsai , Jernej Skrabec , Samuel Holland , Andy Yan Cc: Hans Verkuil , Sebastian Wick , =?utf-8?b?VmlsbGUgU3lyasOkbMOk?= , dri-devel@lists.freedesktop.org, linux-arm-kernel@lists.infradead.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-media@vger.kernel.org, linux-rockchip@lists.infradead.org, linux-sunxi@lists.linux.dev, Maxime Ripard , Dave Stevenson , Sui Jingfeng X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=3844; i=mripard@kernel.org; h=from:subject:message-id; bh=mip2dTposQAfd+SqycxyXVPYbKW0NKtrqBLWMYUsIvY=; b=owGbwMvMwCmsHn9OcpHtvjLG02pJDGk+xRcaksyX7r8Z672EM2ib4OnvFrk5L87FPky5MqN+a nn2V56KjqksDMKcDLJiiixPZMJOL29fXOVgv/IHzBxWJpAhDFycAjCRw7sYG34k6Td8XRFYX7Ce Ywb3Z8abyvVsl16+C+YsXbt/0tdjk3+5pU5Z1PxXUU+udIsVh8EZPcaGnWvWOiacMyvdasz6sj+ VjV/d6drKQ/tmzOAvLwwo6mupir/prHdI6Jdo52JTt7XV/ycCAA== X-Developer-Key: i=mripard@kernel.org; a=openpgp; fpr=BE5675C37E818C8B5764241C254BCFC56BF6CE8D X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240521_031356_886925_6D2E0F9B X-CRM114-Status: GOOD ( 15.98 ) 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 A lot of the various HDMI drivers duplicate some logic that depends on the HDMI spec itself and not really a particular hardware implementation. Output BPC or format selection, infoframe generation are good examples of such areas. This creates a lot of boilerplate, with a lot of variations, which makes it hard for userspace to rely on, and makes it difficult to get it right for drivers. In the next patches, we'll add a lot of infrastructure around the drm_connector and drm_connector_state structures, which will allow to abstract away the duplicated logic. This infrastructure comes with a few requirements though, and thus we need a new initialization function. Hopefully, this will make drivers simpler to handle, and their behaviour more consistent. Reviewed-by: Dave Stevenson Reviewed-by: Sui Jingfeng Signed-off-by: Maxime Ripard Reviewed-by: Dmitry Baryshkov --- drivers/gpu/drm/drm_connector.c | 39 +++++++++++++++++++++++++++++++++++++++ include/drm/drm_connector.h | 5 +++++ 2 files changed, 44 insertions(+) diff --git a/drivers/gpu/drm/drm_connector.c b/drivers/gpu/drm/drm_connector.c index b0516505f7ae..d9961cce8245 100644 --- a/drivers/gpu/drm/drm_connector.c +++ b/drivers/gpu/drm/drm_connector.c @@ -450,10 +450,49 @@ int drmm_connector_init(struct drm_device *dev, return 0; } EXPORT_SYMBOL(drmm_connector_init); +/** + * drmm_connector_hdmi_init - Init a preallocated HDMI connector + * @dev: DRM device + * @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 + * + * Initialises a preallocated HDMI connector. Connectors can be + * subclassed as part of driver connector objects. + * + * Cleanup is automatically handled with a call to + * drm_connector_cleanup() in a DRM-managed action. + * + * The connector structure should be allocated with drmm_kzalloc(). + * + * Returns: + * Zero on success, error code on failure. + */ +int drmm_connector_hdmi_init(struct drm_device *dev, + struct drm_connector *connector, + const struct drm_connector_funcs *funcs, + int connector_type, + struct i2c_adapter *ddc) +{ + int ret; + + if (!(connector_type == DRM_MODE_CONNECTOR_HDMIA || + connector_type == DRM_MODE_CONNECTOR_HDMIB)) + return -EINVAL; + + ret = drmm_connector_init(dev, connector, funcs, connector_type, ddc); + if (ret) + return ret; + + return 0; +} +EXPORT_SYMBOL(drmm_connector_hdmi_init); + /** * drm_connector_attach_edid_property - attach edid property. * @connector: the connector * * Some connector types like DRM_MODE_CONNECTOR_VIRTUAL do not get a diff --git a/include/drm/drm_connector.h b/include/drm/drm_connector.h index fe88d7fc6b8f..4491c4c2fb6e 100644 --- a/include/drm/drm_connector.h +++ b/include/drm/drm_connector.h @@ -1902,10 +1902,15 @@ int drm_connector_init_with_ddc(struct drm_device *dev, int drmm_connector_init(struct drm_device *dev, struct drm_connector *connector, const struct drm_connector_funcs *funcs, int connector_type, struct i2c_adapter *ddc); +int drmm_connector_hdmi_init(struct drm_device *dev, + struct drm_connector *connector, + const struct drm_connector_funcs *funcs, + int connector_type, + struct i2c_adapter *ddc); void drm_connector_attach_edid_property(struct drm_connector *connector); int drm_connector_register(struct drm_connector *connector); void drm_connector_unregister(struct drm_connector *connector); int drm_connector_attach_encoder(struct drm_connector *connector, struct drm_encoder *encoder);