Skip to content
This repository has been archived by the owner on Apr 3, 2020. It is now read-only.

Commit

Permalink
[Ozone] VAAPI wrapper should open its own render node.
Browse files Browse the repository at this point in the history
This prevents a double-close problem that arises when libva uses the same drm
fd as gbm.

TODO(hshi): refactor VAAPI wrapper's management of drm file (crbug.com/475250).

BUG=462459
BUG=464628
TEST=verify that video acceleration works and the netflix hang is fixed
[email protected], [email protected]
[email protected]

Review URL: https://codereview.chromium.org/1073653003

Cr-Commit-Position: refs/heads/master@{#324329}
(cherry picked from commit b46fe98)

Review URL: https://codereview.chromium.org/1071033002

Cr-Commit-Position: refs/branch-heads/2357@{#33}
Cr-Branched-From: 59d4494-refs/heads/master@{#323860}
  • Loading branch information
hshi-chromium committed Apr 9, 2015
1 parent f7e78a8 commit 1f7c3cb
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
9 changes: 5 additions & 4 deletions content/common/gpu/media/vaapi_wrapper.cc
Original file line number Diff line number Diff line change
Expand Up @@ -291,10 +291,11 @@ bool VaapiWrapper::VaInitialize(const base::Closure& report_error_to_uma_cb) {
#if defined(USE_X11)
va_display_ = vaGetDisplay(gfx::GetXDisplay());
#elif defined(USE_OZONE)
ui::OzonePlatform* platform = ui::OzonePlatform::GetInstance();
ui::SurfaceFactoryOzone* factory = platform->GetSurfaceFactoryOzone();

va_display_ = vaGetDisplayDRM(factory->GetDrmFd());
const char* kDriRenderNode0Path = "/dev/dri/renderD128";
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());
#endif // USE_X11

if (!vaDisplayIsValid(va_display_)) {
Expand Down
6 changes: 6 additions & 0 deletions content/common/gpu/media/vaapi_wrapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include <set>
#include <vector>

#include "base/files/file.h"
#include "base/lazy_instance.h"
#include "base/memory/ref_counted.h"
#include "base/synchronization/lock.h"
Expand Down Expand Up @@ -302,6 +303,11 @@ class CONTENT_EXPORT VaapiWrapper {
VAContextID va_vpp_context_id_;
VABufferID va_vpp_buffer_id_;

#if defined(USE_OZONE)
// Drm file used to obtain access to the driver interface by VA.
base::File drm_file_;
#endif // USE_OZONE

// Singleton variable to store supported profile information for encode and
// decode.
static base::LazyInstance<LazyProfileInfos> profile_infos_;
Expand Down
2 changes: 2 additions & 0 deletions content/common/sandbox_linux/bpf_gpu_policy_linux.cc
Original file line number Diff line number Diff line change
Expand Up @@ -321,13 +321,15 @@ void GpuProcessPolicy::InitGpuBrokerProcess(
const std::vector<BrokerFilePermission>& permissions_extra) {
static const char kDriRcPath[] = "/etc/drirc";
static const char kDriCard0Path[] = "/dev/dri/card0";
static const char kDriRenderNode0Path[] = "/dev/dri/renderD128";
static const char kDevShm[] = "/dev/shm/";

CHECK(broker_process_ == NULL);

// All GPU process policies need these files brokered out.
std::vector<BrokerFilePermission> permissions;
permissions.push_back(BrokerFilePermission::ReadWrite(kDriCard0Path));
permissions.push_back(BrokerFilePermission::ReadWrite(kDriRenderNode0Path));
permissions.push_back(BrokerFilePermission::ReadOnly(kDriRcPath));
if (!IsChromeOS()) {
permissions.push_back(
Expand Down

0 comments on commit 1f7c3cb

Please sign in to comment.