From 30aab83c0433a9c2b51fdeaaf01aba8c8bef259c Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Wed, 12 Jun 2013 16:46:25 +0200 Subject: videoout: Add rotation support --- live.c | 2 +- videoout.c | 11 ++++++++++- videoout.h | 3 ++- 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); -- cgit v1.2.3