Geometric distortions (barrel and pincushion), can be corrected on UYVY and NV12 data formats. Radial back mapping is used in this mode. An additional affine transform can be configured at the same time.
- Check and wait for the LDC_PCR[2] BUSY bit to become IDLE (0x0).
- Set the LDC_PCR[4:3] MODE bit field for UYVY (0x0) or NV12 data (0x2).
- Set the LDC_PCR[1] LDMAPEN bit to 1 to enable lens distortion back mapping.
- Set the input frame base address in the LDC_RD_BASE[31:0] RBASE bit field. The frame base address must be aligned on a 32-byte boundary.
- Set the input frame line offset in the LDC_RD_OFST[15:0] ROFST bit field.
- If reading the input image from a circular buffer:
- Set LDC_PCR[9]CIRCEN = 1.
- LDC computes the row number and applies a modulo operation. The absolute address in the buffer is computed from this wrap-around row and the column number and then data is fetched from the circular buffer. Set the circular buffer size in LDC_RD_OFST.MOD. In UYVY mode, the number of rows in the buffer is LDC_RD_OFST.MOD. In NV12 and NV21 modes, the number of rows in the Y buffer is LDC_RD_OFST.MOD and the number of rows in the Cb/Cr buffers is (LDC_RD_OFST.MOD / 2).
- Set the tile size in the LDC_BLOCK[15:8] OBH and LDC_BLOCK[7:0] OBW bit fields. See constraints on OBW in Table 9-2739
- Set the pixel pad in the LDC_BLOCK[19:16] PIXPAD bit field.
- Set the input frame size in LDC_INPUT_FRAME_SIZE[29:16] H and LDC_INPUT_FRAME_SIZE[13:0] W.
- Set the output frame size in the LDC_FRAME_SIZE[29:16] H and LDC_FRAME_SIZE[13:0] W bit fields. H and W values must be multiples of OBH and OBW, respectively.
- Set the starting output point in the LDC_INITXY[13:0] INITX and LDC_INITXY[29:16] INITY bit fields.
- Set the output frame starting address in the LDC_WR_BASE[31:0] WBASE bit field. The output frame must be 32-byte aligned.
- Set the output frame line offset in the LDC_WR_OFST[15:0] WOFST bit field.
- If the data format is NV12, set the 4:2:0 UV input plane base address in the LDC_420C_RD_BASE[31:0] RBASE bit field. This address must be 16-byte aligned.
- If the data format is NV12, set the 4:2:0 UV output plane base address in the LDC_420C_WR_BASE[31:0] WBASE bit field. This address must be 16-byte aligned.
- Set the mesh offset table pointer to the correct address ( LDC_MESHTABLE_BASE[31:0] BASE and LDC_MESHTABLE_OFST[15:0] OFST). Set the table downsampling factor for MxM downsampling in LDC_MESHTABLE_CONFIG[2:0] M.
- If the LDC is connected to image buffers where the output address is not updated for each tile, set the constant mode to 0x1 in the LDC_CONFIG[7] CNST_MD bit field.
- Set the Y plane interpolation type to bilinear or bicubic in the LDC_CONFIG[6] YINT_TYP bit.
- If also using affine transform, set the six affine transform parameters in the following bit fields:
If affine transform is not used, these need to be set to the following values:
- Set LDC_PCR[0] EN = 1 to start the LDC operation.
- Wait for the LDC_PCR[2] BUSY bit to become IDLE (0x0) or wait for the completion interrupt.