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