| 1486 | } |
| 1487 | |
| 1488 | void parseGPUConfigurationLine(char* currentLine, uint32_t preferedGpuId) |
| 1489 | { |
| 1490 | char propertyName[MAX_GPU_VENDOR_STRING_LENGTH] = {}; |
| 1491 | char ruleParameters[MAX_GPU_VENDOR_STRING_LENGTH] = {}; |
| 1492 | char assignmentValue[MAX_GPU_VENDOR_STRING_LENGTH] = {}; |
| 1493 | |
| 1494 | // parse selection rule |
| 1495 | size_t ruleLength = strcspn(currentLine, "#"); |
| 1496 | const char* pLineEnd = currentLine + ruleLength; |
| 1497 | GPUConfigurationRule* currentConfigurationRule = |
| 1498 | &gGraphicsConfigRules.mGPUConfigurationRules[gGraphicsConfigRules.mGPUConfigurationRulesCount]; |
| 1499 | *currentConfigurationRule = {}; |
| 1500 | char* tokens[] = { propertyName, ruleParameters, assignmentValue }; |
| 1501 | tokenizeLine(currentLine, pLineEnd, ";", MAX_GPU_VENDOR_STRING_LENGTH, TF_ARRAY_COUNT(tokens), tokens); |
| 1502 | char* rulesBegin = ruleParameters; |
| 1503 | currentConfigurationRule->pUpdateProperty = propertyNameToGpuProperty(stringToLower(propertyName)); |
| 1504 | if (currentConfigurationRule->pUpdateProperty) |
| 1505 | { |
| 1506 | // check assignment value |
| 1507 | int base = ((strcmp(currentConfigurationRule->pUpdateProperty->name, "vendorid") == 0) || |
| 1508 | (strcmp(currentConfigurationRule->pUpdateProperty->name, "deviceid") == 0)) |
| 1509 | ? 16 |
| 1510 | : 10; |
| 1511 | bool validConversion = false; |
| 1512 | if (strcmp(currentConfigurationRule->pUpdateProperty->name, "gpupresetlevel") == 0) |
| 1513 | { |
| 1514 | currentConfigurationRule->assignmentValue = stringToPresetLevel(assignmentValue); |
| 1515 | validConversion = currentConfigurationRule->assignmentValue != GPU_PRESET_NONE; |
| 1516 | ASSERT(validConversion); |
| 1517 | } |
| 1518 | else |
| 1519 | { |
| 1520 | validConversion = stringToLargeInteger(assignmentValue, ¤tConfigurationRule->assignmentValue, base); |
| 1521 | } |
| 1522 | // parse comparison rules separated by "," |
| 1523 | parseConfigurationRules(¤tConfigurationRule->pConfigurationRules, ¤tConfigurationRule->comparisonRulesCount, rulesBegin, |
| 1524 | preferedGpuId); |
| 1525 | if (currentConfigurationRule->pConfigurationRules == NULL) |
| 1526 | { |
| 1527 | LOGF(eDEBUG, "parseGPUConfigurationSetting: invalid rules for Field name: '%s'.", |
| 1528 | currentConfigurationRule->pUpdateProperty->name); |
| 1529 | tf_free(currentConfigurationRule->pConfigurationRules); |
| 1530 | } |
| 1531 | else if (!validConversion) |
| 1532 | { |
| 1533 | LOGF(eDEBUG, "parseGPUConfigurationSetting: cannot convert %s for Field name: '%s'.", assignmentValue, |
| 1534 | currentConfigurationRule->pUpdateProperty->name); |
| 1535 | tf_free(currentConfigurationRule->pConfigurationRules); |
| 1536 | } |
| 1537 | else |
| 1538 | { |
| 1539 | gGraphicsConfigRules.mGPUConfigurationRulesCount++; |
| 1540 | } |
| 1541 | } |
| 1542 | else |
| 1543 | { |
| 1544 | LOGF(eDEBUG, "parseGPUConfigurationSetting: invalid property: '%s'.", propertyName); |
| 1545 | tf_free(currentConfigurationRule->pConfigurationRules); |
no test coverage detected