summaryrefslogtreecommitdiff
path: root/sys/dev/usb
diff options
context:
space:
mode:
authorMarcus Glocker <mglocker@cvs.openbsd.org>2008-05-24 19:37:35 +0000
committerMarcus Glocker <mglocker@cvs.openbsd.org>2008-05-24 19:37:35 +0000
commitec8b8e37b2177d2b6911ecc80da5c5211d200380 (patch)
treee75a0bea9b7e89835738efd8affa4cead1803068 /sys/dev/usb
parent49a507fbe9895f9d7339d9e4f70a773072da0d09 (diff)
- Enable userland to read(2) video stream from /dev/video.
- Prepare for mmap(2).
Diffstat (limited to 'sys/dev/usb')
-rw-r--r--sys/dev/usb/uvideo.c23
-rw-r--r--sys/dev/usb/uvideo.h7
2 files changed, 26 insertions, 4 deletions
diff --git a/sys/dev/usb/uvideo.c b/sys/dev/usb/uvideo.c
index 3e3fde7fb23..1ca14d2fdf2 100644
--- a/sys/dev/usb/uvideo.c
+++ b/sys/dev/usb/uvideo.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: uvideo.c,v 1.16 2008/05/18 09:35:35 mglocker Exp $ */
+/* $OpenBSD: uvideo.c,v 1.17 2008/05/24 19:37:34 mglocker Exp $ */
/*
* Copyright (c) 2008 Robert Nagy <robert@openbsd.org>
@@ -54,7 +54,8 @@ int uvideo_debug = 1;
int uvideo_enable(void *);
void uvideo_disable(void *);
-int uvideo_open(void *, int);
+int uvideo_open(void *, int, int *, uint8_t *, void (*)(void *),
+ void *arg);
int uvideo_close(void *);
int uvideo_match(struct device *, void *, void *);
@@ -197,7 +198,8 @@ uvideo_disable(void *v)
}
int
-uvideo_open(void *addr, int flags)
+uvideo_open(void *addr, int flags, int *size, uint8_t *buffer,
+ void (*intr)(void *), void *arg)
{
struct uvideo_softc *sc = addr;
usbd_status error;
@@ -208,6 +210,12 @@ uvideo_open(void *addr, int flags)
if (sc->sc_dying)
return (EIO);
+ /* pointers to upper layer which we need */
+ sc->sc_uplayer_arg = arg;
+ sc->sc_uplayer_fsize = size;
+ sc->sc_uplayer_fbuffer = buffer;
+ sc->sc_uplayer_intr = intr;
+
/* open video stream pipe */
error = uvideo_vs_open(sc);
if (error != USBD_NORMAL_COMPLETION)
@@ -1161,6 +1169,15 @@ uvideo_vs_decode_stream_header(struct uvideo_softc *sc, uint8_t *frame,
usb_rem_task(sc->sc_udev, &sc->sc_task_write);
usb_add_task(sc->sc_udev, &sc->sc_task_write);
#endif
+ /*
+ * Copy video frame to upper layer buffer and call
+ * upper layer interrupt.
+ */
+ bzero(sc->sc_uplayer_fbuffer, 32000);
+ *sc->sc_uplayer_fsize = fb->offset;
+ bcopy(fb->buf, sc->sc_uplayer_fbuffer, fb->offset);
+ sc->sc_uplayer_intr(sc->sc_uplayer_arg);
+
fb->fragment = 0;
fb->fid = 0;
// fb->offset = 0;
diff --git a/sys/dev/usb/uvideo.h b/sys/dev/usb/uvideo.h
index 8bc8fc006e8..6950f5d76db 100644
--- a/sys/dev/usb/uvideo.h
+++ b/sys/dev/usb/uvideo.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: uvideo.h,v 1.7 2008/04/20 09:14:05 mglocker Exp $ */
+/* $OpenBSD: uvideo.h,v 1.8 2008/05/24 19:37:34 mglocker Exp $ */
/*
* Copyright (c) 2007 Robert Nagy <robert@openbsd.org>
@@ -393,4 +393,9 @@ struct uvideo_softc {
#define UVIDEO_MAX_VS_NUM 8
struct uvideo_vs_iface *sc_vs_curr;
struct uvideo_vs_iface sc_vs_coll[UVIDEO_MAX_VS_NUM];
+
+ void *sc_uplayer_arg;
+ int *sc_uplayer_fsize;
+ uint8_t *sc_uplayer_fbuffer;
+ void (*sc_uplayer_intr)(void *);
};