Show a patch.

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

{
    "id": 2530,
    "url": "https://patchwork.libcamera.org/api/1.1/patches/2530/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/2530/",
    "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": "<20200108101725.6404-3-jacopo@jmondi.org>",
    "date": "2020-01-08T10:17:24",
    "name": "[libcamera-devel,v2,2/3] v4l2: camera_proxy: Break out try_fmt",
    "commit_ref": "fce110c6d961c3bb645289184c59d9443d56e224",
    "pull_url": null,
    "state": "accepted",
    "archived": false,
    "hash": "55855c5759e829bb14cb37320e29932c417575d3",
    "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/2530/mbox/",
    "series": [
        {
            "id": 609,
            "url": "https://patchwork.libcamera.org/api/1.1/series/609/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=609",
            "date": "2020-01-08T10:17:22",
            "name": "v4l2: minor fixes",
            "version": 2,
            "mbox": "https://patchwork.libcamera.org/series/609/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/2530/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/2530/checks/",
    "tags": {},
    "headers": {
        "Return-Path": "<jacopo@jmondi.org>",
        "Received": [
            "from relay11.mail.gandi.net (relay11.mail.gandi.net\n\t[217.70.178.231])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 3C59B60668\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed,  8 Jan 2020 11:15:08 +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 relay11.mail.gandi.net (Postfix) with ESMTPSA id 7FB77100010;\n\tWed,  8 Jan 2020 10:15:07 +0000 (UTC)"
        ],
        "From": "Jacopo Mondi <jacopo@jmondi.org>",
        "To": "libcamera-devel@lists.libcamera.org",
        "Date": "Wed,  8 Jan 2020 11:17:24 +0100",
        "Message-Id": "<20200108101725.6404-3-jacopo@jmondi.org>",
        "X-Mailer": "git-send-email 2.24.0",
        "In-Reply-To": "<20200108101725.6404-1-jacopo@jmondi.org>",
        "References": "<20200108101725.6404-1-jacopo@jmondi.org>",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "Subject": "[libcamera-devel] [PATCH v2 2/3] v4l2: camera_proxy: Break out\n\ttry_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": "Wed, 08 Jan 2020 10:15:08 -0000"
    },
    "content": "Calling vidioc_s_fmt() calls vidioc_try_fmt() duplicating prinouts.\n\nBreakout try format procedure and call it from both functions.\n\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\nSigned-off-by: Jacopo Mondi <jacopo@jmondi.org>\n---\n src/v4l2/v4l2_camera_proxy.cpp | 54 +++++++++++++++++++---------------\n src/v4l2/v4l2_camera_proxy.h   |  1 +\n 2 files changed, 31 insertions(+), 24 deletions(-)",
    "diff": "diff --git a/src/v4l2/v4l2_camera_proxy.cpp b/src/v4l2/v4l2_camera_proxy.cpp\nindex 0f1d5ea4be39..f3a49fea2a5a 100644\n--- a/src/v4l2/v4l2_camera_proxy.cpp\n+++ b/src/v4l2/v4l2_camera_proxy.cpp\n@@ -235,13 +235,39 @@ int V4L2CameraProxy::vidioc_g_fmt(struct v4l2_format *arg)\n \treturn 0;\n }\n \n+void V4L2CameraProxy::tryFormat(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 \n-\tint ret = vidioc_try_fmt(arg);\n-\tif (ret < 0)\n-\t\treturn ret;\n+\tif (!validateBufferType(arg->type))\n+\t\treturn -EINVAL;\n+\n+\ttryFormat(arg);\n \n \tSize size(arg->fmt.pix.width, arg->fmt.pix.height);\n \tret = vcam_->invokeMethod(&V4L2Camera::configure,\n@@ -269,27 +295,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+\ttryFormat(arg);\n \n \treturn 0;\n }\ndiff --git a/src/v4l2/v4l2_camera_proxy.h b/src/v4l2/v4l2_camera_proxy.h\nindex 3d702084f8ff..b59d19d70759 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 tryFormat(struct v4l2_format *arg);\n \tvoid updateBuffers();\n \tint freeBuffers();\n \n",
    "prefixes": [
        "libcamera-devel",
        "v2",
        "2/3"
    ]
}