From 887a34a2a401b51ee1e2e35e17c022066a70353d Mon Sep 17 00:00:00 2001 From: Miguel Casas Date: Wed, 20 Feb 2019 12:18:38 -0500 Subject: [PATCH 1/4] Add preliminary VAImageFormats info --- configure.ac | 2 +- vainfo/vainfo.c | 52 +++++++++++++++++++++++++++++++++++++------------ 2 files changed, 41 insertions(+), 13 deletions(-) diff --git a/configure.ac b/configure.ac index 9b64683b..5835c6a4 100644 --- a/configure.ac +++ b/configure.ac @@ -41,7 +41,7 @@ m4_append([libva_utils_version], libva_utils_pre_version, [.pre]) # libva minimum version requirement, at this released version # libva-utils was created -m4_define([libva_api_min_version], [1.1.0]) +m4_define([libva_api_min_version], [1.0.0]) # libdrm minimun version requirement m4_define([libdrm_version], [2.4]) diff --git a/vainfo/vainfo.c b/vainfo/vainfo.c index 148e617c..d9517378 100644 --- a/vainfo/vainfo.c +++ b/vainfo/vainfo.c @@ -8,11 +8,11 @@ * distribute, sub license, and/or sell copies of the Software, and to * permit persons to whom the Software is furnished to do so, subject to * the following conditions: - * + * * The above copyright notice and this permission notice (including the * next paragraph) shall be included in all copies or substantial portions * of the Software. - * + * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. @@ -90,13 +90,15 @@ int main(int argc, const char* argv[]) VAStatus va_status; int major_version, minor_version; const char *driver; - const char *name = strrchr(argv[0], '/'); + const char *name = strrchr(argv[0], '/'); VAProfile profile, *profile_list = NULL; int num_profiles, max_num_profiles, i; VAEntrypoint entrypoint, *entrypoints = NULL; int num_entrypoint = 0; int ret_val = 0; - + int num_image_formats, max_num_image_formats; + VAImageFormat image_format, *image_formats = NULL; + if (name) name++; else @@ -110,10 +112,10 @@ int main(int argc, const char* argv[]) fprintf(stderr, "%s: vaGetDisplay() failed\n", name); return 2; } - + va_status = vaInitialize(va_dpy, &major_version, &minor_version); - CHECK_VASTATUS(va_status, "vaInitialize", 3); - + //CHECK_VASTATUS(va_status, "vaInitialize", 3); + printf("%s: VA-API version: %d.%d (libva %s)\n", name, major_version, minor_version, LIBVA_VERSION_S); @@ -143,25 +145,51 @@ int main(int argc, const char* argv[]) for (i = 0; i < num_profiles; i++) { profile = profile_list[i]; - va_status = vaQueryConfigEntrypoints(va_dpy, profile, entrypoints, + va_status = vaQueryConfigEntrypoints(va_dpy, profile, entrypoints, &num_entrypoint); if (va_status == VA_STATUS_ERROR_UNSUPPORTED_PROFILE) - continue; + continue; CHECK_VASTATUS(va_status, "vaQueryConfigEntrypoints", 4); for (entrypoint = 0; entrypoint < num_entrypoint; entrypoint++) { - printf(" %-32s: %s\n", + printf(" %-32s: %s\n", vaProfileStr(profile), vaEntrypointStr(entrypoints[entrypoint])); } } - + + max_num_image_formats = vaMaxNumImageFormats(va_dpy); + image_formats = malloc(max_num_image_formats * sizeof(VAImageFormat)); + if (max_num_image_formats < 0) { + printf("Failed to allocate memory for image format list\n"); + ret_val = -1; + goto error; + } + + va_status = + vaQueryImageFormats(va_dpy, image_formats, &num_image_formats); + CHECK_VASTATUS(va_status, "vaQueryImageFormats failed", 6); + if (num_image_formats < 0 || num_image_formats > max_num_image_formats) + goto error; + + for (i = 0; i < num_image_formats; i++) { + image_format = image_formats[i]; + char fourcc_as_string[5] = {0}; + sprintf(fourcc_as_string, "%c%c%c%c", + (image_format.fourcc >> 24) & 0xFF, + (image_format.fourcc >> 16) & 0xFF, + (image_format.fourcc >> 8) & 0xFF, image_format.fourcc & 0xFF); + printf(" %s: %d\n", fourcc_as_string, image_format.bits_per_pixel); + } + + error: free(entrypoints); free(profile_list); + free(image_formats); vaTerminate(va_dpy); va_close_display(va_dpy); - + return ret_val; } From dc2c6c735a3bcafa434dd3bbc4ff9f51eb93fff3 Mon Sep 17 00:00:00 2001 From: Miguel Casas Date: Wed, 20 Feb 2019 15:50:47 -0500 Subject: [PATCH 2/4] Finished up vaGetConfigAttributes() and expanding the RT Format --- vainfo/vainfo.c | 110 +++++++++++++++++++++++++++++++++--------------- 1 file changed, 77 insertions(+), 33 deletions(-) diff --git a/vainfo/vainfo.c b/vainfo/vainfo.c index d9517378..2a69869c 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,90 @@ 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}; + VAConfigID va_config_id; + unsigned int num_attributes; + VASurfaceAttrib attribute, *attributes = NULL; + 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: %d\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[]) @@ -98,13 +163,14 @@ int main(int argc, const char* argv[]) int ret_val = 0; int num_image_formats, max_num_image_formats; VAImageFormat image_format, *image_formats = NULL; + 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) @@ -114,7 +180,7 @@ int main(int argc, const char* argv[]) } va_status = vaInitialize(va_dpy, &major_version, &minor_version); - //CHECK_VASTATUS(va_status, "vaInitialize", 3); + CHECK_VASTATUS(va_status, "vaInitialize", 3); printf("%s: VA-API version: %d.%d (libva %s)\n", name, major_version, minor_version, LIBVA_VERSION_S); @@ -156,38 +222,16 @@ 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]); } } - max_num_image_formats = vaMaxNumImageFormats(va_dpy); - image_formats = malloc(max_num_image_formats * sizeof(VAImageFormat)); - if (max_num_image_formats < 0) { - printf("Failed to allocate memory for image format list\n"); - ret_val = -1; - goto error; - } - - va_status = - vaQueryImageFormats(va_dpy, image_formats, &num_image_formats); - CHECK_VASTATUS(va_status, "vaQueryImageFormats failed", 6); - if (num_image_formats < 0 || num_image_formats > max_num_image_formats) - goto error; - - for (i = 0; i < num_image_formats; i++) { - image_format = image_formats[i]; - char fourcc_as_string[5] = {0}; - sprintf(fourcc_as_string, "%c%c%c%c", - (image_format.fourcc >> 24) & 0xFF, - (image_format.fourcc >> 16) & 0xFF, - (image_format.fourcc >> 8) & 0xFF, image_format.fourcc & 0xFF); - printf(" %s: %d\n", fourcc_as_string, image_format.bits_per_pixel); - } - - error: free(entrypoints); free(profile_list); - free(image_formats); vaTerminate(va_dpy); va_close_display(va_dpy); From 099af33904642c7e0e2bb2547e530d884eea95c4 Mon Sep 17 00:00:00 2001 From: Miguel Casas Date: Wed, 20 Feb 2019 15:52:27 -0500 Subject: [PATCH 3/4] Restored whitespaces to minimize changes --- configure.ac | 2 +- vainfo/vainfo.c | 22 ++++++++++------------ 2 files changed, 11 insertions(+), 13 deletions(-) diff --git a/configure.ac b/configure.ac index 5835c6a4..9b64683b 100644 --- a/configure.ac +++ b/configure.ac @@ -41,7 +41,7 @@ m4_append([libva_utils_version], libva_utils_pre_version, [.pre]) # libva minimum version requirement, at this released version # libva-utils was created -m4_define([libva_api_min_version], [1.0.0]) +m4_define([libva_api_min_version], [1.1.0]) # libdrm minimun version requirement m4_define([libdrm_version], [2.4]) diff --git a/vainfo/vainfo.c b/vainfo/vainfo.c index 2a69869c..5fec065f 100644 --- a/vainfo/vainfo.c +++ b/vainfo/vainfo.c @@ -8,11 +8,11 @@ * distribute, sub license, and/or sell copies of the Software, and to * permit persons to whom the Software is furnished to do so, subject to * the following conditions: - * + * * The above copyright notice and this permission notice (including the * next paragraph) shall be included in all copies or substantial portions * of the Software. - * + * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. @@ -155,14 +155,12 @@ int main(int argc, const char* argv[]) VAStatus va_status; int major_version, minor_version; const char *driver; - const char *name = strrchr(argv[0], '/'); + const char *name = strrchr(argv[0], '/'); VAProfile profile, *profile_list = NULL; int num_profiles, max_num_profiles, i; VAEntrypoint entrypoint, *entrypoints = NULL; int num_entrypoint = 0; int ret_val = 0; - int num_image_formats, max_num_image_formats; - VAImageFormat image_format, *image_formats = NULL; char verbose = FALSE; if (name) @@ -178,10 +176,10 @@ int main(int argc, const char* argv[]) fprintf(stderr, "%s: vaGetDisplay() failed\n", name); return 2; } - + va_status = vaInitialize(va_dpy, &major_version, &minor_version); CHECK_VASTATUS(va_status, "vaInitialize", 3); - + printf("%s: VA-API version: %d.%d (libva %s)\n", name, major_version, minor_version, LIBVA_VERSION_S); @@ -211,15 +209,15 @@ int main(int argc, const char* argv[]) for (i = 0; i < num_profiles; i++) { profile = profile_list[i]; - va_status = vaQueryConfigEntrypoints(va_dpy, profile, entrypoints, + va_status = vaQueryConfigEntrypoints(va_dpy, profile, entrypoints, &num_entrypoint); if (va_status == VA_STATUS_ERROR_UNSUPPORTED_PROFILE) - continue; + continue; CHECK_VASTATUS(va_status, "vaQueryConfigEntrypoints", 4); for (entrypoint = 0; entrypoint < num_entrypoint; entrypoint++) { - printf(" %-32s: %s\n", + printf(" %-32s: %s\n", vaProfileStr(profile), vaEntrypointStr(entrypoints[entrypoint])); if (verbose == FALSE) @@ -228,12 +226,12 @@ int main(int argc, const char* argv[]) entrypoints[entrypoint]); } } - + error: free(entrypoints); free(profile_list); vaTerminate(va_dpy); va_close_display(va_dpy); - + return ret_val; } From 769e91c39723647395261a653b9b6f048bbd25b4 Mon Sep 17 00:00:00 2001 From: Miguel Casas Date: Wed, 20 Feb 2019 15:58:39 -0500 Subject: [PATCH 4/4] Removed unused variables and printing |value| as unsigned --- vainfo/vainfo.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/vainfo/vainfo.c b/vainfo/vainfo.c index 5fec065f..e6f0b321 100644 --- a/vainfo/vainfo.c +++ b/vainfo/vainfo.c @@ -118,9 +118,6 @@ void print_supported_config_attributes(VADisplay va_dpy, {0x80000000, "VA_RT_FORMAT_PROTECTED"}}; VAStatus va_status; VAConfigAttrib attribs[1] = {0}; - VAConfigID va_config_id; - unsigned int num_attributes; - VASurfaceAttrib attribute, *attributes = NULL; int j, k; const size_t num_va_rt_formats = sizeof(va_rt_format_to_names_map) / @@ -135,7 +132,7 @@ void print_supported_config_attributes(VADisplay va_dpy, if (attribs[0].value == VA_ATTRIB_NOT_SUPPORTED) continue; if (attribs[0].type != VAConfigAttribRTFormat) { - printf(" %-32s default value: %d\n", + printf(" %-32s default value: %u\n", vaConfigAttribTypeStr(j), attribs[0].value); } else { // VAConfigAttribRTFormat conveys a bitmask.