diff options
author | Marcus Glocker <mglocker@cvs.openbsd.org> | 2008-05-26 17:51:19 +0000 |
---|---|---|
committer | Marcus Glocker <mglocker@cvs.openbsd.org> | 2008-05-26 17:51:19 +0000 |
commit | ca26a9bd219d772f10b862a874a5081363d7e7ec (patch) | |
tree | 2e4e0a55438e5152a42a297644ab2319e8dc68aa /sys | |
parent | 54b6ea90d23bfd6581cb3e5a7a674863920d777f (diff) |
Add more ioctl's (still unfinished); VIDIOC_ENUM_FMT, VIDIOC_ENUMINPUT,
VIDIOC_S_INPUT, VIDIOC_TRY_FMT. Allows me at least to use a small V4L2
compatible webcam application to capture some images.
Diffstat (limited to 'sys')
-rw-r--r-- | sys/dev/usb/uvideo.c | 75 | ||||
-rw-r--r-- | sys/dev/video.c | 24 | ||||
-rw-r--r-- | sys/dev/video_if.h | 6 |
3 files changed, 101 insertions, 4 deletions
diff --git a/sys/dev/usb/uvideo.c b/sys/dev/usb/uvideo.c index f28b433c610..4d6230b7809 100644 --- a/sys/dev/usb/uvideo.c +++ b/sys/dev/usb/uvideo.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uvideo.c,v 1.18 2008/05/25 07:47:47 mglocker Exp $ */ +/* $OpenBSD: uvideo.c,v 1.19 2008/05/26 17:51:18 mglocker Exp $ */ /* * Copyright (c) 2008 Robert Nagy <robert@openbsd.org> @@ -131,9 +131,13 @@ void uvideo_debug_file_write_sample(void *); * IOCTL's */ int uvideo_querycap(void *, struct v4l2_capability *); +int uvideo_enum_fmt(void *, struct v4l2_fmtdesc *); int uvideo_s_fmt(void *, struct v4l2_format *); int uvideo_g_fmt(void *, struct v4l2_format *); int uvideo_reqbufs(void *, struct v4l2_requestbuffers *); +int uvideo_enum_input(void *, struct v4l2_input *); +int uvideo_s_input(void *, int); +int uvideo_try_fmt(void *, struct v4l2_format *); #define DEVNAME(_s) ((_s)->sc_dev.dv_xname) @@ -159,11 +163,15 @@ struct video_hw_if uvideo_hw_if = { uvideo_open, /* open */ uvideo_close, /* close */ uvideo_querycap, /* VIDIOC_QUERYCAP */ + uvideo_enum_fmt, /* VIDIOC_ENUM_FMT */ uvideo_s_fmt, /* VIDIOC_S_FMT */ uvideo_g_fmt, /* VIDIOC_G_FMT */ uvideo_reqbufs, /* VIDIOC_REQBUFS */ + uvideo_enum_input, /* VIDIOC_ENUMINPUT */ + uvideo_s_input, /* VIDIOC_S_INPUT */ NULL, /* VIDIOC_QBUF */ - NULL /* VIDIOC_DQBUF */ + NULL, /* VIDIOC_DQBUF */ + uvideo_try_fmt /* VIDIOC_TRY_FMT */ }; int @@ -1638,11 +1646,42 @@ uvideo_querycap(void *v, struct v4l2_capability *caps) } int +uvideo_enum_fmt(void *v, struct v4l2_fmtdesc *fmtdesc) +{ + struct uvideo_softc *sc = v; + + if (fmtdesc->type != V4L2_BUF_TYPE_VIDEO_CAPTURE || + fmtdesc->index > 0) + return (EINVAL); + + /* + * XXX We need to create a sc->sc_desc_format pointer array + * which containts all available format descriptors. + */ + switch (sc->sc_desc_format_mjpeg->bDescriptorSubtype) { + case UDESCSUB_VS_FORMAT_MJPEG: + fmtdesc->flags = V4L2_FMT_FLAG_COMPRESSED; + (void)strlcpy(fmtdesc->description, "MJPEG", + sizeof(fmtdesc->description)); + break; + default: + fmtdesc->flags = 0; + (void)strlcpy(fmtdesc->description, "Unknown Format", + sizeof(fmtdesc->description)); + break; + } + + return (0); +} + +int uvideo_s_fmt(void *v, struct v4l2_format *fmt) { if (fmt->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) return (EINVAL); + fmt->fmt.pix.sizeimage = 32000; + return (0); } @@ -1660,3 +1699,35 @@ uvideo_reqbufs(void *v, struct v4l2_requestbuffers *rb) { return (0); } + +int +uvideo_enum_input(void *v, struct v4l2_input *input) +{ + if (input->index != 0) + /* XXX we just support one input for now */ + return (EINVAL); + + strlcpy(input->name, "Camera Terminal", sizeof(input->name)); + input->type = V4L2_INPUT_TYPE_CAMERA; + + return (0); +} + +int +uvideo_s_input(void *v, int input) +{ + if (input != 0) + /* XXX we just support one input for now */ + return (EINVAL); + + return (0); +} + +int +uvideo_try_fmt(void *v, struct v4l2_format *fmt) +{ + if (fmt->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) + return (EINVAL); + + return (0); +} diff --git a/sys/dev/video.c b/sys/dev/video.c index ffb8dbcd182..646f0e99511 100644 --- a/sys/dev/video.c +++ b/sys/dev/video.c @@ -1,4 +1,4 @@ -/* $OpenBSD: video.c,v 1.3 2008/05/25 07:47:47 mglocker Exp $ */ +/* $OpenBSD: video.c,v 1.4 2008/05/26 17:51:18 mglocker Exp $ */ /* * Copyright (c) 2008 Robert Nagy <robert@openbsd.org> * @@ -165,6 +165,11 @@ videoioctl(dev_t dev, u_long cmd, caddr_t data, int flags, struct proc *p) error = (sc->hw_if->querycap)(sc->hw_hdl, (struct v4l2_capability *)data); break; + case VIDIOC_ENUM_FMT: + if (sc->hw_if->enum_fmt) + error = (sc->hw_if->enum_fmt)(sc->hw_hdl, + (struct v4l2_fmtdesc *)data); + break; case VIDIOC_S_FMT: if (!(flags & FWRITE)) return (EACCES); @@ -182,8 +187,25 @@ videoioctl(dev_t dev, u_long cmd, caddr_t data, int flags, struct proc *p) error = (sc->hw_if->reqbufs)(sc->hw_hdl, (struct v4l2_requestbuffers *)data); break; + case VIDIOC_ENUMINPUT: + if (sc->hw_if->enum_input) + error = (sc->hw_if->enum_input)(sc->hw_hdl, + (struct v4l2_input *)data); + break; + case VIDIOC_S_INPUT: + if (sc->hw_if->s_input) + error = (sc->hw_if->s_input)(sc->hw_hdl, + (int)*data); + break; case VIDIOC_QUERYBUF: + break; case VIDIOC_QBUF: + break; + case VIDIOC_TRY_FMT: + if (sc->hw_if->try_fmt) + error = (sc->hw_if->try_fmt)(sc->hw_hdl, + (struct v4l2_format *)data); + break; default: error = (ENOTTY); } diff --git a/sys/dev/video_if.h b/sys/dev/video_if.h index 464ae8c8c4e..4003eb5e4f5 100644 --- a/sys/dev/video_if.h +++ b/sys/dev/video_if.h @@ -1,4 +1,4 @@ -/* $OpenBSD: video_if.h,v 1.3 2008/05/25 07:47:47 mglocker Exp $ */ +/* $OpenBSD: video_if.h,v 1.4 2008/05/26 17:51:18 mglocker Exp $ */ /* * Copyright (c) 2008 Robert Nagy <robert@openbsd.org> * @@ -34,11 +34,15 @@ struct video_hw_if { /* ioctl's */ int (*querycap)(void *, struct v4l2_capability *); + int (*enum_fmt)(void *, struct v4l2_fmtdesc *); int (*s_fmt)(void *, struct v4l2_format *); int (*g_fmt)(void *, struct v4l2_format *); int (*reqbufs)(void *, struct v4l2_requestbuffers *); + int (*enum_input)(void *, struct v4l2_input *); + int (*s_input)(void *, int); int (*qbuf)(void *, struct v4l2_buffer *); int (*dqbuf)(void *, struct v4l2_buffer *); + int (*try_fmt)(void *, struct v4l2_format *); }; struct video_attach_args { |