Learning about Dolby Vision and CoreELEC development

They wouldn’t licence something and then just accept it if someone finds a workaround. Every device in the chain has had to pay for DV certification since inception. They don’t have a legal team on the payroll just sitting around. Up to CE, but I wouldn’t get involved. If someone personally made a build available, be it on them. I’m not staff though, just my opinion. Why bother.

Even Dolby Vision licensed devices need compatible dovi.ko modules to play Dolby Vision. At the moment there are no 5.15 dovi.ko modules for any of the CE-NG devices, and likely never will be. This work may be the only hope of these licensed NG devices having any DV playback capabilities in CE-NO (5.15).

I’m not sure if this methodology will work with Amlogic NG (edit: meant NE) devices, they are more locked down?

It was first working a a -ng build. There is not direct link at all to the kernel version.

As long as you can access the DV metadata for a frame (which is contained in sei data that is needed for other uses so should always be available) and write to a layer above the video in native resolution (i.e., a gui overlay) you should be all good to do this on anything.

Sorry I meant I’m not sure if this would work with NE devices?

Unfortunately, there does appear to be an indirect link. To embed the metadata, it is needed to write to a layer above the video that has a native resolution of the output. This is where the need to disable the gui scaling comes from.

In -no, I have found through further testing that I am unable to play any 4K content (with the exception of very low bitrate samples) with gui scaling disabled without getting many dropped frames and significantly screen corruption.

In -ng, I am only getting these problems with 4K 60fps content. So I will likely be reverting back to -ng with the older 4.9 kernel.

This could be avoided if the second osd layer (that all the amlogic hardware seems to support) could be enabled over the top of the existing gui layer. While native resolution would still be needed, the layer would only need to be 4 x 3840 pixels, so should not come the problems of a native 4K gui that (I think I saw somewhere) are related to memory bandwidth.

I have spent a fair bit of time trying to enable the second OSD layer, but have got nowhere. If any of the devs that know the kernel better could please provide some help with doing this and/or provide some input into if enabling a new 4 x 3840 pixel layer over the top of the existing gui layer is possible, it would be greatly appreciated. @Portisch?

edit: enabling a new layer of the top of the gui would also resolve the issues with black-screens that have been seen when the gui updates (and corrupts) the top pixels when pausing etc.

3 Likes

Would assume so, but I don’t have a device compatible with NE to test with and haven’t looked into if NE has any major differences that would create a roadblock

1 Like

Ok looking forward to new build with CoreELEC 4.9

Will test when is available!!!

Happy Testing

So I’ve found a thread about enabling the second osd to use as a cursor plane for a N2(+) running chrome OS. In this post, a patch is provided for some version of 5.15 that implements hardware cursor support with OSD2.

If I’m understanding it correctly, it seems enable a buffer that covers a portion of the screen is possible and is exactly what I’d like to do

/*
 * The format of these registers is (x2 << 16 | x1),
 * where x2 is exclusive.
 * e.g. +30x1920 would be (1919 << 16) | 30
 */
/* For now, OSD Cursor is always on top of the primary plane */

However, whatever kernel that is patching seems fairly different to the amlogic one being used here.

I have no clue how that patch works myself, but does anyone here understand that patch? If so, does it indeed do the functionality I was asking about and could it be adapted to the amlogic kernel?

I doubt this patch will be much helpful because it is based on mainline linux and it is for drm which ce doesn’t use.

Shame it doesn’t appear useful.

In the -no builds, the output of cat /sys/class/amcanvas/canvas_pool_map has own=osd_drm for the canvas that is the OSD. What is the osd_drm referring to then?

Maybe I was wrong and this files are indeed compiled.
And this commit above almost apply - should not be hard to fix 2 hunks.

patching file drivers/gpu/drm/meson/Makefile
Hunk #1 succeeded at 1 with fuzz 1.
patching file drivers/gpu/drm/meson/meson_crtc.c
patching file drivers/gpu/drm/meson/meson_cursor.c
patching file drivers/gpu/drm/meson/meson_cursor.h
patching file drivers/gpu/drm/meson/meson_drv.c
Hunk #2 succeeded at 246 (offset 3 lines).
Hunk #3 succeeded at 330 with fuzz 2 (offset 7 lines).
patching file drivers/gpu/drm/meson/meson_drv.h
patching file drivers/gpu/drm/meson/meson_plane.c
patching file drivers/gpu/drm/meson/meson_viu.c
Hunk #1 FAILED at 78.
Hunk #6 FAILED at 495.
2 out of 6 hunks FAILED -- saving rejects to file drivers/gpu/drm/meson/meson_viu.c.rej

Interesting, I just eyeballed it and it seemed very different. I’ll try to give that patch a proper go.

