 |
libxcoder
5.2.0
|
Go to the documentation of this file.
51 static void getStr(
const char *prompt,
char *str)
56 if (fgets(para,
sizeof(para), stdin) != 0) {
57 size_t len = strlen(para);
58 if (len > 0 && para[len - 1] ==
'\n')
71 static int getCmd(
const char *prompt)
73 char cmd[64] = {
'\0'};
86 static void change_log_level(
void)
91 getStr(
"set log level to [none, fatal, error, info, debug, trace]: ",
99 fprintf(stderr,
"ERROR: unknown log level selected: %s", log_str);
110 static int getInt(
const char *prompt)
114 getStr(prompt, para);
125 NI_UNUSED static float getFloat(
const char *prompt)
129 getStr(prompt, para);
130 return (
float)
atof(para);
140 NI_UNUSED static long getLong(
const char *prompt)
144 getStr(prompt, para);
155 static void listOneTypeCoders(
void)
164 for (i = 0; i < count; i++)
178 static void listModuleId(
void)
189 if (WAIT_ABANDONED == WaitForSingleObject(p_device_pool->
lock, INFINITE))
191 fprintf(stderr,
"ERROR: listModuleId() failed o obtain mutex: %p", p_device_pool->
lock);
195 if (lockf(p_device_pool->
lock, F_LOCK, 0))
197 fprintf(stderr,
"ERROR: %s() lockf() failed: %s\n", __func__,
206 printf(
"Num %ss: %u\n", g_device_type_str[k], ptr->
xcoder_cnt[k]);
211 printf(
"[%u]. %d (load: %d inst: %u %s.%d)\n", i,
214 p_device_info->
hw_id);
221 ReleaseMutex(p_device_pool->
lock);
223 if (lockf(p_device_pool->
lock, F_ULOCK, 0))
225 fprintf(stderr,
"Error lockf() failed\n");
239 static void listAllCodersFull(
void)
244 if (p_coders == NULL)
247 "Error: memory allocation failed, fatal error, exiting\n");
256 printf(
"Num %ss: %d\n", g_device_type_str[k],
275 static void getCoderDetailInfo(
void)
282 guid = getInt(
"Coder module ID: ");
283 printf(
"type: %d id %d\n", type, guid);
302 if (*(int32_t *)a < *(int32_t *)b)
306 else if (*(int32_t *)a > *(int32_t *)b)
323 static void displayRsrcMon(
void)
333 fprintf(stderr,
"FATAL: cannot get devices info\n");
337 printf(
"**************************************************\n");
346 int module_count = 0;
347 char module_name[8] = {
'\0'};
348 int32_t *module_id_arr = NULL;
353 fprintf(stderr,
"ERROR: unsupported module_type %d\n", module_type);
357 module_count = coders->
xcoder_cnt[module_type];
358 strcpy(module_name, g_device_type_str[module_type]);
360 module_id_arr = malloc(
sizeof(*module_id_arr) * module_count);
363 fprintf(stderr,
"ERROR: malloc() failed for module_id_arr\n");
366 memcpy(module_id_arr, coders->
xcoders[module_type],
367 sizeof(int32_t) * module_count);
369 printf(
"Num %ss: %d\n", g_device_type_str[module_type], module_count);
372 qsort(module_id_arr, module_count,
sizeof(int32_t),
compareInt32_t);
377 printf(
"%-5s %-4s %-10s %-4s %-4s %-9s %-7s %-14s\n",
"INDEX",
378 "LOAD",
"MODEL_LOAD",
"INST",
"MEM",
"SHARE_MEM",
"P2P_MEM",
383 for (i = 0; i < module_count; i++)
389 if (p_device_context)
400 "ERROR: ni_device_open() failed for %s: %s\n",
412 fprintf(stderr,
"Error query %s %s.%d\n", module_name,
431 printf(
"%-5d %-4u %-10u %-4u %-4u %-9u %-7u %-14s\n",
450 printf(
"**************************************************\n");
460 static void addCoder(
void)
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): ");
476 static void initRsrc(
void)
478 int should_match_rev =
479 getInt(
"should match current release version, yes (1) no (0): ");
480 int timeout_seconds = getInt(
"timeout_seconds: ");
491 static void niRsrcRefresh(
void)
493 int should_match_rev =
494 getInt(
"should match current release version, yes (1) no (0): ");
505 static void checkHwAvailable(
void)
507 int guid = getInt(
"guid :");
508 int deviceType=getInt(
"deviceType : ");
520 static void getlocaldevicelist(
void)
532 static void deleteCoder(
void)
535 getStr(
"device name (/dev/*): ", dev);
546 static void removeAllDevices(
void)
552 static void checkHWInfo(
void)
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)
559 fprintf(stderr,
"%s, read parameters failed", __func__);
586 int ret =
ni_check_hw_info(&device_info,task_mode,threshold,device_type,coder_param,hw_mode,consider_mem);
588 printf(
"ret = %d\n",ret);
600 static void allocAuto(
void)
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);
612 if (p_device_context)
614 printf(
"Successfully auto-allocated s/w instance on:\n");
616 printf(
"Allocated load: %"PRIu64
"\n", model_load);
628 printf(
"Key function\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"
636 "i Initialize and create all resources required to work with \n"
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"
650 int control = getCmd(
"> ");
667 printf(
"Release ver: %s\n"
684 getCoderDetailInfo();
690 getlocaldevicelist();
uint32_t fw_p2p_mem_usage
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.
void ni_rsrc_free_device_pool(ni_device_pool_t *p_device_pool)
Free all resources taken by the device pool.
ni_device_info_t xcoders[NI_DEVICE_TYPE_XCODER_MAX][NI_MAX_DEVICE_CNT]
int ni_rsrc_remove_device(const char *dev)
Remove an NetInt h/w device from resource pool on the host.
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....
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()
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 ...
void ni_device_close(ni_device_handle_t device_handle)
Close device and release resources.
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.
void ni_log_set_level(ni_log_level_t level)
Set ni_log_level.
Public definitions for managing NETINT video processing devices.
int xcoder_cnt[NI_DEVICE_TYPE_XCODER_MAX]
#define NI_XCODER_REVISION
ni_device_handle_t blk_io_handle
ni_device_queue_t * p_device_queue
ni_device_type_t device_type
uint32_t fw_share_mem_usage
int ni_rsrc_add_device(const char *dev, int should_match_rev)
Add an NetInt h/w device into resource pool on the host.
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...
char dev_name[NI_MAX_DEVICE_NAME_LEN]
LIB_API ni_device_pool_t * ni_rsrc_get_device_pool(void)
Create and return the allocated ni_device_pool_t struct.
ni_log_level_t arg_to_ni_log_level(const char *arg_str)
Convert terminal arg string to ni_log_level_t.
int32_t xcoders[NI_DEVICE_TYPE_XCODER_MAX][NI_MAX_DEVICE_CNT]
#define IS_XCODER_DEVICE_TYPE(t)
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.
uint32_t fw_video_mem_usage
ni_device_handle_t device_handle
void ni_rsrc_free_device_context(ni_device_context_t *p_device_context)
Free previously allocated device context.
#define NI_SW_RELEASE_TIME
void ni_rsrc_print_device_info(const ni_device_info_t *p_device_info)
Print the content of the ni_device_info_t struct.
int compareInt32_t(const void *a, const void *b)
compare two int32_t for qsort
void ni_rsrc_print_all_devices_capability(void)
Print detailed capability information of all devices on the system.
void ni_device_session_context_clear(ni_session_context_t *p_ctx)
Clear already allocated session context.
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.
#define NI_MAX_DEVICE_CNT
Private definitions used by ni_rsrc_api.cpp for management of NETINT video processing devices.
ni_hw_device_info_quadra_scaler_param_t * scaler_param
ni_device_info_t * p_device_info
ni_load_query_t load_query
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
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.
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....
#define LIBXCODER_API_VERSION
@ NI_DEVICE_TYPE_XCODER_MAX
uint32_t max_nvme_io_size
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.
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.
ni_hw_device_info_quadra_encoder_param_t * encoder_param
ni_retcode_t ni_device_session_context_init(ni_session_context_t *p_ctx)
Initialize already allocated session context to a known state.
uint32_t xcoder_cnt[NI_DEVICE_TYPE_XCODER_MAX]
int ni_rsrc_remove_all_devices(void)
Remove all NetInt h/w devices from resource pool on the host.
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()
ni_hw_device_info_quadra_decoder_param_t * decoder_param