dw100.rst 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. .. SPDX-License-Identifier: GPL-2.0
  2. DW100 dewarp driver
  3. ===================
  4. The Vivante DW100 Dewarp Processor IP core found on i.MX8MP SoC applies a
  5. programmable geometrical transformation on the input image to correct distortion
  6. introduced by lenses.
  7. The transformation function is exposed by the hardware as a grid map with 16x16
  8. pixel macroblocks indexed using X, Y vertex coordinates.
  9. ::
  10. Image width
  11. <--------------------------------------->
  12. ^ .-------.-------.-------.-------.-------.
  13. | | 16x16 | | | | |
  14. I | | pixel | | | | |
  15. m | | block | | | | |
  16. a | .-------.-------.-------.-------.-------.
  17. g | | | | | | |
  18. e | | | | | | |
  19. | | | | | | |
  20. h | .-------.-------.-------.-------.-------.
  21. e | | | | | | |
  22. i | | | | | | |
  23. g | | | | | | |
  24. h | .-------.-------.-------.-------.-------.
  25. t | | | | | | |
  26. | | | | | | |
  27. | | | | | | |
  28. v '-------'-------'-------'-------'-------'
  29. Grid of Image Blocks for Dewarping Map
  30. Each x, y coordinate register uses 16 bits to record the coordinate address in
  31. an unsigned 12.4 fixed point format (UQ12.4).
  32. ::
  33. .----------------------.--------..----------------------.--------.
  34. | 31~20 | 19~16 || 15~4 | 3~0 |
  35. | (integer) | (frac) || (integer) | (frac) |
  36. '----------------------'--------''----------------------'--------'
  37. <-------------------------------><------------------------------->
  38. Y coordinate X coordinate
  39. Remap Register Layout
  40. The dewarping map is set from applications using the
  41. V4L2_CID_DW100_DEWARPING_16x16_VERTEX_MAP control. The control contains
  42. an array of u32 values storing (x, y) destination coordinates for each
  43. vertex of the grid. The x coordinate is stored in the 16 LSBs and the y
  44. coordinate in the 16 MSBs.
  45. The number of elements in the array must match the image size:
  46. .. code-block:: C
  47. elems = (DIV_ROUND_UP(width, 16) + 1) * (DIV_ROUND_UP(height, 16) + 1);
  48. If the control has not been set by the application, the driver uses an identity
  49. map.
  50. More details on the DW100 hardware operations can be found in
  51. *chapter 13.15 DeWarp* of IMX8MP_ reference manual.
  52. The Vivante DW100 m2m driver implements the following driver-specific control:
  53. ``V4L2_CID_DW100_DEWARPING_16x16_VERTEX_MAP (__u32 array)``
  54. Specifies to DW100 driver its dewarping map (aka LUT) blob as described in
  55. *chapter 13.15.2.3 Dewarping Remap* of IMX8MP_ reference manual as an U32
  56. dynamic array. The image is divided into many small 16x16 blocks. If the
  57. width/height of the image is not divisible by 16, the size of the
  58. rightmost/bottommost block is the remainder. The dewarping map only saves
  59. the vertex coordinates of the block. The dewarping grid map is comprised of
  60. vertex coordinates for x and y. Each x, y coordinate register uses 16 bits
  61. (UQ12.4) to record the coordinate address, with the Y coordinate in the
  62. upper bits and X in the lower bits. The driver modifies the dimensions of
  63. this control when the sink format is changed, to reflect the new input
  64. resolution.
  65. .. _IMX8MP: https://www.nxp.com/webapp/Download?colCode=IMX8MPRM