mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-05 07:28:11 +02:00
intel/dev/tools: add json as an output format for intel_dev_info
intel_dev_info prints out struct intel_device_info in a user-friendly format. Json format enables this information to be used as input for tools. Reviewed-by: Dylan Baker <dylan@pnwbakers.com> Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/27557>
This commit is contained in:
parent
1f725a222a
commit
56da473b6f
2 changed files with 15 additions and 3 deletions
|
|
@ -36,6 +36,7 @@
|
|||
#include "util/libdrm.h"
|
||||
|
||||
#include "intel_device_info.h"
|
||||
#include "intel_device_info_serialize.h"
|
||||
#include "intel_hwconfig.h"
|
||||
|
||||
static int
|
||||
|
|
@ -179,12 +180,13 @@ main(int argc, char *argv[])
|
|||
drmDevicePtr devices[8];
|
||||
int max_devices, i;
|
||||
char c;
|
||||
bool help = false, print_hwconfig = false, all = false, print_workarounds = false;
|
||||
bool help = false, print_hwconfig = false, all = false, print_workarounds = false, print_json = false;
|
||||
const char *platform = NULL;
|
||||
const struct option opts[] = {
|
||||
{ "help", no_argument, (int *) &help, true },
|
||||
{ "platform", required_argument, NULL, false },
|
||||
{ "hwconfig", no_argument, (int *) &print_hwconfig, true },
|
||||
{ "json", no_argument, (int *) &print_json, true },
|
||||
{ "workarounds", no_argument, (int *) &print_workarounds, true },
|
||||
{ "all", no_argument, (int *) &all, true },
|
||||
};
|
||||
|
|
@ -211,6 +213,7 @@ main(int argc, char *argv[])
|
|||
" --help / h display this help and exit\n"
|
||||
" --platform <name> print a given platform's info (skl, icl, tgl, etc...)\n"
|
||||
" --hwconfig print the hwconfig table\n"
|
||||
" --json print json representation of device info\n"
|
||||
" --workarounds print the list of hardware workarounds for the system\n"
|
||||
" --all / -a print all optional details\n");
|
||||
exit(0);
|
||||
|
|
@ -255,6 +258,15 @@ main(int argc, char *argv[])
|
|||
if (!success)
|
||||
continue;
|
||||
|
||||
if (print_json) {
|
||||
JSON_Value *json = intel_device_info_dump_json(&devinfo);
|
||||
char *pretty_string = json_serialize_to_string_pretty(json);
|
||||
printf("%s", pretty_string);
|
||||
json_free_serialized_string(pretty_string);
|
||||
json_value_free(json);
|
||||
continue;
|
||||
}
|
||||
|
||||
fprintf(stdout, "%s:\n", path);
|
||||
|
||||
print_base_devinfo(&devinfo);
|
||||
|
|
|
|||
|
|
@ -120,8 +120,8 @@ endif
|
|||
if with_intel_tools
|
||||
intel_dev_info = executable(
|
||||
'intel_dev_info',
|
||||
files('intel_dev_info.c'),
|
||||
dependencies : [dep_libdrm, dep_dl, dep_thread, dep_m, idep_intel_dev],
|
||||
[files('intel_dev_info.c'), [intel_dev_serialize_src]],
|
||||
dependencies : [dep_libdrm, dep_dl, dep_thread, dep_m, idep_intel_dev, idep_parson],
|
||||
include_directories : [inc_include, inc_src, inc_intel],
|
||||
c_args : [no_override_init_args],
|
||||
gnu_symbol_visibility : 'hidden',
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue