1 /* SPDX-License-Identifier: BSD-3-Clause
2  *
3  * Copyright(c) 2022 Intel Corporation. All rights reserved.
4  */
5 /*! \file processing_module_prerequisites.h */
6 
7 #ifndef _PROCESSING_MODULE_PREREQUISITES_H_
8 #define _PROCESSING_MODULE_PREREQUISITES_H_
9 
10 #include <stdint.h>
11 #include <stddef.h>
12 
13 namespace intel_adsp
14 {
15 	/*!
16 	 * \brief "Scoped enumeration" of values which specify data buffer alignment of input or
17 	 * output stream buffer.
18 	 */
19 	struct StreamBufferAlignment {
20 		/*! \brief the enumeration type of StreamBufferAlignment "scoped enumeration" */
21 		enum WordSize {
22 			/*! \brief enumeration tag for 4-bytes aligned buffer */
23 			_4_BYTES = 4,
24 			/*! \brief enumeration tag for 8-bytes aligned buffer */
25 			_8_BYTES = 8
26 		};
27 
28 		/*! \brief Type of the inner integral value */
29 		typedef uint8_t Type;
30 
31 		/*! \brief Initializes a new instance of StreamBufferAlignment with value set
32 		 * to _4_BYTES
33 		 */
StreamBufferAlignmentStreamBufferAlignment34 		StreamBufferAlignment(void)
35 			:   value(_4_BYTES)
36 		{}
37 
38 		/*! \brief Initializes a new instance of StreamBufferAlignment given
39 		 * a StreamBufferAlignment::WordSize value
40 		 */
StreamBufferAlignmentStreamBufferAlignment41 		StreamBufferAlignment(WordSize val)
42 			:   value(val)
43 		{}
44 
45 		/*! \brief Initializes a new instance of StreamBufferAlignment given
46 		 * a StreamBufferAlignment::Type value
47 		 */
StreamBufferAlignmentStreamBufferAlignment48 		explicit StreamBufferAlignment(Type val)
49 			:   value(val)
50 		{}
51 
52 		/*! \brief Copy constructor */
StreamBufferAlignmentStreamBufferAlignment53 		StreamBufferAlignment(const StreamBufferAlignment &ref)
54 			:   value(ref.value)
55 		{}
56 
57 		/*! \brief Implicit cast operator to IoChunkAligment::WordSize */
WordSizeStreamBufferAlignment58 		operator WordSize(void)
59 		{
60 			return (WordSize) value;
61 		}
62 
63 		/*! \brief Implicit cast operator to IoChunkAligment::Type */
TypeStreamBufferAlignment64 		operator Type(void)
65 		{
66 			return value;
67 		}
68 
69 		/*! \brief default assignment operator */
70 		StreamBufferAlignment &operator = (const StreamBufferAlignment &src)
71 		{
72 			value = src.value;
73 			return *this;
74 		}
75 
76 		/*! \brief assignment operator given a StreamBufferAlignment::WordSize value */
77 		StreamBufferAlignment &operator = (const StreamBufferAlignment::WordSize &src)
78 		{
79 			value = src;
80 			return *this;
81 		}
82 
83 		/*! \brief implement comparison operator */
84 		bool operator>(const StreamBufferAlignment &r) const
85 		{ return value > r.value; }
86 
87 		/*! \brief implement comparison operator */
88 		bool operator<(const StreamBufferAlignment &r) const
89 		{ return value < r.value; }
90 
91 		/*! \brief implement comparison operator */
92 		bool operator == (const StreamBufferAlignment &r) const
93 		{ return value == r.value; }
94 
95 		/*! \brief implement comparison operator */
96 		bool operator != (const StreamBufferAlignment &r) const
97 		{ return value != r.value; }
98 
99 	private:
100 		/*! \brief inner integral value for the StreamBufferAlignment */
101 		Type value;
102 	};
103 
104 	/*!
105 	 * \brief Descriptor on prerequisites for ProcessingModuleInterface instance creation.
106 	 */
107 	struct ProcessingModulePrerequisites {
108 	public:
109 		/*! \brief Initializes a new instance of ProcessingModulePrerequisites
110 		 * with default values
111 		 */
ProcessingModulePrerequisitesProcessingModulePrerequisites112 		ProcessingModulePrerequisites()
113 			:   stream_buffer_alignment(StreamBufferAlignment::_4_BYTES),
114 			    input_pins_count(0), output_pins_count(0), event_count(0)
115 		{}
116 
117 		/*! \brief holds the buffer alignment constraint in size of bytes for input
118 		 *  or output chunk buffer
119 		 *
120 		 * Default constructor set this field value to StreamBufferAlignment::_4_BYTES.
121 		 */
122 		StreamBufferAlignment stream_buffer_alignment;
123 
124 		/*! \brief Indicates the count of input pins for the module type about
125 		 *  to be created.
126 		 */
127 		size_t input_pins_count;
128 		/*! \brief Indicates the count of output pins for the module type about
129 		 * to be created.
130 		 */
131 		size_t output_pins_count;
132 		/*! \brief Indicates the count of events for the module type about
133 		 *  to be created.
134 		 */
135 		size_t event_count;
136 	};
137 }
138 
139 #endif /* _PROCESSING_MODULE_PREREQUISITES_H_ */
140