~saiarcot895/chromium-browser/chromium-browser.xenial.dev

« back to all changes in this revision

Viewing changes to debian/patches/enable_vaapi_on_linux.diff~

  • Committer: Saikrishna Arcot
  • Date: 2016-05-26 15:36:19 UTC
  • Revision ID: saikrishna@saikrishna-vps-20160526153619-a52oucdwmdgyr3mw
Tags: 52.0.2743.6-0ubuntu1~ppa2~16.04.1
Fixes to libva patch.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
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.
 
2
 
 
3
Index: dev.xenial/chrome/browser/about_flags.cc
 
4
===================================================================
 
5
--- dev.xenial.orig/chrome/browser/about_flags.cc
 
6
+++ dev.xenial/chrome/browser/about_flags.cc
 
7
@@ -869,7 +869,7 @@ const FeatureEntry kFeatureEntries[] = {
 
8
         "disable-accelerated-video-decode",
 
9
         IDS_FLAGS_ACCELERATED_VIDEO_DECODE_NAME,
 
10
         IDS_FLAGS_ACCELERATED_VIDEO_DECODE_DESCRIPTION,
 
11
-        kOsMac | kOsWin | kOsCrOS,
 
12
+        kOsAll,
 
13
         SINGLE_DISABLE_VALUE_TYPE(switches::kDisableAcceleratedVideoDecode),
 
14
     },
 
15
 #if defined(USE_ASH)
 
16
Index: dev.xenial/content/common/sandbox_linux/bpf_gpu_policy_linux.cc
 
17
===================================================================
 
18
--- dev.xenial.orig/content/common/sandbox_linux/bpf_gpu_policy_linux.cc
 
19
+++ dev.xenial/content/common/sandbox_linux/bpf_gpu_policy_linux.cc
 
20
@@ -23,6 +23,8 @@
 
21
 #include "base/macros.h"
 
22
 #include "base/memory/ptr_util.h"
 
23
 #include "build/build_config.h"
 
24
+// Auto-generated for dlopen libva libraries
 
25
+#include "content/common/va_stubs.h"
 
26
 #include "content/common/sandbox_linux/sandbox_bpf_base_policy_linux.h"
 
27
 #include "content/common/sandbox_linux/sandbox_seccomp_bpf_linux.h"
 
28
 #include "content/common/set_process_title.h"
 
29
@@ -33,6 +35,8 @@
 
30
 #include "sandbox/linux/syscall_broker/broker_file_permission.h"
 
31
 #include "sandbox/linux/syscall_broker/broker_process.h"
 
32
 #include "sandbox/linux/system_headers/linux_syscalls.h"
 
33
+#include "third_party/libva/va/va.h"
 
34
+#include "third_party/libva/va/va_x11.h"
 
35
 
 
36
 using sandbox::arch_seccomp_data;
 
37
 using sandbox::bpf_dsl::Allow;
 
38
@@ -42,6 +46,14 @@ using sandbox::syscall_broker::BrokerFil
 
39
 using sandbox::syscall_broker::BrokerProcess;
 
40
 using sandbox::SyscallSets;
 
41
 
 
42
+using content_common::kModuleVa;
 
43
+using content_common::kModuleVa_x11;
 
44
+#if defined(USE_OZONE)
 
45
+using content_common::kModuleVa_drm;
 
46
+#endif
 
47
+using content_common::InitializeStubs;
 
48
+using content_common::StubPathMap;
 
49
+
 
