Changeset 54571 in vbox for trunk/src/VBox
- Timestamp:
- Mar 1, 2015 2:00:56 AM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Graphics/testcase/dump-vmwgfx.c
r54569 r54571 20 20 * Header Files * 21 21 *******************************************************************************/ 22 #include <stdio.h> 23 #include <string.h> 24 #include <stdint.h> 22 #include <assert.h> 23 #include <dirent.h> 25 24 #include <errno.h> 26 25 #include <fcntl.h> 26 #include <stdio.h> 27 #include <stdint.h> 27 28 #include <stdlib.h> 29 #include <string.h> 28 30 #include <sys/ioctl.h> 31 #include <sys/mman.h> 32 #include <sys/stat.h> 33 #include <unistd.h> 34 29 35 30 36 /******************************************************************************* … … 52 58 #define DRM_VMW_PARAM_MAX_MOB_SIZE 10 53 59 60 54 61 /******************************************************************************* 55 62 * Structures and Typedefs * … … 84 91 85 92 93 typedef struct FLAGDESC 94 { 95 uint32_t fMask; 96 const char *pszName; 97 } FLAGDESC; 98 typedef FLAGDESC const *PCFLAGDESC; 99 100 101 /******************************************************************************* 102 * Global Variables * 103 *******************************************************************************/ 104 /** The size of the 3D capabilities. */ 105 static uint32_t g_cb3dCaps; 106 /** Set if the driver will return the new 3D capability format. */ 107 static int g_fNew3dCapFormat = 0; 108 /** The SVGA_CAP_XXX mask for the card. */ 109 static uint64_t g_fHwCaps = 0; 110 111 /** Names for the vmsvga 3d capabilities, prefixed with format type hint char. (Copied from DevSVGA.cpp.) */ 112 static const char * const g_apszVmSvgaDevCapNames[] = 113 { 114 "x3D", /* = 0 */ 115 "xMAX_LIGHTS", 116 "xMAX_TEXTURES", 117 "xMAX_CLIP_PLANES", 118 "xVERTEX_SHADER_VERSION", 119 "xVERTEX_SHADER", 120 "xFRAGMENT_SHADER_VERSION", 121 "xFRAGMENT_SHADER", 122 "xMAX_RENDER_TARGETS", 123 "xS23E8_TEXTURES", 124 "xS10E5_TEXTURES", 125 "xMAX_FIXED_VERTEXBLEND", 126 "xD16_BUFFER_FORMAT", 127 "xD24S8_BUFFER_FORMAT", 128 "xD24X8_BUFFER_FORMAT", 129 "xQUERY_TYPES", 130 "xTEXTURE_GRADIENT_SAMPLING", 131 "rMAX_POINT_SIZE", 132 "xMAX_SHADER_TEXTURES", 133 "xMAX_TEXTURE_WIDTH", 134 "xMAX_TEXTURE_HEIGHT", 135 "xMAX_VOLUME_EXTENT", 136 "xMAX_TEXTURE_REPEAT", 137 "xMAX_TEXTURE_ASPECT_RATIO", 138 "xMAX_TEXTURE_ANISOTROPY", 139 "xMAX_PRIMITIVE_COUNT", 140 "xMAX_VERTEX_INDEX", 141 "xMAX_VERTEX_SHADER_INSTRUCTIONS", 142 "xMAX_FRAGMENT_SHADER_INSTRUCTIONS", 143 "xMAX_VERTEX_SHADER_TEMPS", 144 "xMAX_FRAGMENT_SHADER_TEMPS", 145 "xTEXTURE_OPS", 146 "xSURFACEFMT_X8R8G8B8", 147 "xSURFACEFMT_A8R8G8B8", 148 "xSURFACEFMT_A2R10G10B10", 149 "xSURFACEFMT_X1R5G5B5", 150 "xSURFACEFMT_A1R5G5B5", 151 "xSURFACEFMT_A4R4G4B4", 152 "xSURFACEFMT_R5G6B5", 153 "xSURFACEFMT_LUMINANCE16", 154 "xSURFACEFMT_LUMINANCE8_ALPHA8", 155 "xSURFACEFMT_ALPHA8", 156 "xSURFACEFMT_LUMINANCE8", 157 "xSURFACEFMT_Z_D16", 158 "xSURFACEFMT_Z_D24S8", 159 "xSURFACEFMT_Z_D24X8", 160 "xSURFACEFMT_DXT1", 161 "xSURFACEFMT_DXT2", 162 "xSURFACEFMT_DXT3", 163 "xSURFACEFMT_DXT4", 164 "xSURFACEFMT_DXT5", 165 "xSURFACEFMT_BUMPX8L8V8U8", 166 "xSURFACEFMT_A2W10V10U10", 167 "xSURFACEFMT_BUMPU8V8", 168 "xSURFACEFMT_Q8W8V8U8", 169 "xSURFACEFMT_CxV8U8", 170 "xSURFACEFMT_R_S10E5", 171 "xSURFACEFMT_R_S23E8", 172 "xSURFACEFMT_RG_S10E5", 173 "xSURFACEFMT_RG_S23E8", 174 "xSURFACEFMT_ARGB_S10E5", 175 "xSURFACEFMT_ARGB_S23E8", 176 "xMISSING62", 177 "xMAX_VERTEX_SHADER_TEXTURES", 178 "xMAX_SIMULTANEOUS_RENDER_TARGETS", 179 "xSURFACEFMT_V16U16", 180 "xSURFACEFMT_G16R16", 181 "xSURFACEFMT_A16B16G16R16", 182 "xSURFACEFMT_UYVY", 183 "xSURFACEFMT_YUY2", 184 "xMULTISAMPLE_NONMASKABLESAMPLES", 185 "xMULTISAMPLE_MASKABLESAMPLES", 186 "xALPHATOCOVERAGE", 187 "xSUPERSAMPLE", 188 "xAUTOGENMIPMAPS", 189 "xSURFACEFMT_NV12", 190 "xSURFACEFMT_AYUV", 191 "xMAX_CONTEXT_IDS", 192 "xMAX_SURFACE_IDS", 193 "xSURFACEFMT_Z_DF16", 194 "xSURFACEFMT_Z_DF24", 195 "xSURFACEFMT_Z_D24S8_INT", 196 "xSURFACEFMT_BC4_UNORM", 197 "xSURFACEFMT_BC5_UNORM", /* 83 */ 198 "xVGPU10", 199 "xVIDEO_DECODE", 200 "xVIDEO_PROCESS", 201 "xLINE_AA", 202 "xLINE_STRIPPLE", 203 "fMAX_LINE_WIDTH", 204 "fMAX_AA_LINE_WIDTH", /* 90 */ 205 "xSURFACEFMT_YV12", 206 "xLOGICOPS", 207 "xSCREENTARGETS", 208 "xTS_COLOR_KEY", 209 "xDX", /* 95 */ 210 }; 211 212 /** SVGA_CAP flag descriptors. */ 213 static FLAGDESC const g_aVmSvgaCapFlags[] = 214 { 215 { UINT32_C(0x00000001), "unknown-bit-0" }, 216 { UINT32_C(0x00000002), "SVGA_CAP_RECT_COPY" }, 217 { UINT32_C(0x00000004), "unknown-bit-2" }, 218 { UINT32_C(0x00000008), "unknown-bit-3" }, 219 { UINT32_C(0x00000010), "unknown-bit-4" }, 220 { UINT32_C(0x00000020), "SVGA_CAP_CURSOR" }, 221 { UINT32_C(0x00000040), "SVGA_CAP_CURSOR_BYPASS" }, 222 { UINT32_C(0x00000080), "SVGA_CAP_CURSOR_BYPASS_2" }, 223 { UINT32_C(0x00000100), "SVGA_CAP_8BIT_EMULATION" }, 224 { UINT32_C(0x00000200), "SVGA_CAP_ALPHA_CURSOR" }, 225 { UINT32_C(0x00000400), "unknown-bit-10" }, 226 { UINT32_C(0x00000800), "unknown-bit-11" }, 227 { UINT32_C(0x00001000), "unknown-bit-12" }, 228 { UINT32_C(0x00002000), "unknown-bit-13" }, 229 { UINT32_C(0x00004000), "SVGA_CAP_3D" }, 230 { UINT32_C(0x00008000), "SVGA_CAP_EXTENDED_FIFO" }, 231 { UINT32_C(0x00010000), "SVGA_CAP_MULTIMON" }, 232 { UINT32_C(0x00020000), "SVGA_CAP_PITCHLOCK" }, 233 { UINT32_C(0x00040000), "SVGA_CAP_IRQMASK" }, 234 { UINT32_C(0x00080000), "SVGA_CAP_DISPLAY_TOPOLOGY" }, 235 { UINT32_C(0x00100000), "SVGA_CAP_GMR" }, 236 { UINT32_C(0x00200000), "SVGA_CAP_TRACES" }, 237 { UINT32_C(0x00400000), "SVGA_CAP_GMR2" }, 238 { UINT32_C(0x00800000), "SVGA_CAP_SCREEN_OBJECT_2" }, 239 { UINT32_C(0x01000000), "SVGA_CAP_COMMAND_BUFFERS" }, 240 { UINT32_C(0x02000000), "SVGA_CAP_DEAD1" }, 241 { UINT32_C(0x04000000), "SVGA_CAP_CMD_BUFFERS_2" }, 242 { UINT32_C(0x08000000), "SVGA_CAP_GBOBJECTS" }, 243 { UINT32_C(0x10000000), "unknown-bit-28" }, 244 { UINT32_C(0x20000000), "unknown-bit-29" }, 245 { UINT32_C(0x40000000), "unknown-bit-30" }, 246 { UINT32_C(0x80000000), "unknown-bit-31" }, 247 }; 248 249 /** SVGA_FIFO_CAP flag descriptors. */ 250 static FLAGDESC const g_aVmSvgaFifoCapFlags[] = 251 { 252 { UINT32_C(0x00000001), "SVGA_FIFO_CAP_FENCE" }, 253 { UINT32_C(0x00000002), "SVGA_FIFO_CAP_ACCELFRONT" }, 254 { UINT32_C(0x00000004), "SVGA_FIFO_CAP_PITCHLOCK" }, 255 { UINT32_C(0x00000008), "SVGA_FIFO_CAP_VIDEO" }, 256 { UINT32_C(0x00000010), "SVGA_FIFO_CAP_CURSOR_BYPASS_3" }, 257 { UINT32_C(0x00000020), "SVGA_FIFO_CAP_ESCAPE" }, 258 { UINT32_C(0x00000040), "SVGA_FIFO_CAP_RESERVE" }, 259 { UINT32_C(0x00000080), "SVGA_FIFO_CAP_SCREEN_OBJECT" }, 260 { UINT32_C(0x00000100), "SVGA_FIFO_CAP_GMR2/SVGA_FIFO_CAP_3D_HWVERSION_REVISED" }, 261 { UINT32_C(0x00000200), "SVGA_FIFO_CAP_SCREEN_OBJECT_2" }, 262 { UINT32_C(0x00000400), "SVGA_FIFO_CAP_DEAD" }, 263 { UINT32_C(0x00000800), "unknown-bit-11" }, 264 { UINT32_C(0x00001000), "unknown-bit-12" }, 265 { UINT32_C(0x00002000), "unknown-bit-13" }, 266 { UINT32_C(0x00004000), "unknown-bit-14" }, 267 { UINT32_C(0x00008000), "unknown-bit-15" }, 268 { UINT32_C(0x00010000), "unknown-bit-16" }, 269 { UINT32_C(0x00020000), "unknown-bit-17" }, 270 { UINT32_C(0x00040000), "unknown-bit-18" }, 271 { UINT32_C(0x00080000), "unknown-bit-19" }, 272 { UINT32_C(0x00100000), "unknown-bit-20" }, 273 { UINT32_C(0x00200000), "unknown-bit-21" }, 274 { UINT32_C(0x00400000), "unknown-bit-22" }, 275 { UINT32_C(0x00800000), "unknown-bit-23" }, 276 { UINT32_C(0x01000000), "unknown-bit-24" }, 277 { UINT32_C(0x02000000), "unknown-bit-25" }, 278 { UINT32_C(0x04000000), "unknown-bit-26" }, 279 { UINT32_C(0x08000000), "unknown-bit-27" }, 280 { UINT32_C(0x10000000), "unknown-bit-28" }, 281 { UINT32_C(0x20000000), "unknown-bit-29" }, 282 { UINT32_C(0x40000000), "unknown-bit-30" }, 283 { UINT32_C(0x80000000), "unknown-bit-31" }, 284 }; 285 286 287 static void DisplayFlags(PCFLAGDESC paFlagDescs, uint32_t fFlags, unsigned cchIndent) 288 { 289 uint32_t i; 290 for (i = 0; i < 32; i++) 291 { 292 assert(paFlagDescs[i].fMask == (UINT32_C(1) << i)); 293 if (paFlagDescs[i].fMask & fFlags) 294 printf("%*s%s\n", cchIndent, "", paFlagDescs[i].pszName); 295 } 296 } 297 298 86 299 static int QueryParam(int fd, uint32_t uParam, const char *pszParam) 87 300 { 88 struct drm_vmw_getparam_arg Arg = { 0, uParam, 0 }; 89 int rc = ioctl(fd, DRM_IOCTL_VMW_GET_PARAM, &Arg); 301 struct drm_vmw_getparam_arg Arg; 302 int rc; 303 304 Arg.value = 0; 305 Arg.param = uParam; 306 Arg.pad64 = 0; 307 rc = ioctl(fd, DRM_IOCTL_VMW_GET_PARAM, &Arg); 90 308 if (rc >= 0) 91 printf("%32s: %#llx (%lld)\n", pszParam, Arg.value, Arg.value); 309 { 310 switch (uParam) 311 { 312 case DRM_VMW_PARAM_3D: 313 printf("%30s: %#llx -- enabled: %s\n", pszParam, Arg.value, 314 Arg.value == 0 ? "no" : Arg.value == 1 ? "yes" : "huh?"); 315 break; 316 317 case DRM_VMW_PARAM_FIFO_HW_VERSION: 318 printf("%30s: %#llx -- major=%llu minor=%llu\n", pszParam, Arg.value, Arg.value >> 16, Arg.value & 0xffff); 319 break; 320 321 case DRM_VMW_PARAM_HW_CAPS: 322 printf("%30s: %#llx\n", pszParam, Arg.value); 323 DisplayFlags(g_aVmSvgaCapFlags, (uint32_t)Arg.value, 32); 324 g_fHwCaps = Arg.value; 325 break; 326 327 case DRM_VMW_PARAM_FIFO_CAPS: 328 printf("%30s: %#llx\n", pszParam, Arg.value); 329 DisplayFlags(g_aVmSvgaFifoCapFlags, (uint32_t)Arg.value, 32); 330 break; 331 332 case DRM_VMW_PARAM_3D_CAP_SIZE: 333 printf("%30s: %#llx (%lld) [bytes]\n", pszParam, Arg.value, Arg.value); 334 g_cb3dCaps = (uint32_t)Arg.value; 335 break; 336 337 default: 338 printf("%30s: %#llx (%lld)\n", pszParam, Arg.value, Arg.value); 339 break; 340 } 341 } 92 342 else 93 343 printf("%32s: failed: rc=%d errno=%d (%s)\n", pszParam, rc, errno, strerror(errno)); … … 96 346 97 347 348 static int Dump3DParameters(int fd, int rcExit) 349 { 350 int rc; 351 printf("\n**** vmwgfx parameters *****\n"); 352 #define QUERY_PARAM(nm) QueryParam(fd, nm, #nm) 353 rc = QUERY_PARAM(DRM_VMW_PARAM_HW_CAPS); 354 if (rc < 0) 355 rcExit = 1; 356 QUERY_PARAM(DRM_VMW_PARAM_FIFO_CAPS); 357 QUERY_PARAM(DRM_VMW_PARAM_FIFO_HW_VERSION); 358 QUERY_PARAM(DRM_VMW_PARAM_3D); 359 QUERY_PARAM(DRM_VMW_PARAM_NUM_STREAMS); 360 QUERY_PARAM(DRM_VMW_PARAM_FREE_STREAMS); 361 QUERY_PARAM(DRM_VMW_PARAM_MAX_FB_SIZE); 362 QUERY_PARAM(DRM_VMW_PARAM_MAX_SURF_MEMORY); 363 QUERY_PARAM(DRM_VMW_PARAM_3D_CAP_SIZE); 364 rc = QUERY_PARAM(DRM_VMW_PARAM_MAX_MOB_MEMORY); 365 if (rc >= 0) 366 g_fNew3dCapFormat = g_fHwCaps & UINT32_C(0x08000000) /*SVGA_CAP_GBOBJECTS */; 367 QUERY_PARAM(DRM_VMW_PARAM_MAX_MOB_SIZE); 368 return rcExit; 369 } 370 371 372 static void PrintOne3DCapability(uint32_t iCap, uint32_t uValue) 373 { 374 union 375 { 376 float rValue; 377 uint32_t u32Value; 378 } u; 379 u.u32Value = uValue; 380 if (iCap < sizeof(g_apszVmSvgaDevCapNames) / sizeof(g_apszVmSvgaDevCapNames[0])) 381 { 382 const char *pszName = g_apszVmSvgaDevCapNames[iCap]; 383 if (pszName[0] == 'x') 384 printf(" cap[%u]=%#010x {%s}\n", iCap, u.u32Value, pszName + 1); 385 else 386 printf(" cap[%u]=%d.%04u {%s}\n", iCap, (int)u.rValue, (unsigned)(u.rValue * 1000) % 10000, pszName + 1); 387 } 388 else 389 printf(" cap[%u]=%#010x\n", iCap, u.u32Value); 390 } 391 392 393 static void DumpOld3dCapabilityRecords(struct SVGA3dCapsRecord *pCur) 394 { 395 for (;;) 396 { 397 printf(" SVGA3dCapsRecordHeader: length=%#x (%d) type=%d\n", 398 pCur->header.length, pCur->header.length, pCur->header.type); 399 if (pCur->header.length == 0) 400 break; 401 402 uint32_t i; 403 for (i = 0; i < pCur->header.length - 2; i += 2) 404 PrintOne3DCapability(pCur->data[i], pCur->data[i + 1]); 405 pCur = (struct SVGA3dCapsRecord *)((uint32_t *)pCur + pCur->header.length); 406 } 407 } 408 409 410 static int Dump3DCapabilities(int fd, int rcExit) 411 { 412 struct SVGA3dCapsRecord *pBuf; 413 struct drm_vmw_get_3d_cap_arg Caps3D; 414 int rc; 415 416 417 printf("\n**** 3D capabilities *****\n"); 418 Caps3D.pad64 = 0; 419 Caps3D.max_size = 1024 * sizeof(uint32_t); 420 pBuf = (struct SVGA3dCapsRecord *)calloc(Caps3D.max_size, 1); 421 Caps3D.buffer = (uintptr_t)pBuf; 422 423 errno = 0; 424 rc = ioctl(fd, DRM_IOCTL_VMW_GET_3D_CAP, &Caps3D); 425 if (rc >= 0) 426 { 427 printf("DRM_IOCTL_VMW_GET_3D_CAP: rc=%d\n", rc); 428 if (!g_fNew3dCapFormat) 429 DumpOld3dCapabilityRecords(pBuf); 430 else 431 { 432 uint32_t const *pau32Data = (uint32_t const *)pBuf; 433 uint32_t cCaps = g_cb3dCaps / sizeof(uint32_t); 434 uint32_t iCap; 435 for (iCap = 0; iCap < cCaps; iCap++) 436 PrintOne3DCapability(iCap, pau32Data[iCap]); 437 } 438 } 439 else 440 { 441 fprintf(stderr, "DRM_IOCTL_VMW_GET_3D_CAP failed: %d - %s\n", errno, strerror(errno)); 442 rcExit = 1; 443 } 444 445 free(pBuf); 446 return rcExit; 447 } 448 449 450 static int FindAndMapFifo(uint32_t const **ppau32Fifo, uint32_t *pcbFifo, int rcExit) 451 { 452 const char g_szDir[] = "/sys/bus/pci/devices"; 453 DIR *pDir = opendir(g_szDir); 454 if (pDir) 455 { 456 struct dirent *pEntry; 457 char szPath[4096]; 458 size_t offPath = sizeof(g_szDir); 459 memcpy(szPath, g_szDir, sizeof(g_szDir)); 460 szPath[offPath - 1] = '/'; 461 462 while ((pEntry = readdir(pDir)) != NULL) 463 { 464 struct stat st; 465 size_t cchName = strlen(pEntry->d_name); 466 memcpy(&szPath[offPath], pEntry->d_name, cchName); 467 strcpy(&szPath[offPath + cchName], "/boot_vga"); 468 if (stat(szPath, &st) >= 0) 469 { 470 /* Found something that looks like the VGA device. Try map resource2. */ 471 strcpy(&szPath[offPath + cchName], "/resource2"); 472 if (stat(szPath, &st) >= 0) 473 { 474 int fdFifo = open(szPath, O_RDONLY); 475 if (fdFifo >= 0) 476 { 477 *pcbFifo = (uint32_t)st.st_size; 478 *ppau32Fifo = (uint32_t *)mmap(NULL, *pcbFifo, PROT_READ, MAP_SHARED | MAP_FILE, fdFifo, 0); 479 if (*ppau32Fifo != MAP_FAILED) 480 { 481 printf("info: Mapped %s at %p LB %#x\n", szPath, *ppau32Fifo, *pcbFifo); 482 close(fdFifo); 483 closedir(pDir); 484 return rcExit; 485 } 486 487 fprintf(stderr, "error: failed to mmap '%s': %d (%s)\n", szPath, errno, strerror(errno)); 488 close(fdFifo); 489 } 490 else 491 fprintf(stderr, "error: failed to open '%s': %d (%s)\n", g_szDir, errno, strerror(errno)); 492 } 493 else 494 fprintf(stderr, "error: boot_vga devices doesn't have '%s'. (%d [%s])\n", szPath, errno, strerror(errno)); 495 } 496 } /* for each directory entry */ 497 498 closedir(pDir); 499 } 500 else 501 fprintf(stderr, "error: failed to open '%s': %d (%s)\n", g_szDir, errno, strerror(errno)); 502 return 1; 503 } 504 505 506 static int DumpFifoStuff(uint32_t const *pau32Fifo, uint32_t cbFifo, int rcExit) 507 { 508 uint32_t cMax = cbFifo / sizeof(uint32_t); 509 uint32_t i, iMin, iMax; 510 511 printf("\n***** FIFO - %u bytes (%#x) *****\n", cbFifo, cbFifo); 512 if (cMax >= 4) 513 { 514 iMin = pau32Fifo[0] / sizeof(uint32_t); 515 printf(" FIFO_MIN: %#09x -- iMin=%#08x\n", pau32Fifo[0], iMin); 516 iMax = pau32Fifo[1] / sizeof(uint32_t); 517 printf(" FIFO_MAX: %#09x -- iMax=%#08x\n", pau32Fifo[1], iMax); 518 printf(" FIFO_NEXT_CMD: %#09x -- iNextCmd=%#08x\n", pau32Fifo[2], (uint32_t)(pau32Fifo[2] / sizeof(uint32_t))); 519 printf(" FIFO_STOP: %#09x -- iStop=%#08x\n", pau32Fifo[3], (uint32_t)(pau32Fifo[3] / sizeof(uint32_t))); 520 } 521 else 522 { 523 fprintf(stderr, "error: cbFifo=%#x is too small\n", cbFifo); 524 return 1; 525 } 526 if (iMin > 4) 527 { 528 printf(" FIFO_CAPABILITIES: %#x (%d)\n", pau32Fifo[4], pau32Fifo[4]); 529 DisplayFlags(g_aVmSvgaFifoCapFlags, pau32Fifo[4], 28); 530 } 531 if (iMin > 5) 532 printf(" FIFO_FLAGS: %#x (%d)\n", pau32Fifo[5], pau32Fifo[5]); 533 if (iMin > 6) 534 printf(" FIFO_FENCE: %#x (%d)\n", pau32Fifo[6], pau32Fifo[6]); 535 if (iMin > 7) 536 printf(" FIFO_3D_VERSION: %#x -- %u.%u\n", pau32Fifo[7], pau32Fifo[7] >> 16, pau32Fifo[7] & 0xffff); 537 if (iMin > 8) 538 printf(" FIFO_PITCH_LOCK: %#x (%d)\n", pau32Fifo[8], pau32Fifo[8]); 539 if (iMin > 9) 540 printf(" FIFO_CURSOR_ON: %#x (%d)\n", pau32Fifo[9], pau32Fifo[9]); 541 if (iMin > 10) 542 printf(" FIFO_CURSOR_X: %#x (%d)\n", pau32Fifo[10], pau32Fifo[10]); 543 if (iMin > 11) 544 printf(" FIFO_CURSOR_Y: %#x (%d)\n", pau32Fifo[11], pau32Fifo[11]); 545 if (iMin > 12) 546 printf(" FIFO_CURSOR_COUNT: %#x (%d)\n", pau32Fifo[12], pau32Fifo[12]); 547 if (iMin > 13) 548 printf(" FIFO_CURSOR_LAST_UPDATED: %#x (%d)\n", pau32Fifo[13], pau32Fifo[13]); 549 if (iMin > 14) 550 printf(" FIFO_RESERVED: %#x (%d)\n", pau32Fifo[14], pau32Fifo[14]); 551 if (iMin > 15) 552 printf(" FIFO_CURSOR_SCREEN_ID: %#x (%d)\n", pau32Fifo[15], pau32Fifo[15]); 553 if (iMin > 16) 554 printf(" FIFO_DEAD: %#x (%d)\n", pau32Fifo[16], pau32Fifo[16]); 555 if (iMin > 17) 556 printf("FIFO_3D_HWVERSION_REVISED: %#x -- %u.%u\n", pau32Fifo[17], pau32Fifo[17] >> 16, pau32Fifo[7] & 0xffff); 557 558 for (i = 18; i < 32 && i < iMin; i++) 559 if (pau32Fifo[i] != 0) 560 printf("FIFO_UNKNOWN_%u: %#x (%d)\n", i, pau32Fifo[i], pau32Fifo[i]); 561 562 if (iMin >= 32+64) 563 { 564 if (pau32Fifo[32]) 565 { 566 printf(" FIFO_3D_CAPS:\n"); 567 DumpOld3dCapabilityRecords((struct SVGA3dCapsRecord *)&pau32Fifo[32]); 568 } 569 else 570 printf("warning: 3D capabilities not present?\n"); 571 } 572 573 574 if (iMin > 288) 575 printf(" FIFO_GUEST_3D_HWVERSION: %#x -- %u.%u\n", pau32Fifo[288], pau32Fifo[288] >> 16, pau32Fifo[288] & 0xffff); 576 if (iMin > 289) 577 printf(" FIFO_FENCE_GOAL: %#x (%d)\n", pau32Fifo[289], pau32Fifo[289]); 578 if (iMin > 290) 579 printf(" FIFO_BUSY: %#x (%d)\n", pau32Fifo[290], pau32Fifo[290]); 580 581 for (i = 291; i < iMin; i++) 582 if (pau32Fifo[i] != 0) 583 printf("FIFO_UNKNOWN_%u: %#x (%d)\n", i, pau32Fifo[i], pau32Fifo[i]); 584 585 return rcExit; 586 } 587 588 589 590 591 98 592 int main(int argc, char **argv) 99 593 { 100 int rcExit = 1;594 int rcExit = 0; 101 595 const char *pszDev = "/dev/dri/card0"; 102 596 if (argc == 2) … … 106 600 if (fd != -1) 107 601 { 602 uint32_t const *pau32Fifo = NULL; 603 uint32_t cbFifo = 0; 604 108 605 /* 109 606 * Parameters. 110 607 */ 111 #define QUERY_PARAM(nm) QueryParam(fd, nm, #nm) 112 QUERY_PARAM(DRM_VMW_PARAM_NUM_STREAMS); 113 QUERY_PARAM(DRM_VMW_PARAM_FREE_STREAMS); 114 QUERY_PARAM(DRM_VMW_PARAM_3D); 115 QUERY_PARAM(DRM_VMW_PARAM_HW_CAPS); 116 QUERY_PARAM(DRM_VMW_PARAM_FIFO_CAPS); 117 QUERY_PARAM(DRM_VMW_PARAM_MAX_FB_SIZE); 118 QUERY_PARAM(DRM_VMW_PARAM_FIFO_HW_VERSION); 119 QUERY_PARAM(DRM_VMW_PARAM_MAX_SURF_MEMORY); 120 QUERY_PARAM(DRM_VMW_PARAM_3D_CAP_SIZE); 121 /*QUERY_PARAM(DRM_VMW_PARAM_MAX_MOB_MEMORY); -- changes 3d cap on success. */ 122 QUERY_PARAM(DRM_VMW_PARAM_MAX_MOB_SIZE); 608 rcExit = Dump3DParameters(fd, rcExit); 123 609 124 610 /* 125 611 * 3D capabilities. 126 612 */ 127 struct SVGA3dCapsRecord *pBuf = (struct SVGA3dCapsRecord *)calloc(1024, sizeof(uint32_t)); 128 struct drm_vmw_get_3d_cap_arg Caps3D = { (uintptr_t)pBuf, 1024 * sizeof(uint32_t), 0 }; 129 errno = 0; 130 int rc = ioctl(fd, DRM_IOCTL_VMW_GET_3D_CAP, &Caps3D); 131 if (rc >= 0) 132 { 133 struct SVGA3dCapsRecord *pCur = pBuf; 134 printf("DRM_IOCTL_VMW_GET_3D_CAP: rc=%d\n", rc); 135 for (;;) 136 { 137 printf("SVGA3dCapsRecordHeader: length=%#x (%d) type=%d\n", 138 pCur->header.length, pCur->header.length, pCur->header.type); 139 if (pCur->header.length == 0) 140 break; 141 uint32_t i; 142 for (i = 0; i < pCur->header.length - 2; i += 2) 143 { 144 printf(" cap %#04x = %#010x (%d)\n", pCur->data[i], pCur->data[i + 1], pCur->data[i + 1]); 145 } 146 pCur = (struct SVGA3dCapsRecord *)((uint32_t *)pCur + pCur->header.length); 147 } 148 rcExit = 0; 149 } 150 else 151 fprintf(stderr, "DRM_IOCTL_VMW_GET_3D_CAP failed: %d - %s\n", errno, strerror(errno)); 152 } 153 else 613 rcExit = Dump3DCapabilities(fd, rcExit); 614 615 /* 616 * Map and dump the FIFO registers. 617 */ 618 rcExit = FindAndMapFifo(&pau32Fifo, &cbFifo, rcExit); 619 if (pau32Fifo && cbFifo) 620 rcExit = DumpFifoStuff(pau32Fifo, cbFifo, rcExit); 621 } 622 else 623 { 154 624 fprintf(stderr, "error opening '%s': %d\n", pszDev, errno); 155 625 rcExit = 1; 626 } 156 627 157 628 return rcExit;
Note:
See TracChangeset
for help on using the changeset viewer.