On some systems there is no access to /proc/cpuinfo. So the inline assembly is used directly to detect the CPUID string.
V1->V2: Based on the Matt Turner's suggestion the __cpuid defined in GCC cpuid.h is called directly, which is helpful to handle the PIC issue on 32-bit. Signed-off-by: Zhao Yakui <[email protected]> --- src/i965_device_info.c | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/src/i965_device_info.c b/src/i965_device_info.c index 5ebea2a..fa99803 100755 --- a/src/i965_device_info.c +++ b/src/i965_device_info.c @@ -30,6 +30,7 @@ #include <string.h> #include <strings.h> #include <errno.h> +#include <cpuid.h> /* Extra set of chroma formats supported for H.264 decoding (beyond YUV 4:2:0) */ #define EXTRA_H264_DEC_CHROMA_FORMATS \ @@ -378,6 +379,7 @@ i965_get_device_info(int devid) } } +#if 0 static int intel_driver_detect_cpustring(char *model_id) { FILE *fp; @@ -416,7 +418,43 @@ static int intel_driver_detect_cpustring(char *model_id) else return -EINVAL; } +#else +static void cpuid(unsigned int op, + unsigned int *eax, unsigned int *ebx, + unsigned int *ecx, unsigned int *edx) +{ + __cpuid_count(op, 0, *eax, *ebx, *ecx, *edx); +} + +/* + * This function doesn't check the length. And the caller should + * assure that the length of input string should be greater than 48. + */ +static int intel_driver_detect_cpustring(char *model_id) +{ + unsigned int *rdata; + if (model_id == NULL) + return -EINVAL; + + rdata = (unsigned int *)model_id; + + /* obtain the max supported extended CPUID info */ + cpuid(0x80000000, &rdata[0], &rdata[1], &rdata[2], &rdata[3]); + + /* If the max extended CPUID info is less than 0x80000004, fail */ + if (rdata[0] < 0x80000004) + return -EINVAL; + + /* obtain the CPUID string */ + cpuid(0x80000002, &rdata[0], &rdata[1], &rdata[2], &rdata[3]); + cpuid(0x80000003, &rdata[4], &rdata[5], &rdata[6], &rdata[7]); + cpuid(0x80000004, &rdata[8], &rdata[9], &rdata[10], &rdata[11]); + + *(model_id + 48) = '\0'; + return 0; +} +#endif /* * the hook_list for HSW. * It is captured by /proc/cpuinfo and the space character is stripped. -- 1.7.10.1 _______________________________________________ Libva mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/libva
