[ci skip] Reformat load_hisilicon

pull/408/head
Dmitry Ilyin 2022-08-29 12:41:43 +03:00
parent a56504b28b
commit cdb730b524
1 changed files with 97 additions and 113 deletions

View File

@ -4,7 +4,7 @@
# #
# Board # Board
board=demo; board=demo
# SoC detect # SoC detect
chipid=$(ipcinfo --chip-name) chipid=$(ipcinfo --chip-name)
@ -18,7 +18,7 @@ mem_total=${mem_total:=64}
os_mem_size=$(fw_printenv -n osmem | tr -d 'M') os_mem_size=$(fw_printenv -n osmem | tr -d 'M')
os_mem_size=${os_mem_size:=32} os_mem_size=${os_mem_size:=32}
YUV_TYPE0=0; # 0 -- raw, 1 --DC, 2 --bt1120, 3 --bt656 YUV_TYPE0=0 # 0 -- raw, 1 --DC, 2 --bt1120, 3 --bt656
################################################################## ##################################################################
# #
@ -64,8 +64,7 @@ YUV_TYPE0=0; # 0 -- raw, 1 --DC, 2 --bt1120, 3 --bt656
# #
################################################################## ##################################################################
report_error() report_error() {
{
echo "******* Error: There's something wrong, please check! *****" echo "******* Error: There's something wrong, please check! *****"
exit 1 exit 1
} }
@ -81,8 +80,7 @@ check_allocator() {
fi fi
} }
insert_osal() insert_osal() {
{
check_allocator check_allocator
MMZ=$(awk -F '=' '$1=="mmz"{print $2}' RS=" " /proc/cmdline) MMZ=$(awk -F '=' '$1=="mmz"{print $2}' RS=" " /proc/cmdline)
@ -93,8 +91,7 @@ insert_osal()
fi fi
} }
insert_detect() insert_detect() {
{
cd /lib/modules/$(uname -r)/hisilicon cd /lib/modules/$(uname -r)/hisilicon
modprobe open_sys_config chip=${chipid} sensors=unknown g_cmos_yuv_flag=$YUV_TYPE0 board=${board} modprobe open_sys_config chip=${chipid} sensors=unknown g_cmos_yuv_flag=$YUV_TYPE0 board=${board}
insert_osal insert_osal
@ -104,8 +101,7 @@ insert_detect()
modprobe open_sensor_spi modprobe open_sensor_spi
} }
remove_detect() remove_detect() {
{
rmmod -w open_sensor_spi rmmod -w open_sensor_spi
rmmod -w open_sensor_i2c rmmod -w open_sensor_i2c
rmmod -w hi3516ev200_isp rmmod -w hi3516ev200_isp
@ -114,8 +110,7 @@ remove_detect()
rmmod -w open_sys_config rmmod -w open_sys_config
} }
insert_audio() insert_audio() {
{
modprobe open_aio modprobe open_aio
modprobe open_ai modprobe open_ai
modprobe open_ao modprobe open_ao
@ -126,8 +121,7 @@ insert_audio()
echo "insert audio" echo "insert audio"
} }
remove_audio() remove_audio() {
{
rmmod -w open_acodec rmmod -w open_acodec
# rmmod -w hi_tlv320aic31 # rmmod -w hi_tlv320aic31
rmmod -w open_adec rmmod -w open_adec
@ -139,13 +133,11 @@ remove_audio()
echo "remove audio" echo "remove audio"
} }
insert_isp() insert_isp() {
{
modprobe hi3516ev200_isp modprobe hi3516ev200_isp
} }
insert_sil9024() insert_sil9024() {
{
i2c_sel=2 i2c_sel=2
if [ "${chipid}" == "hi3516ev300" ]; then if [ "${chipid}" == "hi3516ev300" ]; then
i2c_sel=1 i2c_sel=1
@ -156,8 +148,7 @@ insert_sil9024()
fi fi
} }
insert_adv7179() insert_adv7179() {
{
i2c_sel=2 i2c_sel=2
if [ "${chipid}" == "hi3516ev300" ]; then if [ "${chipid}" == "hi3516ev300" ]; then
i2c_sel=1 i2c_sel=1
@ -168,16 +159,14 @@ insert_adv7179()
fi fi
} }
insert_piris() insert_piris() {
{
if [ "{chipid}" == "hi3516ev300" -a "${board}" == "demo" ]; then if [ "{chipid}" == "hi3516ev300" -a "${board}" == "demo" ]; then
modprobe open_piris modprobe open_piris
# modprobe open_pm # Maybe need for Hi3518Ev300 # modprobe open_pm # Maybe need for Hi3518Ev300
fi fi
} }
insert_ko() insert_ko() {
{
modprobe open_sys_config chip=${chipid} sensors=$SENSOR g_cmos_yuv_flag=$YUV_TYPE0 board=${board} modprobe open_sys_config chip=${chipid} sensors=$SENSOR g_cmos_yuv_flag=$YUV_TYPE0 board=${board}
insert_osal insert_osal
modprobe open_base modprobe open_base
@ -186,7 +175,7 @@ insert_ko()
modprobe open_rgn modprobe open_rgn
modprobe open_vgs modprobe open_vgs
modprobe open_vi modprobe open_vi
insert_isp; insert_isp
modprobe open_vpss modprobe open_vpss
# modprobe open_vo # disabled, info by @widgetii # modprobe open_vo # disabled, info by @widgetii
# insmod hifb video="hifb:vram0_size:1620" # default fb0:D1 # disabled, info by @widgetii # insmod hifb video="hifb:vram0_size:1620" # default fb0:D1 # disabled, info by @widgetii
@ -202,7 +191,7 @@ insert_ko()
modprobe open_sensor_i2c modprobe open_sensor_i2c
modprobe open_sensor_spi modprobe open_sensor_spi
insert_piris insert_piris
insert_sil9024; # BT1120 insert_sil9024 # BT1120
# insert_adv7179; # BT656 # insert_adv7179; # BT656
insert_audio insert_audio
modprobe open_mipi_rx modprobe open_mipi_rx
@ -210,8 +199,7 @@ insert_ko()
modprobe open_wdt modprobe open_wdt
} }
remove_ko() remove_ko() {
{
rmmod -w open_wdt rmmod -w open_wdt
# rmmod -w hi_user # rmmod -w hi_user
remove_audio remove_audio
@ -244,9 +232,7 @@ remove_ko()
rmmod -w open_sys_config rmmod -w open_sys_config
} }
load_usage() {
load_usage()
{
echo "Usage: ./load_hisilicon [-option] [sensor_name]" echo "Usage: ./load_hisilicon [-option] [sensor_name]"
echo "options:" echo "options:"
echo " -i insert modules" echo " -i insert modules"
@ -258,21 +244,20 @@ load_usage()
echo -e "for example: ./load_hisilicon -i -sensor imx307 -osmem 32M -board demo -yuv0 0\n" echo -e "for example: ./load_hisilicon -i -sensor imx307 -osmem 32M -board demo -yuv0 0\n"
} }
calc_mmz_info() calc_mmz_info() {
{ mmz_start=$(echo "$mem_start $os_mem_size" |
mmz_start=`echo "$mem_start $os_mem_size" |
awk 'BEGIN { temp = 0; } awk 'BEGIN { temp = 0; }
{ {
temp = $1/1024/1024 + $2; temp = $1/1024/1024 + $2;
} }
END { printf("0x%x00000\n", temp); }'` END { printf("0x%x00000\n", temp); }')
mmz_size=`echo "$mem_total $os_mem_size" | mmz_size=$(echo "$mem_total $os_mem_size" |
awk 'BEGIN { temp = 0; } awk 'BEGIN { temp = 0; }
{ {
temp = $1 - $2; temp = $1 - $2;
} }
END { printf("%dM\n", temp); }'` END { printf("%dM\n", temp); }')
echo "mmz_start: $mmz_start, mmz_size: $mmz_size" echo "mmz_start: $mmz_start, mmz_size: $mmz_size"
} }
@ -285,78 +270,77 @@ b_arg_remove=0
b_arg_os_mem=0 b_arg_os_mem=0
b_arg_board=0 b_arg_board=0
for arg in $@ for arg in $@; do
do
if [ $b_arg_sensor0 -eq 1 ]; then if [ $b_arg_sensor0 -eq 1 ]; then
b_arg_sensor0=0; b_arg_sensor0=0
SENSOR_MANUAL=$arg; SENSOR_MANUAL=$arg
export SENSOR=${SENSOR_MANUAL} export SENSOR=${SENSOR_MANUAL}
fi fi
if [ $b_arg_os_mem -eq 1 ]; then if [ $b_arg_os_mem -eq 1 ]; then
b_arg_os_mem=0; b_arg_os_mem=0
os_mem_size=$arg; os_mem_size=$arg
if [ -z $os_mem_size ]; then if [ -z $os_mem_size ]; then
echo "[error] os_mem_size is null" echo "[error] os_mem_size is null"
exit; exit
fi fi
fi fi
if [ $b_arg_yuv_type0 -eq 1 ]; then if [ $b_arg_yuv_type0 -eq 1 ]; then
b_arg_yuv_type0=0; b_arg_yuv_type0=0
YUV_TYPE0=$arg; YUV_TYPE0=$arg
fi fi
if [ $b_arg_board -eq 1 ]; then if [ $b_arg_board -eq 1 ]; then
b_arg_board=0; b_arg_board=0
BOARD=$arg; BOARD=$arg
fi fi
case $arg in case $arg in
"-i") "-i")
b_arg_insmod=1; b_arg_insmod=1
;; ;;
"-r") "-r")
b_arg_remove=1; b_arg_remove=1
;; ;;
"-a") "-a")
b_arg_insmod=1; b_arg_insmod=1
b_arg_remove=1; b_arg_remove=1
;; ;;
"-h") "-h")
load_usage; load_usage
;; ;;
"-sensor0") "-sensor0")
b_arg_sensor0=1; b_arg_sensor0=1
;; ;;
"-sensor") "-sensor")
b_arg_sensor0=1; b_arg_sensor0=1
;; ;;
"-osmem") "-osmem")
b_arg_os_mem=1; b_arg_os_mem=1
;; ;;
"-yuv0") "-yuv0")
b_arg_yuv_type0=1; b_arg_yuv_type0=1
;; ;;
"-board") "-board")
b_arg_board=1; b_arg_board=1
;; ;;
esac esac
done done
#######################parse arg end######################## #######################parse arg end########################
if [ $os_mem_size -ge $mem_total ]; then if [ $os_mem_size -ge $mem_total ]; then
echo "[err] os_mem[$os_mem_size], over total_mem[$mem_total]" echo "[err] os_mem[$os_mem_size], over total_mem[$mem_total]"
exit; exit
fi fi
calc_mmz_info; calc_mmz_info
#######################Action############################### #######################Action###############################
if [ $# -lt 1 ]; then if [ $# -lt 1 ]; then
load_usage; load_usage
exit 0; exit 0
fi fi
# Sensor config # Sensor config
@ -380,7 +364,7 @@ else
fi fi
if [ $b_arg_remove -eq 1 ]; then if [ $b_arg_remove -eq 1 ]; then
remove_ko; remove_ko
fi fi
if [ "$SENSOR" = "unknown" ]; then if [ "$SENSOR" = "unknown" ]; then
@ -388,6 +372,6 @@ if [ "$SENSOR" = "unknown" ]; then
else else
if [ $b_arg_insmod -eq 1 ]; then if [ $b_arg_insmod -eq 1 ]; then
cd /lib/modules/$(uname -r)/hisilicon cd /lib/modules/$(uname -r)/hisilicon
insert_ko; insert_ko
fi fi
fi fi