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
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.
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>
16 Commit 926645d43fd43622a2b056471a2cf41cc19cbf4c upstream
18 Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
20 drivers/media/v4l2-core/v4l2-ctrls.c | 13 +++++++++++++
21 include/uapi/linux/v4l2-controls.h | 7 +++++++
22 2 files changed, 20 insertions(+)
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
30 + static const char * const camera_orientation[] = {
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;
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";
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;
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;
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)
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
85 +#define V4L2_CID_CAMERA_SENSOR_ROTATION (V4L2_CID_CAMERA_CLASS_BASE+35)
87 /* FM Modulator class control IDs */
89 #define V4L2_CID_FM_TX_CLASS_BASE (V4L2_CTRL_CLASS_FM_TX | 0x900)