All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [0/7] USB UVC updates
@ 2011-06-02  5:41 Brad Hards
  2011-06-02  5:41 ` [Qemu-devel] [PATCH 1/7] usb: Turn off debug output by default Brad Hards
                   ` (7 more replies)
  0 siblings, 8 replies; 10+ messages in thread
From: Brad Hards @ 2011-06-02  5:41 UTC (permalink / raw)
  To: claunia, qemu-devel

Hi Natalia,

As you suggested, I've stopped my nonsense and worked from your
UVC patches (http://patchwork.ozlabs.org/patch/55001 and
http://patchwork.ozlabs.org/patch/55000). These changes
are relative to your patches (applied on top of trunk).

I've mostly just incorporated some changes requested by Blue
Swirl in his review. Fixing the checkpatch stuff changed a lot
of whitespace (tab -> spaces), so I'd like to make sure this is
OK before making more changes.

The next change I propose to make is to rework the descriptors
and add constants / defines for magic numbers.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Qemu-devel] [PATCH 1/7] usb: Turn off debug output by default.
  2011-06-02  5:41 [Qemu-devel] [0/7] USB UVC updates Brad Hards
@ 2011-06-02  5:41 ` Brad Hards
  2011-06-02  5:41 ` [Qemu-devel] [PATCH 2/7] usb-uvc: compile fix Brad Hards
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 10+ messages in thread
From: Brad Hards @ 2011-06-02  5:41 UTC (permalink / raw)
  To: claunia, qemu-devel; +Cc: Brad Hards

Addresses comment by Blue Swirl (2010-06-10 17:46:16)

Signed-off-by: Brad Hards <bradh@frogmouth.net>
---
 hw/usb-uvc.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/hw/usb-uvc.c b/hw/usb-uvc.c
index b711f51..e88ee00 100644
--- a/hw/usb-uvc.c
+++ b/hw/usb-uvc.c
@@ -31,7 +31,7 @@
 #include <sys/ioctl.h>
 #include <linux/videodev2.h>
 
-#define DEBUG_UVC
+// #define DEBUG_UVC
 
 #ifdef DEBUG_UVC
 #define DPRINTF(fmt, ...) \
