[Intel-gfx] [PATCH 08/10] quick_dump: SWIG chipset interface

Ben Widawsky ben at bwidawsk.net
Sun Feb 3 01:08:00 CET 2013


This isn't strictly necessary it would have been easy enough to simply
convert intel_chipset.h but this should be nice prep work for directly
doing MMIO. It also serves as a nice review point.

It's demonstrated with an autodetect function in the script. That
autodetect has a hardcoded path that shouldn't be there, but it will go
away in the next patch when we can properly link in libpciaccess.

Thanks to Matt for helping whip the automake stuff into shape.

Cc: Matt Turner <mattst88 at gmail.com>
Signed-off-by: Ben Widawsky <ben at bwidawsk.net>
---
 tools/Makefile.am                |  2 +-
 tools/quick_dump/Makefile.am     | 18 +++++++++++++++++-
 tools/quick_dump/chipset.i       | 12 ++++++++++++
 tools/quick_dump/intel_chipset.c | 16 ++++++++++++++++
 tools/quick_dump/quick_dump.py   | 15 +++++++++++++++
 5 files changed, 61 insertions(+), 2 deletions(-)
 create mode 100644 tools/quick_dump/chipset.i
 create mode 100644 tools/quick_dump/intel_chipset.c

diff --git a/tools/Makefile.am b/tools/Makefile.am
index 016fb89..6088919 100644
--- a/tools/Makefile.am
+++ b/tools/Makefile.am
@@ -1,4 +1,4 @@
-DIST_SUBDIRS = quick_dump
+SUBDIRS = quick_dump
 
 bin_PROGRAMS = 				\
 	intel_disable_clock_gating 	\
diff --git a/tools/quick_dump/Makefile.am b/tools/quick_dump/Makefile.am
index a0c7083..6c04dd5 100644
--- a/tools/quick_dump/Makefile.am
+++ b/tools/quick_dump/Makefile.am
@@ -1,6 +1,22 @@
+BUILT_SOURCES = chipset_wrap_python.c
+
+bin_SCRIPTS = quick_dump.py chipset.py
+
+lib_LTLIBRARIES = I915ChipsetPython.la
+I915ChipsetPython_la_CFLAGS = -I$(top_srcdir)/lib $(PYTHON_CPPFLAGS)
+I915ChipsetPython_la_LDFLAGS = -module -avoid-version $(PYTHON_LDFLAGS)
+I915ChipsetPython_la_SOURCES = chipset_wrap_python.c intel_chipset.c
+
+chipset_wrap_python.c: chipset.i
+	$(SWIG) $(AX_SWIG_PYTHON_OPT) -I$(top_srcdir)/lib -o $@ $<
+
+all-local: I915ChipsetPython.la
+	$(LN_S) -f .libs/I915ChipsetPython.so _chipset.so
+
+CLEANFILES = chipset_wrap_python.c chipset.py _chipset.so
 EXTRA_DIST =  \
 	      base_display.txt base_interrupt.txt base_other.txt base_power.txt base_rings.txt \
 	      gen6_other.txt sandybridge \
 	      gen7_other.txt ivybridge \
 	      vlv_display.txt valleyview \
-	      quick_dump.py
+	      chipset.i quick_dump.py chipset.py
diff --git a/tools/quick_dump/chipset.i b/tools/quick_dump/chipset.i
new file mode 100644
index 0000000..16c4932
--- /dev/null
+++ b/tools/quick_dump/chipset.i
@@ -0,0 +1,12 @@
+%module chipset 
+%{
+#include "intel_chipset.h"
+extern int is_sandybridge(unsigned short pciid);
+extern int is_ivybridge(unsigned short pciid);
+extern int is_valleyview(unsigned short pciid);
+%}
+
+%include "intel_chipset.h"
+extern int is_sandybridge(unsigned short pciid);
+extern int is_ivybridge(unsigned short pciid);
+extern int is_valleyview(unsigned short pciid);
diff --git a/tools/quick_dump/intel_chipset.c b/tools/quick_dump/intel_chipset.c
new file mode 100644
index 0000000..b242ffc
--- /dev/null
+++ b/tools/quick_dump/intel_chipset.c
@@ -0,0 +1,16 @@
+#include "intel_chipset.h"
+
+int is_sandybridge(unsigned short pciid)
+{
+	return IS_GEN6(pciid);
+}
+
+int is_ivybridge(unsigned short pciid)
+{
+	return IS_IVYBRIDGE(pciid);
+}
+
+int is_valleyview(unsigned short pciid)
+{
+	return IS_VALLEYVIEW(pciid);
+}
diff --git a/tools/quick_dump/quick_dump.py b/tools/quick_dump/quick_dump.py
index 3fea7bb..59cae1f 100755
--- a/tools/quick_dump/quick_dump.py
+++ b/tools/quick_dump/quick_dump.py
@@ -5,6 +5,7 @@ import os
 import sys
 import ast
 import subprocess
+import chipset
 
 def parse_file(file):
 	for line in file:
@@ -18,6 +19,7 @@ def parse_file(file):
 
 parser = argparse.ArgumentParser(description='Dumb register dumper.')
 parser.add_argument('-b', '--baseless', action='store_true', default=False, help='baseless mode, ignore files starting with base_')
+parser.add_argument('-a', '--autodetect', action='store_true', default=False, help='autodetect chipset')
 parser.add_argument('profile', nargs='?', type=argparse.FileType('r'), default=None)
 args = parser.parse_args()
 
@@ -29,6 +31,19 @@ if args.baseless == False:
 				file = open(name.rstrip(), 'r')
 				parse_file(file)
 
+if args.autodetect:
+	sysfs_file = open('/sys/class/drm/card0/device/device', 'r')
+	devid_str = sysfs_file.read()
+	devid = int(devid_str, 16)
+	if chipset.is_sandybridge(devid):
+		args.profile = open('sandybridge', 'r')
+	elif chipset.is_ivybridge(devid):
+		args.profile = open('ivybridge', 'r')
+	elif chipset.is_valleyview(devid):
+		args.profile = open('valleyview', 'r')
+	else:
+		print("Autodetect of %x " + devid + " failed")
+
 if args.profile == None:
 	sys.exit()
 
-- 
1.8.1.2




More information about the Intel-gfx mailing list