Dynamic function management method and device for multi-port device and storage medium

By establishing an event pool in multi-port devices for serialized management and selecting an arbitration strategy, and independently controlling power and data functions, the resource conflict problem is solved, and the function reuse rate and management reliability are improved.

CN121807388APending Publication Date: 2026-04-07SHANGHAI SUMI TECH CO LTD +1
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-12-11
Publication Date
2026-04-07

AI Technical Summary

Technical Problem

Multi-port devices may experience functional failures or instability due to resource conflicts during parallel operation, making it difficult to meet the functional reuse requirements of complex application scenarios.

Method used

By establishing a port event pool for serialized management, selecting an arbitration strategy to generate functional control information, and independently controlling power and data functions, resource conflicts caused by parallel processing can be avoided.

Benefits of technology

It enables dynamic management of multi-port functions, improves function reuse rate, eliminates signal crosstalk, and enhances the reliability of function management.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121807388A_ABST
    Figure CN121807388A_ABST
Patent Text Reader

Abstract

The invention provides a dynamic function management method and device for a multi-port device and a storage medium, and the method comprises the steps: building a port event pool associated with the multi-port device, the port event pool is used for storing the following types of events of each port on the multi-port equipment: a port insertion event, a port pull-out event and a power role exchange event; periodically reading a to-be-executed port event in the port event pool, and querying a function role of a current port corresponding to the to-be-executed port event, the function role including a power role based on a power function and a data role based on a data function; selecting an arbitration strategy matched with the event type of the port event to be executed, and generating function control information for one or more target ports in each port by adopting the arbitration strategy; and in response to execution of corresponding function control operation on the one or more target ports, processing the one or more target ports based on the function control information to complete the port event to be executed.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates primarily to the field of multi-port device technology, and in particular to a method, device, and storage medium for dynamic management of functions of multi-port devices. Background Technology

[0002] Multi-port devices are increasingly used in POS systems. These devices have multiple physical ports (such as USB Type-C ports), and each port relies on resource allocation to perform one of the following functions: charging, discharging, etc. However, this approach can lead to functional failures or instability due to resource conflicts when accessing multiple ports, making it difficult to reuse the functions of multiple ports and thus failing to meet the needs of complex real-world application scenarios. Summary of the Invention

[0003] The purpose of this application is to solve the resource conflict problem caused by parallel operation of multiple ports, realize serialized processing of multi-port events and dynamic management of functions, thereby improving the port function reuse rate and meeting various complex application scenarios.

[0004] In a first aspect, a method for dynamic management of functions in a multi-port device is provided, comprising:

[0005] A port event pool associated with the multi-port device is established. This pool stores events of the following types for each port on the multi-port device: port insertion events, port removal events, and power role switching events. The pending port events in the port event pool are periodically read, and the functional role of the current port corresponding to the pending port event is queried. The functional roles include power roles based on power functions and data roles based on data functions. An arbitration strategy matching the event type of the pending port event is selected, and the arbitration strategy is used to generate functional control information for one or more target ports among the various ports. In response to performing corresponding functional control operations on the one or more target ports, the one or more target ports are processed based on the functional control information to complete the pending port event.

[0006] In some embodiments, for the event type being a port insertion event, the function control information includes first power state control information and first data state control information, and the arbitration strategy includes:

[0007] Determine whether the functional role of the current port meets the arbitration conditions; if so, generate the first power state control information by detecting role conflicts related to power function between the current port and other ports, and generate the first data state control information by detecting role conflicts related to data function between the current port and other ports, wherein the first power state control information is used to indicate that the power state of the target port switches between the following states: paused state and running state, and the first data state control information is used to indicate that the data state of the target port switches between the following states: paused state and running state; otherwise, wait to read the next event as the port event to be executed.

[0008] In some embodiments, generating the first power state control information by detecting power function-related role conflicts between the current port and other ports includes:

[0009] If the power function-related role conflict indicates that the power function of another port with higher power priority conflicts with the power function of the current port, and the power state of the other port with higher power priority is running, then the current port is determined as the target port, and the first power state control information is used to indicate that the power state of the current port is switched to the paused state; if the power function-related role conflict indicates that the power function of another port with lower power priority conflicts with the power function of the current port, and the power state of the other port with lower power priority is running, then the current port and the other port with lower power priority are determined as the target ports, and the first power state control information is used to indicate that the power state of the other port with lower power priority is switched to the paused state, and the power state of the current port is switched to the running state; if there is no power function-related role conflict, then the current port is determined as the target port, and the first power state control information is used to indicate that the power state of the current port is switched to the running state.

