1# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
2%YAML 1.2
3---
4$id: http://devicetree.org/schemas/media/video-interface-devices.yaml#
5$schema: http://devicetree.org/meta-schemas/core.yaml#
6
7title: Common Properties for Video Receiver and Transmitter Devices
8
9maintainers:
10  - Jacopo Mondi <jacopo@jmondi.org>
11  - Sakari Ailus <sakari.ailus@linux.intel.com>
12
13properties:
14  flash-leds:
15    $ref: /schemas/types.yaml#/definitions/phandle-array
16    description:
17      An array of phandles, each referring to a flash LED, a sub-node of the LED
18      driver device node.
19
20  lens-focus:
21    $ref: /schemas/types.yaml#/definitions/phandle
22    description:
23      A phandle to the node of the focus lens controller.
24
25  rotation:
26    $ref: /schemas/types.yaml#/definitions/uint32
27    enum: [ 0, 90, 180, 270 ]
28    description: |
29      The camera rotation is expressed as the angular difference in degrees
30      between two reference systems, one relative to the camera module, and one
31      defined on the external world scene to be captured when projected on the
32      image sensor pixel array.
33
34      A camera sensor has a 2-dimensional reference system 'Rc' defined by its
35      pixel array read-out order. The origin is set to the first pixel being
36      read out, the X-axis points along the column read-out direction towards
37      the last columns, and the Y-axis along the row read-out direction towards
38      the last row.
39
40      A typical example for a sensor with a 2592x1944 pixel array matrix
41      observed from the front is:
42
43              2591       X-axis          0
44                <------------------------+ 0
45                .......... ... ..........!
46                .......... ... ..........! Y-axis
47                           ...           !
48                .......... ... ..........!
49                .......... ... ..........! 1943
50                                         V
51
52      The external world scene reference system 'Rs' is a 2-dimensional
53      reference system on the focal plane of the camera module. The origin is
54      placed on the top-left corner of the visible scene, the X-axis points
55      towards the right, and the Y-axis points towards the bottom of the scene.
56      The top, bottom, left and right directions are intentionally not defined
57      and depend on the environment in which the camera is used.
58
59      A typical example of a (very common) picture of a shark swimming from left
60      to right, as seen from the camera, is:
61
62               0               X-axis
63             0 +------------------------------------->
64               !
65               !
66               !
67               !           |\____)\___
68               !           ) _____  __`<
69               !           |/     )/
70               !
71               !
72               !
73               V
74             Y-axis
75
76      with the reference system 'Rs' placed on the camera focal plane:
77
78                                  ¸.·˙!
79                              ¸.·˙    !
80                  _       ¸.·˙        !
81               +-/ \-+¸.·˙            !
82               | (o) |                ! Camera focal plane
83               +-----+˙·.¸            !
84                          ˙·.¸        !
85                              ˙·.¸    !
86                                  ˙·.¸!
87
88      When projected on the sensor's pixel array, the image and the associated
89      reference system 'Rs' are typically (but not always) inverted, due to the
90      camera module's lens optical inversion effect.
91
92      Assuming the above represented scene of the swimming shark, the lens
93      inversion projects the scene and its reference system onto the sensor
94      pixel array, seen from the front of the camera sensor, as follows:
95
96            Y-axis
97               ^
98               !
99               !
100               !
101               !            |\_____)\__
102               !            ) ____  ___.<
103               !            |/    )/
104               !
105               !
106               !
107             0 +------------------------------------->
108               0               X-axis
109
110      Note the shark being upside-down.
111
112      The resulting projected reference system is named 'Rp'.
113
114      The camera rotation property is then defined as the angular difference in
115      the counter-clockwise direction between the camera reference system 'Rc'
116      and the projected scene reference system 'Rp'. It is expressed in degrees
117      as a number in the range [0, 360[.
118
119      Examples
120
121      0 degrees camera rotation:
122
123
124                    Y-Rp
125                     ^
126              Y-Rc   !
127               ^     !
128               !     !
129               !     !
130               !     !
131               !     !
132               !     !
133               !     !
134               !     !
135               !   0 +------------------------------------->
136               !     0               X-Rp
137             0 +------------------------------------->
138               0               X-Rc
139
140
141                                X-Rc                0
142               <------------------------------------+ 0
143                           X-Rp                 0   !
144           <------------------------------------+ 0 !
145                                                !   !
146                                                !   !
147                                                !   !
148                                                !   !
149                                                !   !
150                                                !   !
151                                                !   !
152                                                !   V
153                                                !  Y-Rc
154                                                V
155                                               Y-Rp
156
157      90 degrees camera rotation:
158
159               0        Y-Rc
160             0 +-------------------->
161               !   Y-Rp
162               !    ^
163               !    !
164               !    !
165               !    !
166               !    !
167               !    !
168               !    !
169               !    !
170               !    !
171               !    !
172               !  0 +------------------------------------->
173               !    0              X-Rp
174               !
175               !
176               !
177               !
178               V
179              X-Rc
180
181      180 degrees camera rotation:
182
183                                            0
184       <------------------------------------+ 0
185                        X-Rc                !
186              Y-Rp                          !
187               ^                            !
188               !                            !
189               !                            !
190               !                            !
191               !                            !
192               !                            !
193               !                            !
194               !                            V
195               !                           Y-Rc
196             0 +------------------------------------->
197               0              X-Rp
198
199      270 degrees camera rotation:
200
201               0        Y-Rc
202             0 +-------------------->
203               !                                        0
204               !    <-----------------------------------+ 0
205               !                    X-Rp                !
206               !                                        !
207               !                                        !
208               !                                        !
209               !                                        !
210               !                                        !
211               !                                        !
212               !                                        !
213               !                                        !
214               !                                        V
215               !                                       Y-Rp
216               !
217               !
218               !
219               !
220               V
221              X-Rc
222
223
224      Example one - Webcam
225
226      A camera module installed on the user facing part of a laptop screen
227      casing used for video calls. The captured images are meant to be displayed
228      in landscape mode (width > height) on the laptop screen.
229
230      The camera is typically mounted upside-down to compensate the lens optical
231      inversion effect:
232
233                    Y-Rp
234              Y-Rc   ^
235               ^     !
236               !     !
237               !     !       |\_____)\__
238               !     !       ) ____  ___.<
239               !     !       |/    )/
240               !     !
241               !     !
242               !     !
243               !   0 +------------------------------------->
244               !     0           X-Rp
245             0 +------------------------------------->
246               0            X-Rc
247
248      The two reference systems are aligned, the resulting camera rotation is
249      0 degrees, no rotation correction needs to be applied to the resulting
250      image once captured to memory buffers to correctly display it to users:
251
252               +--------------------------------------+
253               !                                      !
254               !                                      !
255               !                                      !
256               !             |\____)\___              !
257               !             ) _____  __`<            !
258               !             |/     )/                !
259               !                                      !
260               !                                      !
261               !                                      !
262               +--------------------------------------+
263
264      If the camera sensor is not mounted upside-down to compensate for the lens
265      optical inversion, the two reference systems will not be aligned, with
266      'Rp' being rotated 180 degrees relatively to 'Rc':
267
268
269                        X-Rc                0
270       <------------------------------------+ 0
271                                            !
272              Y-Rp                          !
273               ^                            !
274               !                            !
275               !       |\_____)\__          !
276               !       ) ____  ___.<        !
277               !       |/    )/             !
278               !                            !
279               !                            !
280               !                            V
281               !                           Y-Rc
282             0 +------------------------------------->
283               0            X-Rp
284
285      The image once captured to memory will then be rotated by 180 degrees:
286
287               +--------------------------------------+
288               !                                      !
289               !                                      !
290               !                                      !
291               !              __/(_____/|             !
292               !            >.___  ____ (             !
293               !                 \(    \|             !
294               !                                      !
295               !                                      !
296               !                                      !
297               +--------------------------------------+
298
299      A software rotation correction of 180 degrees should be applied to
300      correctly display the image:
301
302               +--------------------------------------+
303               !                                      !
304               !                                      !
305               !                                      !
306               !             |\____)\___              !
307               !             ) _____  __`<            !
308               !             |/     )/                !
309               !                                      !
310               !                                      !
311               !                                      !
312               +--------------------------------------+
313
314      Example two - Phone camera
315
316      A camera installed on the back side of a mobile device facing away from
317      the user. The captured images are meant to be displayed in portrait mode
318      (height > width) to match the device screen orientation and the device
319      usage orientation used when taking the picture.
320
321      The camera sensor is typically mounted with its pixel array longer side
322      aligned to the device longer side, upside-down mounted to compensate for
323      the lens optical inversion effect:
324
325               0        Y-Rc
326             0 +-------------------->
327               !   Y-Rp
328               !    ^
329               !    !
330               !    !
331               !    !
332               !    !            |\_____)\__
333               !    !            ) ____  ___.<
334               !    !            |/    )/
335               !    !
336               !    !
337               !    !
338               !  0 +------------------------------------->
339               !    0                X-Rp
340               !
341               !
342               !
343               !
344               V
345              X-Rc
346
347      The two reference systems are not aligned and the 'Rp' reference system is
348      rotated by 90 degrees in the counter-clockwise direction relatively to the
349      'Rc' reference system.
350
351      The image once captured to memory will be rotated:
352
353               +-------------------------------------+
354               |                 _ _                 |
355               |                \   /                |
356               |                 | |                 |
357               |                 | |                 |
358               |                 |  >                |
359               |                <  |                 |
360               |                 | |                 |
361               |                   .                 |
362               |                  V                  |
363               +-------------------------------------+
364
365      A correction of 90 degrees in counter-clockwise direction has to be
366      applied to correctly display the image in portrait mode on the device
367      screen:
368
369                        +--------------------+
370                        |                    |
371                        |                    |
372                        |                    |
373                        |                    |
374                        |                    |
375                        |                    |
376                        |   |\____)\___      |
377                        |   ) _____  __`<    |
378                        |   |/     )/        |
379                        |                    |
380                        |                    |
381                        |                    |
382                        |                    |
383                        |                    |
384                        +--------------------+
385
386  orientation:
387    description:
388      The orientation of a device (typically an image sensor or a flash LED)
389      describing its mounting position relative to the usage orientation of the
390      system where the device is installed on.
391    $ref: /schemas/types.yaml#/definitions/uint32
392    enum:
393        # Front. The device is mounted on the front facing side of the system. For
394        # mobile devices such as smartphones, tablets and laptops the front side
395        # is the user facing side.
396      - 0
397        # Back. The device is mounted on the back side of the system, which is
398        # defined as the opposite side of the front facing one.
399      - 1
400        # External. The device is not attached directly to the system but is
401        # attached in a way that allows it to move freely.
402      - 2
403
404additionalProperties: true
405
406...
407