Received: by 2002:ab2:6203:0:b0:1f5:f2ab:c469 with SMTP id o3csp2852194lqt; Tue, 23 Apr 2024 03:47:25 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCU07NCASXC0OJaQOVgIkW833MndQ48l9P+jR4SLrjfzx0K6gNwOW5ijslkN9aIZRwpm/LXlEWZFwD0ycPipT6C01B2f4Ia8NmgPD+87Sg== X-Google-Smtp-Source: AGHT+IGI7sZPGvpkQmmws6xtfZ1S2ULmJD4BmsUqbrsHt8RzchevdN53ZryLsj+QXKtSIpL6zQO2 X-Received: by 2002:a17:902:e5d2:b0:1e4:6938:6fbd with SMTP id u18-20020a170902e5d200b001e469386fbdmr13551539plf.7.1713869244877; Tue, 23 Apr 2024 03:47:24 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713869244; cv=pass; d=google.com; s=arc-20160816; b=A8RVwmE5GZivZIi+Q7C8qnk03U4MY072A8m/sG40IBZNnnHHQpVDfeX6RSsOgn0r9d wvUMjtZkPyl7uCYiPKOTAL/TKxYCVDdLaki5n7fHpWk1VdMVsQ7rJQpHUGw/QyVSCj5/ VmF6/+lQRfnmlCObSH+LS+30gLyDhq38BrorYnwaWQw7fjkm7bKZs0YDhjQTwSKGlTMk sMbkV53aJbNEUxv6DbjtqsCd3cjLpVEAiSBx8Bwg2mrqyYTCY7eB1orLVw2BkLeCnklw 9sSnvyvIReHAlK8a0M2lOUdJUgJiX6UqcKdZH938zgkvk/x38/PrTIs8nWTvJMg/yhH/ ufLg== 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=FoFSN+3dtVp6p7nqx8MdNJWFjGjdW7abKZSiW+jrd3I=; fh=9Hsik6x8C5TtzOEfmQ7fSqQK+L/kyVCu4a7tBzWtauA=; b=06OsQ9fq5Nd+ttqcQl+Q9+51JLAhVn2xdIfJgUDJE11OW93rrUVafRZH/aV3Se101/ kaYpvjWwPAiR2/TP/MNUYlkvloP2MpvfSIj7F0+6sns+y170QYUKtZiflsmfLSgRmJ1a GmS5tnFaGxFIE9qbCZpDJ/OvTyEQDTiXIF04ChVEPS+xsV+TGDpzpn7+loGlcRRWwwVS eVylDSbMdEKkmEHnsAiWlN4F6F91g3RGU7t5jpCutFu2X994loOBuk9f8wjUWbivpk3O JrzqbrJ9Lno8kF6Rj1l7kIWvtwLkM4es0wZDZMBbwJmugoZeEw8XQQkOXbZKjLzfIP32 5SXA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=qTykdAJ2; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-154892-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-154892-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id w19-20020a170902c79300b001e3d2474b16si9178642pla.597.2024.04.23.03.47.24 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Apr 2024 03:47:24 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-154892-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=qTykdAJ2; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-154892-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-154892-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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 2C348B210E8 for ; Tue, 23 Apr 2024 10:46:10 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id ABBCF78C6E; Tue, 23 Apr 2024 10:45:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="qTykdAJ2" 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 B20BF745E2; Tue, 23 Apr 2024 10:45:49 +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=1713869149; cv=none; b=P2RnxjDnbtKjZgA9FzA3RwhC71vy1VHS7epmwEWZjEkjm76SSv1Ibpd5OgpXLVF/ineKwSXBXtSA9tbic45G6ziVSInOdVo/uxKFSf32SrdgaHHyn/1+bBFp5PhLWQBZN72WejaAphyISDSotL5T1l0FO99aLwKQl1jMfbNDIho= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713869149; c=relaxed/simple; bh=fUzqY0ouRur7PJeAXKsb/9zPUDH+Gpv/H3MTr507Vho=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=n1qv8fpfkSxLkUAyznz/2XNaBGVARFdp2WkIke+vfoddk+LjRH/Y+s+y/j8QEdeXpJSgIk7HTyovHujvpkJPoDudAs6EAT2peCLsxLLJuyCfmzWeJR/GWboQGy4CM2LbDSTM73B85PVJnr9EpxbRG7YxA2UvkmjHVf/iWutx25M= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=qTykdAJ2; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id EE31FC3277B; Tue, 23 Apr 2024 10:45:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1713869149; bh=fUzqY0ouRur7PJeAXKsb/9zPUDH+Gpv/H3MTr507Vho=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=qTykdAJ23eQtuaqFVfNK9vZ8fJEoTvPC2z0WNWSsz30Ab7d68i+DTe3YMbwIlP090 Yz7P25i6iDyAboouSyYHWIpLRtULn0ahBTAXMpEuWmFIs2y0bCujpfRnSM1CEMC42e 4RvmeE0lfVhg12+AHfwOA/3DzT8jyRJAnbkTx3P+DirB0y3oD2gYR8wrNjWrnty4SA YpXMzKIE8inMY/LNiIzIrRU9SulGekeMoc/VK0T6QWCPCH6RJBSvB2GWo6wCfpfkO9 sOjrlDcIBNW+ZnamAyC4m9O8A/+kyHZPOXZggtmUBvUUhMpTge4rnK7R8Amfh3Mk/8 Q5+Ht2LPi2o4g== From: Maxime Ripard Date: Tue, 23 Apr 2024 12:45:30 +0200 Subject: [PATCH v12 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: <20240423-kms-hdmi-connector-state-v12-1-3338e4c0b189@kernel.org> References: <20240423-kms-hdmi-connector-state-v12-0-3338e4c0b189@kernel.org> In-Reply-To: <20240423-kms-hdmi-connector-state-v12-0-3338e4c0b189@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=fUzqY0ouRur7PJeAXKsb/9zPUDH+Gpv/H3MTr507Vho=; b=owGbwMvMwCmsHn9OcpHtvjLG02pJDGnqE70+z157UP/HM829C59ZclcE7n+oObv8rNKJk7P+m mm+CXa40jGVhUGYk0FWTJHliUzY6eXti6sc7Ff+gJnDygQyhIGLUwAmElfN2HDVzNGJ55FhmN1n xQ9CEbrltsFTNl94ISKnazbj/YvL22v///n1UIZ9AuvjO/8fhT5S12Ss4ShbsPX5CbMavh+7GwJ cORY+Y/fq595llB356x1n8fP8XxFxZ6/17Us3/MSuLLFWaVMjAA== 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.44.0