[0010] In some embodiments, generating the first data state control information by detecting role conflicts related to data functions between the current port and other ports includes:

[0011] If the data function-related role conflict indicates that the data function of another port with higher data priority conflicts with the data function of the current port, and the data state of the other port with higher data priority is running, then the current port is determined as the target port, and the first data state control information is used to instruct the data state of the current port to switch to a paused state; if the data function-related role conflict indicates that the data function of another port with lower data priority conflicts with the data function of the current port, then the current port and the other port with lower data priority are the target ports, and the first data state control information is used to instruct the data state of the other port with lower data priority to switch to a paused state, and the data state of the current port to switch to a running state; if there is no data function-related role conflict, then the current port is determined as the target port, and the first data state control information is used to instruct the data state of the current port to switch to a running state.

[0012] In some embodiments, for the event type being a port unplug event, the function control information includes second power state control information and second data state control information, wherein the second power state control information includes first power control sub-information and second power control sub-information, and the second data state control information includes first data control sub-information and second data control information; the arbitration strategy includes:

[0013] Determine whether the functional role of the current port meets the arbitration conditions; if so, designate the current port as the first target port, thereby generating the first power control sub-information and the first data control sub-information, wherein the first power control sub-information is used to indicate that the power state of the current port switches to the terminated state, and the first data control sub-information is used to indicate that the data state of the current port switches to the terminated state; and select another port as the second target port for which the power state switching is applicable, thereby generating the second power control sub-information, and select another port as the third target port for which the data state switching is applicable, thereby generating the second data control sub-information, wherein the second power control sub-information is used to indicate that the power state of the second target port switches to the running state, and the second data control sub-information is used to indicate that the data state of the third target port switches to the running state; otherwise, wait to read the next event as the port event to be executed.

[0014] In some embodiments, selecting an other port as the second target port for the applicable power state switching includes:

[0015] Based on the power priority of each port, another port whose power priority is lower than that of the current port and whose power status is paused is selected as the second target port.

[0016] Selecting another port as the third target port for applicable data state switching includes:

[0017] Based on the data priority of each port, another port whose data priority is lower than that of the current port and whose data status is paused is selected as the third target port.

[0018] In some embodiments, for the power role switching event, the function control information includes power function switching information, and the arbitration strategy includes:

[0019] Determine whether the functional role of the current port meets the arbitration condition and whether the power state of the current port is running; if so, generate the power function exchange information based on the power role of the current port, wherein the power function exchange information is used to instruct the current port to exchange between the following combinations of power roles: charging and discharging; otherwise, wait to read the next event as the port event to be executed.

[0020] In some embodiments, querying the functional role of the current port corresponding to the port event to be executed includes:

[0021] Based on the charging protocol of the current port corresponding to the port event to be executed, query the functional role of the current port, wherein the charging protocol includes the TYPE-C protocol and / or the BC1.2 protocol.

[0022] In a second aspect, an electronic device is provided. The electronic device includes: one or more processors; and one or more memories coupled to the one or more processors and storing instructions thereon. When the instructions are executed individually or jointly by the one or more processors, the electronic device performs the methods described above.

[0023] In a third aspect, a non-transitory computer-readable storage medium is provided that stores machine-executable instructions. When executed by one or more processors of a machine, the machine-executable instructions cause the machine to perform any of the methods described above.

[0024] In a fourth aspect, a computer program product including machine-executable instructions is provided. When executed by one or more processors of a machine, the machine-executable instructions cause the machine to perform any of the methods described above.

[0025] Based on the above approach, the advantages of this application are:

[0026] 1) This solution serializes the events of each port into a port event pool, ensuring that the hardware processes only one event at a time, avoiding mutual interference caused by parallel processing, which could lead to state chaos and function failure. This solves the resource conflict problem caused by multi-port parallel operation.