50
 namespace content {
 
51
 
 
52
 namespace {
 
53
@@ -96,7 +108,7 @@ inline bool UseLibV4L2() {
 
54
 
 
55
 bool IsAcceleratedVaapiVideoEncodeEnabled() {
 
56
   bool accelerated_encode_enabled = false;
 
57
-#if defined(OS_CHROMEOS)
 
58
+#if defined(OS_CHROMEOS) || defined(OS_LINUX)
 
59
   const base::CommandLine& command_line =
 
60
       *base::CommandLine::ForCurrentProcess();
 
61
   accelerated_encode_enabled =
 
62
@@ -302,27 +314,65 @@ bool GpuProcessPolicy::PreSandboxHook()
 
63
     // inside the sandbox, so preload them now.
 
64
     if (IsAcceleratedVaapiVideoEncodeEnabled() ||
 
65
         IsAcceleratedVideoDecodeEnabled()) {
 
66
-      const char* I965DrvVideoPath = NULL;
 
67
-      const char* I965HybridDrvVideoPath = NULL;
 
68
-
 
69
-      if (IsArchitectureX86_64()) {
 
70
-        I965DrvVideoPath = "/usr/lib64/va/drivers/i965_drv_video.so";
 
71
-        I965HybridDrvVideoPath = "/usr/lib64/va/drivers/hybrid_drv_video.so";
 
72
-      } else if (IsArchitectureI386()) {
 
73
-        I965DrvVideoPath = "/usr/lib/va/drivers/i965_drv_video.so";
 
74
+      VLOG(1) << "Attempting to enable hardware video acceleration.";
 
75
+      StubPathMap paths;
 
76
+      paths[kModuleVa].push_back("libva.so.1");
 
77
+      paths[kModuleVa_x11].push_back("libva-x11.so.1");
 
78
+#if defined(USE_OZONE)
 
79
+      paths[kModuleVa_drm].push_back("libva-drm.so.1");
 
80
+#endif
 
81
+      if (!InitializeStubs(paths)) {
 
82
+        LOG(WARNING) << "Failed to initialize stubs";
 
83
+        return true;
 
84
       }
 
85
 
 
86
-      dlopen(I965DrvVideoPath, RTLD_NOW|RTLD_GLOBAL|RTLD_NODELETE);
 
87
-      if (I965HybridDrvVideoPath)
 
88
-        dlopen(I965HybridDrvVideoPath, RTLD_NOW|RTLD_GLOBAL|RTLD_NODELETE);
 
89
-      dlopen("libva.so.1", RTLD_NOW|RTLD_GLOBAL|RTLD_NODELETE);
 
90
+      // libva drivers won't get loaded even above two libraries get dlopened.
 
91
+      // Thus, libva calls will fail after post sandbox stage.
 
92
+      //
 
93
+      // To get the va driver loaded before sandboxing, upstream simply dlopen
 
94
+      // the hard-coded va driver path because ChromeOS is the only platform
 
95
+      // that Google want to support libva.
 
96
+      //
 
97
+      // While generic linux distros ship va driver as anywhere they want.
 
98
+      // Fortunately, the va driver will be loadded when vaInitialize() get
 
99
+      // called.
 
100
+      // So the following code is to call vaInitialize() before sandboxing.
 
101
+
 
102
+      VADisplay va_display = NULL;
 
103
 #if defined(USE_OZONE)
 
104
-      dlopen("libva-drm.so.1", RTLD_NOW|RTLD_GLOBAL|RTLD_NODELETE);
 
105
-#elif defined(USE_X11)
 
106
-      dlopen("libva-x11.so.1", RTLD_NOW|RTLD_GLOBAL|RTLD_NODELETE);
 
107
+      struct wl_display* wayland_display = wl_display_connect(NULL);
 
108
+      if (wayland_display) {
 
109
+        va_display = vaGetDisplayWl(wayland_display);
 
110
+        if (!vaDisplayIsValid(va_display)) {
 
111
+          LOG(WARNING) << "Failed to call vaGetDisplayWl()";
 
112
+          va_display = NULL;
 
113
+        }
 
114
+      } else {
 
115
+        LOG(WARNING) << "Failed to find Wayland display";
 
116
+      }
 
117
 #endif
 
118
-    }
 
119
-  }
 
120
+
 
121
+      if (!va_display) {
 
122
+        Display* x_display = XOpenDisplay(NULL);
 
123
+        if (!x_display) {
 
124
+          LOG(WARNING) << "Failed to find X-Display";
 
125
+          return true;
 
126
+        }
 
127
+        va_display = vaGetDisplay(x_display);
 
128
+        if (!vaDisplayIsValid(va_display)) {
 
129
+          LOG(WARNING) << "Failed to call vaGetDisplay()";
 
130
+          return true;
 
131
+        }
 
132
+      }
 
133
+
 
134
+      int major_version, minor_version;
 
135
+      if (vaInitialize(va_display, &major_version, &minor_version)
 
136
+          != VA_STATUS_SUCCESS) {
 
137
+        LOG(WARNING) << "Failed to call vaInitialize()";
 
138
+        return true;
 
139
+      }
 
140
+    }  // end of IsAcceleratedVaapiVideoEncodeEnabled() || IsAcceleratedVideoDecodeEnabled()
 
141
+  }  // end of IsArchitectureX86_64() || IsArchitectureI386()
 
142
 
 
143
   return true;
 
144
 }
 
145
Index: dev.xenial/content/content_gpu.gypi
 
146
===================================================================
 
147
--- dev.xenial.orig/content/content_gpu.gypi
 
148
+++ dev.xenial/content/content_gpu.gypi
 
149
@@ -49,7 +49,7 @@
 
150
         ],
 
