Figure 8-22 shows how the synchronization codes for the CAL internal pipeline are extracted from the CSI-2 stream. CSI-2 PPI IF corresponds to the byte stream after lane merge and PHY LS -> HS transition detection. CSI-2 LL state corresponds to the internal state of the TAG generation engine. CAL pipeline corresponds to the tags sent to the CAL processing pipeline.
Data is packed into words of 64-bits before it can be sent to the shared CAL processing pipeline. Each PPI has its own TAG generation & packing state machine. Both CSI2 PHYs are therefore independent and can operate simultaneously. Each PPI FSM has 8 copies of the CAL_CSI2_CTXy_l (y = [0 to 7], CAL_CSI2_CTX0_l through CAL_CSI2_CTX7_l) state registers (that is, contexts).
To use a context, SW must define:
- The used virtual channel (through CAL_CSI2_CTXy_l[7:0] VC register bit-field)
- The expected MIPI CSI-2 Data Type (through CAL_CSI2_CTXy_l[5:0] DT bit-field)
- The CPORT ID to use (through CAL_CSI2_CTXy_l[12:8] CPORT bit-field) for the data, and if it should be tagged as Attribute (that is, Embedded) data or as Pixel data (through CAL_CSI2_CTXy_l[13] ATT bit).
Attribute data is tagged using ATT_DAT_S, ATT_DAT and ATT_E tags. Pixel data is tagged using PIX_DAT_FS, PIX_DAT, PIX_DAT_LE, PIX_DAT_LS, PIX_DAT_FE. Data reception is disabled by setting CAL_CSI2_CTXy_l[5:0] DT bit to 0.
The tag generation FSM accumulates words of up to 64-bits of data from the physical interface. Two SW selectable modes are supported:
- Line mode (set by CAL_CSI2_CTXy_l[14] PACK_MODE = 0). In this mode CAL generates frame (PIX_DAT_FS; PIX_DAT_FE) and line (PIX_DAT_LS, PIX_DAT_LE) synchronization codes using synchronization information provided by the CSI-2 transmitter. It pads words with 0's when the line end or frame end is reached and generates the adequate data validity qualifier (VQ). Line and frame starts always correspond to full 64-bit words (VQ=0x0). This is typically the mode to be used to receive pixel data.
- Frame mode (set by CAL_CSI2_CTXy_l[14] PACK_MODE = 1). In this mode CAL only generates PIX_DAT_FS and PIX_DAT_FE synchronization codes. PIX_DAT_LE and PIX_DAT_LS are replaced by PIX_DAT and adequate data validity qualifiers are generated to create a contiguous stream. This mode is typically used to receive a JPEG frame from a CSI-2 camera.
This appended dummy data can be cropped by the Write DMA, or the hardware accelerator attached to the Video port. The shared CAL processing pipeline therefore always receives full 64-bit words. The line length is detected from the CSI-2 long packet header and mismatches are detected through CRC errors.
The tag generation FSM ensures that only valid TAG sequences can be provided to the shared CAL processing pipeline. FS, LS and LE codes are directly extracted from the CSI-2 stream. The FE code is not directly available and can be generated by two mechanisms:
- If SW knows the number of lines transmitted by the camera, it must write it into the CAL_CSI2_CTXy_l[29:16] LINES register bit-field. The tag generation FSM will send a FE TAG for the last received line of each frame instead of the LE TAG. This leads to regular video timings and avoids potential artifacts. CAL generates the FE_CODE tag when the FE short packet is received earlier than expected (for example, incorrect configuration or lines discarded due to transmission errors). The PIX_DATA_FE tag is generated at the end of the last line specified in CAL_CSI2_CTXy_l[29:16] LINES bit-field. Additional lines received for the same frame are discarded.
- If the number of lines is not known, SW must set the CAL_CSI2_CTXy_l[29:16] LINES register bit-field to 0. The tag generation FSM sends the PIX_DAT_LE TAG for the last line in the case and FE_CODE tag line when a FE short packet is received.
No LS/LE tags are generated when CAL_CSI2_CTXy_l[13] ATT = 1.
Figure 8-23 through Figure 8-26 illustrate the operation of the packing stage.
Data is discarded and an FIFO_OVR event is triggered when the CAL shared pipeline cannot accept the data from PPI interfaces fast enough. The tag generation FSM ensures however that only valid tag sequences can be generated:
- Only a few words are dropped in the middle of a line: corresponding data words are dropped and synchronization TAGs (LE or FE) are transmitted normally. The line where the overflow has occurred is therefore corrupted (that is, pixels shifted left), but synchronization is recovered from the next line start.
- The overflow condition persists over a line or frame boundary: one or multiple lines/frames are dropped. HW waits until one word becomes available in the PPI FIFO and inserts a data word with TAG FE. It then waits for the next FS to resume normal operation.
No specific SW intervention is required to recover synchronization and the HW ensures that no protocol violations or accesses outside of allocated buffers could occur.
Note: Optional MIPI CSI-2 LS and LE short packets are ignored by CAL. They are allowed in the datastream from the camera, but are not used and not forwarded to the CAL shared processing pipeline.
CAL does not have a specific mechanism to ignore CRC checking. SW must simply disable the CS_IRQ event. CAL does not discard data with invalid CRC.