mirror of
https://github.com/nyanmisaka/mpp.git
synced 2025-10-05 17:16:50 +08:00
[osal]: Add hardware platform detection
Change-Id: I0223b79608a9ea8346dbf194805c2536a90beb3b Signed-off-by: leo.ding <leo.ding@rock-chips.com>
This commit is contained in:
@@ -14,29 +14,76 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifdef RKPLATFORM
|
||||
#include <fcntl.h>
|
||||
#endif
|
||||
#include "mpp_log.h"
|
||||
#include "mpp_common.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 flag = 0;
|
||||
static RK_U32 flag = 0;
|
||||
|
||||
if (flag)
|
||||
return flag;
|
||||
|
||||
#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;
|
||||
{
|
||||
/* judge vdpu support version */
|
||||
RK_S32 fd = -1;
|
||||
/* set vpu1 defalut for old chip without dts */
|
||||
flag = HAVE_VPU1;
|
||||
fd = open("/proc/device-tree/compatible", O_RDONLY);
|
||||
if (fd < 0) {
|
||||
mpp_err("open /proc/device-tree/compatible error.\n");
|
||||
} else {
|
||||
RK_U32 i = 0;
|
||||
char temp[256];
|
||||
if (read(fd, temp, sizeof(temp) - 1) > 0) {
|
||||
for (i = 0; i < MPP_ARRAY_ELEMS(mpp_vpu_version); i++) {
|
||||
if (strstr(temp, mpp_vpu_version[i].compatible)) {
|
||||
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
|
||||
|
||||
return flag;
|
||||
|
Reference in New Issue
Block a user