-- 
1.7.4.1

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [Qemu-devel] [PATCH 2/7] usb-uvc: compile fix
  2011-06-02  5:41 [Qemu-devel] [0/7] USB UVC updates Brad Hards
  2011-06-02  5:41 ` [Qemu-devel] [PATCH 1/7] usb: Turn off debug output by default Brad Hards
@ 2011-06-02  5:41 ` Brad Hards
  2011-06-02  5:41 ` [Qemu-devel] [PATCH 3/7] usb-uvc: Fix all checkpatch style issues Brad Hards
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 10+ messages in thread
From: Brad Hards @ 2011-06-02  5:41 UTC (permalink / raw)
  To: claunia, qemu-devel; +Cc: Brad Hards

Looks like function signature changed.

Signed-off-by: Brad Hards <bradh@frogmouth.net>
---
 hw/usb-uvc.c |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/hw/usb-uvc.c b/hw/usb-uvc.c
index e88ee00..c9c8f77 100644
--- a/hw/usb-uvc.c
+++ b/hw/usb-uvc.c
@@ -307,8 +307,9 @@ static void usb_uvc_handle_reset(USBDevice *dev)
 	DPRINTF("Reset called\n");
 }
 
-static int usb_uvc_handle_control(USBDevice *dev, int request, int value,
-								  int index, int length, uint8_t *data)
+static int usb_uvc_handle_control(USBDevice *dev, USBPacket *p, int request,
+                                  int value, int index, int length,
+                                  uint8_t *data)
 {
 	int ret = 0;
 	USBUVCState *s = (USBUVCState *)dev;
-- 
1.7.4.1

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [Qemu-devel] [PATCH 3/7] usb-uvc: Fix all checkpatch style issues.
  2011-06-02  5:41 [Qemu-devel] [0/7] USB UVC updates Brad Hards
  2011-06-02  5:41 ` [Qemu-devel] [PATCH 1/7] usb: Turn off debug output by default Brad Hards
  2011-06-02  5:41 ` [Qemu-devel] [PATCH 2/7] usb-uvc: compile fix Brad Hards
@ 2011-06-02  5:41 ` Brad Hards
  2011-06-02  5:41 ` [Qemu-devel] [PATCH 4/7] usb-uvc: fix some spelling issues Brad Hards
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 10+ messages in thread
From: Brad Hards @ 2011-06-02  5:41 UTC (permalink / raw)
  To: claunia, qemu-devel; +Cc: Brad Hards

Signed-off-by: Brad Hards <bradh@frogmouth.net>
---
 hw/usb-uvc.c | 1917 +++++++++++++++++++++++++++++-----------------------------
 1 files changed, 945 insertions(+), 972 deletions(-)

diff --git a/hw/usb-uvc.c b/hw/usb-uvc.c
index c9c8f77..20ac23e 100644
--- a/hw/usb-uvc.c
+++ b/hw/usb-uvc.c
@@ -27,12 +27,12 @@
 #include <stdio.h>
 #include <fcntl.h>
 #include <errno.h>
-// V4L2 ioctls
+
+/* V4L2 ioctls */
 #include <sys/ioctl.h>
 #include <linux/videodev2.h>
 
-// #define DEBUG_UVC
-
+/* #define DEBUG_UVC */
 #ifdef DEBUG_UVC
 #define DPRINTF(fmt, ...) \
 do { printf("usb-uvc: " fmt , ## __VA_ARGS__); } while (0)
@@ -41,26 +41,26 @@ do { printf("usb-uvc: " fmt , ## __VA_ARGS__); } while (0)
 #endif
 
 /* USB Video Class Request codes */
-#define USB_UVC_RC_UNDEFINED	0x00
-#define USB_UVC_SET_CUR			0x01
-#define USB_UVC_GET_CUR			0x81
-#define USB_UVC_GET_MIN			0x82
-#define USB_UVC_GET_MAX			0x83
-#define USB_UVC_GET_RES			0x84
-#define USB_UVC_GET_LEN			0x85
-#define USB_UVC_GET_INFO		0x86
-#define USB_UVC_GET_DEF			0x87
+#define USB_UVC_RC_UNDEFINED    0x00
+#define USB_UVC_SET_CUR         0x01
+#define USB_UVC_GET_CUR         0x81
+#define USB_UVC_GET_MIN         0x82
+#define USB_UVC_GET_MAX         0x83
+#define USB_UVC_GET_RES         0x84
+#define USB_UVC_GET_LEN         0x85
+#define USB_UVC_GET_INFO        0x86
+#define USB_UVC_GET_DEF         0x87
 
 /* USB Video Class Request types */
-#define UVCSetVideoControl		0x2100
-#define UVCSetVideoStreaming	0x2200
-#define UVCGetVideoControl		0xA100
-#define UVCGetVideoStreaming	0xA200
+#define UVCSetVideoControl      0x2100
+#define UVCSetVideoStreaming    0x2200
+#define UVCGetVideoControl      0xA100
+#define UVCGetVideoStreaming    0xA200
 
 typedef struct USBUVCState {
     USBDevice dev;
-	char	current_input;
-	char	*v4l2_device;
+    char      current_input;
+    char      *v4l2_device;
 } USBUVCState;
 
 static int v4l2_fd;
@@ -73,1001 +73,974 @@ static int frame_remaining_bytes;
 static int frame_max_length;
 
 static const uint8_t qemu_uvc_dev_descriptor[] = {
-	0x12,       /*  u8 bLength; */
-	0x01,       /*  u8 bDescriptorType; Device */
-	0x00, 0x02, /*  u16 bcdUSB; v2.0 */
-	
-	0xEF,	    /*  u8  bDeviceClass; */
-	0x02,	    /*  u8  bDeviceSubClass; */
-	0x01,       /*  u8  bDeviceProtocol; [ low/full speeds only ] */
-	0x08,       /*  u8  bMaxPacketSize0; 8 Bytes */
-	
-	/* Vendor and product id are arbitrary.  */
-	0x00, 0x00, /*  u16 idVendor; */
- 	0x00, 0x00, /*  u16 idProduct; */
-	0x00, 0x00, /*  u16 bcdDevice */
-	
-	0x01,       /*  u8  iManufacturer; */
-	0x02,       /*  u8  iProduct; */
-	0x00,       /*  u8  iSerialNumber; */
-	0x01        /*  u8  bNumConfigurations; */
+    0x12,       /*  u8  bLength; */
+    0x01,       /*  u8  bDescriptorType; Device */
+    0x00, 0x02, /*  u16 bcdUSB; v2.0 */
+
+    0xEF,       /*  u8  bDeviceClass; */
+    0x02,       /*  u8  bDeviceSubClass; */
+    0x01,       /*  u8  bDeviceProtocol; [ low/full speeds only ] */
+    0x08,       /*  u8  bMaxPacketSize0; 8 Bytes */
+
+    /* Vendor and product id are arbitrary.  */
+    0x00, 0x00, /*  u16 idVendor; */
+    0x00, 0x00, /*  u16 idProduct; */
+    0x00, 0x00, /*  u16 bcdDevice */
+
+    0x01,       /*  u8  iManufacturer; */
+    0x02,       /*  u8  iProduct; */
+    0x00,       /*  u8  iSerialNumber; */
+    0x01        /*  u8  bNumConfigurations; */
 };
 
 static const uint8_t qemu_uvc_config_descriptor[] = {
-	
-	/* one configuration */
-	0x09,       /*  u8  bLength; */
-	0x02,       /*  u8  bDescriptorType; Configuration */
-	0xB7, 0x00, /*  u16 wTotalLength; */
-	0x02,       /*  u8  bNumInterfaces; (2) */
-	0x01,       /*  u8  bConfigurationValue; */
-	0x00,       /*  u8  iConfiguration; */
-	0x80,       /*  u8  bmAttributes;
-				 Bit 7: must be set,
-				 6: Self-powered,
-				 5: Remote wakeup,
-				 4..0: resvd */
-	0xFA,       /*  u8  MaxPower; */
-	
-	/* interface association */
-	0x08,		/*  u8  ifa_bLength; */
-	0x0B,		/*  u8  ifa_bDescriptorType; Interface Association */
-	0x00,		/*  u8  ifa_bFirstInterface; */
-	0x02,		/*  u8  ifa_bInterfaceCount; */
-	0x0E,		/*  u8  ifa_bFunctionClass; CC_VIDEO */
-	0x03,		/*  u8  ifa_bFunctionSubClass; SS_VIDEO_INTERFACE_COLLECTION */
-	0x00,		/*  u8  ifa_bFunctionProtocol; unused */
-	0x02,		/*  u8  ifa_iFunction; */
-	
-	/* video control interface */
-	0x09,       /*  u8  if_bLength; */
-	0x04,       /*  u8  if_bDescriptorType; Interface */
-	0x00,       /*  u8  if_bInterfaceNumber; */
-	0x00,       /*  u8  if_bAlternateSetting; */
-	0x01,       /*  u8  if_bNumEndpoints; */
-	0x0E,       /*  u8  if_bInterfaceClass; CC_VIDEO */
-	0x01,       /*  u8  if_bInterfaceSubClass; SC_VIDEOCONTROL */
-	0x00,       /*  u8  if_bInterfaceProtocol; unused */
-	0x02,       /*  u8  if_iInterface; */
-	
-	/* class specific vc interface descriptor */
-	0x0D,		/*  u8  cif_bLength; */
-	0x24,		/*  u8  cif_bDescriptorType; CS_INTERFACE */
-	0x01,		/*  u8  cif_bDescriptorSubType; VC_HEADER */
-	0x00, 0x01, /*  u16 cif_bcdUVC; 1.0 */
-	0x42, 0x00, /*  u16 cif_wTotalLength */
-	0x80, 0x8D, /*  u32 cif_dwClockFrequency; Deprecated, 6Mhz */
-	0x5B, 0x00,
-	0x01,		/*  u8  cif_bInCollection; */
-	0x01,		/*  u8  cif_baInterfaceNr; */
-	
-	/* input terminal descriptor */
-	0x11,		/*  u8  itd_bLength; */
-	0x24,		/*  u8  itd_bDescriptorType; CS_INTERFACE */
-	0x02,		/*  u8  itd_bDescriptorSubtype; VC_INPUT_TERMINAL */
-	0x01,		/*  u8  itd_bTerminalID; */
-	0x01, 0x02, /*  u16  itd_wTerminalType; ITT_CAMERA */
-	0x00,		/*  u8  itd_bAssocTerminal; No association */
-	0x00,		/*  u8  itd_iTerminal; Unused */
-	0x00, 0x00, /*  u16  itd_wObjectiveFocalLengthMin; No optical zoom */
-	0x00, 0x00, /*  u16  itd_wObjectiveFocalLengthMax; No optical zoom */
-	0x00, 0x00, /*  u16  itd_wOcularFocalLength; No optical zoom */
-	0x02,		/*  u8  itd_bControlSize; No controls implemented */
-	0x00, 0x00, /*  u16  itd_bmControls; No controls supported */
-	
-	0x08,		/*	u8	itd_bLength; */
-	0x24,		/*	u8	itd_bDescriptorType; CS_INTERFACE */
-	0x02,		/*	u8	itd_bDescriptorSubtype; VC_INPUT_TERMINAL */
-	0x02,		/*	u8	itd_bTerminalID; */
-	0x01, 0x04,	/*	u16	itd_wTerminalType; ITT_COMPOSITE */
-	0x00,		/*	u8	itd_bAssocTerminal; */
-	0x00,		/*	u8	itd_iTerminal; */
-	
-	/* output terminal descriptor */
-	0x09,		/*	u8	otd_bLength; */
-	0x24,		/*	u8	otd_bDescriptorType; CS_INTERFACE */
-	0x03,		/*	u8	otd_bDescriptorSubtype; VC_OUTPUT_TERMINAL */
-	0x03,		/*	u8	otd_bTerminalID; */
-	0x01, 0x01,	/*	u16	otd_wTerminalType; TT_STREAMING */
-	0x00,		/*	u8	otd_bAssocTerminal; No association */
-	0x05,		/*	u8	otd_bSourceID; */
-	0x00,		/*	u8	otd_iTerminal; */
-	
-	/* selector unit descriptor */
-	0x08,		/*	u8	sud_bLength; */
-	0x24,		/*	u8	sud_bDescriptorType; CS_INTERFACE */
-	0x04,		/*	u8	sud_bDescriptorSubtype; VC_SELECTOR_UNIT */
-	0x04,		/*	u8	sud_bUnitID; */
-	0x02,		/*	u8	sud_bNrInPins; */
-	0x01,		/*	u8	sud_baSourceID; */
-	0x02,
-	0x00,		/*	u8	sud_iSelector; */
-	
-	/* processing unit descriptor */
-	0x0B,		/*	u8	pud_bLength; */
-	0x24,		/*	u8	pud_bDescriptorType; CS_INTERFACE */
-	0x05,		/*	u8	pud_bDescriptorSubtype; VC_PROCESSING_UNIT */
-	0x05,		/*	u8	pud_bUnitID; */
-	0x04,		/*	u8	pud_bSourceID; */
-	0x00, 0x00,	/*	u16	pud_wMaxMultiplier; */
-	0x02,		/*	u8	pud_bControlSize; */
-	0x01, 0x00,	/*	u16	pud_bmControls; Brightness control supported */
-	0x00,		/*	u8	pud_iProcessing; */
-	
-	/* standard interrupt endpoint */
-	0x07,		/*	u8	ep_bLenght; */
-	0x05,		/*	u8	ep_bDescriptorType; Endpoint */
-	0x81,		/*	u8	ep_bEndpointAddress; IN Endpoint 1 */
-	0x03,		/*	u8	ep_bmAttributes; Interrupt */
-	0x08, 0x00,	/*	u8	ep_wMaxPacketSize; 8 bytes */
-	0xFF,		/*	u8	ep_bInterval; 32ms */
-	
-	/* class-specific interrupt endpoint */
-	0x05,		/*	u8	ep_bLenght; */
-	0x25,		/*	u8	ep_bDescriptorType; CS_ENDPOINT */
-	0x03,		/*	u8	ep_bmAttributes; EP_INTERRUPT */
-	0x08, 0x00,	/*	u8	ep_wMaxPacketSize; 8 bytes */
-	
-	/* standard vs interface descriptor alternate 0 */
-	0x09,		/*	u8	bLength; */
-	0x04,		/*	u8	bDescriptorType; INTERFACE */
-	0x01,		/*	u8	bInterfaceNumber; */
-	0x00,		/*	u8	bAlternateSetting; */
-	0x01,		/*	u8	bNumEndpoints; */
-	0x0E,		/*	u8	bInterfaceClass; CC_VIDEO */
-	0x02,		/*	u8	bInterfaceSubClass; SC_VIDEO_STREAMING */
-	0x00,		/*	u8	bInterfaceProtocol; PC_PROTOCOL_UNDEFINED */
-	0x00,		/*	u8	iInterface; Unused */
-	
-	/* class-specific vs header descriptor input alternate 0 */
-	0x0E,		/*	u8	bLength; */
-	0x24,		/*	u8	bDescriptorType; CS_INTERFACE */
-	0x01,		/*	u8	bDescriptorSubtype; VS_INPUT_HEADER */
-	0x01,		/*	u8	bNumFormats; */
-	0x46, 0x00,	/*	u8	wTotalLength; */
-	0x82,		/*	u8	bEndpointAddress; */
-	0x00,		/*	u8	bmInfo; */
-	0x03,		/*	u8	bTerminalLink; */
-	0x00,		/*	u8	bStillCaptureMethod; */
-	0x00,		/*	u8	bTriggerSupport; */
-	0x00,		/*	u8	bTriggerUsage; */
-	0x01,		/*	u8	bControlSize; */
-	0x00,		/*	u8	bmaControls; */
-	
-	/* class-specific vs format descriptor alternate 0 */
-	0x0B,		/*	u8	bLength; */
-	0x24,		/*	u8	bDescriptorType; CS_INTERFACE */
-	0x06,		/*	u8	bDescriptorSubtype; VS_FORMAT_MJPEG */
-	0x01,		/*	u8	bFormatIndex; */
-	0x01,		/*	u8	bNumFrameDescriptors; */
-	0x01,		/*	u8	bmFlags; */
-	0x01,		/*	u8	bDefaultFrameIndex; */
-	0x00,		/*	u8	bAspectRatioX; */
-	0x00,		/*	u8	bAspectRatioY; */
-	0x02,		/*	u8	bmInterlaceFlags; */
-	0x00,		/*	u8	bCopyProtect; */
-	
-	/* class-specific vs frame descriptor alternate 0 */
-	0x26,		/*	u8	bLength; */
-	0x24,		/*	u8	bDescriptorType; CS_INTERFACE */
-	0x07,		/*	u8	bDescriptorSubtype; VS_FRAME_MJPEG */
-	0x01,		/*	u8	bFrameIndex; */
-	0x01,		/*	u8	bmCapabilities; */
-	0x40, 0x01,	/*	u8	wWidth; 320 */
-	0xF0, 0x00,	/*	u8	wHeight; 240 */
-	0x00, 0xEC,
-	0x0D, 0x00,	/*	u32	dwMinBitRate; */
-	0x00, 0xEC,
-	0x0D, 0x00,	/*	u32	dwMaxBitRate; */
-	0x72, 0xCE,
-	0x00, 0x00,	/*	u32	dwMaxVideoFrameBufSize; */
-	0x2A, 0x2C,
-	0x0A, 0x00,	/*	u32	dwDefaultFrameInterval; */
-	0x00,		/*	u8	bFrameIntervalType;	*/
-	0x2A, 0x2C,
-	0x0A, 0x00,	/*	u32	dwMinFrameInterval; */
-	0x2A, 0x2C,
-	0x0A, 0x00,	/*	u32	dwMaxFrameInterval; */
-	0x00, 0x00,
-	0x00, 0x00,	/*	u32	dwFrameIntervalStep; */
-	
-	/* standard vs isochronous video data endpoint descriptor */
-	0x07,		/*	u8	bLength; */
-	0x05,		/*	u8	bDescriptorType; */
-	0x82,		/*	u8	bEndpointAddress; IN endpoint 2 */
-	0x02,		/*	u8	bmAttributes; Isochronous transfer, asynchronous sync */
-	0x40, 0x00,	/*	u16	wMaxPacketSize; 510 bytes */
-	0x00		/*	u8	bInterval; */
+
+    /* one configuration */
+    0x09,       /*  u8  bLength; */
+    0x02,       /*  u8  bDescriptorType; Configuration */
+    0xB7, 0x00, /*  u16 wTotalLength; */
+    0x02,       /*  u8  bNumInterfaces; (2) */
+    0x01,       /*  u8  bConfigurationValue; */
+    0x00,       /*  u8  iConfiguration; */
+    0x80,       /*  u8  bmAttributes;
+                 Bit 7: must be set,
+                 6: Self-powered,
+                 5: Remote wakeup,
+                 4..0: resvd */
+    0xFA,       /*  u8  MaxPower; */
+
+    /* interface association */
+    0x08,       /*  u8  ifa_bLength; */
+    0x0B,       /*  u8  ifa_bDescriptorType; Interface Association */
+    0x00,       /*  u8  ifa_bFirstInterface; */
+    0x02,       /*  u8  ifa_bInterfaceCount; */
+    0x0E,       /*  u8  ifa_bFunctionClass; CC_VIDEO */
+    0x03,       /*  u8  ifa_bFunctionSubClass; SS_VIDEO_INTERFACE_COLLECTION */
+    0x00,       /*  u8  ifa_bFunctionProtocol; unused */
+    0x02,       /*  u8  ifa_iFunction; */
+
+    /* video control interface */
+    0x09,       /*  u8  if_bLength; */
+    0x04,       /*  u8  if_bDescriptorType; Interface */
+    0x00,       /*  u8  if_bInterfaceNumber; */
+    0x00,       /*  u8  if_bAlternateSetting; */
+    0x01,       /*  u8  if_bNumEndpoints; */
+    0x0E,       /*  u8  if_bInterfaceClass; CC_VIDEO */
+    0x01,       /*  u8  if_bInterfaceSubClass; SC_VIDEOCONTROL */
+    0x00,       /*  u8  if_bInterfaceProtocol; unused */
+    0x02,       /*  u8  if_iInterface; */
+
+    /* class specific vc interface descriptor */
+    0x0D,       /*  u8  cif_bLength; */
+    0x24,       /*  u8  cif_bDescriptorType; CS_INTERFACE */
+    0x01,       /*  u8  cif_bDescriptorSubType; VC_HEADER */
+    0x00, 0x01, /*  u16 cif_bcdUVC; 1.0 */
+    0x42, 0x00, /*  u16 cif_wTotalLength */
+    0x80, 0x8D, /*  u32 cif_dwClockFrequency; Deprecated, 6Mhz */
+    0x5B, 0x00,
+    0x01,       /*  u8  cif_bInCollection; */
+    0x01,       /*  u8  cif_baInterfaceNr; */
+
+    /* input terminal descriptor */
+    0x11,       /*  u8  itd_bLength; */
+    0x24,       /*  u8  itd_bDescriptorType; CS_INTERFACE */
+    0x02,       /*  u8  itd_bDescriptorSubtype; VC_INPUT_TERMINAL */
+    0x01,       /*  u8  itd_bTerminalID; */
+    0x01, 0x02, /*  u16 itd_wTerminalType; ITT_CAMERA */
+    0x00,       /*  u8  itd_bAssocTerminal; No association */
+    0x00,       /*  u8  itd_iTerminal; Unused */
+    0x00, 0x00, /*  u16 itd_wObjectiveFocalLengthMin; No optical zoom */
+    0x00, 0x00, /*  u16 itd_wObjectiveFocalLengthMax; No optical zoom */
+    0x00, 0x00, /*  u16 itd_wOcularFocalLength; No optical zoom */
+    0x02,       /*  u8  itd_bControlSize; No controls implemented */
+    0x00, 0x00, /*  u16 itd_bmControls; No controls supported */
+
+    0x08,       /*  u8  itd_bLength; */
+    0x24,       /*  u8  itd_bDescriptorType; CS_INTERFACE */
+    0x02,       /*  u8  itd_bDescriptorSubtype; VC_INPUT_TERMINAL */
+    0x02,       /*  u8  itd_bTerminalID; */
+    0x01, 0x04, /*  u16 itd_wTerminalType; ITT_COMPOSITE */
+    0x00,       /*  u8  itd_bAssocTerminal; */
+    0x00,       /*  u8  itd_iTerminal; */
+
+    /* output terminal descriptor */
+    0x09,       /*  u8  otd_bLength; */
+    0x24,       /*  u8  otd_bDescriptorType; CS_INTERFACE */
+    0x03,       /*  u8  otd_bDescriptorSubtype; VC_OUTPUT_TERMINAL */
+    0x03,       /*  u8  otd_bTerminalID; */
+    0x01, 0x01, /*  u16 otd_wTerminalType; TT_STREAMING */
+    0x00,       /*  u8  otd_bAssocTerminal; No association */
+    0x05,       /*  u8  otd_bSourceID; */
+    0x00,       /*  u8  otd_iTerminal; */
+
+    /* selector unit descriptor */
+    0x08,       /*  u8  sud_bLength; */
+    0x24,       /*  u8  sud_bDescriptorType; CS_INTERFACE */
+    0x04,       /*  u8  sud_bDescriptorSubtype; VC_SELECTOR_UNIT */
+    0x04,       /*  u8  sud_bUnitID; */
+    0x02,       /*  u8  sud_bNrInPins; */
+    0x01,       /*  u8  sud_baSourceID; */
+    0x02,
+    0x00,       /*  u8  sud_iSelector; */
+
+    /* processing unit descriptor */
+    0x0B,       /*  u8  pud_bLength; */
+    0x24,       /*  u8  pud_bDescriptorType; CS_INTERFACE */
+    0x05,       /*  u8  pud_bDescriptorSubtype; VC_PROCESSING_UNIT */
+    0x05,       /*  u8  pud_bUnitID; */
+    0x04,       /*  u8  pud_bSourceID; */
+    0x00, 0x00, /*  u16 pud_wMaxMultiplier; */
+    0x02,       /*  u8  pud_bControlSize; */
+    0x01, 0x00, /*  u16 pud_bmControls; Brightness control supported */
+    0x00,       /*  u8  pud_iProcessing; */
+
+    /* standard interrupt endpoint */
+    0x07,       /*  u8  ep_bLenght; */
+    0x05,       /*  u8  ep_bDescriptorType; Endpoint */
+    0x81,       /*  u8  ep_bEndpointAddress; IN Endpoint 1 */
+    0x03,       /*  u8  ep_bmAttributes; Interrupt */
+    0x08, 0x00, /*  u8  ep_wMaxPacketSize; 8 bytes */
+    0xFF,       /*  u8  ep_bInterval; 32ms */
+
+    /* class-specific interrupt endpoint */
+    0x05,       /*  u8  ep_bLenght; */
+    0x25,       /*  u8  ep_bDescriptorType; CS_ENDPOINT */
+    0x03,       /*  u8  ep_bmAttributes; EP_INTERRUPT */
+    0x08, 0x00, /*  u8  ep_wMaxPacketSize; 8 bytes */
+
+    /* standard vs interface descriptor alternate 0 */
+    0x09,       /*  u8  bLength; */
+    0x04,       /*  u8  bDescriptorType; INTERFACE */
+    0x01,       /*  u8  bInterfaceNumber; */
+    0x00,       /*  u8  bAlternateSetting; */
+    0x01,       /*  u8  bNumEndpoints; */
+    0x0E,       /*  u8  bInterfaceClass; CC_VIDEO */
+    0x02,       /*  u8  bInterfaceSubClass; SC_VIDEO_STREAMING */
+    0x00,       /*  u8  bInterfaceProtocol; PC_PROTOCOL_UNDEFINED */
+    0x00,       /*  u8  iInterface; Unused */
+
+    /* class-specific vs header descriptor input alternate 0 */
+    0x0E,       /*  u8  bLength; */
+    0x24,       /*  u8  bDescriptorType; CS_INTERFACE */
+    0x01,       /*  u8  bDescriptorSubtype; VS_INPUT_HEADER */
+    0x01,       /*  u8  bNumFormats; */
+    0x46, 0x00, /*  u8  wTotalLength; */
+    0x82,       /*  u8  bEndpointAddress; */
+    0x00,       /*  u8  bmInfo; */
+    0x03,       /*  u8  bTerminalLink; */
+    0x00,       /*  u8  bStillCaptureMethod; */
+    0x00,       /*  u8  bTriggerSupport; */
+    0x00,       /*  u8  bTriggerUsage; */
+    0x01,       /*  u8  bControlSize; */
+    0x00,       /*  u8  bmaControls; */
+
+    /* class-specific vs format descriptor alternate 0 */
+    0x0B,       /*  u8  bLength; */
+    0x24,       /*  u8  bDescriptorType; CS_INTERFACE */
+    0x06,       /*  u8  bDescriptorSubtype; VS_FORMAT_MJPEG */
+    0x01,       /*  u8  bFormatIndex; */
+    0x01,       /*  u8  bNumFrameDescriptors; */
+    0x01,       /*  u8  bmFlags; */
+    0x01,       /*  u8  bDefaultFrameIndex; */
+    0x00,       /*  u8  bAspectRatioX; */
+    0x00,       /*  u8  bAspectRatioY; */
+    0x02,       /*  u8  bmInterlaceFlags; */
+    0x00,       /*  u8  bCopyProtect; */
+
+    /* class-specific vs frame descriptor alternate 0 */
+    0x26,       /*  u8  bLength; */
+    0x24,       /*  u8  bDescriptorType; CS_INTERFACE */
+    0x07,       /*  u8  bDescriptorSubtype; VS_FRAME_MJPEG */
+    0x01,       /*  u8  bFrameIndex; */
+    0x01,       /*  u8  bmCapabilities; */
+    0x40, 0x01, /*  u8  wWidth; 320 */
+    0xF0, 0x00, /*  u8  wHeight; 240 */
+    0x00, 0xEC,
+    0x0D, 0x00, /*  u32 dwMinBitRate; */
+    0x00, 0xEC,
+    0x0D, 0x00, /*  u32 dwMaxBitRate; */
+    0x72, 0xCE,
+    0x00, 0x00, /*  u32 dwMaxVideoFrameBufSize; */
+    0x2A, 0x2C,
+    0x0A, 0x00, /*  u32 dwDefaultFrameInterval; */
+    0x00,       /*  u8  bFrameIntervalType;    */
+    0x2A, 0x2C,
+    0x0A, 0x00, /*  u32 dwMinFrameInterval; */
+    0x2A, 0x2C,
+    0x0A, 0x00, /*  u32 dwMaxFrameInterval; */
+    0x00, 0x00,
+    0x00, 0x00, /*  u32 dwFrameIntervalStep; */
+
+    /* standard vs isochronous video data endpoint descriptor */
+    0x07,       /*  u8  bLength; */
+    0x05,       /*  u8  bDescriptorType; */
+    0x82,       /*  u8  bEndpointAddress; IN endpoint 2 */
+    0x02,       /*  u8  bmAttributes; Isochronous transfer, asynchronous sync */
+    0x40, 0x00, /*  u16 wMaxPacketSize; 510 bytes */
+    0x00        /*  u8  bInterval; */
 };
 
 static void get_frame_read(void)
 {
-	DPRINTF("Getting frame.\n");
-	frame = frame_start;
-	frame_length = read(v4l2_fd, frame, frame_max_length);
-	
-	if(frame_length == -1)
-	{
-		DPRINTF("Error while reading frame.\n");
-		frame_length = 0;
-	}
-	else
-	{
-		frame_id = frame_id ^ 1;
-		first_bulk_packet = 1;
-		frame_remaining_bytes = frame_length;
-		DPRINTF("Got a frame of %d bytes.\n", frame_length);
-	}
-	
-	return;
+    DPRINTF("Getting frame.\n");
+    frame = frame_start;
+    frame_length = read(v4l2_fd, frame, frame_max_length);
+
+    if (frame_length == -1) {
+        DPRINTF("Error while reading frame.\n");
+        frame_length = 0;
+    } else {
+        frame_id = frame_id ^ 1;
+        first_bulk_packet = 1;
+        frame_remaining_bytes = frame_length;
+        DPRINTF("Got a frame of %d bytes.\n", frame_length);
+    }
+
+    return;
 }
 
 static void usb_uvc_handle_reset(USBDevice *dev)
 {
-	DPRINTF("Reset called\n");
+    DPRINTF("Reset called\n");
 }
 
 static int usb_uvc_handle_control(USBDevice *dev, USBPacket *p, int request,
                                   int value, int index, int length,
                                   uint8_t *data)
 {
-	int ret = 0;
-	USBUVCState *s = (USBUVCState *)dev;
-	
-	DPRINTF("Control called\n");
-	//	DPRINTF("Request: 0x%08X\n", request);
-	//	DPRINTF("Value: 0x%08X\n", value);
-	//	DPRINTF("Index: 0x%08X\n", index);
-	//	DPRINTF("Length: 0x%08X\n", length);
-	
-	switch(request)
-	{
-		case DeviceRequest | USB_REQ_GET_STATUS:
-			DPRINTF("USB Request: Get Status\n");
-			data[0] = (1 << USB_DEVICE_SELF_POWERED) |
-            (dev->remote_wakeup << USB_DEVICE_REMOTE_WAKEUP);
-			data[1] = 0x00;
-			ret = 2;
-			break;
-		case DeviceOutRequest | USB_REQ_CLEAR_FEATURE:
-			DPRINTF("USB Request: Clear feature\n");
-			if (value == USB_DEVICE_REMOTE_WAKEUP) {
-				DPRINTF("USB Request: Unset remote wakeup\n");
-				dev->remote_wakeup = 0;
-			} else {
-				goto fail;
-			}
-			ret = 0;
-			break;
-		case DeviceOutRequest | USB_REQ_SET_FEATURE:
-			DPRINTF("USB Request: Set feature\n");
-			if (value == USB_DEVICE_REMOTE_WAKEUP) {
-				DPRINTF("USB Request: Set remote wakeup\n");
-				dev->remote_wakeup = 1;
-			} else {
-				goto fail;
-			}
-			ret = 0;
-			break;
-		case DeviceOutRequest | USB_REQ_SET_ADDRESS:
-			DPRINTF("USB Request: Set address to 0x%08X\n", value);
-			dev->addr = value;
-			ret = 0;
-			break;			
-		case DeviceRequest | USB_REQ_GET_DESCRIPTOR:
-			DPRINTF("USB Request: Get descriptor\n");
-			switch(value >> 8) {
-				case USB_DT_DEVICE:
-					DPRINTF("USB Request: Get device descriptor\n");
-					memcpy(data, qemu_uvc_dev_descriptor,
-						   sizeof(qemu_uvc_dev_descriptor));
-					ret = sizeof(qemu_uvc_dev_descriptor);
-					break;
-				case USB_DT_CONFIG:
-					DPRINTF("USB Request: Get configuration descriptor\n");
-					memcpy(data, qemu_uvc_config_descriptor,
-						   sizeof(qemu_uvc_config_descriptor));
-					ret = sizeof(qemu_uvc_config_descriptor);
-					break;
-				case USB_DT_STRING:
-					DPRINTF("USB Request: Get device strings\n");
-					switch(value & 0xff) {
-						case 0:
-							DPRINTF("USB Request: Get language IDs\n");
-							/* language ids */
-							data[0] = 4;
-							data[1] = 3;
-							data[2] = 0x09;
-							data[3] = 0x04;
-							ret = 4;
-							break;
-						case 1:
-							/* vendor description */
-							DPRINTF("USB Request: Get vendor string\n");
-							ret = set_usb_string(data, "QEMU " QEMU_VERSION);
-							break;
-						case 2:
-							/* product description */
-							DPRINTF("USB Request: Get product string\n");
-							ret = set_usb_string(data, "QEMU USB VIDEO CLASS 2");
-							break;
-						case 3:
-							/* serial number */
-							DPRINTF("USB Request: Get serial number string\n");
-							ret = set_usb_string(data, "1");
-							break;
-						default:
-							goto fail;
-					}
-					break;
-				default:
-					goto fail;
-			}
-			break;
-		case DeviceRequest | USB_REQ_GET_CONFIGURATION:
-			DPRINTF("USB Request: Get configuration\n");
-			data[0] = 1;
-			ret = 1;
-			break;
-		case DeviceOutRequest | USB_REQ_SET_CONFIGURATION:
-			DPRINTF("USB Request: Set configuration\n");
-			ret = 0;
-			break;
-		case DeviceRequest | USB_REQ_GET_INTERFACE:
-			DPRINTF("USB Request: Get interface\n");
-			data[0] = 0;
-			ret = 1;
-			break;
-		case DeviceOutRequest | USB_REQ_SET_INTERFACE:
-			DPRINTF("USB Request: Set interface\n");
-			ret = 0;
-			break;
-		case EndpointOutRequest | USB_REQ_CLEAR_FEATURE:
-			DPRINTF("USB Request: Clear endpoint\n");
-			ret = 0;
-			break;
-		case InterfaceOutRequest | USB_REQ_SET_INTERFACE:
-			DPRINTF("USB Request: Set interface\n");
-			ret = 0;
-			break;
-			/* Class specific requests.  */
-		case UVCGetVideoControl | USB_UVC_GET_CUR:
-			ret = 0;
-			
-			if((index&0xFF) == 0x01 && ((value&0xFF00) == 0x0100 || (value&0xFF00) == 0x0200))
-			{
-				DPRINTF("USB Request: Get video control current setting attribute for interface %d\n", index&0xFF);
-				if((value&0xFF00) == 0x0100)
-					DPRINTF("\tVS_PROBE_CONTROL\n");
-				else
-					DPRINTF("\tVS_COMMIT_CONTROL\n");
-				
-				if(length != 26)
-				{
-					DPRINTF("USB Request: Requested %d bytes, expected 26 bytes\n", length);
-					goto fail;
-				}
-				
-				data[0] = 0; // bmHint
-				data[1] = 0;
-				data[2] = 1; // bFormatIndex
-				data[3] = 1; // bFrameIndex
-				data[4] = 0x2A; // dwFrameInterval
-				data[5] = 0x2C;
-				data[6] = 0x0A;
-				data[7] = 0x00;
-				data[8] = 0; // wKeyFrameRate
-				data[9] = 0;
-				data[10] = 0; // wPFrameRate
-				data[11] = 0;
-				data[12] = 0; // wCompQuality
-				data[13] = 0;
-				data[14] = 1; // wCompWindowSize
-				data[15] = 0;
-				data[16] = 0x20; // wDelay
-				data[17] = 0;
-				data[18] = 0x72; // dwMaxVideoFrameSize
-				data[19] = 0xCE;
-				data[20] = 0x00;
-				data[21] = 0x00;
-				data[22] = 0x72; // dwMaxPayloadTransferSize
-				data[23] = 0xCE;
-				data[24] = 0x00;
-				data[25] = 0x00;
-				ret = 26;
-			}
-			else if((index&0xFF00) == 0x0400 && (value&0xFF00) == 0x0100) // Setting input
-			{
-				DPRINTF("USB Request: Asking for current input\n");
-				if(length != 1)
-				{
-					DPRINTF("USB Request: Requested %d bytes, expected 1 byte\n", length);
-					goto fail;
-				}
-				
-				data[0] = s->current_input;
-				ret = 1;
-			}
-			else if((index&0xFF00) == 0x0500 && (value&0xFF00) == 0x0200) // PU_BRIGHTNESS_CONTROL of PROCESSING_UNIT
-			{
-				DPRINTF("USB Resquest: Asking for current brightness\n");
-				if(length != 2)
-				{
-					DPRINTF("USB Request: Requested %d bytes, expected 2 bytes\n", length);
-					goto fail;
-				}
-				
-				data[0] = 1;
-				data[1] = 0;
-				ret = 2;
-			}
-			else
-				goto fail;
-			break;
-		case UVCGetVideoControl | USB_UVC_GET_MIN:
-			ret = 0;
-			
-			if((index&0xFF) == 0x01 && ((value&0xFF00) == 0x0100 || (value&0xFF00) == 0x0200))
-			{
-				DPRINTF("USB Request: Get video control minimum setting attribute for interface %d\n", index&0xFF);
-				
-				if(length != 26)
-				{
-					DPRINTF("USB Request: Requested %d bytes, expected 26 bytes\n", length);
-					goto fail;
-				}
-				
-				data[0] = 0; // bmHint
-				data[1] = 0;
-				data[2] = 1; // bFormatIndex
-				data[3] = 1; // bFrameIndex
-				data[4] = 0x2A; // dwFrameInterval
-				data[5] = 0x2C;
-				data[6] = 0x0A;
-				data[7] = 0x00;
-				data[8] = 0; // wKeyFrameRate
-				data[9] = 0;
-				data[10] = 0; // wPFrameRate
-				data[11] = 0;
-				data[12] = 0; // wCompQuality
-				data[13] = 0;
-				data[14] = 1; // wCompWindowSize
-				data[15] = 0;
-				data[16] = 0x20; // wDelay
-				data[17] = 0;
-				data[18] = 0x72; // dwMaxVideoFrameSize
-				data[19] = 0xCE;
-				data[20] = 0x00;
-				data[21] = 0x00;
-				data[22] = 0x72; // dwMaxPayloadTransferSize
-				data[23] = 0xCE;
-				data[24] = 0x00;
-				data[25] = 0x00;
-				ret = 26;
-			}
-			else if((index&0xFF00) == 0x0400 && (value&0xFF00) == 0x0100) // Setting input
-			{
-				DPRINTF("USB Request: Asking for minimum input\n");
-				if(length != 1)
-				{
-					DPRINTF("USB Request: Requested %d bytes, expected 1 byte\n", length);
-					goto fail;
-				}
-				
-				data[0] = 0;
-				ret = 1;
-			}
-			else if((index&0xFF00) == 0x0500 && (value&0xFF00) == 0x0200) // PU_BRIGHTNESS_CONTROL of PROCESSING_UNIT
-			{
-				DPRINTF("USB Resquest: Asking for minimum brightness\n");
-				if(length != 2)
-				{
-					DPRINTF("USB Request: Requested %d bytes, expected 2 bytes\n", length);
-					goto fail;
-				}
-				
-				data[0] = 1;
-				data[1] = 0;
-				ret = 2;
-			}
-			else
-				goto fail;
-			break;
-		case UVCGetVideoControl | USB_UVC_GET_MAX:
-			if((index&0xFF) == 0x01 && ((value&0xFF00) == 0x0100 || (value&0xFF00) == 0x0200))
-			{
-				DPRINTF("USB Request: Get video control maximum setting attribute for interface %d\n", index&0xFF);
-				
-				if(length != 26)
-				{
-					DPRINTF("USB Request: Requested %d bytes, expected 26 bytes\n", length);
-					goto fail;
-				}
-				
-				data[0] = 0; // bmHint
-				data[1] = 0;
-				data[2] = 1; // bFormatIndex
-				data[3] = 1; // bFrameIndex
-				data[4] = 0x2A; // dwFrameInterval
-				data[5] = 0x2C;
-				data[6] = 0x0A;
-				data[7] = 0x00;
-				data[8] = 0; // wKeyFrameRate
-				data[9] = 0;
-				data[10] = 0; // wPFrameRate
-				data[11] = 0;
-				data[12] = 0; // wCompQuality
-				data[13] = 0;
-				data[14] = 1; // wCompWindowSize
-				data[15] = 0;
-				data[16] = 0x20; // wDelay
-				data[17] = 0;
-				data[18] = 0x72; // dwMaxVideoFrameSize
-				data[19] = 0xCE;
-				data[20] = 0x00;
-				data[21] = 0x00;
-				data[22] = 0x72; // dwMaxPayloadTransferSize
-				data[23] = 0xCE;
-				data[24] = 0x00;
-				data[25] = 0x00;
-				ret = 26;
-			}
-			else if((index&0xFF00) == 0x0400 && (value&0xFF00) == 0x0100) // Setting input
-			{
-				DPRINTF("USB Request: Asking maximum input\n");
-				if(length != 1)
-				{
-					DPRINTF("USB Request: Requested %d bytes, expected 1 byte\n", length);
-					goto fail;
-				}
-				
-				data[0] = 1;
-				ret = 1;
-			}					
-			else if((index&0xFF00) == 0x0500 && (value&0xFF00) == 0x0200) // PU_BRIGHTNESS_CONTROL of PROCESSING_UNIT
-			{
-				DPRINTF("USB Resquest: Asking for maximum brightness\n");
-				if(length != 2)
-				{
-					DPRINTF("USB Request: Requested %d bytes, expected 2 bytes\n", length);
-					goto fail;
-				}
-				
-				data[0] = 1;
-				data[1] = 0;
-				ret = 2;
-			}
-			else
-				goto fail;
-			break;
-		case UVCGetVideoControl | USB_UVC_GET_DEF:		
-			if((index&0xFF) == 0x01 && ((value&0xFF00) == 0x0100 || (value&0xFF00) == 0x0200))
-			{
-				DPRINTF("USB Request: Get video control default setting attribute for interface %d\n", index&0xFF);
-				
-				if(length != 26)
-				{
-					DPRINTF("USB Request: Requested %d bytes, expected 26 bytes\n", length);
-					goto fail;
-				}
-				
-				data[0] = 0; // bmHint
-				data[1] = 0;
-				data[2] = 1; // bFormatIndex
-				data[3] = 1; // bFrameIndex
-				data[4] = 0x2A; // dwFrameInterval
-				data[5] = 0x2C;
-				data[6] = 0x0A;
-				data[7] = 0x00;
-				data[8] = 0; // wKeyFrameRate
-				data[9] = 0;
-				data[10] = 0; // wPFrameRate
-				data[11] = 0;
-				data[12] = 0; // wCompQuality
-				data[13] = 0;
-				data[14] = 1; // wCompWindowSize
-				data[15] = 0;
-				data[16] = 0x20; // wDelay
-				data[17] = 0;
-				data[18] = 0x72; // dwMaxVideoFrameSize
-				data[19] = 0xCE;
-				data[20] = 0x00;
-				data[21] = 0x00;
-				data[22] = 0x72; // dwMaxPayloadTransferSize
-				data[23] = 0xCE;
-				data[24] = 0x00;
-				data[25] = 0x00;
-				ret = 26;
-			}
-			else if((index&0xFF00) == 0x0400 && (value&0xFF00) == 0x0100) // Setting input
-			{
-				DPRINTF("USB Request: Asking for default input\n");
-				if(length != 1)
-				{
-					DPRINTF("USB Request: Requested %d bytes, expected 1 byte\n", length);
-					goto fail;
-				}
-				
-				data[0] = 0;
-				ret = 1;
-			}
-			else if((index&0xFF00) == 0x0500 && (value&0xFF00) == 0x0200) // PU_BRIGHTNESS_CONTROL of PROCESSING_UNIT
-			{
-				DPRINTF("USB Resquest: Asking for default brightness\n");
-				if(length != 2)
-				{
-					DPRINTF("USB Request: Requested %d bytes, expected 2 bytes\n", length);
-					goto fail;
-				}
-				
-				data[0] = 1;
-				data[1] = 0;
-				ret = 2;
-			}
-			else
-				goto fail;
-			break;
-		case UVCSetVideoControl | USB_UVC_SET_CUR:
-			DPRINTF("USB Request: Set video control setting attribute for interface %d\n", index&0xFF);
-			
-			ret = 0;
-			
-			if((index&0xFF) == 0x01 && ((value&0xFF00) == 0x0100 || (value&0xFF00) == 0x0200))
-			{
-				if((value&0xFF00) == 0x0100)
-					DPRINTF("\tVS_PROBE_CONTROL\n");
-				else
-					DPRINTF("\tVS_COMMIT_CONTROL\n");
-				
-				if(length != 26)
-				{
-					DPRINTF("USB Request: Requested %d bytes, expected 26 bytes\n", length);
-					goto fail;
-				}
-				
-				DPRINTF("\tbmHint = 0x%02X%02X\n", data[1], data[0]);
-				DPRINTF("\tbFormatIndex = %d\n", data[2]);
-				DPRINTF("\tbFrameIndex = %d\n", data[3]);
-				DPRINTF("\tdwFrameInterval = 0x%02X%02X%02X%02X\n", data[7], data[6], data[5], data[4]);
-				DPRINTF("\twKeyFrameRate = 0x%02X%02X\n", data[9], data[8]);
-				DPRINTF("\twPFrameRate = 0x%02X%02X\n", data[11], data[10]);
-				DPRINTF("\twCompQuality = 0x%02X%02X\n", data[13], data[12]);
-				DPRINTF("\twCompWindowSize = 0x%02X%02X\n", data[15], data[14]);
-				DPRINTF("\twDelay = 0x%02X%02X\n", data[17], data[16]);
-				DPRINTF("\tdwMaxVideoFrameSize= 0x%02X%02X%02X%02X\n", data[21], data[20], data[19], data[18]);
-				DPRINTF("\tdwMaxPayloadTransferSize= 0x%02X%02X%02X%02X\n", data[25], data[24], data[23], data[22]);
-				
-				frame = frame_start;
-				frame_remaining_bytes = frame_length;
-				first_bulk_packet = 1;
-				
-				ret = 26;
-			}
-			else if((index&0xFF00) == 0x0400 && (value&0xFF00) == 0x0100) // Setting input
-			{
-				DPRINTF("Setting input to %d\n", data[0]);
-				if(length != 1)
-				{
-					DPRINTF("USB Request: Requested %d bytes, expected 1 byte\n", length);
-					goto fail;
-				}
-				
-				s->current_input = data[0];
-				ret = 1;
-			}
-			else if((index&0xFF00) == 0x0500 && (value&0xFF00) == 0x0200) // PU_BRIGHTNESS_CONTROL of PROCESSING_UNIT
-			{
-				DPRINTF("USB Resquest: Setting brightness, value stays the same\n");
-				if(length != 2)
-				{
-					DPRINTF("USB Request: Requested %d bytes, expected 2 bytes\n", length);
-					goto fail;
-				}
-				
-				ret = 2;
-			}
-			else
-				goto fail;
-			break;
-		case UVCGetVideoControl | USB_UVC_GET_RES:
-			if((index&0xFF00) == 0x0500 && (value&0xFF00) == 0x0200) // PU_BRIGHTNESS_CONTROL of PROCESSING_UNIT
-			{
-				DPRINTF("USB Resquest: Asking for brightness resolution\n");
-				if(length != 2)
-				{
-					DPRINTF("USB Request: Requested %d bytes, expected 2 bytes\n", length);
-					goto fail;
-				}
-				
-				data[0] = 1;
-				data[1] = 0;
-				ret = 2;
-			}
-			else
-				goto fail;
-			break;
-		default:
-		fail:
-			DPRINTF("USB Request: Unhandled control request\n");
-			DPRINTF("\tRequest: 0x%08X\n", request);
-			DPRINTF("\tValue: 0x%08X\n", value);
-			DPRINTF("\tIndex: 0x%08X\n", index);
-			DPRINTF("\tLength: 0x%08X\n", length);
-			ret = USB_RET_STALL;
-			break;
+    int ret = 0;
+    USBUVCState *s = (USBUVCState *)dev;
+
+    DPRINTF("Control called\n");
+    /*    DPRINTF("Request: 0x%08X\n", request);
+          DPRINTF("Value: 0x%08X\n", value);
+          DPRINTF("Index: 0x%08X\n", index);
+          DPRINTF("Length: 0x%08X\n", length); */
+
+    switch (request) {
+    case DeviceRequest | USB_REQ_GET_STATUS:
+        DPRINTF("USB Request: Get Status\n");
+        data[0] = (1 << USB_DEVICE_SELF_POWERED) |
+        (dev->remote_wakeup << USB_DEVICE_REMOTE_WAKEUP);
+        data[1] = 0x00;
+        ret = 2;
+        break;
+    case DeviceOutRequest | USB_REQ_CLEAR_FEATURE:
+        DPRINTF("USB Request: Clear feature\n");
+        if (value == USB_DEVICE_REMOTE_WAKEUP) {
+            DPRINTF("USB Request: Unset remote wakeup\n");
+            dev->remote_wakeup = 0;
+        } else {
+            goto fail;
+        }
+        ret = 0;
+        break;
+    case DeviceOutRequest | USB_REQ_SET_FEATURE:
+        DPRINTF("USB Request: Set feature\n");
+        if (value == USB_DEVICE_REMOTE_WAKEUP) {
+            DPRINTF("USB Request: Set remote wakeup\n");
+            dev->remote_wakeup = 1;
+        } else {
+            goto fail;
+        }
+        ret = 0;
+        break;
+    case DeviceOutRequest | USB_REQ_SET_ADDRESS:
+        DPRINTF("USB Request: Set address to 0x%08X\n", value);
+        dev->addr = value;
+        ret = 0;
+        break;
+    case DeviceRequest | USB_REQ_GET_DESCRIPTOR:
+        DPRINTF("USB Request: Get descriptor\n");
+        switch (value >> 8) {
+        case USB_DT_DEVICE:
+            DPRINTF("USB Request: Get device descriptor\n");
+            memcpy(data, qemu_uvc_dev_descriptor,
+                    sizeof(qemu_uvc_dev_descriptor));
+            ret = sizeof(qemu_uvc_dev_descriptor);
+            break;
+        case USB_DT_CONFIG:
+            DPRINTF("USB Request: Get configuration descriptor\n");
+            memcpy(data, qemu_uvc_config_descriptor,
+                    sizeof(qemu_uvc_config_descriptor));
+            ret = sizeof(qemu_uvc_config_descriptor);
+            break;
+        case USB_DT_STRING:
+            DPRINTF("USB Request: Get device strings\n");
+            switch (value & 0xff) {
+            case 0:
+                DPRINTF("USB Request: Get language IDs\n");
+                /* language ids */
+                data[0] = 4;
+                data[1] = 3;
+                data[2] = 0x09;
+                data[3] = 0x04;
+                ret = 4;
+                break;
+            case 1:
+                /* vendor description */
+                DPRINTF("USB Request: Get vendor string\n");
+                ret = set_usb_string(data, "QEMU " QEMU_VERSION);
+                break;
+            case 2:
+                /* product description */
+                DPRINTF("USB Request: Get product string\n");
+                ret = set_usb_string(data, "QEMU USB VIDEO CLASS 2");
+                break;
+            case 3:
+                /* serial number */
+                DPRINTF("USB Request: Get serial number string\n");
+                ret = set_usb_string(data, "1");
+                break;
+            default:
+                goto fail;
+            }
+            break;
+        default:
+            goto fail;
+        }
+        break;
+    case DeviceRequest | USB_REQ_GET_CONFIGURATION:
+        DPRINTF("USB Request: Get configuration\n");
+        data[0] = 1;
+        ret = 1;
+        break;
+    case DeviceOutRequest | USB_REQ_SET_CONFIGURATION:
+        DPRINTF("USB Request: Set configuration\n");
+        ret = 0;
+        break;
+    case DeviceRequest | USB_REQ_GET_INTERFACE:
+        DPRINTF("USB Request: Get interface\n");
+        data[0] = 0;
+        ret = 1;
+        break;
+    case DeviceOutRequest | USB_REQ_SET_INTERFACE:
+        DPRINTF("USB Request: Set interface\n");
+        ret = 0;
+        break;
+    case EndpointOutRequest | USB_REQ_CLEAR_FEATURE:
+        DPRINTF("USB Request: Clear endpoint\n");
+        ret = 0;
+        break;
+    case InterfaceOutRequest | USB_REQ_SET_INTERFACE:
+        DPRINTF("USB Request: Set interface\n");
+        ret = 0;
+        break;
+        /* Class specific requests.  */
+    case UVCGetVideoControl | USB_UVC_GET_CUR:
+        ret = 0;
+
+        if (((index & 0xFF) == 0x01) && (((value & 0xFF00) == 0x0100) ||
+                                            ((value & 0xFF00) == 0x0200))) {
+            DPRINTF("USB Request: Get video control current setting "
+                    "attribute for interface %d\n", index & 0xFF);
+            if ((value & 0xFF00) == 0x0100) {
+                DPRINTF("\tVS_PROBE_CONTROL\n");
+            } else {
+                DPRINTF("\tVS_COMMIT_CONTROL\n");
+            }
+            if (length != 26) {
+                DPRINTF("USB Request: Requested %d bytes, expected 26 "
+                        "bytes\n", length);
+                goto fail;
+            }
+
+            data[0] = 0; /* bmHint */
+            data[1] = 0;
+            data[2] = 1; /* bFormatIndex */
+            data[3] = 1; /* bFrameIndex */
+            data[4] = 0x2A; /* dwFrameInterval */
+            data[5] = 0x2C;
+            data[6] = 0x0A;
+            data[7] = 0x00;
+            data[8] = 0; /* wKeyFrameRate */
+            data[9] = 0;
+            data[10] = 0; /* wPFrameRate */
+            data[11] = 0;
+            data[12] = 0; /* wCompQuality */
+            data[13] = 0;
+            data[14] = 1; /* wCompWindowSize */
+            data[15] = 0;
+            data[16] = 0x20; /* wDelay */
+            data[17] = 0;
+            data[18] = 0x72; /* dwMaxVideoFrameSize */
+            data[19] = 0xCE;
+            data[20] = 0x00;
+            data[21] = 0x00;
+            data[22] = 0x72; /* dwMaxPayloadTransferSize */
+            data[23] = 0xCE;
+            data[24] = 0x00;
+            data[25] = 0x00;
+            ret = 26;
+        } else if (((index & 0xFF00) == 0x0400) &&
+                    ((value & 0xFF00) == 0x0100)) {
+            /* Setting input */
+            DPRINTF("USB Request: Asking for current input\n");
+            if (length != 1) {
+                DPRINTF("USB Request: Requested %d bytes, expected 1 "
+                        "byte\n", length);
+                goto fail;
+            }
+
+            data[0] = s->current_input;
+            ret = 1;
+        } else if (((index & 0xFF00) == 0x0500) &&
+                    ((value & 0xFF00) == 0x0200)) {
+            /* PU_BRIGHTNESS_CONTROL of PROCESSING_UNIT */
+            DPRINTF("USB Resquest: Asking for current brightness\n");
+            if (length != 2) {
+                DPRINTF("USB Request: Requested %d bytes, expected 2 "
+                        "bytes\n", length);
+                goto fail;
+            }
+
+            data[0] = 1;
+            data[1] = 0;
+            ret = 2;
+        } else {
+            goto fail;
+        }
+        break;
+    case UVCGetVideoControl | USB_UVC_GET_MIN:
+        ret = 0;
+
+        if (((index & 0xFF) == 0x01) && (((value & 0xFF00) == 0x0100) ||
+                                            ((value & 0xFF00) == 0x0200))) {
+            DPRINTF("USB Request: Get video control minimum setting "
+                    "attribute for interface %d\n", index&0xFF);
+
+            if (length != 26) {
+                DPRINTF("USB Request: Requested %d bytes, expected 26 "
+                        "bytes\n", length);
+                goto fail;
+            }
+
+            data[0] = 0; /* bmHint */
+            data[1] = 0;
+            data[2] = 1; /* bFormatIndex */
+            data[3] = 1; /* bFrameIndex */
+            data[4] = 0x2A; /* dwFrameInterval */
+            data[5] = 0x2C;
+            data[6] = 0x0A;
+            data[7] = 0x00;
+            data[8] = 0; /* wKeyFrameRate */
+            data[9] = 0;
+            data[10] = 0; /* wPFrameRate */
+            data[11] = 0;
+            data[12] = 0; /* wCompQuality */
+            data[13] = 0;
+            data[14] = 1; /* wCompWindowSize */
+            data[15] = 0;
+            data[16] = 0x20; /* wDelay */
+            data[17] = 0;
+            data[18] = 0x72; /* dwMaxVideoFrameSize */
+            data[19] = 0xCE;
+            data[20] = 0x00;
+            data[21] = 0x00;
+            data[22] = 0x72; /* dwMaxPayloadTransferSize */
+            data[23] = 0xCE;
+            data[24] = 0x00;
+            data[25] = 0x00;
+            ret = 26;
+        } else if ((index&0xFF00) == 0x0400 && (value&0xFF00) == 0x0100) {
+            /* Setting input */
+            DPRINTF("USB Request: Asking for minimum input\n");
+            if (length != 1) {
+                DPRINTF("USB Request: Requested %d bytes, expected 1 "
+                        "byte\n", length);
+                goto fail;
+            }
+
+            data[0] = 0;
+            ret = 1;
+        } else if ((index&0xFF00) == 0x0500 && (value&0xFF00) == 0x0200) {
+            /* PU_BRIGHTNESS_CONTROL of PROCESSING_UNIT */
+            DPRINTF("USB Resquest: Asking for minimum brightness\n");
+            if (length != 2) {
+                DPRINTF("USB Request: Requested %d bytes, expected 2 "
+                        "bytes\n", length);
+                goto fail;
+            }
+
+            data[0] = 1;
+            data[1] = 0;
+            ret = 2;
+        } else {
+            goto fail;
+        }
+        break;
+    case UVCGetVideoControl | USB_UVC_GET_MAX:
+        if (((index & 0xFF) == 0x01) && (((value & 0xFF00) == 0x0100) ||
+                                            ((value & 0xFF00) == 0x0200))) {
+            DPRINTF("USB Request: Get video control maximum setting "
+                    "attribute for interface %d\n", index & 0xFF);
+
+            if (length != 26) {
+                DPRINTF("USB Request: Requested %d bytes, expected 26 "
+                        "bytes\n", length);
+                goto fail;
+            }
+
+            data[0] = 0; /* bmHint */
+            data[1] = 0;
+            data[2] = 1; /* bFormatIndex */
+            data[3] = 1; /* bFrameIndex */
+            data[4] = 0x2A; /* dwFrameInterval */
+            data[5] = 0x2C;
+            data[6] = 0x0A;
+            data[7] = 0x00;
+            data[8] = 0; /* wKeyFrameRate */
+            data[9] = 0;
+            data[10] = 0; /* wPFrameRate */
+            data[11] = 0;
+            data[12] = 0; /* wCompQuality */
+            data[13] = 0;
+            data[14] = 1; /* wCompWindowSize */
+            data[15] = 0;
+            data[16] = 0x20; /* wDelay */
+            data[17] = 0;
+            data[18] = 0x72; /* dwMaxVideoFrameSize */
+            data[19] = 0xCE;
+            data[20] = 0x00;
+            data[21] = 0x00;
+            data[22] = 0x72; /* dwMaxPayloadTransferSize */
+            data[23] = 0xCE;
+            data[24] = 0x00;
+            data[25] = 0x00;
+            ret = 26;
+        } else if (((index & 0xFF00) == 0x0400) &&
+                    ((value & 0xFF00) == 0x0100)) {
+            /* Setting input (*/
+            DPRINTF("USB Request: Asking maximum input\n");
+            if (length != 1) {
+                DPRINTF("USB Request: Requested %d bytes, expected 1 "
+                        "byte\n", length);
+                goto fail;
+            }
+
+            data[0] = 1;
+            ret = 1;
+        } else if ((index&0xFF00) == 0x0500 && (value&0xFF00) == 0x0200) {
+            /* PU_BRIGHTNESS_CONTROL of PROCESSING_UNIT */
+            DPRINTF("USB Resquest: Asking for maximum brightness\n");
+            if (length != 2) {
+                DPRINTF("USB Request: Requested %d bytes, expected 2 "
+                        "bytes\n", length);
+                goto fail;
+            }
+
+            data[0] = 1;
+            data[1] = 0;
+            ret = 2;
+        } else {
+            goto fail;
+        }
+        break;
+    case UVCGetVideoControl | USB_UVC_GET_DEF:
+        if (((index & 0xFF) == 0x01) &&
+            ((value & 0xFF00) == 0x0100 || (value & 0xFF00) == 0x0200)) {
+            DPRINTF("USB Request: Get video control default setting "
+                    "attribute for interface %d\n", index&0xFF);
+
+            if (length != 26) {
+                DPRINTF("USB Request: Requested %d bytes, expected 26 "
+                        "bytes\n", length);
+                goto fail;
+            }
+
+            data[0] = 0; /* bmHint */
+            data[1] = 0;
+            data[2] = 1; /* bFormatIndex */
+            data[3] = 1; /* bFrameIndex */
+            data[4] = 0x2A; /* dwFrameInterval */
+            data[5] = 0x2C;
+            data[6] = 0x0A;
+            data[7] = 0x00;
+            data[8] = 0; /* wKeyFrameRate */
+            data[9] = 0;
+            data[10] = 0; /* wPFrameRate */
+            data[11] = 0;
+            data[12] = 0; /* wCompQuality */
+            data[13] = 0;
+            data[14] = 1; /* wCompWindowSize */
+            data[15] = 0;
+            data[16] = 0x20; /* wDelay */
+            data[17] = 0;
+            data[18] = 0x72; /* dwMaxVideoFrameSize */
+            data[19] = 0xCE;
+            data[20] = 0x00;
+            data[21] = 0x00;
+            data[22] = 0x72; /* dwMaxPayloadTransferSize */
+            data[23] = 0xCE;
+            data[24] = 0x00;
+            data[25] = 0x00;
+            ret = 26;
+        } else if ((index&0xFF00) == 0x0400 && (value&0xFF00) == 0x0100) {
+            /* Setting input */
+            DPRINTF("USB Request: Asking for default input\n");
+            if (length != 1) {
+                DPRINTF("USB Request: Requested %d bytes, expected 1 "
+                        "byte\n", length);
+                goto fail;
+            }
+
+            data[0] = 0;
+            ret = 1;
+        } else if ((index&0xFF00) == 0x0500 && (value&0xFF00) == 0x0200) {
+            /* PU_BRIGHTNESS_CONTROL of PROCESSING_UNIT */
+            DPRINTF("USB Resquest: Asking for default brightness\n");
+            if (length != 2) {
+                DPRINTF("USB Request: Requested %d bytes, expected 2 "
+                        "bytes\n", length);
+                goto fail;
+            }
+
+            data[0] = 1;
+            data[1] = 0;
+            ret = 2;
+        } else {
+            goto fail;
+        }
+        break;
+    case UVCSetVideoControl | USB_UVC_SET_CUR:
+        DPRINTF("USB Request: Set video control setting attribute for "
+                "interface %d\n", index & 0xFF);
+
+        ret = 0;
+
+        if (((index & 0xFF) == 0x01) &&
+            ((value & 0xFF00) == 0x0100 || (value & 0xFF00) == 0x0200)) {
+            if ((value & 0xFF00) == 0x0100) {
+                DPRINTF("\tVS_PROBE_CONTROL\n");
+            } else {
+                DPRINTF("\tVS_COMMIT_CONTROL\n");
+            }
+            if (length != 26) {
+                DPRINTF("USB Request: Requested %d bytes, "
+                        "expected 26 bytes\n", length);
+                goto fail;
+            }
+
+            DPRINTF("\tbmHint = 0x%02X%02X\n", data[1], data[0]);
+            DPRINTF("\tbFormatIndex = %d\n", data[2]);
+            DPRINTF("\tbFrameIndex = %d\n", data[3]);
+            DPRINTF("\tdwFrameInterval = 0x%02X%02X%02X%02X\n",
+                    data[7], data[6], data[5], data[4]);
+            DPRINTF("\twKeyFrameRate = 0x%02X%02X\n", data[9], data[8]);
+            DPRINTF("\twPFrameRate = 0x%02X%02X\n", data[11], data[10]);
+            DPRINTF("\twCompQuality = 0x%02X%02X\n", data[13], data[12]);
+            DPRINTF("\twCompWindowSize = 0x%02X%02X\n", data[15], data[14]);
+            DPRINTF("\twDelay = 0x%02X%02X\n", data[17], data[16]);
+            DPRINTF("\tdwMaxVideoFrameSize= 0x%02X%02X%02X%02X\n",
+                    data[21], data[20], data[19], data[18]);
+            DPRINTF("\tdwMaxPayloadTransferSize= 0x%02X%02X%02X%02X\n",
+                    data[25], data[24], data[23], data[22]);
+
+            frame = frame_start;
+            frame_remaining_bytes = frame_length;
+            first_bulk_packet = 1;
+
+            ret = 26;
+        } else if ((index&0xFF00) == 0x0400 && (value&0xFF00) == 0x0100) {
+            /* Setting input */
+            DPRINTF("Setting input to %d\n", data[0]);
+            if (length != 1) {
+                DPRINTF("USB Request: Requested %d bytes, "
+                        "expected 1 byte\n", length);
+                goto fail;
+            }
+
+            s->current_input = data[0];
+            ret = 1;
+        } else if ((index&0xFF00) == 0x0500 && (value&0xFF00) == 0x0200) {
+            /* PU_BRIGHTNESS_CONTROL of PROCESSING_UNIT */
+            DPRINTF("USB Request: Setting brightness, "
+                    "value stays the same\n");
+            if (length != 2) {
+                DPRINTF("USB Request: "
+                        "Requested %d bytes, expected 2 bytes\n", length);
+                goto fail;
+            }
+
+            ret = 2;
+        } else {
+            goto fail;
+        }
+        break;
+    case UVCGetVideoControl | USB_UVC_GET_RES:
+        if ((index&0xFF00) == 0x0500 && (value&0xFF00) == 0x0200) {
+            /* PU_BRIGHTNESS_CONTROL of PROCESSING_UNIT */
+            DPRINTF("USB Resquest: Asking for brightness resolution\n");
+            if (length != 2) {
+                DPRINTF("USB Request: Requested %d bytes, "
+                        "expected 2 bytes\n", length);
+                goto fail;
+            }
+
+            data[0] = 1;
+            data[1] = 0;
+            ret = 2;
+        } else {
+            goto fail;
+        }
+        break;
+    default:
+fail:
+        DPRINTF("USB Request: Unhandled control request\n");
+        DPRINTF("\tRequest: 0x%08X\n", request);
+        DPRINTF("\tValue: 0x%08X\n", value);
+        DPRINTF("\tIndex: 0x%08X\n", index);
+        DPRINTF("\tLength: 0x%08X\n", length);
+        ret = USB_RET_STALL;
+        break;
     }
-	
-	return ret;
+
+    return ret;
 }
 
 static int usb_uvc_handle_data(USBDevice *dev, USBPacket *p)
 {
-	int ret = 0;
-	
-	//DPRINTF("Data called\n");
-	//DPRINTF("Packet ID: %d\n", p->pid);
-	//DPRINTF("Device address: %d\n", p->devaddr);
-	//DPRINTF("Device endpoint: %d\n", p->devep);
-	//DPRINTF("Data length: %d\n", p->len);
-	
-	switch (p->pid)
-	{
-		case USB_TOKEN_OUT:
-			DPRINTF("USB Data Out requested.\n");
-			break;
-		case USB_TOKEN_IN:
-			if(p->devep == 1) // IN endpoint 1 (hardware button)
-			{
-				p->data[0] = 2;
-				p->data[1] = 1;
-				p->data[2] = 0;
-				p->data[3] = 0;
-			}
-			else if(p->devep == 2) // IN endpoint 2 (video data)
-			{
-				if(first_bulk_packet)
-				{
-					p->data[0] = 2;
-					p->data[1] = 0x82 | frame_id;
-					memcpy((p->data)+2,frame,62);
-					ret = 64;
-					first_bulk_packet=0;
-					frame = frame + 62;
-					frame_remaining_bytes = frame_remaining_bytes - 62;
-				}
-				else if(frame_remaining_bytes<64)
-				{
-					memcpy(p->data,frame,frame_remaining_bytes); 
-					ret = frame_remaining_bytes;
-					get_frame_read();
-				}
-				else if(frame_remaining_bytes==64)
-				{
-					memcpy(p->data,frame,frame_remaining_bytes); 
-					ret = frame_remaining_bytes;
-					frame_remaining_bytes = 0;
-				}
-				else if(frame_remaining_bytes==0)
-				{
-					ret = 0;
-					get_frame_read();
-				}
-				else
-				{
-					memcpy(p->data,frame,64);
-					frame = frame+64;
-					frame_remaining_bytes = frame_remaining_bytes-64;
-					ret = 64;
-				}
-			}
-			else
-			{
-				DPRINTF("USB Data In requested.\n");
-				DPRINTF("Requested data from endpoint %02X\n", p->devep);
-			}
-			break;
-	    default:
-			DPRINTF("Bad token: %d\n", p->pid);
-			//fail:
-			ret = USB_RET_STALL;
-			break;
+    int ret = 0;
+
+    /* DPRINTF("Data called\n");
+       DPRINTF("Packet ID: %d\n", p->pid);
+       DPRINTF("Device address: %d\n", p->devaddr);
+       DPRINTF("Device endpoint: %d\n", p->devep);
+       DPRINTF("Data length: %d\n", p->len);
+     */
+
+    switch (p->pid) {
+    case USB_TOKEN_OUT:
+        DPRINTF("USB Data Out requested.\n");
+        break;
+    case USB_TOKEN_IN:
+        if (p->devep == 1) { /* IN endpoint 1 (hardware button) */
+            p->data[0] = 2;
+            p->data[1] = 1;
+            p->data[2] = 0;
+            p->data[3] = 0;
+        } else if (p->devep == 2) { /* IN endpoint 2 (video data) */
+            if (first_bulk_packet) {
+                p->data[0] = 2;
+                p->data[1] = 0x82 | frame_id;
+                memcpy((p->data) + 2, frame, 62);
+                ret = 64;
+                first_bulk_packet = 0;
+                frame = frame + 62;
+                frame_remaining_bytes = frame_remaining_bytes - 62;
+            } else if (frame_remaining_bytes < 64) {
+                memcpy(p->data, frame, frame_remaining_bytes);
+                ret = frame_remaining_bytes;
+                get_frame_read();
+            } else if (frame_remaining_bytes == 64) {
+                memcpy(p->data, frame, frame_remaining_bytes);
+                ret = frame_remaining_bytes;
+                frame_remaining_bytes = 0;
+            } else if (frame_remaining_bytes == 0) {
+                ret = 0;
+                get_frame_read();
+            } else {
+                memcpy(p->data, frame, 64);
+                frame = frame + 64;
+                frame_remaining_bytes = frame_remaining_bytes - 64;
+                ret = 64;
+            }
+        } else {
+            DPRINTF("USB Data In requested.\n");
+            DPRINTF("Requested data from endpoint %02X\n", p->devep);
+        }
+        break;
+    default:
+        DPRINTF("Bad token: %d\n", p->pid);
+        /* fail: */
+        ret = USB_RET_STALL;
+        break;
     }
-	
+
     return ret;
 }
 
 static void usb_uvc_handle_destroy(USBDevice *dev)
 {
-	DPRINTF("Destroy called\n");
-	close(v4l2_fd);
+    DPRINTF("Destroy called\n");
+    close(v4l2_fd);
 }
 
 static int usb_uvc_initfn(USBDevice *dev)
 {
-	struct v4l2_capability capabilities;
-	struct v4l2_input video_input;
-	struct v4l2_format v_format;
-	int video_input_index;
-	int ret_err;
-	
-	DPRINTF("Init called\n");
-	
-	USBUVCState *s = (USBUVCState *)dev;
-	
-	s->current_input = 0;
-	s->dev.speed = USB_SPEED_FULL;
-	
-	if (!s->v4l2_device) {
+    struct v4l2_capability capabilities;
+    struct v4l2_input video_input;
+    struct v4l2_format v_format;
+    int video_input_index;
+    int ret_err;
+
+    DPRINTF("Init called\n");
+
+    USBUVCState *s = (USBUVCState *)dev;
+
+    s->current_input = 0;
+    s->dev.speed = USB_SPEED_FULL;
+
+    if (!s->v4l2_device) {
         error_report("V4L2 device specification needed.\n");
         return -1;
+    } else {
+        DPRINTF("Trying to open %s\n.", s->v4l2_device);
+    }
+
+    v4l2_fd = open(s->v4l2_device, O_RDWR);
+
+    if (v4l2_fd == -1) {
+        switch (errno) {
+        case EACCES:
+            error_report("Access denied.");
+            break;
+        case EBUSY:
+            error_report("Device busy.");
+            break;
+        case ENXIO:
+            error_report("Device does not exist.");
+            break;
+        case ENOMEM:
+            error_report("Not enough memory to open device.");
+            break;
+        case EMFILE:
+            error_report("Process reached maximum files opened.");
+            break;
+        case ENFILE:
+            error_report("System reached maximum files opened.");
+            break;
+        default:
+            error_report("Unknown error %d opening device.", errno);
+            break;
+        }
+
+        return -1;
+    }
+
+    DPRINTF("Device opened correctly.\n");
+
+    DPRINTF("Querying capabilities.\n");
+
+    ret_err = ioctl(v4l2_fd, VIDIOC_QUERYCAP, &capabilities);
+
+    if (ret_err == -1) {
+        switch (errno) {
+        case EINVAL:
+            error_report("Device is not V4L2 device.\n");
+            break;
+        default:
+            error_report("Device returned unknown error %d.\n", errno);
+            break;
+        }
+
+        return -1;
+    }
+
+    DPRINTF("Device driver: %s\n", capabilities.driver);
+    DPRINTF("Device name: %s\n", capabilities.card);
+    DPRINTF("Device bus: %s\n", capabilities.bus_info);
+    DPRINTF("Driver version: %u.%u.%u\n", (capabilities.version >> 16) & 0xFF,
+                                          (capabilities.version >> 8) & 0xFF,
+                                          capabilities.version & 0xFF);
+    DPRINTF("Device capabilities: 0x%08X\n", capabilities.capabilities);
+
+    DPRINTF("Enumerating video inputs.\n");
+    memset(&video_input, 0, sizeof(video_input));
+    video_input.index = 0;
+    while ((ioctl(v4l2_fd, VIDIOC_ENUMINPUT, &video_input) == 0)) {
+        if (video_input.type == V4L2_INPUT_TYPE_CAMERA) {
+            video_input_index = video_input.index;
+            break;
+        }
+
+        video_input.index++;
+    }
+
+    DPRINTF("Setting video input to index %d\n", video_input_index);
+    ret_err = ioctl(v4l2_fd, VIDIOC_S_INPUT, &video_input_index);
+
+    if (ret_err == -1) {
+        switch (errno) {
+        case EINVAL:
+            error_report("Incorrect video input selected.\n");
+            break;
+        case EBUSY:
+            error_report("Input cannot be switched.\n");
+            break;
+        default:
+            error_report("Unknown error %d.\n", errno);
+            break;
+        }
+
+        return -1;
     }
-	else
-	{
-		DPRINTF("Trying to open %s\n.", s->v4l2_device);
-	}
-	
-	v4l2_fd = open(s->v4l2_device, O_RDWR);
-	
-	if(v4l2_fd==-1)
-	{
-		switch(errno)
-		{
-			case EACCES:
-				error_report("Access denied.");
-				break;
-			case EBUSY:
-				error_report("Device busy.");
-				break;
-			case ENXIO:
-				error_report("Device does not exist.");
-				break;
-			case ENOMEM:
-				error_report("Not enough memory to open device.");
-				break;
-			case EMFILE:
-				error_report("Process reached maximum files opened.");
-				break;
-			case ENFILE:
-				error_report("System reached maximum files opened.");
-				break;
-			default:
-				error_report("Unknown error %d opening device.", errno);
-				break;
-		}
-		
-		return -1;
-	}
-	
-	DPRINTF("Device opened correctly.\n");
-	
-	DPRINTF("Querying capabilities.\n");
-	
-	ret_err = ioctl(v4l2_fd, VIDIOC_QUERYCAP, &capabilities);
-	
-	if(ret_err==-1)
-	{
-		switch(errno)
-		{
-			case EINVAL:
-				error_report("Device is not V4L2 device.\n");
-				break;
-			default:
-				error_report("Device returned unknown error %d.\n", errno);
-				break;
-		}
-		
-		return -1;
-	}
-	
-	DPRINTF("Device driver: %s\n", capabilities.driver);
-	DPRINTF("Device name: %s\n", capabilities.card);
-	DPRINTF("Device bus: %s\n", capabilities.bus_info);
-	DPRINTF("Driver version: %u.%u.%u\n",(capabilities.version >> 16) & 0xFF,(capabilities.version >> 8) & 0xFF,	capabilities.version & 0xFF);
-	DPRINTF("Device capabilities: 0x%08X\n", capabilities.capabilities);
-	
-	DPRINTF("Enumerating video inputs.\n");
-	memset(&video_input, 0, sizeof(video_input));
-	video_input.index=0;
-	while((ioctl(v4l2_fd, VIDIOC_ENUMINPUT, &video_input)==0))
-	{
-		if(video_input.type == V4L2_INPUT_TYPE_CAMERA)
-		{
-			video_input_index = video_input.index;
-			break;
-		}
-		
-		video_input.index++;
-	}
-	
-	DPRINTF("Setting video input to index %d\n", video_input_index);
-	ret_err = ioctl(v4l2_fd, VIDIOC_S_INPUT, &video_input_index);
-	
-	if(ret_err==-1)
-	{
-		switch(errno)
-		{
-			case EINVAL:
-				error_report("Incorrect video input selected.\n");
-				break;
-			case EBUSY:
-				error_report("Input cannot be switched.\n");
-				break;
-			default:
-				error_report("Unknown error %d.\n", errno);
-				break;
-		}
-		
-		return -1;
-	}
-	
-	ioctl(v4l2_fd, VIDIOC_G_INPUT, &ret_err);
-	
-	if(ret_err==video_input_index)
-		DPRINTF("Video input correctly set.\n");
-	else
-	{
-		error_report("Some error happened while setting video input.\n");
-		return -1;
-	}
-	
-	DPRINTF("Trying to set 320x240 MJPEG.\n");
-	memset(&v_format, 0, sizeof(v_format));
-	v_format.type                = V4L2_BUF_TYPE_VIDEO_CAPTURE;
-	v_format.fmt.pix.width       = 320; 
-	v_format.fmt.pix.height      = 240;
-	v_format.fmt.pix.pixelformat = V4L2_PIX_FMT_MJPEG;
-	v_format.fmt.pix.field       = V4L2_FIELD_INTERLACED;
-	
-	ret_err = ioctl (v4l2_fd, VIDIOC_S_FMT, &v_format);
-	
-	if(ret_err == -1)
-	{
-		switch(errno)
-		{
-			case EBUSY:
-				error_report("Device busy while changing format.\n");
-				break;
-			case EINVAL:
-				error_report("Invalid format.\n");
-				break;
-			default:
-				error_report("Unknown error %d while changing format.\n", errno);
-				break;
-		}
-		
-		return -1;
-	}
-
-	frame_max_length = v_format.fmt.pix.sizeimage;
-	
-	DPRINTF("Format correctly set.\n");
-	DPRINTF("Maximum image size: %d bytes.\n", frame_max_length);
-	
-	DPRINTF("Allocating memory for frames.\n");
-	frame = malloc(frame_max_length);
-	frame_start = frame;
-	
-	frame_id = 1;
-	
-	get_frame_read();
-	
+
+    ioctl(v4l2_fd, VIDIOC_G_INPUT, &ret_err);
+
+    if (ret_err == video_input_index) {
+        DPRINTF("Video input correctly set.\n");
+    } else {
+        error_report("Some error happened while setting video input.\n");
+        return -1;
+    }
+
+    DPRINTF("Trying to set 320x240 MJPEG.\n");
+    memset(&v_format, 0, sizeof(v_format));
+    v_format.type                = V4L2_BUF_TYPE_VIDEO_CAPTURE;
+    v_format.fmt.pix.width       = 320;
+    v_format.fmt.pix.height      = 240;
+    v_format.fmt.pix.pixelformat = V4L2_PIX_FMT_MJPEG;
+    v_format.fmt.pix.field       = V4L2_FIELD_INTERLACED;
+
+    ret_err = ioctl(v4l2_fd, VIDIOC_S_FMT, &v_format);
+
+    if (ret_err == -1) {
+        switch (errno) {
+        case EBUSY:
+            error_report("Device busy while changing format.\n");
+            break;
+        case EINVAL:
+            error_report("Invalid format.\n");
+            break;
+        default:
+            error_report("Unknown error %d while changing format.\n", errno);
+            break;
+        }
+
+        return -1;
+    }
+
+    frame_max_length = v_format.fmt.pix.sizeimage;
+
+    DPRINTF("Format correctly set.\n");
+    DPRINTF("Maximum image size: %d bytes.\n", frame_max_length);
+
+    DPRINTF("Allocating memory for frames.\n");
+    frame = malloc(frame_max_length);
+    frame_start = frame;
+
+    frame_id = 1;
+
+    get_frame_read();
+
     return 0;
 }
 
 static USBDevice *usb_uvc_init(const char *filename)
 {
     USBDevice *dev;
-	
+
     dev = usb_create(NULL /* FIXME */, "usb-uvc-webcam");
     qdev_init_nofail(&dev->qdev);
-	
-	DPRINTF("Filename: %s\n.", filename);
-	
-	if (!*filename) {
+
+    DPRINTF("Filename: %s\n.", filename);
+
+    if (!*filename) {
         error_report("character device specification needed");
         return NULL;
     }
-	
+
     return dev;
 }
 
@@ -1076,7 +1049,7 @@ static struct USBDeviceInfo usb_uvc_info = {
     .qdev.name      = "usb-uvc-webcam",
     .qdev.desc      = "QEMU USB Video Class Device",
     .usbdevice_name = "uvc-webcam",
-	.usbdevice_init = usb_uvc_init,
+    .usbdevice_init = usb_uvc_init,
     .qdev.size      = sizeof(USBUVCState),
     .init           = usb_uvc_initfn,
     .handle_packet  = usb_generic_handle_packet,
@@ -1084,10 +1057,10 @@ static struct USBDeviceInfo usb_uvc_info = {
     .handle_control = usb_uvc_handle_control,
     .handle_data    = usb_uvc_handle_data,
     .handle_destroy = usb_uvc_handle_destroy,
-	.qdev.props		= (Property[]) {
-		DEFINE_PROP_STRING("device", USBUVCState, v4l2_device),
-		DEFINE_PROP_END_OF_LIST(),
-	},
+    .qdev.props        = (Property[]) {
+        DEFINE_PROP_STRING("device", USBUVCState, v4l2_device),
+        DEFINE_PROP_END_OF_LIST()
+    },
 };
 
 static void usb_uvc_register_devices(void)
-- 
1.7.4.1

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [Qemu-devel] [PATCH 4/7] usb-uvc: fix some spelling issues.
  2011-06-02  5:41 [Qemu-devel] [0/7] USB UVC updates Brad Hards
                   ` (2 preceding siblings ...)
  2011-06-02  5:41 ` [Qemu-devel] [PATCH 3/7] usb-uvc: Fix all checkpatch style issues Brad Hards
@ 2011-06-02  5:41 ` Brad Hards
  2011-06-02  5:41 ` [Qemu-devel] [PATCH 5/7] usb-uvc: Add spaces around & Brad Hards
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 10+ messages in thread
From: Brad Hards @ 2011-06-02  5:41 UTC (permalink / raw)
  To: claunia, qemu-devel; +Cc: Brad Hards

Signed-off-by: Brad Hards <bradh@frogmouth.net>
---
 hw/usb-uvc.c |   10 +++++-----
 1 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/hw/usb-uvc.c b/hw/usb-uvc.c
index 20ac23e..5437a13 100644
--- a/hw/usb-uvc.c
+++ b/hw/usb-uvc.c
@@ -487,7 +487,7 @@ static int usb_uvc_handle_control(USBDevice *dev, USBPacket *p, int request,
         } else if (((index & 0xFF00) == 0x0500) &&
                     ((value & 0xFF00) == 0x0200)) {
             /* PU_BRIGHTNESS_CONTROL of PROCESSING_UNIT */
-            DPRINTF("USB Resquest: Asking for current brightness\n");
+            DPRINTF("USB Request: Asking for current brightness\n");
             if (length != 2) {
                 DPRINTF("USB Request: Requested %d bytes, expected 2 "
                         "bytes\n", length);
@@ -555,7 +555,7 @@ static int usb_uvc_handle_control(USBDevice *dev, USBPacket *p, int request,
             ret = 1;
         } else if ((index&0xFF00) == 0x0500 && (value&0xFF00) == 0x0200) {
             /* PU_BRIGHTNESS_CONTROL of PROCESSING_UNIT */
-            DPRINTF("USB Resquest: Asking for minimum brightness\n");
+            DPRINTF("USB Request: Asking for minimum brightness\n");
             if (length != 2) {
                 DPRINTF("USB Request: Requested %d bytes, expected 2 "
                         "bytes\n", length);
@@ -622,7 +622,7 @@ static int usb_uvc_handle_control(USBDevice *dev, USBPacket *p, int request,
             ret = 1;
         } else if ((index&0xFF00) == 0x0500 && (value&0xFF00) == 0x0200) {
             /* PU_BRIGHTNESS_CONTROL of PROCESSING_UNIT */
-            DPRINTF("USB Resquest: Asking for maximum brightness\n");
+            DPRINTF("USB Request: Asking for maximum brightness\n");
             if (length != 2) {
                 DPRINTF("USB Request: Requested %d bytes, expected 2 "
                         "bytes\n", length);
@@ -688,7 +688,7 @@ static int usb_uvc_handle_control(USBDevice *dev, USBPacket *p, int request,
             ret = 1;
         } else if ((index&0xFF00) == 0x0500 && (value&0xFF00) == 0x0200) {
             /* PU_BRIGHTNESS_CONTROL of PROCESSING_UNIT */
-            DPRINTF("USB Resquest: Asking for default brightness\n");
+            DPRINTF("USB Request: Asking for default brightness\n");
             if (length != 2) {
                 DPRINTF("USB Request: Requested %d bytes, expected 2 "
                         "bytes\n", length);
@@ -770,7 +770,7 @@ static int usb_uvc_handle_control(USBDevice *dev, USBPacket *p, int request,
     case UVCGetVideoControl | USB_UVC_GET_RES:
         if ((index&0xFF00) == 0x0500 && (value&0xFF00) == 0x0200) {
             /* PU_BRIGHTNESS_CONTROL of PROCESSING_UNIT */
-            DPRINTF("USB Resquest: Asking for brightness resolution\n");
+            DPRINTF("USB Request: Asking for brightness resolution\n");
             if (length != 2) {
                 DPRINTF("USB Request: Requested %d bytes, "
                         "expected 2 bytes\n", length);
-- 
1.7.4.1

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [Qemu-devel] [PATCH 5/7] usb-uvc: Add spaces around &
  2011-06-02  5:41 [Qemu-devel] [0/7] USB UVC updates Brad Hards
                   ` (3 preceding siblings ...)
  2011-06-02  5:41 ` [Qemu-devel] [PATCH 4/7] usb-uvc: fix some spelling issues Brad Hards
@ 2011-06-02  5:41 ` Brad Hards
  2011-06-02  5:41 ` [Qemu-devel] [PATCH 6/7] usb-uvc: Fix a couple of typos Brad Hards
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 10+ messages in thread
From: Brad Hards @ 2011-06-02  5:41 UTC (permalink / raw)
  To: claunia, qemu-devel; +Cc: Brad Hards

As requested by Blue Swirl (2010-06-10 17:46:16)

Signed-off-by: Brad Hards <bradh@frogmouth.net>
---
 hw/usb-uvc.c |   30 +++++++++++++++++++-----------
 1 files changed, 19 insertions(+), 11 deletions(-)

diff --git a/hw/usb-uvc.c b/hw/usb-uvc.c
index 5437a13..661eb1a 100644
--- a/hw/usb-uvc.c
+++ b/hw/usb-uvc.c
@@ -507,7 +507,7 @@ static int usb_uvc_handle_control(USBDevice *dev, USBPacket *p, int request,
         if (((index & 0xFF) == 0x01) && (((value & 0xFF00) == 0x0100) ||
                                             ((value & 0xFF00) == 0x0200))) {
             DPRINTF("USB Request: Get video control minimum setting "
-                    "attribute for interface %d\n", index&0xFF);
+                    "attribute for interface %d\n", index & 0xFF);
 
             if (length != 26) {
                 DPRINTF("USB Request: Requested %d bytes, expected 26 "
@@ -542,7 +542,8 @@ static int usb_uvc_handle_control(USBDevice *dev, USBPacket *p, int request,
             data[24] = 0x00;
             data[25] = 0x00;
             ret = 26;
-        } else if ((index&0xFF00) == 0x0400 && (value&0xFF00) == 0x0100) {
+        } else if (((index & 0xFF00) == 0x0400) &&
+                   ((value & 0xFF00) == 0x0100)) {
             /* Setting input */
             DPRINTF("USB Request: Asking for minimum input\n");
             if (length != 1) {
@@ -553,7 +554,8 @@ static int usb_uvc_handle_control(USBDevice *dev, USBPacket *p, int request,
 
             data[0] = 0;
             ret = 1;
-        } else if ((index&0xFF00) == 0x0500 && (value&0xFF00) == 0x0200) {
+        } else if (((index & 0xFF00) == 0x0500) &&
+                   ((value & 0xFF00) == 0x0200)) {
             /* PU_BRIGHTNESS_CONTROL of PROCESSING_UNIT */
             DPRINTF("USB Request: Asking for minimum brightness\n");
             if (length != 2) {
@@ -571,7 +573,7 @@ static int usb_uvc_handle_control(USBDevice *dev, USBPacket *p, int request,
         break;
     case UVCGetVideoControl | USB_UVC_GET_MAX:
         if (((index & 0xFF) == 0x01) && (((value & 0xFF00) == 0x0100) ||
-                                            ((value & 0xFF00) == 0x0200))) {
+                                         ((value & 0xFF00) == 0x0200))) {
             DPRINTF("USB Request: Get video control maximum setting "
                     "attribute for interface %d\n", index & 0xFF);
 
@@ -620,7 +622,8 @@ static int usb_uvc_handle_control(USBDevice *dev, USBPacket *p, int request,
 
             data[0] = 1;
             ret = 1;
-        } else if ((index&0xFF00) == 0x0500 && (value&0xFF00) == 0x0200) {
+        } else if (((index & 0xFF00) == 0x0500) &&
+                   ((value & 0xFF00) == 0x0200)) {
             /* PU_BRIGHTNESS_CONTROL of PROCESSING_UNIT */
             DPRINTF("USB Request: Asking for maximum brightness\n");
             if (length != 2) {
@@ -640,7 +643,7 @@ static int usb_uvc_handle_control(USBDevice *dev, USBPacket *p, int request,
         if (((index & 0xFF) == 0x01) &&
             ((value & 0xFF00) == 0x0100 || (value & 0xFF00) == 0x0200)) {
             DPRINTF("USB Request: Get video control default setting "
-                    "attribute for interface %d\n", index&0xFF);
+                    "attribute for interface %d\n", index & 0xFF);
 
             if (length != 26) {
                 DPRINTF("USB Request: Requested %d bytes, expected 26 "
@@ -675,7 +678,8 @@ static int usb_uvc_handle_control(USBDevice *dev, USBPacket *p, int request,
             data[24] = 0x00;
             data[25] = 0x00;
             ret = 26;
-        } else if ((index&0xFF00) == 0x0400 && (value&0xFF00) == 0x0100) {
+        } else if (((index & 0xFF00) == 0x0400) &&
+                   ((value & 0xFF00) == 0x0100)) {
             /* Setting input */
             DPRINTF("USB Request: Asking for default input\n");
             if (length != 1) {
@@ -686,7 +690,8 @@ static int usb_uvc_handle_control(USBDevice *dev, USBPacket *p, int request,
 
             data[0] = 0;
             ret = 1;
-        } else if ((index&0xFF00) == 0x0500 && (value&0xFF00) == 0x0200) {
+        } else if (((index & 0xFF00) == 0x0500) &&
+                   ((value & 0xFF00) == 0x0200)) {
             /* PU_BRIGHTNESS_CONTROL of PROCESSING_UNIT */
             DPRINTF("USB Request: Asking for default brightness\n");
             if (length != 2) {
@@ -741,7 +746,8 @@ static int usb_uvc_handle_control(USBDevice *dev, USBPacket *p, int request,
             first_bulk_packet = 1;
 
             ret = 26;
-        } else if ((index&0xFF00) == 0x0400 && (value&0xFF00) == 0x0100) {
+        } else if (((index & 0xFF00) == 0x0400) && 
+                    ((value & 0xFF00) == 0x0100)) {
             /* Setting input */
             DPRINTF("Setting input to %d\n", data[0]);
             if (length != 1) {
@@ -752,7 +758,8 @@ static int usb_uvc_handle_control(USBDevice *dev, USBPacket *p, int request,
 
             s->current_input = data[0];
             ret = 1;
-        } else if ((index&0xFF00) == 0x0500 && (value&0xFF00) == 0x0200) {
+        } else if (((index & 0xFF00) == 0x0500) &&
+                   ((value & 0xFF00) == 0x0200)) {
             /* PU_BRIGHTNESS_CONTROL of PROCESSING_UNIT */
             DPRINTF("USB Request: Setting brightness, "
                     "value stays the same\n");
@@ -768,7 +775,8 @@ static int usb_uvc_handle_control(USBDevice *dev, USBPacket *p, int request,
         }
         break;
     case UVCGetVideoControl | USB_UVC_GET_RES:
-        if ((index&0xFF00) == 0x0500 && (value&0xFF00) == 0x0200) {
+        if (((index & 0xFF00) == 0x0500) &&
+            ((value & 0xFF00) == 0x0200)) {
             /* PU_BRIGHTNESS_CONTROL of PROCESSING_UNIT */
             DPRINTF("USB Request: Asking for brightness resolution\n");
             if (length != 2) {
-- 
1.7.4.1

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [Qemu-devel] [PATCH 6/7] usb-uvc: Fix a couple of typos
  2011-06-02  5:41 [Qemu-devel] [0/7] USB UVC updates Brad Hards
                   ` (4 preceding siblings ...)
  2011-06-02  5:41 ` [Qemu-devel] [PATCH 5/7] usb-uvc: Add spaces around & Brad Hards
@ 2011-06-02  5:41 ` Brad Hards
  2011-06-02  5:41 ` [Qemu-devel] [PATCH 7/7] usb-uvc: Use qemu_malloc() Brad Hards
  2011-06-06  9:32 ` [Qemu-devel] [0/7] USB UVC updates Natalia Portillo
  7 siblings, 0 replies; 10+ messages in thread
