Type-C positive and negative insertion dynamic switching method and device, electronic equipment and storage medium

By monitoring polarity switching trigger information and performing status evaluation, backup path pre-configuration, and data stream freezing under the connection status of the Type-C interface, dynamic adjustment of the positive and negative insertion polarity of the Type-C interface is realized without disconnecting the connection. This solves the problem of the inability to dynamically adjust polarity in the existing technology and improves the stability and adaptability of the connection.

CN122064629APending Publication Date: 2026-05-19CIX TECH (SUZHOU) CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
CIX TECH (SUZHOU) CO LTD
Filing Date
2026-04-20
Publication Date
2026-05-19

AI Technical Summary

Technical Problem

The existing Type-C interface cannot dynamically adjust the polarity after the connection is established, which means that it needs to be disconnected and reconnected when the physical position of the device or the cable routing changes, affecting the stability of the connection and data transmission.

Method used

By monitoring polarity switching trigger information in the connected state, and combining techniques such as pre-switching state assessment, backup path pre-configuration, data stream freezing, atomic switching, and post-switching verification, the positive and negative insertion polarity of the Type-C interface can be dynamically adjusted without disconnecting the connection.

Benefits of technology

It reduces switching latency, minimizes the risk of data transmission interruption, improves the smoothness and reliability of the connection process, and enhances adaptability to rotating and dynamic cabling equipment.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122064629A_ABST
    Figure CN122064629A_ABST
Patent Text Reader

Abstract

The invention provides a Type-C forward and reverse insertion dynamic switching method and device, electronic equipment and a storage medium, polarity switching trigger information is monitored in a connection state, and technical means of state evaluation before switching, standby path pre-configuration, data flow freezing, atomic switching, verification after switching, state recovery and the like are combined, so that the Type-C forward and reverse insertion dynamic switching is realized. According to the invention, the Type-C interface can complete the dynamic adjustment of the positive and negative plugging polarity under the condition of not disconnecting the connection, thereby reducing the switching delay, reducing the data transmission interruption risk, improving the smoothness and reliability of the connection process, and enhancing the adaptation capability of the Type-C interface to a rotating device, a dynamic wiring device and an innovative terminal form.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This disclosure relates to the field of interface communication and connection control technology, and more specifically, to a method, apparatus, electronic device and storage medium for dynamic switching of Type-C reversible insertion. Background Technology

[0002] The USB Type-C interface, with its advantages of reversible insertion, small size, strong power supply capability, and compatibility with multiple data transmission and expansion modes, has been widely used in mobile phones, tablets, laptops, display devices, docking stations, and various smart terminals. In existing Type-C connection systems, the insertion direction is typically detected via the Configuration Channel (CC) pin. Based on the detection result, the current polarity is determined, and the VBUS power path, VCONN power path, and USB data path or Alt Mode path are configured accordingly to establish a stable connection. After initial identification and configuration, the system generally maintains this polarity configuration throughout the connection until the device is detected as unplugged, at which point it restarts polarity identification and link establishment.

[0003] However, most existing Type-C reversible insertion identification methods are one-time detection and fixed configuration mechanisms at the time of insertion. Their core characteristic is that they only determine whether the insertion is correct or reversed based on the CC pin state at the initial stage of connection establishment and select the corresponding signal path accordingly. During the subsequent connection maintenance, they do not dynamically adjust for polarity changes. In other words, once the interface connection is established, even if the physical orientation of the device, cable routing, or the relative direction of the interface changes, existing systems typically cannot re-adapt to the new polarity state without disconnecting the connection. Instead, they can only re-complete the detection, enumeration, and negotiation process by disconnecting and re-inserting the device. Summary of the Invention

[0004] This disclosure provides at least one method, apparatus, electronic device, and storage medium for dynamic switching of Type-C reversible insertion. By monitoring polarity switching trigger information during connection, and combining pre-switching state assessment, backup path pre-configuration, data stream freezing, atomic switching, post-switching verification, and state recovery, the Type-C interface can dynamically adjust the reversible insertion polarity without disconnecting the connection. This reduces switching latency, minimizes the risk of data transmission interruption, improves the smoothness and reliability of the connection process, and enhances the adaptability of the Type-C interface to rotating devices, dynamic cabling devices, and innovative terminal forms.

[0005] This disclosure provides a method for dynamic switching of Type-C reversible insertion, including: When the Type-C interface is in a connected state, the system monitors the triggering information that indicates the current connection polarity needs to be adjusted in real time, and generates a switching request when a polarity switching trigger condition is detected. In response to the handover request, the current Type-C connection status is evaluated to determine whether the handover execution conditions are met, and the current connection parameters are recorded when the handover execution conditions are met. Based on the target switching polarity, pre-configuration is performed on the currently inactive backup path so that the backup path is prepared for at least one of the power supply path and data path before the formal switching. Before performing a path switch, the current data stream is frozen to pause new data scheduling and save the current connection session state. After the backup path meets the predetermined ready conditions, an atomic switch is performed between the current active path and the backup path to switch the working polarity of the Type-C interface from the current polarity to the target polarity. After the switch is completed, the integrity of the connection after the switch is verified, and the connection session state before the freeze is restored when the verification is successful; after the restoration is completed, the resources corresponding to the original path are released, and the polarity status information of the current Type-C interface is updated.

[0006] In one optional implementation, in response to the handover request, the current Type-C connection state is evaluated to determine whether the handover execution conditions are met, and the current connection parameters are recorded when the handover execution conditions are met, specifically including: Check if VBUS is in a stable state; Detect the PD negotiation status and current data transmission activity; Based on VBUS stability, PD negotiation status, and data transmission activity, determine whether the current conditions for smooth handover are met. If the conditions for a smooth handover are not met but there is an urgent handover requirement, this handover will be marked as a forced handover mode. If the conditions for a smooth handover are not met and there is no urgent handover requirement, wait for the preset transmission window before performing subsequent handover processing; The recorded current connection parameters include at least one of the following: current CC pin configuration, current current level, Alt Mode configuration, and current data channel status; the switching execution conditions include at least one of the following: no high-speed data transmission, PD negotiation completed, backup path link training completed, and backup path link integrity test passed.

[0007] In one optional implementation, based on the target switching polarity, pre-configuration is performed on currently inactive backup paths to ensure that the backup paths are prepared for at least one of the power supply path and data path before the formal switchover, specifically including: While maintaining continuous power supply to the currently active CC path, VCONN power supply is activated for the backup CC path; Monitor the load current of the backup CC path to determine if there are any abnormalities in the backup CC path; Configure an alternate MUX path and perform link training on the PHY layer corresponding to the alternate path; Establish a backup logical channel and perform a link integrity test on the backup logical channel; Maintain separate protocol stack states for the currently active path and the backup path; Establish a dual-channel cache for PD messages and a dual buffer for USB transaction queues.

[0008] In one optional implementation, before performing a path switch, the current data stream is frozen to pause new data scheduling and save the current connection session state, specifically including: Send a pause request to the USB host controller; Waiting for the currently executing transaction to complete; Pause new USB transaction scheduling; Write the current connection session state to the freeze buffer. The connection session state includes at least one of the following: USB endpoint state, bulk transfer queue state, interrupted transfer state, synchronous transfer timestamp, and Alt Mode state. Insert checkpoint markers into the data stream; Record the sequence number of the last successfully received data packet as a baseline for data recovery after the switchover.

