From nobody Tue Feb 10 09:10:59 2026 Received: from mail-lf1-f49.google.com (mail-lf1-f49.google.com [209.85.167.49]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6D08B16D9C2 for ; Tue, 24 Dec 2024 23:10:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.49 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735081823; cv=none; b=igiDjaUOQDjhx4AombWyWZsCDCXAC+rP2Wm/rmYf2MgIK5kGvIgiSV8Ry+VD8gOxYa793VWbtoL5Lo7N/Js30wXuD9MYcCfzrSQ4IYRcosKJ3lb0jpZYH+vVFu/IDFLf4NmWfesi/vwVpm6GN9fdl6RBSZh416f2f9yCtZxLZjM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735081823; c=relaxed/simple; bh=zAP9ylKK8F/k8ADKJQaYiAs3G6twCNuwzluDDLOa0/w=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=hC2mSQFmuYxqq9S5ZHQtBGK5nSLJLSKY4HSbU5kDkYaX8RYDlQXKhOltZnGsdLgxb1qzWVLDMvn9EWeVNpGkJbS9EEwxECnQUIUo3//niOOTMYg3+RDhJ9Fgi79jyyYi+irnTOKufvd22xURzpd4l/8QEDBOqEO6yZ2BfOmbvtg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=x/Dct+2j; arc=none smtp.client-ip=209.85.167.49 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="x/Dct+2j" Received: by mail-lf1-f49.google.com with SMTP id 2adb3069b0e04-53f757134cdso6006912e87.2 for ; Tue, 24 Dec 2024 15:10:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1735081819; x=1735686619; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=gkEAYK8kPNECxsGkRJpsJ7xiXmTY2irxwmm/stUUQ/U=; b=x/Dct+2jS1ovln6Po6/i89SpASf6IFeDiH2RgSVC2924UC9pjcXZ0N/5920e9shfOs BNKG5xjSPiPk+9GeCq6BhgmRdFw1ueRGF62MAF5nyhqJZQR5BJ+KNZ7sze95V1yEjXem oJqNGDIV0XjwjHT7h1WfU80wBWIiHhxwiBcKw79nYlpV/zzN+xEdS8TERyIQh2SJJJQK jkuqwnavZgJgqmgiMAKP2KOnbrW9tSFoKDap6rHOK2kahcjdZHkRWpIhWv6TN0NqlqZv Rk7vp3bFKuD/J/SoeMy4Rve0uPzpzO2h7bSisQ5y3P0elBPs9ltc3JP1WokrG/rrgF7w g3Xg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1735081819; x=1735686619; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=gkEAYK8kPNECxsGkRJpsJ7xiXmTY2irxwmm/stUUQ/U=; b=HSTbpYt/Bwt9zCqaGme0MCDIanImdsk2r5PNO653/kggiV9yf80j5vxMv0klgtJguu g+ZVeyd/ERUeqBP0AwhyXGE7RH8z2JvUQGSBa8yereLeu51poah4Fo6hyXO/xU/v3MiR x83mOIZR8GV/mPe6BAMHcHxXcBNIAnBkeDmGXKg9+hCKpnMmfFa8DEILDMNqie2RD3gQ KQsJGBdMR5hEgjy2OSwi3CRmN9oVRux/kPwrKvesGIlLc+vua6TsF39PVl8USRTz0vCq ++UfKwpZ6uFz+xsSx2wsm3vk6Y74TD6Alz3qWqXCZ0CdqVuz5yBMMhqWbX8J4OtAVq9R v1Rg== X-Forwarded-Encrypted: i=1; AJvYcCULUH5B+rqaEhpaUHih+FKRu7i5QVT4nD6BVIAdACRrNPxfKT9R1lICzP3SUZ7HmQiFNpXdt+baAr2KcWY=@vger.kernel.org X-Gm-Message-State: AOJu0YwEYsBtD+fRTIRgJVnxUNgEE7F/cP9WcjI0bdh9hxQVdVA0yR4i 8R4JE6TYpxhxB2BjRh6k7GFCdVkUiuJjanLRxPQAA2OOXwSJDYHB8mGM7eSrCvQ= X-Gm-Gg: ASbGncvL7Qw899cv3RnAiheW8EorAE6R0zGjobidd/u9KoGrdOD3/sSHgNPE9Trocy/ YsE7uDnQA8Zjy/YK6RA/a7XXM2U2J68bIMsUEq3L+pLqmQRNaMXCnePoRoKtNKpW9znkriulCNl 8xAW5xkU1PjVuGraEMX5tHo9qNMA351g2u35ADsdQO2NYh22a+jW0NsLDqtMxRcnrzeiSupNKfS 0LoEO+tG0mkiQCl2+Sa+6B7YnJCrBk7AQso8k/iwOJ2OKtBa7pPMD9JlV99wRaA X-Google-Smtp-Source: AGHT+IEwyLXiTl6HwqZYINQzprUx9IZAjXK9evHUTV0H4dLVrHUyChVy+Pe58BeM4nIcvMJsFNUKTA== X-Received: by 2002:a05:6512:239b:b0:53e:44a4:34e0 with SMTP id 2adb3069b0e04-5422953306amr6782564e87.16.1735081819558; Tue, 24 Dec 2024 15:10:19 -0800 (PST) Received: from umbar.lan ([192.130.178.90]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-542235f5f74sm1721283e87.43.2024.12.24.15.10.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Dec 2024 15:10:18 -0800 (PST) From: Dmitry Baryshkov Date: Wed, 25 Dec 2024 01:10:09 +0200 Subject: [PATCH RFC/RFT 1/9] drm/connector: add CEC-related fields 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: quoted-printable Message-Id: <20241225-drm-hdmi-connector-cec-v1-1-b80380c67221@linaro.org> References: <20241225-drm-hdmi-connector-cec-v1-0-b80380c67221@linaro.org> In-Reply-To: <20241225-drm-hdmi-connector-cec-v1-0-b80380c67221@linaro.org> To: Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Simona Vetter , Dave Stevenson , =?utf-8?q?Ma=C3=ADra_Canal?= , Raspberry Pi Kernel Maintenance , Andrzej Hajda , Neil Armstrong , Robert Foss , Laurent Pinchart , Jonas Karlman , Jernej Skrabec Cc: dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=4628; i=dmitry.baryshkov@linaro.org; h=from:subject:message-id; bh=zAP9ylKK8F/k8ADKJQaYiAs3G6twCNuwzluDDLOa0/w=; b=owEBbQGS/pANAwAKAYs8ij4CKSjVAcsmYgBnaz9VkF4oX+7gjkZP8Y1yKMqgeZkKR90iM2yAs HhTV8Tw6NqJATMEAAEKAB0WIQRMcISVXLJjVvC4lX+LPIo+Aiko1QUCZ2s/VQAKCRCLPIo+Aiko 1XUoCACouGUa5oAtjD5GnC3gjruGwotvNm5gGr85SrA2/2pOOxq9l+xKlniMFWQJUctZSR4hwUw z0FsPogNoXzjPlpIbcOy8l0yL2OqeY67nIRTP+dn2BPL6hu7Z/p1WLqJ+hZ65DN/FCYC2Wd4TrW 5qY5PssSUpxywdZIow7P62xhJvUcMleK8wob+tB9b4ObCb6IjBJDEdT3+3+JBfXP5aV5CgwrEUP 3uN3u9K4Xu4JgIDHBR2y9E0wMjOkPr5X71LPX8QRkhXC+eSJdFyqEtx2tZzgUR34lPLW8ZGf8xL ygyhLgFERD3wYyQXapYukJPLcrwhdQLUDKmWmX83FUAxvjvc X-Developer-Key: i=dmitry.baryshkov@linaro.org; a=openpgp; fpr=8F88381DD5C873E4AE487DA5199BF1243632046A As a preparation to adding HDMI CEC helper code, add CEC-related fields to the struct drm_connector. Include both cec_adapter and cec_notifier, allowing drivers to select which one to use. The unregister callback is provided to let drivers unregister CEC-related data in a generic way without polluting drm_connector.c with dependencies on the CEC functions. Signed-off-by: Dmitry Baryshkov --- drivers/gpu/drm/drm_connector.c | 23 ++++++++++++++++++++++ include/drm/drm_connector.h | 43 +++++++++++++++++++++++++++++++++++++= ++++ 2 files changed, 66 insertions(+) diff --git a/drivers/gpu/drm/drm_connector.c b/drivers/gpu/drm/drm_connecto= r.c index 1383fa9fff9bcf31488453e209a36c6fe97be2f1..ef299733041e2c64bebd73c3fe2= 1d4492bc07d3a 100644 --- a/drivers/gpu/drm/drm_connector.c +++ b/drivers/gpu/drm/drm_connector.c @@ -279,6 +279,7 @@ static int drm_connector_init_only(struct drm_device *d= ev, INIT_LIST_HEAD(&connector->probed_modes); INIT_LIST_HEAD(&connector->modes); mutex_init(&connector->mutex); + mutex_init(&connector->cec.mutex); mutex_init(&connector->eld_mutex); mutex_init(&connector->edid_override_mutex); mutex_init(&connector->hdmi.infoframes.lock); @@ -698,6 +699,26 @@ static void drm_mode_remove(struct drm_connector *conn= ector, drm_mode_destroy(connector->dev, mode); } =20 +/** + * drm_connector_cec_unregister - clean up CEC registration + * @connector: connector to cleanup + * + * Reverse corresponding CEC registration. This function is supposed to be + * called only by bridge drivers which need to handle CEC manually. Normal= ly + * CEC adapter or notifier are automatically unregistered during drm_conne= ctor + * teardown. + */ +void drm_connector_cec_unregister(struct drm_connector *connector) +{ + mutex_lock(&connector->cec.mutex); + + if (connector->cec.unregister) + connector->cec.unregister(connector); + + mutex_unlock(&connector->cec.mutex); +} +EXPORT_SYMBOL(drm_connector_cec_unregister); + /** * drm_connector_cleanup - cleans up an initialised connector * @connector: connector to cleanup @@ -718,6 +739,8 @@ void drm_connector_cleanup(struct drm_connector *connec= tor) =20 platform_device_unregister(connector->hdmi_audio.codec_pdev); =20 + drm_connector_cec_unregister(connector); + if (connector->privacy_screen) { drm_privacy_screen_put(connector->privacy_screen); connector->privacy_screen =3D NULL; diff --git a/include/drm/drm_connector.h b/include/drm/drm_connector.h index f13d597370a30dc1b14c630ee00145256052ba56..feecd02e7c698cc0c553b79048c= 9130f69121012 100644 --- a/include/drm/drm_connector.h +++ b/include/drm/drm_connector.h @@ -46,6 +46,7 @@ struct drm_property_blob; struct drm_printer; struct drm_privacy_screen; struct drm_edid; +struct cec_adapter; struct edid; struct hdmi_codec_daifmt; struct hdmi_codec_params; @@ -1832,6 +1833,41 @@ struct drm_connector_hdmi { } infoframes; }; =20 +/** + * struct drm_connector_cec - DRM Connector CEC-related structure + */ +struct drm_connector_cec { + /** + * @mutex: protects all CEC-related fields + */ + struct mutex mutex; + + /** + * @adap: CEC adapter corresponding to the DRM connector. + */ + struct cec_adapter *adapter; + + /** + * @notifier: CEC notifier corresponding to the DRM connector. + */ + struct cec_notifier *notifier; + + /** + * @adap_unregister: unregister CEC adapter / notifier. + * + * The callback to unregister CEC adapter or notifier, so that the core + * DRM layer doesn't depend on the CEC_CORE. + */ + void (*unregister)(struct drm_connector *connector); + + /** + * @uninit_cec_cb: teardown CEC adapter + * + * Perform additional tasks to teardown the CEC adapter. + */ + void (*uninit_cec)(struct drm_connector *connector); +}; + /** * struct drm_connector - central DRM connector control structure * @@ -2253,6 +2289,11 @@ struct drm_connector { * @hdmi_audio: HDMI codec properties and non-DRM state. */ struct drm_connector_hdmi_audio hdmi_audio; + + /** + * @cec: CEC-related data. + */ + struct drm_connector_cec cec; }; =20 #define obj_to_connector(x) container_of(x, struct drm_connector, base) @@ -2294,6 +2335,8 @@ int drm_connector_attach_encoder(struct drm_connector= *connector, =20 void drm_connector_cleanup(struct drm_connector *connector); =20 +void drm_connector_cec_unregister(struct drm_connector *connector); + static inline unsigned int drm_connector_index(const struct drm_connector = *connector) { return connector->index; --=20 2.39.5