[c-host] add ability to provide NvFBC privData

This commit is contained in:
Geoffrey McRae 2019-04-10 22:23:56 +10:00
parent 878eb057d1
commit bee221c18d
2 changed files with 25 additions and 3 deletions

View File

@ -1 +1 @@
a12-148-gda7c66419a+1 a12-149-g878eb057d1+1

View File

@ -85,13 +85,35 @@ static bool nvfbc_create()
if (!NvFBCInit()) if (!NvFBCInit())
return false; return false;
this = (struct iface *)calloc(sizeof(struct iface), 1); int bufferLen = GetEnvironmentVariable("NVFBC_PRIV_DATA", NULL, 0);
uint8_t * privData = NULL;
int privDataLen = 0;
if (!NvFBCToSysCreate(NULL, 0, &this->nvfbc, &this->maxWidth, &this->maxHeight)) if(bufferLen)
{ {
char * buffer = malloc(bufferLen);
GetEnvironmentVariable("NVFBC_PRIV_DATA", buffer, bufferLen);
privDataLen = (bufferLen - 1) / 2;
privData = (uint8_t *)malloc(privDataLen);
char hex[3] = {0};
for(int i = 0; i < privDataLen; ++i)
{
memcpy(hex, &buffer[i*2], 2);
privData[i] = (uint8_t)strtoul(hex, NULL, 16);
}
free(buffer);
}
this = (struct iface *)calloc(sizeof(struct iface), 1);
if (!NvFBCToSysCreate(privData, privDataLen, &this->nvfbc, &this->maxWidth, &this->maxHeight))
{
free(privData);
nvfbc_free(); nvfbc_free();
return false; return false;
} }
free(privData);
this->frameEvent = os_createEvent(true); this->frameEvent = os_createEvent(true);
if (!this->frameEvent) if (!this->frameEvent)