From patchwork Tue Oct 31 16:48:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Ripard X-Patchwork-Id: 160237 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b90f:0:b0:403:3b70:6f57 with SMTP id t15csp372840vqg; Tue, 31 Oct 2023 09:49:25 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGDn9zbBwNWPluGzXH+t7onkEp1A3Tr3h+Ropw53mAKpaSF5NGR6zVCZFpesmXXNOr3xXOd X-Received: by 2002:a17:902:d484:b0:1cc:43af:f580 with SMTP id c4-20020a170902d48400b001cc43aff580mr6142111plg.64.1698770965193; Tue, 31 Oct 2023 09:49:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698770965; cv=none; d=google.com; s=arc-20160816; b=zCGFssL77OkMsHjvpZQJ05wSqbT9Eu7TltdK4T1jc1P8OBlwcDb4WbRUgGqg+ZbAr0 pxUxgtNf1ZLeeRCB9wzhq4y0XLy+cMiMtkwTmMzZSGszd7G09TbTxQsD3jgyt0vs0qx1 jD0sTGTmqKKZqNGSwjCm2em8IJ36DqCCZscyMR8hYgNUh7GIQHO9KFPQCGvgwW2PECsc I4v+42u7n+VyP7EYYEnnW3NjJcKCft5d8maOG6+0MGY88k//Z/J0wl0mvY4ogKRIcOfq 6V3bQtyWf123JXh8eIPbu4jr4f3jNB1Dj2rCCWF8+5qnMzYVuJvDoiUAEu1x6hKgsvGy RHig== 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=rqs9Cp6+jqFcATqgDeLZAR/s6eRFmTiEPAFAo9SfZnY=; fh=e6/uyeFf2k7v8JUtB6fPyaAS5iN3eSA1hjtg35V2Rzw=; b=eyrzeZnLnZw6DcWHm0pZw9XapgQZhwAu9aeNU6wpkfFTbkpFMreuUq6qlLmkkH0yNT sV/f/gwwv7qdLY9wUqFlTsxzuXLSXAkL8un7i3rLjMQex0CCKD0xyYZAK/0kJUaH5izt //m/ilBp3w8KdRJ0hjzULrIsAV2jcBVDfquQ0LinKIvdRYFr2HFZRvsvO9q6MNpy7gVo LB/lWMwJbusvvv11NEsZFSQCczLs9Beu+GgxZL7D3W/l/grx76tSiK6IRuGlPHZl92cB Q3D++XW0tbk5GzztAKifBdy7dQVU9JMNTRqC8kQpzODkK39LhIFDDVfxr+X45DRH6ojf AMFw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=cvHZr8l0; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 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 lipwig.vger.email (lipwig.vger.email. [23.128.96.33]) by mx.google.com with ESMTPS id lc6-20020a170902fa8600b001cbe9b9f160si1180787plb.5.2023.10.31.09.49.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 31 Oct 2023 09:49:25 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) client-ip=23.128.96.33; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=cvHZr8l0; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 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 (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id ADE0E80CD73B; Tue, 31 Oct 2023 09:49:22 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346002AbjJaQso (ORCPT + 33 others); Tue, 31 Oct 2023 12:48:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60884 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346151AbjJaQsk (ORCPT ); Tue, 31 Oct 2023 12:48:40 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 239D192; Tue, 31 Oct 2023 09:48:38 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 70DE0C433C7; Tue, 31 Oct 2023 16:48:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1698770917; bh=VPZB/POV7iVmeWtbXi3+KcObCDwbStqo6BKswkAb6p8=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=cvHZr8l07BS+Y0v93fwcnWqL9hNjBiHp1pgopGN2hm9Q4U7GeKRRyineA8Svs7P4T LcWwt5VnlgYKGOQCCFocZseBOD12t9U+ULCfibP0ey5t8r5/mVtyfQR/7/+MGg7Qgu UZO26MNEtkDeliJFerKTXpF0wAAAvumK+dqC+B3eQ8cAveteRJfEgiCeI8Sw6KzFM4 8x5y1Hzny4rE/yc2lCyAdNg8yOMcnTtdma/ODfbrrLMGsQqd7/Du09jWIfy02rP8pH 30ZxpaK9JQRro7MTiiEGPDmD5XfIEdM8wyURWZu5t7mqjDgQYdQQDZAep7564jSh+g tBxip7ab5NAag== From: Maxime Ripard Date: Tue, 31 Oct 2023 17:48:14 +0100 Subject: [PATCH RFC v3 01/37] drm/connector: Introduce an HDMI connector MIME-Version: 1.0 Message-Id: <20231031-kms-hdmi-connector-state-v3-1-328b0fae43a7@kernel.org> References: <20231031-kms-hdmi-connector-state-v3-0-328b0fae43a7@kernel.org> In-Reply-To: <20231031-kms-hdmi-connector-state-v3-0-328b0fae43a7@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 X-Mailer: b4 0.12.3 X-Developer-Signature: v=1; a=openpgp-sha256; l=3285; i=mripard@kernel.org; h=from:subject:message-id; bh=VPZB/POV7iVmeWtbXi3+KcObCDwbStqo6BKswkAb6p8=; b=owGbwMvMwCX2+D1vfrpE4FHG02pJDKmO+ndLbqf1LJsbrPBv38onJ79PmFBYLl/7V9/DUU1FQ C0r/65NRykLgxgXg6yYIkuMsPmSuFOzXney8c2DmcPKBDKEgYtTACYyX5OR4eKqC70GV203W2aX v48vP7Vg5aXdR2TS1/MGPGd46FXbJczwP55/f9HWlJNaUcve6l1+Mp/NYpPj9JQ6X5XDfSeZ1qy v4AQA X-Developer-Key: i=mripard@kernel.org; a=openpgp; fpr=BE5675C37E818C8B5764241C254BCFC56BF6CE8D X-Spam-Status: No, score=-1.7 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Tue, 31 Oct 2023 09:49:22 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1781290463402920691 X-GMAIL-MSGID: 1781290463402920691 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/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 c44d5bcf1284..997f8ab21d04 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 d300fde6c1a4..c86cd363d652 100644 --- a/include/drm/drm_connector.h +++ b/include/drm/drm_connector.h @@ -1894,6 +1894,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);