All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH i-g-t 00/17] tools/intel_bios_reader updates
@ 2016-05-03 14:18 Jani Nikula
  2016-05-03 14:18 ` [PATCH i-g-t 01/17] tools/intel_bios_reader: drop unused macros Jani Nikula
                   ` (17 more replies)
  0 siblings, 18 replies; 22+ messages in thread
From: Jani Nikula @ 2016-05-03 14:18 UTC (permalink / raw)
  To: intel-gfx; +Cc: jani.nikula

Give the intel_bios_reader tool some love. The last patch updating the
man page doubles as a summary.

BR,
Jani.


Jani Nikula (17):
  tools/intel_bios_reader: drop unused macros
  tools/intel_bios_reader: make VBIOS non-global
  tools/intel_bios_reader: add command line option parsing and --file
    parameter
  tools/intel_bios_reader: add --devid parameter
  tools/intel_bios_reader: drop unused lvds_support variable
  tools/intel_bios_reader: drop silly tv_present variable and printout
  tools/intel_bios_reader: pass around a context pointer instead of
    bdb_header
  tools/intel_bios_reader: move more globals to struct context
  tools/intel_bios_reader: move devid to context too
  tools/intel_bios_reader: drop dependencies on lvds block parsing
  tools/intel_bios_reader: let the user specify panel type on the
    command line
  tools/intel_bios_reader: dump the blocks in numerical order
  tools/intel_bios_reader: add --hexdump option to dump hex, disable by
    default
  tools/intel_bios_reader: add support for dumping only specific section
  tools/intel_bios_reader: add --all-panels option to dump all panels
  tools/intel_bios_reader: free the block returned by find_section
  man: update intel_bios_reader man page

 man/intel_bios_reader.rst |  48 +++++--
 tools/intel_bios_reader.c | 310 +++++++++++++++++++++++++++++++---------------
 2 files changed, 249 insertions(+), 109 deletions(-)

-- 
2.1.4

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 22+ messages in thread

* [PATCH i-g-t 01/17] tools/intel_bios_reader: drop unused macros
  2016-05-03 14:18 [PATCH i-g-t 00/17] tools/intel_bios_reader updates Jani Nikula
@ 2016-05-03 14:18 ` Jani Nikula
  2016-05-03 14:18 ` [PATCH i-g-t 02/17] tools/intel_bios_reader: make VBIOS non-global Jani Nikula
                   ` (16 subsequent siblings)
  17 siblings, 0 replies; 22+ messages in thread
From: Jani Nikula @ 2016-05-03 14:18 UTC (permalink / raw)
  To: intel-gfx; +Cc: jani.nikula

Signed-off-by: Jani Nikula <jani.nikula@intel.com>
---
 tools/intel_bios_reader.c | 8 --------
 1 file changed, 8 deletions(-)

diff --git a/tools/intel_bios_reader.c b/tools/intel_bios_reader.c
index 991ee79545c2..709d386431fd 100644
--- a/tools/intel_bios_reader.c
+++ b/tools/intel_bios_reader.c
@@ -55,14 +55,6 @@ static uint32_t devid = -1;
 
 uint8_t *VBIOS;
 
-#define INTEL_BIOS_8(_addr)	(VBIOS[_addr])
-#define INTEL_BIOS_16(_addr)	(VBIOS[_addr] | \
-				 (VBIOS[_addr + 1] << 8))
-#define INTEL_BIOS_32(_addr)	(VBIOS[_addr] | \
-				 (VBIOS[_addr + 1] << 8) | \
-				 (VBIOS[_addr + 2] << 16) | \
-				 (VBIOS[_addr + 3] << 24))
-
 #define YESNO(val) ((val) ? "yes" : "no")
 
 /* This is not for mapping to memory layout. */
-- 
2.1.4

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [PATCH i-g-t 02/17] tools/intel_bios_reader: make VBIOS non-global
  2016-05-03 14:18 [PATCH i-g-t 00/17] tools/intel_bios_reader updates Jani Nikula
  2016-05-03 14:18 ` [PATCH i-g-t 01/17] tools/intel_bios_reader: drop unused macros Jani Nikula
@ 2016-05-03 14:18 ` Jani Nikula
  2016-05-03 14:18 ` [PATCH i-g-t 03/17] tools/intel_bios_reader: add command line option parsing and --file parameter Jani Nikula
                   ` (15 subsequent siblings)
  17 siblings, 0 replies; 22+ messages in thread
From: Jani Nikula @ 2016-05-03 14:18 UTC (permalink / raw)
  To: intel-gfx; +Cc: jani.nikula

No need for it to be global.

Signed-off-by: Jani Nikula <jani.nikula@intel.com>
---
 tools/intel_bios_reader.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/tools/intel_bios_reader.c b/tools/intel_bios_reader.c
index 709d386431fd..66f21df553f7 100644
--- a/tools/intel_bios_reader.c
+++ b/tools/intel_bios_reader.c
@@ -53,8 +53,6 @@ static uint32_t devid = -1;
 #define _V_BLANK(x) (x[6] + ((x[7] & 0x0F) << 8))
 #define _PIXEL_CLOCK(x) (x[0] + (x[1] << 8)) * 10000
 
-uint8_t *VBIOS;
-
 #define YESNO(val) ((val) ? "yes" : "no")
 
 /* This is not for mapping to memory layout. */
@@ -1374,6 +1372,7 @@ static void dump_section(const struct bdb_header *bdb, int section_id, int size)
 
 int main(int argc, char **argv)
 {
+	uint8_t *VBIOS;
 	int fd;
 	struct vbt_header *vbt = NULL;
 	int vbt_off, bdb_off, i;
-- 
2.1.4

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [PATCH i-g-t 03/17] tools/intel_bios_reader: add command line option parsing and --file parameter
  2016-05-03 14:18 [PATCH i-g-t 00/17] tools/intel_bios_reader updates Jani Nikula
  2016-05-03 14:18 ` [PATCH i-g-t 01/17] tools/intel_bios_reader: drop unused macros Jani Nikula
  2016-05-03 14:18 ` [PATCH i-g-t 02/17] tools/intel_bios_reader: make VBIOS non-global Jani Nikula
@ 2016-05-03 14:18 ` Jani Nikula
  2016-05-03 14:18 ` [PATCH i-g-t 04/17] tools/intel_bios_reader: add --devid parameter Jani Nikula
                   ` (14 subsequent siblings)
  17 siblings, 0 replies; 22+ messages in thread
From: Jani Nikula @ 2016-05-03 14:18 UTC (permalink / raw)
  To: intel-gfx; +Cc: jani.nikula

Keep positional parameter support for entering filename for backwards
compatibility.

Signed-off-by: Jani Nikula <jani.nikula@intel.com>
---
 tools/intel_bios_reader.c | 47 +++++++++++++++++++++++++++++++++++++++++------
 1 file changed, 41 insertions(+), 6 deletions(-)

diff --git a/tools/intel_bios_reader.c b/tools/intel_bios_reader.c
index 66f21df553f7..b424b17e4852 100644
--- a/tools/intel_bios_reader.c
+++ b/tools/intel_bios_reader.c
@@ -27,6 +27,7 @@
 
 #include <errno.h>
 #include <fcntl.h>
+#include <getopt.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
@@ -1370,13 +1371,22 @@ static void dump_section(const struct bdb_header *bdb, int section_id, int size)
 	printf("\n");
 }
 
