Discussion:
[linux-uvc-devel] How can I send the command through the extension unit to the device
stream hu
2012-01-11 02:04:08 UTC
Permalink
Hi,all:

I'm studying the UVC by reading the document about UVC, such as
"USB_Video_Class_1.1.pdf" , and so on.
In the document, there is "Extension Unit Control Requests", which defines
the format of the request sent to the device. I have known the defination
of the request type and data, but confused with the CS(wValue) and
Extension Unit ID and Inferface, what's the value of them?

I want to send a command to the device which the device supported.

In windows, I can use uvc extension unit in DirectShow by IExtensionUnit
interface, and I send the data as the following: 20 46 b4 31; 20 38 b4 02;
20 40 b4 00; 20 41 b4 00; 20 44 b4 01, then the device will zoom in the
video(0x31 means that).

And in linux, I have used the libusb_control_transfer to do the function,
the code is:
unsigned char ioBuffer[4] = {0x20,0x46,0xb4,0x31};
response = libusb_control_transfer(
handle, //handle
0x21, //bmRequestType
0x01, //bRequest
0x0400, //wValue
0x0400, //wIndex
ioBuffer, //data
4, //wLength
0 //timeout
);
it seems that the device also has respond on the command.

But I'm wondering what should I do in UVC extension unit?
According to the "doc/Documentation/video4linux/uvcvideo.txt", I can do
this through two ways:
- through mappings of XU controls to V4L2 controls
- through a driver-specific ioctl interface

But I failed in mapping the controls and don't know the detail of ioctl
interface, so could anyone give some advices on how to write the XMl file
for Mapping or give me a example about it?
Any advices will be appreciated.
Thanks very much!

Stream
Oleksij Rempel (Alexey Fisher)
2012-01-11 07:54:45 UTC
Permalink
Hi Strean, Davis,

looks like you have same question.
Thank you for reading documentation!

Take a look at source code of uvc driver. You will need to grub linux
kernel source for it.
here is the driver:
drivers/media/video/uvc/
here you can find function uvc_query_ctrl() responsible for uvc controls:
drivers/media/video/uvc/uvc_video.c
here happens all XU voodoo, you will also find ZOOM requests:
drivers/media/video/uvc/uvc_ctrl.c

in linux you usually work with v4l2 not with uvcvideo directly
(webcam-<>-uvcvideo-<>-v4l2-api-<>-your app)

search for this words:
V4L2_CID_ZOOM_ABSOLUTE
UVC_CT_ZOOM_ABSOLUTE_CONTROL

take also look to the source of guvcview and uvcdynctrl.

There is different kind of XUs, some of them have official uvc defined
guid, some are proprietary. If something not defined in uvc
specification, manufacturer free to implement it by it self. But it will
not go to driver. Take a look to:
/usr/share/uvcdynctrl/data/046d/logitech.xml
from uvcdynctrl-data package. It is good example of additional XUs.
Post by stream hu
I'm studying the UVC by reading the document about UVC, such as
"USB_Video_Class_1.1.pdf" , and so on.
In the document, there is "Extension Unit Control Requests", which defines
the format of the request sent to the device. I have known the defination
of the request type and data, but confused with the CS(wValue) and
Extension Unit ID and Inferface, what's the value of them?
I want to send a command to the device which the device supported.
In windows, I can use uvc extension unit in DirectShow by IExtensionUnit
interface, and I send the data as the following: 20 46 b4 31; 20 38 b4 02;
20 40 b4 00; 20 41 b4 00; 20 44 b4 01, then the device will zoom in the
video(0x31 means that).
And in linux, I have used the libusb_control_transfer to do the function,
unsigned char ioBuffer[4] = {0x20,0x46,0xb4,0x31};
response = libusb_control_transfer(
handle, //handle
0x21, //bmRequestType
0x01, //bRequest
0x0400, //wValue
0x0400, //wIndex
ioBuffer, //data
4, //wLength
0 //timeout
);
it seems that the device also has respond on the command.
But I'm wondering what should I do in UVC extension unit?
According to the "doc/Documentation/video4linux/uvcvideo.txt", I can do
- through mappings of XU controls to V4L2 controls
- through a driver-specific ioctl interface
But I failed in mapping the controls and don't know the detail of ioctl
interface, so could anyone give some advices on how to write the XMl file
for Mapping or give me a example about it?
Any advices will be appreciated.
Thanks very much!
Stream
------------------------------------------------------------------------------
Ridiculously easy VDI. With Citrix VDI-in-a-Box, you don't need a complex
infrastructure or vast IT resources to deliver seamless, secure access to
virtual desktops. With this all-in-one solution, easily deploy virtual
desktops for less than the cost of PCs and save 60% on VDI infrastructure
costs. Try it free! http://p.sf.net/sfu/Citrix-VDIinabox
_______________________________________________
Linux-uvc-devel mailing list
https://lists.sourceforge.net/lists/listinfo/linux-uvc-devel
- --
Regards,
Alexey
stream hu
2012-01-11 12:41:54 UTC
Permalink
Hi,Oleksij Rempel:


