From patchwork Thu Feb 7 18:39:33 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ben Widawsky X-Patchwork-Id: 2112711 Return-Path: X-Original-To: patchwork-intel-gfx@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by patchwork1.kernel.org (Postfix) with ESMTP id 250DB3FCD5 for ; Thu, 7 Feb 2013 18:42:16 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 1A2E0E6393 for ; Thu, 7 Feb 2013 10:42:16 -0800 (PST) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from shiva.chad-versace.us (209-20-75-48.static.cloud-ips.com [209.20.75.48]) by gabe.freedesktop.org (Postfix) with ESMTP id AFC77E6882 for ; Thu, 7 Feb 2013 10:39:24 -0800 (PST) Received: by shiva.chad-versace.us (Postfix, from userid 1005) id CCA5C88120; Thu, 7 Feb 2013 18:42:27 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on shiva.chad-versace.us X-Spam-Level: X-Spam-Status: No, score=-2.9 required=5.0 tests=ALL_TRUSTED,BAYES_00 autolearn=unavailable version=3.3.2 Received: from lundgren.nims.intel.com (jfdmzpr02-ext.jf.intel.com [134.134.137.71]) by shiva.chad-versace.us (Postfix) with ESMTPSA id 35EF58845A; Thu, 7 Feb 2013 18:41:27 +0000 (UTC) From: Ben Widawsky To: intel-gfx@lists.freedesktop.org Date: Thu, 7 Feb 2013 10:39:33 -0800 Message-Id: <1360262377-24179-8-git-send-email-ben@bwidawsk.net> X-Mailer: git-send-email 1.8.1.2 In-Reply-To: <1360262377-24179-1-git-send-email-ben@bwidawsk.net> References: <1360262377-24179-1-git-send-email-ben@bwidawsk.net> Cc: Ben Widawsky Subject: [Intel-gfx] [PATCH 08/12] quick_dump: SWIG chipset interface X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: intel-gfx-bounces+patchwork-intel-gfx=patchwork.kernel.org@lists.freedesktop.org Errors-To: intel-gfx-bounces+patchwork-intel-gfx=patchwork.kernel.org@lists.freedesktop.org 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. v2: Switch to $(top_srcdir) Reviewed-by: Matt Turner Signed-off-by: Ben Widawsky --- 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()