38#if __linux__ || __APPLE__
53#include <sys/syslimits.h>
67#if __linux__ || __APPLE__
76#define PCI_BDF_STR_LEN 12
77#define PCIE_ADDRS_MAX 16
78#define PCIE_GEN4_LINK_SPEED 16
81static int read_file_content(
const char *path,
char *buf,
size_t bufsz)
83 FILE *fp = fopen(path,
"r");
84 int n = (bufsz > (size_t)INT_MAX) ? INT_MAX : (int)bufsz;
87 if (!fgets(buf, n, fp))
93 char *nl = strchr(buf,
'\n');
99static int find_root_port_from_device(
const char *device_bdf,
char *root_port_bdf)
101 char block_path[PATH_MAX];
102 char abs_path[PATH_MAX];
103 char *ptr, *saveptr = NULL;
107 struct dirent *entry;
109 if (!device_bdf || !root_port_bdf)
112 dir = opendir(
"/sys/block");
116 while ((entry = readdir(dir)))
119 if (strncmp(entry->d_name,
"nvme", 4) != 0)
122 snprintf(block_path,
sizeof(block_path),
"/sys/block/%s", entry->d_name);
124 if (realpath(block_path, abs_path) == NULL)
127 if (strstr(abs_path, device_bdf) == NULL)
130 ptr = strtok_r(abs_path,
"/", &saveptr);
135 unsigned int d, b, dev, f;
136 if (sscanf(ptr,
"%x:%x:%x.%x", &d, &b, &dev, &f) == 4)
141 if (pcie_addrs[addr_count]) {
149 ptr = strtok_r(NULL,
"/", &saveptr);
152 for (
int i = addr_count - 2; i >= 0; i--)
154 char class_path[PATH_MAX];
156 unsigned long class_val;
161 snprintf(class_path,
sizeof(class_path),
"/sys/bus/pci/devices/%s/class", pcie_addrs[i]);
162 if (read_file_content(class_path, class_buf,
sizeof(class_buf)) != 0)
165 class_val = strtoul(class_buf, NULL, 0);
166 if ((class_val & 0xffff00) != 0x060400)
171 for (
int j = 0; j < addr_count; j++)
180 for (
int j = 0; j < addr_count; j++)
191static int read_pcie_capability_sysfs(
const char *bdf)
194 char raw_buf[64] = {0};
199 snprintf(path,
sizeof(path),
"/sys/bus/pci/devices/%s/max_link_speed", bdf);
200 if (read_file_content(path, raw_buf,
sizeof(raw_buf)) != 0)
203 if (raw_buf[0] ==
'\0')
206 unsigned int speed_num = 0;
207 if (sscanf(raw_buf,
"%u", &speed_num) != 1)
209 return (
int)speed_num;
212static int get_pcie_gen3_on_gen4_status(
const char *device_name, uint8_t fw_flavour)
215 char host_port[64] = {0};
216 int device_speed_num = -1;
217 int host_speed_num = -1;
223 device_speed_num = read_pcie_capability_sysfs(pcie);
224 if (find_root_port_from_device(pcie, host_port) == 0)
225 host_speed_num = read_pcie_capability_sysfs(host_port);
227 if (device_speed_num >= 0 && host_speed_num >= 0 &&
366 const char *l = (
const char *)p_str;
367 const char *r = (
const char *)p_str1;
370 while (!isdigit(*l) && (*l) !=
'\0')
374 while (!isdigit(*r) && (*r) !=
'\0')
408 snprintf(p_name, max_name_len,
"%s/NI_QUADRA_lck_%c%d",
LOCK_DIR, type, guid);
412 snprintf(p_name, max_name_len,
"%s/NI_lck_%c%d",
LOCK_DIR, type, guid);
432 snprintf(p_name, max_name_len,
"NI_QUADRA_shm_%c%d", type, guid);
436 snprintf(p_name, max_name_len,
"NI_shm_%c%d", type, guid);
443 const ni_device_handle_t device_handle,
445 const int fw_ver_compat_warning,
450 int gen3_on_gen4 = -1;
460 memcpy(device_info->
fw_rev,
461 device_capability->
fw_rev,
462 sizeof(device_info->
fw_rev));
499 gen3_on_gen4 = get_pcie_gen3_on_gen4_status(device_name, extra_info.
fw_flavour);
500 if (gen3_on_gen4 < 0)
509 const int should_match_rev,
510 const int existing_number_of_devices,
513 int i, j, compatible_device_counter;
520 device_queue->
xcoders[i][j] = -1;
524 compatible_device_counter = 0;
525 for (i = 0; i < existing_number_of_devices; i++)
534 compatible_device_counter++;
538 "Maximum number of supported and compatible devices "
539 "reached. Ignoring other supported and compatible "
553 uint32_t guid_mask[4] = {0};
557 temp_guid = device_queue->
xcoders[device_type][i];
560 guid_mask[temp_guid / 32] |= (1u << ((uint32_t)temp_guid % 32));
564 for (i = 0; i < 4; i++)
566 for (j = 0; j < 32; j++)
568 if ((guid_mask[i] & (1u << j)) == 0)
570 *guidn = (i * 32) + j;
580 const bool device_open_should_succeed,
581 const int should_match_rev,
585 int i, j, fw_compat_cmp;
586 char fw_api_ver_str[5];
589 ni_device_handle_t device_handle;
598 if (device_handle == NI_INVALID_DEVICE_HANDLE)
600 if (device_open_should_succeed)
603 "ERROR: %s(): Failed to add %s\n: Failed ni_device_open2()\n",
624 if (should_match_rev && \
629 "Skipping %s init: device FW v%s incompatible with this version of Libxcoder\n",
643 "%s %s disabled...\n",
650 guid = j ? device_queue->
xcoders[i][j-1] + 1 : 0;
654 "initialized devices exceeds %d\n", __FUNCTION__,
659 device_queue->
xcoders[i][j] = guid;
662 fill_device_info(&device_info,
666 (should_match_rev && fw_compat_cmp) ? 1 : 0,
673 if (fw_compat_cmp < 0) {
675 "Libxcoder supported FW API version\n", device_name,
677 }
else if (fw_compat_cmp > 0) {
679 "Libxcoder supported FW API version\n", device_name,
685 ret_ts = system(
"host_ts.sh");
705 for(i = 0; i <
sizeof(XCODERS_RETRY_LCK_NAME) /
sizeof(XCODERS_RETRY_LCK_NAME[0]); ++i)
707 retry_shm_fd = open(XCODERS_RETRY_LCK_NAME[i], O_RDWR | O_CREAT | O_CLOEXEC | O_EXCL, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP);
714 ni_log(
NI_LOG_ERROR,
"Failed to create %s ERROR: %s\n", XCODERS_RETRY_LCK_NAME[i], errmsg);
760 char shm_name[32] = { 0 };
761 char lck_name[32] = { 0 };
764 HANDLE map_file_handle = NULL;
765 ni_lock_handle_t mutex_handle = NULL;
766 SECURITY_DESCRIPTOR security_descriptor = { 0 };
775 ni_log(
NI_LOG_DEBUG,
"%s(): shm_name %s, lck_name %s\n", __func__, shm_name, lck_name);
778 mutex_handle = CreateMutex(NULL,
781 if (NULL == mutex_handle)
787 if (WAIT_ABANDONED == WaitForSingleObject(mutex_handle, INFINITE))
790 "obtain mutex: %p\n", mutex_handle);
794 InitializeSecurityDescriptor(&security_descriptor, SECURITY_DESCRIPTOR_REVISION);
797 map_file_handle = CreateFileMapping(
798 INVALID_HANDLE_VALUE,
806 if (NULL == map_file_handle)
816 if (ERROR_ALREADY_EXISTS == rc)
823 ni_log(
NI_LOG_INFO,
"CreateFileMapping created a new mapFile for %s, handle: %p ..\n", shm_name, map_file_handle);
835 if (NULL == p_coder_info_map)
845 if (p_coder_info_map)
847 UnmapViewOfFile(p_coder_info_map);
851 ReleaseMutex(mutex_handle);
871 if ((!p_device_context) || (!p_session_context))
921 const int existing_number_of_devices,
926 HANDLE map_file_handle = NULL;
928 map_file_handle = CreateFileMapping(
929 INVALID_HANDLE_VALUE,
937 if (NULL == map_file_handle)
946 if(ERROR_ALREADY_EXISTS == rc)
948 ni_log(
NI_LOG_INFO,
"NETINT resources have been initialized already, exiting ..\n");
949 CloseHandle(map_file_handle);
954 ni_log(
NI_LOG_INFO,
"NETINT resources not initialized, starting initialization ..\n");
966 if (NULL == p_device_queue)
970 CloseHandle(map_file_handle);
979 UnmapViewOfFile(p_device_queue);
980 CloseHandle(map_file_handle);
984 if (WAIT_ABANDONED == WaitForSingleObject(lock, INFINITE))
990 UnmapViewOfFile(p_device_queue);
991 CloseHandle(map_file_handle);
995 fill_shared_memory(p_device_queue,
997 existing_number_of_devices,
998 existing_device_names);
1000 UnmapViewOfFile(p_device_queue);
1006#elif __linux__ || __APPLE__
1016static bool check_correctness_count(
const ni_device_queue_t *existing_device_queue,
1017 const int should_match_rev,
1018 const int existing_number_of_devices,
1024 bool device_found_in_queue;
1027 ni_device_handle_t device_handle;
1039 for (queue_idx = 0; queue_idx < existing_device_queue->
xcoder_cnt[j]; queue_idx++)
1041 guid = existing_device_queue->
xcoders[j][queue_idx];
1051 ni_log(
NI_LOG_ERROR,
"ERROR: %s(): guid_map_count[%d] exceeds NI_MAX_DEVICE_CNT\n", __func__, j);
1055 guid_map[j][guid_map_count[j]].guid = guid;
1058 guid_map_count[j]++;
1061 else if (device_context)
1069 for (i = 0; i < existing_number_of_devices; i++)
1072 if (device_handle == NI_INVALID_DEVICE_HANDLE)
1079 (should_match_rev && \
1092 device_found_in_queue =
false;
1093 for (queue_idx = 0; queue_idx < guid_map_count[j]; queue_idx++)
1097 device_found_in_queue =
true;
1101 if (!device_found_in_queue)
1109 for (queue_idx = 0; queue_idx < guid_map_count[k]; queue_idx++)
1114 "ERROR: %s(): Discovered device %s is not in queue for module %s but is in %s\n",
1137 "WARNING: %s(): Discovered %u %s, expected %u\n",
1148 const int existing_number_of_devices,
1156 for (i = 0; i < existing_number_of_devices; i++)
1160 module_id = existing_device_queue->
xcoders[j][i];
1161 if (module_id == -1)
1167 if (!device_context)
1170 "WARNING: %s(): Missing device context for %s %s\n",
1189static void sigbus_handler(
int signal)
1194static void setup_signal_handler(
struct sigaction *p,
const int signum)
1198 memset(&c, 0,
sizeof(
struct sigaction));
1199 if (sigemptyset(&c.sa_mask) == -1)
1202 "ERROR: %s(): Could not initialize signal set: %d\n",
1207 c.sa_handler = sigbus_handler;
1209 if (sigaction(signum, NULL, p) == -1)
1212 "ERROR: %s(): Could not save previous signal handler: %d\n",
1218 if (sigaction(signum, &c, NULL) == -1)
1221 "ERROR: %s(): Could not register signal handler: %d\n",
1230 const int should_match_rev,
1231 const int existing_number_of_devices,
1234 bool result =
false;
1236 const int signum = SIGBUS;
1239 setup_signal_handler(&p, signum);
1241 if (sigsetjmp(env, 1))
1247 if (!check_correctness_count(existing_device_queue,
1249 existing_number_of_devices,
1255 if (!check_device_queue(existing_device_queue,
1256 existing_number_of_devices,
1267 if (sigaction(signum, &p, NULL) == -1)
1270 "ERROR: %s(): Could not restore previous signal handler: %d\n",
1280 const int existing_number_of_devices,
1284 int return_value = 0;
1287 ni_rsrc_shm_state state = NI_RSRC_SHM_IS_INVALID;
1288 int flags = O_CREAT | O_RDWR | O_CLOEXEC;
1289 mode_t mode = S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP;
1292 if ((ni_rsrc_try_get_shm_lock(
CODERS_LCK_NAME, flags, mode, &lck_fd) < 0) ||
1301 (
void **)&p_device_queue)) < 0) {
1308 if (NI_RSRC_SHM_IS_EXISTED == state) {
1309 if (check_correctness(p_device_queue,
1311 existing_number_of_devices,
1312 existing_device_names))
1320 if (lockf(lck_fd, F_ULOCK, 0) < 0) {
1326#ifndef __OPENHARMONY__
1329 ni_rsrc_remove_all_shm();
1331 if (limit_depth <= 0)
1336 existing_number_of_devices,
1337 existing_device_names,
1341 fill_shared_memory(p_device_queue,
1343 existing_number_of_devices,
1344 existing_device_names);
1347 if (p_device_queue && p_device_queue != MAP_FAILED) {
1349 p_device_queue = NULL;
1354 if (lockf(lck_fd, F_ULOCK, 0) < 0) {
1361#ifndef __OPENHARMONY__
1367 return return_value;
1379 int32_t shm_fd = -1;
1380 ni_rsrc_shm_state state = NI_RSRC_SHM_IS_INVALID;
1382 int flags = O_CREAT | O_RDWR | O_CLOEXEC;
1383 mode_t mode = S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP;
1384 char shm_name[32] = { 0 };
1385 char lck_name[32] = { 0 };
1388 if(! p_device_info) {
1395 ni_log(
NI_LOG_DEBUG,
"%s(): shm_name %s, lck_name %s\n", __func__, shm_name, lck_name);
1397 if (ni_rsrc_try_get_shm_lock(lck_name, flags, mode, (
int *)&lock) < 0) {
1402 if (ni_rsrc_open_shm(shm_name,
1405 (
int *)&shm_fd) < 0) {
1410 if ((ni_rsrc_mmap_shm(shm_name,
1413 (
void **)&p_coder_info_dst)) < 0) {
1420#ifndef __OPENHARMONY__
1421 if (msync((
void*)p_coder_info_dst,
sizeof(
ni_device_info_t), MS_SYNC | MS_INVALIDATE)) {
1432 if (p_coder_info_dst && p_coder_info_dst != MAP_FAILED) {
1434 p_coder_info_dst = NULL;
1438#ifndef __OPENHARMONY__
1444 if (lockf(lock, F_ULOCK, 0) < 0) {
1445 ni_log(
NI_LOG_ERROR,
"Will exit from %s(), but failed to unlock lck_fd for %s\n", __func__, shm_name);
1464 if ((!p_device_context) || (!p_session_context))
1499 "p_device_info: %s\n", __func__, errmsg);
1518 char *domain,
char *slot,
char *dev,
char *func)
1525 char path[PATH_MAX];
1528 if (!device_name || !strstr(device_name,
"/dev/nvme") || !pcie)
1533 char *start = device_name + 5;
1535 snprintf(path,
sizeof(path),
"/sys/block/%s", start);
1538 char target[PATH_MAX];
1539 ssize_t len = readlink(path, target,
sizeof(target) - 1);
1547 char *saveptr = NULL;
1549 pcie[4] = pcie[7] =
':';
1551 while(ptr != NULL) {
1555 ret = sscanf(ptr,
"%4c:%2c:%2c.%1c", pcie, pcie+5,pcie+8,pcie+11);
1568 if (!domain || !slot || !dev || !func)
1572 domain[4] = slot[2] = dev[2] = func[1] =
'\0';
1573 sscanf(pcie,
"%4[^:]:%2[^:]:%2[^.].%1s", domain, slot, dev, func);
1574 ni_log2(NULL,
NI_LOG_DEBUG,
"\t%d: Domain: %s, Slot: %s, Device: %s, Function: %s\n", i, domain, slot, dev, func);
1594ni_retcode_t ni_rsrc_try_get_shm_lock(
const char *lck_name,
1601 if (!lck_name || !lck_fd) {
1608 if (0 != mkdir(
LOCK_DIR, S_IRWXU | S_IRWXG | S_IRWXO)) {
1616 lock = open(lck_name, flags, mode);
1620 __func__, lck_name, errmsg);
1626 while (lockf(lock, F_TLOCK, 0) != 0)
1630 if (retry_cnt >= 900)
1633 ni_log(
NI_LOG_ERROR,
"ERROR %s() lockf() %s fail: %s\n", __func__, lck_name, errmsg);
1634 ni_log(
NI_LOG_ERROR,
"ERROR %s() If persists, stop traffic and run rm /dev/shm/NI_*\n", __func__);
1645#if defined(__OPENHARMONY__)
1646static ni_retcode_t openharmony_open_shm(
const char *shm_name,
1648 ni_rsrc_shm_state *state,
1652 int flag = IPC_CREAT | IPC_EXCL;
1653 char shm_path[PATH_MAX];
1655 if (!shm_name || !shm_fd) {
1660 memset(shm_path, 0, PATH_MAX);
1661 snprintf(shm_path, PATH_MAX,
"%s/%s",
LOCK_DIR, shm_name);
1665 if (0 != access(shm_path, F_OK)) {
1666 int fd = open(shm_path, O_RDWR | O_CREAT | O_CLOEXEC,
1667 S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP);
1670 ni_log(
NI_LOG_ERROR,
"ERROR: %s() open() %s fail: %s\n", __func__, shm_name, errmsg);
1678 key_t key = ftok(shm_path, PROJ_ID);
1685 *state = NI_RSRC_SHM_IS_CREATED;
1688 mode_t mode = S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH;
1689 shm_id = shmget(key, shm_size, mode | flag);
1692 *state = NI_RSRC_SHM_IS_EXISTED;
1694 shm_id = shmget(key, shm_size, mode | flag);
1708static ni_retcode_t openharmony_remove_shm(
const char *shm_name,
1712 char shm_path[PATH_MAX];
1719 memset(shm_path, 0, PATH_MAX);
1720 snprintf(shm_path, PATH_MAX,
"%s/%s",
LOCK_DIR, shm_name);
1723 if (0 != access(shm_path, F_OK)) {
1729 key_t key = ftok(shm_path, PROJ_ID);
1737 mode_t mode = S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH;
1738 shm_id = shmget(key, shm_size, mode);
1745 shmctl(shm_id, IPC_RMID,
nullptr);
1750#elif defined(_ANDROID)
1751static ni_retcode_t android_open_shm(
const char *shm_name,
1753 ni_rsrc_shm_state *state,
1756 int shm_fd_tmp = -1;
1758 if (!shm_name || !shm_fd) {
1769 *state = NI_RSRC_SHM_IS_CREATED;
1771 string param = shm_name;
1772 Return<void> retvalue =
1773 service->GetAppFlag(param, [&](int32_t ret, hidl_handle handle) {
1775 *state = NI_RSRC_SHM_IS_EXISTED;
1776 shm_fd_tmp = dup(handle->data[0]);
1782 if (!retvalue.isOk()) {
1787 if (shm_fd_tmp < 0) {
1788 int fd = ashmem_create_region(shm_name, shm_size);
1790 native_handle_t *native_handle = native_handle_create(1, 0);
1791 if (!native_handle) {
1795 native_handle->data[0] = fd;
1798 handle.setTo(native_handle,
true);
1799 service->SetAppFlag(param, handle);
1800 shm_fd_tmp = dup(fd);
1806 *shm_fd = shm_fd_tmp;
1811static ni_retcode_t android_remove_shm(
const char *shm_name,
1825 string param = shm_name;
1826 Return<void> retvalue =
service->RemoveAppFlag(param);
1827 if (!retvalue.isOk()) {
1843 Return<void> retvalue =
service->RemoveAllAppFlags();
1844 if (!retvalue.isOk()) {
1853static ni_retcode_t linux_open_shm(
const char *shm_name,
1855 ni_rsrc_shm_state *state,
1858 int shm_fd_tmp = -1;
1859 const mode_t mode = S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP;
1860 int flag = O_CREAT | O_EXCL | O_RDWR;
1861 bool skip_ftruncate =
false;
1863 if (!shm_name || !shm_fd) {
1868 *state = NI_RSRC_SHM_IS_CREATED;
1871 shm_fd_tmp = shm_open(shm_name, flag, mode);
1872 if (shm_fd_tmp < 0) {
1874 skip_ftruncate =
true;
1875 *state = NI_RSRC_SHM_IS_EXISTED;
1877 shm_fd_tmp = shm_open(shm_name, flag, mode);
1880 if (shm_fd_tmp < 0) {
1884 __func__, shm_name, errmsg);
1890 if (!skip_ftruncate && ftruncate(shm_fd_tmp, shm_size) < 0) {
1892 shm_unlink(shm_name);
1896 *shm_fd = shm_fd_tmp;
1922 ni_rsrc_shm_state *state,
1925#if defined(__OPENHARMONY__)
1926 return openharmony_open_shm(shm_name, shm_size, state, shm_fd);
1927#elif defined(_ANDROID)
1928 return android_open_shm(shm_name, shm_size, state, shm_fd);
1930 return linux_open_shm(shm_name, shm_size, state, shm_fd);
1953 if (!shm_name || !shm_addr) {
1959#ifdef __OPENHARMONY__
1960 *shm_addr = shmat(shm_fd,
nullptr, 0);
1961 if ((
void *)(-1) == *shm_addr) {
1968 *shm_addr = mmap(0, shm_size, PROT_READ | PROT_WRITE,
1969 MAP_SHARED, shm_fd, 0);
1970 if (MAP_FAILED == *shm_addr) {
2000#ifdef __OPENHARMONY__
2003 munmap(shm_addr, shm_size);
2024#ifdef __OPENHARMONY__
2025 return openharmony_remove_shm(shm_name, shm_size);
2026#elif defined(_ANDROID)
2027 return android_remove_shm(shm_name, shm_size);
2029 shm_unlink(shm_name);
2048 struct dirent *dirent;
2049 char path_to_remove[PATH_MAX];
2062 while ((dirent = readdir(dir)) != NULL) {
2063 if (strncmp(dirent->d_name,
"NI_", 3) != 0) {
2067 snprintf(path_to_remove, PATH_MAX,
"%s/%s",
LOCK_DIR, dirent->d_name);
2070 if (strncasecmp(dirent->d_name,
"NI_SHM", 6) == 0) {
2071#ifdef __OPENHARMONY__
2072 openharmony_remove_shm(dirent->d_name, 1);
2074 shm_unlink(dirent->d_name);
2079 remove(path_to_remove);
2083 android_remove_all_shm();
2086 if (closedir(dir) == -1) {
#define NI_XCODER_REVISION_API_MAJOR_VER_IDX
#define NI_MAX_DEVICE_CNT
#define NI_XCODER_REVISION
#define NI_MAX_DEVICE_NAME_LEN
@ NI_DEVICE_TYPE_XCODER_MAX
#define GET_XCODER_DEVICE_TYPE(t)
#define GET_XCODER_DEVICE_TYPE_STR(t)
@ NI_RETCODE_ERROR_LOCK_DOWN_DEVICE
@ NI_RETCODE_INVALID_PARAM
ni_retcode_t ni_query_fl_fw_versions(ni_device_handle_t device_handle, ni_device_info_t *p_dev_info)
Query firmware loader and firmware versions from the device.
ni_retcode_t ni_device_capability_query2(ni_device_handle_t device_handle, ni_device_capability_t *p_cap, bool device_in_ctxt)
Query device and return device capability structure This function had replaced ni_device_capability_q...
void ni_device_close(ni_device_handle_t device_handle)
Close device and release resources.
ni_retcode_t ni_query_extra_info(ni_device_handle_t device_handle, ni_device_extra_info_t *p_dev_extra_info, uint8_t fw_rev[])
Query CompositeTemp from device.
ni_device_handle_t ni_device_open2(const char *p_dev, ni_device_mode_t mode)
Open device and return device device_handle if successful.
Public definitions for operating NETINT video processing devices for video processing.
#define NI_PARAM_AV1_MAX_HEIGHT
#define NI_PARAM_AV1_MAX_WIDTH
#define NI_MIN_RESOLUTION_WIDTH_JPEG
#define MAX_CHAR_IN_DEVICE_NAME
#define NI_MIN_RESOLUTION_HEIGHT_JPEG
void ni_log2(const void *p_context, ni_log_level_t level, const char *fmt,...)
print log message and additional information using ni_log_callback,
void ni_log(ni_log_level_t level, const char *fmt,...)
print log message using ni_log_callback
Private definitions for interfacing with NETINT video processing devices over NVMe.
int ni_nvme_enumerate_devices(char ni_devices[][NI_MAX_DEVICE_NAME_LEN], int max_handles)
void ni_rsrc_free_device_context(ni_device_context_t *p_device_context)
Free previously allocated device context.
Public definitions for managing NETINT video processing devices.
#define NI_LEVELS_SUPP_STR_LEN
#define NI_PROFILES_SUPP_STR_LEN
#define NI_ADDITIONAL_INFO_STR_LEN
LIB_API ni_device_context_t * ni_rsrc_get_device_context(ni_device_type_t type, int guid)
Allocates and returns a pointer to ni_device_context_t struct based on provided device_type and guid....
Public definitions for managing NETINT video processing devices on Android.
android::sp< INidec > service
int ni_rsrc_android_init()
Init android net.int.SharedBuffer service for binder using.
#define PCIE_GEN4_LINK_SPEED
uint32_t g_xcoder_stop_process
void ni_rsrc_get_shm_name(ni_device_type_t device_type, int32_t guid, char *p_name, size_t max_name_len)
ni_retcode_t ni_rsrc_fill_device_info(ni_device_info_t *p_device_info, ni_codec_t fmt, ni_device_type_t type, ni_hw_capability_t *p_hw_cap)
ni_retcode_t ni_rsrc_create_retry_lck()
void ni_rsrc_get_lock_name(ni_device_type_t device_type, int32_t guid, char *p_name, size_t max_name_len)
bool add_to_shared_memory(const char device_name[NI_MAX_DEVICE_NAME_LEN], const bool device_open_should_succeed, const int should_match_rev, ni_device_queue_t *device_queue)
int ni_rsrc_strcmp(const void *p_str, const void *p_str1)
bool find_available_guid(ni_device_queue_t *device_queue, int device_type, int *guidn)
Private definitions used by ni_rsrc_api.cpp for management of NETINT video processing devices.
void ni_rsrc_update_record(ni_device_context_t *p_device_context, ni_session_context_t *p_session_ctx)
void ni_rsrc_get_one_device_info(ni_device_info_t *p_device_info)
int ni_rsrc_enumerate_devices(char ni_devices[][NI_MAX_DEVICE_NAME_LEN], int max_handles)
int ni_rsrc_init_priv(const int should_match_rev, const int existing_number_of_devices, const char device_names[NI_MAX_DEVICE_CNT][NI_MAX_DEVICE_NAME_LEN], int limit_depth)
void get_dev_pcie_addr(char *device_name, char *pcie, char *domain, char *slot, char *dev, char *func)
ni_retcode_t ni_strncpy(char *dest, size_t dmax, const char *src, size_t slen)
void ni_fmt_fw_api_ver_str(const char ver_str[], char fmt_str[])
Get formatted FW API version string from unformatted FW API version string.
ni_retcode_t ni_strerror(char *dest, size_t dmax, int errnum)
char * ni_strtok(char *s, const char *delim, char **saveptr)
void ni_usleep(int64_t usec)
int ni_cmp_fw_api_ver(const char ver1[], const char ver2[])
Compare two 3 character strings containing a FW API version. Handle comparision when FW API version f...
uint8_t xcoder_cnt[NI_DEVICE_TYPE_XCODER_MAX]
uint8_t fw_commit_time[26]
uint8_t serial_number[20]
uint8_t fw_commit_hash[41]
ni_hw_capability_t xcoder_devices[NI_MAX_DEVICES_PER_HW_INSTANCE]
uint8_t fw_branch_name[256]
uint8_t fw_build_time[26]
ni_device_info_t * p_device_info
int pcie_gen3_on_gen4_host
uint8_t fw_commit_time[26]
uint8_t serial_number[20]
char dev_name[NI_MAX_DEVICE_NAME_LEN]
uint8_t fw_commit_hash[41]
char blk_name[NI_MAX_DEVICE_NAME_LEN]
ni_sw_instance_info_t sw_instance[NI_MAX_CONTEXTS_PER_HW_INSTANCE]
int fw_ver_compat_warning
ni_device_type_t device_type
uint8_t fw_branch_name[256]
uint8_t fw_build_time[26]
ni_device_video_capability_t dev_cap[EN_CODEC_MAX]
int32_t xcoders[NI_DEVICE_TYPE_XCODER_MAX][NI_MAX_DEVICE_CNT]
uint32_t xcoder_cnt[NI_DEVICE_TYPE_XCODER_MAX]
char level[NI_LEVELS_SUPP_STR_LEN]
char profiles_supported[NI_PROFILES_SUPP_STR_LEN]
char additional_info[NI_ADDITIONAL_INFO_STR_LEN]
uint16_t min_video_height
uint16_t max_video_height
uint8_t max_number_of_contexts
ni_context_query_t context_status[NI_MAX_CONTEXTS_PER_HW_INSTANCE]
ni_load_query_t load_query
ni_sw_instance_status_t status