Skip to content
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

USBD event and composite-device handling #13403

Closed
2 tasks done
pawelzadrozniak opened this issue Feb 14, 2019 · 2 comments
Closed
2 tasks done

USBD event and composite-device handling #13403

pawelzadrozniak opened this issue Feb 14, 2019 · 2 comments
Assignees
Labels
area: USB Universal Serial Bus Enhancement Changes/Updates/Additions to existing features

Comments

@pawelzadrozniak
Copy link
Collaborator

pawelzadrozniak commented Feb 14, 2019

Issues to be addressed:

  • The USB (power) events should be notified to the application by the core USB stack, not the particular classes. This means they are handled in common code and not by each particular class. This means a new type of event that is common to all classes, and we need a new core USB callback to the application that is not tied to any class, but common to all of them.

  • Composite and non-composite code paths are currently separate implementations. These should be merged into a single one that handles both cases, by making the code composite-enabled. PRs USB: Automatically define COUNT number of USB Devices #13310 and USB: first step at unifying legacy and composite #11041 are starting points in that direction.

In-depth description:

USB device stack - power state tracking.
In a real life application with USB device stack, we need to keep track of power state. if the cable is connected or not and if the bus is suspended or active. I see it as a fundamental feature, so it could be embedded in USBD to simplify application.

Currently, USBD acts as a proxy passing driver events to the class implementation and the only way knowing the bus state in application is to use class callback - classes forward the event from driver. To make things worse, we will get multiplied events (i.e. "suspended") when using a multiple classes/instances (composite device).
Power / bus events are related to the stack itself and IMO should not be coming from class.

This is how see it:
A main dispatcher in usb_device.c (just like the one for composite device) which will forward driver events to every class instance + application callback (only necessary events, like cable connect/disconnect, etc.).
Classes would pass only related events in a callback, i.e. HID events.
In such case - do we still need to split implementation info composite and non-composite device?
I would prefer to avoid #ifdef CONFIG_COMPOSITE_DEVICE everywhere.

Please let me know what you think.

@pawelzadrozniak pawelzadrozniak added the Enhancement Changes/Updates/Additions to existing features label Feb 14, 2019
@jfischer-no jfischer-no added the area: USB Universal Serial Bus label Feb 14, 2019
@jfischer-no
Copy link
Collaborator

In such case - do we still need to split implementation info composite and non-composite device?
I would prefer to avoid #ifdef CONFIG_COMPOSITE_DEVICE everywhere.

No, this should go away.
I started working on it, but I do not have time to finish it. @aurel32 has opened a PR that goes in this direction #11041

@eobalski
Copy link
Collaborator

Closed by #20375

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: USB Universal Serial Bus Enhancement Changes/Updates/Additions to existing features
Projects
None yet
Development

No branches or pull requests

5 participants