menu "USB-OTG"
    visible if IDF_TARGET_ESP32S2 || IDF_TARGET_ESP32S3

    # Invisible item, enabled when USB_OTG peripheral does exist
    config USB_OTG_SUPPORTED
        bool
        default y if IDF_TARGET_ESP32S2 || IDF_TARGET_ESP32S3

    config USB_HOST_CONTROL_TRANSFER_MAX_SIZE
        depends on USB_OTG_SUPPORTED
        int "Largest size (in bytes) of transfers to/from default endpoints"
        default 256
        help
            Each USB device attached is allocated a dedicated buffer for its OUT/IN transfers to/from the device's
            control endpoint. The maximum size of that buffer is determined by this option. The limited size of the
            transfer buffer have the following implications:
            - The maximum length of control transfers is limited
            - Device's with configuration descriptors larger than this limit cannot be supported

    choice USB_HOST_HW_BUFFER_BIAS
        depends on USB_OTG_SUPPORTED
        prompt "Hardware FIFO size biasing"
        default USB_HOST_HW_BUFFER_BIAS_BALANCED
        help
            The underlying hardware has size adjustable FIFOs to cache USB packets on reception (IN) or for
            transmission (OUT). The size of these FIFOs will affect the largest MPS (maximum packet size) and the
            maximum number of packets that can be cached at any one time. The hardware contains the following
            FIFOS: RX (for all IN packets), Non-periodic TX (for Bulk and Control OUT packets), and Periodic TX
            (for Interrupt and Isochronous OUT packets). This configuration option allows biasing the FIFO sizes
            towards a particular use case, which may be necessary for devices that have endpoints with large MPS.
            The MPS limits for each biasing are listed below:

            Balanced:
            - IN (all transfer types), 408 bytes
            - OUT non-periodic (Bulk/Control), 192 bytes (i.e., 3 x 64 byte packets)
            - OUT periodic (Interrupt/Isochronous), 192 bytes

            Bias IN:
            - IN (all transfer types), 600 bytes
            - OUT non-periodic (Bulk/Control), 64 bytes (i.e., 1 x 64 byte packets)
            - OUT periodic (Interrupt/Isochronous), 128 bytes

            Bias Periodic OUT:
            - IN (all transfer types), 128 bytes
            - OUT non-periodic (Bulk/Control), 64 bytes (i.e., 1 x 64 byte packets)
            - OUT periodic (Interrupt/Isochronous), 600 bytes

        config USB_HOST_HW_BUFFER_BIAS_BALANCED
            bool "Balanced"
        config USB_HOST_HW_BUFFER_BIAS_IN
            bool "Bias IN"
        config USB_HOST_HW_BUFFER_BIAS_PERIODIC_OUT
            bool "Periodic OUT"
    endchoice

endmenu #USB-OTG
