Skip to content

cec: backport 5.15 AOCEC driver to 4.9 with __ATTR table refactor#5

Open
samtheruby wants to merge 1 commit into
pannal:amlogic-4.9-20from
samtheruby:cec-backport
Open

cec: backport 5.15 AOCEC driver to 4.9 with __ATTR table refactor#5
samtheruby wants to merge 1 commit into
pannal:amlogic-4.9-20from
samtheruby:cec-backport

Conversation

@samtheruby
Copy link
Copy Markdown

@samtheruby samtheruby commented May 15, 2026

Backport changes

  • Split monolithic hdmi_ao_cec.c into three files (hdmi_ao_cec.c, hdmi_aocec_api.c, hdmi_cec_dump.c) matching the 5.15 driver layout.
  • Replace all aml_mbox calls with scpi_protocol equivalents:
    • MBOX_CMD_SET_CEC_DATA -> scpi_send_cec_data / scpi_send_usr_data
    • MBOX_CMD_GET_CEC1/2 -> scpi_get_cec_val
    • MBOX_CMD_GET_CEC_OTP/AS_MSG -> scpi_get_cec_wk_msg
  • Add get_hdmitx_phy_addr() shim (5.15 accessor not in 4.9 hdmi_tx_ext.h).
  • CEC_MAIL_BOX and CEC_FREEZE_WAKE_UP intentionally left undefined: 4.9 uses scpi_protocol; freeze/s2idle not supported on ng hardware.
  • HPD regression fix: 5.15 cec_hdmi_plug_handler clears stale phy_addr on unplug, preventing phantom active-source responses.
  • Add null guards to hdmitx/hdmirx notify callbacks against races during driver probe/remove.
  • Drop CONFIG_AMLOGIC_HDMITX21 guards (not in 4.9); fix CONFIG_HAS_EARLYSUSPEND -> CONFIG_AMLOGIC_LEGACY_EARLY_SUSPEND; fix HDMIRX include path for 4.9 tree layout.
  • Remove the missing linux/earlysuspend.h include — all needed declarations come from linux/amlogic/pm.h under CONFIG_AMLOGIC_LEGACY_EARLY_SUSPEND.

Refactor on top

  • Replace per-attribute CLASS_ATTR_xx static declarations and the aocec_class_attrs[] pointer array with a single aocec_class_attr_list[] table built from __ATTR_xx macros. Same set of attributes, same RW/RO/WO semantics; cleans up the namespace and makes adding new attributes a one-line change.

Test plan

  • Build + flash on G12B/S922Z.
  • Confirm `/sys/class/aocec/*` exposes the expected attribute set with correct R/W permissions.
  • CEC enumeration with a TV: logical address claim, polling, vendor ID exchange.
  • Route change: switch active source between Kodi and another HDMI input; verify the device releases / re-claims correctly.
  • Power round-trip: TV power-on/off, standby, wake-up — verify ACTIVE_SOURCE and IMAGE_VIEW_ON behave.
  • HPD plug/unplug while running: previous regression (stale phy_addr after unplug) should be gone.
  • Regression test on SM1 (S905X3) if available.
  • libCEC interop with Kodi's PeripheralCecAdapter end-to-end.

Full replacement of the 4.9 AOCEC driver with the 5.15 version, adapted
for the 4.9 Amlogic-ng kernel (G12B/SM1 targets).

Backport changes:
- Split monolithic hdmi_ao_cec.c into three files (hdmi_ao_cec.c,
  hdmi_aocec_api.c, hdmi_cec_dump.c) matching the 5.15 driver layout.
- Replace all aml_mbox calls with scpi_protocol equivalents:
    MBOX_CMD_SET_CEC_DATA       -> scpi_send_cec_data / scpi_send_usr_data
    MBOX_CMD_GET_CEC1/2         -> scpi_get_cec_val
    MBOX_CMD_GET_CEC_OTP/AS_MSG -> scpi_get_cec_wk_msg
- Add get_hdmitx_phy_addr() shim (5.15 accessor not in 4.9 hdmi_tx_ext.h).
- CEC_MAIL_BOX and CEC_FREEZE_WAKE_UP intentionally left undefined: 4.9
  uses scpi_protocol; freeze/s2idle not supported on ng hardware.
- HPD regression fix: 5.15 cec_hdmi_plug_handler clears stale phy_addr on
  unplug, preventing phantom active-source responses.
- Add null guards to hdmitx/hdmirx notify callbacks against races during
  driver probe/remove.
- Drop CONFIG_AMLOGIC_HDMITX21 guards (not in 4.9); fix
  CONFIG_HAS_EARLYSUSPEND -> CONFIG_AMLOGIC_LEGACY_EARLY_SUSPEND; fix
  HDMIRX include path for 4.9 tree layout.
- Remove the missing linux/earlysuspend.h include — all needed
  declarations come from linux/amlogic/pm.h under
  CONFIG_AMLOGIC_LEGACY_EARLY_SUSPEND.

Refactor on top:
- Replace per-attribute CLASS_ATTR_xx static declarations and the
  aocec_class_attrs[] pointer array with a single aocec_class_attr_list[]
  table built from __ATTR_xx macros. Same set of attributes, same
  RW/RO/WO semantics; cleans up the namespace and makes adding new
  attributes a one-line change.
@samtheruby
Copy link
Copy Markdown
Author

samtheruby commented May 15, 2026

All possible tests passed, As well as 0 bugs when in regular use, I think this is ready for prime time!

@samtheruby
Copy link
Copy Markdown
Author

Please note this also requires the fix pannal/CoreELEC#52

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant