You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
97 lines
2.0 KiB
97 lines
2.0 KiB
/*
|
|
* Copyright (c) Hisilicon Technologies Co., Ltd. 2019-2019. All rights reserved.
|
|
* Description: adec lock function
|
|
* Author: audio
|
|
* Create: 2019-12-30
|
|
*/
|
|
|
|
#include <pthread.h>
|
|
|
|
#include "adec_common.h"
|
|
#include "drv_ioctl_adec.h"
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif /* __cplusplus */
|
|
|
|
static pthread_mutex_t g_adec_mpi_mutex = PTHREAD_MUTEX_INITIALIZER;
|
|
|
|
static pthread_mutex_t g_adec_api_mutex[ADEC_INSTANCE_MAXNUM] = {
|
|
[0 ... (ADEC_INSTANCE_MAXNUM - 1)] = PTHREAD_MUTEX_INITIALIZER
|
|
};
|
|
static pthread_mutex_t g_adec_data_mutex[ADEC_INSTANCE_MAXNUM] = {
|
|
[0 ... (ADEC_INSTANCE_MAXNUM - 1)] = PTHREAD_MUTEX_INITIALIZER
|
|
};
|
|
static pthread_mutex_t g_adec_io_mutex[ADEC_INSTANCE_MAXNUM] = {
|
|
[0 ... (ADEC_INSTANCE_MAXNUM - 1)] = PTHREAD_MUTEX_INITIALIZER
|
|
};
|
|
|
|
td_void adec_mpi_lock(td_void)
|
|
{
|
|
adec_mutex_lock(&g_adec_mpi_mutex);
|
|
}
|
|
|
|
td_void adec_mpi_unlock(td_void)
|
|
{
|
|
adec_mutex_unlock(&g_adec_mpi_mutex);
|
|
}
|
|
|
|
td_void adec_api_lock(td_u32 adec_id)
|
|
{
|
|
if (adec_id >= ADEC_INSTANCE_MAXNUM) {
|
|
return;
|
|
}
|
|
|
|
adec_mutex_lock(&g_adec_api_mutex[adec_id]);
|
|
}
|
|
|
|
td_void adec_api_unlock(td_u32 adec_id)
|
|
{
|
|
if (adec_id >= ADEC_INSTANCE_MAXNUM) {
|
|
return;
|
|
}
|
|
|
|
adec_mutex_unlock(&g_adec_api_mutex[adec_id]);
|
|
}
|
|
|
|
td_void adec_data_lock(td_u32 adec_id)
|
|
{
|
|
if (adec_id >= ADEC_INSTANCE_MAXNUM) {
|
|
return;
|
|
}
|
|
|
|
adec_mutex_lock(&g_adec_data_mutex[adec_id]);
|
|
}
|
|
|
|
td_void adec_data_unlock(td_u32 adec_id)
|
|
{
|
|
if (adec_id >= ADEC_INSTANCE_MAXNUM) {
|
|
return;
|
|
}
|
|
|
|
adec_mutex_unlock(&g_adec_data_mutex[adec_id]);
|
|
}
|
|
|
|
td_void adec_io_lock(td_u32 adec_id)
|
|
{
|
|
if (adec_id >= ADEC_INSTANCE_MAXNUM) {
|
|
return;
|
|
}
|
|
|
|
adec_mutex_lock(&g_adec_io_mutex[adec_id]);
|
|
}
|
|
|
|
td_void adec_io_unlock(td_u32 adec_id)
|
|
{
|
|
if (adec_id >= ADEC_INSTANCE_MAXNUM) {
|
|
return;
|
|
}
|
|
|
|
adec_mutex_unlock(&g_adec_io_mutex[adec_id]);
|
|
}
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif /* __cplusplus */
|
|
|