makenai / node-uvc-control

Control UVC compliant USB webcams from node
80 stars 28 forks source link

Get list of supported controls #22

Closed positlabs closed 5 years ago

positlabs commented 7 years ago

We shouldn't pass controls to the user unless they are supported by the device. There is supposedly a list of supported controls in the Processing Unit Descriptor and Camera Terminal Descriptor.

The bmControls field in those descriptors is a 3 byte bitmap that lists supported controls. I'm not exactly sure how to get these descriptors, but it seems like they may be stashed in the "extra" buffer of one of the interface descriptors.

3.7.2 Class-Specific VC Interface Descriptor The class-specific VC interface descriptor is a concatenation of all the descriptors that are used to fully describe the video function, i.e., all Unit Descriptors (UDs) and Terminal Descriptors (TDs). The total length of the class-specific VC interface descriptor depends on the number of Units and Terminals in the video function. Therefore, the descriptor starts with a header that reflects the total length in bytes of the entire class-specific VC interface descriptor in the wTotalLength field.

positlabs commented 5 years ago

Docs are here: https://usb.org/sites/default/files/USB_Video_Class_1_1_090711.zip

https://www.usb.org/documents?search=&type%5B0%5D=55&items_per_page=50

positlabs commented 5 years ago

I have a prototype, but it doesn't seem accurate. e.g. contrast is not listed, but I know it is supported on my Logitech Brio.

https://github.com/positlabs/node-uvc-control/blob/controls/test/get-supported-controls.js

Another approach would be to brute-force getting/setting control values and see which ones succeed