Tips on getting HDR passthrough working on Linux.



Apologies if I have missed an obvious post or guide somewhere, but I had a really difficult time getting the conclusive information and details needed HDR passthrough working on my Gentoo-based Linux HTPC. I had to piece it all together through various random comments and guides around the nets, and given the volume of other people trying to figure this out and hearing it isn’t possible or getting misinformation or being told, “just use LibreElec!”, I’m not the only one. Given that I just figured it out, I thought it would be good to make a post here to more conclusively guide others embarking on the same quest. Hopefully it becomes common knowledge.  
 
In short, the requirements for Kodi HDR to work on linux at this time (at least, as I found it) are as follows:  
 
1. Video driver that supports DRM and VA-API, and Kodi compiled with VA-API support. In my case, that’s the AMDGPU / RadeonSI driver, using the integrated graphics on a Ryzen 5700G. I have read that Intel GPU drivers also have this support, but have not tested this myself so can’t speak to it personally.  nVidia drivers don’t have proper VA-API support and Kodi HDR doesn’t work with VDPAU, that I could find. Sorry, nvidia users. I did try to make it work with my gtx1660, but no go (though for those of you using Plex as the backend and integrating with Kodi via PlexKodiConnect, nvidia cards still work wonderfully with plex for hardware transcoding. I actually use both an AMD and nVidia GPU in my setup this way). Kodi compilation flags: -DENABLE_VAAPI=ON -DENABLE_VDPAU=OFF  
2. Kodi compiled with GBM windowing support. Xorg or Wayland or any other desktop environment are out at this time of writing. Compilation flag: -DCORE_PLATFORM_NAME=gbm  
3. Kodi compiled with GLES support. This was the detail that eluded me for a long time. For whatever reason, HDR passthrough doesn’t work with full OpenGL, but does with the pared down OpenGL ES. Compilation flag: -DAPP_RENDER_SYSTEM=gles  
 
tl;dr — Compile Kodi with the VA-API, GBM, and GLES flags, setup a system with proper working video hardware/drivers but without a desktop environment, and run either ‘kodi-standalone’ or ‘kodi-gbm’ (depending on your distro / code source) from commandline. For the Gentoo users out there, I accomplished this in my Gentoo build by configuring Kodi’s package.use with these use flags: gbm gles vaapi -X -wayland -vdpau  
 
On a related note: for those of you building an HTPC and want Kodi to launch at boot without need for login, check out [kodi-standalone-service](https://github.com/graysky2/kodi-standal…master/x86). This way you can set your system up similar to a media appliance but without the limitations that come with LibreElec in that you can put whatever else you want on the system if it’s got the power to handle it.  
 
Hopefully this helps somebody out there somewhere. And, if anybody can confirm this works with Intel graphics, I think that would also be helpful to many. Best of luck to everybody out there trying to get this to work!