diff --git a/vainfo/vainfo.c b/vainfo/vainfo.c index 148e617c..e6f0b321 100644 --- a/vainfo/vainfo.c +++ b/vainfo/vainfo.c @@ -46,12 +46,16 @@ if (va_status != VA_STATUS_SUCCESS) { \ goto error; \ } +#define TRUE 1 +#define FALSE 0 + static void usage_exit(const char *program) { fprintf(stdout, "Show information from VA-API driver\n"); fprintf(stdout, "Usage: %s --help\n", program); - fprintf(stdout, "\t--help print this message\n\n"); + fprintf(stdout, "\t--help print this message\n"); + fprintf(stdout, "\t--verbose\n\n"); fprintf(stdout, "Usage: %s [options]\n", program); va_print_display_options(stdout); @@ -59,29 +63,87 @@ usage_exit(const char *program) } static void -parse_args(const char *name, int argc, char **argv) +parse_args(const char *name, int argc, char **argv, char *verbose) { int c; int option_index = 0; static struct option long_options[] = { {"help", no_argument, 0, 'h'}, + {"verbose", no_argument, 0, 'v'}, { NULL, 0, NULL, 0 } }; - va_init_display_args(&argc, argv); - while ((c = getopt_long(argc, argv, - "", + "hv", long_options, &option_index)) != -1) { switch(c) { + case 'v': + *verbose = TRUE; + break; case 'h': default: usage_exit(name); break; } } + + va_init_display_args(&argc, argv); +} + + +void print_supported_config_attributes(VADisplay va_dpy, + VAProfile profile, + VAEntrypoint entrypoint) { + static struct { + int bitmask; + char name[22]; + } va_rt_format_to_names_map[] = { + {0x00000001, "VA_RT_FORMAT_YUV420 "}, + {0x00000002, "VA_RT_FORMAT_YUV422 "}, + {0x00000004, "VA_RT_FORMAT_YUV444 "}, + {0x00000008, "VA_RT_FORMAT_YUV411 "}, + {0x00000010, "VA_RT_FORMAT_YUV400 "}, + {0x00000100, "VA_RT_FORMAT_YUV420_10"}, + {0x00000200, "VA_RT_FORMAT_YUV422_10"}, + {0x00000400, "VA_RT_FORMAT_YUV444_10"}, + {0x00001000, "VA_RT_FORMAT_YUV420_12"}, + {0x00002000, "VA_RT_FORMAT_YUV422_12"}, + {0x00004000, "VA_RT_FORMAT_YUV444_12"}, + {0x00010000, "VA_RT_FORMAT_RGB16 "}, + {0x00020000, "VA_RT_FORMAT_RGB32 "}, + {0x00100000, "VA_RT_FORMAT_RGBP "}, + {0x00200000, "VA_RT_FORMAT_RGB32_10 "}, + {0x80000000, "VA_RT_FORMAT_PROTECTED"}}; + VAStatus va_status; + VAConfigAttrib attribs[1] = {0}; + int j, k; + + const size_t num_va_rt_formats = sizeof(va_rt_format_to_names_map) / + sizeof(va_rt_format_to_names_map[0]); + + for (j = 0; j < VAConfigAttribTypeMax; j++) { + attribs[0].type = (VAConfigAttribType)j; + va_status = vaGetConfigAttributes(va_dpy, profile, entrypoint, + attribs, 1); + if (va_status != VA_STATUS_SUCCESS) + continue; + if (attribs[0].value == VA_ATTRIB_NOT_SUPPORTED) + continue; + if (attribs[0].type != VAConfigAttribRTFormat) { + printf(" %-32s default value: %u\n", + vaConfigAttribTypeStr(j), attribs[0].value); + } else { + // VAConfigAttribRTFormat conveys a bitmask. + for (k = 0; k < num_va_rt_formats; k++) { + if (attribs[0].value & va_rt_format_to_names_map[k].bitmask) { + printf(" %-32s: %s\n", vaConfigAttribTypeStr(j), + va_rt_format_to_names_map[k].name); + } + } + } + } } int main(int argc, const char* argv[]) @@ -96,13 +158,14 @@ int main(int argc, const char* argv[]) VAEntrypoint entrypoint, *entrypoints = NULL; int num_entrypoint = 0; int ret_val = 0; - + char verbose = FALSE; + if (name) name++; else name = argv[0]; - parse_args(name, argc, (char **)argv); + parse_args(name, argc, (char **)argv, &verbose); va_dpy = va_open_display(); if (NULL == va_dpy) @@ -154,6 +217,10 @@ int main(int argc, const char* argv[]) printf(" %-32s: %s\n", vaProfileStr(profile), vaEntrypointStr(entrypoints[entrypoint])); + if (verbose == FALSE) + continue; + print_supported_config_attributes(va_dpy, profile, + entrypoints[entrypoint]); } }