summaryrefslogtreecommitdiff
path: root/utils/rkisp1
diff options
context:
space:
mode:
Diffstat (limited to 'utils/rkisp1')
-rwxr-xr-xutils/rkisp1/rkisp1-capture.sh56
1 files changed, 55 insertions, 1 deletions
diff --git a/utils/rkisp1/rkisp1-capture.sh b/utils/rkisp1/rkisp1-capture.sh
index 2549779d..c5f859f2 100755
--- a/utils/rkisp1/rkisp1-capture.sh
+++ b/utils/rkisp1/rkisp1-capture.sh
@@ -14,6 +14,37 @@
# - raw2rgbpnm (from git://git.retiisi.org.uk/~sailus/raw2rgbpnm.git)
# - yavta (from git://git.ideasonboard.org/yavta.git)
+# Return the entity connected to a given pad
+# $1: The pad, expressed as "entity":index
+mc_remote_entity() {
+ local entity="${1%:*}"
+ local pad="${1#*:}"
+
+ ${mediactl} -p | awk '
+/^- entity / {
+ in_entity=0
+}
+
+/^- entity [0-9]+: '"${entity}"' / {
+ in_entity=1
+}
+
+/^[ \t]+pad/ {
+ in_pad=0
+}
+
+/^[ \t]+pad'"${pad}"': / {
+ in_pad=1
+}
+
+/^[ \t]+(<-|->) "[^"]+"/ {
+ if (in_entity && in_pad) {
+ print gensub(/^[^"]+"([^"]+)":([0-9]+).*$/, "\\1", "g")
+ exit
+ }
+}'
+}
+
# Locate the sensor entity
find_sensor() {
local bus
@@ -28,6 +59,17 @@ find_sensor() {
echo "$sensor_name $bus"
}
+# Locate the CSI-2 receiver
+find_csi2_rx() {
+ local sensor_name=$1
+ local csi2_rx
+
+ csi2_rx=$(mc_remote_entity "$sensor_name:0")
+ if [ "$csi2_rx" != rkisp1_isp ] ; then
+ echo "$csi2_rx"
+ fi
+}
+
# Locate the media device
find_media_device() {
local mdev
@@ -63,15 +105,27 @@ configure_pipeline() {
local format="fmt:$sensor_mbus_code/$sensor_size"
local capture_mbus_code=$1
local capture_size=$2
+ local csi2_rx
echo "Configuring pipeline for $sensor in $format"
+ csi2_rx=$(find_csi2_rx "$sensor")
+
$mediactl -r
- $mediactl -l "'$sensor':0 -> 'rkisp1_isp':0 [1]"
+ if [ -n "$csi2_rx" ] ; then
+ $mediactl -l "'$sensor':0 -> '$csi2_rx':0 [1]"
+ $mediactl -l "'$csi2_rx':1 -> 'rkisp1_isp':0 [1]"
+ else
+ $mediactl -l "'$sensor':0 -> 'rkisp1_isp':0 [1]"
+ fi
$mediactl -l "'rkisp1_isp':2 -> 'rkisp1_resizer_mainpath':0 [1]"
$mediactl -V "\"$sensor\":0 [$format]"
+ if [ -n "$csi2_rx" ] ; then
+ $mediactl -V "'$csi2_rx':0 [$format]"
+ $mediactl -V "'$csi2_rx':1 [$format]"
+ fi
$mediactl -V "'rkisp1_isp':0 [$format crop:(0,0)/$sensor_size]"
$mediactl -V "'rkisp1_isp':2 [fmt:$capture_mbus_code/$sensor_size crop:(0,0)/$sensor_size]"
$mediactl -V "'rkisp1_resizer_mainpath':0 [fmt:$capture_mbus_code/$sensor_size crop:(0,0)/$sensor_size]"