[0027] 2) This solution achieves dynamic management of multi-port functions by selecting an arbitration strategy that matches the event type of the port event to be executed, and using the arbitration strategy to generate functional control information for one or more target ports among the various ports. This helps to improve the port function reuse rate and meet various practical application scenarios.

[0028] 3) This solution physically isolates power signals and physical signals by independently controlling the power and data functions of each port, eliminating signal crosstalk and thus preventing it from affecting the function control of other ports, thereby improving the reliability of dynamic function management.

[0029] It should be understood that the summary section is not intended to identify key or essential features of the embodiments of this disclosure, nor is it intended to limit the scope of this disclosure. Other features of this disclosure will become readily apparent from the following description. Attached Figure Description

[0030] The above and other objects, features, and advantages of this disclosure will become more apparent from the more detailed description of some embodiments thereof in the accompanying drawings, in which:

[0031] Figure 1 A flowchart of a method for dynamic management of functions for multi-port devices is shown;

[0032] Figure 2 A logical diagram of a method for dynamic management of functions for multi-port devices is shown.

[0033] Figure 3 A flowchart illustrating an exemplary process of a port insertion event according to some embodiments of the present disclosure is shown;

[0034] Figure 4 A flowchart illustrating an exemplary process of a port unplugging event according to some embodiments of the present disclosure is shown;

[0035] Figure 5 A flowchart illustrating an exemplary process of a power role switching event according to some embodiments of the present disclosure is shown;

[0036] Figure 6 A simplified block diagram of an electronic device suitable for implementing exemplary embodiments of the present disclosure is shown. Detailed Implementation

[0037] The principles of this disclosure will now be described with reference to some embodiments. It should be understood that these embodiments are described for illustrative purposes only and to assist those skilled in the art in understanding and implementing this disclosure, and do not impose any limitation on the scope of this disclosure. The disclosure described herein may be implemented in ways other than those described below.

[0038] In the following description and claims, unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this disclosure pertains.

[0039] References to "an embodiment," "embodiment," "exemplary embodiment," etc., in this disclosure indicate that the described embodiments may include specific features, structures, or characteristics, but not every embodiment needs to include specific features, structures, or characteristics. Furthermore, such phrases do not necessarily refer to the same embodiment. Moreover, when a specific feature, structure, or characteristic is described in connection with an exemplary embodiment, whether explicitly described or not, those skilled in the art will recognize that such a feature, structure, or characteristic affects its connection to other embodiments.

[0040] It should be understood that while the terms “first” and “second”, etc., may be used herein to describe various elements, these elements should not be limited by these terms. These terms are used only to distinguish one element from another. For example, without departing from the scope of the exemplary embodiments, a first element may be referred to as a second element, and similarly, a second element may be referred to as a first element. The term “and / or” as used herein includes any and all combinations of one or more of the listed terms.

[0041] The terminology used herein is for the purpose of describing particular embodiments only and is not intended to limit the exemplary embodiments. The singular forms “a,” “an,” and “the” used herein also include the plural forms unless the context clearly indicates otherwise. The terms “a group of elements” or “a collection of elements” as used herein are intended to include one or more elements. It should also be understood that the terms “comprising,” “including,” “having,” “possessing,” “including,” and / or “comprising,” when used herein, specify the presence of the stated features, elements, and / or components, but do not exclude the presence or addition of one or more other features, elements, components, and / or combinations thereof.

[0042] The specific embodiments of this application are described in detail below with reference to the accompanying drawings.

[0043] It should be noted that before executing the exemplary process of the dynamic management method for multi-port devices described below, the multi-port device pre-initializes the configuration information of each port. This configuration information includes, but is not limited to: port ID, data capability, data priority, current data capability, current data status, power capability, power priority, current power capability, and current power status, thereby providing the data foundation for this exemplary process.

[0044] Figure 1 This is a flowchart of a method for dynamic management of functions of a multi-port device provided in this application. Figure 2 This is a logical diagram illustrating a method for dynamic management of functions in multi-port devices. For example... Figure 1 , Figure 2 As shown, the method includes the following steps:

[0045] S10, establish a port event pool associated with the multi-port device.

[0046] The port event pool is used to store the following types of events for each port on a multi-port device: port insertion events, port unplug events, and power role switching events.