From: Brad Hards @ 2011-06-02  5:41 UTC (permalink / raw)
  To: claunia, qemu-devel; +Cc: Brad Hards

Signed-off-by: Brad Hards <bradh@frogmouth.net>
---
 hw/usb-uvc.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/hw/usb-uvc.c b/hw/usb-uvc.c
index 661eb1a..1e3d339 100644
--- a/hw/usb-uvc.c
+++ b/hw/usb-uvc.c
@@ -893,7 +893,7 @@ static int usb_uvc_initfn(USBDevice *dev)
         error_report("V4L2 device specification needed.\n");
         return -1;
     } else {
-        DPRINTF("Trying to open %s\n.", s->v4l2_device);
+        DPRINTF("Trying to open %s.\n", s->v4l2_device);
     }
 
     v4l2_fd = open(s->v4l2_device, O_RDWR);
@@ -1042,7 +1042,7 @@ static USBDevice *usb_uvc_init(const char *filename)
     dev = usb_create(NULL /* FIXME */, "usb-uvc-webcam");
     qdev_init_nofail(&dev->qdev);
 
-    DPRINTF("Filename: %s\n.", filename);
+    DPRINTF("Filename: %s.\n", filename);
 
     if (!*filename) {
         error_report("character device specification needed");
-- 
1.7.4.1

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [Qemu-devel] [PATCH 7/7] usb-uvc: Use qemu_malloc()
  2011-06-02  5:41 [Qemu-devel] [0/7] USB UVC updates Brad Hards
                   ` (5 preceding siblings ...)
  2011-06-02  5:41 ` [Qemu-devel] [PATCH 6/7] usb-uvc: Fix a couple of typos Brad Hards
@ 2011-06-02  5:41 ` Brad Hards
  2011-06-06  9:32 ` [Qemu-devel] [0/7] USB UVC updates Natalia Portillo
  7 siblings, 0 replies; 10+ messages in thread
From: Brad Hards @ 2011-06-02  5:41 UTC (permalink / raw)
  To: claunia, qemu-devel; +Cc: Brad Hards

As requested by Blue Swirl (2010-06-10)

Signed-off-by: Brad Hards <bradh@frogmouth.net>
---
 hw/usb-uvc.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/hw/usb-uvc.c b/hw/usb-uvc.c
index 1e3d339..d1e71f8 100644
--- a/hw/usb-uvc.c
+++ b/hw/usb-uvc.c
@@ -1025,7 +1025,7 @@ static int usb_uvc_initfn(USBDevice *dev)
     DPRINTF("Maximum image size: %d bytes.\n", frame_max_length);
 
     DPRINTF("Allocating memory for frames.\n");
-    frame = malloc(frame_max_length);
+    frame = qemu_malloc(frame_max_length);
     frame_start = frame;
 
     frame_id = 1;
-- 
1.7.4.1

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* Re: [Qemu-devel] [0/7] USB UVC updates
  2011-06-02  5:41 [Qemu-devel] [0/7] USB UVC updates Brad Hards
                   ` (6 preceding siblings ...)
  2011-06-02  5:41 ` [Qemu-devel] [PATCH 7/7] usb-uvc: Use qemu_malloc() Brad Hards
@ 2011-06-06  9:32 ` Natalia Portillo
  2011-06-06  9:45   ` Brad Hards
  7 siblings, 1 reply; 10+ messages in thread
From: Natalia Portillo @ 2011-06-06  9:32 UTC (permalink / raw)
  To: Brad Hards; +Cc: QEMU Developers

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

Hi Brad,

El 02/06/2011, a las 06:41, Brad Hards escribió:

> Hi Natalia,
> 
> As you suggested, I've stopped my nonsense and worked from your
> UVC patches (http://patchwork.ozlabs.org/patch/55001 and
> http://patchwork.ozlabs.org/patch/55000). These changes
> are relative to your patches (applied on top of trunk).
> 
> I've mostly just incorporated some changes requested by Blue
> Swirl in his review. Fixing the checkpatch stuff changed a lot
> of whitespace (tab -> spaces), so I'd like to make sure this is
> OK before making more changes.

I see it ok, have you tested nothing broken? (specially with the &s patch)
I should take more care with 's's in typos next time

> The next change I propose to make is to rework the descriptors
> and add constants / defines for magic numbers.

Yeah, there are a couple of magic numbers that can be added.
Please note that most of the constants used in the descriptors should go
in usb.h

Also take special care with the descriptors, the minimal change can break it very easily.
The ideal solution would be to make the descriptors be dynamic depending on the host
webcam capabilities.

Bad thing the USB IF put the resolutions and formats in the descriptor, instead of in a
query command.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG/MacGPG2 v2.0.17 (Darwin)
Comment: GPGTools - http://gpgtools.org

iF0EAREIAAYFAk3snrEACgkQv/wfOsykIRRbngD492YNOzZGwRgwwVqok+AewO6H
kXvTClUJibR4fTVaDgEArEqcnm/xLF8gvANDc7DX6l8z7jOY8pagK4V488PMOhI=
=gzkf
-----END PGP SIGNATURE-----

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [Qemu-devel] [0/7] USB UVC updates
  2011-06-06  9:32 ` [Qemu-devel] [0/7] USB UVC updates Natalia Portillo
@ 2011-06-06  9:45   ` Brad Hards
  0 siblings, 0 replies; 10+ messages in thread
From: Brad Hards @ 2011-06-06  9:45 UTC (permalink / raw)
  To: Natalia Portillo; +Cc: QEMU Developers

On Mon, 6 Jun 2011 07:32:32 PM Natalia Portillo wrote:
> I see it ok, have you tested nothing broken? (specially with the &s patch)
It doesn't work for me (before or after). The descriptor part (which I've now 
implemented) works OK (i.e. the guest can dump it), cheese runs in the guest 
but doesn't show images. luvcview opens but won't capture data. So I have more 
work to do.

> I should take more care with 's's in typos next time
I don't think this is the biggest problem :-)
 
> > The next change I propose to make is to rework the descriptors
> > and add constants / defines for magic numbers.
> 
> Yeah, there are a couple of magic numbers that can be added.
> Please note that most of the constants used in the descriptors should go
> in usb.h
I was planning to do the ones that are specific to usb-uvc.c in that file, and 
only (potentially) shared things like the interface descriptor stuff in usb.h

> Also take special care with the descriptors, the minimal change can break
> it very easily. The ideal solution would be to make the descriptors be
> dynamic depending on the host webcam capabilities.
I believe that part of the descriptor change may be associated with not 
reading data. I could easily have introduced a problem. I haven't finished 
debugging it, but I never see transactions to EP 2 (the isoc data endpoint).

> Bad thing the USB IF put the resolutions and formats in the descriptor,
> instead of in a query command.
Indeed, but like everything in USB device space, its designed down to minimise 
cost on (real) hardware.

Thanks.

Brad

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2011-06-06  9:46 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-06-02  5:41 [Qemu-devel] [0/7] USB UVC updates Brad Hards
2011-06-02  5:41 ` [Qemu-devel] [PATCH 1/7] usb: Turn off debug output by default Brad Hards
2011-06-02  5:41 ` [Qemu-devel] [PATCH 2/7] usb-uvc: compile fix Brad Hards
2011-06-02  5:41 ` [Qemu-devel] [PATCH 3/7] usb-uvc: Fix all checkpatch style issues Brad Hards
2011-06-02  5:41 ` [Qemu-devel] [PATCH 4/7] usb-uvc: fix some spelling issues Brad Hards
2011-06-02  5:41 ` [Qemu-devel] [PATCH 5/7] usb-uvc: Add spaces around & Brad Hards
2011-06-02  5:41 ` [Qemu-devel] [PATCH 6/7] usb-uvc: Fix a couple of typos Brad Hards
2011-06-02  5:41 ` [Qemu-devel] [PATCH 7/7] usb-uvc: Use qemu_malloc() Brad Hards
2011-06-06  9:32 ` [Qemu-devel] [0/7] USB UVC updates Natalia Portillo
2011-06-06  9:45   ` Brad Hards

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.