Currently it is next to impossible to implement CEC handling for the setup using drm_bridges and drm_bridge_connector: bridges don't have a hold of the connector at the proper time to be able to route CEC events. At the same time it not very easy and obvious to get the CEC physical address handling correctly. Drivers handle it at various places, ending up with the slight differences in behaviour. Follow up the HDMI Connector and HDMI Audio series and implement generic HDMI CEC set of helpers that link into the HDMI Connector and drm_bridge_connector frameworks and provide a way to implement CEC handling for HDMI bridges in an easy yet standard way. Notes: - the patchset was only compile-tested - being an RFC some of the API functions and structures are left undocumented - although the patchset provides drm_bridge / drm_bridge_connector API for working with CEC, there is no actual bridge that uses the API (yet) - I'm pretty unhappy with the drm_bridge integration code, we end up duplicating wrappers for CEC functions instead of reusing the drm_connector wrapping functions. An easy way would be to map drm_bridge to the corresponding drm_connector, but that would either require a state or storing drm_connector inside a drm_bridge. Current code stores cec_adapter instead. Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@xxxxxxxxxx> --- Changes in v4: - Rebased on top of drm-misc-next + commit 78a5acf5433d ("drm/display: hdmi: Do not read EDID on disconnected connectors") - Moved 'select DRM_DISPLAY_HDMI_CEC_HELPER' under the DRM_I2C_ADV7511_CEC symbol - Fixed documentation for @hdmi_audio_i2s_formats to describe default behaviour. - Split drm_connector_cleanup() patch from the patch adding CEC-related data structures (Maxime). - Documented that CEC mutex protects all data fields in struct drm_connector_cec (Maxime). - Improved drm_connector_cec_funcs.unregister() documentation. - Documented struct drm_connector_hdmi_cec_adapter_ops fields. Added a note to the commit message on the difference between it and struct drm_connector_cec_funcs (Maxime). - Fixed Kconfig dependencies. - Link to v3: https://lore.kernel.org/r/20250126-drm-hdmi-connector-cec-v3-0-5b5b2d4956da@xxxxxxxxxx Changes in v3: - Moved default available_las setting to drm_connector_hdmi_cec_register(), allowing drivers to pass 0 instead of CEC_MAX_LOG_ADDRS. - Reworked drm_bridge interface to store opaque pointer and interpret it as drm_connector in CEC helpers code. - Fixed EINVAL checks in drm_connector_hdmi_cec_register(). - Added the adv7511 patch, demonstrating CEC helpers for the DRM bridges. - Link to v2: https://lore.kernel.org/r/20250110-drm-hdmi-connector-cec-v2-0-9067c8f34663@xxxxxxxxxx Changes in v2: - Refactored CEC funcs, adding more wrappers to provide more consistent interface (Maxime) - Removed export of drm_connector_cec_unregister() (Maxime) - Restored and rephrased comment in vc4_hdmi (Maxime) - Squashed vc4 patches - Link to v1: https://lore.kernel.org/r/20241225-drm-hdmi-connector-cec-v1-0-b80380c67221@xxxxxxxxxx --- Dmitry Baryshkov (12): drm/connector: add CEC-related fields drm/connector: unregister CEC data drm/display: move CEC_CORE selection to DRM_DISPLAY_HELPER drm/display: add CEC helpers code drm/display: hdmi-state-helper: handle CEC physical address drm/vc4: hdmi: switch to generic CEC helpers drm/display: bridge-connector: hook in CEC notifier support drm/bridge: move private data to the end of the struct drm/display: hdmi-cec-helper: add bridge-related functions drm/display: bridge-connector: handle CEC adapters drm/bridge: allow limiting I2S formats drm/bridge: adv7511: switch to the HDMI connector helpers drivers/gpu/drm/bridge/adv7511/Kconfig | 5 +- drivers/gpu/drm/bridge/adv7511/adv7511.h | 51 ++-- drivers/gpu/drm/bridge/adv7511/adv7511_audio.c | 77 +----- drivers/gpu/drm/bridge/adv7511/adv7511_cec.c | 56 ++-- drivers/gpu/drm/bridge/adv7511/adv7511_drv.c | 342 ++++++++++-------------- drivers/gpu/drm/bridge/adv7511/adv7533.c | 4 - drivers/gpu/drm/bridge/lontium-lt9611.c | 2 +- drivers/gpu/drm/display/Kconfig | 9 +- drivers/gpu/drm/display/Makefile | 2 + drivers/gpu/drm/display/drm_bridge_connector.c | 105 +++++++- drivers/gpu/drm/display/drm_hdmi_audio_helper.c | 2 + drivers/gpu/drm/display/drm_hdmi_cec_helper.c | 247 +++++++++++++++++ drivers/gpu/drm/display/drm_hdmi_state_helper.c | 7 +- drivers/gpu/drm/drm_bridge.c | 15 ++ drivers/gpu/drm/drm_connector.c | 13 + drivers/gpu/drm/vc4/Kconfig | 1 + drivers/gpu/drm/vc4/vc4_hdmi.c | 140 ++++------ drivers/gpu/drm/vc4/vc4_hdmi.h | 1 - include/drm/display/drm_hdmi_audio_helper.h | 1 + include/drm/display/drm_hdmi_cec_helper.h | 94 +++++++ include/drm/drm_bridge.h | 79 ++++-- include/drm/drm_connector.h | 46 ++++ 22 files changed, 863 insertions(+), 436 deletions(-) --- base-commit: 7271a88629857dc285d4291055b8e7811f9d3603 change-id: 20241223-drm-hdmi-connector-cec-34902ce847b7 prerequisite-message-id: 20250113-hdmi-conn-edid-read-fix-v2-1-d2a0438a44ab@xxxxxxxxxxxxx prerequisite-patch-id: 87a719632f0ca1a6f3c0a495eef515a463c3fa7d Best regards, -- Dmitry Baryshkov <dmitry.baryshkov@xxxxxxxxxx>