Thanks very much for your reply, and I have read the source code of the uvc
driver, but it seems that it's a little difficult for to understanding the
content.
Also I have studied the /usr/share/uvcdynctrl/data/046d/logitech.xml, and
modified it by using my own VID and PID, but i failed in mapping it with
uvcdynctl command.

when i refer to the control command 0x31, it's just an example. The control
command is defined by product maker and they have defined many control
commands ,from 0x31 to 0x 4D, so I need to find a way to transfer this
command to the device, then the device will response it.

As well as you known, v4l2 will do the function of sending the control
command to the device, just like libusb does(method usb_control_msg()), but
I couldn't find the resource about how v4l2 does this function, so could
you give me any advice about it? Just a small example will be appreciated.

Now I have used the V4L2 to catch the video frame and show them in the UI,
but I have no idea about how to control the device by send the control
command. That's why I want to map the XU controls to V4L2 controls. But it
seems that I need to go the second way by using the driver-specific ioctl
interface, is it true?

Thanks again for your attention.

Stream
Oleksij Rempel (Alexey Fisher)
2012-01-12 09:10:28 UTC
Permalink
Post by stream hu
Thanks very much for your reply, and I have read the source code of
the uvc driver, but it seems that it's a little difficult for to
understanding the content. Also I have studied the
/usr/share/uvcdynctrl/data/046d/logitech.xml, and modified it by
using my own VID and PID, but i failed in mapping it with
uvcdynctl command.
when i refer to the control command 0x31, it's just an example. The
control command is defined by product maker and they have defined
many control commands ,from 0x31 to 0x 4D, so I need to find a way
to transfer this command to the device, then the device will
response it.
As well as you known, v4l2 will do the function of sending the
control command to the device, just like libusb does(method
usb_control_msg()), but I couldn't find the resource about how v4l2
does this function, so could you give me any advice about it? Just
a small example will be appreciated.
Now I have used the V4L2 to catch the video frame and show them in
the UI, but I have no idea about how to control the device by send
the control command. That's why I want to map the XU controls to
V4L2 controls. But it seems that I need to go the second way by
using the driver-specific ioctl interface, is it true?
there seems to be some kernel regression, so it do not work with
kernel version 3.1.0 and 3.2.0-..

in attachment is a patch, it reflect uvc documentation.

- --
Regards,
Alexey
Laurent Pinchart
2012-02-18 20:19:27 UTC
Permalink
Hi,
Post by stream hu
I'm studying the UVC by reading the document about UVC, such as
"USB_Video_Class_1.1.pdf" , and so on.
In the document, there is "Extension Unit Control Requests", which defines
the format of the request sent to the device. I have known the defination
of the request type and data, but confused with the CS(wValue) and
Extension Unit ID and Inferface, what's the value of them?
I want to send a command to the device which the device supported.
In windows, I can use uvc extension unit in DirectShow by IExtensionUnit
interface, and I send the data as the following: 20 46 b4 31; 20 38 b4 02;
20 40 b4 00; 20 41 b4 00; 20 44 b4 01, then the device will zoom in the
video(0x31 means that).
And in linux, I have used the libusb_control_transfer to do the function,
unsigned char ioBuffer[4] = {0x20,0x46,0xb4,0x31};
response = libusb_control_transfer(
handle, //handle
0x21, //bmRequestType
0x01, //bRequest
0x0400, //wValue
0x0400, //wIndex
ioBuffer, //data
4, //wLength
0 //timeout
);
it seems that the device also has respond on the command.
But I'm wondering what should I do in UVC extension unit?
According to the "doc/Documentation/video4linux/uvcvideo.txt", I can do
- through mappings of XU controls to V4L2 controls
- through a driver-specific ioctl interface
The best option would be to get the vendor to expose proper XU controls that
could meaningfully be mapped to V4L2 controls. In your above example, an XU
control that handles zooming only and takes the zoom level as a single value
would be much easier to handle.

As fixing the webcam isn't possible (but if you have a channel to provide
feedback to the device vendor, please ask them to contact me to discuss XU
controls and how they should be best developed to make software support
easier) the second best option here is to use the uvcvideo XU ioctls.

The ioctl you need to use is UVCIOC_CTRL_QUERY. In your above example, you
should set the uvc_xu_control_query fields as follows.

unit = 0x04; // This will be mapped to the wIndex field
selector = 0x04; // This will be mapped to the wValue field
query = UVC_SET_CUR; // This will be mapped to the bRequest field
Post by stream hu
But I failed in mapping the controls and don't know the detail of ioctl
interface, so could anyone give some advices on how to write the XMl file
for Mapping or give me a example about it?
--
Regards,

Laurent Pinchart
Loading...