From patchwork Mon Feb 12 13:12:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Ripard X-Patchwork-Id: 199749 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:50ea:b0:106:860b:bbdd with SMTP id r10csp2419122dyd; Mon, 12 Feb 2024 05:16:28 -0800 (PST) X-Google-Smtp-Source: AGHT+IHBGIqO8FTU0Hd8gG2NkLK4/Xnade85TXR1rem/vSdkJV+iHuTBQFcNAe4gf5sXPHnQAtWo X-Received: by 2002:a17:903:187:b0:1da:933:fb15 with SMTP id z7-20020a170903018700b001da0933fb15mr9034114plg.0.1707743788805; Mon, 12 Feb 2024 05:16:28 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707743788; cv=pass; d=google.com; s=arc-20160816; b=o5PAOnSPO90pJ48RWCQuZyjjpyOvLVq8+hRnNCRGg7tto5cuJy2O9NM+4OcR7S+s/H 4ET+VXVDxLx3RhMq8952lR5sZXcjhZgffXw6QmjO9sOpTk718wNsUBSbnBkAVuhzlZXf AjHE1Mul//aL03fM6OQ+dblbHf690c28V2Bb3lzuS8jWGNqidpFmTHqnkwy6p6LEXBa5 0+cEA2RBsFFkS3gqvSqVU/Cx1VuSOahAxuRvgn79P2KfMOh/q+4WXv1SRawpCMnzcgvf gKJTZAXlztEvooX0mi44SUCIi1lBRr/aKlZP7TkwD5kl0WAR2zQi9FSEwwf10RDSk3D3 pjaw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :subject:date:from:dkim-signature; bh=KV6yGSAJzyzAhKoiN+q1w2n6yC3jSToLAxSG+Q0+3SA=; fh=QRMVPxq+gWYQqJFhViuOQOceymh2pV4M4/9Z5ynaGtI=; b=E4pVnKUtqckI/HauJf7nR6oHXFdEALNwDjNCtD8L29qS7dVHWbOrAaeFuhnJQ07l/k BnmEkwyc2uMqNTyx98J8R88YiTW7at2I/V/Jq/7Kq8xvbW2kcSDg24dspF3mRyF5M7iJ fAI7mK60FBFjS5Xk8I4kxLpUehWyB01eJmNrnoX+UTOfr0dlNlJLBEsp4pbyYF+4RVn6 GJVkPVECIJZNnjhBqOJ7WY5HTWYIrrzMEjKwYQejvzQAD/bsV+s8kxfm7kY931C0pmKw lCbkvNP2ZlyhrO2vKc3UnksgVtG8Z2xYmlvt1IR9wbPDO76XS26XhLTn4Z9jiC6Wrbk5 R7ig==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=XXNn7xfi; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-61620-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-61620-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org X-Forwarded-Encrypted: i=2; AJvYcCWXfBVDA/CdSunPs62zZRPVbueO9FjcmIsyJT9g4ANhJGvnUPu6QnCu00SCzKRzyoVbd8OcPBAFTt3lsUAf2xEfYZTllQ== Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id h9-20020a170902680900b001da1dc5fc05si234175plk.29.2024.02.12.05.16.28 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Feb 2024 05:16:28 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-61620-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=XXNn7xfi; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-61620-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-61620-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id C9889287208 for ; Mon, 12 Feb 2024 13:15:56 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0BE1A3CF61; Mon, 12 Feb 2024 13:13:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="XXNn7xfi" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2D4E53C47D; Mon, 12 Feb 2024 13:13:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707743626; cv=none; b=qforG/PJZnCoz5SzyzkPpjT4DK84dkNMpo3LvevTQsQCiqfJzjpKSfHoMjq9yjHp/7eOTFHZq4vieGpDWQbpVT0FVwtbdotThAnWG3Lght1h2b/JaYGFPUdUbeYJUrgFvUydeYNkhTQaU1e8RcmxGkQKZhXtflXSVZVCMZUXvbc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707743626; c=relaxed/simple; bh=0u5x3Bm9z3fvcYrHOnOZJKukvzBne3+qdXlM1owrzgk=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=oRXqaksGqpKlLcRKsmk1YTwYuC0ItkAtDlV2C0Z18cZlzGaBwCQR7x+pQr2n8Khg1q4WYND/fw+OIDGX8EvlF+hlwbT+bqUWaltBmwVghFzpoxVn1hLF0q1M0P0y6pdhWpUpCIG0fFh+jTQjQunL+40Hsi2Xo/1rqg+Aw4RsSv8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=XXNn7xfi; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4B496C433C7; Mon, 12 Feb 2024 13:13:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1707743625; bh=0u5x3Bm9z3fvcYrHOnOZJKukvzBne3+qdXlM1owrzgk=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=XXNn7xfi/rOc+qn5d558ZyxFMN16YJJrQnPTntYcvrUovPTz2i6i/9dWSVYI5UDMX SWkjSo0Usim/8z38ftwzwn6fx49RLacaR/bkqFaMQOA3n3BWb0ayvN9NhS+aO7hOt1 lUuLxIeqv2Ejd0l7a+tHzqbFzNd2D8aN5ru/ey/OICpEEiJ4Vp3wSPuU4BDzHM1xtz qliGfGkvYpVQMJVt/giIKX2VUjssExhntwl1eGJPuLcWrbXQfrBnDc8Dj9zU9jxqX0 nw7krWE9Mjv/cPMqnAvOKtW4sGfPA4O2pvTkRsB0M/10W3WYoSQE3Jsw3HIDl5MVzt 0Y0vtVDjKP3PQ== From: Maxime Ripard Date: Mon, 12 Feb 2024 14:12:49 +0100 Subject: [PATCH v6 06/36] drm/connector: Introduce an HDMI connector initialization function Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240212-kms-hdmi-connector-state-v6-6-f4bcdc979e6f@kernel.org> References: <20240212-kms-hdmi-connector-state-v6-0-f4bcdc979e6f@kernel.org> In-Reply-To: <20240212-kms-hdmi-connector-state-v6-0-f4bcdc979e6f@kernel.org> To: Maarten Lankhorst , Thomas Zimmermann , David Airlie , Daniel Vetter , Emma Anholt , Jonathan Corbet , Sandy Huang , =?utf-8?q?Heiko_St=C3=BCbner?= , Chen-Yu Tsai , Jernej Skrabec , Samuel Holland Cc: Hans Verkuil , 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 X-Mailer: b4 0.12.3 X-Developer-Signature: v=1; a=openpgp-sha256; l=3492; i=mripard@kernel.org; h=from:subject:message-id; bh=0u5x3Bm9z3fvcYrHOnOZJKukvzBne3+qdXlM1owrzgk=; b=owGbwMvMwCX2+D1vfrpE4FHG02pJDKmnJJO690yIi+juXXGwerVyC9fa7CqWuQ+nfXjmX3y2N oVHmndlRykLgxgXg6yYIkuMsPmSuFOzXney8c2DmcPKBDKEgYtTACaS85uR4cCd9A8GD9Xz3i6R TWk+btu+vYQ5hsXnYILPgX/XRNbFFzIyLDy+9no629NY9axp0pvrds+u4bvY8i9G7su9EweebGb 4zQcA X-Developer-Key: i=mripard@kernel.org; a=openpgp; fpr=BE5675C37E818C8B5764241C254BCFC56BF6CE8D X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790699150891899391 X-GMAIL-MSGID: 1790699150891899391 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 Signed-off-by: Maxime Ripard --- 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 @@ -452,6 +452,45 @@ int drmm_connector_init(struct drm_device *dev, } 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 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 @@ -1904,6 +1904,11 @@ int drmm_connector_init(struct drm_device *dev, 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);