[0009] In one optional implementation, after the backup path meets predetermined readiness conditions, an atomic switch is performed between the currently active path and the backup path to switch the operating polarity of the Type-C interface from the current polarity to the target polarity, specifically including: Confirm that the backup path is ready; Control the MUX to enter temporary bypass mode, while keeping the currently active path active and performing pre-activation on the target path; By atomically writing to the MUX control register, the MUX can switch to the target path within a single cycle; After completing the path switch, switch the VCONN primary path and send a switch completion notification to the protocol layer; When the PD session is active, save the current PD message sequence number, send a PD session migration prompt message on the switched CC path, and migrate the PD state machine after receiving confirmation information from the peer.

[0010] In one optional implementation, after the handover is completed, the integrity of the connection after the handover is verified, and the connection session state before freezing is restored when the verification passes. Specifically, this includes: Measure whether the voltage of the CC pin is within the preset range after switching; Detect the VCONN load current after switching and verify the USB endpoint response status; Check the Alt Mode link status, and if the verification is successful, restore the connection session state saved before freezing from the freeze buffer. The restoration of the connection session state before freezing includes: restoring the USB endpoint state, restoring the bulk transfer queue, restoring the interrupted transfer state, and performing delay compensation on the synchronization transfer timestamp. When any integrity verification result is detected to be unsatisfactory, a rollback process is executed. The rollback process includes: immediately switching the working path back to the original CC path; marking the target path that failed to switch as a degraded mode and outputting error report information.

[0011] In one optional implementation, after the recovery is complete, the resources corresponding to the original path are released, and the polarity status information of the current Type-C interface is updated, specifically including: Turn off the power supply to VCONN corresponding to the original CC path; Disable the original MUX path and release the PHY layer resources corresponding to the original path; Update the global CC polarity state and output a switching completion notification to the upper-layer driver; Record the delay and success rate information of this handover, and adjust the pre-configured parameters used in subsequent handovers based on the recorded results.

[0012] This disclosure also provides a Type-C reversible plug dynamic switching device, including: The request generation module is used to monitor in real time the trigger information that indicates the current connection polarity needs to be adjusted when the Type-C interface is in a connected state, and generate a switching request when the polarity switching trigger condition is detected. The parameter recording module is used to respond to the switching request, evaluate the current Type-C connection status, determine whether the switching execution conditions are met, and record the current connection parameters when the switching execution conditions are met. The preparation module is used to perform pre-configuration on the currently inactive backup path based on the target switching polarity, so that the backup path completes preparation of at least one of the power supply path and data path before the formal switching. The polarity switching module is used to freeze the current data stream before performing path switching, so as to pause new data scheduling and save the current connection session state. After the backup path meets the predetermined ready conditions, it performs an atomic switch between the current effective path and the backup path, so that the working polarity of the Type-C interface is switched from the current polarity to the target polarity. The update module is used to verify the integrity of the connection after the switch is completed, and restore the connection session state before freezing when the verification is successful; after the restoration is completed, the resources corresponding to the original path are released, and the polarity status information of the current Type-C interface is updated.

[0013] This disclosure also provides an electronic device, including: a processor, a memory, and a bus. The memory stores machine-readable instructions executable by the processor. When the electronic device is running, the processor communicates with the memory via the bus. When the machine-readable instructions are executed by the processor, the steps of the above-described Type-C reversible insertion dynamic switching method or any possible implementation of the above-described Type-C reversible insertion dynamic switching method are performed.

[0014] This disclosure also provides a computer-readable storage medium storing a computer program that, when executed by a processor, performs the steps of the above-described Type-C reversible insertion dynamic switching method, or any possible implementation of the above-described Type-C reversible insertion dynamic switching method.

[0015] This disclosure also provides a computer program product, including a computer program / instruction, which, when executed by a processor, implements the above-described Type-C reversible insertion dynamic switching method, or the steps in any possible implementation of the above-described Type-C reversible insertion dynamic switching method.

[0016] This disclosure provides a method, apparatus, electronic device, and storage medium for dynamic switching of Type-C reversible insertion. By monitoring polarity switching trigger information during connection, and combining pre-switching state assessment, backup path pre-configuration, data stream freezing, atomic switching, post-switching verification, and state recovery, the Type-C interface can dynamically adjust the reversible insertion polarity without disconnecting the connection. This reduces switching latency, minimizes the risk of data transmission interruption, improves the smoothness and reliability of the connection process, and enhances the adaptability of the Type-C interface to rotating devices, dynamic cabling devices, and innovative terminal forms.

[0017] To make the above-mentioned objects, features and advantages of this disclosure more apparent and understandable, preferred embodiments are described below in detail with reference to the accompanying drawings. Attached Figure Description

[0018] To more clearly illustrate the technical solutions of the embodiments of this disclosure, the accompanying drawings used in the embodiments will be briefly described below. These drawings are incorporated in and constitute a part of this specification. They illustrate embodiments conforming to this disclosure and, together with the specification, serve to explain the technical solutions of this disclosure. It should be understood that the following drawings only show some embodiments of this disclosure and should not be considered as limiting the scope. Those skilled in the art can obtain other related drawings based on these drawings without creative effort.

[0019] Figure 1 A flowchart of a Type-C reversible insertion dynamic switching method provided in an embodiment of this disclosure is shown; Figure 2 A schematic diagram of a Type-C reversible plug dynamic switching device provided in an embodiment of this disclosure is shown; Figure 3 A schematic diagram of an electronic device provided in an embodiment of the present disclosure is shown. Detailed Implementation

[0020] To make the objectives, technical solutions, and advantages of the embodiments of this disclosure clearer, the technical solutions of the embodiments of this disclosure will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only a part of the embodiments of this disclosure, and not all of them. The components of the embodiments of this disclosure described and shown in the accompanying drawings can generally be arranged and designed in various different configurations. Therefore, the following detailed description of the embodiments of this disclosure provided in the accompanying drawings is not intended to limit the scope of the claimed disclosure, but merely represents selected embodiments of this disclosure. All other embodiments obtained by those skilled in the art based on the embodiments of this disclosure without inventive effort are within the scope of protection of this disclosure.

[0021] It should be noted that similar labels and letters in the following figures indicate similar items. Therefore, once an item is defined in one figure, it does not need to be further defined and explained in subsequent figures.

[0022] In this document, the term "and / or" merely describes a relationship, indicating that three relationships can exist. For example, A and / or B can represent three cases: A alone, A and B simultaneously, and B alone. Furthermore, the term "at least one" in this document means any combination of at least two of any one or more elements. For example, including at least one of A, B, and C can mean including any one or more elements selected from the set consisting of A, B, and C.

[0023] Research has revealed that most existing Type-C reversible insertion identification methods are one-time detection and fixed configuration mechanisms at the time of insertion. Their core characteristic is that they only determine whether the insertion is correct or reversed based on the CC pin status at the initial stage of connection establishment and select the corresponding signal path accordingly. During the subsequent connection maintenance, they do not dynamically adjust for polarity changes. In other words, once the interface connection is established, even if the physical orientation of the device, cable routing, or the relative direction of the interface changes, existing systems typically cannot re-adapt to the new polarity state without disconnecting the connection. Instead, they must re-insert the device and complete the detection, enumeration, and negotiation process.

[0024] Based on the above research, this disclosure provides a method, device, electronic device, and storage medium for dynamic switching of Type-C reversible insertion. By monitoring polarity switching trigger information in the connected state, and combining technical means such as pre-switching state assessment, backup path pre-configuration, data stream freezing, atomic switching, post-switching verification, and state recovery, the Type-C interface can dynamically adjust the reversible insertion polarity without disconnecting the connection. This reduces switching latency, minimizes the risk of data transmission interruption, improves the smoothness and reliability of the connection process, and enhances the adaptability of the Type-C interface to rotating devices, dynamic cabling devices, and innovative terminal forms.

