-
Notifications
You must be signed in to change notification settings - Fork 0
/
enable_vaapi_on_linux.diff
645 lines (607 loc) · 24.2 KB
/
enable_vaapi_on_linux.diff
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
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. The code in bpf_gpu_policy_linux.cc was then updated by Steven Newbury to support Nvidia drivers.
Index: dev/chrome/browser/about_flags.cc
===================================================================
--- dev.orig/chrome/browser/about_flags.cc
+++ dev/chrome/browser/about_flags.cc
@@ -1476,7 +1476,7 @@ const FeatureEntry kFeatureEntries[] = {
"disable-accelerated-video-decode",
flag_descriptions::kAcceleratedVideoDecodeName,
flag_descriptions::kAcceleratedVideoDecodeDescription,
- kOsMac | kOsWin | kOsCrOS | kOsAndroid,
+ kOsAll,
SINGLE_DISABLE_VALUE_TYPE(switches::kDisableAcceleratedVideoDecode),
},
#if defined(OS_WIN)
Index: dev/content/common/BUILD.gn
===================================================================
--- dev.orig/content/common/BUILD.gn
+++ dev/content/common/BUILD.gn
@@ -26,6 +26,53 @@ buildflag_header("features") {
]
}
+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/vaapi/va.sigs",
+ ]
+ inputs = [
+ extra_header,
+ ]
+ if (use_x11) {
+ sources += [
+ "../../media/gpu/vaapi/va_x11.sigs",
+ ]
+ }
+ if (use_ozone) {
+ sources += [
+ "../../media/gpu/vaapi/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)
@@ -540,6 +587,16 @@ source_set("common") {
"sandbox_linux/sandbox_bpf_base_policy_linux.h",
]
}
+ } else {
+ if (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" ]
+ }
+ }
}
if (is_mac) {
Index: dev/content/common/sandbox_linux/bpf_gpu_policy_linux.cc
===================================================================
--- dev.orig/content/common/sandbox_linux/bpf_gpu_policy_linux.cc
+++ dev/content/common/sandbox_linux/bpf_gpu_policy_linux.cc
@@ -25,6 +25,10 @@
#include "base/memory/ptr_util.h"
#include "base/strings/stringprintf.h"
#include "build/build_config.h"
+
+// Auto-generated for dlopen libva libraries
+#include "content/common/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/public/common/content_switches.h"
@@ -36,6 +40,26 @@
#include "sandbox/linux/system_headers/linux_syscalls.h"
#include "services/service_manager/embedder/set_process_title.h"
+#include "third_party/libva/va/va.h"
+#include "third_party/libva/va/va_backend.h"
+#if defined(USE_X11)
+#include "third_party/libva/va/va_x11.h"
+#include "ui/gfx/x/x11_types.h"
+#elif defined(USE_OZONE)
+#include "base/files/file.h"
+#include "third_party/libva/va/drm/va_drm.h"
+#include "third_party/libva/va/va_drmcommon.h"
+#endif
+
+#define DRIVER_EXTENSION "_drv_video.so"
+#if defined(__x86_64__)
+#define VA_DRIVERS_PATH "/usr/lib/x86_64-linux-gnu/dri"
+#elif defined(__i386__)
+#define VA_DRIVERS_PATH "/usr/lib/i386-linux-gnu/dri"
+#elif defined(__aarch64__)
+#define VA_DRIVERS_PATH "/usr/lib/aarch64-linux-gnu/dri"
+#endif
+
using sandbox::arch_seccomp_data;
using sandbox::bpf_dsl::Allow;
using sandbox::bpf_dsl::ResultExpr;
@@ -44,6 +68,15 @@ using sandbox::syscall_broker::BrokerFil
using sandbox::syscall_broker::BrokerProcess;
using sandbox::SyscallSets;
+using content_common::kModuleVa;
+#if defined(USE_X11)
+using content_common::kModuleVa_x11;
+#elif defined(USE_OZONE)
+using content_common::kModuleVa_drm;
+#endif
+using content_common::InitializeStubs;
+using content_common::StubPathMap;
+
namespace content {
namespace {
@@ -98,7 +131,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 =
@@ -290,6 +323,36 @@ ResultExpr GpuProcessPolicy::EvaluateSys
}
}
+#if !defined(__arm__)
+static VADisplay VaapiGetVADisplay() {
+ StubPathMap paths;
+ VADisplay va_display;
+ paths[kModuleVa].push_back("libva.so.1");
+#if defined(USE_OZONE)
+ paths[kModuleVa_drm].push_back("libva-drm.so.1");
+#elif defined (USE_X11)
+ paths[kModuleVa_x11].push_back("libva-x11.so.1");
+#endif
+ if (!InitializeStubs(paths)) {
+ return NULL;
+ }
+#if defined(USE_OZONE)
+ const char kDriRenderNode0Path[] = "/dev/dri/renderD128";
+ base::File drm_file = base::File(
+ base::FilePath::FromUTF8Unsafe(kDriRenderNode0Path),
+ base::File::FLAG_OPEN | base::File::FLAG_READ | base::File::FLAG_WRITE);
+ va_display = vaGetDisplayDRM(drm_file.GetPlatformFile());
+#elif defined(USE_X11)
+ va_display = vaGetDisplay(gfx::GetXDisplay());
+#endif
+ if (!vaDisplayIsValid(va_display)) {
+ LOG(WARNING) << "Unable to get display.";
+ return NULL;
+ }
+ return va_display;
+}
+#endif
+
bool GpuProcessPolicy::PreSandboxHook() {
// Warm up resources needed by the policy we're about to enable and
// eventually start a broker process.
@@ -303,31 +366,70 @@ bool GpuProcessPolicy::PreSandboxHook()
GpuBrokerProcessPolicy::Create,
std::vector<BrokerFilePermission>()); // No extra files in whitelist.
- 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";
+ // Accelerated video dlopen()'s some shared objects
+ // inside the sandbox, so preload them now.
+ if (IsAcceleratedVaapiVideoEncodeEnabled() ||
+ IsAcceleratedVideoDecodeEnabled()) {
+ // Init a VA Context, get driver name (and path), close context and preload
+#if defined(USE_OZONE) || defined(USE_X11)
+ VADisplay va_display = VaapiGetVADisplay();
+ if (va_display) {
+ char *va_search_path = getenv("LIBVA_DRIVERS_PATH");
+ char *va_driver_name = getenv("LIBVA_DRIVER_NAME");
+ char *saveptr, *driver_dir;
+ if (!va_driver_name) {
+ VADisplayContextP pDisplayContext =
+ static_cast<VADisplayContextP>(va_display);
+ pDisplayContext->vaGetDriverName(pDisplayContext, &va_driver_name);
}
- 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 (!va_driver_name) {
+ return true;
+ }
+
+ if (!va_search_path) {
+ va_search_path = strdup(VA_DRIVERS_PATH);
+ }
+
+ driver_dir = strtok_r(va_search_path, ":", &saveptr);
+ while (driver_dir) {
+ std::string driver_path = base::StringPrintf("%s/%s%s", driver_dir,
+ va_driver_name, DRIVER_EXTENSION);
+
+ // attempt to dlopen() the va driver
+ LOG(INFO) << "Looking for " << driver_path << "...";
+ if (access(driver_path.c_str(), R_OK) != -1) {
+ LOG(WARNING) << "Attempting to pre-load " << va_driver_name << " VA driver...";
+ if (dlopen(driver_path.c_str(), RTLD_NOW | RTLD_GLOBAL | RTLD_NODELETE)) {
+ LOG(WARNING) << "VA driver \"" << driver_path << "\" opened!";
+
+ if (strcmp(va_driver_name, "nvidia") == 0) {
+ LOG(WARNING) << "Pre-loading NVIDIA VDPAU driver libraries...";
+ if (dlopen("libvdpau_nvidia.so", RTLD_NOW | RTLD_GLOBAL | RTLD_NODELETE)) {
+ LOG(WARNING) << "Loaded libvdpau_nvidia.so";
+ }
+
+ if (dlopen("libvdpau.so", RTLD_NOW | RTLD_GLOBAL | RTLD_NODELETE)) {
+ LOG(WARNING) << "Loaded libvdpau.so";
+ }
+ }
+ LOG(WARNING) << "Loading libva libraries...";
+ 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);
+ 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);
+ dlopen("libva-x11.so.1", RTLD_NOW | RTLD_GLOBAL | RTLD_NODELETE);
#endif
+ break;
+ }
+ LOG(ERROR) << "VA driver failed to open!";
+ }
+
+ driver_dir = strtok_r(NULL, ":", &saveptr);
+ }
+ free(va_search_path);
}
+#endif
}
return true;
Index: dev/content/common/va_wayland.sigs
===================================================================
--- /dev/null
+++ dev/content/common/va_wayland.sigs
@@ -0,0 +1,8 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+//------------------------------------------------
+// Functions from libva-wayland used in chromium code.
+//------------------------------------------------
+VADisplay vaGetDisplayWl(struct wl_display *display);
Index: dev/content/gpu/BUILD.gn
===================================================================
--- dev.orig/content/gpu/BUILD.gn
+++ dev/content/gpu/BUILD.gn
@@ -103,7 +103,7 @@ target(link_target_type, "gpu_sources")
]
}
- if (is_chromeos && current_cpu != "arm") {
+ if (is_desktop_linux || (is_chromeos && current_cpu != "arm")) {
configs += [ "//third_party/libva:libva_config" ]
}
Index: dev/content/gpu/gpu_main.cc
===================================================================
--- dev.orig/content/gpu/gpu_main.cc
+++ dev/content/gpu/gpu_main.cc
@@ -84,7 +84,7 @@
#include "ui/ozone/public/ozone_platform.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
@@ -135,7 +135,7 @@ class ContentSandboxHelper : public gpu:
(void)base::RandUint64();
}
-#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
#if defined(OS_WIN)
Index: dev/content/public/common/content_switches.cc
===================================================================
--- dev.orig/content/public/common/content_switches.cc
+++ dev/content/public/common/content_switches.cc
@@ -1000,7 +1000,9 @@ const char kDisableAudioSupportForDeskto
#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";
Index: dev/content/public/common/content_switches.h
===================================================================
--- dev.orig/content/public/common/content_switches.h
+++ dev/content/public/common/content_switches.h
@@ -284,6 +284,8 @@ CONTENT_EXPORT extern const char kEnable
#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
Index: dev/gpu/config/software_rendering_list.json
===================================================================
--- dev.orig/gpu/config/software_rendering_list.json
+++ dev/gpu/config/software_rendering_list.json
@@ -371,17 +371,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, 629434],
Index: dev/media/BUILD.gn
===================================================================
--- dev.orig/media/BUILD.gn
+++ dev/media/BUILD.gn
@@ -330,7 +330,7 @@ source_set("unit_tests") {
sources += [ "filters/vpx_video_decoder_unittest.cc" ]
}
- if (current_cpu != "arm" && is_chromeos) {
+ if ((current_cpu != "arm" && is_chromeos) || is_desktop_linux) {
sources += [ "filters/h264_bitstream_buffer_unittest.cc" ]
}
Index: dev/media/gpu/BUILD.gn
===================================================================
--- dev.orig/media/gpu/BUILD.gn
+++ dev/media/gpu/BUILD.gn
@@ -18,7 +18,7 @@ if (is_mac) {
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"
@@ -249,7 +249,7 @@ component("gpu") {
}
}
- if (is_chromeos) {
+ if (is_linux) {
sources += [
"vp8_decoder.cc",
"vp8_decoder.h",
@@ -284,7 +284,7 @@ component("gpu") {
"EGL",
"GLESv2",
]
- if (current_cpu == "arm") {
+ if (current_cpu == "arm" && is_chromeos) {
sources += [
"tegra_v4l2_device.cc",
"tegra_v4l2_device.h",
Index: dev/media/gpu/gpu_video_decode_accelerator_factory.cc
===================================================================
--- dev.orig/media/gpu/gpu_video_decode_accelerator_factory.cc
+++ dev/media/gpu/gpu_video_decode_accelerator_factory.cc
@@ -16,7 +16,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"
@@ -87,7 +87,7 @@ GpuVideoDecodeAcceleratorFactory::GetDec
capabilities.supported_profiles =
DXVAVideoDecodeAccelerator::GetSupportedProfiles(gpu_preferences,
workarounds);
-#elif defined(OS_CHROMEOS)
+#elif defined(OS_CHROMEOS) || defined(OS_LINUX)
VideoDecodeAccelerator::SupportedProfiles vda_profiles;
#if defined(USE_V4L2_CODEC)
vda_profiles = V4L2VideoDecodeAccelerator::GetSupportedProfiles();
@@ -140,7 +140,7 @@ GpuVideoDecodeAcceleratorFactory::Create
&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)
@@ -221,11 +221,12 @@ GpuVideoDecodeAcceleratorFactory::Create
}
#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<VideoDecodeAccelerator>
GpuVideoDecodeAcceleratorFactory::CreateVaapiVDA(
const gpu::GpuDriverBugWorkarounds& workarounds,
const gpu::GpuPreferences& gpu_preferences) const {
+ VLOG(1) << "Creating new VAAPI video decode accelerator.";
std::unique_ptr<VideoDecodeAccelerator> decoder;
decoder.reset(new VaapiVideoDecodeAccelerator(make_context_current_cb_,
bind_image_cb_));
Index: dev/media/gpu/gpu_video_decode_accelerator_factory.h
===================================================================
--- dev.orig/media/gpu/gpu_video_decode_accelerator_factory.h
+++ dev/media/gpu/gpu_video_decode_accelerator_factory.h
@@ -105,7 +105,7 @@ class MEDIA_GPU_EXPORT GpuVideoDecodeAcc
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<VideoDecodeAccelerator> CreateVaapiVDA(
const gpu::GpuDriverBugWorkarounds& workarounds,
const gpu::GpuPreferences& gpu_preferences) const;
Index: dev/media/gpu/ipc/service/BUILD.gn
===================================================================
--- dev.orig/media/gpu/ipc/service/BUILD.gn
+++ dev/media/gpu/ipc/service/BUILD.gn
@@ -50,7 +50,7 @@ target(link_target_type, "service") {
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" ]
}
Index: dev/media/gpu/ipc/service/gpu_video_decode_accelerator.cc
===================================================================
--- dev.orig/media/gpu/ipc/service/gpu_video_decode_accelerator.cc
+++ dev/media/gpu/ipc/service/gpu_video_decode_accelerator.cc
@@ -58,7 +58,7 @@ static bool MakeDecoderContextCurrent(
return true;
}
-#if (defined(OS_CHROMEOS) && defined(ARCH_CPU_X86_FAMILY)) || \
+#if defined(OS_LINUX) || (defined(OS_CHROMEOS) && defined(ARCH_CPU_X86_FAMILY)) || \
defined(OS_MACOSX) || defined(OS_WIN)
static bool BindImage(const base::WeakPtr<gpu::GpuCommandBufferStub>& stub,
uint32_t client_texture_id,
@@ -175,7 +175,7 @@ GpuVideoDecodeAccelerator::GpuVideoDecod
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)) || \
+#if defined(OS_LINUX) || (defined(OS_CHROMEOS) && defined(ARCH_CPU_X86_FAMILY)) || \
defined(OS_MACOSX) || defined(OS_WIN)
bind_image_cb_ = base::Bind(&BindImage, stub_->AsWeakPtr());
#endif
Index: dev/media/gpu/va_stub_header.fragment
===================================================================
--- dev.orig/media/gpu/va_stub_header.fragment
+++ dev/media/gpu/va_stub_header.fragment
@@ -5,8 +5,9 @@ extern "C" {
#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
}
Index: dev/media/gpu/vaapi_video_decode_accelerator.cc
===================================================================
--- dev.orig/media/gpu/vaapi_video_decode_accelerator.cc
+++ dev/media/gpu/vaapi_video_decode_accelerator.cc
@@ -364,17 +364,17 @@ bool VaapiVideoDecodeAccelerator::Initia
base::AutoLock auto_lock(lock_);
DCHECK_EQ(state_, kUninitialized);
- DVLOG(2) << "Initializing VAVDA, profile: " << GetProfileName(profile);
+ VLOG(1) << "Initializing VAVDA, profile: " << GetProfileName(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;
}
@@ -384,7 +384,7 @@ bool VaapiVideoDecodeAccelerator::Initia
VaapiWrapper::kDecode, profile, base::Bind(&ReportToUMA, VAAPI_ERROR));
if (!vaapi_wrapper_.get()) {
- DVLOG(1) << "Failed initializing VAAPI for profile "
+ VLOG(1) << "Failed initializing VAAPI for profile "
<< GetProfileName(profile);
return false;
}
@@ -400,7 +400,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 " << GetProfileName(profile);
+ VLOG(1) << "Unsupported profile " << GetProfileName(profile);
return false;
}
Index: dev/media/gpu/vaapi_wrapper.cc
===================================================================
--- dev.orig/media/gpu/vaapi_wrapper.cc
+++ dev/media/gpu/vaapi_wrapper.cc
@@ -189,7 +189,7 @@ scoped_refptr<VaapiWrapper> VaapiWrapper
VAProfile va_profile,
const base::Closure& report_error_to_uma_cb) {
if (!GetProfileInfos()->IsProfileSupported(mode, va_profile)) {
- DVLOG(1) << "Unsupported va_profile: " << va_profile;
+ VLOG(1) << "Unsupported va_profile: " << va_profile;
return nullptr;
}
@@ -341,15 +341,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;
@@ -408,7 +410,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;
@@ -432,8 +434,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;
}
}
Index: dev/media/filters/BUILD.gn
===================================================================
--- dev.orig/media/filters/BUILD.gn
+++ dev/media/filters/BUILD.gn
@@ -214,7 +214,7 @@ source_set("filters") {
]
}
- if (current_cpu != "arm" && is_chromeos) {
+ if ((current_cpu != "arm" && is_chromeos) || is_desktop_linux) {
sources += [
"h264_bitstream_buffer.cc",
"h264_bitstream_buffer.h",