Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix ContextEgl for EGLStreams. Support Nvidia TX1/2 #381

Merged
merged 1 commit into from
Aug 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@ FlafyDev <flafyarazi@gmail.com>
Makoto Sato (makoto.sato@atmark-techno.com)
Yunhao Tian (t123yh@outlook.com)
Luke Howard <lukeh@padl.com>
Stanislav Shmarov <github@snarpix.com>
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ namespace flutter {

ContextEglStream::ContextEglStream(
std::unique_ptr<EnvironmentEglStream> environment)
: ContextEgl(std::move(environment), EGL_STREAM_BIT_KHR) {
: ContextEgl(std::move(environment), false, EGL_STREAM_BIT_KHR) {
if (!valid_) {
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

#include <chrono>
#include <memory>
#include <optional>
#include <string>
#include <unordered_map>
#include <vector>
Expand Down Expand Up @@ -262,29 +263,31 @@ class ELinuxWindowDrm : public ELinuxWindow, public WindowBindingHandler {
}

constexpr char kFileNameSeparator[] = "/";
auto pos = device_filename.find_last_of(kFileNameSeparator);
if (pos == std::string::npos) {
ELINUX_LOG(ERROR) << "Failed to get device name position.";
udev_unref(udev);
return false;
}
if (device_filename != "drm-nvdc") {
auto pos = device_filename.find_last_of(kFileNameSeparator);
if (pos == std::string::npos) {
ELINUX_LOG(ERROR) << "Failed to get device name position.";
udev_unref(udev);
return false;
}

auto device_name = device_filename.substr(pos + 1);
auto device = udev_device_new_from_subsystem_sysname(
udev, kUdevMonitorSubsystemDrm, device_name.c_str());
if (!device) {
ELINUX_LOG(ERROR) << "Failed to get device from " << device_name;
udev_unref(udev);
return false;
}
auto device_name = device_filename.substr(pos + 1);
auto device = udev_device_new_from_subsystem_sysname(
udev, kUdevMonitorSubsystemDrm, device_name.c_str());
if (!device) {
ELINUX_LOG(ERROR) << "Failed to get device from " << device_name;
udev_unref(udev);
return false;
}

auto sysnum = udev_device_get_sysnum(device);
if (!sysnum) {
ELINUX_LOG(ERROR) << "Failed to get device id.";
udev_unref(udev);
return false;
auto sysnum = udev_device_get_sysnum(device);
if (!sysnum) {
ELINUX_LOG(ERROR) << "Failed to get device id.";
udev_unref(udev);
return false;
}
drm_device_id_ = std::atoi(sysnum);
}
drm_device_id_ = std::atoi(sysnum);
udev_unref(udev);

if (sd_event_new(&udev_drm_event_loop_) < 0) {
Expand Down Expand Up @@ -348,7 +351,7 @@ class ELinuxWindowDrm : public ELinuxWindow, public WindowBindingHandler {
if (!sysnum) {
ELINUX_LOG(ERROR) << "Failed to get device id.";
return false;
} else if (std::atoi(sysnum) != drm_device_id_) {
} else if (drm_device_id_ && std::atoi(sysnum) != *drm_device_id_) {
ELINUX_LOG(ERROR) << "Not expected device id.";
return false;
}
Expand Down Expand Up @@ -721,7 +724,7 @@ class ELinuxWindowDrm : public ELinuxWindow, public WindowBindingHandler {

sd_event* udev_drm_event_loop_ = nullptr;
udev_monitor* udev_monitor_ = nullptr;
int drm_device_id_;
std::optional<int> drm_device_id_;
};

} // namespace flutter
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,11 @@ namespace flutter {
NativeWindowDrm::NativeWindowDrm(const char* device_filename,
const uint16_t rotation,
bool enable_vsync) {
drm_device_ = open(device_filename, O_RDWR | O_CLOEXEC);
if (!strcmp("drm-nvdc", device_filename)) {
drm_device_ = drmOpen(device_filename, nullptr);
} else {
drm_device_ = open(device_filename, O_RDWR | O_CLOEXEC);
}
if (drm_device_ == -1) {
ELINUX_LOG(ERROR) << "Couldn't open " << device_filename;
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@

#include <xf86drmMode.h>

#include <cstddef>
#include <cstdint>
#include <string>

#include "flutter/shell/platform/linux_embedded/surface/surface_gl.h"
Expand Down