[0025] To facilitate understanding of this embodiment, a detailed description of the Type-C reversible insertion dynamic switching method disclosed in this disclosure embodiment will be provided first. The executing entity of the Type-C reversible insertion dynamic switching method provided in this disclosure embodiment is generally a computer device with a certain computing capability. This computer device may include, for example, a terminal device, a server, or other processing devices. The terminal device may be a user equipment (UE), mobile device, user terminal, terminal, cellular phone, cordless phone, personal digital assistant (PDA), handheld device, computing device, in-vehicle device, wearable device, etc. In some possible implementations, this Type-C reversible insertion dynamic switching method can be implemented by the processor calling computer-readable instructions stored in memory.

[0026] See Figure 1 The diagram shows a flowchart of a dynamic switching method for Type-C reversible insertion provided in an embodiment of this disclosure. The method includes steps S101 to S105, wherein: S101. When the Type-C interface is in a connected state, monitor in real time the trigger information that indicates the current connection polarity needs to be adjusted, and generate a switching request when the polarity switching trigger condition is detected.

[0027] In practice, when the Type-C interface has completed insertion recognition and is in the working state after connection establishment, the control unit does not only maintain the initially determined polarity configuration, but also continuously monitors the trigger information that can reflect whether the current connection polarity needs to be readjusted in real time, so as to dynamically determine whether to perform positive or negative insertion switching according to the actual usage state during the connection.

[0028] Here, the connection state can be a state where CC channel identification and VBUS power supply relationship have been completed, or a state after further completion of USB data link establishment, PD negotiation establishment, and Alt Mode configuration establishment. The control unit can be implemented by a Type-C port controller, protocol controller, main control processor, or control logic composed of them.

[0029] Specifically, the triggering information may include at least one of physical state triggering information, interface electrical state triggering information, user control triggering information, and external system linkage triggering information. Physical state triggering information can be used to characterize whether the device body, interface module, or connecting cable has undergone a change relative to its current initial connection posture sufficient to trigger a target polarity switching requirement. For example, it can be acquired through accelerometers, gyroscopes, Hall effect sensors, angle detection components, or flip detection components to collect information on device rotation angle, posture change direction, folding state change, and interface orientation change. When the posture change information meets a preset change threshold or corresponds to a preset rotation scenario, a polarity adjustment requirement can be determined.

[0030] Here, the interface electrical state trigger information can be used to characterize whether the current CC pin or related signal path is mismatched with the original polarity configuration or has decreased stability. For example, by monitoring the voltage state, signal quality parameters, signal-to-noise ratio, bit error rate, jitter, contact stability or path load changes of the CC1 and CC2 pins, it can be determined whether the current connection path has degraded, interference has increased or the other polarity path has better connection conditions.

[0031] User-controlled trigger information can originate from active switching commands issued by the user through the operating system interface, driver control interface, function keys, or external control commands, enabling the system to trigger subsequent switching processes when the user desires to change the connection direction mapping relationship. External system linkage trigger information can originate from linkage control signals output by the docking station, base, rotating bracket, cable management module, or other external devices, to synchronously request Type-C connection polarity adjustment when the external mechanism moves or the wiring status changes.

[0032] To achieve stable and reliable real-time monitoring, the control unit can acquire the aforementioned trigger information according to a preset sampling period, an event interruption method, or a combination of both. In one implementation, for signals with relatively clear changes, such as attitude changes, Hall sensor state changes, and external button triggers, an interrupt triggering method is preferred to ensure a rapid response when a trigger event occurs. For continuously changing parameters such as CC signal quality, bit error rate, and load current, periodic sampling and sliding window analysis can be used to improve judgment accuracy and avoid false triggers caused by transient noise. Furthermore, trigger information from different sources can be fused and analyzed, for example, by simultaneously combining the attitude change amplitude, CC state offset degree, and current service status to comprehensively assess whether a polarity switch is indeed necessary, thereby reducing the probability of misjudgment.

[0033] A switching request is generated when a polarity switching trigger condition is detected. Here, the polarity switching trigger condition can be a single condition or a combination of multiple conditions. For example, a switching request can be generated directly when a device is detected to have rotated more than a preset angle; or, a switching request can be generated when the signal quality of the current CC path is detected to be lower than a first threshold and the detection result of the backup CC path is better than the current path; or, a switching request can be generated when a user-initiated switching command is received, regardless of whether there is a significant physical change.

[0034] To improve system robustness, before generating a switching request, the trigger information can be debouncing, duration judgment, or multiple sampling consistency confirmation. Only when the target trigger state lasts for a preset time or multiple consecutive detection results are consistent is the switching trigger condition considered met.

[0035] The handover request can be understood as a handover task identifier or control signal output to the subsequent handover control process, which at least indicates that the system enters the handover preparation phase. The handover request may carry auxiliary parameters related to this handover, such as the trigger source type, current polarity state, target polarity state, trigger timestamp, current link operating mode, and whether it is a forced handover request, so that subsequent steps can take corresponding handover strategies based on different trigger reasons and the current link state.

[0036] For example, for handover requests triggered by user-initiated actions, the response priority can be increased; for handover requests triggered by signal quality degradation, link health checks can be performed first in subsequent steps; and for handover requests triggered by attitude changes, the target path can be predicted by combining the rotation direction.

[0037] By continuously monitoring the trigger information representing the need for polarity changes when the Type-C interface is in a connected state, and generating a switching request in a timely manner when the conditions are met, the system is no longer limited to one-time polarity identification at the time of insertion. Instead, it has the ability to sense changes in physical state, link state, and user operation needs during the connection period. This provides a trigger basis for subsequent dynamic forward and reverse insertion switching, which is conducive to improving the adaptability and connection flexibility of the Type-C interface in dynamic usage scenarios.

[0038] S102. In response to the switching request, evaluate the current Type-C connection status, determine whether the switching execution conditions are met, and record the current connection parameters when the switching execution conditions are met.

[0039] In practical implementation, after the monitoring module or control module generates the switching request, the system does not immediately perform dynamic switching between positive and negative insertion. Instead, it first evaluates the current Type-C connection status to determine whether the conditions for polarity switching are met. This avoids direct switching in situations such as unstable power supply, incomplete protocol negotiation, or heavy high-speed data transmission, which could lead to link abnormalities, interruptions, or data loss. The connection status evaluation can be performed collaboratively by at least one of the Type-C port controller, PD controller, USB host controller, protocol management module, and host processor, or it can be performed independently by a pre-set status evaluation logic module.

[0040] Specifically, the evaluation of the current Type-C connection status may include detecting at least one of the following: power supply status, protocol status, data transmission status, and link operating mode.

[0041] First, the current VBUS power supply status can be detected to determine whether the current port power supply is within a stable range. For example, VBUS voltage, current, ripple information, or voltage change slope can be collected, and the detection results can be compared with a preset stability threshold. When the VBUS voltage is within a preset operating voltage range and shows no significant fluctuations over several consecutive sampling periods, the current VBUS can be considered to be in a stable state. Second, the current PD negotiation status can be detected to determine whether the current port has completed power negotiation, role negotiation, or extended mode-related negotiation. The PD negotiation status can be obtained by reading the current stage of the PD state machine, message interaction completion flag, power supply role identifier, data role identifier, and negotiation success flag. When the PD state machine is in a stable session state, or at least has completed the current round of key negotiation, the protocol layer can be considered to have the basis for further switching. Third, the current data transmission status can be detected to determine whether there are active services affecting smooth switching. For example, it can monitor whether there are incomplete transactions on the current USB host, whether there are pending data packets in the endpoint queue, whether the high-speed link is in a continuous transmission state, and whether the Alt Mode link is in a critical display output stage. When there is no high-speed continuous transmission task or the current active transmission has entered a pauseable window, it can be considered that the data conditions required for smooth switching are met.

