From patchwork Mon Jul 11 16:44:13 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Umang Jain X-Patchwork-Id: 16593 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 E0309BD1F1 for ; Mon, 11 Jul 2022 16:44:27 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 468F963316; Mon, 11 Jul 2022 18:44:27 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1657557867; bh=kz6P4jk8D66MRZIjzvaoudIkr/n4DDsHiqanKAD2CLA=; h=To:Date:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=Bflgfb/uu1ssnoQ3w/NpPuPXxYpjiUy+S5pbuL2Rf8IKFA8cvPZuzy1BfNN8BlxaV BTnXYMgK1rPlb9WZb/px6O4Y3h7wSCvdcBgPPD2aKpI/TxQRQlhkK4VOCAHBXi7L33 udKlXQB+PChu4bF1yhmi8JTfJ5Twa3FOT1ZETDLwlc52V2wZaPm+5s5yWiwEtLxwmQ jiDjKwXrPQbT94tu3SghmaQujlMFHpm61RSlmJupsA8Wm9/F9LwdjfXiebYy5alNsZ TZInf+LhfMS2GHvF3JGAJ2VYah00Ye2lBGQ5qib0n7gHedYTc+/iXk2QaE8SzMzVvG 7p3gG3CNV+pAw== 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 BB28D6330F for ; Mon, 11 Jul 2022 18:44:25 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="EieOBzw5"; dkim-atps=neutral Received: from perceval.ideasonboard.com (unknown [IPv6:2401:4900:1f3f:b3fb:3712:29bf:7855:376e]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 7D0C7326; Mon, 11 Jul 2022 18:44:24 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1657557865; bh=kz6P4jk8D66MRZIjzvaoudIkr/n4DDsHiqanKAD2CLA=; h=From:To:Cc:Subject:Date:From; b=EieOBzw5mF2+byEYB5OgYodDrmhmdWnHcNqUVhkzaWvlIrr4vEtjYlz9fnM2zJLI1 SfUBbnI5QUquD3vdnTy1jnfcJKNanXRqkAqjTFgwI5ZUJo420TXUCdE+9zDeNgSclx ZN6JVklFqmNj1kUks7H53v7dGNlNpm9m9Da1SEME= To: libcamera-devel@lists.libcamera.org Date: Mon, 11 Jul 2022 22:14:13 +0530 Message-Id: <20220711164413.76229-1-umang.jain@ideasonboard.com> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 Subject: [libcamera-devel] [RFC PATCH] utils: ipu3-process: Stream multiple frames using v4l2-ctl 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: Umang Jain via libcamera-devel From: Umang Jain Reply-To: Umang Jain Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Stream IMGU using v4l2-ctl as it provides more granular controls on the video nodes. The goal here is to stream a single input file containing multiple frames in 10-bit IPU3 packed bayer format. Such a input file can be created using the ipu3-pack utility. This patch enables the IMGU's parameter node as well in configure_pipeline() without which, the input node won't stream successive input frames. The viewfinder and output nodes will still stream using yavta, so no changes required there. It's is quite tricky to stream input and parameters nodes synchronously with v4l2-ctl commands for each. The patch overcomes this short-coming by streaming both the nodes endlessly until both of them are killed. A sleep of 1 second is introduced to make sure $frame_count buffers are captured on the output and vf nodes. Another short-coming of this patch is when specific parameter-buffer(s) (from a file) are needed to streamed on the parameters node, this might require some adjusting. For now, the parameters node streams with un-assigned buffers. It depends on the decision how this script is expanded further down the line. Signed-off-by: Umang Jain --- utils/ipu3/ipu3-process.sh | 29 ++++++++++++++++++++++++----- 1 file changed, 24 insertions(+), 5 deletions(-) diff --git a/utils/ipu3/ipu3-process.sh b/utils/ipu3/ipu3-process.sh index bb4abbe8..48466d70 100755 --- a/utils/ipu3/ipu3-process.sh +++ b/utils/ipu3/ipu3-process.sh @@ -37,11 +37,13 @@ configure_pipeline() { local enable_3a=1 local enable_out=1 local enable_vf=1 + local enable_param=1 local mode=0 # Configure the links $mediactl -r $mediactl -l "\"$imgu_entity input\":0 -> \"$imgu_entity\":0[1]" + $mediactl -l "\"$imgu_entity parameters\":0 -> \"$imgu_entity\":1[$enable_param]" $mediactl -l "\"$imgu_entity\":2 -> \"$imgu_entity output\":0[$enable_out]" $mediactl -l "\"$imgu_entity\":3 -> \"$imgu_entity viewfinder\":0[$enable_vf]" $mediactl -l "\"$imgu_entity\":4 -> \"$imgu_entity 3a stat\":0[$enable_3a]" @@ -76,9 +78,26 @@ process_frames() { $yavta $($mediactl -e "$imgu_entity 3a stat") & sleep 0.5 - # Feed the IMGU input. - $yavta -f $IMGU_IN_PIXELFORMAT -s $in_size "-F$in_file" \ - $($mediactl -e "$imgu_entity input") + echo "Feeding IMGU $in_size" + # Start stream parameters node first + v4l2-ctl -d$($mediactl -e "$imgu_entity parameters") --stream-out-mmap & + local param_streaming=$! + + # Start streaming on input node + local width=$(echo $in_size | awk -F 'x' '{print $1}') + local height=$(echo $in_size | awk -F 'x' '{print $2}') + v4l2-ctl -d $($mediactl -e "$imgu_entity input") \ + --set-fmt-video-out=width=$width,height=$height,pixelformat=$IMGU_IN_PIXELFORMAT \ + --stream-out-mmap --stream-from=$in_file --stream-loop & + local input_streaming=$! + + # Sleep for 1 second and then kill the IMGU streaming. By then $frame_count output and vf + # buffers should have been captured. + sleep 1 + kill $input_streaming + kill $param_streaming + + echo "IMGU FED" } # Convert captured files to ppm @@ -98,7 +117,7 @@ convert_files() { } run_test() { - IMGU_IN_PIXELFORMAT=IPU3_SGRBG10 + IMGU_IN_PIXELFORMAT=ip3G IMGU_OUT_PIXELFORMAT=NV12 IMGU_VF_PIXELFORMAT=NV12 @@ -193,6 +212,6 @@ mediactl="media-ctl -d $mdev" echo "Using device $mdev" output_dir="/tmp" -frame_count=5 +frame_count=10 nbufs=7 run_test