Hi Tharindu,

On Wednesday 17 October 2007, Tharindu Rukshan Bamunuarachchi wrote:
> Dear Laurent/All,
>
> Thank you very much for quick reply.
>
> Pls find attachment.

Thanks. Please try the attached patch.

Best regards,

Laurent Pinchart
Index: uvc_ctrl.c
===================================================================
--- uvc_ctrl.c	(revision 132)
+++ uvc_ctrl.c	(working copy)
@@ -415,7 +415,7 @@
 
 static int uvc_entity_match_guid(struct uvc_entity *entity, __u8 guid[16])
 {
-	switch (entity->type) {
+	switch (UVC_ENTITY_TYPE(entity)) {
 	case ITT_CAMERA:
 		return memcmp(uvc_camera_guid, guid, 16) == 0;
 
@@ -885,7 +885,7 @@
 	if (!found)
 		return;
 
-	if (entity->type == VC_EXTENSION_UNIT) {
+	if (UVC_ENTITY_TYPE(entity) == VC_EXTENSION_UNIT) {
 		/* Check if the device control information and length match
 		 * the user supplied information.
 		 */
@@ -1046,13 +1046,13 @@
 		unsigned int bControlSize = 0, ncontrols = 0;
 		__u8 *bmControls = NULL;
 
-		if (entity->type == VC_EXTENSION_UNIT) {
+		if (UVC_ENTITY_TYPE(entity) == VC_EXTENSION_UNIT) {
 			bmControls = entity->extension.bmControls;
 			bControlSize = entity->extension.bControlSize;
-		} else if (entity->type == VC_PROCESSING_UNIT) {
+		} else if (UVC_ENTITY_TYPE(entity) == VC_PROCESSING_UNIT) {
 			bmControls = entity->processing.bmControls;
 			bControlSize = entity->processing.bControlSize;
-		} else if (entity->type == ITT_CAMERA) {
+		} else if (UVC_ENTITY_TYPE(entity) == ITT_CAMERA) {
 			bmControls = entity->camera.bmControls;
 			bControlSize = entity->camera.bControlSize;
 		}
Index: uvc_v4l2.c
===================================================================
--- uvc_v4l2.c	(revision 133)
+++ uvc_v4l2.c	(working copy)
@@ -607,7 +607,7 @@
 		memset(input, 0, sizeof *input);
 		input->index = index;
 		strncpy(input->name, iterm->name, sizeof input->name);
-		if (iterm->type == ITT_CAMERA)
+		if (UVC_ENTITY_TYPE(iterm) == ITT_CAMERA)
 			input->type = V4L2_INPUT_TYPE_CAMERA;
 	}
 		break;
Index: uvc_driver.c
===================================================================
--- uvc_driver.c	(revision 134)
+++ uvc_driver.c	(working copy)
@@ -261,7 +261,7 @@
 		entity = list_entry(&dev->entities, struct uvc_entity, list);
 
 	list_for_each_entry_continue(entity, &dev->entities, list) {
-		switch (entity->type) {
+		switch (UVC_ENTITY_TYPE(entity)) {
 		case TT_STREAMING:
 			if (entity->output.bSourceID == id)
 				return entity;
@@ -922,16 +922,16 @@
 				return -ENOMEM;
 
 			term->id = buffer[3];
-			term->type = type;
+			term->type = type | UVC_TERM_INPUT;
 
-			if (term->type == ITT_CAMERA) {
+			if (UVC_ENTITY_TYPE(term) == ITT_CAMERA) {
 				term->camera.bControlSize = n;
 				term->camera.bmControls = (__u8*)term + sizeof *term;
 				term->camera.wObjectiveFocalLengthMin = le16_to_cpup((__le16*)&buffer[8]);
 				term->camera.wObjectiveFocalLengthMax = le16_to_cpup((__le16*)&buffer[10]);
 				term->camera.wOcularFocalLength = le16_to_cpup((__le16*)&buffer[12]);
 				memcpy(term->camera.bmControls, &buffer[15], n);
-			} else if (term->type == ITT_MEDIA_TRANSPORT_INPUT) {
+			} else if (UVC_ENTITY_TYPE(term) == ITT_MEDIA_TRANSPORT_INPUT) {
 				term->media.bControlSize = n;
 				term->media.bmControls = (__u8*)term + sizeof *term;
 				term->media.bTransportModeSize = p;
@@ -942,9 +942,9 @@
 
 			if (buffer[7] != 0)
 				usb_string(udev, buffer[7], term->name, sizeof term->name);
-			else if (term->type == ITT_CAMERA)
+			else if (UVC_ENTITY_TYPE(term) == ITT_CAMERA)
 				sprintf(term->name, "Camera %u", buffer[3]);
-			else if (term->type == ITT_MEDIA_TRANSPORT_INPUT)
+			else if (UVC_ENTITY_TYPE(term) == ITT_MEDIA_TRANSPORT_INPUT)
 				sprintf(term->name, "Media %u", buffer[3]);
 			else
 				sprintf(term->name, "Input %u", buffer[3]);
@@ -978,7 +978,7 @@
 				return -ENOMEM;
 
 			term->id = buffer[3];
-			term->type = type;
+			term->type = type | UVC_TERM_OUTPUT;
 			term->output.bSourceID = buffer[7];
 
 			if (buffer[8] != 0)
@@ -1146,7 +1146,7 @@
 static int uvc_scan_chain_entity(struct uvc_video_device *video,
 	struct uvc_entity *entity)
 {
-	switch (entity->type) {
+	switch (UVC_ENTITY_TYPE(entity)) {
 	case VC_EXTENSION_UNIT:
 		if (uvc_trace_param & UVC_TRACE_PROBE)
 			printk(" <- XU %d", entity->id);
@@ -1201,7 +1201,7 @@
 
 	default:
 		uvc_trace(UVC_TRACE_DESCR, "Unsupported entity type "
-			"0x%04x found in chain.n", entity->type);
+			"0x%04x found in chain.n", UVC_ENTITY_TYPE(entity));
 		return -1;
 	}
 
@@ -1224,7 +1224,7 @@
 		if (forward == NULL)
 			break;
 
-		if (forward == prev || forward->type != VC_EXTENSION_UNIT)
+		if (forward == prev || UVC_ENTITY_TYPE(forward) != VC_EXTENSION_UNIT)
 			continue;
 
 		if (forward->extension.bNrInPins != 1) {
@@ -1254,7 +1254,7 @@
 	struct uvc_entity *term;
 	int id = -1, i;
 
-	switch (entity->type) {
+	switch (UVC_ENTITY_TYPE(entity)) {
 	case VC_EXTENSION_UNIT:
 		id = entity->extension.baSourceID[0];
 		break;
@@ -1365,7 +1365,7 @@
 	list_for_each_entry(term, &dev->entities, list) {
 		struct uvc_streaming *streaming;
 
-		if (term->type != TT_STREAMING)
+		if (UVC_ENTITY_TYPE(term) != TT_STREAMING)
 			continue;
 
 		memset(&dev->video, 0, sizeof dev->video);
Index: uvcvideo.h
===================================================================
--- uvcvideo.h	(revision 132)
+++ uvcvideo.h	(working copy)
@@ -234,16 +234,21 @@
 #define OTT_DISPLAY                     0x0301
 #define OTT_MEDIA_TRANSPORT_OUTPUT      0x0302
 
+/* External Terminal types */
 #define EXTERNAL_VENDOR_SPECIFIC        0x0400
 #define COMPOSITE_CONNECTOR             0x0401
 #define SVIDEO_CONNECTOR                0x0402
 #define COMPONENT_CONNECTOR             0x0403
 
-#define UVC_ENTITY_IS_UNIT(entity)	((entity->type & 0xff00) == 0)
-#define UVC_ENTITY_IS_TERM(entity)	((entity->type & 0xff00) != 0)
-#define UVC_ENTITY_IS_ITERM(entity)	((entity->type & 0xff00) == ITT_VENDOR_SPECIFIC)
-#define UVC_ENTITY_IS_OTERM(entity)	((entity->type & 0xff00) == OTT_VENDOR_SPECIFIC)
+#define UVC_TERM_INPUT			0x0000
+#define UVC_TERM_OUTPUT			0x8000
 
+#define UVC_ENTITY_TYPE(entity)		((entity)->type & 0x7fff)
+#define UVC_ENTITY_IS_UNIT(entity)	(((entity)->type & 0xff00) == 0)
+#define UVC_ENTITY_IS_TERM(entity)	(((entity)->type & 0xff00) != 0)
+#define UVC_ENTITY_IS_ITERM(entity)	(((entity)->type & 0x8000) == UVC_TERM_INPUT)
+#define UVC_ENTITY_IS_OTERM(entity)	(((entity)->type & 0x8000) == UVC_TERM_OUTPUT)
+
 /* ------------------------------------------------------------------------
  * GUIDs
  */
@@ -401,7 +406,7 @@
  * always have a null MSB for units. All terminal types defined by the UVC
  * specification have a non-null MSB, so it is safe to use the MSB to
  * differentiate between units and terminals as long as the descriptor parsing
- * code makes sur terminal types have a non-null MSB.
+ * code makes sure terminal types have a non-null MSB.
  */
 
 struct uvc_entity {
_______________________________________________
Linux-uvc-devel mailing list
[email protected]
https://lists.berlios.de/mailman/listinfo/linux-uvc-devel

Reply via email to