Lines Matching full:entity

114 /* Automatically assign Entity IDs based on entities order in devicetree */
120 /* Connected Entity ID or 0 if property is not defined. Rely on devicetree
124 #define CONNECTED_ENTITY_ID(entity, phandle) \ argument
125 COND_CODE_1(DT_NODE_HAS_PROP(entity, phandle), \
126 (ENTITY_ID(DT_PHANDLE_BY_IDX(entity, phandle, 0))), (0))
128 #define ID_IF_TERMINAL_ASSOCIATES_WITH_TARGET(entity, target_id) \ argument
130 CONNECTED_ENTITY_ID(entity, assoc_terminal), target_id), \
132 DT_NODE_HAS_COMPAT(entity, zephyr_uac2_input_terminal), \
133 DT_NODE_HAS_COMPAT(entity, zephyr_uac2_output_terminal) \
134 )), (ENTITY_ID(entity)))
136 /* Find ID of terminal entity associated with given terminal entity. This macro
137 * evaluates to "+ 0" if there isn't any terminal entity associated. If there
142 * If there is more than one associated entity, then it will fail at build time
145 #define FIND_ASSOCIATED_TERMINAL(entity) \ argument
146 DT_FOREACH_CHILD_VARGS(DT_PARENT(entity), \
147 ID_IF_TERMINAL_ASSOCIATES_WITH_TARGET, ENTITY_ID(entity)) + 0
149 /* If entity has assoc_terminal property, return the entity ID of associated
150 * terminal. Otherwise, search if any other terminal entity points to us and
157 #define ASSOCIATED_TERMINAL_ID(entity) \ argument
158 COND_CODE_1(DT_NODE_HAS_PROP(entity, assoc_terminal), \
159 (CONNECTED_ENTITY_ID(entity, assoc_terminal)), \
160 (FIND_ASSOCIATED_TERMINAL(entity)))
163 #define CLOCK_SOURCE_ATTRIBUTES(entity) \ argument
164 (DT_ENUM_IDX(entity, clock_type)) | \
165 (DT_PROP(entity, sof_synchronized) << 2)
178 #define CONTROL_TOKEN(entity, control_name) \ argument
179 COND_CODE_1(DT_NODE_HAS_PROP(entity, control_name), \
180 (DT_STRING_UPPER_TOKEN(entity, control_name)), \
183 #define CONTROL_BITS(entity, control_name, bitshift) \ argument
184 (UTIL_CAT(CONTROL_, CONTROL_TOKEN(entity, control_name)) << bitshift)
186 #define CONTROL_TOKEN_BY_IDX(entity, control_name, idx) \ argument
187 COND_CODE_1(DT_PROP_HAS_IDX(entity, control_name, idx), \
188 (DT_STRING_UPPER_TOKEN_BY_IDX(entity, control_name, idx)), \
191 #define CONTROL_BITS_BY_IDX(entity, control_name, idx, bitshift) \ argument
192 (UTIL_CAT(CONTROL_, CONTROL_TOKEN_BY_IDX(entity, control_name, idx)) \
195 #define CLOCK_SOURCE_CONTROLS(entity) \ argument
196 CONTROL_BITS(entity, frequency_control, 0) | \
197 CONTROL_BITS(entity, validity_control, 2)
199 #define INPUT_TERMINAL_CONTROLS(entity) \ argument
200 CONTROL_BITS(entity, copy_protect_control, 0) | \
201 CONTROL_BITS(entity, connector_control, 2) | \
202 CONTROL_BITS(entity, overload_control, 4) | \
203 CONTROL_BITS(entity, cluster_control, 6) | \
204 CONTROL_BITS(entity, underflow_control, 8) | \
205 CONTROL_BITS(entity, overflow_control, 10)
207 #define OUTPUT_TERMINAL_CONTROLS(entity) \ argument
208 CONTROL_BITS(entity, copy_protect_control, 0) | \
209 CONTROL_BITS(entity, connector_control, 2) | \
210 CONTROL_BITS(entity, overload_control, 4) | \
211 CONTROL_BITS(entity, underflow_control, 6) | \
212 CONTROL_BITS(entity, overflow_control, 8)
214 #define FEATURE_UNIT_CHANNEL_CONTROLS(entity, ch) \ argument
215 CONTROL_BITS_BY_IDX(entity, mute_control, ch, 0) | \
216 CONTROL_BITS_BY_IDX(entity, volume_control, ch, 2) | \
217 CONTROL_BITS_BY_IDX(entity, bass_control, ch, 4) | \
218 CONTROL_BITS_BY_IDX(entity, mid_control, ch, 6) | \
219 CONTROL_BITS_BY_IDX(entity, treble_control, ch, 8) | \
220 CONTROL_BITS_BY_IDX(entity, graphic_equalizer_control, ch, 10) | \
221 CONTROL_BITS_BY_IDX(entity, automatic_gain_control, ch, 12) | \
222 CONTROL_BITS_BY_IDX(entity, delay_control, ch, 14) | \
223 CONTROL_BITS_BY_IDX(entity, bass_boost_control, ch, 16) | \
224 CONTROL_BITS_BY_IDX(entity, loudness_control, ch, 18) | \
225 CONTROL_BITS_BY_IDX(entity, input_gain_control, ch, 20) | \
226 CONTROL_BITS_BY_IDX(entity, input_gain_pad_control, ch, 22) | \
227 CONTROL_BITS_BY_IDX(entity, phase_inverter_control, ch, 24) | \
228 CONTROL_BITS_BY_IDX(entity, underflow_control, ch, 26) | \
229 CONTROL_BITS_BY_IDX(entity, overflow_control, ch, 28)
268 #define SPATIAL_LOCATIONS_U32(entity) \ argument
269 (FOR_EACH_IDX(ARRAY_BIT, (|), SPATIAL_LOCATIONS_ARRAY(entity)))
270 #define NUM_SPATIAL_LOCATIONS(entity) \ argument
272 FOR_EACH(EMPTY_ON_ZERO, (,), SPATIAL_LOCATIONS_ARRAY(entity)) \
274 #define SPATIAL_LOCATIONS(entity) U32_LE(SPATIAL_LOCATIONS_U32(entity)) argument
276 #define FEATURE_UNIT_NUM_CHANNELS(entity) \ argument
277 NUM_SPATIAL_LOCATIONS(DT_PHANDLE_BY_IDX(entity, data_source, 0))
279 #define FEATURE_UNIT_CONTROLS_BY_IDX(i, entity) \ argument
280 U32_LE(FEATURE_UNIT_CHANNEL_CONTROLS(entity, i))
282 #define FEATURE_UNIT_CONTROLS_ARRAYS(entity) \ argument
283 LISTIFY(UTIL_INC(FEATURE_UNIT_NUM_CHANNELS(entity)), \
284 FEATURE_UNIT_CONTROLS_BY_IDX, (,), entity)
286 #define FEATURE_UNIT_DESCRIPTOR_LENGTH(entity) \ argument
287 (6 + (FEATURE_UNIT_NUM_CHANNELS(entity) + 1) * 4)
290 #define CLOCK_SOURCE_DESCRIPTOR(entity) \ argument
294 ENTITY_ID(entity), /* bClockID */ \
295 CLOCK_SOURCE_ATTRIBUTES(entity), /* bmAttributes */ \
296 CLOCK_SOURCE_CONTROLS(entity), /* bmControls */ \
297 CONNECTED_ENTITY_ID(entity, assoc_terminal), /* bAssocTerminal */ \
301 #define INPUT_TERMINAL_DESCRIPTOR(entity) \ argument
305 ENTITY_ID(entity), /* bTerminalID */ \
306 U16_LE(DT_PROP(entity, terminal_type)), /* wTerminalType */ \
307 ASSOCIATED_TERMINAL_ID(entity), /* bAssocTerminal */ \
308 CONNECTED_ENTITY_ID(entity, clock_source), /* bCSourceID */ \
309 NUM_SPATIAL_LOCATIONS(entity), /* bNrChannels */ \
310 SPATIAL_LOCATIONS(entity), /* bmChannelConfig */ \
312 U16_LE(INPUT_TERMINAL_CONTROLS(entity)), /* bmControls */ \
316 #define OUTPUT_TERMINAL_DESCRIPTOR(entity) \ argument
320 ENTITY_ID(entity), /* bTerminalID */ \
321 U16_LE(DT_PROP(entity, terminal_type)), /* wTerminalType */ \
322 ASSOCIATED_TERMINAL_ID(entity), /* bAssocTerminal */ \
323 CONNECTED_ENTITY_ID(entity, data_source), /* bSourceID */ \
324 CONNECTED_ENTITY_ID(entity, clock_source), /* bCSourceID */ \
325 U16_LE(OUTPUT_TERMINAL_CONTROLS(entity)), /* bmControls */ \
329 #define FEATURE_UNIT_DESCRIPTOR(entity) \ argument
330 FEATURE_UNIT_DESCRIPTOR_LENGTH(entity), /* bLength */ \
333 ENTITY_ID(entity), /* bUnitID */ \
334 CONNECTED_ENTITY_ID(entity, data_source), /* bSourceID */ \
335 FEATURE_UNIT_CONTROLS_ARRAYS(entity), /* bmaControls 0..ch */ \
338 #define ENTITY_HEADER(entity) \ argument
339 IF_ENABLED(DT_NODE_HAS_COMPAT(entity, zephyr_uac2_clock_source), ( \
340 CLOCK_SOURCE_DESCRIPTOR(entity) \
342 IF_ENABLED(DT_NODE_HAS_COMPAT(entity, zephyr_uac2_input_terminal), ( \
343 INPUT_TERMINAL_DESCRIPTOR(entity) \
345 IF_ENABLED(DT_NODE_HAS_COMPAT(entity, zephyr_uac2_output_terminal), ( \
346 OUTPUT_TERMINAL_DESCRIPTOR(entity) \
348 IF_ENABLED(DT_NODE_HAS_COMPAT(entity, zephyr_uac2_feature_unit), ( \
349 FEATURE_UNIT_DESCRIPTOR(entity) \
352 #define ENTITY_HEADER_ARRAYS(entity) \ argument
353 IF_ENABLED(UTIL_NOT(IS_EMPTY(ENTITY_HEADER(entity))), ( \
354 static uint8_t DESCRIPTOR_NAME(ac_entity, entity)[] = { \
355 ENTITY_HEADER(entity) \
359 #define ENTITY_HEADER_PTRS(entity) \ argument
360 IF_ENABLED(UTIL_NOT(IS_EMPTY(ENTITY_HEADER(entity))), ( \
361 (struct usb_desc_header *) &DESCRIPTOR_NAME(ac_entity, entity), \
370 CONTROL_BITS(entity, active_alternate_setting_control, 0) | \
371 CONTROL_BITS(entity, valid_alternate_settings_control, 2)
388 /* Track back Output Terminal data source to entity that has channel cluster */
402 * entity.
607 #define CLK_IS_SOF_SYNCHRONIZED(entity) \ argument
608 IF_ENABLED(DT_NODE_HAS_COMPAT(entity, zephyr_uac2_clock_source), ( \
609 DT_PROP(entity, sof_synchronized) \
615 #define CLK_MAX_FREQUENCY(entity) \ argument
616 IF_ENABLED(DT_NODE_HAS_COMPAT(entity, zephyr_uac2_clock_source), ( \
617 DT_PROP_BY_IDX(entity, sampling_frequencies, \
618 UTIL_DEC(DT_PROP_LEN(entity, sampling_frequencies))) \
999 #define VALIDATE_INPUT_TERMINAL_ASSOCIATION(entity) \ argument
1000 UTIL_OR(UTIL_NOT(DT_NODE_HAS_PROP(entity, assoc_terminal)), \
1001 DT_NODE_HAS_COMPAT(DT_PROP(entity, assoc_terminal), \
1004 #define VALIDATE_OUTPUT_TERMINAL_ASSOCIATION(entity) \ argument
1005 UTIL_OR(UTIL_NOT(DT_NODE_HAS_PROP(entity, assoc_terminal)), \
1006 DT_NODE_HAS_COMPAT(DT_PROP(entity, assoc_terminal), \
1009 #define VALIDATE_OUTPUT_TERMINAL_DATA_SOURCE(entity) \ argument
1010 UTIL_OR(DT_NODE_HAS_COMPAT(DT_PROP(entity, data_source), \
1012 DT_NODE_HAS_COMPAT(DT_PROP(entity, data_source), \
1015 #define VALIDATE_FEATURE_UNIT_DATA_SOURCE(entity) \ argument
1016 DT_NODE_HAS_COMPAT(DT_PROP(entity, data_source), \
1028 #define BUILD_ASSERT_FEATURE_UNIT_CONTROLS_LENGTH(entity) \ argument
1029 BUILD_ASSERT_FEATURE_UNIT_CONTROL(entity, mute_control) \
1030 BUILD_ASSERT_FEATURE_UNIT_CONTROL(entity, volume_control) \
1031 BUILD_ASSERT_FEATURE_UNIT_CONTROL(entity, bass_control) \
1032 BUILD_ASSERT_FEATURE_UNIT_CONTROL(entity, mid_control) \
1033 BUILD_ASSERT_FEATURE_UNIT_CONTROL(entity, treble_control) \
1034 BUILD_ASSERT_FEATURE_UNIT_CONTROL(entity, graphic_equalizer_control) \
1035 BUILD_ASSERT_FEATURE_UNIT_CONTROL(entity, automatic_gain_control) \
1036 BUILD_ASSERT_FEATURE_UNIT_CONTROL(entity, delay_control) \
1037 BUILD_ASSERT_FEATURE_UNIT_CONTROL(entity, bass_boost_control) \
1038 BUILD_ASSERT_FEATURE_UNIT_CONTROL(entity, loudness_control) \
1039 BUILD_ASSERT_FEATURE_UNIT_CONTROL(entity, input_gain_control) \
1040 BUILD_ASSERT_FEATURE_UNIT_CONTROL(entity, input_gain_pad_control) \
1041 BUILD_ASSERT_FEATURE_UNIT_CONTROL(entity, phase_inverter_control) \
1042 BUILD_ASSERT_FEATURE_UNIT_CONTROL(entity, underflow_control) \
1043 BUILD_ASSERT_FEATURE_UNIT_CONTROL(entity, overflow_control)