Files
mpp/osal/linux/os_allocator.c
Randy Li c56a9365f6 [ion]: file descriptor for the external buffer
The imported buffer may be released from its origin allocator,
I would suggest to use the new file descriptor from new ion
handle.

The ion only has map_user() to export buffer to userspace,
There is no unmap_user() because the mapping is represented as
a file descriptor in user space. The closing of that file
descriptor will cause the memory to be unmapped from
the calling process.

Change-Id: Ief855aab11793238b40b73da92af853ca3b58349
Signed-off-by: Randy Li <randy.li@rock-chips.com>
Signed-off-by: ayaka <ayaka@soulik.info>
2017-11-02 17:55:23 +08:00

68 lines
1.6 KiB
C

/*
* Copyright 2015 Rockchip Electronics Co. LTD
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#if defined(__gnu_linux__)
#include "mpp_log.h"
#include "allocator_std.h"
#include "allocator_ion.h"
#ifdef HAVE_DRM
#include "allocator_drm.h"
#endif
/*
* Linux only support MPP_BUFFER_TYPE_NORMAL so far
* we can support MPP_BUFFER_TYPE_V4L2 later
*/
MPP_RET os_allocator_get(os_allocator *api, MppBufferType type)
{
MPP_RET ret = MPP_OK;
switch (type) {
case MPP_BUFFER_TYPE_NORMAL : {
*api = allocator_std;
} break;
case MPP_BUFFER_TYPE_ION : {
#ifdef RKPLATFORM
#ifdef HAVE_DRM
*api = allocator_drm;
#else
*api = allocator_ion;
#endif
#else
*api = allocator_std;
#endif
} break;
case MPP_BUFFER_TYPE_V4L2 : {
mpp_err("os_allocator_get Linux MPP_BUFFER_TYPE_V4L2 do not implement yet\n");
*api = allocator_std;
} break;
case MPP_BUFFER_TYPE_DRM : {
#ifdef HAVE_DRM
*api = allocator_drm;
#else
*api = allocator_std;
#endif
} break;
default : {
ret = MPP_NOK;
} break;
}
return ret;
}
#endif