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.barysh...@linaro.org>
---
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-9067c8f34...@linaro.org

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-b80380c67...@linaro.org

---
Dmitry Baryshkov (10):
      drm/connector: add CEC-related fields
      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          |   4 +
 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                 |   6 +
 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 |   9 +-
 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       |  69 +++++
 include/drm/drm_bridge.h                        |  77 ++++--
 include/drm/drm_connector.h                     |  44 +++
 22 files changed, 834 insertions(+), 434 deletions(-)
---
base-commit: 7c3127e4814c304c7d5a2fa796a42e75a9b8606f
change-id: 20241223-drm-hdmi-connector-cec-34902ce847b7

Best regards,
-- 
Dmitry Baryshkov <dmitry.barysh...@linaro.org>

Reply via email to