{"id":17823,"url":"https://patchwork.libcamera.org/api/1.1/patches/17823/?format=json","web_url":"https://patchwork.libcamera.org/patch/17823/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/1.1/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":"<20221121154421.11732-2-david.plowman@raspberrypi.com>","date":"2022-11-21T15:44:17","name":"[libcamera-devel,v2,1/5] libcamera: bayer_format: Add toMbusCode method","commit_ref":null,"pull_url":null,"state":"new","archived":false,"hash":"5258153d4d910cd765662ebbec681b3f06217f12","submitter":{"id":42,"url":"https://patchwork.libcamera.org/api/1.1/people/42/?format=json","name":"David Plowman","email":"david.plowman@raspberrypi.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/17823/mbox/","series":[{"id":3625,"url":"https://patchwork.libcamera.org/api/1.1/series/3625/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=3625","date":"2022-11-21T15:44:16","name":"Resolve invalid attempts to set sensor flip controls","version":2,"mbox":"https://patchwork.libcamera.org/series/3625/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/17823/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/17823/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 8BC74BE08B\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 21 Nov 2022 15:44:30 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 579A86331A;\n\tMon, 21 Nov 2022 16:44:30 +0100 (CET)","from mail-wr1-x42f.google.com (mail-wr1-x42f.google.com\n\t[IPv6:2a00:1450:4864:20::42f])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id CFD3E6331C\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 21 Nov 2022 16:44:27 +0100 (CET)","by mail-wr1-x42f.google.com with SMTP id s5so3250814wru.1\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 21 Nov 2022 07:44:27 -0800 (PST)","from pi4-davidp.pitowers.org\n\t([2a00:1098:3142:14:e4a2:3070:eea4:e434])\n\tby smtp.gmail.com with ESMTPSA id\n\tt11-20020adff60b000000b0022e035a4e93sm11742257wrp.87.2022.11.21.07.44.25\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tMon, 21 Nov 2022 07:44:26 -0800 (PST)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1669045470;\n\tbh=QeE2XrkMAXBq+xIM6/xevcr7Oh2p3OxWkukLjNSxJy0=;\n\th=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:\n\tFrom;\n\tb=dxA1cyVSg/zweQUFx+YYsoAgyVuf0v4nIJ3toXEg9Jcc23LEvKvxy7FaQrA3n8/F/\n\tksqlVOCPQj1kae8lnMf8DRK/Rdv9jmUR0amaPZlGx/IV50kUpbcSVDmsfWfRr54ca3\n\tml4zpMGGa3svUwSpUVrmxujN5f0dOf75TbB+HWlxUlHiHuWXOP1FyeZj8PLVFujiir\n\tQ8Yjd9+dVlki4VFeHBdJjRHqMDoF6MkmbruuwwgiL3J/gFg0Q1Np+rE3WDVE7e2SgC\n\tzxHVSTQKjfglFa6qkjeYMxZgtwNLn5Jf5tZUEjPJtvlJ5t9GEIBoUajKIDRXfedVHn\n\tK/yazX600qYng==","v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=raspberrypi.com; s=google;\n\th=content-transfer-encoding:mime-version:references:in-reply-to\n\t:message-id:date:subject:cc:to:from:from:to:cc:subject:date\n\t:message-id:reply-to;\n\tbh=sEHYM3NRf6pMdIrl/YwUGcydrfNxZgsax8Tl7eXR3Tw=;\n\tb=SehATThxw9vxrhAuyH7ysnmC28L3/sknBySspmz29B6DqXBQCaWXJTIFU7c2+Y7vKr\n\tg6jkQa6FZ8GPDEB/nERMAG14TXF7TH0TL7k94Oc5HZMcVUtV8kAvv5BuOngfKBxMgPEV\n\t2JLEjCxzpT9/02XmFM9Z/Q0noBFplJI3oynSlrXErJCYRdrbf9vk/FDiNWE4TDDyTakL\n\tezTe/EEEm+WQUj+FZPTlUwdW3I17GgWvJyjT9KX8aCyEi99WcntK8x4wDoMvFSubGVz/\n\tLttiR9gzxr7/CQs5kr964ohqDywX6F2ZpiIbyzREMIFDcd5v5b5JTaU4jflwxgMl2lwH\n\tWO8g=="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (2048-bit key; \n\tunprotected) header.d=raspberrypi.com\n\theader.i=@raspberrypi.com\n\theader.b=\"SehATThx\"; dkim-atps=neutral","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20210112;\n\th=content-transfer-encoding:mime-version:references:in-reply-to\n\t:message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc\n\t:subject:date:message-id:reply-to;\n\tbh=sEHYM3NRf6pMdIrl/YwUGcydrfNxZgsax8Tl7eXR3Tw=;\n\tb=4LuNeCJEE5QkxgIIrnrp/EMIwYX3SCqN5u3iFGbw+Kh5IwxsNWOQ1SmQFhVjtSfdFq\n\tiY3AXMuFvollExL1o5x0gN1Z35XL5Qza6xyHnNDlNbEuRQoQPeuNUo4Mu3KRDh0CogLx\n\tJJtAA8LnTPo8pDu5OO2F/zI+6Z2rtlN9IP2yLl2m8is4coGfeyY9MUB/vS6PFxZeFtDk\n\tnzwj7Ts4aTslCUsot66qXakWrBoHnuTNPjJ9QVcVbUFTgB1xgG9xa0kIzpO/HaRdcFHT\n\tDvxvcBKOSLbJmalW1hDbPVze7/SFUr/Y2UkCAmk31qofI0gtyFEd4iWT0Xnl+hpRch2b\n\tR+Kw==","X-Gm-Message-State":"ANoB5pmQ7VO4y+38Lzi/gsFTOMoTu5C0pMDhEPZ75nV39x6akM86vJ7T\n\tS8cQ9cup6ARenjtG2dGYo7xZl0pgAoxaJg==","X-Google-Smtp-Source":"AA0mqf6zQnJqzgf/nomMAwRoqEhDmCE+X6/J2RNtRHIuS3sHPGcjZNqD95LoFnKvoBz/TO93FmucYQ==","X-Received":"by 2002:adf:ebc6:0:b0:241:c6d8:be83 with SMTP id\n\tv6-20020adfebc6000000b00241c6d8be83mr3671748wrn.454.1669045466951; \n\tMon, 21 Nov 2022 07:44:26 -0800 (PST)","To":"libcamera-devel@lists.libcamera.org","Date":"Mon, 21 Nov 2022 15:44:17 +0000","Message-Id":"<20221121154421.11732-2-david.plowman@raspberrypi.com>","X-Mailer":"git-send-email 2.30.2","In-Reply-To":"<20221121154421.11732-1-david.plowman@raspberrypi.com>","References":"<20221121154421.11732-1-david.plowman@raspberrypi.com>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [PATCH v2 1/5] libcamera: bayer_format: Add\n\ttoMbusCode method","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>","From":"David Plowman via libcamera-devel <libcamera-devel@lists.libcamera.org>","Reply-To":"David Plowman <david.plowman@raspberrypi.com>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"},"content":"This makes it easier to perform transformations on Bayer type mbus\ncodes by converting them to a BayerFormat, doing the transform, and\nthen converting them back again.\n\nSigned-off-by: David Plowman <david.plowman@raspberrypi.com>\nReviewed-by: Jacopo Mondi <jacopo@jmondi.org>\n---\n include/libcamera/internal/bayer_format.h |  1 +\n src/libcamera/bayer_format.cpp            | 11 +++++++++++\n 2 files changed, 12 insertions(+)","diff":"diff --git a/include/libcamera/internal/bayer_format.h b/include/libcamera/internal/bayer_format.h\nindex 78ba3969..3601dccb 100644\n--- a/include/libcamera/internal/bayer_format.h\n+++ b/include/libcamera/internal/bayer_format.h\n@@ -47,6 +47,7 @@ public:\n \t}\n \n \tstatic const BayerFormat &fromMbusCode(unsigned int mbusCode);\n+\tunsigned int toMbusCode() const;\n \tbool isValid() const { return bitDepth != 0; }\n \n \tstd::string toString() const;\ndiff --git a/src/libcamera/bayer_format.cpp b/src/libcamera/bayer_format.cpp\nindex f27cc166..fdbc4af1 100644\n--- a/src/libcamera/bayer_format.cpp\n+++ b/src/libcamera/bayer_format.cpp\n@@ -226,6 +226,17 @@ const BayerFormat &BayerFormat::fromMbusCode(unsigned int mbusCode)\n \t\treturn it->second;\n }\n \n+/**\n+ * \\brief Retrieve the media bus code corresponding this this BayerFormat\n+ * \\return The corresponding media bus code, or zero if none was found\n+ */\n+unsigned int BayerFormat::toMbusCode() const\n+{\n+\tauto it = std::find_if(mbusCodeToBayer.begin(), mbusCodeToBayer.end(),\n+\t\t\t       [this](const auto &i) { return i.second == *this; });\n+\treturn it != mbusCodeToBayer.end() ? it->first : 0;\n+}\n+\n /**\n  * \\fn BayerFormat::isValid()\n  * \\brief Return whether a BayerFormat is valid\n","prefixes":["libcamera-devel","v2","1/5"]}