38#if __linux__ || __APPLE__
53#include <sys/syslimits.h>
70#if __linux__ || __APPLE__
79#define PCI_BDF_STR_LEN 12
80#define PCIE_ADDRS_MAX 16
81#define PCIE_GEN4_LINK_SPEED 16
85int read_file_content(
const char *path,
char *buf,
size_t bufsz)
87 FILE *fp = fopen(path,
"r");
88 const int n = (bufsz > (size_t)INT_MAX) ? INT_MAX : (int)bufsz;
91 if (!fgets(buf, n, fp))
97 char *nl = strchr(buf,
'\n');
103int find_root_port_from_device(
const char *device_bdf,
char *root_port_bdf)
105 char block_path[PATH_MAX];
106 char abs_path[PATH_MAX];
107 char *ptr, *saveptr = NULL;
111 struct dirent *entry;
113 if (!device_bdf || !root_port_bdf)
116 dir = opendir(
"/sys/block");
120 while ((entry = readdir(dir)))
123 if (strncmp(entry->d_name,
"nvme", 4) != 0)
126 (void)snprintf(block_path,
sizeof(block_path),
"/sys/block/%s", entry->d_name);
128 if (realpath(block_path, abs_path) == NULL)
131 if (strstr(abs_path, device_bdf) == NULL)
134 ptr = strtok_r(abs_path,
"/", &saveptr);
139 unsigned int d, b, dev, f;
140 if (sscanf(ptr,
"%x:%x:%x.%x", &d, &b, &dev, &f) == 4)
145 if (pcie_addrs[addr_count]) {
153 ptr = strtok_r(NULL,
"/", &saveptr);
156 for (
int i = addr_count - 2; i >= 0; i--)
158 char class_path[PATH_MAX];
160 unsigned long class_val;
165 (void)snprintf(class_path,
sizeof(class_path),
"/sys/bus/pci/devices/%s/class", pcie_addrs[i]);
166 if (read_file_content(class_path, class_buf,
sizeof(class_buf)) != 0)
169 class_val = strtoul(class_buf, NULL, 0);
170 if ((class_val & 0xffff00) != 0x060400)
175 for (
int j = 0; j < addr_count; j++)
184 for (
int j = 0; j < addr_count; j++)
195int read_pcie_capability_sysfs(
const char *bdf)
198 char raw_buf[64] = {0};
203 (void)snprintf(path,
sizeof(path),
"/sys/bus/pci/devices/%s/max_link_speed", bdf);
204 if (read_file_content(path, raw_buf,
sizeof(raw_buf)) != 0)
207 if (raw_buf[0] ==
'\0')
210 unsigned int speed_num = 0;
211 if (sscanf(raw_buf,
"%u", &speed_num) != 1)
213 return (
int)speed_num;
216int get_pcie_gen3_on_gen4_status(
const char *device_name, uint8_t fw_flavour)
219 char host_port[64] = {0};
220 int device_speed_num = -1;
221 int host_speed_num = -1;
227 device_speed_num = read_pcie_capability_sysfs(pcie);
228 if (find_root_port_from_device(pcie, host_port) == 0)
229 host_speed_num = read_pcie_capability_sysfs(host_port);
231 if (device_speed_num >= 0 && host_speed_num >= 0 &&
371 const char *l = (
const char *)p_str;
372 const char *r = (
const char *)p_str1;
377 return (!l && !r) ? 0 : (!l ? -1 : 1);
380 while (!isdigit(*l) && (*l) !=
'\0')
384 while (!isdigit(*r) && (*r) !=
'\0')
390 vl = (int)strtol(l, &end_l, 10);
391 vr = (int)strtol(r, &end_r, 10);
392 if (end_l == l || end_r == r)
394 return strcmp((
const char *)p_str, (
const char *)p_str1);
425 (void)snprintf(p_name, max_name_len,
"%s/NI_QUADRA_lck_%c%d",
LOCK_DIR, type, guid);
429 (void)snprintf(p_name, max_name_len,
"%s/NI_lck_%c%d",
LOCK_DIR, type, guid);
449 (void)snprintf(p_name, max_name_len,
"NI_QUADRA_shm_%c%d", type, guid);
453 (void)snprintf(p_name, max_name_len,
"NI_shm_%c%d", type, guid);
461 const ni_device_handle_t device_handle,
463 const int fw_ver_compat_warning,
468 int gen3_on_gen4 = -1;
478 memcpy(device_info->
fw_rev,
479 device_capability->
fw_rev,
480 sizeof(device_info->
fw_rev));
519 gen3_on_gen4 = get_pcie_gen3_on_gen4_status(device_name, extra_info.
fw_flavour);
523 if (gen3_on_gen4 < 0)
532 const int should_match_rev,
533 const int existing_number_of_devices,
536 int i, j, compatible_device_counter;
549 device_queue->
xcoders[i][j] = -1;
553 compatible_device_counter = 0;
554 for (i = 0; i < existing_number_of_devices; i++)
563 compatible_device_counter++;
567 "Maximum number of supported and compatible devices "
568 "reached. Ignoring other supported and compatible "
575bool find_available_guid(
ni_device_queue_t *device_queue,
int device_type,
int *guidn)
582 uint32_t guid_mask[4] = {0};
586 temp_guid = device_queue->
xcoders[device_type][i];
589 guid_mask[temp_guid / 32] |= (1u << ((uint32_t)temp_guid % 32));
593 for (i = 0; i < 4; i++)
595 for (j = 0; j < 32; j++)
597 if ((guid_mask[i] & (1u << j)) == 0)
599 *guidn = (i * 32) + j;
610 const bool device_open_should_succeed,
611 const int should_match_rev,
615 int i, j, fw_compat_cmp;
616 char fw_api_ver_str[5];
619 ni_device_handle_t device_handle;
624 if (device_handle == NI_INVALID_DEVICE_HANDLE)
626 if (device_open_should_succeed)
629 "ERROR: %s(): Failed to add %s\n: Failed ni_device_open2()\n",
650 if (should_match_rev && \
655 "Skipping %s init: device FW v%s incompatible with this version of Libxcoder\n",
669 "%s %s disabled...\n",
676 guid = j ? device_queue->
xcoders[i][j-1] + 1 : 0;
680 "initialized devices exceeds %d\n", __FUNCTION__,
685 device_queue->
xcoders[i][j] = guid;
688 fill_device_info(&device_info,
692 (should_match_rev && fw_compat_cmp) ? 1 : 0,
699 if (fw_compat_cmp < 0) {
701 "Libxcoder supported FW API version\n", device_name,
703 }
else if (fw_compat_cmp > 0) {
705 "Libxcoder supported FW API version\n", device_name,
708 ni_log(
NI_LOG_INFO,
"Initialized %s with FW API v%s\n", device_name, fw_api_ver_str);
727 for(i = 0; i <
sizeof(XCODERS_RETRY_LCK_NAME) /
sizeof(XCODERS_RETRY_LCK_NAME[0]); ++i)
729 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);
736 ni_log(
NI_LOG_ERROR,
"Failed to create %s ERROR: %s\n", XCODERS_RETRY_LCK_NAME[i], errmsg);
782 char shm_name[32] = { 0 };
783 char lck_name[32] = { 0 };
786 HANDLE map_file_handle = NULL;
787 ni_lock_handle_t mutex_handle = NULL;
788 SECURITY_DESCRIPTOR security_descriptor = { 0 };
797 ni_log(
NI_LOG_DEBUG,
"%s(): shm_name %s, lck_name %s\n", __func__, shm_name, lck_name);
800 mutex_handle = CreateMutexA(NULL,
803 if (NULL == mutex_handle)
809 if (WAIT_ABANDONED == WaitForSingleObject(mutex_handle, INFINITE))
812 "obtain mutex: %p\n", mutex_handle);
816 InitializeSecurityDescriptor(&security_descriptor, SECURITY_DESCRIPTOR_REVISION);
819 map_file_handle = CreateFileMappingA(
820 INVALID_HANDLE_VALUE,
828 if (NULL == map_file_handle)
838 if (ERROR_ALREADY_EXISTS == rc)
845 ni_log(
NI_LOG_INFO,
"CreateFileMapping created a new mapFile for %s, handle: %p ..\n", shm_name, map_file_handle);
857 if (NULL == p_coder_info_map)
867 if (p_coder_info_map)
869 UnmapViewOfFile(p_coder_info_map);
873 ReleaseMutex(mutex_handle);
893 if ((!p_device_context) || (!p_session_context))
943 const int existing_number_of_devices,
948 HANDLE map_file_handle = NULL;
950 map_file_handle = CreateFileMappingA(
951 INVALID_HANDLE_VALUE,
959 if (NULL == map_file_handle)
968 if(ERROR_ALREADY_EXISTS == rc)
970 ni_log(
NI_LOG_INFO,
"NETINT resources have been initialized already, exiting ..\n");
971 CloseHandle(map_file_handle);
976 ni_log(
NI_LOG_INFO,
"NETINT resources not initialized, starting initialization ..\n");
988 if (NULL == p_device_queue)
992 CloseHandle(map_file_handle);
1001 UnmapViewOfFile(p_device_queue);
1002 CloseHandle(map_file_handle);
1006 if (WAIT_ABANDONED == WaitForSingleObject(lock, INFINITE))
1012 UnmapViewOfFile(p_device_queue);
1013 CloseHandle(map_file_handle);
1017 fill_shared_memory(p_device_queue,
1019 existing_number_of_devices,
1020 existing_device_names);
1022 UnmapViewOfFile(p_device_queue);
1028#elif __linux__ || __APPLE__
1041 const int should_match_rev,
1042 const int existing_number_of_devices,
1048 bool device_found_in_queue;
1051 ni_device_handle_t device_handle;
1063 for (queue_idx = 0; queue_idx < existing_device_queue->
xcoder_cnt[j]; queue_idx++)
1065 guid = existing_device_queue->
xcoders[j][queue_idx];
1075 ni_log(
NI_LOG_ERROR,
"ERROR: %s(): guid_map_count[%d] exceeds NI_MAX_DEVICE_CNT\n", __func__, j);
1079 guid_map[j][guid_map_count[j]].guid = guid;
1082 guid_map_count[j]++;
1085 else if (device_context)
1093 for (i = 0; i < existing_number_of_devices; i++)
1096 if (device_handle == NI_INVALID_DEVICE_HANDLE)
1103 (should_match_rev && \
1116 device_found_in_queue =
false;
1117 for (queue_idx = 0; queue_idx < guid_map_count[j]; queue_idx++)
1121 device_found_in_queue =
true;
1125 if (!device_found_in_queue)
1133 for (queue_idx = 0; queue_idx < guid_map_count[k]; queue_idx++)
1138 "ERROR: %s(): Discovered device %s is not in queue for module %s but is in %s\n",
1161 "WARNING: %s(): Discovered %u %s, expected %u\n",
1172 const int existing_number_of_devices,
1180 for (i = 0; i < existing_number_of_devices; i++)
1184 module_id = existing_device_queue->
xcoders[j][i];
1185 if (module_id == -1)
1191 if (!device_context)
1194 "WARNING: %s(): Missing device context for %s %s\n",
1213void sigbus_handler(
int signal)
1219void setup_signal_handler(
struct sigaction *p,
const int signum)
1223 memset(&c, 0,
sizeof(
struct sigaction));
1224 if (sigemptyset(&c.sa_mask) == -1)
1227 "ERROR: %s(): Could not initialize signal set: %d\n",
1230 _Exit(EXIT_FAILURE);
1232 c.sa_handler = sigbus_handler;
1234 if (sigaction(signum, NULL, p) == -1)
1237 "ERROR: %s(): Could not save previous signal handler: %d\n",
1240 _Exit(EXIT_FAILURE);
1243 if (sigaction(signum, &c, NULL) == -1)
1246 "ERROR: %s(): Could not register signal handler: %d\n",
1249 _Exit(EXIT_FAILURE);
1255 const int should_match_rev,
1256 const int existing_number_of_devices,
1259 bool result =
false;
1261 const int signum = SIGBUS;
1264 setup_signal_handler(&p, signum);
1266 if (sigsetjmp(env, 1))
1272 if (!check_correctness_count(existing_device_queue,
1274 existing_number_of_devices,
1280 if (!check_device_queue(existing_device_queue,
1281 existing_number_of_devices,
1292 if (sigaction(signum, &p, NULL) == -1)
1295 "ERROR: %s(): Could not restore previous signal handler: %d\n",
1298 _Exit(EXIT_FAILURE);
1306 const int existing_number_of_devices,
1310 int return_value = 0;
1313 ni_rsrc_shm_state state = NI_RSRC_SHM_IS_INVALID;
1314 const int flags = O_CREAT | O_RDWR | O_CLOEXEC;
1315 const mode_t mode = S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP;
1318 if ((ni_rsrc_try_get_shm_lock(
CODERS_LCK_NAME, flags, mode, &lck_fd) < 0) ||
1327 (
void **)&p_device_queue)) < 0) {
1334 if (NI_RSRC_SHM_IS_EXISTED == state) {
1335 if (check_correctness(p_device_queue,
1337 existing_number_of_devices,
1338 existing_device_names))
1346 if (lockf(lck_fd, F_ULOCK, 0) < 0) {
1352#ifndef __OPENHARMONY__
1355 ni_rsrc_remove_all_shm();
1357 if (limit_depth <= 0)
1362 existing_number_of_devices,
1363 existing_device_names,
1367 fill_shared_memory(p_device_queue,
1369 existing_number_of_devices,
1370 existing_device_names);
1373 if (p_device_queue && p_device_queue != MAP_FAILED) {
1375 p_device_queue = NULL;
1380 if (lockf(lck_fd, F_ULOCK, 0) < 0) {
1387#ifndef __OPENHARMONY__
1393 return return_value;
1405 int32_t shm_fd = -1;
1406 ni_rsrc_shm_state state = NI_RSRC_SHM_IS_INVALID;
1408 const int flags = O_CREAT | O_RDWR | O_CLOEXEC;
1409 const mode_t mode = S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP;
1410 char shm_name[32] = { 0 };
1411 char lck_name[32] = { 0 };
1414 if(! p_device_info) {
1421 ni_log(
NI_LOG_DEBUG,
"%s(): shm_name %s, lck_name %s\n", __func__, shm_name, lck_name);
1423 if (ni_rsrc_try_get_shm_lock(lck_name, flags, mode, (
int *)&lock) < 0) {
1428 if (ni_rsrc_open_shm(shm_name,
1431 (
int *)&shm_fd) < 0) {
1436 if ((ni_rsrc_mmap_shm(shm_name,
1439 (
void **)&p_coder_info_dst)) < 0) {
1446#ifndef __OPENHARMONY__
1447 if (msync((
void*)p_coder_info_dst,
sizeof(
ni_device_info_t), MS_SYNC | MS_INVALIDATE)) {
1458 if (p_coder_info_dst && p_coder_info_dst != MAP_FAILED) {
1460 p_coder_info_dst = NULL;
1464#ifndef __OPENHARMONY__
1471 if (lockf(lock, F_ULOCK, 0) < 0) {
1472 ni_log(
NI_LOG_ERROR,
"Will exit from %s(), but failed to unlock lck_fd for %s\n", __func__, shm_name);
1488 if ((!p_device_context) || (!p_session_context))
1523 "p_device_info: %s\n", __func__, errmsg);
1542 char *domain,
char *slot,
char *dev,
char *func)
1549 char path[PATH_MAX];
1552 if (!device_name || !strstr(device_name,
"/dev/nvme") || !pcie)
1557 char *start = device_name + 5;
1559 (void)snprintf(path,
sizeof(path),
"/sys/block/%s", start);
1562 char target[PATH_MAX];
1563 const ssize_t len = readlink(path, target,
sizeof(target) - 1);
1571 char *saveptr = NULL;
1573 pcie[4] = pcie[7] =
':';
1575 while(ptr != NULL) {
1579 ret = sscanf(ptr,
"%4c:%2c:%2c.%1c", pcie, pcie+5,pcie+8,pcie+11);
1592 if (!domain || !slot || !dev || !func)
1596 domain[4] = slot[2] = dev[2] = func[1] =
'\0';
1597 (void)sscanf(pcie,
"%4[^:]:%2[^:]:%2[^.].%1s", domain, slot, dev, func);
1598 ni_log2(NULL,
NI_LOG_DEBUG,
"\t%d: Domain: %s, Slot: %s, Device: %s, Function: %s\n", i, domain, slot, dev, func);
1618ni_retcode_t ni_rsrc_try_get_shm_lock(
const char *lck_name,
1625 if (!lck_name || !lck_fd) {
1632 if (0 != mkdir(
LOCK_DIR, S_IRWXU | S_IRWXG | S_IRWXO)) {
1640 lock = open(lck_name, flags, mode);
1644 __func__, lck_name, errmsg);
1650 while (lockf(lock, F_TLOCK, 0) != 0)
1654 if (retry_cnt >= 900)
1657 ni_log(
NI_LOG_ERROR,
"ERROR %s() lockf() %s fail: %s\n", __func__, lck_name, errmsg);
1658 ni_log(
NI_LOG_ERROR,
"ERROR %s() If persists, stop traffic and run rm /dev/shm/NI_*\n", __func__);
1669#if defined(__OPENHARMONY__)
1670static ni_retcode_t openharmony_open_shm(
const char *shm_name,
1672 ni_rsrc_shm_state *state,
1676 int flag = IPC_CREAT | IPC_EXCL;
1677 char shm_path[PATH_MAX];
1679 if (!shm_name || !shm_fd) {
1684 memset(shm_path, 0, PATH_MAX);
1685 snprintf(shm_path, PATH_MAX,
"%s/%s",
LOCK_DIR, shm_name);
1689 if (0 != access(shm_path, F_OK)) {
1690 int fd = open(shm_path, O_RDWR | O_CREAT | O_CLOEXEC,
1691 S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP);
1694 ni_log(
NI_LOG_ERROR,
"ERROR: %s() open() %s fail: %s\n", __func__, shm_name, errmsg);
1702 key_t key = ftok(shm_path, PROJ_ID);
1709 *state = NI_RSRC_SHM_IS_CREATED;
1712 mode_t mode = S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH;
1713 shm_id = shmget(key, shm_size, mode | flag);
1716 *state = NI_RSRC_SHM_IS_EXISTED;
1718 shm_id = shmget(key, shm_size, mode | flag);
1732static ni_retcode_t openharmony_remove_shm(
const char *shm_name,
1736 char shm_path[PATH_MAX];
1743 memset(shm_path, 0, PATH_MAX);
1744 snprintf(shm_path, PATH_MAX,
"%s/%s",
LOCK_DIR, shm_name);
1747 if (0 != access(shm_path, F_OK)) {
1753 key_t key = ftok(shm_path, PROJ_ID);
1761 mode_t mode = S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH;
1762 shm_id = shmget(key, shm_size, mode);
1769 shmctl(shm_id, IPC_RMID,
nullptr);
1774#elif defined(_ANDROID)
1775static ni_retcode_t android_open_shm(
const char *shm_name,
1777 ni_rsrc_shm_state *state,
1780 int shm_fd_tmp = -1;
1782 if (!shm_name || !shm_fd) {
1793 *state = NI_RSRC_SHM_IS_CREATED;
1795 string param = shm_name;
1796 Return<void> retvalue =
1797 service->GetAppFlag(param, [&](int32_t ret, hidl_handle handle) {
1799 *state = NI_RSRC_SHM_IS_EXISTED;
1800 shm_fd_tmp = dup(handle->data[0]);
1806 if (!retvalue.isOk()) {
1811 if (shm_fd_tmp < 0) {
1812 int fd = ashmem_create_region(shm_name, shm_size);
1814 native_handle_t *native_handle = native_handle_create(1, 0);
1815 if (!native_handle) {
1819 native_handle->data[0] = fd;
1822 handle.setTo(native_handle,
true);
1823 service->SetAppFlag(param, handle);
1824 shm_fd_tmp = dup(fd);
1830 *shm_fd = shm_fd_tmp;
1835static ni_retcode_t android_remove_shm(
const char *shm_name,
1849 string param = shm_name;
1850 Return<void> retvalue =
service->RemoveAppFlag(param);
1851 if (!retvalue.isOk()) {
1867 Return<void> retvalue =
service->RemoveAllAppFlags();
1868 if (!retvalue.isOk()) {
1880 ni_rsrc_shm_state *state,
1883 int shm_fd_tmp = -1;
1884 const mode_t mode = S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP;
1885 int flag = O_CREAT | O_EXCL | O_RDWR;
1886 bool skip_ftruncate =
false;
1888 if (!shm_name || !shm_fd) {
1893 *state = NI_RSRC_SHM_IS_CREATED;
1896 shm_fd_tmp = shm_open(shm_name, flag, mode);
1897 if (shm_fd_tmp < 0) {
1899 skip_ftruncate =
true;
1900 *state = NI_RSRC_SHM_IS_EXISTED;
1902 shm_fd_tmp = shm_open(shm_name, flag, mode);
1905 if (shm_fd_tmp < 0) {
1909 __func__, shm_name, errmsg);
1915 if (!skip_ftruncate && ftruncate(shm_fd_tmp, shm_size) < 0) {
1917 shm_unlink(shm_name);
1921 *shm_fd = shm_fd_tmp;
1948 ni_rsrc_shm_state *state,
1951#if defined(__OPENHARMONY__)
1952 return openharmony_open_shm(shm_name, shm_size, state, shm_fd);
1953#elif defined(_ANDROID)
1954 return android_open_shm(shm_name, shm_size, state, shm_fd);
1956 return linux_open_shm(shm_name, shm_size, state, shm_fd);
1979 if (!shm_name || !shm_addr) {
1985#ifdef __OPENHARMONY__
1986 *shm_addr = shmat(shm_fd,
nullptr, 0);
1987 if ((
void *)(-1) == *shm_addr) {
1994 *shm_addr = mmap(0, shm_size, PROT_READ | PROT_WRITE,
1995 MAP_SHARED, shm_fd, 0);
1996 if (MAP_FAILED == *shm_addr) {
2026#ifdef __OPENHARMONY__
2029 munmap(shm_addr, shm_size);
2051#ifdef __OPENHARMONY__
2052 return openharmony_remove_shm(shm_name, shm_size);
2053#elif defined(_ANDROID)
2054 return android_remove_shm(shm_name, shm_size);
2056 shm_unlink(shm_name);
2075 struct dirent *dirent;
2076 char path_to_remove[PATH_MAX];
2089 while ((dirent = readdir(dir)) != NULL) {
2090 if (strncmp(dirent->d_name,
"NI_", 3) != 0) {
2094 (void)snprintf(path_to_remove, PATH_MAX,
"%s/%s",
LOCK_DIR, dirent->d_name);
2097 if (strncasecmp(dirent->d_name,
"NI_SHM", 6) == 0) {
2098#ifdef __OPENHARMONY__
2099 openharmony_remove_shm(dirent->d_name, 1);
2101 shm_unlink(dirent->d_name);
2106 (void)remove(path_to_remove);
2110 android_remove_all_shm();
2113 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
Set host timestamp on Quadra NVMe controllers.
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)
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