From patchwork Mon Jun 20 21:06:58 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 16297 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id A36E3BD808 for ; Mon, 20 Jun 2022 21:07:25 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 44AD165641; Mon, 20 Jun 2022 23:07:25 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1655759245; bh=0fhs8ySHonSCSmy5HzMPEw4hKvUUaLrUIVBKAopcUnw=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=H9QkfXWaH6YfHx6+SMiF66Ntan1oN7IGDG2rpS90scUeyIUMaIRxazGQ347PoMmVk NJGSnPwf69nrGW4rRGLyKhmZ7HPe9lCsyEoRZL8n7IEFAOkke7Mcuv16stW+ynh4OY u+LNxvq3wTyQ08Y6K1kjgFEgZVdqxlPcGSJEG2A1tLHTn9GK9XBN56JWVG0yw4y8/j /j/LRVBkEPsLcvEsnewlS/ROFe2D5g2JcqaaTIN3edqoeD4SVj52v55sVnIgdjg2p3 bBvUXPy297USozp5uZ+6C+utCb49zOea1WTi4NsililOsDotTO4VAjF2/u2II3K5Fm dd8IH7CCVFIXA== Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 58D076563B for ; Mon, 20 Jun 2022 23:07:19 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="p/6JClEh"; dkim-atps=neutral Received: from pendragon.lan (62-78-145-57.bb.dnainternet.fi [62.78.145.57]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 8721BE5 for ; Mon, 20 Jun 2022 23:07:18 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1655759238; bh=0fhs8ySHonSCSmy5HzMPEw4hKvUUaLrUIVBKAopcUnw=; h=From:To:Subject:Date:In-Reply-To:References:From; b=p/6JClEh94tFA4ezDEvHVBuaQSxsQ5l8amMiuvKmNpG9zK0F+OVl5arWcHcB3WQox atzSB+0ZU0Tl8wYjQ4iwX5txH+SSmqzHWouyakzdjbvpRAzlkCp0W1iCrZU0ujejiF 4VE0YhxQ/FrppiQXEgyoiMxm/qrtiV4e4iTpxgdk= To: libcamera-devel@lists.libcamera.org Date: Tue, 21 Jun 2022 00:06:58 +0300 Message-Id: <20220620210658.20288-5-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220620210658.20288-1-laurent.pinchart@ideasonboard.com> References: <20220620210658.20288-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 4/4] utils: rkisp1: Support optional CSI-2 receiver subdev X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Laurent Pinchart via libcamera-devel From: Laurent Pinchart Reply-To: Laurent Pinchart Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" 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 Reviewed-by: Paul Elder --- utils/rkisp1/rkisp1-capture.sh | 56 +++++++++++++++++++++++++++++++++- 1 file changed, 55 insertions(+), 1 deletion(-) diff --git a/utils/rkisp1/rkisp1-capture.sh b/utils/rkisp1/rkisp1-capture.sh index 2549779d0f78..c5f859f21001 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]"