Skip to content

Commit

Permalink
utils: rkisp1: Support optional CSI-2 receiver subdev
Browse files Browse the repository at this point in the history
The media graph may include a CSI-2 receiver entity between the sensor
and the ISP for platforms that have a CSI-2 receiver external to the
ISP. Support this by configuring the pipeline accordingly.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
  • Loading branch information
pinchartl committed Jul 15, 2022
1 parent 4d3a118 commit a5877e0
Showing 1 changed file with 55 additions and 1 deletion.
56 changes: 55 additions & 1 deletion utils/rkisp1/rkisp1-capture.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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]"
Expand Down

0 comments on commit a5877e0

Please sign in to comment.