-
Notifications
You must be signed in to change notification settings - Fork 6.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[topic-usb]First step to rework USB core. #26733
[topic-usb]First step to rework USB core. #26733
Conversation
usb_cfg_data data structure is handling usb funciton specifig data. USB device descriptor is single instance located in special RAM section. This deletion is a step forward to make core stack aware of classes it handles. Signed-off-by: Emil Obalski <[email protected]>
c6535a5
to
838e625
Compare
* only one alternate setting, this may change in the future. | ||
*/ | ||
struct usb_if_container { | ||
const struct usb_if_descriptor *const iface; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This well be reworked in subsequent patches as discussed, right? (just to clarify)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. I don't want to make everything in one PR, as it will grow significantly. This is just a base, usb_if_container
will be reworked anyway. I treat 'topic-usb' branch as wip/devel branch.
include/usb/usb_device.h
Outdated
enum usb_dc_status_code cb_status, | ||
const uint8_t *param); | ||
/** USB request handlers */ | ||
struct usb_request_handlers request_handlers; | ||
/* Number of interfaces for this function */ | ||
/** Number of interfaces for this class */ | ||
const uint8_t num_interfaces; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const uint8_t num_interfaces; can be removed? or moved to usb_if_container?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const uint8_t num_interfaces;
is number of usb_if_containers
so it must stay here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it make sense to rename it too, num_if_containers
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Definitely yes. I will rename it. Wondering if We should also rethink the usb_ep_cfg_data
and make it consistent with each other.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe just usb_ep_data or usb_ep_cfg?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will leave endpoints for now. What I will change is:
usb_cfg_data::interfaces -> usb_cfg_data::if_containers
usb_cfg_data::num_interfaces -> usb_cfg_data::num_if_containers
Rename USB usb_cfg_data structures to better reflect its meaning. interface -> request_handlers Name interface was used here as a communication interface between USB core stack and Class implementations. This naming could be missleading as USB specification defines interface as a part of the USB device descriptor. endpoint -> endpoints This change was made to reflect that there might be more than one endpoint. Signed-off-by: Emil Obalski <[email protected]>
This patch cleans webusb class. WebUSB class were using custom request handler structure which is not necessary. This one is removed and API struct is used instead. Signed-off-by: Emil Obalski <[email protected]>
51f34d1
to
85ca527
Compare
Rework the way how the interfaces are handled by the USB core stack. Until now USB stack was aware of only the first interface associated with each class. This led to a problem when not first interface was addressed by the request. This patch allow to filter out the request at core level. The usb_cfg_data struct is legacy of initial implementation of USB device stack. Initially the USB device stack was implemented to support single class devices with no composite support. This structure was intended to be used to configure the device in run time by calling usb_set_config(). Because of how things grow the structure was used to represent the classes instead of devices. This patch removes device configuration descriptor pointer. Adds pointer to table of USB interface containers associated with he function it represents. Each container consist of pointer to interface descriptor, its alternate setting (if exists) and currently selected alternate setting. This help USB core stack to properly address SET/GET interface requests. This patch should be followed by renaming the structure to something closer to 'class' specific data as described in USB 2.0 spec. This patch is first step to rework the USB core stack and is not meant to be considered as final form of USB core. Signed-off-by: Emil Obalski <[email protected]>
The name 'usb_cfg_data' is legacy of initial implementation of the USB device stack. This structure was intended to be used to configure the device in run time by calling usb_set_config(). Because of how things grown this was used to represent the data of classes rather than the device as a whole. One device may consist of many classes (composite device). When the stack was initially developed this was not considered. Alongside with renaming usb_cfg_data -> usb_class_data, all relevant functions/macros/variables are updated accordingly. Signed-off-by: Emil Obalski <[email protected]>
85ca527
to
6644bff
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This all looks very reasonable to me, including the new names.
usb: Rework the USB core internals.
Rework the way how the interfaces are handled by the USB core stack.
Until now USB stack was aware of only the first interface associated
with each class. This led to a problem when not first interface was
addressed by the request.
This patch allow to filter out the request at core level.
This is not done in this PR but inits foreground
The usb_cfg_data struct is legacy of initial implementation
of USB device stack. Initially the USB device stack was
implemented to support single class devices with
no composite support. This structure was intended to be used to
configure the device in run time by calling usb_set_config().
Because of how things grow the structure was used to represent
the classes instead of devices.
This patch removes device configuration descriptor pointer.
Adds pointer to table of USB interface containers associated with
he function it represents. Each container consist of pointer to
interface descriptor, its alternate setting (if exists) and currently
selected alternate setting. This help USB core stack to properly address
SET/GET interface requests.
This patch renames some of the
usb_cfg_data
fields to betterrepresent its meaning. The
usb_cfg_data
struct is renamed itselfas this name is no longer valid (look up).
This patch is first step to rework the USB core stack and is not meant
to be considered as final form of USB core.
Signed-off-by: Emil Obalski [email protected]