-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsafe_link.sh
More file actions
executable file
·23 lines (17 loc) · 900 Bytes
/
Copy pathsafe_link.sh
File metadata and controls
executable file
·23 lines (17 loc) · 900 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#!/bin/bash
MEDIA_DEV="/dev/media2"
# Get dynamic entity IDs to avoid kernel panic/instability from static IDs
OV_ID=$(media-ctl -d $MEDIA_DEV -e "ov7251 3-0060" 2>/dev/null || media-ctl -d $MEDIA_DEV -p | grep "ov7251" | awk -F: '{print $1}' | awk '{print $NF}')
CSI_ID=$(media-ctl -d $MEDIA_DEV -e "ipu3-csi2 0" 2>/dev/null || media-ctl -d $MEDIA_DEV -p | grep "ipu3-csi2 0" | awk -F: '{print $1}' | awk '{print $NF}')
if [ -z "$OV_ID" ] || [ -z "$CSI_ID" ]; then
echo "Error: Could not find OV7251 or CSI2 entities."
exit 1
fi
echo "Found OV7251: Entity $OV_ID"
echo "Found CSI2 0: Entity $CSI_ID"
# Link and setup
echo "Linking..."
sudo media-ctl -d $MEDIA_DEV -l "${OV_ID}:0 -> ${CSI_ID}:0[1]"
echo "Setting format..."
sudo media-ctl -d $MEDIA_DEV --set-v4l2 "${OV_ID}:0[fmt:SBGGR10_1X10/640x480]"
echo "Done. Verify with: media-ctl -d $MEDIA_DEV -p | grep -A 5 \"entity $OV_ID\""