[mpp_platform]: Improve ioctl version detection

Move kernel ioctl api version detection to library loading stage.

Change-Id: If8ee750e1eaefb99924fd622d03270ef5032d1be
Signed-off-by: Herman Chen <herman.chen@rock-chips.com>
This commit is contained in:
Herman Chen
2020-01-19 15:27:09 +08:00
parent 2c7148f110
commit e04f0e83e7
2 changed files with 36 additions and 32 deletions

View File

@@ -22,6 +22,11 @@
/* /*
* Platform flag detection is for rockchip hardware platform detection * Platform flag detection is for rockchip hardware platform detection
*/ */
typedef enum MppIoctlVersion_e {
IOCTL_VCODEC_SERVICE,
IOCTL_MPP_SERVICE_V1,
IOCTL_VERSION_BUTT,
} MppIoctlVersion;
/* /*
* Platform video codec hardware feature * Platform video codec hardware feature
@@ -45,27 +50,27 @@ typedef enum {
} VPU_CLIENT2_TYPE; } VPU_CLIENT2_TYPE;
/* RK combined codec */ /* RK combined codec */
#define HAVE_VDPU1 (1 << VPU_CLIENT_VDPU1) /* 0x00000001 */ #define HAVE_VDPU1 (1 << VPU_CLIENT_VDPU1) /* 0x00000001 */
#define HAVE_VDPU2 (1 << VPU_CLIENT_VDPU2) /* 0x00000002 */ #define HAVE_VDPU2 (1 << VPU_CLIENT_VDPU2) /* 0x00000002 */
#define HAVE_VDPU1_PP (1 << VPU_CLIENT_VDPU1_PP) /* 0x00000004 */ #define HAVE_VDPU1_PP (1 << VPU_CLIENT_VDPU1_PP) /* 0x00000004 */
#define HAVE_VDPU2_PP (1 << VPU_CLIENT_VDPU2_PP) /* 0x00000008 */ #define HAVE_VDPU2_PP (1 << VPU_CLIENT_VDPU2_PP) /* 0x00000008 */
/* RK standalone decoder */ /* RK standalone decoder */
#define HAVE_HEVC_DEC (1 << VPU_CLIENT_HEVC_DEC) /* 0x00000100 */ #define HAVE_HEVC_DEC (1 << VPU_CLIENT_HEVC_DEC) /* 0x00000100 */
#define HAVE_RKVDEC (1 << VPU_CLIENT_RKVDEC) /* 0x00000200 */ #define HAVE_RKVDEC (1 << VPU_CLIENT_RKVDEC) /* 0x00000200 */
#define HAVE_AVSDEC (1 << VPU_CLIENT_AVSPLUS_DEC) /* 0x00001000 */ #define HAVE_AVSDEC (1 << VPU_CLIENT_AVSPLUS_DEC) /* 0x00001000 */
/* RK standalone encoder */ /* RK standalone encoder */
#define HAVE_RKVENC (1 << VPU_CLIENT_RKVENC) /* 0x00010000 */ #define HAVE_RKVENC (1 << VPU_CLIENT_RKVENC) /* 0x00010000 */
#define HAVE_VEPU1 (1 << VPU_CLIENT_VEPU1) /* 0x00020000 */ #define HAVE_VEPU1 (1 << VPU_CLIENT_VEPU1) /* 0x00020000 */
#define HAVE_VEPU2 (1 << VPU_CLIENT_VEPU2) /* 0x00040000 */ #define HAVE_VEPU2 (1 << VPU_CLIENT_VEPU2) /* 0x00040000 */
#define HAVE_VEPU2_LITE (1 << VPU_CLIENT_VEPU2_LITE) /* 0x00080000 */ #define HAVE_VEPU2_LITE (1 << VPU_CLIENT_VEPU2_LITE) /* 0x00080000 */
/* External encoder */ /* External encoder */
#define HAVE_VEPU22 (1 << VPU_CLIENT_VEPU22) /* 0x01000000 */ #define HAVE_VEPU22 (1 << VPU_CLIENT_VEPU22) /* 0x01000000 */
/* Platform image process hardware feature */ /* Platform image process hardware feature */
#define HAVE_IPP (0x00000001) #define HAVE_IPP (0x00000001)
#define HAVE_RGA (0x00000002) #define HAVE_RGA (0x00000002)
#define HAVE_RGA2 (0x00000004) #define HAVE_RGA2 (0x00000004)
#define HAVE_IEP (0x00000008) #define HAVE_IEP (0x00000008)
/* Hal device id */ /* Hal device id */
typedef enum MppDeviceId_e { typedef enum MppDeviceId_e {
@@ -80,10 +85,10 @@ typedef enum MppDeviceId_e {
extern "C" { extern "C" {
#endif #endif
MppIoctlVersion mpp_get_ioctl_version(void);
const char *mpp_get_soc_name(void); const char *mpp_get_soc_name(void);
RK_U32 mpp_get_vcodec_type(void); RK_U32 mpp_get_vcodec_type(void);
RK_U32 mpp_get_2d_hw_flag(void); RK_U32 mpp_get_2d_hw_flag(void);
RK_U32 mpp_get_ioctl_version(void);
RK_U32 mpp_refresh_vcodec_type(RK_U32 vcodec_type); RK_U32 mpp_refresh_vcodec_type(RK_U32 vcodec_type);
const char *mpp_get_platform_dev_name(MppCtxType type, MppCodingType coding, RK_U32 platform); const char *mpp_get_platform_dev_name(MppCtxType type, MppCodingType coding, RK_U32 platform);
const char *mpp_get_vcodec_dev_name(MppCtxType type, MppCodingType coding); const char *mpp_get_vcodec_dev_name(MppCtxType type, MppCodingType coding);

View File

@@ -149,6 +149,7 @@ private:
MppPlatformService(const MppPlatformService &); MppPlatformService(const MppPlatformService &);
MppPlatformService &operator=(const MppPlatformService &); MppPlatformService &operator=(const MppPlatformService &);
MppIoctlVersion ioctl_version;
char *soc_name; char *soc_name;
RockchipSocType soc_type; RockchipSocType soc_type;
RK_U32 vcodec_type; RK_U32 vcodec_type;
@@ -160,15 +161,17 @@ public:
return &instance; return &instance;
} }
MppIoctlVersion get_ioctl_version(void) { return ioctl_version; };
const char *get_soc_name() { return soc_name; }; const char *get_soc_name() { return soc_name; };
RockchipSocType get_soc_type() { return soc_type; }; RockchipSocType get_soc_type() { return soc_type; };
RK_U32 get_vcodec_type() { return vcodec_type; }; RK_U32 get_vcodec_type() { return vcodec_type; };
void refresh_vcodec_type(RK_U32 val) { vcodec_type = val; }; void set_vcodec_type(RK_U32 val) { vcodec_type = val; };
RK_U32 get_vcodec_capability() { return vcodec_capability; }; RK_U32 get_vcodec_capability() { return vcodec_capability; };
}; };
MppPlatformService::MppPlatformService() MppPlatformService::MppPlatformService()
: soc_name(NULL), : ioctl_version(IOCTL_VCODEC_SERVICE),
soc_name(NULL),
vcodec_type(0), vcodec_type(0),
vcodec_capability(0) vcodec_capability(0)
{ {
@@ -222,6 +225,7 @@ MppPlatformService::MppPlatformService()
/* if /dev/mpp_service not double check */ /* if /dev/mpp_service not double check */
if (mpp_find_device(mpp_service_dev)) { if (mpp_find_device(mpp_service_dev)) {
ioctl_version = IOCTL_MPP_SERVICE_V1;
mpp_dbg(MPP_DBG_PLATFORM, "/dev/mpp_service not double check device\n"); mpp_dbg(MPP_DBG_PLATFORM, "/dev/mpp_service not double check device\n");
goto __return; goto __return;
} }
@@ -280,6 +284,11 @@ MppPlatformService::~MppPlatformService()
MPP_FREE(soc_name); MPP_FREE(soc_name);
} }
MppIoctlVersion mpp_get_ioctl_version(void)
{
return MppPlatformService::get_instance()->get_ioctl_version();
}
const char *mpp_get_soc_name(void) const char *mpp_get_soc_name(void)
{ {
static const char *soc_name = NULL; static const char *soc_name = NULL;
@@ -314,27 +323,17 @@ RK_U32 mpp_get_2d_hw_flag(void)
return flag; return flag;
} }
RK_U32 mpp_get_ioctl_version(void)
{
RK_U32 flag = 0;
flag = mpp_find_device(mpp_service_dev) ? 1 : 0;
return flag;
}
RK_U32 mpp_refresh_vcodec_type(RK_U32 vcodec_type) RK_U32 mpp_refresh_vcodec_type(RK_U32 vcodec_type)
{ {
MppPlatformService::get_instance()->refresh_vcodec_type(vcodec_type); MppPlatformService::get_instance()->set_vcodec_type(vcodec_type);
return 0; return 0;
} }
const char *mpp_get_platform_dev_name(MppCtxType type, MppCodingType coding, RK_U32 platform) const char *mpp_get_platform_dev_name(MppCtxType type, MppCodingType coding, RK_U32 platform)
{ {
const char *dev = NULL; const char *dev = mpp_find_device(mpp_service_dev);
if (dev) {
if ((dev = mpp_find_device(mpp_service_dev)) != NULL) {
mpp_log("got the %s\n", dev); mpp_log("got the %s\n", dev);
} else if ((platform & HAVE_RKVDEC) && (type == MPP_CTX_DEC) && } else if ((platform & HAVE_RKVDEC) && (type == MPP_CTX_DEC) &&
(coding == MPP_VIDEO_CodingAVC || (coding == MPP_VIDEO_CodingAVC ||