Update:

Changes

  • Primarily just reverting to a -ng build instead of a -no build for much improved performance when using a 4k gui. I’m now only seeing stuttering / screen corruption with 60fps video.
  • Some code cleanup / bugfixes.

Usage and what works
Play a DV file. Anything playable as p8.1 should work correctly. Profile 5 content will play and trigger DV, but the colors will be wrong to varying extents.

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.

For anyone that had tested my previous build, it will likely be needed to do a clean install of a -ng build before updating as the previous one was a -no build.

Next up?
Idea was to look at making the level 5 crop metadata dynamically altered based on if the gui has been updated in the last X ms. If it has been updated in that time, remove the crop so that subtitles / the gui can be seen.

Bringing up the osd is also causing the embedded metadata to be corrupted as the kodi gui updates the top pixels - this is causing a black flicker on my tv. Does anyone know if it is possible to modify the skin so that kodi leaves to pixels in the top 4 rows alone when a video is playing?

2 Likes

@freddy Can you give this a test and let me know how it goes? It should fix the issue you were having with p8 content without needing any commands.

Unfortunately all Dolby Vision test file playback = Black Screen.
Profile 5 Profile 8.1

TV Display info shows Dolby Vision, can hear audio playback on True Romance test file…
Rise of gru test file froze on image…

Tried echo command
No file or directory exists.

Also during black screen, no functionality of keyboard input.

Thanks for testing.

Hmm, try

 echo N > /sys/module/amvideo/parameters/check_vf_for_dv

before playing a file. Should then match the previous build, so profile 5 going, but profile 8 content as HDR10 for you.

Yeah, all commands change between -ng and -no. Do

echo 2 > /sys/module/amvideo/parameters/dv_injection_log_level

and then a upload a dmesg log to try and see what is going on.

I have no idea what would be causing that.

None of those files seem to be used. It seems the files in common_drivers/drivers/drm are used and not the files in drivers/gpu/drm/meson. There are functions with similar names - but completely different implementations.

Feels almost pointless asking, but does anyone actually know how this code works that could comment if that patch could be adapted to enabled the second osd layer?

No Dolby Vision test files work,regardless of profile,5, 8.1.,
Black screen

Echo command does nothing

Will see if free time this weekend to upload log.

Update:

Changes

  • Large rework of the processing of the metadata. Now happens ahead of time, and just copied later. Seems to work better and minimise issues with black screens / flickering when paused. Also just a all-round better approach.
  • Added automatic on-the-fly adjustment to any L5 crop metadata. This allows subtitles and the gui to show when playing a file that uses a L5 crop. Any L5 crop is removed if the osd / gui has been updated in the last osd_L5_timeout_ms milliseconds. Defaults to 3 seconds. Adjust with
 echo 3000 > /sys/module/amvideo/parameters/osd_L5_timeout_ms

Initial once-off setup:
Set kodi to use 12-bit 422 with a 3840 x 2160 gui resolution. Enable the option “Disable GUI scaling”. Set refresh rate to 25 fps (or any other refresh rate that is different to your DV files - ensures correct colors when stopping video). Reboot.

Usage and what works
Play a DV file. Anything playable as p8.1 should work correctly. Profile 5 content will play and trigger DV, but the colors will be wrong to varying extents.

Aside from the below issues, it really seems to “just work” for me.

Known Issues

  • If a video with a L5 crop is paused without the giu first being visible, the crop L5 crop will remain and may cut off some of the gui. This is due to processing the metadata ahead of time. Very edge case, not likely to be solved as I don’t care. Workaround is to just bring up the gui before pausing.
  • If any subtitles are enabled the L5 crop is always removed even when they are not actually currently showing anything. This is not due to the auto L5 adjustment I have added, but rather Kodi itself updating the gui every single frame when a subtitle track is enable even if no subtitles are currently showing…
  • A flicker of a black screen may occur when pausing / bringing up the gui. Think it is caused by frame drops that mean the dv metadata isn’t injected. Again, issue will likely remain as frequently pausing while playing a DV file isn’t really a use case.
  • Screen corruption on 60fps video. Not directly related to the DV stuff, problem that occurs due to the native 4k gui. Solution would be to not need a 4k gui, but no one seems to know how to enable the second osd layer that would remove this requirement - this would also let a -no build work properly.
5 Likes

Ok
First test was Black Screen
As always Human Error
Forgot to set
12 bit
4.2.2
We are successful now
No more Black Screen

Went back and tested older versionfrom July, set 12 bit 4.2.2.
Also all working





These Screen Shots are from your latest Build.
Kodi/CoreELEC UI does not display actual image

On my TV display image playback is visable

Nice Work!!!