[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:
Herman Chen
2018-05-28 16:53:16 +08:00
parent 50eac8ef38
commit 91189232df

View File

@@ -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