Received: by 2002:ab2:6816:0:b0:1f9:5764:f03e with SMTP id t22csp2979211lqo; Tue, 21 May 2024 03:14:17 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUWrLEqtUwwzu+dt6Ouq/ehTdY6ffv7aYNCD44pjWOh6gJmEtVPi8T6C/+BSr0fp9e1AECaIc5NQ0Rt5NeOIOa3ux3WuqiEXKM9rgqmCQ== X-Google-Smtp-Source: AGHT+IE+Yxz0nVNEdvxN6sm0Jd/JTi+7l+MdUzeA5qycUcIFz+LbJTXmm8voXcf87wxr0rjNg68K X-Received: by 2002:a05:622a:105:b0:43a:664f:e1c7 with SMTP id d75a77b69052e-43dfdb22fddmr337070651cf.16.1716286457226; Tue, 21 May 2024 03:14:17 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1716286457; cv=pass; d=google.com; s=arc-20160816; b=x4U7pxQRL/HoiWTI54eWNuRiht2X39k4c0eB3tlrzyUeUUKlLbwE6xnwWlLnWDBLhM MuVQK/BgVQV6tWqn5QS0fyYJKUdupIZb3jQA/5kGqKeubU1o0T7cNeyhycvIycym22NW IwlYLt2Lk/8GX5SddIdMnS5cvUoyJ3ao3aq80FcuFd2jqnvOh5GNaPwOYYXZe3E2kIzG RyGxyggalCIZgQEZ1h1ea1HaTf7VUqZhOswanUrTfl8nide6rZadxrJqHEjyrL2OYZ4C 6abUM/iQD4NwPDRX+DJGgldYDvoBFKI5JaxzuGILsueSi6fYpFOwkC/LH7+NX0Q/HYXt umkw== 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=Gc8J3OejQdHBK5N0rA/h4cyBYobI5XqR5DdDZ23jyT4=; fh=9Hsik6x8C5TtzOEfmQ7fSqQK+L/kyVCu4a7tBzWtauA=; b=I72jjKYsZoCOvG9oftu9FAeBv00xsZ8B+CLE47T+dcyhHY7btl4P4xKZUILcVGvdGr YCAjPpzzRvGkIuq/vqf5O7E5UsEmyoS4I31K9juzWIGdmsULfW0rdSYiSRrJCSUC18oL cb1/z3sZUXDcOYgcG/RNKr5ZkKtC+3G68Iyac5q4tqxvm3xirKK9OExElUVxIon3A1cm T2sR+Qy1f4zg66w6fyhKAtR3PjtaD/28MF+ulvzUUQiNm7f4xr0v4kB2ZalREIXcDCnH JXQ2NOY3p/4oYnqxGevAN2CUs35XNzVDHnnEpBR+A/Y7yYAbVK+QHI11LWmFGVu4ZTU8 B0Jg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=kiCXBoXC; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-184761-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-184761-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id d75a77b69052e-43df56d50c5si1533471cf.688.2024.05.21.03.14.16 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 May 2024 03:14:17 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-184761-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=kiCXBoXC; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-184761-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-184761-linux.lists.archive=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 ny.mirrors.kernel.org (Postfix) with ESMTPS id CB5C71C216B9 for ; Tue, 21 May 2024 10:14:16 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6BD7E70CC9; Tue, 21 May 2024 10:13:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="kiCXBoXC" 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 755D46CDD5; Tue, 21 May 2024 10:13:55 +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=1716286435; cv=none; b=adDdzT+1VLZRzXn8aJXsN4DrnjAM8huxi/nJ5l4fhGNpMd49acCx6cs9NqfwciHpuCslYvdFV6HQBZZOgv4uXmNRgCZlGabJAAp9GZKLQl5lvrNXQxnk6WY4CYQU0FDWH0Z1rp79hqB3nDDmau1uURXqaiWLiTpU/4YVJ8SZBws= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716286435; c=relaxed/simple; bh=mip2dTposQAfd+SqycxyXVPYbKW0NKtrqBLWMYUsIvY=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=sSezLmgkztkt2Uu3jGcYVop9Lu5oYwXp57U7q8brW0RNwUwpAfjogxsrK+xH+GWLAUlHc3XeqsYS5ScAwrfsfoxRaE5rXEKlaJ5cI0hiRW0LPIwV92YWxeJKhbufDIee9uH6FEk4Db77Ex7xmtfFNavCuxhCs7roxIdJ2+L94IE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=kiCXBoXC; arc=none smtp.client-ip=10.30.226.201 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 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit 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?q?Ville_Syrj=C3=A4l=C3=A4?= , 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 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 --- 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); -- 2.45.0