[0047] In step S101, each port reports events to the port event pool according to pre-defined principles, which include one or more of the following:

[0048] If a device is detected inserted into a port, a port insertion event is reported.

[0049] If a port is unplugged, report the port unplug event.

[0050] If the PD chip initiates a power role switch, it will report the power role switch event.

[0051] S20: Periodically read the port events to be executed in the port event pool and query the functional role of the current port corresponding to the port event to be executed.

[0052] In practical applications, accessing multiple ports may cause functional failures or instability due to resource conflicts.

[0053] To address the aforementioned issues, this solution aggregates events from each port into a port event pool for serialized management. This ensures that the hardware processes only one event at a time, preventing parallel processing from interfering with each other and causing state confusion or functional failure. This resolves the resource conflict problem caused by multi-port parallel operations.

[0054] The functional roles include power roles based on power functions and data roles based on data functions.

[0055] In some embodiments, querying the functional role of the current port corresponding to the port event to be executed includes: querying the functional role of the current port based on the charging protocol of the current port corresponding to the port event to be executed, wherein the charging protocol includes the TYPE-C protocol and / or the BC1.2 protocol.

[0056] For example, if the port event to be executed is a port insertion event, the power role and data role of the current port are queried based on the TYPE-C protocol and the BC1.2 protocol. The query process includes the following steps:

[0057] The TYPE-C protocol is initiated to identify the initial power source role;

[0058] If the initial power role is MPORT_POWER_ROLE_SOURCE, then the power role of the current port is determined to be MPORT_POWER_ROLE_SOURCE, and the data role of the current port is MPORT_DATA_ROLE_USB_HOST.

[0059] If the initial power role is MPORT_POWER_ROLE_SINK, then the BC1.2 protocol is initiated to identify the charging type;

[0060] If the charging type is SDP or CDP, then the power role of the current port is determined to be MPORT_POWER_ROLE_SINK, and the data role of the current port is determined to be MPORT_DATA_ROLE_USB_DEVICE.

[0061] If the charging type is not SDP or CDP, then the power role of the current port is determined to be MPORT_POWER_ROLE_SINK, and the data role of the current port is determined to be MPORT_DATA_ROLE_IDLE.

[0062] S30, select an arbitration strategy that matches the event type of the port event to be executed, and use the arbitration strategy to generate functional control information for one or more target ports among the ports.

[0063] Furthermore, to meet various practical application scenarios, this solution selects an arbitration strategy that matches the event type of the port event to be executed, and uses the arbitration strategy to generate functional control information for one or more target ports among the various ports, thereby realizing dynamic management of multi-port functions and helping to improve the port function reuse rate.

[0064] refer to Figure 3 In some embodiments, for an event type of port insertion event, the function control information includes first power state control information and first data state control information, and the arbitration strategy includes the following steps:

[0065] A1. Determine if the current port's functional role meets the arbitration conditions; if yes, execute A2; otherwise, execute A3.

[0066] A2 includes: A2.1: generating first power state control information by detecting role conflicts related to power functions between the current port and other ports; and A2.2: generating first data state control information by detecting role conflicts related to data functions between the current port and other ports.

[0067] A3, waiting to read the next event as the port event to be executed.

[0068] In A1, the arbitration conditions include one or a combination of the following conditions:

[0069] The data role is: MPORT_DATA_ROLE_USB_HOST, or the data port is: MPORT_DATA_ROLE_USB_DEVICE;

[0070] The power role is: MPORT_POWER_ROLE_SINK, or the power port is: MPORT_POWER_ROLE_SOURCE.

[0071] In A2, the first power state control information is used to indicate that the power state of the target port switches between the following states: paused state (MPORT_STATE_SUSPEND) and running state (MPORT_STATE_RUNNING). The first data state control information is used to indicate that the data state of the target port switches between the following states: paused state (MPORT_STATE_SUSPEND) and running state (MPORT_STATE_RUNNING).

[0072] In A2.1, first power state control information is generated by detecting role conflicts related to power functions between the current port and other ports, including:

[0073] A2.1.1 If the role conflict related to the power function indicates that the power function of another port with higher power priority conflicts with the power function of the current port, and the power state of the other port with higher power priority is running, then the current port is determined as the target port, and the first power state control information is used to indicate that the power state of the current port is switched to the paused state.

