使用CX3 MIPI CSI-2接口传输RAW10输入格式的数据到16/24 bit输出格式的常见问题 – KBA224387 (ZH)
Version: **
注: 参考阅读 AN90369 - How to Interface a MIPI CSI-2 Image Sensor With EZ-USB® CX3获得本篇KBA的补充信息。
1. CX3如何将输入的RAW10格式的数据打包为16/24 bit的输出格式?
回答:CX3具有MIPI CSI-2的接收端将串行的MIPI数据转换为并行格式。内置的GPIF II模块对并行数据采样并通过DMA通道发送到USB端。
如图 1所示,用户可以使用CX3配置工具选择相应的输入格式和输出格式。
假设图像传感器输出RAW10格式的数据流,分辨率为1080p,帧率30 fps。
1. 选择Input Video Format为RAW10,Output Video Format为16 bit,并在Image Sensor Configuration标签页里填入其他传输1080p@30 fps视频流所需要的参数。
2. 如图 2所示,跳转到CX3 Receiver Configuration页,调整MIPI CSI-2接收端模块。MIPI CSI-2 Inputs中的格式为RAW10,并且CX3 MIPI interface中的数据格式为RAW10。这意味着,MIPI CSI-2会将输入的串行RAW10数据转换为并行的10 bit数据。
3. 然而,内置固定的GPIF II模块支持配置为8/16/24 bit数据总线。在这个例子中,GPIF II模块配置为16 bit的数据总线模式。因此,它在每个clock采样16 bit的数据。在这16 bit的采样中,只有10 bit是真实有效的数据,其他的6 bit是每个时钟填充的多余bit。这将会使得每个像素的尺寸变大为实际尺寸的1.6倍,从而每一帧的尺寸增大为实际尺寸的1.6倍。用户应该移除这多余的6 bit以在主机端应用中显示实际帧大小。
图 1. Image Sensor Configuration
图 2. CX3 MIPI Receiver Configuration
上述设置对应的MIPI CSI-2配置如下:
/* XYZ_Sensor_RAW10_Resolution0 : */
CyU3PMipicsiCfg_t XYZ_Sensor_RAW10_Resolution0 =
{
CY_U3P_CSI_DF_RAW10, /* CyU3PMipicsiDataFormat_t dataFormat */
2, /* uint8_t numDataLanes */
2, /* uint8_t pllPrd */
89, /* uint16_t pllFbd */
CY_U3P_CSI_PLL_FRS_250_500M, /* CyU3PMipicsiPllClkFrs_t pllFrs */
CY_U3P_CSI_PLL_CLK_DIV_4, /* CyU3PMipicsiPllClkDiv_t csiRxClkDiv */
CY_U3P_CSI_PLL_CLK_DIV_4, /* CyU3PMipicsiPllClkDiv_t parClkDiv */
0, /* uint16_t mClkCtl */
CY_U3P_CSI_PLL_CLK_DIV_2, /* CyU3PMipicsiPllClkDiv_t mClkRefDiv */
1920, /* uint16_t hResolution */
50 /* uint16_t fifoDelay */
};
将上述配置中的CY_U3P_CSI_DF_RAW10替换为CY_U3P_CSI_DF_YUV422_8_2,或者在Image Sensor Configuration标签页中将选择输出格式为24 bit,都可以每像素将多余的6 bit移除。
注意 MIPI CSI Configuration中的Output data format将决定填充0的数量,并不影响传输视频流的格式。
下面讨论这两种情况。
A. 将CY_U3P_CSI_DF_RAW10替换为CY_U3P_CSI_DF_YUV422_8_2:
将Output data format设置为CY_U3P_CSI_DF_YUV422_8_2时,输入的RAW10格式的数据将会打包为16 bit的并行数据,并通过MIPI CSI-2接口发送。此时,没有额外填充的数据。
注意在这种情况下,用户只需要修改cyu3mipicsi.c中的输出格式,CX3 Receiver Configuration标签页中的时钟设置无需改变。因此,这种配置不适用于时钟需要改变的场景。如果遇到此类问题,请联系Cypress技术支持。
RAW10的输入数据按照如下的规则打包为16 bit的数据:
a. MIPI CSI-2按照图 3所示的格式接收RAW10标准格式数据(来源:MIPI Alliance Specification for Camera Serial interface 2 (CSI-2))
b. 输入的串行RAW10格式的数据按照如下的规则转换为并行16 bit数据;随后GPIF II对其进行采样。
i.e. GPIF II在每个时钟周期接收16 bit数据:
§ 第一个时钟周期:P1[9:2] P2[9:2]
§ 第二个时钟周期:P3[9:2] P4[9:2]
§ 第三个时钟周期:P1[1:0] P2[1:0] P3[1:0] P4[1:0] P5[9:2]
§ 第四个时钟周期:依此类推
图 3. RAW10传输格式 (来源: MIPI Alliance Specification for Camera Serial Interface 2)
注意当Output data format选择为16 bit时,GPIF II应当配置为16 bit数据总线格式。当数据从RAW10打包为16 bit的格式时,每帧的行尺寸需要为16的整数倍。
B. Output data format选择为24 bit
当Image Sensor Configuration标签页中的Output data format选择为24 bit时,输入的RAW10格式的数据将会被打包为24 bit的并行数据,并通过MIPI CSI-2并行接口发送出去。此时并没有额外填充的数据。
输入的串行RAW10格式的数据按照如下的规则转换为并行24 bit数据;随后GPIF II对其进行采样。
也就是说,GPIF II在每个时钟周期都采样24 bit的数据
§ 第一个时钟周期 - P1[9:2],P2[9:2],P3[9:2]
§ 第二个时钟周期 – P4[9:2],P1[1:0],P2[1:0],P3[1:0],P4[1:0],P5[9:2]
§ 第三个时钟周期 – 依此类推
注意,当选择Output data format为24 bit时,GPIF II需要设置为24 bit数据总线。当数据从RAW10打包为24 bit的格式时,每帧的行尺寸需要为24的整数倍。
2. 为了传输RAW10格式的视频,如何设置USB descriptor和Probe Control structure?
Microsoft提供的标准的UVC驱动借助GUID值传输视频流。标准驱动并不支持传输RAW格式的视频,因此Microsoft并没有为RAW格式提供GUID值。因此标准UVC驱动不能传输RAW格式。
然而,用户可以采取以下的替代方法传输RAW格式视频流,并且无明显播放限制。此时,用户需要客制化主机端应用以便更好的播放视频。
1. 采用Microsoft提供的Uncompressed Video Streaming(VS) format descriptor。
2. 根据CX3 MIPI bridge输入和输出的数据格式,设置相应的USB descriptor(包括Uncompressed VS format descriptor和Uncompressed VS frame Descriptor)和Probe control structure。
按照上述的设置,UVC驱动可以传输数据;主机程序可以根据第一步中提供的GUID值对数据进行解码。但是此时用户往往会看到一些色块而不是正确的图像。因为输入的数据是RAW格式而主机程序按照YUY2的标准格式进行解码。尽管视频,用户也可以用这种方法调试UVC设备。
下面列出了输出RAW10为三种不同格式的UVC descriptor和Probe control structure的例子。如所示,用户可以自行对固件中的UVC descriptor和Probe control structure做必要的修改。如果需要正常显示视频,用户需要对主机端软件进行客制化。
例1:RAW10输出格式(CY_U3P_CSI_DF_RAW10)
假设传输的是1920x1080,30 fps的RAW10视频,相关参数如下:
b. 高度(像素) :1080
c. 每像素bit :10
d. 帧/秒 :30
e. 帧尺寸 :1920 x 1080 x 10 bit
f. 比特率 :1920 x 1080 x 10 x 30 bit/s
在上述配置中,对于RAW10的输出格式,GPIF II接口需要配置为16 bit的并行口。对应的每个像素多填充6 bit,导致帧尺寸增大。因此需要修改计算结果如下:
a. 宽度(像素) :1920
b. 高度(像素) :1080
c. 每像素bit :16(因为每像素填充的6 bit)
d. 帧/秒 :30
e. 帧尺寸 :1920 x 1080 x 16 bit
f. 比特率 :1920 x 1080 x 16 x 30 bit/s
USB descriptor和Probe control structure如下所示:
/* Class specific Uncompressed VS format descriptor */
0x1B, /* Descriptor size */
CX3_CS_INTRFC_DESCR, /* Class-specific VS interface Type */
0x04, /* Subtype : VS_FORMAT_UNCOMPRESSED */
0x01, /* Format desciptor index */
0x04, /* Number of Frame Descriptors that follow this descriptor: 3 */
/* GUID, globally unique identifier used to identify streaming-encoding format: YUY2 */
0x59, 0x55, 0x59, 0x32, /*MEDIASUBTYPE_YUY2 GUID: 32595559-0000-0010-8000-00AA00389B71 */
0x00, 0x00, 0x10, 0x00,
0x80, 0x00, 0x00, 0xAA,
0x00, 0x38, 0x9B, 0x71,
0x10, /* Number of bits per pixel: 16*/
0x01, /* Optimum Frame Index for this stream: 2 (1080p) */
0x00, /* X dimension of the picture aspect ratio; Non-interlaced */
0x00, /* Y dimension of the pictuer aspect ratio: Non-interlaced */
0x00, /* Interlace Flags: Progressive scanning, no interlace */
0x00, /* duplication of the video stream restriction: 0 - no restriction */
/* Class specific Uncompressed VS Frame Descriptor - 1080p@30fps */
0x1E, /* Descriptor size */
CX3_CS_INTRFC_DESCR, /* Descriptor type*/
0x05, /* Subtype: Uncompressed frame interface*/
0x01, /* Frame Descriptor Index: 1 */
0x00, /* No Still image capture supported */
0x80, 0x07, /* Width in pixel: 1920 */
0x38, 0x04, /* Height in pixel: 1080 */
0x00, 0x80, 0x53, 0x3B, /* Min bit rate (bits/s): 1080 x 1920 x 16 x 30 = 995328000 */
0x00, 0x80, 0x53, 0x3B, /* Max bit rate (bits/s): Fixed rate so same as Min */
0x00, 0x48, 0x3F, 0x00, /* Maximum video or still frame size in bytes(Deprecated: 1920x1080 x2*/
0x15, 0x16, 0x05, 0x00, /* Default frame interval (in 100ns units): (1/30)x10^7 */
0x01, /* Frame interval type : No of discrete intervals */
0x15, 0x16, 0x05, 0x00, /* Frame interval 3: Same as Default frame interval */
/* UVC Probe Control Setting - 1080p@30FPS */
uint8_t const gl1080pProbeCtrl[CX3_APP_MAX_PROBE_SETTING] ={
0x00, 0x00, /* bmHint : No fixed parameters */
0x01, /* Use 1st Video format index */
0x01, /* Use 1st Video frame index */
0x15, 0x16, 0x05, 0x00, /* Desired frame interval in 100ns = (1/30)x10^7 */
0x00, 0x00, /* Key frame rate in key frame/video frame units */
0x00, 0x00, /* PFrame rate in PFrame / key frame units */
0x00, 0x00, /* Compression quality control */
0x00, 0x00, /* Window size for average bit rate */
0x00, 0x00, /* Internal video streaming i/f latency in ms */
0x00, 0x48, 0x3F, 0x00, /* Max video frame size in bytes = 1920 x 1080 x 2 */
#ifdef CX3_UVC_1_0_SUPPORT
0x00, 0x90, 0x00, 0x00 /* No. of bytes device can rx in single payload: 36KB */
#else
/* UVC 1.1 Probe Control has additional fields from UVC 1.0 */
0x00, 0x90, 0x00, 0x00, /* No. of bytes device can rx in single payload: 36KB */
0x00, 0x60, 0xE3, 0x16, /* Device Clock */
0x00, /* Framing Information - Ignored for uncompressed format*/
0x00, /* Preferred payload format version */
0x00, /* Minimum payload format version */
0x00 /* Maximum payload format version */
#endif
};
注意这里主机应用程序需要解码接收到的RAW10格式的数据,移除每个像素填充的6 bit的数据,以此得到正确的帧尺寸并且显示RAW10的视频。
例2:16 bit数据输出格式(CY_U3P_CSI_DF_YUV422_8_2)
将cyu3mipicsi.c中的输出格式从CY_U3P_CSI_DF_RAW10改为CY_U3P_CSI_DF_YUV422_8_2,可以移除填充的0。
假设用户正在传输分辨率为1920 x 1080,帧率为30 fps,RAW10格式的视频。则对应的像素宽度,像素高度,每像素bit,每秒帧数,帧尺寸和比特率按照如下方式计算:
a. 宽度(像素) :1920
b. 高度(像素) :1080
c. 每像素bit :10
d. 帧/秒 :30
e. 帧尺寸 :1920 x 1080 x 10 bit
f. 比特率 :1920 x 1080 x 10 x 30 bit/s
a. 宽度(像素) :1200
b. 高度(像素) :1080
c. 每像素bit :16
d. 帧/秒 :30
e. 帧尺寸 :1280 x 1080 x 16 bit
f. 比特率 :1920 x 1080 x 16 x 30 bit/s
在固件中对UVC Descriptor和Probe control structures作如下修改:
/* Class specific Uncompressed VS format descriptor */
0x1B, /* Descriptor size */
CX3_CS_INTRFC_DESCR, /* Class-specific VS interface Type */
0x04, /* Subtype: VS_FORMAT_UNCOMPRESSED */
0x01, /* Format desciptor index */
0x04, /* Number of Frame Descriptors that follow this descriptor: 3 */
/* GUID, globally unique identifier used to identify streaming-encoding format: YUY2 */
0x59, 0x55, 0x59, 0x32, /*MEDIASUBTYPE_YUY2 GUID: 32595559-0000-0010-8000-00AA00389B71 */
0x00, 0x00, 0x10, 0x00,
0x80, 0x00, 0x00, 0xAA,
0x00, 0x38, 0x9B, 0x71,
0x10, /* Number of bits per pixel: 16*/
0x01, /* Optimum Frame Index for this stream: 1 (1080p) */
0x00, /* X dimension of the picture aspect ratio; Non-interlaced */
0x00, /* Y dimension of the pictuer aspect ratio: Non-interlaced */
0x00, /* Interlace Flags: Progressive scanning, no interlace */
0x00, /* duplication of the video stream restriction: 0 - no restriction */
/* Class specific Uncompressed VS Frame Descriptor - 1080p@30fps */
0x1E, /*Descriptor size */
CX3_CS_INTRFC_DESCR, /* Descriptor type*/
0x05, /* Subtype: Uncompressed frame interface*/
0x01, /* Frame Descriptor Index: 1 */
0x00, /* No Still image capture supported */
0xB0, 0x04, /* Width in pixel: 1200 */
0x38, 0x04, /* Height in pixel: 1080 */
0x00, 0x30, 0x14, 0x25, /* Min bit rate (bits/s): 1080 x 1200 x 16 x 30 = 622080000*/
0x00, 0x80, 0x53, 0x3B, /* Max bit rate (bits/s): Fixed rate so same as Min */
0x00, 0x8D, 0x27, 0x00, /* Maximum video or still frame size in bytes(Deprecated: 1200x1080 x2*/
0x15, 0x16, 0x05, 0x00, /* Default frame interval (in 100ns units): (1/30)x10^7 */
0x01, /* Frame interval type : No of discrete intervals */
0x15, 0x16, 0x05, 0x00, /* Frame interval 3: Same as Default frame interval */
/* UVC Probe Control Setting - 1080p@30FPS */
uint8_t const gl1080pProbeCtrl[CX3_APP_MAX_PROBE_SETTING] = {
0x00, 0x00, /* bmHint : No fixed parameters */
0x01, /* Use 1st Video format index */
0x01, /* Use 1st Video frame index */
0x15, 0x16, 0x05, 0x00, /* Desired frame interval in 100ns = (1/30)x10^7 */
0x00, 0x00, /* Key frame rate in key frame/video frame units */
0x00, 0x00, /* PFrame rate in PFrame / key frame units */
0x00, 0x00, /* Compression quality control */
0x00, 0x00, /* Window size for average bit rate */
0x00, 0x00, /* Internal video streaming i/f latency in ms */
0x00, 0x8D, 0x27, 0x00, /* Max video frame size in bytes = 1200 x 1080 x 2 */
#ifdef CX3_UVC_1_0_SUPPORT
0x00, 0x90, 0x00, 0x00 /* No. of bytes device can rx in single payload: 36KB */
#else
/* UVC 1.1 Probe Control has additional fields from UVC 1.0 */
0x00, 0x90, 0x00, 0x00, /* No. of bytes device can rx in single payload: 36KB */
0x00, 0x60, 0xE3, 0x16, /* Device Clock */
0x00, /* Framing Information - Ignored for uncompressed format*/
0x00, /* Preferred payload format version */
0x00, /* Minimum payload format version */
0x00 /* Maximum payload format version */
#endif
};
例3:24 bit数据输出格式(CY_U3P_CSI_DF_RGB888)
在Image Sensor Configuration标签页里面将输出数据格式设置为24 bit将使得输入的RAW10格式的数据打包为24 bit的并行数据,之后通过MIPI CSI-2并行接口传送。在这种情况下,并没有多余填充的bit位。
RAW10格式的数据打包为24 bit时,对应的descriptors和Probe control structures 和16 bit时的没有区别,因此用户可以使用和例2里一样的descriptors和Probe control structures。
注: 参考阅读 AN90369 - How to Interface a MIPI CSI-2 Image Sensor With EZ-USB® CX3获得本篇KBA的补充信息。
1. CX3如何将输入的RAW10格式的数据打包为16/24 bit的输出格式?
回答:CX3具有MIPI CSI-2的接收端将串行的MIPI数据转换为并行格式。内置的GPIF II模块对并行数据采样并通过DMA通道发送到USB端。
如图 1所示,用户可以使用CX3配置工具选择相应的输入格式和输出格式。
假设图像传感器输出RAW10格式的数据流,分辨率为1080p,帧率30 fps。
1. 选择Input Video Format为RAW10,Output Video Format为16 bit,并在Image Sensor Configuration标签页里填入其他传输1080p@30 fps视频流所需要的参数。
2. 如图 2所示,跳转到CX3 Receiver Configuration页,调整MIPI CSI-2接收端模块。MIPI CSI-2 Inputs中的格式为RAW10,并且CX3 MIPI interface中的数据格式为RAW10。这意味着,MIPI CSI-2会将输入的串行RAW10数据转换为并行的10 bit数据。
3. 然而,内置固定的GPIF II模块支持配置为8/16/24 bit数据总线。在这个例子中,GPIF II模块配置为16 bit的数据总线模式。因此,它在每个clock采样16 bit的数据。在这16 bit的采样中,只有10 bit是真实有效的数据,其他的6 bit是每个时钟填充的多余bit。这将会使得每个像素的尺寸变大为实际尺寸的1.6倍,从而每一帧的尺寸增大为实际尺寸的1.6倍。用户应该移除这多余的6 bit以在主机端应用中显示实际帧大小。
图 1. Image Sensor Configuration
图 2. CX3 MIPI Receiver Configuration
上述设置对应的MIPI CSI-2配置如下:
/* XYZ_Sensor_RAW10_Resolution0 : */
CyU3PMipicsiCfg_t XYZ_Sensor_RAW10_Resolution0 =
{
CY_U3P_CSI_DF_RAW10, /* CyU3PMipicsiDataFormat_t dataFormat */
2, /* uint8_t numDataLanes */
2, /* uint8_t pllPrd */
89, /* uint16_t pllFbd */
CY_U3P_CSI_PLL_FRS_250_500M, /* CyU3PMipicsiPllClkFrs_t pllFrs */
CY_U3P_CSI_PLL_CLK_DIV_4, /* CyU3PMipicsiPllClkDiv_t csiRxClkDiv */
CY_U3P_CSI_PLL_CLK_DIV_4, /* CyU3PMipicsiPllClkDiv_t parClkDiv */
0, /* uint16_t mClkCtl */
CY_U3P_CSI_PLL_CLK_DIV_2, /* CyU3PMipicsiPllClkDiv_t mClkRefDiv */
1920, /* uint16_t hResolution */
50 /* uint16_t fifoDelay */
};
将上述配置中的CY_U3P_CSI_DF_RAW10替换为CY_U3P_CSI_DF_YUV422_8_2,或者在Image Sensor Configuration标签页中将选择输出格式为24 bit,都可以每像素将多余的6 bit移除。
注意 MIPI CSI Configuration中的Output data format将决定填充0的数量,并不影响传输视频流的格式。
下面讨论这两种情况。
A. 将CY_U3P_CSI_DF_RAW10替换为CY_U3P_CSI_DF_YUV422_8_2:
将Output data format设置为CY_U3P_CSI_DF_YUV422_8_2时,输入的RAW10格式的数据将会打包为16 bit的并行数据,并通过MIPI CSI-2接口发送。此时,没有额外填充的数据。
注意在这种情况下,用户只需要修改cyu3mipicsi.c中的输出格式,CX3 Receiver Configuration标签页中的时钟设置无需改变。因此,这种配置不适用于时钟需要改变的场景。如果遇到此类问题,请联系Cypress技术支持。
RAW10的输入数据按照如下的规则打包为16 bit的数据:
a. MIPI CSI-2按照图 3所示的格式接收RAW10标准格式数据(来源:MIPI Alliance Specification for Camera Serial interface 2 (CSI-2))
b. 输入的串行RAW10格式的数据按照如下的规则转换为并行16 bit数据;随后GPIF II对其进行采样。
i.e. GPIF II在每个时钟周期接收16 bit数据:
§ 第一个时钟周期:P1[9:2] P2[9:2]
§ 第二个时钟周期:P3[9:2] P4[9:2]
§ 第三个时钟周期:P1[1:0] P2[1:0] P3[1:0] P4[1:0] P5[9:2]
§ 第四个时钟周期:依此类推
图 3. RAW10传输格式 (来源: MIPI Alliance Specification for Camera Serial Interface 2)
注意当Output data format选择为16 bit时,GPIF II应当配置为16 bit数据总线格式。当数据从RAW10打包为16 bit的格式时,每帧的行尺寸需要为16的整数倍。
B. Output data format选择为24 bit
当Image Sensor Configuration标签页中的Output data format选择为24 bit时,输入的RAW10格式的数据将会被打包为24 bit的并行数据,并通过MIPI CSI-2并行接口发送出去。此时并没有额外填充的数据。
输入的串行RAW10格式的数据按照如下的规则转换为并行24 bit数据;随后GPIF II对其进行采样。
也就是说,GPIF II在每个时钟周期都采样24 bit的数据
§ 第一个时钟周期 - P1[9:2],P2[9:2],P3[9:2]
§ 第二个时钟周期 – P4[9:2],P1[1:0],P2[1:0],P3[1:0],P4[1:0],P5[9:2]
§ 第三个时钟周期 – 依此类推
注意,当选择Output data format为24 bit时,GPIF II需要设置为24 bit数据总线。当数据从RAW10打包为24 bit的格式时,每帧的行尺寸需要为24的整数倍。
2. 为了传输RAW10格式的视频,如何设置USB descriptor和Probe Control structure?
Microsoft提供的标准的UVC驱动借助GUID值传输视频流。标准驱动并不支持传输RAW格式的视频,因此Microsoft并没有为RAW格式提供GUID值。因此标准UVC驱动不能传输RAW格式。
然而,用户可以采取以下的替代方法传输RAW格式视频流,并且无明显播放限制。此时,用户需要客制化主机端应用以便更好的播放视频。
1. 采用Microsoft提供的Uncompressed Video Streaming(VS) format descriptor。
2. 根据CX3 MIPI bridge输入和输出的数据格式,设置相应的USB descriptor(包括Uncompressed VS format descriptor和Uncompressed VS frame Descriptor)和Probe control structure。
按照上述的设置,UVC驱动可以传输数据;主机程序可以根据第一步中提供的GUID值对数据进行解码。但是此时用户往往会看到一些色块而不是正确的图像。因为输入的数据是RAW格式而主机程序按照YUY2的标准格式进行解码。尽管视频,用户也可以用这种方法调试UVC设备。
下面列出了输出RAW10为三种不同格式的UVC descriptor和Probe control structure的例子。如所示,用户可以自行对固件中的UVC descriptor和Probe control structure做必要的修改。如果需要正常显示视频,用户需要对主机端软件进行客制化。
例1:RAW10输出格式(CY_U3P_CSI_DF_RAW10)
假设传输的是1920x1080,30 fps的RAW10视频,相关参数如下:
b. 高度(像素) :1080
c. 每像素bit :10
d. 帧/秒 :30
e. 帧尺寸 :1920 x 1080 x 10 bit
f. 比特率 :1920 x 1080 x 10 x 30 bit/s
在上述配置中,对于RAW10的输出格式,GPIF II接口需要配置为16 bit的并行口。对应的每个像素多填充6 bit,导致帧尺寸增大。因此需要修改计算结果如下:
a. 宽度(像素) :1920
b. 高度(像素) :1080
c. 每像素bit :16(因为每像素填充的6 bit)
d. 帧/秒 :30
e. 帧尺寸 :1920 x 1080 x 16 bit
f. 比特率 :1920 x 1080 x 16 x 30 bit/s
USB descriptor和Probe control structure如下所示:
/* Class specific Uncompressed VS format descriptor */
0x1B, /* Descriptor size */
CX3_CS_INTRFC_DESCR, /* Class-specific VS interface Type */
0x04, /* Subtype : VS_FORMAT_UNCOMPRESSED */
0x01, /* Format desciptor index */
0x04, /* Number of Frame Descriptors that follow this descriptor: 3 */
/* GUID, globally unique identifier used to identify streaming-encoding format: YUY2 */
0x59, 0x55, 0x59, 0x32, /*MEDIASUBTYPE_YUY2 GUID: 32595559-0000-0010-8000-00AA00389B71 */
0x00, 0x00, 0x10, 0x00,
0x80, 0x00, 0x00, 0xAA,
0x00, 0x38, 0x9B, 0x71,
0x10, /* Number of bits per pixel: 16*/
0x01, /* Optimum Frame Index for this stream: 2 (1080p) */
0x00, /* X dimension of the picture aspect ratio; Non-interlaced */
0x00, /* Y dimension of the pictuer aspect ratio: Non-interlaced */
0x00, /* Interlace Flags: Progressive scanning, no interlace */
0x00, /* duplication of the video stream restriction: 0 - no restriction */
/* Class specific Uncompressed VS Frame Descriptor - 1080p@30fps */
0x1E, /* Descriptor size */
CX3_CS_INTRFC_DESCR, /* Descriptor type*/
0x05, /* Subtype: Uncompressed frame interface*/
0x01, /* Frame Descriptor Index: 1 */
0x00, /* No Still image capture supported */
0x80, 0x07, /* Width in pixel: 1920 */
0x38, 0x04, /* Height in pixel: 1080 */
0x00, 0x80, 0x53, 0x3B, /* Min bit rate (bits/s): 1080 x 1920 x 16 x 30 = 995328000 */
0x00, 0x80, 0x53, 0x3B, /* Max bit rate (bits/s): Fixed rate so same as Min */
0x00, 0x48, 0x3F, 0x00, /* Maximum video or still frame size in bytes(Deprecated: 1920x1080 x2*/
0x15, 0x16, 0x05, 0x00, /* Default frame interval (in 100ns units): (1/30)x10^7 */
0x01, /* Frame interval type : No of discrete intervals */
0x15, 0x16, 0x05, 0x00, /* Frame interval 3: Same as Default frame interval */
/* UVC Probe Control Setting - 1080p@30FPS */
uint8_t const gl1080pProbeCtrl[CX3_APP_MAX_PROBE_SETTING] ={
0x00, 0x00, /* bmHint : No fixed parameters */
0x01, /* Use 1st Video format index */
0x01, /* Use 1st Video frame index */
0x15, 0x16, 0x05, 0x00, /* Desired frame interval in 100ns = (1/30)x10^7 */
0x00, 0x00, /* Key frame rate in key frame/video frame units */
0x00, 0x00, /* PFrame rate in PFrame / key frame units */
0x00, 0x00, /* Compression quality control */
0x00, 0x00, /* Window size for average bit rate */
0x00, 0x00, /* Internal video streaming i/f latency in ms */
0x00, 0x48, 0x3F, 0x00, /* Max video frame size in bytes = 1920 x 1080 x 2 */
#ifdef CX3_UVC_1_0_SUPPORT
0x00, 0x90, 0x00, 0x00 /* No. of bytes device can rx in single payload: 36KB */
#else
/* UVC 1.1 Probe Control has additional fields from UVC 1.0 */
0x00, 0x90, 0x00, 0x00, /* No. of bytes device can rx in single payload: 36KB */
0x00, 0x60, 0xE3, 0x16, /* Device Clock */
0x00, /* Framing Information - Ignored for uncompressed format*/
0x00, /* Preferred payload format version */
0x00, /* Minimum payload format version */
0x00 /* Maximum payload format version */
#endif
};
注意这里主机应用程序需要解码接收到的RAW10格式的数据,移除每个像素填充的6 bit的数据,以此得到正确的帧尺寸并且显示RAW10的视频。
例2:16 bit数据输出格式(CY_U3P_CSI_DF_YUV422_8_2)
将cyu3mipicsi.c中的输出格式从CY_U3P_CSI_DF_RAW10改为CY_U3P_CSI_DF_YUV422_8_2,可以移除填充的0。
假设用户正在传输分辨率为1920 x 1080,帧率为30 fps,RAW10格式的视频。则对应的像素宽度,像素高度,每像素bit,每秒帧数,帧尺寸和比特率按照如下方式计算:
a. 宽度(像素) :1920
b. 高度(像素) :1080
c. 每像素bit :10
d. 帧/秒 :30
e. 帧尺寸 :1920 x 1080 x 10 bit
f. 比特率 :1920 x 1080 x 10 x 30 bit/s
a. 宽度(像素) :1200
b. 高度(像素) :1080
c. 每像素bit :16
d. 帧/秒 :30
e. 帧尺寸 :1280 x 1080 x 16 bit
f. 比特率 :1920 x 1080 x 16 x 30 bit/s
在固件中对UVC Descriptor和Probe control structures作如下修改:
/* Class specific Uncompressed VS format descriptor */
0x1B, /* Descriptor size */
CX3_CS_INTRFC_DESCR, /* Class-specific VS interface Type */
0x04, /* Subtype: VS_FORMAT_UNCOMPRESSED */
0x01, /* Format desciptor index */
0x04, /* Number of Frame Descriptors that follow this descriptor: 3 */
/* GUID, globally unique identifier used to identify streaming-encoding format: YUY2 */
0x59, 0x55, 0x59, 0x32, /*MEDIASUBTYPE_YUY2 GUID: 32595559-0000-0010-8000-00AA00389B71 */
0x00, 0x00, 0x10, 0x00,
0x80, 0x00, 0x00, 0xAA,
0x00, 0x38, 0x9B, 0x71,
0x10, /* Number of bits per pixel: 16*/
0x01, /* Optimum Frame Index for this stream: 1 (1080p) */
0x00, /* X dimension of the picture aspect ratio; Non-interlaced */
0x00, /* Y dimension of the pictuer aspect ratio: Non-interlaced */
0x00, /* Interlace Flags: Progressive scanning, no interlace */
0x00, /* duplication of the video stream restriction: 0 - no restriction */
/* Class specific Uncompressed VS Frame Descriptor - 1080p@30fps */
0x1E, /*Descriptor size */
CX3_CS_INTRFC_DESCR, /* Descriptor type*/
0x05, /* Subtype: Uncompressed frame interface*/
0x01, /* Frame Descriptor Index: 1 */
0x00, /* No Still image capture supported */
0xB0, 0x04, /* Width in pixel: 1200 */
0x38, 0x04, /* Height in pixel: 1080 */
0x00, 0x30, 0x14, 0x25, /* Min bit rate (bits/s): 1080 x 1200 x 16 x 30 = 622080000*/
0x00, 0x80, 0x53, 0x3B, /* Max bit rate (bits/s): Fixed rate so same as Min */
0x00, 0x8D, 0x27, 0x00, /* Maximum video or still frame size in bytes(Deprecated: 1200x1080 x2*/
0x15, 0x16, 0x05, 0x00, /* Default frame interval (in 100ns units): (1/30)x10^7 */
0x01, /* Frame interval type : No of discrete intervals */
0x15, 0x16, 0x05, 0x00, /* Frame interval 3: Same as Default frame interval */
/* UVC Probe Control Setting - 1080p@30FPS */
uint8_t const gl1080pProbeCtrl[CX3_APP_MAX_PROBE_SETTING] = {
0x00, 0x00, /* bmHint : No fixed parameters */
0x01, /* Use 1st Video format index */
0x01, /* Use 1st Video frame index */
0x15, 0x16, 0x05, 0x00, /* Desired frame interval in 100ns = (1/30)x10^7 */
0x00, 0x00, /* Key frame rate in key frame/video frame units */
0x00, 0x00, /* PFrame rate in PFrame / key frame units */
0x00, 0x00, /* Compression quality control */
0x00, 0x00, /* Window size for average bit rate */
0x00, 0x00, /* Internal video streaming i/f latency in ms */
0x00, 0x8D, 0x27, 0x00, /* Max video frame size in bytes = 1200 x 1080 x 2 */
#ifdef CX3_UVC_1_0_SUPPORT
0x00, 0x90, 0x00, 0x00 /* No. of bytes device can rx in single payload: 36KB */
#else
/* UVC 1.1 Probe Control has additional fields from UVC 1.0 */
0x00, 0x90, 0x00, 0x00, /* No. of bytes device can rx in single payload: 36KB */
0x00, 0x60, 0xE3, 0x16, /* Device Clock */
0x00, /* Framing Information - Ignored for uncompressed format*/
0x00, /* Preferred payload format version */
0x00, /* Minimum payload format version */
0x00 /* Maximum payload format version */
#endif
};
例3:24 bit数据输出格式(CY_U3P_CSI_DF_RGB888)
在Image Sensor Configuration标签页里面将输出数据格式设置为24 bit将使得输入的RAW10格式的数据打包为24 bit的并行数据,之后通过MIPI CSI-2并行接口传送。在这种情况下,并没有多余填充的bit位。
RAW10格式的数据打包为24 bit时,对应的descriptors和Probe control structures 和16 bit时的没有区别,因此用户可以使用和例2里一样的descriptors和Probe control structures。