Show a patch.

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

{
    "id": 655,
    "url": "https://patchwork.libcamera.org/api/patches/655/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/655/",
    "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": "<20190228162913.6508-3-laurent.pinchart@ideasonboard.com>",
    "date": "2019-02-28T16:29:05",
    "name": "[libcamera-devel,02/10] libcamera: pipeline: uvcvideo: Create UVCCameraData",
    "commit_ref": null,
    "pull_url": null,
    "state": "accepted",
    "archived": false,
    "hash": "40c4fcfd917c51a161f5939f558062ee77ac3aa6",
    "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/655/mbox/",
    "series": [
        {
            "id": 196,
            "url": "https://patchwork.libcamera.org/api/series/196/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=196",
            "date": "2019-02-28T16:29:03",
            "name": "Rework request completion handling",
            "version": 1,
            "mbox": "https://patchwork.libcamera.org/series/196/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/655/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/655/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 8CBEE610B6\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 28 Feb 2019 17:29:25 +0100 (CET)",
            "from pendragon.bb.dnainternet.fi (81-175-216-236.bb.dnainternet.fi\n\t[81.175.216.236])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 1ABF349\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 28 Feb 2019 17:29:25 +0100 (CET)"
        ],
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1551371365;\n\tbh=7FvWZq179Oj/YrYcO2feox0TvkwfyhVFEakflXYIuUM=;\n\th=From:To:Subject:Date:In-Reply-To:References:From;\n\tb=G+0+/CjZi3itgwHc9gRc3BDojj8kukj+cvmK65JIVydpZGIdontrWTt+EbBVCNmef\n\txGu561UXf8chutohU7RD6VvB7VYprOUO+Js+5MGXMHHWdt+0KP2Ljr3+R7vhHOlV+6\n\tkB6bLn4lXIeIcihA4gzCNcRavG0GHkD1YqF9RYEM=",
        "From": "Laurent Pinchart <laurent.pinchart@ideasonboard.com>",
        "To": "libcamera-devel@lists.libcamera.org",
        "Date": "Thu, 28 Feb 2019 18:29:05 +0200",
        "Message-Id": "<20190228162913.6508-3-laurent.pinchart@ideasonboard.com>",
        "X-Mailer": "git-send-email 2.19.2",
        "In-Reply-To": "<20190228162913.6508-1-laurent.pinchart@ideasonboard.com>",
        "References": "<20190228162913.6508-1-laurent.pinchart@ideasonboard.com>",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "Subject": "[libcamera-devel] [PATCH 02/10] libcamera: pipeline: uvcvideo:\n\tCreate UVCCameraData",
        "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": "Thu, 28 Feb 2019 16:29:25 -0000"
    },
    "content": "Subclassing CameraData will become mandatory for pipeline handlers.\nCreate a new UVCCameraData class and instantiate it when creating\ncameras to prepare for that change. The video_ and stream_ fields of the\nUVC pipeline handler belong to the camera data, move them there.\n\nSigned-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n---\n src/libcamera/pipeline/uvcvideo.cpp | 74 +++++++++++++++++++++--------\n 1 file changed, 53 insertions(+), 21 deletions(-)",
    "diff": "diff --git a/src/libcamera/pipeline/uvcvideo.cpp b/src/libcamera/pipeline/uvcvideo.cpp\nindex dd20bb085a29..4ad311163a95 100644\n--- a/src/libcamera/pipeline/uvcvideo.cpp\n+++ b/src/libcamera/pipeline/uvcvideo.cpp\n@@ -13,6 +13,7 @@\n #include \"log.h\"\n #include \"media_device.h\"\n #include \"pipeline_handler.h\"\n+#include \"utils.h\"\n #include \"v4l2_device.h\"\n \n namespace libcamera {\n@@ -42,21 +43,38 @@ public:\n \tbool match(DeviceEnumerator *enumerator);\n \n private:\n+\tclass UVCCameraData : public CameraData\n+\t{\n+\tpublic:\n+\t\tUVCCameraData()\n+\t\t{\n+\t\t}\n+\n+\t\t~UVCCameraData()\n+\t\t{\n+\t\t\tdelete video_;\n+\t\t}\n+\n+\t\tV4L2Device *video_;\n+\t\tStream stream_;\n+\t};\n+\n+\tUVCCameraData *cameraData(const Camera *camera)\n+\t{\n+\t\treturn static_cast<UVCCameraData *>(\n+\t\t\tPipelineHandler::cameraData(camera));\n+\t}\n+\n \tstd::shared_ptr<MediaDevice> media_;\n-\tV4L2Device *video_;\n-\tStream stream_;\n };\n \n PipelineHandlerUVC::PipelineHandlerUVC(CameraManager *manager)\n-\t: PipelineHandler(manager), media_(nullptr), video_(nullptr)\n+\t: PipelineHandler(manager), media_(nullptr)\n {\n }\n \n PipelineHandlerUVC::~PipelineHandlerUVC()\n {\n-\tif (video_)\n-\t\tdelete video_;\n-\n \tif (media_)\n \t\tmedia_->release();\n }\n@@ -65,8 +83,9 @@ std::map<Stream *, StreamConfiguration>\n PipelineHandlerUVC::streamConfiguration(Camera *camera,\n \t\t\t\t\tstd::vector<Stream *> &streams)\n {\n+\tUVCCameraData *data = cameraData(camera);\n+\n \tstd::map<Stream *, StreamConfiguration> configs;\n-\n \tStreamConfiguration config{};\n \n \tLOG(UVC, Debug) << \"Retrieving default format\";\n@@ -75,7 +94,7 @@ PipelineHandlerUVC::streamConfiguration(Camera *camera,\n \tconfig.pixelFormat = V4L2_PIX_FMT_YUYV;\n \tconfig.bufferCount = 4;\n \n-\tconfigs[&stream_] = config;\n+\tconfigs[&data->stream_] = config;\n \n \treturn configs;\n }\n@@ -83,7 +102,8 @@ PipelineHandlerUVC::streamConfiguration(Camera *camera,\n int PipelineHandlerUVC::configureStreams(Camera *camera,\n \t\t\t\t\t std::map<Stream *, StreamConfiguration> &config)\n {\n-\tStreamConfiguration *cfg = &config[&stream_];\n+\tUVCCameraData *data = cameraData(camera);\n+\tStreamConfiguration *cfg = &config[&data->stream_];\n \tint ret;\n \n \tLOG(UVC, Debug) << \"Configure the camera for resolution \"\n@@ -94,7 +114,7 @@ int PipelineHandlerUVC::configureStreams(Camera *camera,\n \tformat.height = cfg->height;\n \tformat.fourcc = cfg->pixelFormat;\n \n-\tret = video_->setFormat(&format);\n+\tret = data->video_->setFormat(&format);\n \tif (ret)\n \t\treturn ret;\n \n@@ -108,31 +128,36 @@ int PipelineHandlerUVC::configureStreams(Camera *camera,\n \n int PipelineHandlerUVC::allocateBuffers(Camera *camera, Stream *stream)\n {\n+\tUVCCameraData *data = cameraData(camera);\n \tconst StreamConfiguration &cfg = stream->configuration();\n \n \tLOG(UVC, Debug) << \"Requesting \" << cfg.bufferCount << \" buffers\";\n \n-\treturn video_->exportBuffers(&stream->bufferPool());\n+\treturn data->video_->exportBuffers(&stream->bufferPool());\n }\n \n int PipelineHandlerUVC::freeBuffers(Camera *camera, Stream *stream)\n {\n-\treturn video_->releaseBuffers();\n+\tUVCCameraData *data = cameraData(camera);\n+\treturn data->video_->releaseBuffers();\n }\n \n int PipelineHandlerUVC::start(const Camera *camera)\n {\n-\treturn video_->streamOn();\n+\tUVCCameraData *data = cameraData(camera);\n+\treturn data->video_->streamOn();\n }\n \n void PipelineHandlerUVC::stop(const Camera *camera)\n {\n-\tvideo_->streamOff();\n+\tUVCCameraData *data = cameraData(camera);\n+\tdata->video_->streamOff();\n }\n \n int PipelineHandlerUVC::queueRequest(const Camera *camera, Request *request)\n {\n-\tBuffer *buffer = request->findBuffer(&stream_);\n+\tUVCCameraData *data = cameraData(camera);\n+\tBuffer *buffer = request->findBuffer(&data->stream_);\n \tif (!buffer) {\n \t\tLOG(UVC, Error)\n \t\t\t<< \"Attempt to queue request with invalid stream\";\n@@ -140,7 +165,7 @@ int PipelineHandlerUVC::queueRequest(const Camera *camera, Request *request)\n \t\treturn -ENOENT;\n \t}\n \n-\tvideo_->queueBuffer(buffer);\n+\tdata->video_->queueBuffer(buffer);\n \n \treturn 0;\n }\n@@ -150,29 +175,36 @@ bool PipelineHandlerUVC::match(DeviceEnumerator *enumerator)\n \tDeviceMatch dm(\"uvcvideo\");\n \n \tmedia_ = enumerator->search(dm);\n-\n \tif (!media_)\n \t\treturn false;\n \n \tmedia_->acquire();\n \n+\tstd::unique_ptr<UVCCameraData> data = utils::make_unique<UVCCameraData>();\n+\n+\t/* Locate and open the default video node. */\n \tfor (MediaEntity *entity : media_->entities()) {\n \t\tif (entity->flags() & MEDIA_ENT_FL_DEFAULT) {\n-\t\t\tvideo_ = new V4L2Device(entity);\n+\t\t\tdata->video_ = new V4L2Device(entity);\n \t\t\tbreak;\n \t\t}\n \t}\n \n-\tif (!video_ || video_->open()) {\n-\t\tif (!video_)\n+\tif (!data->video_ || data->video_->open()) {\n+\t\tif (!data->video_)\n \t\t\tLOG(UVC, Error) << \"Could not find a default video device\";\n \n \t\treturn false;\n \t}\n \n-\tstd::vector<Stream *> streams{ &stream_ };\n+\t/* Create and register the camera. */\n+\tstd::vector<Stream *> streams{ &data->stream_ };\n \tstd::shared_ptr<Camera> camera = Camera::create(this, media_->model(), streams);\n+\n+\tsetCameraData(camera.get(), std::move(data));\n \tregisterCamera(std::move(camera));\n+\n+\t/* Enable hot-unplug notifications. */\n \thotplugMediaDevice(media_.get());\n \n \treturn true;\n",
    "prefixes": [
        "libcamera-devel",
        "02/10"
    ]
}