Dawn Framework 1.0
Universal data acquisition framework for embedded systems
iomux.hxx
1// dawn/include/dawn/prog/iomux.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
21class CProgIOMux : public CProgCommon
22{
23public:
24 enum
25 {
26 PROG_IOMUX_CFG_FIRST = 0,
27 PROG_IOMUX_CFG_CONTROL = 1,
28 PROG_IOMUX_CFG_INPUTS = 2,
29 PROG_IOMUX_CFG_OUTPUT = 3,
30 PROG_IOMUX_CFG_LAST = 31
31 };
32
33 explicit CProgIOMux(CDescObject &desc);
34 ~CProgIOMux() override;
35
36#ifdef CONFIG_DAWN_OBJECT_HAS_NAME
37 const char *getClassNameStr() const override
38 {
39 return "iomux";
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_IOMUX, 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_IOMUX, SObjectId::DTYPE_ANY, rw, size, id);
60 }
61
62 constexpr static SObjectCfg::ObjectCfgId cfgIdControl()
63 {
64 return CProgIOMux::cfgId(false, 1, PROG_IOMUX_CFG_CONTROL);
65 }
66
67 constexpr static SObjectCfg::ObjectCfgId cfgIdInputs(uint16_t size)
68 {
69 return CProgIOMux::cfgId(false, size, PROG_IOMUX_CFG_INPUTS);
70 }
71
72 constexpr static SObjectCfg::ObjectCfgId cfgIdOutput()
73 {
74 return CProgIOMux::cfgId(false, 1, PROG_IOMUX_CFG_OUTPUT);
75 }
76
77private:
78 struct SInput
79 {
80 CProgIOMux *owner;
81 CIOCommon *io;
83 size_t index;
84 };
85
86 CIOCommon *control;
87 SObjectId::ObjectId controlId;
88 std::vector<SInput> inputs;
89 CIOCommon *output;
90 SObjectId::ObjectId outputId;
91 io_ddata_t *dataBuf;
92 size_t currentIndex;
93 bool active;
94 bool registered;
95
96 static int controlNotifierCb(void *priv, io_ddata_t *data);
97 static int inputNotifierCb(void *priv, io_ddata_t *data);
98
99 int configureDesc(const CDescObject &desc);
100 int allocInput(SObjectId::ObjectId ioId);
101 int validateShape(CIOCommon *io) const;
102 void routeIndex(uint32_t index);
103};
104} // 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 multiplexer: routes selected input to one output.
Definition iomux.hxx:22
bool hasThread() const
Check if a background thread is active.
Definition iomux.cxx:304
int init()
One-time initialize object after bindings are resolved.
Definition iomux.cxx:147
int configure()
Configure object from descriptor data.
Definition iomux.cxx:125
int doStart()
Start implementation hook.
Definition iomux.cxx:247
int deinit()
De-initialize object.
Definition iomux.cxx:200
int doStop()
Stop implementation hook.
Definition iomux.cxx:282
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