mirror of
https://github.com/nyanmisaka/mpp.git
synced 2025-10-10 03:20:04 +08:00
[osal]: Use access to replace file open
When doing ion / drm detection use access is a better idea. For open will introduce some unnecessary kernel operation. And access is more flexible to use library on different stage of boot up. Change-Id: Ib6e98d26cb59dd1c8b0899cfa43911fc25097bd4 Signed-off-by: Herman Chen <herman.chen@rock-chips.com>
This commit is contained in:
@@ -76,27 +76,22 @@ RK_U32 MppRuntimeService::get_allocator_valid(MppBufferType type)
|
||||
|
||||
MppRuntimeService::MppRuntimeService()
|
||||
{
|
||||
int fd = -1;
|
||||
allocator_valid[MPP_BUFFER_TYPE_NORMAL] = 1;
|
||||
|
||||
fd = open("/dev/ion", O_RDWR);
|
||||
if (fd < 0) {
|
||||
if (access("/dev/ion", F_OK | R_OK | W_OK)) {
|
||||
allocator_valid[MPP_BUFFER_TYPE_ION] = 0;
|
||||
mpp_log("NOT found ion allocator\n");
|
||||
} else {
|
||||
allocator_valid[MPP_BUFFER_TYPE_ION] = 1;
|
||||
mpp_log("found ion allocator\n");
|
||||
close(fd);
|
||||
}
|
||||
|
||||
fd = open("/dev/dri/card0", O_RDWR);
|
||||
if (fd < 0) {
|
||||
if (access("/dev/dri/card0", F_OK | R_OK | W_OK)) {
|
||||
allocator_valid[MPP_BUFFER_TYPE_DRM] = 0;
|
||||
mpp_log("NOT found drm allocator\n");
|
||||
} else {
|
||||
allocator_valid[MPP_BUFFER_TYPE_DRM] = 1;
|
||||
mpp_log("found drm allocator\n");
|
||||
close(fd);
|
||||
}
|
||||
|
||||
// If both ion and drm is enabled detect allocator in dts to choose one
|
||||
|
Reference in New Issue
Block a user