summaryrefslogtreecommitdiff
path: root/sys/dev
diff options
context:
space:
mode:
authorMarcus Glocker <mglocker@cvs.openbsd.org>2008-07-02 21:28:51 +0000
committerMarcus Glocker <mglocker@cvs.openbsd.org>2008-07-02 21:28:51 +0000
commitc00ec0958600b76454b1056aab1e9e4cd8ed2789 (patch)
treec32de05e31962d8991e8a0bf2c2dbcfc9b951918 /sys/dev
parent3bca07f41f059e90fe9b325296d3578b93276650 (diff)
Add first bits to support uncompressed format.
Diffstat (limited to 'sys/dev')
-rw-r--r--sys/dev/usb/uvideo.c111
-rw-r--r--sys/dev/usb/uvideo.h38
2 files changed, 141 insertions, 8 deletions
diff --git a/sys/dev/usb/uvideo.c b/sys/dev/usb/uvideo.c
index 4ae8d1aa1b2..87d3d8653d8 100644
--- a/sys/dev/usb/uvideo.c
+++ b/sys/dev/usb/uvideo.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: uvideo.c,v 1.44 2008/07/01 11:02:44 mglocker Exp $ */
+/* $OpenBSD: uvideo.c,v 1.45 2008/07/02 21:28:50 mglocker Exp $ */
/*
* Copyright (c) 2008 Robert Nagy <robert@openbsd.org>
@@ -76,9 +76,13 @@ int uvideo_vs_parse_desc_input_header(struct uvideo_softc *,
int uvideo_vs_parse_desc_format(struct uvideo_softc *);
int uvideo_vs_parse_desc_format_mjpeg(struct uvideo_softc *,
const usb_descriptor_t *);
+int uvideo_vs_parse_desc_format_uncompressed(struct uvideo_softc *,
+ const usb_descriptor_t *);
int uvideo_vs_parse_desc_frame(struct uvideo_softc *);
int uvideo_vs_parse_desc_frame_mjpeg(struct uvideo_softc *,
const usb_descriptor_t *);
+int uvideo_vs_parse_desc_frame_uncompressed(struct uvideo_softc *,
+ const usb_descriptor_t *);
int uvideo_vs_parse_desc_alt(struct uvideo_softc *,
struct usb_attach_arg *uaa, int, int, int);
int uvideo_vs_set_alt(struct uvideo_softc *, usbd_interface_handle,
@@ -126,6 +130,10 @@ void uvideo_dump_desc_frame_mjpeg(struct uvideo_softc *,
const usb_descriptor_t *);
void uvideo_dump_desc_format_mjpeg(struct uvideo_softc *,
const usb_descriptor_t *);
+void uvideo_dump_desc_format_uncompressed(struct uvideo_softc *,
+ const usb_descriptor_t *);
+void uvideo_dump_desc_frame_uncompressed(struct uvideo_softc *,
+ const usb_descriptor_t *);
void uvideo_hexdump(void *, int);
int uvideo_debug_file_open(struct uvideo_softc *);
void uvideo_debug_file_write_sample(void *);
@@ -587,6 +595,12 @@ uvideo_vs_parse_desc_format(struct uvideo_softc *sc)
uvideo_vs_parse_desc_format_mjpeg(sc, desc);
}
break;
+ case UDESCSUB_VS_FORMAT_UNCOMPRESSED:
+ if (desc->bLength == 27) {
+ uvideo_vs_parse_desc_format_uncompressed(sc,
+ desc);
+ }
+ break;
}
desc = usb_desc_iter_next(&iter);
@@ -615,6 +629,25 @@ uvideo_vs_parse_desc_format_mjpeg(struct uvideo_softc *sc,
}
int
+uvideo_vs_parse_desc_format_uncompressed(struct uvideo_softc *sc,
+ const usb_descriptor_t *desc)
+{
+ struct usb_video_format_uncompressed_desc *d;
+
+ d = (struct usb_video_format_uncompressed_desc *)(uint8_t *)desc;
+
+ if (d->bNumFrameDescriptors == 0) {
+ printf("%s: no UNCOMPRESSED frame descriptors found!\n",
+ DEVNAME(sc));
+ return (-1);
+ }
+
+ /* TODO */
+
+ return (0);
+}
+
+int
uvideo_vs_parse_desc_frame(struct uvideo_softc *sc)
{
usbd_desc_iter_t iter;
@@ -1360,14 +1393,31 @@ uvideo_dump_desc_all(struct uvideo_softc *sc)
case UDESCSUB_VC_SELECTOR_UNIT:
printf("bDescriptorSubtype=0x%02x",
desc->bDescriptorSubtype);
- printf(" (UDESCSUB_VC_SELECTOR_UNIT)\n");
- /* TODO */
+ if (desc->bLength == 27) {
+ printf(" (UDESCSUB_VS_FORMAT_"
+ "UNCOMPRESSED)\n");
+ uvideo_dump_desc_format_uncompressed(
+ sc, desc);
+ } else {
+ printf(" (UDESCSUB_VC_SELECTOR_"
+ "UNIT)\n");
+ /* TODO */
+ }
break;
case UDESCSUB_VC_PROCESSING_UNIT:
printf("bDescriptorSubtype=0x%02x",
desc->bDescriptorSubtype);
- printf(" (UDESCSUB_VC_PROCESSING_UNIT)\n");
- /* TODO */
+ /* XXX do correct length calculation */
+ if (desc->bLength > 11) {
+ printf(" (UDESCSUB_VS_FRAME_"
+ "UNCOMPRESSED)\n");
+ uvideo_dump_desc_frame_uncompressed(
+ sc, desc);
+ } else {
+ printf(" (UDESCSUB_VC_PROCESSING_"
+ "UNIT)\n");
+ /* TODO */
+ }
break;
case UDESCSUB_VC_EXTENSION_UNIT:
printf("bDescriptorSubtype=0x%02x",
@@ -1377,7 +1427,8 @@ uvideo_dump_desc_all(struct uvideo_softc *sc)
printf("|\n");
uvideo_dump_desc_format_mjpeg(sc, desc);
} else {
- printf(" (UDESCSUB_VC_EXTENSION_UNIT)\n");
+ printf(" (UDESCSUB_VC_EXTENSION_"
+ "UNIT)\n");
/* TODO */
}
break;
@@ -1671,6 +1722,52 @@ uvideo_dump_desc_format_mjpeg(struct uvideo_softc *sc,
}
void
+uvideo_dump_desc_frame_uncompressed(struct uvideo_softc *sc,
+ const usb_descriptor_t *desc)
+{
+ struct usb_video_frame_uncompressed_desc *d;
+
+ d = (struct usb_video_frame_uncompressed_desc *)(uint8_t *)desc;
+
+ printf("bLength=%d\n", d->bLength);
+ printf("bDescriptorType=0x%02x\n", d->bDescriptorType);
+ printf("bDescriptorSubtype=0x%02x\n", d->bDescriptorSubtype);
+ printf("bFrameIndex=0x%02x\n", d->bFrameIndex);
+ printf("bmCapabilities=0x%02x\n", d->bmCapabilities);
+ printf("wWidth=%d\n", UGETW(d->wWidth));
+ printf("wHeight=%d\n", UGETW(d->wHeight));
+ printf("dwMinBitRate=%d\n", UGETDW(d->dwMinBitRate));
+ printf("dwMaxBitRate=%d\n", UGETDW(d->dwMaxBitRate));
+ printf("dwMaxVideoFrameBufferSize=%d\n",
+ UGETDW(d->dwMaxVideoFrameBufferSize));
+ printf("dwDefaultFrameInterval=%d\n",
+ UGETDW(d->dwDefaultFrameInterval));
+ printf("bFrameIntervalType=0x%02x\n", d->bFrameIntervalType);
+}
+
+void
+uvideo_dump_desc_format_uncompressed(struct uvideo_softc *sc,
+ const usb_descriptor_t *desc)
+{
+ struct usb_video_format_uncompressed_desc *d;
+
+ d = (struct usb_video_format_uncompressed_desc *)(uint8_t *)desc;
+
+ printf("bLength=%d\n", d->bLength);
+ printf("bDescriptorType=0x%02x\n", d->bDescriptorType);
+ printf("bDescriptorSubtype=0x%02x\n", d->bDescriptorSubtype);
+ printf("bFormatIndex=0x%02x\n", d->bFormatIndex);
+ printf("bNumFrameDescriptors=0x%02x\n", d->bNumFrameDescriptors);
+ printf("guidFormat=%s\n", d->guidFormat);
+ printf("bBitsPerPixel=0x%02x\n", d->bBitsPerPixel);
+ printf("bDefaultFrameIndex=0x%02x\n", d->bDefaultFrameIndex);
+ printf("bAspectRatioX=0x%02x\n", d->bAspectRatioX);
+ printf("bAspectRatioY=0x%02x\n", d->bAspectRatioY);
+ printf("bmInterlaceFlags=0x%02x\n", d->bmInterlaceFlags);
+ printf("bCopyProtect=0x%02x\n", d->bCopyProtect);
+}
+
+void
uvideo_hexdump(void *buf, int len)
{
int i;
@@ -1768,7 +1865,7 @@ uvideo_enum_fmt(void *v, struct v4l2_fmtdesc *fmtdesc)
/*
* XXX We need to create a sc->sc_desc_format pointer array
- * which containts all available format descriptors.
+ * which contains all available format descriptors.
*/
switch (sc->sc_desc_format_mjpeg->bDescriptorSubtype) {
case UDESCSUB_VS_FORMAT_MJPEG:
diff --git a/sys/dev/usb/uvideo.h b/sys/dev/usb/uvideo.h
index a90baaca5e9..3c3fcdd4530 100644
--- a/sys/dev/usb/uvideo.h
+++ b/sys/dev/usb/uvideo.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: uvideo.h,v 1.16 2008/06/30 17:04:18 mglocker Exp $ */
+/* $OpenBSD: uvideo.h,v 1.17 2008/07/02 21:28:50 mglocker Exp $ */
/*
* Copyright (c) 2007 Robert Nagy <robert@openbsd.org>
@@ -325,6 +325,42 @@ struct usb_video_frame_mjpeg_desc {
} __packed;
/*
+ * USB Video Payload Uncompressed
+ */
+/* Table 3-1: Uncompressed Video Format Descriptor */
+struct usb_video_format_uncompressed_desc {
+ uByte bLength;
+ uByte bDescriptorType;
+ uByte bDescriptorSubtype;
+ uByte bFormatIndex;
+ uByte bNumFrameDescriptors;
+ uByte guidFormat[16];
+ uByte bBitsPerPixel;
+ uByte bDefaultFrameIndex;
+ uByte bAspectRatioX;
+ uByte bAspectRatioY;
+ uByte bmInterlaceFlags;
+ uByte bCopyProtect;
+} __packed;
+
+/* Table 3-2: Uncompressed Video Frame Descriptor */
+struct usb_video_frame_uncompressed_desc {
+ uByte bLength;
+ uByte bDescriptorType;
+ uByte bDescriptorSubtype;
+ uByte bFrameIndex;
+ uByte bmCapabilities;
+ uWord wWidth;
+ uWord wHeight;
+ uDWord dwMinBitRate;
+ uDWord dwMaxBitRate;
+ uDWord dwMaxVideoFrameBufferSize;
+ uDWord dwDefaultFrameInterval;
+ uByte bFrameIntervalType;
+ /* TODO add continous/discrete frame intervals (Table 3-3/3-4) */
+} __packed;
+
+/*
* Driver specific private definitions.
*/
#define UVIDEO_NFRAMES_MAX 40