[0074] A2.1.2 If the role conflict related to the power function indicates that the power function of another port with a lower power priority conflicts with the power function of the current port, and the power state of the other port with a lower power priority is in the running state, then the current port and the other port with a lower power priority are determined as the target ports, and the first power state control information is used to indicate that the power state of the other port with a lower power priority is switched to the pause state, and the power state of the current port is switched to the running state.

[0075] A2.1.3 If there is no role conflict related to power function, the current port is determined as the target port, and the first power state control information is used to indicate that the power state of the current port is switched to the running state.

[0076] In A2.2, first data status control information is generated by detecting role conflicts related to data functions between the current port and other ports, including:

[0077] A2.2.1 If the role conflict related to the data function indicates that the data function of another port with higher data priority conflicts with the data function of the current port, and the data status of the other port with higher data priority is running, then the current port is determined as the target port, and the first data status control information is used to indicate that the data status of the current port is switched to the paused state.

[0078] A2.2.2 If a role conflict related to a data function indicates a conflict between the data function of another port with a lower data priority and the data function of the current port, then the current port and the other port with a lower data priority are the target ports, and the first data status control information is used to indicate that the data status of the other port with a lower data priority is switched to the paused state, and the data status of the current port is switched to the running state.

[0079] A2.2.3 If there is no role conflict related to the data function, the current port is determined as the target port, and the first data status control information is used to indicate that the data status of the current port is switched to the running state.

[0080] Further, refer to Figure 4 In some embodiments, for an event type of port unplugging event, the function control information includes second power state control information and second data state control information, wherein the second power state control information includes first power control sub-information and second power control sub-information, and the second data state control information includes first data control sub-information and second data control sub-information. The arbitration strategy includes:

[0081] B1: Determine whether the current port's functional role meets the arbitration conditions. If yes, execute B2; otherwise, execute B3.

[0082] In B1, the arbitration conditions include one or a combination of the following:

[0083] The data role is: MPORT_DATA_ROLE_USB_HOST, or the data port is: MPORT_DATA_ROLE_USB_DEVICE;

[0084] The power role is: MPORT_POWER_ROLE_SINK, or the power port is: MPORT_POWER_ROLE_SOURCE.

[0085] B2, which includes: B2.1, taking the current port as the first target port to generate first power control sub-information and first data control sub-information; and B2.2, selecting another port as the second target port for applicable power state switching to generate second power control sub-information, and selecting another port as the third target port for applicable data state switching to generate second data control sub-information.

[0086] B3, waiting to read the next event as the port event to be executed.

[0087] In B2.1, the first power control sub-information is used to indicate that the power state of the current port is switched to the terminated state, and the first data control sub-information is used to indicate that the data state of the current port is switched to the terminated state.

[0088] In B2.2, the second power control sub-information is used to indicate that the power state of the second target port is switched to the running state, and the second data control sub-information is used to indicate that the data state of the third target port is switched to the running state.

[0089] Specifically, in B2.2, selecting an other port as the second target port for the applicable power state switching includes: based on the power priority of each port, selecting an other port whose power priority is lower than that of the current port and whose power state is paused as the second target port;

[0090] Select an other port as the third target port for applicable data state switching, including: based on the data priority of each port, select an other port whose corresponding data priority is lower than that of the current port and whose corresponding data state is paused as the third target port.

[0091] It will be understood that, in B2.2, the second and third target ports are not logically related. Therefore, in practical applications, the physical entities of the second and third target ports may or may not be the same.

[0092] For example, in a multi-port device, a first process for power state switching and a second process for data state switching can be run. In B2.2, the first process extracts the power priority from the configuration information of each port and selects the second target port according to the power priority order. At the same time, the second process extracts the data priority from the configuration information of each port and selects the third target port according to the data priority order.

[0093] Therefore, based on Figure 3 , Figure 4 The operational logic shown for port insertion and port removal events can be divided into two categories for the same port, based on the different functional objects: power function control and data function control. In practical applications, power function control and data function control are implemented using different signals. Therefore, this solution physically isolates power signals from physical signals, eliminating signal crosstalk and preventing it from affecting the functional control of other ports, thus improving the reliability of dynamic function management.

