Igt-dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Ville Syrjala <ville.syrjala@linux.intel.com>
To: igt-dev@lists.freedesktop.org
Cc: Jani Nikula <jani.nikula@intel.com>
Subject: [PATCH i-g-t v2 4/5] tools/intel_vbt_decode: Also dump the second panel (panel_type2)
Date: Mon, 25 Mar 2024 18:33:27 +0200	[thread overview]
Message-ID: <20240325163327.22757-1-ville.syrjala@linux.intel.com> (raw)
In-Reply-To: <20240322163251.11102-5-ville.syrjala@linux.intel.com>

From: Ville Syrjälä <ville.syrjala@linux.intel.com>

Modern VBTs can declare two panel types in order to support
dual panel systems. Dump the panel information for the second
panel as well. Since panel_type2 could also be declared as 255
(== match pnpid to EDID) we also add a new command line knob
to select panel_type2 by hand.

Data for the second panel will be indicated by "(2)", as opposed
to "(1)" for the first panel.

We can also end up in a situation where panel_type==panel_type2.
The reasons being a dodgy VBT, or the VBT might declare
panel_type==255 and panel_type2=0, and if we can't determine
which panel the 255 refers to (via pnpid) then we just default
to panel_type==0.

v2: Break the ?: into separate ifs (Jani)
    Clarify why we can end up with panel_type==panel_type2 (Jani)

Reviewed-by: Jani Nikula <jani.nikula@intel.com>
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
---
 tools/intel_vbt_decode.c | 45 ++++++++++++++++++++++++++++++++++------
 1 file changed, 39 insertions(+), 6 deletions(-)

diff --git a/tools/intel_vbt_decode.c b/tools/intel_vbt_decode.c
index 98f64d0822c6..788c2903e4a1 100644
--- a/tools/intel_vbt_decode.c
+++ b/tools/intel_vbt_decode.c
@@ -79,7 +79,7 @@ struct context {
 	int size;
 
 	uint32_t devid;
-	int panel_type;
+	int panel_type, panel_type2;
 	bool dump_all_panel_types;
 	bool hexdump;
 };
