diff options
author | Robert Nagy <robert@cvs.openbsd.org> | 2008-06-09 05:49:11 +0000 |
---|---|---|
committer | Robert Nagy <robert@cvs.openbsd.org> | 2008-06-09 05:49:11 +0000 |
commit | 0cdbb8efe06fea47797ab4394ddece21c51ae77e (patch) | |
tree | 25056be3cb66c75c881a4fd8d03de875f6ff92a2 /sys/dev | |
parent | 0fea6ee3bb1c9040cf4bb57de571d7edec646a8f (diff) |
Allocate the video buffer based on the maximum frame size that's reported
by the device instead of using the statically set VIDEO_BUF_SIZE.
ok mglocker@
Diffstat (limited to 'sys/dev')
-rw-r--r-- | sys/dev/usb/uvideo.c | 24 | ||||
-rw-r--r-- | sys/dev/video.c | 8 | ||||
-rw-r--r-- | sys/dev/video_if.h | 6 |
3 files changed, 30 insertions, 8 deletions
diff --git a/sys/dev/usb/uvideo.c b/sys/dev/usb/uvideo.c index c6526b90611..9c01f93b83a 100644 --- a/sys/dev/usb/uvideo.c +++ b/sys/dev/usb/uvideo.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uvideo.c,v 1.27 2008/06/08 20:11:30 mglocker Exp $ */ +/* $OpenBSD: uvideo.c,v 1.28 2008/06/09 05:49:10 robert Exp $ */ /* * Copyright (c) 2008 Robert Nagy <robert@openbsd.org> @@ -147,6 +147,11 @@ int uvideo_streamon(void *, int); int uvideo_try_fmt(void *, struct v4l2_format *); caddr_t uvideo_mappage(void *, off_t, int); +/* + * Other hardware interface related functions + */ +int uvideo_get_bufsize(void *); + #define DEVNAME(_s) ((_s)->sc_dev.dv_xname) const struct cfattach uvideo_ca = { @@ -182,7 +187,8 @@ struct video_hw_if uvideo_hw_if = { uvideo_dqbuf, /* VIDIOC_DQBUF */ uvideo_streamon, /* VIDIOC_STREAMON */ uvideo_try_fmt, /* VIDIOC_TRY_FMT */ - uvideo_mappage /* mmap */ + uvideo_mappage, /* mmap */ + uvideo_get_bufsize /* read */ }; int @@ -885,6 +891,8 @@ uvideo_vs_get_probe(struct uvideo_softc *sc, uint8_t *probe_data) } DPRINTF(1, "%s: GET probe request successfully\n", DEVNAME(sc)); + sc->sc_video_buf_size = UGETDW(pc->dwMaxVideoFrameSize); + DPRINTF(1, "bmHint=0x%02x\n", UGETW(pc->bmHint)); DPRINTF(1, "bFormatIndex=0x%02x\n", pc->bFormatIndex); DPRINTF(1, "bFrameIndex=0x%02x\n", pc->bFrameIndex); @@ -895,7 +903,7 @@ uvideo_vs_get_probe(struct uvideo_softc *sc, uint8_t *probe_data) DPRINTF(1, "wCompWindowSize=0x%04x\n", UGETW(pc->wCompWindowSize)); DPRINTF(1, "wDelay=%d (ms)\n", UGETW(pc->wDelay)); DPRINTF(1, "dwMaxVideoFrameSize=%d (bytes)\n", - UGETDW(pc->dwMaxVideoFrameSize)); + sc->sc_video_buf_size); DPRINTF(1, "dwMaxPayloadTransferSize=%d (bytes)\n", UGETDW(pc->dwMaxPayloadTransferSize)); @@ -936,7 +944,7 @@ uvideo_vs_alloc_sample(struct uvideo_softc *sc) fb->buf_size = UGETDW(sc->sc_desc_probe.dwMaxVideoFrameSize); /* don't overflow the upper layer sample buffer */ - if (VIDEO_BUF_SIZE < fb->buf_size) { + if (sc->sc_video_buf_size < fb->buf_size) { printf("%s: sofware video buffer is too small!\n", DEVNAME(sc)); return (USBD_NOMEM); } @@ -1923,6 +1931,14 @@ uvideo_try_fmt(void *v, struct v4l2_format *fmt) return (0); } +int +uvideo_get_bufsize(void *v) +{ + struct uvideo_softc *sc = v; + + return (sc->sc_video_buf_size); +} + caddr_t uvideo_mappage(void *v, off_t off, int prot) { diff --git a/sys/dev/video.c b/sys/dev/video.c index 36cfc3c1f57..3f5b930224a 100644 --- a/sys/dev/video.c +++ b/sys/dev/video.c @@ -1,4 +1,4 @@ -/* $OpenBSD: video.c,v 1.7 2008/06/07 22:14:57 mglocker Exp $ */ +/* $OpenBSD: video.c,v 1.8 2008/06/09 05:49:10 robert Exp $ */ /* * Copyright (c) 2008 Robert Nagy <robert@openbsd.org> * @@ -63,13 +63,17 @@ videoattach(struct device *parent, struct device *self, void *aux) { struct video_softc *sc = (void *) self; struct video_attach_args *sa = aux; + int video_buf_size = 0; printf("\n"); sc->hw_if = sa->hwif; sc->hw_hdl = sa->hdl; sc->sc_dev = parent; - sc->sc_fbuffer = malloc(VIDEO_BUF_SIZE, M_DEVBUF, M_NOWAIT); + if (sc->hw_if->get_bufsize) + video_buf_size = (sc->hw_if->get_bufsize)(sc->hw_hdl); + + sc->sc_fbuffer = malloc(video_buf_size, M_DEVBUF, M_NOWAIT); if (sc->sc_fbuffer == NULL) { printf("video: could not allocate frame buffer\n"); return; diff --git a/sys/dev/video_if.h b/sys/dev/video_if.h index 2ecbc9f2720..b54c9f89ee9 100644 --- a/sys/dev/video_if.h +++ b/sys/dev/video_if.h @@ -1,4 +1,4 @@ -/* $OpenBSD: video_if.h,v 1.8 2008/06/07 22:14:57 mglocker Exp $ */ +/* $OpenBSD: video_if.h,v 1.9 2008/06/09 05:49:10 robert Exp $ */ /* * Copyright (c) 2008 Robert Nagy <robert@openbsd.org> * @@ -23,7 +23,6 @@ */ #define VIDEOUNIT(x) (minor(x)) -#define VIDEO_BUF_SIZE 131072 struct video_hw_if { /* open hardware */ @@ -47,6 +46,9 @@ struct video_hw_if { int (*streamon)(void *, int); int (*try_fmt)(void *, struct v4l2_format *); caddr_t (*mappage)(void *, off_t, int); + + /* other functions */ + int (*get_bufsize)(void *); }; struct video_attach_args { |