[0094] Further, refer to Figure 5 In some embodiments, for power role switching events, the function control information includes power function switching information, and the arbitration strategy includes:

[0095] C1 determines whether the current port's functional role meets the arbitration conditions and whether the current port's power status is running; if yes, execute C2; ​​otherwise, execute C3.

[0096] In C1, the arbitration conditions include any one of the following:

[0097] The power role is: MPORT_POWER_ROLE_SINK, or the power port is: MPORT_POWER_ROLE_SOURCE.

[0098] C2 generates power function exchange information based on the power role of the current port;

[0099] Among them, the power function exchange information is used to indicate whether the current port is switching between the following combinations of power roles: a combination of charging and discharging;

[0100] For example, if the current port’s power role is charging, then the power function switching information is used to instruct the current port to switch its power role to discharging.

[0101] C3 is waiting to read the next event as the port event to be executed.

[0102] S40, in response to performing corresponding function control operations for one or more target ports, processes one or more target ports based on function control information to complete the port event to be executed.

[0103] It should be noted that in some embodiments, the function control operations include independent power function control operations and data function control operations, so as to eliminate signal crosstalk through physical isolation. Based on the above approach, this solution solves the resource conflict problem caused by multi-port parallel operation and realizes dynamic management of multi-port functions, which helps to improve the port function reuse rate and meet various practical application scenarios.

[0104] Furthermore, such as Figure 6 An exemplary embodiment of this application also provides an electronic device including one or more memories 601 and one or more processors 602, wherein the one or more memories 601 are coupled to and store instructions thereon on the one or more processors 602, the instructions being executable individually or jointly by the one or more processors 602, causing the electronic device to perform the method as described in any of the first aspects.

[0105] It should be understood that the processor mentioned in the embodiments of this application can be a CPU, or other general-purpose processors, DSPs, ASICs, FPGAs, or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor can be a microprocessor or any conventional processor.

[0106] It should also be understood that the memory mentioned in the embodiments of this application can be volatile memory or non-volatile memory, or may include both volatile and non-volatile memory. Non-volatile memory can be read-only memory (ROM), programmable read-only memory, erasable programmable read-only memory, electrically erasable programmable read-only memory, or flash memory. Volatile memory can be random access memory (RAM), which is used as an external cache. By way of example, but not limitation, many forms of RAM are available, such as static random access memory, dynamic random access memory, synchronous dynamic random access memory, double data rate synchronous dynamic random access memory, enhanced synchronous dynamic random access memory, synchronous linked dynamic random access memory, and direct memory bus random access memory.

[0107] This application also provides a non-transitory computer-readable storage medium storing machine-executable instructions that can be executed by one or more processors of a machine. The machine may include electronic devices as mentioned above. When the machine-executable instructions are executed by one or more processors, the machine performs any of the methods mentioned above.

[0108] Computer-readable storage media may contain a propagated data signal containing computer program code, for example, on baseband or as part of a carrier wave. This propagated signal may take various forms, including electromagnetic, optical, and so on, or suitable combinations thereof. The computer-readable storage medium can be connected to an instruction execution system, apparatus, or device to enable communication, propagation, or transmission of a program for use. The program code located on the computer-readable storage medium can be propagated through any suitable medium, including radio, cable, fiber optic cable, radio frequency signals, or similar media, or any combination of the above media.

[0109] The basic concepts have been described above. Obviously, for those skilled in the art, the above disclosure is merely illustrative and does not constitute a limitation of this application. Although not explicitly stated herein, those skilled in the art may make various modifications, improvements, and corrections to this application. Such modifications, improvements, and corrections are suggested in this application, and therefore remain within the spirit and scope of the exemplary embodiments of this application.

[0110] Furthermore, this application uses specific terms to describe embodiments of the application. For example, "an embodiment," "one embodiment," and / or "some embodiments" refer to a particular feature, structure, or characteristic related to at least one embodiment of the application. Therefore, it should be emphasized and noted that "an embodiment," "one embodiment," or "an alternative embodiment" mentioned twice or more in different locations in this specification do not necessarily refer to the same embodiment. In addition, certain features, structures, or characteristics in one or more embodiments of the application can be appropriately combined.

