|
13 | 13 |
|
14 | 14 | #include <chrono> |
15 | 15 | #include <memory> |
| 16 | +#include <optional> |
16 | 17 | #include <string> |
17 | 18 | #include <unordered_map> |
18 | 19 | #include <vector> |
@@ -262,29 +263,31 @@ class ELinuxWindowDrm : public ELinuxWindow, public WindowBindingHandler { |
262 | 263 | } |
263 | 264 |
|
264 | 265 | constexpr char kFileNameSeparator[] = "/"; |
265 | | - auto pos = device_filename.find_last_of(kFileNameSeparator); |
266 | | - if (pos == std::string::npos) { |
267 | | - ELINUX_LOG(ERROR) << "Failed to get device name position."; |
268 | | - udev_unref(udev); |
269 | | - return false; |
270 | | - } |
| 266 | + if (device_filename != "drm-nvdc") { |
| 267 | + auto pos = device_filename.find_last_of(kFileNameSeparator); |
| 268 | + if (pos == std::string::npos) { |
| 269 | + ELINUX_LOG(ERROR) << "Failed to get device name position."; |
| 270 | + udev_unref(udev); |
| 271 | + return false; |
| 272 | + } |
271 | 273 |
|
272 | | - auto device_name = device_filename.substr(pos + 1); |
273 | | - auto device = udev_device_new_from_subsystem_sysname( |
274 | | - udev, kUdevMonitorSubsystemDrm, device_name.c_str()); |
275 | | - if (!device) { |
276 | | - ELINUX_LOG(ERROR) << "Failed to get device from " << device_name; |
277 | | - udev_unref(udev); |
278 | | - return false; |
279 | | - } |
| 274 | + auto device_name = device_filename.substr(pos + 1); |
| 275 | + auto device = udev_device_new_from_subsystem_sysname( |
| 276 | + udev, kUdevMonitorSubsystemDrm, device_name.c_str()); |
| 277 | + if (!device) { |
| 278 | + ELINUX_LOG(ERROR) << "Failed to get device from " << device_name; |
| 279 | + udev_unref(udev); |
| 280 | + return false; |
| 281 | + } |
280 | 282 |
|
281 | | - auto sysnum = udev_device_get_sysnum(device); |
282 | | - if (!sysnum) { |
283 | | - ELINUX_LOG(ERROR) << "Failed to get device id."; |
284 | | - udev_unref(udev); |
285 | | - return false; |
| 283 | + auto sysnum = udev_device_get_sysnum(device); |
| 284 | + if (!sysnum) { |
| 285 | + ELINUX_LOG(ERROR) << "Failed to get device id."; |
| 286 | + udev_unref(udev); |
| 287 | + return false; |
| 288 | + } |
| 289 | + drm_device_id_ = std::atoi(sysnum); |
286 | 290 | } |
287 | | - drm_device_id_ = std::atoi(sysnum); |
288 | 291 | udev_unref(udev); |
289 | 292 |
|
290 | 293 | if (sd_event_new(&udev_drm_event_loop_) < 0) { |
@@ -348,7 +351,7 @@ class ELinuxWindowDrm : public ELinuxWindow, public WindowBindingHandler { |
348 | 351 | if (!sysnum) { |
349 | 352 | ELINUX_LOG(ERROR) << "Failed to get device id."; |
350 | 353 | return false; |
351 | | - } else if (std::atoi(sysnum) != drm_device_id_) { |
| 354 | + } else if (drm_device_id_ && std::atoi(sysnum) != *drm_device_id_) { |
352 | 355 | ELINUX_LOG(ERROR) << "Not expected device id."; |
353 | 356 | return false; |
354 | 357 | } |
@@ -721,7 +724,7 @@ class ELinuxWindowDrm : public ELinuxWindow, public WindowBindingHandler { |
721 | 724 |
|
722 | 725 | sd_event* udev_drm_event_loop_ = nullptr; |
723 | 726 | udev_monitor* udev_monitor_ = nullptr; |
724 | | - int drm_device_id_; |
| 727 | + std::optional<int> drm_device_id_; |
725 | 728 | }; |
726 | 729 |
|
727 | 730 | } // namespace flutter |
|
0 commit comments