Skip to content

Commit 4dac174

Browse files
committed
camera: add generic NHX and CAMX helper updates
Update camera helpers to better support NHX validation across targets. Changes include: - board-aware camera module selection from DT data - generic CAMERA_ICP firmware discovery under /lib/firmware/qcom - package detection for both opkg and dnf/rpm based images - cam-server logging helpers for status and stdout capture - NHX dump size helper built on shared file size detection Signed-off-by: Srikanth Muppandam <smuppand@qti.qualcomm.com>
1 parent a518204 commit 4dac174

1 file changed

Lines changed: 129 additions & 22 deletions

File tree

Runner/utils/camera/lib_camera.sh

Lines changed: 129 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -442,36 +442,93 @@ camx_read_soc_id() {
442442
# Find ICP camera firmware ELF (CAMERA_ICP_*.elf)
443443
# Prints first match path on stdout.
444444
camx_find_icp_firmware() {
445-
soc="$(camx_read_soc_id 2>/dev/null || true)"
446-
447-
# First try soc-specific canonical path
448-
for root in /usr/lib/firmware /lib/firmware; do
449-
if [ -n "$soc" ] && [ -d "$root/qcom/$soc" ]; then
450-
p="$(find "$root/qcom/$soc" -maxdepth 1 -type f -name 'CAMERA_ICP_*.elf' 2>/dev/null | head -n 1)"
451-
[ -n "$p" ] && echo "$p" && return 0
452-
fi
453-
done
454-
455-
# Fallback bounded search
456-
for root in /usr/lib/firmware /lib/firmware; do
457-
if [ -d "$root/qcom" ]; then
458-
p="$(find "$root/qcom" -maxdepth 2 -type f -name 'CAMERA_ICP_*.elf' 2>/dev/null | head -n 1)"
459-
[ -n "$p" ] && echo "$p" && return 0
445+
token_list=""
446+
token=""
447+
cand=""
448+
449+
if [ -r /proc/device-tree/compatible ]; then
450+
token_list="$(
451+
tr '\0' '\n' </proc/device-tree/compatible 2>/dev/null \
452+
| tr '[:upper:]' '[:lower:]' \
453+
| sed -n 's#.*\(qcm[0-9][0-9]*\|qcs[0-9][0-9]*\|sa[0-9][0-9]*p\).*#\1#p' \
454+
| sort -u
455+
)"
456+
fi
457+
458+
for token in $token_list; do
459+
if [ -d "/lib/firmware/qcom/$token" ]; then
460+
for cand in \
461+
"/lib/firmware/qcom/$token/CAMERA_ICP.mbn" \
462+
"/lib/firmware/qcom/$token/CAMERA_ICP.elf"
463+
do
464+
if [ -f "$cand" ]; then
465+
printf '%s\n' "$cand"
466+
return 0
467+
fi
468+
done
469+
470+
cand="$(
471+
find "/lib/firmware/qcom/$token" -maxdepth 1 -type f \
472+
\( -name 'CAMERA_ICP*.mbn' -o -name 'CAMERA_ICP*.elf' \) \
473+
2>/dev/null | sort | head -n 1
474+
)"
475+
if [ -n "$cand" ] && [ -f "$cand" ]; then
476+
printf '%s\n' "$cand"
477+
return 0
478+
fi
460479
fi
461480
done
462-
481+
482+
cand="$(
483+
find /lib/firmware/qcom -type f \
484+
\( -name 'CAMERA_ICP.mbn' -o -name 'CAMERA_ICP.elf' -o -name 'CAMERA_ICP*.mbn' -o -name 'CAMERA_ICP*.elf' \) \
485+
2>/dev/null | sort | head -n 1
486+
)"
487+
if [ -n "$cand" ] && [ -f "$cand" ]; then
488+
printf '%s\n' "$cand"
489+
return 0
490+
fi
491+
492+
cand="$(
493+
find /lib/firmware -type f \
494+
\( -name 'CAMERA_ICP.mbn' -o -name 'CAMERA_ICP.elf' -o -name 'CAMERA_ICP*.mbn' -o -name 'CAMERA_ICP*.elf' \) \
495+
2>/dev/null | sort | head -n 1
496+
)"
497+
if [ -n "$cand" ] && [ -f "$cand" ]; then
498+
printf '%s\n' "$cand"
499+
return 0
500+
fi
501+
463502
return 1
464503
}
465-
466504
# -----------------------------------------------------------------------------
467505
# Package helpers (Yocto/QLI proprietary builds)
468506
# -----------------------------------------------------------------------------
469507
camx_opkg_list_camx() {
470-
command -v opkg >/dev/null 2>&1 || return 1
471-
out="$(opkg list-installed 2>/dev/null | grep -i '^camx' || true)"
472-
[ -n "$out" ] || return 1
473-
printf '%s\n' "$out"
474-
return 0
508+
out=""
509+
510+
if command -v opkg >/dev/null 2>&1; then
511+
out="$(opkg list-installed 2>/dev/null | grep -i '^camx' || true)"
512+
[ -n "$out" ] || return 1
513+
printf '%s\n' "$out"
514+
return 0
515+
fi
516+
517+
if command -v dnf >/dev/null 2>&1; then
518+
out="$(dnf list installed 2>/dev/null | grep -i '^camx' || true)"
519+
[ -n "$out" ] || return 1
520+
printf '%s\n' "$out"
521+
return 0
522+
fi
523+
524+
if command -v rpm >/dev/null 2>&1; then
525+
out="$(rpm -qa 2>/dev/null | grep -i '^camx' || true)"
526+
[ -n "$out" ] || return 1
527+
printf '%s\n' "$out"
528+
return 0
529+
fi
530+
531+
return 1
475532
}
476533

