Re: Missing descriptor in uvideo.h

2015-07-21 Thread Ludovic Coues
On 20/07/15(Mon) 16:44, Martin Pieuchot wrote:
 Is it because by ``wWord'' you mean uDword?  Did you consider using an
 union with #define?
 

I don't know what I could do with an union but I followed the advice. I
rewrote the diff, dropped the data field and used a couple of macro to
access the two last field. It involve a bit of pointer arithmetic but it
work.
Index: sys/dev/usb/uvideo.h
===
RCS file: /cvs/src/sys/dev/usb/uvideo.h,v
retrieving revision 1.57
diff -u -p -r1.57 uvideo.h
--- sys/dev/usb/uvideo.h9 Jul 2015 14:58:32 -   1.57
+++ sys/dev/usb/uvideo.h21 Jul 2015 13:26:42 -
@@ -208,6 +208,18 @@ struct usb_video_camera_terminal_desc {
uByte   *bmControls;
 } __packed;
 
+/* Table 3-7: VC Selector Unit Descriptor */
+struct usb_video_vc_selector_desc {
+   uByte   bLength;
+   uByte   bDescriptorType;
+   uByte   bDescriptorSubType;
+   uByte   bUnitID;
+   uByte   bNrInPins;
+   uByte   baSourceID[1];
+/* uByte   iSelector; */
+#defineVC_GET_ISELECTOR(w) ((w).baSourceID[0] + (w).bNrInPins)
+} __packed;
+
 /* Table 3-8: VC Processing Unit Descriptor */
 struct usb_video_vc_processing_desc {
uByte   bLength;
@@ -222,7 +234,20 @@ struct usb_video_vc_processing_desc {
/* uByte bmVideoStandards; */
 } __packed;
 
-/* Table 3-9: VC Extension Unit Descriptor */
+/* Table 3-9: VC Encoding Unit Descriptor */
+struct usb_video_vc_encoding_desc {
+   uByte   bLength;
+   uByte   bDescriptorType;
+   uByte   bDescriptorSubtype;
+   uByte   bUnitID;
+   uByte   bSourceID;
+   uByte   iEncoding;
+   uByte   bControlSize;
+   uByte   bmControls[3];
+   uByte   bmControlsRuntime[3];
+} __packed;
+
+/* Table 3-10: VC Extension Unit Descriptor */
 struct usb_video_vc_extension_desc {
uByte   bLength;
uByte   bDescriptorType;
@@ -233,7 +258,7 @@ struct usb_video_vc_extension_desc {
uByte   bNrInPins;
 } __packed;
 
-/* Table 3-11: VC Endpoint Descriptor */
+/* Table 3-12: VC Endpoint Descriptor */
 struct usb_video_vc_endpoint_desc {
uByte   bLength;
uByte   bDescriptorType;
@@ -241,7 +266,7 @@ struct usb_video_vc_endpoint_desc {
uWord   wMaxTransferSize;
 } __packed;
 
-/* Table 3-13: Interface Input Header Descriptor */
+/* Table 3-14: Interface Input Header Descriptor */
 struct usb_video_input_header_desc {
uByte   bLength;
uByte   bDescriptorType;
@@ -262,7 +287,39 @@ struct usb_video_input_header_desc_all {
uByte   *bmaControls;
 };
 
-/* Table 3-18: Color Matching Descriptor */
+/* Table 3-15: Interface Output Header Descriptor */
+struct usb_video_output_header_desc {
+   uByte   bLength;
+   uByte   bDescriptorType;
+   uByte   bDescriptorSubtype;
+   uByte   bNumFormats;
+   uWord   wTotalLength;
+   uByte   bEndpointAddress;
+   uByte   bTerminalLink;
+   uByte   bControlSize;
+   uByte   bmaControls[1];
+} __packed;
+
+/* Table 3-18: Still Image Frame Descriptor */
+struct usb_video_still_image_frame_desc {
+   uByte   bLength;
+   uByte   bDescriptorType;
+   uByte   bDescriptorSubtype;
+   uByte   bEndpointAddress;
+   uByte   bNumImageSizePatterns;
+   struct {
+   uWord   wWidth;
+   uWord   wHeight;
+   } __packed size[1];
+/* uByte   bNumCompressionPattern; */
+#defineVC_GET_BNUMCOMPRESSION(w)  \
+   ( *( (uByte *)(w) + 5 + 4 * (w)-bNumImageSizePatterns ) )
+/* uByte   bCompression[1]; */
+#defineVC_GET_BCOMPRESSION(w) \
+   (  ( (uByte *)(w) + 6 + 4 * (w)-bNumImageSizePatterns ) )
+} __packed;
+
+/* Table 3-19: Color Matching Descriptor */
 struct usb_video_color_matching_descr {
uByte   bLength;
uByte   bDescriptorType;


Re: Missing descriptor in uvideo.h

2015-07-20 Thread ludovic coues
There is a typo with struct usb_video_output_header_desc,
corresponding to table 3-15. Last field should be bmaControls.


-- 

Cordialement, Coues Ludovic
+336 148 743 42



Re: Missing descriptor in uvideo.h

2015-07-20 Thread Martin Pieuchot
On 15/07/15(Wed) 17:30, ludovic coues wrote:
 2015-07-15 17:04 GMT+02:00 Martin Pieuchot m...@openbsd.org:
  On 15/07/15(Wed) 16:45, Ludovic Coues wrote:
  Following is a diff adding missing USB descriptor to uvideo.h according
  to USB Video spec 1.5 . It also update a couple of table reference from
  spec 1.1 to 1.5
 
  Do not hesitate to explain *why* do you need that, it might not be clear
  to everybody on this list :)
 
 
 Oh, right.
 I'm working on an alternative to lsusb for my summer of code. By
 design, I'm using pretty much every USB descriptor defined by the
 spec.
 
  Index: sys/dev/usb/uvideo.h
  ===
  RCS file: /cvs/src/sys/dev/usb/uvideo.h,v
  retrieving revision 1.57
  diff -u -p -r1.57 uvideo.h
  --- sys/dev/usb/uvideo.h  9 Jul 2015 14:58:32 -   1.57
  +++ sys/dev/usb/uvideo.h  14 Jul 2015 17:24:42 -
  +/* Table 3-18: Still Image Frame Descriptor */
  +struct usb_video_still_image_frame_desc {
  + uByte   bLength;
  + uByte   bDescriptorType;
  + uByte   bDescriptorSubtype;
  + uByte   bEndpointAddress;
  + uByte   bNumImageSizePatterns;
  + uByte   data[1];
  +/*   struct {
  + uWord   wWidth;
  + wWord   wHeight;
  + } __packed size[1]; */
  +/*   uByte   bNumCompressionPattern; */
  +/*   uByte   bCompression[1]; */
 
  Why are they commented?
 
 Mainly as a way to document the spec in the code.
 I could remove the data field and uncomment the size field. I would be
 pretty close to the spec and this struct could be filled with a
 memcpy. But size would be a field of size 32 followed by two field of
 size 8. I don't know how I could access bNumCompressionPattern or
 bCompression in this case.

Is it because by ``wWord'' you mean uDword?  Did you consider using an
union with #define?

Martin



Re: Missing descriptor in uvideo.h

2015-07-15 Thread ludovic coues
2015-07-15 17:04 GMT+02:00 Martin Pieuchot m...@openbsd.org:
 On 15/07/15(Wed) 16:45, Ludovic Coues wrote:
 Following is a diff adding missing USB descriptor to uvideo.h according
 to USB Video spec 1.5 . It also update a couple of table reference from
 spec 1.1 to 1.5

 Do not hesitate to explain *why* do you need that, it might not be clear
 to everybody on this list :)


Oh, right.
I'm working on an alternative to lsusb for my summer of code. By
design, I'm using pretty much every USB descriptor defined by the
spec.

 Index: sys/dev/usb/uvideo.h
 ===
 RCS file: /cvs/src/sys/dev/usb/uvideo.h,v
 retrieving revision 1.57
 diff -u -p -r1.57 uvideo.h
 --- sys/dev/usb/uvideo.h  9 Jul 2015 14:58:32 -   1.57
 +++ sys/dev/usb/uvideo.h  14 Jul 2015 17:24:42 -
 +/* Table 3-18: Still Image Frame Descriptor */
 +struct usb_video_still_image_frame_desc {
 + uByte   bLength;
 + uByte   bDescriptorType;
 + uByte   bDescriptorSubtype;
 + uByte   bEndpointAddress;
 + uByte   bNumImageSizePatterns;
 + uByte   data[1];
 +/*   struct {
 + uWord   wWidth;
 + wWord   wHeight;
 + } __packed size[1]; */
 +/*   uByte   bNumCompressionPattern; */
 +/*   uByte   bCompression[1]; */

 Why are they commented?

Mainly as a way to document the spec in the code.
I could remove the data field and uncomment the size field. I would be
pretty close to the spec and this struct could be filled with a
memcpy. But size would be a field of size 32 followed by two field of
size 8. I don't know how I could access bNumCompressionPattern or
bCompression in this case.

I choose instead of describing the data as code in a comment and
putting a field to allow access to the data. Maybe I should add macro
to access the 'ghost' field.


-- 

Cordialement, Coues Ludovic
+336 148 743 42



Missing descriptor in uvideo.h

2015-07-15 Thread Ludovic Coues
Following is a diff adding missing USB descriptor to uvideo.h according
to USB Video spec 1.5 . It also update a couple of table reference from
spec 1.1 to 1.5
Index: sys/dev/usb/uvideo.h
===
RCS file: /cvs/src/sys/dev/usb/uvideo.h,v
retrieving revision 1.57
diff -u -p -r1.57 uvideo.h
--- sys/dev/usb/uvideo.h9 Jul 2015 14:58:32 -   1.57
+++ sys/dev/usb/uvideo.h14 Jul 2015 17:24:42 -
@@ -208,6 +208,18 @@ struct usb_video_camera_terminal_desc {
uByte   *bmControls;
 } __packed;
 
+/* Table 3-7: VC Selector Unit Descriptor */
+struct usb_video_vc_selector_desc {
+   uByte   bLength;
+   uByte   bDescriptorType;
+   uByte   bDescriptorSubType;
+   uByte   bUnitID;
+   uByte   bNrInPins;
+   uByte   baSourceID[1];
+/* uByte   iSelector; */
+#defineVC_GET_ISELECTOR(w) ((w).baSourceID[0] + (w).bNrInPins)
+} __packed;
+
 /* Table 3-8: VC Processing Unit Descriptor */
 struct usb_video_vc_processing_desc {
uByte   bLength;
@@ -222,7 +234,20 @@ struct usb_video_vc_processing_desc {
/* uByte bmVideoStandards; */
 } __packed;
 
-/* Table 3-9: VC Extension Unit Descriptor */
+/* Table 3-9: VC Encoding Unit Descriptor */
+struct usb_video_vc_encoding_desc {
+   uByte   bLength;
+   uByte   bDescriptorType;
+   uByte   bDescriptorSubtype;
+   uByte   bUnitID;
+   uByte   bSourceID;
+   uByte   iEncoding;
+   uByte   bControlSize;
+   uByte   bmControls[3];
+   uByte   bmControlsRuntime[3];
+} __packed;
+
+/* Table 3-10: VC Extension Unit Descriptor */
 struct usb_video_vc_extension_desc {
uByte   bLength;
uByte   bDescriptorType;
@@ -233,7 +258,7 @@ struct usb_video_vc_extension_desc {
uByte   bNrInPins;
 } __packed;
 
-/* Table 3-11: VC Endpoint Descriptor */
+/* Table 3-12: VC Endpoint Descriptor */
 struct usb_video_vc_endpoint_desc {
uByte   bLength;
uByte   bDescriptorType;
@@ -241,7 +266,7 @@ struct usb_video_vc_endpoint_desc {
uWord   wMaxTransferSize;
 } __packed;
 
-/* Table 3-13: Interface Input Header Descriptor */
+/* Table 3-14: Interface Input Header Descriptor */
 struct usb_video_input_header_desc {
uByte   bLength;
uByte   bDescriptorType;
@@ -262,7 +287,36 @@ struct usb_video_input_header_desc_all {
uByte   *bmaControls;
 };
 
-/* Table 3-18: Color Matching Descriptor */
+/* Table 3-15: Interface Output Header Descriptor */
+struct usb_video_output_header_desc {
+   uByte   bLength;
+   uByte   bDescriptorType;
+   uByte   bDescriptorSubtype;
+   uByte   bNumFormats;
+   uWord   wTotalLength;
+   uByte   bEndpointAddress;
+   uByte   bTerminalLink;
+   uByte   bControlSize;
+   uByte   baControls[1];
+} __packed;
+
+/* Table 3-18: Still Image Frame Descriptor */
+struct usb_video_still_image_frame_desc {
+   uByte   bLength;
+   uByte   bDescriptorType;
+   uByte   bDescriptorSubtype;
+   uByte   bEndpointAddress;
+   uByte   bNumImageSizePatterns;
+   uByte   data[1];
+/* struct {
+   uWord   wWidth;
+   wWord   wHeight;
+   } __packed size[1]; */
+/* uByte   bNumCompressionPattern; */
+/* uByte   bCompression[1]; */
+} __packed;
+
+/* Table 3-19: Color Matching Descriptor */
 struct usb_video_color_matching_descr {
uByte   bLength;
uByte   bDescriptorType;


Re: Missing descriptor in uvideo.h

2015-07-15 Thread Martin Pieuchot
On 15/07/15(Wed) 16:45, Ludovic Coues wrote:
 Following is a diff adding missing USB descriptor to uvideo.h according
 to USB Video spec 1.5 . It also update a couple of table reference from
 spec 1.1 to 1.5

Do not hesitate to explain *why* do you need that, it might not be clear
to everybody on this list :)

 Index: sys/dev/usb/uvideo.h
 ===
 RCS file: /cvs/src/sys/dev/usb/uvideo.h,v
 retrieving revision 1.57
 diff -u -p -r1.57 uvideo.h
 --- sys/dev/usb/uvideo.h  9 Jul 2015 14:58:32 -   1.57
 +++ sys/dev/usb/uvideo.h  14 Jul 2015 17:24:42 -
 +/* Table 3-18: Still Image Frame Descriptor */
 +struct usb_video_still_image_frame_desc {
 + uByte   bLength;
 + uByte   bDescriptorType;
 + uByte   bDescriptorSubtype;
 + uByte   bEndpointAddress;
 + uByte   bNumImageSizePatterns;
 + uByte   data[1];
 +/*   struct {
 + uWord   wWidth;
 + wWord   wHeight;
 + } __packed size[1]; */
 +/*   uByte   bNumCompressionPattern; */
 +/*   uByte   bCompression[1]; */

Why are they commented?

 +} __packed;
 +
 +/* Table 3-19: Color Matching Descriptor */
  struct usb_video_color_matching_descr {
   uByte   bLength;
   uByte   bDescriptorType;