[0042] In addition, the current link operating mode can be used for judgment. For example, it can be identified that the current port is working in USB 2.0 mode, USB 3.x mode, USB 4 mode, DisplayPort Alt Mode or Thunderbolt compatible mode, and different evaluation criteria can be used according to the tolerance switching timing and link recovery requirements corresponding to different modes.

[0043] In a preferred embodiment, determining whether the handover execution conditions are met may include: if there is no high-speed data transmission at present, or although there is service but PD negotiation has been completed and the current link is in a stable phase that can be temporarily frozen, then the smooth handover conditions are met; if there is continuous service transmission but external triggering constitutes an emergency handover requirement, such as a severe degradation in the electrical quality of the current path, unstable contact, or a user explicitly issuing a forced handover command, then the current handover request can be marked as a forced handover mode; if neither the smooth handover conditions are met nor there is an emergency handover requirement, then the handover is not executed immediately, but the current connection state is maintained, and the evaluation is re-initiated after the next preset evaluation time or after an available transmission window appears.

[0044] Furthermore, to improve the accuracy of the assessment, the status assessment can employ a multi-indicator joint judgment method, rather than relying solely on a single signal result. For example, even when a significant change in device attitude is detected, the system can still continue to determine whether the current VBUS is stable, whether the backup path is available, whether the PD state machine is in a stable state, and whether the current endpoint queue allows for pausing; only when multiple indicators meet preset logical relationships is the current handover execution condition confirmed. The preset logical relationships can be AND logic, OR logic, weighted scoring logic, or priority logic. For example, "VBUS stability" can be set as a necessary condition, and "PD negotiation completed" and "high-speed data idle" can be set as preferred conditions; when the necessary condition is met and at least one of the preferred conditions is met, the current handover is determined to be permitted.

[0045] When the switching execution conditions are met, the current connection parameters are recorded. These current connection parameters serve as the basis for state maintenance and switching recovery during subsequent freeze, switchover, verification, and recovery processes. Specifically, the current connection parameters may include at least one of the following: current CC pin configuration, current connection polarity identifier, VBUS power supply status parameters, current current level, current power supply role and data role, PD negotiation result, Alt Mode configuration parameters, current data channel operating status, and identification information related to the current session.

[0046] Among them, the current CC pin configuration can indicate whether CC1 or CC2 is currently responsible for the effective configuration channel function; the current connection polarity identifier can indicate whether the current interface is in the positive or negative insertion path; the current current level can include the default USB current, 1.5A, 3A or higher negotiated power level; Alt Mode configuration parameters can include DisplayPort channel mapping, MST status, Lane allocation method, auxiliary channel status, etc.; the current data channel working status can include USB 2.0 link enable status, USB 3.x Ultra-High Speed ​​channel mapping relationship, USB4 tunnel status or other logical channel establishment status.

[0047] In one implementation, recording the current connection parameters can be achieved by establishing a connection state snapshot table or a state context cache. After confirming that the switching execution conditions are met, the control unit can write the current key parameters into a preset storage area and generate a corresponding context identifier for this switching operation.

[0048] In this way, during subsequent backup path pre-configuration, data stream freezing, atomic switching, and post-switching state recovery, the system can quickly retrieve the original connection parameters based on this context identifier to compare, migrate, and correct the state before and after the switch. If necessary, it can also simultaneously record auxiliary information such as the trigger source of this switch request, the switch determination result, the switch execution mode, and the evaluation timestamp, so as to facilitate subsequent fine-grained control or fault tracing analysis.

[0049] Furthermore, integrity checks can be performed on the recorded parameters before or after recording the current connection parameters to avoid inconsistencies in the recorded information due to momentary sampling errors or asynchronous changes during state switching. For example, key parameters can be repeatedly read, latched in registers, or have timing consistency checks performed. Only when the currently acquired polarity state, protocol state, and power supply state are confirmed to be consistent are they saved as valid connection parameters. This approach improves the accuracy and reliability of subsequent handover recovery.

[0050] By evaluating the current Type-C connection status after responding to a handover request and recording the current connection parameters only when the handover execution conditions are met, we can avoid rashly changing the polarity path at unsuitable times for handover, thus reducing the risk of link interruption. On the other hand, we can provide an accurate contextual basis for subsequent backup path pre-configuration, session freezing, handover execution, and state recovery, thereby ensuring that the entire dynamic handover process has better smoothness, controllability, and reliability.

[0051] S103. Based on the target switching polarity, perform pre-configuration on the currently inactive backup path so that the backup path completes preparation of at least one of the power supply path and data path before the formal switching.

[0052] In practice, after determining that the current connection status meets the switching execution conditions and completing the recording of the current connection parameters, the system does not directly switch the currently effective path to another polarity path. Instead, it first performs pre-configuration processing on the currently ineffective backup path based on the target switching polarity, so that the backup path has the ability to carry the connection relationship in advance before the formal switch.

[0053] Here, the target switching polarity can be understood as another working polarity corresponding to the current connection polarity. For example, when the path corresponding to CC1 is currently active, the path corresponding to CC2 can be determined as the backup path corresponding to the target switching polarity; conversely, when the path corresponding to CC2 is currently active, the path corresponding to CC1 can be determined as the backup path.

[0054] Specifically, the pre-configuration of currently inactive backup paths may include pre-establishing the power supply paths corresponding to the backup paths. The preparation of power supply paths mainly refers to ensuring that the power supply capacity and load detection capability corresponding to the backup paths are available before the formal switchover.

[0055] For example, provided that the currently active CC path is working normally, the control module can perform power-on preparation for the VCONN branch corresponding to the backup CC path, so that the backup path has the conditions to supply power to the cable electronic marker chip, direction recognition circuit or related auxiliary devices.

[0056] To avoid current surges, voltage drop fluctuations, or malfunctions caused by directly powering on the backup branch, a soft-start method can be used to gradually increase the driving capability of the backup VCONN branch. During the power-on process, the load current, voltage response, short-circuit status, or abnormal leakage status on the backup path are simultaneously monitored. When the monitoring results indicate that there are no short circuits, overcurrents, or abnormal loads on the backup path, the backup power supply path can be considered successfully pre-established.

[0057] For VBUS-related paths, the switch control status, current limiting parameters, or power supply mapping relationship corresponding to the target path can be preloaded according to the specific system architecture without affecting the current power supply relationship, so that the migration of the main power supply path can be completed more quickly during the subsequent formal switchover.

[0058] Furthermore, the pre-configuration may also include pre-establishing the data path corresponding to the backup path. Since the Type-C interface involves not only the CC configuration channel and power supply channel, but also the polarity mapping of data paths such as USB 2.0, USB 3.x, USB4, or Alt Mode, pre-processing the backup data path before the formal switchover helps ensure that the data link can quickly recover stability after the subsequent switchover.

[0059] In one implementation, the control module can pre-configure a backup MUX path, so that the data line mapping relationship matching the target switching polarity is written into the corresponding control register or selection logic in advance, and the backup signal path is in an active state.

[0060] Building upon this, the PHY layer resources corresponding to the backup path can be further initialized, such as initiating receive equalization parameter loading, transmit drive parameter preset, terminal matching network preparation, and link training preparation. For systems that support high-speed link training, pre-training or pre-calibration operations can also be performed on the backup path without disrupting the current primary path service, so as to reduce the waiting time required to re-establish the link during the formal handover.

[0061] In another embodiment, the data path preparation may further include establishing a backup logical channel. Here, the logical channel may refer to a data transmission context, transaction processing context, or protocol mapping context corresponding to the backup polarity. The control module can allocate corresponding logical resources for the backup path in the background, so that the data identifier, channel number, buffer index, routing relationship, or protocol processing entry related to the target polarity path is pre-established, and the availability of the backup path is verified by sending test patterns, verification sequences, or link integrity detection signals. If the verification result meets the preset requirements, it indicates that the backup path has completed the basic data layer preparation and can enter the switchover state.

