contrib/mk_detect_intel_gpu: add a tool to detect Intel GPUs from their PCI IDs
PATCH v3 1/1 contrib/mk_detect_intel_gpu: add a tool to detect Intel GPUs from their PCI IDs
From: Mauro Carvalho Chehab <[email protected]>
Such tool parses the Kernel drivers for both i915 and Xe and generates a script that helps detecting Intel GPU models.
Signed-off-by Mauro Carvalho Chehab <[email protected]>
--- contrib/mk_detect_intel_gpu/Makefile | 57 +++++++ contrib/mk_detect_intel_gpu/get_gpu.c | 216 ++++++++++++++++++++++++++ 2 files changed, 273 insertions(+) create mode 100644 contrib/mk_detect_intel_gpu/Makefile create mode 100644 contrib/mk_detect_intel_gpu/get_gpu.c
contrib/mk_detect_intel_gpu/Makefile new file +57 -0
@@ -0,0 +1,57 @@ +# SPDX-License-Identifier: MIT +# +# Copyright © 2022-2024 Intel Corporation +# Author: Mauro Carvalho Chehab <[email protected]> +# +# Usage: specify either: +# make KERNEL_DIR=<directory to copy files for both i915 and Xe Intel drivers> +# or: +# make XE_DIR=<directory to copy files for Xe Intel driver> I915_DIR=<directory to copy files for i915 Intel driver> + +XE_DIR := +I915_DIR := + +all: intel_detect_gpu.pl + +clean: + rm i915_pciids.h i915_id.h xe_pciids.h xe_pci.c get_gpu intel_detect_gpu.pl + +ifneq ($(KERNEL_DIR),) + XE_DIR := $(KERNEL_DIR) + I915_DIR := $(KERNEL_DIR) +endif + +ifeq ($(XE_DIR),) + $(error Need a directory with the XE driver) +endif + +ifeq ($(I915_DIR),) + $(error Need a directory with the i915 driver) +endif + +intel_detect_gpu.pl: get_gpu + ./get_gpu >intel_detect_gpu.pl + chmod 755 intel_detect_gpu.pl + +i915_pciids.h: + cp ${I915_DIR}/include/drm/i915_pciids.h . + sed s,"(unsigned long) info }","info }", -i i915_pciids.h + +xe_pci_ids.h: + cp ${XE_DIR}/include/drm/xe_pciids.h . + +xe_pci.c: + cp ${XE_DIR}/drivers/gpu/drm/xe/xe_pci.c . + +i915_id.h: i915_pciids.h xe_pci.c + echo "static struct pci_device_id pci_ids[] = {" > i915_id.h + tac i915_pciids.h |grep define|perl -ne 'if (/define\s+INTEL_(\w+)_IDS/) { print "\tINTEL_$$1_IDS(\"$$1\"),\n" }' >> i915_id.h + + cat xe_pci.c|perl -ne 'if (m/(XE_)([\w_]+)(_IDS\(INTEL_VGA_DEVICE)/) { print "\t$$1$$2$$3, \"$$2\"),\n"}' >> i915_id.h + + echo "};" >> i915_id.h + +get_gpu: get_gpu.c i915_id.h i915_pciids.h xe_pci_ids.h + gcc -g -Wall get_gpu.c -o get_gpu + +.PHONY: i915_id.h i915_pciids.h
contrib/mk_detect_intel_gpu/get_gpu.c new file +216 -0
216 lines not on this page · raw message
Signature · 1 line
2.44.0