blob: eb2c9ee6f721a9e55304a083c89188fb4bad0223 [file] [log] [blame]
Sam Protsenkoce268502023-09-08 19:45:36 -05001/*
2 * Copyright (C) 2020 Samsung Electronics Co. Ltd.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#include "ExynosGraphicBuffer.h"
18
19#if defined(NO_ION_HELPER)
20
21int vendor::graphics::ion::get_ion_fd() {
22 return -1;
23}
24
25#else /* NO_ION_HELPER */
26
27#include <hardware/exynos/ion.h>
28#include <log/log.h>
29
30static int ion_client;
31
32int vendor::graphics::ion::get_ion_fd() {
33 if (ion_client <= 0) {
34 ion_client = exynos_ion_open();
35
36 if (ion_client < 0) {
37 int ret = errno;
38 ALOGE("failed to get ion client %s", strerror(ret));
39 return -ret;
40 }
41 }
42
43 return ion_client;
44}
45
46#endif /* NO_ION_HELPER */