85 lines · plain
1.. SPDX-License-Identifier: GPL-2.02 3DW100 dewarp driver4===================5 6The Vivante DW100 Dewarp Processor IP core found on i.MX8MP SoC applies a7programmable geometrical transformation on the input image to correct distortion8introduced by lenses.9 10The transformation function is exposed by the hardware as a grid map with 16x1611pixel macroblocks indexed using X, Y vertex coordinates.12::13 14 Image width15 <--------------------------------------->16 17 ^ .-------.-------.-------.-------.-------.18 | | 16x16 | | | | |19 I | | pixel | | | | |20 m | | block | | | | |21 a | .-------.-------.-------.-------.-------.22 g | | | | | | |23 e | | | | | | |24 | | | | | | |25 h | .-------.-------.-------.-------.-------.26 e | | | | | | |27 i | | | | | | |28 g | | | | | | |29 h | .-------.-------.-------.-------.-------.30 t | | | | | | |31 | | | | | | |32 | | | | | | |33 v '-------'-------'-------'-------'-------'34 35 Grid of Image Blocks for Dewarping Map36 37 38Each x, y coordinate register uses 16 bits to record the coordinate address in39an unsigned 12.4 fixed point format (UQ12.4).40::41 42 .----------------------.--------..----------------------.--------.43 | 31~20 | 19~16 || 15~4 | 3~0 |44 | (integer) | (frac) || (integer) | (frac) |45 '----------------------'--------''----------------------'--------'46 <-------------------------------><------------------------------->47 Y coordinate X coordinate48 49 Remap Register Layout50 51The dewarping map is set from applications using the52V4L2_CID_DW100_DEWARPING_16x16_VERTEX_MAP control. The control contains53an array of u32 values storing (x, y) destination coordinates for each54vertex of the grid. The x coordinate is stored in the 16 LSBs and the y55coordinate in the 16 MSBs.56 57The number of elements in the array must match the image size:58 59.. code-block:: C60 61 elems = (DIV_ROUND_UP(width, 16) + 1) * (DIV_ROUND_UP(height, 16) + 1);62 63If the control has not been set by the application, the driver uses an identity64map.65 66More details on the DW100 hardware operations can be found in67*chapter 13.15 DeWarp* of IMX8MP_ reference manual.68 69The Vivante DW100 m2m driver implements the following driver-specific control:70 71``V4L2_CID_DW100_DEWARPING_16x16_VERTEX_MAP (__u32 array)``72 Specifies to DW100 driver its dewarping map (aka LUT) blob as described in73 *chapter 13.15.2.3 Dewarping Remap* of IMX8MP_ reference manual as an U3274 dynamic array. The image is divided into many small 16x16 blocks. If the75 width/height of the image is not divisible by 16, the size of the76 rightmost/bottommost block is the remainder. The dewarping map only saves77 the vertex coordinates of the block. The dewarping grid map is comprised of78 vertex coordinates for x and y. Each x, y coordinate register uses 16 bits79 (UQ12.4) to record the coordinate address, with the Y coordinate in the80 upper bits and X in the lower bits. The driver modifies the dimensions of81 this control when the sink format is changed, to reflect the new input82 resolution.83 84.. _IMX8MP: https://www.nxp.com/webapp/Download?colCode=IMX8MPRM85