diff options
author | Jani Nikula <jani.nikula@intel.com> | 2016-05-03 12:07:30 +0300 |
---|---|---|
committer | Jani Nikula <jani.nikula@intel.com> | 2016-05-12 14:02:52 +0300 |
commit | 21467dc5e48ff32892e3f390aaba3f72bc5c532f (patch) | |
tree | b12c547ca64b141d946e30d1c418432f0bd131d1 /tools | |
parent | 17ae0a6d6b7c4aba359875988e2a896cf4943751 (diff) |
tools/intel_bios_reader: let the user specify panel type on the command line
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>
Diffstat (limited to 'tools')
-rw-r--r-- | tools/intel_bios_reader.c | 50 |
1 files changed, 46 insertions, 4 deletions
diff --git a/tools/intel_bios_reader.c b/tools/intel_bios_reader.c index 3e622b84..e4366d3f 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); |