xref: /rockchip-linux_mpp/mpp/vproc/mpp_vproc_dev.c (revision 437bfbeb9567cca9cd9080e3f6954aa9d6a94f18)
1 /* SPDX-License-Identifier: Apache-2.0 OR MIT */
2 /*
3  * Copyright (c) 2020 Rockchip Electronics Co., Ltd.
4  */
5 
6 #include "iep_common.h"
7 
8 #include "mpp_common.h"
9 #include "mpp_log.h"
10 
11 #include "iep_api.h"
12 #include "iep2_api.h"
13 
14 struct dev_compatible dev_comp[] = {
15     {
16         .compatible = "/dev/iep",
17         .get = rockchip_iep_api_alloc_ctx,
18         .put = rockchip_iep_api_release_ctx,
19         .ver = 1,
20     },
21     {
22         .compatible = "/dev/mpp_service",
23         .get = rockchip_iep2_api_alloc_ctx,
24         .put = rockchip_iep2_api_release_ctx,
25         .ver = 2,
26     },
27 };
28 
get_iep_ctx()29 iep_com_ctx* get_iep_ctx()
30 {
31     uint32_t i;
32 
33     for (i = 0; i < MPP_ARRAY_ELEMS(dev_comp); ++i) {
34         if (!access(dev_comp[i].compatible, F_OK)) {
35             iep_com_ctx *ctx = dev_comp[i].get();
36 
37             ctx->ver = dev_comp[i].ver;
38             mpp_log("device %s select in vproc\n", dev_comp[i].compatible);
39 
40             ctx->ops->release = dev_comp[i].put;
41 
42             return ctx;
43         }
44     }
45 
46     return NULL;
47 }
48 
put_iep_ctx(iep_com_ctx * ictx)49 void put_iep_ctx(iep_com_ctx *ictx)
50 {
51     if (ictx->ops->release)
52         ictx->ops->release(ictx);
53 }
54 
55