Dawn Framework 1.0
Universal data acquisition framework for embedded systems
iodemux.hxx
1// dawn/include/dawn/prog/iodemux.hxx
2//
3// SPDX-License-Identifier: Apache-2.0
4//
5
6#pragma once
7
8#include <inttypes.h>
9#include <vector>
10
11#include "dawn/io/ddata.hxx"
12#include "dawn/prog/common.hxx"
13
14namespace dawn
15{
16class CIOCommon;
17
22{
23public:
24 enum
25 {
26 PROG_IODEMUX_CFG_FIRST = 0,
27 PROG_IODEMUX_CFG_CONTROL = 1,
28 PROG_IODEMUX_CFG_INPUT = 2,
29 PROG_IODEMUX_CFG_OUTPUTS = 3,
30 PROG_IODEMUX_CFG_LAST = 31
31 };
32
33 explicit CProgIODemux(CDescObject &desc);
34 ~CProgIODemux() override;
35
36#ifdef CONFIG_DAWN_OBJECT_HAS_NAME
37 const char *getClassNameStr() const override
38 {
39 return "iodemux";
40 }
41#endif
42
43 int configure() override;
44 int init() override;
45 int deinit() override;
46 int doStart() override;
47 int doStop() override;
48 bool hasThread() const override;
49
50 constexpr static SObjectId::ObjectId objectId(uint16_t inst)
51 {
53 SObjectId::OBJTYPE_PROG, CProgCommon::PROG_CLASS_IODEMUX, SObjectId::DTYPE_ANY, 0, inst);
54 }
55
56 constexpr static SObjectCfg::ObjectCfgId cfgId(bool rw, uint8_t size, uint8_t id)
57 {
59 SObjectId::OBJTYPE_PROG, CProgCommon::PROG_CLASS_IODEMUX, SObjectId::DTYPE_ANY, rw, size, id);
60 }
61
62 constexpr static SObjectCfg::ObjectCfgId cfgIdControl()
63 {
64 return CProgIODemux::cfgId(false, 1, PROG_IODEMUX_CFG_CONTROL);
65 }
66
67 constexpr static SObjectCfg::ObjectCfgId cfgIdInput()
68 {
69 return CProgIODemux::cfgId(false, 1, PROG_IODEMUX_CFG_INPUT);
70 }
71
72 constexpr static SObjectCfg::ObjectCfgId cfgIdOutputs(uint16_t size)
73 {
74 return CProgIODemux::cfgId(false, size, PROG_IODEMUX_CFG_OUTPUTS);
75 }
76
77private:
78 CIOCommon *control;
79 SObjectId::ObjectId controlId;
80 CIOCommon *input;
81 SObjectId::ObjectId inputId;
82 std::vector<CIOCommon *> outputs;
83 std::vector<SObjectId::ObjectId> outputIds;
84 io_ddata_t *dataBuf;
85 size_t currentIndex;
86 bool active;
87 bool registered;
88
89 static int controlNotifierCb(void *priv, io_ddata_t *data);
90 static int inputNotifierCb(void *priv, io_ddata_t *data);
91
92 int configureDesc(const CDescObject &desc);
93 int allocOutput(SObjectId::ObjectId ioId);
94 int validateShape(CIOCommon *io) const;
95 void routeIndex(uint32_t index);
96};
97} // namespace dawn
Descriptor wrapper for individual object configuration.
Base class for all I/O objects.
Definition common.hxx:27
Base class for all PROG (processing) objects.
Definition common.hxx:27
IO demultiplexer: routes one input to the selected output.
Definition iodemux.hxx:22
int doStop()
Stop implementation hook.
Definition iodemux.cxx:267
int doStart()
Start implementation hook.
Definition iodemux.cxx:235
int configure()
Configure object from descriptor data.
Definition iodemux.cxx:120
int init()
One-time initialize object after bindings are resolved.
Definition iodemux.cxx:141
bool hasThread() const
Check if a background thread is active.
Definition iodemux.cxx:286
int deinit()
De-initialize object.
Definition iodemux.cxx:191
static ObjectCfgId objectCfg(uint8_t type, uint16_t cls, uint8_t dtype, bool rw, uint16_t size, uint8_t id)
Construct 32-bit ConfigID from component fields.
uint32_t ObjectCfgId
ConfigID type - single 32-bit value.
Definition objectcfg.hxx:60
Out-of-tree user-extension hooks for Dawn.
Definition bindable.hxx:13
@ OBJTYPE_PROG
Program/algorithm object type.
Definition objectid.hxx:202
@ DTYPE_ANY
Wildcard data type (matches any actual type).
Definition objectid.hxx:68
uint32_t ObjectId
ObjectID type - single 32-bit value.
Definition objectid.hxx:44
static ObjectId objectId(uint8_t type, uint16_t cls, uint8_t dtype, uint8_t flags, uint16_t priv)
Construct 32-bit ObjectID from component fields.
Definition objectid.hxx:290
Heap-allocated dynamic I/O data buffer.
Definition ddata.hxx:21