summaryrefslogtreecommitdiff
path: root/Documentation/userspace-api/media/drivers/dw100.rst
blob: fceea6ece62213b1b1a91ebfbc013189ea670725 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
.. SPDX-License-Identifier: GPL-2.0

DW100 dewarp driver
===================

The Vivante DW100 Dewarp Processor IP core found on i.MX8MP SoC applies a
programmable geometrical transformation on the input image to correct distortion
introduced by lenses.

The transformation function is exposed by the hardware as a grid map with 16x16
pixel macroblocks indexed using X, Y vertex coordinates.
::

                          Image width
           <--------------------------------------->

      ^    .-------.-------.-------.-------.-------.
      |    | 16x16 |       |       |       |       |
   I  |    | pixel |       |       |       |       |
   m  |    | block |       |       |       |       |
   a  |    .-------.-------.-------.-------.-------.
   g  |    |       |       |       |       |       |
   e  |    |       |       |       |       |       |
      |    |       |       |       |       |       |
   h  |    .-------.-------.-------.-------.-------.
   e  |    |       |       |       |       |       |
   i  |    |       |       |       |       |       |
   g  |    |       |       |       |       |       |
   h  |    .-------.-------.-------.-------.-------.
   t  |    |       |       |       |       |       |
      |    |       |       |       |       |       |
      |    |       |       |       |       |       |
      v    '-------'-------'-------'-------'-------'

            Grid of Image Blocks for Dewarping Map


Each x, y coordinate register uses 16 bits to record the coordinate address in
an unsigned 12.4 fixed point format (UQ12.4).
::

    .----------------------.--------..----------------------.--------.
    |         31~20        | 19~16  ||         15~4         |  3~0   |
    |       (integer)      | (frac) ||       (integer)      | (frac) |
    '----------------------'--------''----------------------'--------'
    <-------------------------------><------------------------------->
                Y coordinate                     X coordinate

                           Remap Register Layout

The dewarping map is set from applications using the
V4L2_CID_DW100_DEWARPING_16x16_VERTEX_MAP control. The control contains
an array of u32 values storing (x, y) destination coordinates for each
vertex of the grid. The x coordinate is stored in the 16 LSBs and the y
coordinate in the 16 MSBs.

The number of elements in the array must match the image size:

.. code-block:: C

    elems = (DIV_ROUND_UP(width, 16) + 1) * (DIV_ROUND_UP(height, 16) + 1);

If the control has not been set by the application, the driver uses an identity
map.

More details on the DW100 hardware operations can be found in
*chapter 13.15 DeWarp* of IMX8MP_ reference manual.

The Vivante DW100 m2m driver implements the following driver-specific control:

``V4L2_CID_DW100_DEWARPING_16x16_VERTEX_MAP (__u32 array)``
    Specifies to DW100 driver its dewarping map (aka LUT) blob as described in
    *chapter 13.15.2.3 Dewarping Remap* of IMX8MP_ reference manual as an U32
    dynamic array. The image is divided into many small 16x16 blocks. If the
    width/height of the image is not divisible by 16, the size of the
    rightmost/bottommost block is the remainder. The dewarping map only saves
    the vertex coordinates of the block. The dewarping grid map is comprised of
    vertex coordinates for x and y. Each x, y coordinate register uses 16 bits
    (UQ12.4) to record the coordinate address, with the Y coordinate in the
    upper bits and X in the lower bits. The driver modifies the dimensions of
    this control when the sink format is changed, to reflect the new input
    resolution.

.. _IMX8MP: https://www.nxp.com/webapp/Download?colCode=IMX8MPRM