Advertisement
xerpi

PSVita UDCD UVC USB descriptors, /dev/video1

Oct 21st, 2017
273
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 14.85 KB | None | 0 0
  1. #define CONTROL_INTERFACE   0
  2. #define STREAM_INTERFACE    1
  3.  
  4. #define INTERFACE_CTRL_ID   0
  5. #define CAMERA_TERMINAL_ID  1
  6. #define PROCESSING_UNIT_ID  2
  7. #define EXTENSION_UNIT_ID   3
  8. #define OUTPUT_TERMINAL_ID  4
  9.  
  10. static
  11. unsigned char interface_association_descriptor[] = {
  12.     /* Interface Association Descriptor */
  13.     0x08,           /* Descriptor Size */
  14.     0x0B,           /* Interface Association Descr Type: 11 */
  15.     0x00,           /* I/f number of first VideoControl i/f */
  16.     0x02,           /* Number of Video i/f */
  17.     0x0E,           /* CC_VIDEO : Video i/f class code */
  18.     0x03,           /* SC_VIDEO_INTERFACE_COLLECTION : Subclass code */
  19.     0x00,           /* Protocol : Not used */
  20.     0x00,           /* String desc index for interface */
  21. };
  22.  
  23. static
  24. unsigned char video_control_descriptors[] = {
  25.         /* Class specific VC Interface Header Descriptor */
  26.         0x0D,                           /* Descriptor size */
  27.         0x24,                           /* Class Specific I/f Header Descriptor type */
  28.         0x01,                           /* Descriptor Sub type : VC_HEADER */
  29.         0x10, 0x01,                     /* Revision of UVC class spec: 1.1 - Minimum version required
  30.                                            for USB Compliance. Not supported on Windows XP*/
  31.         0x51, 0x00,                     /* Total Size of class specific descriptors (till Output terminal) */
  32.         0x00,0x6C,0xDC,0x02,            /* Clock frequency : 48MHz(Deprecated) */
  33.         0x01,                           /* Number of streaming interfaces */
  34.         0x01,                           /* Video streaming I/f 1 belongs to VC i/f */
  35.  
  36.         /* Input (Camera) Terminal Descriptor */
  37.         0x12,                           /* Descriptor size */
  38.         0x24,                           /* Class specific interface desc type */
  39.         0x02,                           /* Input Terminal Descriptor type */
  40.         CAMERA_TERMINAL_ID,             /* ID of this terminal */
  41.         0x01,0x02,                      /* Camera terminal type */
  42.         0x00,                           /* No association terminal */
  43.         0x00,                           /* String desc index : Not used */
  44.         0x00,0x00,                      /* No optical zoom supported */
  45.         0x00,0x00,                      /* No optical zoom supported */
  46.         0x00,0x00,                      /* No optical zoom supported */
  47.         0x03,                           /* Size of controls field for this terminal : 3 bytes */
  48.         0x00,0x00,0x00,                 /* bmControls field of camera terminal: No controls supported */
  49.  
  50.         /* Processing Unit Descriptor */
  51.         0x0D,                           /* Descriptor size */
  52.         0x24,                           /* Class specific interface desc type */
  53.         0x05,                           /* Processing Unit Descriptor type */
  54.         PROCESSING_UNIT_ID,             /* ID of this terminal */
  55.         CAMERA_TERMINAL_ID,             /* Source ID : 1 : Conencted to input terminal */
  56.         0x00,0x40,                      /* Digital multiplier */
  57.         0x03,                           /* Size of controls field for this terminal : 3 bytes */
  58.         0x00,0x00,0x00,                 /* bmControls field of processing unit: Brightness control supported */
  59.         0x00,                           /* String desc index : Not used */
  60.         0x00,                           /* Analog Video Standards Supported: None */
  61.  
  62.         /* Extension Unit Descriptor */
  63.         0x1C,                           /* Descriptor size */
  64.         0x24,                           /* Class specific interface desc type */
  65.         0x06,                           /* Extension Unit Descriptor type */
  66.         EXTENSION_UNIT_ID,              /* ID of this terminal */
  67.         0xFF,0xFF,0xFF,0xFF,            /* 16 byte GUID */
  68.         0xFF,0xFF,0xFF,0xFF,
  69.         0xFF,0xFF,0xFF,0xFF,
  70.         0xFF,0xFF,0xFF,0xFF,
  71.         0x00,                           /* Number of controls in this terminal */
  72.         0x01,                           /* Number of input pins in this terminal */
  73.         PROCESSING_UNIT_ID,             /* Source ID : 2 : Connected to Proc Unit */
  74.         0x03,                           /* Size of controls field for this terminal : 3 bytes */
  75.         0x00,0x00,0x00,                 /* No controls supported */
  76.         0x00,                           /* String desc index : Not used */
  77.  
  78.         /* Output Terminal Descriptor */
  79.         0x09,                           /* Descriptor size */
  80.         0x24,                           /* Class specific interface desc type */
  81.         0x03,                           /* Output Terminal Descriptor type */
  82.         OUTPUT_TERMINAL_ID,             /* ID of this terminal */
  83.         0x01,0x01,                      /* USB Streaming terminal type */
  84.         0x00,                           /* No association terminal */
  85.         EXTENSION_UNIT_ID,              /* Source ID : 3 : Connected to Extn Unit */
  86.         0x00,                           /* String desc index : Not used */
  87. };
  88.  
  89. static
  90. unsigned char video_control_specific_endpoint_descriptors[] = {
  91.     0x05,                           /* Descriptor size */
  92.     0x25,                           /* Class Specific Endpoint Descriptor Type */
  93.     3,                              /* End point Sub Type */
  94.     0x40,0x00,                      /* Max packet size = 64 bytes */
  95. };
  96.  
  97. static
  98. unsigned char video_streaming_descriptors[] = {
  99.     /* Class-specific Video Streaming Input Header Descriptor */
  100.     0x0E,           /* Descriptor size */
  101.     0x24,           /* Class-specific VS I/f Type */
  102.     0x01,           /* Descriptotor Subtype : Input Header */
  103.     0x00,           /* No format desciptor supported for FS device */
  104.     0x0E, 0x00,     /* Total size of Class specific VS descr */
  105.     0x83,           /* EP address for BULK video data */
  106.     0x00,           /* No dynamic format change supported */
  107.     0x04,           /* Output terminal ID : 4 */
  108.     0x01,           /* Still image capture method 1 supported */
  109.     0x00,           /* Hardware trigger NOT supported */
  110.     0x00,           /* Hardware to initiate still image capture NOT supported */
  111.     0x01,           /* Size of controls field : 1 byte */
  112.     0x00,           /* D2 : Compression quality supported */
  113.  
  114.     /* Class specific Uncompressed VS format descriptor */
  115.     0x1B,                           /* Descriptor size */
  116.     0x24,                           /* Class-specific VS I/f Type */
  117.     0x04,                           /* Subtype : uncompressed format I/F */
  118.     0x01,                           /* Format desciptor index (only one format is supported) */
  119.     0x01,                           /* number of frame descriptor followed */
  120.     0x59,0x55,0x59,0x32,            /* GUID used to identify streaming-encoding format: YUY2  */
  121.     0x00,0x00,0x10,0x00,
  122.     0x80,0x00,0x00,0xAA,
  123.     0x00,0x38,0x9B,0x71,
  124.     0x10,                           /* Number of bits per pixel used to specify color in the decoded video frame.
  125.                            0 if not applicable: 16 bit per pixel */
  126.     0x01,                           /* Optimum Frame Index for this stream: 1 */
  127.     0x08,                           /* X dimension of the picture aspect ratio: Non-interlaced in progressive scan */
  128.     0x06,                           /* Y dimension of the picture aspect ratio: Non-interlaced in progressive scan*/
  129.     0x00,                           /* Interlace Flags: Progressive scanning, no interlace */
  130.     0x00,                           /* duplication of the video stream restriction: 0 - no restriction */
  131.  
  132.     /* Class specific Uncompressed VS Frame descriptor */
  133.     0x1E,                           /* Descriptor size */
  134.     0x24,                           /* Descriptor type*/
  135.     0x05,                           /* Subtype: uncompressed frame I/F */
  136.     0x01,                           /* Frame Descriptor Index */
  137.     0x01,                           /* Still image capture method 1 supported */
  138.     0x80,0x02,                      /* Width in pixel: 320-QVGA */
  139.     0xE0,0x01,                      /* Height in pixel 240-QVGA */
  140.     0x00,0x50,0x97,0x31,            /* Min bit rate bits/s. Not specified, taken from MJPEG */
  141.     0x00,0x50,0x97,0x31,            /* Max bit rate bits/s. Not specified, taken from MJPEG */
  142.     0x00,0x60,0x09,0x00,            /* Maximum video or still frame size in bytes(Deprecated) */
  143.     0x2A,0x2C,0x0A,0x00,            /* Default Frame Interval */
  144.     0x01,                           /* Frame interval(Frame Rate) types: Only one frame interval supported */
  145.     0x2A,0x2C,0x0A,0x00,            /* Shortest Frame Interval */
  146. };
  147.  
  148. /* Endpoint blocks */
  149. static
  150. struct SceUdcdEndpoint endpoints[4] = {
  151.     {0x00, 0, 0, 0},
  152.     {0x00, 1, 0, 0},
  153.     {0x80, 2, 0, 0},
  154.     {0x80, 3, 0, 0}
  155. };
  156.  
  157. /* Interfaces */
  158. static
  159. struct SceUdcdInterface interfaces[1] = {
  160.     {-1, 0, 2},
  161. };
  162.  
  163. /* String descriptor */
  164. static
  165. struct SceUdcdStringDescriptor string_descriptors[2] = {
  166.     {
  167.         18,
  168.         USB_DT_STRING,
  169.         {'V', 'i', 't', 'a', ' ', 'U', 'V', 'C'}
  170.     },
  171.     {
  172.         0,
  173.         USB_DT_STRING
  174.     }
  175. };
  176.  
  177. /* Hi-Speed device descriptor */
  178. static
  179. struct SceUdcdDeviceDescriptor devdesc_hi = {
  180.     USB_DT_DEVICE_SIZE,
  181.     USB_DT_DEVICE,
  182.     0x200,          /* bcdUSB */
  183.     0xEF,           /* bDeviceClass */
  184.     0x02,           /* bDeviceSubClass */
  185.     0x01,           /* bDeviceProtocol */
  186.     64,         /* bMaxPacketSize0 */
  187.     0,          /* idProduct */
  188.     0,          /* idVendor */
  189.     0x100,          /* bcdDevice */
  190.     0,          /* iManufacturer */
  191.     0,          /* iProduct */
  192.     0,          /* iSerialNumber */
  193.     1           /* bNumConfigurations */
  194. };
  195.  
  196. /* Hi-Speed endpoint descriptors */
  197. static
  198. struct SceUdcdEndpointDescriptor endpdesc_hi[4] = {
  199.     /* Video Control endpoints */
  200.     {
  201.         USB_DT_ENDPOINT_SIZE,
  202.         USB_DT_ENDPOINT,
  203.         0x01,           /* bEndpointAddress */
  204.         0x02,           /* bmAttributes */
  205.         0x200,          /* wMaxPacketSize */
  206.         0x00            /* bInterval */
  207.     },
  208.     {
  209.         USB_DT_ENDPOINT_SIZE,
  210.         USB_DT_ENDPOINT,
  211.         0x82,           /* bEndpointAddress */
  212.         0x03,           /* bmAttributes */
  213.         0x40,           /* wMaxPacketSize */
  214.         0x01            /* bInterval */
  215.     },
  216.     /* Video Streaming endpoints */
  217.     {
  218.         USB_DT_ENDPOINT_SIZE,
  219.         USB_DT_ENDPOINT,
  220.         0x83,           /* bEndpointAddress */
  221.         0x02,           /* bmAttributes */
  222.         0x200,          /* wMaxPacketSize */
  223.         0x00            /* bInterval */
  224.     },
  225.     {
  226.         0,
  227.     }
  228. };
  229.  
  230. /* Hi-Speed interface descriptor */
  231. static
  232. struct SceUdcdInterfaceDescriptor interdesc_hi[3] = {
  233.     {   /* Standard Video Control Interface Descriptor */
  234.         USB_DT_INTERFACE_SIZE,
  235.         USB_DT_INTERFACE,
  236.         CONTROL_INTERFACE,      /* bInterfaceNumber */
  237.         0,              /* bAlternateSetting */
  238.         2,              /* bNumEndpoints */
  239.         0x0E,               /* bInterfaceClass */
  240.         0x01,               /* bInterfaceSubClass */
  241.         0x00,               /* bInterfaceProtocol */
  242.         0,              /* iInterface */
  243.         &endpdesc_hi[0],        /* endpoints */
  244.         video_control_descriptors,
  245.         sizeof(video_control_descriptors)
  246.     },
  247.     {   /* Standard Video Streaming Interface Descriptor */
  248.         USB_DT_INTERFACE_SIZE,
  249.         USB_DT_INTERFACE,
  250.         STREAM_INTERFACE,       /* bInterfaceNumber */
  251.         0,              /* bAlternateSetting */
  252.         1,              /* bNumEndpoints */
  253.         0x0E,               /* bInterfaceClass */
  254.         0x02,               /* bInterfaceSubClass */
  255.         0x00,               /* bInterfaceProtocol */
  256.         0,              /* iInterface */
  257.         &endpdesc_hi[2],        /* endpoints */
  258.         video_streaming_descriptors,
  259.         sizeof(video_streaming_descriptors)
  260.     },
  261.     {
  262.         0
  263.     }
  264. };
  265.  
  266. /* Hi-Speed settings */
  267. static
  268. struct SceUdcdInterfaceSettings settings_hi[1] = {
  269.     {
  270.         interdesc_hi,
  271.         0,
  272.         2
  273.     }
  274. };
  275.  
  276. /* Hi-Speed configuration descriptor */
  277. static
  278. struct SceUdcdConfigDescriptor confdesc_hi = {
  279.     USB_DT_CONFIG_SIZE,
  280.     USB_DT_CONFIG,
  281.     (USB_DT_CONFIG_SIZE + 2 * USB_DT_INTERFACE_SIZE + 3 * USB_DT_ENDPOINT_SIZE +
  282.         /* sizeof(interface_association_descriptor) + Doesn't have to be added? */
  283.         sizeof(video_control_descriptors) +
  284.         sizeof(video_streaming_descriptors)),   /* wTotalLength */
  285.     2,          /* bNumInterfaces */
  286.     1,          /* bConfigurationValue */
  287.     0,          /* iConfiguration */
  288.     0xC0,           /* bmAttributes */
  289.     0,          /* bMaxPower */
  290.     &settings_hi[0],
  291.     interface_association_descriptor,
  292.     sizeof(interface_association_descriptor)
  293. };
  294.  
  295. /* Hi-Speed configuration */
  296. static
  297. struct SceUdcdConfiguration config_hi = {
  298.     &confdesc_hi,
  299.     &settings_hi[0],
  300.     &interdesc_hi[0],
  301.     &endpdesc_hi[0]
  302. };
  303.  
  304. /* Full-Speed device descriptor */
  305. static
  306. struct SceUdcdDeviceDescriptor devdesc_full = {
  307.     USB_DT_DEVICE_SIZE,
  308.     USB_DT_DEVICE,
  309.     0x200,          /* bcdUSB (should be 0x110 but the PSVita freezes otherwise) */
  310.     0xEF,           /* bDeviceClass */
  311.     0x02,           /* bDeviceSubClass */
  312.     0x01,           /* bDeviceProtocol */
  313.     0x40,           /* bMaxPacketSize0 */
  314.     0,          /* idProduct */
  315.     0,          /* idVendor */
  316.     0x200,          /* bcdDevice */
  317.     0,          /* iManufacturer */
  318.     0,          /* iProduct */
  319.     0,          /* iSerialNumber */
  320.     1           /* bNumConfigurations */
  321. };
  322.  
  323. /* Full-Speed endpoint descriptors */
  324. static
  325. struct SceUdcdEndpointDescriptor endpdesc_full[4] = {
  326.     /* Video Control endpoints */
  327.     {
  328.         USB_DT_ENDPOINT_SIZE,
  329.         USB_DT_ENDPOINT,
  330.         0x01,           /* bEndpointAddress */
  331.         0x02,           /* bmAttributes */
  332.         0x40,           /* wMaxPacketSize */
  333.         0x00            /* bInterval */
  334.     },
  335.     {
  336.         USB_DT_ENDPOINT_SIZE,
  337.         USB_DT_ENDPOINT,
  338.         0x82,           /* bEndpointAddress */
  339.         0x03,           /* bmAttributes */
  340.         0x40,           /* wMaxPacketSize */
  341.         0x01            /* bInterval */
  342.     },
  343.     /* Video Streaming endpoints */
  344.     {
  345.         USB_DT_ENDPOINT_SIZE,
  346.         USB_DT_ENDPOINT,
  347.         0x83,           /* bEndpointAddress */
  348.         0x02,           /* bmAttributes */
  349.         0x40,           /* wMaxPacketSize */
  350.         0x00            /* bInterval */
  351.     },
  352.     {
  353.         0,
  354.     }
  355. };
  356.  
  357. /* Full-Speed interface descriptor */
  358. static
  359. struct SceUdcdInterfaceDescriptor interdesc_full[3] = {
  360.     {   /* Standard Video Control Interface Descriptor */
  361.         USB_DT_INTERFACE_SIZE,
  362.         USB_DT_INTERFACE,
  363.         0,              /* bInterfaceNumber */
  364.         0,              /* bAlternateSetting */
  365.         2,              /* bNumEndpoints */
  366.         14,             /* bInterfaceClass */
  367.         0x01,               /* bInterfaceSubClass */
  368.         0x00,               /* bInterfaceProtocol */
  369.         1,              /* iInterface */
  370.         &endpdesc_full[0],      /* endpoints */
  371.         video_control_descriptors,
  372.         sizeof(video_control_descriptors)
  373.     },
  374.     {   /* Standard Video Streaming Interface Descriptor */
  375.         USB_DT_INTERFACE_SIZE,
  376.         USB_DT_INTERFACE,
  377.         1,              /* bInterfaceNumber */
  378.         0,              /* bAlternateSetting */
  379.         1,              /* bNumEndpoints */
  380.         14,             /* bInterfaceClass */
  381.         0x02,               /* bInterfaceSubClass */
  382.         0x00,               /* bInterfaceProtocol */
  383.         1,              /* iInterface */
  384.         &endpdesc_full[2],      /* endpoints */
  385.         video_streaming_descriptors,
  386.         sizeof(video_streaming_descriptors)
  387.     },
  388.     {
  389.         0
  390.     }
  391. };
  392.  
  393. /* Full-Speed settings */
  394. static
  395. struct SceUdcdInterfaceSettings settings_full[1] = {
  396.     {
  397.         &interdesc_full[0],
  398.         0,
  399.         2
  400.     }
  401. };
  402.  
  403. /* Full-Speed configuration descriptor */
  404. static
  405. struct SceUdcdConfigDescriptor confdesc_full = {
  406.     USB_DT_CONFIG_SIZE,
  407.     USB_DT_CONFIG,
  408.     (USB_DT_CONFIG_SIZE + 2 * USB_DT_INTERFACE_SIZE + 3 * USB_DT_ENDPOINT_SIZE +
  409.         sizeof(interface_association_descriptor) +
  410.         sizeof(video_control_descriptors) +
  411.         sizeof(video_streaming_descriptors)),   /* wTotalLength */
  412.     2,          /* bNumInterfaces */
  413.     1,          /* bConfigurationValue */
  414.     0,          /* iConfiguration */
  415.     0xC0,           /* bmAttributes */
  416.     0,          /* bMaxPower */
  417.     &settings_full[0],
  418.     interface_association_descriptor,
  419.     sizeof(interface_association_descriptor)
  420. };
  421.  
  422. /* Full-Speed configuration */
  423. static
  424. struct SceUdcdConfiguration config_full = {
  425.     &confdesc_full,
  426.     &settings_full[0],
  427.     &interdesc_full[0],
  428.     &endpdesc_full[0]
  429. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement