xref: /OK3568_Linux_fs/external/camera_engine_rkaiq/rkaiq/rkaiq.go (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1package rkaiqdefaults
2
3import (
4	"android/soong/android"
5	"android/soong/cc"
6    "fmt"   // required if we want to print usefull messages on the console
7    "os"
8)
9
10func rkaiqFlags(ctx android.BaseContext) []string {
11    var cflags []string
12    //fmt.Fprintf(os.Stderr, "%s\n", "deviceFlags called") //example prints
13    //fmt.Fprintf(os.Stderr, "%s\n", ctx.AConfig())
14    board := ctx.Config().Getenv("TARGET_BOARD_PLATFORM") //currently using this for reference but you can refer to README for other variables.
15    fmt.Fprintf(os.Stderr, ">>>>>>>>>>>>>>>>>>>>> %s\n", board)
16    if board == "rv1126" {
17       cflags = append(cflags, "-DISP_HW_V20")
18    }
19    if board == "rk356x" {
20       cflags = append(cflags, "-DISP_HW_V21")
21    }
22    if board == "rk3588" {
23       cflags = append(cflags, "-DISP_HW_V30")
24    }
25    if board == "rv1106" {
26        cflags = append(cflags, "-DISP_HW_V32")
27    }
28    if board == "rk3562" {
29        cflags = append(cflags, "-DISP_HW_V32_LITE")
30    }
31    return cflags
32}
33
34func rkaiq_get_aiq_version(ctx android.BaseContext) string {
35    board := ctx.Config().Getenv("TARGET_BOARD_PLATFORM")
36    // fmt.Fprintf(os.Stderr, ">>>>>>>>>>>>>>>>>>>>> %s\n", board)
37    return board;
38}
39
40func rkaiqDefaults(ctx android.LoadHookContext) {
41    type props struct {
42        Target struct {
43            Android struct {
44                Cflags  []string
45                Enabled *bool
46            }
47            Host struct {
48                Enabled *bool
49            }
50            Not_windows struct {
51                Cflags []string
52            }
53        }
54        Cflags []string
55    }
56    p := &props{}
57
58    //p.Cflags = deviceFlags(ctx)
59
60    soc := rkaiq_get_aiq_version(ctx)
61    macros_map := rkaiq_macro_switch(soc)
62    p.Target.Android.Cflags = rkaiq_getAlgosMacros(macros_map)
63    cflags := rkaiqFlags(ctx)
64    p.Target.Android.Cflags = append(p.Target.Android.Cflags, cflags...)
65    ctx.AppendProperties(p)
66}
67
68func rkaiqLibraryShared(ctx android.LoadHookContext) {
69    type props struct {
70        Target struct {
71            Android struct {
72                Srcs  []string
73                Static_libs []string
74                Enabled *bool
75            }
76            Host struct {
77                Enabled *bool
78            }
79            Not_windows struct {
80            }
81        }
82        Srcs []string
83    }
84    p := &props{}
85    soc := rkaiq_get_aiq_version(ctx)
86    macros_map := rkaiq_macro_switch(soc)
87    p.Target.Android.Srcs = rkaiq_getSrcsFiles(soc, macros_map)
88    p.Target.Android.Static_libs = rkaiq_getAlgosLib(macros_map)
89    ctx.AppendProperties(p)
90}
91
92func rkaiqLibraryStatic(ctx android.LoadHookContext) {
93    type props struct {
94        Srcs []string
95    }
96    p := &props{}
97    soc := rkaiq_get_aiq_version(ctx)
98    macros_map := rkaiq_macro_switch(soc)
99    p.Srcs = rkaiq_getStaticLibSrcs(ctx.ModuleName(), macros_map)
100    ctx.AppendProperties(p)
101}
102
103/* This is called from the boot strap process
104 * We register a module here
105*/
106func init() {
107    android.RegisterModuleType("rkaiq_defaults", rkaiqDefaultFactory)
108    android.RegisterModuleType("cc_rkaiq_library_shared", cc_rkaiq_library_sharedFactory)
109    android.RegisterModuleType("cc_rkaiq_library_static", cc_rkaiq_library_staticFactory)
110}
111
112func rkaiqDefaultFactory() android.Module {
113    module := cc.DefaultsFactory()
114    android.AddLoadHook(module, rkaiqDefaults)
115    return module
116}
117
118func cc_rkaiq_library_sharedFactory() android.Module {
119    module := cc.LibrarySharedFactory()
120    android.AddLoadHook(module, rkaiqLibraryShared)
121    return module
122}
123
124func cc_rkaiq_library_staticFactory() android.Module {
125    module := cc.LibraryStaticFactory()
126    android.AddLoadHook(module, rkaiqLibraryStatic)
127    return module
128}
129