Lines Matching refs:node
28 #define ARRAY_ELEMENT_LESS_THAN_NEXT(node, prop, idx) \ argument
29 COND_CODE_1(IS_EQ(idx, UTIL_DEC(DT_PROP_LEN(node, prop))), \
31 ((DT_PROP_BY_IDX(node, prop, idx) < \
32 DT_PROP_BY_IDX(node, prop, UTIL_INC(idx)))))
33 #define IS_ARRAY_SORTED(node, prop) \ argument
34 DT_FOREACH_PROP_ELEM_SEP(node, prop, ARRAY_ELEMENT_LESS_THAN_NEXT, (&&))
118 #define DESCRIPTOR_NAME(prefix, node) uac2_## prefix ## _ ## node argument
231 #define AUDIO_STREAMING_DATA_ENDPOINT_CONTROLS(node) \ argument
232 CONTROL_BITS(node, pitch_control, 0) | \
233 CONTROL_BITS(node, data_overrun_control, 2) | \
234 CONTROL_BITS(node, data_underrun_control, 4)
364 #define ENTITY_HEADERS(node) DT_FOREACH_CHILD(node, ENTITY_HEADER) argument
365 #define ENTITY_HEADERS_ARRAYS(node) DT_FOREACH_CHILD(node, ENTITY_HEADER_ARRAYS) argument
366 #define ENTITY_HEADERS_PTRS(node) DT_FOREACH_CHILD(node, ENTITY_HEADER_PTRS) argument
367 #define ENTITY_HEADERS_LENGTH(node) sizeof((uint8_t []){ENTITY_HEADERS(node)}) argument
369 #define AUDIO_STREAMING_CONTROLS(node) \ argument
377 #define AUDIO_STREAMING_FORMAT_TYPE(node) \ argument
378 COND_CODE_0(DT_PROP(node, external_interface), \
380 #define AUDIO_STREAMING_FORMATS(node) U32_LE(0x00000001) argument
382 #define FEATURE_UNIT_CHANNEL_CLUSTER(node) \ argument
383 IF_ENABLED(DT_NODE_HAS_COMPAT(DT_PROP(node, data_source), \
385 DT_PROP(node, data_source) \
389 #define OUTPUT_TERMINAL_CHANNEL_CLUSTER(node) \ argument
390 IF_ENABLED(DT_NODE_HAS_COMPAT(DT_PROP(node, data_source), \
392 DT_PROP(node, data_source) \
394 IF_ENABLED(DT_NODE_HAS_COMPAT(DT_PROP(node, data_source), \
396 FEATURE_UNIT_CHANNEL_CLUSTER(DT_PROP(node, data_source))\
404 #define AUDIO_STREAMING_CHANNEL_CLUSTER(node) \ argument
405 IF_ENABLED(DT_NODE_HAS_COMPAT(DT_PROP(node, linked_terminal), \
407 DT_PROP(node, linked_terminal) \
409 IF_ENABLED(DT_NODE_HAS_COMPAT(DT_PROP(node, linked_terminal), \
411 DT_PROP(node, linked_terminal)) \
414 #define AUDIO_STREAMING_NUM_SPATIAL_LOCATIONS(node) \ argument
415 NUM_SPATIAL_LOCATIONS(AUDIO_STREAMING_CHANNEL_CLUSTER(node))
416 #define AUDIO_STREAMING_SPATIAL_LOCATIONS(node) \ argument
417 SPATIAL_LOCATIONS(AUDIO_STREAMING_CHANNEL_CLUSTER(node))
420 #define AUDIO_STREAMING_GENERAL_DESCRIPTOR(node) \ argument
424 CONNECTED_ENTITY_ID(node, linked_terminal), /* bTerminalLink */ \
425 AUDIO_STREAMING_CONTROLS(node), /* bmControls*/ \
426 AUDIO_STREAMING_FORMAT_TYPE(node), /* bFormatType */ \
427 AUDIO_STREAMING_FORMATS(node), /* bmFormats */ \
428 AUDIO_STREAMING_NUM_SPATIAL_LOCATIONS(node), /* bNrChannels */ \
429 AUDIO_STREAMING_SPATIAL_LOCATIONS(node), /* bmChannelConfig */ \
435 #define AUDIO_STREAMING_FORMAT_I_TYPE_DESCRIPTOR(node) \ argument
440 DT_PROP(node, subslot_size), /* bSubslotSize */ \
441 DT_PROP(node, bit_resolution), /* bBitResolution */
446 #define AUDIO_STREAMING_FORMAT_IV_TYPE_DESCRIPTOR(node) \ argument
453 #define AUDIO_STREAMING_FORMAT_TYPE_DESCRIPTOR(node) \ argument
454 IF_ENABLED(IS_EQ(AUDIO_STREAMING_FORMAT_TYPE(node), FORMAT_TYPE_I), ( \
455 AUDIO_STREAMING_FORMAT_I_TYPE_DESCRIPTOR(node))) \
456 IF_ENABLED(IS_EQ(AUDIO_STREAMING_FORMAT_TYPE(node), FORMAT_TYPE_IV), ( \
457 AUDIO_STREAMING_FORMAT_IV_TYPE_DESCRIPTOR(node)))
459 #define AUDIO_STREAMING_INTERFACE_DESCRIPTORS_ARRAYS(node) \ argument
460 static uint8_t DESCRIPTOR_NAME(as_general_desc, node)[] = { \
461 AUDIO_STREAMING_GENERAL_DESCRIPTOR(node) \
463 static uint8_t DESCRIPTOR_NAME(as_format_desc, node)[] = { \
464 AUDIO_STREAMING_FORMAT_TYPE_DESCRIPTOR(node) \
468 #define AUDIO_STREAMING_INTERFACE_DESCRIPTORS_PTRS(node) \ argument
469 (struct usb_desc_header *) &DESCRIPTOR_NAME(as_general_desc, node), \
470 (struct usb_desc_header *) &DESCRIPTOR_NAME(as_format_desc, node),
473 #define AC_INTERFACE_HEADER_DESCRIPTOR(node) \ argument
478 DT_PROP(node, audio_function), /* bCategory */ \
479 U16_LE(9 + ENTITY_HEADERS_LENGTH(node)), /* wTotalLength */ \
482 #define AC_INTERFACE_HEADER_DESCRIPTOR_ARRAY(node) \ argument
483 static uint8_t DESCRIPTOR_NAME(ac_header, node)[] = { \
484 AC_INTERFACE_HEADER_DESCRIPTOR(node) \
487 #define AC_INTERFACE_HEADER_DESCRIPTOR_PTR(node) \ argument
488 (struct usb_desc_header *) &DESCRIPTOR_NAME(ac_header, node),
490 #define IS_AUDIOSTREAMING_INTERFACE(node) \ argument
491 DT_NODE_HAS_COMPAT(node, zephyr_uac2_audio_streaming)
493 #define UAC2_NUM_INTERFACES(node) \ argument
495 DT_FOREACH_CHILD_SEP(node, IS_AUDIOSTREAMING_INTERFACE, (+))
497 #define UAC2_ALLOWED_AT_FULL_SPEED(node) \ argument
498 DT_PROP(node, full_speed)
500 #define UAC2_ALLOWED_AT_HIGH_SPEED(node) \ argument
501 DT_PROP(node, high_speed)
504 #define UAC2_INTERFACE_ASSOCIATION_DESCRIPTOR(node) \ argument
508 UAC2_NUM_INTERFACES(node), /* bInterfaceCount */ \
514 #define UAC2_INTERFACE_ASSOCIATION_DESCRIPTOR_ARRAY(node) \ argument
515 IF_ENABLED(UAC2_ALLOWED_AT_FULL_SPEED(node), ( \
516 static uint8_t DESCRIPTOR_NAME(fs_iad, node)[] = { \
517 UAC2_INTERFACE_ASSOCIATION_DESCRIPTOR(node) \
520 IF_ENABLED(UAC2_ALLOWED_AT_HIGH_SPEED(node), ( \
521 static uint8_t DESCRIPTOR_NAME(hs_iad, node)[] = { \
522 UAC2_INTERFACE_ASSOCIATION_DESCRIPTOR(node) \
526 #define UAC2_INTERFACE_ASSOCIATION_FS_DESCRIPTOR_PTR(node) \ argument
527 (struct usb_desc_header *) &DESCRIPTOR_NAME(fs_iad, node),
529 #define UAC2_INTERFACE_ASSOCIATION_HS_DESCRIPTOR_PTR(node) \ argument
530 (struct usb_desc_header *) &DESCRIPTOR_NAME(hs_iad, node),
533 #define AC_INTERFACE_DESCRIPTOR(node) \ argument
538 DT_PROP(node, interrupt_endpoint), /* bNumEndpoints */ \
544 #define AC_INTERFACE_DESCRIPTOR_ARRAY(node) \ argument
545 IF_ENABLED(UAC2_ALLOWED_AT_FULL_SPEED(node), ( \
546 static uint8_t DESCRIPTOR_NAME(fs_ac_interface, node)[] = { \
547 AC_INTERFACE_DESCRIPTOR(node) \
550 IF_ENABLED(UAC2_ALLOWED_AT_HIGH_SPEED(node), ( \
551 static uint8_t DESCRIPTOR_NAME(hs_ac_interface, node)[] = { \
552 AC_INTERFACE_DESCRIPTOR(node) \
556 #define AC_INTERFACE_FS_DESCRIPTOR_PTR(node) \ argument
557 (struct usb_desc_header *) &DESCRIPTOR_NAME(fs_ac_interface, node),
559 #define AC_INTERFACE_HS_DESCRIPTOR_PTR(node) \ argument
560 (struct usb_desc_header *) &DESCRIPTOR_NAME(hs_ac_interface, node),
563 #define AC_ENDPOINT_DESCRIPTOR(node) \ argument
571 #define AC_ENDPOINT_DESCRIPTOR_ARRAY(node) \ argument
572 static uint8_t DESCRIPTOR_NAME(ac_endpoint, node)[] = { \
573 AC_ENDPOINT_DESCRIPTOR(node) \
576 #define AC_ENDPOINT_DESCRIPTOR_PTR(node) \ argument
577 (struct usb_desc_header *) &DESCRIPTOR_NAME(ac_endpoint, node),
579 #define FIND_AUDIOSTREAMING(node, fn, ...) \ argument
580 IF_ENABLED(DT_NODE_HAS_COMPAT(node, zephyr_uac2_audio_streaming), ( \
581 fn(node, __VA_ARGS__)))
583 #define FOR_EACH_AUDIOSTREAMING_INTERFACE(node, fn, ...) \ argument
584 DT_FOREACH_CHILD_VARGS(node, FIND_AUDIOSTREAMING, fn, __VA_ARGS__)
586 #define COUNT_AS_INTERFACES_BEFORE_IDX(node, idx) \ argument
587 + 1 * (DT_NODE_CHILD_IDX(node) < idx)
589 #define AS_INTERFACE_NUMBER(node) \ argument
591 FOR_EACH_AUDIOSTREAMING_INTERFACE(DT_PARENT(node), \
592 COUNT_AS_INTERFACES_BEFORE_IDX, DT_NODE_CHILD_IDX(node))
594 #define AS_HAS_ISOCHRONOUS_DATA_ENDPOINT(node) \ argument
595 UTIL_NOT(DT_PROP(node, external_interface))
597 #define AS_IS_USB_ISO_IN(node) \ argument
598 UTIL_AND(AS_HAS_ISOCHRONOUS_DATA_ENDPOINT(node), \
599 DT_NODE_HAS_COMPAT(DT_PROP(node, linked_terminal), \
602 #define AS_IS_USB_ISO_OUT(node) \ argument
603 UTIL_AND(AS_HAS_ISOCHRONOUS_DATA_ENDPOINT(node), \
604 DT_NODE_HAS_COMPAT(DT_PROP(node, linked_terminal), \
621 #define AS_CLK_SOURCE(node) \ argument
622 DT_PROP(DT_PROP(node, linked_terminal), clock_source)
624 #define AS_CLK_MAX_FREQUENCY(node) \ argument
625 CLK_MAX_FREQUENCY(AS_CLK_SOURCE(node))
627 #define AS_IS_SOF_SYNCHRONIZED(node) \ argument
628 CLK_IS_SOF_SYNCHRONIZED(AS_CLK_SOURCE(node))
630 #define AS_HAS_EXPLICIT_FEEDBACK_ENDPOINT(node) \ argument
631 UTIL_AND(UTIL_AND(AS_HAS_ISOCHRONOUS_DATA_ENDPOINT(node), \
632 UTIL_NOT(DT_PROP(node, implicit_feedback))), \
633 UTIL_AND(UTIL_NOT(AS_IS_SOF_SYNCHRONIZED(node)), \
634 AS_IS_USB_ISO_OUT(node)))
636 #define AS_INTERFACE_NUM_ENDPOINTS(node) \ argument
637 (AS_HAS_ISOCHRONOUS_DATA_ENDPOINT(node) + \
638 AS_HAS_EXPLICIT_FEEDBACK_ENDPOINT(node))
641 #define AS_INTERFACE_DESCRIPTOR(node, alternate, numendpoints) \ argument
644 AS_INTERFACE_NUMBER(node), /* bInterfaceNumber */ \
652 #define AS_INTERFACE_FS_DESCRIPTOR_ARRAY(node, alternate, numendpoints) \ argument
653 static uint8_t DESCRIPTOR_NAME(fs_as_if_alt##alternate, node)[] = { \
654 AS_INTERFACE_DESCRIPTOR(node, alternate, numendpoints) \
657 #define AS_INTERFACE_HS_DESCRIPTOR_ARRAY(node, alternate, numendpoints) \ argument
658 static uint8_t DESCRIPTOR_NAME(hs_as_if_alt##alternate, node)[] = { \
659 AS_INTERFACE_DESCRIPTOR(node, alternate, numendpoints) \
662 #define AS_INTERFACE_DESCRIPTOR_ARRAY(node, alternate, numendpoints) \ argument
663 IF_ENABLED(UAC2_ALLOWED_AT_FULL_SPEED(DT_PARENT(node)), ( \
664 AS_INTERFACE_FS_DESCRIPTOR_ARRAY(node, alternate, numendpoints) \
666 IF_ENABLED(UAC2_ALLOWED_AT_HIGH_SPEED(DT_PARENT(node)), ( \
667 AS_INTERFACE_HS_DESCRIPTOR_ARRAY(node, alternate, numendpoints) \
670 #define AS_INTERFACE_FS_DESCRIPTOR_PTR(node, altnum) \ argument
671 (struct usb_desc_header *) &DESCRIPTOR_NAME(fs_as_if_alt##altnum, node),
673 #define AS_INTERFACE_HS_DESCRIPTOR_PTR(node, altnum) \ argument
674 (struct usb_desc_header *) &DESCRIPTOR_NAME(hs_as_if_alt##altnum, node),
676 #define COUNT_AS_OUT_ENDPOINTS_BEFORE_IDX(node, idx) \ argument
677 + AS_IS_USB_ISO_OUT(node) * (DT_NODE_CHILD_IDX(node) < idx)
679 #define COUNT_AS_IN_ENDPOINTS_BEFORE_IDX(node, idx) \ argument
680 + (AS_IS_USB_ISO_IN(node) + AS_HAS_EXPLICIT_FEEDBACK_ENDPOINT(node)) \
681 * (DT_NODE_CHILD_IDX(node) < idx)
692 #define AS_NEXT_OUT_EP_ADDR(node) \ argument
694 FOR_EACH_AUDIOSTREAMING_INTERFACE(DT_PARENT(node), \
695 COUNT_AS_OUT_ENDPOINTS_BEFORE_IDX, DT_NODE_CHILD_IDX(node))
697 #define AS_NEXT_IN_EP_ADDR(node) \ argument
698 FIRST_IN_EP_ADDR + DT_PROP(DT_PARENT(node), interrupt_endpoint) + \
699 FOR_EACH_AUDIOSTREAMING_INTERFACE(DT_PARENT(node), \
700 COUNT_AS_IN_ENDPOINTS_BEFORE_IDX, DT_NODE_CHILD_IDX(node))
702 #define AS_DATA_EP_ADDR(node) \ argument
703 COND_CODE_1(AS_IS_USB_ISO_OUT(node), \
704 (AS_NEXT_OUT_EP_ADDR(node)), \
705 (AS_NEXT_IN_EP_ADDR(node)))
707 #define AS_BYTES_PER_SAMPLE(node) \ argument
708 DT_PROP(node, subslot_size)
711 #define AS_SAMPLES_PER_FRAME(node) \ argument
712 ((ROUND_UP(AS_CLK_MAX_FREQUENCY(node), 1000) / 1000) + \
713 UTIL_NOT(AS_IS_SOF_SYNCHRONIZED(node)))
715 #define AS_SAMPLES_PER_MICROFRAME(node) \ argument
716 ((ROUND_UP(AS_CLK_MAX_FREQUENCY(node), 8000) / 8000) + \
717 UTIL_NOT(AS_IS_SOF_SYNCHRONIZED(node)))
719 #define AS_DATA_EP_SYNC_TYPE(node) \ argument
720 COND_CODE_1(AS_IS_SOF_SYNCHRONIZED(node), (0x3 << 2), (0x1 << 2))
722 #define AS_DATA_EP_USAGE_TYPE(node) \ argument
723 COND_CODE_1(UTIL_AND(DT_PROP(node, implicit_feedback), \
724 UTIL_NOT(AS_IS_USB_ISO_OUT(node))), (0x2 << 4), (0x0 << 4))
726 #define AS_DATA_EP_ATTR(node) \ argument
727 USB_EP_TYPE_ISO | AS_DATA_EP_SYNC_TYPE(node) | \
728 AS_DATA_EP_USAGE_TYPE(node)
730 #define AS_FS_DATA_EP_MAX_PACKET_SIZE(node) \ argument
731 AUDIO_STREAMING_NUM_SPATIAL_LOCATIONS(node) * \
732 AS_BYTES_PER_SAMPLE(node) * AS_SAMPLES_PER_FRAME(node)
734 #define AS_HS_DATA_EP_TPL(node) \ argument
735 USB_TPL_ROUND_UP(AUDIO_STREAMING_NUM_SPATIAL_LOCATIONS(node) * \
736 AS_BYTES_PER_SAMPLE(node) * AS_SAMPLES_PER_MICROFRAME(node))
738 #define AS_HS_DATA_EP_MAX_PACKET_SIZE(node) \ argument
739 USB_TPL_TO_MPS(AS_HS_DATA_EP_TPL(node))
742 #define STANDARD_AS_ISOCHRONOUS_DATA_ENDPOINT_FS_DESCRIPTOR(node) \ argument
745 AS_DATA_EP_ADDR(node), /* bEndpointAddress */ \
746 AS_DATA_EP_ATTR(node), /* bmAttributes */ \
747 U16_LE(AS_FS_DATA_EP_MAX_PACKET_SIZE(node)), /* wMaxPacketSize */ \
750 #define AS_ISOCHRONOUS_DATA_ENDPOINT_FS_DESCRIPTORS_ARRAYS(node) \ argument
751 static uint8_t DESCRIPTOR_NAME(fs_std_data_ep, node)[] = { \
752 STANDARD_AS_ISOCHRONOUS_DATA_ENDPOINT_FS_DESCRIPTOR(node) \
755 #define STANDARD_AS_ISOCHRONOUS_DATA_ENDPOINT_HS_DESCRIPTOR(node) \ argument
758 AS_DATA_EP_ADDR(node), /* bEndpointAddress */ \
759 AS_DATA_EP_ATTR(node), /* bmAttributes */ \
760 U16_LE(AS_HS_DATA_EP_MAX_PACKET_SIZE(node)), /* wMaxPacketSize */ \
763 #define AS_ISOCHRONOUS_DATA_ENDPOINT_HS_DESCRIPTORS_ARRAYS(node) \ argument
764 static uint8_t DESCRIPTOR_NAME(hs_std_data_ep, node)[] = { \
765 STANDARD_AS_ISOCHRONOUS_DATA_ENDPOINT_HS_DESCRIPTOR(node) \
768 #define LOCK_DELAY_UNITS(node) \ argument
769 COND_CODE_1(DT_NODE_HAS_PROP(node, lock_delay_units), \
770 (1 + DT_ENUM_IDX(node, lock_delay_units)), \
774 #define CLASS_SPECIFIC_AS_ISOCHRONOUS_DATA_ENDPOINT_DESCRIPTOR(node) \ argument
779 AUDIO_STREAMING_DATA_ENDPOINT_CONTROLS(node), /* bmControls */ \
780 LOCK_DELAY_UNITS(node), /* bLockDelayUnits */ \
781 U16_LE(DT_PROP_OR(node, lock_delay, 0)), /* wLockDelay */
784 #define AS_ISOCHRONOUS_DATA_ENDPOINT_CS_DESCRIPTORS_ARRAYS(node) \ argument
785 static uint8_t DESCRIPTOR_NAME(cs_data_ep, node)[] = { \
786 CLASS_SPECIFIC_AS_ISOCHRONOUS_DATA_ENDPOINT_DESCRIPTOR(node) \
789 #define AS_ISOCHRONOUS_DATA_ENDPOINT_FS_DESCRIPTORS_PTRS(node) \ argument
790 (struct usb_desc_header *) &DESCRIPTOR_NAME(fs_std_data_ep, node), \
791 (struct usb_desc_header *) &DESCRIPTOR_NAME(cs_data_ep, node),
793 #define AS_ISOCHRONOUS_DATA_ENDPOINT_HS_DESCRIPTORS_PTRS(node) \ argument
794 (struct usb_desc_header *) &DESCRIPTOR_NAME(hs_std_data_ep, node), \
795 (struct usb_desc_header *) &DESCRIPTOR_NAME(cs_data_ep, node),
797 #define AS_EXPLICIT_FEEDBACK_ENDPOINT_FS_DESCRIPTOR(node) \ argument
800 AS_NEXT_IN_EP_ADDR(node), /* bEndpointAddress */ \
805 #define AS_EXPLICIT_FEEDBACK_FS_DESCRIPTOR_ARRAY(node) \ argument
806 static uint8_t DESCRIPTOR_NAME(fs_feedback_ep, node)[] = { \
807 AS_EXPLICIT_FEEDBACK_ENDPOINT_FS_DESCRIPTOR(node) \
810 #define AS_EXPLICIT_FEEDBACK_ENDPOINT_FS_DESCRIPTOR_PTR(node) \ argument
811 (struct usb_desc_header *) &DESCRIPTOR_NAME(fs_feedback_ep, node),
813 #define AS_EXPLICIT_FEEDBACK_ENDPOINT_HS_DESCRIPTOR(node) \ argument
816 AS_NEXT_IN_EP_ADDR(node), /* bEndpointAddress */ \
821 #define AS_EXPLICIT_FEEDBACK_HS_DESCRIPTOR_ARRAY(node) \ argument
822 static uint8_t DESCRIPTOR_NAME(hs_feedback_ep, node)[] = { \
823 AS_EXPLICIT_FEEDBACK_ENDPOINT_HS_DESCRIPTOR(node) \
826 #define AS_EXPLICIT_FEEDBACK_ENDPOINT_HS_DESCRIPTOR_PTR(node) \ argument
827 (struct usb_desc_header *) &DESCRIPTOR_NAME(hs_feedback_ep, node),
829 #define AS_FS_DESCRIPTORS_ARRAYS(node) \ argument
830 IF_ENABLED(AS_HAS_ISOCHRONOUS_DATA_ENDPOINT(node), ( \
831 AS_ISOCHRONOUS_DATA_ENDPOINT_FS_DESCRIPTORS_ARRAYS(node) \
832 IF_ENABLED(AS_HAS_EXPLICIT_FEEDBACK_ENDPOINT(node), ( \
833 AS_EXPLICIT_FEEDBACK_FS_DESCRIPTOR_ARRAY(node))) \
836 #define AS_HS_DESCRIPTORS_ARRAYS(node) \ argument
837 IF_ENABLED(AS_HAS_ISOCHRONOUS_DATA_ENDPOINT(node), ( \
838 AS_ISOCHRONOUS_DATA_ENDPOINT_HS_DESCRIPTORS_ARRAYS(node) \
839 IF_ENABLED(AS_HAS_EXPLICIT_FEEDBACK_ENDPOINT(node), ( \
840 AS_EXPLICIT_FEEDBACK_HS_DESCRIPTOR_ARRAY(node))) \
843 #define AS_DESCRIPTORS_ARRAYS(node) \ argument
844 AS_INTERFACE_DESCRIPTOR_ARRAY(node, 0, 0) \
845 IF_ENABLED(AS_HAS_ISOCHRONOUS_DATA_ENDPOINT(node), ( \
846 AS_INTERFACE_DESCRIPTOR_ARRAY(node, 1, \
847 AS_INTERFACE_NUM_ENDPOINTS(node)))) \
848 AUDIO_STREAMING_INTERFACE_DESCRIPTORS_ARRAYS(node) \
849 IF_ENABLED(UAC2_ALLOWED_AT_FULL_SPEED(DT_PARENT(node)), ( \
850 AS_FS_DESCRIPTORS_ARRAYS(node))) \
851 IF_ENABLED(UAC2_ALLOWED_AT_HIGH_SPEED(DT_PARENT(node)), ( \
852 AS_HS_DESCRIPTORS_ARRAYS(node))) \
853 IF_ENABLED(AS_HAS_ISOCHRONOUS_DATA_ENDPOINT(node), ( \
854 AS_ISOCHRONOUS_DATA_ENDPOINT_CS_DESCRIPTORS_ARRAYS(node)))
856 #define AS_FS_DESCRIPTORS_PTRS(node) \ argument
857 AS_INTERFACE_FS_DESCRIPTOR_PTR(node, 0) \
858 IF_ENABLED(AS_HAS_ISOCHRONOUS_DATA_ENDPOINT(node), ( \
859 AS_INTERFACE_FS_DESCRIPTOR_PTR(node, 1))) \
860 AUDIO_STREAMING_INTERFACE_DESCRIPTORS_PTRS(node) \
861 IF_ENABLED(AS_HAS_ISOCHRONOUS_DATA_ENDPOINT(node), ( \
862 AS_ISOCHRONOUS_DATA_ENDPOINT_FS_DESCRIPTORS_PTRS(node) \
863 IF_ENABLED(AS_HAS_EXPLICIT_FEEDBACK_ENDPOINT(node), ( \
864 AS_EXPLICIT_FEEDBACK_ENDPOINT_FS_DESCRIPTOR_PTR(node))) \
867 #define AS_HS_DESCRIPTORS_PTRS(node) \ argument
868 AS_INTERFACE_HS_DESCRIPTOR_PTR(node, 0) \
869 IF_ENABLED(AS_HAS_ISOCHRONOUS_DATA_ENDPOINT(node), ( \
870 AS_INTERFACE_HS_DESCRIPTOR_PTR(node, 1))) \
871 AUDIO_STREAMING_INTERFACE_DESCRIPTORS_PTRS(node) \
872 IF_ENABLED(AS_HAS_ISOCHRONOUS_DATA_ENDPOINT(node), ( \
873 AS_ISOCHRONOUS_DATA_ENDPOINT_HS_DESCRIPTORS_PTRS(node) \
874 IF_ENABLED(AS_HAS_EXPLICIT_FEEDBACK_ENDPOINT(node), ( \
875 AS_EXPLICIT_FEEDBACK_ENDPOINT_HS_DESCRIPTOR_PTR(node))) \
878 #define AS_DESCRIPTORS_ARRAYS_IF_AUDIOSTREAMING(node) \ argument
879 IF_ENABLED(DT_NODE_HAS_COMPAT(node, zephyr_uac2_audio_streaming), ( \
880 AS_DESCRIPTORS_ARRAYS(node)))
882 #define AS_FS_DESCRIPTORS_PTRS_IF_AUDIOSTREAMING(node) \ argument
883 IF_ENABLED(DT_NODE_HAS_COMPAT(node, zephyr_uac2_audio_streaming), ( \
884 AS_FS_DESCRIPTORS_PTRS(node)))
886 #define AS_HS_DESCRIPTORS_PTRS_IF_AUDIOSTREAMING(node) \ argument
887 IF_ENABLED(DT_NODE_HAS_COMPAT(node, zephyr_uac2_audio_streaming), ( \
888 AS_HS_DESCRIPTORS_PTRS(node)))
890 #define UAC2_AUDIO_CONTROL_DESCRIPTOR_ARRAYS(node) \ argument
891 AC_INTERFACE_DESCRIPTOR_ARRAY(node) \
892 AC_INTERFACE_HEADER_DESCRIPTOR_ARRAY(node) \
893 ENTITY_HEADERS_ARRAYS(node) \
894 IF_ENABLED(DT_PROP(node, interrupt_endpoint), ( \
895 AC_ENDPOINT_DESCRIPTOR_ARRAY(node)))
897 #define UAC2_AUDIO_CONTROL_COMMON_DESCRIPTOR_PTRS(node) \ argument
898 AC_INTERFACE_HEADER_DESCRIPTOR_PTR(node) \
899 ENTITY_HEADERS_PTRS(node) \
900 IF_ENABLED(DT_PROP(node, interrupt_endpoint), ( \
901 AC_ENDPOINT_DESCRIPTOR_PTR(node)))
903 #define UAC2_AUDIO_CONTROL_FS_DESCRIPTOR_PTRS(node) \ argument
904 AC_INTERFACE_FS_DESCRIPTOR_PTR(node) \
905 UAC2_AUDIO_CONTROL_COMMON_DESCRIPTOR_PTRS(node)
907 #define UAC2_AUDIO_CONTROL_HS_DESCRIPTOR_PTRS(node) \ argument
908 AC_INTERFACE_HS_DESCRIPTOR_PTR(node) \
909 UAC2_AUDIO_CONTROL_COMMON_DESCRIPTOR_PTRS(node)
911 #define UAC2_DESCRIPTOR_ARRAYS(node) \ argument
912 UAC2_INTERFACE_ASSOCIATION_DESCRIPTOR_ARRAY(node) \
913 UAC2_AUDIO_CONTROL_DESCRIPTOR_ARRAYS(node) \
914 DT_FOREACH_CHILD(node, AS_DESCRIPTORS_ARRAYS_IF_AUDIOSTREAMING)
916 #define UAC2_FS_DESCRIPTOR_PTRS(node) \ argument
917 UAC2_INTERFACE_ASSOCIATION_FS_DESCRIPTOR_PTR(node) \
918 UAC2_AUDIO_CONTROL_FS_DESCRIPTOR_PTRS(node) \
919 DT_FOREACH_CHILD(node, AS_FS_DESCRIPTORS_PTRS_IF_AUDIOSTREAMING) \
922 #define UAC2_HS_DESCRIPTOR_PTRS(node) \ argument
923 UAC2_INTERFACE_ASSOCIATION_HS_DESCRIPTOR_PTR(node) \
924 UAC2_AUDIO_CONTROL_HS_DESCRIPTOR_PTRS(node) \
925 DT_FOREACH_CHILD(node, AS_HS_DESCRIPTORS_PTRS_IF_AUDIOSTREAMING) \
928 #define UAC2_FS_DESCRIPTOR_PTRS_ARRAY(node) \ argument
929 COND_CODE_1(UAC2_ALLOWED_AT_FULL_SPEED(node), \
930 ({UAC2_FS_DESCRIPTOR_PTRS(node)}), ({NULL}))
932 #define UAC2_HS_DESCRIPTOR_PTRS_ARRAY(node) \ argument
933 COND_CODE_1(UAC2_ALLOWED_AT_HIGH_SPEED(node), \
934 ({UAC2_HS_DESCRIPTOR_PTRS(node)}), ({NULL}))
940 #define COUNT_AS_DESCRIPTORS_UP_TO_IDX(node, idx) \ argument
941 (COUNT_PTRS(COND_CODE_1(UAC2_ALLOWED_AT_FULL_SPEED(DT_PARENT(node)), \
942 (AS_FS_DESCRIPTORS_PTRS_IF_AUDIOSTREAMING(node)), \
943 (AS_HS_DESCRIPTORS_PTRS_IF_AUDIOSTREAMING(node))))) * \
944 (DT_NODE_CHILD_IDX(node) <= idx)
946 #define UAC2_DESCRIPTOR_AS_DESC_END_COUNT(node) \ argument
947 (COUNT_PTRS(COND_CODE_1(UAC2_ALLOWED_AT_FULL_SPEED(DT_PARENT(node)), ( \
948 UAC2_INTERFACE_ASSOCIATION_FS_DESCRIPTOR_PTR(DT_PARENT(node)) \
949 UAC2_AUDIO_CONTROL_FS_DESCRIPTOR_PTRS(DT_PARENT(node)) \
951 UAC2_INTERFACE_ASSOCIATION_HS_DESCRIPTOR_PTR(DT_PARENT(node)) \
952 UAC2_AUDIO_CONTROL_HS_DESCRIPTOR_PTRS(DT_PARENT(node)) \
953 )))) + DT_FOREACH_CHILD_SEP_VARGS(DT_PARENT(node), \
955 DT_NODE_CHILD_IDX(node))
957 #define AS_ISOCHRONOUS_DATA_ENDPOINT_DESCRIPTORS_COUNT(node) \ argument
958 COUNT_PTRS(COND_CODE_1(UAC2_ALLOWED_AT_FULL_SPEED(DT_PARENT(node)), ( \
959 AS_ISOCHRONOUS_DATA_ENDPOINT_FS_DESCRIPTORS_PTRS(node) \
961 AS_ISOCHRONOUS_DATA_ENDPOINT_HS_DESCRIPTORS_PTRS(node) \
964 #define AS_EXPLICIT_FEEDBACK_ENDPOINT_DESCRIPTOR_COUNT(node) \ argument
965 COND_CODE_1(AS_HAS_EXPLICIT_FEEDBACK_ENDPOINT(node), (COUNT_PTRS( \
966 COND_CODE_1(UAC2_ALLOWED_AT_FULL_SPEED(DT_PARENT(node)), ( \
967 AS_EXPLICIT_FEEDBACK_ENDPOINT_FS_DESCRIPTOR_PTR(node) \
969 AS_EXPLICIT_FEEDBACK_ENDPOINT_HS_DESCRIPTOR_PTR(node) \
980 #define UAC2_DESCRIPTOR_AS_DATA_EP_INDEX(node) \ argument
981 UAC2_DESCRIPTOR_AS_DESC_END_COUNT(node) \
982 - AS_EXPLICIT_FEEDBACK_ENDPOINT_DESCRIPTOR_COUNT(node) \
983 - AS_ISOCHRONOUS_DATA_ENDPOINT_DESCRIPTORS_COUNT(node)
992 #define UAC2_DESCRIPTOR_AS_FEEDBACK_EP_INDEX(node) \ argument
993 UAC2_DESCRIPTOR_AS_DESC_END_COUNT(node) \
994 - AS_EXPLICIT_FEEDBACK_ENDPOINT_DESCRIPTOR_COUNT(node)
1045 #define NEEDS_SUBSLOT_SIZE_AND_BIT_RESOLUTION(node) UTIL_OR( \ argument
1046 UTIL_OR(IS_EQ(AUDIO_STREAMING_FORMAT_TYPE(node), FORMAT_TYPE_I), \
1047 IS_EQ(AUDIO_STREAMING_FORMAT_TYPE(node), FORMAT_TYPE_III)), \
1048 UTIL_OR(IS_EQ(AUDIO_STREAMING_FORMAT_TYPE(node), EXT_FORMAT_TYPE_I), \
1049 IS_EQ(AUDIO_STREAMING_FORMAT_TYPE(node), EXT_FORMAT_TYPE_III)))
1051 #define VALIDATE_SUBSLOT_SIZE(node) \ argument
1052 (DT_PROP(node, subslot_size) >= 1 && DT_PROP(node, subslot_size) <= 4)
1054 #define VALIDATE_BIT_RESOLUTION(node) \ argument
1055 (DT_PROP(node, bit_resolution) <= (DT_PROP(node, subslot_size) * 8))
1057 #define VALIDATE_LINKED_TERMINAL(node) \ argument
1058 UTIL_OR(DT_NODE_HAS_COMPAT(DT_PROP(node, linked_terminal), \
1060 DT_NODE_HAS_COMPAT(DT_PROP(node, linked_terminal), \
1063 #define VALIDATE_AS_BANDWIDTH(node) \ argument
1064 IF_ENABLED(UAC2_ALLOWED_AT_FULL_SPEED(DT_PARENT(node)), ( \
1065 BUILD_ASSERT(AS_FS_DATA_EP_MAX_PACKET_SIZE(node) <= 1023, \
1068 IF_ENABLED(UAC2_ALLOWED_AT_HIGH_SPEED(DT_PARENT(node)), ( \
1069 BUILD_ASSERT(USB_TPL_IS_VALID(AS_HS_DATA_EP_TPL(node)), \
1073 #define VALIDATE_NODE(node) \ argument
1074 IF_ENABLED(DT_NODE_HAS_COMPAT(node, zephyr_uac2_clock_source), ( \
1075 BUILD_ASSERT(DT_PROP_LEN(node, sampling_frequencies), \
1077 BUILD_ASSERT(IS_ARRAY_SORTED(node, sampling_frequencies), \
1080 IF_ENABLED(DT_NODE_HAS_COMPAT(node, zephyr_uac2_input_terminal), ( \
1081 BUILD_ASSERT(!((SPATIAL_LOCATIONS_U32(node) & BIT(31))) || \
1082 SPATIAL_LOCATIONS_U32(node) == BIT(31), \
1084 BUILD_ASSERT(VALIDATE_INPUT_TERMINAL_ASSOCIATION(node), \
1087 IF_ENABLED(DT_NODE_HAS_COMPAT(node, zephyr_uac2_output_terminal), ( \
1088 BUILD_ASSERT(VALIDATE_OUTPUT_TERMINAL_ASSOCIATION(node), \
1090 BUILD_ASSERT(VALIDATE_OUTPUT_TERMINAL_DATA_SOURCE(node), \
1093 IF_ENABLED(DT_NODE_HAS_COMPAT(node, zephyr_uac2_feature_unit), ( \
1094 BUILD_ASSERT(VALIDATE_FEATURE_UNIT_DATA_SOURCE(node), \
1096 BUILD_ASSERT_FEATURE_UNIT_CONTROLS_LENGTH(node); \
1098 IF_ENABLED(DT_NODE_HAS_COMPAT(node, zephyr_uac2_audio_streaming), ( \
1099 BUILD_ASSERT(VALIDATE_LINKED_TERMINAL(node), \
1101 BUILD_ASSERT(!NEEDS_SUBSLOT_SIZE_AND_BIT_RESOLUTION(node) || \
1102 VALIDATE_SUBSLOT_SIZE(node), \
1104 BUILD_ASSERT(!NEEDS_SUBSLOT_SIZE_AND_BIT_RESOLUTION(node) || \
1105 VALIDATE_BIT_RESOLUTION(node), \
1107 BUILD_ASSERT(!DT_PROP(node, implicit_feedback) || \
1108 !AS_IS_SOF_SYNCHRONIZED(node), \
1110 IF_ENABLED(AS_HAS_ISOCHRONOUS_DATA_ENDPOINT(node), ( \
1111 VALIDATE_AS_BANDWIDTH(node))) \