Patch Detail
Show a patch.
GET /api/patches/744/?format=api
{ "id": 744, "url": "https://patchwork.libcamera.org/api/patches/744/?format=api", "web_url": "https://patchwork.libcamera.org/patch/744/", "project": { "id": 1, "url": "https://patchwork.libcamera.org/api/projects/1/?format=api", "name": "libcamera", "link_name": "libcamera", "list_id": "libcamera_core", "list_email": "libcamera-devel@lists.libcamera.org", "web_url": "", "scm_url": "", "webscm_url": "" }, "msgid": "<20190319184324.4864-1-laurent.pinchart@ideasonboard.com>", "date": "2019-03-19T18:43:24", "name": "[libcamera-devel] utils: rkisp1: Add test capture script", "commit_ref": "ffef90a1c1f1990581d8fbc22193bfc766d23d3b", "pull_url": null, "state": "accepted", "archived": false, "hash": "80d7eddeba192b64d8d097c4e28f359b7ee7fb81", "submitter": { "id": 2, "url": "https://patchwork.libcamera.org/api/people/2/?format=api", "name": "Laurent Pinchart", "email": "laurent.pinchart@ideasonboard.com" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/744/mbox/", "series": [ { "id": 212, "url": "https://patchwork.libcamera.org/api/series/212/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=212", "date": "2019-03-19T18:43:24", "name": "[libcamera-devel] utils: rkisp1: Add test capture script", "version": 1, "mbox": "https://patchwork.libcamera.org/series/212/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/744/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/744/checks/", "tags": {}, "headers": { "Return-Path": "<laurent.pinchart@ideasonboard.com>", "Received": [ "from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 5B8A7610C5\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 19 Mar 2019 19:43:59 +0100 (CET)", "from pendragon.nordic-sky.finnair.com (unknown [38.98.37.141])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 436E131C\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 19 Mar 2019 19:43:52 +0100 (CET)" ], "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1553021039;\n\tbh=/OJSl7O9E4HR8O4swXderTmr2Wh0XDiaAcEEovcYB3Y=;\n\th=From:To:Subject:Date:From;\n\tb=gONh8+Y68FfX4d8fNZFrzTuTt80zqbTaEyqo7BlXUNPS4pv9K6TPgA8b1q1OhEMHM\n\tnzZKmy97oe45Ouvg2nf4Ss1nYegnhYloks0b650RDmHEZbiUQw9RoAYqcIK5r8eSY9\n\t6nYpEaevBt010QW2krlAM5i+hfRRVhIcGJjvP3CY=", "From": "Laurent Pinchart <laurent.pinchart@ideasonboard.com>", "To": "libcamera-devel@lists.libcamera.org", "Date": "Tue, 19 Mar 2019 20:43:24 +0200", "Message-Id": "<20190319184324.4864-1-laurent.pinchart@ideasonboard.com>", "X-Mailer": "git-send-email 2.19.2", "MIME-Version": "1.0", "Content-Transfer-Encoding": "8bit", "Subject": "[libcamera-devel] [PATCH] utils: rkisp1: Add test capture script", "X-BeenThere": "libcamera-devel@lists.libcamera.org", "X-Mailman-Version": "2.1.23", "Precedence": "list", "List-Id": "<libcamera-devel.lists.libcamera.org>", "List-Unsubscribe": "<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>", "List-Archive": "<https://lists.libcamera.org/pipermail/libcamera-devel/>", "List-Post": "<mailto:libcamera-devel@lists.libcamera.org>", "List-Help": "<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>", "List-Subscribe": "<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>", "X-List-Received-Date": "Tue, 19 Mar 2019 18:43:59 -0000" }, "content": "The script captures raw or processed frames from cameras based on the\nRockchip ISP1. It takes the sensor name as an argument and isn't meant\nto depend on a particular platform.\n\nSigned-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n---\n utils/rkisp1/rkisp1-capture.sh | 182 +++++++++++++++++++++++++++++++++\n 1 file changed, 182 insertions(+)\n create mode 100755 utils/rkisp1/rkisp1-capture.sh", "diff": "diff --git a/utils/rkisp1/rkisp1-capture.sh b/utils/rkisp1/rkisp1-capture.sh\nnew file mode 100755\nindex 000000000000..cffe9fed8d12\n--- /dev/null\n+++ b/utils/rkisp1/rkisp1-capture.sh\n@@ -0,0 +1,182 @@\n+#!/bin/sh\n+# SPDX-License-Identifier: GPL-2.0-or-later\n+# Copyright (C) 2019, Google Inc.\n+#\n+# Author: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n+#\n+# rkisp-capture.sh - Capture processed frames from cameras based on the\n+# Rockchip ISP1\n+#\n+# The scripts makes use of the following tools, which are expected to be\n+# executable from the system-wide path or from the local directory:\n+#\n+# - media-ctl (from v4l-utils git://linuxtv.org/v4l-utils.git)\n+# - raw2rgbpnm (from git://git.retiisi.org.uk/~sailus/raw2rgbpnm.git)\n+# - yavta (from git://git.ideasonboard.org/yavta.git)\n+\n+# Locate the sensor entity\n+find_sensor() {\n+\tlocal bus\n+\tlocal sensor_name=$1\n+\n+\tbus=$(grep \"$sensor_name \" /sys/class/video4linux/v4l-subdev*/name | cut -d ' ' -f 2)\n+\tif [[ -z $bus ]]; then\n+\t\techo \"Sensor '$sensor_name' not found.\" >&2\n+\t\texit 1\n+\tfi\n+\n+\techo \"$sensor_name $bus\"\n+}\n+\n+# Locate the media device\n+find_media_device() {\n+\tlocal mdev\n+\tlocal name=$1\n+\n+\tfor mdev in /dev/media* ; do\n+\t\tmedia-ctl -d $mdev -p | grep -q \"^driver[ \\t]*$name$\" && break\n+\t\tmdev=\n+\tdone\n+\n+\tif [[ -z $mdev ]] ; then\n+\t\techo \"$name media device not found.\" >&2\n+\t\texit 1\n+\tfi\n+\n+\techo $mdev\n+}\n+\n+# Get the sensor format\n+get_sensor_format() {\n+\tlocal format\n+\tlocal sensor=$1\n+\n+\tformat=$($mediactl --get-v4l2 \"'$sensor':0\" | sed 's/\\[\\([^ ]*\\).*/\\1/')\n+\tsensor_mbus_code=$(echo $format | sed 's/fmt:\\([A-Z0-9_]*\\).*/\\1/')\n+\tsensor_size=$(echo $format | sed 's/[^\\/]*\\/\\([0-9x]*\\).*/\\1/')\n+\n+\techo \"Capturing ${sensor_size} from sensor $sensor in ${sensor_mbus_code}\"\n+}\n+\n+# Configure the pipeline\n+configure_pipeline() {\n+\tlocal format=\"fmt:$sensor_mbus_code/$sensor_size\"\n+\tlocal capture_mbus_code=$1\n+\tlocal capture_size=$2\n+\n+\techo \"Configuring pipeline for $sensor in $format\"\n+\n+\t$mediactl -r\n+\n+\t$mediactl -l \"'$sensor':0 -> 'rockchip-sy-mipi-dphy':0 [1]\"\n+\t$mediactl -l \"'rockchip-sy-mipi-dphy':1 -> 'rkisp1-isp-subdev':0 [1]\"\n+\t$mediactl -l \"'rkisp1-isp-subdev':2 -> 'rkisp1_mainpath':0 [1]\"\n+\n+\t$mediactl -V \"\\\"$sensor\\\":0 [$format]\"\n+\t$mediactl -V \"'rockchip-sy-mipi-dphy':1 [$format]\"\n+\t$mediactl -V \"'rkisp1-isp-subdev':0 [$format crop:(0,0)/$sensor_size]\"\n+\t$mediactl -V \"'rkisp1-isp-subdev':2 [fmt:$capture_mbus_code/$capture_size crop:(0,0)/$capture_size]\"\n+}\n+\n+# Capture frames\n+capture_frames() {\n+\tlocal file_op\n+\tlocal capture_format=$1\n+\tlocal capture_size=$2\n+\tlocal frame_count=$3\n+\tlocal save_file=$4\n+\n+\tif [[ $save_file -eq 1 ]]; then\n+\t\tfile_op=\"--file=/tmp/frame-#.bin\"\n+\tfi\n+\n+\tyavta -c$frame_count -n5 -I -f $capture_format -s $capture_size \\\n+\t\t$file_op $($mediactl -e \"rkisp1_mainpath\")\n+}\n+\n+# Convert captured files to ppm\n+convert_files() {\n+\tlocal format=$1\n+\tlocal size=$2\n+\tlocal frame_count=$3\n+\n+\techo \"Converting ${frame_count} frames (${size})\"\n+\n+\tfor i in `seq 0 $(($frame_count - 1))`; do\n+\t\ti=$(printf %06u $i)\n+\t\traw2rgbpnm -f $format -s $size /tmp/frame-$i.bin /tmp/frame-$i.ppm\n+\tdone\n+}\n+\n+# Print usage message\n+usage() {\n+\techo \"Usage: $1 [options] sensor-name\"\n+\techo \"Supported options:\"\n+\techo \"-c,--count n Number of frame to capture\"\n+\techo \"--no-save Do not save captured frames to disk\"\n+\techo \"-r, --raw Capture RAW frames\"\n+\techo \"-s, --size wxh Frame size\"\n+}\n+\n+# Parse command line arguments\n+capture_size=1024x768\n+frame_count=10\n+raw=false\n+save_file=1\n+\n+while [[ $# -ne 0 ]] ; do\n+\tcase $1 in\n+\t-c|--count)\n+\t\tframe_count=$2\n+\t\tshift 2\n+\t\t;;\n+\t--no-save)\n+\t\tsave_file=0\n+\t\tshift\n+\t\t;;\n+\n+\t-r|--raw)\n+\t\traw=true\n+\t\tshift\n+\t\t;;\n+\t-s|--size)\n+\t\tcapture_size=$2\n+\t\tshift 2\n+\t\t;;\n+\t-*)\n+\t\techo \"Unsupported option $1\" >&2\n+\t\tusage $0\n+\t\texit 1\n+\t\t;;\n+\t*)\n+\t\tbreak\n+\t\t;;\n+\tesac\n+done\n+\n+if [[ $# -ne 1 ]] ; then\n+\tusage $0\n+\texit 1\n+fi\n+\n+sensor_name=$1\n+\n+modprobe mipi_dphy_sy\n+modprobe video_rkisp1\n+\n+sensor=$(find_sensor $sensor_name) || exit\n+mdev=$(find_media_device rkisp1) || exit\n+mediactl=\"media-ctl -d $mdev\"\n+\n+get_sensor_format \"$sensor\"\n+if [[ $raw == true ]] ; then\n+\tcapture_format=$(echo $sensor_mbus_code | sed 's/_[0-9X]$//')\n+\tcapture_mbus_code=$sensor_mbus_code\n+else\n+\tcapture_format=YUYV\n+\tcapture_mbus_code=YUYV8_2X8\n+fi\n+\n+configure_pipeline $capture_mbus_code $capture_size\n+capture_frames $capture_format $capture_size $frame_count $save_file\n+[[ $save_file -eq 1 ]] && convert_files $capture_format $capture_size $frame_count\n", "prefixes": [ "libcamera-devel" ] }