{"id":3650,"url":"https://patchwork.libcamera.org/api/patches/3650/?format=json","web_url":"https://patchwork.libcamera.org/patch/3650/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/projects/1/?format=json","name":"libcamera","link_name":"libcamera","list_id":"libcamera_core","list_email":"libcamera-devel@lists.libcamera.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20200501151651.864358-1-jacopo@jmondi.org>","date":"2020-05-01T15:16:51","name":"[libcamera-devel] libcamera: vimc: Adjust crop rectangle","commit_ref":null,"pull_url":null,"state":"accepted","archived":false,"hash":"f15916502f28a6f0ed1b8d45ef5310b1e405e376","submitter":{"id":3,"url":"https://patchwork.libcamera.org/api/people/3/?format=json","name":"Jacopo Mondi","email":"jacopo@jmondi.org"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/3650/mbox/","series":[{"id":866,"url":"https://patchwork.libcamera.org/api/series/866/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=866","date":"2020-05-01T15:16:51","name":"[libcamera-devel] libcamera: vimc: Adjust crop rectangle","version":1,"mbox":"https://patchwork.libcamera.org/series/866/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/3650/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/3650/checks/","tags":{},"headers":{"Return-Path":"<jacopo@jmondi.org>","Received":["from relay8-d.mail.gandi.net (relay8-d.mail.gandi.net\n\t[217.70.183.201])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 8CEC6603F3\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri,  1 May 2020 17:13:46 +0200 (CEST)","from localhost.localdomain (2-224-242-101.ip172.fastwebnet.it\n\t[2.224.242.101]) (Authenticated sender: jacopo@jmondi.org)\n\tby relay8-d.mail.gandi.net (Postfix) with ESMTPSA id EF4C31BF204;\n\tFri,  1 May 2020 15:13:45 +0000 (UTC)"],"X-Originating-IP":"2.224.242.101","From":"Jacopo Mondi <jacopo@jmondi.org>","To":"libcamera-devel@lists.libcamera.org","Date":"Fri,  1 May 2020 17:16:51 +0200","Message-Id":"<20200501151651.864358-1-jacopo@jmondi.org>","X-Mailer":"git-send-email 2.26.1","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [PATCH] libcamera: vimc: Adjust crop rectangle","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":"Fri, 01 May 2020 15:13:46 -0000"},"content":"Since the Linux kernel commit:\n69e39d40587b (\"media: vimc: Implement get/set selection in sink\")\nthe crop rectangle on the VIMC scaler sink pad needs to be\nreset to match the requested format to avoid hitting a pipeline format\nmis-configurations when the applied format is larger than the one\nset in a previous capture session.\n\nAs the V4L2 specification is not clear on what the correct behaviour\nis, if the crop rectangle should be reset automatically or not on a\nset_fmt operation, momentary fix the pipeline handler to please the\ndriver and manually reset the crop rectangle.\n\nSigned-off-by: Jacopo Mondi <jacopo@jmondi.org>\n---\n\nTested on v5.6, please test on older kernel releases.\n\n---\n src/libcamera/pipeline/vimc/vimc.cpp | 10 ++++++++++\n 1 file changed, 10 insertions(+)\n\n--\n2.26.1","diff":"diff --git a/src/libcamera/pipeline/vimc/vimc.cpp b/src/libcamera/pipeline/vimc/vimc.cpp\nindex ccfd7f86d158..339d1cf653fb 100644\n--- a/src/libcamera/pipeline/vimc/vimc.cpp\n+++ b/src/libcamera/pipeline/vimc/vimc.cpp\n@@ -224,6 +224,16 @@ int PipelineHandlerVimc::configure(Camera *camera, CameraConfiguration *config)\n \tif (ret)\n \t\treturn ret;\n\n+\tRectangle crop = {\n+\t\t.x = 0,\n+\t\t.y = 0,\n+\t\t.width = subformat.size.width,\n+\t\t.height = subformat.size.height,\n+\t};\n+\tret = data->scaler_->setSelection(0, V4L2_SEL_TGT_CROP, &crop);\n+\tif (ret && ret != -ENOTTY)\n+\t\treturn ret;\n+\n \tsubformat.size = cfg.size;\n \tret = data->scaler_->setFormat(1, &subformat);\n \tif (ret)\n","prefixes":["libcamera-devel"]}