Dawn Framework 1.0
Universal data acquisition framework for embedded systems
adjust.hxx
1// dawn/include/dawn/prog/adjust.hxx
2//
3// SPDX-License-Identifier: Apache-2.0
4//
5
6#pragma once
7
8#include "dawn/porting/config.hxx"
9#include "dawn/prog/common.hxx"
10
11namespace dawn
12{
13// Forward declaration
14
15class CIOCommon;
16class IIOCommon;
17class io_ddata_t;
18
31{
32public:
33 enum
34 {
39 };
40
41 struct
42 {
45 } typedef SProgAdjustIOBind;
46
47 struct
48 {
49 uint32_t offset;
50 uint32_t scale;
51 } typedef SProgAdjustParams;
52
53 explicit CProgAdjust(CDescObject &desc)
54 : CProgCommon(desc)
55 , src(nullptr)
56 , output(nullptr)
57 , cfg(nullptr)
58 , ioData(nullptr)
59 , outputData(nullptr)
60 , ioscale(0)
61 , iooffset(0)
62 , srcType(SObjectId::DTYPE_ANY)
63 , outputType(SObjectId::DTYPE_ANY)
64 {
65 }
66
67 ~CProgAdjust() override;
68
69#ifdef CONFIG_DAWN_OBJECT_HAS_NAME
70 const char *getClassNameStr() const override
71 {
72 return "adjust";
73 }
74#endif
75
76 int configure() override;
77 int init() override;
78 int deinit() override;
79 int doStart() override;
80
81 constexpr static SObjectId::ObjectId objectId(uint16_t inst)
82 {
85 }
86
87 constexpr static SObjectCfg::ObjectCfgId cfgId(bool rw, uint8_t size, uint8_t id)
88 {
91 }
92
93 constexpr static SObjectCfg::ObjectCfgId cfgIdIOBind(size_t i = 1)
94 {
95 return CProgAdjust::cfgId(false, 1 + i, PROG_ADJUST_CFG_IOBIND);
96 }
97
98 constexpr static SObjectCfg::ObjectCfgId cfgParams()
99 {
100 return CProgAdjust::cfgId(false, 2, PROG_ADJUST_CFG_PARAMS);
101 }
102
103private:
104 CIOCommon *src; // @Source I/O object.
105 CIOCommon *output; // @Result output I/O object.
106 SProgAdjustIOBind *cfg; // Configuration structure reference.
107 io_ddata_t *ioData; // Input data buffer.
108 io_ddata_t *outputData; // Output data buffer.
109 uint32_t ioscale; // Stored scale parameter.
110 uint32_t iooffset; // Stored offset parameter.
111 int srcType; // Source dtype.
112 int outputType; // Result dtype.
113
114 static int ioNotifierCb(void *priv, io_ddata_t *data);
115
116 int configureDesc(const CDescObject &desc);
117 int allocObject(SProgAdjustIOBind *alloc);
118 int bindPrepare();
119 bool isSupportedConvType(int sourceType, int targetType);
120 int refresh();
121 void handle(io_ddata_t *data);
122};
123} // Namespace dawn
Data scaling and offset transformation PROG.
Definition adjust.hxx:31
int init()
One-time initialize object after bindings are resolved.
Definition adjust.cxx:538
@ PROG_ADJUST_CFG_PARAMS
Adjustment parameters (scale, offset)
Definition adjust.hxx:37
@ PROG_ADJUST_CFG_LAST
reserved
Definition adjust.hxx:38
@ PROG_ADJUST_CFG_IOBIND
I/O binding configuration.
Definition adjust.hxx:36
@ PROG_ADJUST_CFG_FIRST
reserved
Definition adjust.hxx:35
int doStart()
Start implementation hook.
Definition adjust.cxx:598
int configure()
Configure object from descriptor data.
Definition adjust.cxx:440
int deinit()
De-initialize object.
Definition adjust.cxx:524
Base class for all PROG (processing) objects.
Definition common.hxx:27
@ PROG_CLASS_ADJUST
Scale/offset adjustment.
Definition common.hxx:71
CProgCommon(CDescObject &desc)
Constructor.
Definition common.cxx:16
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
32-bit encoded object identifier (union with bit field).
Definition objectid.hxx:218