mirror of
https://github.com/nyanmisaka/mpp.git
synced 2025-10-06 01:26:49 +08:00
fix[common]: Add mpp_dup function
mpp_dup function use fnctl F_DUPFD_CLOEXEC for fd dup with CLOEXEC flag. Signed-off-by: Herman Chen <herman.chen@rock-chips.com> Change-Id: Idd82eb935b06d2885685aeb696b95e910981539d
This commit is contained in:
@@ -17,7 +17,6 @@
|
|||||||
#define MODULE_TAG "vpu"
|
#define MODULE_TAG "vpu"
|
||||||
|
|
||||||
#include <sys/ioctl.h>
|
#include <sys/ioctl.h>
|
||||||
#include <fcntl.h>
|
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
@@ -16,7 +16,6 @@
|
|||||||
|
|
||||||
#define MODULE_TAG "vpu_api_legacy"
|
#define MODULE_TAG "vpu_api_legacy"
|
||||||
|
|
||||||
#include <fcntl.h>
|
|
||||||
#include "string.h"
|
#include "string.h"
|
||||||
|
|
||||||
#include "mpp_mem.h"
|
#include "mpp_mem.h"
|
||||||
|
@@ -16,7 +16,6 @@
|
|||||||
|
|
||||||
#define MODULE_TAG "vpu_api_mlvec"
|
#define MODULE_TAG "vpu_api_mlvec"
|
||||||
|
|
||||||
#include <fcntl.h>
|
|
||||||
#include "string.h"
|
#include "string.h"
|
||||||
|
|
||||||
#include "mpp_mem.h"
|
#include "mpp_mem.h"
|
||||||
|
@@ -17,7 +17,6 @@
|
|||||||
#define MODULE_TAG "iep"
|
#define MODULE_TAG "iep"
|
||||||
|
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include <fcntl.h>
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include "mpp_env.h"
|
#include "mpp_env.h"
|
||||||
|
@@ -17,7 +17,6 @@
|
|||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <sys/ioctl.h>
|
#include <sys/ioctl.h>
|
||||||
#include <fcntl.h>
|
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
@@ -19,7 +19,6 @@
|
|||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <fcntl.h>
|
|
||||||
#include <sys/ioctl.h>
|
#include <sys/ioctl.h>
|
||||||
#include <sys/mman.h>
|
#include <sys/mman.h>
|
||||||
|
|
||||||
@@ -113,7 +112,7 @@ static MPP_RET try_flip_flag(RK_U32 orig, RK_U32 flag)
|
|||||||
src = &heap_infos[used];
|
src = &heap_infos[used];
|
||||||
if (src->fd > 0) {
|
if (src->fd > 0) {
|
||||||
/* found valid heap use it */
|
/* found valid heap use it */
|
||||||
dst->fd = dup(src->fd);
|
dst->fd = mpp_dup(src->fd);
|
||||||
dst->flags = src->flags;
|
dst->flags = src->flags;
|
||||||
|
|
||||||
dma_heap_dbg_chk("dma-heap type %x %s remap to %x %s\n",
|
dma_heap_dbg_chk("dma-heap type %x %s remap to %x %s\n",
|
||||||
@@ -278,7 +277,7 @@ static MPP_RET os_allocator_dma_heap_import(void *ctx, MppBufferInfo *data)
|
|||||||
|
|
||||||
mpp_assert(fd_ext > 0);
|
mpp_assert(fd_ext > 0);
|
||||||
|
|
||||||
data->fd = dup(fd_ext);
|
data->fd = mpp_dup(fd_ext);
|
||||||
data->ptr = NULL;
|
data->ptr = NULL;
|
||||||
|
|
||||||
dma_heap_dbg_ops("dev %d import %3d -> %3d\n", p->device, fd_ext, data->fd);
|
dma_heap_dbg_ops("dev %d import %3d -> %3d\n", p->device, fd_ext, data->fd);
|
||||||
|
@@ -19,7 +19,6 @@
|
|||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <fcntl.h>
|
|
||||||
#include <sys/ioctl.h>
|
#include <sys/ioctl.h>
|
||||||
#include <sys/mman.h>
|
#include <sys/mman.h>
|
||||||
|
|
||||||
@@ -254,7 +253,7 @@ static MPP_RET os_allocator_drm_import(void *ctx, MppBufferInfo *data)
|
|||||||
|
|
||||||
mpp_assert(fd_ext > 0);
|
mpp_assert(fd_ext > 0);
|
||||||
|
|
||||||
data->fd = dup(fd_ext);
|
data->fd = mpp_dup(fd_ext);
|
||||||
data->ptr = NULL;
|
data->ptr = NULL;
|
||||||
|
|
||||||
if (data->fd <= 0) {
|
if (data->fd <= 0) {
|
||||||
|
@@ -19,7 +19,6 @@
|
|||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <fcntl.h>
|
|
||||||
#include <sys/ioctl.h>
|
#include <sys/ioctl.h>
|
||||||
#include <sys/mman.h>
|
#include <sys/mman.h>
|
||||||
|
|
||||||
|
@@ -135,6 +135,7 @@
|
|||||||
#include <direct.h>
|
#include <direct.h>
|
||||||
#include <io.h>
|
#include <io.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
|
|
||||||
#define chdir _chdir
|
#define chdir _chdir
|
||||||
#define mkdir _mkdir
|
#define mkdir _mkdir
|
||||||
#define access _access
|
#define access _access
|
||||||
@@ -150,6 +151,7 @@
|
|||||||
#else
|
#else
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
|
#include <fcntl.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#define mkdir(x) mkdir(x, S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH)
|
#define mkdir(x) mkdir(x, S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH)
|
||||||
@@ -210,6 +212,12 @@ static __inline RK_U32 mpp_is_32bit()
|
|||||||
return ((sizeof(void *) == 4) ? (1) : (0));
|
return ((sizeof(void *) == 4) ? (1) : (0));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static __inline RK_S32 mpp_dup(RK_S32 fd)
|
||||||
|
{
|
||||||
|
/* avoid stdin / stdout / stderr so start from 3 */
|
||||||
|
return fcntl(fd, F_DUPFD_CLOEXEC, 3);
|
||||||
|
}
|
||||||
|
|
||||||
RK_S32 axb_div_c(RK_S32 a, RK_S32 b, RK_S32 c);
|
RK_S32 axb_div_c(RK_S32 a, RK_S32 b, RK_S32 c);
|
||||||
RK_U32 mpp_align_16(RK_U32 val);
|
RK_U32 mpp_align_16(RK_U32 val);
|
||||||
RK_U32 mpp_align_64(RK_U32 val);
|
RK_U32 mpp_align_64(RK_U32 val);
|
||||||
|
@@ -125,7 +125,7 @@ CamSource *camera_source_init(const char *device, RK_U32 bufcnt, RK_U32 width, R
|
|||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
ctx->bufcnt = bufcnt;
|
ctx->bufcnt = bufcnt;
|
||||||
ctx->fd = open(device, O_RDWR, 0);
|
ctx->fd = open(device, O_RDWR | O_CLOEXEC, 0);
|
||||||
if (ctx->fd < 0) {
|
if (ctx->fd < 0) {
|
||||||
mpp_err_f("Cannot open device\n");
|
mpp_err_f("Cannot open device\n");
|
||||||
goto FAIL;
|
goto FAIL;
|
||||||
|
Reference in New Issue
Block a user