• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/bin/sh
2# Copyright (C) 2021 Hisilicon (Shanghai) Technologies Co., Ltd. All rights reserved.
3
4# Usage: ./load3516dv300 [ -r|-i|-a ] [ sensor0~1 ]
5#         -r : rmmod all modules
6#         -i : insmod all modules
7#         -a : rmmod all modules and then insmod them
8# e.g: RAW:        ./load3516dv300 -i -sensor0 imx335 -sensor1 imx335
9# e.g: BT1120/DC : ./load3516dv300 -i -sensor0 imx327 -sensor1 imx327 -osmem 128 -yuv0 1
10# e.g: BT656     : ./load3516dv300 -i -sensor0 imx327 -sensor1 imx327 -osmem 128 -yuv0 2
11
12####################Variables Definition##########################
13
14SNS_TYPE0=imx335;           # sensor type
15SNS_TYPE1=NULL;            	# sensor type
16YUV_TYPE0=0;                # 0 -- raw, 1 -- bt1120/DC, 2 --bt656
17CHIP_TYPE=hi3516dv300;      # chip type
18#DDR start:0x80000000,   kernel start:0x80000000,  OS(128M); MMZ start:0x88000000
19mem_total=512                # 512M, total mem
20mem_start=0x80000000          # phy mem start
21os_mem_size=128               # 128M, os mem
22mmz_start=0x88000000;         # mmz start addr
23mmz_size=384M;               # 384M, mmz size
24##################################################################
25
26report_error()
27{
28    echo "******* Error: There's something wrong, please check! *****"
29    exit 1
30}
31
32insert_isp()
33{
34    insmod hi3516cv500_isp.ko
35}
36
37
38insert_ko()
39{
40    # driver load
41    #insmod hi_osal.ko anony=1 mmz_allocator=hisi mmz=anonymous,0,$mmz_start,$mmz_size || report_error
42    insmod hi_osal.ko anony=1 mmz_allocator=hisi mmz=anonymous,0,0xA8000000,384M
43    insmod hi_irq.ko
44    insmod hi_proc.ko
45
46    # sys config
47    insmod sys_config.ko chip=$CHIP_TYPE sensors=sns0=$SNS_TYPE0,sns1=$SNS_TYPE1, g_cmos_yuv_flag=$YUV_TYPE0
48    insmod hi3516cv500_base.ko
49    insmod hi3516cv500_sys.ko
50    insmod hi3516cv500_tde.ko
51    insmod hi3516cv500_vo_dev.ko
52    insmod hifb.ko video="hifb:vram0_size:16200"     # default fb0:1080p
53    insmod hi3516cv500_hdmi.ko
54
55    insmod hi_mipi_rx.ko
56}
57
58remove_ko()
59{
60    rmmod hi_mipi_rx
61    rmmod hifb
62    rmmod hi3516cv500_vo_dev.ko
63    rmmod hi3516cv500_tde
64    rmmod hi3516cv500_hdmi
65    rmmod hi3516cv500_sys
66    rmmod hi3516cv500_base
67    rmmod sys_config
68
69    rmmod hi_irq.ko
70    rmmod hi_proc.ko
71    rmmod hi_osal
72    rmmod hi_securec.ko
73}
74
75sys_restore()
76{
77    ####################################################
78    clkcfg_hi3516cv500.sh > /dev/null
79
80    # system configuration
81    sysctl_hi3516cv500.sh  # > /dev/null
82    sns_config;
83}
84
85load_usage()
86{
87    echo "Usage:  ./load3516dv300 [-option] [sensor0~1]"
88    echo "options:"
89    echo "    -i                       insert modules"
90    echo "    -r                       remove modules"
91    echo "    -a                       remove modules first, then insert modules"
92    echo "    -sensor sensor_name      config sensor type [default: imx335]"
93    echo "    -total mem_size          config total mem size [unit: M, default: 512]"
94    echo "    -osmem os_mem_size       config os mem size [unit: M, default: 128]"
95    echo "    -h                       help information"
96    echo -e "Available sensors: imx327 imx335 os05a imx307"
97    echo -e "for example: ./load3516dv300 -i -sensor0 imx335 -sensor1 imx335\n"
98}
99
100calc_mmz_info()
101{
102    mmz_start=`echo "$mem_start $os_mem_size"  |
103    awk 'BEGIN { temp = 0; }
104    {
105        temp = $1/1024/1024 + $2;
106    }
107    END { printf("0x%x00000\n", temp); }'`
108
109    mmz_size=`echo "$mem_total $os_mem_size"  |
110    awk 'BEGIN { temp = 0; }
111    {
112        temp = $1 - $2;
113    }
114    END { printf("%dM\n", temp); }'`
115    echo "mmz_start: $mmz_start, mmz_size: $mmz_size"
116}
117
118######################parse arg###################################
119b_arg_sensor0=0
120b_arg_sensor1=0
121b_arg_yuv_type0=0
122b_arg_insmod=0
123b_arg_remove=0
124b_arg_restore=0
125b_arg_total_mem=0
126b_arg_os_mem=0
127
128for arg in $@
129do
130    if [ $b_arg_sensor0 -eq 1 ] ; then
131        b_arg_sensor0=0;
132        SNS_TYPE0=$arg;
133    fi
134    if [ $b_arg_sensor1 -eq 1 ] ; then
135        b_arg_sensor1=0;
136        SNS_TYPE1=$arg;
137    fi
138    if [ $b_arg_total_mem -eq 1 ]; then
139        b_arg_total_mem=0;
140        mem_total=$arg;
141
142        if [ -z $mem_total ]; then
143            echo "[error] mem_total is null"
144            exit;
145        fi
146    fi
147
148    if [ $b_arg_os_mem -eq 1 ] ; then
149        b_arg_os_mem=0;
150        os_mem_size=$arg;
151
152        if [ -z $os_mem_size ]; then
153            echo "[error] os_mem_size is null"
154            exit;
155        fi
156    fi
157
158    if [ $b_arg_yuv_type0 -eq 1 ] ; then
159        b_arg_yuv_type0=0;
160        YUV_TYPE0=$arg;
161    fi
162
163    case $arg in
164        "-i")
165            b_arg_insmod=1;
166            ;;
167        "-r")
168            b_arg_remove=1;
169            ;;
170        "-a")
171            b_arg_insmod=1;
172            b_arg_remove=1;
173            ;;
174        "-h")
175            load_usage;
176            ;;
177        "-sensor0")
178            b_arg_sensor0=1;
179            ;;
180        "-sensor")
181            b_arg_sensor0=1;
182            ;;
183        "-sensor1")
184            b_arg_sensor1=1;
185            ;;
186        "-osmem")
187            b_arg_os_mem=1;
188            ;;
189        "-yuv0")
190            b_arg_yuv_type0=1;
191            ;;
192        "-total")
193            b_arg_total_mem=1;
194            ;;
195        "-restore")
196            b_arg_restore=1;
197            ;;
198    esac
199done
200#######################parse arg end########################
201if [ $os_mem_size -ge $mem_total ] ; then
202    echo "[err] os_mem[$os_mem_size], over total_mem[$mem_total]"
203    exit;
204fi
205
206calc_mmz_info;
207
208#######################Action###############################
209
210if [ $# -lt 1 ]; then
211    load_usage;
212    exit 0;
213fi
214
215
216if [ $b_arg_remove -eq 1 ]; then
217    remove_ko;
218fi
219
220if [ $b_arg_insmod -eq 1 ]; then
221    insert_ko;
222fi
223
224if [ $b_arg_restore -eq 1 ]; then
225    sys_restore;
226fi
227
228