[0062] To further improve the smoothness of the handover process, the pre-configuration can be extended to protocol layer resource preparation. In a preferred embodiment, the system maintains independent or semi-independent protocol contexts for the currently active path and the backup path, respectively, so that the backup path already has basic protocol carrying capabilities before the formal handover.

[0063] For example, corresponding CC state caches, PD message caches, USB transaction buffers, or Alt Mode state mapping tables can be configured for the two paths respectively. When a formal handover occurs, the system can quickly resume the current session based on pre-established protocol resources without having to re-initialize the entire protocol environment from scratch at the moment of handover. This helps reduce protocol recovery latency and also helps reduce anomalies perceived by upper-layer applications during the handover process.

[0064] It should be noted that preparing at least one of the power supply path and data path is to broaden the protection scope of this step. In some implementations, backup path pre-configuration may only prepare the power supply path, such as prioritizing the establishment of backup VCONN power supply capability to ensure that the target path has basic physical layer operating conditions after the switchover. In other implementations, only the data path may be pre-configured, for example, if the power supply structure inherently supports bidirectional standby, the focus may be on preparing the backup MUX path and PHY link. In a more preferred implementation, both the power supply path and data path are pre-configured simultaneously, so that the backup path is in a relatively complete takeover ready state before the formal switchover, thereby achieving lower switchover latency and higher switchover success rate.

[0065] Furthermore, during the pre-configuration process, the system can also combine the current connection parameters recorded in the previous step to perform targeted parameter mirroring or migration on the backup path. For example, it can preset the current limiting threshold of the backup power supply path based on the current session's current level, preset the data mapping relationship of the backup path based on the current Alt Mode configuration, and load the corresponding PHY parameter template based on the current USB link mode. This avoids inconsistencies between the backup path and the current session state caused by using default configurations, thereby further improving continuity and compatibility after switching.

[0066] In practical applications, to avoid interference from the pre-configuration of the backup path to the currently active path, the pre-configuration process is preferably performed under controlled conditions. Specifically, this can be achieved by setting an isolating switch, bypass state, pre-activation state, or read-only detection state, so that although the backup path completes the necessary preparations, it does not actually take over the current service data flow or main power supply responsibilities before the formal switchover. In other words, the backup path is in a prepared but not yet officially active state after pre-configuration, and only transitions from standby to actual working state when it receives the formal switchover control signal in subsequent switchover steps.

[0067] By pre-configuring currently inactive backup paths based on the target switching polarity, the backup paths can complete preparation of at least one of the power supply path and data path before the formal switching. This allows the system to move a large amount of initialization work forward to before the switching action, thereby reducing the processing burden at the moment of switching, shortening the time required for dynamic switching of forward and reverse insertion, and improving the continuity of connection and execution reliability during the switching process.

[0068] S104. Before performing path switching, the current data stream is frozen to pause new data scheduling and save the current connection session state. After the backup path meets the predetermined ready conditions, an atomic switch is performed between the current effective path and the backup path to switch the working polarity of the Type-C interface from the current polarity to the target polarity.

[0069] In practice, after completing the pre-configuration of the backup path, in order to avoid data packet loss, transaction disorder, inconsistent protocol status, or abnormal disturbances of the high-speed link during the switching moment, the system freezes the current data stream before performing the path switching. After confirming that the backup path meets the predetermined ready conditions, the system then performs an atomic switch between the current active path and the backup path, so that the working polarity of the Type-C interface can be smoothly switched from the current polarity to the target polarity.

[0070] Specifically, freezing the current data stream means temporarily preventing new data transactions from entering the pending execution state without immediately interrupting the current connection session, and saving the key operational state in the current connection context so that execution can resume after the polarity switch is completed. This freezing process can be performed collaboratively by the USB host module, Type-C port control module, protocol management module, and host processor, or it can be executed by specially designed data freezing control logic.

[0071] In one implementation, the freeze process first includes suspending new data scheduling. Specifically, the control module may send a pause control signal to the USB host controller, the data transaction scheduling module, or the corresponding endpoint management logic, causing them to stop sending new transaction requests, endpoint scheduling requests, or data packet transmission requests to the currently active path.

[0072] Here, pausing new data scheduling does not mean immediately and abruptly cutting off the current transmission. Instead, it is preferable to allow transactions that have already entered the sending or receiving phase to complete naturally within a preset protection time, so that the freeze time falls as close as possible to a relatively complete transaction boundary.

[0073] For example, after issuing a pause control, the system can wait for the currently executing USB transaction to complete. The waiting time can be set to no more than a preset time limit to balance switching speed and transaction integrity. If the current transaction is completed within the preset time limit, it will enter the next freeze phase. If it is not completed after the preset time limit, a forced freeze or delayed switch can be executed according to the current strategy.

[0074] Furthermore, after pausing new data scheduling, the system saves the current connection session state. This current connection session state primarily represents the operating context of the link and protocol stack before the handover, enabling state recovery and service continuation after the handover is completed.

[0075] Specifically, the session state may include at least one of the following: USB endpoint state, data switching bit corresponding to each endpoint, bulk transfer queue state, interrupted transfer state, synchronous transfer timestamp, host controller transaction state, currently sent but unacknowledged data packet sequence information, and Alt Mode related state.

[0076] For example, in a normal USB data transfer scenario, it can record whether each endpoint is currently busy, the current buffer pointer position, the pending transaction descriptor, and the identifier of the last successfully completed transaction; in a synchronous audio / video transfer scenario, it can also record timestamps, frame boundary markers, or clock compensation information; in a DisplayPort AltMode, USB4, or other extended mode scenario, it can also record the current link mapping relationship, channel occupancy status, auxiliary link status, or mode negotiation results.

[0077] In a preferred embodiment, to improve the recoverability of the freeze point, the system can also set a verification reference point during the freeze process. Specifically, before the data stream enters the freeze, the current data link status can be marked, for example, by recording the sequence number of the last successfully received or sent data packet, the current transaction number, the boundary state corresponding to the error detection code, or by inserting a verification identifier corresponding to the freeze time into the internal buffer. In this way, during subsequent recovery, data can be resumed, reassembled, or verified based on the recorded reference point, thereby reducing the risk of data duplication, omission, or timing disorder caused by switching.

[0078] After the data stream freeze process is completed, path switching is not performed immediately. Instead, it is necessary to determine whether the backup path meets the predetermined readiness conditions. Here, the predetermined readiness conditions are mainly used to confirm that the backup path has the basic capability to take over the current session. Specifically, it may include at least one of the following: the VCONN power supply corresponding to the backup path has been established and is in a stable state; the load current, voltage response, or short-circuit detection result of the backup path meets the preset requirements; the backup MUX path has been configured and is in a switchable state; the PHY layer corresponding to the backup path has completed parameter loading, link training, or integrity detection; the backup logical channel has been established and passed basic connectivity verification; and the protocol context corresponding to the target polarity has been prepared.

[0079] For different product solutions and different link modes, the predetermined readiness conditions can be configured to be met by one or more conditions together. For example, for scenarios involving only USB 2.0 low-speed or full-speed, the availability of power supply paths and basic paths can be the primary requirement; for USB 3.x, USB4, or Alt Mode high-speed scenarios, it is preferable to require that backup paths be more fully prepared at both the physical layer and the protocol layer.

[0080] Once the backup path is confirmed to meet the predetermined readiness conditions, an atomic switch is performed between the currently active path and the backup path. The essence of the atomic switch is to complete the switching action between the current working path and the target working path in an indivisible manner within a short and controlled time window, thereby avoiding situations such as exposure of intermediate states, path contention, power supply idling, or data mapping chaos.

