diff options
Diffstat (limited to 'enable_vaapi_on_linux-r11.diff')
-rw-r--r-- | enable_vaapi_on_linux-r11.diff | 413 |
1 files changed, 413 insertions, 0 deletions
diff --git a/enable_vaapi_on_linux-r11.diff b/enable_vaapi_on_linux-r11.diff new file mode 100644 index 000000000000..f45eddcd25e4 --- /dev/null +++ b/enable_vaapi_on_linux-r11.diff @@ -0,0 +1,413 @@ +--- orig/media/gpu/gpu_video_decode_accelerator_factory_impl.cc ++++ mod/media/gpu/gpu_video_decode_accelerator_factory_impl.cc +@@ -13,17 +13,14 @@ + #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) +-#if defined(USE_V4L2_CODEC) ++#elif defined(OS_CHROMEOS) && defined(USE_V4L2_CODEC) + #include "media/gpu/v4l2_device.h" + #include "media/gpu/v4l2_slice_video_decode_accelerator.h" + #include "media/gpu/v4l2_video_decode_accelerator.h" + #include "ui/gl/gl_surface_egl.h" +-#endif +-#if defined(ARCH_CPU_X86_FAMILY) ++#elif (defined(OS_CHROMEOS) && defined(ARCH_CPU_X86_FAMILY)) || defined(OS_LINUX) + #include "media/gpu/vaapi_video_decode_accelerator.h" + #include "ui/gl/gl_implementation.h" +-#endif + #elif defined(OS_ANDROID) + #include "media/gpu/android_video_decode_accelerator.h" + #endif +@@ -78,7 +75,7 @@ + #if defined(OS_WIN) + capabilities.supported_profiles = + DXVAVideoDecodeAccelerator::GetSupportedProfiles(); +-#elif defined(OS_CHROMEOS) ++#elif defined(OS_CHROMEOS) || defined(OS_LINUX) + media::VideoDecodeAccelerator::SupportedProfiles vda_profiles; + #if defined(USE_V4L2_CODEC) + vda_profiles = V4L2VideoDecodeAccelerator::GetSupportedProfiles(); +@@ -129,7 +126,7 @@ + &GpuVideoDecodeAcceleratorFactoryImpl::CreateV4L2VDA, + &GpuVideoDecodeAcceleratorFactoryImpl::CreateV4L2SVDA, + #endif +-#if defined(OS_CHROMEOS) && defined(ARCH_CPU_X86_FAMILY) ++#if (defined(OS_CHROMEOS) && defined(ARCH_CPU_X86_FAMILY)) || defined(OS_LINUX) + &GpuVideoDecodeAcceleratorFactoryImpl::CreateVaapiVDA, + #endif + #if defined(OS_MACOSX) +@@ -194,7 +191,7 @@ + } + #endif + +-#if defined(OS_CHROMEOS) && defined(ARCH_CPU_X86_FAMILY) ++#if (defined(OS_CHROMEOS) && defined(ARCH_CPU_X86_FAMILY)) || defined(OS_LINUX) + std::unique_ptr<media::VideoDecodeAccelerator> + GpuVideoDecodeAcceleratorFactoryImpl::CreateVaapiVDA( + const gpu::GpuPreferences& gpu_preferences) const { +--- orig/media/gpu/gpu_video_decode_accelerator_factory_impl.h ++++ mod/media/gpu/gpu_video_decode_accelerator_factory_impl.h +@@ -95,7 +95,7 @@ + std::unique_ptr<media::VideoDecodeAccelerator> CreateV4L2SVDA( + const gpu::GpuPreferences& gpu_preferences) const; + #endif +-#if defined(OS_CHROMEOS) && defined(ARCH_CPU_X86_FAMILY) ++#if (defined(OS_CHROMEOS) && defined(ARCH_CPU_X86_FAMILY)) || defined(OS_LINUX) + std::unique_ptr<media::VideoDecodeAccelerator> CreateVaapiVDA( + const gpu::GpuPreferences& gpu_preferences) const; + #endif +--- orig/media/gpu/ipc/service/gpu_video_decode_accelerator.cc ++++ mod/media/gpu/ipc/service/gpu_video_decode_accelerator.cc +@@ -57,7 +57,7 @@ + return true; + } + +-#if (defined(OS_CHROMEOS) && defined(ARCH_CPU_X86_FAMILY)) || defined(OS_MACOSX) ++#if (defined(OS_CHROMEOS) && defined(ARCH_CPU_X86_FAMILY)) || defined(OS_MACOSX) || defined(OS_LINUX) + static bool BindImage(const base::WeakPtr<gpu::GpuCommandBufferStub>& stub, + uint32_t client_texture_id, + uint32_t texture_target, +@@ -169,7 +169,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_CHROMEOS) && defined(ARCH_CPU_X86_FAMILY)) || defined(OS_MACOSX) || defined(OS_LINUX) + bind_image_cb_ = base::Bind(&BindImage, stub_->AsWeakPtr()); + #endif + get_gles2_decoder_cb_ = base::Bind(&GetGLES2Decoder, stub_->AsWeakPtr()); + +--- orig/media/media_gpu.gypi ++++ mod/media/media_gpu.gypi +@@ -869,7 +869,7 @@ + }, + ], + }], +- ['chromeos==1', { ++ ['chromeos==1 or desktop_linux==1', { + 'sources': [ + 'gpu/accelerated_video_decoder.h', + 'gpu/h264_decoder.cc', +@@ -925,7 +925,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', +--- orig/content/content_gpu.gypi ++++ mod/content/content_gpu.gypi +@@ -41,7 +41,7 @@ + ], + }, + }], +- ['target_arch!="arm" and chromeos == 1', { ++ ['target_arch!="arm" and (chromeos == 1 or desktop_linux == 1)', { + 'include_dirs': [ + '<(DEPTH)/third_party/libva', + ], +--- orig/media/media.gyp ++++ mod/media/media.gyp +@@ -1784,7 +1784,7 @@ + ], + }], + +- ['chromeos==1 and target_arch != "arm"', { ++ ['desktop_linux==1 or (chromeos==1 and target_arch != "arm")', { + 'targets': [ + { + 'target_name': 'vaapi_jpeg_decoder_unittest', +--- orig/content/public/common/content_switches.cc ++++ mod/content/public/common/content_switches.cc +@@ -963,7 +963,9 @@ const char kEnableAudioSupportForDesktop + #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"; +--- orig/content/public/common/content_switches.h ++++ mod/content/public/common/content_switches.h +@@ -278,6 +278,8 @@ CONTENT_EXPORT extern const char kSyncIn + + #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 + +--- orig/media/media.gyp ++++ mod/media/media.gyp +@@ -734,7 +734,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', +@@ -1355,7 +1355,7 @@ + 'cdm/cdm_adapter_unittest.cc', + ], + }], +- ['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', + ], +--- orig/gpu/config/software_rendering_list_json.cc ++++ mod/gpu/config/software_rendering_list_json.cc +@@ -484,17 +484,6 @@ const char kSoftwareRenderingListJson[] + ] + }, + { +- "id": 48, +- "description": "Accelerated video decode is unavailable on Linux", +- "cr_bugs": [137247], +- "os": { +- "type": "linux" +- }, +- "features": [ +- "accelerated_video_decode" +- ] +- }, +- { + "id": 49, + "description": "NVidia GeForce GT 650M can cause the system to hang with flash 3D", + "cr_bugs": [140175], +--- orig/content/common/sandbox_linux/bpf_gpu_policy_linux.cc ++++ mod/content/common/sandbox_linux/bpf_gpu_policy_linux.cc +@@ -22,6 +22,8 @@ + #include "base/macros.h" + #include "base/memory/scoped_ptr.h" + #include "build/build_config.h" ++// Auto-generated for dlopen libva libraries ++#include "out/Release/gen/va/media/gpu/va_stubs.h" + #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" +@@ -32,6 +34,8 @@ + #include "sandbox/linux/syscall_broker/broker_file_permission.h" + #include "sandbox/linux/syscall_broker/broker_process.h" + #include "sandbox/linux/system_headers/linux_syscalls.h" ++#include "third_party/libva/va/va.h" ++#include "third_party/libva/va/va_x11.h" + + using sandbox::arch_seccomp_data; + using sandbox::bpf_dsl::Allow; +@@ -41,6 +45,11 @@ using sandbox::syscall_broker::BrokerFil + using sandbox::syscall_broker::BrokerProcess; + using sandbox::SyscallSets; + ++using media_gpu::kModuleVa; ++using media_gpu::kModuleVa_x11; ++using media_gpu::InitializeStubs; ++using media_gpu::StubPathMap; ++ + namespace content { + + namespace { +@@ -95,7 +104,7 @@ inline bool UseLibV4L2() { + + 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 = +@@ -300,27 +309,41 @@ bool GpuProcessPolicy::PreSandboxHook() + // inside the sandbox, so preload them now. + if (IsAcceleratedVaapiVideoEncodeEnabled() || + IsAcceleratedVideoDecodeEnabled()) { +- const char* I965DrvVideoPath = NULL; +- const char* I965HybridDrvVideoPath = NULL; ++ 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 (!InitializeStubs(paths)) { ++ VLOG(1) << "Failed to initialize stubs"; ++ return false; ++ } + +- 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"; ++ // 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. ++ Display* x_display = XOpenDisplay(NULL); ++ VADisplay va_display = vaGetDisplay(x_display); ++ if (!vaDisplayIsValid(va_display)) { ++ VLOG(1) << "Failed to call vaGetDisplay()"; ++ return false; + } + +- 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); +-#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); +-#endif +- } +- } ++ int major_version, minor_version; ++ if (vaInitialize(va_display, &major_version, &minor_version) ++ != VA_STATUS_SUCCESS) { ++ VLOG(1) << "Failed to call vaInitialize()"; ++ return false; ++ } ++ } // end of IsAcceleratedVaapiVideoEncodeEnabled() || IsAcceleratedVideoDecodeEnabled() ++ } // end of IsArchitectureX86_64() || IsArchitectureI386() + + return true; + } +--- orig/chrome/browser/about_flags.cc ++++ mod/chrome/browser/about_flags.cc +@@ -841,7 +841,7 @@ const FeatureEntry kFeatureEntries[] = { + "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) +--- orig/media/gpu/vaapi_wrapper.cc ++++ mod/media/gpu/vaapi_wrapper.cc +@@ -184,7 +184,7 @@ scoped_refptr<VaapiWrapper> VaapiWrapper + 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; + } + +@@ -339,15 +339,17 @@ VaapiWrapper::GetSupportedProfileInfosFo + 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; +@@ -415,7 +417,7 @@ bool VaapiWrapper::IsEntrypointSupported + 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; +@@ -439,8 +441,8 @@ bool VaapiWrapper::AreAttribsSupported_L + 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; + } + } +--- orig/media/gpu/vaapi_video_decode_accelerator.cc ++++ mod/media/gpu/vaapi_video_decode_accelerator.cc +@@ -333,17 +333,17 @@ bool VaapiVideoDecodeAccelerator::Initia + + 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 (gfx::GetGLImplementation() != gfx::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 (gfx::GetGLImplementation() != gfx::kGLImplementationEGLGLES2) { +- DVLOG(1) << "HW video decode acceleration not available without " ++ VLOG(1) << "HW video decode acceleration not available without " + << "EGLGLES2."; + return false; + } +@@ -353,7 +353,7 @@ bool VaapiVideoDecodeAccelerator::Initia + 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; + } + +@@ -370,7 +370,7 @@ bool VaapiVideoDecodeAccelerator::Initia + 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; + } + +--- orig/content/gpu/gpu_main.cc ++++ mod/content/gpu/gpu_main.cc +@@ -73,7 +73,7 @@ + #include "content/common/sandbox_mac.h" + #endif + +-#if defined(OS_CHROMEOS) && defined(ARCH_CPU_X86_FAMILY) ++#if (defined(OS_CHROMEOS) && defined(ARCH_CPU_X86_FAMILY)) || defined(OS_LINUX) + #include "media/gpu/vaapi_wrapper.h" + #endif + +@@ -248,7 +248,7 @@ int GpuMain(const MainFunctionParams& pa + GetGpuInfoFromCommandLine(gpu_info, command_line); + gpu_info.in_process_gpu = false; + +-#if defined(OS_CHROMEOS) && defined(ARCH_CPU_X86_FAMILY) ++#if (defined(OS_CHROMEOS) && defined(ARCH_CPU_X86_FAMILY)) || defined(OS_LINUX) + media::VaapiWrapper::PreSandboxInitialization(); + #endif + |