Skip to content

Commit 926645d

Browse files
jmondimchehab
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>
1 parent 9926c22 commit 926645d

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
@@ -583,6 +583,12 @@ const char * const *v4l2_ctrl_get_menu(u32 id)
583583
"Annex B Start Code",
584584
NULL,
585585
};
586+
static const char * const camera_orientation[] = {
587+
"Front",
588+
"Back",
589+
"External",
590+
NULL,
591+
};
586592

587593
switch (id) {
588594
case V4L2_CID_MPEG_AUDIO_SAMPLING_FREQ:
@@ -708,6 +714,8 @@ const char * const *v4l2_ctrl_get_menu(u32 id)
708714
return hevc_decode_mode;
709715
case V4L2_CID_MPEG_VIDEO_HEVC_START_CODE:
710716
return hevc_start_code;
717+
case V4L2_CID_CAMERA_ORIENTATION:
718+
return camera_orientation;
711719
default:
712720
return NULL;
713721
}
@@ -1020,6 +1028,8 @@ const char *v4l2_ctrl_get_name(u32 id)
10201028
case V4L2_CID_PAN_SPEED: return "Pan, Speed";
10211029
case V4L2_CID_TILT_SPEED: return "Tilt, Speed";
10221030
case V4L2_CID_UNIT_CELL_SIZE: return "Unit Cell Size";
1031+
case V4L2_CID_CAMERA_ORIENTATION: return "Camera Orientation";
1032+
case V4L2_CID_CAMERA_SENSOR_ROTATION: return "Camera Sensor Rotation";
10231033

10241034
/* FM Radio Modulator controls */
10251035
/* Keep the order of the 'case's the same as in v4l2-controls.h! */
@@ -1293,6 +1303,7 @@ void v4l2_ctrl_fill(u32 id, const char **name, enum v4l2_ctrl_type *type,
12931303
case V4L2_CID_MPEG_VIDEO_HEVC_LOOP_FILTER_MODE:
12941304
case V4L2_CID_MPEG_VIDEO_HEVC_DECODE_MODE:
12951305
case V4L2_CID_MPEG_VIDEO_HEVC_START_CODE:
1306+
case V4L2_CID_CAMERA_ORIENTATION:
12961307
*type = V4L2_CTRL_TYPE_MENU;
12971308
break;
12981309
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)