[0081] In other words, during the switching process, the system does not change the path one by one with multiple independent actions and long intervals. Instead, it uses register latching, hardware state machine control, multiplexer synchronous switching, or preset mapping to make the deactivation of the currently active path and the activation of the backup path highly close in timing or even constitute a single-cycle switching.

[0082] Specifically, in one implementation, the control module can first preload the switching parameters of the current path and the target path into the corresponding hardware control register, so that the currently active path remains active and the backup path is in a pre-active state; after the switching trigger time is reached, the data path selection relationship, CC mapping relationship and related channel enable state are switched from the current path to the target path under the same controlled timing by performing an atomic write to the MUX control register or issuing a unified switching command through the hardware state machine.

[0083] After the path switch is completed, the VCONN main power supply relationship and related protocol status notifications corresponding to the target path are updated synchronously to ensure that all functional units within the system have a consistent understanding of the new polarity state. Since a large amount of preparatory work has been completed in the preceding steps, the formal switchover action itself only involves path takeover and state inversion, which can significantly shorten the switchover window.

[0084] Furthermore, during the atomic handover process, a temporary bypass mode, a dual-path short-term overlap maintenance mode, or a handover protection mode can be employed to further suppress transient disturbances. For example, before the handover begins, the control MUX briefly enters a bypass protection state, so that the signal path is in a controlled transition state for a very short time; then the target path immediately takes over the service, while the original path exits after confirming that the target path has taken effect.

[0085] For power supply paths, the original path's power supply can be kept unreleased within a predetermined micro-hour sequence window, while the target path first enters a stable output state. The original path is then shut down only after the switching is confirmed to be complete, thus avoiding VCONN interruption due to the power supply being disconnected before being reconnected. The above processing methods are all specific implementations of atomic switching.

[0086] After the atomic switch is completed, the operating polarity of the Type-C interface changes from the current polarity to the target polarity. This polarity switch includes not only the change of the effective side of the CC channel, but also the corresponding migration of the power supply path mapping relationship, data line mapping relationship, and necessary protocol bearer relationship related to this polarity. In other words, the target path after the switch becomes the new effective path, while the original path exits the current service bearer state, awaiting subsequent execution verification, recovery, and resource release operations.

[0087] By freezing the current data stream before performing a path switch to pause new data scheduling and save the current connection session state, and then performing an atomic switch between the current active path and the backup path after the backup path meets the predetermined ready conditions, the switching action can be performed under the premise that the business state is controllable and the context is recoverable, thus avoiding significant damage to existing transactions during the switching process. On the other hand, since the formal switch is completed atomically, the uncertain time in the path flipping process can be significantly shortened, improving the smoothness, real-time performance, and stability of the dynamic forward and reverse insertion switching of the Type-C interface.

[0088] S105. After the handover is completed, verify the integrity of the connection after the handover, and restore the connection session state before freezing when the verification is successful; after the restoration is completed, release the resources corresponding to the original path and update the polarity status information of the current Type-C interface.

[0089] In practice, after an atomic switch is completed between the current effective path and the backup path, the system does not immediately unfreeze and fully restore services. Instead, it first verifies the integrity of the connection after the switch to confirm that the new working path corresponding to the target polarity can stably carry the current Type-C connection session. After the verification is successful, the connection session state saved before the freeze is restored. After the restoration is completed, the resources corresponding to the original path are released and the polarity status information of the current Type-C interface is updated.

[0090] Specifically, verifying the integrity of the connection after the switch can include detecting at least one of the physical layer status, power supply status, protocol layer status, and service response status. First, at the physical layer, it can detect whether the voltage status on the target CC path after the switch is within a preset specification range, and whether the level identification result on the current target path is consistent with the target polarity; at the same time, it can also detect the load current, voltage response, or on / off status of the VCONN branch corresponding to the target path to confirm that the auxiliary power supply relationship after the switch has been established normally.

[0091] Specifically, verifying the integrity of the connection after the switch can include detecting at least one of the physical layer status, power supply status, protocol layer status, and service response status. First, at the physical layer, it can detect whether the voltage status on the target CC path after the switch is within a preset specification range, and whether the level identification result on the current target path is consistent with the target polarity; at the same time, it can also detect the load current, voltage response, or on / off status of the VCONN branch corresponding to the target path to confirm that the auxiliary power supply relationship after the switch has been established normally.

[0092] Secondly, at the protocol layer, it is possible to verify whether the protocol session remains continuous after the switch. For example, handshake detection information, link liveness detection information, or protocol verification information can be sent to the peer, and the current protocol stack can be judged to work normally on the new path based on the peer's return results. For USB data sessions, it is possible to detect whether each endpoint can respond normally to master access, whether there are abnormal timeouts, and whether there are endpoint mismatches or transaction errors; for PD sessions, it is possible to detect whether the current PD state machine has successfully migrated to the working state corresponding to the new path, and whether it can continue to maintain the original power supply role, data role, and power negotiation results; for Alt Mode working scenarios, it is also possible to detect whether the link mapping, auxiliary channel status, and related mode configurations in extended mode remain consistent to ensure that extended services are not abnormally interrupted after the switch.

[0093] Furthermore, the connection integrity verification can also include business-level response detection. That is, after the basic physical connection and protocol session are both successful, key business responses can be confirmed based on the current business scenario. For example, when there are batch transmission tasks, it can be verified whether the queue can still be submitted and completed after the switch; when there are interrupted transmission tasks, it can be verified whether the interruption response remains valid; when there are synchronous transmission tasks, it can be verified whether the data time base remains continuous after recovery and whether compensation is required; in display output or high-speed interconnect scenarios, it can also be verified whether the video stream, channel bandwidth mapping, or tunnel status remains normal after the switch.

[0094] In one implementation, when the integrity verification of the switched connection passes, the connection session state before the freeze is restored. The restoration process can be understood as: reloading the various context information saved during the aforementioned freeze phase into the target path where the switch has taken effect, and restarting the suspended data scheduling, thereby allowing the previously temporarily frozen business sessions to continue running on the new polarity path.

[0095] Specifically, information such as USB endpoint state, transaction scheduling state, bulk transfer queue state, interrupted transfer state, and synchronization transfer timestamp can be recovered from the frozen buffer and rewritten into the master control structure, endpoint management structure, transfer scheduling structure, or protocol context. During the recovery process, the recovery start point and recovery order can be determined based on the transaction boundaries, packet sequence numbers, timestamps, or checkpoints recorded at the time of freezing, in order to ensure that the recovery actions are as consistent as possible with the business context before freezing.

[0096] Recovery methods can vary depending on the transmission type. For example, for batch and control transmissions, it is preferable to continue scheduling subsequent transactions after the last confirmed transaction. For interrupted transmissions, the interrupted polling state and response context can be restored. For synchronous transmissions, the timestamp can be restored along with compensation for the actual delay caused by the handover, thus reducing the impact of the handover on real-time audio and video services. For Alt Mode services, previously recorded mode parameters, link configurations, and channel occupancy relationships can be restored, allowing related extended services to continue operating on the new polarity path. After recovery, the control module can remove the pause restriction on new data scheduling requests, allowing the system to continue processing subsequent data transmissions according to the normal business process.

[0097] It should be noted that in some preferred embodiments, when the connection integrity verification fails after switching, a rollback process can also be performed, that is, the working path is switched back to the original path, and the original session environment is restored using the session state saved during the freeze phase, so as to avoid the connection being completely interrupted due to the abnormal target path.

