Received: by 2002:ab2:788f:0:b0:1ee:8f2e:70ae with SMTP id b15csp561283lqi; Thu, 7 Mar 2024 05:39:55 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWsCAjIoFLImGYlkk4tI90bBkb8SIlowcSP13c22c5iqRzLjF/djoY/powKd5+NHtoatZWUimsIfM5lz3Or09inP8DiX09AGDtLWm03hQ== X-Google-Smtp-Source: AGHT+IEJLqMuMGYY6FXOeTbjUbyPf5sI4XJZ8OU8Uo+a92FJJMS1Dm6IYCua8zgKR5QmQmu/IDWF X-Received: by 2002:a17:903:2343:b0:1d9:3bb5:2819 with SMTP id c3-20020a170903234300b001d93bb52819mr10182509plh.34.1709818795320; Thu, 07 Mar 2024 05:39:55 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709818795; cv=pass; d=google.com; s=arc-20160816; b=FWTkext6Dv2SjZhB8ZRYLRNIBMklJz6nOqIGUVJO61gVHLdgLisXuJUhjPqWblssjK EB7pCRt1bZxXQk6klROlpc304TRHcqY4ot3GN72aaHpecuaQhWAs+gNrHKzXSkBFZIj3 NVfLpHgNZ1ErHyP8DwFG4mhbq6e5+cUCTXTIDRlze/5VCHjsz14P4xIRJ0UwIG4UHZce iV+iVFrZse0eeFCrN954dV3QqjSco+XxLQXsC7UwwA9zFzuJxRLAtJI74Xf1KVmpcERr vAkCnJNUggetEFsreBwo/sUM5JgDfEaiuM/IQ8zHcHny0I/0BziETjCv88D/Na2bWYo9 3DyQ== 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=FIheTSeTUA4ggvnHTiVrQo9HFsJIN1tVBvMc47r3zEs=; fh=8wcoxKk21hICD+6obVirG13fsSSMhKa/pufykSf87d0=; b=pM+4jgCVXfrb3qs8E2b4aa6+LIryoDeLQpEMrcXSm1HT7lMzB0qd8T1eYcvWZpZBI2 n9wNe7aNj31eR9WtKmuz6Mrsl+AoxK6g+twWsHtuqPU1y/7VQIjBzn3pmrME1+W2HbId XGIBvPKFjFym0ECfeXg46c7S3meLjujSnzRP5G+6nsJD8izUtgeqlavei4RgYUSNHmiE KnJzumicLWQUoTcN08FQD3lFxMSgegY4y1hD2nZAzXwHhilkRLa8Q504N8qYk9eFHTAB bN9kOxIXpEI4mS2l/+jEj3PBb5uM6YZxWKX18ulazV9QnNwJ8Nq8HdFZ1ibtEucXqGMC +Y5w==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=p0LZQl4v; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-95620-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-95620-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id mf15-20020a170902fc8f00b001dd07e1394fsi8627333plb.565.2024.03.07.05.39.55 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Mar 2024 05:39:55 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-95620-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=p0LZQl4v; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-95620-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-95620-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 050B5282828 for ; Thu, 7 Mar 2024 13:39:55 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id EFF2A12EBCE; Thu, 7 Mar 2024 13:38:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="p0LZQl4v" 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 F0A2B12E1EA; Thu, 7 Mar 2024 13:38:58 +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=1709818739; cv=none; b=kYh9TodUFGGPbGVtcMnkS14sxJJDP7AY9wvXE4hi1hSTQPptUyC4g7cjL7K43k7gnFy36VoIqbZqv4EUSsuMpqRDUlJauvfhknPSCGE5I+N3cILD3AMH4aLF5q+h8l/jBzw1T3743lT/ixYhbLJI2T9manhPzQYgW67aPk+DUMU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709818739; c=relaxed/simple; bh=uITNeO8iu5HQmM+XePNnDpEdGi4EM3JrAF8vMV6INqk=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=cWkBQCvhJdBAQGSjXEvp02hQy5U44TnDpkf5aRwg0f5hxQB36YW0Q6RMbMDPPytqrVLLY3v0ZNaDkI/XOnQwAo1DD1LKNsHFyTdLOhVM3i2WNVgo17UhPO/7sl4UKrdOZr65au+cGMibkXboV8gjWf3k150gBKZ6Sg2TwDHTCzA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=p0LZQl4v; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7D675C43390; Thu, 7 Mar 2024 13:38:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1709818738; bh=uITNeO8iu5HQmM+XePNnDpEdGi4EM3JrAF8vMV6INqk=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=p0LZQl4vQo1L7AtHVWq5j6k+N1/Zfhf3/+cdVg2aSTvDX448azNIs+9l76ZevPE5+ Q+me9GpZSJXI0rOAbHkNUVn9QcREgLMGsLSZv0mY5xLULheaTfHfhM3xUn8hj1bcI0 YLMgS1um+NcMH/fUSkp5L/TeiFlQcVkdPwdlw/EqCiEx84ywijsS/ftWddaXUrMOat GKDQa5/00zPb4iLNs/0X4emF5hhqrwBgwwLhszcpyA8r/Z0deByXt7CTObSR3PNIgP qYUQuF7VM558o1FIwS0bLDax7QhR9B30XT+g27zVY1UJDXmf5lhPQ+jYSHkW9kwern E1oXpdBjjvieA== From: Maxime Ripard Date: Thu, 07 Mar 2024 14:38:28 +0100 Subject: [PATCH v8 01/27] 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: <20240307-kms-hdmi-connector-state-v8-1-ef6a6f31964b@kernel.org> References: <20240307-kms-hdmi-connector-state-v8-0-ef6a6f31964b@kernel.org> In-Reply-To: <20240307-kms-hdmi-connector-state-v8-0-ef6a6f31964b@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 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 X-Mailer: b4 0.12.3 X-Developer-Signature: v=1; a=openpgp-sha256; l=3792; i=mripard@kernel.org; h=from:subject:message-id; bh=uITNeO8iu5HQmM+XePNnDpEdGi4EM3JrAF8vMV6INqk=; b=owGbwMvMwCX2+D1vfrpE4FHG02pJDKkvD0eL6D20nXCnq6NTm5F5U1xPw2f1+Qnsc4w8c06/z 03y6JncUcrCIMbFICumyBIjbL4k7tSs151sfPNg5rAygQxh4OIUgIk8/cPIsLTA9dZ/7/9Cz/ke Hv6yxWeSD9O1tuzG4k/20u6z1VoXnGFkuJnWvmwKW+vFqTMV8o/Z+HU/7j31hsHndeFVtgcnSuM yGAA= 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 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.43.2