Hi everybody,

here's a patch to fix camera descriptors parsing for UVC devices. The camera 
descriptors currently reports "junk at descriptor end".

Laurent Pinchart
? camera_controls.patch
Index: lsusb.c
===================================================================
RCS file: /cvsroot/linux-usb/usbutils/lsusb.c,v
retrieving revision 1.22
diff -u -r1.22 lsusb.c
--- lsusb.c	17 Jan 2006 15:59:46 -0000	1.22
+++ lsusb.c	6 Feb 2006 13:46:45 -0000
@@ -1236,6 +1236,14 @@
 		"White Balance Component, Auto", "Digital Multiplier", "Digital Multiplier Limit",
 		"Analog Video Standard", "Analog Video Lock Status"
 	};
+	static const char *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"
+	};
 	static const char *stdnames[] = {
 		"None", "NTSC - 525/60", "PAL - 625/50", "SECAM - 625/50",
 		"NTSC - 625/50", "PAL - 525/60" };
@@ -1273,8 +1281,9 @@
 		printf("(INPUT_TERMINAL)\n");
 		get_string(dev, term, sizeof(term), buf[7]);
 		termt = buf[4] | (buf[5] << 8);
+		n = termt == 0x0201 ? 7 : 0;
 		get_videoterminal_string(termts, sizeof(termts), termt);
-		if (buf[0] < 8)
+		if (buf[0] < 8 + n)
 			printf("      Warning: Descriptor too short\n");
 		printf("        bTerminalID         %5u\n"
 		       "        wTerminalType      0x%04x %s\n"
@@ -1282,8 +1291,23 @@
 		       buf[3], termt, termts, buf[6]);
 		printf("        iTerminal           %5u %s\n",
 		       buf[7], term);
-		/* TODO: handle additional data */
-		dump_junk(buf, "        ", 8);
+		if (termt == 0x0201) {
+			n += buf[14];
+			printf("        wObjectiveFocalLengthMin  %5u\n"
+			       "        wObjectiveFocalLengthMax  %5u\n"
+			       "        wOcularFocalLength        %5u\n"
+			       "        bControlSize              %5u\n",
+			       buf[8] | (buf[9] << 8), buf[10] | (buf[11] << 8),
+			       buf[12] | (buf[13] << 8), buf[14]);
+			ctrls = 0;
+			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]);
+		}
+		dump_junk(buf, "        ", 8+n);
 		break;
 
 	case 0x03:  /* OUTPUT_TERMINAL */
@@ -1525,7 +1549,8 @@
 		       buf[9] | (buf[10] << 8) | (buf[11] << 16) | (buf[12] << 24),
 		       buf[13] | (buf[14] << 8) | (buf[15] << 16) | (buf[16] << 24),
 		       buf[17] | (buf[18] << 8) | (buf[19] << 16) | (buf[20] << 24),
-		       buf[23], buf[25]);
+		       buf[21] | (buf[22] << 8) | (buf[23] << 16) | (buf[24] << 24),
+		       buf[25]);
 		if (buf[25] == 0)
 			printf("        dwMinFrameInterval          %9u\n"
 			       "        dwMaxFrameInterval          %9u\n"

Reply via email to