Permalink
Browse files

Merge pull request #51 from jazzguitar81/master

add UVC1.5 video control interface descriptors and fix some minor bugs
  • Loading branch information...
2 parents 00b975b + c045806 commit db140993d6b5d08e716622eaee6ed53e620000eb @gregkh committed on GitHub Mar 7, 2017
Showing with 64 additions and 14 deletions.
  1. +64 −14 lsusb.c
View
78 lsusb.c
@@ -103,6 +103,10 @@
#define USB_AUDIO_CLASS_2 0x20
#endif
+#ifndef USB_VIDEO_PROTOCOL_15
+#define USB_VIDEO_PROTOCOL_15 0x01
+#endif
+
#define VERBLEVEL_DEFAULT 0 /* 0 gives lspci behaviour; 1, lsusb-0.9 */
#define CTRL_RETRIES 2
@@ -145,7 +149,7 @@ static void dump_endpoint(libusb_device_handle *dev, const struct libusb_interfa
static void dump_audiocontrol_interface(libusb_device_handle *dev, const unsigned char *buf, int protocol);
static void dump_audiostreaming_interface(libusb_device_handle *dev, const unsigned char *buf, int protocol);
static void dump_midistreaming_interface(libusb_device_handle *dev, const unsigned char *buf);
-static void dump_videocontrol_interface(libusb_device_handle *dev, const unsigned char *buf);
+static void dump_videocontrol_interface(libusb_device_handle *dev, const unsigned char *buf, int protocol);
static void dump_videostreaming_interface(const unsigned char *buf);
static void dump_dfu_interface(const unsigned char *buf);
static char *dump_comm_descriptor(libusb_device_handle *dev, const unsigned char *buf, char *indent);
@@ -553,7 +557,7 @@ static void dump_altsetting(libusb_device_handle *dev, const struct libusb_inter
case USB_CLASS_VIDEO:
switch (interface->bInterfaceSubClass) {
case 1:
- dump_videocontrol_interface(dev, buf);
+ dump_videocontrol_interface(dev, buf, interface->bInterfaceProtocol);
break;
case 2:
dump_videostreaming_interface(buf);
@@ -2099,22 +2103,30 @@ static void dump_midistreaming_endpoint(const unsigned char *buf)
* Video Class descriptor dump
*/
-static void dump_videocontrol_interface(libusb_device_handle *dev, const unsigned char *buf)
+static void dump_videocontrol_interface(libusb_device_handle *dev, const unsigned char *buf, int protocol)
{
static const char * const ctrlnames[] = {
"Brightness", "Contrast", "Hue", "Saturation", "Sharpness", "Gamma",
"White Balance Temperature", "White Balance Component", "Backlight Compensation",
"Gain", "Power Line Frequency", "Hue, Auto", "White Balance Temperature, Auto",
"White Balance Component, Auto", "Digital Multiplier", "Digital Multiplier Limit",
- "Analog Video Standard", "Analog Video Lock Status"
+ "Analog Video Standard", "Analog Video Lock Status", "Contrast, Auto"
};
static const char * const camctrlnames[] = {
"Scanning Mode", "Auto-Exposure Mode", "Auto-Exposure Priority",
"Exposure Time (Absolute)", "Exposure Time (Relative)", "Focus (Absolute)",
"Focus (Relative)", "Iris (Absolute)", "Iris (Relative)", "Zoom (Absolute)",
"Zoom (Relative)", "PanTilt (Absolute)", "PanTilt (Relative)",
"Roll (Absolute)", "Roll (Relative)", "Reserved", "Reserved", "Focus, Auto",
- "Privacy"
+ "Privacy", "Focus, Simple", "Window", "Region of Interest"
+ };
+ static const char * const enctrlnames[] = {
+ "Select Layer", "Profile and Toolset", "Video Resolution", "Minimum Frame Interval",
+ "Slice Mode", "Rate Control Mode", "Average Bit Rate", "CPB Size", "Peak Bit Rate",
+ "Quantization Parameter", "Synchronization and Long-Term Reference Frame",
+ "Long-Term Buffer", "Picture Long-Term Reference", "LTR Validation",
+ "Level IDC", "SEI Message", "QP Range", "Priority ID", "Start or Stop Layer/View",
+ "Error Resiliency"
};
static const char * const stdnames[] = {
"None", "NTSC - 525/60", "PAL - 625/50", "SECAM - 625/50",
@@ -2175,9 +2187,16 @@ static void dump_videocontrol_interface(libusb_device_handle *dev, const unsigne
for (i = 0; i < 3 && i < buf[14]; i++)
ctrls = (ctrls << 8) | buf[8+n-i-1];
printf(" bmControls 0x%08x\n", ctrls);
- for (i = 0; i < 19; i++)
- if ((ctrls >> i) & 1)
- printf(" %s\n", camctrlnames[i]);
+ if (protocol == USB_VIDEO_PROTOCOL_15) {
+ for (i = 0; i < 22; i++)
+ if ((ctrls >> i) & 1)
+ printf(" %s\n", camctrlnames[i]);
+ }
+ else {
+ for (i = 0; i < 19; i++)
+ if ((ctrls >> i) & 1)
+ printf(" %s\n", camctrlnames[i]);
+ }
}
dump_junk(buf, " ", 8+n);
break;
@@ -2230,12 +2249,19 @@ static void dump_videocontrol_interface(libusb_device_handle *dev, const unsigne
for (i = 0; i < 3 && i < n; i++)
ctrls = (ctrls << 8) | buf[8+n-i-1];
printf(" bmControls 0x%08x\n", ctrls);
- for (i = 0; i < 18; i++)
- if ((ctrls >> i) & 1)
- printf(" %s\n", ctrlnames[i]);
+ if (protocol == USB_VIDEO_PROTOCOL_15) {
+ for (i = 0; i < 19; i++)
+ if ((ctrls >> i) & 1)
+ printf(" %s\n", ctrlnames[i]);
+ }
+ else {
+ for (i = 0; i < 18; i++)
+ if ((ctrls >> i) & 1)
+ printf(" %s\n", ctrlnames[i]);
+ }
stds = buf[9+n];
printf(" iProcessing %5u %s\n"
- " bmVideoStandards 0x%2x\n", buf[8+n], term, stds);
+ " bmVideoStandards 0x%02x\n", buf[8+n], term, stds);
for (i = 0; i < 6; i++)
if ((stds >> i) & 1)
printf(" %s\n", stdnames[i]);
@@ -2263,6 +2289,30 @@ static void dump_videocontrol_interface(libusb_device_handle *dev, const unsigne
dump_junk(buf, " ", 24+p+n);
break;
+ case 0x07: /* ENCODING UNIT */
+ printf("(ENCODING UNIT)\n");
+ term = get_dev_string(dev, buf[5]);
+ if (buf[0] < 13)
+ printf(" Warning: Descriptor too short\n");
+ printf(" bUnitID %5u\n"
+ " bSourceID %5u\n"
+ " iEncoding %5u %s\n"
+ " bControlSize %5u\n",
+ buf[3], buf[4], buf[5], term, buf[6]);
+ for (i = 0; i < 3; i++)
+ ctrls = (ctrls << 8) | buf[9-i];
+ printf(" bmControls 0x%08x\n", ctrls);
+ for (i = 0; i < 20; i++)
+ if ((ctrls >> i) & 1)
+ printf(" %s\n", enctrlnames[i]);
+ for (i = 0; i< 3; i++)
+ ctrls = (ctrls << 8) | buf[12-i];
+ printf(" bmControlsRuntime 0x%08x\n", ctrls);
+ for (i = 0; i < 20; i++)
+ if ((ctrls >> i) & 1)
+ printf(" %s\n", enctrlnames[i]);
+ break;
+
default:
printf("(unknown)\n"
" Invalid desc subtype:");
@@ -2401,7 +2451,7 @@ static void dump_videostreaming_interface(const unsigned char *buf)
printf("Random pattern of fields 1 and 2\n");
break;
}
- printf(" bCopyProtect %5u\n", buf[26]);
+ printf(" bCopyProtect %5u\n", buf[26]);
if (buf[2] == 0x10)
printf(" bVariableSize %5u\n", buf[27]);
dump_junk(buf, " ", len);
@@ -2505,7 +2555,7 @@ static void dump_videostreaming_interface(const unsigned char *buf)
printf("Random pattern of fields 1 and 2\n");
break;
}
- printf(" bCopyProtect %5u\n", buf[10]);
+ printf(" bCopyProtect %5u\n", buf[10]);
dump_junk(buf, " ", 11);
break;

0 comments on commit db14099

Please sign in to comment.