18c2ecf20Sopenharmony_ciCommon bindings for video receiver and transmitter interfaces 28c2ecf20Sopenharmony_ci 38c2ecf20Sopenharmony_ciGeneral concept 48c2ecf20Sopenharmony_ci--------------- 58c2ecf20Sopenharmony_ci 68c2ecf20Sopenharmony_ciVideo data pipelines usually consist of external devices, e.g. camera sensors, 78c2ecf20Sopenharmony_cicontrolled over an I2C, SPI or UART bus, and SoC internal IP blocks, including 88c2ecf20Sopenharmony_civideo DMA engines and video data processors. 98c2ecf20Sopenharmony_ci 108c2ecf20Sopenharmony_ciSoC internal blocks are described by DT nodes, placed similarly to other SoC 118c2ecf20Sopenharmony_ciblocks. External devices are represented as child nodes of their respective 128c2ecf20Sopenharmony_cibus controller nodes, e.g. I2C. 138c2ecf20Sopenharmony_ci 148c2ecf20Sopenharmony_ciData interfaces on all video devices are described by their child 'port' nodes. 158c2ecf20Sopenharmony_ciConfiguration of a port depends on other devices participating in the data 168c2ecf20Sopenharmony_citransfer and is described by 'endpoint' subnodes. 178c2ecf20Sopenharmony_ci 188c2ecf20Sopenharmony_cidevice { 198c2ecf20Sopenharmony_ci ... 208c2ecf20Sopenharmony_ci ports { 218c2ecf20Sopenharmony_ci #address-cells = <1>; 228c2ecf20Sopenharmony_ci #size-cells = <0>; 238c2ecf20Sopenharmony_ci 248c2ecf20Sopenharmony_ci port@0 { 258c2ecf20Sopenharmony_ci ... 268c2ecf20Sopenharmony_ci endpoint@0 { ... }; 278c2ecf20Sopenharmony_ci endpoint@1 { ... }; 288c2ecf20Sopenharmony_ci }; 298c2ecf20Sopenharmony_ci port@1 { ... }; 308c2ecf20Sopenharmony_ci }; 318c2ecf20Sopenharmony_ci}; 328c2ecf20Sopenharmony_ci 338c2ecf20Sopenharmony_ciIf a port can be configured to work with more than one remote device on the same 348c2ecf20Sopenharmony_cibus, an 'endpoint' child node must be provided for each of them. If more than 358c2ecf20Sopenharmony_cione port is present in a device node or there is more than one endpoint at a 368c2ecf20Sopenharmony_ciport, or port node needs to be associated with a selected hardware interface, 378c2ecf20Sopenharmony_cia common scheme using '#address-cells', '#size-cells' and 'reg' properties is 388c2ecf20Sopenharmony_ciused. 398c2ecf20Sopenharmony_ci 408c2ecf20Sopenharmony_ciAll 'port' nodes can be grouped under optional 'ports' node, which allows to 418c2ecf20Sopenharmony_cispecify #address-cells, #size-cells properties independently for the 'port' 428c2ecf20Sopenharmony_ciand 'endpoint' nodes and any child device nodes a device might have. 438c2ecf20Sopenharmony_ci 448c2ecf20Sopenharmony_ciTwo 'endpoint' nodes are linked with each other through their 'remote-endpoint' 458c2ecf20Sopenharmony_ciphandles. An endpoint subnode of a device contains all properties needed for 468c2ecf20Sopenharmony_ciconfiguration of this device for data exchange with other device. In most 478c2ecf20Sopenharmony_cicases properties at the peer 'endpoint' nodes will be identical, however they 488c2ecf20Sopenharmony_cimight need to be different when there is any signal modifications on the bus 498c2ecf20Sopenharmony_cibetween two devices, e.g. there are logic signal inverters on the lines. 508c2ecf20Sopenharmony_ci 518c2ecf20Sopenharmony_ciIt is allowed for multiple endpoints at a port to be active simultaneously, 528c2ecf20Sopenharmony_ciwhere supported by a device. For example, in case where a data interface of 538c2ecf20Sopenharmony_cia device is partitioned into multiple data busses, e.g. 16-bit input port 548c2ecf20Sopenharmony_cidivided into two separate ITU-R BT.656 8-bit busses. In such case bus-width 558c2ecf20Sopenharmony_ciand data-shift properties can be used to assign physical data lines to each 568c2ecf20Sopenharmony_ciendpoint node (logical bus). 578c2ecf20Sopenharmony_ci 588c2ecf20Sopenharmony_ciDocumenting bindings for devices 598c2ecf20Sopenharmony_ci-------------------------------- 608c2ecf20Sopenharmony_ci 618c2ecf20Sopenharmony_ciAll required and optional bindings the device supports shall be explicitly 628c2ecf20Sopenharmony_cidocumented in device DT binding documentation. This also includes port and 638c2ecf20Sopenharmony_ciendpoint nodes for the device, including unit-addresses and reg properties where 648c2ecf20Sopenharmony_cirelevant. 658c2ecf20Sopenharmony_ci 668c2ecf20Sopenharmony_ciPlease also see Documentation/devicetree/bindings/graph.txt . 678c2ecf20Sopenharmony_ci 688c2ecf20Sopenharmony_ciRequired properties 698c2ecf20Sopenharmony_ci------------------- 708c2ecf20Sopenharmony_ci 718c2ecf20Sopenharmony_ciIf there is more than one 'port' or more than one 'endpoint' node or 'reg' 728c2ecf20Sopenharmony_ciproperty is present in port and/or endpoint nodes the following properties 738c2ecf20Sopenharmony_ciare required in a relevant parent node: 748c2ecf20Sopenharmony_ci 758c2ecf20Sopenharmony_ci - #address-cells : number of cells required to define port/endpoint 768c2ecf20Sopenharmony_ci identifier, should be 1. 778c2ecf20Sopenharmony_ci - #size-cells : should be zero. 788c2ecf20Sopenharmony_ci 798c2ecf20Sopenharmony_ci 808c2ecf20Sopenharmony_ciOptional properties 818c2ecf20Sopenharmony_ci------------------- 828c2ecf20Sopenharmony_ci 838c2ecf20Sopenharmony_ci- flash-leds: An array of phandles, each referring to a flash LED, a sub-node 848c2ecf20Sopenharmony_ci of the LED driver device node. 858c2ecf20Sopenharmony_ci 868c2ecf20Sopenharmony_ci- lens-focus: A phandle to the node of the focus lens controller. 878c2ecf20Sopenharmony_ci 888c2ecf20Sopenharmony_ci- rotation: The camera rotation is expressed as the angular difference in 898c2ecf20Sopenharmony_ci degrees between two reference systems, one relative to the camera module, and 908c2ecf20Sopenharmony_ci one defined on the external world scene to be captured when projected on the 918c2ecf20Sopenharmony_ci image sensor pixel array. 928c2ecf20Sopenharmony_ci 938c2ecf20Sopenharmony_ci A camera sensor has a 2-dimensional reference system 'Rc' defined by 948c2ecf20Sopenharmony_ci its pixel array read-out order. The origin is set to the first pixel 958c2ecf20Sopenharmony_ci being read out, the X-axis points along the column read-out direction 968c2ecf20Sopenharmony_ci towards the last columns, and the Y-axis along the row read-out 978c2ecf20Sopenharmony_ci direction towards the last row. 988c2ecf20Sopenharmony_ci 998c2ecf20Sopenharmony_ci A typical example for a sensor with a 2592x1944 pixel array matrix 1008c2ecf20Sopenharmony_ci observed from the front is: 1018c2ecf20Sopenharmony_ci 1028c2ecf20Sopenharmony_ci 2591 X-axis 0 1038c2ecf20Sopenharmony_ci <------------------------+ 0 1048c2ecf20Sopenharmony_ci .......... ... ..........! 1058c2ecf20Sopenharmony_ci .......... ... ..........! Y-axis 1068c2ecf20Sopenharmony_ci ... ! 1078c2ecf20Sopenharmony_ci .......... ... ..........! 1088c2ecf20Sopenharmony_ci .......... ... ..........! 1943 1098c2ecf20Sopenharmony_ci V 1108c2ecf20Sopenharmony_ci 1118c2ecf20Sopenharmony_ci The external world scene reference system 'Rs' is a 2-dimensional 1128c2ecf20Sopenharmony_ci reference system on the focal plane of the camera module. The origin is 1138c2ecf20Sopenharmony_ci placed on the top-left corner of the visible scene, the X-axis points 1148c2ecf20Sopenharmony_ci towards the right, and the Y-axis points towards the bottom of the 1158c2ecf20Sopenharmony_ci scene. The top, bottom, left and right directions are intentionally not 1168c2ecf20Sopenharmony_ci defined and depend on the environment in which the camera is used. 1178c2ecf20Sopenharmony_ci 1188c2ecf20Sopenharmony_ci A typical example of a (very common) picture of a shark swimming from 1198c2ecf20Sopenharmony_ci left to right, as seen from the camera, is: 1208c2ecf20Sopenharmony_ci 1218c2ecf20Sopenharmony_ci 0 X-axis 1228c2ecf20Sopenharmony_ci 0 +-------------------------------------> 1238c2ecf20Sopenharmony_ci ! 1248c2ecf20Sopenharmony_ci ! 1258c2ecf20Sopenharmony_ci ! 1268c2ecf20Sopenharmony_ci ! |\____)\___ 1278c2ecf20Sopenharmony_ci ! ) _____ __`< 1288c2ecf20Sopenharmony_ci ! |/ )/ 1298c2ecf20Sopenharmony_ci ! 1308c2ecf20Sopenharmony_ci ! 1318c2ecf20Sopenharmony_ci ! 1328c2ecf20Sopenharmony_ci V 1338c2ecf20Sopenharmony_ci Y-axis 1348c2ecf20Sopenharmony_ci 1358c2ecf20Sopenharmony_ci with the reference system 'Rs' placed on the camera focal plane: 1368c2ecf20Sopenharmony_ci 1378c2ecf20Sopenharmony_ci ¸.·˙! 1388c2ecf20Sopenharmony_ci ¸.·˙ ! 1398c2ecf20Sopenharmony_ci _ ¸.·˙ ! 1408c2ecf20Sopenharmony_ci +-/ \-+¸.·˙ ! 1418c2ecf20Sopenharmony_ci | (o) | ! Camera focal plane 1428c2ecf20Sopenharmony_ci +-----+˙·.¸ ! 1438c2ecf20Sopenharmony_ci ˙·.¸ ! 1448c2ecf20Sopenharmony_ci ˙·.¸ ! 1458c2ecf20Sopenharmony_ci ˙·.¸! 1468c2ecf20Sopenharmony_ci 1478c2ecf20Sopenharmony_ci When projected on the sensor's pixel array, the image and the associated 1488c2ecf20Sopenharmony_ci reference system 'Rs' are typically (but not always) inverted, due to 1498c2ecf20Sopenharmony_ci the camera module's lens optical inversion effect. 1508c2ecf20Sopenharmony_ci 1518c2ecf20Sopenharmony_ci Assuming the above represented scene of the swimming shark, the lens 1528c2ecf20Sopenharmony_ci inversion projects the scene and its reference system onto the sensor 1538c2ecf20Sopenharmony_ci pixel array, seen from the front of the camera sensor, as follows: 1548c2ecf20Sopenharmony_ci 1558c2ecf20Sopenharmony_ci Y-axis 1568c2ecf20Sopenharmony_ci ^ 1578c2ecf20Sopenharmony_ci ! 1588c2ecf20Sopenharmony_ci ! 1598c2ecf20Sopenharmony_ci ! 1608c2ecf20Sopenharmony_ci ! |\_____)\__ 1618c2ecf20Sopenharmony_ci ! ) ____ ___.< 1628c2ecf20Sopenharmony_ci ! |/ )/ 1638c2ecf20Sopenharmony_ci ! 1648c2ecf20Sopenharmony_ci ! 1658c2ecf20Sopenharmony_ci ! 1668c2ecf20Sopenharmony_ci 0 +-------------------------------------> 1678c2ecf20Sopenharmony_ci 0 X-axis 1688c2ecf20Sopenharmony_ci 1698c2ecf20Sopenharmony_ci Note the shark being upside-down. 1708c2ecf20Sopenharmony_ci 1718c2ecf20Sopenharmony_ci The resulting projected reference system is named 'Rp'. 1728c2ecf20Sopenharmony_ci 1738c2ecf20Sopenharmony_ci The camera rotation property is then defined as the angular difference 1748c2ecf20Sopenharmony_ci in the counter-clockwise direction between the camera reference system 1758c2ecf20Sopenharmony_ci 'Rc' and the projected scene reference system 'Rp'. It is expressed in 1768c2ecf20Sopenharmony_ci degrees as a number in the range [0, 360[. 1778c2ecf20Sopenharmony_ci 1788c2ecf20Sopenharmony_ci Examples 1798c2ecf20Sopenharmony_ci 1808c2ecf20Sopenharmony_ci 0 degrees camera rotation: 1818c2ecf20Sopenharmony_ci 1828c2ecf20Sopenharmony_ci 1838c2ecf20Sopenharmony_ci Y-Rp 1848c2ecf20Sopenharmony_ci ^ 1858c2ecf20Sopenharmony_ci Y-Rc ! 1868c2ecf20Sopenharmony_ci ^ ! 1878c2ecf20Sopenharmony_ci ! ! 1888c2ecf20Sopenharmony_ci ! ! 1898c2ecf20Sopenharmony_ci ! ! 1908c2ecf20Sopenharmony_ci ! ! 1918c2ecf20Sopenharmony_ci ! ! 1928c2ecf20Sopenharmony_ci ! ! 1938c2ecf20Sopenharmony_ci ! ! 1948c2ecf20Sopenharmony_ci ! 0 +-------------------------------------> 1958c2ecf20Sopenharmony_ci ! 0 X-Rp 1968c2ecf20Sopenharmony_ci 0 +-------------------------------------> 1978c2ecf20Sopenharmony_ci 0 X-Rc 1988c2ecf20Sopenharmony_ci 1998c2ecf20Sopenharmony_ci 2008c2ecf20Sopenharmony_ci X-Rc 0 2018c2ecf20Sopenharmony_ci <------------------------------------+ 0 2028c2ecf20Sopenharmony_ci X-Rp 0 ! 2038c2ecf20Sopenharmony_ci <------------------------------------+ 0 ! 2048c2ecf20Sopenharmony_ci ! ! 2058c2ecf20Sopenharmony_ci ! ! 2068c2ecf20Sopenharmony_ci ! ! 2078c2ecf20Sopenharmony_ci ! ! 2088c2ecf20Sopenharmony_ci ! ! 2098c2ecf20Sopenharmony_ci ! ! 2108c2ecf20Sopenharmony_ci ! ! 2118c2ecf20Sopenharmony_ci ! V 2128c2ecf20Sopenharmony_ci ! Y-Rc 2138c2ecf20Sopenharmony_ci V 2148c2ecf20Sopenharmony_ci Y-Rp 2158c2ecf20Sopenharmony_ci 2168c2ecf20Sopenharmony_ci 90 degrees camera rotation: 2178c2ecf20Sopenharmony_ci 2188c2ecf20Sopenharmony_ci 0 Y-Rc 2198c2ecf20Sopenharmony_ci 0 +--------------------> 2208c2ecf20Sopenharmony_ci ! Y-Rp 2218c2ecf20Sopenharmony_ci ! ^ 2228c2ecf20Sopenharmony_ci ! ! 2238c2ecf20Sopenharmony_ci ! ! 2248c2ecf20Sopenharmony_ci ! ! 2258c2ecf20Sopenharmony_ci ! ! 2268c2ecf20Sopenharmony_ci ! ! 2278c2ecf20Sopenharmony_ci ! ! 2288c2ecf20Sopenharmony_ci ! ! 2298c2ecf20Sopenharmony_ci ! ! 2308c2ecf20Sopenharmony_ci ! ! 2318c2ecf20Sopenharmony_ci ! 0 +-------------------------------------> 2328c2ecf20Sopenharmony_ci ! 0 X-Rp 2338c2ecf20Sopenharmony_ci ! 2348c2ecf20Sopenharmony_ci ! 2358c2ecf20Sopenharmony_ci ! 2368c2ecf20Sopenharmony_ci ! 2378c2ecf20Sopenharmony_ci V 2388c2ecf20Sopenharmony_ci X-Rc 2398c2ecf20Sopenharmony_ci 2408c2ecf20Sopenharmony_ci 180 degrees camera rotation: 2418c2ecf20Sopenharmony_ci 2428c2ecf20Sopenharmony_ci 0 2438c2ecf20Sopenharmony_ci <------------------------------------+ 0 2448c2ecf20Sopenharmony_ci X-Rc ! 2458c2ecf20Sopenharmony_ci Y-Rp ! 2468c2ecf20Sopenharmony_ci ^ ! 2478c2ecf20Sopenharmony_ci ! ! 2488c2ecf20Sopenharmony_ci ! ! 2498c2ecf20Sopenharmony_ci ! ! 2508c2ecf20Sopenharmony_ci ! ! 2518c2ecf20Sopenharmony_ci ! ! 2528c2ecf20Sopenharmony_ci ! ! 2538c2ecf20Sopenharmony_ci ! V 2548c2ecf20Sopenharmony_ci ! Y-Rc 2558c2ecf20Sopenharmony_ci 0 +-------------------------------------> 2568c2ecf20Sopenharmony_ci 0 X-Rp 2578c2ecf20Sopenharmony_ci 2588c2ecf20Sopenharmony_ci 270 degrees camera rotation: 2598c2ecf20Sopenharmony_ci 2608c2ecf20Sopenharmony_ci 0 Y-Rc 2618c2ecf20Sopenharmony_ci 0 +--------------------> 2628c2ecf20Sopenharmony_ci ! 0 2638c2ecf20Sopenharmony_ci ! <-----------------------------------+ 0 2648c2ecf20Sopenharmony_ci ! X-Rp ! 2658c2ecf20Sopenharmony_ci ! ! 2668c2ecf20Sopenharmony_ci ! ! 2678c2ecf20Sopenharmony_ci ! ! 2688c2ecf20Sopenharmony_ci ! ! 2698c2ecf20Sopenharmony_ci ! ! 2708c2ecf20Sopenharmony_ci ! ! 2718c2ecf20Sopenharmony_ci ! ! 2728c2ecf20Sopenharmony_ci ! ! 2738c2ecf20Sopenharmony_ci ! V 2748c2ecf20Sopenharmony_ci ! Y-Rp 2758c2ecf20Sopenharmony_ci ! 2768c2ecf20Sopenharmony_ci ! 2778c2ecf20Sopenharmony_ci ! 2788c2ecf20Sopenharmony_ci ! 2798c2ecf20Sopenharmony_ci V 2808c2ecf20Sopenharmony_ci X-Rc 2818c2ecf20Sopenharmony_ci 2828c2ecf20Sopenharmony_ci 2838c2ecf20Sopenharmony_ci Example one - Webcam 2848c2ecf20Sopenharmony_ci 2858c2ecf20Sopenharmony_ci A camera module installed on the user facing part of a laptop screen 2868c2ecf20Sopenharmony_ci casing used for video calls. The captured images are meant to be 2878c2ecf20Sopenharmony_ci displayed in landscape mode (width > height) on the laptop screen. 2888c2ecf20Sopenharmony_ci 2898c2ecf20Sopenharmony_ci The camera is typically mounted upside-down to compensate the lens 2908c2ecf20Sopenharmony_ci optical inversion effect: 2918c2ecf20Sopenharmony_ci 2928c2ecf20Sopenharmony_ci Y-Rp 2938c2ecf20Sopenharmony_ci Y-Rc ^ 2948c2ecf20Sopenharmony_ci ^ ! 2958c2ecf20Sopenharmony_ci ! ! 2968c2ecf20Sopenharmony_ci ! ! |\_____)\__ 2978c2ecf20Sopenharmony_ci ! ! ) ____ ___.< 2988c2ecf20Sopenharmony_ci ! ! |/ )/ 2998c2ecf20Sopenharmony_ci ! ! 3008c2ecf20Sopenharmony_ci ! ! 3018c2ecf20Sopenharmony_ci ! ! 3028c2ecf20Sopenharmony_ci ! 0 +-------------------------------------> 3038c2ecf20Sopenharmony_ci ! 0 X-Rp 3048c2ecf20Sopenharmony_ci 0 +-------------------------------------> 3058c2ecf20Sopenharmony_ci 0 X-Rc 3068c2ecf20Sopenharmony_ci 3078c2ecf20Sopenharmony_ci The two reference systems are aligned, the resulting camera rotation is 3088c2ecf20Sopenharmony_ci 0 degrees, no rotation correction needs to be applied to the resulting 3098c2ecf20Sopenharmony_ci image once captured to memory buffers to correctly display it to users: 3108c2ecf20Sopenharmony_ci 3118c2ecf20Sopenharmony_ci +--------------------------------------+ 3128c2ecf20Sopenharmony_ci ! ! 3138c2ecf20Sopenharmony_ci ! ! 3148c2ecf20Sopenharmony_ci ! ! 3158c2ecf20Sopenharmony_ci ! |\____)\___ ! 3168c2ecf20Sopenharmony_ci ! ) _____ __`< ! 3178c2ecf20Sopenharmony_ci ! |/ )/ ! 3188c2ecf20Sopenharmony_ci ! ! 3198c2ecf20Sopenharmony_ci ! ! 3208c2ecf20Sopenharmony_ci ! ! 3218c2ecf20Sopenharmony_ci +--------------------------------------+ 3228c2ecf20Sopenharmony_ci 3238c2ecf20Sopenharmony_ci If the camera sensor is not mounted upside-down to compensate for the 3248c2ecf20Sopenharmony_ci lens optical inversion, the two reference systems will not be aligned, 3258c2ecf20Sopenharmony_ci with 'Rp' being rotated 180 degrees relatively to 'Rc': 3268c2ecf20Sopenharmony_ci 3278c2ecf20Sopenharmony_ci 3288c2ecf20Sopenharmony_ci X-Rc 0 3298c2ecf20Sopenharmony_ci <------------------------------------+ 0 3308c2ecf20Sopenharmony_ci ! 3318c2ecf20Sopenharmony_ci Y-Rp ! 3328c2ecf20Sopenharmony_ci ^ ! 3338c2ecf20Sopenharmony_ci ! ! 3348c2ecf20Sopenharmony_ci ! |\_____)\__ ! 3358c2ecf20Sopenharmony_ci ! ) ____ ___.< ! 3368c2ecf20Sopenharmony_ci ! |/ )/ ! 3378c2ecf20Sopenharmony_ci ! ! 3388c2ecf20Sopenharmony_ci ! ! 3398c2ecf20Sopenharmony_ci ! V 3408c2ecf20Sopenharmony_ci ! Y-Rc 3418c2ecf20Sopenharmony_ci 0 +-------------------------------------> 3428c2ecf20Sopenharmony_ci 0 X-Rp 3438c2ecf20Sopenharmony_ci 3448c2ecf20Sopenharmony_ci The image once captured to memory will then be rotated by 180 degrees: 3458c2ecf20Sopenharmony_ci 3468c2ecf20Sopenharmony_ci +--------------------------------------+ 3478c2ecf20Sopenharmony_ci ! ! 3488c2ecf20Sopenharmony_ci ! ! 3498c2ecf20Sopenharmony_ci ! ! 3508c2ecf20Sopenharmony_ci ! __/(_____/| ! 3518c2ecf20Sopenharmony_ci ! >.___ ____ ( ! 3528c2ecf20Sopenharmony_ci ! \( \| ! 3538c2ecf20Sopenharmony_ci ! ! 3548c2ecf20Sopenharmony_ci ! ! 3558c2ecf20Sopenharmony_ci ! ! 3568c2ecf20Sopenharmony_ci +--------------------------------------+ 3578c2ecf20Sopenharmony_ci 3588c2ecf20Sopenharmony_ci A software rotation correction of 180 degrees should be applied to 3598c2ecf20Sopenharmony_ci correctly display the image: 3608c2ecf20Sopenharmony_ci 3618c2ecf20Sopenharmony_ci +--------------------------------------+ 3628c2ecf20Sopenharmony_ci ! ! 3638c2ecf20Sopenharmony_ci ! ! 3648c2ecf20Sopenharmony_ci ! ! 3658c2ecf20Sopenharmony_ci ! |\____)\___ ! 3668c2ecf20Sopenharmony_ci ! ) _____ __`< ! 3678c2ecf20Sopenharmony_ci ! |/ )/ ! 3688c2ecf20Sopenharmony_ci ! ! 3698c2ecf20Sopenharmony_ci ! ! 3708c2ecf20Sopenharmony_ci ! ! 3718c2ecf20Sopenharmony_ci +--------------------------------------+ 3728c2ecf20Sopenharmony_ci 3738c2ecf20Sopenharmony_ci Example two - Phone camera 3748c2ecf20Sopenharmony_ci 3758c2ecf20Sopenharmony_ci A camera installed on the back side of a mobile device facing away from 3768c2ecf20Sopenharmony_ci the user. The captured images are meant to be displayed in portrait mode 3778c2ecf20Sopenharmony_ci (height > width) to match the device screen orientation and the device 3788c2ecf20Sopenharmony_ci usage orientation used when taking the picture. 3798c2ecf20Sopenharmony_ci 3808c2ecf20Sopenharmony_ci The camera sensor is typically mounted with its pixel array longer side 3818c2ecf20Sopenharmony_ci aligned to the device longer side, upside-down mounted to compensate for 3828c2ecf20Sopenharmony_ci the lens optical inversion effect: 3838c2ecf20Sopenharmony_ci 3848c2ecf20Sopenharmony_ci 0 Y-Rc 3858c2ecf20Sopenharmony_ci 0 +--------------------> 3868c2ecf20Sopenharmony_ci ! Y-Rp 3878c2ecf20Sopenharmony_ci ! ^ 3888c2ecf20Sopenharmony_ci ! ! 3898c2ecf20Sopenharmony_ci ! ! 3908c2ecf20Sopenharmony_ci ! ! 3918c2ecf20Sopenharmony_ci ! ! |\_____)\__ 3928c2ecf20Sopenharmony_ci ! ! ) ____ ___.< 3938c2ecf20Sopenharmony_ci ! ! |/ )/ 3948c2ecf20Sopenharmony_ci ! ! 3958c2ecf20Sopenharmony_ci ! ! 3968c2ecf20Sopenharmony_ci ! ! 3978c2ecf20Sopenharmony_ci ! 0 +-------------------------------------> 3988c2ecf20Sopenharmony_ci ! 0 X-Rp 3998c2ecf20Sopenharmony_ci ! 4008c2ecf20Sopenharmony_ci ! 4018c2ecf20Sopenharmony_ci ! 4028c2ecf20Sopenharmony_ci ! 4038c2ecf20Sopenharmony_ci V 4048c2ecf20Sopenharmony_ci X-Rc 4058c2ecf20Sopenharmony_ci 4068c2ecf20Sopenharmony_ci The two reference systems are not aligned and the 'Rp' reference 4078c2ecf20Sopenharmony_ci system is rotated by 90 degrees in the counter-clockwise direction 4088c2ecf20Sopenharmony_ci relatively to the 'Rc' reference system. 4098c2ecf20Sopenharmony_ci 4108c2ecf20Sopenharmony_ci The image once captured to memory will be rotated: 4118c2ecf20Sopenharmony_ci 4128c2ecf20Sopenharmony_ci +-------------------------------------+ 4138c2ecf20Sopenharmony_ci | _ _ | 4148c2ecf20Sopenharmony_ci | \ / | 4158c2ecf20Sopenharmony_ci | | | | 4168c2ecf20Sopenharmony_ci | | | | 4178c2ecf20Sopenharmony_ci | | > | 4188c2ecf20Sopenharmony_ci | < | | 4198c2ecf20Sopenharmony_ci | | | | 4208c2ecf20Sopenharmony_ci | . | 4218c2ecf20Sopenharmony_ci | V | 4228c2ecf20Sopenharmony_ci +-------------------------------------+ 4238c2ecf20Sopenharmony_ci 4248c2ecf20Sopenharmony_ci A correction of 90 degrees in counter-clockwise direction has to be 4258c2ecf20Sopenharmony_ci applied to correctly display the image in portrait mode on the device 4268c2ecf20Sopenharmony_ci screen: 4278c2ecf20Sopenharmony_ci 4288c2ecf20Sopenharmony_ci +--------------------+ 4298c2ecf20Sopenharmony_ci | | 4308c2ecf20Sopenharmony_ci | | 4318c2ecf20Sopenharmony_ci | | 4328c2ecf20Sopenharmony_ci | | 4338c2ecf20Sopenharmony_ci | | 4348c2ecf20Sopenharmony_ci | | 4358c2ecf20Sopenharmony_ci | |\____)\___ | 4368c2ecf20Sopenharmony_ci | ) _____ __`< | 4378c2ecf20Sopenharmony_ci | |/ )/ | 4388c2ecf20Sopenharmony_ci | | 4398c2ecf20Sopenharmony_ci | | 4408c2ecf20Sopenharmony_ci | | 4418c2ecf20Sopenharmony_ci | | 4428c2ecf20Sopenharmony_ci | | 4438c2ecf20Sopenharmony_ci +--------------------+ 4448c2ecf20Sopenharmony_ci 4458c2ecf20Sopenharmony_ci- orientation: The orientation of a device (typically an image sensor or a flash 4468c2ecf20Sopenharmony_ci LED) describing its mounting position relative to the usage orientation of the 4478c2ecf20Sopenharmony_ci system where the device is installed on. 4488c2ecf20Sopenharmony_ci Possible values are: 4498c2ecf20Sopenharmony_ci 0 - Front. The device is mounted on the front facing side of the system. 4508c2ecf20Sopenharmony_ci For mobile devices such as smartphones, tablets and laptops the front side is 4518c2ecf20Sopenharmony_ci the user facing side. 4528c2ecf20Sopenharmony_ci 1 - Back. The device is mounted on the back side of the system, which is 4538c2ecf20Sopenharmony_ci defined as the opposite side of the front facing one. 4548c2ecf20Sopenharmony_ci 2 - External. The device is not attached directly to the system but is 4558c2ecf20Sopenharmony_ci attached in a way that allows it to move freely. 4568c2ecf20Sopenharmony_ci 4578c2ecf20Sopenharmony_ciOptional endpoint properties 4588c2ecf20Sopenharmony_ci---------------------------- 4598c2ecf20Sopenharmony_ci 4608c2ecf20Sopenharmony_ci- remote-endpoint: phandle to an 'endpoint' subnode of a remote device node. 4618c2ecf20Sopenharmony_ci- slave-mode: a boolean property indicating that the link is run in slave mode. 4628c2ecf20Sopenharmony_ci The default when this property is not specified is master mode. In the slave 4638c2ecf20Sopenharmony_ci mode horizontal and vertical synchronization signals are provided to the 4648c2ecf20Sopenharmony_ci slave device (data source) by the master device (data sink). In the master 4658c2ecf20Sopenharmony_ci mode the data source device is also the source of the synchronization signals. 4668c2ecf20Sopenharmony_ci- bus-type: data bus type. Possible values are: 4678c2ecf20Sopenharmony_ci 1 - MIPI CSI-2 C-PHY 4688c2ecf20Sopenharmony_ci 2 - MIPI CSI1 4698c2ecf20Sopenharmony_ci 3 - CCP2 4708c2ecf20Sopenharmony_ci 4 - MIPI CSI-2 D-PHY 4718c2ecf20Sopenharmony_ci 5 - Parallel 4728c2ecf20Sopenharmony_ci 6 - Bt.656 4738c2ecf20Sopenharmony_ci- bus-width: number of data lines actively used, valid for the parallel busses. 4748c2ecf20Sopenharmony_ci- data-shift: on the parallel data busses, if bus-width is used to specify the 4758c2ecf20Sopenharmony_ci number of data lines, data-shift can be used to specify which data lines are 4768c2ecf20Sopenharmony_ci used, e.g. "bus-width=<8>; data-shift=<2>;" means, that lines 9:2 are used. 4778c2ecf20Sopenharmony_ci- hsync-active: active state of the HSYNC signal, 0/1 for LOW/HIGH respectively. 4788c2ecf20Sopenharmony_ci- vsync-active: active state of the VSYNC signal, 0/1 for LOW/HIGH respectively. 4798c2ecf20Sopenharmony_ci Note, that if HSYNC and VSYNC polarities are not specified, embedded 4808c2ecf20Sopenharmony_ci synchronization may be required, where supported. 4818c2ecf20Sopenharmony_ci- data-active: similar to HSYNC and VSYNC, specifies data line polarity. 4828c2ecf20Sopenharmony_ci- data-enable-active: similar to HSYNC and VSYNC, specifies the data enable 4838c2ecf20Sopenharmony_ci signal polarity. 4848c2ecf20Sopenharmony_ci- field-even-active: field signal level during the even field data transmission. 4858c2ecf20Sopenharmony_ci- pclk-sample: sample data on rising (1) or falling (0) edge of the pixel clock 4868c2ecf20Sopenharmony_ci signal. 4878c2ecf20Sopenharmony_ci- sync-on-green-active: active state of Sync-on-green (SoG) signal, 0/1 for 4888c2ecf20Sopenharmony_ci LOW/HIGH respectively. 4898c2ecf20Sopenharmony_ci- data-lanes: an array of physical data lane indexes. Position of an entry 4908c2ecf20Sopenharmony_ci determines the logical lane number, while the value of an entry indicates 4918c2ecf20Sopenharmony_ci physical lane, e.g. for 2-lane MIPI CSI-2 bus we could have 4928c2ecf20Sopenharmony_ci "data-lanes = <1 2>;", assuming the clock lane is on hardware lane 0. 4938c2ecf20Sopenharmony_ci If the hardware does not support lane reordering, monotonically 4948c2ecf20Sopenharmony_ci incremented values shall be used from 0 or 1 onwards, depending on 4958c2ecf20Sopenharmony_ci whether or not there is also a clock lane. This property is valid for 4968c2ecf20Sopenharmony_ci serial busses only (e.g. MIPI CSI-2). 4978c2ecf20Sopenharmony_ci- clock-lanes: an array of physical clock lane indexes. Position of an entry 4988c2ecf20Sopenharmony_ci determines the logical lane number, while the value of an entry indicates 4998c2ecf20Sopenharmony_ci physical lane, e.g. for a MIPI CSI-2 bus we could have "clock-lanes = <0>;", 5008c2ecf20Sopenharmony_ci which places the clock lane on hardware lane 0. This property is valid for 5018c2ecf20Sopenharmony_ci serial busses only (e.g. MIPI CSI-2). Note that for the MIPI CSI-2 bus this 5028c2ecf20Sopenharmony_ci array contains only one entry. 5038c2ecf20Sopenharmony_ci- clock-noncontinuous: a boolean property to allow MIPI CSI-2 non-continuous 5048c2ecf20Sopenharmony_ci clock mode. 5058c2ecf20Sopenharmony_ci- link-frequencies: Allowed data bus frequencies. For MIPI CSI-2, for 5068c2ecf20Sopenharmony_ci instance, this is the actual frequency of the bus, not bits per clock per 5078c2ecf20Sopenharmony_ci lane value. An array of 64-bit unsigned integers. 5088c2ecf20Sopenharmony_ci- lane-polarities: an array of polarities of the lanes starting from the clock 5098c2ecf20Sopenharmony_ci lane and followed by the data lanes in the same order as in data-lanes. 5108c2ecf20Sopenharmony_ci Valid values are 0 (normal) and 1 (inverted). The length of the array 5118c2ecf20Sopenharmony_ci should be the combined length of data-lanes and clock-lanes properties. 5128c2ecf20Sopenharmony_ci If the lane-polarities property is omitted, the value must be interpreted 5138c2ecf20Sopenharmony_ci as 0 (normal). This property is valid for serial busses only. 5148c2ecf20Sopenharmony_ci- strobe: Whether the clock signal is used as clock (0) or strobe (1). Used 5158c2ecf20Sopenharmony_ci with CCP2, for instance. 5168c2ecf20Sopenharmony_ci 5178c2ecf20Sopenharmony_ciExample 5188c2ecf20Sopenharmony_ci------- 5198c2ecf20Sopenharmony_ci 5208c2ecf20Sopenharmony_ciThe example snippet below describes two data pipelines. ov772x and imx074 are 5218c2ecf20Sopenharmony_cicamera sensors with a parallel and serial (MIPI CSI-2) video bus respectively. 5228c2ecf20Sopenharmony_ciBoth sensors are on the I2C control bus corresponding to the i2c0 controller 5238c2ecf20Sopenharmony_cinode. ov772x sensor is linked directly to the ceu0 video host interface. 5248c2ecf20Sopenharmony_ciimx074 is linked to ceu0 through the MIPI CSI-2 receiver (csi2). ceu0 has a 5258c2ecf20Sopenharmony_ci(single) DMA engine writing captured data to memory. ceu0 node has a single 5268c2ecf20Sopenharmony_ci'port' node which may indicate that at any time only one of the following data 5278c2ecf20Sopenharmony_cipipelines can be active: ov772x -> ceu0 or imx074 -> csi2 -> ceu0. 5288c2ecf20Sopenharmony_ci 5298c2ecf20Sopenharmony_ci ceu0: ceu@fe910000 { 5308c2ecf20Sopenharmony_ci compatible = "renesas,sh-mobile-ceu"; 5318c2ecf20Sopenharmony_ci reg = <0xfe910000 0xa0>; 5328c2ecf20Sopenharmony_ci interrupts = <0x880>; 5338c2ecf20Sopenharmony_ci 5348c2ecf20Sopenharmony_ci mclk: master_clock { 5358c2ecf20Sopenharmony_ci compatible = "renesas,ceu-clock"; 5368c2ecf20Sopenharmony_ci #clock-cells = <1>; 5378c2ecf20Sopenharmony_ci clock-frequency = <50000000>; /* Max clock frequency */ 5388c2ecf20Sopenharmony_ci clock-output-names = "mclk"; 5398c2ecf20Sopenharmony_ci }; 5408c2ecf20Sopenharmony_ci 5418c2ecf20Sopenharmony_ci port { 5428c2ecf20Sopenharmony_ci #address-cells = <1>; 5438c2ecf20Sopenharmony_ci #size-cells = <0>; 5448c2ecf20Sopenharmony_ci 5458c2ecf20Sopenharmony_ci /* Parallel bus endpoint */ 5468c2ecf20Sopenharmony_ci ceu0_1: endpoint@1 { 5478c2ecf20Sopenharmony_ci reg = <1>; /* Local endpoint # */ 5488c2ecf20Sopenharmony_ci remote = <&ov772x_1_1>; /* Remote phandle */ 5498c2ecf20Sopenharmony_ci bus-width = <8>; /* Used data lines */ 5508c2ecf20Sopenharmony_ci data-shift = <2>; /* Lines 9:2 are used */ 5518c2ecf20Sopenharmony_ci 5528c2ecf20Sopenharmony_ci /* If hsync-active/vsync-active are missing, 5538c2ecf20Sopenharmony_ci embedded BT.656 sync is used */ 5548c2ecf20Sopenharmony_ci hsync-active = <0>; /* Active low */ 5558c2ecf20Sopenharmony_ci vsync-active = <0>; /* Active low */ 5568c2ecf20Sopenharmony_ci data-active = <1>; /* Active high */ 5578c2ecf20Sopenharmony_ci pclk-sample = <1>; /* Rising */ 5588c2ecf20Sopenharmony_ci }; 5598c2ecf20Sopenharmony_ci 5608c2ecf20Sopenharmony_ci /* MIPI CSI-2 bus endpoint */ 5618c2ecf20Sopenharmony_ci ceu0_0: endpoint@0 { 5628c2ecf20Sopenharmony_ci reg = <0>; 5638c2ecf20Sopenharmony_ci remote = <&csi2_2>; 5648c2ecf20Sopenharmony_ci }; 5658c2ecf20Sopenharmony_ci }; 5668c2ecf20Sopenharmony_ci }; 5678c2ecf20Sopenharmony_ci 5688c2ecf20Sopenharmony_ci i2c0: i2c@fff20000 { 5698c2ecf20Sopenharmony_ci ... 5708c2ecf20Sopenharmony_ci ov772x_1: camera@21 { 5718c2ecf20Sopenharmony_ci compatible = "ovti,ov772x"; 5728c2ecf20Sopenharmony_ci reg = <0x21>; 5738c2ecf20Sopenharmony_ci vddio-supply = <®ulator1>; 5748c2ecf20Sopenharmony_ci vddcore-supply = <®ulator2>; 5758c2ecf20Sopenharmony_ci 5768c2ecf20Sopenharmony_ci clock-frequency = <20000000>; 5778c2ecf20Sopenharmony_ci clocks = <&mclk 0>; 5788c2ecf20Sopenharmony_ci clock-names = "xclk"; 5798c2ecf20Sopenharmony_ci 5808c2ecf20Sopenharmony_ci port { 5818c2ecf20Sopenharmony_ci /* With 1 endpoint per port no need for addresses. */ 5828c2ecf20Sopenharmony_ci ov772x_1_1: endpoint { 5838c2ecf20Sopenharmony_ci bus-width = <8>; 5848c2ecf20Sopenharmony_ci remote-endpoint = <&ceu0_1>; 5858c2ecf20Sopenharmony_ci hsync-active = <1>; 5868c2ecf20Sopenharmony_ci vsync-active = <0>; /* Who came up with an 5878c2ecf20Sopenharmony_ci inverter here ?... */ 5888c2ecf20Sopenharmony_ci data-active = <1>; 5898c2ecf20Sopenharmony_ci pclk-sample = <1>; 5908c2ecf20Sopenharmony_ci }; 5918c2ecf20Sopenharmony_ci }; 5928c2ecf20Sopenharmony_ci }; 5938c2ecf20Sopenharmony_ci 5948c2ecf20Sopenharmony_ci imx074: camera@1a { 5958c2ecf20Sopenharmony_ci compatible = "sony,imx074"; 5968c2ecf20Sopenharmony_ci reg = <0x1a>; 5978c2ecf20Sopenharmony_ci vddio-supply = <®ulator1>; 5988c2ecf20Sopenharmony_ci vddcore-supply = <®ulator2>; 5998c2ecf20Sopenharmony_ci 6008c2ecf20Sopenharmony_ci clock-frequency = <30000000>; /* Shared clock with ov772x_1 */ 6018c2ecf20Sopenharmony_ci clocks = <&mclk 0>; 6028c2ecf20Sopenharmony_ci clock-names = "sysclk"; /* Assuming this is the 6038c2ecf20Sopenharmony_ci name in the datasheet */ 6048c2ecf20Sopenharmony_ci port { 6058c2ecf20Sopenharmony_ci imx074_1: endpoint { 6068c2ecf20Sopenharmony_ci clock-lanes = <0>; 6078c2ecf20Sopenharmony_ci data-lanes = <1 2>; 6088c2ecf20Sopenharmony_ci remote-endpoint = <&csi2_1>; 6098c2ecf20Sopenharmony_ci }; 6108c2ecf20Sopenharmony_ci }; 6118c2ecf20Sopenharmony_ci }; 6128c2ecf20Sopenharmony_ci }; 6138c2ecf20Sopenharmony_ci 6148c2ecf20Sopenharmony_ci csi2: csi2@ffc90000 { 6158c2ecf20Sopenharmony_ci compatible = "renesas,sh-mobile-csi2"; 6168c2ecf20Sopenharmony_ci reg = <0xffc90000 0x1000>; 6178c2ecf20Sopenharmony_ci interrupts = <0x17a0>; 6188c2ecf20Sopenharmony_ci #address-cells = <1>; 6198c2ecf20Sopenharmony_ci #size-cells = <0>; 6208c2ecf20Sopenharmony_ci 6218c2ecf20Sopenharmony_ci port@1 { 6228c2ecf20Sopenharmony_ci compatible = "renesas,csi2c"; /* One of CSI2I and CSI2C. */ 6238c2ecf20Sopenharmony_ci reg = <1>; /* CSI-2 PHY #1 of 2: PHY_S, 6248c2ecf20Sopenharmony_ci PHY_M has port address 0, 6258c2ecf20Sopenharmony_ci is unused. */ 6268c2ecf20Sopenharmony_ci csi2_1: endpoint { 6278c2ecf20Sopenharmony_ci clock-lanes = <0>; 6288c2ecf20Sopenharmony_ci data-lanes = <2 1>; 6298c2ecf20Sopenharmony_ci remote-endpoint = <&imx074_1>; 6308c2ecf20Sopenharmony_ci }; 6318c2ecf20Sopenharmony_ci }; 6328c2ecf20Sopenharmony_ci port@2 { 6338c2ecf20Sopenharmony_ci reg = <2>; /* port 2: link to the CEU */ 6348c2ecf20Sopenharmony_ci 6358c2ecf20Sopenharmony_ci csi2_2: endpoint { 6368c2ecf20Sopenharmony_ci remote-endpoint = <&ceu0_0>; 6378c2ecf20Sopenharmony_ci }; 6388c2ecf20Sopenharmony_ci }; 6398c2ecf20Sopenharmony_ci }; 640