{"id":8916,"url":"https://patchwork.libcamera.org/api/patches/8916/?format=json","web_url":"https://patchwork.libcamera.org/patch/8916/","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":"<20200722122543.119759-1-paul.elder@ideasonboard.com>","date":"2020-07-22T12:25:43","name":"[libcamera-devel,RFC,v2,DO,NOT,MERGE] IPA: raspberrypi: Sample IPA data structure IDL definition and output","commit_ref":null,"pull_url":null,"state":"superseded","archived":false,"hash":"ea117f3a7d9e1bc4ce8e02c7bc5abcc822a9f948","submitter":{"id":17,"url":"https://patchwork.libcamera.org/api/people/17/?format=json","name":"Paul Elder","email":"paul.elder@ideasonboard.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/8916/mbox/","series":[{"id":1126,"url":"https://patchwork.libcamera.org/api/series/1126/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=1126","date":"2020-07-22T12:25:43","name":"[libcamera-devel,RFC,v2,DO,NOT,MERGE] IPA: raspberrypi: Sample IPA data structure IDL definition and output","version":2,"mbox":"https://patchwork.libcamera.org/series/1126/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/8916/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/8916/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 720D7BDB1B\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed, 22 Jul 2020 12:26:00 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id E5B4D60983;\n\tWed, 22 Jul 2020 14:25:59 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 5DEF76053C\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 22 Jul 2020 14:25:58 +0200 (CEST)","from pyrite.rasen.tech (unknown\n\t[IPv6:2400:4051:61:600:2c71:1b79:d06d:5032])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id BE197329;\n\tWed, 22 Jul 2020 14:25:51 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"F8eXdXHE\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1595420753;\n\tbh=6w7Wbb7QigO4FFKun9TJOCHK77PZxDY9eCu5oRwoHVQ=;\n\th=From:To:Cc:Subject:Date:From;\n\tb=F8eXdXHEqQByx+G0WNzQygTnT4jZjDsB0zCWFloF1oAYJcpYR7fsVpbSuF1vvjAdP\n\twb4SkgygZ+wGSc8E+nBJRN/m7gBaZUBLVfspjAPuSGOZcPcrqk+8yWih2owRvEx6Bf\n\tZtHOhyLrniB5AtI+vY+q/GIXxIrSJqV+ePElyKbc=","From":"Paul Elder <paul.elder@ideasonboard.com>","To":"libcamera-devel@lists.libcamera.org","Date":"Wed, 22 Jul 2020 21:25:43 +0900","Message-Id":"<20200722122543.119759-1-paul.elder@ideasonboard.com>","X-Mailer":"git-send-email 2.27.0","MIME-Version":"1.0","Subject":"[libcamera-devel] [RFC PATCH v2] [DO NOT MERGE] IPA: raspberrypi:\n\tSample IPA data structure IDL definition and output","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>","Content-Type":"text/plain; charset=\"us-ascii\"","Content-Transfer-Encoding":"7bit","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"},"content":"In this whole patch, keep in mind that whenever flatbuffers is\nmentioned, it could be replaced by anything else, such as protobuf.\n\nAlso, in general, naming of anything is flexible. I tried to chose\nreasonable placeholders to show how things would work.\n\nI have not yet done the theoretical plumbing. I wanted to get this draft\nout first at least, before continuing too far without feedback.\n\n* Introduction\n\nraspberrypi.libcamera.decl shows a sample custom IPA data structure IDL\ndefinition for the raspberrypi pipeline handler. The intent is that I\nwill implement a custom compiler that will compile this definition into\nflatbuffers, as well as the header that will be included in the pipeline\nhandler and the IPA. flatbuffers will compile the flatbuffers definition\ninto the flatbuffers header that the included header will use for serdes.\n\nThe purpose of this custom IPA data structure definition is to allow\npipeline handlers and IPAs to use custom data structures for configure,\nprocessEvent, and queueFrameAction, rather than the rigid\nIPAOperationData. Hooking it up with framebuffers, and the compiler that\nI inted to write, will implement serdes for these custom data structures\nthat the IPAProxies can use.\n\nraspberrypi.fbs shows the intended output of the compiler that I intend\nto write, which will be in the input to the flatbuffers compiler.\n\nraspberrypi_wrapper.h shows the other intended output of the of the\ncompiler that I inted to write. This is the header that will be included\nby the pipeline handler and the IPA. The structs that are defined in\nthis header can be used directly by the pipeline handler and IPA, and\nthe serialize function and the deserialization constructor are meant to\nbe used by the IPAProxy (maybe they could be made private and IPAProxy\ninto a friend class?).\n\nThe custom compiler is necessary to place restrictions on the allowed\ndata definitions and make the definitions cleaner based on the\nrestrictions, as well as generate a header that is a wrapper around the\nflatbuffers-generated header for the pipeline handler and IPA to include.\n\n* Custom data definition file\n\nraspberrypi.libcamera.decl\n\nThere are three different types of custom data structures that must be\ndefined, for the three IPA functions that take IPAOperationData:\n- configure (for IPAInterface::configure())\n- event (for IPAInterface::processEvent())\n- action (for IPAInterface::queueFrameAction)\n\nDiscussion point: should configure have a separate input and output data\ndefinition?\n\nSince all three have an \"opcode\" and a payload, that is all that needs\nto be defined. The opcodes can be seen in the enums ConfigOps, EventOps,\nand ActionOps. The payloads can be seen in the unions ConfigPayload,\nEventPayload, and ActionPayload. Since the opcodes are essentially\nselectors into the unions, which field of the union the opcode points to\nmust be specified as shown in the enums.\n\nDiscussion point: ConfigPayload will become an element in a vector, so\nthere can be multiple instances of in in a single configure() call.\nConversely, EventPayload and ActionPayload are scalars in\nprocessEvent() and queueFrameAction. Should they be vectorized like\nConfigPayload?\n\nDiscussion point: can unions be disallowed besides at the top level of\nthe data definition tree in the payload?\n\nThese opcode and payload definitions are the only required components of\nthe custom data definition. Once these are satisfied, the rest of the\nfile follows standard flatbuffers rules.\n\nAlso, since flatbuffers structs are a bit of a pain, I've decided to\nonly allow flatbuffers tables in the definition (flatbuffers structs are\nnot allowed ). In C++ (and C if I ever have to implement that compiler\ntoo...) they're wrapped as structs, though.\n\nUnions cannot have unions as a direct child.\n\n* flatbuffers input file\n\nraspberrypi.fbs is the intended output with raspberrypi.libcamera.decl,\nas described above.\n\nSome things to note...\n\n- RPiConfigParameters is not flags. I decided that rather than scanning\n  flags and parsing a vector payload based on that, it would be better\n  to have a vector of opcode-payload pairs.\n\n- NONE needs to be added to enums to appease flatbuffers. One of the\n  many reasons why I think we should have a custom data definition to\n  make writing the data definition cleaner for developers.\n\n- In flatbuffers, primitives cannot be members of unions. I'll add a\n  global header that defines wrappers around primitives. In the custom\n  data definition they are allowed, though. My compiler shall convert\n  them to the wrapper.\n\n- libcamera already comes with a really nice ControlList serdes. In the\n  flatbuffers global header I'll add the ControlList definition that is\n  seen here. It's just defined as a byte array, so we can use\n  libcamera's ControlList serializer. It does need to be renamed,\n  though.\n\n- As mentioned earlier, RPiConfigParams has a vector of opcode-payload\n  pairs, while RPiEventParams and RPiActionParams have a single\n  opcode-payload pair\n\n* Custom generated header\n\nraspberrypi_wrapper.h\n\nflatbuffers will compile the flatbuffers input file into a flatbuffers\nheader that can be included. This file cannot be used directly by\npipeline handlers and IPAs without them directly interfacing with\nflatbuffers and its API. Thus, a custom header will also be generated by\nthe compiler that I'll implement. This custom header implements wrappers\nfor the data structures defined in the custom data definition file for\npipeline handlers and IPAs to use, as well as serialize and deserialize\nfunctions for the proxies to use. The intended output of this header can\nbe seen in raspberrypi_wrapper.h.\n\nThe structs and enums and unions defined in this header can be used by\npipeline handlers and IPAs as-is (ie. no special API like flatbuffers).\n\nDiscussion point: maybe make the serialize function and deserialization\nconstructor private and make IPAProxy a friend class?\n\nA Serializable class is reference but never defined. This class is meant\nto simply have a serialize() function (deserialize is implemented as an\noverloaded constructor). This class might not even be necessary.\n\nThere are a couple helpers for serializing and deserializing\nControlList such that it can work well with the flatbuffers data\nstructures. I got the implementation from the test for\nControlSerializer.\n\nThere are also a couple helpers for extracting the fds and injecting\nthe fds. The fd extraction is meant to be done by the IPAProxy prior to\nserialization. The IPAProxy can then use sendmsg and recvmsg (or some\nsimilar facility) to send the fds across the process boundary. These fds\ncan then be injected back into the object after it is deserialized and\nreconstructed. The extracted fds are saved in a queue, in post-order.\nSince the data container tree is the same before and after serdes, the\norder of the fds is guaranteed to match, as the fds are injected also in\npost-order.\n\nSerialization, deserialization, fd extraction, and fd injection are all\nimplemented with recursion. The fd extraction and injection functions\nmay or may not be be ommitted if no members in the data container tree\ncontain no fds. This is TBD.\n\nThere are a few rules for the compilation...\n\n- unions and enums are as-is\n\n- tables are compiled with its members as member variables, and have\n  three constructors, 1) empty default, 2) define all members, and\n  3) deserialization constructor. They also get a serialize function\n  that takes a flatbuffer builder and outputs a flatbuffer offset. This\n  allows recursion to do serialization. Only the top-level\n  (RPiConfigureParamsWrapper, RPiEventParamsWrapper,\n  RPiActionParamsWrapper) tables get a serialize functions that takes\n  void and returns a pair of byte array and length.\n\n- serialization is implemented as:\n  - for every member variable:\n    - if it is primitive, nop\n    - if it is controls, call serializeControlList\n    - if it is table, call table's serialize\n    - if it is a vector, convert the vector to a vector of flatbuffer\n      offsets by serializing every member based on the above three rules\n    - if it is a union:\n      - switch on opcode:\n        - set union type based on opcode\n        - set union content based on the same above four rules\n  - call flatbuffer's create object with all the serialized members\n\n- deserialization is implemented as a constructor. top-level tables take\n  a pointer to a byte array as input, while non-top-level tables take a\n  pointer to a byte array casted to the flatbuffers object. If the table\n  is used in a vector anywhere in the data definition, there will be\n  another deserialization constructor that takes a flatbuffer offset.\n  - cast input to flatbuffers offset (if necessary)\n  - for every member variable:\n    - if it is primitive, set the member variable\n    - if it is controls, set member variable with deserializeControlList\n    - if it is table, construct the table with the deserialization\n      constructor, and set the member variable\n    - if it is vector, convert the vector of flatbuffer offsets into the\n      vector of the member variable by deserializing based on the above\n      three rules\n    - if it is union:\n      - switch on opcode:\n        - set member variable union content based on same above four rules\n\n- fd extraction is implemented as:\n  - for every member variable:\n    - if it is primitive or contols, nop\n    - if it is table, extract the fds from the table, and add to\n      extracted fds queue\n    - if it is a vector, append the extracted fds for each element of\n      the table, according to the above two rules\n    - if it is a union:\n      - switch on opcode:\n        - append extracted fds according to above three rules\n\n- fd injection is implemented as the inverse of fd extraction, so\n  instead of enqueueing the fds, the fds are dequeued and assigned\n\nSigned-off-by: Paul Elder <paul.elder@ideasonboard.com>\n\n---\nChanes in v2:\n- add fd support to inteded custom compiler output to ease the\n  IPAProxy's job of extracting, sending the fds over the process\n  boundary, and reinjecting the fds\n- add a declaration to the custom data definition to specify the\n  ControlInfoMap (the ControlSerializer needs this)\n- add discussion point, if we can disallow unions in data definition\n  outside of the top-level payload container\nIn the commit message:\n- add paragraph about fd extraction and injection in \"Custom generated\n  header\" section\n- remove paragraph about \"fds not supported\" in pre-introduction\n- add description of fd extraction and injection mechanism in\n  compilation rules section of \"Custom generated header\" section\n---\n include/libcamera/ipa/raspberrypi.fbs         | 107 +++\n include/libcamera/ipa/raspberrypi.h           |  18 -\n .../libcamera/ipa/raspberrypi.libcamera.decl  |  83 +++\n include/libcamera/ipa/raspberrypi_wrapper.h   | 658 ++++++++++++++++++\n 4 files changed, 848 insertions(+), 18 deletions(-)\n create mode 100644 include/libcamera/ipa/raspberrypi.fbs\n create mode 100644 include/libcamera/ipa/raspberrypi.libcamera.decl\n create mode 100644 include/libcamera/ipa/raspberrypi_wrapper.h","diff":"diff --git a/include/libcamera/ipa/raspberrypi.fbs b/include/libcamera/ipa/raspberrypi.fbs\nnew file mode 100644\nindex 0000000..dcc1918\n--- /dev/null\n+++ b/include/libcamera/ipa/raspberrypi.fbs\n@@ -0,0 +1,107 @@\n+enum RPiConfigParameters:uint16 {\n+\tNONE = 0,\n+\tRPI_IPA_CONFIG_LS_TABLE,\n+\tRPI_IPA_CONFIG_STAGGERED_WRITE,\n+\tRPI_IPA_CONFIG_SENSOR,\n+\tRPI_IPA_CONFIG_SEND_FD,\n+}\n+\n+enum RPiEvents:uint16 {\n+\tNONE = 0,\n+\tRPI_IPA_EVENT_SIGNAL_STAT_READY,\n+\tRPI_IPA_EVENT_SIGNAL_ISP_PREPARE,\n+\tRPI_IPA_EVENT_QUEUE_REQUEST,\n+\tRPI_IPA_EVENT_SEND_FD,\n+}\n+\n+enum RPiActions:uint16 {\n+\tNONE = 0,\n+\tRPI_IPA_ACTION_V4L2_SET_STAGGERED,\n+\tRPI_IPA_ACTION_V4L2_SET_ISP,\n+\tRPI_IPA_ACTION_STATS_METADATA_COMPLETE,\n+\tRPI_IPA_ACTION_RUN_ISP,\n+\tRPI_IPA_ACTION_RUN_ISP_AND_DROP_FRAME,\n+\tRPI_IPA_ACTION_EMBEDDED_COMPLETE,\n+}\n+\n+// TODO define this for all primitive types, and make global\n+table UnsignedInt {\n+\tvalue:uint32;\n+}\n+\n+table SignedInt {\n+\tvalue:int32;\n+}\n+\n+// TODO make this global\n+// TODO rename this\n+table ControlList {\n+\tlist:[uint8];\n+}\n+\n+// Data containers\n+\n+table RPiStaggeredWritePayload {\n+\tgainDelay:uint32;\n+\texposureDelay:uint32;\n+\tsensorMetadata:uint32;\n+}\n+\n+table RPiIspPreparePayload {\n+\tembeddedbufferId:uint32;\n+\tbayerbufferId:uint32;\n+}\n+\n+table RPiStatsCompletePayload {\n+\tbufferId:uint32;\n+\tcontrols:ControlList;\n+}\n+\n+\n+// Payload unions\n+\n+union RPiConfigureUnion {\n+\tlsTableHandle:UnsignedInt,\n+\tstaggeredWriteResult:RPiStaggeredWritePayload,\n+\tcontrols:ControlList,\n+\tbufferFd:SignedInt,\n+}\n+\n+table RPiConfigurePayload {\n+        op:RPiConfigParameters;\n+\tpayload:RPiConfigureUnion;\n+}\n+\n+union RPiEventPayload {\n+\tbufferId:UnsignedInt,\n+\tispPrepare:RPiIspPreparePayload,\n+\tcontrols:ControlList,\n+\tbufferFd:SignedInt,\n+}\n+\n+union RPiActionPayload {\n+\tbufferId:UnsignedInt,\n+\tstatsComplete:RPiStatsCompletePayload,\n+\tcontrols:ControlList,\n+}\n+\n+\n+// IPA function parameters\n+\n+table RPiConfigParams {\n+\tparams:[RPiConfigurePayload];\n+}\n+\n+table RPiEventParams {\n+\tev:RPiEvents;\n+\tpayload:RPiEventPayload;\n+}\n+\n+table RPiActionParams {\n+\top:RPiActions;\n+\tpayload:RPiActionPayload;\n+}\n+\n+root_type RPiConfigureParams;\n+root_type RPiEventParams;\n+root_type RPiActionParams;\ndiff --git a/include/libcamera/ipa/raspberrypi.h b/include/libcamera/ipa/raspberrypi.h\nindex a493776..69b3808 100644\n--- a/include/libcamera/ipa/raspberrypi.h\n+++ b/include/libcamera/ipa/raspberrypi.h\n@@ -10,24 +10,6 @@\n #include <libcamera/control_ids.h>\n #include <libcamera/controls.h>\n \n-enum RPiConfigParameters {\n-\tRPI_IPA_CONFIG_LS_TABLE = (1 << 0),\n-\tRPI_IPA_CONFIG_STAGGERED_WRITE = (1 << 1),\n-\tRPI_IPA_CONFIG_SENSOR = (1 << 2),\n-};\n-\n-enum RPiOperations {\n-\tRPI_IPA_ACTION_V4L2_SET_STAGGERED = 1,\n-\tRPI_IPA_ACTION_V4L2_SET_ISP,\n-\tRPI_IPA_ACTION_STATS_METADATA_COMPLETE,\n-\tRPI_IPA_ACTION_RUN_ISP,\n-\tRPI_IPA_ACTION_RUN_ISP_AND_DROP_FRAME,\n-\tRPI_IPA_ACTION_EMBEDDED_COMPLETE,\n-\tRPI_IPA_EVENT_SIGNAL_STAT_READY,\n-\tRPI_IPA_EVENT_SIGNAL_ISP_PREPARE,\n-\tRPI_IPA_EVENT_QUEUE_REQUEST,\n-};\n-\n enum RPiIpaMask {\n \tID\t\t= 0x0ffff,\n \tSTATS\t\t= 0x10000,\ndiff --git a/include/libcamera/ipa/raspberrypi.libcamera.decl b/include/libcamera/ipa/raspberrypi.libcamera.decl\nnew file mode 100644\nindex 0000000..851ae6c\n--- /dev/null\n+++ b/include/libcamera/ipa/raspberrypi.libcamera.decl\n@@ -0,0 +1,83 @@\n+namespace RPi;\n+\n+// this is necessary for de/serializeControlList()\n+// define in include/libcamera/ipa/raspberrypi.h\n+ControlInfoMap RPiControls;\n+\n+// opcodes\n+// these must be enums, and must be named as shown\n+\n+// required\n+// must specify which union option each value corresponds to\n+enum ConfigOps {\n+\tRPI_IPA_CONFIG_LS_TABLE:lsTableHandle,\n+\tRPI_IPA_CONFIG_STAGGERED_WRITE:staggeredWriteResult,\n+\tRPI_IPA_CONFIG_SENSOR:controls,\n+\tRPI_IPA_CONFIG_SEND_FD:bufferFd,\n+}\n+\n+// required\n+// must specify which union option each value corresponds to\n+enum EventOps {\n+\tRPI_IPA_EVENT_SIGNAL_STAT_READY:bufferId,\n+\tRPI_IPA_EVENT_SIGNAL_ISP_PREPARE:ispPrepare,\n+\tRPI_IPA_EVENT_QUEUE_REQUEST:controls,\n+\tRPI_IPA_EVENT_SEND_FD:bufferFd,\n+}\n+\n+// required\n+// must specify which union option each value corresponds to\n+enum ActionOps {\n+\tRPI_IPA_ACTION_V4L2_SET_STAGGERED:controls,\n+\tRPI_IPA_ACTION_V4L2_SET_ISP:controls,\n+\tRPI_IPA_ACTION_STATS_METADATA_COMPLETE:statsComplete,\n+\tRPI_IPA_ACTION_RUN_ISP:bufferId,\n+\tRPI_IPA_ACTION_RUN_ISP_AND_DROP_FRAME:bufferId,\n+\tRPI_IPA_ACTION_EMBEDDED_COMPLETE:bufferId,\n+}\n+\n+// Custom Data containers\n+\n+table RPiStaggeredWritePayload {\n+\tgainDelay:uint32;\n+\texposureDelay:uint32;\n+\tsensorMetadata:uint32;\n+}\n+\n+table RPiIspPreparePayload {\n+\tembeddedbufferId:uint32;\n+\tbayerbufferId:uint32;\n+}\n+\n+table RPiStatsCompletePayload {\n+\tbufferId:uint32;\n+\tcontrols:ControlList;\n+}\n+\n+\n+// First level payload unions\n+// these must be unions, and must be named as shown\n+\n+// required\n+// this one is actually in a vector of payload objects (op-union pair)\n+union ConfigPayload {\n+\tlsTableHandle:uint32,\n+\tstaggeredWriteResult:RPiStaggeredWritePayload,\n+\tcontrols:ControlList,\n+\tbufferFd:int32,\n+}\n+\n+// required\n+union EventPayload {\n+\tbufferId:uint32,\n+\tispPrepare:RPiIspPreparePayload,\n+\tcontrols:ControlList,\n+\tbufferFd:int32,\n+}\n+\n+// required\n+union ActionPayload {\n+\tbufferId:uint32,\n+\tstatsComplete:RPiStatsCompletePayload,\n+\tcontrols:ControlList,\n+}\ndiff --git a/include/libcamera/ipa/raspberrypi_wrapper.h b/include/libcamera/ipa/raspberrypi_wrapper.h\nnew file mode 100644\nindex 0000000..eab51d3\n--- /dev/null\n+++ b/include/libcamera/ipa/raspberrypi_wrapper.h\n@@ -0,0 +1,658 @@\n+// will be automatically generated by custom compiler\n+\n+#ifndef __LIBCAMERA_IPA_INTERFACE_RASPBERRYPI_FB_H__\n+#define __LIBCAMERA_IPA_INTERFACE_RASPBERRYPI_FB_H__\n+\n+#include \"raspberrypi_generated.h\"\n+\n+namespace libcamera {\n+\n+// TODO this (and deserialize) should go global\n+inline flatbuffers::Offset<ControlList> serializeControlList(flatbuffers::FlatBufferBuilder &builder, ControlList &list)\n+{\n+\tControlSerializer serializer;\n+\n+\t// TODO need a way to get the info map (param? #defined param?)\n+\tsize_t size = serializer.binarySize(RPiControls);\n+\tstd::vector<uint8_t> infoData(size);\n+\tByteStreamBuffer buffer(infoData.data(), infoData.size());\n+\tserializer.serialize(RPiControls, buffer);\n+\n+\tsize = serializer.binarySize(list);\n+\tstd::vector<uint8_t> listData(size);\n+\tbuffer = ByteStreamBuffer(listData.data(), listData.size());\n+\tserializer.serialize(list, buffer);\n+\n+\t// don't need to error check; just write empty vector\n+\treturn CreateControlListDirect(builder, listData);\n+}\n+\n+// TODO fix the input type for this (like ControlListFB or something?)\n+inline ControlList deserializeControlList(ControlList *obj)\n+{\n+\tControlSerializer deserializer;\n+\tstd::vector<uint8_t> buf = std::vector(obj->begin(), obj->end());\n+\n+\tstd::vector<uint8_t> infoData(size);\n+\tBytesStreamBuffer buffer(const_cast<const uint8_t *>(infoData.data()), infoData.size());\n+\tControlInfoMap infoMap = deserializer.deserialize<ControlInfoMap>(buffer);\n+\t// TODO what to do for error checking?\n+\n+\tstd::vector<uint8_t> listData(size);\n+\tbuffer = ByteStreamBuffer(const_cast<const uint8_t *>(listData.data()), listData.size());\n+\tControlList list = deserializer.deserialize<ControlList>(buffer);\n+\n+\treturn list;\n+}\n+\n+\n+enum RPiConfigParametersWrapper {\n+\tRPI_IPA_CONFIG_LS_TABLE = 1,\n+\tRPI_IPA_CONFIG_STAGGERED_WRITE = 2,\n+\tRPI_IPA_CONFIG_SENSOR = 3,\n+\tRPI_IPA_CONFIG_SEND_FD = 4,\n+};\n+\n+enum RPiEventsWrapper {\n+  RPI_IPA_EVENT_SIGNAL_STAT_READY = 1,\n+  RPI_IPA_EVENT_SIGNAL_ISP_PREPARE = 2,\n+  RPI_IPA_EVENT_QUEUE_REQUEST = 3,\n+  RPI_IPA_EVENT_SEND_FD = 4,\n+};\n+\n+enum RPiActionsWrapper {\n+\tRPI_IPA_ACTION_V4L2_SET_STAGGERED,\n+\tRPI_IPA_ACTION_V4L2_SET_ISP,\n+\tRPI_IPA_ACTION_STATS_METADATA_COMPLETE,\n+\tRPI_IPA_ACTION_RUN_ISP,\n+\tRPI_IPA_ACTION_RUN_ISP_AND_DROP_FRAME,\n+\tRPI_IPA_ACTION_EMBEDDED_COMPLETE,\n+};\n+\n+struct RPiStaggeredWritePayloadWrapper : Serializable\n+{\n+\tRPiStaggeredWritePayloadWrapper() {}\n+\n+\tRPiStaggeredWritePayloadWrapper(uint32_t gainDelay, uint32_t exposureDelay, uint32_t sensorMetadata) : gainDelay_(gainDelay), exposureDelay_(exposureDelay), sensorMetadata_(sensorMetadata) {}\n+\n+\tRPiStaggeredWritePayloadWrapper(const RPiStaggeredWritePayload *buf)\n+\t{\n+\t\tconst RPiStaggeredWritePayload *obj = flatbuffers::GetRoot<RPiStaggeredWritePayload>(buf);\n+\n+\t\tgainDelay_ = obj->gainDelay();\n+\t\texposureDelay_ = obj->exposureDelay();\n+\t\tsensorMetadata_ = obj->sensorMetadata();\n+\t}\n+\n+\tflatbuffers::Offset<RPiStaggeredWritePayload> serialize(flatbuffers::FlatBufferBuilder &builder)\n+\t{\n+\t\t// - construct compound children depth-first\n+\t\t// - get simple data\n+\t\t// - feed to Create\n+\n+\t\t// nop for gainDelay_\n+\n+\t\t// nop for exposureDelay_\n+\n+\t\t// nop for sensorMetadata_\n+\n+\t\treturn CreateRPiStaggeredWritePayload(builder, gainDelay_, exposureDelay_, sensorMetadata_);\n+\t}\n+\n+\tstd::deque<int> extractFds()\n+\t{\n+\t\t// contains no fd and no compound children, so return empty\n+\t\treturn {};\n+\t}\n+\n+\tvoid injectFds(std::deque<int> &fds)\n+\t{\n+\t\t// nop\n+\t}\n+\n+\tuint32_t gainDelay_;\n+\tuint32_t exposureDelay_;\n+\tuint32_t sensorMetadata_;\n+}\n+\n+struct RPiIspPreparePayloadWrapper : Serializable\n+{\n+\tRPiIspPreparePayloadWrapper() {}\n+\n+\tRPiIspPreparePayloadWrapper(uint32_t embeddedbufferId, uint32_t bayerbufferId) : embeddedbufferId_(embeddedbufferId), bayerbufferId_(bayerbufferId) {}\n+\n+\tRPiIspPreparePayloadWrapper(const RPiIspPreparePayload *buf)\n+\t{\n+\t\tconst RPiIspPreparePayload *obj = flatbuffers::GetRoot<RPiIspPreparePayload>(buf);\n+\n+\t\tembeddedbufferId_ = obj->embeddedbufferId();\n+\t\tbayerbufferId_ = obj->bayerbufferId();\n+\t}\n+\n+\tflatbuffers::Offset<RPiIspPreparePayload> serialize(flatbuffers::FlatBufferBuilder &builder)\n+\t{\n+\t\t// - construct compound children depth-first\n+\t\t// - get simple data\n+\t\t// - feed to Create\n+\n+\t\t// nop for embeddedbufferId_\n+\n+\t\t// nop for bayerbufferId_\n+\n+\t\treturn CreateRPiIspPreparePayload(builder, embeddedbufferId_, bayerbufferId_);\n+\t}\n+\n+\t// these could be generated for every struct and not just those that\n+\t// fds in their tree. that'll save parsing the dependency graph in the\n+\t// compiler\n+\tstd::deque<int> extractFds()\n+\t{\n+\t\treturn {};\n+\t}\n+\n+\tvoid injectFds(std::deque<int> &fds)\n+\t{\n+\t\t// nop\n+\t}\n+\n+\tuint32_t embeddedbufferId_;\n+\tuint32_t bayerbufferId_;\n+}\n+\n+struct RPiStatsCompletePayloadWrapper : Serializable\n+{\n+\tRPiStatsCompletePayloadWrapper() {}\n+\n+\tRPiStatsCompletePayloadWrapper(uint32_t bufferId, ControlList &controls) : bufferId_(bufferId), controls_(controls) {}\n+\n+\t// deserialize\n+\tRPiStatsCompletePayloadWrapper(const RPiStatsCompletePayload *buf)\n+\t{\n+\t\tconst RPiStatsCompletePayload *obj = flatbuffers::GetRoot<RPiStatsCompletePayload>(buf);\n+\n+\t\tbufferId_ = obj->bufferId();\n+\t\tcontrols_ = deserializeControlList(obj->controls());\n+\t}\n+\n+\tflatbuffers::Offset<RPiStatsCompletePayloadWrapper> serialize(flatbuffers::FlatBufferBuilder &builder)\n+\t{\n+\t\t// - construct compound children depth-first\n+\t\t// - get simple data\n+\t\t// - feed to Create\n+\n+\t\t// nop for bufferId_\n+\n+\t\t// serialize controls_\n+\t\tflatbuffers::Offset<ControlList> controls = serializeControlList(builder, controls_);\n+\n+\t\treturn CreateRPiStatsCompletePayload(builder, bufferId_, controls);\n+\t}\n+\n+\tuint32_t bufferId_;\n+\tControlList controls_;\n+}\n+\n+union RPiConfigureUnionWrapper\n+{\n+\tuint32_t lsTableHandle_;\n+\tRPiStaggeredWritePayload staggeredWriteResult_;\n+\tControlList contols_;\n+\tint32_t bufferFd_;\n+}\n+\n+struct RPiConfigurePayloadWrapper : Serializable\n+{\n+\tRPiConfigurePayloadWrapper() {}\n+\n+\tRPiConfigurePayloadWrapper(enum RPiConfigParametersWrapper op, RPiConfigureUnionWrapper payload) : op_(op), payload_(payload) {}\n+\n+\t// deserialize\n+\tRPiConfigurePayloadWrapper(const RPiConfigurePayload *buf)\n+\t{\n+\t\t// yeah fill this in if you want\n+\t}\n+\n+\t// deserialize\n+\t// TODO need this if is a member of vector\n+\tRPiConfigurePayloadWrapper(flatbuffers::Offset<RPiConfigurePayload> &p)\n+\t{\n+\t\t// nop for op\n+\t\top_ = p.op();\n+\n+\t\t// start of union block for payload_\n+\t\tswitch (op_) {\n+\t\tcase RPI_IPA_CONFIG_LS_TABLE:\n+\t\t\tpayload_.lsTableHandle_ = p.payload_as_lsTableHandle();\n+\t\t\tbreak;\n+\t\tcase RPI_IPA_CONFIG_STAGGERED_WRITE:\n+\t\t\tpayload_.staggeredWriteResult_ = RPiStaggeredWritePayloadWrapper(p.payload_as_staggeredWriteResult);\n+\t\t\tbreak;\n+\t\tcase RPI_IPA_CONFIG_SENSOR:\n+\t\t\tpayload_.controls_ = deserializeControlList(p.payload_as_controls());\n+\t\t\tbreak;\n+\t\tcase RPI_IPA_CONFIG_SEND_FD:\n+\t\t\tpayload_.bufferFd_ = p.payload_as_bufferFd();\n+\t\t\tbreak;\n+\t\t}\n+\t\t// end of union block for payload_\n+\t}\n+\n+\tflatbuffers::Offset<RPiConfigurePayload> serialize(flatbuffers::FlatBufferBuilder &builder)\n+\t{\n+\t\t// - construct compound children depth-first\n+\t\t// - get simple data\n+\t\t// - feed to Create\n+\n+\t\t// nop for op_\n+\t\tRPiConfigureUnion payloadType;\n+\t\tflatbuffers::Offset<void> payload;\n+\n+\t\t// start of union block for payload_\n+\t\tswitch (op_) {\n+\t\tcase RPI_IPA_CONFIG_LS_TABLE:\n+\t\t\tpayloadType = RPiConfigureUnion_lsTableHandle;\n+\t\t\tpayload = CreateUnsignedInt(builder, payload_.lsTableHandle_);\n+\t\t\tbreak;\n+\t\tcase RPI_IPA_CONFIG_STAGGERED_WRITE:\n+\t\t\tpayloadType = RPiConfigureUnion_staggeredWriteResult;\n+\t\t\tpayload = payload_.staggeredWriteResult_.serialize(builder);\n+\t\t\tbreak;\n+\t\tcase RPI_IPA_CONFIG_SENSOR:\n+\t\t\t// controls\n+\t\t\tpayloadType = RPiConfigureUnion_controls;\n+\t\t\tpayload = serializeControlList(builder, payload_.controls_);\n+\t\t\tbreak;\n+\t\tcase RPI_IPA_CONFIG_SEND_FD:\n+\t\t\tpayloadType = RPiConfigureUnion_bufferFd;\n+\t\t\tpayload = CreateSignedInt(builder, payload_.bufferFd_);\n+\t\t\tbreak;\n+\t\t}\n+\t\t// end of union block for payload_\n+\n+\t\treturn CreateRPiConfigurePayload(builder, op_, payloadType, payload);\n+\t}\n+\n+\tstd::deque<int> extractFds()\n+\t{\n+\t\tstd::deque<int> fds;\n+\n+\t\t// nop for op_, since it has no children, and is not fd\n+\n+\t\t// start of union block for payload_\n+\t\tswitch (op_) {\n+\t\tcase RPI_IPA_CONFIG_LS_TABLE:\n+\t\t\t// value is not fd\n+\t\t\tbreak;\n+\t\tcase RPI_IPA_CONFIG_STAGGERED_WRITE:\n+\t\t\tstd::deque<int> pfds = payload_.staggeredWriteResult_.extractFds();\n+\t\t\tfds.insert(fds.end(), pfds,begin(), pfds.end());\n+\t\t\tbreak;\n+\t\tcase RPI_IPA_CONFIG_SENSOR:\n+\t\t\t// value is not fd\n+\t\t\tbreak;\n+\t\tcase RPI_IPA_CONFIG_SEND_FD:\n+\t\t\tfds.push_back(payload.bufferFd_);\n+\t\t\tbreak;\n+\t\t}\n+\t\t// end of union block for payload_\n+\n+\t\treturn fds;\n+\t}\n+\n+\tvoid injectFds(std::deque<int> &fds)\n+\t{\n+\t\t// nop for op_\n+\n+\t\t// start of union block for payload_\n+\t\tswitch (op_) {\n+\t\tcase RPI_IPA_CONFIG_LS_TABLE:\n+\t\t\tbreak;\n+\t\tcase RPI_IPA_CONFIG_STAGGERED_WRITE:\n+\t\t\tpayload_.staggeredWriteResult_.injectFds(fds);\n+\t\t\tbreak;\n+\t\tcase RPI_IPA_CONFIG_SENSOR:\n+\t\t\tbreak;\n+\t\tcase RPI_IPA_CONFIG_SEND_FD:\n+\t\t\tpayload_.bufferFd_ = fds.at(0);\n+\t\t\tfds.pop_front();\n+\t\t\tbreak;\n+\t\t}\n+\t\t// end of union block for payload_\n+\t}\n+\n+\tenum RPiConfigParametersWrapper op_;\n+\tRPiConfigureUnionWrapper payload_;\n+}\n+\n+union RPiEventPayloadWrapper\n+{\n+\tuint32_t bufferId_;\n+\tRPiIspPreparePayloadWrapper ispPrepare_;\n+\tControlList controls_;\n+\tint32_t bufferFd_;\n+}\n+\n+union RPiActionPayloadWrapper\n+{\n+\tuint32_t bufferId_;\n+\tRPiStatsCompletePayloadWrapper statsComplete_;\n+\tControlList controls_;\n+}\n+\n+struct RPiConfigureParamsWrapper : Serializable\n+{\n+\tRPiConfigureParamsWrapper() {}\n+\n+\tRPiConfigureParamsWrapper(std::vector<RPiConfigurePayloadWrapper> payload) : payload_(payload) {}\n+\n+\t// deserialize\n+\t// only top-level gets fds\n+\tRPiConfigureParamsWrapper(const uint8_t *buf, std::dequeue<int> fds)\n+\t{\n+\t\tconst RPiConfigureParams *obj = flatbuffers::GetRoot<RPiConfigureParams>(buf);\n+\n+\t\t// start of vector block for payload_\n+\t\tflatbuffers::Vector<flatbuffers::Offset<RPiConfigurePayload>> *payload = obj->params();\n+\t\tstd::transform(payload->begin(), payload->end(), std::back_inserter(payload_),\n+\t\t\t\t[](flatbuffers::Offset<RPiConfigurePayload> &p) -> RPiConfigurePayloadWrapper {\n+\t\t\t\t\treturn RPiConfigurePayloadWrapper(p);\n+\t\t\t\t});\n+\t\t// end of vector block for payload_\n+\n+\n+\t\t// after constructing all the children, we need to inject the fds\n+\t\tinjecetFds(fds);\n+\t}\n+\n+\tflatbuffers::Offset<RPiConfigureParams> serialize(flatbuffers::FlatBufferBuilder &builder)\n+\t{\n+\t\t// - construct compound children depth-first\n+\t\t// - get simple data\n+\t\t// - feed to Create\n+\n+\t\t// start of vector block for payload_\n+\t\tstd::vector<flatbuffers::Offset<RPiConfigurePayload>> payload;\n+\t\tstd::transform(payload_.begin(), payload_.end(), std::back_inserter(payload),\n+\t\t\t\t[](RPiConfigurePayloadWrapper &p) -> flatbuffers::Offset<RPiConfigurePayload> { return p.serialize(builder); });\n+\t\t// end of vector block for payload_\n+\n+\t\t// use direct if there's vector as a member\n+\t\treturn CreateRPiConfigureParamsDirect(builder, payload);\n+\t}\n+\n+\t// this is only for root_type\n+\tstd::deque<int> extractFds()\n+\t{\n+\t\tstd::deque<int> fds;\n+\n+\t\t// start of vector block for payload_\n+\t\tfor (RPiConfigurePayloadWrapper &payload : payload_)  {\n+\t\t\tstd::deque<int> &pfds = payload_.extractFds();\n+\t\t\tfds.insert(fds.end(), pfds.begin(), pfds.end());\n+\t\t}\n+\t\t// end of vector block for payload_\n+\n+\t\treturn fds;\n+\t}\n+\n+\tvoid injectFds(std::deque<int> &fds)\n+\t{\n+\t\t// start of vector block for payload_\n+\t\tfor (RPiConfigurePayloadWrapper &payload : payload_) \n+\t\t\tpayload_.injectFds(fds);\n+\t\t// end of vector block for payload_\n+\t}\n+\n+\t// this is only for root_type\n+\t// returns buffer pointer, buffer size (in bytes), and vector of fds\n+\t// the fds are matched by index; the index maps to full path in object\n+\t// tree, generated by the special compiler\n+\tstd::tuple<uint8_t *, size_t, std::deque<int>> serialize()\n+\t{\n+\t\tflatbuffers::FlatBufferBuilder builder(1024);\n+\t\tbuilder.Finish(this.serialize(builder));\n+\n+\t\tuint8_t *buf = builder.GetBufferPointer();\n+\t\tsize_t size = builder.GetSize();\n+\t\treturn {buf, size, extractFds()};\n+\t}\n+\n+\tstd::vector<RPiConfigurePayloadWrapper> payload_;\n+}\n+\n+struct RPiEventParamsWrapper : Serializable\n+{\n+\tRPiEventParamsWrapper() {}\n+\n+\tRPiEventParamsWrapper(enum RPiEventsWrapper ev, RPiEventPayloadWrapper payload) : ev_(ev), payload_(payload) {}\n+\n+\t// deserialize\n+\t// root_type needs fds\n+\tRPiEventParamsWrapper(const uint8_t *buf, std::deque<int> fds)\n+\t{\n+\t\tconst RPiEventParams *obj = flatbuffers::GetRoot<RPiEventParams>(buf);\n+\n+\t\tev_ = obj->ev();\n+\n+\t\t// start of union block for payload_\n+\t\tswitch (ev_) {\n+\t\tcase RPI_IPA_EVENT_SIGNAL_STAT_READY:\n+\t\t\tpayload_.bufferId_ = obj->payload_as_bufferId()->value();\n+\t\t\tbreak;\n+\t\tcase RPI_IPA_EVENT_SIGNAL_ISP_PREPARE:\n+\t\t\tpayload_.ispPrepare_ = RPiIspPreparePayloadWrapper(obj->payload_as_ispPrepare());\n+\t\t\tbreak;\n+\t\tcase RPI_IPA_EVENT_QUEUE_REQUEST:\n+\t\t\tpayload_.controls_ = deserializeControlList(obj->payload_as_controls());\n+\t\t\tbreak;\n+\t\tcase RPI_IPA_EVENT_SEND_FD:\n+\t\t\tpayload_.bufferFd_ = obj->payload_as_bufferFd()->value();\n+\t\t\tbreak;\n+\t\t}\n+\t\t// end of union block for payload_\n+\n+\t\tinjectFds(fds);\n+\t}\n+\n+\tflatbuffers::Offset<RPiEventParams> serialize(flatbuffers::FlatBufferBuilder &builder)\n+\t{\n+\t\t// - construct compound children depth-first\n+\t\t// - get simple data\n+\t\t// - feed to Create\n+\n+\t\t// nop for ev_\n+\n+\t\t// start of union block for payload_\n+\t\tRPiEventPayload payloadType;\n+\t\tflatbuffers::Offset<void> payload;\n+\n+\t\tswitch (ev_) {\n+\t\tcase RPI_IPA_EVENT_SIGNAL_STAT_READY:\n+\t\t\tpayloadType = RPiEventPayload_bufferId;\n+\t\t\tpayload = CreateUnsignedInt(builder, payload_.bufferId_);\n+\t\t\tbreak;\n+\t\tcase RPI_IPA_EVENT_SIGNAL_ISP_PREPARE:\n+\t\t\tpayloadType = RPiEventPayload_ispPrepare;\n+\t\t\tpayload = payload_.ispPrepare_.serialize(builder);\n+\t\t\tbreak;\n+\t\tcase RPI_IPA_EVENT_QUEUE_REQUEST:\n+\t\t\tpayloadType = RPiEventPayload_controls;\n+\t\t\tpayload = serializeControlList(builder, payload_.controls_);\n+\t\t\tbreak;\n+\t\tcase RPI_IPA_EVENT_SEND_FD:\n+\t\t\tpayloadType = RPiEventPayload_bufferFd;\n+\t\t\tpayload = CreateSignedInt(builder, payload_.bufferFd_);\n+\t\t\tbreak;\n+\t\t}\n+\t\t// end of union block\n+\n+\t\treturn CreateRPiEventParams(builder, ev_, payloadType, payload);\n+\t}\n+\n+\tstd::deque<int> extractFds()\n+\t{\n+\t\tstd::deque<int> fds;\n+\n+\t\t// nop for ev_\n+\n+\t\t// start of union block for payload_\n+\t\tswitch (ev_) {\n+\t\tcase RPI_IPA_EVENT_SIGNAL_STAT_READY:\n+\t\t\t// non-fd scalar\n+\t\t\tbreak;\n+\t\tcase RPI_IPA_EVENT_SIGNAL_ISP_PREPARE:\n+\t\t\tstd::deque<int> &pfds = payload_.ispPrepare_.extractFds();\n+\t\t\tfds.insert(fds.end(), pfds.begin(), pfds.end());\n+\t\t\tbreak;\n+\t\tcase RPI_IPA_EVENT_QUEUE_REQUEST:\n+\t\t\t// non-fd controls\n+\t\t\tbreak;\n+\t\tcase RPI_IPA_EVENT_SEND_FD:\n+\t\t\tfds.push_back(payload_.bufferFd_);\n+\t\t\tbreak;\n+\t\t}\n+\t\t// end of union block for payload_\n+\n+\t\treturn fds;\n+\t}\n+\n+\tvoid injectFds(std::deque<int> &fds)\n+\t{\n+\t\t// nop for ev_\n+\n+\t\t// start of union block for payload_\n+\t\tswitch (ev_) {\n+\t\tcase RPI_IPA_EVENT_SIGNAL_STAT_READY:\n+\t\t\tbreak;\n+\t\tcase RPI_IPA_EVENT_SIGNAL_ISP_PREPARE:\n+\t\t\tpayload_.ispPrepare_.injectFds(fds);\n+\t\t\tbreak;\n+\t\tcase RPI_IPA_EVENT_QUEUE_REQUEST:\n+\t\t\tbreak;\n+\t\tcase RPI_IPA_EVENT_SEND_FD:\n+\t\t\tpayload_.bufferFd_ = fds.at(0);\n+\t\t\tfds.pop_front();\n+\t\t\tbreak;\n+\t\t}\n+\t\t// end of union block for payload_\n+\t}\n+\n+\t// this is only for root_type\n+\t// returns buffer pointer, buffer size (in bytes), and vector of fds\n+\t// the fds are matched by index; the index maps to full path in object\n+\t// tree, generated by the special compiler\n+\tstd::tuple<uint8_t *, size_t, std::deque<int>> serialize()\n+\t{\n+\t\tflatbuffers::FlatBufferBuilder builder(1024);\n+\t\tbuilder.Finish(this.serialize(builder));\n+\n+\t\tuint8_t *buf = builder.GetBufferPointer();\n+\t\tsize_t size = builder.GetSize();\n+\t\treturn {buf, size, extractFds()};\n+\t}\n+\n+\tenum RPiEventsWrapper ev_;\n+\tRPiEventPayloadWrapper payload_;\n+}\n+\n+struct RPiActionParamsWrapper : Serializable\n+{\n+\tRPiActionParamsWrapper() {}\n+\n+\tRPiActionParamsWrapper(enum RPiActionsWrapper op, RPiActionPayloadWrapper payload) : op_(op), payload_(payload) {}\n+\n+\t// deserialize\n+\t// root_type needs fds\n+\tRPiActionParamsWrapper(const uint8_t *buf, std::deque<int> &fds)\n+\t{\n+\t\tconst RPiActionParams *obj = flatbuffers::GetRoot<RPiActionParams>(buf);\n+\n+\t\top_ = obj->op();\n+\n+\t\t// start of union block for payload_\n+\t\tswitch (op_) {\n+\t\tcase RPI_IPA_ACTION_V4L2_SET_STAGGERED:\n+\t\tcase RPI_IPA_ACTION_V4L2_SET_ISP:\n+\t\t\tpayload_.controls_ = deserializeControlList(obj->payload_as_controls());\n+\t\t\tbreak;\n+\t\tcase RPI_IPA_ACTION_STATS_METADATA_COMPLETE:\n+\t\t\tpayload_.statsComplete_ = RPiStatsCompletePayloadWrapper(obj->payload_as_statsComplete());\n+\t\t\tbreak;\n+\t\tcase RPI_IPA_ACTION_RUN_ISP:\n+\t\tcase RPI_IPA_ACTION_RUN_ISP_AND_DROP_FRAME:\n+\t\tcase RPI_IPA_ACTION_EMBEDDED_COMPLETE:\n+\t\t\t// UnsignedInt needs ->value()\n+\t\t\tpayload_.bufferId_ = obj->payload_as_bufferId()->value();\n+\t\t\tbreak;\n+\t\t}\n+\t\t// end of union block for payload_\n+\n+\t\tinjectFds(fds);\n+\t}\n+\n+\tflatbuffers::Offset<RPiEventParams> serialize(flatbuffers::FlatBufferBuilder &builder)\n+\t{\n+\t\t// - construct compound children depth-first\n+\t\t// - get simple data\n+\t\t// - feed to Create\n+\n+\t\t// nop for op_\n+\n+\t\t// start of union block for payload_\n+\t\tRPiActionPayload payloadType;\n+\t\tflatbuffers::Offset<void> payload;\n+\n+\t\tswitch (op_) {\n+\t\tcase RPI_IPA_ACTION_V4L2_SET_STAGGERED:\n+\t\tcase RPI_IPA_ACTION_V4L2_SET_ISP:\n+\t\t\tpayloadType = RPiActionPayload_controls;\n+\t\t\tpayload = serializeControlList(builder, payload_.controls_);\n+\t\t\tbreak;\n+\t\tcase RPI_IPA_ACTION_STATS_METADATA_COMPLETE:\n+\t\t\tpayloadType = RPiActionPayload_statsComplete;\n+\t\t\tpayload = payload_.statsComplete_.serialize(builder);\n+\t\t\tbreak;\n+\t\tcase RPI_IPA_ACTION_RUN_ISP:\n+\t\tcase RPI_IPA_ACTION_RUN_ISP_AND_DROP_FRAME:\n+\t\tcase RPI_IPA_ACTION_EMBEDDED_COMPLETE:\n+\t\t\tpayloadType = RPiActionPayload_bufferId;\n+\t\t\tpayload = CreateUnsignedInt(builder, payload_.bufferId_);\n+\t\t\tbreak;\n+\t\t}\n+\t\t// end of union block for payload_\n+\n+\t\treturn CreateRPiActionParams(builder, op_, payloadType, payload);\n+\t}\n+\n+\t// root_type needs it even if it's empty, because of top-level serialize()\n+\tstd::deque<int> extractFds()\n+\t{\n+\t\treturn {};\n+\t}\n+\n+\tstd::deque<int> injectFds()\n+\t{\n+\t\t// nop\n+\t}\n+\n+\t// this is only for root_type\n+\t// returns buffer pointer, buffer size (in bytes), and vector of fds\n+\t// the fds are matched by index; the index maps to full path in object\n+\t// tree, generated by the special compiler\n+\tstd::tuple<uint8_t *, size_t, std::deque<int>> serialize()\n+\t{\n+\t\tflatbuffers::FlatBufferBuilder builder(1024);\n+\t\tbuilder.Finish(this.serialize(builder));\n+\n+\t\tuint8_t *buf = builder.GetBufferPointer();\n+\t\tsize_t size = builder.GetSize();\n+\t\treturn {buf, size, extractFds()};\n+\t}\n+\n+\tenum RPiActionsWrapper op_;\n+\tRPiActionPayloadWrapper payload_;\n+}\n+\n+} /* namespace libcamera */\n+\n+#endif /* __LIBCAMERA_IPA_INTERFACE_RASPBERRYPI_FB_H__ */\n","prefixes":["libcamera-devel","RFC","v2","DO","NOT","MERGE"]}