1 /*
2 * Copyright 2020 Rockchip 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 "iep_common.h"
18
19 #include "mpp_common.h"
20 #include "mpp_log.h"
21
22 #include "iep_api.h"
23 #include "iep2_api.h"
24
25 struct dev_compatible dev_comp[] = {
26 {
27 .compatible = "/dev/iep",
28 .get = rockchip_iep_api_alloc_ctx,
29 .put = rockchip_iep_api_release_ctx,
30 .ver = 1,
31 },
32 {
33 .compatible = "/dev/mpp_service",
34 .get = rockchip_iep2_api_alloc_ctx,
35 .put = rockchip_iep2_api_release_ctx,
36 .ver = 2,
37 },
38 };
39
get_iep_ctx()40 iep_com_ctx* get_iep_ctx()
41 {
42 uint32_t i;
43
44 for (i = 0; i < MPP_ARRAY_ELEMS(dev_comp); ++i) {
45 if (!access(dev_comp[i].compatible, F_OK)) {
46 iep_com_ctx *ctx = dev_comp[i].get();
47
48 ctx->ver = dev_comp[i].ver;
49 mpp_log("device %s select in vproc\n", dev_comp[i].compatible);
50
51 ctx->ops->release = dev_comp[i].put;
52
53 return ctx;
54 }
55 }
56
57 return NULL;
58 }
59
put_iep_ctx(iep_com_ctx * ictx)60 void put_iep_ctx(iep_com_ctx *ictx)
61 {
62 if (ictx->ops->release)
63 ictx->ops->release(ictx);
64 }
65
66