Show a patch.

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

{
    "id": 1288,
    "url": "https://patchwork.libcamera.org/api/patches/1288/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/1288/",
    "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": "<20190524162139.4446-4-jacopo@jmondi.org>",
    "date": "2019-05-24T16:21:36",
    "name": "[libcamera-devel,3/6] libcamera: v4l2_device: Add META support in g/s_fmt",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": false,
    "hash": "a2e4038f267c590213d9f7826fe1a55cd825d695",
    "submitter": {
        "id": 3,
        "url": "https://patchwork.libcamera.org/api/people/3/?format=api",
        "name": "Jacopo Mondi",
        "email": "jacopo@jmondi.org"
    },
    "delegate": null,
    "mbox": "https://patchwork.libcamera.org/patch/1288/mbox/",
    "series": [
        {
            "id": 326,
            "url": "https://patchwork.libcamera.org/api/series/326/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=326",
            "date": "2019-05-24T16:21:33",
            "name": "META_OUTPUT support + IPU3 parameters tuning",
            "version": 1,
            "mbox": "https://patchwork.libcamera.org/series/326/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/1288/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/1288/checks/",
    "tags": {},
    "headers": {
        "Return-Path": "<jacopo@jmondi.org>",
        "Received": [
            "from relay1-d.mail.gandi.net (relay1-d.mail.gandi.net\n\t[217.70.183.193])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id ACD1861865\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 24 May 2019 18:20:40 +0200 (CEST)",
            "from uno.lan (2-224-242-101.ip172.fastwebnet.it [2.224.242.101])\n\t(Authenticated sender: jacopo@jmondi.org)\n\tby relay1-d.mail.gandi.net (Postfix) with ESMTPSA id 4595024000A;\n\tFri, 24 May 2019 16:20:39 +0000 (UTC)"
        ],
        "X-Originating-IP": "2.224.242.101",
        "From": "Jacopo Mondi <jacopo@jmondi.org>",
        "To": "libcamera-devel@lists.libcamera.org",
        "Date": "Fri, 24 May 2019 18:21:36 +0200",
        "Message-Id": "<20190524162139.4446-4-jacopo@jmondi.org>",
        "X-Mailer": "git-send-email 2.21.0",
        "In-Reply-To": "<20190524162139.4446-1-jacopo@jmondi.org>",
        "References": "<20190524162139.4446-1-jacopo@jmondi.org>",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "Subject": "[libcamera-devel] [PATCH 3/6] libcamera: v4l2_device: Add META\n\tsupport in g/s_fmt",
        "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": "Fri, 24 May 2019 16:20:40 -0000"
    },
    "content": "Add two operations to set and get format on devices implementing the\nV4L2 Metadata Interface, identified by the META_OUTPUT or META_CAPTURE\ncapabilities.\n\nWhile at it, sort get/setFormat operations alphabetically and unify\ntheir style (eg. no empty line before ioctl).\n\nSigned-off-by: Jacopo Mondi <jacopo@jmondi.org>\n---\n src/libcamera/include/v4l2_device.h |   7 +-\n src/libcamera/v4l2_device.cpp       | 110 +++++++++++++++++++++-------\n 2 files changed, 89 insertions(+), 28 deletions(-)",
    "diff": "diff --git a/src/libcamera/include/v4l2_device.h b/src/libcamera/include/v4l2_device.h\nindex cecafa151caa..bdecc087fe5a 100644\n--- a/src/libcamera/include/v4l2_device.h\n+++ b/src/libcamera/include/v4l2_device.h\n@@ -150,12 +150,15 @@ protected:\n \tstd::string logPrefix() const;\n \n private:\n-\tint getFormatSingleplane(V4L2DeviceFormat *format);\n-\tint setFormatSingleplane(V4L2DeviceFormat *format);\n+\tint getFormatMeta(V4L2DeviceFormat *format);\n+\tint setFormatMeta(V4L2DeviceFormat *format);\n \n \tint getFormatMultiplane(V4L2DeviceFormat *format);\n \tint setFormatMultiplane(V4L2DeviceFormat *format);\n \n+\tint getFormatSingleplane(V4L2DeviceFormat *format);\n+\tint setFormatSingleplane(V4L2DeviceFormat *format);\n+\n \tint requestBuffers(unsigned int count);\n \tint createPlane(Buffer *buffer, unsigned int plane,\n \t\t\tunsigned int length);\ndiff --git a/src/libcamera/v4l2_device.cpp b/src/libcamera/v4l2_device.cpp\nindex e42f6ef0c340..789f76b0f69f 100644\n--- a/src/libcamera/v4l2_device.cpp\n+++ b/src/libcamera/v4l2_device.cpp\n@@ -428,8 +428,12 @@ std::string V4L2Device::logPrefix() const\n  */\n int V4L2Device::getFormat(V4L2DeviceFormat *format)\n {\n-\treturn caps_.isMultiplanar() ? getFormatMultiplane(format) :\n-\t\t\t\t       getFormatSingleplane(format);\n+\tif (caps_.isMeta())\n+\t\treturn getFormatMeta(format);\n+\tif (caps_.isMultiplanar())\n+\t\treturn getFormatMultiplane(format);\n+\telse\n+\t\treturn getFormatSingleplane(format);\n }\n \n /**\n@@ -443,14 +447,18 @@ int V4L2Device::getFormat(V4L2DeviceFormat *format)\n  */\n int V4L2Device::setFormat(V4L2DeviceFormat *format)\n {\n-\treturn caps_.isMultiplanar() ? setFormatMultiplane(format) :\n-\t\t\t\t       setFormatSingleplane(format);\n+\tif (caps_.isMeta())\n+\t\treturn setFormatMeta(format);\n+\tif (caps_.isMultiplanar())\n+\t\treturn setFormatMultiplane(format);\n+\telse\n+\t\treturn setFormatSingleplane(format);\n }\n \n-int V4L2Device::getFormatSingleplane(V4L2DeviceFormat *format)\n+int V4L2Device::getFormatMeta(V4L2DeviceFormat *format)\n {\n \tstruct v4l2_format v4l2Format = {};\n-\tstruct v4l2_pix_format *pix = &v4l2Format.fmt.pix;\n+\tstruct v4l2_meta_format *pix = &v4l2Format.fmt.meta;\n \tint ret;\n \n \tv4l2Format.type = bufferType_;\n@@ -461,29 +469,24 @@ int V4L2Device::getFormatSingleplane(V4L2DeviceFormat *format)\n \t\treturn ret;\n \t}\n \n-\tformat->size.width = pix->width;\n-\tformat->size.height = pix->height;\n-\tformat->fourcc = pix->pixelformat;\n+\tformat->size.width = pix->buffersize;\n+\tformat->size.height = 1;\n+\tformat->fourcc = pix->dataformat;\n \tformat->planesCount = 1;\n-\tformat->planes[0].bpl = pix->bytesperline;\n-\tformat->planes[0].size = pix->sizeimage;\n+\tformat->planes[0].bpl = pix->buffersize;\n+\tformat->planes[0].size = pix->buffersize;\n \n \treturn 0;\n }\n \n-int V4L2Device::setFormatSingleplane(V4L2DeviceFormat *format)\n+int V4L2Device::setFormatMeta(V4L2DeviceFormat *format)\n {\n \tstruct v4l2_format v4l2Format = {};\n-\tstruct v4l2_pix_format *pix = &v4l2Format.fmt.pix;\n+\tstruct v4l2_meta_format *pix = &v4l2Format.fmt.meta;\n \tint ret;\n \n \tv4l2Format.type = bufferType_;\n-\tpix->width = format->size.width;\n-\tpix->height = format->size.height;\n-\tpix->pixelformat = format->fourcc;\n-\tpix->bytesperline = format->planes[0].bpl;\n-\tpix->field = V4L2_FIELD_NONE;\n-\n+\tpix->dataformat = format->fourcc;\n \tret = ioctl(fd_, VIDIOC_S_FMT, &v4l2Format);\n \tif (ret) {\n \t\tret = -errno;\n@@ -495,12 +498,12 @@ int V4L2Device::setFormatSingleplane(V4L2DeviceFormat *format)\n \t * Return to caller the format actually applied on the device,\n \t * which might differ from the requested one.\n \t */\n-\tformat->size.width = pix->width;\n-\tformat->size.height = pix->height;\n-\tformat->fourcc = pix->pixelformat;\n+\tformat->size.width = pix->buffersize;\n+\tformat->size.height = 1;\n+\tformat->fourcc = format->fourcc;\n \tformat->planesCount = 1;\n-\tformat->planes[0].bpl = pix->bytesperline;\n-\tformat->planes[0].size = pix->sizeimage;\n+\tformat->planes[0].bpl = pix->buffersize;\n+\tformat->planes[0].size = pix->buffersize;\n \n \treturn 0;\n }\n@@ -523,7 +526,6 @@ int V4L2Device::getFormatMultiplane(V4L2DeviceFormat *format)\n \tformat->size.height = pix->height;\n \tformat->fourcc = pix->pixelformat;\n \tformat->planesCount = pix->num_planes;\n-\n \tfor (unsigned int i = 0; i < format->planesCount; ++i) {\n \t\tformat->planes[i].bpl = pix->plane_fmt[i].bytesperline;\n \t\tformat->planes[i].size = pix->plane_fmt[i].sizeimage;\n@@ -544,7 +546,6 @@ int V4L2Device::setFormatMultiplane(V4L2DeviceFormat *format)\n \tpix->pixelformat = format->fourcc;\n \tpix->num_planes = format->planesCount;\n \tpix->field = V4L2_FIELD_NONE;\n-\n \tfor (unsigned int i = 0; i < pix->num_planes; ++i) {\n \t\tpix->plane_fmt[i].bytesperline = format->planes[i].bpl;\n \t\tpix->plane_fmt[i].sizeimage = format->planes[i].size;\n@@ -573,6 +574,63 @@ int V4L2Device::setFormatMultiplane(V4L2DeviceFormat *format)\n \treturn 0;\n }\n \n+int V4L2Device::getFormatSingleplane(V4L2DeviceFormat *format)\n+{\n+\tstruct v4l2_format v4l2Format = {};\n+\tstruct v4l2_pix_format *pix = &v4l2Format.fmt.pix;\n+\tint ret;\n+\n+\tv4l2Format.type = bufferType_;\n+\tret = ioctl(fd_, VIDIOC_G_FMT, &v4l2Format);\n+\tif (ret) {\n+\t\tret = -errno;\n+\t\tLOG(V4L2, Error) << \"Unable to get format: \" << strerror(-ret);\n+\t\treturn ret;\n+\t}\n+\n+\tformat->size.width = pix->width;\n+\tformat->size.height = pix->height;\n+\tformat->fourcc = pix->pixelformat;\n+\tformat->planesCount = 1;\n+\tformat->planes[0].bpl = pix->bytesperline;\n+\tformat->planes[0].size = pix->sizeimage;\n+\n+\treturn 0;\n+}\n+\n+int V4L2Device::setFormatSingleplane(V4L2DeviceFormat *format)\n+{\n+\tstruct v4l2_format v4l2Format = {};\n+\tstruct v4l2_pix_format *pix = &v4l2Format.fmt.pix;\n+\tint ret;\n+\n+\tv4l2Format.type = bufferType_;\n+\tpix->width = format->size.width;\n+\tpix->height = format->size.height;\n+\tpix->pixelformat = format->fourcc;\n+\tpix->bytesperline = format->planes[0].bpl;\n+\tpix->field = V4L2_FIELD_NONE;\n+\tret = ioctl(fd_, VIDIOC_S_FMT, &v4l2Format);\n+\tif (ret) {\n+\t\tret = -errno;\n+\t\tLOG(V4L2, Error) << \"Unable to set format: \" << strerror(-ret);\n+\t\treturn ret;\n+\t}\n+\n+\t/*\n+\t * Return to caller the format actually applied on the device,\n+\t * which might differ from the requested one.\n+\t */\n+\tformat->size.width = pix->width;\n+\tformat->size.height = pix->height;\n+\tformat->fourcc = pix->pixelformat;\n+\tformat->planesCount = 1;\n+\tformat->planes[0].bpl = pix->bytesperline;\n+\tformat->planes[0].size = pix->sizeimage;\n+\n+\treturn 0;\n+}\n+\n int V4L2Device::requestBuffers(unsigned int count)\n {\n \tstruct v4l2_requestbuffers rb = {};\n",
    "prefixes": [
        "libcamera-devel",
        "3/6"
    ]
}