151
       },
 
152
     }],
 
153
-    ['target_arch!="arm" and chromeos == 1', {
 
154
+    ['target_arch!="arm" and (chromeos == 1 or desktop_linux == 1)', {
 
155
       'include_dirs': [
 
156
         '<(DEPTH)/third_party/libva',
 
157
       ],
 
158
Index: dev.xenial/content/gpu/BUILD.gn
 
159
===================================================================
 
160
--- dev.xenial.orig/content/gpu/BUILD.gn
 
161
+++ dev.xenial/content/gpu/BUILD.gn
 
162
@@ -85,7 +85,7 @@ source_set("gpu_sources") {
 
163
     ]
 
164
   }
 
165
 
 
166
-  if (is_chromeos && current_cpu != "arm") {
 
167
+  if ((is_desktop_linux || is_chromeos) && current_cpu != "arm") {
 
168
     configs += [ "//third_party/libva:libva_config" ]
 
169
   }
 
170
 
 
171
Index: dev.xenial/content/gpu/gpu_main.cc
 
172
===================================================================
 
173
--- dev.xenial.orig/content/gpu/gpu_main.cc
 
174
+++ dev.xenial/content/gpu/gpu_main.cc
 
175
@@ -75,7 +75,7 @@
 
176
 #include "content/common/sandbox_mac.h"
 
177
 #endif
 
178
 
 
179
-#if defined(OS_CHROMEOS) && defined(ARCH_CPU_X86_FAMILY)
 
180
+#if (defined(OS_LINUX) || defined(OS_CHROMEOS)) && defined(ARCH_CPU_X86_FAMILY)
 
181
 #include "media/gpu/vaapi_wrapper.h"
 
182
 #endif
 
183
 
 
184
@@ -252,7 +252,7 @@ int GpuMain(const MainFunctionParams& pa
 
185
   GetGpuInfoFromCommandLine(gpu_info, command_line);
 
186
   gpu_info.in_process_gpu = false;
 
187
 
 
188
-#if defined(OS_CHROMEOS) && defined(ARCH_CPU_X86_FAMILY)
 
189
+#if (defined(OS_LINUX) || defined(OS_CHROMEOS)) && defined(ARCH_CPU_X86_FAMILY)
 
190
   media::VaapiWrapper::PreSandboxInitialization();
 
191
 #endif
 
192
 
 
193
Index: dev.xenial/content/public/common/content_switches.cc
 
194
===================================================================
 
195
--- dev.xenial.orig/content/public/common/content_switches.cc
 
196
+++ dev.xenial/content/public/common/content_switches.cc
 
197
@@ -970,7 +970,9 @@ const char kDisableAudioSupportForDeskto
 
198
 #if defined(OS_CHROMEOS)
 
199
 // Disables panel fitting (used for mirror mode).
 
200
 const char kDisablePanelFitting[]           = "disable-panel-fitting";
 
201
+#endif
 
202
 
 
203
+#if defined(OS_CHROMEOS) || defined(OS_LINUX)
 
204
 // Disables VA-API accelerated video encode.
 
205
 const char kDisableVaapiAcceleratedVideoEncode[] =
 
206
     "disable-vaapi-accelerated-video-encode";
 
207
Index: dev.xenial/content/public/common/content_switches.h
 
208
===================================================================
 
209
--- dev.xenial.orig/content/public/common/content_switches.h
 
210
+++ dev.xenial/content/public/common/content_switches.h
 
211
@@ -278,6 +278,8 @@ CONTENT_EXPORT extern const char kEnable
 
212
 
 
213
 #if defined(OS_CHROMEOS)
 
214
 CONTENT_EXPORT extern const char kDisablePanelFitting[];
 
215
+#endif
 
216
+#if defined(OS_CHROMEOS) || defined(OS_LINUX)
 
217
 CONTENT_EXPORT extern const char kDisableVaapiAcceleratedVideoEncode[];
 
218
 #endif
 
219
 
 
220
Index: dev.xenial/gpu/config/software_rendering_list_json.cc
 
221
===================================================================
 
222
--- dev.xenial.orig/gpu/config/software_rendering_list_json.cc
 
223
+++ dev.xenial/gpu/config/software_rendering_list_json.cc
 
224
@@ -488,17 +488,6 @@ const char kSoftwareRenderingListJson[]
 
225
       ]
 
226
     },
 
227
     {
 
228
-      "id": 48,
 
229
-      "description": "Accelerated video decode is unavailable on Linux",
 
230
-      "cr_bugs": [137247],
 
231
-      "os": {
 
232
-        "type": "linux"
 
233
-      },
 
234
-      "features": [
 
235
-        "accelerated_video_decode"
 
236
-      ]
 
237
-    },
 
238
-    {
 
239
       "id": 49,
 
240
       "description": "NVidia GeForce GT 650M can cause the system to hang with flash 3D",
 
241
       "cr_bugs": [140175],
 
242
Index: dev.xenial/media/BUILD.gn
 
243
===================================================================
 
244
--- dev.xenial.orig/media/BUILD.gn
 
245
+++ dev.xenial/media/BUILD.gn
 
246
@@ -339,7 +339,7 @@ component("media") {
 
247
     allow_circular_includes_from = [ "//media/base/android" ]
 
248
   }
 
249
 
 
250
-  if (current_cpu != "arm" && is_chromeos) {
 
251
+  if (current_cpu != "arm" && (is_chromeos || is_desktop_linux)) {
 
252
     sources += [
 
253
       "filters/h264_bitstream_buffer.cc",
 
254
       "filters/h264_bitstream_buffer.h",
 
255
@@ -629,7 +629,7 @@ test("media_unittests") {
 
256
     }
 
257
   }
 
258
 
 
259
-  if (current_cpu != "arm" && is_chromeos) {
 
260
+  if (current_cpu != "arm" && (is_chromeos || is_desktop_linux)) {
 
261
     sources += [ "filters/h264_bitstream_buffer_unittest.cc" ]
 
262
   }
 
263
 
 
264
Index: dev.xenial/media/gpu/BUILD.gn
 
265
===================================================================
 
266
--- dev.xenial.orig/media/gpu/BUILD.gn
 
267
+++ dev.xenial/media/gpu/BUILD.gn
 
268
@@ -12,7 +12,7 @@ if (is_mac) {
 
269
   import("//build/config/mac/mac_sdk.gni")
 
270
 }
 
271
 
 
272
-if (is_chromeos && current_cpu != "arm") {
 
273
+if ((is_desktop_linux || is_chromeos) && current_cpu != "arm") {
 
274
   action("libva_generate_stubs") {
 
275
     extra_header = "va_stub_header.fragment"
 
276
 
 
277
@@ -229,7 +229,7 @@ component("gpu") {
 
278
     }
 
279
   }
 
280
 
 
281
-  if (is_chromeos) {
 
282
+  if (is_linux) {
 
283
     sources += [
 
284
       "accelerated_video_decoder.h",
 
285
       "h264_decoder.cc",
 
286
@@ -273,7 +273,7 @@ component("gpu") {
 
287
         "GLESv2",
 
288
       ]
 
289
     }
 
290
-    if (current_cpu == "arm") {
 
291
+    if (current_cpu == "arm" && is_chromeos) {
 
292
       sources += [
 
293
         "tegra_v4l2_device.cc",
 
294
         "tegra_v4l2_device.h",
 
295
Index: dev.xenial/media/gpu/gpu_video_decode_accelerator_factory_impl.cc
 
296
===================================================================
 
297
--- dev.xenial.orig/media/gpu/gpu_video_decode_accelerator_factory_impl.cc
 
298
+++ dev.xenial/media/gpu/gpu_video_decode_accelerator_factory_impl.cc
 
299
@@ -14,7 +14,7 @@
 
300
 #include "media/gpu/dxva_video_decode_accelerator_win.h"
 
301
 #elif defined(OS_MACOSX)
 
302
 #include "media/gpu/vt_video_decode_accelerator_mac.h"
 
303
-#elif defined(OS_CHROMEOS)
 
304
+#elif defined(OS_CHROMEOS) || defined(OS_LINUX)
 
305
 #if defined(USE_V4L2_CODEC)
 
306
 #include "media/gpu/v4l2_device.h"
 
307
 #include "media/gpu/v4l2_slice_video_decode_accelerator.h"
 
308
@@ -79,7 +79,7 @@ GpuVideoDecodeAcceleratorFactoryImpl::Ge
 
309
 #if defined(OS_WIN)
 
310
   capabilities.supported_profiles =
 
311
       DXVAVideoDecodeAccelerator::GetSupportedProfiles();
 
312
-#elif defined(OS_CHROMEOS)
 
313
+#elif defined(OS_CHROMEOS) || defined(OS_LINUX)
 
314
   media::VideoDecodeAccelerator::SupportedProfiles vda_profiles;
 
315
 #if defined(USE_V4L2_CODEC)
 
316
   vda_profiles = V4L2VideoDecodeAccelerator::GetSupportedProfiles();
 
317
@@ -130,7 +130,7 @@ GpuVideoDecodeAcceleratorFactoryImpl::Cr
 
318
     &GpuVideoDecodeAcceleratorFactoryImpl::CreateV4L2VDA,
 
319
     &GpuVideoDecodeAcceleratorFactoryImpl::CreateV4L2SVDA,
 
320
 #endif
 
321
-#if defined(OS_CHROMEOS) && defined(ARCH_CPU_X86_FAMILY)
 
322
+#if (defined(OS_LINUX) || defined(OS_CHROMEOS)) && defined(ARCH_CPU_X86_FAMILY)
 
323
     &GpuVideoDecodeAcceleratorFactoryImpl::CreateVaapiVDA,
 
324
 #endif
 
325
 #if defined(OS_MACOSX)
 
326
@@ -194,10 +194,11 @@ GpuVideoDecodeAcceleratorFactoryImpl::Cr
 
327
 }
 
328
 #endif
 
329
 
 
330
-#if defined(OS_CHROMEOS) && defined(ARCH_CPU_X86_FAMILY)
 
331
+#if (defined(OS_LINUX) || defined(OS_CHROMEOS)) && defined(ARCH_CPU_X86_FAMILY)
 
332
 std::unique_ptr<media::VideoDecodeAccelerator>
 
333
 GpuVideoDecodeAcceleratorFactoryImpl::CreateVaapiVDA(
 
334
     const gpu::GpuPreferences& gpu_preferences) const {
 
335
+  VLOG(1) << "Creating new VAAPI video decode accelerator.";
 
336
   std::unique_ptr<media::VideoDecodeAccelerator> decoder;
 
337
   decoder.reset(new VaapiVideoDecodeAccelerator(make_context_current_cb_,
 
338
                                                 bind_image_cb_));
 
339
Index: dev.xenial/media/gpu/gpu_video_decode_accelerator_factory_impl.h
 
340
===================================================================
 
341
--- dev.xenial.orig/media/gpu/gpu_video_decode_accelerator_factory_impl.h
 
342
+++ dev.xenial/media/gpu/gpu_video_decode_accelerator_factory_impl.h
 
343
@@ -99,7 +99,7 @@ class MEDIA_GPU_EXPORT GpuVideoDecodeAcc
 
344
   std::unique_ptr<media::VideoDecodeAccelerator> CreateV4L2SVDA(
 
345
       const gpu::GpuPreferences& gpu_preferences) const;
 
346
 #endif
 
347
-#if defined(OS_CHROMEOS) && defined(ARCH_CPU_X86_FAMILY)
 
348
+#if (defined(OS_LINUX) || defined(OS_CHROMEOS)) && defined(ARCH_CPU_X86_FAMILY)
 
349
   std::unique_ptr<media::VideoDecodeAccelerator> CreateVaapiVDA(
 
350
       const gpu::GpuPreferences& gpu_preferences) const;
 
351
 #endif
 
352
Index: dev.xenial/media/gpu/ipc/service/BUILD.gn
 
353
===================================================================
 
354
--- dev.xenial.orig/media/gpu/ipc/service/BUILD.gn
 
355
+++ dev.xenial/media/gpu/ipc/service/BUILD.gn
 
356
@@ -37,7 +37,7 @@ source_set("service") {
 
357
     "//third_party/mesa:mesa_headers",
 
358
   ]
 
359
 
 
360
-  if (is_chromeos && current_cpu != "arm") {
 
361
+  if ((is_desktop_linux || is_chromeos) && current_cpu != "arm") {
 
362
     configs += [ "//third_party/libva:libva_config" ]
 
363
   }
 
364
 
 
365
Index: dev.xenial/media/gpu/ipc/service/gpu_video_decode_accelerator.cc
 
366
===================================================================
 
367
--- dev.xenial.orig/media/gpu/ipc/service/gpu_video_decode_accelerator.cc
 
368
+++ dev.xenial/media/gpu/ipc/service/gpu_video_decode_accelerator.cc
 
369
@@ -58,7 +58,7 @@ static bool MakeDecoderContextCurrent(
 
370
   return true;
 
371
 }
 
372
 
 
373
-#if (defined(OS_CHROMEOS) && defined(ARCH_CPU_X86_FAMILY)) || defined(OS_MACOSX)
 
374
+#if ((defined(OS_LINUX) || defined(OS_CHROMEOS)) && defined(ARCH_CPU_X86_FAMILY)) || defined(OS_MACOSX)
 
375
 static bool BindImage(const base::WeakPtr<gpu::GpuCommandBufferStub>& stub,
 
376
                       uint32_t client_texture_id,
 
377
                       uint32_t texture_target,
 
378
@@ -170,7 +170,7 @@ GpuVideoDecodeAccelerator::GpuVideoDecod
 
379
   get_gl_context_cb_ = base::Bind(&GetGLContext, stub_->AsWeakPtr());
 
380
   make_context_current_cb_ =
 
381
       base::Bind(&MakeDecoderContextCurrent, stub_->AsWeakPtr());
 
382
-#if (defined(OS_CHROMEOS) && defined(ARCH_CPU_X86_FAMILY)) || defined(OS_MACOSX)
 
383
+#if ((defined(OS_LINUX) || defined(OS_CHROMEOS)) && defined(ARCH_CPU_X86_FAMILY)) || defined(OS_MACOSX)
 
384
   bind_image_cb_ = base::Bind(&BindImage, stub_->AsWeakPtr());
 
385
 #endif
 
386
   get_gles2_decoder_cb_ = base::Bind(&GetGLES2Decoder, stub_->AsWeakPtr());
 
387
Index: dev.xenial/media/gpu/vaapi_video_decode_accelerator.cc
 
388
===================================================================
 
389
--- dev.xenial.orig/media/gpu/vaapi_video_decode_accelerator.cc
 
390
+++ dev.xenial/media/gpu/vaapi_video_decode_accelerator.cc
 
391
@@ -342,17 +342,17 @@ bool VaapiVideoDecodeAccelerator::Initia
 
392
 
 
393
   base::AutoLock auto_lock(lock_);
 
394
   DCHECK_EQ(state_, kUninitialized);
 
395
-  DVLOG(2) << "Initializing VAVDA, profile: " << profile;
 
396
+  VLOG(1) << "Initializing VAVDA, profile: " << profile;
 
397
 
 
398
 #if defined(USE_X11)
 
399
   if (gfx::GetGLImplementation() != gfx::kGLImplementationDesktopGL) {
 
400
-    DVLOG(1) << "HW video decode acceleration not available without "
 
401
+    VLOG(1) << "HW video decode acceleration not available without "
 
402
                 "DesktopGL (GLX).";
 
403
     return false;
 
404
   }
 
405
 #elif defined(USE_OZONE)
 
406
   if (gfx::GetGLImplementation() != gfx::kGLImplementationEGLGLES2) {
 
407
-    DVLOG(1) << "HW video decode acceleration not available without "
 
408
+    VLOG(1) << "HW video decode acceleration not available without "
 
409
              << "EGLGLES2.";
 
410
     return false;
 
411
   }
 
412
@@ -362,7 +362,7 @@ bool VaapiVideoDecodeAccelerator::Initia
 
413
       VaapiWrapper::kDecode, profile, base::Bind(&ReportToUMA, VAAPI_ERROR));
 
414
 
 
415
   if (!vaapi_wrapper_.get()) {
 
416
-    DVLOG(1) << "Failed initializing VAAPI for profile " << profile;
 
417
+    VLOG(1) << "Failed initializing VAAPI for profile " << profile;
 
418
     return false;
 
419
   }
 
420
 
 
421
@@ -379,7 +379,7 @@ bool VaapiVideoDecodeAccelerator::Initia
 
422
     vp9_accelerator_.reset(new VaapiVP9Accelerator(this, vaapi_wrapper_.get()));
 
423
     decoder_.reset(new VP9Decoder(vp9_accelerator_.get()));
 
424
   } else {
 
425
-    DLOG(ERROR) << "Unsupported profile " << profile;
 
426
+    VLOG(1) << "Unsupported profile " << profile;
 
427
     return false;
 
428
   }
 
429
 
 
430
Index: dev.xenial/media/gpu/vaapi_wrapper.cc
 
431
===================================================================
 
432
--- dev.xenial.orig/media/gpu/vaapi_wrapper.cc
 
433
+++ dev.xenial/media/gpu/vaapi_wrapper.cc
 
434
@@ -189,7 +189,7 @@ scoped_refptr<VaapiWrapper> VaapiWrapper
 
435
     VAProfile va_profile,
 
436
     const base::Closure& report_error_to_uma_cb) {
 
437
   if (!profile_infos_.Get().IsProfileSupported(mode, va_profile)) {
 
438
-    DVLOG(1) << "Unsupported va_profile: " << va_profile;
 
439
+    VLOG(1) << "Unsupported va_profile: " << va_profile;
 
440
     return nullptr;
 
441
   }
 
442
 
 
443
@@ -342,15 +342,17 @@ VaapiWrapper::GetSupportedProfileInfosFo
 
444
 bool VaapiWrapper::VaInitialize(const base::Closure& report_error_to_uma_cb) {
 
445
   static bool vaapi_functions_initialized = PostSandboxInitialization();
 
446
   if (!vaapi_functions_initialized) {
 
447
-    bool running_on_chromeos = false;
 
448
-#if defined(OS_CHROMEOS)
 
449
+    bool error_level_logging = false;
 
450
+#if defined(OS_LINUX)
 
451
+    error_level_logging = true;
 
452
+#elif defined(OS_CHROMEOS)
 
453
     // When chrome runs on linux with chromeos=1, do not log error message
 
454
     // without VAAPI libraries.
 
455
-    running_on_chromeos = base::SysInfo::IsRunningOnChromeOS();
 
456
+    error_level_logging = base::SysInfo::IsRunningOnChromeOS();
 
457
 #endif
 
458
     static const char kErrorMsg[] = "Failed to initialize VAAPI libs";
 
459
-    if (running_on_chromeos)
 
460
-      LOG(ERROR) << kErrorMsg;
 
461
+    if (error_level_logging)
 
462
+      VLOG(1) << kErrorMsg;
 
463
     else
 
464
       DVLOG(1) << kErrorMsg;
 
465
     return false;
 
466
@@ -416,7 +418,7 @@ bool VaapiWrapper::IsEntrypointSupported
 
467
 
 
468
   if (std::find(supported_entrypoints.begin(), supported_entrypoints.end(),
 
469
                 entrypoint) == supported_entrypoints.end()) {
 
470
-    DVLOG(1) << "Unsupported entrypoint";
 
471
+    VLOG(1) << "Unsupported entrypoint";
 
472
     return false;
 
473
   }
 
474
   return true;
 
475
@@ -440,8 +442,8 @@ bool VaapiWrapper::AreAttribsSupported_L
 
476
     if (attribs[i].type != required_attribs[i].type ||
 
477
         (attribs[i].value & required_attribs[i].value) !=
 
478
             required_attribs[i].value) {
 
479
-      DVLOG(1) << "Unsupported value " << required_attribs[i].value
 
480
-               << " for attribute type " << required_attribs[i].type;
 
481
+      VLOG(1) << "Unsupported value " << required_attribs[i].value
 
482
+              << " for attribute type " << required_attribs[i].type;
 
483
       return false;
 
484
     }
 
485
   }
 
486
Index: dev.xenial/media/media.gyp
 
487
===================================================================
 
488
--- dev.xenial.orig/media/media.gyp
 
489
+++ dev.xenial/media/media.gyp
 
490
@@ -752,7 +752,7 @@
 
491
           ],
 
492
         }],
 
493
         # For VaapiVideoEncodeAccelerator.
 
494
-        ['target_arch != "arm" and chromeos == 1', {
 
495
+        ['target_arch != "arm" and (chromeos == 1 or desktop_linux == 1)', {
 
496
           'sources': [
 
497
             'filters/h264_bitstream_buffer.cc',
 
498
             'filters/h264_bitstream_buffer.h',
 
499
@@ -1330,7 +1330,7 @@
 
500
             'cdm/cdm_adapter_unittest.cc',
 
501
           ],
 
502
         }],
 
503
-        ['target_arch != "arm" and chromeos == 1 and use_x11 == 1', {
 
504
+        ['target_arch != "arm" and (chromeos == 1 or desktop_linux == 1) and use_x11 == 1', {
 
505
           'sources': [
 
506
             'filters/h264_bitstream_buffer_unittest.cc',
 
507
           ],
 
508
@@ -2264,7 +2264,7 @@
 
509
       ],
 
510
     }],
 
511
 
 
512
-    ['chromeos==1 and target_arch != "arm"', {
 
513
+    ['(desktop_linux==1 or chromeos==1) and target_arch != "arm"', {
 
514
       'targets': [
 
515
           {
 
516
             'target_name': 'vaapi_jpeg_decoder_unittest',
 
517
Index: dev.xenial/media/media_gpu.gypi
 
518
===================================================================
 
519
--- dev.xenial.orig/media/media_gpu.gypi
 
520
+++ dev.xenial/media/media_gpu.gypi
 
521
@@ -230,7 +230,7 @@
 
522
         'gpu/tegra_v4l2_device.h',
 
523
       ],
 
524
     }],
 
525
-    ['target_arch != "arm" and chromeos == 1', {
 
526
+    ['target_arch != "arm" and (chromeos == 1 or desktop_linux == 1)', {
 
527
       'dependencies': [
 
528
         '../media/media.gyp:media',
 
529
         '../third_party/libyuv/libyuv.gyp:libyuv',
 
530
Index: dev.xenial/content/common/BUILD.gn
 
531
===================================================================
 
532
--- dev.xenial.orig/content/common/BUILD.gn
 
533
+++ dev.xenial/content/common/BUILD.gn
 
534
@@ -11,6 +11,49 @@ if (is_mac) {
 
535
   import("//build/config/mac/mac_sdk.gni")
 
536
 }
 
537
 
 
538
+if ((is_desktop_linux || is_chromeos) && current_cpu != "arm") {
 
539
+  action("libva_generate_stubs") {
 
540
+    extra_header = "../../media/gpu/va_stub_header.fragment"
 
541
+
 
542
+    script = "../../tools/generate_stubs/generate_stubs.py"
 
543
+    sources = [
 
544
+      "../../media/gpu/va.sigs",
 
545
+    ]
 
546
+    inputs = [
 
547
+      extra_header,
 
548
+    ]
 
549
+    sources += [ "../../media/gpu/va_x11.sigs" ]
 
550
+    if (use_ozone) {
 
551
+      sources += [
 
552
+        "../../media/gpu/va_drm.sigs",
 
553
+        "va_wayland.sigs",
 
554
+      ]
 
555
+    }
 
556
+    stubs_filename_root = "va_stubs"
 
557
+
 
558
+    outputs = [
 
559
+      "$target_gen_dir/$stubs_filename_root.cc",
 
560
+      "$target_gen_dir/$stubs_filename_root.h",
 
561
+    ]
 
562
+    args = [
 
563
+      "-i",
 
564
+      rebase_path("$target_gen_dir", root_build_dir),
 
565
+      "-o",
 
566
+      rebase_path("$target_gen_dir", root_build_dir),
 
567
+      "-t",
 
568
+      "posix_stubs",
 
569
+      "-e",
 
570
+      rebase_path(extra_header, root_build_dir),
 
571
+      "-s",
 
572
+      stubs_filename_root,
 
573
+      "-p",
 
574
+      "content/common",
 
575
+    ]
 
576
+
 
577
+    args += rebase_path(sources, root_build_dir)
 
578
+  }
 
579
+}
 
580
+
 
581
 source_set("common") {
 
582
   # Targets external to content should always link to the public API.
 
583
   # In addition, targets outside of the content component (shell and tests)
 
584
@@ -178,6 +221,11 @@ source_set("common") {
 
585
 
 
586
   if (use_seccomp_bpf) {
 
587
     defines += [ "USE_SECCOMP_BPF" ]
 
588
+    if (current_cpu != "arm") {
 
589
+      sources += get_target_outputs(":libva_generate_stubs")
 
590
+      deps += [ ":libva_generate_stubs" ]
 
591
+      configs += [ "//third_party/libva:libva_config" ]
 
592
+    }
 
593
   } else {
 
594
     if (is_linux) {
 
595
       sources -= [