[0098] After recovery is complete, release the resources corresponding to the original path. Here, the original path refers to the old polarity path that was active before the switch and has exited its working role after the switch. Since the current target path has become the new working path, the power supply resources, path resources, and protocol resources corresponding to the original path do not need to remain fully active and can be released according to the system policy to reduce unnecessary resource occupation and power consumption.

[0099] Specifically, this may include: shutting down the VCONN power supply branch corresponding to the original CC path, disconnecting or disabling the original MUX path, releasing the PHY layer resources, link training resources, cache resources, or auxiliary detection resources occupied by the original path, and clearing the temporary contexts in standby or hold-up states under the original path. For systems implemented with dual buffers, dual protocol contexts, or dual logical channels, some reusable framework resources may be selectively retained, while dynamic resources directly related to the current old path's carrying state may be released, so that they can be reconfigured when polarity switching occurs again in the future.

[0100] Furthermore, after releasing the original path resources, the polarity status information of the current Type-C interface is updated. This polarity status information is used to indicate that the current interface has switched from its original polarity to the target polarity, and serves as the basis for subsequent monitoring, control, and anomaly handling.

[0101] Specifically, the currently valid CC path identifier, the current connection polarity identifier, the currently active data path identifier, the current VCONN main path identifier, and global state variables related to the current session can be updated. This state information can be written to the Type-C port controller register, the system global state management table, the driver layer state context, or the monitoring module, ensuring that the underlying hardware control logic, protocol stack, and upper-layer driver software maintain a consistent understanding of the current polarity state.

[0102] In one implementation, after updating the polarity state information, a switching completion notification can be output to the upper-layer driver, system service module, or performance monitoring module. For example, the system can be notified that the current polarity has completed a dynamic switch via interrupt, event reporting, message queue, or status callback, facilitating subsequent log recording, statistical analysis, performance learning, or fault tracing. Simultaneously, the verification results, recovery time, resource release results, and final polarity state of this switch can also be recorded for subsequent adaptive parameter adjustments and switching strategy optimization.

[0103] By verifying the integrity of the connection after the switch is completed, restoring the connection session state before freezing upon successful verification, and then releasing the resources corresponding to the original path and updating the polarity status information of the current Type-C interface after restoration, we can ensure that the new path after dynamic polarity switching truly has stable working capabilities and avoid subsequent anomalies caused by blindly restoring services. On the other hand, it can enable the original path resources to be reclaimed in a timely manner and keep the system's internal understanding of the current polarity status consistent, thereby improving the stability, recoverability, and resource utilization efficiency of the entire Type-C reversible insertion dynamic switching process.

[0104] This disclosure provides a method for dynamic switching of Type-C reversible insertion. By monitoring polarity switching trigger information during connection, and combining it with technical means such as pre-switching state assessment, backup path pre-configuration, data stream freezing, atomic switching, post-switching verification, and state recovery, the Type-C interface can dynamically adjust the reversible insertion polarity without disconnecting the connection. This reduces switching latency, minimizes the risk of data transmission interruption, improves the smoothness and reliability of the connection process, and enhances the adaptability of the Type-C interface to rotating devices, dynamic cabling devices, and innovative terminal forms.

[0105] Those skilled in the art will understand that, in the above-described method of the specific implementation, the order in which each step is written does not imply a strict execution order and does not constitute any limitation on the implementation process. The specific execution order of each step should be determined by its function and possible internal logic.

[0106] Based on the same inventive concept, this disclosure also provides a Type-C reversible insertion dynamic switching device corresponding to the Type-C reversible insertion dynamic switching method. Since the principle of the device in this disclosure for solving the problem is similar to the Type-C reversible insertion dynamic switching method described above, the implementation of the device can refer to the implementation of the method, and the repeated parts will not be described again.

[0107] Please see Figure 2 , Figure 2 This is a schematic diagram of a Type-C reversible plug dynamic switching device provided in an embodiment of this disclosure. Figure 2 As shown in the figure, the Type-C reversible plug dynamic switching device 200 provided in this embodiment includes: The request generation module 210 is used to monitor in real time the trigger information that indicates the current connection polarity needs to be adjusted when the Type-C interface is in a connected state, and generate a switching request when the polarity switching trigger condition is detected.

[0108] The parameter recording module 220 is used to respond to the switching request, evaluate the current Type-C connection status, determine whether the switching execution conditions are met, and record the current connection parameters when the switching execution conditions are met.

[0109] Preparation module 230 is used to perform pre-configuration on currently inactive backup paths based on the target switching polarity, so that the backup paths are prepared at least one of the power supply path and data path before the formal switching.

[0110] The polarity switching module 240 is used to freeze the current data stream before performing path switching, so as to pause new data scheduling and save the current connection session state. After the backup path meets the predetermined ready conditions, it performs an atomic switch between the current effective path and the backup path, so as to switch the working polarity of the Type-C interface from the current polarity to the target polarity.

[0111] The update module 250 is used to verify the integrity of the connection after the switch is completed, and restore the connection session state before freezing when the verification is successful; after the restoration is completed, the resources corresponding to the original path are released, and the polarity status information of the current Type-C interface is updated.

[0112] The processing flow of each module in the device and the interaction flow between each module can be referred to the relevant descriptions in the above method embodiments, and will not be detailed here.

[0113] This disclosure provides a Type-C reversible plug dynamic switching device. By monitoring polarity switching trigger information during connection, and combining pre-switching state assessment, backup path pre-configuration, data stream freezing, atomic switching, post-switching verification, and state recovery, the Type-C interface can dynamically adjust the reversible plug polarity without disconnecting the connection. This reduces switching latency, minimizes the risk of data transmission interruption, improves the smoothness and reliability of the connection process, and enhances the adaptability of the Type-C interface to rotating devices, dynamic cabling devices, and innovative terminal forms.

[0114] Corresponding to Figure 1 In addition to the method for dynamic switching of Type-C reversible insertion, this disclosure also provides an electronic device 300, such as... Figure 3 The diagram shown is a structural schematic of an electronic device 300 provided in an embodiment of this disclosure, including: Processor 31, memory 32, and bus 33; memory 32 is used to store execution instructions, including main memory 321 and external memory 322; the main memory 321, also called internal memory, is used to temporarily store the computational data in processor 31, as well as the data exchanged with external memory 322 such as hard disk. Processor 31 exchanges data with external memory 322 through main memory 321. When the electronic device 300 is running, processor 31 and memory 32 communicate through bus 33, enabling processor 31 to execute... Figure 1 The steps of the dynamic switching method for Type-C reversible insertion.

[0115] This disclosure also provides a computer-readable storage medium storing a computer program. When executed by a processor, the computer program performs the steps of the Type-C reversible insertion dynamic switching method described in the above method embodiments. The storage medium can be a volatile or non-volatile computer-readable storage medium.

[0116] This disclosure also provides a computer program product, which includes computer instructions. When the computer instructions are executed by a processor, they can perform the steps of the Type-C reversible insertion dynamic switching method described in the above method embodiments. For details, please refer to the above method embodiments, which will not be repeated here.

[0117] The aforementioned computer program product can be implemented through hardware, software, or a combination thereof. In one optional embodiment, the computer program product is specifically embodied in a computer storage medium; in another optional embodiment, the computer program product is specifically embodied in a software product, such as a software development kit (SDK), etc.

[0118] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the specific working process of the device described above can be referred to the corresponding process in the foregoing method embodiments, and will not be repeated here. In the several embodiments provided in this disclosure, it should be understood that the disclosed device and method can be implemented in other ways. The device embodiments described above are merely illustrative. For example, the division of units is only a logical functional division, and in actual implementation, there may be other division methods. Furthermore, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Another point is that the displayed or discussed mutual coupling or direct coupling or communication connection may be through some communication interfaces; the indirect coupling or communication connection of devices or units may be electrical, mechanical, or other forms.

