Originally from https://raw.githubusercontent.com/saiarcot895/chromium-ubuntu-build/master/debian/patches/enable_vaapi_on_linux.diff Thanks to Saikrishna Arcot (saiarcot895) Refactored for Chromium 54 by Eric Hameleers Description: Enables using VA-API hardware acceleration in Linux. The patch for bpf_gpu_policy_linux.cc initially came from https://codereview.chromium.org/15955009/diff/92001/content/common/sandbox_linux/bpf_gpu_policy_linux.cc. diff -uar chromium-54.0.2840.90.orig/chrome/browser/about_flags.cc chromium-54.0.2840.90/chrome/browser/about_flags.cc --- chromium-54.0.2840.90.orig/chrome/browser/about_flags.cc 2016-11-01 21:59:07.000000000 +0100 +++ chromium-54.0.2840.90/chrome/browser/about_flags.cc 2016-11-02 10:42:04.629114886 +0100 @@ -968,7 +968,7 @@ "disable-accelerated-video-decode", IDS_FLAGS_ACCELERATED_VIDEO_DECODE_NAME, IDS_FLAGS_ACCELERATED_VIDEO_DECODE_DESCRIPTION, - kOsMac | kOsWin | kOsCrOS, + kOsAll, SINGLE_DISABLE_VALUE_TYPE(switches::kDisableAcceleratedVideoDecode), }, #if defined(USE_ASH) diff -uar chromium-54.0.2840.90.orig/content/common/BUILD.gn chromium-54.0.2840.90/content/common/BUILD.gn --- chromium-54.0.2840.90.orig/content/common/BUILD.gn 2016-11-01 21:59:11.000000000 +0100 +++ chromium-54.0.2840.90/content/common/BUILD.gn 2016-11-02 10:42:04.630115037 +0100 @@ -12,6 +12,49 @@ import("//build/config/mac/mac_sdk.gni") } +if ((is_desktop_linux || is_chromeos) && current_cpu != "arm") { + action("libva_generate_stubs") { + extra_header = "../../media/gpu/va_stub_header.fragment" + + script = "../../tools/generate_stubs/generate_stubs.py" + sources = [ + "../../media/gpu/va.sigs", + ] + inputs = [ + extra_header, + ] + sources += [ "../../media/gpu/va_x11.sigs" ] + if (use_ozone) { + sources += [ + "../../media/gpu/va_drm.sigs", + "va_wayland.sigs", + ] + } + stubs_filename_root = "va_stubs" + + outputs = [ + "$target_gen_dir/$stubs_filename_root.cc", + "$target_gen_dir/$stubs_filename_root.h", + ] + args = [ + "-i", + rebase_path("$target_gen_dir", root_build_dir), + "-o", + rebase_path("$target_gen_dir", root_build_dir), + "-t", + "posix_stubs", + "-e", + rebase_path(extra_header, root_build_dir), + "-s", + stubs_filename_root, + "-p", + "content/common", + ] + + args += rebase_path(sources, root_build_dir) + } +} + source_set("common") { # Targets external to content should always link to the public API. # In addition, targets outside of the content component (shell and tests) @@ -186,6 +229,15 @@ if (use_seccomp_bpf) { defines += [ "USE_SECCOMP_BPF" ] + if (current_cpu != "arm" && is_desktop_linux) { + sources += get_target_outputs(":libva_generate_stubs") + deps += [ ":libva_generate_stubs" ] + configs += [ "//third_party/libva:libva_config" ] + if (use_ozone) { + configs += [ "//build/config/linux:x11" ] + deps += [ "//third_party/wayland:wayland_client" ] + } + } } else { if (is_linux) { sources -= [ diff -uar chromium-54.0.2840.90.orig/content/common/sandbox_linux/bpf_gpu_policy_linux.cc chromium-54.0.2840.90/content/common/sandbox_linux/bpf_gpu_policy_linux.cc --- chromium-54.0.2840.90.orig/content/common/sandbox_linux/bpf_gpu_policy_linux.cc 2016-11-01 21:59:11.000000000 +0100 +++ chromium-54.0.2840.90/content/common/sandbox_linux/bpf_gpu_policy_linux.cc 2016-11-02 10:42:04.631115188 +0100 @@ -24,6 +24,12 @@ #include "base/memory/ptr_util.h" #include "base/strings/stringprintf.h" #include "build/build_config.h" + +#if !defined(__arm__) +// Auto-generated for dlopen libva libraries +#include "content/common/va_stubs.h" +#endif + #include "content/common/sandbox_linux/sandbox_bpf_base_policy_linux.h" #include "content/common/sandbox_linux/sandbox_seccomp_bpf_linux.h" #include "content/common/set_process_title.h" @@ -35,6 +41,14 @@ #include "sandbox/linux/syscall_broker/broker_process.h" #include "sandbox/linux/system_headers/linux_syscalls.h" +#if !defined(__arm__) +#include "third_party/libva/va/va.h" +#include "third_party/libva/va/va_x11.h" +#if defined(USE_OZONE) +#include "third_party/libva/va/wayland/va_wayland.h" +#endif +#endif + using sandbox::arch_seccomp_data; using sandbox::bpf_dsl::Allow; using sandbox::bpf_dsl::ResultExpr; @@ -43,6 +57,16 @@ using sandbox::syscall_broker::BrokerProcess; using sandbox::SyscallSets; +#if !defined(__arm__) +using content_common::kModuleVa; +using content_common::kModuleVa_x11; +#if defined(USE_OZONE) +using content_common::kModuleVa_drm; +#endif +using content_common::InitializeStubs; +using content_common::StubPathMap; +#endif + namespace content { namespace { @@ -97,7 +121,7 @@ bool IsAcceleratedVaapiVideoEncodeEnabled() { bool accelerated_encode_enabled = false; -#if defined(OS_CHROMEOS) +#if defined(OS_CHROMEOS) || defined(OS_LINUX) const base::CommandLine& command_line = *base::CommandLine::ForCurrentProcess(); accelerated_encode_enabled = @@ -295,32 +319,72 @@ GpuBrokerProcessPolicy::Create, std::vector()); // No extra files in whitelist. +#if !defined(__arm__) if (IsArchitectureX86_64() || IsArchitectureI386()) { // Accelerated video dlopen()'s some shared objects // inside the sandbox, so preload them now. if (IsAcceleratedVaapiVideoEncodeEnabled() || IsAcceleratedVideoDecodeEnabled()) { - const char* I965DrvVideoPath = NULL; - const char* I965HybridDrvVideoPath = NULL; - - if (IsArchitectureX86_64()) { - I965DrvVideoPath = "/usr/lib64/va/drivers/i965_drv_video.so"; - I965HybridDrvVideoPath = "/usr/lib64/va/drivers/hybrid_drv_video.so"; - } else if (IsArchitectureI386()) { - I965DrvVideoPath = "/usr/lib/va/drivers/i965_drv_video.so"; + VLOG(1) << "Attempting to enable hardware video acceleration."; + StubPathMap paths; + paths[kModuleVa].push_back("libva.so.1"); + paths[kModuleVa_x11].push_back("libva-x11.so.1"); +#if defined(USE_OZONE) + paths[kModuleVa_drm].push_back("libva-drm.so.1"); +#endif + if (!InitializeStubs(paths)) { + LOG(WARNING) << "Failed to initialize stubs"; + return true; } - dlopen(I965DrvVideoPath, RTLD_NOW | RTLD_GLOBAL | RTLD_NODELETE); - if (I965HybridDrvVideoPath) - dlopen(I965HybridDrvVideoPath, RTLD_NOW | RTLD_GLOBAL | RTLD_NODELETE); - dlopen("libva.so.1", RTLD_NOW | RTLD_GLOBAL | RTLD_NODELETE); + // libva drivers won't get loaded even above two libraries get dlopened. + // Thus, libva calls will fail after post sandbox stage. + // + // To get the va driver loaded before sandboxing, upstream simply dlopen + // the hard-coded va driver path because ChromeOS is the only platform + // that Google want to support libva. + // + // While generic linux distros ship va driver as anywhere they want. + // Fortunately, the va driver will be loadded when vaInitialize() get + // called. + // So the following code is to call vaInitialize() before sandboxing. + + VADisplay va_display = NULL; #if defined(USE_OZONE) - dlopen("libva-drm.so.1", RTLD_NOW | RTLD_GLOBAL | RTLD_NODELETE); -#elif defined(USE_X11) - dlopen("libva-x11.so.1", RTLD_NOW | RTLD_GLOBAL | RTLD_NODELETE); + struct wl_display* wayland_display = wl_display_connect(NULL); + if (wayland_display) { + va_display = vaGetDisplayWl(wayland_display); + if (!vaDisplayIsValid(va_display)) { + LOG(WARNING) << "Failed to call vaGetDisplayWl()"; + va_display = NULL; + } + } else { + LOG(WARNING) << "Failed to find Wayland display"; + } +#endif + + if (!va_display) { + Display* x_display = XOpenDisplay(NULL); + if (!x_display) { + LOG(WARNING) << "Failed to find X-Display"; + return true; + } + va_display = vaGetDisplay(x_display); + if (!vaDisplayIsValid(va_display)) { + LOG(WARNING) << "Failed to call vaGetDisplay()"; + return true; + } + } + + int major_version, minor_version; + if (vaInitialize(va_display, &major_version, &minor_version) + != VA_STATUS_SUCCESS) { + LOG(WARNING) << "Failed to call vaInitialize()"; + return true; + } + } // end of IsAcceleratedVaapiVideoEncodeEnabled() || IsAcceleratedVideoDecodeEnabled() + } // end of IsArchitectureX86_64() || IsArchitectureI386() #endif - } - } return true; } Only in chromium-54.0.2840.90/content/common: va_wayland.sigs diff -uar chromium-54.0.2840.90.orig/content/content_common.gypi chromium-54.0.2840.90/content/content_common.gypi --- chromium-54.0.2840.90.orig/content/content_common.gypi 2016-11-01 21:59:11.000000000 +0100 +++ chromium-54.0.2840.90/content/content_common.gypi 2016-11-02 10:42:04.645117305 +0100 @@ -631,6 +631,52 @@ ], }, { 'defines': ['USE_SECCOMP_BPF'], + 'dependencies': [ + '../build/linux/system.gyp:x11', + ], + 'variables': { + 'sig_files': [ + '../media/gpu/va.sigs', + '../media/gpu/va_x11.sigs', + ], + 'generate_stubs_script': '../tools/generate_stubs/generate_stubs.py', + 'extra_header': '../media/gpu/va_stub_header.fragment', + 'outfile_type': 'posix_stubs', + 'stubs_filename_root': 'va_stubs', + 'project_path': 'content/common', + 'intermediate_dir': '<(INTERMEDIATE_DIR)', + 'output_root': '<(SHARED_INTERMEDIATE_DIR)/va', + }, + 'actions': [ + { + 'action_name': 'libva_generate_stubs', + 'inputs': [ + '<(generate_stubs_script)', + '<(extra_header)', + '<@(sig_files)', + ], + 'outputs': [ + '<(intermediate_dir)/<(stubs_filename_root).cc', + '<(output_root)/<(project_path)/<(stubs_filename_root).h', + ], + 'action': ['python', + '<(generate_stubs_script)', + '-i', '<(intermediate_dir)', + '-o', '<(output_root)/<(project_path)', + '-t', '<(outfile_type)', + '-e', '<(extra_header)', + '-s', '<(stubs_filename_root)', + '-p', '<(project_path)', + '<@(_inputs)', + ], + 'process_outputs_as_sources': 1, + 'message': 'Generating libva stubs for dynamic loading', + }, + ], + 'include_dirs': [ + '<(DEPTH)/third_party/libva', + '<(output_root)', + ], }], ['use_ozone==1', { 'dependencies': [ diff -uar chromium-54.0.2840.90.orig/content/content_gpu.gypi chromium-54.0.2840.90/content/content_gpu.gypi --- chromium-54.0.2840.90.orig/content/content_gpu.gypi 2016-11-01 21:59:11.000000000 +0100 +++ chromium-54.0.2840.90/content/content_gpu.gypi 2016-11-02 10:42:04.631115188 +0100 @@ -47,7 +47,7 @@ ], }, }], - ['target_arch!="arm" and chromeos == 1', { + ['target_arch!="arm" and (chromeos == 1 or desktop_linux == 1)', { 'include_dirs': [ '<(DEPTH)/third_party/libva', ], diff -uar chromium-54.0.2840.90.orig/content/gpu/BUILD.gn chromium-54.0.2840.90/content/gpu/BUILD.gn --- chromium-54.0.2840.90.orig/content/gpu/BUILD.gn 2016-11-01 21:59:11.000000000 +0100 +++ chromium-54.0.2840.90/content/gpu/BUILD.gn 2016-11-02 10:42:04.631115188 +0100 @@ -92,7 +92,7 @@ ] } - if (is_chromeos && current_cpu != "arm") { + if ((is_desktop_linux || is_chromeos) && current_cpu != "arm") { configs += [ "//third_party/libva:libva_config" ] } diff -uar chromium-54.0.2840.90.orig/content/gpu/gpu_main.cc chromium-54.0.2840.90/content/gpu/gpu_main.cc --- chromium-54.0.2840.90.orig/content/gpu/gpu_main.cc 2016-11-01 21:59:11.000000000 +0100 +++ chromium-54.0.2840.90/content/gpu/gpu_main.cc 2016-11-02 10:42:04.631115188 +0100 @@ -77,7 +77,7 @@ #include "content/common/sandbox_mac.h" #endif -#if defined(OS_CHROMEOS) && defined(ARCH_CPU_X86_FAMILY) +#if (defined(OS_LINUX) || defined(OS_CHROMEOS)) && defined(ARCH_CPU_X86_FAMILY) #include "media/gpu/vaapi_wrapper.h" #endif @@ -255,7 +255,7 @@ GetGpuInfoFromCommandLine(gpu_info, command_line); gpu_info.in_process_gpu = false; -#if defined(OS_CHROMEOS) && defined(ARCH_CPU_X86_FAMILY) +#if (defined(OS_LINUX) || defined(OS_CHROMEOS)) && defined(ARCH_CPU_X86_FAMILY) media::VaapiWrapper::PreSandboxInitialization(); #endif diff -uar chromium-54.0.2840.90.orig/content/public/common/content_switches.cc chromium-54.0.2840.90/content/public/common/content_switches.cc --- chromium-54.0.2840.90.orig/content/public/common/content_switches.cc 2016-11-01 21:59:12.000000000 +0100 +++ chromium-54.0.2840.90/content/public/common/content_switches.cc 2016-11-02 10:42:04.632115339 +0100 @@ -1001,7 +1001,9 @@ #if defined(OS_CHROMEOS) // Disables panel fitting (used for mirror mode). const char kDisablePanelFitting[] = "disable-panel-fitting"; +#endif +#if defined(OS_CHROMEOS) || defined(OS_LINUX) // Disables VA-API accelerated video encode. const char kDisableVaapiAcceleratedVideoEncode[] = "disable-vaapi-accelerated-video-encode"; diff -uar chromium-54.0.2840.90.orig/content/public/common/content_switches.h chromium-54.0.2840.90/content/public/common/content_switches.h --- chromium-54.0.2840.90.orig/content/public/common/content_switches.h 2016-11-01 21:59:12.000000000 +0100 +++ chromium-54.0.2840.90/content/public/common/content_switches.h 2016-11-02 10:42:04.632115339 +0100 @@ -293,6 +293,8 @@ #if defined(OS_CHROMEOS) CONTENT_EXPORT extern const char kDisablePanelFitting[]; +#endif +#if defined(OS_CHROMEOS) || defined(OS_LINUX) CONTENT_EXPORT extern const char kDisableVaapiAcceleratedVideoEncode[]; #endif diff -uar chromium-54.0.2840.90.orig/gpu/config/software_rendering_list_json.cc chromium-54.0.2840.90/gpu/config/software_rendering_list_json.cc --- chromium-54.0.2840.90.orig/gpu/config/software_rendering_list_json.cc 2016-11-01 21:59:12.000000000 +0100 +++ chromium-54.0.2840.90/gpu/config/software_rendering_list_json.cc 2016-11-02 10:42:04.633115490 +0100 @@ -415,17 +415,6 @@ ] }, { - "id": 48, - "description": "Accelerated video decode is unavailable on Linux", - "cr_bugs": [137247], - "os": { - "type": "linux" - }, - "features": [ - "accelerated_video_decode" - ] - }, - { "id": 50, "description": "Disable VMware software renderer on older Mesa", "cr_bugs": [145531, 332596, 571899], diff -uar chromium-54.0.2840.90.orig/media/BUILD.gn chromium-54.0.2840.90/media/BUILD.gn --- chromium-54.0.2840.90.orig/media/BUILD.gn 2016-11-01 21:59:13.000000000 +0100 +++ chromium-54.0.2840.90/media/BUILD.gn 2016-11-02 10:42:04.633115490 +0100 @@ -368,7 +368,7 @@ allow_circular_includes_from = [ "//media/base/android" ] } - if (current_cpu != "arm" && is_chromeos) { + if (current_cpu != "arm" && (is_chromeos || is_desktop_linux)) { sources += [ "filters/h264_bitstream_buffer.cc", "filters/h264_bitstream_buffer.h", @@ -651,7 +651,7 @@ } } - if (current_cpu != "arm" && is_chromeos) { + if (current_cpu != "arm" && (is_chromeos || is_desktop_linux)) { sources += [ "filters/h264_bitstream_buffer_unittest.cc" ] } diff -uar chromium-54.0.2840.90.orig/media/gpu/BUILD.gn chromium-54.0.2840.90/media/gpu/BUILD.gn --- chromium-54.0.2840.90.orig/media/gpu/BUILD.gn 2016-11-01 21:59:13.000000000 +0100 +++ chromium-54.0.2840.90/media/gpu/BUILD.gn 2016-11-02 10:42:04.634115641 +0100 @@ -12,7 +12,7 @@ import("//build/config/mac/mac_sdk.gni") } -if (is_chromeos && current_cpu != "arm") { +if ((is_desktop_linux || is_chromeos) && current_cpu != "arm") { action("libva_generate_stubs") { extra_header = "va_stub_header.fragment" @@ -239,7 +239,7 @@ } } - if (is_chromeos) { + if (is_linux) { sources += [ "accelerated_video_decoder.h", "h264_decoder.cc", @@ -282,7 +282,7 @@ "GLESv2", ] } - if (current_cpu == "arm") { + if (current_cpu == "arm" && is_chromeos) { sources += [ "tegra_v4l2_device.cc", "tegra_v4l2_device.h", diff -uar chromium-54.0.2840.90.orig/media/gpu/gpu_video_decode_accelerator_factory.cc chromium-54.0.2840.90/media/gpu/gpu_video_decode_accelerator_factory.cc --- chromium-54.0.2840.90.orig/media/gpu/gpu_video_decode_accelerator_factory.cc 2016-11-01 21:59:13.000000000 +0100 +++ chromium-54.0.2840.90/media/gpu/gpu_video_decode_accelerator_factory.cc 2016-11-02 10:42:04.634115641 +0100 @@ -14,7 +14,7 @@ #include "media/gpu/dxva_video_decode_accelerator_win.h" #elif defined(OS_MACOSX) #include "media/gpu/vt_video_decode_accelerator_mac.h" -#elif defined(OS_CHROMEOS) +#elif defined(OS_CHROMEOS) || defined(OS_LINUX) #if defined(USE_V4L2_CODEC) #include "media/gpu/v4l2_device.h" #include "media/gpu/v4l2_slice_video_decode_accelerator.h" @@ -79,7 +79,7 @@ #if defined(OS_WIN) capabilities.supported_profiles = DXVAVideoDecodeAccelerator::GetSupportedProfiles(gpu_preferences); -#elif defined(OS_CHROMEOS) +#elif defined(OS_CHROMEOS) || defined(OS_LINUX) VideoDecodeAccelerator::SupportedProfiles vda_profiles; #if defined(USE_V4L2_CODEC) vda_profiles = V4L2VideoDecodeAccelerator::GetSupportedProfiles(); @@ -131,7 +131,7 @@ &GpuVideoDecodeAcceleratorFactory::CreateV4L2VDA, &GpuVideoDecodeAcceleratorFactory::CreateV4L2SVDA, #endif -#if defined(OS_CHROMEOS) && defined(ARCH_CPU_X86_FAMILY) +#if (defined(OS_LINUX) || defined(OS_CHROMEOS)) && defined(ARCH_CPU_X86_FAMILY) &GpuVideoDecodeAcceleratorFactory::CreateVaapiVDA, #endif #if defined(OS_MACOSX) @@ -199,11 +199,12 @@ } #endif -#if defined(OS_CHROMEOS) && defined(ARCH_CPU_X86_FAMILY) +#if (defined(OS_LINUX) || defined(OS_CHROMEOS)) && defined(ARCH_CPU_X86_FAMILY) std::unique_ptr GpuVideoDecodeAcceleratorFactory::CreateVaapiVDA( const gpu::GpuDriverBugWorkarounds& workarounds, const gpu::GpuPreferences& gpu_preferences) const { + VLOG(1) << "Creating new VAAPI video decode accelerator."; std::unique_ptr decoder; decoder.reset(new VaapiVideoDecodeAccelerator(make_context_current_cb_, bind_image_cb_)); diff -uar chromium-54.0.2840.90.orig/media/gpu/gpu_video_decode_accelerator_factory.h chromium-54.0.2840.90/media/gpu/gpu_video_decode_accelerator_factory.h --- chromium-54.0.2840.90.orig/media/gpu/gpu_video_decode_accelerator_factory.h 2016-11-01 21:59:13.000000000 +0100 +++ chromium-54.0.2840.90/media/gpu/gpu_video_decode_accelerator_factory.h 2016-11-02 10:42:04.634115641 +0100 @@ -98,7 +98,7 @@ const gpu::GpuDriverBugWorkarounds& workarounds, const gpu::GpuPreferences& gpu_preferences) const; #endif -#if defined(OS_CHROMEOS) && defined(ARCH_CPU_X86_FAMILY) +#if (defined(OS_LINUX) || defined(OS_CHROMEOS)) && defined(ARCH_CPU_X86_FAMILY) std::unique_ptr CreateVaapiVDA( const gpu::GpuDriverBugWorkarounds& workarounds, const gpu::GpuPreferences& gpu_preferences) const; diff -uar chromium-54.0.2840.90.orig/media/gpu/ipc/service/BUILD.gn chromium-54.0.2840.90/media/gpu/ipc/service/BUILD.gn --- chromium-54.0.2840.90.orig/media/gpu/ipc/service/BUILD.gn 2016-11-01 21:59:13.000000000 +0100 +++ chromium-54.0.2840.90/media/gpu/ipc/service/BUILD.gn 2016-11-02 10:42:04.634115641 +0100 @@ -45,7 +45,7 @@ configs += [ "//media/gpu:gpu_config" ] - if (is_chromeos && current_cpu != "arm") { + if ((is_desktop_linux || is_chromeos) && current_cpu != "arm") { configs += [ "//third_party/libva:libva_config" ] } diff -uar chromium-54.0.2840.90.orig/media/gpu/ipc/service/gpu_video_decode_accelerator.cc chromium-54.0.2840.90/media/gpu/ipc/service/gpu_video_decode_accelerator.cc --- chromium-54.0.2840.90.orig/media/gpu/ipc/service/gpu_video_decode_accelerator.cc 2016-11-01 21:59:13.000000000 +0100 +++ chromium-54.0.2840.90/media/gpu/ipc/service/gpu_video_decode_accelerator.cc 2016-11-02 10:42:04.635115792 +0100 @@ -58,7 +58,7 @@ return true; } -#if (defined(OS_CHROMEOS) && defined(ARCH_CPU_X86_FAMILY)) || defined(OS_MACOSX) +#if ((defined(OS_LINUX) || defined(OS_CHROMEOS)) && defined(ARCH_CPU_X86_FAMILY)) || defined(OS_MACOSX) static bool BindImage(const base::WeakPtr& stub, uint32_t client_texture_id, uint32_t texture_target, @@ -171,7 +171,7 @@ get_gl_context_cb_ = base::Bind(&GetGLContext, stub_->AsWeakPtr()); make_context_current_cb_ = base::Bind(&MakeDecoderContextCurrent, stub_->AsWeakPtr()); -#if (defined(OS_CHROMEOS) && defined(ARCH_CPU_X86_FAMILY)) || defined(OS_MACOSX) +#if ((defined(OS_LINUX) || defined(OS_CHROMEOS)) && defined(ARCH_CPU_X86_FAMILY)) || defined(OS_MACOSX) bind_image_cb_ = base::Bind(&BindImage, stub_->AsWeakPtr()); #endif get_gles2_decoder_cb_ = base::Bind(&GetGLES2Decoder, stub_->AsWeakPtr()); diff -uar chromium-54.0.2840.90.orig/media/gpu/va_stub_header.fragment chromium-54.0.2840.90/media/gpu/va_stub_header.fragment --- chromium-54.0.2840.90.orig/media/gpu/va_stub_header.fragment 2016-11-01 21:59:13.000000000 +0100 +++ chromium-54.0.2840.90/media/gpu/va_stub_header.fragment 2016-11-02 10:42:04.635115792 +0100 @@ -5,8 +5,9 @@ #include "third_party/libva/va/drm/va_drm.h" #include "third_party/libva/va/va.h" -#if defined(USE_X11) #include "third_party/libva/va/va_x11.h" +#if defined(USE_OZONE) +#include "third_party/libva/va/wayland/va_wayland.h" #endif } diff -uar chromium-54.0.2840.90.orig/media/gpu/vaapi_video_decode_accelerator.cc chromium-54.0.2840.90/media/gpu/vaapi_video_decode_accelerator.cc --- chromium-54.0.2840.90.orig/media/gpu/vaapi_video_decode_accelerator.cc 2016-11-01 21:59:13.000000000 +0100 +++ chromium-54.0.2840.90/media/gpu/vaapi_video_decode_accelerator.cc 2016-11-02 10:42:04.635115792 +0100 @@ -359,17 +359,17 @@ base::AutoLock auto_lock(lock_); DCHECK_EQ(state_, kUninitialized); - DVLOG(2) << "Initializing VAVDA, profile: " << profile; + VLOG(1) << "Initializing VAVDA, profile: " << profile; #if defined(USE_X11) if (gl::GetGLImplementation() != gl::kGLImplementationDesktopGL) { - DVLOG(1) << "HW video decode acceleration not available without " + VLOG(1) << "HW video decode acceleration not available without " "DesktopGL (GLX)."; return false; } #elif defined(USE_OZONE) if (gl::GetGLImplementation() != gl::kGLImplementationEGLGLES2) { - DVLOG(1) << "HW video decode acceleration not available without " + VLOG(1) << "HW video decode acceleration not available without " << "EGLGLES2."; return false; } @@ -379,7 +379,7 @@ VaapiWrapper::kDecode, profile, base::Bind(&ReportToUMA, VAAPI_ERROR)); if (!vaapi_wrapper_.get()) { - DVLOG(1) << "Failed initializing VAAPI for profile " << profile; + VLOG(1) << "Failed initializing VAAPI for profile " << profile; return false; } @@ -394,7 +394,7 @@ vp9_accelerator_.reset(new VaapiVP9Accelerator(this, vaapi_wrapper_.get())); decoder_.reset(new VP9Decoder(vp9_accelerator_.get())); } else { - DLOG(ERROR) << "Unsupported profile " << profile; + VLOG(1) << "Unsupported profile " << profile; return false; } diff -uar chromium-54.0.2840.90.orig/media/gpu/vaapi_wrapper.cc chromium-54.0.2840.90/media/gpu/vaapi_wrapper.cc --- chromium-54.0.2840.90.orig/media/gpu/vaapi_wrapper.cc 2016-11-01 21:59:13.000000000 +0100 +++ chromium-54.0.2840.90/media/gpu/vaapi_wrapper.cc 2016-11-02 10:42:04.636115943 +0100 @@ -194,7 +194,7 @@ VAProfile va_profile, const base::Closure& report_error_to_uma_cb) { if (!profile_infos_.Get().IsProfileSupported(mode, va_profile)) { - DVLOG(1) << "Unsupported va_profile: " << va_profile; + VLOG(1) << "Unsupported va_profile: " << va_profile; return nullptr; } @@ -347,15 +347,17 @@ bool VaapiWrapper::VaInitialize(const base::Closure& report_error_to_uma_cb) { static bool vaapi_functions_initialized = PostSandboxInitialization(); if (!vaapi_functions_initialized) { - bool running_on_chromeos = false; -#if defined(OS_CHROMEOS) + bool error_level_logging = false; +#if defined(OS_LINUX) + error_level_logging = true; +#elif defined(OS_CHROMEOS) // When chrome runs on linux with chromeos=1, do not log error message // without VAAPI libraries. - running_on_chromeos = base::SysInfo::IsRunningOnChromeOS(); + error_level_logging = base::SysInfo::IsRunningOnChromeOS(); #endif static const char kErrorMsg[] = "Failed to initialize VAAPI libs"; - if (running_on_chromeos) - LOG(ERROR) << kErrorMsg; + if (error_level_logging) + VLOG(1) << kErrorMsg; else DVLOG(1) << kErrorMsg; return false; @@ -421,7 +423,7 @@ if (std::find(supported_entrypoints.begin(), supported_entrypoints.end(), entrypoint) == supported_entrypoints.end()) { - DVLOG(1) << "Unsupported entrypoint"; + VLOG(1) << "Unsupported entrypoint"; return false; } return true; @@ -445,8 +447,8 @@ if (attribs[i].type != required_attribs[i].type || (attribs[i].value & required_attribs[i].value) != required_attribs[i].value) { - DVLOG(1) << "Unsupported value " << required_attribs[i].value - << " for attribute type " << required_attribs[i].type; + VLOG(1) << "Unsupported value " << required_attribs[i].value + << " for attribute type " << required_attribs[i].type; return false; } } diff -uar chromium-54.0.2840.90.orig/media/media.gyp chromium-54.0.2840.90/media/media.gyp --- chromium-54.0.2840.90.orig/media/media.gyp 2016-11-01 21:59:13.000000000 +0100 +++ chromium-54.0.2840.90/media/media.gyp 2016-11-02 10:42:04.644117154 +0100 @@ -756,7 +756,7 @@ ], }], # For VaapiVideoEncodeAccelerator. - ['target_arch != "arm" and chromeos == 1', { + ['target_arch != "arm" and (chromeos == 1 or desktop_linux == 1)', { 'sources': [ 'filters/h264_bitstream_buffer.cc', 'filters/h264_bitstream_buffer.h', @@ -1319,7 +1319,7 @@ }] ], }], - ['target_arch != "arm" and chromeos == 1 and use_x11 == 1', { + ['target_arch != "arm" and (chromeos == 1 or desktop_linux == 1) and use_x11 == 1', { 'sources': [ 'filters/h264_bitstream_buffer_unittest.cc', ], @@ -2289,7 +2289,7 @@ ], }], - ['chromeos==1 and target_arch != "arm"', { + ['(desktop_linux==1 or chromeos==1) and target_arch != "arm"', { 'targets': [ { 'target_name': 'vaapi_jpeg_decoder_unittest', diff -uar chromium-54.0.2840.90.orig/media/media_gpu.gypi chromium-54.0.2840.90/media/media_gpu.gypi --- chromium-54.0.2840.90.orig/media/media_gpu.gypi 2016-11-01 21:59:13.000000000 +0100 +++ chromium-54.0.2840.90/media/media_gpu.gypi 2016-11-02 10:42:04.645117305 +0100 @@ -175,7 +175,7 @@ }, ], }], - ['chromeos==1', { + ['chromeos==1 or desktop_linux==1', { 'sources': [ 'gpu/accelerated_video_decoder.h', 'gpu/h264_decoder.cc', @@ -231,7 +231,7 @@ 'gpu/tegra_v4l2_device.h', ], }], - ['target_arch != "arm" and chromeos == 1', { + ['target_arch != "arm" and (chromeos == 1 or desktop_linux == 1)', { 'dependencies': [ '../media/media.gyp:media', '../third_party/libyuv/libyuv.gyp:libyuv',