summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLaurent Pinchart <laurent.pinchart@ideasonboard.com>2013-06-12 16:46:25 +0200
committerLaurent Pinchart <laurent.pinchart@ideasonboard.com>2015-11-12 17:00:50 +0200
commit30aab83c0433a9c2b51fdeaaf01aba8c8bef259c (patch)
tree2b48119a6e160c987cae02f89198dacb3b44905e
parent7aa0337975506ad37fc793e184c52713a2ca411b (diff)
videoout: Add rotation support
-rw-r--r--live.c2
-rw-r--r--videoout.c11
-rw-r--r--videoout.h3
3 files changed, 13 insertions, 3 deletions
diff --git a/live.c b/live.c
index d1785da..e13a210 100644
--- a/live.c
+++ b/live.c
@@ -879,7 +879,7 @@ int main(int argc __attribute__((__unused__)), char *argv[] __attribute__((__unu
format.pixelformat = V4L2_PIX_FMT_YUYV;
format.width = rect.width;
format.height = rect.height;
- vo = vo_init(vo_devname, &vo_ops, buffers, &format);
+ vo = vo_init(vo_devname, &vo_ops, buffers, &format, 0);
if (vo == NULL) {
printf("error: unable to initialize video output\n");
goto cleanup;
diff --git a/videoout.c b/videoout.c
index 51bed8b..f12ee68 100644
--- a/videoout.c
+++ b/videoout.c
@@ -54,11 +54,13 @@ struct videoout
struct videoout *vo_init(const char *devname,
const struct video_out_operations *ops,
unsigned int buffers,
- struct v4l2_pix_format *format)
+ struct v4l2_pix_format *format,
+ unsigned int rotation)
{
struct v4l2_pix_format pixfmt;
struct v4l2_format fmt;
struct videoout *vo;
+ int32_t ctrl;
int ret;
/* Allocate the video output object. */
@@ -76,6 +78,13 @@ struct videoout *vo_init(const char *devname,
goto error;
}
+ ctrl = rotation;
+ ret = v4l2_set_control(vo->dev, V4L2_CID_ROTATE, &ctrl);
+ if (ret < 0) {
+ perror("failed to configure rotation\n");
+ goto error;
+ }
+
pixfmt.pixelformat = format->pixelformat;
pixfmt.width = format->width;
pixfmt.height = format->height;
diff --git a/videoout.h b/videoout.h
index 0f4cc4c..bcef450 100644
--- a/videoout.h
+++ b/videoout.h
@@ -37,7 +37,8 @@ struct video_out_operations {
struct videoout *vo_init(const char *devname,
const struct video_out_operations *ops,
unsigned int buffers,
- struct v4l2_pix_format *format);
+ struct v4l2_pix_format *format,
+ unsigned int rotation);
void vo_cleanup(struct videoout *vo);
int vo_enable_colorkey(struct videoout *vo, unsigned int val);