[osal]: Add hardware platform detection

Change-Id: I0223b79608a9ea8346dbf194805c2536a90beb3b
Signed-off-by: leo.ding <leo.ding@rock-chips.com>
This commit is contained in:
leo.ding
2017-01-05 10:40:00 +08:00
committed by Herman Chen
parent 4c1ae218e6
commit b0902117fc
2 changed files with 73 additions and 20 deletions

View File

@@ -30,12 +30,18 @@ extern "C" {
/* /*
* Platform video codec hardware feature * Platform video codec hardware feature
*/ */
/* RK combined codec */
#define HAVE_VPU1 (0x00000001) #define HAVE_VPU1 (0x00000001)
#define HAVE_VPU2 (0x00000002) #define HAVE_VPU2 (0x00000002)
#define HAVE_HEVC_DEC (0x00000010) /* RK standalone decoder */
#define HAVE_RKVDEC (0x00000020) #define HAVE_HEVC_DEC (0x00000100)
#define HAVE_RKVENC (0x00000100) #define HAVE_RKVDEC (0x00000200)
#define HAVE_H265E (0x00010000) #define HAVE_AVSDEC (0x00001000)
/* RK standalone encoder */
#define HAVE_RKVENC (0x00010000)
#define HAVE_VEPU (0x00020000)
/* External encoder */
#define HAVE_H265E (0x01000000)
RK_U32 mpp_get_vcodec_hw_flag(void); RK_U32 mpp_get_vcodec_hw_flag(void);

View File

@@ -14,29 +14,76 @@
* limitations under the License. * limitations under the License.
*/ */
#ifdef RKPLATFORM
#include <fcntl.h>
#endif
#include "mpp_log.h"
#include "mpp_common.h" #include "mpp_common.h"
#include "mpp_platform.h" #include "mpp_platform.h"
typedef struct {
const char *compatible;
RK_U32 flag;
} MppVpuType;
static const MppVpuType mpp_vpu_version[] = {
{ "rk3066", HAVE_VPU1, },
{ "rk312x", HAVE_VPU1, },
{ "rk3288", HAVE_VPU1, },
{ "rk3368", HAVE_VPU1, },
{ "rk3399", HAVE_VPU2, },
{ "rk322x", HAVE_VPU2, },
{ "rk322xh", HAVE_VPU2, },
{ "rk1108", HAVE_VPU2, },
{ "rv1108", HAVE_VPU2, },
};
RK_U32 mpp_get_vcodec_hw_flag(void) RK_U32 mpp_get_vcodec_hw_flag(void)
{ {
RK_U32 flag = 0; static RK_U32 flag = 0;
if (flag)
return flag;
#ifdef RKPLATFORM #ifdef RKPLATFORM
/* NOTE: current only support vpu2 */ {
if (!access("/dev/vpu_service", F_OK)) /* judge vdpu support version */
flag |= HAVE_VPU2; RK_S32 fd = -1;
/* set vpu1 defalut for old chip without dts */
/* for rk3288 / rk3368 /rk312x hevc decoder */ flag = HAVE_VPU1;
if (!access("/dev/hevc_service", F_OK)) fd = open("/proc/device-tree/compatible", O_RDONLY);
flag |= HAVE_HEVC_DEC; if (fd < 0) {
mpp_err("open /proc/device-tree/compatible error.\n");
/* for rk3228 / rk3229 / rk3399 decoder */ } else {
if (!access("/dev/rkvdec", F_OK)) RK_U32 i = 0;
flag |= HAVE_RKVDEC; char temp[256];
if (read(fd, temp, sizeof(temp) - 1) > 0) {
/* for rk1108 encoder */ for (i = 0; i < MPP_ARRAY_ELEMS(mpp_vpu_version); i++) {
if (!access("/dev/rkvenc", F_OK)) if (strstr(temp, mpp_vpu_version[i].compatible)) {
flag |= HAVE_RKVENC; flag = mpp_vpu_version[i].flag;
break;
}
}
}
close(fd);
}
/* 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;
}
/* for avs decoder */
if (!access("/dev/avsd", F_OK)) {
flag |= HAVE_AVSDEC;
}
}
#endif #endif
return flag; return flag;