[0111] Some aspects of this application can be executed entirely by hardware, entirely by software (including firmware, resident software, microcode, etc.), or by a combination of hardware and software. The aforementioned hardware or software may be referred to as a "data block," "module," "engine," "unit," "component," or "system." The processor may be one or more application-specific integrated circuits (ASICs), digital signal processors (DSPs), digital signal processing devices (DAPDs), programmable logic devices (PLDs), field-programmable gate arrays (FPGAs), processors, controllers, microcontrollers, microprocessors, or combinations thereof. Furthermore, aspects of this application may manifest as computer products residing in one or more computer-readable media, including computer-readable program code. For example, computer-readable media may include, but are not limited to, magnetic storage devices (e.g., hard disks, floppy disks, magnetic tapes, etc.), optical discs (e.g., compressed CDs, digital multifunction DVDs, etc.), smart cards, and flash memory devices (e.g., cards, sticks, key drives, etc.).

[0112] A computer-readable medium may contain a propagated data signal containing computer program code, for example, on baseband or as part of a carrier wave. This propagated signal may take various forms, including electromagnetic, optical, and so on, or suitable combinations thereof. A computer-readable medium can be any computer-readable medium other than a computer-readable storage medium, which can be connected to an instruction execution system, apparatus, or device to enable communication, propagation, or transmission of a program for use. The program code located on the computer-readable medium can be propagated through any suitable medium, including radio, cable, fiber optic cable, radio frequency signals, or similar media, or any combination of the above media.

[0113] Similarly, it should be noted that, in order to simplify the description of the present application and thus aid in the understanding of one or more embodiments of the invention, the foregoing description of the embodiments of the present application sometimes combines multiple features into a single embodiment, drawing, or description thereof. However, this disclosure method does not imply that the subject matter of the application requires more features than those mentioned in the claims. In fact, the embodiments contain fewer features than all the features of the single embodiments disclosed above.

[0114] In some embodiments, numbers describing the quantity of components and attributes are used. It should be understood that such numbers used in the description of embodiments are modified in some examples with the terms "approximately," "approximately," or "generally." Unless otherwise stated, "approximately," "approximately," or "generally" indicates that the numbers are allowed to vary by ±20%. Accordingly, in some embodiments, the numerical parameters used in the specification and claims are approximate values, which may be changed depending on the characteristics required by individual embodiments. In some embodiments, numerical parameters should take into account specified significant digits and employ a general method of digit reservation. Although the numerical ranges and parameters used to confirm their breadth of scope in some embodiments of this application are approximate values, in specific embodiments, such values ​​are set as precisely as feasible.

[0115] Although this application has been described with reference to specific embodiments, those skilled in the art should recognize that the above embodiments are only used to illustrate this application, and various equivalent changes or substitutions can be made without departing from the spirit of this application. Therefore, any changes or modifications to the above embodiments within the essential spirit of this application will fall within the scope of the claims of this application.

Claims

1. A method for dynamic management of functions in multi-port devices, characterized in that, include: Establish a port event pool associated with the multi-port device, the port event pool being used to store the following types of events for each port on the multi-port device: port insertion event, port removal event, and power role switching event; Periodically read the port events to be executed in the port event pool, and query the functional role of the current port corresponding to the port event to be executed. The functional roles include power roles based on power functions and data roles based on data functions. Select an arbitration strategy that matches the event type of the port event to be executed, and use the arbitration strategy to generate functional control information for one or more target ports among the ports; In response to performing a corresponding function control operation on the one or more target ports, the one or more target ports are processed based on the function control information to complete the port event to be executed.

2. The method as described in claim 1, characterized in that, For the event type being a port insertion event, the function control information includes first power state control information and first data state control information, and the arbitration strategy includes: Determine whether the functional role of the current port meets the arbitration conditions; If so, the first power state control information is generated by detecting role conflicts related to power function between the current port and other ports, and the first data state control information is generated by detecting role conflicts related to data function between the current port and other ports. The first power state control information is used to indicate that the power state of the target port switches between the following states: paused state and running state. The first data state control information is used to indicate that the data state of the target port switches between the following states: paused state and running state. Otherwise, wait to read the next event as the pending port event.

