Did some testing now and at least this fix SDR/DV VS10 and back in DV-Std and DV-LL mode:
diff --git a/resources/lib/ui/mode_select.py b/resources/lib/ui/mode_select.py
index f30819a..6b3b4ee 100644
--- a/resources/lib/ui/mode_select.py
+++ b/resources/lib/ui/mode_select.py
@@ -33,6 +33,15 @@ _DVMODE = "/sys/class/amdolby_vision/dv_mode"
# for that playback and not for an HDR10 one -- see ``_player_led_mode``.
_LL_POLICY = "/sys/module/aml_media/parameters/dolby_vision_ll_policy"
+_DOLBY_VISION_LL_DISABLE = "0"
+_DOLBY_VISION_LL_YUV422 = "1"
+
+_DV_STATUS = "/sys/module/aml_media/parameters/dolby_vision_status"
+
+_DV_STATUS_OFF = "0"
+_DV_STATUS_ON = "1"
+
+
# dolby_vision_policy: AMDV_FOLLOW_SINK, AMDV_FOLLOW_SOURCE and
# AMDV_FORCE_OUTPUT_MODE. Forcing is what a VS10 mode is; follow-source is what
# Kodi leaves behind when it turns Dolby Vision off, and so what a mode that
@@ -120,6 +129,22 @@ def _dv_output_active() -> bool:
return _read(_DV_OUTPUT) in _DV_OUTPUT_MODES
+def _dv_status_off() -> bool:
+ """Poll if Dolby Vision is on."""
+ return _read(_DV_STATUS) == _DV_STATUS_OFF
+
+
+def _wait_for_dv_status_off(timeout_ms: int = 500, step_ms: int = 50) -> bool:
+ """Poll the DV driver state, returning True when DV status goes off."""
+ waited = 0
+ while waited < timeout_ms:
+ _delay(step_ms)
+ waited += step_ms
+ if _dv_status_off():
+ return True
+ return True
+
+
def _wait_for_dv_output_change(
before: bool,
timeout_ms: int = _DV_OUTPUT_TIMEOUT_MS,
@@ -183,14 +208,6 @@ def _reset_display_on_dv_change(name: str, dv_before: bool) -> None:
if (name in _DV_MODES) == dv_before:
return
- if not _player_led_mode():
- xbmc.log(
- f"TinyPPI: '{name}' crossed the Dolby Vision line, but this box is "
- "TV-LED and signals that itself -> no display reset",
- xbmc.LOGINFO,
- )
- return
-
if not _wait_for_dv_output_change(dv_before):
xbmc.log(
f"TinyPPI: '{name}' did not move the driver's output mode "
@@ -216,14 +233,31 @@ def _write_sequence(
def _set_passthrough_mode(dv_mode: str, delay_ms: int = 100) -> None:
"""Set the CoreELEC policy and enable Dolby Vision in the requested mode."""
- _write_sequence(
- (
- (_POLICY, _POLICY_FORCE_OUTPUT),
- (_ENABLE, "Y"),
- (_DVMODE, dv_mode),
- ),
- delay_ms=delay_ms,
- )
+ steps = []
+
+ if dv_mode != _MODE_BYPASS:
+ steps.append((_ENABLE, "Y"))
+ steps.append((_POLICY, _POLICY_FORCE_OUTPUT))
+ else:
+ steps.append((_POLICY, _POLICY_FOLLOW_SOURCE))
+
+ if dv_mode == _MODE_DV_TUNNEL:
+ steps.append((_LL_POLICY, _DOLBY_VISION_LL_DISABLE))
+ elif dv_mode == _MODE_DV_IPT:
+ steps.append((_LL_POLICY, _DOLBY_VISION_LL_YUV422))
+
+ steps.append((_DVMODE, dv_mode))
+
+ _write_sequence(tuple(steps), delay_ms=delay_ms)
+
+ _wait_for_dv_status_off()
+
+ if dv_mode == _MODE_BYPASS:
+ _write_sequence(
+ (
+ (_ENABLE, "N"),
+ )
+ )
def _set_sdr_conversion_mode(dv_mode: str) -> None:
A second issue is you can’t just swap from HDR10 to DV or vise versa.
You need to reset to SDR first to get correct display parameter.
But the switch to SDR, then to HDR in one call does not work. It must be splited thread calls.
So a interlock matrix like:
if control_id == 1003:
self.getControl(1004).setEnabled(False)
elif control_id == 1004:
self.getControl(1003).setEnabled(False)
elif control_id == 1002:
self.getControl(1003).setEnabled(True)
self.getControl(1004).setEnabled(True)
and same for the 2 others should somehow work.
Then user must go back to SDR first before he can go to HDR when he was on DV.
Then this diff is also need to:
diff --git a/resources/lib/ui/mode_select.py b/resources/lib/ui/mode_select.py
index 6b3b4ee..5ff78e8 100644
--- a/resources/lib/ui/mode_select.py
+++ b/resources/lib/ui/mode_select.py
@@ -261,12 +261,11 @@ def _set_passthrough_mode(dv_mode: str, delay_ms: int = 100) -> None:
def _set_sdr_conversion_mode(dv_mode: str) -> None:
- """Reset to SDR first, then enable the requested conversion mode."""
+ """Enable the requested conversion mode."""
_write_sequence(
(
- (_POLICY, _POLICY_FORCE_OUTPUT),
- (_DVMODE, _MODE_BYPASS),
(_ENABLE, "Y"),
+ (_POLICY, _POLICY_FORCE_OUTPUT),
(_DVMODE, dv_mode),
)
)