mirror of https://github.com/OpenIPC/firmware.git
74 lines
1.8 KiB
Bash
Executable File
74 lines
1.8 KiB
Bash
Executable File
#!/bin/sh
|
|
#
|
|
# OpenIPC.org | 2024
|
|
#
|
|
|
|
PATH_MODULE=/lib/modules/4.9.84/sigmastar
|
|
PATH_SENSOR=${PATH_MODULE}/sensor
|
|
SENSOR=$(fw_printenv -n sensor)
|
|
|
|
detect_sensor() {
|
|
insmod ${PATH_SENSOR}/sensor_config.ko
|
|
if [ -e /dev/srcfg ]; then
|
|
echo srcfg 0 1 0 0 0 0 > /dev/srcfg
|
|
rmmod sensor_config
|
|
fi
|
|
SENSOR=$(ipcinfo -s)
|
|
fw_setenv sensor ${SENSOR}
|
|
}
|
|
|
|
set_sensor() {
|
|
case ${SENSOR} in
|
|
gc2053|gc2083|gc4023|gc4653|imx307|imx335|jxf37|jxq03|os02g10)
|
|
insmod ${PATH_SENSOR}/sensor_${SENSOR}_mipi.ko chmap=1
|
|
;;
|
|
sc200ai|sc401ai|sc2239|sc223a|sc2335|sc3335|sc3338)
|
|
insmod ${PATH_SENSOR}/sensor_${SENSOR}_mipi.ko chmap=1
|
|
;;
|
|
*)
|
|
echo -e "\n\e[1;31mUNSUPPORTED sensor - ${SENSOR}\e[0m\n" | logger -s -t OpenIPC
|
|
;;
|
|
esac
|
|
}
|
|
|
|
insert_ko() {
|
|
insmod ${PATH_MODULE}/mhal.ko
|
|
insmod ${PATH_MODULE}/mi_common.ko
|
|
insmod ${PATH_MODULE}/mi_sys.ko cmdQBufSize=256 logBufSize=256
|
|
insmod ${PATH_MODULE}/mi_rgn.ko
|
|
insmod ${PATH_MODULE}/mi_ai.ko
|
|
insmod ${PATH_MODULE}/mi_ao.ko
|
|
insmod ${PATH_MODULE}/mi_sensor.ko
|
|
insmod ${PATH_MODULE}/mi_shadow.ko
|
|
insmod ${PATH_MODULE}/mi_divp.ko
|
|
insmod ${PATH_MODULE}/mi_vif.ko
|
|
insmod ${PATH_MODULE}/mi_vpe.ko
|
|
insmod ${PATH_MODULE}/mi_venc.ko fw_path=/etc/firmware/chagall.bin
|
|
|
|
MAJOR=$(awk '$2=="mi_poll" {print $1}' /proc/devices)
|
|
mknod /dev/mi_poll c ${MAJOR} 0
|
|
echo isproot /etc/firmware > /dev/ispmid
|
|
}
|
|
|
|
if [ ! -e /sys/module/mhal ]; then
|
|
insert_ko
|
|
fi
|
|
|
|
if [ -z ${SENSOR} ]; then
|
|
echo -e "\n\e[1;33mAutodetect sensor\e[0m\n" | logger -s -t OpenIPC
|
|
detect_sensor
|
|
fi
|
|
|
|
if [ -z ${SENSOR} ]; then
|
|
echo -e "\n\e[1;31mSensor parameter MISSING\e[0m\n" | logger -s -t OpenIPC
|
|
exit 1
|
|
else
|
|
echo -e "\n\e[1;32mSensor assigned - ${SENSOR}\e[0m\n" | logger -s -t OpenIPC
|
|
if [ -e /sys/module/sensor* ]; then
|
|
rmmod $(ls -d /sys/module/sensor* | cut -d/ -f4)
|
|
fi
|
|
set_sensor
|
|
fi
|
|
|
|
exit 0
|