summaryrefslogtreecommitdiff
path: root/sys/dev/usb
diff options
context:
space:
mode:
authorMarcus Glocker <mglocker@cvs.openbsd.org>2008-06-06 19:14:46 +0000
committerMarcus Glocker <mglocker@cvs.openbsd.org>2008-06-06 19:14:46 +0000
commitbbb3fd3a3951d37d7f793b96201e38a29ea4c66b (patch)
treea5b298dbfdbfb407e1d44134e920b4109d0d426b /sys/dev/usb
parent91ddd39e8419447fd44d70d29f76efb14e86a638 (diff)
Arrange our mmap buffer struct better.
Diffstat (limited to 'sys/dev/usb')
-rw-r--r--sys/dev/usb/uvideo.c36
-rw-r--r--sys/dev/usb/uvideo.h9
2 files changed, 24 insertions, 21 deletions
diff --git a/sys/dev/usb/uvideo.c b/sys/dev/usb/uvideo.c
index d82bf4eb2f5..b45a7ef7710 100644
--- a/sys/dev/usb/uvideo.c
+++ b/sys/dev/usb/uvideo.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: uvideo.c,v 1.23 2008/06/05 20:50:28 mglocker Exp $ */
+/* $OpenBSD: uvideo.c,v 1.24 2008/06/06 19:14:45 mglocker Exp $ */
/*
* Copyright (c) 2008 Robert Nagy <robert@openbsd.org>
@@ -1755,8 +1755,8 @@ uvideo_reqbufs(void *v, struct v4l2_requestbuffers *rb)
buf_size = UGETDW(sc->sc_desc_probe.dwMaxVideoFrameSize);
buf_size_total = buf_count * buf_size;
buf_size_total = round_page(buf_size_total); /* page align buffer */
- sc->sc_mmap_buffer.buf = malloc(buf_size_total, M_DEVBUF, M_NOWAIT);
- if (sc->sc_mmap_buffer.buf == NULL) {
+ sc->sc_mmap_buffer = malloc(buf_size_total, M_DEVBUF, M_NOWAIT);
+ if (sc->sc_mmap_buffer == NULL) {
printf("%s: can't allocate mmap buffer!\n", DEVNAME(sc));
return (EINVAL);
}
@@ -1765,20 +1765,22 @@ uvideo_reqbufs(void *v, struct v4l2_requestbuffers *rb)
/* fill the v4l2_buffer structure */
for (i = 0; i < buf_count; i++) {
- sc->sc_mmap_buffer.v4l2_buf[i].index = i;
- sc->sc_mmap_buffer.v4l2_buf[i].m.offset = i * buf_size;
- sc->sc_mmap_buffer.v4l2_buf[i].length = buf_size;
- sc->sc_mmap_buffer.v4l2_buf[i].type =
- V4L2_BUF_TYPE_VIDEO_CAPTURE;
- sc->sc_mmap_buffer.v4l2_buf[i].sequence = 0;
- sc->sc_mmap_buffer.v4l2_buf[i].field = V4L2_FIELD_NONE;
- sc->sc_mmap_buffer.v4l2_buf[i].memory = V4L2_MEMORY_MMAP;
- sc->sc_mmap_buffer.v4l2_buf[i].flags = V4L2_MEMORY_MMAP;
+ sc->sc_mmap[i].buf = sc->sc_mmap_buffer + (i * buf_size);
+
+ sc->sc_mmap[i].v4l2_buf.index = i;
+ sc->sc_mmap[i].v4l2_buf.m.offset = i * buf_size;
+ sc->sc_mmap[i].v4l2_buf.length = buf_size;
+ sc->sc_mmap[i].v4l2_buf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
+ sc->sc_mmap[i].v4l2_buf.sequence = 0;
+ sc->sc_mmap[i].v4l2_buf.field = V4L2_FIELD_NONE;
+ sc->sc_mmap[i].v4l2_buf.memory = V4L2_MEMORY_MMAP;
+ sc->sc_mmap[i].v4l2_buf.flags = V4L2_MEMORY_MMAP;
+
DPRINTF(1, "%s: %s: index=%d, offset=%d, length=%d\n",
DEVNAME(sc), __func__,
- sc->sc_mmap_buffer.v4l2_buf[i].index,
- sc->sc_mmap_buffer.v4l2_buf[i].m.offset,
- sc->sc_mmap_buffer.v4l2_buf[i].length);
+ sc->sc_mmap[i].v4l2_buf.index,
+ sc->sc_mmap[i].v4l2_buf.m.offset,
+ sc->sc_mmap[i].v4l2_buf.length);
}
/* tell how many buffers we have really allocated */
@@ -1796,7 +1798,7 @@ uvideo_querybuf(void *v, struct v4l2_buffer *qb)
qb->memory != V4L2_MEMORY_MMAP)
return (EINVAL);
- bcopy(&sc->sc_mmap_buffer.v4l2_buf[qb->index], qb,
+ bcopy(&sc->sc_mmap[qb->index].v4l2_buf, qb,
sizeof(struct v4l2_buffer));
DPRINTF(1, "%s: %s: index=%d, offset=%d, length=%d\n",
@@ -1823,7 +1825,7 @@ uvideo_mappage(void *v, off_t off, int prot)
struct uvideo_softc *sc = v;
caddr_t p;
- p = sc->sc_mmap_buffer.buf + off;
+ p = sc->sc_mmap_buffer + off;
return (p);
}
diff --git a/sys/dev/usb/uvideo.h b/sys/dev/usb/uvideo.h
index 593ea01138c..33b1865bc13 100644
--- a/sys/dev/usb/uvideo.h
+++ b/sys/dev/usb/uvideo.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: uvideo.h,v 1.10 2008/06/05 20:50:28 mglocker Exp $ */
+/* $OpenBSD: uvideo.h,v 1.11 2008/06/06 19:14:45 mglocker Exp $ */
/*
* Copyright (c) 2007 Robert Nagy <robert@openbsd.org>
@@ -352,7 +352,7 @@ struct uvideo_sample_buffer {
};
#define UVIDEO_MAX_BUFFERS 256
-struct uvideo_mmap_buffer {
+struct uvideo_mmap {
/*
* TODO
* Complete buffer so we can queue/dequeue video frames.
@@ -360,7 +360,7 @@ struct uvideo_mmap_buffer {
*/
uint8_t *buf;
- struct v4l2_buffer v4l2_buf[UVIDEO_MAX_BUFFERS];
+ struct v4l2_buffer v4l2_buf;
};
struct uvideo_softc {
@@ -392,7 +392,8 @@ struct uvideo_softc {
u_int32_t quirks;
struct uvideo_sample_buffer sc_sample_buffer;
- struct uvideo_mmap_buffer sc_mmap_buffer;
+ struct uvideo_mmap sc_mmap[UVIDEO_MAX_BUFFERS];
+ uint8_t *sc_mmap_buffer;
struct vnode *sc_vp;
struct usb_task sc_task_write;