diff options
author | Laurent Pinchart <laurent.pinchart@ideasonboard.com> | 2012-06-21 13:23:10 +0200 |
---|---|---|
committer | Laurent Pinchart <laurent.pinchart@ideasonboard.com> | 2012-06-21 15:03:38 +0200 |
commit | 972cb1c49b47a4c8775e24024c5b825a0990ee65 (patch) | |
tree | bb28f6c002118ef72b78e4e911d5f5b00956ca2e | |
parent | 685c68af9768c4219b7bb8ae68863293e3a4f63c (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.c | 49 | ||||
-rw-r--r-- | videoout.h | 3 |
2 files changed, 40 insertions, 12 deletions
@@ -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) @@ -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); |