+enum opt {
+	OPT_UNKNOWN = '?',
+	OPT_END = -1,
+	OPT_FILE,
+};
+
 int main(int argc, char **argv)
 {
 	uint8_t *VBIOS;
+	int index;
+	enum opt opt;
 	int fd;
 	struct vbt_header *vbt = NULL;
 	int vbt_off, bdb_off, i;
-	const char *filename = "bios";
+	const char *filename = NULL;
+	const char *toolname = argv[0];
 	struct stat finfo;
 	int size;
 	struct bdb_block *block;
@@ -1384,16 +1394,41 @@ int main(int argc, char **argv)
 	char signature[17];
 	char *devid_string;
 
-	if (argc != 2) {
-		printf("usage: %s <rom file>\n", argv[0]);
-		return 1;
+	static struct option options[] = {
+		{ "file",	required_argument,	NULL,	OPT_FILE },
+		{ 0 }
+	};
+
+	for (opt = 0; opt != OPT_END; ) {
+		opt = getopt_long(argc, argv, "", options, &index);
+
+		switch (opt) {
+		case OPT_FILE:
+			filename = optarg;
+			break;
+		case OPT_END:
+			break;
+		case OPT_UNKNOWN:
+			return EXIT_FAILURE;
+		}
+	}
+
+	argc -= optind;
+	argv += optind;
+
+	if (!filename) {
+		if (argc == 1) {
+			/* for backwards compatibility */
+			filename = argv[0];
+		} else {
+			printf("usage: %s --file=<rom file>\n", toolname);
+			return EXIT_FAILURE;
+		}
 	}
 
 	if ((devid_string = getenv("DEVICE")))
 	    devid = strtoul(devid_string, NULL, 0);
 
-	filename = argv[1];
-
 	fd = open(filename, O_RDONLY);
 	if (fd == -1) {
 		printf("Couldn't open \"%s\": %s\n", filename, strerror(errno));
-- 
2.1.4

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [PATCH i-g-t 04/17] tools/intel_bios_reader: add --devid parameter
  2016-05-03 14:18 [PATCH i-g-t 00/17] tools/intel_bios_reader updates Jani Nikula
                   ` (2 preceding siblings ...)
  2016-05-03 14:18 ` [PATCH i-g-t 03/17] tools/intel_bios_reader: add command line option parsing and --file parameter Jani Nikula
@ 2016-05-03 14:18 ` Jani Nikula
  2016-05-04 15:25   ` Marius Vlad
  2016-05-03 14:18 ` [PATCH i-g-t 05/17] tools/intel_bios_reader: drop unused lvds_support variable Jani Nikula
                   ` (13 subsequent siblings)
  17 siblings, 1 reply; 22+ messages in thread
From: Jani Nikula @ 2016-05-03 14:18 UTC (permalink / raw)
  To: intel-gfx; +Cc: jani.nikula

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 <jani.nikula@intel.com>
---
 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: <unknown platform>\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);
-- 
2.1.4

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [PATCH i-g-t 05/17] tools/intel_bios_reader: drop unused lvds_support variable
  2016-05-03 14:18 [PATCH i-g-t 00/17] tools/intel_bios_reader updates Jani Nikula
                   ` (3 preceding siblings ...)
  2016-05-03 14:18 ` [PATCH i-g-t 04/17] tools/intel_bios_reader: add --devid parameter Jani Nikula
@ 2016-05-03 14:18 ` Jani Nikula
  2016-05-03 14:18 ` [PATCH i-g-t 06/17] tools/intel_bios_reader: drop silly tv_present variable and printout Jani Nikula
                   ` (12 subsequent siblings)
  17 siblings, 0 replies; 22+ messages in thread
From: Jani Nikula @ 2016-05-03 14:18 UTC (permalink / raw)
  To: intel-gfx; +Cc: jani.nikula

Signed-off-by: Jani Nikula <jani.nikula@intel.com>
---
 tools/intel_bios_reader.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/tools/intel_bios_reader.c b/tools/intel_bios_reader.c
index d74e766250df..ec6976b2bb4d 100644
--- a/tools/intel_bios_reader.c
+++ b/tools/intel_bios_reader.c
@@ -65,7 +65,6 @@ struct bdb_block {
 
 const struct bdb_lvds_lfp_data_ptrs *lvds_lfp_data_ptrs;
 static int tv_present;
-static int lvds_present;
 static int panel_type;
 
 /* Get BDB block size given a pointer to Block ID. */
@@ -174,7 +173,6 @@ static void dump_general_features(const struct bdb_header *bdb,
 	printf("\tIntegrated TV: %s\n", YESNO(features->int_tv_support));
 
 	tv_present = 1;		/* should be based on whether TV DAC exists */
-	lvds_present = 1;	/* should be based on IS_MOBILE() */
 }
 
 static void dump_backlight_info(const struct bdb_header *bdb,
-- 
2.1.4

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [PATCH i-g-t 06/17] tools/intel_bios_reader: drop silly tv_present variable and printout
  2016-05-03 14:18 [PATCH i-g-t 00/17] tools/intel_bios_reader updates Jani Nikula
                   ` (4 preceding siblings ...)
  2016-05-03 14:18 ` [PATCH i-g-t 05/17] tools/intel_bios_reader: drop unused lvds_support variable Jani Nikula
@ 2016-05-03 14:18 ` Jani Nikula
  2016-05-03 14:18 ` [PATCH i-g-t 07/17] tools/intel_bios_reader: pass around a context pointer instead of bdb_header Jani Nikula
                   ` (11 subsequent siblings)
  17 siblings, 0 replies; 22+ messages in thread
From: Jani Nikula @ 2016-05-03 14:18 UTC (permalink / raw)
  To: intel-gfx; +Cc: jani.nikula

There's no point in dumping a fixed value.

Signed-off-by: Jani Nikula <jani.nikula@intel.com>
---
 tools/intel_bios_reader.c | 4 ----
 1 file changed, 4 deletions(-)

diff --git a/tools/intel_bios_reader.c b/tools/intel_bios_reader.c
index ec6976b2bb4d..391e98d79ccf 100644
--- a/tools/intel_bios_reader.c
+++ b/tools/intel_bios_reader.c
@@ -64,7 +64,6 @@ struct bdb_block {
 };
 
 const struct bdb_lvds_lfp_data_ptrs *lvds_lfp_data_ptrs;
-static int tv_present;
 static int panel_type;
 
 /* Get BDB block size given a pointer to Block ID. */
@@ -171,8 +170,6 @@ static void dump_general_features(const struct bdb_header *bdb,
 	       YESNO(features->legacy_monitor_detect));
 	printf("\tIntegrated CRT: %s\n", YESNO(features->int_crt_support));
 	printf("\tIntegrated TV: %s\n", YESNO(features->int_tv_support));
-
-	tv_present = 1;		/* should be based on whether TV DAC exists */
 }
 
 static void dump_backlight_info(const struct bdb_header *bdb,
@@ -412,7 +409,6 @@ static void dump_general_definitions(const struct bdb_header *bdb,
 	printf("\tUse DPMS on AIM devices: %s\n", YESNO(defs->dpms_aim));
 	printf("\tBoot display type: 0x%02x%02x\n", defs->boot_display[1],
 	       defs->boot_display[0]);
-	printf("\tTV data block present: %s\n", YESNO(tv_present));
 	printf("\tChild device size: %d\n", defs->child_dev_size);
 	child_device_num = (block->size - sizeof(*defs)) /
 		defs->child_dev_size;
-- 
2.1.4

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [PATCH i-g-t 07/17] tools/intel_bios_reader: pass around a context pointer instead of bdb_header
  2016-05-03 14:18 [PATCH i-g-t 00/17] tools/intel_bios_reader updates Jani Nikula
                   ` (5 preceding siblings ...)
  2016-05-03 14:18 ` [PATCH i-g-t 06/17] tools/intel_bios_reader: drop silly tv_present variable and printout Jani Nikula
@ 2016-05-03 14:18 ` Jani Nikula
  2016-05-03 14:18 ` [PATCH i-g-t 08/17] tools/intel_bios_reader: move more globals to struct context Jani Nikula
                   ` (10 subsequent siblings)
  17 siblings, 0 replies; 22+ messages in thread
From: Jani Nikula @ 2016-05-03 14:18 UTC (permalink / raw)
  To: intel-gfx; +Cc: jani.nikula

Allow putting stuff in there instead of a global. A bit like passing
dev_priv in the kernel.

Signed-off-by: Jani Nikula <jani.nikula@intel.com>
---
 tools/intel_bios_reader.c | 85 ++++++++++++++++++++++++++---------------------
 1 file changed, 47 insertions(+), 38 deletions(-)

diff --git a/tools/intel_bios_reader.c b/tools/intel_bios_reader.c
index 391e98d79ccf..aacf56ad5937 100644
--- a/tools/intel_bios_reader.c
+++ b/tools/intel_bios_reader.c
@@ -63,6 +63,11 @@ struct bdb_block {
 	const void *data;
 };
 
+struct context {
+	const struct bdb_header *bdb;
+	int size;
+};
+
 const struct bdb_lvds_lfp_data_ptrs *lvds_lfp_data_ptrs;
 static int panel_type;
 
@@ -76,9 +81,10 @@ static uint32_t _get_blocksize(const uint8_t *block_base)
 		return *((const uint16_t *)(block_base + 1));
 }
 
-static struct bdb_block *find_section(const struct bdb_header *bdb,
-				      int section_id, int length)
+static struct bdb_block *find_section(struct context *context, int section_id)
 {
+	const struct bdb_header *bdb = context->bdb;
+	int length = context->size;
 	struct bdb_block *block;
 	const uint8_t *base = (const uint8_t *)bdb;
 	int index = 0;
@@ -120,7 +126,7 @@ static struct bdb_block *find_section(const struct bdb_header *bdb,
 	return NULL;
 }
 
-static void dump_general_features(const struct bdb_header *bdb,
+static void dump_general_features(struct context *context,
 				  const struct bdb_block *block)
 {
 	const struct bdb_general_features *features = block->data;
@@ -172,7 +178,7 @@ static void dump_general_features(const struct bdb_header *bdb,
 	printf("\tIntegrated TV: %s\n", YESNO(features->int_tv_support));
 }
 
-static void dump_backlight_info(const struct bdb_header *bdb,
+static void dump_backlight_info(struct context *context,
 				const struct bdb_block *block)
 {
 	const struct bdb_lvds_backlight *backlight = block->data;
@@ -355,7 +361,7 @@ static const char *efp_conn(uint8_t type)
 
 
 
-static void dump_child_device(const struct bdb_header *bdb,
+static void dump_child_device(struct context *context,
 			      struct child_device_config *child)
 {
 	char child_id[11];
@@ -363,7 +369,7 @@ static void dump_child_device(const struct bdb_header *bdb,
 	if (!child->device_type)
 		return;
 
-	if (bdb->version < 152) {
+	if (context->bdb->version < 152) {
 		strncpy(child_id, (char *)child->device_id, 10);
 		child_id[10] = 0;
 
@@ -394,7 +400,7 @@ static void dump_child_device(const struct bdb_header *bdb,
 	}
 }
 
-static void dump_general_definitions(const struct bdb_header *bdb,
+static void dump_general_definitions(struct context *context,
 				     const struct bdb_block *block)
 {
 	const struct bdb_general_definitions *defs = block->data;
@@ -413,10 +419,10 @@ static void dump_general_definitions(const struct bdb_header *bdb,
 	child_device_num = (block->size - sizeof(*defs)) /
 		defs->child_dev_size;
 	for (i = 0; i < child_device_num; i++)
-		dump_child_device(bdb,(void*)&defs->devices[i * defs->child_dev_size]);
+		dump_child_device(context, (void*)&defs->devices[i * defs->child_dev_size]);
 }
 
-static void dump_child_devices(const struct bdb_header *bdb,
+static void dump_child_devices(struct context *context,
 			       const struct bdb_block *block)
 {
 	const struct bdb_child_devices *child_devs = block->data;
@@ -440,7 +446,7 @@ static void dump_child_devices(const struct bdb_header *bdb,
 	}
 }
 
-static void dump_lvds_options(const struct bdb_header *bdb,
+static void dump_lvds_options(struct context *context,
 			      const struct bdb_block *block)
 {
 	const struct bdb_lvds_options *options = block->data;
@@ -457,7 +463,7 @@ static void dump_lvds_options(const struct bdb_header *bdb,
 	printf("\tPFIT mode: %d\n", options->pfit_mode);
 }
 
-static void dump_lvds_ptr_data(const struct bdb_header *bdb,
+static void dump_lvds_ptr_data(struct context *context,
 			       const struct bdb_block *block)
 {
 	const struct bdb_lvds_lfp_data_ptrs *ptrs = block->data;
@@ -468,7 +474,7 @@ static void dump_lvds_ptr_data(const struct bdb_header *bdb,
 	lvds_lfp_data_ptrs = ptrs;
 }
 
-static void dump_lvds_data(const struct bdb_header *bdb,
+static void dump_lvds_data(struct context *context,
 			   const struct bdb_block *block)
 {
 	const struct bdb_lvds_lfp_data *lvds_data = block->data;
@@ -541,7 +547,7 @@ static void dump_lvds_data(const struct bdb_header *bdb,
 	}
 }
 
-static void dump_driver_feature(const struct bdb_header *bdb,
+static void dump_driver_feature(struct context *context,
 				const struct bdb_block *block)
 {
 	const struct bdb_driver_feature *feature = block->data;
@@ -608,7 +614,7 @@ static void dump_driver_feature(const struct bdb_header *bdb,
 	       feature->legacy_crt_max_refresh);
 }
 
-static void dump_edp(const struct bdb_header *bdb,
+static void dump_edp(struct context *context,
 		     const struct bdb_block *block)
 {
 	const struct bdb_edp *edp = block->data;
@@ -738,7 +744,7 @@ print_detail_timing_data(const struct lvds_dvo_timing2 *dvo_timing)
 	printf("\tclock: %d\n", dvo_timing->clock * 10);
 }
 
-static void dump_sdvo_panel_dtds(const struct bdb_header *bdb,
+static void dump_sdvo_panel_dtds(struct context *context,
 				 const struct bdb_block *block)
 {
 	const struct lvds_dvo_timing2 *dvo_timing = block->data;
@@ -751,7 +757,7 @@ static void dump_sdvo_panel_dtds(const struct bdb_header *bdb,
 	}
 }
 
-static void dump_sdvo_lvds_options(const struct bdb_header *bdb,
+static void dump_sdvo_lvds_options(struct context *context,
 				   const struct bdb_block *block)
 {
 	const struct bdb_sdvo_lvds_options *options = block->data;
@@ -773,7 +779,7 @@ static void dump_sdvo_lvds_options(const struct bdb_header *bdb,
 	printf("\tmisc[3]: %x\n", options->panel_misc_bits_4);
 }
 
-static void dump_mipi_config(const struct bdb_header *bdb,
+static void dump_mipi_config(struct context *context,
 			     const struct bdb_block *block)
 {
 	const struct bdb_mipi_config *start = block->data;
@@ -1160,7 +1166,7 @@ static int goto_next_sequence_v3(const uint8_t *data, int index, int total)
 	return 0;
 }
 
-static void dump_mipi_sequence(const struct bdb_header *bdb,
+static void dump_mipi_sequence(struct context *context,
 			       const struct bdb_block *block)
 {
 	const struct bdb_mipi_sequence *sequence = block->data;
@@ -1241,7 +1247,7 @@ get_device_id(unsigned char *bios, int size)
 struct dumper {
 	uint8_t id;
 	const char *name;
-	void (*dump)(const struct bdb_header *bdb,
+	void (*dump)(struct context *context,
 		     const struct bdb_block *block);
 };
 
@@ -1334,7 +1340,7 @@ static void hex_dump(const struct bdb_block *block)
 	printf("\n\n");
 }
 
-static void dump_section(const struct bdb_header *bdb, int section_id, int size)
+static void dump_section(struct context *context, int section_id)
 {
 	struct dumper *dumper = NULL;
 	const struct bdb_block *block;
@@ -1345,7 +1351,7 @@ static void dump_section(const struct bdb_header *bdb, int section_id, int size)
 		return;
 	done[section_id] = 1;
 
-	block = find_section(bdb, section_id, size);
+	block = find_section(context, section_id);
 	if (!block)
 		return;
 
@@ -1363,7 +1369,7 @@ static void dump_section(const struct bdb_header *bdb, int section_id, int size)
 
 	hex_dump(block);
 	if (dumper && dumper->dump)
-		dumper->dump(bdb, block);
+		dumper->dump(context, block);
 	printf("\n");
 }
 
@@ -1388,6 +1394,7 @@ int main(int argc, char **argv)
 	int size;
 	struct bdb_block *block;
 	struct bdb_header *bdb;
+	struct context context = {};
 	char signature[17];
 	char *endp;
 
@@ -1497,10 +1504,12 @@ int main(int argc, char **argv)
 	printf("BDB sig: %s\n", signature);
 	printf("BDB vers: %d\n", bdb->version);
 
-	printf("Available sections: ");
+	context.bdb = bdb;
+	context.size = size;
 
+	printf("Available sections: ");
 	for (i = 0; i < 256; i++) {
-		block = find_section(bdb, i, size);
+		block = find_section(&context, i);
 		if (!block)
 			continue;
 		printf("%d ", i);
@@ -1518,24 +1527,24 @@ int main(int argc, char **argv)
 	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);
-	dump_section(bdb, BDB_CHILD_DEVICE_TABLE, size);
-	dump_section(bdb, BDB_LVDS_OPTIONS, size);
-	dump_section(bdb, BDB_LVDS_LFP_DATA_PTRS, size);
-	dump_section(bdb, BDB_LVDS_LFP_DATA, size);
-	dump_section(bdb, BDB_LVDS_BACKLIGHT, size);
+	dump_section(&context, BDB_GENERAL_FEATURES);
+	dump_section(&context, BDB_GENERAL_DEFINITIONS);
+	dump_section(&context, BDB_CHILD_DEVICE_TABLE);
+	dump_section(&context, BDB_LVDS_OPTIONS);
+	dump_section(&context, BDB_LVDS_LFP_DATA_PTRS);
+	dump_section(&context, BDB_LVDS_LFP_DATA);
+	dump_section(&context, BDB_LVDS_BACKLIGHT);
 
-	dump_section(bdb, BDB_SDVO_LVDS_OPTIONS, size);
-	dump_section(bdb, BDB_SDVO_PANEL_DTDS, size);
+	dump_section(&context, BDB_SDVO_LVDS_OPTIONS);
+	dump_section(&context, BDB_SDVO_PANEL_DTDS);
 
-	dump_section(bdb, BDB_DRIVER_FEATURES, size);
-	dump_section(bdb, BDB_EDP, size);
-	dump_section(bdb, BDB_MIPI_CONFIG, size);
-	dump_section(bdb, BDB_MIPI_SEQUENCE, size);
+	dump_section(&context, BDB_DRIVER_FEATURES);
+	dump_section(&context, BDB_EDP);
+	dump_section(&context, BDB_MIPI_CONFIG);
+	dump_section(&context, BDB_MIPI_SEQUENCE);
 
 	for (i = 0; i < 256; i++)
-		dump_section(bdb, i, size);
+		dump_section(&context, i);
 
 	return 0;
 }
-- 
2.1.4

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [PATCH i-g-t 08/17] tools/intel_bios_reader: move more globals to struct context
  2016-05-03 14:18 [PATCH i-g-t 00/17] tools/intel_bios_reader updates Jani Nikula
                   ` (6 preceding siblings ...)
  2016-05-03 14:18 ` [PATCH i-g-t 07/17] tools/intel_bios_reader: pass around a context pointer instead of bdb_header Jani Nikula
@ 2016-05-03 14:18 ` Jani Nikula
  2016-05-03 14:18 ` [PATCH i-g-t 09/17] tools/intel_bios_reader: move devid to context too Jani Nikula
                   ` (9 subsequent siblings)
  17 siblings, 0 replies; 22+ messages in thread
From: Jani Nikula @ 2016-05-03 14:18 UTC (permalink / raw)
  To: intel-gfx; +Cc: jani.nikula

It's just good hygiene.

Signed-off-by: Jani Nikula <jani.nikula@intel.com>
---
 tools/intel_bios_reader.c | 26 +++++++++++++-------------
 1 file changed, 13 insertions(+), 13 deletions(-)

diff --git a/tools/intel_bios_reader.c b/tools/intel_bios_reader.c
index aacf56ad5937..9b4b90d32df5 100644
--- a/tools/intel_bios_reader.c
+++ b/tools/intel_bios_reader.c
@@ -66,10 +66,10 @@ struct bdb_block {
 struct context {
 	const struct bdb_header *bdb;
 	int size;
-};
 
-const struct bdb_lvds_lfp_data_ptrs *lvds_lfp_data_ptrs;
-static int panel_type;
+	const struct bdb_lvds_lfp_data_ptrs *lvds_lfp_data_ptrs;
+	int panel_type;
+};
 
 /* Get BDB block size given a pointer to Block ID. */
 static uint32_t _get_blocksize(const uint8_t *block_base)
@@ -190,7 +190,7 @@ static void dump_backlight_info(struct context *context,
 		return;
 	}
 
-	blc = &backlight->panels[panel_type];
+	blc = &backlight->panels[context->panel_type];
 
 	printf("\tInverter type: %d\n", blc->inverter_type);
 	printf("\t     polarity: %d\n", blc->inverter_polarity);
@@ -451,8 +451,8 @@ static void dump_lvds_options(struct context *context,
 {
 	const struct bdb_lvds_options *options = block->data;
 
-	panel_type = options->panel_type;
-	printf("\tPanel type: %d\n", panel_type);
+	context->panel_type = options->panel_type;
+	printf("\tPanel type: %d\n", context->panel_type);
 	printf("\tLVDS EDID available: %s\n", YESNO(options->lvds_edid));
 	printf("\tPixel dither: %s\n", YESNO(options->pixel_dither));
 	printf("\tPFIT auto ratio: %s\n", YESNO(options->pfit_ratio_auto));
@@ -471,14 +471,14 @@ static void dump_lvds_ptr_data(struct context *context,
 	printf("\tNumber of entries: %d\n", ptrs->lvds_entries);
 
 	/* save for use by dump_lvds_data() */
-	lvds_lfp_data_ptrs = ptrs;
+	context->lvds_lfp_data_ptrs = ptrs;
 }
 
 static void dump_lvds_data(struct context *context,
 			   const struct bdb_block *block)
 {
 	const struct bdb_lvds_lfp_data *lvds_data = block->data;
-	const struct bdb_lvds_lfp_data_ptrs *ptrs = lvds_lfp_data_ptrs;
+	const struct bdb_lvds_lfp_data_ptrs *ptrs = context->lvds_lfp_data_ptrs;
 	int num_entries;
 	int i;
 	int hdisplay, hsyncstart, hsyncend, htotal;
@@ -509,7 +509,7 @@ static void dump_lvds_data(struct context *context,
 		    (const struct bdb_lvds_lfp_data_entry *)lfp_data_ptr;
 		char marker;
 
-		if (i == panel_type)
+		if (i == context->panel_type)
 			marker = '*';
 		else
 			marker = ' ';
@@ -622,7 +622,7 @@ static void dump_edp(struct context *context,
 	int i;
 
 	for (i = 0; i < 16; i++) {
-		printf("\tPanel %d%s\n", i, panel_type == i ? " *" : "");
+		printf("\tPanel %d%s\n", i, context->panel_type == i ? " *" : "");
 
 		printf("\t\tPower Sequence: T3 %d T7 %d T9 %d T10 %d T12 %d\n",
 		       edp->power_seqs[i].t3,
@@ -786,8 +786,8 @@ static void dump_mipi_config(struct context *context,
 	const struct mipi_config *config;
 	const struct mipi_pps_data *pps;
 
-	config = &start->config[panel_type];
-	pps = &start->pps[panel_type];
+	config = &start->config[context->panel_type];
+	pps = &start->pps[context->panel_type];
 
 	printf("\tGeneral Param\n");
 	printf("\t\t BTA disable: %s\n", config->bta ? "Disabled" : "Enabled");
@@ -1190,7 +1190,7 @@ static void dump_mipi_sequence(struct context *context,
 		return;
 	}
 
-	data = find_panel_sequence_block(sequence, panel_type,
+	data = find_panel_sequence_block(sequence, context->panel_type,
 					 block->size, &seq_size);
 	if (!data)
 		return;
-- 
2.1.4

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [PATCH i-g-t 09/17] tools/intel_bios_reader: move devid to context too
  2016-05-03 14:18 [PATCH i-g-t 00/17] tools/intel_bios_reader updates Jani Nikula
                   ` (7 preceding siblings ...)
  2016-05-03 14:18 ` [PATCH i-g-t 08/17] tools/intel_bios_reader: move more globals to struct context Jani Nikula
@ 2016-05-03 14:18 ` Jani Nikula
  2016-05-03 14:19 ` [PATCH i-g-t 10/17] tools/intel_bios_reader: drop dependencies on lvds block parsing Jani Nikula
                   ` (8 subsequent siblings)
  17 siblings, 0 replies; 22+ messages in thread
From: Jani Nikula @ 2016-05-03 14:18 UTC (permalink / raw)
  To: intel-gfx; +Cc: jani.nikula

Signed-off-by: Jani Nikula <jani.nikula@intel.com>
---
 tools/intel_bios_reader.c | 26 +++++++++++++-------------
 1 file changed, 13 insertions(+), 13 deletions(-)

diff --git a/tools/intel_bios_reader.c b/tools/intel_bios_reader.c
index 9b4b90d32df5..388e98e180c4 100644
--- a/tools/intel_bios_reader.c
+++ b/tools/intel_bios_reader.c
@@ -41,8 +41,6 @@
 #include "intel_chipset.h"
 #include "drmtest.h"
 
-static uint32_t devid;
-
 /* no bother to include "edid.h" */
 #define _H_ACTIVE(x) (x[2] + ((x[4] & 0xF0) << 4))
 #define _H_SYNC_OFF(x) (x[8] + ((x[11] & 0xC0) << 2))
@@ -67,6 +65,7 @@ struct context {
 	const struct bdb_header *bdb;
 	int size;
 
+	uint32_t devid;
 	const struct bdb_lvds_lfp_data_ptrs *lvds_lfp_data_ptrs;
 	int panel_type;
 };
@@ -153,12 +152,13 @@ static void dump_general_features(struct context *context,
 	printf("\tExternal VBT: %s\n", YESNO(features->download_ext_vbt));
 	printf("\tEnable SSC: %s\n", YESNO(features->enable_ssc));
 	if (features->enable_ssc) {
-		if (!devid)
+		if (!context->devid)
 			printf("\tSSC frequency: <unknown platform>\n");
-		else if (IS_VALLEYVIEW(devid) || IS_CHERRYVIEW(devid) ||
-			 IS_BROXTON(devid))
+		else if (IS_VALLEYVIEW(context->devid) ||
+			 IS_CHERRYVIEW(context->devid) ||
+			 IS_BROXTON(context->devid))
 			printf("\tSSC frequency: 100 MHz\n");
-		else if (HAS_PCH_SPLIT(devid))
+		else if (HAS_PCH_SPLIT(context->devid))
 			printf("\tSSC frequency: %s\n", features->ssc_freq ?
 			       "100 MHz" : "120 MHz");
 		else
@@ -1412,8 +1412,8 @@ int main(int argc, char **argv)
 			filename = optarg;
 			break;
 		case OPT_DEVID:
-			devid = strtoul(optarg, &endp, 16);
-			if (!devid || *endp) {
+			context.devid = strtoul(optarg, &endp, 16);
+			if (!context.devid || *endp) {
 				fprintf(stderr, "invalid devid '%s'\n", optarg);
 				return EXIT_FAILURE;
 			}
@@ -1517,14 +1517,14 @@ int main(int argc, char **argv)
 	}
 	printf("\n");
 
-	if (!devid) {
+	if (!context.devid) {
 		const char *devid_string = getenv("DEVICE");
 		if (devid_string)
-			devid = strtoul(devid_string, NULL, 0);
+			context.devid = strtoul(devid_string, NULL, 0);
 	}
-	if (!devid)
-		devid = get_device_id(VBIOS, size);
-	if (!devid)
+	if (!context.devid)
+		context.devid = get_device_id(VBIOS, size);
+	if (!context.devid)
 		fprintf(stderr, "Warning: could not find PCI device ID!\n");
 
 	dump_section(&context, BDB_GENERAL_FEATURES);
-- 
2.1.4

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [PATCH i-g-t 10/17] tools/intel_bios_reader: drop dependencies on lvds block parsing
  2016-05-03 14:18 [PATCH i-g-t 00/17] tools/intel_bios_reader updates Jani Nikula
                   ` (8 preceding siblings ...)
  2016-05-03 14:18 ` [PATCH i-g-t 09/17] tools/intel_bios_reader: move devid to context too Jani Nikula
@ 2016-05-03 14:19 ` Jani Nikula
  2016-05-03 14:19 ` [PATCH i-g-t 11/17] tools/intel_bios_reader: let the user specify panel type on the command line Jani Nikula
                   ` (7 subsequent siblings)
  17 siblings, 0 replies; 22+ messages in thread
From: Jani Nikula @ 2016-05-03 14:19 UTC (permalink / raw)
  To: intel-gfx; +Cc: jani.nikula

Don't mandate a specific ordering on the parsing of the blocks.

Signed-off-by: Jani Nikula <jani.nikula@intel.com>
---
 tools/intel_bios_reader.c | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/tools/intel_bios_reader.c b/tools/intel_bios_reader.c
index 388e98e180c4..68248187ec89 100644
--- a/tools/intel_bios_reader.c
+++ b/tools/intel_bios_reader.c
@@ -66,7 +66,6 @@ struct context {
 	int size;
 
 	uint32_t devid;
-	const struct bdb_lvds_lfp_data_ptrs *lvds_lfp_data_ptrs;
 	int panel_type;
 };
 
@@ -469,16 +468,14 @@ static void dump_lvds_ptr_data(struct context *context,
 	const struct bdb_lvds_lfp_data_ptrs *ptrs = block->data;
 
 	printf("\tNumber of entries: %d\n", ptrs->lvds_entries);
-
-	/* save for use by dump_lvds_data() */
-	context->lvds_lfp_data_ptrs = ptrs;
 }
 
 static void dump_lvds_data(struct context *context,
 			   const struct bdb_block *block)
 {
 	const struct bdb_lvds_lfp_data *lvds_data = block->data;
-	const struct bdb_lvds_lfp_data_ptrs *ptrs = context->lvds_lfp_data_ptrs;
+	struct bdb_block *ptrs_block;
+	const struct bdb_lvds_lfp_data_ptrs *ptrs;
 	int num_entries;
 	int i;
 	int hdisplay, hsyncstart, hsyncend, htotal;
@@ -486,11 +483,14 @@ static void dump_lvds_data(struct context *context,
 	float clock;
 	int lfp_data_size, dvo_offset;
 
-	if (!ptrs) {
+	ptrs_block = find_section(context, BDB_LVDS_LFP_DATA_PTRS);
+	if (!ptrs_block) {
 		printf("No LVDS ptr block\n");
 		return;
 	}
 
+	ptrs = ptrs_block->data;
+
 	lfp_data_size =
 	    ptrs->ptr[1].fp_timing_offset - ptrs->ptr[0].fp_timing_offset;
 	dvo_offset =
@@ -545,6 +545,8 @@ static void dump_lvds_data(struct context *context,
 		       (hsyncend > htotal || vsyncend > vtotal) ?
 		       "BAD!" : "good");
 	}
+
+	free(ptrs_block);
 }
 
 static void dump_driver_feature(struct context *context,
-- 
2.1.4

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [PATCH i-g-t 11/17] tools/intel_bios_reader: let the user specify panel type on the command line
  2016-05-03 14:18 [PATCH i-g-t 00/17] tools/intel_bios_reader updates Jani Nikula
                   ` (9 preceding siblings ...)
  2016-05-03 14:19 ` [PATCH i-g-t 10/17] tools/intel_bios_reader: drop dependencies on lvds block parsing Jani Nikula
@ 2016-05-03 14:19 ` Jani Nikula
  2016-05-03 14:19 ` [PATCH i-g-t 12/17] tools/intel_bios_reader: dump the blocks in numerical order Jani Nikula
                   ` (6 subsequent siblings)
  17 siblings, 0 replies; 22+ messages in thread
From: Jani Nikula @ 2016-05-03 14:19 UTC (permalink / raw)
  To: intel-gfx; +Cc: jani.nikula

On some systems the VBT panel type may be overridden in the opregion,
and we can't necessarily get at that. Let the user specify it on the
command line.

As a byproduct, the section parsing order no longer matters.

Signed-off-by: Jani Nikula <jani.nikula@intel.com>
---
 tools/intel_bios_reader.c | 50 +++++++++++++++++++++++++++++++++++++++++++----
 1 file changed, 46 insertions(+), 4 deletions(-)

diff --git a/tools/intel_bios_reader.c b/tools/intel_bios_reader.c
index 68248187ec89..fcef4ff43618 100644
--- a/tools/intel_bios_reader.c
+++ b/tools/intel_bios_reader.c
@@ -450,8 +450,11 @@ static void dump_lvds_options(struct context *context,
 {
 	const struct bdb_lvds_options *options = block->data;
 
-	context->panel_type = options->panel_type;
-	printf("\tPanel type: %d\n", context->panel_type);
+	if (context->panel_type == options->panel_type)
+		printf("\tPanel type: %d\n", options->panel_type);
+	else
+		printf("\tPanel type: %d (override %d)\n",
+		       options->panel_type, context->panel_type);
 	printf("\tLVDS EDID available: %s\n", YESNO(options->lvds_edid));
 	printf("\tPixel dither: %s\n", YESNO(options->pixel_dither));
 	printf("\tPFIT auto ratio: %s\n", YESNO(options->pfit_ratio_auto));
@@ -1226,6 +1229,25 @@ static void dump_mipi_sequence(struct context *context,
 			dump_sequence(sequence_ptrs[i], sequence->version);
 }
 
+/* get panel type from lvds options block, or -1 if block not found */
+static int get_panel_type(struct context *context)
+{
+	struct bdb_block *block;
+	const struct bdb_lvds_options *options;
+	int panel_type;
+
+	block = find_section(context, BDB_LVDS_OPTIONS);
+	if (!block)
+		return -1;
+
+	options = block->data;
+	panel_type = options->panel_type;
+
+	free(block);
+
+	return panel_type;
+}
+
 static int
 get_device_id(unsigned char *bios, int size)
 {
@@ -1380,6 +1402,7 @@ enum opt {
 	OPT_END = -1,
 	OPT_FILE,
 	OPT_DEVID,
+	OPT_PANEL_TYPE,
 };
 
 int main(int argc, char **argv)
@@ -1394,15 +1417,17 @@ int main(int argc, char **argv)
 	const char *toolname = argv[0];
 	struct stat finfo;
 	int size;
-	struct bdb_block *block;
 	struct bdb_header *bdb;
-	struct context context = {};
+	struct context context = {
+		.panel_type = -1,
+	};
 	char signature[17];
 	char *endp;
 
 	static struct option options[] = {
 		{ "file",	required_argument,	NULL,	OPT_FILE },
 		{ "devid",	required_argument,	NULL,	OPT_DEVID },
+		{ "panel-type",	required_argument,	NULL,	OPT_PANEL_TYPE },
 		{ 0 }
 	};
 
@@ -1420,6 +1445,14 @@ int main(int argc, char **argv)
 				return EXIT_FAILURE;
 			}
 			break;
+		case OPT_PANEL_TYPE:
+			context.panel_type = strtoul(optarg, &endp, 0);
+			if (*endp || context.panel_type > 15) {
+				fprintf(stderr, "invalid panel type '%s'\n",
+					optarg);
+				return EXIT_FAILURE;
+			}
+			break;
 		case OPT_END:
 			break;
 		case OPT_UNKNOWN:
@@ -1511,6 +1544,8 @@ int main(int argc, char **argv)
 
 	printf("Available sections: ");
 	for (i = 0; i < 256; i++) {
+		struct bdb_block *block;
+
 		block = find_section(&context, i);
 		if (!block)
 			continue;
@@ -1529,6 +1564,13 @@ int main(int argc, char **argv)
 	if (!context.devid)
 		fprintf(stderr, "Warning: could not find PCI device ID!\n");
 
+	if (context.panel_type == -1)
+		context.panel_type = get_panel_type(&context);
+	if (context.panel_type == -1) {
+		fprintf(stderr, "Warning: panel type not set, using 0\n");
+		context.panel_type = 0;
+	}
+
 	dump_section(&context, BDB_GENERAL_FEATURES);
 	dump_section(&context, BDB_GENERAL_DEFINITIONS);
 	dump_section(&context, BDB_CHILD_DEVICE_TABLE);
-- 
2.1.4

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [PATCH i-g-t 12/17] tools/intel_bios_reader: dump the blocks in numerical order
  2016-05-03 14:18 [PATCH i-g-t 00/17] tools/intel_bios_reader updates Jani Nikula
                   ` (10 preceding siblings ...)
  2016-05-03 14:19 ` [PATCH i-g-t 11/17] tools/intel_bios_reader: let the user specify panel type on the command line Jani Nikula
@ 2016-05-03 14:19 ` Jani Nikula
  2016-05-03 14:19 ` [PATCH i-g-t 13/17] tools/intel_bios_reader: add --hexdump option to dump hex, disable by default Jani Nikula
                   ` (5 subsequent siblings)
  17 siblings, 0 replies; 22+ messages in thread
From: Jani Nikula @ 2016-05-03 14:19 UTC (permalink / raw)
  To: intel-gfx; +Cc: jani.nikula

All parsers fetch the information they need without ordering
constraints, so dump all in numerical order. This also makes it
unnecessary to track already dumped blocks.

Signed-off-by: Jani Nikula <jani.nikula@intel.com>
---
 tools/intel_bios_reader.c | 21 ---------------------
 1 file changed, 21 deletions(-)

diff --git a/tools/intel_bios_reader.c b/tools/intel_bios_reader.c
index fcef4ff43618..94b0d6055eb1 100644
--- a/tools/intel_bios_reader.c
+++ b/tools/intel_bios_reader.c
@@ -1368,13 +1368,8 @@ static void dump_section(struct context *context, int section_id)
 {
 	struct dumper *dumper = NULL;
 	const struct bdb_block *block;
-	static int done[256];
 	int i;
 
-	if (done[section_id])
-		return;
-	done[section_id] = 1;
-
 	block = find_section(context, section_id);
 	if (!block)
 		return;
@@ -1571,22 +1566,6 @@ int main(int argc, char **argv)
 		context.panel_type = 0;
 	}
 
-	dump_section(&context, BDB_GENERAL_FEATURES);
-	dump_section(&context, BDB_GENERAL_DEFINITIONS);
-	dump_section(&context, BDB_CHILD_DEVICE_TABLE);
-	dump_section(&context, BDB_LVDS_OPTIONS);
-	dump_section(&context, BDB_LVDS_LFP_DATA_PTRS);
-	dump_section(&context, BDB_LVDS_LFP_DATA);
-	dump_section(&context, BDB_LVDS_BACKLIGHT);
-
-	dump_section(&context, BDB_SDVO_LVDS_OPTIONS);
-	dump_section(&context, BDB_SDVO_PANEL_DTDS);
-
-	dump_section(&context, BDB_DRIVER_FEATURES);
-	dump_section(&context, BDB_EDP);
-	dump_section(&context, BDB_MIPI_CONFIG);
-	dump_section(&context, BDB_MIPI_SEQUENCE);
-
 	for (i = 0; i < 256; i++)
 		dump_section(&context, i);
 
-- 
2.1.4

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [PATCH i-g-t 13/17] tools/intel_bios_reader: add --hexdump option to dump hex, disable by default
  2016-05-03 14:18 [PATCH i-g-t 00/17] tools/intel_bios_reader updates Jani Nikula
                   ` (11 preceding siblings ...)
  2016-05-03 14:19 ` [PATCH i-g-t 12/17] tools/intel_bios_reader: dump the blocks in numerical order Jani Nikula
@ 2016-05-03 14:19 ` Jani Nikula
  2016-05-03 14:19 ` [PATCH i-g-t 14/17] tools/intel_bios_reader: add support for dumping only specific section Jani Nikula
                   ` (4 subsequent siblings)
  17 siblings, 0 replies; 22+ messages in thread
From: Jani Nikula @ 2016-05-03 14:19 UTC (permalink / raw)
  To: intel-gfx; +Cc: jani.nikula

The hex dump is useful, just not by default.

Signed-off-by: Jani Nikula <jani.nikula@intel.com>
---
 tools/intel_bios_reader.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/tools/intel_bios_reader.c b/tools/intel_bios_reader.c
index 94b0d6055eb1..0b334871224d 100644
--- a/tools/intel_bios_reader.c
+++ b/tools/intel_bios_reader.c
@@ -67,6 +67,7 @@ struct context {
 
 	uint32_t devid;
 	int panel_type;
+	bool hexdump;
 };
 
 /* Get BDB block size given a pointer to Block ID. */
@@ -1386,7 +1387,8 @@ static void dump_section(struct context *context, int section_id)
 	else
 		printf("BDB block %d:\n", block->id);
 
-	hex_dump(block);
+	if (context->hexdump)
+		hex_dump(block);
 	if (dumper && dumper->dump)
 		dumper->dump(context, block);
 	printf("\n");
@@ -1398,6 +1400,7 @@ enum opt {
 	OPT_FILE,
 	OPT_DEVID,
 	OPT_PANEL_TYPE,
+	OPT_HEXDUMP,
 };
 
 int main(int argc, char **argv)
@@ -1423,6 +1426,7 @@ int main(int argc, char **argv)
 		{ "file",	required_argument,	NULL,	OPT_FILE },
 		{ "devid",	required_argument,	NULL,	OPT_DEVID },
 		{ "panel-type",	required_argument,	NULL,	OPT_PANEL_TYPE },
+		{ "hexdump",	no_argument,		NULL,	OPT_HEXDUMP },
 		{ 0 }
 	};
 
@@ -1448,6 +1452,9 @@ int main(int argc, char **argv)
 				return EXIT_FAILURE;
 			}
 			break;
+		case OPT_HEXDUMP:
+			context.hexdump = true;
+			break;
 		case OPT_END:
 			break;
 		case OPT_UNKNOWN:
-- 
2.1.4

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [PATCH i-g-t 14/17] tools/intel_bios_reader: add support for dumping only specific section
  2016-05-03 14:18 [PATCH i-g-t 00/17] tools/intel_bios_reader updates Jani Nikula
                   ` (12 preceding siblings ...)
  2016-05-03 14:19 ` [PATCH i-g-t 13/17] tools/intel_bios_reader: add --hexdump option to dump hex, disable by default Jani Nikula
@ 2016-05-03 14:19 ` Jani Nikula
  2016-05-03 14:19 ` [PATCH i-g-t 15/17] tools/intel_bios_reader: add --all-panels option to dump all panels Jani Nikula
                   ` (3 subsequent siblings)
  17 siblings, 0 replies; 22+ messages in thread
From: Jani Nikula @ 2016-05-03 14:19 UTC (permalink / raw)
  To: intel-gfx; +Cc: jani.nikula

Now that the parsers for blocks don't depend on the dump ordering, we
can also choose to dump specific sections only.

Signed-off-by: Jani Nikula <jani.nikula@intel.com>
---
 tools/intel_bios_reader.c | 30 ++++++++++++++++++++++++++----
 1 file changed, 26 insertions(+), 4 deletions(-)

diff --git a/tools/intel_bios_reader.c b/tools/intel_bios_reader.c
index 0b334871224d..029cb48fb4cf 100644
--- a/tools/intel_bios_reader.c
+++ b/tools/intel_bios_reader.c
@@ -1365,7 +1365,7 @@ static void hex_dump(const struct bdb_block *block)
 	printf("\n\n");
 }
 
-static void dump_section(struct context *context, int section_id)
+static bool dump_section(struct context *context, int section_id)
 {
 	struct dumper *dumper = NULL;
 	const struct bdb_block *block;
@@ -1373,7 +1373,7 @@ static void dump_section(struct context *context, int section_id)
 
 	block = find_section(context, section_id);
 	if (!block)
-		return;
+		return false;
 
 	for (i = 0; i < ARRAY_SIZE(dumpers); i++) {
 		if (block->id == dumpers[i].id) {
@@ -1392,6 +1392,8 @@ static void dump_section(struct context *context, int section_id)
 	if (dumper && dumper->dump)
 		dumper->dump(context, block);
 	printf("\n");
+
+	return true;
 }
 
 enum opt {
@@ -1401,6 +1403,7 @@ enum opt {
 	OPT_DEVID,
 	OPT_PANEL_TYPE,
 	OPT_HEXDUMP,
+	OPT_BLOCK,
 };
 
 int main(int argc, char **argv)
@@ -1421,12 +1424,14 @@ int main(int argc, char **argv)
 	};
 	char signature[17];
 	char *endp;
+	int block_number = -1;
 
 	static struct option options[] = {
 		{ "file",	required_argument,	NULL,	OPT_FILE },
 		{ "devid",	required_argument,	NULL,	OPT_DEVID },
 		{ "panel-type",	required_argument,	NULL,	OPT_PANEL_TYPE },
 		{ "hexdump",	no_argument,		NULL,	OPT_HEXDUMP },
+		{ "block",	required_argument,	NULL,	OPT_BLOCK },
 		{ 0 }
 	};
 
@@ -1455,6 +1460,14 @@ int main(int argc, char **argv)
 		case OPT_HEXDUMP:
 			context.hexdump = true;
 			break;
+		case OPT_BLOCK:
+			block_number = strtoul(optarg, &endp, 0);
+			if (*endp) {
+				fprintf(stderr, "invalid block number '%s'\n",
+					optarg);
+				return EXIT_FAILURE;
+			}
+			break;
 		case OPT_END:
 			break;
 		case OPT_UNKNOWN:
@@ -1573,8 +1586,17 @@ int main(int argc, char **argv)
 		context.panel_type = 0;
 	}
 
-	for (i = 0; i < 256; i++)
-		dump_section(&context, i);
+	if (block_number != -1) {
+		/* dump specific section only */
+		if (!dump_section(&context, block_number)) {
+			fprintf(stderr, "Block %d not found\n", block_number);
+			return EXIT_FAILURE;
+		}
+	} else {
+		/* dump all sections  */
+		for (i = 0; i < 256; i++)
+			dump_section(&context, i);
+	}
 
 	return 0;
 }
-- 
2.1.4

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [PATCH i-g-t 15/17] tools/intel_bios_reader: add --all-panels option to dump all panels
  2016-05-03 14:18 [PATCH i-g-t 00/17] tools/intel_bios_reader updates Jani Nikula
                   ` (13 preceding siblings ...)
  2016-05-03 14:19 ` [PATCH i-g-t 14/17] tools/intel_bios_reader: add support for dumping only specific section Jani Nikula
@ 2016-05-03 14:19 ` Jani Nikula
  2016-05-03 14:19 ` [PATCH i-g-t 16/17] tools/intel_bios_reader: free the block returned by find_section Jani Nikula
                   ` (2 subsequent siblings)
  17 siblings, 0 replies; 22+ messages in thread
From: Jani Nikula @ 2016-05-03 14:19 UTC (permalink / raw)
  To: intel-gfx; +Cc: jani.nikula

Only dump the one matching panel_type by default. Cleans up the output,
and allows the users to get more verbose output if he so chooses.

Signed-off-by: Jani Nikula <jani.nikula@intel.com>
---
 tools/intel_bios_reader.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/tools/intel_bios_reader.c b/tools/intel_bios_reader.c
index 029cb48fb4cf..3e5df3007520 100644
--- a/tools/intel_bios_reader.c
+++ b/tools/intel_bios_reader.c
@@ -67,6 +67,7 @@ struct context {
 
 	uint32_t devid;
 	int panel_type;
+	bool dump_all_panel_types;
 	bool hexdump;
 };
 
@@ -513,6 +514,9 @@ static void dump_lvds_data(struct context *context,
 		    (const struct bdb_lvds_lfp_data_entry *)lfp_data_ptr;
 		char marker;
 
+		if (i != context->panel_type && !context->dump_all_panel_types)
+			continue;
+
 		if (i == context->panel_type)
 			marker = '*';
 		else
@@ -628,6 +632,9 @@ static void dump_edp(struct context *context,
 	int i;
 
 	for (i = 0; i < 16; i++) {
+		if (i != context->panel_type && !context->dump_all_panel_types)
+			continue;
+
 		printf("\tPanel %d%s\n", i, context->panel_type == i ? " *" : "");
 
 		printf("\t\tPower Sequence: T3 %d T7 %d T9 %d T10 %d T12 %d\n",
@@ -1402,6 +1409,7 @@ enum opt {
 	OPT_FILE,
 	OPT_DEVID,
 	OPT_PANEL_TYPE,
+	OPT_ALL_PANELS,
 	OPT_HEXDUMP,
 	OPT_BLOCK,
 };
@@ -1430,6 +1438,7 @@ int main(int argc, char **argv)
 		{ "file",	required_argument,	NULL,	OPT_FILE },
 		{ "devid",	required_argument,	NULL,	OPT_DEVID },
 		{ "panel-type",	required_argument,	NULL,	OPT_PANEL_TYPE },
+		{ "all-panels",	no_argument,		NULL,	OPT_ALL_PANELS },
 		{ "hexdump",	no_argument,		NULL,	OPT_HEXDUMP },
 		{ "block",	required_argument,	NULL,	OPT_BLOCK },
 		{ 0 }
@@ -1457,6 +1466,9 @@ int main(int argc, char **argv)
 				return EXIT_FAILURE;
 			}
 			break;
+		case OPT_ALL_PANELS:
+			context.dump_all_panel_types = true;
+			break;
 		case OPT_HEXDUMP:
 			context.hexdump = true;
 			break;
-- 
2.1.4

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [PATCH i-g-t 16/17] tools/intel_bios_reader: free the block returned by find_section
  2016-05-03 14:18 [PATCH i-g-t 00/17] tools/intel_bios_reader updates Jani Nikula
                   ` (14 preceding siblings ...)
  2016-05-03 14:19 ` [PATCH i-g-t 15/17] tools/intel_bios_reader: add --all-panels option to dump all panels Jani Nikula
@ 2016-05-03 14:19 ` Jani Nikula
  2016-05-03 14:19 ` [PATCH i-g-t 17/17] man: update intel_bios_reader man page Jani Nikula
  2016-05-04 17:35 ` [PATCH i-g-t 00/17] tools/intel_bios_reader updates Marius Vlad
  17 siblings, 0 replies; 22+ messages in thread
From: Jani Nikula @ 2016-05-03 14:19 UTC (permalink / raw)
  To: intel-gfx; +Cc: jani.nikula

Since we no longer store pointers to previous blocks, we can free them.

Signed-off-by: Jani Nikula <jani.nikula@intel.com>
---
 tools/intel_bios_reader.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/tools/intel_bios_reader.c b/tools/intel_bios_reader.c
index 3e5df3007520..de90f5d37d5d 100644
--- a/tools/intel_bios_reader.c
+++ b/tools/intel_bios_reader.c
@@ -1375,7 +1375,7 @@ static void hex_dump(const struct bdb_block *block)
 static bool dump_section(struct context *context, int section_id)
 {
 	struct dumper *dumper = NULL;
-	const struct bdb_block *block;
+	struct bdb_block *block;
 	int i;
 
 	block = find_section(context, section_id);
@@ -1400,6 +1400,8 @@ static bool dump_section(struct context *context, int section_id)
 		dumper->dump(context, block);
 	printf("\n");
 
+	free(block);
+
 	return true;
 }
 
-- 
2.1.4

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [PATCH i-g-t 17/17] man: update intel_bios_reader man page
  2016-05-03 14:18 [PATCH i-g-t 00/17] tools/intel_bios_reader updates Jani Nikula
                   ` (15 preceding siblings ...)
  2016-05-03 14:19 ` [PATCH i-g-t 16/17] tools/intel_bios_reader: free the block returned by find_section Jani Nikula
@ 2016-05-03 14:19 ` Jani Nikula
  2016-05-04 17:35 ` [PATCH i-g-t 00/17] tools/intel_bios_reader updates Marius Vlad
  17 siblings, 0 replies; 22+ messages in thread
From: Jani Nikula @ 2016-05-03 14:19 UTC (permalink / raw)
  To: intel-gfx; +Cc: jani.nikula

Signed-off-by: Jani Nikula <jani.nikula@intel.com>
---
 man/intel_bios_reader.rst | 48 +++++++++++++++++++++++++++++++++++++++--------
 1 file changed, 40 insertions(+), 8 deletions(-)

diff --git a/man/intel_bios_reader.rst b/man/intel_bios_reader.rst
index 7024f4ded226..0e935904bcfb 100644
--- a/man/intel_bios_reader.rst
+++ b/man/intel_bios_reader.rst
@@ -2,9 +2,9 @@
 intel_bios_reader
 =================
 
---------------------------------------------------
-Parse an Intel BIOS and display many of its tables
---------------------------------------------------
+-----------------------------
+Intel Video BIOS Table parser
+-----------------------------
 .. include:: defs.rst
 :Author: Intel Graphics for Linux <intel-gfx@lists.freedesktop.org>
 :Date: 2016-03-01
@@ -16,15 +16,47 @@ Parse an Intel BIOS and display many of its tables
 SYNOPSIS
 ========
 
-**intel_bios_reader** *FILENAME*
+**intel_bios_reader** [*OPTIONS*]
 
 DESCRIPTION
 ===========
 
-**intel_bios_reader** is a tool to parse the contents of an Intel video BIOS
-file. The file can come from **intel_bios_dumper(1)**. This can be used for
-quick debugging of video bios table handling, which is harder when done inside
-of the kernel graphics driver.
+**intel_bios_reader** is a tool to parse the Intel Video BIOS Tables (VBT) and
+present the information in a human readable format.
+
+The preferred ways of getting the binary VBT to parse are:
+
+1) /sys/kernel/debug/dri/0/i915_vbt (since kernel version 4.5)
+
+2) /sys/kernel/debug/dri/0/i915_opregion
+
+3) Using the **intel_bios_dumper(1)** tool.
+
+The VBT consists of a VBT header, a BIOS Data Block (BDB) header, and a number
+of BIOS Data Blocks.
+
+OPTIONS
+=======
+
+--file=FILE
+    Parse Video BIOS Tables from FILE.
+
+--devid=DEVID
+    Pretend to be PCI ID DEVID. Some details can be parsed more accurately if
+    the platform is known.
+
+--panel-type=N
+    Parse the details for flat panel N. Usually this is retrieved from the Video
+    BIOS Tables, but this can be used to override.
+
+--all-panels
+    Parse the details for all flat panels present in the Video BIOS Tables.
+
+--hexdump
+    Hex dump the blocks.
+
+--block=N
+    Dump only the BIOS Data Block number N.
 
 REPORTING BUGS
 ==============
-- 
2.1.4

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply related	[flat|nested] 22+ messages in thread

* Re: [PATCH i-g-t 04/17] tools/intel_bios_reader: add --devid parameter
  2016-05-03 14:18 ` [PATCH i-g-t 04/17] tools/intel_bios_reader: add --devid parameter Jani Nikula
@ 2016-05-04 15:25   ` Marius Vlad
  2016-05-04 15:47     ` Jani Nikula
  0 siblings, 1 reply; 22+ messages in thread
From: Marius Vlad @ 2016-05-04 15:25 UTC (permalink / raw)
  To: Jani Nikula; +Cc: intel-gfx


[-- Attachment #1.1: Type: text/plain, Size: 3671 bytes --]

On Tue, May 03, 2016 at 05:18:54PM +0300, Jani Nikula wrote:
> 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 <jani.nikula@intel.com>
> ---
>  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: <unknown platform>\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);
Wouldn't this allow to pass either base 10, 16 or 8? (as an argument
devid seems to be always specified in base 16).
> +	}
> +	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);
> -- 
> 2.1.4
> 
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/intel-gfx

[-- Attachment #1.2: Digital signature --]
[-- Type: application/pgp-signature, Size: 473 bytes --]

[-- Attachment #2: Type: text/plain, Size: 160 bytes --]

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH i-g-t 04/17] tools/intel_bios_reader: add --devid parameter
  2016-05-04 15:25   ` Marius Vlad
@ 2016-05-04 15:47     ` Jani Nikula
  0 siblings, 0 replies; 22+ messages in thread
From: Jani Nikula @ 2016-05-04 15:47 UTC (permalink / raw)
  To: Marius Vlad; +Cc: intel-gfx

On Wed, 04 May 2016, Marius Vlad <marius.c.vlad@intel.com> wrote:
> On Tue, May 03, 2016 at 05:18:54PM +0300, Jani Nikula wrote:
>> 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 <jani.nikula@intel.com>
>> ---
>>  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: <unknown platform>\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);
> Wouldn't this allow to pass either base 10, 16 or 8? (as an argument
> devid seems to be always specified in base 16).

That's a change in how the DEVICE environment variable was handled
previously, but indeed should be changed.

Thanks,
Jani.

>> +	}
>> +	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);
>> -- 
>> 2.1.4
>> 
>> _______________________________________________
>> Intel-gfx mailing list
>> Intel-gfx@lists.freedesktop.org
>> https://lists.freedesktop.org/mailman/listinfo/intel-gfx

-- 
Jani Nikula, Intel Open Source Technology Center
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH i-g-t 00/17] tools/intel_bios_reader updates
  2016-05-03 14:18 [PATCH i-g-t 00/17] tools/intel_bios_reader updates Jani Nikula
                   ` (16 preceding siblings ...)
  2016-05-03 14:19 ` [PATCH i-g-t 17/17] man: update intel_bios_reader man page Jani Nikula
@ 2016-05-04 17:35 ` Marius Vlad
  2016-05-12 11:18   ` Jani Nikula
  17 siblings, 1 reply; 22+ messages in thread
From: Marius Vlad @ 2016-05-04 17:35 UTC (permalink / raw)
  To: Jani Nikula; +Cc: intel-gfx


[-- Attachment #1.1: Type: text/plain, Size: 3367 bytes --]

Care to add this usage for it as well?

Signed-off-by: Marius Vlad <marius.c.vlad@intel.com>
---
 tools/intel_bios_reader.c | 19 ++++++++++++++++++-
 1 file changed, 18 insertions(+), 1 deletion(-)

diff --git a/tools/intel_bios_reader.c b/tools/intel_bios_reader.c
index de90f5d..4192919 100644
--- a/tools/intel_bios_reader.c
+++ b/tools/intel_bios_reader.c
@@ -1414,8 +1414,22 @@ enum opt {
 	OPT_ALL_PANELS,
 	OPT_HEXDUMP,
 	OPT_BLOCK,
+	OPT_USAGE
 };
 
+static void usage(const char *toolname)
+{
+	fprintf(stderr, "usage %s:", toolname);
+	fprintf(stderr, " --file=<rom file>"
+			" [--devid=<device_id>]"
+			" [--panel-type=<panel_type>]"
+			" [--all-panels]"
+			" [--hexdump]"
+			" [--block=<block_no>]"
+			" [--help]\n");
+
+}
+
 int main(int argc, char **argv)
 {
 	uint8_t *VBIOS;
@@ -1443,6 +1457,7 @@ int main(int argc, char **argv)
 		{ "all-panels",	no_argument,		NULL,	OPT_ALL_PANELS },
 		{ "hexdump",	no_argument,		NULL,	OPT_HEXDUMP },
 		{ "block",	required_argument,	NULL,	OPT_BLOCK },
+		{ "help",	no_argument,		NULL,	OPT_USAGE },
 		{ 0 }
 	};
 
@@ -1484,7 +1499,9 @@ int main(int argc, char **argv)
 			break;
 		case OPT_END:
 			break;
+		case OPT_USAGE: /* fall-through */
 		case OPT_UNKNOWN:
+			usage(toolname);
 			return EXIT_FAILURE;
 		}
 	}
@@ -1497,7 +1514,7 @@ int main(int argc, char **argv)
 			/* for backwards compatibility */
 			filename = argv[0];
 		} else {
-			printf("usage: %s --file=<rom file>\n", toolname);
+			usage(toolname);
 			return EXIT_FAILURE;
 		}
 	}
-- 
2.5.0


On Tue, May 03, 2016 at 05:18:50PM +0300, Jani Nikula wrote:
> Give the intel_bios_reader tool some love. The last patch updating the
> man page doubles as a summary.
> 
> BR,
> Jani.
> 
> 
> Jani Nikula (17):
>   tools/intel_bios_reader: drop unused macros
>   tools/intel_bios_reader: make VBIOS non-global
>   tools/intel_bios_reader: add command line option parsing and --file
>     parameter
>   tools/intel_bios_reader: add --devid parameter
>   tools/intel_bios_reader: drop unused lvds_support variable
>   tools/intel_bios_reader: drop silly tv_present variable and printout
>   tools/intel_bios_reader: pass around a context pointer instead of
>     bdb_header
>   tools/intel_bios_reader: move more globals to struct context
>   tools/intel_bios_reader: move devid to context too
>   tools/intel_bios_reader: drop dependencies on lvds block parsing
>   tools/intel_bios_reader: let the user specify panel type on the
>     command line
>   tools/intel_bios_reader: dump the blocks in numerical order
>   tools/intel_bios_reader: add --hexdump option to dump hex, disable by
>     default
>   tools/intel_bios_reader: add support for dumping only specific section
>   tools/intel_bios_reader: add --all-panels option to dump all panels
>   tools/intel_bios_reader: free the block returned by find_section
>   man: update intel_bios_reader man page
> 
>  man/intel_bios_reader.rst |  48 +++++--
>  tools/intel_bios_reader.c | 310 +++++++++++++++++++++++++++++++---------------
>  2 files changed, 249 insertions(+), 109 deletions(-)
> 
> -- 
> 2.1.4
> 
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/intel-gfx

[-- Attachment #1.2: Digital signature --]
[-- Type: application/pgp-signature, Size: 473 bytes --]

[-- Attachment #2: Type: text/plain, Size: 160 bytes --]

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply related	[flat|nested] 22+ messages in thread

* Re: [PATCH i-g-t 00/17] tools/intel_bios_reader updates
  2016-05-04 17:35 ` [PATCH i-g-t 00/17] tools/intel_bios_reader updates Marius Vlad
@ 2016-05-12 11:18   ` Jani Nikula
  0 siblings, 0 replies; 22+ messages in thread
From: Jani Nikula @ 2016-05-12 11:18 UTC (permalink / raw)
  To: Marius Vlad; +Cc: intel-gfx

On Wed, 04 May 2016, Marius Vlad <marius.c.vlad@intel.com> wrote:
> Care to add this usage for it as well?

Pushed the entire series, with the strtoul in patch 4 fixed, and added
this usage patch, with a few minor tweaks.

BR,
Jani.

>
> Signed-off-by: Marius Vlad <marius.c.vlad@intel.com>
> ---
>  tools/intel_bios_reader.c | 19 ++++++++++++++++++-
>  1 file changed, 18 insertions(+), 1 deletion(-)
>
> diff --git a/tools/intel_bios_reader.c b/tools/intel_bios_reader.c
> index de90f5d..4192919 100644
> --- a/tools/intel_bios_reader.c
> +++ b/tools/intel_bios_reader.c
> @@ -1414,8 +1414,22 @@ enum opt {
>  	OPT_ALL_PANELS,
>  	OPT_HEXDUMP,
>  	OPT_BLOCK,
> +	OPT_USAGE
>  };
>  
> +static void usage(const char *toolname)
> +{
> +	fprintf(stderr, "usage %s:", toolname);
> +	fprintf(stderr, " --file=<rom file>"
> +			" [--devid=<device_id>]"
> +			" [--panel-type=<panel_type>]"
> +			" [--all-panels]"
> +			" [--hexdump]"
> +			" [--block=<block_no>]"
> +			" [--help]\n");
> +
> +}
> +
>  int main(int argc, char **argv)
>  {
>  	uint8_t *VBIOS;
> @@ -1443,6 +1457,7 @@ int main(int argc, char **argv)
>  		{ "all-panels",	no_argument,		NULL,	OPT_ALL_PANELS },
>  		{ "hexdump",	no_argument,		NULL,	OPT_HEXDUMP },
>  		{ "block",	required_argument,	NULL,	OPT_BLOCK },
> +		{ "help",	no_argument,		NULL,	OPT_USAGE },
>  		{ 0 }
>  	};
>  
> @@ -1484,7 +1499,9 @@ int main(int argc, char **argv)
>  			break;
>  		case OPT_END:
>  			break;
> +		case OPT_USAGE: /* fall-through */
>  		case OPT_UNKNOWN:
> +			usage(toolname);
>  			return EXIT_FAILURE;
>  		}
>  	}
> @@ -1497,7 +1514,7 @@ int main(int argc, char **argv)
>  			/* for backwards compatibility */
>  			filename = argv[0];
>  		} else {
> -			printf("usage: %s --file=<rom file>\n", toolname);
> +			usage(toolname);
>  			return EXIT_FAILURE;
>  		}
>  	}

-- 
Jani Nikula, Intel Open Source Technology Center
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 22+ messages in thread

end of thread, other threads:[~2016-05-12 11:18 UTC | newest]

Thread overview: 22+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-05-03 14:18 [PATCH i-g-t 00/17] tools/intel_bios_reader updates Jani Nikula
2016-05-03 14:18 ` [PATCH i-g-t 01/17] tools/intel_bios_reader: drop unused macros Jani Nikula
2016-05-03 14:18 ` [PATCH i-g-t 02/17] tools/intel_bios_reader: make VBIOS non-global Jani Nikula
2016-05-03 14:18 ` [PATCH i-g-t 03/17] tools/intel_bios_reader: add command line option parsing and --file parameter Jani Nikula
2016-05-03 14:18 ` [PATCH i-g-t 04/17] tools/intel_bios_reader: add --devid parameter Jani Nikula
2016-05-04 15:25   ` Marius Vlad
2016-05-04 15:47     ` Jani Nikula
2016-05-03 14:18 ` [PATCH i-g-t 05/17] tools/intel_bios_reader: drop unused lvds_support variable Jani Nikula
2016-05-03 14:18 ` [PATCH i-g-t 06/17] tools/intel_bios_reader: drop silly tv_present variable and printout Jani Nikula
2016-05-03 14:18 ` [PATCH i-g-t 07/17] tools/intel_bios_reader: pass around a context pointer instead of bdb_header Jani Nikula
2016-05-03 14:18 ` [PATCH i-g-t 08/17] tools/intel_bios_reader: move more globals to struct context Jani Nikula
2016-05-03 14:18 ` [PATCH i-g-t 09/17] tools/intel_bios_reader: move devid to context too Jani Nikula
2016-05-03 14:19 ` [PATCH i-g-t 10/17] tools/intel_bios_reader: drop dependencies on lvds block parsing Jani Nikula
2016-05-03 14:19 ` [PATCH i-g-t 11/17] tools/intel_bios_reader: let the user specify panel type on the command line Jani Nikula
2016-05-03 14:19 ` [PATCH i-g-t 12/17] tools/intel_bios_reader: dump the blocks in numerical order Jani Nikula
2016-05-03 14:19 ` [PATCH i-g-t 13/17] tools/intel_bios_reader: add --hexdump option to dump hex, disable by default Jani Nikula
2016-05-03 14:19 ` [PATCH i-g-t 14/17] tools/intel_bios_reader: add support for dumping only specific section Jani Nikula
2016-05-03 14:19 ` [PATCH i-g-t 15/17] tools/intel_bios_reader: add --all-panels option to dump all panels Jani Nikula
2016-05-03 14:19 ` [PATCH i-g-t 16/17] tools/intel_bios_reader: free the block returned by find_section Jani Nikula
2016-05-03 14:19 ` [PATCH i-g-t 17/17] man: update intel_bios_reader man page Jani Nikula
2016-05-04 17:35 ` [PATCH i-g-t 00/17] tools/intel_bios_reader updates Marius Vlad
2016-05-12 11:18   ` Jani Nikula

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.