Show a patch.

GET /api/patches/18/?format=api
HTTP 200 OK
Allow: GET, PUT, PATCH, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
    "id": 18,
    "url": "https://patchwork.libcamera.org/api/patches/18/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/18/",
    "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": "<20181128224507.24596-1-laurent.pinchart@ideasonboard.com>",
    "date": "2018-11-28T22:45:07",
    "name": "[libcamera-devel] utils: ipu3: Add test capture script",
    "commit_ref": null,
    "pull_url": null,
    "state": "accepted",
    "archived": false,
    "hash": "27008a0275890bdc3e9bbbfc6d964f50340cdc62",
    "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/18/mbox/",
    "series": [
        {
            "id": 9,
            "url": "https://patchwork.libcamera.org/api/series/9/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=9",
            "date": "2018-11-28T22:45:07",
            "name": "[libcamera-devel] utils: ipu3: Add test capture script",
            "version": 1,
            "mbox": "https://patchwork.libcamera.org/series/9/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/18/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/18/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 198D460002\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 28 Nov 2018 23:44:45 +0100 (CET)",
            "from avalon.bb.dnainternet.fi\n\t(dfj612ybrt5fhg77mgycy-3.rev.dnainternet.fi\n\t[IPv6:2001:14ba:21f5:5b00:2e86:4862:ef6a:2804])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 7909255A\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 28 Nov 2018 23:44:44 +0100 (CET)"
        ],
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1543445084;\n\tbh=7GNe1ck/v9o/WwvrZOoWVQkuvWQFEHvPMD7vTg/W8ek=;\n\th=From:To:Subject:Date:From;\n\tb=bvI88CKySoHPJWa6Faqh/jRXeRYsk3acA3dL+d+bpywVNW4KHoPsr2JbcCSJKyS7n\n\tlnfNQqz6RW0dTl73Z6QrGIXFkug5aiSsnMh6Wbu8xa6t0/QmuXTBQl+syD5Oov5xLj\n\t7TasKxi4Ti15ceVL1RKasdnzLHR8HIaejQJ0dm4A=",
        "From": "Laurent Pinchart <laurent.pinchart@ideasonboard.com>",
        "To": "libcamera-devel@lists.libcamera.org",
        "Date": "Thu, 29 Nov 2018 00:45:07 +0200",
        "Message-Id": "<20181128224507.24596-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: ipu3: 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": "Wed, 28 Nov 2018 22:44:45 -0000"
    },
    "content": "The script captures raw frames from cameras based on the Intel IPU3. It\ntakes the sensor name as an argument and isn't meant to depend on a\nparticular platform.\n\nSigned-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n---\n utils/ipu3/ipu3-capture.sh | 182 +++++++++++++++++++++++++++++++++++++\n 1 file changed, 182 insertions(+)\n create mode 100755 utils/ipu3/ipu3-capture.sh",
    "diff": "diff --git a/utils/ipu3/ipu3-capture.sh b/utils/ipu3/ipu3-capture.sh\nnew file mode 100755\nindex 000000000000..930e697e7b44\n--- /dev/null\n+++ b/utils/ipu3/ipu3-capture.sh\n@@ -0,0 +1,182 @@\n+#!/bin/bash\n+# SPDX-License-Identifier: GPL-2.0-or-later\n+# Copyright (C) 2018, Google Inc.\n+#\n+# Author: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n+#\n+# ipu3-capture.sh - Capture raw frames from cameras based on the Intel IPU3\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+# - raw2pnm (from nvt https://github.com/intel/nvt.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+\n+\tfor mdev in /dev/media* ; do\n+\t\tmedia-ctl -d $mdev -p | grep -q ipu3-cio2 && break\n+\t\tmdev=\n+\tdone\n+\n+\tif [[ -z $mdev ]] ; then\n+\t       echo \"IPU3 media device not found.\" >&2\n+\t       exit 1\n+\tfi\n+\n+\techo $mdev\n+}\n+\n+# Locate the CSI2 and CIO2 and get the sensor format\n+parse_pipeline() {\n+\tlocal cio2_queue\n+\tlocal resolution\n+\tlocal sensor=$1\n+\n+\tread cio2_queue bus_format sensor_size <<< $($mediactl -p | awk \"\n+\t/^- entity [0-9]*:/ {\n+\t\tsensor=0;\n+\t}\n+\n+\t/^- entity [0-9]*: $sensor/ {\n+\t\tsensor=1;\n+\t}\n+\n+\t/^[ \\t]*(stream:0)?\\[fmt:/ {\n+\t\tif (sensor) {\n+\t\t\tgsub(\\\".*fmt:\\\", \\\"\\\");\n+\t\t\tgsub(\\\"[] ].*\\\", \\\"\\\");\n+\t\t\tgsub(\\\"/\\\", \\\" \\\");\n+\t\t\tformat=\\$0;\n+\t\t}\n+\t}\n+\n+\t/^[ \\t]*->/ {\n+\t\tif (sensor)\n+\t\t\tcio2=substr(\\$3, 0, 1);\n+\t}\n+\n+\tEND {\n+\t\tprint cio2 \\\" \\\" format;\n+\t}\n+\t\")\n+\n+\tipu3_csi2=\"ipu3-csi2 $cio2_queue\"\n+\tipu3_capture=\"ipu3-cio2 $cio2_queue\"\n+\n+\tsensor_width=$(echo $sensor_size | cut -d 'x' -f 1)\n+\tsensor_height=$(echo $sensor_size | cut -d 'x' -f 2)\n+\n+\techo \"Using device $mdev with IPU3 CIO2 queue $cio2_queue\"\n+}\n+\n+# Configure the pipeline\n+configure_pipeline() {\n+\tlocal format=\"fmt:$bus_format/$sensor_size\"\n+\n+\techo \"Configuring pipeline for $sensor in $format\"\n+\n+\t$mediactl -r\n+\n+\t$mediactl -l \"\\\"$sensor\\\":0 -> \\\"$ipu3_csi2\\\":0[1]\"\n+\t$mediactl -l \"\\\"$ipu3_csi2\\\":1 -> \\\"$ipu3_capture\\\":0[1]\"\n+\n+\t$mediactl -V \"\\\"$sensor\\\":0 [$format]\"\n+\t$mediactl -V \"\\\"$ipu3_csi2\\\":1 [$format]\"\n+}\n+\n+# Capture frames\n+capture_frames() {\n+\tlocal file_op\n+\tlocal frame_count=$1\n+\tlocal ipu3_format=IPU3_${bus_format/_1X10/}\n+\tlocal save_file=$2\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 $ipu3_format -s $sensor_size $file_op \\\n+\t\t$($mediactl -e \"$ipu3_capture\")\n+}\n+\n+# Convert captured files to ppm\n+convert_files() {\n+\tlocal frame_count=$1\n+\tlocal format=${bus_format/_1X10/}\n+\tlocal padded_width=$(expr \\( $sensor_width + 49 \\) / 50 \\* 50)\n+\n+\techo \"Converting ${sensor_width}x${sensor_height} (${padded_width}x${sensor_height})\"\n+\n+\tfor i in `seq -f '%06.0f' 0 $(($frame_count - 1))`; do\n+\t\tipu3-unpack /tmp/frame-$i.bin /tmp/frame-$i.raw\n+\t\traw2pnm -x$padded_width -y$sensor_height -f$format /tmp/frame-$i.raw /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+}\n+\n+# Parse command line arguments\n+frame_count=10\n+save_file=1\n+\n+while (( \"$#\" )) ; 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+\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 [ $# != 1 ] ; then\n+\tusage $0\n+\texit 1\n+fi\n+\n+sensor_name=$1\n+\n+sensor=$(find_sensor $sensor_name)\n+mdev=$(find_media_device)\n+\n+mediactl=\"media-ctl -d $mdev\"\n+\n+parse_pipeline $sensor\n+configure_pipeline\n+capture_frames $frame_count $save_file\n+[[ $save_file -eq 1 ]] && convert_files $frame_count\n",
    "prefixes": [
        "libcamera-devel"
    ]
}