libxcoder  5.2.0
test_rsrc_api.c
Go to the documentation of this file.
1 /*******************************************************************************
2  *
3  * Copyright (C) 2022 NETINT Technologies
4  *
5  * Permission is hereby granted, free of charge, to any person obtaining a copy
6  * of this software and associated documentation files (the "Software"), to deal
7  * in the Software without restriction, including without limitation the rights
8  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9  * copies of the Software, and to permit persons to whom the Software is
10  * furnished to do so, subject to the following conditions:
11  *
12  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
13  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
14  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
15  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
16  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
17  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
18  * SOFTWARE.
19  *
20  ******************************************************************************/
21 
22 /*!*****************************************************************************
23  * \file test_rsrc_api.c
24  *
25  * \brief Application for manually managing NETINT video processing devices on
26  * system. Its code provides examples on how to programatically use
27  * ni_rsrc_api.h for NETINT resource management
28  ******************************************************************************/
29 
30 #ifdef __linux__
31 #include <unistd.h>
32 #endif
33 #include <stdio.h>
34 #include <stdlib.h>
35 #include <fcntl.h>
36 #include <string.h>
37 #include <errno.h>
38 
39 #include "ni_rsrc_api.h"
40 #include "ni_rsrc_priv.h"
41 #include "ni_util.h"
42 
43 
44 /*******************************************************************************
45  * @brief
46  *
47  * @param
48  *
49  * @return
50  *******************************************************************************/
51 static void getStr(const char *prompt, char *str)
52 {
53  char para[64];
54  printf("%s", prompt);
55 
56  if (fgets(para, sizeof(para), stdin) != 0) {
57  size_t len = strlen(para);
58  if (len > 0 && para[len - 1] == '\n')
59  para[len - 1] = '\0';
60  strcpy(str, para);
61  }
62 }
63 
64 /*******************************************************************************
65  * @brief
66  *
67  * @param
68  *
69  * @return
70  *******************************************************************************/
71 static int getCmd(const char *prompt)
72 {
73  char cmd[64] = {'\0'};
74 
75  getStr(prompt, cmd);
76  return (int)cmd[0];
77 }
78 
79 /******************************************************************************
80  * @brief
81  *
82  * @param
83  *
84  * @return
85  ******************************************************************************/
86 static void change_log_level(void)
87 {
88  char log_str[64];
89  ni_log_level_t log_level;
90 
91  getStr("set log level to [none, fatal, error, info, debug, trace]: ",
92  log_str);
93 
94  log_level = arg_to_ni_log_level(log_str);
95  if (log_level != NI_LOG_INVALID)
96  {
97  ni_log_set_level(log_level);
98  } else {
99  fprintf(stderr, "ERROR: unknown log level selected: %s", log_str);
100  }
101 }
102 
103 /*******************************************************************************
104  * @brief
105  *
106  * @param
107  *
108  * @return
109  *******************************************************************************/
110 static int getInt(const char *prompt)
111 {
112  char para[64];
113 
114  getStr(prompt, para);
115  return atoi(para);
116 }
117 
118 /*******************************************************************************
119  * @brief
120  *
121  * @param
122  *
123  * @return
124  *******************************************************************************/
125 NI_UNUSED static float getFloat(const char *prompt)
126 {
127  char para[64];
128 
129  getStr(prompt, para);
130  return (float)atof(para);
131 }
132 
133 /*******************************************************************************
134  * @brief
135  *
136  * @param
137  *
138  * @return
139  *******************************************************************************/
140 NI_UNUSED static long getLong(const char *prompt)
141 {
142  char para[64];
143 
144  getStr(prompt, para);
145  return atol(para);
146 }
147 
148 /*******************************************************************************
149  * @brief
150  *
151  * @param
152  *
153  * @return
154  *******************************************************************************/
155 static void listOneTypeCoders(void)
156 {
157  ni_device_type_t type;
158  int i, count = 0;
159  ni_device_info_t coders[NI_MAX_DEVICE_CNT] = {0};
160 
161  type = (ni_device_type_t)getInt("coder type, decoder (0) encoder (1): ");
162  if (ni_rsrc_list_devices(type, coders, &count) == 0)
163  {
164  for (i = 0; i < count; i++)
165  {
166  ni_rsrc_print_device_info(&coders[i]);
167  }
168  }
169 }
170 
171 /*******************************************************************************
172  * @brief
173  *
174  * @param
175  *
176  * @return
177  *******************************************************************************/
178 static void listModuleId(void)
179 {
180  /* read back the stored coders numbers */
181  uint32_t i, k;
182  ni_device_queue_t *ptr;
183  ni_device_pool_t *p_device_pool;
184 
185  p_device_pool = ni_rsrc_get_device_pool();
186  if (p_device_pool)
187  {
188 #ifdef _WIN32
189  if (WAIT_ABANDONED == WaitForSingleObject(p_device_pool->lock, INFINITE)) // no time-out interval)
190  {
191  fprintf(stderr, "ERROR: listModuleId() failed o obtain mutex: %p", p_device_pool->lock);
192  return;
193  }
194 #elif __linux__
195  if (lockf(p_device_pool->lock, F_LOCK, 0))
196  {
197  fprintf(stderr, "ERROR: %s() lockf() failed: %s\n", __func__,
198  strerror(NI_ERRNO));
199  }
200 #endif
201 
202  /* print out coders in their current order */
203  ptr = p_device_pool->p_device_queue;
204  for (k = 0; k < NI_DEVICE_TYPE_XCODER_MAX; k++)
205  {
206  printf("Num %ss: %u\n", g_device_type_str[k], ptr->xcoder_cnt[k]);
207  for (i = 0; i < ptr->xcoder_cnt[k]; i++)
208  {
209  ni_device_info_t *p_device_info =
210  ni_rsrc_get_device_info(k, ptr->xcoders[k][i]);
211  printf("[%u]. %d (load: %d inst: %u %s.%d)\n", i,
212  ptr->xcoders[k][i], p_device_info->load,
213  p_device_info->active_num_inst, p_device_info->dev_name,
214  p_device_info->hw_id);
215  free(p_device_info);
216  }
217  printf("\n\n");
218  }
219 
220 #ifdef _WIN32
221  ReleaseMutex(p_device_pool->lock);
222 #elif __linux__
223  if (lockf(p_device_pool->lock, F_ULOCK, 0))
224  {
225  fprintf(stderr, "Error lockf() failed\n");
226  }
227 #endif
228  ni_rsrc_free_device_pool(p_device_pool);
229  }
230 }
231 
232 /*******************************************************************************
233  * @brief
234  *
235  * @param
236  *
237  * @return
238  *******************************************************************************/
239 static void listAllCodersFull(void)
240 {
241  int i, k;
242  ni_device_t *p_coders = NULL;
243  p_coders = (ni_device_t *)malloc(sizeof(ni_device_t));
244  if (p_coders == NULL)
245  {
246  fprintf(stderr,
247  "Error: memory allocation failed, fatal error, exiting\n");
248  return;
249  }
250 
251  if (ni_rsrc_list_all_devices(p_coders) == 0)
252  {
253  for (k = 0; k < NI_DEVICE_TYPE_XCODER_MAX; k++)
254  {
255  /* print out coders in the order based on their guid */
256  printf("Num %ss: %d\n", g_device_type_str[k],
257  p_coders->xcoder_cnt[k]);
258 
259  for (i = 0; i < p_coders->xcoder_cnt[k]; i++)
260  {
261  ni_rsrc_print_device_info(&(p_coders->xcoders[k][i]));
262  }
263  }
264  }
265  free(p_coders);
266 }
267 
268 /*******************************************************************************
269  * @brief
270  *
271  * @param
272  *
273  * @return
274  *******************************************************************************/
275 static void getCoderDetailInfo(void)
276 {
277  ni_device_type_t type;
278  int guid;
279  ni_device_info_t *p_device_info;
280 
281  type = (ni_device_type_t)getInt("coder type, decoder (0) encoder (1): ");
282  guid = getInt("Coder module ID: ");
283  printf("type: %d id %d\n", type, guid);
284  p_device_info = ni_rsrc_get_device_info(type, guid);
285  if (p_device_info)
286  {
287  ni_rsrc_print_device_info(p_device_info);
288  free(p_device_info);
289  }
290 }
291 
292 /*!******************************************************************************
293  * \brief compare two int32_t for qsort
294  *
295  * \param[in] const void *a
296  * \param[in] const void *b
297  *
298  * \return int atoi(numArray)
299  *******************************************************************************/
300 static int compareInt32_t(const void *a, const void *b)
301 {
302  if (*(int32_t *)a < *(int32_t *)b)
303  {
304  return -1;
305  }
306  else if (*(int32_t *)a > *(int32_t *)b)
307  {
308  return 1;
309  }
310  else
311  {
312  return 0;
313  }
314 }
315 
316 /******************************************************************************
317  * @brief
318  *
319  * @param
320  *
321  * @return
322  ******************************************************************************/
323 static void displayRsrcMon(void)
324 {
325  ni_device_pool_t *p_device_pool = NULL;
326  ni_device_queue_t *coders = NULL;
327  ni_session_context_t xCtxt = {0};
328  int k;
329 
330  p_device_pool = ni_rsrc_get_device_pool();
331  if (!p_device_pool)
332  {
333  fprintf(stderr, "FATAL: cannot get devices info\n");
334  return;
335  }
336 
337  printf("**************************************************\n");
339  coders = p_device_pool->p_device_queue;
340 
341  for (k = 0; k < NI_DEVICE_TYPE_XCODER_MAX; k++)
342  {
343  ni_device_type_t module_type = k;
344  ni_session_context_t *sessionCtxt = &xCtxt;
345  int i; // used in later FOR-loop when compiled without c99
346  int module_count = 0;
347  char module_name[8] = {'\0'};
348  int32_t *module_id_arr = NULL;
349  ni_device_context_t *p_device_context = NULL;
350 
351  if (!IS_XCODER_DEVICE_TYPE(module_type))
352  {
353  fprintf(stderr, "ERROR: unsupported module_type %d\n", module_type);
354  break;
355  }
356 
357  module_count = coders->xcoder_cnt[module_type];
358  strcpy(module_name, g_device_type_str[module_type]);
359 
360  module_id_arr = malloc(sizeof(*module_id_arr) * module_count);
361  if (!module_id_arr)
362  {
363  fprintf(stderr, "ERROR: malloc() failed for module_id_arr\n");
364  break;
365  }
366  memcpy(module_id_arr, coders->xcoders[module_type],
367  sizeof(int32_t) * module_count);
368 
369  printf("Num %ss: %d\n", g_device_type_str[module_type], module_count);
370 
371  // sort module IDs used
372  qsort(module_id_arr, module_count, sizeof(int32_t), compareInt32_t);
373 
374  // Print performance info headings
375  if (IS_XCODER_DEVICE_TYPE(module_type))
376  {
377  printf("%-5s %-4s %-10s %-4s %-4s %-9s %-7s %-14s\n", "INDEX",
378  "LOAD", "MODEL_LOAD", "INST", "MEM", "SHARE_MEM", "P2P_MEM",
379  "DEVICE");
380  }
381 
383  for (i = 0; i < module_count; i++)
384  {
385  p_device_context =
386  ni_rsrc_get_device_context(module_type, module_id_arr[i]);
387 
389  if (p_device_context)
390  {
391  sessionCtxt->device_handle =
392  ni_device_open(p_device_context->p_device_info->dev_name,
393  &sessionCtxt->max_nvme_io_size);
394  sessionCtxt->blk_io_handle = sessionCtxt->device_handle;
395 
396  // Check device can be opened
397  if (NI_INVALID_DEVICE_HANDLE == sessionCtxt->device_handle)
398  {
399  fprintf(stderr,
400  "ERROR: ni_device_open() failed for %s: %s\n",
401  p_device_context->p_device_info->dev_name,
402  strerror(NI_ERRNO));
403  ni_rsrc_free_device_context(p_device_context);
404  continue;
405  }
406 
407  sessionCtxt->hw_id = p_device_context->p_device_info->hw_id;
408  if (NI_RETCODE_SUCCESS !=
409  ni_device_session_query(sessionCtxt, module_type))
410  {
411  ni_device_close(sessionCtxt->device_handle);
412  fprintf(stderr, "Error query %s %s.%d\n", module_name,
413  p_device_context->p_device_info->dev_name,
414  p_device_context->p_device_info->hw_id);
415  ni_rsrc_free_device_context(p_device_context);
416  continue;
417  }
418  // printf("Done query %s %s.%d\n", module_name,
419  // p_device_context->p_device_info->dev_name,
420  // p_device_context->p_device_info->hw_id);
421  ni_device_close(sessionCtxt->device_handle);
422 
423  if (0 == sessionCtxt->load_query.total_contexts)
424  {
425  sessionCtxt->load_query.current_load = 0;
426  }
427 
428  // Print performance info row
429  if (IS_XCODER_DEVICE_TYPE(module_type))
430  {
431  printf("%-5d %-4u %-10u %-4u %-4u %-9u %-7u %-14s\n",
432  p_device_context->p_device_info->module_id,
433  sessionCtxt->load_query.current_load,
434  sessionCtxt->load_query.fw_model_load,
435  sessionCtxt->load_query.total_contexts,
436  sessionCtxt->load_query.fw_video_mem_usage,
437  sessionCtxt->load_query.fw_share_mem_usage,
438  sessionCtxt->load_query.fw_p2p_mem_usage,
439  p_device_context->p_device_info->dev_name);
440  }
441  ni_rsrc_free_device_context(p_device_context);
442  }
443  }
444  free(module_id_arr);
445  }
446 
448  ni_rsrc_free_device_pool(p_device_pool);
449 
450  printf("**************************************************\n");
451 }
452 
453 /*******************************************************************************
454  * @brief
455  *
456  * @param
457  *
458  * @return
459  ******************************************************************************/
460 static void addCoder(void)
461 {
462  char dev[64];
463  int should_match_rev = 0;
464  getStr("device name (/dev/*): ", dev);
465  should_match_rev = getInt("should match current release version, yes (1) no (0): ");
466  ni_rsrc_add_device(dev, should_match_rev);
467 }
468 
469 /*******************************************************************************
470  * @brief
471  *
472  * @param
473  *
474  * @return
475  ******************************************************************************/
476 static void initRsrc(void)
477 {
478  int should_match_rev =
479  getInt("should match current release version, yes (1) no (0): ");
480  int timeout_seconds = getInt("timeout_seconds: ");
481  ni_rsrc_init(should_match_rev, timeout_seconds);
482 }
483 
484 /******************************************************************************
485  * @brief
486  *
487  * @param
488  *
489  * @return
490  ******************************************************************************/
491 static void niRsrcRefresh(void)
492 {
493  int should_match_rev =
494  getInt("should match current release version, yes (1) no (0): ");
495  ni_rsrc_refresh(should_match_rev);
496 }
497 
498 /******************************************************************************
499  * @brief
500  *
501  * @param
502  *
503  * @return
504  ******************************************************************************/
505 static void checkHwAvailable(void)
506 {
507  int guid = getInt("guid :");
508  int deviceType=getInt("deviceType : ");
509  ni_rsrc_check_hw_available(guid,deviceType);
510 }
511 
512 
513 /******************************************************************************
514  * @brief
515  *
516  * @param
517  *
518  * @return
519  ******************************************************************************/
520 static void getlocaldevicelist(void)
521 {
523 }
524 
525 /******************************************************************************
526  * @brief
527  *
528  * @param
529  *
530  * @return
531  ******************************************************************************/
532 static void deleteCoder(void)
533 {
534  char dev[64];
535  getStr("device name (/dev/*): ", dev);
537 }
538 
539 /******************************************************************************
540  * @brief
541  *
542  * @param
543  *
544  * @return
545  ******************************************************************************/
546 static void removeAllDevices(void)
547 {
549 }
550 
551 
552 static void checkHWInfo(void)
553 {
554  int task_mode = 0, device_type = 0, hw_mode = 0, consider_mem = 0;
555  printf("Please enter task mode, device type, hw mode and if to consider memory (Divided by spaces)\n");
556  int ret_scanf = scanf("%d %d %d %d",&task_mode,&device_type,&hw_mode,&consider_mem);
557  if(ret_scanf == EOF || ret_scanf < 4)
558  {
559  fprintf(stderr, "%s, read parameters failed", __func__);
560  }
561  ni_hw_device_info_quadra_t *device_info = NULL;
563  threshold[0].device_type = NI_DEVICE_TYPE_DECODER;//0
564  threshold[0].load_threshold = 10;
565  threshold[0].task_num_threshold = 10;
566  threshold[1].device_type = NI_DEVICE_TYPE_ENCODER;//1
567  threshold[1].load_threshold = 20;
568  threshold[1].task_num_threshold = 10;
569  threshold[2].device_type = NI_DEVICE_TYPE_SCALER;//2
570  threshold[2].load_threshold = 30;
571  threshold[2].task_num_threshold = 10;
572  threshold[3].device_type = NI_DEVICE_TYPE_AI;//3
573  threshold[3].load_threshold = 40;
574  threshold[3].task_num_threshold = 10;
575 
577  coder_param->encoder_param->w = 7680;
578  coder_param->encoder_param->h = 4320;
579  coder_param->encoder_param->lookaheadDepth = 20;
580  coder_param->decoder_param->w = 7680;
581  coder_param->decoder_param->h = 4320;
582  coder_param->decoder_param->hw_frame = 1;
583  coder_param->scaler_param->h = 7680;
584  coder_param->scaler_param->w = 1920;
585  coder_param->scaler_param->bit_8_10 = 8;
586  int ret = ni_check_hw_info(&device_info,task_mode,threshold,device_type,coder_param,hw_mode,consider_mem);
587  // int ret = ni_check_hw_info(&device_info, 1, threshold, 1, coder_param, 1, 0);
588  printf("ret = %d\n",ret);
590  ni_hw_device_info_free_quadra(device_info);
591 }
592 
593 /*******************************************************************************
594  * @brief
595  *
596  * @param
597  *
598  * @return
599  *******************************************************************************/
600 static void allocAuto(void)
601 {
602  ni_device_context_t *p_device_context;
603  ni_device_type_t type;
604  ni_alloc_rule_t rule;
605  uint64_t model_load;
606 
607  type = (ni_device_type_t)getInt("coder type, decoder (0) encoder (1): ");
608  rule = (ni_alloc_rule_t)getInt("auto-alloc rule, least-load (0) load-instance (1): ");
609  printf("type: %d rule %d\n", type, rule);
610 
611  p_device_context = ni_rsrc_allocate_auto(type, rule, EN_H265, 1920, 1080, 30, &model_load);
612  if (p_device_context)
613  {
614  printf("Successfully auto-allocated s/w instance on:\n");
615  ni_rsrc_print_device_info(p_device_context->p_device_info);
616  printf("Allocated load: %"PRIu64"\n", model_load);
617  ni_rsrc_free_device_context(p_device_context);
618  }
619 }
620 
621 
622 int main(void)
623 {
624  int stop = 0;
625 
626  while (!stop)
627  {
628  printf("Key function\n"
629  "? show this help\n"
630  "v change libxcoder log level\n"
631  "l list all decoders, or all encoders\n"
632  "L list all coders detailed info\n"
633  "o list all coders' module #, in order of position in queue\n"
634  "g get a coder's info\n"
635 #ifndef _WIN32
636  "i Initialize and create all resources required to work with \n"
637 #endif
638  "d delete xcoder from host resource pool\n"
639  "D Remove all NetInt h/w devices from resource pool on the host.\n"
640  "x add xcoder into host resource pool\n"
641  "m display ni_rsrc_mom value\n"
642  "s Scan and refresh all resources on the host, taking into account\n"
643  " hot-plugged and pulled out cards.\n"
644  "r check the NetInt h/w device in resource pool on the host.\n"
645  "p Print detailed capability information of all devices on the system.\n"
646  "C check hardware device detailed info\n"
647  "a allocate automatically a s/w instance\n"
648  "q quit\n");
649 
650  int control = getCmd("> ");
651  switch (control)
652  {
653  case '?':
654  continue;
655 #ifndef _WIN32
656  case 'i':
657  initRsrc();
658  break;
659 #endif
660  case 'D':
661  removeAllDevices();
662  break;
663  case 'v':
664  change_log_level();
665  break;
666  case 'V':
667  printf("Release ver: %s\n"
668  "API ver: %s\n"
669  "Date: %s\n"
670  "ID: %s\n",
673  break;
674  case 'l':
675  listOneTypeCoders();
676  break;
677  case 'L':
678  listAllCodersFull();
679  break;
680  case 'o':
681  listModuleId();
682  break;
683  case 'g':
684  getCoderDetailInfo();
685  break;
686  case 's':
687  niRsrcRefresh();
688  break;
689  case 'p':
690  getlocaldevicelist();
691  break;
692  case 'x':
693  addCoder();
694  break;
695  case 'd':
696  deleteCoder();
697  break;
698  case 'r':
699  checkHwAvailable();
700  break;
701  case 'm':
702  displayRsrcMon();
703  break;
704  case 'C':
705  checkHWInfo();
706  break;
707  case 'a':
708  allocAuto();
709  break;
710  case 'q':
711  case EOF:
712  stop = 1;
713  break;
714  default:
715  continue;
716  }
717  }
718 
719  return 0;
720 }
_ni_load_query::fw_p2p_mem_usage
uint32_t fw_p2p_mem_usage
Definition: ni_device_api.h:1211
ni_log_level_t
ni_log_level_t
Definition: ni_log.h:55
_ni_device_pool::lock
ni_lock_handle_t lock
Definition: ni_rsrc_api.h:98
ni_rsrc_check_hw_available
int ni_rsrc_check_hw_available(int guid, ni_device_type_t device_type)
check the NetInt h/w device in resource pool on the host.
Definition: ni_rsrc_api.cpp:2016
NI_UNUSED
#define NI_UNUSED
Definition: ni_defs.h:64
NI_DEVICE_TYPE_ENCODER
@ NI_DEVICE_TYPE_ENCODER
Definition: ni_defs.h:347
main
int main(void)
Definition: test_rsrc_api.c:622
ni_rsrc_free_device_pool
void ni_rsrc_free_device_pool(ni_device_pool_t *p_device_pool)
Free all resources taken by the device pool.
Definition: ni_rsrc_api.cpp:2621
_ni_device::xcoders
ni_device_info_t xcoders[NI_DEVICE_TYPE_XCODER_MAX][NI_MAX_DEVICE_CNT]
Definition: ni_rsrc_api.h:142
ni_rsrc_remove_device
int ni_rsrc_remove_device(const char *dev)
Remove an NetInt h/w device from resource pool on the host.
Definition: ni_rsrc_api.cpp:2203
ni_rsrc_get_device_context
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....
ni_destory_hw_device_info_quadra_coder_param
void ni_destory_hw_device_info_quadra_coder_param(ni_hw_device_info_quadra_coder_param_t *p_hw_device_info_quadra_coder_param)
Free resource in p_hw_device_info_quadra_coder_param This function is used for ni_check_hw_info()
Definition: ni_rsrc_api.cpp:3271
_ni_load_query::current_load
uint32_t current_load
Definition: ni_device_api.h:1198
_ni_load_query::total_contexts
uint32_t total_contexts
Definition: ni_device_api.h:1201
ni_device_session_query
ni_retcode_t ni_device_session_query(ni_session_context_t *p_ctx, ni_device_type_t device_type)
Query session data from the device - If device_type is valid, will query session data from specified ...
Definition: ni_device_api.c:1920
ni_device_close
void ni_device_close(ni_device_handle_t device_handle)
Close device and release resources.
Definition: ni_device_api.c:503
NI_DEVICE_TYPE_DECODER
@ NI_DEVICE_TYPE_DECODER
Definition: ni_defs.h:346
_ni_hw_device_info_quadra_encoder_param::w
uint32_t w
Definition: ni_rsrc_api.h:178
_ni_hw_device_info_quadra_encoder_param::lookaheadDepth
uint32_t lookaheadDepth
Definition: ni_rsrc_api.h:182
NI_SW_RELEASE_ID
#define NI_SW_RELEASE_ID
Definition: ni_release_info.h:29
ni_device_type_t
ni_device_type_t
Definition: ni_defs.h:341
_ni_hw_device_info_quadra_scaler_param::h
uint32_t h
Definition: ni_rsrc_api.h:200
NI_RETCODE_SUCCESS
@ NI_RETCODE_SUCCESS
Definition: ni_defs.h:427
ni_device_open
ni_device_handle_t ni_device_open(const char *p_dev, uint32_t *p_max_io_size_out)
Open device and return device device_handle if successful.
Definition: ni_device_api.c:360
_ni_device_info::active_num_inst
uint32_t active_num_inst
Definition: ni_rsrc_api.h:128
EN_H265
@ EN_H265
Definition: ni_rsrc_api.h:51
ni_log_set_level
void ni_log_set_level(ni_log_level_t level)
Set ni_log_level.
Definition: ni_log.c:202
ni_rsrc_api.h
Public definitions for managing NETINT video processing devices.
_ni_device::xcoder_cnt
int xcoder_cnt[NI_DEVICE_TYPE_XCODER_MAX]
Definition: ni_rsrc_api.h:141
_ni_device
Definition: ni_rsrc_api.h:139
NI_XCODER_REVISION
#define NI_XCODER_REVISION
Definition: ni_defs.h:95
_ni_session_context::blk_io_handle
ni_device_handle_t blk_io_handle
Definition: ni_device_api.h:1465
_ni_device_pool::p_device_queue
ni_device_queue_t * p_device_queue
Definition: ni_rsrc_api.h:99
_ni_hw_device_info_quadra_threshold_param::device_type
ni_device_type_t device_type
Definition: ni_rsrc_api.h:216
_ni_load_query::fw_share_mem_usage
uint32_t fw_share_mem_usage
Definition: ni_device_api.h:1210
ni_rsrc_add_device
int ni_rsrc_add_device(const char *dev, int should_match_rev)
Add an NetInt h/w device into resource pool on the host.
Definition: ni_rsrc_api.cpp:2523
ni_create_hw_device_info_quadra_coder_param
ni_hw_device_info_quadra_coder_param_t * ni_create_hw_device_info_quadra_coder_param(int mode)
Create and alloc a pointer to ni_hw_device_info_quadra_coder_param_t This function is used for ni_che...
Definition: ni_rsrc_api.cpp:3118
_ni_hw_device_info_quadra_threshold_param::task_num_threshold
int task_num_threshold
Definition: ni_rsrc_api.h:218
_ni_session_context::hw_id
int hw_id
Definition: ni_device_api.h:1478
_ni_device_info::hw_id
int hw_id
Definition: ni_rsrc_api.h:106
_ni_device_info::dev_name
char dev_name[NI_MAX_DEVICE_NAME_LEN]
Definition: ni_rsrc_api.h:104
_ni_load_query::fw_model_load
uint32_t fw_model_load
Definition: ni_device_api.h:1199
_ni_hw_device_info_quadra_scaler_param::w
uint32_t w
Definition: ni_rsrc_api.h:201
ni_rsrc_get_device_pool
LIB_API ni_device_pool_t * ni_rsrc_get_device_pool(void)
Create and return the allocated ni_device_pool_t struct.
arg_to_ni_log_level
ni_log_level_t arg_to_ni_log_level(const char *arg_str)
Convert terminal arg string to ni_log_level_t.
Definition: ni_log.c:262
atof
#define atof(p_str)
Definition: ni_device_api.c:7179
_ni_device_queue::xcoders
int32_t xcoders[NI_DEVICE_TYPE_XCODER_MAX][NI_MAX_DEVICE_CNT]
Definition: ni_rsrc_api.h:70
IS_XCODER_DEVICE_TYPE
#define IS_XCODER_DEVICE_TYPE(t)
Definition: ni_defs.h:410
ni_rsrc_get_device_info
ni_device_info_t * ni_rsrc_get_device_info(ni_device_type_t device_type, int guid)
Query a specific device with detailed information on the system.
Definition: ni_rsrc_api.cpp:1748
_ni_device_info
Definition: ni_rsrc_api.h:102
NI_DEVICE_TYPE_AI
@ NI_DEVICE_TYPE_AI
Definition: ni_defs.h:349
ni_alloc_rule_t
ni_alloc_rule_t
Definition: ni_rsrc_api.h:252
_ni_hw_device_info_quadra_encoder_param::h
uint32_t h
Definition: ni_rsrc_api.h:177
_ni_load_query::fw_video_mem_usage
uint32_t fw_video_mem_usage
Definition: ni_device_api.h:1203
_ni_session_context::device_handle
ni_device_handle_t device_handle
Definition: ni_device_api.h:1462
ni_rsrc_free_device_context
void ni_rsrc_free_device_context(ni_device_context_t *p_device_context)
Free previously allocated device context.
Definition: ni_rsrc_api.cpp:1310
NI_SW_RELEASE_TIME
#define NI_SW_RELEASE_TIME
Definition: ni_release_info.h:28
_ni_device_queue
Definition: ni_rsrc_api.h:67
ni_rsrc_print_device_info
void ni_rsrc_print_device_info(const ni_device_info_t *p_device_info)
Print the content of the ni_device_info_t struct.
Definition: ni_rsrc_api.cpp:1600
NI_LOG_INVALID
@ NI_LOG_INVALID
Definition: ni_log.h:57
_ni_device_info::module_id
int module_id
Definition: ni_rsrc_api.h:107
_ni_hw_device_info_quadra_coder_param
Definition: ni_rsrc_api.h:221
compareInt32_t
int compareInt32_t(const void *a, const void *b)
compare two int32_t for qsort
Definition: ni_rsrc_mon.c:267
ni_rsrc_print_all_devices_capability
void ni_rsrc_print_all_devices_capability(void)
Print detailed capability information of all devices on the system.
Definition: ni_rsrc_api.cpp:1681
ni_device_session_context_clear
void ni_device_session_context_clear(ni_session_context_t *p_ctx)
Clear already allocated session context.
Definition: ni_device_api.c:249
_ni_hw_device_info_quadra_decoder_param::h
uint32_t h
Definition: ni_rsrc_api.h:191
ni_rsrc_allocate_auto
ni_device_context_t * ni_rsrc_allocate_auto(ni_device_type_t device_type, ni_alloc_rule_t rule, ni_codec_t codec, int width, int height, int frame_rate, uint64_t *p_load)
Allocate resources for decoding/encoding, based on the provided rule.
Definition: ni_rsrc_api.cpp:4103
_ni_device_context
Definition: ni_rsrc_api.h:145
_ni_hw_device_info_quadra_scaler_param::bit_8_10
uint32_t bit_8_10
Definition: ni_rsrc_api.h:202
NI_DEVICE_TYPE_SCALER
@ NI_DEVICE_TYPE_SCALER
Definition: ni_defs.h:348
NI_ERRNO
#define NI_ERRNO
Definition: ni_defs.h:217
_ni_hw_device_info_quadra_threshold_param::load_threshold
int load_threshold
Definition: ni_rsrc_api.h:217
_ni_session_context
Definition: ni_device_api.h:1408
NI_MAX_DEVICE_CNT
#define NI_MAX_DEVICE_CNT
Definition: ni_defs.h:223
ni_rsrc_priv.h
Private definitions used by ni_rsrc_api.cpp for management of NETINT video processing devices.
_ni_hw_device_info_quadra_coder_param::scaler_param
ni_hw_device_info_quadra_scaler_param_t * scaler_param
Definition: ni_rsrc_api.h:226
_ni_device_context::p_device_info
ni_device_info_t * p_device_info
Definition: ni_rsrc_api.h:149
_ni_session_context::load_query
ni_load_query_t load_query
Definition: ni_device_api.h:1500
atoi
#define atoi(p_str)
Definition: ni_device_api.c:7178
ni_check_hw_info
int ni_check_hw_info(ni_hw_device_info_quadra_t **pointer_to_p_hw_device_info, int task_mode, ni_hw_device_info_quadra_threshold_param_t *hw_info_threshold_param, ni_device_type_t preferential_device_type, ni_hw_device_info_quadra_coder_param_t *coder_param, int hw_mode, int consider_mem)
check hw info, return the appropriate card number to use depends on the load&task_num&used resource
Definition: ni_rsrc_api.cpp:3401
ni_rsrc_list_all_devices
ni_retcode_t ni_rsrc_list_all_devices(ni_device_t *p_device)
List all devices with full information including s/w instances on the system.
Definition: ni_rsrc_api.cpp:1445
ni_rsrc_init
LIB_API int ni_rsrc_init(int should_match_rev, int timeout_seconds)
Initialize and create all resources required to work with NETINT NVMe transcoder devices....
LIBXCODER_API_VERSION
#define LIBXCODER_API_VERSION
Definition: ni_defs.h:112
NI_DEVICE_TYPE_XCODER_MAX
@ NI_DEVICE_TYPE_XCODER_MAX
Definition: ni_defs.h:350
_ni_session_context::max_nvme_io_size
uint32_t max_nvme_io_size
Definition: ni_device_api.h:1476
_ni_device_pool
Definition: ni_rsrc_api.h:96
_ni_hw_device_info_quadra_decoder_param::hw_frame
int hw_frame
Definition: ni_rsrc_api.h:195
ni_rsrc_list_devices
ni_retcode_t ni_rsrc_list_devices(ni_device_type_t device_type, ni_device_info_t *p_device_info, int *p_device_count)
List device(s) based on device type with full information including s/w instances on the system.
Definition: ni_rsrc_api.cpp:1340
ni_util.h
Utility definitions.
_ni_hw_device_info_quadra_decoder_param::w
uint32_t w
Definition: ni_rsrc_api.h:192
_ni_hw_device_info_quadra_threshold_param
Definition: ni_rsrc_api.h:214
_ni_hw_device_info_quadra
Definition: ni_rsrc_api.h:163
ni_rsrc_refresh
ni_retcode_t ni_rsrc_refresh(int should_match_rev)
Scan and refresh all resources on the host, taking into account hot-plugged and pulled out cards.
Definition: ni_rsrc_api.cpp:159
_ni_hw_device_info_quadra_coder_param::encoder_param
ni_hw_device_info_quadra_encoder_param_t * encoder_param
Definition: ni_rsrc_api.h:224
ni_device_session_context_init
ni_retcode_t ni_device_session_context_init(ni_session_context_t *p_ctx)
Initialize already allocated session context to a known state.
Definition: ni_device_api.c:156
_ni_device_queue::xcoder_cnt
uint32_t xcoder_cnt[NI_DEVICE_TYPE_XCODER_MAX]
Definition: ni_rsrc_api.h:69
ni_rsrc_remove_all_devices
int ni_rsrc_remove_all_devices(void)
Remove all NetInt h/w devices from resource pool on the host.
Definition: ni_rsrc_api.cpp:2407
_ni_device_info::load
int load
Definition: ni_rsrc_api.h:108
ni_hw_device_info_free_quadra
void ni_hw_device_info_free_quadra(ni_hw_device_info_quadra_t *p_hw_device_info)
Free resource in a pointer of ni_hw_device_info_quadra_t This function is used for ni_check_hw_info()
Definition: ni_rsrc_api.cpp:3381
_ni_hw_device_info_quadra_coder_param::decoder_param
ni_hw_device_info_quadra_decoder_param_t * decoder_param
Definition: ni_rsrc_api.h:225