xref: /OK3568_Linux_fs/kernel/Documentation/devicetree/bindings/media/video-interfaces.txt (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593SmuzhiyunCommon bindings for video receiver and transmitter interfaces
2*4882a593Smuzhiyun
3*4882a593SmuzhiyunGeneral concept
4*4882a593Smuzhiyun---------------
5*4882a593Smuzhiyun
6*4882a593SmuzhiyunVideo data pipelines usually consist of external devices, e.g. camera sensors,
7*4882a593Smuzhiyuncontrolled over an I2C, SPI or UART bus, and SoC internal IP blocks, including
8*4882a593Smuzhiyunvideo DMA engines and video data processors.
9*4882a593Smuzhiyun
10*4882a593SmuzhiyunSoC internal blocks are described by DT nodes, placed similarly to other SoC
11*4882a593Smuzhiyunblocks.  External devices are represented as child nodes of their respective
12*4882a593Smuzhiyunbus controller nodes, e.g. I2C.
13*4882a593Smuzhiyun
14*4882a593SmuzhiyunData interfaces on all video devices are described by their child 'port' nodes.
15*4882a593SmuzhiyunConfiguration of a port depends on other devices participating in the data
16*4882a593Smuzhiyuntransfer and is described by 'endpoint' subnodes.
17*4882a593Smuzhiyun
18*4882a593Smuzhiyundevice {
19*4882a593Smuzhiyun	...
20*4882a593Smuzhiyun	ports {
21*4882a593Smuzhiyun		#address-cells = <1>;
22*4882a593Smuzhiyun		#size-cells = <0>;
23*4882a593Smuzhiyun
24*4882a593Smuzhiyun		port@0 {
25*4882a593Smuzhiyun			...
26*4882a593Smuzhiyun			endpoint@0 { ... };
27*4882a593Smuzhiyun			endpoint@1 { ... };
28*4882a593Smuzhiyun		};
29*4882a593Smuzhiyun		port@1 { ... };
30*4882a593Smuzhiyun	};
31*4882a593Smuzhiyun};
32*4882a593Smuzhiyun
33*4882a593SmuzhiyunIf a port can be configured to work with more than one remote device on the same
34*4882a593Smuzhiyunbus, an 'endpoint' child node must be provided for each of them.  If more than
35*4882a593Smuzhiyunone port is present in a device node or there is more than one endpoint at a
36*4882a593Smuzhiyunport, or port node needs to be associated with a selected hardware interface,
37*4882a593Smuzhiyuna common scheme using '#address-cells', '#size-cells' and 'reg' properties is
38*4882a593Smuzhiyunused.
39*4882a593Smuzhiyun
40*4882a593SmuzhiyunAll 'port' nodes can be grouped under optional 'ports' node, which allows to
41*4882a593Smuzhiyunspecify #address-cells, #size-cells properties independently for the 'port'
42*4882a593Smuzhiyunand 'endpoint' nodes and any child device nodes a device might have.
43*4882a593Smuzhiyun
44*4882a593SmuzhiyunTwo 'endpoint' nodes are linked with each other through their 'remote-endpoint'
45*4882a593Smuzhiyunphandles.  An endpoint subnode of a device contains all properties needed for
46*4882a593Smuzhiyunconfiguration of this device for data exchange with other device.  In most
47*4882a593Smuzhiyuncases properties at the peer 'endpoint' nodes will be identical, however they
48*4882a593Smuzhiyunmight need to be different when there is any signal modifications on the bus
49*4882a593Smuzhiyunbetween two devices, e.g. there are logic signal inverters on the lines.
50*4882a593Smuzhiyun
51*4882a593SmuzhiyunIt is allowed for multiple endpoints at a port to be active simultaneously,
52*4882a593Smuzhiyunwhere supported by a device.  For example, in case where a data interface of
53*4882a593Smuzhiyuna device is partitioned into multiple data busses, e.g. 16-bit input port
54*4882a593Smuzhiyundivided into two separate ITU-R BT.656 8-bit busses.  In such case bus-width
55*4882a593Smuzhiyunand data-shift properties can be used to assign physical data lines to each
56*4882a593Smuzhiyunendpoint node (logical bus).
57*4882a593Smuzhiyun
58*4882a593SmuzhiyunDocumenting bindings for devices
59*4882a593Smuzhiyun--------------------------------
60*4882a593Smuzhiyun
61*4882a593SmuzhiyunAll required and optional bindings the device supports shall be explicitly
62*4882a593Smuzhiyundocumented in device DT binding documentation. This also includes port and
63*4882a593Smuzhiyunendpoint nodes for the device, including unit-addresses and reg properties where
64*4882a593Smuzhiyunrelevant.
65*4882a593Smuzhiyun
66*4882a593SmuzhiyunPlease also see Documentation/devicetree/bindings/graph.txt .
67*4882a593Smuzhiyun
68*4882a593SmuzhiyunRequired properties
69*4882a593Smuzhiyun-------------------
70*4882a593Smuzhiyun
71*4882a593SmuzhiyunIf there is more than one 'port' or more than one 'endpoint' node or 'reg'
72*4882a593Smuzhiyunproperty is present in port and/or endpoint nodes the following properties
73*4882a593Smuzhiyunare required in a relevant parent node:
74*4882a593Smuzhiyun
75*4882a593Smuzhiyun - #address-cells : number of cells required to define port/endpoint
76*4882a593Smuzhiyun		    identifier, should be 1.
77*4882a593Smuzhiyun - #size-cells    : should be zero.
78*4882a593Smuzhiyun
79*4882a593Smuzhiyun
80*4882a593SmuzhiyunOptional properties
81*4882a593Smuzhiyun-------------------
82*4882a593Smuzhiyun
83*4882a593Smuzhiyun- flash-leds: An array of phandles, each referring to a flash LED, a sub-node
84*4882a593Smuzhiyun  of the LED driver device node.
85*4882a593Smuzhiyun
86*4882a593Smuzhiyun- lens-focus: A phandle to the node of the focus lens controller.
87*4882a593Smuzhiyun
88*4882a593Smuzhiyun- rotation: The camera rotation is expressed as the angular difference in
89*4882a593Smuzhiyun  degrees between two reference systems, one relative to the camera module, and
90*4882a593Smuzhiyun  one defined on the external world scene to be captured when projected on the
91*4882a593Smuzhiyun  image sensor pixel array.
92*4882a593Smuzhiyun
93*4882a593Smuzhiyun  A camera sensor has a 2-dimensional reference system 'Rc' defined by
94*4882a593Smuzhiyun  its pixel array read-out order. The origin is set to the first pixel
95*4882a593Smuzhiyun  being read out, the X-axis points along the column read-out direction
96*4882a593Smuzhiyun  towards the last columns, and the Y-axis along the row read-out
97*4882a593Smuzhiyun  direction towards the last row.
98*4882a593Smuzhiyun
99*4882a593Smuzhiyun  A typical example for a sensor with a 2592x1944 pixel array matrix
100*4882a593Smuzhiyun  observed from the front is:
101*4882a593Smuzhiyun
102*4882a593Smuzhiyun              2591       X-axis          0
103*4882a593Smuzhiyun                <------------------------+ 0
104*4882a593Smuzhiyun                .......... ... ..........!
105*4882a593Smuzhiyun                .......... ... ..........! Y-axis
106*4882a593Smuzhiyun                           ...           !
107*4882a593Smuzhiyun                .......... ... ..........!
108*4882a593Smuzhiyun                .......... ... ..........! 1943
109*4882a593Smuzhiyun                                         V
110*4882a593Smuzhiyun
111*4882a593Smuzhiyun  The external world scene reference system 'Rs' is a 2-dimensional
112*4882a593Smuzhiyun  reference system on the focal plane of the camera module. The origin is
113*4882a593Smuzhiyun  placed on the top-left corner of the visible scene, the X-axis points
114*4882a593Smuzhiyun  towards the right, and the Y-axis points towards the bottom of the
115*4882a593Smuzhiyun  scene. The top, bottom, left and right directions are intentionally not
116*4882a593Smuzhiyun  defined and depend on the environment in which the camera is used.
117*4882a593Smuzhiyun
118*4882a593Smuzhiyun  A typical example of a (very common) picture of a shark swimming from
119*4882a593Smuzhiyun  left to right, as seen from the camera, is:
120*4882a593Smuzhiyun
121*4882a593Smuzhiyun               0               X-axis
122*4882a593Smuzhiyun             0 +------------------------------------->
123*4882a593Smuzhiyun               !
124*4882a593Smuzhiyun               !
125*4882a593Smuzhiyun               !
126*4882a593Smuzhiyun               !           |\____)\___
127*4882a593Smuzhiyun               !           ) _____  __`<
128*4882a593Smuzhiyun               !           |/     )/
129*4882a593Smuzhiyun               !
130*4882a593Smuzhiyun               !
131*4882a593Smuzhiyun               !
132*4882a593Smuzhiyun               V
133*4882a593Smuzhiyun             Y-axis
134*4882a593Smuzhiyun
135*4882a593Smuzhiyun  with the reference system 'Rs' placed on the camera focal plane:
136*4882a593Smuzhiyun
137*4882a593Smuzhiyun                                  ¸.·˙!
138*4882a593Smuzhiyun                              ¸.·˙    !
139*4882a593Smuzhiyun                  _       ¸.·˙        !
140*4882a593Smuzhiyun               +-/ \-+¸.·˙            !
141*4882a593Smuzhiyun               | (o) |                ! Camera focal plane
142*4882a593Smuzhiyun               +-----+˙·.¸            !
143*4882a593Smuzhiyun                          ˙·.¸        !
144*4882a593Smuzhiyun                              ˙·.¸    !
145*4882a593Smuzhiyun                                  ˙·.¸!
146*4882a593Smuzhiyun
147*4882a593Smuzhiyun  When projected on the sensor's pixel array, the image and the associated
148*4882a593Smuzhiyun  reference system 'Rs' are typically (but not always) inverted, due to
149*4882a593Smuzhiyun  the camera module's lens optical inversion effect.
150*4882a593Smuzhiyun
151*4882a593Smuzhiyun  Assuming the above represented scene of the swimming shark, the lens
152*4882a593Smuzhiyun  inversion projects the scene and its reference system onto the sensor
153*4882a593Smuzhiyun  pixel array, seen from the front of the camera sensor, as follows:
154*4882a593Smuzhiyun
155*4882a593Smuzhiyun            Y-axis
156*4882a593Smuzhiyun               ^
157*4882a593Smuzhiyun               !
158*4882a593Smuzhiyun               !
159*4882a593Smuzhiyun               !
160*4882a593Smuzhiyun               !            |\_____)\__
161*4882a593Smuzhiyun               !            ) ____  ___.<
162*4882a593Smuzhiyun               !            |/    )/
163*4882a593Smuzhiyun               !
164*4882a593Smuzhiyun               !
165*4882a593Smuzhiyun               !
166*4882a593Smuzhiyun             0 +------------------------------------->
167*4882a593Smuzhiyun               0               X-axis
168*4882a593Smuzhiyun
169*4882a593Smuzhiyun  Note the shark being upside-down.
170*4882a593Smuzhiyun
171*4882a593Smuzhiyun  The resulting projected reference system is named 'Rp'.
172*4882a593Smuzhiyun
173*4882a593Smuzhiyun  The camera rotation property is then defined as the angular difference
174*4882a593Smuzhiyun  in the counter-clockwise direction between the camera reference system
175*4882a593Smuzhiyun  'Rc' and the projected scene reference system 'Rp'. It is expressed in
176*4882a593Smuzhiyun  degrees as a number in the range [0, 360[.
177*4882a593Smuzhiyun
178*4882a593Smuzhiyun  Examples
179*4882a593Smuzhiyun
180*4882a593Smuzhiyun  0 degrees camera rotation:
181*4882a593Smuzhiyun
182*4882a593Smuzhiyun
183*4882a593Smuzhiyun                    Y-Rp
184*4882a593Smuzhiyun                     ^
185*4882a593Smuzhiyun              Y-Rc   !
186*4882a593Smuzhiyun               ^     !
187*4882a593Smuzhiyun               !     !
188*4882a593Smuzhiyun               !     !
189*4882a593Smuzhiyun               !     !
190*4882a593Smuzhiyun               !     !
191*4882a593Smuzhiyun               !     !
192*4882a593Smuzhiyun               !     !
193*4882a593Smuzhiyun               !     !
194*4882a593Smuzhiyun               !   0 +------------------------------------->
195*4882a593Smuzhiyun               !     0               X-Rp
196*4882a593Smuzhiyun             0 +------------------------------------->
197*4882a593Smuzhiyun               0               X-Rc
198*4882a593Smuzhiyun
199*4882a593Smuzhiyun
200*4882a593Smuzhiyun                                X-Rc                0
201*4882a593Smuzhiyun               <------------------------------------+ 0
202*4882a593Smuzhiyun                           X-Rp                 0   !
203*4882a593Smuzhiyun           <------------------------------------+ 0 !
204*4882a593Smuzhiyun                                                !   !
205*4882a593Smuzhiyun                                                !   !
206*4882a593Smuzhiyun                                                !   !
207*4882a593Smuzhiyun                                                !   !
208*4882a593Smuzhiyun                                                !   !
209*4882a593Smuzhiyun                                                !   !
210*4882a593Smuzhiyun                                                !   !
211*4882a593Smuzhiyun                                                !   V
212*4882a593Smuzhiyun                                                !  Y-Rc
213*4882a593Smuzhiyun                                                V
214*4882a593Smuzhiyun                                               Y-Rp
215*4882a593Smuzhiyun
216*4882a593Smuzhiyun  90 degrees camera rotation:
217*4882a593Smuzhiyun
218*4882a593Smuzhiyun               0        Y-Rc
219*4882a593Smuzhiyun             0 +-------------------->
220*4882a593Smuzhiyun               !   Y-Rp
221*4882a593Smuzhiyun               !    ^
222*4882a593Smuzhiyun               !    !
223*4882a593Smuzhiyun               !    !
224*4882a593Smuzhiyun               !    !
225*4882a593Smuzhiyun               !    !
226*4882a593Smuzhiyun               !    !
227*4882a593Smuzhiyun               !    !
228*4882a593Smuzhiyun               !    !
229*4882a593Smuzhiyun               !    !
230*4882a593Smuzhiyun               !    !
231*4882a593Smuzhiyun               !  0 +------------------------------------->
232*4882a593Smuzhiyun               !    0              X-Rp
233*4882a593Smuzhiyun               !
234*4882a593Smuzhiyun               !
235*4882a593Smuzhiyun               !
236*4882a593Smuzhiyun               !
237*4882a593Smuzhiyun               V
238*4882a593Smuzhiyun              X-Rc
239*4882a593Smuzhiyun
240*4882a593Smuzhiyun  180 degrees camera rotation:
241*4882a593Smuzhiyun
242*4882a593Smuzhiyun                                            0
243*4882a593Smuzhiyun       <------------------------------------+ 0
244*4882a593Smuzhiyun                        X-Rc                !
245*4882a593Smuzhiyun              Y-Rp                          !
246*4882a593Smuzhiyun               ^                            !
247*4882a593Smuzhiyun               !                            !
248*4882a593Smuzhiyun               !                            !
249*4882a593Smuzhiyun               !                            !
250*4882a593Smuzhiyun               !                            !
251*4882a593Smuzhiyun               !                            !
252*4882a593Smuzhiyun               !                            !
253*4882a593Smuzhiyun               !                            V
254*4882a593Smuzhiyun               !                           Y-Rc
255*4882a593Smuzhiyun             0 +------------------------------------->
256*4882a593Smuzhiyun               0              X-Rp
257*4882a593Smuzhiyun
258*4882a593Smuzhiyun  270 degrees camera rotation:
259*4882a593Smuzhiyun
260*4882a593Smuzhiyun               0        Y-Rc
261*4882a593Smuzhiyun             0 +-------------------->
262*4882a593Smuzhiyun               !                                        0
263*4882a593Smuzhiyun               !    <-----------------------------------+ 0
264*4882a593Smuzhiyun               !                    X-Rp                !
265*4882a593Smuzhiyun               !                                        !
266*4882a593Smuzhiyun               !                                        !
267*4882a593Smuzhiyun               !                                        !
268*4882a593Smuzhiyun               !                                        !
269*4882a593Smuzhiyun               !                                        !
270*4882a593Smuzhiyun               !                                        !
271*4882a593Smuzhiyun               !                                        !
272*4882a593Smuzhiyun               !                                        !
273*4882a593Smuzhiyun               !                                        V
274*4882a593Smuzhiyun               !                                       Y-Rp
275*4882a593Smuzhiyun               !
276*4882a593Smuzhiyun               !
277*4882a593Smuzhiyun               !
278*4882a593Smuzhiyun               !
279*4882a593Smuzhiyun               V
280*4882a593Smuzhiyun              X-Rc
281*4882a593Smuzhiyun
282*4882a593Smuzhiyun
283*4882a593Smuzhiyun  Example one - Webcam
284*4882a593Smuzhiyun
285*4882a593Smuzhiyun  A camera module installed on the user facing part of a laptop screen
286*4882a593Smuzhiyun  casing used for video calls. The captured images are meant to be
287*4882a593Smuzhiyun  displayed in landscape mode (width > height) on the laptop screen.
288*4882a593Smuzhiyun
289*4882a593Smuzhiyun  The camera is typically mounted upside-down to compensate the lens
290*4882a593Smuzhiyun  optical inversion effect:
291*4882a593Smuzhiyun
292*4882a593Smuzhiyun                    Y-Rp
293*4882a593Smuzhiyun              Y-Rc   ^
294*4882a593Smuzhiyun               ^     !
295*4882a593Smuzhiyun               !     !
296*4882a593Smuzhiyun               !     !       |\_____)\__
297*4882a593Smuzhiyun               !     !       ) ____  ___.<
298*4882a593Smuzhiyun               !     !       |/    )/
299*4882a593Smuzhiyun               !     !
300*4882a593Smuzhiyun               !     !
301*4882a593Smuzhiyun               !     !
302*4882a593Smuzhiyun               !   0 +------------------------------------->
303*4882a593Smuzhiyun               !     0           X-Rp
304*4882a593Smuzhiyun             0 +------------------------------------->
305*4882a593Smuzhiyun               0            X-Rc
306*4882a593Smuzhiyun
307*4882a593Smuzhiyun  The two reference systems are aligned, the resulting camera rotation is
308*4882a593Smuzhiyun  0 degrees, no rotation correction needs to be applied to the resulting
309*4882a593Smuzhiyun  image once captured to memory buffers to correctly display it to users:
310*4882a593Smuzhiyun
311*4882a593Smuzhiyun               +--------------------------------------+
312*4882a593Smuzhiyun               !                                      !
313*4882a593Smuzhiyun               !                                      !
314*4882a593Smuzhiyun               !                                      !
315*4882a593Smuzhiyun               !             |\____)\___              !
316*4882a593Smuzhiyun               !             ) _____  __`<            !
317*4882a593Smuzhiyun               !             |/     )/                !
318*4882a593Smuzhiyun               !                                      !
319*4882a593Smuzhiyun               !                                      !
320*4882a593Smuzhiyun               !                                      !
321*4882a593Smuzhiyun               +--------------------------------------+
322*4882a593Smuzhiyun
323*4882a593Smuzhiyun  If the camera sensor is not mounted upside-down to compensate for the
324*4882a593Smuzhiyun  lens optical inversion, the two reference systems will not be aligned,
325*4882a593Smuzhiyun  with 'Rp' being rotated 180 degrees relatively to 'Rc':
326*4882a593Smuzhiyun
327*4882a593Smuzhiyun
328*4882a593Smuzhiyun                        X-Rc                0
329*4882a593Smuzhiyun       <------------------------------------+ 0
330*4882a593Smuzhiyun                                            !
331*4882a593Smuzhiyun              Y-Rp                          !
332*4882a593Smuzhiyun               ^                            !
333*4882a593Smuzhiyun               !                            !
334*4882a593Smuzhiyun               !       |\_____)\__          !
335*4882a593Smuzhiyun               !       ) ____  ___.<        !
336*4882a593Smuzhiyun               !       |/    )/             !
337*4882a593Smuzhiyun               !                            !
338*4882a593Smuzhiyun               !                            !
339*4882a593Smuzhiyun               !                            V
340*4882a593Smuzhiyun               !                           Y-Rc
341*4882a593Smuzhiyun             0 +------------------------------------->
342*4882a593Smuzhiyun               0            X-Rp
343*4882a593Smuzhiyun
344*4882a593Smuzhiyun  The image once captured to memory will then be rotated by 180 degrees:
345*4882a593Smuzhiyun
346*4882a593Smuzhiyun               +--------------------------------------+
347*4882a593Smuzhiyun               !                                      !
348*4882a593Smuzhiyun               !                                      !
349*4882a593Smuzhiyun               !                                      !
350*4882a593Smuzhiyun               !              __/(_____/|             !
351*4882a593Smuzhiyun               !            >.___  ____ (             !
352*4882a593Smuzhiyun               !                 \(    \|             !
353*4882a593Smuzhiyun               !                                      !
354*4882a593Smuzhiyun               !                                      !
355*4882a593Smuzhiyun               !                                      !
356*4882a593Smuzhiyun               +--------------------------------------+
357*4882a593Smuzhiyun
358*4882a593Smuzhiyun  A software rotation correction of 180 degrees should be applied to
359*4882a593Smuzhiyun  correctly display the image:
360*4882a593Smuzhiyun
361*4882a593Smuzhiyun               +--------------------------------------+
362*4882a593Smuzhiyun               !                                      !
363*4882a593Smuzhiyun               !                                      !
364*4882a593Smuzhiyun               !                                      !
365*4882a593Smuzhiyun               !             |\____)\___              !
366*4882a593Smuzhiyun               !             ) _____  __`<            !
367*4882a593Smuzhiyun               !             |/     )/                !
368*4882a593Smuzhiyun               !                                      !
369*4882a593Smuzhiyun               !                                      !
370*4882a593Smuzhiyun               !                                      !
371*4882a593Smuzhiyun               +--------------------------------------+
372*4882a593Smuzhiyun
373*4882a593Smuzhiyun  Example two - Phone camera
374*4882a593Smuzhiyun
375*4882a593Smuzhiyun  A camera installed on the back side of a mobile device facing away from
376*4882a593Smuzhiyun  the user. The captured images are meant to be displayed in portrait mode
377*4882a593Smuzhiyun  (height > width) to match the device screen orientation and the device
378*4882a593Smuzhiyun  usage orientation used when taking the picture.
379*4882a593Smuzhiyun
380*4882a593Smuzhiyun  The camera sensor is typically mounted with its pixel array longer side
381*4882a593Smuzhiyun  aligned to the device longer side, upside-down mounted to compensate for
382*4882a593Smuzhiyun  the lens optical inversion effect:
383*4882a593Smuzhiyun
384*4882a593Smuzhiyun               0        Y-Rc
385*4882a593Smuzhiyun             0 +-------------------->
386*4882a593Smuzhiyun               !   Y-Rp
387*4882a593Smuzhiyun               !    ^
388*4882a593Smuzhiyun               !    !
389*4882a593Smuzhiyun               !    !
390*4882a593Smuzhiyun               !    !
391*4882a593Smuzhiyun               !    !            |\_____)\__
392*4882a593Smuzhiyun               !    !            ) ____  ___.<
393*4882a593Smuzhiyun               !    !            |/    )/
394*4882a593Smuzhiyun               !    !
395*4882a593Smuzhiyun               !    !
396*4882a593Smuzhiyun               !    !
397*4882a593Smuzhiyun               !  0 +------------------------------------->
398*4882a593Smuzhiyun               !    0                X-Rp
399*4882a593Smuzhiyun               !
400*4882a593Smuzhiyun               !
401*4882a593Smuzhiyun               !
402*4882a593Smuzhiyun               !
403*4882a593Smuzhiyun               V
404*4882a593Smuzhiyun              X-Rc
405*4882a593Smuzhiyun
406*4882a593Smuzhiyun  The two reference systems are not aligned and the 'Rp' reference
407*4882a593Smuzhiyun  system is rotated by 90 degrees in the counter-clockwise direction
408*4882a593Smuzhiyun  relatively to the 'Rc' reference system.
409*4882a593Smuzhiyun
410*4882a593Smuzhiyun  The image once captured to memory will be rotated:
411*4882a593Smuzhiyun
412*4882a593Smuzhiyun               +-------------------------------------+
413*4882a593Smuzhiyun               |                 _ _                 |
414*4882a593Smuzhiyun               |                \   /                |
415*4882a593Smuzhiyun               |                 | |                 |
416*4882a593Smuzhiyun               |                 | |                 |
417*4882a593Smuzhiyun               |                 |  >                |
418*4882a593Smuzhiyun               |                <  |                 |
419*4882a593Smuzhiyun               |                 | |                 |
420*4882a593Smuzhiyun               |                   .                 |
421*4882a593Smuzhiyun               |                  V                  |
422*4882a593Smuzhiyun               +-------------------------------------+
423*4882a593Smuzhiyun
424*4882a593Smuzhiyun  A correction of 90 degrees in counter-clockwise direction has to be
425*4882a593Smuzhiyun  applied to correctly display the image in portrait mode on the device
426*4882a593Smuzhiyun  screen:
427*4882a593Smuzhiyun
428*4882a593Smuzhiyun                        +--------------------+
429*4882a593Smuzhiyun                        |                    |
430*4882a593Smuzhiyun                        |                    |
431*4882a593Smuzhiyun                        |                    |
432*4882a593Smuzhiyun                        |                    |
433*4882a593Smuzhiyun                        |                    |
434*4882a593Smuzhiyun                        |                    |
435*4882a593Smuzhiyun                        |   |\____)\___      |
436*4882a593Smuzhiyun                        |   ) _____  __`<    |
437*4882a593Smuzhiyun                        |   |/     )/        |
438*4882a593Smuzhiyun                        |                    |
439*4882a593Smuzhiyun                        |                    |
440*4882a593Smuzhiyun                        |                    |
441*4882a593Smuzhiyun                        |                    |
442*4882a593Smuzhiyun                        |                    |
443*4882a593Smuzhiyun                        +--------------------+
444*4882a593Smuzhiyun
445*4882a593Smuzhiyun- orientation: The orientation of a device (typically an image sensor or a flash
446*4882a593Smuzhiyun  LED) describing its mounting position relative to the usage orientation of the
447*4882a593Smuzhiyun  system where the device is installed on.
448*4882a593Smuzhiyun  Possible values are:
449*4882a593Smuzhiyun  0 - Front. The device is mounted on the front facing side of the system.
450*4882a593Smuzhiyun  For mobile devices such as smartphones, tablets and laptops the front side is
451*4882a593Smuzhiyun  the user facing side.
452*4882a593Smuzhiyun  1 - Back. The device is mounted on the back side of the system, which is
453*4882a593Smuzhiyun  defined as the opposite side of the front facing one.
454*4882a593Smuzhiyun  2 - External. The device is not attached directly to the system but is
455*4882a593Smuzhiyun  attached in a way that allows it to move freely.
456*4882a593Smuzhiyun
457*4882a593SmuzhiyunOptional endpoint properties
458*4882a593Smuzhiyun----------------------------
459*4882a593Smuzhiyun
460*4882a593Smuzhiyun- remote-endpoint: phandle to an 'endpoint' subnode of a remote device node.
461*4882a593Smuzhiyun- slave-mode: a boolean property indicating that the link is run in slave mode.
462*4882a593Smuzhiyun  The default when this property is not specified is master mode. In the slave
463*4882a593Smuzhiyun  mode horizontal and vertical synchronization signals are provided to the
464*4882a593Smuzhiyun  slave device (data source) by the master device (data sink). In the master
465*4882a593Smuzhiyun  mode the data source device is also the source of the synchronization signals.
466*4882a593Smuzhiyun- bus-type: data bus type. Possible values are:
467*4882a593Smuzhiyun  1 - MIPI CSI-2 C-PHY
468*4882a593Smuzhiyun  2 - MIPI CSI1
469*4882a593Smuzhiyun  3 - CCP2
470*4882a593Smuzhiyun  4 - MIPI CSI-2 D-PHY
471*4882a593Smuzhiyun  5 - Parallel
472*4882a593Smuzhiyun  6 - Bt.656
473*4882a593Smuzhiyun- bus-width: number of data lines actively used, valid for the parallel busses.
474*4882a593Smuzhiyun- data-shift: on the parallel data busses, if bus-width is used to specify the
475*4882a593Smuzhiyun  number of data lines, data-shift can be used to specify which data lines are
476*4882a593Smuzhiyun  used, e.g. "bus-width=<8>; data-shift=<2>;" means, that lines 9:2 are used.
477*4882a593Smuzhiyun- hsync-active: active state of the HSYNC signal, 0/1 for LOW/HIGH respectively.
478*4882a593Smuzhiyun- vsync-active: active state of the VSYNC signal, 0/1 for LOW/HIGH respectively.
479*4882a593Smuzhiyun  Note, that if HSYNC and VSYNC polarities are not specified, embedded
480*4882a593Smuzhiyun  synchronization may be required, where supported.
481*4882a593Smuzhiyun- data-active: similar to HSYNC and VSYNC, specifies data line polarity.
482*4882a593Smuzhiyun- data-enable-active: similar to HSYNC and VSYNC, specifies the data enable
483*4882a593Smuzhiyun  signal polarity.
484*4882a593Smuzhiyun- field-even-active: field signal level during the even field data transmission.
485*4882a593Smuzhiyun- pclk-sample: sample data on rising (1) or falling (0) edge of the pixel clock
486*4882a593Smuzhiyun  signal.
487*4882a593Smuzhiyun- sync-on-green-active: active state of Sync-on-green (SoG) signal, 0/1 for
488*4882a593Smuzhiyun  LOW/HIGH respectively.
489*4882a593Smuzhiyun- data-lanes: an array of physical data lane indexes. Position of an entry
490*4882a593Smuzhiyun  determines the logical lane number, while the value of an entry indicates
491*4882a593Smuzhiyun  physical lane, e.g. for 2-lane MIPI CSI-2 bus we could have
492*4882a593Smuzhiyun  "data-lanes = <1 2>;", assuming the clock lane is on hardware lane 0.
493*4882a593Smuzhiyun  If the hardware does not support lane reordering, monotonically
494*4882a593Smuzhiyun  incremented values shall be used from 0 or 1 onwards, depending on
495*4882a593Smuzhiyun  whether or not there is also a clock lane. This property is valid for
496*4882a593Smuzhiyun  serial busses only (e.g. MIPI CSI-2).
497*4882a593Smuzhiyun- clock-lanes: an array of physical clock lane indexes. Position of an entry
498*4882a593Smuzhiyun  determines the logical lane number, while the value of an entry indicates
499*4882a593Smuzhiyun  physical lane, e.g. for a MIPI CSI-2 bus we could have "clock-lanes = <0>;",
500*4882a593Smuzhiyun  which places the clock lane on hardware lane 0. This property is valid for
501*4882a593Smuzhiyun  serial busses only (e.g. MIPI CSI-2). Note that for the MIPI CSI-2 bus this
502*4882a593Smuzhiyun  array contains only one entry.
503*4882a593Smuzhiyun- clock-noncontinuous: a boolean property to allow MIPI CSI-2 non-continuous
504*4882a593Smuzhiyun  clock mode.
505*4882a593Smuzhiyun- link-frequencies: Allowed data bus frequencies. For MIPI CSI-2, for
506*4882a593Smuzhiyun  instance, this is the actual frequency of the bus, not bits per clock per
507*4882a593Smuzhiyun  lane value. An array of 64-bit unsigned integers.
508*4882a593Smuzhiyun- lane-polarities: an array of polarities of the lanes starting from the clock
509*4882a593Smuzhiyun  lane and followed by the data lanes in the same order as in data-lanes.
510*4882a593Smuzhiyun  Valid values are 0 (normal) and 1 (inverted). The length of the array
511*4882a593Smuzhiyun  should be the combined length of data-lanes and clock-lanes properties.
512*4882a593Smuzhiyun  If the lane-polarities property is omitted, the value must be interpreted
513*4882a593Smuzhiyun  as 0 (normal). This property is valid for serial busses only.
514*4882a593Smuzhiyun- strobe: Whether the clock signal is used as clock (0) or strobe (1). Used
515*4882a593Smuzhiyun  with CCP2, for instance.
516*4882a593Smuzhiyun
517*4882a593SmuzhiyunExample
518*4882a593Smuzhiyun-------
519*4882a593Smuzhiyun
520*4882a593SmuzhiyunThe example snippet below describes two data pipelines.  ov772x and imx074 are
521*4882a593Smuzhiyuncamera sensors with a parallel and serial (MIPI CSI-2) video bus respectively.
522*4882a593SmuzhiyunBoth sensors are on the I2C control bus corresponding to the i2c0 controller
523*4882a593Smuzhiyunnode.  ov772x sensor is linked directly to the ceu0 video host interface.
524*4882a593Smuzhiyunimx074 is linked to ceu0 through the MIPI CSI-2 receiver (csi2). ceu0 has a
525*4882a593Smuzhiyun(single) DMA engine writing captured data to memory.  ceu0 node has a single
526*4882a593Smuzhiyun'port' node which may indicate that at any time only one of the following data
527*4882a593Smuzhiyunpipelines can be active: ov772x -> ceu0 or imx074 -> csi2 -> ceu0.
528*4882a593Smuzhiyun
529*4882a593Smuzhiyun	ceu0: ceu@fe910000 {
530*4882a593Smuzhiyun		compatible = "renesas,sh-mobile-ceu";
531*4882a593Smuzhiyun		reg = <0xfe910000 0xa0>;
532*4882a593Smuzhiyun		interrupts = <0x880>;
533*4882a593Smuzhiyun
534*4882a593Smuzhiyun		mclk: master_clock {
535*4882a593Smuzhiyun			compatible = "renesas,ceu-clock";
536*4882a593Smuzhiyun			#clock-cells = <1>;
537*4882a593Smuzhiyun			clock-frequency = <50000000>;	/* Max clock frequency */
538*4882a593Smuzhiyun			clock-output-names = "mclk";
539*4882a593Smuzhiyun		};
540*4882a593Smuzhiyun
541*4882a593Smuzhiyun		port {
542*4882a593Smuzhiyun			#address-cells = <1>;
543*4882a593Smuzhiyun			#size-cells = <0>;
544*4882a593Smuzhiyun
545*4882a593Smuzhiyun			/* Parallel bus endpoint */
546*4882a593Smuzhiyun			ceu0_1: endpoint@1 {
547*4882a593Smuzhiyun				reg = <1>;		/* Local endpoint # */
548*4882a593Smuzhiyun				remote = <&ov772x_1_1>;	/* Remote phandle */
549*4882a593Smuzhiyun				bus-width = <8>;	/* Used data lines */
550*4882a593Smuzhiyun				data-shift = <2>;	/* Lines 9:2 are used */
551*4882a593Smuzhiyun
552*4882a593Smuzhiyun				/* If hsync-active/vsync-active are missing,
553*4882a593Smuzhiyun				   embedded BT.656 sync is used */
554*4882a593Smuzhiyun				hsync-active = <0>;	/* Active low */
555*4882a593Smuzhiyun				vsync-active = <0>;	/* Active low */
556*4882a593Smuzhiyun				data-active = <1>;	/* Active high */
557*4882a593Smuzhiyun				pclk-sample = <1>;	/* Rising */
558*4882a593Smuzhiyun			};
559*4882a593Smuzhiyun
560*4882a593Smuzhiyun			/* MIPI CSI-2 bus endpoint */
561*4882a593Smuzhiyun			ceu0_0: endpoint@0 {
562*4882a593Smuzhiyun				reg = <0>;
563*4882a593Smuzhiyun				remote = <&csi2_2>;
564*4882a593Smuzhiyun			};
565*4882a593Smuzhiyun		};
566*4882a593Smuzhiyun	};
567*4882a593Smuzhiyun
568*4882a593Smuzhiyun	i2c0: i2c@fff20000 {
569*4882a593Smuzhiyun		...
570*4882a593Smuzhiyun		ov772x_1: camera@21 {
571*4882a593Smuzhiyun			compatible = "ovti,ov772x";
572*4882a593Smuzhiyun			reg = <0x21>;
573*4882a593Smuzhiyun			vddio-supply = <&regulator1>;
574*4882a593Smuzhiyun			vddcore-supply = <&regulator2>;
575*4882a593Smuzhiyun
576*4882a593Smuzhiyun			clock-frequency = <20000000>;
577*4882a593Smuzhiyun			clocks = <&mclk 0>;
578*4882a593Smuzhiyun			clock-names = "xclk";
579*4882a593Smuzhiyun
580*4882a593Smuzhiyun			port {
581*4882a593Smuzhiyun				/* With 1 endpoint per port no need for addresses. */
582*4882a593Smuzhiyun				ov772x_1_1: endpoint {
583*4882a593Smuzhiyun					bus-width = <8>;
584*4882a593Smuzhiyun					remote-endpoint = <&ceu0_1>;
585*4882a593Smuzhiyun					hsync-active = <1>;
586*4882a593Smuzhiyun					vsync-active = <0>; /* Who came up with an
587*4882a593Smuzhiyun							       inverter here ?... */
588*4882a593Smuzhiyun					data-active = <1>;
589*4882a593Smuzhiyun					pclk-sample = <1>;
590*4882a593Smuzhiyun				};
591*4882a593Smuzhiyun			};
592*4882a593Smuzhiyun		};
593*4882a593Smuzhiyun
594*4882a593Smuzhiyun		imx074: camera@1a {
595*4882a593Smuzhiyun			compatible = "sony,imx074";
596*4882a593Smuzhiyun			reg = <0x1a>;
597*4882a593Smuzhiyun			vddio-supply = <&regulator1>;
598*4882a593Smuzhiyun			vddcore-supply = <&regulator2>;
599*4882a593Smuzhiyun
600*4882a593Smuzhiyun			clock-frequency = <30000000>;	/* Shared clock with ov772x_1 */
601*4882a593Smuzhiyun			clocks = <&mclk 0>;
602*4882a593Smuzhiyun			clock-names = "sysclk";		/* Assuming this is the
603*4882a593Smuzhiyun							   name in the datasheet */
604*4882a593Smuzhiyun			port {
605*4882a593Smuzhiyun				imx074_1: endpoint {
606*4882a593Smuzhiyun					clock-lanes = <0>;
607*4882a593Smuzhiyun					data-lanes = <1 2>;
608*4882a593Smuzhiyun					remote-endpoint = <&csi2_1>;
609*4882a593Smuzhiyun				};
610*4882a593Smuzhiyun			};
611*4882a593Smuzhiyun		};
612*4882a593Smuzhiyun	};
613*4882a593Smuzhiyun
614*4882a593Smuzhiyun	csi2: csi2@ffc90000 {
615*4882a593Smuzhiyun		compatible = "renesas,sh-mobile-csi2";
616*4882a593Smuzhiyun		reg = <0xffc90000 0x1000>;
617*4882a593Smuzhiyun		interrupts = <0x17a0>;
618*4882a593Smuzhiyun		#address-cells = <1>;
619*4882a593Smuzhiyun		#size-cells = <0>;
620*4882a593Smuzhiyun
621*4882a593Smuzhiyun		port@1 {
622*4882a593Smuzhiyun			compatible = "renesas,csi2c";	/* One of CSI2I and CSI2C. */
623*4882a593Smuzhiyun			reg = <1>;			/* CSI-2 PHY #1 of 2: PHY_S,
624*4882a593Smuzhiyun							   PHY_M has port address 0,
625*4882a593Smuzhiyun							   is unused. */
626*4882a593Smuzhiyun			csi2_1: endpoint {
627*4882a593Smuzhiyun				clock-lanes = <0>;
628*4882a593Smuzhiyun				data-lanes = <2 1>;
629*4882a593Smuzhiyun				remote-endpoint = <&imx074_1>;
630*4882a593Smuzhiyun			};
631*4882a593Smuzhiyun		};
632*4882a593Smuzhiyun		port@2 {
633*4882a593Smuzhiyun			reg = <2>;			/* port 2: link to the CEU */
634*4882a593Smuzhiyun
635*4882a593Smuzhiyun			csi2_2: endpoint {
636*4882a593Smuzhiyun				remote-endpoint = <&ceu0_0>;
637*4882a593Smuzhiyun			};
638*4882a593Smuzhiyun		};
639*4882a593Smuzhiyun	};
640