| 4.31.2 |
2020-12-14 |
diff --git a/docs/index.html b/docs/index.html
index 094b8d4..4a73a1a 100644
--- a/docs/index.html
+++ b/docs/index.html
@@ -169,7 +169,7 @@
systeminformation
- Current Version: 4.31.2
+ Current Version: 4.32.0
diff --git a/lib/graphics.js b/lib/graphics.js
index 2a67498..c1f0a6c 100644
--- a/lib/graphics.js
+++ b/lib/graphics.js
@@ -202,6 +202,7 @@ function graphics(callback) {
vendor: '',
model: '',
bus: '',
+ busAddress: '',
vram: -1,
vramDynamic: false
};
@@ -235,6 +236,7 @@ function graphics(callback) {
vendor: '',
model: '',
bus: '',
+ busAddress: '',
vram: -1,
vramDynamic: false
};
@@ -242,6 +244,7 @@ function graphics(callback) {
isGraphicsController = true;
let endpos = lines[i].search(/\[[0-9a-f]{4}:[0-9a-f]{4}]|$/);
let parts = lines[i].substr(vgapos, endpos - vgapos).split(':');
+ currentController.busAddress = lines[i].substr(0, vgapos).trim();
if (parts.length > 1) {
parts[1] = parts[1].trim();
if (parts[1].toLowerCase().indexOf('corporation') >= 0) {
@@ -288,12 +291,72 @@ function graphics(callback) {
}
}
}
- if (currentController.vendor || currentController.model || currentController.bus || currentController.vram !== -1 || currentController.vramDynamic) { // already a controller found
+ if (currentController.vendor || currentController.model || currentController.bus || currentController.busAddress || currentController.vram !== -1 || currentController.vramDynamic) { // already a controller found
controllers.push(currentController);
}
return (controllers);
}
+ function parseLinesLinuxClinfo(controllers, lines) {
+ const fieldPattern = /\[([^\]]+)\]\s+(\w+)\s+(.*)/;
+ const devices = lines.reduce((devices, line) => {
+ const field = fieldPattern.exec(line.trim());
+ if (field) {
+ if (!devices[field[1]]) {
+ devices[field[1]] = {};
+ }
+ devices[field[1]][field[2]] = field[3];
+ }
+ return devices
+ }, {});
+ for (let deviceId in devices) {
+ const device = devices[deviceId]
+ if (device['CL_DEVICE_TYPE'] === 'CL_DEVICE_TYPE_GPU') {
+ let busAddress;
+ if (device['CL_DEVICE_TOPOLOGY_AMD']) {
+ const bdf = device['CL_DEVICE_TOPOLOGY_AMD'].match(/[a-zA-Z0-9]+:\d+\.\d+/);
+ if (bdf) {
+ busAddress = bdf[0];
+ }
+ } else if (device['CL_DEVICE_PCI_BUS_ID_NV'] && device['CL_DEVICE_PCI_SLOT_ID_NV']) {
+ const bus = parseInt(device['CL_DEVICE_PCI_BUS_ID_NV']);
+ const slot = parseInt(device['CL_DEVICE_PCI_SLOT_ID_NV']);
+ if (!isNaN(bus) && !isNaN(slot)) {
+ const b = bus & 0xff;
+ const d = (slot >> 3) & 0xff;
+ const f = slot & 0x07;
+ busAddress = `${b.toString().padStart(2, '0')}:${d.toString().padStart(2, '0')}.${f}`;
+ }
+ }
+ if (busAddress) {
+ let controller = controllers.find(controller => controller.busAddress === busAddress);
+ if (!controller) {
+ controller = {
+ vendor: '',
+ model: '',
+ bus: '',
+ busAddress,
+ vram: -1,
+ vramDynamic: false
+ };
+ controllers.push(controller);
+ }
+ controller.vendor = device['CL_DEVICE_VENDOR'];
+ if (device['CL_DEVICE_BOARD_NAME_AMD']) {
+ controller.model = device['CL_DEVICE_BOARD_NAME_AMD'];
+ } else {
+ controller.model = device['CL_DEVICE_NAME'];
+ }
+ const memory = parseInt(device['CL_DEVICE_GLOBAL_MEM_SIZE']);
+ if (!isNaN(memory)) {
+ controller.vram = Math.round(memory / 1024 / 1024);
+ }
+ }
+ }
+ }
+ return controllers
+ }
+
function parseLinesLinuxEdid(edid) {
// parsen EDID
// --> model
@@ -530,23 +593,30 @@ function graphics(callback) {
let lines = stdout.toString().split('\n');
result.controllers = parseLinesLinuxControllers(lines);
}
- let cmd = 'xdpyinfo 2>/dev/null | grep \'depth of root window\' | awk \'{ print $5 }\'';
+ let cmd = "clinfo --raw";
exec(cmd, function (error, stdout) {
- let depth = 0;
if (!error) {
let lines = stdout.toString().split('\n');
- depth = parseInt(lines[0]) || 0;
+ result.controllers = parseLinesLinuxClinfo(result.controllers, lines);
}
- let cmd = 'xrandr --verbose 2>/dev/null';
+ let cmd = 'xdpyinfo 2>/dev/null | grep \'depth of root window\' | awk \'{ print $5 }\'';
exec(cmd, function (error, stdout) {
+ let depth = 0;
if (!error) {
let lines = stdout.toString().split('\n');
- result.displays = parseLinesLinuxDisplays(lines, depth);
+ depth = parseInt(lines[0]) || 0;
}
- if (callback) {
- callback(result);
- }
- resolve(result);
+ let cmd = 'xrandr --verbose 2>/dev/null';
+ exec(cmd, function (error, stdout) {
+ if (!error) {
+ let lines = stdout.toString().split('\n');
+ result.displays = parseLinesLinuxDisplays(lines, depth);
+ }
+ if (callback) {
+ callback(result);
+ }
+ resolve(result);
+ });
});
});
});
diff --git a/lib/index.d.ts b/lib/index.d.ts
index 47ba3c4..76cb327 100644
--- a/lib/index.d.ts
+++ b/lib/index.d.ts
@@ -252,6 +252,7 @@ export namespace Systeminformation {
vendor: string;
model: string;
bus: string;
+ busAddress?: string;
vram: number;
vramDynamic: boolean;
}