diff options
author | Jani Nikula <jani.nikula@intel.com> | 2017-09-27 16:24:31 +0300 |
---|---|---|
committer | Jani Nikula <jani.nikula@intel.com> | 2017-10-20 16:15:19 +0300 |
commit | 9ba736aecc2a3cb34a2aeec8d417f66390e0c82b (patch) | |
tree | f2609d930dde6ba8b8a0a24cff9630ce37a50a53 /tools/intel_vbt_decode.c | |
parent | 3d2b8ed4bb45d3cee86fc13a5edb74e935a76ba3 (diff) |
tools/intel_vbt_decode: abstract child devices printing more
Unify the common code for current and legacy blocks.
Acked-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Diffstat (limited to 'tools/intel_vbt_decode.c')
-rw-r--r-- | tools/intel_vbt_decode.c | 70 |
1 files changed, 31 insertions, 39 deletions
diff --git a/tools/intel_vbt_decode.c b/tools/intel_vbt_decode.c index ed9f43b8..9d90c69d 100644 --- a/tools/intel_vbt_decode.c +++ b/tools/intel_vbt_decode.c @@ -483,25 +483,12 @@ static void dump_child_device(struct context *context, } } -static void dump_general_definitions(struct context *context, - const struct bdb_block *block) + +static void dump_child_devices(struct context *context, const uint8_t *devices, + uint8_t child_dev_num, uint8_t child_dev_size) { - const struct bdb_general_definitions *defs = block->data; struct child_device_config *child; int i; - int child_device_num; - - printf("\tCRT DDC GMBUS addr: 0x%02x\n", defs->crt_ddc_gmbus_pin); - printf("\tUse ACPI DPMS CRT power states: %s\n", - YESNO(defs->dpms_acpi)); - printf("\tSkip CRT detect at boot: %s\n", - YESNO(defs->skip_boot_crt_detect)); - 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("\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 @@ -510,9 +497,9 @@ static void dump_general_definitions(struct context *context, */ 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)); + for (i = 0; i < child_dev_num; i++) { + memcpy(child, devices + i * child_dev_size, + min(sizeof(*child), child_dev_size)); dump_child_device(context, child); } @@ -520,33 +507,38 @@ static void dump_general_definitions(struct context *context, free(child); } -static void dump_legacy_child_devices(struct context *context, - const struct bdb_block *block) +static void dump_general_definitions(struct context *context, + const struct bdb_block *block) { - const struct bdb_legacy_child_devices *defs = block->data; - struct child_device_config *child; - int i; - int child_device_num; + const struct bdb_general_definitions *defs = block->data; + int child_dev_num; + printf("\tCRT DDC GMBUS addr: 0x%02x\n", defs->crt_ddc_gmbus_pin); + printf("\tUse ACPI DPMS CRT power states: %s\n", + YESNO(defs->dpms_acpi)); + printf("\tSkip CRT detect at boot: %s\n", + YESNO(defs->skip_boot_crt_detect)); + 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("\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)); + child_dev_num = (block->size - sizeof(*defs)) / defs->child_dev_size; + dump_child_devices(context, defs->devices, + child_dev_num, defs->child_dev_size); +} - for (i = 0; i < child_device_num; i++) { - memcpy(child, &defs->devices[i * defs->child_dev_size], - min(sizeof(*child), defs->child_dev_size)); +static void dump_legacy_child_devices(struct context *context, + const struct bdb_block *block) +{ + const struct bdb_legacy_child_devices *defs = block->data; + int child_dev_num; - dump_child_device(context, child); - } + printf("\tChild device size: %d\n", defs->child_dev_size); - free(child); + child_dev_num = (block->size - sizeof(*defs)) / defs->child_dev_size; + dump_child_devices(context, defs->devices, + child_dev_num, defs->child_dev_size); } static void dump_lvds_options(struct context *context, |