From patchwork Tue May 3 14:18:54 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jani Nikula X-Patchwork-Id: 9004141 Return-Path: X-Original-To: patchwork-intel-gfx@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 1AAE79F39D for ; Tue, 3 May 2016 14:19:25 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 2887120121 for ; Tue, 3 May 2016 14:19:24 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 606AC2010C for ; Tue, 3 May 2016 14:19:22 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id ECBC46E883; Tue, 3 May 2016 14:19:21 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by gabe.freedesktop.org (Postfix) with ESMTP id 5D95D6E883 for ; Tue, 3 May 2016 14:19:20 +0000 (UTC) Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga102.jf.intel.com with ESMTP; 03 May 2016 07:19:19 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.24,572,1455004800"; d="scan'208";a="971596107" Received: from jnikula-mobl.fi.intel.com (HELO localhost) ([10.237.72.67]) by fmsmga002.fm.intel.com with ESMTP; 03 May 2016 07:19:19 -0700 From: Jani Nikula To: intel-gfx@lists.freedesktop.org Date: Tue, 3 May 2016 17:18:54 +0300 Message-Id: <434028dedd35194616a4462f547ece391239e62c.1462285023.git.jani.nikula@intel.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: References: In-Reply-To: References: Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo Cc: jani.nikula@intel.com Subject: [Intel-gfx] [PATCH i-g-t 04/17] tools/intel_bios_reader: add --devid parameter X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Spam-Status: No, score=-5.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Not sure it's a great idea to do platform specific parsing of the BIOS, but at least make it possible to pass in the devid on the command line and not just the environment. Signed-off-by: Jani Nikula --- tools/intel_bios_reader.c | 35 ++++++++++++++++++++++++----------- 1 file changed, 24 insertions(+), 11 deletions(-) diff --git a/tools/intel_bios_reader.c b/tools/intel_bios_reader.c index b424b17e4852..d74e766250df 100644 --- a/tools/intel_bios_reader.c +++ b/tools/intel_bios_reader.c @@ -41,7 +41,7 @@ #include "intel_chipset.h" #include "drmtest.h" -static uint32_t devid = -1; +static uint32_t devid; /* no bother to include "edid.h" */ #define _H_ACTIVE(x) (x[2] + ((x[4] & 0xF0) << 4)) @@ -149,8 +149,10 @@ static void dump_general_features(const struct bdb_header *bdb, printf("\tExternal VBT: %s\n", YESNO(features->download_ext_vbt)); printf("\tEnable SSC: %s\n", YESNO(features->enable_ssc)); if (features->enable_ssc) { - if (IS_VALLEYVIEW(devid) || IS_CHERRYVIEW(devid) || - IS_BROXTON(devid)) + if (!devid) + printf("\tSSC frequency: \n"); + else if (IS_VALLEYVIEW(devid) || IS_CHERRYVIEW(devid) || + IS_BROXTON(devid)) printf("\tSSC frequency: 100 MHz\n"); else if (HAS_PCH_SPLIT(devid)) printf("\tSSC frequency: %s\n", features->ssc_freq ? @@ -1375,6 +1377,7 @@ enum opt { OPT_UNKNOWN = '?', OPT_END = -1, OPT_FILE, + OPT_DEVID, }; int main(int argc, char **argv) @@ -1392,10 +1395,11 @@ int main(int argc, char **argv) struct bdb_block *block; struct bdb_header *bdb; char signature[17]; - char *devid_string; + char *endp; static struct option options[] = { { "file", required_argument, NULL, OPT_FILE }, + { "devid", required_argument, NULL, OPT_DEVID }, { 0 } }; @@ -1406,6 +1410,13 @@ int main(int argc, char **argv) case OPT_FILE: filename = optarg; break; + case OPT_DEVID: + devid = strtoul(optarg, &endp, 16); + if (!devid || *endp) { + fprintf(stderr, "invalid devid '%s'\n", optarg); + return EXIT_FAILURE; + } + break; case OPT_END: break; case OPT_UNKNOWN: @@ -1426,9 +1437,6 @@ int main(int argc, char **argv) } } - if ((devid_string = getenv("DEVICE"))) - devid = strtoul(devid_string, NULL, 0); - fd = open(filename, O_RDONLY); if (fd == -1) { printf("Couldn't open \"%s\": %s\n", filename, strerror(errno)); @@ -1506,10 +1514,15 @@ int main(int argc, char **argv) } printf("\n"); - if (devid == -1) - devid = get_device_id(VBIOS, size); - if (devid == -1) - printf("Warning: could not find PCI device ID!\n"); + if (!devid) { + const char *devid_string = getenv("DEVICE"); + if (devid_string) + devid = strtoul(devid_string, NULL, 0); + } + if (!devid) + devid = get_device_id(VBIOS, size); + if (!devid) + fprintf(stderr, "Warning: could not find PCI device ID!\n"); dump_section(bdb, BDB_GENERAL_FEATURES, size); dump_section(bdb, BDB_GENERAL_DEFINITIONS, size);