-
Notifications
You must be signed in to change notification settings - Fork 7.9k
uvc: improve standard compliance and MacOS compat #92320
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
uvc: improve standard compliance and MacOS compat #92320
Conversation
Force-push:
I could check that it fixes a bug, but another one appears after it. |
Force-push:
Mac OSX should now work however some extra changes are required to get most applications work out of the box: |
429c057
to
ba50197
Compare
Force-push:
|
Some OSes like MacOS use shorter UVC 1.1 probe/commit messages even when UVC 1.5 is supported, without bUsage, bBitDepthLuma, bmSettings, bMaxNumberOfRefFramesPlus1, bmRateControlModes bmLayoutPerStream. Accept messages of arbitrary size to safely be processed, ignoring all missing fields, improving standard compliance. Signed-off-by: Josuah Demangeon <[email protected]>
Force-push:
|
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.
The "some cases" for wLength are generally related to alignment and granularity requirements.
size = net_buf_tailroom(buf); | ||
size = MIN(size, sizeof(struct uvc_probe)); | ||
size = MIN(size, setup->wLength); |
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.
Three lines are probably one or two too many, maybe just
size = MIN(net_buf_tailroom(buf), MIN(sizeof(struct uvc_probe), setup->wLength));
something like that should be more aligned to what we have in the tree.
Or keep the const size
const size_t size = MIN(sizeof(struct uvc_probe),
MIN(net_buf_tailroom(buf), setup->wLength));
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 was hesitating between the two when making the pach... Applied.
I was supposing some behavior from allocation but now I see more clearly, thanks. |
Please expand the "some cases" in commit message then. People who later come on this commit may not necessarily look into the PR. |
Due to the alignment and granularity requirements of memory allocation, setup->wLength is shorter than the allocated buffer size. This lead to responses larger than what the host requested, which it rejected. Fix it by using the minimum between the allocated size, the struct size, and the wLength requested. Signed-off-by: Josuah Demangeon <[email protected]>
You are right, applied. Thanks for the reminder. |
|
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.
"setup->wLength is shorter than the allocated buffer size" -> "setup->wLength can be shorter than the allocated buffer size"
I'll get better at commit messages... |
Don't worry, you are well above the project average. |
That also improve standard compliance:
cc @kartben who was interested in testing on this platform