1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600
|
/*
* Copyright (c) 2009-2020, Intel Corporation
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* 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 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 NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*/
//!
//! \file cm_hal_os.cpp
//! \brief HAL Layer for CM Component on Linux
//!
#include "mos_os.h"
#include "cm_hal.h"
#include "cm_def_os.h"
#include "i915_drm.h"
#include "cm_execution_adv.h"
#include "mos_graphicsresource.h"
#include "mos_utilities.h"
#define Y_TILE_WIDTH 128
#define Y_TILE_HEIGHT 32
#define X_TILE_WIDTH 512
#define X_TILE_HEIGHT 8
#define ROUND_UP_TO(x, y) (((x) + (y) - 1) / (y) * (y))
//*-----------------------------------------------------------------------------
//| Purpose: Referece the OsResource
//| Returns: N/A
//*-----------------------------------------------------------------------------
void HalCm_OsResource_Reference(
PMOS_RESOURCE osResource)
{
if (osResource && osResource->bo)
{
mos_bo_reference((MOS_LINUX_BO *)(osResource->bo));
}
}
//*-----------------------------------------------------------------------------
//| Purpose: unreferece the OsResource
//| Returns: N/A
//*-----------------------------------------------------------------------------
void HalCm_OsResource_Unreference(
PMOS_RESOURCE osResource)
{
if (osResource && osResource->bo)
{
mos_bo_unreference((MOS_LINUX_BO *)(osResource->bo));
osResource->bo = nullptr;
}
}
//*-----------------------------------------------------------------------------
//| Purpose: Reference the Command Buffer and Pass it to event
//| Returns: N/A
//*-----------------------------------------------------------------------------
MOS_STATUS HalCm_ReferenceCommandBuf_Linux(
PMOS_RESOURCE osResource, // [in] Command Buffer's MOS Resurce
void **cmdBuffer) // [out] Comamnd Buffer to pass to event
{
if (osResource && osResource->bo)
{
mos_bo_reference((MOS_LINUX_BO *)(osResource->bo));
*cmdBuffer = osResource->bo;
}
return MOS_STATUS_SUCCESS;
}
//*-----------------------------------------------------------------------------
//| Purpose: Set Command Buffer Resource and Pass it to event
//| Returns: N/A
//*-----------------------------------------------------------------------------
MOS_STATUS HalCm_SetCommandBufResource_Linux(
PMOS_RESOURCE osResource, // [in] Command Buffer's MOS Resurce
void **cmdBuffer) // [out] Comamnd Buffer to pass to event
{
if (osResource && osResource->bo)
{
*cmdBuffer = osResource->bo;
}
return MOS_STATUS_SUCCESS;
}
//*-----------------------------------------------------------------------------
//| Purpose: Get 2D surface info and register to OS-Command-Buffer's patch list.
//| Returns: Result of the operation.
//*-----------------------------------------------------------------------------
MOS_STATUS HalCm_GetSurfaceAndRegister(
PCM_HAL_STATE state,
PRENDERHAL_SURFACE renderHalSurface,
CM_HAL_KERNEL_ARG_KIND surfKind,
uint32_t index,
bool pixelPitch)
{
MOS_STATUS eStatus = MOS_STATUS_UNKNOWN;
RENDERHAL_GET_SURFACE_INFO info;
PRENDERHAL_INTERFACE renderHal = state->renderHal;
PMOS_SURFACE surface = &renderHalSurface->OsSurface;
PRENDERHAL_MEDIA_STATE mediaState = nullptr;
if (!renderHalSurface)
{
goto finish;
}
else
{
MOS_ZeroMemory(renderHalSurface, sizeof(RENDERHAL_SURFACE));
}
switch(surfKind)
{
case CM_ARGUMENT_STATE_BUFFER:
mediaState = state->pfnGetMediaStatePtrForSurfaceIndex( state, index );
CM_CHK_HRESULT_GOTOFINISH_MOSERROR(renderHal->pOsInterface->pfnRegisterResource(
renderHal->pOsInterface, mediaState->pDynamicState->memoryBlock.GetResource(), true, true));
surface->OsResource.user_provided_va = state->pfnGetStateBufferVAPtrForSurfaceIndex( state, index );
surface->dwWidth = mediaState->pDynamicState->Curbe.dwSize;
surface->dwHeight = 1;
surface->Format = Format_RAW;
return MOS_STATUS_SUCCESS; // state buffer's OS resource belong to DSH, so don't need sync it and just return directly.
case CM_ARGUMENT_SURFACEBUFFER:
surface->dwWidth = state->bufferTable[index].size;
surface->dwHeight = 1;
surface->Format = Format_RAW;
renderHalSurface->rcSrc.right = surface->dwWidth;
renderHalSurface->rcSrc.bottom = surface->dwHeight;
renderHalSurface->rcDst = renderHalSurface->rcSrc;
CM_CHK_HRESULT_GOTOFINISH_MOSERROR(renderHal->pOsInterface->pfnRegisterResource(
renderHal->pOsInterface, &(state->bufferTable[index].osResource), true, true));
surface->OsResource = state->bufferTable[index].osResource;
break;
case CM_ARGUMENT_SURFACE3D:
/* First register resource on Linux to get allocation slot on GpuContext */
CM_CHK_HRESULT_GOTOFINISH_MOSERROR(renderHal->pOsInterface->pfnRegisterResource(
renderHal->pOsInterface, &(state->surf3DTable[index].osResource), true, true));
surface->OsResource = state->surf3DTable[index].osResource;
surface->Format = Format_Invalid;
MOS_ZeroMemory(&info, sizeof(RENDERHAL_GET_SURFACE_INFO));
CM_CHK_MOSSTATUS_GOTOFINISH(RenderHal_GetSurfaceInfo(
renderHal->pOsInterface,
&info,
surface));
surface->Format = state->surf3DTable[index].osResource.Format;
renderHalSurface->rcSrc.right = surface->dwWidth;
renderHalSurface->rcSrc.bottom = surface->dwHeight;
renderHalSurface->rcDst = renderHalSurface->rcSrc;
break;
case CM_ARGUMENT_SURFACE2D:
/* First register resource on Linux to get allocation slot on GpuContext */
CM_CHK_HRESULT_GOTOFINISH_MOSERROR(renderHal->pOsInterface->pfnRegisterResource(
renderHal->pOsInterface, &(state->umdSurf2DTable[index].osResource), true, true));
surface->OsResource = state->umdSurf2DTable[index].osResource;
MOS_ZeroMemory(&info, sizeof(RENDERHAL_GET_SURFACE_INFO));
CM_CHK_MOSSTATUS_GOTOFINISH(RenderHal_GetSurfaceInfo(
renderHal->pOsInterface,
&info,
surface));
if ( (surface->Format == Format_NV12 || surface->Format == Format_YV12 || surface->Format == Format_Y210 || surface->Format == Format_Y216)
&& (!pixelPitch))
{
renderHalSurface->SurfType = RENDERHAL_SURF_OUT_RENDERTARGET;
}
surface->Format = state->umdSurf2DTable[index].format;
renderHalSurface->rcSrc.right = surface->dwWidth;
renderHalSurface->rcSrc.bottom = surface->dwHeight;
renderHalSurface->rcDst = renderHalSurface->rcSrc;
break;
case CM_ARGUMENT_SURFACE2D_UP:
/* First register resource on Linux to get allocation slot on GpuContext */
CM_CHK_HRESULT_GOTOFINISH_MOSERROR(renderHal->pOsInterface->pfnRegisterResource(
renderHal->pOsInterface, &(state->surf2DUPTable[index].osResource), true, true));
// Get Details of 2D surface and fill the VPHAL surface
surface->OsResource = state->surf2DUPTable[index].osResource;
surface->dwWidth = state->surf2DUPTable[index].width;
surface->dwHeight = state->surf2DUPTable[index].height;
surface->Format = state->surf2DUPTable[index].format;
surface->dwDepth = 1;
surface->TileType = MOS_TILE_LINEAR;
//surface->Channel = MOS_S3D_NONE;
surface->dwOffset = 0;
if ( (surface->Format == Format_NV12 || surface->Format == Format_YV12 || surface->Format == Format_Y210 || surface->Format == Format_Y216)
&& (!pixelPitch))
{
renderHalSurface->SurfType = RENDERHAL_SURF_OUT_RENDERTARGET;
}
MOS_ZeroMemory(&info, sizeof(RENDERHAL_GET_SURFACE_INFO));
CM_CHK_MOSSTATUS_GOTOFINISH(RenderHal_GetSurfaceInfo(
renderHal->pOsInterface,
&info,
surface));
renderHalSurface->rcSrc.right = surface->dwWidth;
renderHalSurface->rcSrc.bottom = surface->dwHeight;
renderHalSurface->rcDst = renderHalSurface->rcSrc;
break;
case CM_ARGUMENT_VME_STATE:
/* First register resource on Linux to get allocation slot on GpuContext */
CM_CHK_HRESULT_GOTOFINISH_MOSERROR(renderHal->pOsInterface->pfnRegisterResource(
renderHal->pOsInterface, &(state->umdSurf2DTable[index].osResource), true, true));
surface->OsResource = state->umdSurf2DTable[index].osResource;
MOS_ZeroMemory(&info, sizeof(RENDERHAL_GET_SURFACE_INFO));
CM_CHK_MOSSTATUS_GOTOFINISH(RenderHal_GetSurfaceInfo(
renderHal->pOsInterface,
&info,
surface));
surface->Format = state->umdSurf2DTable[index].format;
if (!state->cmHalInterface->IsSupportedVMESurfaceFormat(surface->Format))
{
eStatus = MOS_STATUS_INVALID_PARAMETER;
CM_ASSERTMESSAGE("Invalid VME surface format");
goto finish;
}
renderHalSurface->rcSrc.right = surface->dwWidth;
renderHalSurface->rcSrc.bottom = surface->dwHeight;
renderHalSurface->rcDst = renderHalSurface->rcSrc;
break;
case CM_ARGUMENT_SURFACE_SAMPLER8X8_AVS:
case CM_ARGUMENT_SURFACE_SAMPLER8X8_VA:
/* First register resource on Linux to get allocation slot on GpuContext */
CM_CHK_HRESULT_GOTOFINISH_MOSERROR(renderHal->pOsInterface->pfnRegisterResource(
renderHal->pOsInterface, &(state->umdSurf2DTable[index].osResource), true, true));
// Get Details of 2D surface and fill the VPHAL surface
surface->OsResource = state->umdSurf2DTable[index].osResource;
MOS_ZeroMemory(&info, sizeof(RENDERHAL_GET_SURFACE_INFO));
CM_CHK_MOSSTATUS_GOTOFINISH(RenderHal_GetSurfaceInfo(
renderHal->pOsInterface,
&info,
surface));
surface->Format = state->umdSurf2DTable[index].osResource.Format;
renderHalSurface->rcSrc.right = surface->dwWidth;
renderHalSurface->rcSrc.bottom = surface->dwHeight;
renderHalSurface->rcDst = renderHalSurface->rcSrc;
break;
default:
eStatus = MOS_STATUS_INVALID_PARAMETER;
CM_ASSERTMESSAGE(
"Argument kind '%d' is not supported", surfKind);
goto finish;
}
//Tag-based Sync on the Resource/surface
CM_CHK_MOSSTATUS_GOTOFINISH(HalCm_SyncOnResource(state, surface, true));
eStatus = MOS_STATUS_SUCCESS;
finish:
return eStatus;
}
//===============<Os-dependent DDI Functions>============================================
//*-----------------------------------------------------------------------------
//| Purpose: Get 2D surface pitch and physical size for SURFACE2D_UP
//| Returns: Result of the operation.
//*-----------------------------------------------------------------------------
MOS_STATUS HalCm_GetSurfPitchSize(
uint32_t width, uint32_t height, MOS_FORMAT format, uint32_t *pitch, uint32_t *physicalSize, PCM_HAL_STATE state)
{
MOS_STATUS eStatus = MOS_STATUS_SUCCESS;
GMM_RESOURCE_INFO* gmmResInfo = nullptr;
GMM_RESOURCE_FLAG gmmFlags;
GMM_RESCREATE_PARAMS gmmParams;
MOS_ZeroMemory( &gmmFlags, sizeof( GMM_RESOURCE_FLAG ) );
MOS_ZeroMemory( &gmmParams, sizeof( GMM_RESCREATE_PARAMS ) );
if( nullptr == state ||
nullptr == state->osInterface ||
nullptr == pitch ||
nullptr == physicalSize)
{
eStatus = MOS_STATUS_NULL_POINTER;
goto finish;
}
gmmFlags.Info.Linear = true;
gmmFlags.Info.Cacheable = true;
gmmFlags.Gpu.Texture = true;
gmmParams.Type = RESOURCE_2D;
gmmParams.Format = state->osInterface->pfnFmt_MosToGmm( format );
gmmParams.Flags = gmmFlags;
gmmParams.BaseWidth = width;
gmmParams.BaseHeight = height;
gmmParams.Depth = 1;
gmmParams.ArraySize = 1;
gmmParams.NoGfxMemory = true;
// get pitch and size
if (nullptr == state ||
nullptr == state->osInterface)
{
eStatus = MOS_STATUS_NULL_POINTER;
goto finish;
}
gmmResInfo = state->osInterface->pfnGetGmmClientContext(state->osInterface)->CreateResInfoObject(&gmmParams);
if (gmmResInfo != nullptr)
{
*pitch = static_cast<uint32_t>( gmmResInfo->GetRenderPitch() );
*physicalSize = static_cast<uint32_t>( gmmResInfo->GetSizeSurface() );
state->osInterface->pfnGetGmmClientContext(state->osInterface)->DestroyResInfoObject(gmmResInfo);
}
else
{
*pitch = 0;
*physicalSize = 0;
}
finish:
return eStatus;
}
//*-----------------------------------------------------------------------------
//| Purpose: Get 2D surface pitch and physical size for SURFACE2D_UP
//| Returns: Result of the operation.
//*-----------------------------------------------------------------------------
MOS_STATUS HalCm_GetSurface2DPitchAndSize_Linux(
PCM_HAL_STATE state, // [in] Pointer to CM State
PCM_HAL_SURFACE2D_UP_PARAM param) // [in] Pointer to Buffer Param
{
return HalCm_GetSurfPitchSize(param->width, param->height, param->format,
¶m->pitch, ¶m->physicalSize, state);
}
//*-----------------------------------------------------------------------------
//| Purpose: Register APP/Runtime-level created Event Handle as a UMD Object;
//| Returns: Result of the operation.
//*-----------------------------------------------------------------------------
MOS_STATUS HalCm_RegisterUMDNotifyEventHandle_Linux(
PCM_HAL_STATE state,
PCM_HAL_OSSYNC_PARAM syncParam)
{
MOS_STATUS eStatus;
UNUSED(state);
UNUSED(syncParam);
//-----------------------------------------
CM_ASSERT(state);
CM_ASSERT(syncParam);
//-----------------------------------------
eStatus = MOS_STATUS_SUCCESS;
return eStatus;
}
uint32_t HalCm_GetSurf2DUPBaseWidth( uint32_t width, uint32_t pitch, MOS_FORMAT format)
{
uint32_t baseWidth = width;
uint32_t pixelSize = 1;
switch(format)
{
case Format_L8 :
case Format_P8 :
case Format_A8 :
case Format_NV12:
pixelSize = 1;
break;
case Format_X8R8G8B8 :
case Format_A8R8G8B8 :
case Format_A8B8G8R8 :
case Format_R32F :
pixelSize = 4;
break;
case Format_V8U8 :
case Format_YUY2 :
case Format_UYVY :
pixelSize = 2;
break;
default:
CM_ASSERTMESSAGE("Error: Unsupported surface format.");
break;
}
baseWidth = pitch/pixelSize;
return baseWidth;
}
//*-----------------------------------------------------------------------------
//| Purpose: Allocate Linear Buffer or BufferUP
//| Returns: Result of the operation.
//*-----------------------------------------------------------------------------
MOS_STATUS HalCm_AllocateBuffer_Linux(
PCM_HAL_STATE state, // [in] Pointer to CM State
PCM_HAL_BUFFER_PARAM param) // [in] Pointer to Buffer Param
{
MOS_STATUS eStatus;
PMOS_INTERFACE osInterface;
PCM_HAL_BUFFER_ENTRY entry = nullptr;
MOS_ALLOC_GFXRES_PARAMS allocParams;
uint32_t i;
uint32_t size;
uint32_t tileformat;
const char *fmt;
PMOS_RESOURCE osResource;
MOS_LINUX_BO *bo = nullptr;
size = param->size;
tileformat = I915_TILING_NONE;
//-----------------------------------------------
CM_ASSERT(param->size > 0);
//-----------------------------------------------
eStatus = MOS_STATUS_SUCCESS;
osInterface = state->renderHal->pOsInterface;
// Find a free slot
for (i = 0; i < state->cmDeviceParam.maxBufferTableSize; i++)
{
if (state->bufferTable[i].size == 0)
{
entry = &state->bufferTable[i];
param->handle = (uint32_t)i;
break;
}
}
if (!entry)
{
eStatus = MOS_STATUS_INVALID_PARAMETER;
CM_ASSERTMESSAGE("Buffer table is full");
goto finish;
}
// State buffer doesn't need any MOS RESOURCE, so it will return directly after getting a position in the buffer table
if ( param->type == CM_BUFFER_STATE )
{
entry->size = param->size;
entry->isAllocatedbyCmrtUmd = false;
return eStatus;
}
osResource = &(entry->osResource);
if (param->isAllocatedbyCmrtUmd)
{
// Resets the Resource
Mos_ResetResource(osResource);
if (param->data == nullptr)
{
MOS_ZeroMemory(&allocParams, sizeof(MOS_ALLOC_GFXRES_PARAMS));
allocParams.Type = MOS_GFXRES_BUFFER;
allocParams.TileType = MOS_TILE_LINEAR;
allocParams.dwBytes = param->size;
allocParams.pSystemMemory = param->data;
allocParams.Format = Format_Buffer; //used in VpHal_OsAllocateResource_Linux!
if (param->type == CM_BUFFER_N)
{
allocParams.pBufName = "CmBuffer";
}
else if (param->type == CM_BUFFER_STATELESS)
{
allocParams.pBufName = "CmBufferStateless";
}
CM_CHK_HRESULT_GOTOFINISH_MOSERROR(osInterface->pfnAllocateResource(
osInterface,
&allocParams,
&entry->osResource));
}
else //BufferUP
{
// If user provides a system memory pointer, the gfx resource is backed
// by the system memory pages. The resource is required to be linear.
GMM_RESCREATE_PARAMS gmmParams;
MOS_ZeroMemory(&gmmParams, sizeof(GMM_RESCREATE_PARAMS));
gmmParams.Flags.Info.Linear = true;
gmmParams.Flags.Info.Cacheable = true;
gmmParams.NoGfxMemory = true;
gmmParams.Type = RESOURCE_BUFFER;
gmmParams.Flags.Gpu.State = true;
gmmParams.BaseWidth = param->size;
gmmParams.BaseHeight = 1;
gmmParams.ArraySize = 1;
gmmParams.Format = osInterface->pfnFmt_MosToGmm(Format_Buffer);
GMM_CLIENT_CONTEXT* pGmmClientContext = osInterface->pfnGetGmmClientContext(osInterface);
GMM_RESOURCE_INFO* tmpGmmResInfoPtr = pGmmClientContext->CreateResInfoObject(&gmmParams);
osResource->pGmmResInfo = tmpGmmResInfoPtr;
MosUtilities::MosAtomicIncrement(&MosUtilities::m_mosMemAllocCounterGfx);
#if defined(DRM_IOCTL_I915_GEM_USERPTR)
bo = mos_bo_alloc_userptr(osInterface->pOsContext->bufmgr,
"CM Buffer UP",
(void *)(param->data),
tileformat,
ROUND_UP_TO(size,MOS_PAGE_SIZE),
ROUND_UP_TO(size,MOS_PAGE_SIZE),
#if defined(ANDROID)
I915_USERPTR_UNSYNCHRONIZED
#else
0
#endif
);
#else
bo = mos_bo_alloc_vmap(osInterface->pOsContext->bufmgr,
"CM Buffer UP",
(void *)(param->data),
tileformat,
ROUND_UP_TO(size,MOS_PAGE_SIZE),
ROUND_UP_TO(size,MOS_PAGE_SIZE),
#if defined(ANDROID)
I915_USERPTR_UNSYNCHRONIZED
#else
0
#endif
);
#endif
osResource->bMapped = false;
if (bo)
{
osResource->Format = Format_Buffer;
osResource->iWidth = ROUND_UP_TO(size,MOS_PAGE_SIZE);
osResource->iHeight = 1;
osResource->iPitch = ROUND_UP_TO(size,MOS_PAGE_SIZE);
osResource->bo = bo;
osResource->TileType = LinuxToMosTileType(tileformat);
osResource->pData = (uint8_t*) bo->virt;
}
else
{
fmt = "BufferUP";
CM_ASSERTMESSAGE("Fail to Alloc BufferUP %7d bytes (%d x %d %s resource)\n",size, size, 1, fmt);
eStatus = MOS_STATUS_UNKNOWN;
}
osResource->bConvertedFromDDIResource = true;
}
}
else
{
entry->osResource = *param->mosResource;
HalCm_OsResource_Reference(&entry->osResource);
}
entry->size = param->size;
entry->isAllocatedbyCmrtUmd = param->isAllocatedbyCmrtUmd;
entry->surfaceStateEntry[0].surfaceStateSize = entry->size;
entry->surfaceStateEntry[0].surfaceStateOffset = 0;
entry->surfaceStateEntry[0].surfaceStateMOCS = 0;
if(param->type == CM_BUFFER_STATELESS)
{
state->statelessBufferUsed = true;
// get GPU virtual address
// Fix: pfnGetResourceGfxAddress is not implemented. Need to find solution to
// get the GFX address.
param->gfxAddress = osInterface->pfnGetResourceGfxAddress(osInterface,
&(entry->osResource));
entry->address = reinterpret_cast<void *>(param->gfxAddress);
}
if (state->advExecutor)
{
entry->surfStateMgr = state->advExecutor->CreateBufferStateMgr(&entry->osResource);
state->advExecutor->SetBufferOrigSize(entry->surfStateMgr, entry->size);
}
finish:
return eStatus;
}
//*-----------------------------------------------------------------------------
//| Purpose: Allocate Surface2DUP (zero-copy, map system memory to video address space)
//| Returns: Result of the operation.
//*-----------------------------------------------------------------------------
MOS_STATUS HalCm_AllocateSurface2DUP_Linux(
PCM_HAL_STATE state, // [in] Pointer to CM State
PCM_HAL_SURFACE2D_UP_PARAM param) // [in] Pointer to Buffer Param
{
MOS_STATUS eStatus = MOS_STATUS_SUCCESS;
PMOS_INTERFACE osInterface = state->renderHal->pOsInterface;
PCM_HAL_SURFACE2D_UP_ENTRY entry = nullptr;
MOS_ALLOC_GFXRES_PARAMS allocParams;
//-----------------------------------------------
CM_ASSERT(state);
CM_ASSERT(param->width > 0 && param->height > 0);
//-----------------------------------------------
// Find a free slot
for (uint32_t i = 0; i < state->cmDeviceParam.max2DSurfaceUPTableSize; ++i)
{
if (state->surf2DUPTable[i].width == 0)
{
entry = &state->surf2DUPTable[i];
param->handle = (uint32_t)i;
break;
}
}
if (!entry)
{
eStatus = MOS_STATUS_INVALID_PARAMETER;
CM_ASSERTMESSAGE("Surface2DUP table is full");
goto finish;
}
MOS_ZeroMemory(&allocParams, sizeof(allocParams));
allocParams.Type = MOS_GFXRES_2D;
allocParams.TileType = MOS_TILE_LINEAR;
allocParams.dwWidth = param->width;
allocParams.dwHeight = param->height;
allocParams.pSystemMemory = param->data;
allocParams.Format = param->format;
allocParams.pBufName = "CmSurface2DUP";
CM_CHK_HRESULT_GOTOFINISH_MOSERROR(osInterface->pfnAllocateResource(
osInterface,
&allocParams,
&entry->osResource));
entry->width = param->width;
entry->height = param->height;
entry->format = param->format;
if (state->advExecutor)
{
entry->surfStateMgr = state->advExecutor->Create2DStateMgr(&entry->osResource);
}
finish:
return eStatus;
}
//*-----------------------------------------------------------------------------
//| Purpose: Get GPU current frequency
//| Returns: Result of the operation.
//*-----------------------------------------------------------------------------
MOS_STATUS HalCm_GetGPUCurrentFrequency_Linux(
PCM_HAL_STATE state, // [in] Pointer to CM State
uint32_t *currentFrequency) // [out] Pointer to current frequency
{
UNUSED(state);
//-----------------------------------------
CM_ASSERT(state);
//-----------------------------------------
*currentFrequency = 0;
return MOS_STATUS_SUCCESS;
}
MOS_STATUS HalCm_GetGpuTime_Linux(PCM_HAL_STATE state, uint64_t *gpuTime)
{
UNUSED(state);
*gpuTime = 0;
return MOS_STATUS_SUCCESS;
}
//*-----------------------------------------------------------------------------
// Purpose: Check if conditional batch buffer supported
// Returns: False on Linux
//*-----------------------------------------------------------------------------
bool HalCm_IsCbbEnabled(
PCM_HAL_STATE state)
{
return false;
}
//*-----------------------------------------------------------------------------
// Purpose: Wait kernel finished in state heap
// Returns: Result of the operation
//*-----------------------------------------------------------------------------
int32_t HalCm_SyncKernel(
PCM_HAL_STATE state,
uint32_t sync)
{
int32_t eStatus = CM_SUCCESS;
PRENDERHAL_INTERFACE renderHal = state->renderHal;
PRENDERHAL_STATE_HEAP stateHeap = renderHal->pStateHeap;
// Update Sync tags
CM_CHK_MOSSTATUS_GOTOFINISH(renderHal->pfnRefreshSync(renderHal));
while ( ( int32_t )( stateHeap->dwSyncTag - sync ) < 0 )
{
CM_CHK_MOSSTATUS_GOTOFINISH( renderHal->pfnRefreshSync( renderHal ) );
}
finish:
return eStatus;
}
//===============<Os-dependent Private/Non-DDI Functions, Part 2>============================================
//Require DRM VMAP patch,
//Referecing:
// [Intel-gfx] [PATCH 21/21] drm/i915: Introduce vmap (mapping of user pages into video memory) ioctl
// http://lists.freedesktop.org/archives/intel-gfx/2011-April/010241.html
void HalCm_GetLibDrmVMapFnt(
PCM_HAL_STATE cmState)
{
cmState->hLibModule = nullptr;
cmState->drmVMap = nullptr;
return ;
}
//*-----------------------------------------------------------------------------
//| Purpose: Gets platform information like slices/sub-slices/EUPerSubSlice etc.
//| Returns: Result of the operation
//*-----------------------------------------------------------------------------
MOS_STATUS HalCm_GetPlatformInfo_Linux(
PCM_HAL_STATE state, // [in] Pointer to CM State
PCM_PLATFORM_INFO platformInfo, // [out] Pointer to platformInfo
bool euSaturated)
{
MOS_STATUS eStatus = MOS_STATUS_SUCCESS;
MEDIA_SYSTEM_INFO *gtSystemInfo;
UNUSED(euSaturated);
gtSystemInfo = state->osInterface->pfnGetGtSystemInfo(state->osInterface);
platformInfo->numHWThreadsPerEU = gtSystemInfo->ThreadCount / gtSystemInfo->EUCount;
platformInfo->numEUsPerSubSlice = gtSystemInfo->EUCount / gtSystemInfo->SubSliceCount;
if (state->cmHalInterface->CheckMediaModeAvailability())
{
platformInfo->numSlices = gtSystemInfo->SliceCount;
platformInfo->numSubSlices = gtSystemInfo->SubSliceCount;
}
else
{ // not use Slice/SubSlice count set to 0
platformInfo->numSlices = 0;
platformInfo->numSubSlices = 0;
}
return eStatus;
}
//*-----------------------------------------------------------------------------
//| Purpose: Gets GT system information for which slices/sub-slices are enabled
//| Returns: Result of the operation
//*-----------------------------------------------------------------------------
MOS_STATUS HalCm_GetGTSystemInfo_Linux(
PCM_HAL_STATE state, // [in] Pointer to CM state
PCM_GT_SYSTEM_INFO pSystemInfo // [out] Pointer to CM GT system info
)
{
MEDIA_SYSTEM_INFO *gtSystemInfo;
CM_EXPECTED_GT_SYSTEM_INFO expectedGTInfo;
gtSystemInfo = state->osInterface->pfnGetGtSystemInfo(state->osInterface);
pSystemInfo->numMaxSlicesSupported = gtSystemInfo->MaxSlicesSupported;
pSystemInfo->numMaxSubSlicesSupported = gtSystemInfo->MaxSubSlicesSupported;
state->cmHalInterface->GetExpectedGtSystemConfig(&expectedGTInfo);
// check numSlices/SubSlices enabled equal the expected number for this GT
// if match, pSystemInfo->isSliceInfoValid = true, else pSystemInfo->isSliceInfoValid = false
if ((expectedGTInfo.numSlices == gtSystemInfo->SliceCount) &&
(expectedGTInfo.numSubSlices == gtSystemInfo->SubSliceCount))
{
pSystemInfo->isSliceInfoValid = true;
}
else
{
pSystemInfo->isSliceInfoValid = false;
}
// if valid, set the number slice/subSlice to enabled for numSlices/numSubSlices
if(pSystemInfo->isSliceInfoValid)
{
for(uint32_t i = 0; i < gtSystemInfo->SliceCount; ++i)
{
pSystemInfo->sliceInfo[i].Enabled = true;
for(uint32_t j = 0; j < gtSystemInfo->SubSliceCount; ++j)
{
pSystemInfo->sliceInfo[i].SubSliceInfo[j].Enabled = true;
}
}
}
return MOS_STATUS_SUCCESS;
}
//*-----------------------------------------------------------------------------
//| Purpose: Query the status of the task
//| Returns: Result of the operation.
//*-----------------------------------------------------------------------------
MOS_STATUS HalCm_QueryTask_Linux(
PCM_HAL_STATE state,
PCM_HAL_QUERY_TASK_PARAM queryParam)
{
MOS_STATUS eStatus = MOS_STATUS_SUCCESS;
PRENDERHAL_INTERFACE renderHal;
int64_t *piSyncStart;
int64_t *piSyncEnd;
uint64_t ticks;
int32_t syncOffset;
PRENDERHAL_STATE_HEAP stateHeap;
uint64_t hwStartNs;
uint64_t hwEndNs;
int32_t maxTasks;
//-----------------------------------------
CM_ASSERT(state);
CM_ASSERT(queryParam);
//-----------------------------------------
maxTasks = (int32_t)state->cmDeviceParam.maxTasks;
if ((queryParam->taskId < 0) || (queryParam->taskId >= maxTasks) ||
(state->taskStatusTable[queryParam->taskId] == CM_INVALID_INDEX))
{
eStatus = MOS_STATUS_INVALID_PARAMETER;
CM_ASSERTMESSAGE("Invalid Task ID'%d'.", queryParam->taskId);
goto finish;
}
renderHal = state->renderHal;
stateHeap = renderHal->pStateHeap;
syncOffset = state->pfnGetTaskSyncLocation(state, queryParam->taskId);
piSyncStart = (int64_t*)(state->renderTimeStampResource.data + syncOffset);
piSyncEnd = piSyncStart + 1;
queryParam->taskDurationNs = CM_INVALID_INDEX;
if (*piSyncStart == CM_INVALID_INDEX)
{
queryParam->status = CM_TASK_QUEUED;
}
else if (*piSyncEnd == CM_INVALID_INDEX)
{
queryParam->status = CM_TASK_IN_PROGRESS;
}
else
{
queryParam->status = CM_TASK_FINISHED;
hwStartNs = HalCm_ConvertTicksToNanoSeconds(state, *piSyncStart);
hwEndNs = HalCm_ConvertTicksToNanoSeconds(state, *piSyncEnd);
ticks = *piSyncEnd - *piSyncStart;
queryParam->taskDurationTicks = ticks;
queryParam->taskHWStartTimeStampInTicks = *piSyncStart;
queryParam->taskHWEndTimeStampInTicks = *piSyncEnd;
// Convert ticks to Nanoseconds
queryParam->taskDurationNs = HalCm_ConvertTicksToNanoSeconds(state, ticks);
queryParam->taskGlobalSubmitTimeCpu = state->taskTimeStamp->submitTimeInCpu[queryParam->taskId];
CM_CHK_MOSSTATUS_GOTOFINISH(state->pfnConvertToQPCTime(state->taskTimeStamp->submitTimeInGpu[queryParam->taskId], &queryParam->taskSubmitTimeGpu));
CM_CHK_MOSSTATUS_GOTOFINISH(state->pfnConvertToQPCTime(hwStartNs, &queryParam->taskHWStartTimeStamp));
CM_CHK_MOSSTATUS_GOTOFINISH(state->pfnConvertToQPCTime(hwEndNs, &queryParam->taskHWEndTimeStamp));
state->taskStatusTable[queryParam->taskId] = CM_INVALID_INDEX;
}
finish:
return eStatus;
}
MOS_STATUS HalCm_WriteGPUStatusTagToCMTSResource_Linux(
PCM_HAL_STATE state,
PMOS_COMMAND_BUFFER cmdBuffer,
int32_t taskID,
bool isVebox)
{
UNUSED(state);
UNUSED(cmdBuffer);
UNUSED(taskID);
UNUSED(isVebox);
return MOS_STATUS_SUCCESS;
}
//*-----------------------------------------------------------------------------
//| Purpose: Lock the resource and return
//| Returns: Result of the operation.
//*-----------------------------------------------------------------------------
MOS_STATUS HalCm_Lock2DResource(
PCM_HAL_STATE state, // [in] Pointer to CM State
PCM_HAL_SURFACE2D_LOCK_UNLOCK_PARAM param) // [in] Pointer to 2D Param
{
MOS_STATUS eStatus = MOS_STATUS_SUCCESS;
MOS_LOCK_PARAMS lockFlags;
RENDERHAL_GET_SURFACE_INFO info;
MOS_SURFACE surface;
PMOS_INTERFACE osInterface = nullptr;
if ((param->lockFlag != CM_HAL_LOCKFLAG_READONLY) && (param->lockFlag != CM_HAL_LOCKFLAG_WRITEONLY) )
{
CM_ASSERTMESSAGE("Invalid lock flag!");
eStatus = MOS_STATUS_UNKNOWN;
goto finish;
}
MOS_ZeroMemory(&surface, sizeof(surface));
surface.Format = Format_Invalid;
osInterface = state->osInterface;
if(param->data == nullptr)
{ // CMRT@UMD
PCM_HAL_SURFACE2D_ENTRY entry;
// Get the 2D Resource Entry
entry = &state->umdSurf2DTable[param->handle];
// Get resource information
surface.OsResource = entry->osResource;
MOS_ZeroMemory(&info, sizeof(RENDERHAL_GET_SURFACE_INFO));
CM_CHK_MOSSTATUS_GOTOFINISH(RenderHal_GetSurfaceInfo(
osInterface,
&info,
&surface));
param->pitch = surface.dwPitch;
param->format = surface.Format;
param->YSurfaceOffset = surface.YPlaneOffset;
param->USurfaceOffset = surface.UPlaneOffset;
param->VSurfaceOffset = surface.VPlaneOffset;
// Lock the resource
MOS_ZeroMemory(&lockFlags, sizeof(MOS_LOCK_PARAMS));
if (param->lockFlag == CM_HAL_LOCKFLAG_READONLY)
{
lockFlags.ReadOnly = true;
}
else
{
lockFlags.WriteOnly = true;
}
lockFlags.ForceCached = true;
param->data = osInterface->pfnLockResource(
osInterface,
&entry->osResource,
&lockFlags);
}
else
{
CM_ASSERTMESSAGE("Error: Failed to lock surface 2d resource.");
eStatus = MOS_STATUS_UNKNOWN;
}
CM_CHK_NULL_GOTOFINISH_MOSERROR(param->data);
finish:
return eStatus;
}
//*-----------------------------------------------------------------------------
//| Purpose: Unlock the resource and return
//| Returns: Result of the operation.
//*-----------------------------------------------------------------------------
MOS_STATUS HalCm_Unlock2DResource(
PCM_HAL_STATE state, // [in] Pointer to CM State
PCM_HAL_SURFACE2D_LOCK_UNLOCK_PARAM param) // [in] Pointer to 2D Param
{
MOS_STATUS eStatus = MOS_STATUS_SUCCESS;
PMOS_INTERFACE osInterface = state->osInterface;
if(param->data == nullptr)
{
PCM_HAL_SURFACE2D_ENTRY entry;
// Get the 2D Resource Entry
entry = &state->umdSurf2DTable[param->handle];
// UnLock the resource
CM_CHK_HRESULT_GOTOFINISH_MOSERROR(osInterface->pfnUnlockResource(osInterface, &(entry->osResource)));
}
else
{
CM_ASSERTMESSAGE("Error: Failed to unlock surface 2d resource.");
eStatus = MOS_STATUS_UNKNOWN;
}
finish:
return eStatus;
}
//*-----------------------------------------------------------------------------
//| Purpose: Get the GfxMap Filter based on the texture filter type
//| Returns: Result
//*-----------------------------------------------------------------------------
MOS_STATUS HalCm_GetGfxMapFilter(
uint32_t filterMode,
MHW_GFX3DSTATE_MAPFILTER *gfxFilter)
{
MOS_STATUS eStatus = MOS_STATUS_SUCCESS;
switch(filterMode)
{
case CM_TEXTURE_FILTER_TYPE_LINEAR:
*gfxFilter = MHW_GFX3DSTATE_MAPFILTER_LINEAR;
break;
case CM_TEXTURE_FILTER_TYPE_POINT:
*gfxFilter = MHW_GFX3DSTATE_MAPFILTER_NEAREST;
break;
case CM_TEXTURE_FILTER_TYPE_ANISOTROPIC:
*gfxFilter = MHW_GFX3DSTATE_MAPFILTER_ANISOTROPIC;
break;
default:
eStatus = MOS_STATUS_INVALID_PARAMETER;
CM_ASSERTMESSAGE("Filter '%d' not supported", filterMode);
goto finish;
}
finish:
return eStatus;
}
//*-----------------------------------------------------------------------------
//| Purpose: Get the Gfx Texture Address based on the texture coordinate type
//| Returns: Result
//*-----------------------------------------------------------------------------
MOS_STATUS HalCm_GetGfxTextAddress(
uint32_t addressMode,
MHW_GFX3DSTATE_TEXCOORDMODE *gfxAddress)
{
MOS_STATUS eStatus = MOS_STATUS_SUCCESS;
switch(addressMode)
{
case CM_TEXTURE_ADDRESS_WRAP:
*gfxAddress = MHW_GFX3DSTATE_TEXCOORDMODE_WRAP;
break;
case CM_TEXTURE_ADDRESS_MIRROR:
*gfxAddress = MHW_GFX3DSTATE_TEXCOORDMODE_MIRROR;
break;
case CM_TEXTURE_ADDRESS_CLAMP:
*gfxAddress = MHW_GFX3DSTATE_TEXCOORDMODE_CLAMP;
break;
case CM_TEXTURE_ADDRESS_BORDER:
*gfxAddress = MHW_GFX3DSTATE_TEXCOORDMODE_CLAMP_BORDER;
break;
default:
eStatus = MOS_STATUS_INVALID_PARAMETER;
CM_ASSERTMESSAGE("Address '%d' not supported", addressMode);
goto finish;
}
finish:
return eStatus;
}
//*-----------------------------------------------------------------------------
//| Purpose: If WA required to set SLM in L3
//| Returns: Display corruption observed when running MDF workload.
//| This issue is related to SLM setting in L3.
//| To resolve this problem, we need to disable SLM after
//| command submission.
//*-----------------------------------------------------------------------------
bool HalCm_IsWaSLMinL3Cache_Linux()
{
bool flag;
#if ANDROID
flag = false;
#else
flag = true;
#endif
return flag;
}
//*-----------------------------------------------------------------------------
//| Purpose: Enable GPU frequency Turbo boost on Linux
//| Returns: MOS_STATUS_SUCCESS.
//*-----------------------------------------------------------------------------
#define I915_CONTEXT_PRIVATE_PARAM_BOOST 0x80000000
MOS_STATUS HalCm_EnableTurboBoost_Linux(
PCM_HAL_STATE state)
{
#ifndef ANDROID
struct drm_i915_gem_context_param ctxParam;
int32_t retVal = 0;
MOS_ZeroMemory( &ctxParam, sizeof( ctxParam ) );
ctxParam.param = I915_CONTEXT_PRIVATE_PARAM_BOOST;
ctxParam.value = 1;
retVal = drmIoctl( state->osInterface->pOsContext->fd,
DRM_IOCTL_I915_GEM_CONTEXT_SETPARAM, &ctxParam );
#endif
//if drmIoctl fail, we will stay in normal mode.
return MOS_STATUS_SUCCESS;
}
//!
//! \brief Updates tracker resource used in state heap management
//! \param [in] state
//! CM HAL State
//! \param [in,out] cmdBuffer
//! Command buffer containing the workload
//! \param [in] tag
//| Tag to write to tracker resource
//! \return MOS_STATUS
//! MOS_STATUS_SUCCESS if success, else fail reason
//!
MOS_STATUS HalCm_UpdateTrackerResource_Linux(
PCM_HAL_STATE state,
PMOS_COMMAND_BUFFER cmdBuffer,
uint32_t tag)
{
MHW_MI_STORE_DATA_PARAMS storeDataParams;
MOS_GPU_CONTEXT gpuContext = MOS_GPU_CONTEXT_INVALID_HANDLE;
MOS_STATUS eStatus = MOS_STATUS_SUCCESS;
MOS_ZeroMemory(&storeDataParams, sizeof(storeDataParams));
gpuContext = state->renderHal->pOsInterface->CurrentGpuContextOrdinal;
if (gpuContext == MOS_GPU_CONTEXT_VEBOX)
{
MOS_RESOURCE osResource = state->renderHal->veBoxTrackerRes.osResource;
storeDataParams.pOsResource = &osResource;
}
else
{
state->renderHal->trackerProducer.GetLatestTrackerResource(state->renderHal->currentTrackerIndex,
&storeDataParams.pOsResource,
&storeDataParams.dwResourceOffset);
}
storeDataParams.dwValue = tag;
eStatus = state->renderHal->pMhwMiInterface->AddMiStoreDataImmCmd(cmdBuffer, &storeDataParams);
return eStatus;
}
uint32_t HalCm_RegisterStream(CM_HAL_STATE *state)
{
return state->osInterface->streamIndex;
}
void HalCm_OsInitInterface(
PCM_HAL_STATE cmState) // [out] pointer to CM State
{
CM_ASSERT(cmState);
cmState->pfnGetSurface2DPitchAndSize = HalCm_GetSurface2DPitchAndSize_Linux;
cmState->pfnRegisterUMDNotifyEventHandle = HalCm_RegisterUMDNotifyEventHandle_Linux;
cmState->pfnAllocateBuffer = HalCm_AllocateBuffer_Linux;
cmState->pfnAllocateSurface2DUP = HalCm_AllocateSurface2DUP_Linux;
cmState->pfnGetGPUCurrentFrequency = HalCm_GetGPUCurrentFrequency_Linux;
cmState->pfnGetGpuTime = HalCm_GetGpuTime_Linux;
cmState->pfnGetPlatformInfo = HalCm_GetPlatformInfo_Linux;
cmState->pfnGetGTSystemInfo = HalCm_GetGTSystemInfo_Linux;
cmState->pfnReferenceCommandBuffer = HalCm_ReferenceCommandBuf_Linux;
cmState->pfnSetCommandBufferResource = HalCm_SetCommandBufResource_Linux;
cmState->pfnQueryTask = HalCm_QueryTask_Linux;
cmState->pfnIsWASLMinL3Cache = HalCm_IsWaSLMinL3Cache_Linux;
cmState->pfnEnableTurboBoost = HalCm_EnableTurboBoost_Linux;
cmState->pfnUpdateTrackerResource = HalCm_UpdateTrackerResource_Linux;
cmState->pfnRegisterStream = HalCm_RegisterStream;
HalCm_GetLibDrmVMapFnt(cmState);
cmState->syncOnResource = false;
return;
}
//*-------------------------------------------------------------------------------------
//| Purpose: Add PipeControl with a Conditional Time Stamp (valid/invalid time stamp)
//| Returns: On Success, right before Pipe Control commands, insert commands to write
//| time stamp to Sync Location. When the condition same as following
//| "conditional buffer end" command is assert, the time stamp is a valid value,
//| otherwise an invalid time stamp is used to write Sync Location.
//*-------------------------------------------------------------------------------------
MOS_STATUS HalCm_OsAddArtifactConditionalPipeControl(
PCM_HAL_MI_REG_OFFSETS offsets,
PCM_HAL_STATE state,
PMOS_COMMAND_BUFFER cmdBuffer, //commmand buffer
int32_t syncOffset, //offset to syncation of time stamp
PMHW_MI_CONDITIONAL_BATCH_BUFFER_END_PARAMS conditionalParams, //comparing Params
uint32_t trackerTag)
{
MOS_STATUS eStatus = MOS_STATUS_SUCCESS;
MHW_MI_LOAD_REGISTER_REG_PARAMS loadRegRegParams;
MHW_MI_LOAD_REGISTER_IMM_PARAMS loadRegImmParams;
MHW_MI_LOAD_REGISTER_MEM_PARAMS loadRegMemParams;
MHW_MI_STORE_REGISTER_MEM_PARAMS storeRegParams;
MHW_MI_STORE_DATA_PARAMS storeDataParams;
MHW_MI_FLUSH_DW_PARAMS flushDwParams;
MHW_MI_MATH_PARAMS mathParams;
MHW_MI_ALU_PARAMS aluParams[20];
MHW_MI_STORE_REGISTER_MEM_PARAMS storeRegMemParams;
MHW_PIPE_CONTROL_PARAMS pipeCtrlParams;
PMHW_MI_INTERFACE mhwMiInterface = state->renderHal->pMhwMiInterface;
MOS_ZeroMemory(&loadRegRegParams, sizeof(loadRegRegParams));
loadRegRegParams.dwSrcRegister = offsets->timeStampOffset; //read time stamp
loadRegRegParams.dwDstRegister = offsets->gprOffset + 0;
CM_CHK_MOSSTATUS_GOTOFINISH(mhwMiInterface->AddMiLoadRegisterRegCmd(cmdBuffer, &loadRegRegParams));
loadRegRegParams.dwSrcRegister = offsets->timeStampOffset + 4;
loadRegRegParams.dwDstRegister = offsets->gprOffset + 4;
CM_CHK_MOSSTATUS_GOTOFINISH(mhwMiInterface->AddMiLoadRegisterRegCmd(cmdBuffer, &loadRegRegParams)); //R0: time stamp
MOS_ZeroMemory(&mathParams, sizeof(mathParams));
MOS_ZeroMemory(&aluParams, sizeof(aluParams));
aluParams[0].AluOpcode = MHW_MI_ALU_AND;
// store reg1, CF
aluParams[1].AluOpcode = MHW_MI_ALU_STORE;
aluParams[1].Operand1 = MHW_MI_ALU_GPREG1;
aluParams[1].Operand2 = MHW_MI_ALU_CF;
// store reg2, CF
aluParams[2].AluOpcode = MHW_MI_ALU_STORE;
aluParams[2].Operand1 = MHW_MI_ALU_GPREG2;
aluParams[2].Operand2 = MHW_MI_ALU_CF;
// store reg3, CF
aluParams[2].AluOpcode = MHW_MI_ALU_STORE;
aluParams[2].Operand1 = MHW_MI_ALU_GPREG3;
aluParams[2].Operand2 = MHW_MI_ALU_CF; //clear R1 -- R3
mathParams.pAluPayload = aluParams;
mathParams.dwNumAluParams = 3;
CM_CHK_MOSSTATUS_GOTOFINISH(mhwMiInterface->AddMiMathCmd(cmdBuffer, &mathParams)); //MI cmd to clear R1 - R3
MOS_ZeroMemory(&loadRegMemParams, sizeof(loadRegMemParams));
loadRegMemParams.presStoreBuffer = conditionalParams->presSemaphoreBuffer;
loadRegMemParams.dwOffset = conditionalParams->dwOffset;
loadRegMemParams.dwRegister = offsets->gprOffset + 8 * 1;
CM_CHK_MOSSTATUS_GOTOFINISH(mhwMiInterface->AddMiLoadRegisterMemCmd(cmdBuffer, &loadRegMemParams)); //R1: compared value 32bits, in coditional surface
// Load current tracker tag from resource to R8
MOS_ZeroMemory(&loadRegMemParams, sizeof(loadRegMemParams));
state->renderHal->trackerProducer.GetLatestTrackerResource(state->renderHal->currentTrackerIndex,
&loadRegMemParams.presStoreBuffer,
&loadRegMemParams.dwOffset);
loadRegMemParams.dwRegister = offsets->gprOffset+ 8 * 8;
CM_CHK_MOSSTATUS_GOTOFINISH(mhwMiInterface->AddMiLoadRegisterMemCmd(cmdBuffer, &loadRegMemParams)); // R8: current tracker tag
// Load new tag passed to this function to R9
MOS_ZeroMemory(&loadRegImmParams, sizeof(loadRegImmParams));
loadRegImmParams.dwData = trackerTag;
loadRegImmParams.dwRegister = offsets->gprOffset+ 8 * 9;
CM_CHK_MOSSTATUS_GOTOFINISH(mhwMiInterface->AddMiLoadRegisterImmCmd(cmdBuffer, &loadRegImmParams)); // R9: new tracker tag
//
if (!conditionalParams->bDisableCompareMask)
{
loadRegMemParams.presStoreBuffer = conditionalParams->presSemaphoreBuffer;
loadRegMemParams.dwOffset = conditionalParams->dwOffset + 4;
loadRegMemParams.dwRegister = offsets->gprOffset + 8 * 2;
CM_CHK_MOSSTATUS_GOTOFINISH(mhwMiInterface->AddMiLoadRegisterMemCmd(cmdBuffer, &loadRegMemParams)); //r1, r2: compared value and its mask
//load1 reg1, srca
aluParams[0].AluOpcode = MHW_MI_ALU_LOAD;
aluParams[0].Operand1 = MHW_MI_ALU_SRCA;
aluParams[0].Operand2 = MHW_MI_ALU_GPREG1;
//load reg2, srcb
aluParams[1].AluOpcode = MHW_MI_ALU_LOAD;
aluParams[1].Operand1 = MHW_MI_ALU_SRCB;
aluParams[1].Operand2 = MHW_MI_ALU_GPREG2;
//add
aluParams[2].AluOpcode = MHW_MI_ALU_AND;
//store reg1, accu
aluParams[3].AluOpcode = MHW_MI_ALU_STORE;
aluParams[3].Operand1 = MHW_MI_ALU_GPREG1;
aluParams[3].Operand2 = MHW_MI_ALU_ACCU; //REG14 = TS + 1
mathParams.pAluPayload = aluParams;
mathParams.dwNumAluParams = 4;
CM_CHK_MOSSTATUS_GOTOFINISH(mhwMiInterface->AddMiMathCmd(cmdBuffer, &mathParams)); //R1 & R2 --> R1: compared value, to be used
}
MOS_ZeroMemory(&loadRegImmParams, sizeof(loadRegImmParams));
loadRegImmParams.dwData = conditionalParams->dwValue;
loadRegImmParams.dwRegister = offsets->gprOffset + 8 * 2;
CM_CHK_MOSSTATUS_GOTOFINISH(mhwMiInterface->AddMiLoadRegisterImmCmd(cmdBuffer, &loadRegImmParams)); //R2: user value 32bits
MOS_ZeroMemory(&loadRegImmParams, sizeof(loadRegImmParams));
loadRegImmParams.dwData = 1;
loadRegImmParams.dwRegister = offsets->gprOffset + 8 * 3;
CM_CHK_MOSSTATUS_GOTOFINISH(mhwMiInterface->AddMiLoadRegisterImmCmd(cmdBuffer, &loadRegImmParams)); //R3 = 1
//load1 reg3, srca
aluParams[0].AluOpcode = MHW_MI_ALU_LOAD;
aluParams[0].Operand1 = MHW_MI_ALU_SRCA;
aluParams[0].Operand2 = MHW_MI_ALU_GPREG3;
//load reg0, srcb
aluParams[1].AluOpcode = MHW_MI_ALU_LOAD;
aluParams[1].Operand1 = MHW_MI_ALU_SRCB;
aluParams[1].Operand2 = MHW_MI_ALU_GPREG0;
//add
aluParams[2].AluOpcode = MHW_MI_ALU_ADD;
//store reg14, accu
aluParams[3].AluOpcode = MHW_MI_ALU_STORE;
aluParams[3].Operand1 = MHW_MI_ALU_GPREG14;
aluParams[3].Operand2 = MHW_MI_ALU_ACCU; //REG14 = TS + 1
// load srcB, reg1
aluParams[4].AluOpcode = MHW_MI_ALU_LOAD;
aluParams[4].Operand1 = MHW_MI_ALU_SRCB;
aluParams[4].Operand2 = MHW_MI_ALU_GPREG1; //load compared val
// load srcA, reg2
aluParams[5].AluOpcode = MHW_MI_ALU_LOAD;
aluParams[5].Operand1 = MHW_MI_ALU_SRCA;
aluParams[5].Operand2 = MHW_MI_ALU_GPREG2; //load user val
// sub srcA, srcB
aluParams[6].AluOpcode = MHW_MI_ALU_SUB; //if (compared > user) 1 ==> CF otherwise 0 ==> CF
// store reg4, CF
aluParams[7].AluOpcode = MHW_MI_ALU_STOREINV;
aluParams[7].Operand1 = MHW_MI_ALU_GPREG4;
aluParams[7].Operand2 = MHW_MI_ALU_CF; //!CF ==> R4, mask
//load reg4, srcA
aluParams[8].AluOpcode = MHW_MI_ALU_LOAD;
aluParams[8].Operand1 = MHW_MI_ALU_SRCA;
aluParams[8].Operand2 = MHW_MI_ALU_GPREG4;
//load reg14, SRCB
aluParams[9].AluOpcode = MHW_MI_ALU_LOAD;
aluParams[9].Operand1 = MHW_MI_ALU_SRCB;
aluParams[9].Operand2 = MHW_MI_ALU_GPREG14;
//and
aluParams[10].AluOpcode = MHW_MI_ALU_AND; //0 or TS+1 (!CF & TS)
//store reg6, accu
aluParams[11].AluOpcode = MHW_MI_ALU_STORE; //R6 = (TS+1) (to terminate) or 0 (to continue)
aluParams[11].Operand1 = MHW_MI_ALU_GPREG6;
aluParams[11].Operand2 = MHW_MI_ALU_ACCU;
//invalud time stamp is all '1's for MDF
//load reg6, SRCA
aluParams[12].AluOpcode = MHW_MI_ALU_LOAD;
aluParams[12].Operand1 = MHW_MI_ALU_SRCA;
aluParams[12].Operand2 = MHW_MI_ALU_GPREG6;
//load1 SRCB
aluParams[13].AluOpcode = MHW_MI_ALU_LOAD;
aluParams[13].Operand1 = MHW_MI_ALU_SRCB;
aluParams[13].Operand2 = MHW_MI_ALU_GPREG3;
//sub
aluParams[14].AluOpcode = MHW_MI_ALU_SUB; //-1 or TS (!CF & TS)
//store reg7, accu
aluParams[15].AluOpcode = MHW_MI_ALU_STORE; //R7 = (TS) (to terminate) or all '1' ( -1 to continue)
aluParams[15].Operand1 = MHW_MI_ALU_GPREG7;
aluParams[15].Operand2 = MHW_MI_ALU_ACCU;
mathParams.pAluPayload = aluParams;
mathParams.dwNumAluParams = 16;
CM_CHK_MOSSTATUS_GOTOFINISH(mhwMiInterface->AddMiMathCmd(cmdBuffer, &mathParams)); //set artifact time stamp (-1 or TS) per condition in GPR R7
// Add R3 (has value 1) to R4 (~CF) and store result in R10
aluParams[0].AluOpcode = MHW_MI_ALU_LOAD;
aluParams[0].Operand1 = MHW_MI_ALU_SRCA;
aluParams[0].Operand2 = MHW_MI_ALU_GPREG3;
aluParams[1].AluOpcode = MHW_MI_ALU_LOAD;
aluParams[1].Operand1 = MHW_MI_ALU_SRCB;
aluParams[1].Operand2 = MHW_MI_ALU_GPREG4;
aluParams[2].AluOpcode = MHW_MI_ALU_ADD;
aluParams[3].AluOpcode = MHW_MI_ALU_STORE;
aluParams[3].Operand1 = MHW_MI_ALU_GPREG10;
aluParams[3].Operand2 = MHW_MI_ALU_ACCU;
// AND R8 (current tracker tag) with R10 (~CF + 1) and store in R11
aluParams[4].AluOpcode = MHW_MI_ALU_LOAD;
aluParams[4].Operand1 = MHW_MI_ALU_SRCA;
aluParams[4].Operand2 = MHW_MI_ALU_GPREG8;
aluParams[5].AluOpcode = MHW_MI_ALU_LOAD;
aluParams[5].Operand1 = MHW_MI_ALU_SRCB;
aluParams[5].Operand2 = MHW_MI_ALU_GPREG10;
aluParams[6].AluOpcode = MHW_MI_ALU_AND;
aluParams[7].AluOpcode = MHW_MI_ALU_STORE;
aluParams[7].Operand1 = MHW_MI_ALU_GPREG11;
aluParams[7].Operand2 = MHW_MI_ALU_ACCU;
// Store inverse of R10 (-1 --> continue, 0 --> terminate) to R12
aluParams[8].AluOpcode = MHW_MI_ALU_STOREINV;
aluParams[8].Operand1 = MHW_MI_ALU_GPREG12;
aluParams[8].Operand2 = MHW_MI_ALU_GPREG10;
// AND R9 (new tracker tag) and R12 and store in R13
aluParams[9].AluOpcode = MHW_MI_ALU_LOAD;
aluParams[9].Operand1 = MHW_MI_ALU_SRCA;
aluParams[9].Operand2 = MHW_MI_ALU_GPREG9;
aluParams[10].AluOpcode = MHW_MI_ALU_LOAD;
aluParams[10].Operand1 = MHW_MI_ALU_SRCB;
aluParams[10].Operand2 = MHW_MI_ALU_GPREG12;
aluParams[11].AluOpcode = MHW_MI_ALU_AND;
aluParams[12].AluOpcode = MHW_MI_ALU_STORE;
aluParams[12].Operand1 = MHW_MI_ALU_GPREG13;
aluParams[12].Operand2 = MHW_MI_ALU_ACCU;
// ADD R11 and R13 and store in R15
aluParams[13].AluOpcode = MHW_MI_ALU_LOAD;
aluParams[13].Operand1 = MHW_MI_ALU_SRCA;
aluParams[13].Operand2 = MHW_MI_ALU_GPREG11;
aluParams[14].AluOpcode = MHW_MI_ALU_LOAD;
aluParams[14].Operand1 = MHW_MI_ALU_SRCB;
aluParams[14].Operand2 = MHW_MI_ALU_GPREG13;
aluParams[15].AluOpcode = MHW_MI_ALU_ADD;
aluParams[16].AluOpcode = MHW_MI_ALU_STORE;
aluParams[16].Operand1 = MHW_MI_ALU_GPREG15;
aluParams[16].Operand2 = MHW_MI_ALU_ACCU;
mathParams.pAluPayload = aluParams;
mathParams.dwNumAluParams = 17;
CM_CHK_MOSSTATUS_GOTOFINISH(mhwMiInterface->AddMiMathCmd(cmdBuffer, &mathParams));
// Store R15 to trackerResource
MOS_ZeroMemory(&storeRegMemParams, sizeof(storeRegMemParams));
state->renderHal->trackerProducer.GetLatestTrackerResource(state->renderHal->currentTrackerIndex,
&storeRegMemParams.presStoreBuffer,
&storeRegMemParams.dwOffset);
storeRegMemParams.dwRegister = offsets->gprOffset+ 8 * 15;
CM_CHK_MOSSTATUS_GOTOFINISH(mhwMiInterface->AddMiStoreRegisterMemCmd(cmdBuffer, &storeRegMemParams));
//store R6 to synclocation
MOS_ZeroMemory(&storeRegMemParams, sizeof(storeRegMemParams));
storeRegMemParams.presStoreBuffer = &state->renderTimeStampResource.osResource;
storeRegMemParams.dwOffset = syncOffset + sizeof(uint64_t);
storeRegMemParams.dwRegister = offsets->gprOffset + 8 * 7;
CM_CHK_MOSSTATUS_GOTOFINISH(mhwMiInterface->AddMiStoreRegisterMemCmd(cmdBuffer, &storeRegMemParams));
storeRegMemParams.presStoreBuffer = &state->renderTimeStampResource.osResource;
storeRegMemParams.dwOffset = syncOffset + sizeof(uint64_t) + 4;
storeRegMemParams.dwRegister = offsets->gprOffset + 4 + 8 * 7 ;
CM_CHK_MOSSTATUS_GOTOFINISH(mhwMiInterface->AddMiStoreRegisterMemCmd(cmdBuffer, &storeRegMemParams));
// Insert a pipe control for synchronization
pipeCtrlParams = g_cRenderHal_InitPipeControlParams;
pipeCtrlParams.dwPostSyncOp = MHW_FLUSH_NOWRITE;
pipeCtrlParams.dwFlushMode = MHW_FLUSH_WRITE_CACHE;
CM_CHK_MOSSTATUS_GOTOFINISH(mhwMiInterface->AddPipeControl(cmdBuffer, nullptr, &pipeCtrlParams));
pipeCtrlParams.dwFlushMode = MHW_FLUSH_READ_CACHE;
CM_CHK_MOSSTATUS_GOTOFINISH(mhwMiInterface->AddPipeControl(cmdBuffer, nullptr, &pipeCtrlParams));
finish:
return eStatus;
};
uint32_t HalCm_GetNumCmdBuffers(PMOS_INTERFACE osInterface, uint32_t maxTaskNumber)
{
UNUSED(maxTaskNumber);
return 0;
}
MOS_STATUS HalCm_GetSipBinary(PCM_HAL_STATE state)
{
UNUSED(state);
// Function not implemented on Linux, just return success for sanity check
return MOS_STATUS_SUCCESS;
}
MOS_STATUS HalCm_SetupSipSurfaceState(
PCM_HAL_STATE state,
PCM_HAL_INDEX_PARAM indexParam,
int32_t bindingTable)
{
UNUSED(state);
UNUSED(indexParam);
UNUSED(bindingTable);
// Function not implemented on Linux, just return success for sanity check
return MOS_STATUS_SUCCESS;
}
//!
//! \brief Prepare virtual engine hint parametere
//! \details Prepare virtual engine hint parameter for CCS node
//! \param PCM_HAL_STATE state
//! [in] Pointer to CM_HAL_STATE Structure
//! \param bool bScalable
//! [in] is scalable pipe or single pipe
//! \param PMOS_VIRTUALENGINE_HINT_PARAMS pVeHintParam
//! [out] Pointer to prepared VE hint parameter struct
//! \return MOS_STATUS
//!
MOS_STATUS HalCm_PrepareVEHintParam(
PCM_HAL_STATE state,
bool bScalable,
PMOS_VIRTUALENGINE_HINT_PARAMS pVeHintParam)
{
return MOS_STATUS_UNIMPLEMENTED;
}
//!
//! \brief Decompress the surface
//! \details Decompress the media compressed surface
//! \param PCM_HAL_STATE state
//! [in] Pointer to CM_HAL_STATE Structure
//! \param PCM_HAL_KERNEL_ARG_PARAM argParam
//! [in]Pointer to HAL cm kernel argrument parameter
//! \param uint32_t threadIndex
//! [in] is used to get index of surface array
//! \return MOS_STATUS
//!
MOS_STATUS HalCm_DecompressSurface(
PCM_HAL_STATE state,
PCM_HAL_KERNEL_ARG_PARAM argParam,
uint32_t threadIndex)
{
MOS_STATUS eStatus = MOS_STATUS_SUCCESS;
uint32_t handle = 0;
uint8_t *src = nullptr;
PCM_HAL_SURFACE2D_ENTRY pEntry = nullptr;
PMOS_RESOURCE pOsResource = nullptr;
PMOS_INTERFACE pOsInterface = nullptr;
GMM_RESOURCE_FLAG GmmFlags = { 0 };
//Get the index of surface array handle from kernel data
CM_ASSERT(argParam->unitSize == sizeof(handle));
src = argParam->firstValue + (threadIndex * argParam->unitSize);
handle = *((uint32_t *)src) & CM_SURFACE_MASK;
if (handle == CM_NULL_SURFACE)
{
eStatus = MOS_STATUS_SUCCESS;
goto finish;
}
pEntry = &state->umdSurf2DTable[handle];
pOsResource = &pEntry->osResource;
pOsInterface = state->osInterface;
if (pOsResource->pGmmResInfo)
{
GmmFlags = pOsResource->pGmmResInfo->GetResFlags();
if (GmmFlags.Gpu.MMC || pOsResource->pGmmResInfo->IsMediaMemoryCompressed(0))
{
MOS_OS_ASSERT(pOsInterface);
pOsInterface->pfnDecompResource(pOsInterface, pOsResource);
}
}
finish:
return eStatus;
}
MOS_STATUS HalCm_SurfaceSync(
PCM_HAL_STATE pState,
PMOS_SURFACE pSurface,
bool bReadSync )
{
UNUSED(pState);
UNUSED(pSurface);
UNUSED(bReadSync);
return MOS_STATUS_SUCCESS;
}
|