Skip to content

Commit 565fd97

Browse files
jmondipopcornmix
authored andcommitted
media: v4l2-ctrls: Add camera orientation and rotation
Add support for the newly defined V4L2_CID_CAMERA_ORIENTATION and V4L2_CID_CAMERA_SENSOR_ROTATION read-only controls used to report the camera device mounting position and orientation respectively. Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Jacopo Mondi <jacopo@jmondi.org> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org> Commit 926645d upstream Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
1 parent f5ae1af commit 565fd97

2 files changed

Lines changed: 20 additions & 0 deletions

File tree

‎drivers/media/v4l2-core/v4l2-ctrls.c‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -579,6 +579,12 @@ const char * const *v4l2_ctrl_get_menu(u32 id)
579579
"Annex B Start Code",
580580
NULL,
581581
};
582+
static const char * const camera_orientation[] = {
583+
"Front",
584+
"Back",
585+
"External",
586+
NULL,
587+
};
582588

583589
switch (id) {
584590
case V4L2_CID_MPEG_AUDIO_SAMPLING_FREQ:
@@ -704,6 +710,8 @@ const char * const *v4l2_ctrl_get_menu(u32 id)
704710
return hevc_decode_mode;
705711
case V4L2_CID_MPEG_VIDEO_HEVC_START_CODE:
706712
return hevc_start_code;
713+
case V4L2_CID_CAMERA_ORIENTATION:
714+
return camera_orientation;
707715
default:
708716
return NULL;
709717
}
@@ -1017,6 +1025,8 @@ const char *v4l2_ctrl_get_name(u32 id)
10171025
case V4L2_CID_PAN_SPEED: return "Pan, Speed";
10181026
case V4L2_CID_TILT_SPEED: return "Tilt, Speed";
10191027
case V4L2_CID_UNIT_CELL_SIZE: return "Unit Cell Size";
1028+
case V4L2_CID_CAMERA_ORIENTATION: return "Camera Orientation";
1029+
case V4L2_CID_CAMERA_SENSOR_ROTATION: return "Camera Sensor Rotation";
10201030

10211031
/* FM Radio Modulator controls */
10221032
/* Keep the order of the 'case's the same as in v4l2-controls.h! */
@@ -1290,6 +1300,7 @@ void v4l2_ctrl_fill(u32 id, const char **name, enum v4l2_ctrl_type *type,
12901300
case V4L2_CID_MPEG_VIDEO_HEVC_LOOP_FILTER_MODE:
12911301
case V4L2_CID_MPEG_VIDEO_HEVC_DECODE_MODE:
12921302
case V4L2_CID_MPEG_VIDEO_HEVC_START_CODE:
1303+
case V4L2_CID_CAMERA_ORIENTATION:
12931304
*type = V4L2_CTRL_TYPE_MENU;
12941305
break;
12951306
case V4L2_CID_LINK_FREQ:
@@ -1482,6 +1493,8 @@ void v4l2_ctrl_fill(u32 id, const char **name, enum v4l2_ctrl_type *type,
14821493
case V4L2_CID_RDS_RX_TRAFFIC_ANNOUNCEMENT:
14831494
case V4L2_CID_RDS_RX_TRAFFIC_PROGRAM:
14841495
case V4L2_CID_RDS_RX_MUSIC_SPEECH:
1496+
case V4L2_CID_CAMERA_ORIENTATION:
1497+
case V4L2_CID_CAMERA_SENSOR_ROTATION:
14851498
*flags |= V4L2_CTRL_FLAG_READ_ONLY;
14861499
break;
14871500
case V4L2_CID_RF_TUNER_PLL_LOCK:

‎include/uapi/linux/v4l2-controls.h‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -923,6 +923,13 @@ enum v4l2_auto_focus_range {
923923
#define V4L2_CID_PAN_SPEED (V4L2_CID_CAMERA_CLASS_BASE+32)
924924
#define V4L2_CID_TILT_SPEED (V4L2_CID_CAMERA_CLASS_BASE+33)
925925

926+
#define V4L2_CID_CAMERA_ORIENTATION (V4L2_CID_CAMERA_CLASS_BASE+34)
927+
#define V4L2_CAMERA_ORIENTATION_FRONT 0
928+
#define V4L2_CAMERA_ORIENTATION_BACK 1
929+
#define V4L2_CAMERA_ORIENTATION_EXTERNAL 2
930+
931+
#define V4L2_CID_CAMERA_SENSOR_ROTATION (V4L2_CID_CAMERA_CLASS_BASE+35)
932+
926933
/* FM Modulator class control IDs */
927934

928935
#define V4L2_CID_FM_TX_CLASS_BASE (V4L2_CTRL_CLASS_FM_TX | 0x900)

0 commit comments

Comments
 (0)