Show a patch.

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

{
    "id": 2524,
    "url": "https://patchwork.libcamera.org/api/1.1/patches/2524/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/2524/",
    "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": "<20200107165038.93041-3-jacopo@jmondi.org>",
    "date": "2020-01-07T16:50:38",
    "name": "[libcamera-devel,2/2] v4l2: camera_proxy: Break out try_fmt",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": false,
    "hash": "3e7f5d8b9c9987a35e8ee16c83ee2c4c59f429d5",
    "submitter": {
        "id": 3,
        "url": "https://patchwork.libcamera.org/api/1.1/people/3/?format=api",
        "name": "Jacopo Mondi",
        "email": "jacopo@jmondi.org"
    },
    "delegate": null,
    "mbox": "https://patchwork.libcamera.org/patch/2524/mbox/",
    "series": [
        {
            "id": 606,
            "url": "https://patchwork.libcamera.org/api/1.1/series/606/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=606",
            "date": "2020-01-07T16:50:36",
            "name": "v4l2: minor fixes",
            "version": 1,
            "mbox": "https://patchwork.libcamera.org/series/606/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/2524/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/2524/checks/",
    "tags": {},
    "headers": {
        "Return-Path": "<jacopo@jmondi.org>",
        "Received": [
            "from relay6-d.mail.gandi.net (relay6-d.mail.gandi.net\n\t[217.70.183.198])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 4051B60644\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue,  7 Jan 2020 17:48:21 +0100 (CET)",
            "from uno.lan (93-34-114-233.ip49.fastwebnet.it [93.34.114.233])\n\t(Authenticated sender: jacopo@jmondi.org)\n\tby relay6-d.mail.gandi.net (Postfix) with ESMTPSA id A420CC0006;\n\tTue,  7 Jan 2020 16:48:20 +0000 (UTC)"
        ],
        "X-Originating-IP": "93.34.114.233",
        "From": "Jacopo Mondi <jacopo@jmondi.org>",
        "To": "libcamera-devel@lists.libcamera.org",
        "Date": "Tue,  7 Jan 2020 17:50:38 +0100",
        "Message-Id": "<20200107165038.93041-3-jacopo@jmondi.org>",
        "X-Mailer": "git-send-email 2.24.0",
        "In-Reply-To": "<20200107165038.93041-1-jacopo@jmondi.org>",
        "References": "<20200107165038.93041-1-jacopo@jmondi.org>",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "Subject": "[libcamera-devel] [PATCH 2/2] v4l2: camera_proxy: Break out try_fmt",
        "X-BeenThere": "libcamera-devel@lists.libcamera.org",
        "X-Mailman-Version": "2.1.29",
        "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, 07 Jan 2020 16:48:22 -0000"
    },
    "content": "Calling vidioc_s_fmt() calls vidioc_try_fmt() duplicating prinouts.\n\nBreakout try format procedure and call it from both functions.\n\nSigned-off-by: Jacopo Mondi <jacopo@jmondi.org>\n---\n src/v4l2/v4l2_camera_proxy.cpp | 53 +++++++++++++++++++---------------\n src/v4l2/v4l2_camera_proxy.h   |  1 +\n 2 files changed, 30 insertions(+), 24 deletions(-)",
    "diff": "diff --git a/src/v4l2/v4l2_camera_proxy.cpp b/src/v4l2/v4l2_camera_proxy.cpp\nindex dbcf333a761f..a56318cb4fa3 100644\n--- a/src/v4l2/v4l2_camera_proxy.cpp\n+++ b/src/v4l2/v4l2_camera_proxy.cpp\n@@ -236,13 +236,38 @@ int V4L2CameraProxy::vidioc_g_fmt(struct v4l2_format *arg)\n \treturn 0;\n }\n \n+void V4L2CameraProxy::tryFmt(struct v4l2_format *arg)\n+{\n+\tPixelFormat format = v4l2ToDrm(arg->fmt.pix.pixelformat);\n+\tconst std::vector<PixelFormat> &formats =\n+\t\tstreamConfig_.formats().pixelformats();\n+\tif (std::find(formats.begin(), formats.end(), format) == formats.end())\n+\t\tformat = streamConfig_.formats().pixelformats()[0];\n+\n+\tSize size(arg->fmt.pix.width, arg->fmt.pix.height);\n+\tconst std::vector<Size> &sizes = streamConfig_.formats().sizes(format);\n+\tif (std::find(sizes.begin(), sizes.end(), size) == sizes.end())\n+\t\tsize = streamConfig_.formats().sizes(format)[0];\n+\n+\targ->fmt.pix.width        = size.width;\n+\targ->fmt.pix.height       = size.height;\n+\targ->fmt.pix.pixelformat  = drmToV4L2(format);\n+\targ->fmt.pix.field        = V4L2_FIELD_NONE;\n+\targ->fmt.pix.bytesperline = bplMultiplier(drmToV4L2(format)) *\n+\t\t\t\t    arg->fmt.pix.width;\n+\targ->fmt.pix.sizeimage    = imageSize(drmToV4L2(format),\n+\t\t\t\t\t      arg->fmt.pix.width,\n+\t\t\t\t\t      arg->fmt.pix.height);\n+\targ->fmt.pix.colorspace   = V4L2_COLORSPACE_SRGB;\n+}\n+\n int V4L2CameraProxy::vidioc_s_fmt(struct v4l2_format *arg)\n {\n \tLOG(V4L2Compat, Debug) << \"Servicing vidioc_s_fmt\";\n+\tif (!validateBufferType(arg->type))\n+\t\treturn -EINVAL;\n \n-\tint ret = vidioc_try_fmt(arg);\n-\tif (ret < 0)\n-\t\treturn ret;\n+\ttryFmt(arg);\n \n \tSize size(arg->fmt.pix.width, arg->fmt.pix.height);\n \tvcam_->invokeMethod(&V4L2Camera::configure, ConnectionTypeBlocking,\n@@ -268,27 +293,7 @@ int V4L2CameraProxy::vidioc_try_fmt(struct v4l2_format *arg)\n \tif (!validateBufferType(arg->type))\n \t\treturn -EINVAL;\n \n-\tPixelFormat format = v4l2ToDrm(arg->fmt.pix.pixelformat);\n-\tconst std::vector<PixelFormat> &formats =\n-\t\tstreamConfig_.formats().pixelformats();\n-\tif (std::find(formats.begin(), formats.end(), format) == formats.end())\n-\t\tformat = streamConfig_.formats().pixelformats()[0];\n-\n-\tSize size(arg->fmt.pix.width, arg->fmt.pix.height);\n-\tconst std::vector<Size> &sizes = streamConfig_.formats().sizes(format);\n-\tif (std::find(sizes.begin(), sizes.end(), size) == sizes.end())\n-\t\tsize = streamConfig_.formats().sizes(format)[0];\n-\n-\targ->fmt.pix.width        = size.width;\n-\targ->fmt.pix.height       = size.height;\n-\targ->fmt.pix.pixelformat  = drmToV4L2(format);\n-\targ->fmt.pix.field        = V4L2_FIELD_NONE;\n-\targ->fmt.pix.bytesperline = bplMultiplier(drmToV4L2(format)) *\n-\t\t\t\t    arg->fmt.pix.width;\n-\targ->fmt.pix.sizeimage    = imageSize(drmToV4L2(format),\n-\t\t\t\t\t      arg->fmt.pix.width,\n-\t\t\t\t\t      arg->fmt.pix.height);\n-\targ->fmt.pix.colorspace   = V4L2_COLORSPACE_SRGB;\n+\ttryFmt(arg);\n \n \treturn 0;\n }\ndiff --git a/src/v4l2/v4l2_camera_proxy.h b/src/v4l2/v4l2_camera_proxy.h\nindex bef0f0afab3b..d34de925cf29 100644\n--- a/src/v4l2/v4l2_camera_proxy.h\n+++ b/src/v4l2/v4l2_camera_proxy.h\n@@ -39,6 +39,7 @@ private:\n \tvoid setFmtFromConfig(StreamConfiguration &streamConfig);\n \tunsigned int calculateSizeImage(StreamConfiguration &streamConfig);\n \tvoid querycap(std::shared_ptr<Camera> camera);\n+\tvoid tryFmt(struct v4l2_format *arg);\n \tvoid updateBuffers();\n \tint freeBuffers();\n \n",
    "prefixes": [
        "libcamera-devel",
        "2/2"
    ]
}