@@ -87,12 +87,23 @@ struct context {
 static bool dump_panel(const struct context *context, int panel_type)
 {
 	return panel_type == context->panel_type ||
+		panel_type == context->panel_type2 ||
 		context->dump_all_panel_types;
 }
 
 static const char *panel_str(const struct context *context, int panel_type)
 {
-	return panel_type == context->panel_type ? " (1)" : "";
+	if (panel_type == context->panel_type &&
+	    panel_type == context->panel_type2)
+		return " (1)(2)";
+
+	if (panel_type == context->panel_type)
+		return " (1)";
+
+	if (panel_type == context->panel_type2)
+		return " (2)";
+
+	return "";
 }
 
 /* Get BDB block size given a pointer to Block ID. */
@@ -2503,18 +2514,21 @@ static void dump_compression_parameters(struct context *context,
 }
 
 /* get panel type from lvds options block, or -1 if block not found */
-static int get_panel_type(struct context *context)
+static int get_panel_type(struct context *context, bool is_panel_type2)
 {
 	struct bdb_block *block;
 	const struct bdb_lvds_options *options;
-	int panel_type;
+	int panel_type = -1;
 
 	block = find_section(context, BDB_LVDS_OPTIONS);
 	if (!block)
 		return -1;
 
 	options = block_data(block);
-	panel_type = options->panel_type;
+	if (!is_panel_type2)
+		panel_type = options->panel_type;
+	else if (context->bdb->version >= 212)
+		panel_type = options->panel_type2;
 
 	free(block);
 
@@ -2776,6 +2790,7 @@ enum opt {
 	OPT_FILE,
 	OPT_DEVID,
 	OPT_PANEL_TYPE,
+	OPT_PANEL_TYPE2,
 	OPT_ALL_PANELS,
 	OPT_HEXDUMP,
 	OPT_BLOCK,
@@ -2812,6 +2827,7 @@ int main(int argc, char **argv)
 	int size;
 	struct context context = {
 		.panel_type = -1,
+		.panel_type2 = -1,
 	};
 	char *endp;
 	int block_number = -1;
@@ -2821,6 +2837,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 },
+		{ "panel-type2",	required_argument,	NULL,	OPT_PANEL_TYPE2 },
 		{ "all-panels",	no_argument,		NULL,	OPT_ALL_PANELS },
 		{ "hexdump",	no_argument,		NULL,	OPT_HEXDUMP },
 		{ "block",	required_argument,	NULL,	OPT_BLOCK },
@@ -2852,6 +2869,14 @@ int main(int argc, char **argv)
 				return EXIT_FAILURE;
 			}
 			break;
+		case OPT_PANEL_TYPE2:
+			context.panel_type2 = strtoul(optarg, &endp, 0);
+			if (*endp || context.panel_type2 > 15) {
+				fprintf(stderr, "invalid panel type2 '%s'\n",
+					optarg);
+				return EXIT_FAILURE;
+			}
+			break;
 		case OPT_ALL_PANELS:
 			context.dump_all_panel_types = true;
 			break;
@@ -2969,12 +2994,20 @@ int main(int argc, char **argv)
 		fprintf(stderr, "Warning: could not find PCI device ID!\n");
 
 	if (context.panel_type == -1)
-		context.panel_type = get_panel_type(&context);
+		context.panel_type = get_panel_type(&context, false);
 	if (context.panel_type == -1) {
 		fprintf(stderr, "Warning: panel type not set, using 0\n");
 		context.panel_type = 0;
 	}
 
+	if (context.panel_type2 == -1)
+		context.panel_type2 = get_panel_type(&context, true);
+	if (context.panel_type2 != -1 && context.bdb->version < 212) {
+		fprintf(stderr, "Warning: panel type2 not valid for BDB version %d\n",
+			context.bdb->version);
+		context.panel_type2 = -1;
+	}
+
 	if (describe) {
 		print_description(&context);
 	} else if (header_only) {
-- 
2.43.2


  parent reply	other threads:[~2024-03-25 16:33 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-22 16:32 [PATCH i-g-t 0/5] tools/intel_vbt_decode: Improve panel type handling Ville Syrjala
2024-03-22 16:32 ` [PATCH i-g-t 1/5] tools/intel_vbt_decode: Extract dump_panel() Ville Syrjala
2024-03-25 14:56   ` Jani Nikula
2024-03-22 16:32 ` [PATCH i-g-t 2/5] tools/intel_vbt_decode: Extract panel_str() Ville Syrjala
2024-03-25 14:56   ` Jani Nikula
2024-03-22 16:32 ` [PATCH i-g-t 3/5] tools/intel_vbt_decode: Change panel indicator from * to (1) Ville Syrjala
2024-03-25 14:57   ` Jani Nikula
2024-03-22 16:32 ` [PATCH i-g-t 4/5] tools/intel_vbt_decode: Also dump the second panel (panel_type2) Ville Syrjala
2024-03-25 15:04   ` Jani Nikula
2024-03-25 15:08     ` Ville Syrjälä
2024-03-25 16:33   ` Ville Syrjala [this message]
2024-03-22 16:32 ` [PATCH i-g-t 5/5] tools/intel_vbt_decode: Optionally determine panel type from EDID Ville Syrjala
2024-03-25 15:08   ` Jani Nikula
2024-03-25 15:16     ` Ville Syrjälä
2024-03-25 16:36   ` [PATCH i-g-t v2 " Ville Syrjala
2024-03-22 18:51 ` ✓ CI.xeBAT: success for tools/intel_vbt_decode: Improve panel type handling Patchwork
2024-03-22 18:56 ` ✓ Fi.CI.BAT: " Patchwork
2024-03-23 21:17 ` ✗ Fi.CI.IGT: failure " Patchwork
2024-03-25 19:39 ` ✗ Fi.CI.BAT: failure for tools/intel_vbt_decode: Improve panel type handling (rev3) Patchwork
2024-03-25 19:42 ` ✓ CI.xeBAT: success " 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=20240325163327.22757-1-ville.syrjala@linux.intel.com \
    --to=ville.syrjala@linux.intel.com \
    --cc=igt-dev@lists.freedesktop.org \
    --cc=jani.nikula@intel.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox