Learning about Dolby Vision and CoreELEC development

Updated build - Increased compatibility
Minor update to work with older displays as well and a better approach to injecting metadata to make finding the ‘magic’ values easier (@xmlcom thanks for the previous testing showing this was needed)


Test build:


Usage:
Initial once-off setup: Set kodi to use 12-bit 422 with a 3840 x 2160 gui resolution. Enable the option “Disable GUI scaling”. Reboot.

If you have changed the whitelist function make sure it always causes a 2160p display mode.

Ensure you only use frame rate that your tv supports DV mode in, i.e., older TV’s can’t do more than 30Hz (@xmlcom this is you).

Initial test
Start with testing the rise_of_gru_sample_10bit_embedded.mkv test. When playing and no gui, run

echo N > /sys/module/amvideo/parameters/inject_osd_metadata
echo Y > /sys/module/am_vecm/parameters/DV_vsif_send_in_hdmi_packet
echo DV_enable > /sys/devices/virtual/amhdmitx/amhdmitx0/attr
echo Y > /sys/module/am_vecm/parameters/always_send_tvled_DV_vsif

TV-led DV should now be working. If so, disable with

echo N > /sys/module/am_vecm/parameters/always_send_tvled_DV_vsif
echo N > /sys/module/am_vecm/parameters/DV_vsif_send_in_hdmi_packet
echo DV_disable_vsif > /sys/devices/virtual/amhdmitx/amhdmitx0/attr

and move onto setup of the on-the-fly injection.

On-the-fly metadata injection
Need some trial and error to find values that work for different devices. Method of injecting metadata has been improved compared to process done by @xmlcom in the discussions above. Now has ~25% success rate so shouldn’t take very long to find a working value.

The parameter is injected_value. Read with

cat /sys/module/amvideo/parameters/injected_value

Write with, for example the value of 1 with

 echo 1 > /sys/module/amvideo/parameters/injected_value

Valid values are 0 to 764. Use a trial and error approach with this value with the usage commands below to find a value that work for your device.

My tv worked with changing this value on the fly. If you have issues try using the disable commands below, changing the value, and then re-enabling.


Use:
To use trigger DV with a video (any video, doesn’t need to be DV) playing by

echo Y > /sys/module/amvideo/parameters/inject_osd_metadata
echo Y > /sys/module/am_vecm/parameters/DV_vsif_send_in_hdmi_packet
echo DV_enable > /sys/devices/virtual/amhdmitx/amhdmitx0/attr

Will need to do this for every video started.

Note: When the videos stop the gui will by in all the wrong colors. If you want to correct that enter the ssh commands

echo N > /sys/module/am_vecm/parameters/DV_vsif_send_in_hdmi_packet
echo DV_disable_vsif > /sys/devices/virtual/amhdmitx/amhdmitx0/attr

and then do something that triggers a resolution/refresh rate change.


There are two buffers for DV metadata setup - these are not yet being set by metadata from video files. The two are initially loaded with metadata for a source in the IPT (i.e., profile 5) colorspace with very different L1 data.

Change to suit profile 8.1 with

echo 0,0,0,0,82,0,0,37,102,0,0,53,234,37,102,249,252,235,28,37,102,68,202,0,0,1,0,0,0,8,0,0,0,8,0,0,0,28,54,34,67,1,134,14,70,48,142,5,20,0,0,1,166,62,90,255,255,0,0,0,0,0,0,0,0,12,0,1,0,0,62,11,134,42,42,1,0,0,0,6,1,0,20,0,50,0,35,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,11,120,97,107 > /sys/module/amvideo/parameters/metadata_buffer
echo 0,0,0,0,82,0,0,37,102,0,0,53,234,37,102,249,252,235,28,37,102,68,202,0,0,1,0,0,0,8,0,0,0,8,0,0,0,28,54,34,67,1,134,14,70,48,142,5,20,0,0,1,166,62,90,255,255,0,0,0,0,0,0,0,0,12,0,1,0,0,62,11,134,42,42,1,0,0,0,6,1,5,220,13,172,11,184,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,194,81,228,196 > /sys/module/amvideo/parameters/metadata_buffer2

Change back to IPT with

echo 0,0,0,0,82,0,0,32,0,3,31,6,145,32,0,252,91,4,67,32,0,1,11,234,87,0,0,0,0,8,0,0,0,8,0,0,0,66,185,254,163,254,163,254,163,66,185,254,163,254,163,254,163,66,185,255,255,0,0,0,0,0,0,0,0,12,2,1,1,0,62,11,134,0,42,1,0,0,0,6,1,0,20,0,50,0,35,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,189,151,135,54 > /sys/module/amvideo/parameters/metadata_buffer
echo 0,0,0,0,82,0,0,32,0,3,31,6,145,32,0,252,91,4,67,32,0,1,11,234,87,0,0,0,0,8,0,0,0,8,0,0,0,66,185,254,163,254,163,254,163,66,185,254,163,254,163,254,163,66,185,255,255,0,0,0,0,0,0,0,0,12,2,1,1,0,62,11,134,0,42,1,0,0,0,6,1,5,220,13,172,11,184,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,116,190,2,153 > /sys/module/amvideo/parameters/metadata_buffer2

By default these two sets of metadata will be switched between every 125 frames. Can set this timing to whatever, for every 250 frames use

 echo 250 > /sys/module/amvideo/parameters/num_frames_to_toggle_metadata

To disable the auto toggling use

 echo 0 > /sys/module/amvideo/parameters/num_frames_to_toggle_metadata

Can also manually toggle with

echo Y > /sys/module/amvideo/parameters/metadata_toggle

Let me know if it works or not

2 Likes