Merge branch android-common-3.10
[firefly-linux-kernel-4.4.55.git] / drivers / media / video / rk_camsys / camsys_soc_priv.c
1
2 #include "camsys_soc_priv.h"
3
4
5 static camsys_soc_priv_t* camsys_soc_p;
6
7 extern int camsys_rk3288_cfg (camsys_soc_cfg_t cfg_cmd, void* cfg_para);
8 extern int camsys_rk3368_cfg (camsys_soc_cfg_t cfg_cmd, void* cfg_para);
9
10 camsys_soc_priv_t* camsys_soc_get(void)
11 {
12     if (camsys_soc_p != NULL) {
13         return camsys_soc_p;
14     } else {
15         return NULL;
16     }
17 }
18
19 int camsys_soc_init(void)
20 {    
21     camsys_soc_p = kzalloc(sizeof(camsys_soc_priv_t),GFP_KERNEL);
22     if (camsys_soc_p == NULL) {
23         camsys_err("malloc camsys_soc_priv_t failed!");
24         goto fail;
25     }
26
27 #ifdef CONFIG_ARM64
28         strlcpy(camsys_soc_p->name,"camsys_rk3368",31);
29         camsys_soc_p->soc_cfg = camsys_rk3368_cfg;
30         camsys_err("camsys_soc_init exit!");
31 #else
32         if (soc_is_rk3288()) {
33                 strlcpy(camsys_soc_p->name,"camsys_rk3288",31);
34         camsys_soc_p->soc_cfg = camsys_rk3288_cfg;      
35         } else {
36                 camsys_err("camsys isn't support soc: 0x%lx!",rockchip_soc_id);
37                 goto fail;
38         }
39 #endif
40
41     return 0;
42 fail:
43     if (camsys_soc_p != NULL) {
44         kfree(camsys_soc_p);
45         camsys_soc_p = NULL;
46     }
47     return -1;
48 }
49
50 int camsys_soc_deinit(void)
51 {
52     if (camsys_soc_p != NULL) {
53         kfree(camsys_soc_p);
54         camsys_soc_p = NULL;
55     }
56     return 0;
57 }