3. The method as described in claim 2, characterized in that, The step of generating the first power state control information by detecting role conflicts related to power function between the current port and other ports includes: If the power function-related role conflict indicates that the power function of another port with higher power priority conflicts with the power function of the current port, and the power state of the other port with higher power priority is running, then the current port is determined to be the target port, and the first power state control information is used to indicate that the power state of the current port is switched to the paused state. If the power function-related role conflict indicates that the power function of another port with a lower power priority conflicts with the power function of the current port, and the power state of the other port with a lower power priority is running, then the current port and the other port with a lower power priority are determined as the target port, and the first power state control information is used to instruct the power state of the other port with a lower power priority to switch to the paused state, and the power state of the current port to switch to the running state. If there is no role conflict related to the power function, the current port is determined to be the target port, and the first power state control information is used to indicate that the power state of the current port is switched to the running state.

4. The method as described in claim 2, characterized in that, The step of generating the first data status control information by detecting role conflicts related to data functions between the current port and other ports includes: If the role conflict related to the data function indicates that the data function of another port with higher data priority conflicts with the data function of the current port, and the data status of the other port with higher data priority is running, then the current port is determined to be the target port, and the first data status control information is used to indicate that the data status of the current port is switched to the paused state. If the role conflict related to the data function indicates that the data function of another port with a lower data priority conflicts with the data function of the current port, then the current port and the other port with a lower data priority are the target ports, and the first data status control information is used to indicate that the data status of the other port with a lower data priority is switched to a paused state, and the data status of the current port is switched to a running state. If there is no role conflict related to the data function, the current port is determined to be the target port, and the first data status control information is used to indicate that the data status of the current port is switched to the running state.

5. The method as described in claim 1, characterized in that, For the event type being a port unplug event, the function control information includes second power state control information and second data state control information, wherein the second power state control information includes first power control sub-information and second power control sub-information, and the second data state control information includes first data control sub-information and second data control information. The arbitration strategy includes: Determine whether the functional role of the current port meets the arbitration conditions; If so, then: The current port is used as the first target port to generate the first power control sub-information and the first data control sub-information, wherein the first power control sub-information is used to indicate that the power state of the current port is switched to the termination state, and the first data control sub-information is used to indicate that the data state of the current port is switched to the termination state. as well as, Select another port as the second target port for applicable power state switching, thereby generating the second power control sub-information; and select another port as the third target port for applicable data state switching, thereby generating the second data control sub-information. The second power control sub-information is used to indicate that the power state of the second target port is switched to the running state, and the second data control sub-information is used to indicate that the data state of the third target port is switched to the running state. Otherwise, wait to read the next event as the pending port event.

6. The method as described in claim 5, characterized in that, Selecting another port as the second target port for the applicable power state switching includes: Based on the power priority of each port, another port whose power priority is lower than that of the current port and whose power status is paused is selected as the second target port. Selecting another port as the third target port for applicable data state switching includes: Based on the data priority of each port, another port whose data priority is lower than that of the current port and whose data status is paused is selected as the third target port.

7. The method as described in claim 1, characterized in that, For the power role switching event, the function control information includes power function switching information, and the arbitration strategy includes: Determine whether the functional role of the current port meets the arbitration conditions, and whether the power status of the current port is in the running state; If so, the power function switching information is generated based on the power role of the current port, wherein the power function switching information is used to indicate that the current port switches between the following combinations of power roles: charging and discharging; Otherwise, wait to read the next event as the pending port event.

8. The method according to any one of claims 1-7, characterized in that, The function role of the current port corresponding to the port event to be executed includes: Based on the charging protocol of the current port corresponding to the port event to be executed, query the functional role of the current port, wherein the charging protocol includes the TYPE-C protocol and / or the BC1.2 protocol.

9. An electronic device, characterized in that, include: One or more processors; as well as One or more memories coupled to the one or more processors and storing instructions thereon, which, when executed individually or jointly by the one or more processors, cause the electronic device to perform the method of any one of claims 1-8.

10. A non-transitory computer-readable storage medium storing machine-executable instructions, characterized in that, When executed by one or more processors of the machine, the machine-executable instructions cause the machine to perform the method of any one of claims 1-8.

11. A computer program product comprising machine-executable instructions, characterized in that, When executed by one or more processors of the machine, the machine-executable instructions cause the machine to perform the method of any one of claims 1-8.