mirror of
https://github.com/nyanmisaka/mpp.git
synced 2025-10-07 10:00:55 +08:00
feat[kmpp]: Add kmpp module
Change-Id: Ia9c414edf625885fd551ad14f72dd1f7bc34172d Signed-off-by: Yandong Lin <yandong.lin@rock-chips.com>
This commit is contained in:
74
osal/driver/mpp_vcodec_client.c
Normal file
74
osal/driver/mpp_vcodec_client.c
Normal file
@@ -0,0 +1,74 @@
|
||||
/* SPDX-License-Identifier: Apache-2.0 OR MIT */
|
||||
/*
|
||||
* Copyright (c) 2024 Rockchip Electronics Co., Ltd.
|
||||
*/
|
||||
|
||||
#define MODULE_TAG "mpp_vcodec"
|
||||
|
||||
#include <sys/ioctl.h>
|
||||
#include <fcntl.h>
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "mpp_log.h"
|
||||
#include "mpp_env.h"
|
||||
#include "mpp_common.h"
|
||||
#include "mpp_vcodec_client.h"
|
||||
|
||||
#define VOCDEC_IOC_MAGIC 'V'
|
||||
#define VOCDEC_IOC_CFG _IOW(VOCDEC_IOC_MAGIC, 1, unsigned int)
|
||||
|
||||
typedef struct vcodec_req_t {
|
||||
RK_U32 cmd;
|
||||
RK_U32 ctrl_cmd;
|
||||
RK_U32 size;
|
||||
RK_U64 data;
|
||||
} vcodec_req;
|
||||
|
||||
#if __SIZEOF_POINTER__ == 4
|
||||
#define REQ_DATA_PTR(ptr) ((RK_U32)ptr)
|
||||
#elif __SIZEOF_POINTER__ == 8
|
||||
#define REQ_DATA_PTR(ptr) ((RK_U64)ptr)
|
||||
#endif
|
||||
|
||||
RK_S32 mpp_vcodec_open(void)
|
||||
{
|
||||
RK_S32 fd = -1;
|
||||
|
||||
fd = open("/dev/vcodec", O_RDWR | O_CLOEXEC);
|
||||
if (fd < 0) {
|
||||
mpp_err("open /dev/vcodec failed errno %d %s\n", errno, strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
|
||||
return fd;
|
||||
}
|
||||
|
||||
MPP_RET mpp_vcodec_ioctl(RK_S32 fd, RK_U32 cmd, RK_U32 ctrl_cmd, RK_U32 size, void *param)
|
||||
{
|
||||
vcodec_req req;
|
||||
RK_S32 ret = 0;
|
||||
|
||||
memset(&req, 0, sizeof(req));
|
||||
req.cmd = cmd;
|
||||
req.ctrl_cmd = ctrl_cmd;
|
||||
req.size = size;
|
||||
req.data = REQ_DATA_PTR(param);
|
||||
|
||||
ret = (RK_S32)ioctl(fd, VOCDEC_IOC_CFG, &req);
|
||||
if (ret) {
|
||||
mpp_err("ioctl fd %d failed ret %d errno %d %s\n",
|
||||
fd, ret, errno, strerror(errno));
|
||||
return MPP_NOK;
|
||||
}
|
||||
|
||||
return MPP_OK;
|
||||
}
|
||||
|
||||
MPP_RET mpp_vcodec_close(RK_S32 fd)
|
||||
{
|
||||
if (fd)
|
||||
close(fd);
|
||||
|
||||
return MPP_OK;
|
||||
}
|
Reference in New Issue
Block a user