summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLaurent Pinchart <laurent.pinchart@ideasonboard.com>2012-06-21 13:23:10 +0200
committerLaurent Pinchart <laurent.pinchart@ideasonboard.com>2012-06-21 15:03:38 +0200
commit972cb1c49b47a4c8775e24024c5b825a0990ee65 (patch)
treebb28f6c002118ef72b78e4e911d5f5b00956ca2e
parent685c68af9768c4219b7bb8ae68863293e3a4f63c (diff)
videout: Add support for disabling chroma keying
And make vo_enable_colorkey() return 0 on success and a negative error code otherwise. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
-rw-r--r--videoout.c49
-rw-r--r--videoout.h3
2 files changed, 40 insertions, 12 deletions
diff --git a/videoout.c b/videoout.c
index df580c0..f3d3a22 100644
--- a/videoout.c
+++ b/videoout.c
@@ -136,37 +136,62 @@ int vo_enable_colorkey(struct videoout *vo, unsigned int val)
struct v4l2_format fmt;
int ret;
+ ret = ioctl(vo->dev->fd, VIDIOC_G_FBUF, &framebuffer);
+ if (ret < 0) {
+ perror("VIDIOC_G_FBUF");
+ return -errno;
+ }
+
+ if (!(framebuffer.capability & V4L2_FBUF_CAP_CHROMAKEY))
+ return -ENOTSUP;
+
fmt.type = V4L2_BUF_TYPE_VIDEO_OVERLAY;
ret = ioctl(vo->dev->fd, VIDIOC_G_FMT, &fmt);
if (ret < 0) {
perror("VIDIOC_G_FMT\n");
- return 0;
+ return -errno;
}
fmt.fmt.win.chromakey = val;
ret = ioctl(vo->dev->fd, VIDIOC_S_FMT, &fmt);
if (ret < 0) {
perror("VIDIOC_G_FMT\n");
- return 0;
+ return -errno;
+ }
+
+ framebuffer.flags |= V4L2_FBUF_FLAG_CHROMAKEY;
+ framebuffer.flags &= ~V4L2_FBUF_FLAG_LOCAL_ALPHA;
+ ret = ioctl(vo->dev->fd, VIDIOC_S_FBUF, &framebuffer);
+ if (ret < 0) {
+ perror("VIDIOC_S_FBUF");
+ return -errno;
}
+ return 0;
+}
+
+int vo_disable_colorkey(struct videoout *vo)
+{
+ struct v4l2_framebuffer framebuffer;
+ int ret;
+
ret = ioctl(vo->dev->fd, VIDIOC_G_FBUF, &framebuffer);
if (ret < 0) {
perror("VIDIOC_G_FBUF");
- return 0;
+ return -errno;
}
- if (framebuffer.capability & V4L2_FBUF_CAP_CHROMAKEY) {
- framebuffer.flags |= V4L2_FBUF_FLAG_CHROMAKEY;
- framebuffer.flags &= ~V4L2_FBUF_FLAG_LOCAL_ALPHA;
- ret = ioctl(vo->dev->fd, VIDIOC_S_FBUF, &framebuffer);
- if (ret < 0) {
- perror("VIDIOC_S_FBUF");
- return 0;
- }
+ if (!(framebuffer.capability & V4L2_FBUF_CAP_CHROMAKEY))
+ return 0;
+
+ framebuffer.flags &= ~V4L2_FBUF_FLAG_CHROMAKEY;
+ ret = ioctl(vo->dev->fd, VIDIOC_S_FBUF, &framebuffer);
+ if (ret < 0) {
+ perror("VIDIOC_S_FBUF");
+ return -errno;
}
- return 1;
+ return 0;
}
struct v4l2_buffers_pool *vo_get_pool(struct videoout *vo)
diff --git a/videoout.h b/videoout.h
index cf20025..0f4cc4c 100644
--- a/videoout.h
+++ b/videoout.h
@@ -39,7 +39,10 @@ struct videoout *vo_init(const char *devname,
unsigned int buffers,
struct v4l2_pix_format *format);
void vo_cleanup(struct videoout *vo);
+
int vo_enable_colorkey(struct videoout *vo, unsigned int val);
+int vo_disable_colorkey(struct videoout *vo);
+
struct v4l2_buffers_pool *vo_get_pool(struct videoout *vo);
int vo_dequeue_buffer(struct videoout *vo, struct v4l2_video_buffer *buffer);
int vo_queue_buffer(struct videoout *vo, struct v4l2_video_buffer *buffer);