|
4 | 4 |
|
5 | 5 | // 项目自身文件 |
6 | 6 | #include "HWGenerator.h" |
| 7 | +#include "EDIDParser.h" |
7 | 8 |
|
8 | 9 | // Qt库文件 |
9 | 10 | #include <QDebug> |
10 | 11 | #include <QProcess> |
| 12 | +#include <QFile> |
| 13 | +#include <QDir> |
| 14 | +#include <QDebug> |
11 | 15 |
|
12 | 16 | // 其它头文件 |
13 | 17 | #include "DeviceManager/DeviceManager.h" |
@@ -414,3 +418,69 @@ void HWGenerator::getMemoryInfoFromLshw() |
414 | 418 | DeviceManager::instance()->addMemoryDevice(device); |
415 | 419 | } |
416 | 420 | } |
| 421 | + |
| 422 | +static void parseEDID(QStringList allEDIDS,QString input) |
| 423 | +{ |
| 424 | + for (auto edid:allEDIDS) { |
| 425 | + QProcess process; |
| 426 | + process.start(QString("hexdump %1").arg(edid)); |
| 427 | + process.waitForFinished(-1); |
| 428 | + |
| 429 | + QString deviceInfo = process.readAllStandardOutput(); |
| 430 | + if(deviceInfo.isEmpty()) |
| 431 | + continue; |
| 432 | + |
| 433 | + QString edidStr; |
| 434 | + QStringList lines = deviceInfo.split("\n"); |
| 435 | + for (auto line:lines) { |
| 436 | + QStringList words = line.trimmed().split(" "); |
| 437 | + if(words.size() != 9) |
| 438 | + continue; |
| 439 | + |
| 440 | + words.removeAt(0); |
| 441 | + QString l = words.join(""); |
| 442 | + l.append("\n"); |
| 443 | + edidStr.append(l); |
| 444 | + } |
| 445 | + |
| 446 | + lines = edidStr.split("\n"); |
| 447 | + if(lines.size() > 3){ |
| 448 | + EDIDParser edidParser; |
| 449 | + QString errorMsg; |
| 450 | + edidParser.setEdid(edidStr,errorMsg,"\n", false); |
| 451 | + |
| 452 | + QMap<QString, QString> mapInfo; |
| 453 | + mapInfo.insert("Vendor",edidParser.vendor()); |
| 454 | + mapInfo.insert("Model",edidParser.model()); |
| 455 | + mapInfo.insert("Date",edidParser.releaseDate()); |
| 456 | + mapInfo.insert("Size",edidParser.screenSize()); |
| 457 | + mapInfo.insert("Display Input",input); |
| 458 | + |
| 459 | + DeviceMonitor *device = new DeviceMonitor(); |
| 460 | + device->setInfoFromEdid(mapInfo); |
| 461 | + DeviceManager::instance()->addMonitor(device); |
| 462 | + } |
| 463 | + } |
| 464 | +} |
| 465 | + |
| 466 | +void HWGenerator::generatorMonitorDevice() |
| 467 | +{ |
| 468 | + QString toDir = "/sys/class/drm"; |
| 469 | + QDir toDir_(toDir); |
| 470 | + |
| 471 | + if (!toDir_.exists()) |
| 472 | + return; |
| 473 | + |
| 474 | + QFileInfoList fileInfoList = toDir_.entryInfoList(); |
| 475 | + foreach(QFileInfo fileInfo, fileInfoList) { |
| 476 | + if(fileInfo.fileName() == "." || fileInfo.fileName() == ".." || !fileInfo.fileName().startsWith("card")) |
| 477 | + continue; |
| 478 | + |
| 479 | + if(QFile::exists(fileInfo.filePath() + "/" + "edid")) { |
| 480 | + QStringList allEDIDS_all; |
| 481 | + allEDIDS_all.append(fileInfo.filePath() + "/" + "edid"); |
| 482 | + QString interface = fileInfo.fileName().remove("card0-").remove("card1-").remove("card2-"); |
| 483 | + parseEDID(allEDIDS_all,interface); |
| 484 | + } |
| 485 | + } |
| 486 | +} |
0 commit comments