28 lines
1.1 KiB
Bash
Executable File
28 lines
1.1 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# Initialize the camera using the packaged Orin drivers.
|
|
set -euo pipefail
|
|
root="$(cd "$(dirname "$0")/.." && pwd)"
|
|
driver_dir="${DRIVER_DIR:-$root/orin/bin/drivers}"
|
|
device="${1:-/dev/video5}"
|
|
kernel="$(uname -r)"
|
|
for driver in max9295 max9296 sgx-yuv-gmsl2; do
|
|
module="${driver//-/_}"
|
|
[[ -d "/sys/module/$module" ]] && continue
|
|
file="$driver_dir/$driver.ko"
|
|
[[ -f "$file" ]] || { echo "Missing driver: $file" >&2; exit 1; }
|
|
vermagic="$(modinfo -F vermagic "$file")"
|
|
if [[ -n "$vermagic" && "${vermagic%% *}" != "$kernel" ]]; then
|
|
echo "Kernel mismatch: $file ($vermagic), running $kernel" >&2; exit 1
|
|
fi
|
|
if [[ -z "$vermagic" ]]; then
|
|
echo "No vermagic metadata: $file; using normal insmod kernel validation."
|
|
fi
|
|
options=()
|
|
[[ "$driver" == sgx-yuv-gmsl2 ]] && options=(gmsl_mode=2,2,2,2)
|
|
sudo -n insmod "$file" "${options[@]}"
|
|
done
|
|
for _ in {1..20}; do [[ -c "$device" ]] && break; sleep .25; done
|
|
[[ -c "$device" ]] || { echo "Camera not created: $device" >&2; exit 1; }
|
|
v4l2-ctl -d "$device" -c sensor_mode=1,trig_pin=0xffff0007
|
|
echo "Camera ready: $device"
|