mirror of
https://github.com/nyanmisaka/mpp.git
synced 2025-10-06 17:46:50 +08:00
[osal]: add environment detection function
1. add software runtime detection 2. add hardware platform detection Change-Id: I75736ae85130325029023d948e4d756e27953af8 Signed-off-by: Herman Chen <herman.chen@rock-chips.com>
This commit is contained in:
@@ -21,6 +21,8 @@ include_directories(.)
|
|||||||
include_directories(./allocator)
|
include_directories(./allocator)
|
||||||
|
|
||||||
add_library(osal STATIC
|
add_library(osal STATIC
|
||||||
|
mpp_platform.cpp
|
||||||
|
mpp_runtime.cpp
|
||||||
mpp_allocator.cpp
|
mpp_allocator.cpp
|
||||||
mpp_thread.cpp
|
mpp_thread.cpp
|
||||||
mpp_common.cpp
|
mpp_common.cpp
|
||||||
|
57
osal/inc/mpp_platform.h
Normal file
57
osal/inc/mpp_platform.h
Normal file
@@ -0,0 +1,57 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2015 Rockchip Electronics Co. LTD
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef __MPP_PLATFORM__
|
||||||
|
#define __MPP_PLATFORM__
|
||||||
|
|
||||||
|
#include "rk_type.h"
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Platform flag detection is for rockchip hardware platform detection
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Platform video codec hardware feature
|
||||||
|
*/
|
||||||
|
#define HAVE_VPU1 (0x00000001)
|
||||||
|
#define HAVE_VPU2 (0x00000002)
|
||||||
|
#define HAVE_HEVC_DEC (0x00000010)
|
||||||
|
#define HAVE_RKVDEC (0x00000020)
|
||||||
|
#define HAVE_RKVENC (0x00000100)
|
||||||
|
#define HAVE_H265E (0x00010000)
|
||||||
|
|
||||||
|
RK_U32 mpp_get_vcodec_hw_flag(void);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Platform image process hardware feature
|
||||||
|
*/
|
||||||
|
#define HAVE_IPP (0x00000001)
|
||||||
|
#define HAVE_RGA (0x00000002)
|
||||||
|
#define HAVE_RGA2 (0x00000004)
|
||||||
|
#define HAVE_IEP (0x00000008)
|
||||||
|
|
||||||
|
RK_U32 mpp_get_2d_hw_flag(void);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /*__MPP_PLATFORM__*/
|
||||||
|
|
45
osal/inc/mpp_runtime.h
Normal file
45
osal/inc/mpp_runtime.h
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2015 Rockchip Electronics Co. LTD
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef __MPP_RUNTIME__
|
||||||
|
#define __MPP_RUNTIME__
|
||||||
|
|
||||||
|
#include "mpp_common.h"
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Runtime function detection is for rockchip software platform detection
|
||||||
|
*/
|
||||||
|
|
||||||
|
typedef void *(*func_mmap64)(void* addr,size_t length, int prot, int flags,
|
||||||
|
int fd, off_t offset);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Runtime function detection is to support different binary on different
|
||||||
|
* runtime environment. This is usefull on product environemnt.
|
||||||
|
*/
|
||||||
|
|
||||||
|
func_mmap64 mpp_rt_get_mmap64();
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /*__MPP_RUNTIME__*/
|
||||||
|
|
62
osal/mpp_platform.cpp
Normal file
62
osal/mpp_platform.cpp
Normal file
@@ -0,0 +1,62 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2015 Rockchip Electronics Co. LTD
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
|
#include "mpp_platform.h"
|
||||||
|
|
||||||
|
RK_U32 mpp_get_vcodec_hw_flag(void)
|
||||||
|
{
|
||||||
|
RK_U32 flag = 0;
|
||||||
|
|
||||||
|
#ifdef RKPLATFORM
|
||||||
|
/* NOTE: current only support vpu2 */
|
||||||
|
if (!access("/dev/vpu_service", F_OK))
|
||||||
|
flag |= HAVE_VPU2;
|
||||||
|
|
||||||
|
/* for rk3288 / rk3368 /rk312x hevc decoder */
|
||||||
|
if (!access("/dev/hevc_service", F_OK))
|
||||||
|
flag |= HAVE_HEVC_DEC;
|
||||||
|
|
||||||
|
/* for rk3228 / rk3229 / rk3399 decoder */
|
||||||
|
if (!access("/dev/rkvdec", F_OK))
|
||||||
|
flag |= HAVE_RKVDEC;
|
||||||
|
|
||||||
|
/* for rk1108 encoder */
|
||||||
|
if (!access("/dev/rkvenc", F_OK))
|
||||||
|
flag |= HAVE_RKVENC;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return flag;
|
||||||
|
}
|
||||||
|
|
||||||
|
RK_U32 mpp_get_2d_hw_flag(void)
|
||||||
|
{
|
||||||
|
RK_U32 flag = 0;
|
||||||
|
|
||||||
|
#ifdef RKPLATFORM
|
||||||
|
|
||||||
|
if (!access("/dev/rga", F_OK))
|
||||||
|
flag |= HAVE_RGA;
|
||||||
|
|
||||||
|
if (!access("/dev/iep", F_OK))
|
||||||
|
flag |= HAVE_IEP;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return flag;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
43
osal/mpp_runtime.cpp
Normal file
43
osal/mpp_runtime.cpp
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2015 Rockchip Electronics Co. LTD
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifdef RKPLATFORM
|
||||||
|
#include <dlfcn.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "mpp_runtime.h"
|
||||||
|
|
||||||
|
static func_mmap64 mpp_rt_mmap64 = NULL;
|
||||||
|
|
||||||
|
func_mmap64 mpp_rt_get_mmap64()
|
||||||
|
{
|
||||||
|
#ifdef RKPLATFORM
|
||||||
|
static RK_U32 once = 1;
|
||||||
|
|
||||||
|
if (once) {
|
||||||
|
void *libc_hdl = dlopen("libc", RTLD_LAZY);
|
||||||
|
if (libc_hdl) {
|
||||||
|
mpp_rt_mmap64 = (func_mmap64)dlsym(libc_hdl, "mmap64");
|
||||||
|
dlclose(libc_hdl);
|
||||||
|
}
|
||||||
|
|
||||||
|
once = 0;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return mpp_rt_mmap64;
|
||||||
|
}
|
||||||
|
|
Reference in New Issue
Block a user