All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jani Nikula <jani.nikula@intel.com>
To: intel-gfx@lists.freedesktop.org
Cc: jani.nikula@intel.com
Subject: [PATCH i-g-t 6/8] tools/intel_vbt_decode: unify legacy child device block dumping
Date: Thu, 19 Oct 2017 18:22:57 +0300	[thread overview]
Message-ID: <20171019152259.31615-7-jani.nikula@intel.com> (raw)
In-Reply-To: <20171019152259.31615-1-jani.nikula@intel.com>

It's the same stuff as in the new child devices.

Signed-off-by: Jani Nikula <jani.nikula@intel.com>
---
 tools/intel_bios.h       | 30 +++---------------------------
 tools/intel_vbt_decode.c | 37 +++++++++++++++++++++----------------
 2 files changed, 24 insertions(+), 43 deletions(-)

diff --git a/tools/intel_bios.h b/tools/intel_bios.h
index f0475b5cfcc3..78a96d977536 100644
--- a/tools/intel_bios.h
+++ b/tools/intel_bios.h
@@ -42,33 +42,9 @@
 #define DEVICE_TYPE_DVI			0x68d2
 #define DEVICE_TYPE_MIPI		0x7cc2
 
-struct legacy_child_device_config {
-	uint16_t handle;
-	uint16_t device_type;	/* See DEVICE_TYPE_* above */
-	uint8_t device_id[10];
-	uint16_t addin_offset;
-	uint8_t dvo_port;	/* See DEVICE_PORT_* above */
-	uint8_t i2c_pin;
-	uint8_t slave_addr;
-	uint8_t ddc_pin;
-	uint16_t edid_ptr;
-	uint8_t dvo_cfg;	/* See DEVICE_CFG_* above */
-	uint8_t dvo2_port;
-	uint8_t i2c2_pin;
-	uint8_t slave2_addr;
-	uint8_t ddc2_pin;
-	uint8_t capabilities;
-	uint8_t dvo_wiring;	/* See DEVICE_WIRE_* above */
-	uint8_t dvo2_wiring;
-	uint16_t extended_type;
-	uint8_t dvo_function;
-} __attribute__ ((packed));
-
-#define DEVICE_CHILD_SIZE 7
-
-struct bdb_child_devices {
-	uint8_t child_structure_size;
-	struct legacy_child_device_config children[DEVICE_CHILD_SIZE];
+struct bdb_legacy_child_devices {
+	uint8_t child_dev_size;
+	uint8_t devices[0]; /* presumably 7 * 33 */
 } __attribute__ ((packed));
 
 #define BDB_DRIVER_NO_LVDS	0
diff --git a/tools/intel_vbt_decode.c b/tools/intel_vbt_decode.c
index bc5f38112619..3cce60bf2ee2 100644
--- a/tools/intel_vbt_decode.c
+++ b/tools/intel_vbt_decode.c
@@ -526,25 +526,30 @@ static void dump_general_definitions(struct context *context,
 static void dump_legacy_child_devices(struct context *context,
 				      const struct bdb_block *block)
 {
-	const struct bdb_child_devices *child_devs = block->data;
-	const struct legacy_child_device_config *child;
+	const struct bdb_legacy_child_devices *defs = block->data;
+	struct child_device_config *child;
 	int i;
+	int child_device_num;
 
-	for (i = 0; i < DEVICE_CHILD_SIZE; i++) {
-		child = &child_devs->children[i];
-		/* Skip nonexistent children */
-		if (!child->device_type)
-			continue;
-		printf("\tChild device %d\n", i);
-		printf("\t\tType: 0x%04x (%s)\n", child->device_type,
-		       child_device_type(child->device_type));
-		printf("\t\tDVO port: 0x%02x\n", child->dvo_port);
-		printf("\t\tI2C pin: 0x%02x\n", child->i2c_pin);
-		printf("\t\tSlave addr: 0x%02x\n", child->slave_addr);
-		printf("\t\tDDC pin: 0x%02x\n", child->ddc_pin);
-		printf("\t\tDVO config: 0x%02x\n", child->dvo_cfg);
-		printf("\t\tDVO wiring: 0x%02x\n", child->dvo_wiring);
+	printf("\tChild device size: %d\n", defs->child_dev_size);
+	child_device_num = (block->size - sizeof(*defs)) /
+		defs->child_dev_size;
+
+	/*
+	 * Use a temp buffer so dump_child_device() doesn't have to worry about
+	 * accessing the struct beyond child_dev_size. The tail, if any, remains
+	 * initialized to zero.
+	 */
+	child = calloc(1, sizeof(*child));
+
+	for (i = 0; i < child_device_num; i++) {
+		memcpy(child, &defs->devices[i * defs->child_dev_size],
+		       min(sizeof(*child), defs->child_dev_size));
+
+		dump_child_device(context, child);
 	}
+
+	free(child);
 }
 
 static void dump_lvds_options(struct context *context,
-- 
2.11.0

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

  parent reply	other threads:[~2017-10-19 15:21 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-10-19 15:22 [PATCH i-g-t 0/8] tools/intel_vbt_decode: refactoring and cleanups Jani Nikula
2017-10-19 15:22 ` [PATCH i-g-t 1/8] tools/intel_vbt_decode: make a copy of child devices before dumping Jani Nikula
2017-10-19 15:22 ` [PATCH i-g-t 2/8] tools/intel_vbt_decode: update dvo port name dumping Jani Nikula
2017-10-19 15:22 ` [PATCH i-g-t 3/8] tools/intel_vbt_decode: use %.*s instead of duplicating a string Jani Nikula
2017-10-19 15:22 ` [PATCH i-g-t 4/8] tools/intel_vbt_decode: abstract DSI bridge type dump Jani Nikula
2017-10-19 15:22 ` [PATCH i-g-t 5/8] tools/intel_vbt_decode: unify child device printing across versions Jani Nikula
2017-10-19 17:24   ` Ville Syrjälä
2017-10-20 10:56     ` Jani Nikula
2017-10-20 11:33       ` Ville Syrjälä
2017-10-20 13:17         ` Jani Nikula
2017-10-20 13:49           ` Ville Syrjälä
2017-10-19 15:22 ` Jani Nikula [this message]
2017-10-19 15:22 ` [PATCH i-g-t 7/8] tools/intel_vbt_decode: dump more child device data for version < 152 Jani Nikula
2017-10-19 15:22 ` [PATCH i-g-t 8/8] tools/intel_vbt_decode: abstract child devices printing more Jani Nikula
2017-10-19 16:52 ` ✗ Fi.CI.BAT: failure for tools/intel_vbt_decode: refactoring and cleanups Patchwork

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20171019152259.31615-7-jani.nikula@intel.com \
    --to=jani.nikula@intel.com \
    --cc=intel-gfx@lists.freedesktop.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.