Show a patch.

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

{
    "id": 539,
    "url": "https://patchwork.libcamera.org/api/1.1/patches/539/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/539/",
    "project": {
        "id": 1,
        "url": "https://patchwork.libcamera.org/api/1.1/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": "<20190206060818.13907-25-laurent.pinchart@ideasonboard.com>",
    "date": "2019-02-06T06:08:15",
    "name": "[libcamera-devel,24/27] libcamera: pipeline: ipu3: Implement capture support",
    "commit_ref": null,
    "pull_url": null,
    "state": "accepted",
    "archived": false,
    "hash": "77c19b45d8c7a7ed26e1cf42d4ddab510f4bb3bb",
    "submitter": {
        "id": 2,
        "url": "https://patchwork.libcamera.org/api/1.1/people/2/?format=api",
        "name": "Laurent Pinchart",
        "email": "laurent.pinchart@ideasonboard.com"
    },
    "delegate": null,
    "mbox": "https://patchwork.libcamera.org/patch/539/mbox/",
    "series": [
        {
            "id": 170,
            "url": "https://patchwork.libcamera.org/api/1.1/series/170/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=170",
            "date": "2019-02-06T06:07:51",
            "name": "Capture frames throught requests",
            "version": 1,
            "mbox": "https://patchwork.libcamera.org/series/170/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/539/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/539/checks/",
    "tags": {},
    "headers": {
        "Return-Path": "<laurent.pinchart@ideasonboard.com>",
        "Received": [
            "from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 4C84A6102E\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed,  6 Feb 2019 07:08:29 +0100 (CET)",
            "from pendragon.ideasonboard.com (d51A4137F.access.telenet.be\n\t[81.164.19.127])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id EA75D2D8\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed,  6 Feb 2019 07:08:28 +0100 (CET)"
        ],
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1549433309;\n\tbh=MDucwjuFwsuJIjZgyjkqHrLzRxfhWJSMRbAeJMD74Pw=;\n\th=From:To:Subject:Date:In-Reply-To:References:From;\n\tb=oiv0D6Z0feX72kirK/N23RIFNUJaxLztgZ1c3qC+RbRnuvLZct0TYW/a7n4XeLSpQ\n\tOunr+jBMcec/A1GPO4duXstrLQmNSVQQdKXvF5uI80G0M+7IjIoWUHHVukVFIGifvR\n\t6k+fq0KPop98a8z6ZUWDnzKVgs7kgBW4aac2YZQU=",
        "From": "Laurent Pinchart <laurent.pinchart@ideasonboard.com>",
        "To": "libcamera-devel@lists.libcamera.org",
        "Date": "Wed,  6 Feb 2019 08:08:15 +0200",
        "Message-Id": "<20190206060818.13907-25-laurent.pinchart@ideasonboard.com>",
        "X-Mailer": "git-send-email 2.19.2",
        "In-Reply-To": "<20190206060818.13907-1-laurent.pinchart@ideasonboard.com>",
        "References": "<20190206060818.13907-1-laurent.pinchart@ideasonboard.com>",
        "MIME-Version": "1.0",
        "Content-Type": "text/plain; charset=UTF-8",
        "Content-Transfer-Encoding": "8bit",
        "Subject": "[libcamera-devel] [PATCH 24/27] libcamera: pipeline: ipu3:\n\tImplement capture support",
        "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, 06 Feb 2019 06:08:30 -0000"
    },
    "content": "From: Jacopo Mondi <jacopo@jmondi.org>\n\nReplace the buffer allocation, capture start/stop and request queue\nstubs with real implementations.\n\nSigned-off-by: Jacopo Mondi <jacopo@jmondi.org>\nReviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>\nReviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\nSigned-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n---\n src/libcamera/pipeline/ipu3/ipu3.cpp | 123 +++++++++++++++++++++++++--\n 1 file changed, 114 insertions(+), 9 deletions(-)",
    "diff": "diff --git a/src/libcamera/pipeline/ipu3/ipu3.cpp b/src/libcamera/pipeline/ipu3/ipu3.cpp\nindex 9629057a1b2f..34b03995ae31 100644\n--- a/src/libcamera/pipeline/ipu3/ipu3.cpp\n+++ b/src/libcamera/pipeline/ipu3/ipu3.cpp\n@@ -9,6 +9,7 @@\n #include <vector>\n \n #include <libcamera/camera.h>\n+#include <libcamera/request.h>\n #include <libcamera/stream.h>\n \n #include \"device_enumerator.h\"\n@@ -97,12 +98,23 @@ PipelineHandlerIPU3::streamConfiguration(Camera *camera,\n \t\t\t\t\t std::vector<Stream *> &streams)\n {\n \tIPU3CameraData *data = cameraData(camera);\n-\n \tstd::map<Stream *, StreamConfiguration> configs;\n+\tV4L2SubdeviceFormat format = {};\n \n-\tStreamConfiguration config{};\n+\t/*\n+\t * FIXME: As of now, return the image format reported by the sensor.\n+\t * In future good defaults should be provided for each stream.\n+\t */\n+\tif (data->sensor_->getFormat(0, &format)) {\n+\t\tLOG(IPU3, Error) << \"Failed to create stream configurations\";\n+\t\treturn configs;\n+\t}\n \n-\tLOG(IPU3, Info) << \"TODO: Return a good default format\";\n+\tStreamConfiguration config = {};\n+\tconfig.width = format.width;\n+\tconfig.height = format.height;\n+\tconfig.pixelFormat = V4L2_PIX_FMT_IPU3_SGRBG10;\n+\tconfig.bufferCount = 4;\n \n \tconfigs[&data->stream_] = config;\n \n@@ -113,38 +125,131 @@ int PipelineHandlerIPU3::configureStreams(Camera *camera,\n \t\t\t\t\t  std::map<Stream *, StreamConfiguration> &config)\n {\n \tIPU3CameraData *data = cameraData(camera);\n-\n \tStreamConfiguration *cfg = &config[&data->stream_];\n+\tV4L2Subdevice *sensor = data->sensor_;\n+\tV4L2Subdevice *csi2 = data->csi2_;\n+\tV4L2Device *cio2 = data->cio2_;\n+\tV4L2SubdeviceFormat subdevFormat = {};\n+\tV4L2DeviceFormat devFormat = {};\n+\tint ret;\n \n-\tLOG(IPU3, Info) << \"TODO: Configure the camera for resolution \"\n-\t\t\t<< cfg->width << \"x\" << cfg->height;\n+\t/*\n+\t * FIXME: as of now, the format gets applied to the sensor and is\n+\t * propagated along the pipeline. It should instead be applied on the\n+\t * capture device and the sensor format calculated accordingly.\n+\t */\n+\n+\tret = sensor->getFormat(0, &subdevFormat);\n+\tif (ret)\n+\t\treturn ret;\n+\n+\tsubdevFormat.width = cfg->width;\n+\tsubdevFormat.height = cfg->height;\n+\tret = sensor->setFormat(0, &subdevFormat);\n+\tif (ret)\n+\t\treturn ret;\n+\n+\t/* Return error if the requested format cannot be applied to sensor. */\n+\tif (subdevFormat.width != cfg->width ||\n+\t    subdevFormat.height != cfg->height) {\n+\t\tLOG(IPU3, Error)\n+\t\t\t<< \"Failed to apply image format \"\n+\t\t\t<< subdevFormat.width << \"x\" << subdevFormat.height\n+\t\t\t<< \" - got: \" << cfg->width << \"x\" << cfg->height;\n+\t\treturn -EINVAL;\n+\t}\n+\n+\tret = csi2->setFormat(0, &subdevFormat);\n+\tif (ret)\n+\t\treturn ret;\n+\n+\tret = cio2->getFormat(&devFormat);\n+\tif (ret)\n+\t\treturn ret;\n+\n+\tdevFormat.width = subdevFormat.width;\n+\tdevFormat.height = subdevFormat.height;\n+\tdevFormat.fourcc = cfg->pixelFormat;\n+\n+\tret = cio2->setFormat(&devFormat);\n+\tif (ret)\n+\t\treturn ret;\n+\n+\tLOG(IPU3, Info) << cio2->driverName() << \": \"\n+\t\t\t<< devFormat.width << \"x\" << devFormat.height\n+\t\t\t<< \"- 0x\" << std::hex << devFormat.fourcc << \" planes: \"\n+\t\t\t<< devFormat.planes;\n \n \treturn 0;\n }\n \n int PipelineHandlerIPU3::allocateBuffers(Camera *camera, Stream *stream)\n {\n-\treturn -ENOTRECOVERABLE;\n+\tIPU3CameraData *data = cameraData(camera);\n+\tconst StreamConfiguration &cfg = stream->configuration();\n+\n+\tif (!cfg.bufferCount)\n+\t\treturn -EINVAL;\n+\n+\tint ret = data->cio2_->exportBuffers(cfg.bufferCount,\n+\t\t\t\t\t     &stream->bufferPool());\n+\tif (ret) {\n+\t\tLOG(IPU3, Error) << \"Failed to request memory\";\n+\t\treturn ret;\n+\t}\n+\n+\treturn 0;\n }\n \n int PipelineHandlerIPU3::freeBuffers(Camera *camera, Stream *stream)\n {\n+\tIPU3CameraData *data = cameraData(camera);\n+\n+\tint ret = data->cio2_->releaseBuffers();\n+\tif (ret) {\n+\t\tLOG(IPU3, Error) << \"Failed to release memory\";\n+\t\treturn ret;\n+\t}\n+\n \treturn 0;\n }\n \n int PipelineHandlerIPU3::start(const Camera *camera)\n {\n-\tLOG(IPU3, Error) << \"TODO: start camera\";\n+\tIPU3CameraData *data = cameraData(camera);\n+\tint ret;\n+\n+\tret = data->cio2_->streamOn();\n+\tif (ret) {\n+\t\tLOG(IPU3, Info) << \"Failed to start camera \" << camera->name();\n+\t\treturn ret;\n+\t}\n+\n \treturn 0;\n }\n \n void PipelineHandlerIPU3::stop(const Camera *camera)\n {\n-\tLOG(IPU3, Error) << \"TODO: stop camera\";\n+\tIPU3CameraData *data = cameraData(camera);\n+\n+\tif (data->cio2_->streamOff())\n+\t\tLOG(IPU3, Info) << \"Failed to stop camera \" << camera->name();\n }\n \n int PipelineHandlerIPU3::queueRequest(const Camera *camera, Request *request)\n {\n+\tIPU3CameraData *data = cameraData(camera);\n+\tStream *stream = &data->stream_;\n+\n+\tBuffer *buffer = request->findBuffer(stream);\n+\tif (!buffer) {\n+\t\tLOG(IPU3, Error)\n+\t\t\t<< \"Attempt to queue request with invalid stream\";\n+\t\treturn -ENOENT;\n+\t}\n+\n+\tdata->cio2_->queueBuffer(buffer);\n+\n \treturn 0;\n }\n \n",
    "prefixes": [
        "libcamera-devel",
        "24/27"
    ]
}