From 047d8a5eb105e3e894c81cbdc526b7c4d2261230 Mon Sep 17 00:00:00 2001
From: Robert Mader <robert.mader@posteo.de>
Date: Tue, 20 Dec 2022 20:36:51 +0100
Subject: [PATCH 374/463] arm64: dts: rk3399-pinephone-pro: Add correct camera
 rotation values

According to the documentation at
Documentation/userspace-api/media/v4l/ext-ctrls-camera.rst#V4L2_CID_CAMERA_SENSOR_ROTATION
These values are also used by Megapixels, see [1].

The values have been also been verified with pending libcamera patches[2],
the new Pipewire transform support[3] and the Gstreamer-based "Camera" app[4][5]
(the possible "gnome-camera" candidate).

Note: the drivers do not yet support exposing these values via the
`V4L2_CID_CAMERA_SENSOR_ROTATION` API, patches for that will follow.

The motivation is to let the future camera stack, consisting of
libcamera, Pipewire, xdg-camera-portal and [Gstreamer|libwebrtc|obs-studio|...]
properly find the correct camera rotation and adjust the visual results
accordingly.

1: https://github.com/kgmt0/megapixels/blob/3dc718a0626fb89b364b468ba85d9aded41e2f91/config/pine64,pinephone-pro.ini
2: https://patchwork.libcamera.org/patch/17891/
3: https://gitlab.freedesktop.org/pipewire/pipewire/-/merge_requests/1457
4: https://gitlab.gnome.org/jwestman/libaperture/-/merge_requests/22
5: https://gitlab.gnome.org/jwestman/camera

Signed-off-by: Robert Mader <robert.mader@posteo.de>
---
 arch/arm64/boot/dts/rockchip/rk3399-pinephone-pro.dts | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/arm64/boot/dts/rockchip/rk3399-pinephone-pro.dts b/arch/arm64/boot/dts/rockchip/rk3399-pinephone-pro.dts
index dda9df3b33894..43e38c58675ce 100644
--- a/arch/arm64/boot/dts/rockchip/rk3399-pinephone-pro.dts
+++ b/arch/arm64/boot/dts/rockchip/rk3399-pinephone-pro.dts
@@ -772,7 +772,7 @@ wcam: camera@1a {
 		reset-gpios = <&gpio1 RK_PA0 GPIO_ACTIVE_LOW>;
 		powerdown-gpios = <&gpio2 RK_PD4 GPIO_ACTIVE_HIGH>;
 
-		rotation = <180>;
+		rotation = <270>;
 
 		lens-focus = <&wcam_lens>;
 		flash-leds = <&sgm3140_flash>;
@@ -812,7 +812,7 @@ ucam: camera@36 {
 		rockchip,camera-module-name = "CameraKing";
 		rockchip,camera-module-lens-name = "Largan-9569A2";
 
-		rotation = <180>;
+		rotation = <90>;
 
 		port {
 			ucam_out: endpoint {
-- 
2.46.0

