A GPU is named from an embedded PCI ID table, the same on every machine
The router has no lspci, so its GeminiLake chip came up as 'Intel GPU 3185' beside the identical chip's 'Intel UHD Graphics 600' on hamtv. A trimmed pci.ids — the graphics devices of Intel, AMD and NVIDIA, and the virtual GPUs, 115 KB — rides in the binary and is consulted first; lspci is the fallback for a card newer than the table. scripts/pci-ids-gpu.sh regenerates it from the hub's copy. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Fable 5.1
parent
b5cecce435
commit
3a58e265c6
Executable
+35
@@ -0,0 +1,35 @@
|
||||
#!/bin/sh
|
||||
# Trim the PCI ID database to the graphics devices of the GPU vendors, for embedding in
|
||||
# the binary (internal/metrics/pciids_gpu.txt): a machine without pciutils — OpenWrt has
|
||||
# neither lspci nor pci.ids — then names its GPU exactly as every other machine does.
|
||||
#
|
||||
# scripts/pci-ids-gpu.sh [/path/to/pci.ids] default: /usr/share/misc/pci.ids
|
||||
#
|
||||
# Kept: the vendor lines and device lines (never subsystems) of Intel 8086, AMD 1002 and
|
||||
# NVIDIA 10de whose name is bracketed (how pci.ids writes a marketing name) or mentions
|
||||
# graphics, and everything of the three virtual-GPU vendors (virtio 1af4, VMware 15ad,
|
||||
# Bochs 1234). A non-GPU device slipping through costs a line; it is only ever consulted
|
||||
# for a card the kernel already drives as a GPU.
|
||||
set -eu
|
||||
src=${1:-/usr/share/misc/pci.ids}
|
||||
out=$(dirname "$0")/../internal/metrics/pciids_gpu.txt
|
||||
{
|
||||
echo "# Trimmed from pci.ids ($(grep -m1 -i 'version:' "$src" | sed 's/^#[[:space:]]*//')) by scripts/pci-ids-gpu.sh."
|
||||
echo "# Vendor lines and the graphics device lines of Intel, AMD and NVIDIA, plus the virtual GPUs."
|
||||
echo "# pci.ids is distributed under the 3-clause BSD license (https://pci-ids.ucw.cz/)."
|
||||
awk '
|
||||
/^[0-9a-f][0-9a-f][0-9a-f][0-9a-f] / {
|
||||
vendor = substr($0, 1, 4)
|
||||
keep = (vendor == "8086" || vendor == "1002" || vendor == "10de")
|
||||
all = (vendor == "1af4" || vendor == "15ad" || vendor == "1234")
|
||||
if (keep || all) print
|
||||
next
|
||||
}
|
||||
/^\t[0-9a-f][0-9a-f][0-9a-f][0-9a-f] / {
|
||||
if (all) { print; next }
|
||||
if (!keep) next
|
||||
if ($0 ~ /\[/ || $0 ~ /Graphics|Radeon|GeForce|Quadro|Tesla|Arc |Iris|Xe |GPU|Display|VGA|FirePro|Instinct|Data Center/) print
|
||||
}
|
||||
' "$src"
|
||||
} > "$out"
|
||||
echo "$out: $(wc -l < "$out") lines, $(wc -c < "$out") bytes"
|
||||
Reference in New Issue
Block a user