[0119] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.

[0120] In addition, the functional units in the various embodiments of this disclosure can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit.

[0121] If the aforementioned functions are implemented as software functional units and sold or used as independent products, they can be stored in a processor-executable, non-volatile, computer-readable storage medium. Based on this understanding, the technical solution of this disclosure, in essence, or the part that contributes to the prior art, or a portion of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this disclosure. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.

[0122] Finally, it should be noted that the above-described embodiments are merely specific implementations of this disclosure, used to illustrate the technical solutions of this disclosure, and not to limit it. The protection scope of this disclosure is not limited thereto. Although this disclosure has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that any person skilled in the art can still modify or easily conceive of changes to the technical solutions described in the foregoing embodiments, or make equivalent substitutions for some of the technical features, within the scope of the technology disclosed in this disclosure. Such modifications, changes, or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of this disclosure, and should all be covered within the protection scope of this disclosure. Therefore, the protection scope of this disclosure should be determined by the protection scope of the claims.

Claims

1. A method for dynamically switching between reversible and forward insertion of Type-C, characterized in that, include: When the Type-C interface is in a connected state, the system monitors the triggering information that indicates the current connection polarity needs to be adjusted in real time, and generates a switching request when a polarity switching trigger condition is detected. In response to the handover request, the current Type-C connection status is evaluated to determine whether the handover execution conditions are met, and the current connection parameters are recorded when the handover execution conditions are met. Based on the target switching polarity, pre-configuration is performed on the currently inactive backup path so that the backup path is prepared for at least one of the power supply path and data path before the formal switching. Before performing a path switch, the current data stream is frozen to pause new data scheduling and save the current connection session state. After the backup path meets the predetermined ready conditions, an atomic switch is performed between the current active path and the backup path to switch the working polarity of the Type-C interface from the current polarity to the target polarity. After the switchover is complete, the integrity of the new connection is verified, and the connection session state before the freeze is restored if the verification passes. After the recovery is complete, release the resources corresponding to the original path and update the polarity status information of the current Type-C interface.

2. The method according to claim 1, characterized in that, In response to the handover request, the current Type-C connection state is evaluated to determine whether the handover execution conditions are met, and the current connection parameters are recorded when the handover execution conditions are met, specifically including: Check if VBUS is in a stable state; Detect the PD negotiation status and current data transmission activity; Based on VBUS stability, PD negotiation status, and data transmission activity, determine whether the current conditions for smooth handover are met. If the conditions for a smooth handover are not met but there is an urgent handover requirement, this handover will be marked as a forced handover mode. If the conditions for a smooth handover are not met and there is no urgent handover requirement, wait for the preset transmission window before performing subsequent handover processing; The recorded current connection parameters include at least one of the following: current CC pin configuration, current current level, Alt Mode configuration, and current data channel status; the switching execution conditions include at least one of the following: no high-speed data transmission, PD negotiation completed, backup path link training completed, and backup path link integrity test passed.

3. The method according to claim 1, characterized in that, Based on the target switching polarity, pre-configuration is performed on currently inactive backup paths to ensure that the backup paths are prepared for at least one of the power supply path and data path before the formal switchover, specifically including: While maintaining continuous power supply to the currently active CC path, VCONN power supply is activated for the backup CC path; Monitor the load current of the backup CC path to determine if there are any abnormalities in the backup CC path; Configure an alternate MUX path and perform link training on the PHY layer corresponding to the alternate path; Establish a backup logical channel and perform a link integrity test on the backup logical channel; Maintain separate protocol stack states for the currently active path and the backup path; Establish a dual-channel cache for PD messages and a dual buffer for USB transaction queues.

4. The method according to claim 1, characterized in that, Before performing a path switch, the current data stream is frozen to pause new data scheduling and save the current connection session state. Specifically, this includes: Send a pause request to the USB host controller; Waiting for the currently executing transaction to complete; Pause new USB transaction scheduling; Write the current connection session state to the freeze buffer. The connection session state includes at least one of the following: USB endpoint state, bulk transfer queue state, interrupted transfer state, synchronous transfer timestamp, and Alt Mode state. Insert checkpoint markers into the data stream; Record the sequence number of the last successfully received data packet as a baseline for data recovery after the switchover.

5. The method according to claim 1, characterized in that, After the backup path meets the predetermined readiness conditions, an atomic switch is performed between the currently active path and the backup path to change the operating polarity of the Type-C interface from the current polarity to the target polarity. Specifically, this includes: Confirm that the backup path is ready; Control the MUX to enter temporary bypass mode, while keeping the currently active path active and performing pre-activation on the target path; By atomically writing to the MUX control register, the MUX can switch to the target path within a single cycle; After completing the path switch, switch the VCONN primary path and send a switch completion notification to the protocol layer; When the PD session is active, save the current PD message sequence number, send a PD session migration prompt message on the switched CC path, and migrate the PD state machine after receiving confirmation information from the peer.

6. The method according to claim 1, characterized in that, After the switchover is complete, the integrity of the new connection is verified, and the connection session state before the freeze is restored if the verification passes. This includes: Measure whether the voltage of the CC pin is within the preset range after switching; Detect the VCONN load current after switching and verify the USB endpoint response status; Check the Alt Mode link status, and if the verification is successful, restore the connection session state saved before freezing from the freeze buffer. The restoration of the connection session state before freezing includes: restoring the USB endpoint state, restoring the bulk transfer queue, restoring the interrupted transfer state, and performing delay compensation on the synchronization transfer timestamp. When any integrity verification result is detected to be unsatisfactory, a rollback process is executed. The rollback process includes: immediately switching the working path back to the original CC path; marking the target path that failed to switch as a degraded mode and outputting error report information.

7. The method according to claim 1, characterized in that, After the recovery is complete, release the resources corresponding to the original path and update the polarity state information of the current Type-C interface, specifically including: Turn off the power supply to VCONN corresponding to the original CC path; Disable the original MUX path and release the PHY layer resources corresponding to the original path; Update the global CC polarity state and output a switching completion notification to the upper-layer driver; Record the delay and success rate information of this handover, and adjust the pre-configured parameters used in subsequent handovers based on the recorded results.

8. A Type-C reversible plug dynamic switching device, characterized in that, include: The request generation module is used to monitor in real time the trigger information that indicates the current connection polarity needs to be adjusted when the Type-C interface is in a connected state, and generate a switching request when the polarity switching trigger condition is detected. The parameter recording module is used to respond to the switching request, evaluate the current Type-C connection status, determine whether the switching execution conditions are met, and record the current connection parameters when the switching execution conditions are met. The preparation module is used to perform pre-configuration on the currently inactive backup path based on the target switching polarity, so that the backup path completes preparation of at least one of the power supply path and data path before the formal switching. The polarity switching module is used to freeze the current data stream before performing path switching, so as to pause new data scheduling and save the current connection session state. After the backup path meets the predetermined ready conditions, it performs an atomic switch between the current effective path and the backup path, so that the working polarity of the Type-C interface is switched from the current polarity to the target polarity. The update module is used to verify the integrity of the connection after the switch is completed, and restore the connection session state before freezing when the verification is successful. After the recovery is complete, release the resources corresponding to the original path and update the polarity status information of the current Type-C interface.

9. An electronic device, characterized in that, include: The device includes a processor, a memory, and a bus. The memory stores machine-readable instructions executable by the processor. When the electronic device is running, the processor communicates with the memory via the bus. When the machine-readable instructions are executed by the processor, the steps of the Type-C reversible insertion dynamic switching method as described in any one of claims 1 to 7 are performed.

10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program that, when executed by a processor, performs the steps of the Type-C reversible insertion dynamic switching method as described in any one of claims 1 to 7.