Hi,
Tank you for the hint with the raw controls that got me in the right direction
For reference sake and to help future generations, here a little
introduction as to how I did it:
sudo lsusb -vd <verndorID>:<productID>
This will give you a long description. Look for something like:
VideoControl Interface Descriptor:
bLength 33
bDescriptorType 36
bDescriptorSubtype 6 (EXTENSION_UNIT)
bUnitID 3
guidExtensionCode {0aba49de-5c0b-49d5-8f71-0be40f94a67a}
bNumControl 2
bNrPins 1
baSourceID( 0) 2
bControlSize 8
bmControls( 0) 0x0f
bmControls( 1) 0x00
bmControls( 2) 0x00
bmControls( 3) 0xcd
bmControls( 4) 0xff
bmControls( 5) 0x07
bmControls( 6) 0x00
bmControls( 7) 0x00
iExtension 0
After fighting a bug in uvcdynctrl (they do not use the device GUID but always
have 00000000-0000-0000-0000-000000000000) I was able to correctly read the
values.
The problem with controls is that it is impossible to interpret them correctly
without talking to the manufacturer. With things like an uint32 containing two
16 bit values it is rather difficult to address everything correctly.
For examples of functioning xml descriptions take a look at logitech.xml or
tisEUVC.xml. Those are the only examples I found.
<constant type="guid">
<id>UVC_GUID_TISEUVC_XU</id>
<!-- <value>0aba49de-5c0b-49d5-8f71-0be40f94a67a</value> value from
the camera-->
<value>de49ba0a-0b5c-d549-8f71-0be40f94a67a</value>
</constant>
The first three sections of the GIUD of the extension have to be swapped.
<constant type="integer">
<id>V4L2_STROBE_POLARITY</id>
<value>0x0199e212</value> <!-- still not sure if this range is
specified anywhere-->
</constant>
<constant type="integer">
<id>XU_STROBE_MODE</id>
<value>0x06</value>
</constant>
The constants are good for two things:
Defining the needed v4l2 identifier (assuming you do not use preexisting ones)
and defining the registers of your extension unit for readable names.
<!-- BM8, bit 0 = ENABLE, bit 1 = POLARITY, bit 2 = USE_EXPOSURE_TIME -->
<control id="strobe_mode">
<entity>UVC_GUID_TISEUVC_XU</entity>
<selector>XU_STROBE_MODE</selector>
<index>5</index>
<size>4</size>
<requests>
<request>SET_CUR</request>
<request>GET_CUR</request>
<request>GET_DEF</request>
<request>GET_RES</request>
</requests>
</control>
The control sections defines multiple things:
- The extension unit the control is related to (<entity>)
- The associated register (selector and index); index is selector - 1
- The size of the register in byte (though every value seems to work)
- The requests that are possible (e.g. is the register writable, etc.)
<mapping>
<name>Strobe Polarity</name>
<uvc>
<control_ref idref="strobe_mode"/>
<size>1</size>
<offset>1</offset>
<uvc_type>UVC_CTRL_DATA_TYPE_BOOLEAN</uvc_type>
</uvc>
<v4l2>
<id>V4L2_STROBE_POLARITY</id>
<v4l2_type>V4L2_CTRL_TYPE_BOOLEAN</v4l2_type>
</v4l2>
</mapping>
In the mapping section you describe how the control should be interpreted by
uvc and v4l2.
size is in bits and offset describes the bit offset within the register.
Open questions that hopefully someone can explain to me:
What is the difference between selector and index?
Is there a specified range for additional v4l2 controls, or am I free
to choose my own?
Is the size for the control really necessary?
Cheers,
Edgar