477534
# -----------------------------------------------------------------------------
@@ -635,3 +692,53 @@ run_cmd_live_to_log() {
635692
wait "$teepid" 2>/dev/null || true
636693
return "$rc"
637694
}
695+
696+
# -----------------------------------------------------------------------------
697+
# Pick board-specific camera module from DT compatible/model
698+
# -----------------------------------------------------------------------------
699+
camx_pick_camera_module() {
700+
compat_list=""
701+
model_str=""
702+
703+
if [ -r /proc/device-tree/compatible ]; then
704+
compat_list="$(tr '\0' '\n' </proc/device-tree/compatible 2>/dev/null | tr '[:upper:]' '[:lower:]')"
705+
fi
706+
707+
if [ -r /proc/device-tree/model ]; then
708+
model_str="$(tr '[:upper:]' '[:lower:]' </proc/device-tree/model 2>/dev/null)"
709+
fi
710+
711+
case "$compat_list
712+
$model_str" in
713+
*rb3gen2*|*qcm6490*|*qcs6490*)
714+
printf '%s\n' "camera_qcm6490"
715+
return 0
716+
;;
717+
*qcs9100-ride-sx*|*iq-9075-evk*|*qcs8300-ride-sx*|*iq-8275-evk*|*qcs9100*|*qcs8300*)
718+
printf '%s\n' "camera_qcs9100"
719+
return 0
720+
;;
721+
*qcs615-ride*|*iq-615-evk*|*qcs615*)
722+
printf '%s\n' "camera_qcs615"
723+
return 0
724+
;;
725+
esac
726+
727+
return 1
728+
}
729+
730+
# Get the size of the yuv file dump
731+
nhx_dump_size_bytes() {
732+
file_path="$1"
733+
size="$(file_size_bytes "$file_path" 2>/dev/null || printf '%s\n' "0")"
734+
735+
case "$size" in
736+
''|*[!0-9]*)
737+
printf '%s\n' "0"
738+
return 1
739+
;;
740+
esac
741+
742+
printf '%s\n' "$size"
743+
return 0
744+
}

0 commit comments

Comments
 (0)