Hello.

I have an h.264 encoding webcam, and I am trying to make it
work. Currently, it outputs a valid h.264 stream, but each frame
is compressed to ~12K of data, resulting in a very distorted, but
still barely recognizable image. I suppose that some of the XU controls
are responsible for the encoding quality, and they're in some extreme
position by default.

The webcam is "046d:0828 Logitech, Inc. HD Webcam B990".

Here are the XU descriptors (whole `lsusb -v' is 52K long, and I'm not
sure if I really should post it to the list):

----%<----%<----%<----%<----%<----%<----
      VideoControl Interface Descriptor:
        bLength                27
        bDescriptorType        36
        bDescriptorSubtype      6 (EXTENSION_UNIT)
        bUnitID                 3
guidExtensionCode {e48e6769-0f41-db40-a850-7420d7d8240e}
        bNumControl             9
        bNrPins                 1
        baSourceID( 0)          2
        bControlSize            2
        bmControls( 0)       0x3f
        bmControls( 1)       0x07
        iExtension              0
      VideoControl Interface Descriptor:
        bLength                26
        bDescriptorType        36
        bDescriptorSubtype      6 (EXTENSION_UNIT)
        bUnitID                 4
guidExtensionCode {1502e449-34f4-fe47-b158-0e885023e51b}
        bNumControl             2
        bNrPins                 1
        baSourceID( 0)          2
        bControlSize            1
        bmControls( 0)       0x03
        iExtension              0
      VideoControl Interface Descriptor:
        bLength                28
        bDescriptorType        36
        bDescriptorSubtype      6 (EXTENSION_UNIT)
        bUnitID                 6
guidExtensionCode {a94c5d1f-11de-8744-840d-50933c8ec8d1}
        bNumControl            20
        bNrPins                 1
        baSourceID( 0)          4
        bControlSize            3
        bmControls( 0)       0xff
        bmControls( 1)       0xff
        bmControls( 2)       0x1f
        iExtension              0
      VideoControl Interface Descriptor:
        bLength                27
        bDescriptorType        36
        bDescriptorSubtype      6 (EXTENSION_UNIT)
        bUnitID                 7
guidExtensionCode {212de5ff-3080-2c4e-82d9-f587d00540bd}
        bNumControl             6
        bNrPins                 1
        baSourceID( 0)          4
        bControlSize            2
        bmControls( 0)       0x00
        bmControls( 1)       0x3f
        iExtension              0
      VideoControl Interface Descriptor:
        bLength                27
        bDescriptorType        36
        bDescriptorSubtype      6 (EXTENSION_UNIT)
        bUnitID                 8
guidExtensionCode {b600cd9a-4adc-bd4b-bdf8-5ffbb0c0d366}
        bNumControl             6
        bNrPins                 1
        baSourceID( 0)          4
        bControlSize            2
        bmControls( 0)       0x3f
        bmControls( 1)       0x00
        iExtension              0
      VideoControl Interface Descriptor:
        bLength                27
        bDescriptorType        36
        bDescriptorSubtype      6 (EXTENSION_UNIT)
        bUnitID                 9
guidExtensionCode {a032c549-154f-fc4c-908a-5bce154b1cea}
        bNumControl             3
        bNrPins                 1
        baSourceID( 0)          4
        bControlSize            2
        bmControls( 0)       0x07
        bmControls( 1)       0x00
        iExtension              0
      VideoControl Interface Descriptor:
        bLength                27
        bDescriptorType        36
        bDescriptorSubtype      6 (EXTENSION_UNIT)
        bUnitID                10
guidExtensionCode {41769ea2-04de-e347-8b2b-f4341aff003b}
        bNumControl             9
        bNrPins                 1
        baSourceID( 0)          4
        bControlSize            2
        bmControls( 0)       0xcf
        bmControls( 1)       0x0b
        iExtension              0
----%<----%<----%<----%<----%<----%<----

I've googled all the GUIDs, and it turned out that first four of them
also appear in lsusb listings for non-encoding webcams as well. So, I
decided that some of the other three contain the quality control. (It
may not be true, of course, but that's what I will start with.) They have
19 different controls, apparently.

Now, I am trying to tune some of these with UVC, with no success. Here is
the relevant code:

----%<----%<----%<----%<----%<----%<----
void init_controls()
{
        struct uvc_xu_control_mapping mapping = {
                .id   = XU_START,
                .name = "XU control",
                .selector = 1,
                .size = 1,
                .offset = 0,
                .v4l2_type = V4L2_CTRL_TYPE_INTEGER,
                .data_type = UVC_CTRL_DATA_TYPE_SIGNED,
        };

guid_to_byte_array("{a032c549-154f-fc4c-908a-5bce154b1cea}", mapping.entity);

        if(ioctl(fd, UVCIOC_CTRL_MAP, &mapping) < 0) {
                fprintf(stderr, "Cannot add control: %d, %s\n",
                         errno, strerror(errno));
                exit(EXIT_FAILURE);
        }
}
----%<----%<----%<----%<----%<----%<----

(The `guid_to_byte_array' function was taken from libwebcam
sources. Handcrafting the GUID with proper endianness gives
the same result).

It outputs: Cannot add control: 2, No such file or directory

I've examined USB bus transactions. They include a control `request'
and an interrupt `reply'.

The control frame is here:
  bmRequestType: 0x21
  bRequest: 1
  wValue: 0x0200
  wIndex: 1
  wLength: 26

This is somewhat strange. Per sect. 4.2.2.4 of UVC1.1 spec,
bmRequestType=0x21 and bRequest=1 indicate a SET_CUR transfer.
wValue of 0x0200 addresses selects control 2 instead of 1 (through
this is still in range), and wIndex selects XU 1 (while my one
has bUnitID of 8). Also, I do not understand at all what does the
data transmitted means:

    00:00:01:01:00:00:00:00
    00:00:00:00:00:00:00:00
    32:00:00:60:09:00:00:0c
    00:00

The reply contains a -ENOENT (-2) code, as shown by Wireshark.

Using different GUID's or different selectors does not change
anything.

What am I doing wrong here?

--
  WBR, Peter Zotov.
_______________________________________________
Linux-uvc-devel mailing list
Linux-uvc-devel@lists.berlios.de
https://lists.berlios.de/mailman/listinfo/linux-uvc-devel

Reply via email to