mirror of
https://github.com/nyanmisaka/mpp.git
synced 2025-10-06 01:26:49 +08:00
fix[drm]: Fix permission check issue on GKI kernel
The GKI kernel does not allow non-render thread to open /dev/dri/card0 and alloc drm buffer from it. So we need to use /dev/dri/renderD128 instead. Signed-off-by: Herman Chen <herman.chen@rock-chips.com> Change-Id: I0fad306c6eeadd8da5507883f4f4915c11946761
This commit is contained in:
@@ -69,7 +69,11 @@ typedef struct {
|
|||||||
RK_U32 flags;
|
RK_U32 flags;
|
||||||
} allocator_ctx_drm;
|
} allocator_ctx_drm;
|
||||||
|
|
||||||
static const char *dev_drm = "/dev/dri/card0";
|
/* use renderD128 first to avoid GKI kernel permission issue */
|
||||||
|
static const char *dev_drm[] = {
|
||||||
|
"/dev/dri/renderD128",
|
||||||
|
"/dev/dri/card0",
|
||||||
|
};
|
||||||
|
|
||||||
static RK_U32 to_rockchip_gem_mem_flag(RK_U32 flags)
|
static RK_U32 to_rockchip_gem_mem_flag(RK_U32 flags)
|
||||||
{
|
{
|
||||||
@@ -164,8 +168,9 @@ static int drm_free(int fd, RK_U32 handle)
|
|||||||
|
|
||||||
static MPP_RET os_allocator_drm_open(void **ctx, size_t alignment, MppAllocFlagType flags)
|
static MPP_RET os_allocator_drm_open(void **ctx, size_t alignment, MppAllocFlagType flags)
|
||||||
{
|
{
|
||||||
RK_S32 fd;
|
|
||||||
allocator_ctx_drm *p;
|
allocator_ctx_drm *p;
|
||||||
|
RK_S32 fd;
|
||||||
|
RK_S32 i;
|
||||||
|
|
||||||
if (NULL == ctx) {
|
if (NULL == ctx) {
|
||||||
mpp_err_f("does not accept NULL input\n");
|
mpp_err_f("does not accept NULL input\n");
|
||||||
@@ -176,9 +181,17 @@ static MPP_RET os_allocator_drm_open(void **ctx, size_t alignment, MppAllocFlagT
|
|||||||
|
|
||||||
mpp_env_get_u32("drm_debug", &drm_debug, 0);
|
mpp_env_get_u32("drm_debug", &drm_debug, 0);
|
||||||
|
|
||||||
fd = open(dev_drm, O_RDWR | O_CLOEXEC);
|
for (i = 0; i < (RK_S32)MPP_ARRAY_ELEMS(dev_drm); i++) {
|
||||||
|
fd = open(dev_drm[i], O_RDWR | O_CLOEXEC);
|
||||||
|
if (fd > 0)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
if (fd < 0) {
|
if (fd < 0) {
|
||||||
mpp_err_f("open %s failed!\n", dev_drm);
|
mpp_err_f("open all drm device failed.\n");
|
||||||
|
mpp_err("Please check the following device path and access permission:\n");
|
||||||
|
for (i = 0; i < (RK_S32)MPP_ARRAY_ELEMS(dev_drm); i++)
|
||||||
|
mpp_err("%s\n", dev_drm[i]);
|
||||||
return MPP_ERR_UNKNOW;
|
return MPP_ERR_UNKNOW;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -85,7 +85,9 @@ MppRuntimeService::MppRuntimeService()
|
|||||||
|
|
||||||
allocator_valid[MPP_BUFFER_TYPE_NORMAL] = 1;
|
allocator_valid[MPP_BUFFER_TYPE_NORMAL] = 1;
|
||||||
allocator_valid[MPP_BUFFER_TYPE_ION] = !access("/dev/ion", F_OK | R_OK | W_OK);
|
allocator_valid[MPP_BUFFER_TYPE_ION] = !access("/dev/ion", F_OK | R_OK | W_OK);
|
||||||
allocator_valid[MPP_BUFFER_TYPE_DRM] = !access("/dev/dri/card0", F_OK | R_OK | W_OK);
|
allocator_valid[MPP_BUFFER_TYPE_DRM] =
|
||||||
|
!access("/dev/dri/renderD128", F_OK | R_OK | W_OK) ||
|
||||||
|
!access("/dev/dri/card0", F_OK | R_OK | W_OK);
|
||||||
allocator_valid[MPP_BUFFER_TYPE_DMA_HEAP] = !access("/dev/dma_heap", F_OK | R_OK);
|
allocator_valid[MPP_BUFFER_TYPE_DMA_HEAP] = !access("/dev/dma_heap", F_OK | R_OK);
|
||||||
|
|
||||||
if (!allocator_valid[MPP_BUFFER_TYPE_ION] &&
|
if (!allocator_valid[MPP_BUFFER_TYPE_ION] &&
|
||||||
|
Reference in New Issue
Block a user