921b08ee7c963e9dc6a9e2aae79b56bcb1bd2bd6
[openwrt/openwrt.git] /
1 From d25d713f7bfe272cbeaac90769eb88fee382b2e9 Mon Sep 17 00:00:00 2001
2 From: Jacopo Mondi <jacopo@jmondi.org>
3 Date: Sat, 9 May 2020 11:04:48 +0200
4 Subject: [PATCH] media: v4l2-ctrls: Add camera orientation and
5 rotation
6
7 Add support for the newly defined V4L2_CID_CAMERA_ORIENTATION
8 and V4L2_CID_CAMERA_SENSOR_ROTATION read-only controls used to report
9 the camera device mounting position and orientation respectively.
10
11 Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
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 926645d43fd43622a2b056471a2cf41cc19cbf4c upstream
17
18 Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
19 ---
20 drivers/media/v4l2-core/v4l2-ctrls.c | 13 +++++++++++++
21 include/uapi/linux/v4l2-controls.h | 7 +++++++
22 2 files changed, 20 insertions(+)
23
24 --- a/drivers/media/v4l2-core/v4l2-ctrls.c
25 +++ b/drivers/media/v4l2-core/v4l2-ctrls.c
26 @@ -577,6 +577,12 @@ const char * const *v4l2_ctrl_get_menu(u
27 "Annex B Start Code",
28 NULL,
29 };
30 + static const char * const camera_orientation[] = {
31 + "Front",
32 + "Back",
33 + "External",
34 + NULL,
35 + };
36
37 switch (id) {
38 case V4L2_CID_MPEG_AUDIO_SAMPLING_FREQ:
39 @@ -702,6 +708,8 @@ const char * const *v4l2_ctrl_get_menu(u
40 return hevc_decode_mode;
41 case V4L2_CID_MPEG_VIDEO_HEVC_START_CODE:
42 return hevc_start_code;
43 + case V4L2_CID_CAMERA_ORIENTATION:
44 + return camera_orientation;
45 default:
46 return NULL;
47 }
48 @@ -1015,6 +1023,8 @@ const char *v4l2_ctrl_get_name(u32 id)
49 case V4L2_CID_PAN_SPEED: return "Pan, Speed";
50 case V4L2_CID_TILT_SPEED: return "Tilt, Speed";
51 case V4L2_CID_UNIT_CELL_SIZE: return "Unit Cell Size";
52 + case V4L2_CID_CAMERA_ORIENTATION: return "Camera Orientation";
53 + case V4L2_CID_CAMERA_SENSOR_ROTATION: return "Camera Sensor Rotation";
54
55 /* FM Radio Modulator controls */
56 /* Keep the order of the 'case's the same as in v4l2-controls.h! */
57 @@ -1288,6 +1298,7 @@ void v4l2_ctrl_fill(u32 id, const char *
58 case V4L2_CID_MPEG_VIDEO_HEVC_LOOP_FILTER_MODE:
59 case V4L2_CID_MPEG_VIDEO_HEVC_DECODE_MODE:
60 case V4L2_CID_MPEG_VIDEO_HEVC_START_CODE:
61 + case V4L2_CID_CAMERA_ORIENTATION:
62 *type = V4L2_CTRL_TYPE_MENU;
63 break;
64 case V4L2_CID_LINK_FREQ:
65 @@ -1480,6 +1491,8 @@ void v4l2_ctrl_fill(u32 id, const char *
66 case V4L2_CID_RDS_RX_TRAFFIC_ANNOUNCEMENT:
67 case V4L2_CID_RDS_RX_TRAFFIC_PROGRAM:
68 case V4L2_CID_RDS_RX_MUSIC_SPEECH:
69 + case V4L2_CID_CAMERA_ORIENTATION:
70 + case V4L2_CID_CAMERA_SENSOR_ROTATION:
71 *flags |= V4L2_CTRL_FLAG_READ_ONLY;
72 break;
73 case V4L2_CID_RF_TUNER_PLL_LOCK:
74 --- a/include/uapi/linux/v4l2-controls.h
75 +++ b/include/uapi/linux/v4l2-controls.h
76 @@ -917,6 +917,13 @@ enum v4l2_auto_focus_range {
77 #define V4L2_CID_PAN_SPEED (V4L2_CID_CAMERA_CLASS_BASE+32)
78 #define V4L2_CID_TILT_SPEED (V4L2_CID_CAMERA_CLASS_BASE+33)
79
80 +#define V4L2_CID_CAMERA_ORIENTATION (V4L2_CID_CAMERA_CLASS_BASE+34)
81 +#define V4L2_CAMERA_ORIENTATION_FRONT 0
82 +#define V4L2_CAMERA_ORIENTATION_BACK 1
83 +#define V4L2_CAMERA_ORIENTATION_EXTERNAL 2
84 +
85 +#define V4L2_CID_CAMERA_SENSOR_ROTATION (V4L2_CID_CAMERA_CLASS_BASE+35)
86 +
87 /* FM Modulator class control IDs */
88
89 #define V4L2_CID_FM_TX_CLASS_BASE (V4L2_CTRL_CLASS_FM_TX | 0x900)