CN114201432B - Method and electronic device for USB transmission - Google Patents

Method and electronic device for USB transmission Download PDF

Info

Publication number
CN114201432B
CN114201432B CN202010912316.3A CN202010912316A CN114201432B CN 114201432 B CN114201432 B CN 114201432B CN 202010912316 A CN202010912316 A CN 202010912316A CN 114201432 B CN114201432 B CN 114201432B
Authority
CN
China
Prior art keywords
usb
endpoints
endpoint
service
usb host
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN202010912316.3A
Other languages
Chinese (zh)
Other versions
CN114201432A (en
Inventor
徐大庆
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Huawei Technologies Co Ltd
Original Assignee
Huawei Technologies Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Huawei Technologies Co Ltd filed Critical Huawei Technologies Co Ltd
Priority to CN202010912316.3A priority Critical patent/CN114201432B/en
Priority to PCT/CN2021/112163 priority patent/WO2022048419A1/en
Publication of CN114201432A publication Critical patent/CN114201432A/en
Application granted granted Critical
Publication of CN114201432B publication Critical patent/CN114201432B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F13/00Interconnection of, or transfer of information or other signals between, memories, input/output devices or central processing units
    • G06F13/38Information transfer, e.g. on bus
    • G06F13/42Bus transfer protocol, e.g. handshake; Synchronisation
    • G06F13/4282Bus transfer protocol, e.g. handshake; Synchronisation on a serial bus, e.g. I2C bus, SPI bus
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F13/00Interconnection of, or transfer of information or other signals between, memories, input/output devices or central processing units
    • G06F13/38Information transfer, e.g. on bus
    • G06F13/40Bus structure
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F13/00Interconnection of, or transfer of information or other signals between, memories, input/output devices or central processing units
    • G06F13/38Information transfer, e.g. on bus
    • G06F13/40Bus structure
    • G06F13/4063Device-to-bus coupling
    • G06F13/4068Electrical coupling
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F13/00Interconnection of, or transfer of information or other signals between, memories, input/output devices or central processing units
    • G06F13/38Information transfer, e.g. on bus
    • G06F13/42Bus transfer protocol, e.g. handshake; Synchronisation

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • General Engineering & Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Computer Hardware Design (AREA)
  • Information Transfer Systems (AREA)

Abstract

本申请提供了一种用于USB传输的方法和电子设备。该方法包括:USB设备和USB主机可以在传输第一业务之前,提前配置USB设备支持的M个第二端点对应的M个通道,当USB主机和USB设备确定传输第一业务需要N通道时,可以在该M个通道中选择N个通道传输第一业务。这样,不需要USB主机重新加载主机驱动生成N个通道,从而可以节省传输时延。一个虚拟USB接口可以对应M个通道,这样,在传输任何一个业务的业务数据时,不需要通过删除虚拟USB接口或增加虚拟USB接口来切换不同的通道,只需要在一个虚拟USB接口内确定传输业务的通道即可,从而可以节省传输时延。

The present application provides a method and electronic device for USB transmission. The method includes: before transmitting the first service, the USB device and the USB host can configure in advance the M channels corresponding to the M second endpoints supported by the USB device. When the USB host and the USB device determine that N channels are required to transmit the first service, N channels can be selected from the M channels to transmit the first service. In this way, the USB host does not need to reload the host driver to generate N channels, thereby saving transmission delay. A virtual USB interface can correspond to M channels. In this way, when transmitting the service data of any service, there is no need to switch different channels by deleting the virtual USB interface or adding a virtual USB interface. It is only necessary to determine the channel for transmitting the service within a virtual USB interface, thereby saving transmission delay.

Description

Method and electronic device for USB transmission
Technical Field
The present application relates to the field of communications, and more particularly to a method and an electronic device for USB transmission in the field of communications.
Background
Universal serial bus (universal serial bus, USB) devices support plug and play. The USB device can virtualize a plurality of virtual USB interfaces, different combinations of the plurality of virtual USB interfaces correspond to different configurations, and the USB host and the USB device can transmit different services based on the different configurations. Of course, the USB host and the USB device may also transmit one or more services based on one configuration. When the USB host and the USB device need to switch different services corresponding to different configurations, the USB host also needs to switch different configurations, and in the process of switching the configurations, the USB host needs to be disconnected from the USB device, specifically, the USB host needs to clear a USB device descriptor, a configuration descriptor and a virtual USB interface descriptor which are stored on the USB host side. In this process, the USB host and the USB device are completely disconnected physically, and then the USB device needs to report the device descriptor, the configuration descriptor, the virtual USB interface descriptor corresponding to the configuration descriptor, and so on to the USB host. At least three handshakes are required to establish a virtual USB interface corresponding to the new configuration, which results in a longer transmission delay.
Disclosure of Invention
The embodiment of the application provides a method and a device for USB transmission, which can reduce transmission delay.
In a first aspect, there is provided a method for USB transmission, comprising: the USB host determines to transmit a first service with the USB device; the USB host determines N first endpoints used for transmitting the first service in M first endpoints; the USB host transmits service data of the first service through N channels between N first endpoints and N second endpoints in M second endpoints corresponding to one virtual USB interface of the USB device, the physical interface of the USB device corresponds to the one virtual USB interface, the M second endpoints are the number of endpoints supported by the USB device, the M second endpoints and the M first endpoints are in one-to-one correspondence with the M channels, the N first endpoints and the N second endpoints are the endpoints of the USB host, and the M second endpoints are the endpoints of the USB device; wherein M, N is a positive integer, M is greater than or equal to N.
In the above scheme, before the first service is transmitted, the USB device and the USB host may configure M channels corresponding to M second endpoints supported by the USB device in advance, and when the USB host and the USB device determine that N channels are required for transmitting the first service, N channels may be selected from the M channels to transmit the first service. In this way, the USB host is not required to reload the host driver to generate N channels, so that transmission delay can be saved. In other words, a virtual USB interface may correspond to M channels, so when transmitting service data of any service, it is not necessary to delete the virtual USB interface or add the virtual USB interface to switch different channels, and only the channel for transmitting the service needs to be determined in the virtual USB interface, thereby saving transmission delay.
M numbers corresponding to M second endpoints supported by the USB device are in one-to-one correspondence with M numbers corresponding to M first endpoints of the USB host.
The M numbers corresponding to the M first endpoints of the USB host may be allocated to the USB host, or the USB host may determine the numbers of the M first endpoints according to the numbers of the M second endpoints, for example, the USB host may use the numbers of the M second endpoints as the numbers of the M first endpoints.
Optionally, the USB host determines N first endpoints for transmitting the first traffic from M first endpoints, including: the USB host selects N first endpoints meeting the service type of the first service from M first endpoints according to the service type of the first service.
In some possible implementations, before the USB host determines to transmit the first service, the method further includes:
The USB host receives first endpoint information from the USB device, where the first endpoint information is used to indicate endpoint types of the M second endpoints supported by the USB device and endpoint numbers of the M second endpoints: the USB host determines endpoint numbers of the M first endpoints according to the first endpoint information; and the USB host establishes the M channels with the USB device according to the endpoint numbers of the M first endpoints and the endpoint numbers of the M second endpoints.
In the above scheme, the USB device may report, in advance, the endpoint numbers and endpoint types of the M second endpoints supported by the USB device to the USB host, where the USB host and the USB device may be configured with M channels in advance, so as to perform a preparation work in advance for subsequent transmission of service data of the first service.
In some possible implementations, the USB host determining N first endpoints for transmitting the first traffic among M first endpoints includes:
the USB host determines first endpoint combination information used for transmitting the first service in at least one endpoint combination information, wherein different endpoint combination information in the at least one endpoint combination information is used for indicating different endpoint combinations supported by the USB device, the different endpoint combinations comprise different numbers of endpoints and/or different types of endpoints, and the first endpoint combination information is used for indicating the first endpoint combination;
The USB host determines the N first endpoints from the M first endpoints according to the first endpoint combination, wherein the first endpoint combination is used for indicating the number of endpoints as N and the endpoint types of the N endpoints.
In the above-described aspect, the USB host may determine first endpoint combination information for transmitting the first service among the at least one endpoint combination information. The USB host may determine N first endpoints for transmitting traffic data of the first traffic among the M first endpoints according to the first endpoint combination indicated by the first endpoint combination information.
Optionally, the at least one endpoint combination information may be reported to the USB host by the USB device, or may be preset, which is not limited by the present application.
In some possible implementations, the USB host may determine N first endpoints from the M first endpoints according to the first endpoint combination and the endpoint numbers and endpoint types of the M second endpoints. That is, the USB host may select N second endpoints of the M second endpoints according to the endpoint types in the first endpoint combination, and then determine the first endpoints corresponding to the selected N second endpoints as N first endpoints.
In some possible implementations, the determining, by the USB host, the N first endpoints from the M first endpoints according to the first endpoint combination includes: the USB host sends first indication information to the USB equipment, wherein the first indication information is used for indicating the first endpoint combination;
The USB host receives the numbers of the N second endpoints determined by the USB device according to the first endpoint combination indicated by the first indication information;
The USB host determines the N first endpoints according to the numbers of the N second endpoints.
In the above solution, the USB host may send first indication information indicating the first endpoint combination to the USB device, where the USB device determines endpoint numbers of the N second endpoints according to the first endpoint combination, and the USB host may determine first endpoints corresponding to the N second endpoints indicated by the endpoint numbers of the N second endpoints as the N first endpoints.
Alternatively, the USB host may send the first indication information to the USB device through the control endpoint.
In some possible implementations, before the USB host determines to transmit the first service, the method further includes: the USB host allocates resources for the M first endpoints. In other words, the USB host may allocate resources for M channels in advance.
In some possible implementations, after the USB host determines N first endpoints for transmitting the first traffic among M first endpoints, the method further includes: the USB host allocates resources for the N first endpoints. In other words, the USB host determines N first endpoints for transmitting the first traffic among the M first endpoints, and then allocates resources for the N first endpoints.
In some possible implementations, after the USB host determines to transmit the first service, the method further includes:
The USB host determines to transmit a second service;
The USB host determines second endpoint combination information and third endpoint combination information for transmitting the second service in the at least one endpoint combination information, wherein the second endpoint combination information is used for indicating the second endpoint combination, and the third endpoint combination information is used for indicating the third endpoint combination;
If the USB host determines that the first endpoint combination is the same as the second endpoint combination, the USB host transmits partial data of the second service through the N channels.
In the above scheme, the USB host may use N channels for transmitting the service data of the first service to transmit the second service, so when switching services, the USB host and the USB device may be prevented from reallocating resources and numbers to the N channels, thereby saving overhead.
The first endpoint combination is the same as the second endpoint combination, and it is understood that the number of endpoints indicated by the first endpoint combination and the second endpoint combination is N and the endpoint types of the N endpoints are the same.
In some possible implementations, the third endpoint combination is configured to indicate the number of endpoints as P and endpoint types of the P endpoints, P being less than or equal to M-N, and the method further includes:
if the USB host determines that the first endpoint combination is different from the third endpoint combination, the USB host sends second indication information to the USB device, wherein the second indication information is used for indicating the third endpoint combination;
the USB host receives the numbers of the P second endpoints determined by the USB device according to the second indication information;
The USB host determines P channels in M-N channels according to the endpoint numbers of the P second endpoints;
and the USB host transmits the rest business data of the second business with the USB equipment through the P channels.
In the above scheme, the USB host may send a third endpoint combination different from the first endpoint combination of the first service to the USB device through the second indication information, the USB device may determine numbers of P second endpoints among the remaining endpoints according to the third endpoint combination, and the USB host may determine P channels for transmitting remaining portion of service data of the second service among the M-N channels according to the numbers of the P second endpoints.
Alternatively, the USB host may send the second indication information to the USB device through the control endpoint.
In some possible implementations, after the USB host determines to transmit the second service, the method further includes: the USB host sends a switching command to the USB device, wherein the switching command is used for indicating to switch a first service currently being transmitted into a second service.
Alternatively, the USB host may send a switch command to the USB device through the control endpoint.
In a second aspect, there is provided a method for universal serial bus, USB, transmission, comprising: the method comprises the steps that the USB equipment determines N second endpoints which transmit first service with a USB host from M second endpoints corresponding to one virtual USB interface, wherein the M second endpoints are the number of endpoints supported by the USB equipment, and the physical USB interface of the USB equipment corresponds to the virtual USB interface;
the USB device transmits service data of the first service through N channels between the N second endpoints and N first endpoints in M first endpoints of the USB host;
The M second endpoints and the M first endpoints are in one-to-one correspondence with the M channels, the N first endpoints and the N second endpoints are in one-to-one correspondence with the N channels in the M channels, M, N are positive integers, M is greater than or equal to N, the M first endpoints are endpoints of the USB host, and the M second endpoints are endpoints of the USB device.
In some possible implementations, before the USB device determines N second endpoints that transmit the first traffic with the USB host among M second endpoints corresponding to one virtual USB interface, the method further includes:
the USB device sends first endpoint information to the USB host, wherein the first endpoint information is used for indicating endpoint types of the M second endpoints supported by the USB device and endpoint numbers of the M second endpoints;
and the USB equipment establishes the M channels with the USB host according to the first endpoint information.
In some possible implementations, the determining, by the USB device, N second endpoints that transmit the first traffic with the USB host from M second endpoints corresponding to one virtual USB interface includes:
The USB equipment receives first indication information sent by the USB host, wherein the first indication information is used for indicating a first endpoint combination, and the first endpoint combination is used for indicating endpoint types of N endpoints and N endpoints;
And the USB equipment determines the N second endpoints from the M second endpoints according to the first endpoint combination indicated by the first indication information.
In some possible implementations, the method further includes: the USB device sends at least one endpoint combination information to the USB host, different endpoint combination information of the at least one endpoint combination information is used for indicating different endpoint combinations supported by the USB device, the different endpoint combinations comprise different numbers of endpoints and/or different types of endpoints, and first endpoint combination information in the at least one endpoint combination information is used for indicating the first endpoint combination.
In some possible implementations, before the USB device determines N second endpoints that transmit the first traffic with the USB host among M second endpoints corresponding to one virtual USB interface, the method further includes:
and the USB equipment allocates resources for the M second endpoints.
In some possible implementations, after the USB device determines N second endpoints that transmit the first traffic with the USB host among M second endpoints corresponding to one virtual USB interface, the method further includes:
And the USB equipment allocates resources for the N second endpoints.
In some possible implementations, the method further includes:
the USB equipment receives a switching command sent by the USB host, wherein the switching command is used for indicating the USB equipment to switch the first service being transmitted into a second service;
and the switching command of the USB equipment receives part of service data of the second service sent by the USB host through the N channels.
In some possible implementations, the method further includes: the USB equipment receives second indicating information sent by the USB host, wherein the second indicating information is used for indicating a third end point combination, and the third end point combination is used for indicating the number of the end points to be P and the endpoint types of the P end points, and P is smaller than or equal to M-N;
the USB equipment determines the numbers of P second endpoints in the M second endpoints according to the third endpoint combination indicated by the second indication information;
the USB equipment sends the numbers of the P second endpoints to the USB host;
And the USB host transmits the rest business data of the second business with the USB equipment through P channels corresponding to the P second endpoints.
In a third aspect, an apparatus is provided, which is included in an electronic device, the apparatus having functionality to implement the above aspects and possible implementations of the above aspects. The functions may be realized by hardware, or may be realized by hardware executing corresponding software. The hardware or software includes one or more modules or units corresponding to the functions described above. For example, a determination module or unit, a transmission module or unit, etc.
Alternatively, the apparatus may be a USB host or a USB device as described above.
In a fourth aspect, there is provided an apparatus comprising a processor coupled to a memory for storing a computer program or instructions, the processor for executing the computer program or instructions stored in the memory, such that the aspects and methods in possible implementations of the aspects are performed.
For example, a processor is configured to execute a computer program or instructions stored in a memory to cause the apparatus to perform the aspects and possible implementations of the aspects.
Optionally, the apparatus includes one or more processors.
Optionally, a memory coupled to the processor may also be included in the apparatus.
Alternatively, the apparatus may comprise one or more memories.
Alternatively, the memory may be integrated with the processor or provided separately.
Optionally, a transceiver may also be included in the apparatus.
In a fifth aspect, the present application provides an electronic device, comprising: one or more processors; a memory; a plurality of applications; and one or more computer programs. Wherein one or more computer programs are stored in the memory, the one or more computer programs comprising instructions. The instructions, when executed by an electronic device, cause the electronic device to perform the method for USB transfer in any one of the possible implementations of any one of the above aspects.
Optionally, the electronic device may further include: a touch display screen and/or a camera, wherein the touch display screen comprises a touch-sensitive surface and a display;
Alternatively, the electronic device may be the USB device or the USB host described above.
In a sixth aspect, the application provides a computer readable storage medium comprising computer instructions which, when run on an electronic device, cause the electronic device to perform the method for USB transmission possible according to any one of the above aspects.
In a seventh aspect, the application provides a computer program product for causing an electronic device to perform the method for USB transmission possible of any one of the above aspects when the computer program product is run on the electronic device.
Drawings
Fig. 1 is an application scenario diagram provided by an embodiment of the present application.
FIG. 2 is a schematic diagram of a virtual USB interface and configuration according to an embodiment of the present application.
FIG. 3 is a schematic diagram of another virtual USB interface and configuration according to an embodiment of the present application.
Fig. 4 is a system architecture diagram provided in an embodiment of the present application.
Fig. 5 is a schematic diagram of a method for USB transmission according to an embodiment of the present application.
Fig. 6 is a schematic diagram of an endpoint provided by an embodiment of the present application.
Fig. 7 is a schematic diagram of M channels according to an embodiment of the present application.
FIG. 8 is a schematic diagram illustrating a virtual USB interface and at least one endpoint combination information provided by an embodiment of the present application.
Fig. 9 is a schematic diagram of a first endpoint combination according to an embodiment of the present application.
Fig. 10 is a schematic diagram of a method for switching services according to an embodiment of the present application.
Fig. 11 is a schematic diagram of an endpoint for transmitting a second service according to an embodiment of the present application.
FIG. 12 is a schematic diagram of a virtual USB interface and an endpoint according to an embodiment of the present application.
Fig. 13 is a schematic diagram of a method for USB transmission according to an embodiment of the present application.
Fig. 14 is a schematic diagram of an electronic device according to an embodiment of the present application.
Detailed Description
The technical solutions in the embodiments of the present application will be described below with reference to the accompanying drawings in the embodiments of the present application.
The following description of the terms used in the embodiments of the present application will be given.
The USB device is used for communicating with the USB host, information of the USB device can be described by a device descriptor, and the device descriptor can indicate the number of configurations included in the USB device. USB devices include, but are not limited to: keyboard, mouse, joystick, printer, scanner, USB mobile hard disk, USB flash disk, USB CD-ROM, microphone, modem, cell phone, tablet, USB communication network card, sports watch, sports bracelet, USB card reader, USB key, USB Bluetooth adapter, USB wireless network card, USB camera, etc.
The USB host is used for providing services for the USB devices, and the USB host can provide services for one or more USB devices. For example, USB hosts include, but are not limited to: personal computers (personal computer, PCs), host mode handsets, car sets, point of sale (POS) sets, or Televisions (TVs), etc.
The USB line is a physical connecting line for connecting the USB host and the USB device. Of course, the USB flash disk can be also understood to be connected through a USB line when being plugged into a computer.
A configuration, a USB device may include one or more configurations, a configuration descriptor describing characteristics of a configuration in the USB device, a configuration corresponding to one or more virtual USB interfaces, e.g., a configuration descriptor including a length of the configuration descriptor, a type of the configuration descriptor, an interface descriptor, etc. The USB device and the USB host may transmit different services through different configurations, although the USB host and the USB device may transmit different services through one configuration. For example, the USB device may employ two different configurations to transmit a low power mode service and a high power mode service, where the low power mode service may include one or more services and the high power mode service may include one or more services.
Virtual USB interface (interface), a physical USB interface can virtualize one or more virtual USB interfaces, and in the embodiment of the present application, the virtual USB interface refers to a virtual USB interface, and the virtual USB interface is a logic concept. A virtual USB interface may be identified with a virtual USB interface descriptor that describes one or more endpoints to which the virtual USB interface corresponds. The USB host and the USB device communicate through the virtual USB interface, and actually communicate through the endpoint corresponding to the virtual USB interface.
An Endpoint (EP), which is the actual physical unit in a USB device, is the actual transfer of USB data between the endpoint of a USB host and the endpoint of the USB device. The virtual USB interface may correspond to one or more endpoints. As shown in fig. 1, one physical USB interface may correspond to one or more virtual USB interfaces, and one virtual USB interface corresponds to one or more endpoints. When the USB host loads the virtual USB interface host driver, the USB host can allocate an endpoint number to an endpoint corresponding to each virtual USB interface on the USB host side, so that a channel can be established according to the endpoint number of the endpoint corresponding to each virtual USB interface on the USB device side and the endpoint number of the endpoint corresponding to the USB host (the dotted line shown in the figure is the channel), one channel is uniquely identified by utilizing the endpoint numbers on the USB device and the USB host side, and the USB host and the USB device can transmit data corresponding to the service through the established channel. The transmission direction of the endpoint is fixed, the transmission direction of the endpoint uses the USB host as a reference, for example, the virtual USB interface of the USB device corresponds to the endpoint 1 and the endpoint 2, the endpoint 1 is used for sending data, and the endpoint 1 is an Input (IN) endpoint when the endpoint is input to the USB host; endpoint 2 is configured to receive data and is output to the USB host at this time, so endpoint 2 is an Output (OUT) endpoint.
Endpoints may be classified into control endpoints, bulk transfer endpoints, interrupt endpoints, and synchronization endpoints. The control endpoint is used for transmitting a control command, the control endpoint is a bidirectional endpoint, namely, the USB host can transmit the control command to the USB device through the control endpoint, and the USB device can also return a response of the control command to the USB host through the control endpoint.
As shown in fig. 1, the USB device transmits data to the USB host through a USB line, including the USB device transmitting data to the USB host through the USB line, and the USB host transmitting data to the USB device through the USB line. The USB device supports plug and play, and can utilize one physical USB interface to virtually obtain a plurality of virtual USB interfaces, and different combinations of the plurality of virtual USB interfaces correspond to different configurations. Of course, the USB host and the USB device may also transmit one or more services based on one configuration. When the USB host and the USB device need to switch different services corresponding to different configurations, the USB host needs to be disconnected from the USB device, and specifically, the USB host needs to clear the USB device descriptor, the configuration descriptor and the virtual USB interface descriptor stored on the USB host side. In this process, the USB host and the USB device are completely disconnected physically, and then the USB device needs to report the device descriptor, the configuration descriptor, the virtual USB interface descriptor corresponding to the configuration descriptor, and the like to the USB host to perform at least three handshakes to establish a virtual USB interface corresponding to the new configuration, which results in a longer transmission delay. In addition, even if a common virtual USB interface exists in the virtual USB interfaces corresponding to the new configuration in the virtual USB interfaces corresponding to the original configuration, the common virtual USB interface needs to be disconnected first, resources occupied by the virtual USB interfaces are released, interface descriptors of the virtual USB interfaces are cleared, a host driver of the virtual USB interfaces is reloaded by a USB host, resources are configured for the virtual USB interfaces, endpoint numbers are allocated to endpoints corresponding to the virtual USB interfaces, and similarly, the USB device needs to reallocate the endpoint numbers and the resources for endpoints corresponding to the virtual USB interfaces, which causes resource waste and high cost.
It should be noted that fig. 1 is only an exemplary illustration of M endpoints on the USB host side and M endpoints on the USB device side, and the numbers are 1,2 … … M, and in practical application, the numbers of endpoints on the USB host side and the USB device side may be the same or different, which is not a limitation of the present application.
For example, as shown in fig. 2, configuration 1 of the USB device corresponds to the virtual USB interface a, and the USB device needs to allocate resources and numbers to the endpoint corresponding to the virtual USB interface a corresponding to configuration 1. The USB device needs to report a descriptor related to the configuration 1, the USB host initializes an endpoint corresponding to the virtual USB interface A according to the configuration descriptor of the configuration 1, and loads a host driver of the virtual USB interface A to establish a channel of the endpoint corresponding to the virtual USB interface A, and the established channel of the endpoint is used for transmitting the service 1, wherein the USB host can allocate resources for the configuration 1 in the process of initializing the endpoint corresponding to the virtual USB interface A, and the resources allocated by the USB host for the configuration 1 comprise the number of the endpoint corresponding to the virtual USB interface A and occupied resources of the endpoint. When the USB device and the USB host need to switch the service 1, the USB host needs to clear the resources allocated by the USB host for the configuration 1 and the configuration descriptor of the configuration 1, and the USB device also needs to release the resources allocated for the endpoint corresponding to the virtual USB interface a. The USB device and the USB host need to switch the service 1 to the service 2 corresponding to the configuration 2, for example, in fig. 3, the configuration 2 of the USB device corresponds to the virtual USB interface a, the virtual USB interface B, and the virtual USB interface C, and the USB device needs to report the descriptor of the USB device to the USB host first, then report the configuration descriptor of the configuration 2, and also report the interface descriptors of the three virtual USB interfaces corresponding to the configuration 2. in addition, the USB device also needs the resources and numbers allocated to the endpoints corresponding to the virtual USB interfaces corresponding to the configuration 2, i.e., the virtual USB interface a, the virtual USB interface B, and the virtual USB interface C. Initializing a virtual USB interface A by the USB host according to the configuration descriptor of the configuration 2 and the interface descriptor of the virtual USB interface A, and loading host drivers of the virtual USB interface A to establish a channel of an endpoint corresponding to the virtual USB interface A; initializing a virtual USB interface B by the USB host according to the configuration descriptor of the configuration 2 and the interface descriptor of the virtual USB interface B, and loading host drivers of the virtual USB interface B to establish a channel of an endpoint corresponding to the virtual USB interface B; The USB host initializes the virtual USB interface C according to the configuration descriptor of the configuration 2 and the interface descriptor of the virtual USB interface C and loads the host driver of the virtual USB interface C to establish a channel of an endpoint corresponding to the virtual USB interface C. The resources corresponding to the configuration 2 can be generated in the process of initializing the endpoints corresponding to the virtual USB interfaces of the virtual USB interface A, the virtual USB interface B and the virtual USB interface C by the USB host, and the resources corresponding to the configuration 2 comprise the numbers of the endpoints corresponding to the three interfaces of the virtual USB interface A, the virtual USB interface B and the virtual USB interface C and the resources occupied by the endpoints. The established channel of the endpoint corresponding to the virtual USB interface A, the established channel of the endpoint corresponding to the virtual USB interface B and the established channel of the endpoint corresponding to the virtual USB interface C are used for transmitting the service 2. In this process, the USB host needs to clear the USB device descriptor on the USB host side, the configuration descriptor of configuration 1, and the resources corresponding to configuration 1, and the USB host needs to allocate resources for the USB device again, specifically, needs to allocate resources for configuration 2 of the USB device, which results in a large transmission delay, and configuration 1 and configuration 2 include a common interface a, and in the switching process, the USB host still needs to clear the resources related to the virtual USB interface a and the interface descriptor of the virtual USB interface a in configuration 1 on the USB host side, for example, the resources of the virtual USB interface a include the number and the resources of the endpoint corresponding to the virtual USB interface a. The USB device reports the interface descriptor of the virtual USB interface A again, the USB host computer regenerates the resources of the endpoints corresponding to the virtual USB interface A, for example, the resources of the virtual USB interface A comprise the numbers and the resources of the endpoints corresponding to the virtual USB interface A, so that the USB host computer needs to continuously load the host computer drive of the virtual USB interface A, the transmission delay is longer, and the cost is higher. In addition, the USB device allocates resources and numbers to the endpoints corresponding to the virtual USB interface a in the configuration 1, in the switching process, the USB device needs to release the resources allocated to the endpoints corresponding to the virtual USB interface a in the configuration 1, delete the numbers of the endpoints corresponding to the virtual USB interface a, and allocate the resources and numbers to the endpoints corresponding to the virtual USB interface a in the configuration 2 again, so in the switching process, the USB device needs to release the resources and allocate the resources continuously, delete the numbers and allocate the numbers, which results in higher cost.
In view of the above problems, in the embodiment of the present application, the USB device and the USB host may configure the total endpoint numbers supported by the USB device in advance, different services correspond to different endpoint combination information, and the different endpoint combination information includes different endpoint combinations, so when different services are transmitted, data may be transmitted according to the different endpoint combinations, and thus time delay caused by the need of reconfiguring the endpoint numbers may be avoided. In addition, if there are common endpoints in the process of switching different services, the common endpoints can be kept unchanged, that is, the USB hosts and the USB devices do not need to reallocate resources and numbers for the common endpoints, so that the design can be simplified, the time delay can be reduced, the cost can be reduced, and the cost can be saved.
In order to better describe the embodiments of the present application, a system architecture diagram of the embodiments of the present application is described below in conjunction with fig. 4. Fig. 4 is a block diagram of a combination of hardware and software according to an embodiment of the present application. The layered architecture divides software and hardware into several layers, each with distinct roles and branches. The layers communicate via interfaces.
In some embodiments, the USB host is divided into five layers, namely an application layer, a host service management module, a USB host application base library, a kernel layer and a physical layer from top to bottom on the USB host side.
As shown in fig. 4, the application layer may include a series of applications. For example, the application program may be a mobile phone assistant (HiSuite), a USB virtual serial port debugging tool, dial-up networking, a gateway display application opened by a browser after the USB device is connected to the USB host, or the like.
The host service management module comprises a message processing module, a resource management module and a protocol encapsulation and analysis module. The message processing module is used for processing control commands sent by the application program layer, for example, the control commands comprise commands for switching services; the resource management module is used for carrying out resource scheduling; the protocol encapsulation and analysis module is used for analyzing and encapsulating the data.
Wherein, some or all of the sub-modules in the host service management module may belong to the application layer or the USB application base, or some or all of the sub-modules in the host service management sub-module may be independent of the application layer and the USB host application base, which is not limited in the embodiments of the present application.
The USB host application base library provides an application programming interface (application programming interface, API) and programming framework for application programs at the application layer. The USB host application base library includes a number of predefined functions.
The kernel layer may include USB function drivers, USB host controller drivers, and the like. The USB host controller driver is used for driving the USB host controller to identify the USB device and driving the USB host controller to find a corresponding USB function driver for the USB device, for example, the USB function driver comprises a display card corresponding display card driver, a camera corresponding camera driver, a sound card corresponding audio driver, a sensor corresponding sensor driver and the like. In addition, the USB host controller driver is also used for distributing resources for endpoints corresponding to the virtual USB interface. The USB function driver is used to drive a function of the USB device, specifically, the USB device driver is used to drive a function of the USB device and control communication with the USB device. The virtual USB interface host driver in FIG. 1, FIG. 2, FIG. 3 and FIG. 7 comprises a USB host controller driver and a USB function driver.
The physical layer can provide a transmission medium and an interconnection channel for data communication inside the USB host or between the physical layer and the USB device, and a reliable environment is provided for data transmission. The physical layer may be understood as a transport layer providing "signal and medium". As shown in fig. 4, the physical layer includes a USB host controller, a USB bus, and the like.
In some embodiments, the USB device is divided into five layers, namely, an application layer, a device service management module, a USB device application base library, a kernel layer and a physical layer from top to bottom on the USB device side.
As shown in fig. 4, the application layer of the USB device may include a series of applications. Applications may include gallery, music, video, email, calendar, notes, etc.
The equipment service management module comprises an endpoint configuration module and a protocol encapsulation analysis module. The endpoint configuration module is used for managing resource scheduling of endpoints; the protocol encapsulation and analysis module is used for analyzing and encapsulating the data.
Wherein, some or all modules in the device service management module may belong to an application program layer or a USB device application base, or some or all modules in the device service management module may be independent of the application program layer and the USB device application base, which is not limited in the embodiment of the present application.
The USB device application base includes the API of the USB device. The API provides an interactive interface with the kernel layer for applications at the application layer. For example, APIs include an interface to open (open), close (close), read, write, control, etc. an application.
The kernel layer at least comprises USB function drivers, USB device controller drivers and the like. The USB device controller driver is used for driving the USB device controller and driving the USB device controller to find a corresponding USB function driver for the USB device. In addition, the USB device controller driver is also used for distributing resources for the endpoints corresponding to the virtual USB interfaces. The USB function driver is used to drive the function of the USB device, specifically, the USB device driver is used to drive the USB device to communicate with the USB host.
The physical layer can provide a transmission medium and an interconnection channel for data communication inside the USB device or between the physical layer and the USB host, and a reliable environment is provided for data transmission. The physical layer may be understood as a transport layer providing "signal and medium". As shown in fig. 4, the physical layer includes a USB device controller, a USB bus, and the like.
It should be noted that, under the architecture shown in fig. 4, the transmission process of signaling or data from the USB host to the USB device is: the high layer of the USB host is transferred to the low layer of the USB device, and then transferred to the high layer of the USB device by the low layer of the USB device; specifically, the signaling or data sequentially sends data or signaling to the USB device from the application layer, the host service management module, the USB host application base, the kernel layer, and the USB bus driver physical layer of the kernel layer of the USB host in fig. 4; after receiving data or signaling from the USB host, the physical layer of the USB device sequentially reports the data or signaling from the kernel layer, the USB device application base library and the device service management module to the application program layer. The transmission process of the signaling or data transmitted by the USB equipment to the USB host is as follows: the high layer of the USB equipment is transferred to the low layer of the USB host, and then the low layer of the USB host is transferred to the high layer of the USB host; specifically, the signaling or data sequentially sends data or signaling to the USB host from the application layer, the device service management module, the USB device application base library, the kernel layer, and the USB bus driver physical layer of the kernel layer of the USB device in fig. 4; after receiving data or signaling from the USB device, the physical layer of the USB host sequentially reports the data or signaling from the kernel layer, the USB host application base and the host service management module to the application program layer. In order to avoid redundancy, the following embodiments describe the transmission of data or signaling between the USB device and the USB host, and those skilled in the art should understand that the data or signaling between the USB host and the USB device is transmitted from high to low or from low to high according to the different layers shown in fig. 4.
The method for USB transmission provided by the embodiment of the present application is described below with reference to fig. 5. As shown in fig. 5, the method 500 includes:
s501, initializing a USB device.
Optionally, the USB device initialization includes: the USB device determines the endpoint types of the total M second endpoints and the endpoint numbers of the M second endpoints supported by the USB device, for example, the endpoint types of the total M second endpoints and the endpoint numbers of the M second endpoints supported by the USB device may be indicated by using the first endpoint information.
For example, the endpoint types of the USB device supporting 15 IN endpoints and the endpoint types of the 15 OUT endpoints are shown as table 1, with M being 30 (15 IN endpoints and 15 OUT endpoints) IN table 1, as well as the endpoint numbers of these endpoints. Fig. 6 is a schematic diagram of different types of initialized endpoints, where a USB host and a USB device establish a channel for controlling the endpoints in the initialization process, and the black filled endpoints in fig. 6 represent the endpoints for transmitting control commands, including an output control command and an input control command, where the output control command represents that the USB host sends the control command to the USB device, and the input control command represents that the USB device sends the control command to the USB host.
It should be noted that, in the embodiment of the present application, the control endpoint does not belong to an endpoint that needs to be initialized in the process of initializing the USB device, and the control endpoint may be a common control endpoint for each service transmitted, so the endpoint combination indicated by the first endpoint combination information in the embodiment of the present application does not include the control endpoint.
TABLE 1
Optionally, the USB device initialization includes: the USB device determines at least one endpoint combination information, each endpoint combination information in the at least one endpoint combination information is used for indicating endpoint combinations supported by the USB device, and different endpoint combination information indicates different endpoint combinations, wherein the USB host needs one or more endpoint combinations corresponding to the endpoint combination information for transmitting a service. The endpoint combination indicated by each endpoint combination information is an endpoint combination in M second endpoints supported by the USB device, and in the alternative, the endpoint combination indicated by each endpoint combination information is a function combination of endpoints in M second endpoints, and may not include a number combination of endpoints, for example, the endpoint combination indicated by each endpoint combination information is a combination of at least one of an interrupt input or output function, a bulk transfer input or output function, a synchronous input or output function, and a control function.
For example, according to the first service supported by the USB device, the USB device needs to perform a combination of an input/output function, an interrupt input function, and a synchronous input function of batch data, so that the USB device may report endpoint combination information 1 and endpoint combination information 2; endpoint combination information 1 indicates a BULK data input endpoint (BULK endpoint IN), a BULK data output endpoint (BULK endpoint OUT), and endpoint combination information 2 indicates an interrupt input endpoint and a synchronization input endpoint (synchronization endpoint IN). The endpoint combination information 1 and the endpoint combination information 2 indicate which combinations of functions, respectively, may be determined by the USB device itself.
For example, the USB device initializes and determines 5 endpoint combination information (endpoint combinations corresponding to 2 endpoint combination information are used for transmitting service 1, and endpoint combinations corresponding to 3 endpoint combination information are used for transmitting service 2).
Alternatively, the USB device may determine at least one endpoint combination information based on services supported by the USB device. In particular, different services supported by a USB device may require different endpoint combinations.
Optionally, the USB device may also determine at least one endpoint combination information according to a configuration, for example, the USB device supports configuration 2 of fig. 3, configuration 2 corresponds to a virtual USB interface a, a virtual USB interface B and a virtual USB interface C, the virtual USB interface a corresponds to a BULK 1_in endpoint and a BULK 2_out endpoint shown in table 1, the virtual USB interface B corresponds to a BULK 2_in endpoint, a BULK 3_out endpoint and an interrupt 9_in endpoint shown in table 1, and the virtual USB interface C corresponds to a BULK 3_in endpoint, an interrupt 9_in endpoint and a synchronization 13_in shown in table 1; thus, the endpoint combination information 1 includes endpoint combinations of a BULK_IN endpoint and a BULK_OUT endpoint, IN other words, the endpoint combination indicated by the endpoint combination information 1 needs to have a combination of input and output functions of batch data of the virtual USB interface A; the endpoint combination information 2 includes endpoint combinations of BULK_IN endpoint, BULK_OUT endpoint and interrupt_IN endpoint, IN other words, the endpoint combination indicated by the endpoint combination information 2 requires a combination of input, output and interrupt input functions of batch data with the virtual USB interface B; the endpoint combination information 3 includes endpoint combinations of: the endpoint combination indicated by the endpoint combination information 3 requires a combination of BULK data input, interrupt input, and synchronization input functions of the virtual USB interface C.
Illustratively, at least one endpoint combination information is shown as shown in table 2. The above-mentioned endpoint combination information 1 is T1 of table 2, the endpoint combination information 2 is T2 of table 2, and the endpoint combination information 3 is T3 of table 2.
TABLE 2
Illustratively, as shown in fig. 4, the endpoint configuration resource management module in the USB device is configured to initialize, in particular, the endpoint configuration resource management module is configured to determine endpoint numbers of the total M second endpoints supported by the USB device, endpoint types of the M second endpoints, and at least one endpoint combination information.
S502, when the USB device is plugged into the USB host, the USB host discovers the USB device and inquires the USB device, after the USB host inquires the USB device, the USB device reports first endpoint information to the USB host, wherein the first endpoint information is used for indicating endpoint types of M second endpoints and endpoint numbers of the M second endpoints, and M is greater than or equal to 2.
Optionally, the USB device may report the first endpoint information to the USB host through the descriptor, for example, the descriptor may be a configuration descriptor or an interface descriptor or a custom descriptor, which is not limited in the embodiment of the present application.
S503, the USB host allocates endpoint numbers to the M first endpoints of the USB host side according to the first endpoint information.
Optionally, the USB host may assign new endpoint numbers to the M first endpoints on the USB host side, and the USB host may multiplex the numbers of the M second endpoints, and use the numbers of the M second endpoints as the numbers of the M first endpoints.
Optionally, the USB host determines the endpoint types of the M first endpoints according to the endpoint types of the M second endpoints indicated by the first endpoint information. For example, the USB host determines, according to the functions corresponding to the endpoint types of the M second endpoints indicated by the first endpoint information, endpoints that require corresponding functions on the USB host side, for example, if the USB device reports that the endpoint type of one endpoint is BULK endpoint_in, the USB host determines that the endpoint type corresponding to the BULK endpoint_in on the USB host side is BULK endpoint_out.
Alternatively, the USB host may allocate resources for M first endpoints on the USB host side, and the manner in which the USB host allocates resources for the M first endpoints is discussed in two cases below:
In one mode, the USB host loads a USB host controller driver and a USB function driver to allocate numbers and resources for M first endpoints on the USB host side.
In the second mode, the USB host loads the USB host controller driver and the USB function driver to allocate numbers to the M first endpoints of the USB host, and the resource management module shown in fig. 4 of the USB host allocates resources to the M first endpoints according to the numbers of the M first endpoints.
Correspondingly, the endpoint configuration resource management module of the USB device side as shown in fig. 4 may also allocate resources of the USB device side to the M second endpoints.
It should be noted that, in the embodiment of the present application, the resource of the endpoint is a hardware resource of the endpoint, for example, the hardware resource includes at least one of a memory resource, a Flash resource and a CPU resource. The numbering of endpoints referred to in embodiments of the present application may also be referred to as software resources.
S504, the USB host establishes M channels with the USB device according to the endpoint numbers of the M first endpoints of the USB host side and the endpoint numbers of the M second endpoints of the USB device side.
Specifically, in S504, the USB host establishes M connections between M first endpoints on the USB host side and M second endpoints on the USB device side, and the USB device cooperates with the USB host to establish M connections, which are also referred to as M channels.
Optionally, if the USB device allocates resources for the M second endpoints on the USB device side, and the USB host allocates resources for the M first endpoints on the USB host side, then the M channels in S504 occupy corresponding resources, that is, the endpoint numbers at two ends of each channel in S504 may be determined, and the resources occupied by each channel may also be determined.
Optionally, if the USB host does not allocate resources for the M first endpoints and the USB device does not allocate resources for the M second endpoints, only the numbers of the two ends of each channel in S504 may be determined, and the USB host and the USB device may allocate resources for the channels that need to transmit the service in real time according to the transmitted service data.
Of course, the USB device may allocate resources for a portion of the M second endpoints corresponding to the M channels, where the remaining second endpoints do not allocate resources; similarly, the USB host may allocate resources for a portion of the first endpoints in the M first endpoints corresponding to the M channels, where the remaining portion of the first endpoints do not allocate resources, and the embodiment of the present application is not limited.
For example, as shown in fig. 7, the USB device may virtually use one USB physical interface to form one virtual USB interface, where the one virtual USB interface corresponds to M second endpoints on the USB device side, and similarly, on the USB host side, one virtual USB interface corresponds to the loading USB host controller driver and the USB function driver to determine M first endpoints on the USB host side. In this way, the USB host may establish M channels according to the M second endpoints on the USB device side and the M first endpoints on the USB host side, and the multiple dotted lines shown in fig. 7 represent the M channels.
And S505, when the USB equipment is plugged into the USB host, the USB host discovers the USB equipment and inquires the USB equipment, and after the USB host inquires the USB equipment, the USB equipment reports at least one endpoint combination information generated by the initialization of S501 to the USB host.
Alternatively, in S505, the USB device may allocate resources for endpoint combinations indicated by different endpoint combination information according to the resource management module shown in fig. 4. Optionally, the resource management module shown in fig. 4 is configured to manage resource scheduling in an endpoint combining process indicated by at least one endpoint combining information such as applying, enabling, disabling, suspending, or destroying.
Optionally, the USB device may report at least one endpoint combination information to the USB host through the descriptor, for example, the descriptor may be a configuration descriptor or an interface descriptor or a custom descriptor, which is not limited in the embodiment of the present application.
For better understanding of the at least one endpoint combination information, it will be understood below in conjunction with fig. 8 that, as shown in fig. 8, one virtual USB interface of the USB device may correspond to the at least one endpoint combination information, and accordingly, the USB host corresponds to the endpoint combination indicated by the at least one endpoint combination information after loading the USB controller driver and the USB function driver. One dotted line in fig. 8 represents a channel formed by an endpoint combination indicated by one endpoint combination information, and one dotted line in fig. 8 may correspond to a channel formed by one or more endpoints in fig. 7, in particular, one dotted line shown in fig. 8 corresponds to one or more channels in fig. 7, in other words, a combination of one or more endpoints corresponding to one endpoint combination information, where one or more channels corresponding to one endpoint combination information corresponds to one endpoint combination information. For example, a first broken line from top to bottom in fig. 8 may correspond to the first broken line and the second broken line from top to bottom shown in fig. 7.
In S502 and S505, when the USB device is plugged into the USB host, the USB host discovers the USB device and queries the USB device, and after the USB host queries the USB device, the USB device may report the first endpoint information and the at least one endpoint combination information to the USB host, and the USB device may report the first endpoint information and the at least one endpoint combination information to the USB host at the same time, or may report the first endpoint information and the at least one endpoint combination information according to a sequence.
In method 500, the USB device and the USB host may execute one time S501-505, and multiple times S506-S511. In other words, S501-505 are preconfigured procedures, S506-511 are real-time transmission procedures, and multiple services can be transmitted based on one configuration.
S506, the USB host determines service data of the first service transmitted with the USB device.
Illustratively, the application layer triggers the transmission of the first service as shown in fig. 4, and the application layer sends an instruction for transmitting the first service to the message processing module of the hosting service management module.
Optionally, S506 includes: the USB host determines to send service data of a first service to the USB device; or comprises: the USU host determines that the USB device transmits service data of the first service to the USB host.
S507, the USB host determines first endpoint combination information required for transmitting the service data of the first service from the at least one endpoint combination information received in S505, where the first endpoint combination information is used for indicating the first endpoint combination, and the first endpoint combination is used for indicating the number of endpoints as N and endpoint types of the N endpoints. Wherein N is a positive integer less than or equal to M.
Specifically, the USB host determines, in at least one endpoint combination information, first endpoint combination information required for transmitting the first service according to a service type of the first service, and the USB host determines, according to a first endpoint combination indicated by the first endpoint combination information, an endpoint required for transmitting service data of the first service. For example, the USB device reports the combination information of the four endpoints T1, T2, T3, and T4 shown in table 2. The first service is a copy service, the service of the USB device needs to be copied to the USB host, and it may be determined that T2 and T3 are needed to transmit the first service, and the USB host determines that the first service needs to be transmitted T2 corresponds to the bulk_in, bulk_out, interrupt_in, and T3 corresponds to the bulk_in, interrupt_in, and sync_in, as shown IN fig. 9, which illustrates a first endpoint combination needed to transmit the first service.
S508, the USB host sends first indication information to the USB device through the control endpoint, and the USB device receives the first indication information sent by the USB host, wherein the first indication information is used for indicating the first endpoint combination determined in S507.
S509, the USB device determines the numbers of the N second endpoints according to the first endpoint combination.
Specifically, the USB device may assign numbers to the first endpoint combinations indicated by the first indication information among the endpoint numbers of the M second endpoints initialized in S501, for example, the USB device may assign numbers to the first endpoint combinations indicated by the first indication information according to the current situation that the M second endpoints are occupied. For example, if the first endpoint indicated by the first indication information is a combination of BULK_IN and BULK_IN, the USB device assigns a number to BULK_IN IN BULK_1IN-BULK_8IN of Table 1 and assigns a number to BULK_IN IN interrupt 9_IN-interrupt 12_IN of Table 1.
For example, as shown in fig. 4, the endpoint configuration resource management module on the USB device side assigns an endpoint number to the first endpoint combination indicated by the first indication information.
Optionally, if the USB device does not allocate resources for the M second endpoints, the USB device needs to allocate resources for the N second endpoints indicated by the first endpoint combination. Illustratively, as shown in fig. 4, the endpoint configuration resource management module of the USB device allocates endpoint resources for the N second endpoints.
Alternatively, if the USB device allocates resources for M second endpoints, the USB device may not allocate resources for N second endpoints indicated by the first endpoint combination.
S510, the USB device sends the numbers of N second endpoints distributed to the endpoints transmitting the first service to the USB host through the control endpoint.
S511, the USB host determines N channels for transmitting the first service from M channels according to the N second endpoint numbers in S510.
In other words, the end numbers of the two ends of each channel in S503 are fixed, and the USB host may determine a unique channel according to one end number of one end of the channel, where the end number of the other end of the channel is the end number of the end point of the UBS host side.
Illustratively, as shown in fig. 4, the resource management module of the USB host side determines N channels for transmitting the first traffic among the M channels.
Specifically, in S504, the USB host establishes M channels with the USB device according to the endpoint numbers of the M first endpoints on the USB host side and the endpoint numbers of the M second endpoints on the USB device side. The M channels established by the USB host in S504 determine N channels for transmitting the first traffic. For example, m=15, and the numbers of the 16 second endpoints on the USB device side are 0,1,2,3, 15, respectively. The USB host determines in S504 that the first endpoints of the USB host side corresponding to the 16 second endpoints are 16, the numbers are 0, 16, 17, 30 respectively. The end points 0 of the USB equipment side and the USB host side are control end points and are also bidirectional channels, the rest end points form 15 channels, and the second end points of the serial number 1 of the USB equipment side respectively correspond to the first end points of the serial number 16 of the USB host side to form a channel 1; the second endpoint of the serial number 2 of the USB device side corresponds to the first endpoint of the serial number 17 of the USB host side to form a channel 2; the second endpoint of the serial number 3 of the USB device side corresponds to the first endpoint of the serial number 18 of the USB host side to form a channel 3; the second endpoint of the serial number 4 of the USB device side corresponds to the first endpoint of the serial number 19 of the USB host side to form a channel 4; the second endpoint of the serial number 5 of the USB device side corresponds to the first endpoint of the serial number 20 of the USB host side to form a channel 5; the second endpoint of the serial number 6 of the USB device side corresponds to the first endpoint of the serial number 21 of the USB host side to form a channel 6; the second endpoint of the serial number 7 of the USB device side corresponds to the first endpoint of the serial number 22 of the USB host side to form a channel 7; the second endpoint of the serial number 8 on the USB device side corresponds to the first endpoint of the serial number 23 on the USB host side to form channel 8, and so on, plus 16 channels formed by the control endpoints. Referring to the example of fig. 9, if the USB device numbers the bulk_in corresponding to the T2 allocated for transmitting the first service according to the number of the endpoint are 1, the bulk_out is 2, and the interrupt endpoint is 3; the number of the BULK_IN corresponding to the T3 allocated for transmitting the first service is 4, the number of the interrupt endpoint is 5, and the number of the synchronization endpoint is 6. The USB host determines that channel 1, channel 2, channel 3, channel 4, channel 5 and channel 6 are used to transmit the first traffic, i.e. T2 corresponds to channel 1, channel 2 and channel 3 and T3 corresponds to channel 4, channel 5 and channel 6.
Optionally, if in S503, the USB host allocates resources for M first endpoints on the USB host side, the USB host may not allocate resources for N first endpoints corresponding to N channels on the USB side for transmitting the first service; if in S503, the USB host does not allocate resources for the M first endpoints on the USB host side, the USB host needs to allocate resources for the N first endpoints corresponding to the N channels on the USB side for transmitting the first service, for example, the resource management module may allocate resources for the N first endpoints corresponding to the N channels on the USB side for transmitting the first service as shown in fig. 4.
Optionally, in the method 500, S507-S511 may not exist, and as an alternative manner of S507-S511, the USB host may determine, according to the service type of the first service, N first endpoints that meet the service type requirement of the first service, from M first endpoints, and determine N channels corresponding to the N first endpoints as channels for transmitting the first service.
S512, the USB host transmits the first service with the USB device by utilizing the N channels determined in S511.
It should be noted that in the method 500, it is described that both the USB device and the USB host may configure resources for M endpoints on each side corresponding to M channels in advance; or the USB device and the USB host do not configure resources of M first endpoints and M second endpoints corresponding to the M channels in advance, and in the real-time transmission process, the resources are configured for N first endpoints and N second endpoints corresponding to the N channels for transmitting the first service according to the requirement. In the practical application process, the corresponding configuration resources of the embodiment of the application are not limited, the USB host can configure resources for part or all of the M first endpoints of the USB host side in advance, or the USB host can configure resources for part or all of the M first endpoints of the USB host side in advance, the resources are reconfigured during real-time transmission, and whether the USB device side configures resources for the M second endpoints of the USB device side is not limited; conversely, the USB device may allocate resources to some or all of the M second endpoints on the USB device side in advance, or the USB device may allocate resources to some or all of the M second endpoints on the USB device side in advance, and reconfigure resources during real-time transmission, which is not limited as to whether the USB host side allocates resources to the M first endpoints on the USB host side. In other words, in the embodiment of the present application, the configuration of the resources required for N channels for transmitting the first service is not limited, and may be configured when the first service is transmitted or may be configured in advance.
In the above scheme, the USB device may report the first endpoint information indicating M second endpoints supported by the USB device to the USB host, and at the same time, the USB device also reports at least one endpoint combination information to the USB host; the USB host can configure M channels corresponding to M second endpoints in advance according to the first endpoint information, the USB host and the USB device can also configure resources occupied by the M channels in advance, the M channels can be a plurality of channels corresponding to a virtual USB interface, so that when a first service is transmitted, the channel for transmitting the first service is determined in the M channels according to endpoint combination information required by the service, the number of the channel for transmitting the first service and time delay caused by the resources are prevented from being configured in real time, and the transmission time delay can be reduced. Or the USB host may configure M channels corresponding to the M second endpoints in advance according to the first endpoint information, where the M channels may be multiple channels corresponding to one virtual USB interface, so, when transmitting the first service, according to the first endpoint combination information required by the service, N channels for transmitting the first service are determined in the M channels, resources are configured for the N channels for transmitting the first service in real time, which can avoid a delay caused by configuring numbers of the N channels for transmitting the first service in real time, and reduce a transmission delay.
In addition, when the USB host and the USB device switch different services, if the different services include the same endpoint combination information, or if the different services correspond to the different endpoint combination information, but there is an intersection between endpoints indicated by the different endpoint combination information, the endpoint corresponding to the same endpoint combination information or the endpoint having the intersection between different endpoint combination information may be maintained unchanged, so that transmission efficiency may be improved, and the number of the same endpoint does not need to be reconfigured, and a scenario of switching services is described below in connection with the method 500 and fig. 10. As shown in fig. 10, a method 1000 includes:
S1001, the USB host determines to switch the first service transmitted by the method 500 to the second service.
Illustratively, as shown in fig. 4, the application layer at the USB host side determines to switch the transmitted first service to the second service, and sends a switch command to the message processing module of the host service management module, where the switch command carries an identifier of the second service.
Optionally, after S1001, the method further includes: the USB host sends a switching command to the USB device, wherein the switching command is used for indicating to switch the first service currently being transmitted to the second service. The handover command may include an identification of the second service, and after the USB device receives the handover command, S1004 may be performed.
S1002, the USB host determines the endpoint combination required to transmit the service data of the second service.
Specifically, the USB host determines, in at least one endpoint combination information, endpoint combination information for transmitting the second service according to the service type of the second service, and determines, according to the endpoint combination indicated by the endpoint combination information for transmitting the second service, an endpoint combination required for transmitting service data of the second service. For example, the second service is a print service, and data of the USB device needs to be printed, and T1 and T2 of table 2 may be determined to be required for transmitting the second service according to the print service.
S1003, the USB host determines the endpoint combination to be reconfigured according to the first endpoint combination required for transmitting the service data of the first service and the endpoint combination required for transmitting the service data of the second service, for example, the USB host determines that the USB device needs to assign a number to the reconfigured endpoint combination.
Specifically, the USB host determines the same endpoint combination as the endpoint combination that is not required to be reconfigured from among the endpoint combinations required to transmit the service data of the first service and the endpoint combination required to transmit the service data of the second service, and determines the endpoint combination that is required to be reconfigured from the endpoint combination that is required to transmit the service data of the second service to be different from the endpoint combination that is required to transmit the first service. For example, the second end point combination information and the third end point combination information are required for transmitting the second service, the second end point combination indicated by the second end point combination information is the same as the first end point combination, that is, the number of the end points indicated by the second end point combination is N, the end point type indicated by the second end point combination is the same as the end point type indicated by the first end point combination, and the USB host determines that the second end point combination is the end point combination which does not need to be reconfigured. The third endpoint combination indicated by the third endpoint combination information is different from the first endpoint combination, that is, the number (P) of endpoints indicated by the third endpoint combination information is different from the number (N) of endpoints indicated by the first endpoint combination, or the endpoint type indicated by the third endpoint combination information is different from the endpoint type indicated by the first endpoint combination information, and the USB host determines the third endpoint combination as the endpoint combination that needs to be reconfigured.
Optionally, if the USB device allocates resources for M second endpoints on the USB device side, the USB host may determine in S1003 that the USB device does not need to allocate resources for the reconfigured endpoint combination, and the USB device only needs to allocate endpoint numbers; if the USB device does not allocate resources for the M second endpoints on the USB device side, the USB host may determine in S1003 that the USB device needs to allocate numbers and resources for the reconfigured endpoint combination.
Specifically, when the USB host and the USB device transmit different first services and second services, if a common endpoint combination exists between a service endpoint combination required for transmitting the first service and an endpoint combination required for transmitting the second service, channels of the common endpoint combinations can be kept unchanged, that is, the number of the common endpoint combinations is unchanged, the USB device does not need to renumber the common endpoint combinations, and the USB device only needs to allocate the number to the endpoint combination different from the first service, or allocate the number and the resource.
For example, the USB device reports the combination information of the four endpoints T1, T2, T3, and T4 shown in table 2. The first service is a duplicate service and T2 and T3 are required for transmission of the first service in method 500. The second service is a print service, and if data of the USB device needs to be printed, it may be determined that the second service needs to be transmitted T1 and T2 according to the print service, as shown in fig. 11, which is an endpoint required to transmit the second service. Since the first service and the second service have the common endpoint combination information T2. The USB device maintains T2 unchanged from the USB host, i.e., IN fig. 11, the bulk_in, bulk_out, and interrupt_in of fig. 9 are maintained unchanged as compared to fig. 9. The USB host determines that only the USB device is required to allocate the number to the indicated endpoint of T1, or the USB host determines that only the USB device is required to allocate the number and the resource to the indicated endpoint of T1. Of course, the USB device and the USB host may also release the resources occupied by the channel corresponding to the endpoint combination indicated by T3, or may also delete the number of the endpoint combination indicated by T3, or the like.
Optionally, the USB host determines the same endpoint combination as the endpoint combination that is required to transmit the service data of the first service and the endpoint combination that is required to transmit the service data of the second service as endpoint combinations that do not require reconfiguration, and determines endpoint combinations that are different from the endpoint combination that is required to transmit the service data of the first service as endpoint combinations to be released. The USB host may release the resources of these endpoint combinations or release the resources of these endpoint combinations and delete the numbers of these endpoint combinations. In this way, resource overhead may be saved.
And S1004, the USB host sends second indication information to the USB device through the control endpoint, the USB device receives the second indication information sent by the USB host, where the second indication information is used to indicate the endpoint combination determined in S1003 and requiring redistribution of the USB device, for example, the second indication information indicates the third endpoint combination described above.
In S1005, the USB device assigns an endpoint number to the endpoint combination indicated by the second indication information.
Illustratively, as shown in fig. 4, the endpoint configuration resource management module at the USB device side assigns an endpoint number to the endpoint combination indicated by the second indication information. For example, the USB device assigns the endpoint assigned numbers to the endpoint combinations indicated by the second indication information according to table 1.
IN connection with the example of S1003, if the second indication information indicates the endpoint combination indicated by T1, the USB device assigns numbers to bulk_in and bulk_out according to table 1, e.g., assigns number 7 to bulk_in corresponding to T1, and assigns number 8 to bulk_out.
Optionally, the USB device determines, as the endpoint combination to be released, an endpoint combination different from the endpoint combination required to transmit the second service, from among the endpoint combinations required to transmit the service data of the first service. The USB device may release the resources of these endpoint combinations or release the resources of these endpoint combinations and delete the numbers of these endpoint combinations. In this way, resource overhead may be saved.
In S1006, the USB device sends the endpoint number allocated to the endpoint transmitting the second service to the USB host through the control endpoint, e.g., the USB device allocates P numbers to the P endpoints indicated by the third endpoint combination.
S1007, the USB host determines a channel for transmitting the second service among the remaining channels according to the endpoint number in S1006.
In the foregoing example of the second endpoint combination and the third endpoint combination, if the endpoint numbers in S1006 are P, the USB host determines P channels from the remaining M-N channels according to the P endpoint numbers, where P is a positive integer less than or equal to M-N.
Illustratively, as shown in fig. 4, the resource management module of the USB host side determines a channel for transmitting the second traffic among the remaining channels.
IN combination with the example IN S511 and the example IN S1005, 16 channels are established by the USB device and the USB host, where the USB device and the USB host keep channel 1, channel 2, and channel 3 unchanged, and the USB host only needs to allocate an endpoint number to the endpoint corresponding to T1, for example, allocate number 7 to bulk_in and allocate number 8 to bulk_out, so that the USB host determines IN S1007 that the channels for transmitting the second service are channel 7 and channel 8. In this way, the USB host and the USB device can transmit service data of the second service using the channel 1, the channel 2, the channel 3, the channel 7, and the channel 8. In addition, the USB host and USB device may free up the resources occupied by channel 4, channel 5, and channel 6.
Optionally, if in S503, the USB host allocates resources for M first endpoints on the USB host side, the USB host may determine that the USB host does not need to allocate resources for the endpoint combination to be configured; if the USB device does not allocate resources for the M second endpoints on the USB device side, the USB host may determine in S1003 that the USB host also needs to allocate resources for the reconfigured endpoint combination. In connection with the above example, the USB host needs to allocate resources to the endpoints of channel 7 and channel 8 on the USB host side.
S1008, the USB host transmits the second service with the USB device using the channel determined in S1007 and the channel common to the first service.
For example, S1007 may determine that P channels and N channels exist together with the first service, and the USB host may transmit the second service with the USB device through the p+n channels.
In the above scheme, when the USB host and the USB device switch different transmission services, the endpoint combinations corresponding to the common endpoint combination information exist in different services and remain unchanged, that is, the number of the endpoint combinations is unchanged, and only the number or the number and the resource are allocated to the endpoint combinations indicated by the different endpoint combination information, so that the cost can be saved. In addition, since one virtual USB interface comprises M second endpoints, when the USB device and the USB host switch different services, only the endpoint combination in the virtual USB interface needs to be dynamically switched, the virtual USB interface does not need to be disconnected, the virtual USB interface descriptor and the device descriptor do not need to be deleted, and the time delay caused by the fact that the device descriptor and the interface descriptor need to be reported again when the service is switched is avoided.
In S502 of the above method 500, the USB device reports endpoint information of the total M second endpoints supported by the USB device to the USB host, as shown in fig. 7, where the M second endpoints are endpoints corresponding to one virtual USB interface. The USB device reports the endpoint combinations indicated by the at least one endpoint combination information to the USB host as endpoint function combinations of the M second endpoints. However, the embodiment of the present application is not limited, for example, L second endpoints among the M second endpoints are endpoints corresponding to one virtual USB interface, L is a positive integer less than or equal to M, the remaining M-L second endpoints are endpoints corresponding to another virtual USB interface, and L is a positive integer less than M. Thus, part of the endpoint combination information in at least one endpoint combination information reported by the USB equipment is the endpoint function combination of L endpoints, and the rest of the endpoint combination information is the endpoint function combination of M-L endpoints. Thus, when the USB equipment and the USB host transmit different services, the endpoint function combinations of the L endpoints can be switched; or the endpoint functions may be switched among a combination of endpoint functions for M-L endpoints. In particular, the method 500 and the method 1000 for determining endpoint combinations for transmitting different services in endpoint combinations corresponding to different virtual USB interfaces are referred to in the present application, and the detailed description is omitted for avoiding redundancy.
For example, as shown in fig. 12, the USB device may report to the USB host that the virtual USB interface E corresponds to M-L second endpoints and the virtual USB interface F corresponds to L endpoints. In addition, the USB device may report, to the USB host, endpoint combination information of M-L endpoints corresponding to the virtual USB interface E and endpoint combination information of L endpoints corresponding to the virtual USB interface F. If the service 1 and the service 2 have a common endpoint combination, the common endpoint combination can be kept unchanged, that is, the number of the endpoint combination is unchanged or the number and the resource are unchanged, and the USB device configures the endpoint number for the endpoint combination different from the service 1 or configures the endpoint number and the resource, thereby realizing the transmission of different services in the M-L endpoints. For another example, when the USB host and the USB device transmit the service 3 through at least some of the L endpoints, and the USB host needs to switch the service 3 to the service 4, the USB host determines, among the L endpoints, an endpoint combination for transmitting the service 4 according to the requirement of the service 4, and if the service 3 and the service 4 have a common endpoint combination, the common endpoint combination may be kept unchanged, i.e. the number of the endpoint combinations is unchanged or the number and the resource are unchanged, and the USB device configures the endpoint number for an endpoint combination different from the service 3, or configures the endpoint number and the resource, so as to implement transmitting different services among the L endpoints.
It should be noted that, after the endpoint corresponding to one virtual USB interface is released, another virtual USB interface may apply for the released endpoint. In combination with the above example, assuming that the USB host and the USB device release the endpoint 1 from the corresponding L endpoints of the virtual USB interface F, the USB host may apply for the endpoint 1 again for the virtual USB interface E.
A method 1300 for USB transfer according to an embodiment of the present application is described below in conjunction with fig. 13.
S1301, initializing endpoint configuration resource management in a device service management module of the USB device, wherein the initialization comprises the steps of respectively creating an endpoint capability set and a protocol path capability set according to the capability of the USB device, and completing resource initialization.
The endpoint capability set corresponds to the endpoint types of the M second endpoints and the endpoint numbers of the M second endpoints.
Illustratively, the set of protocol pathway capabilities corresponds to the aforementioned at least one endpoint combination information. One protocol path corresponds to one endpoint combination information.
S1302, the USB device is connected with a USB host, the USB device configures a single interface (one USB virtual interface) by default, the USB host queries the USB device capability to obtain a USB device endpoint capability set, and interface initialization and configuration are completed.
Illustratively, the USB host acquiring the endpoint capability set of the USB device to complete the initialization and configuration of the interface may specifically include: the USB host determines the type and number of the endpoint on the USB host side according to the endpoint capability set of the USB device, and the endpoint on the USB host side may be the aforementioned M first endpoints.
S1303, a resource management module in a host service management module of the USB host queries a protocol access capability set supported by the USB device, and completes initialization of resources required by the protocol access set of the USB host side.
For example, the resource management module in the host service management module may query the protocol channel capability set supported by the USB device, and allocate resources to the endpoint combination corresponding to the protocol channel set on the USB host side.
S1304, the application program layer of the USB host acquires the function set supported by the USB device through the host service management module, sends a switching command to the host service management module according to the first service or the second service, processes and executes the switching action by the message processing module, and notifies the resource management module.
In S1305, in the host service management module, the resource management module applies for the protocol path n (Tn), and at the same time, the USB host manages the resources, and needs to notify the USB device to synchronously manage the resources, where the endpoint of the device service management module of the USB device configures the resource management module, and applies for the corresponding protocol path. Under different service scenes, the step can dynamically apply, activate, deactivate, suspend and destroy resources.
S1306, in the host service management module, the protocol encapsulation and analysis module processes the protocol encapsulation and analysis of the communication data on the protocol path n, and the synchronous processing is also required on the USB device side. When multiple protocol paths exist, the protocol encapsulation and parsing module processes each protocol path.
In S1307, an application in the application layer of the USB host may interact with the USB device through the protocol path n, and on the USB device side, there is also a USB device application layer, and an application in the application layer may interact with the USB host through the protocol path n.
The present embodiment may divide the function modules of the USB host and the USB device according to the above method example, for example, each function module may be divided corresponding to each function, or two or more functions may be integrated into one processing module, as shown in fig. 4. The integrated modules described above may be implemented in hardware. It should be noted that the division of the modules in fig. 4 is illustrative in this embodiment, and is merely a logic function division, and there may be another division manner in actual implementation.
It should be noted that, all relevant contents of each step related to the above method embodiment may be cited to the functional description of the corresponding functional module, which is not described herein.
The USB host and the USB device provided in this embodiment are used to execute the method for USB transmission described above, so that the same effects as those of the implementation method described above can be achieved. In case of an integrated unit, the USB host and the USB device may comprise a processing module, a storage module and a communication module, respectively. The processing module can be used for controlling and managing actions of the USB host and the USB device. The memory module may be used to support the USB host and the USB device to execute stored program code and data, etc. And the communication module can be used for supporting the communication between the client and the server and other equipment.
Wherein the processing module may be a processor or a controller. Which may implement or perform the various exemplary logic blocks, modules and circuits described in connection with this disclosure. A processor may also be a combination that performs computing functions, e.g., including one or more microprocessors, digital Signal Processing (DSP) and a combination of microprocessors, and the like. The memory module may be a memory. The communication module can be a radio frequency circuit, a Bluetooth chip, a Wi-Fi chip and other equipment which interact with other electronic equipment.
In one embodiment, when the processing module is a processor and the storage module is a memory, the electronic device according to this embodiment may be a device having the structure shown in fig. 14.
Fig. 14 is a schematic structural diagram of an electronic device 1400 according to an embodiment of the present application. The electronic device 1400 may be a USB host or a USB device, and the electronic device 1400 may include a processor 1410, a memory 1420, and a communication module 1430, among others.
Wherein the processor 1410 may include one or more processing units, the memory 1420 is used to store program code and data. In an embodiment of the application, processor 1410 may execute computer-executable instructions stored in memory 1420 for controlling and managing the actions of electronic device 1400. For example, if the electronic device 1400 is a USB device, the processor 1410 may include the USB device controller shown in fig. 4. For another example, electronic device 1400 is a USB host and processor 1410 may include the USB host controller shown in fig. 4.
The communication module 1430 may be used for communication between various internal modules of the electronic device 1400, communication between the electronic device 1400 and other external electronic devices, or the like. For example, if the electronic device 1400 communicates with other electronic devices through a wired connection, the communication module 1430 may include a physical USB interface and a USB bus as shown in fig. 4, for example, one physical USB interface may be a virtual USB interface or virtual USB interfaces in the embodiment of the present application, and the physical USB interface may be an interface conforming to the USB standard specification, specifically, a Mini physical USB interface, a Micro physical USB interface, a USB Type C interface, or the like. The physical USB interface may be used to connect a charger to charge the electronic device 1400, or may be used to transfer data between the electronic device 1400 and a peripheral device. And can also be used for connecting with a headset, and playing audio through the headset. The interface may also be used to connect other electronic devices, such as AR devices, etc.
Or the communication module 1430 may include an audio device, a radio frequency circuit, a bluetooth chip, a wireless fidelity (WIRELESS FIDELITY, wi-Fi) chip, a near-field communication technology (NFC) module, etc., and interaction between the electronic device 1400 and other electronic devices may be implemented in a variety of different manners.
Optionally, the electronic device 1400 may also include a display screen 1440, where the display screen 1440 may display images or videos, etc. in a human-machine interaction interface.
Optionally, the electronic device 1400 may also include a peripheral device 1450, such as a mouse, keyboard, speaker, microphone, and the like.
It should be appreciated that embodiments of the present application do not specifically limit the structure of the electronic device 1400, except for the various components or modules listed in fig. 14. In other embodiments of the application, electronic device 1400 may also include more or less components than those shown, or combine certain components, split certain components, or a different arrangement of components. The illustrated components may be implemented in hardware, software, or a combination of software and hardware.
The present embodiment also provides a computer-readable storage medium having stored therein computer instructions which, when executed on an electronic device, cause the electronic device to perform the above-described related method steps to implement the method for USB transmission in the above-described embodiments.
The present embodiment also provides a computer program product which, when run on a computer, causes the computer to perform the above-described relevant steps to implement the method for USB transmission in the above-described embodiments.
In addition, embodiments of the present application also provide an apparatus, which may be embodied as a chip, component or module, which may include a processor and a memory coupled to each other; the memory is used for storing computer-executable instructions, and when the device is running, the processor can execute the computer-executable instructions stored in the memory, so that the chip executes the method for safely accessing data in the above method embodiments.
The electronic device, the computer storage medium, the computer program product, or the chip provided in this embodiment are used to execute the corresponding methods provided above, so that the beneficial effects thereof can be referred to the beneficial effects in the corresponding methods provided above, and will not be described herein.
It will be appreciated by those skilled in the art that, for convenience and brevity of description, only the above-described division of the functional modules is illustrated, and in practical application, the above-described functional allocation may be performed by different functional modules according to needs, i.e. the internal structure of the apparatus is divided into different functional modules to perform all or part of the functions described above.
In the several embodiments provided by the present application, it should be understood that the disclosed apparatus and method may be implemented in other manners. For example, the apparatus embodiments described above are merely illustrative, e.g., the division of modules or units is merely a logical function division, and there may be additional divisions when actually implemented, e.g., multiple units or components may be combined or integrated into another apparatus, or some features may be omitted or not performed. Alternatively, the coupling or direct coupling or communication connection shown or discussed with each other may be an indirect coupling or communication connection via some interfaces, devices or units, which may be in electrical, mechanical or other form.
The units described as separate parts may or may not be physically separate, and the parts shown as units may be one physical unit or a plurality of physical units, may be located in one place, or may be distributed in a plurality of different places. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
In addition, each functional unit in the embodiments of the present application may be integrated in one processing unit, or each unit may exist alone physically, or two or more units may be integrated in one unit. The integrated units may be implemented in hardware or in software functional units.
The integrated units, if implemented in the form of software functional units and sold or used as stand-alone products, may be stored in a readable storage medium. Based on such understanding, the technical solution of the embodiments of the present application may be essentially or a part contributing to the prior art or all or part of the technical solution may be embodied in the form of a software product stored in a storage medium, including several instructions for causing a device (may be a single-chip microcomputer, a chip or the like) or a processor (processor) to perform all or part of the steps of the methods of the embodiments of the present application. And the aforementioned storage medium includes: a U-disk, a removable hard disk, a Read Only Memory (ROM), a random access memory (random access memory, RAM), a magnetic disk, or an optical disk, or other various media capable of storing program codes.
The foregoing is merely illustrative of the present application, and the present application is not limited thereto, and any person skilled in the art will readily recognize that variations or substitutions are within the scope of the present application. Therefore, the protection scope of the application is subject to the protection scope of the claims.

Claims (18)

1.一种用于通用串行总线USB传输的方法,其特征在于,包括:1. A method for universal serial bus (USB) transmission, comprising: USB主机确定与USB设备传输第一业务;The USB host determines to transmit the first service with the USB device; 所述USB主机在M个第一端点中确定用于传输所述第一业务的N个第一端点;The USB host determines N first endpoints for transmitting the first service from among the M first endpoints; 所述USB主机通过所述N个第一端点与所述USB设备的一个虚拟USB接口对应的M个第二端点中的N个第二端点之间的N个通道传输所述第一业务的业务数据,所述USB设备的物理USB接口对应所述一个虚拟USB接口,所述M个第二端点为所述USB设备支持的端点数目,所述M个第二端点、所述M个第一端点与M个通道一一对应,所述N个第一端点、所述N个第二端点与所述M个通道中的所述N个通道一一对应,所述M个第一端点为所述USB主机的端点,所述M个第二端点为所述USB设备的端点;The USB host transmits the service data of the first service through N channels between the N first endpoints and N second endpoints among M second endpoints corresponding to a virtual USB interface of the USB device, the physical USB interface of the USB device corresponds to the one virtual USB interface, the M second endpoints are the number of endpoints supported by the USB device, the M second endpoints and the M first endpoints correspond to the M channels one-to-one, the N first endpoints and the N second endpoints correspond to the N channels among the M channels one-to-one, the M first endpoints are endpoints of the USB host, and the M second endpoints are endpoints of the USB device; 其中,M、N为正整数,M大于或等于N;Wherein, M and N are positive integers, and M is greater than or equal to N; 其中,在所述USB主机确定传输第一业务之前,所述方法还包括:Wherein, before the USB host determines to transmit the first service, the method further includes: 所述USB主机接收来自所述USB设备的第一端点信息,所述第一端点信息用于指示所述USB设备支持的所述M个第二端点的端点类型以及所述M个第二端点的端点编号:The USB host receives first endpoint information from the USB device, where the first endpoint information is used to indicate endpoint types of the M second endpoints supported by the USB device and endpoint numbers of the M second endpoints: 所述USB主机根据所述第一端点信息确定所述M个第一端点的端点编号;The USB host determines the endpoint numbers of the M first endpoints according to the first endpoint information; 所述USB主机根据所述M个第一端点的端点编号和所述M个第二端点的端点编号与所述USB设备建立所述M个通道。The USB host establishes the M channels with the USB device according to the endpoint numbers of the M first endpoints and the endpoint numbers of the M second endpoints. 2.根据权利要求1所述的方法,其特征在于,所述USB主机在M个第一端点中确定用于传输所述第一业务的N个第一端点,包括:2. The method according to claim 1, wherein the USB host determines N first endpoints for transmitting the first service from among the M first endpoints, comprising: 所述USB主机在至少一个端点组合信息中确定用于传输所述第一业务的第一端点组合信息,所述至少一个端点组合信息中的不同端点组合信息用于指示所述USB设备支持的不同的端点组合,不同的端点组合包括不同数量的端点和/或不同类型的端点,所述第一端点组合信息用于指示第一端点组合;The USB host determines, in at least one endpoint combination information, first endpoint combination information for transmitting the first service, wherein different endpoint combination information in the at least one endpoint combination information is used to indicate different endpoint combinations supported by the USB device, wherein different endpoint combinations include different numbers of endpoints and/or different types of endpoints, and the first endpoint combination information is used to indicate the first endpoint combination; 所述USB主机根据所述第一端点组合在所述M个第一端点中确定所述N个第一端点,所述第一端点组合用于指示端点的数量为N个以及N个端点的端点类型。The USB host determines the N first endpoints from the M first endpoints according to the first endpoint combination, where the first endpoint combination is used to indicate that the number of endpoints is N and the endpoint types of the N endpoints. 3.根据权利要求2所述的方法,其特征在于,所述USB主机根据所述第一端点组合在所述M个第一端点中确定所述N个第一端点,包括:3. The method according to claim 2, wherein the USB host determines the N first endpoints from the M first endpoints according to the first endpoint combination, comprising: 所述USB主机向所述USB设备发送第一指示信息,所述第一指示信息用于指示所述第一端点组合;The USB host sends first indication information to the USB device, where the first indication information is used to indicate the first endpoint combination; 所述USB主机接收所述USB设备根据所述第一指示信息指示的所述第一端点组合确定的所述N个第二端点的编号;The USB host receives the numbers of the N second endpoints determined by the USB device according to the first endpoint combination indicated by the first indication information; 所述USB主机根据所述N个第二端点的编号确定所述N个第一端点。The USB host determines the N first endpoints according to the numbers of the N second endpoints. 4.根据权利要求2所述的方法,其特征在于,所述方法还包括:4. The method according to claim 2, characterized in that the method further comprises: 所述USB主机接收来自所述USB设备的所述至少一个端点组合信息。The USB host receives the at least one endpoint combination information from the USB device. 5.根据权利要求2所述的方法,其特征在于,在所述USB主机确定传输第一业务之后,所述方法还包括:5. The method according to claim 2, characterized in that after the USB host determines to transmit the first service, the method further comprises: 所述USB主机确定传输第二业务;The USB host determines to transmit a second service; 所述USB主机在所述至少一个端点组合信息中确定用于传输所述第二业务的第二端点组合信息和第三端点组合信息,所述第二端点组合信息用于指示第二端点组合,所述第三端点组合信息用于指示第三端点组合;The USB host determines, from the at least one endpoint combination information, second endpoint combination information and third endpoint combination information for transmitting the second service, wherein the second endpoint combination information is used to indicate a second endpoint combination, and the third endpoint combination information is used to indicate a third endpoint combination; 若所述USB主机确定所述第一端点组合与所述第二端点组合相同,所述USB主机通过所述N个通道传输所述第二业务的部分数据。If the USB host determines that the first endpoint combination is the same as the second endpoint combination, the USB host transmits part of the data of the second service through the N channels. 6.根据权利要求5所述的方法,其特征在于,所述第三端点组合用于指示端点的数量为P个以及P个端点的端点类型,P小于或等于M-N,所述方法还包括:6. The method according to claim 5, wherein the third endpoint combination is used to indicate that the number of endpoints is P and the endpoint types of the P endpoints, P is less than or equal to M-N, and the method further comprises: 若所述USB主机确定所述第一端点组合与所述第三端点组合不同,所述USB主机向所述USB设备发送第二指示信息,所述第二指示信息用于指示所述第三端点组合;If the USB host determines that the first endpoint combination is different from the third endpoint combination, the USB host sends second indication information to the USB device, where the second indication information is used to indicate the third endpoint combination; 所述USB主机接收所述USB设备根据所述第二指示信息确定的P个第二端点的编号;The USB host receives the numbers of the P second endpoints determined by the USB device according to the second indication information; 所述USB主机根据所述P个第二端点的端点编号在M-N个通道中确定P个通道;The USB host determines P channels from the M-N channels according to the endpoint numbers of the P second endpoints; 所述USB主机通过所述P个通道与所述USB设备传输所述第二业务的剩余部分业务数据。The USB host transmits the remaining service data of the second service to the USB device through the P channels. 7.根据权利要求5所述的方法,其特征在于,在所述USB主机确定传输第二业务之后,所述方法还包括:7. The method according to claim 5, characterized in that after the USB host determines to transmit the second service, the method further comprises: 所述USB主机向所述USB设备发送切换命令,所述切换命令用于指示将当前正在传输的第一业务切换为第二业务。The USB host sends a switching command to the USB device, where the switching command is used to instruct to switch a first service currently being transmitted to a second service. 8.根据权利要求1至7中任一项所述的方法,其特征在于,在所述USB主机确定传输第一业务之前,所述方法还包括:8. The method according to any one of claims 1 to 7, characterized in that before the USB host determines to transmit the first service, the method further comprises: 所述USB主机为所述M个第一端点分配资源。The USB host allocates resources to the M first endpoints. 9.根据权利要求1至7中任一项所述的方法,其特征在于,在所述USB主机在M个第一端点中确定用于传输所述第一业务的N个第一端点之后,所述方法还包括:9. The method according to any one of claims 1 to 7, characterized in that after the USB host determines N first endpoints for transmitting the first service from among the M first endpoints, the method further comprises: 所述USB主机为所述N个第一端点分配资源。The USB host allocates resources to the N first endpoints. 10.一种用于通用串行总线USB传输的方法,其特征在于,包括:10. A method for universal serial bus (USB) transmission, comprising: USB设备在一个虚拟USB接口对应的M个第二端点中确定与USB主机传输第一业务的N个第二端点,所述M个第二端点为所述USB设备支持的端点数目,所述USB设备的物理USB接口对应所述一个虚拟USB接口;The USB device determines N second endpoints for transmitting a first service with the USB host from among the M second endpoints corresponding to a virtual USB interface, the M second endpoints being the number of endpoints supported by the USB device, and a physical USB interface of the USB device corresponds to the one virtual USB interface; 所述USB设备通过所述N个第二端点与所述USB主机的M个第一端点中的N个第一端点之间的N个通道传输所述第一业务的业务数据;The USB device transmits the service data of the first service through N channels between the N second endpoints and N first endpoints among the M first endpoints of the USB host; 其中,所述M个第二端点、所述M个第一端点与M个通道一一对应,所述N个第一端点、所述N个第二端点与所述M个通道中的所述N个通道一一对应,M、N为正整数,M大于或等于N,所述M个第一端点为所述USB主机的端点,所述M个第二端点为所述USB设备的端点;The M second endpoints and the M first endpoints correspond to the M channels one-to-one, the N first endpoints and the N second endpoints correspond to the N channels among the M channels one-to-one, M and N are positive integers, M is greater than or equal to N, the M first endpoints are endpoints of the USB host, and the M second endpoints are endpoints of the USB device; 其中,在所述USB设备在一个虚拟USB接口对应的M个第二端点中确定与USB主机传输第一业务的N个第二端点之前,所述方法还包括:Before the USB device determines N second endpoints for transmitting the first service to the USB host from among the M second endpoints corresponding to a virtual USB interface, the method further includes: 所述USB设备向所述USB主机发送第一端点信息,所述第一端点信息用于指示所述USB设备支持的所述M个第二端点的端点类型以及所述M个第二端点的端点编号;The USB device sends first endpoint information to the USB host, where the first endpoint information is used to indicate endpoint types of the M second endpoints supported by the USB device and endpoint numbers of the M second endpoints; 所述USB设备根据所述第一端点信息与所述USB主机建立所述M个通道。The USB device establishes the M channels with the USB host according to the first endpoint information. 11.根据权利要求10所述的方法,其特征在于,所述USB设备在一个虚拟USB接口对应的M个第二端点中确定与USB主机传输第一业务的N个第二端点,包括:11. The method according to claim 10, wherein the USB device determines N second endpoints for transmitting the first service with the USB host from among the M second endpoints corresponding to a virtual USB interface, comprising: 所述USB设备接收所述USB主机发送的第一指示信息,所述第一指示信息用于指示第一端点组合,所述第一端点组合用于指示端点的数量为N个以及N个端点的端点类型;The USB device receives first indication information sent by the USB host, where the first indication information is used to indicate a first endpoint combination, where the first endpoint combination is used to indicate that the number of endpoints is N and the endpoint types of the N endpoints; 所述USB设备根据所述第一指示信息指示的所述第一端点组合在所述M个第二端点中确定所述N个第二端点。The USB device determines the N second endpoints from the M second endpoints according to the first endpoint combination indicated by the first indication information. 12.根据权利要求11所述的方法,其特征在于,所述方法还包括:12. The method according to claim 11, characterized in that the method further comprises: 所述USB设备向所述USB主机发送至少一个端点组合信息,所述至少一个端点组合信息的不同端点组合信息用于指示所述USB设备支持的不同的端点组合,不同的端点组合包括不同数量的端点和/或不同类型的端点,所述至少一个端点组合信息中的第一端点组合信息用于指示所述第一端点组合。The USB device sends at least one endpoint combination information to the USB host, where different endpoint combination information of the at least one endpoint combination information is used to indicate different endpoint combinations supported by the USB device, where different endpoint combinations include different numbers of endpoints and/or different types of endpoints, and the first endpoint combination information in the at least one endpoint combination information is used to indicate the first endpoint combination. 13.根据权利要求10所述的方法,其特征在于,所述方法还包括:13. The method according to claim 10, characterized in that the method further comprises: 所述USB设备接收所述USB主机发送的切换命令,所述切换命令用于指示所述USB设备将正在传输的所述第一业务切换为第二业务;The USB device receives a switching command sent by the USB host, where the switching command is used to instruct the USB device to switch the first service being transmitted to a second service; 所述USB设备根据所述切换命令接收所述USB主机通过所述N个通道发送的所述第二业务的部分业务数据。The USB device receives part of the service data of the second service sent by the USB host through the N channels according to the switching command. 14.根据权利要求13所述的方法,其特征在于,所述方法还包括:14. The method according to claim 13, characterized in that the method further comprises: 所述USB设备接收所述USB主机发送的第二指示信息,所述第二指示信息用于指示第三端点组合,所述第三端点组合用于指示端点的数量为P个以及P个端点的端点类型,P小于或等于M-N;The USB device receives second indication information sent by the USB host, where the second indication information is used to indicate a third endpoint combination, where the third endpoint combination is used to indicate that the number of endpoints is P and the endpoint types of the P endpoints, where P is less than or equal to M-N; 所述USB设备根据所述第二指示信息指示的所述第三端点组合在所述M个第二端点中确定P个第二端点的编号;The USB device determines numbers of P second endpoints among the M second endpoints according to the third endpoint combination indicated by the second indication information; 所述USB设备向所述USB主机发送所述P个第二端点的编号;The USB device sends the numbers of the P second endpoints to the USB host; 所述USB设备通过所述P个第二端点对应的P个通道与所述USB主机传输所述第二业务的剩余部分业务数据。The USB device transmits the remaining service data of the second service to the USB host through the P channels corresponding to the P second endpoints. 15.根据权利要求10至14中的任一项所述的方法,其特征在于,在所述USB设备在一个虚拟USB接口对应的M个第二端点中确定与USB主机传输第一业务的N个第二端点之前,所述方法还包括:15. The method according to any one of claims 10 to 14, characterized in that before the USB device determines N second endpoints for transmitting the first service with the USB host from among the M second endpoints corresponding to a virtual USB interface, the method further comprises: 所述USB设备为所述M个第二端点分配资源。The USB device allocates resources to the M second endpoints. 16.根据权利要求10至14中的任一项所述的方法,其特征在于,在所述USB设备在一个虚拟USB接口对应的M个第二端点中确定与USB主机传输第一业务的N个第二端点之后,所述方法还包括:16. The method according to any one of claims 10 to 14, characterized in that after the USB device determines N second endpoints for transmitting the first service with the USB host from among the M second endpoints corresponding to a virtual USB interface, the method further comprises: 所述USB设备为所述N个第二端点分配资源。The USB device allocates resources to the N second endpoints. 17.一种USB主机,其特征在于,包括处理器,所述处理器与存储器耦合,所述处理器用于执行所述存储器中存储的计算机程序或指令,以使得所述USB主机实现如权利要求1至9中任一项所述的方法。17. A USB host, comprising a processor, wherein the processor is coupled to a memory, and the processor is used to execute a computer program or instruction stored in the memory, so that the USB host implements the method according to any one of claims 1 to 9. 18.一种USB设备,其特征在于,包括处理器,所述处理器与存储器耦合,所述处理器用于执行所述存储器中存储的计算机程序或指令,以使得所述USB设备实现如权利要求10至16中任一项所述的方法。18. A USB device, comprising a processor, wherein the processor is coupled to a memory, and the processor is used to execute a computer program or instruction stored in the memory, so that the USB device implements the method according to any one of claims 10 to 16.
CN202010912316.3A 2020-09-02 2020-09-02 Method and electronic device for USB transmission Active CN114201432B (en)

Priority Applications (2)

Application Number Priority Date Filing Date Title
CN202010912316.3A CN114201432B (en) 2020-09-02 2020-09-02 Method and electronic device for USB transmission
PCT/CN2021/112163 WO2022048419A1 (en) 2020-09-02 2021-08-12 Method for transmission by usb, and electronic device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010912316.3A CN114201432B (en) 2020-09-02 2020-09-02 Method and electronic device for USB transmission

Publications (2)

Publication Number Publication Date
CN114201432A CN114201432A (en) 2022-03-18
CN114201432B true CN114201432B (en) 2024-07-23

Family

ID=80492155

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010912316.3A Active CN114201432B (en) 2020-09-02 2020-09-02 Method and electronic device for USB transmission

Country Status (2)

Country Link
CN (1) CN114201432B (en)
WO (1) WO2022048419A1 (en)

Families Citing this family (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114817115A (en) * 2022-05-20 2022-07-29 深圳市广和通无线通信软件有限公司 Serial port communication method and related device
CN115118552B (en) * 2022-06-21 2024-04-16 深圳市中创电测技术有限公司 Broadband carrier communication gateway device
CN115454895B (en) * 2022-09-14 2026-02-10 山东云海国创云计算装备产业创新中心有限公司 A USB interface expansion method, system, device, and readable storage medium
CN115589428B (en) * 2022-09-24 2025-07-15 南京欧珀软件科技有限公司 Device interconnection method and related products
CN115379280B (en) * 2022-10-19 2023-01-31 深圳沛喆微电子有限公司 A method, device, and smart photo frame for information source channel intercommunication transmission
CN115883645B (en) * 2022-11-24 2024-07-12 百富计算机技术(深圳)有限公司 Communication configuration method, electronic device and storage medium

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105531684A (en) * 2013-09-06 2016-04-27 思科技术公司 Universal PCI EXPRESS port
CN111858439A (en) * 2019-04-26 2020-10-30 英特尔公司 Shared resources for multiple communication services

Family Cites Families (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7222201B2 (en) * 2003-01-06 2007-05-22 Plx Technology, Inc. Virtual endpoint for USB devices
TW200900933A (en) * 2007-03-15 2009-01-01 Wionics Research Virtual pipe for wire adapter communications
JP4740897B2 (en) * 2007-05-24 2011-08-03 株式会社日立製作所 Virtual network configuration method and network system
CN111447103B (en) * 2020-03-09 2022-01-28 杭州海康威视系统技术有限公司 Virtual device management system, electronic device, virtual device management method, and medium

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105531684A (en) * 2013-09-06 2016-04-27 思科技术公司 Universal PCI EXPRESS port
CN111858439A (en) * 2019-04-26 2020-10-30 英特尔公司 Shared resources for multiple communication services

Also Published As

Publication number Publication date
WO2022048419A1 (en) 2022-03-10
CN114201432A (en) 2022-03-18

Similar Documents

Publication Publication Date Title
CN114201432B (en) Method and electronic device for USB transmission
US10698717B2 (en) Accelerator virtualization method and apparatus, and centralized resource manager
CN110032413B (en) A desktop virtualization method, related equipment and computer storage medium
US9396101B2 (en) Shared physical memory protocol
WO2020259523A1 (en) Host and method for communicating with fpga, and fpga interface chip
US11934289B2 (en) Graph-based data multi-operation system
CN115364477A (en) Cloud game control method and device, electronic equipment and storage medium
CN114253704A (en) Method and device for allocating resources
WO2021239073A1 (en) Method for constructing internet of things operating system, system, cloud platform and internet of things device
CN108345496A (en) A kind of method and device of operation application program
CN103414763A (en) Method and related device for controlling manage device
US12554668B2 (en) Chip management apparatus and related method
CN113312137B (en) Data processing method, device, equipment and system
CN112015515B (en) Instantiation method and device of virtual network function
WO2025167482A1 (en) Computing resource management method, system, and device
CN119248462A (en) Virtual instance deployment method and system based on cloud service
CN114942853A (en) data processing system
JP2006277204A (en) Portable communication terminal device
US12386767B2 (en) Method and apparatus for using local area network as service for edge cloud
CN119718694B (en) A frame-type security resource pool management method and device based on lightweight virtualization
CN111901902B (en) Mobile base station and corresponding service processing method and storage medium
CN116737404B (en) Method and terminal device for application connection
HK40091324A (en) Method, apparatus, device, and computer-readable medium for creating a local cloud
HK40091324B (en) Method, apparatus, device, and computer-readable medium for creating a local cloud
CN119440712A (en) Method for running application across devices and electronic device

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant