From patchwork Mon Aug 14 13:56:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Ripard X-Patchwork-Id: 135490 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b824:0:b0:3f2:4152:657d with SMTP id z4csp2797065vqi; Mon, 14 Aug 2023 07:54:38 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGrvtYZwa+uWigDUjG9j5e/WjvFcD25uQHXVIr6F7/9spJCYvsuKx4JsWl5iqU0uMg1FgNT X-Received: by 2002:a05:6a00:2ea4:b0:675:8f71:290a with SMTP id fd36-20020a056a002ea400b006758f71290amr13581312pfb.34.1692024878348; Mon, 14 Aug 2023 07:54:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1692024878; cv=none; d=google.com; s=arc-20160816; b=U6V5CORp8O3XVVozdrVExrR5fCrmeGsEtXLTRpuI+MpKggUHH5LOG4DnTLAc/nPCet pKB4IeSwXPu72+v/94I9t9r4n7pOHYqZwneCOsNJ3CtTC370V32PDc/qu9GtO+9hut5t +VI6FTM1oZM/bGstV6Cvw8f3o6YjhIJAwn6iBdFq10eJBKw+fnJj4wNywAZxEcPFNqd+ wvWunIsir0w1nKxBcGs0VHoDKr4+9iTOSP01ZyOQW8CH2Sw89b7WAXYW5QfGEBnXR7x7 Xlt8UyCtHfln/MbtLwcR0AhHvgPlsNfeK4nJGrOoI4L3XpYN/sGvUOA3u5/3EQHenkg5 vPZw== 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=NVjUTx9x4rj5s7W87ZjmeVhYbioq7zTCpIXFAHPoO+w=; fh=XsS7fCnS6jyV48OHq4AWazZQaFUKJmjcq7fZaQkmGOY=; b=epu7c8wunhX66J7UXhx1Bc+GDOzxsH8PHkS/FDGK0u+RHvA5DfFU679p7MVn80YZ9D UIy8UremqPWLETG2BOeX6+r4GzW3/zhn+0vJz+u8eni/wM4EOTOJhHoCqSkPI+LSSc97 gjcV1Dsax1KNWhJt4205NjZmJ/n4C0zwamIZiDCpaK4IsrBiJKGOqDViPCxAU8X5pE7Z c+8GdwThkOCParFXBpmEdwdB2CyNy7PnkCDMKRYDOGNnB1cUoHrJsDa2zDtGNAURvXkc kXQvKt2tLr1GmBL00/u4s8dWKtKe9XyM27I3sUOSDLr5nmBQcABvwC1+gn43abkBhfrf XsRQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=oUwTESRp; 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 u11-20020a056a00124b00b00682759c6440si8245903pfi.40.2023.08.14.07.54.24; Mon, 14 Aug 2023 07:54:38 -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=oUwTESRp; 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 S231685AbjHNN4y (ORCPT + 99 others); Mon, 14 Aug 2023 09:56:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58632 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231716AbjHNN4a (ORCPT ); Mon, 14 Aug 2023 09:56:30 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 05568E7D for ; Mon, 14 Aug 2023 06:56:30 -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 888BA61A55 for ; Mon, 14 Aug 2023 13:56:29 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 94BE4C433CA; Mon, 14 Aug 2023 13:56:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1692021388; bh=IFS4dquHs0GVQ0YNk9O4KF71KLDK2GvWdi33+XtiI0Y=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=oUwTESRpQHmK/itub/LZ+yB+K/0T9hdRxVopaO1pGG12CA51ovVKS+ys8I9gEEX6u wPbZSYDhyAfFNYSX3OA6rOzExjD1gyi8Xzi273+JtKKZQPxCCn3yNpTPSfIhiN6vJK 15+MJslTwQU0UcBRsQc6zma3lWDGYvi0TaCBk5G9sQDllJqXiwIvAWKNJEM4V+Hjwf iIefVgX4WVaLyJaFIBb0XoqhihHwyWdgN5fsf9svxVATi3NMRPkOBEQXJAMt0Zr27N 946oBF87lL3++VgVdJEEdyd17KwBC0/IF3RlbHWDwe2UORPNbBbUZN+0UYDujzCa+f /CMFqgzbl+FKA== From: Maxime Ripard Date: Mon, 14 Aug 2023 15:56:13 +0200 Subject: [PATCH RFC 01/13] drm/connector: Introduce an HDMI connector MIME-Version: 1.0 Message-Id: <20230814-kms-hdmi-connector-state-v1-1-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=3846; i=mripard@kernel.org; h=from:subject:message-id; bh=IFS4dquHs0GVQ0YNk9O4KF71KLDK2GvWdi33+XtiI0Y=; b=owGbwMvMwCX2+D1vfrpE4FHG02pJDCm3jNqOT/5y68KHkJUz06rK3v+QmXf8rArb+dm3Tua+f PTC5Qn3qo5SFgYxLgZZMUWWGGHzJXGnZr3uZOObBzOHlQlkCAMXpwBM5Ho6I8OSDXrpB15depz6 YNbsK1V8DyvevJj80Crza3r4/Es/XronMPwvEnLtu6p1q5DrxMKma9OuO9Wcj93zfs604+tulYV xOxhxAQA= X-Developer-Key: i=mripard@kernel.org; a=openpgp; fpr=BE5675C37E818C8B5764241C254BCFC56BF6CE8D X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, 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: 1774216678721503254 X-GMAIL-MSGID: 1774216678721503254 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. Let's create a new connector variant specifically dedicated to HDMI controllers that will allow to abstract away the duplicated logic. Hopefully, this will make drivers simpler to handle, and their behaviour more consistent. Signed-off-by: Maxime Ripard --- drivers/gpu/drm/Makefile | 1 + drivers/gpu/drm/drm_hdmi_connector.c | 45 ++++++++++++++++++++++++++++++++++++ include/drm/drm_connector.h | 16 +++++++++++++ 3 files changed, 62 insertions(+) diff --git a/drivers/gpu/drm/Makefile b/drivers/gpu/drm/Makefile index 7a09a89b493b..1520d4ccd3d7 100644 --- a/drivers/gpu/drm/Makefile +++ b/drivers/gpu/drm/Makefile @@ -27,6 +27,7 @@ drm-y := \ drm_fourcc.o \ drm_framebuffer.o \ drm_gem.o \ + drm_hdmi_connector.o \ drm_ioctl.o \ drm_lease.o \ drm_managed.o \ diff --git a/drivers/gpu/drm/drm_hdmi_connector.c b/drivers/gpu/drm/drm_hdmi_connector.c new file mode 100644 index 000000000000..62f01dd2e6df --- /dev/null +++ b/drivers/gpu/drm/drm_hdmi_connector.c @@ -0,0 +1,45 @@ +// SPDX-License-Identifier: GPL-2.0+ + +#include +#include + +#include + +/** + * drmm_hdmi_connector_init - Init a preallocated HDMI connector + * @dev: DRM device + * @hdmi_connector: A pointer to the HDMI connector to init + * @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_hdmi_connector_init(struct drm_device *dev, + struct drm_hdmi_connector *hdmi_connector, + const struct drm_connector_funcs *funcs, + int connector_type, + struct i2c_adapter *ddc) +{ + struct drm_connector *connector = &hdmi_connector->base; + 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_hdmi_connector_init); diff --git a/include/drm/drm_connector.h b/include/drm/drm_connector.h index d300fde6c1a4..1859b74083f5 100644 --- a/include/drm/drm_connector.h +++ b/include/drm/drm_connector.h @@ -2042,6 +2042,22 @@ void drm_connector_attach_privacy_screen_provider( struct drm_connector *connector, struct drm_privacy_screen *priv); void drm_connector_update_privacy_screen(const struct drm_connector_state *connector_state); +struct drm_hdmi_connector { + /** + * @base: Base Connector + */ + struct drm_connector base; +}; + +#define connector_to_hdmi_connector(connector) \ + container_of_const(connector, struct drm_hdmi_connector, base) + +int drmm_hdmi_connector_init(struct drm_device *dev, + struct drm_hdmi_connector *hdmi_connector, + const struct drm_connector_funcs *funcs, + int connector_type, + struct i2c_adapter *ddc); + /** * struct drm_tile_group - Tile group metadata * @refcount: reference count