Show a patch.

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

{
    "id": 15338,
    "url": "https://patchwork.libcamera.org/api/1.1/patches/15338/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/15338/",
    "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": "<20220207150059.22515-1-ecurtin@redhat.com>",
    "date": "2022-02-07T15:00:59",
    "name": "[libcamera-devel,v2] cam: kms_sink: Remove limitation that camera and display must match",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": false,
    "hash": "33b434d48247f94400ec492e7be11c0769085f39",
    "submitter": {
        "id": 101,
        "url": "https://patchwork.libcamera.org/api/1.1/people/101/?format=api",
        "name": "Eric Curtin",
        "email": "ecurtin@redhat.com"
    },
    "delegate": null,
    "mbox": "https://patchwork.libcamera.org/patch/15338/mbox/",
    "series": [
        {
            "id": 2919,
            "url": "https://patchwork.libcamera.org/api/1.1/series/2919/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=2919",
            "date": "2022-02-07T15:00:59",
            "name": "[libcamera-devel,v2] cam: kms_sink: Remove limitation that camera and display must match",
            "version": 2,
            "mbox": "https://patchwork.libcamera.org/series/2919/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/15338/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/15338/checks/",
    "tags": {},
    "headers": {
        "Return-Path": "<libcamera-devel-bounces@lists.libcamera.org>",
        "X-Original-To": "parsemail@patchwork.libcamera.org",
        "Delivered-To": "parsemail@patchwork.libcamera.org",
        "Received": [
            "from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id F1DA7BDCBF\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon,  7 Feb 2022 15:01:22 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 18E1561070;\n\tMon,  7 Feb 2022 16:01:22 +0100 (CET)",
            "from us-smtp-delivery-124.mimecast.com\n\t(us-smtp-delivery-124.mimecast.com [170.10.133.124])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id A72C960E58\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon,  7 Feb 2022 16:01:19 +0100 (CET)",
            "from mail-wm1-f72.google.com (mail-wm1-f72.google.com\n\t[209.85.128.72]) by relay.mimecast.com with ESMTP with STARTTLS\n\t(version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id\n\tus-mta-650-6V6I3cOVN6KVxR2cNlBSIw-1; Mon, 07 Feb 2022 10:01:16 -0500",
            "by mail-wm1-f72.google.com with SMTP id\n\tl4-20020a05600c4f0400b0037bb2ce79d8so4089894wmq.9\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 07 Feb 2022 07:01:15 -0800 (PST)",
            "from p1.Home ([2001:8a0:6724:4500:a69c:e66f:828e:b340])\n\tby smtp.gmail.com with ESMTPSA id\n\tb2sm11112320wri.88.2022.02.07.07.01.13\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tMon, 07 Feb 2022 07:01:13 -0800 (PST)"
        ],
        "Authentication-Results": [
            "lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n\tunprotected) header.d=redhat.com header.i=@redhat.com\n\theader.b=\"YcGu80MM\"; dkim-atps=neutral",
            "relay.mimecast.com;\n\tauth=pass smtp.auth=CUSA124A263 smtp.mailfrom=ecurtin@redhat.com"
        ],
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com;\n\ts=mimecast20190719; t=1644246078;\n\th=from:from:reply-to:subject:subject:date:date:message-id:message-id:\n\tto:to:cc:cc:mime-version:mime-version:content-type:content-type:\n\tcontent-transfer-encoding:content-transfer-encoding;\n\tbh=+/ce/bTMCeXhfBG/CcISIXicWhiLJVLPvUfdMeodz2M=;\n\tb=YcGu80MML/VtK8115p+pFA3sf+vEg6AZGkVKhGbHaxpAjr8bhARIwQrOOuGAXhtSUuFmkB\n\tXgBlE+C4j7b7bvHFyCDRoKfpnMTBY4LsRjuK0m+bYhXG0JCGISTtAyqkdW5Tq+Fwp1M+Cc\n\tMvVoOmkGAIT+bchEKqctpQj9nnXJIeM=",
        "X-MC-Unique": "6V6I3cOVN6KVxR2cNlBSIw-1",
        "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20210112;\n\th=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version\n\t:content-transfer-encoding;\n\tbh=+/ce/bTMCeXhfBG/CcISIXicWhiLJVLPvUfdMeodz2M=;\n\tb=LNJcjvZ7uf7/ITWdpfshdmRdqTaSzNIsdyXyvfvERHnJZmczA2UFCIRxeC/ffmwAj+\n\tMP3zQB1qzZiwxZKWqZxxSTBvdRBMv+JPduPHJdqQNhZBSPjXoUxWQE3goVhh9MkNoF5f\n\tdIW8NKC+OUvC0qgkCRPjz31UKuQnahz4jAq+GLf3aVg8EMnGBVqm0QTpqvUWLx+poYJp\n\tlss/ov8ux2Vn8NQM9UNvVUUCusyNDs0JAyAHx6YtYUaNRcTbtIAd+UffDXnvvtBKSrqO\n\tGyDLvhlibNRaU0vbByUzOWw+hz/xGYsgvdxpgsqH9/OWyc70EFv3OEpb1o7+T9IWMQts\n\tOoCQ==",
        "X-Gm-Message-State": "AOAM532OUcNNIVJ1foRgt4D800tTTST1vZSirymKrOP4Ne5R0rG60P8Y\n\tN+fl0wlxqS0JITzqSeE0RV/auVsOmsIbVNMIt6RtP2WbGx83LgPgw4qPyXUQJZ8kThaLtYjwEhq\n\tEZMQwf547KIe5x4+Wc6pT/T2qNfHDvXDTnoQQr2KXU5eMofPcZEtSLf+gyOL//on0tznEzUq6he\n\txsid9Nf568",
        "X-Received": [
            "by 2002:adf:e0c9:: with SMTP id\n\tm9mr10026200wri.435.1644246074411; \n\tMon, 07 Feb 2022 07:01:14 -0800 (PST)",
            "by 2002:adf:e0c9:: with SMTP id\n\tm9mr10026177wri.435.1644246074133; \n\tMon, 07 Feb 2022 07:01:14 -0800 (PST)"
        ],
        "X-Google-Smtp-Source": "ABdhPJwsvSzRq76c0fr9OegFlqaCPxvQJt4Lc21TUGSYQm7LeXRtQjtOC09PIBYU33oEloam5HaQ/A==",
        "From": "Eric Curtin <ecurtin@redhat.com>",
        "To": "libcamera-devel@lists.libcamera.org",
        "Date": "Mon,  7 Feb 2022 15:00:59 +0000",
        "Message-Id": "<20220207150059.22515-1-ecurtin@redhat.com>",
        "X-Mailer": "git-send-email 2.34.1",
        "MIME-Version": "1.0",
        "X-Mimecast-Spam-Score": "0",
        "X-Mimecast-Originator": "redhat.com",
        "Content-Transfer-Encoding": "8bit",
        "Content-Type": "text/plain; charset=\"US-ASCII\"",
        "Subject": "[libcamera-devel] [PATCH v2] cam: kms_sink: Remove limitation that\n\tcamera and display must match",
        "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>",
        "Errors-To": "libcamera-devel-bounces@lists.libcamera.org",
        "Sender": "\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"
    },
    "content": "There is a limitation that requires input and output to be pixel\nfor pixel identical in terms of height and width. Remove this\nlimitation to enable more hardware that doesn't match exactly in\nterms of pixels. Centralize the image. This works for the case\nwhere camera output has more pixels than the display and\nvice-versa. In the case where there are too many pixels for the\ndisplay, we take the most central part of the image cropping out\nthe border.\n\nSigned-off-by: Eric Curtin <ecurtin@redhat.com>\n---\n\nChanges in v2:\n- Tested and support drawing from negative pixel range\n  kernel parameter (video=960x540@60) was useful here\n\n src/cam/kms_sink.cpp | 32 ++++++++++++++------------------\n src/cam/kms_sink.h   |  2 ++\n 2 files changed, 16 insertions(+), 18 deletions(-)",
    "diff": "diff --git a/src/cam/kms_sink.cpp b/src/cam/kms_sink.cpp\nindex 973cd370..8eb51454 100644\n--- a/src/cam/kms_sink.cpp\n+++ b/src/cam/kms_sink.cpp\n@@ -113,24 +113,20 @@ int KMSSink::configure(const libcamera::CameraConfiguration &config)\n \tconst libcamera::StreamConfiguration &cfg = config.at(0);\n \n \tconst std::vector<DRM::Mode> &modes = connector_->modes();\n-\tconst auto iter = std::find_if(modes.begin(), modes.end(),\n-\t\t\t\t       [&](const DRM::Mode &mode) {\n-\t\t\t\t\t       return mode.hdisplay == cfg.size.width &&\n-\t\t\t\t\t\t      mode.vdisplay == cfg.size.height;\n-\t\t\t\t       });\n-\tif (iter == modes.end()) {\n-\t\tstd::cerr\n-\t\t\t<< \"No mode matching \" << cfg.size.toString()\n-\t\t\t<< std::endl;\n-\t\treturn -EINVAL;\n-\t}\n \n \tint ret = configurePipeline(cfg.pixelFormat);\n \tif (ret < 0)\n \t\treturn ret;\n \n-\tmode_ = &*iter;\n+\tmode_ = &modes[0];\n \tsize_ = cfg.size;\n+\n+\t// We need to cast for the case where the camera output has more\n+\t// pixels than the display, in this case we start drawing from a\n+\t// negative pixel point to crop out the content to display just\n+\t// the middle part.\n+\tx_ = (mode_->hdisplay - static_cast<int>(size_.width)) / 2;\n+\ty_ = (mode_->vdisplay - static_cast<int>(size_.height)) / 2;\n \tstride_ = cfg.stride;\n \n \treturn 0;\n@@ -297,12 +293,12 @@ bool KMSSink::processRequest(libcamera::Request *camRequest)\n \t\tdrmRequest->addProperty(plane_, \"CRTC_ID\", crtc_->id());\n \t\tdrmRequest->addProperty(plane_, \"SRC_X\", 0 << 16);\n \t\tdrmRequest->addProperty(plane_, \"SRC_Y\", 0 << 16);\n-\t\tdrmRequest->addProperty(plane_, \"SRC_W\", mode_->hdisplay << 16);\n-\t\tdrmRequest->addProperty(plane_, \"SRC_H\", mode_->vdisplay << 16);\n-\t\tdrmRequest->addProperty(plane_, \"CRTC_X\", 0);\n-\t\tdrmRequest->addProperty(plane_, \"CRTC_Y\", 0);\n-\t\tdrmRequest->addProperty(plane_, \"CRTC_W\", mode_->hdisplay);\n-\t\tdrmRequest->addProperty(plane_, \"CRTC_H\", mode_->vdisplay);\n+\t\tdrmRequest->addProperty(plane_, \"SRC_W\", size_.width << 16);\n+\t\tdrmRequest->addProperty(plane_, \"SRC_H\", size_.height << 16);\n+\t\tdrmRequest->addProperty(plane_, \"CRTC_X\", x_);\n+\t\tdrmRequest->addProperty(plane_, \"CRTC_Y\", y_);\n+\t\tdrmRequest->addProperty(plane_, \"CRTC_W\", size_.width);\n+\t\tdrmRequest->addProperty(plane_, \"CRTC_H\", size_.height);\n \n \t\tflags |= DRM::AtomicRequest::FlagAllowModeset;\n \t}\ndiff --git a/src/cam/kms_sink.h b/src/cam/kms_sink.h\nindex 4a0a872c..2c16182c 100644\n--- a/src/cam/kms_sink.h\n+++ b/src/cam/kms_sink.h\n@@ -61,6 +61,8 @@ private:\n \tlibcamera::PixelFormat format_;\n \tlibcamera::Size size_;\n \tunsigned int stride_;\n+\tint x_;  // Where to start drawing camera output\n+\tint y_;  // Where to start drawing camera output\n \n \tstd::map<libcamera::FrameBuffer *, std::unique_ptr<DRM::FrameBuffer>> buffers_;\n \n",
    "prefixes": [
        "libcamera-devel",
        "v2"
    ]
}