Sat Sep 20 18:17:56 2008 UTC ()
Add UYVY support.


(jmcneill)
diff -r1.14 -r1.15 src/sys/dev/usb/uvideo.c
diff -r1.1 -r1.2 src/sys/dev/usb/uvideoreg.h

cvs diff -r1.14 -r1.15 src/sys/dev/usb/uvideo.c (expand / switch to unified diff)

--- src/sys/dev/usb/uvideo.c 2008/09/20 15:55:38 1.14
+++ src/sys/dev/usb/uvideo.c 2008/09/20 18:17:56 1.15
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: uvideo.c,v 1.14 2008/09/20 15:55:38 jmcneill Exp $ */ 1/* $NetBSD: uvideo.c,v 1.15 2008/09/20 18:17:56 jmcneill Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 2008 Patrick Mahoney 4 * Copyright (c) 2008 Patrick Mahoney
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * This code was written by Patrick Mahoney (pat@polycrystal.org) as 7 * This code was written by Patrick Mahoney (pat@polycrystal.org) as
8 * part of Google Summer of Code 2008. 8 * part of Google Summer of Code 2008.
9 * 9 *
10 * Redistribution and use in source and binary forms, with or without 10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions 11 * modification, are permitted provided that the following conditions
12 * are met: 12 * are met:
13 * 1. Redistributions of source code must retain the above copyright 13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer. 14 * notice, this list of conditions and the following disclaimer.
@@ -32,27 +32,27 @@ @@ -32,27 +32,27 @@
32 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 32 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
33 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 33 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
34 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 34 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
35 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 35 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36 * POSSIBILITY OF SUCH DAMAGE. 36 * POSSIBILITY OF SUCH DAMAGE.
37 */ 37 */
38 38
39/* 39/*
40 * USB video specs: 40 * USB video specs:
41 * http://www.usb.org/developers/devclass_docs/USB_Video_Class_1_1.zip 41 * http://www.usb.org/developers/devclass_docs/USB_Video_Class_1_1.zip
42 */ 42 */
43 43
44#include <sys/cdefs.h> 44#include <sys/cdefs.h>
45__KERNEL_RCSID(0, "$NetBSD: uvideo.c,v 1.14 2008/09/20 15:55:38 jmcneill Exp $"); 45__KERNEL_RCSID(0, "$NetBSD: uvideo.c,v 1.15 2008/09/20 18:17:56 jmcneill Exp $");
46 46
47#ifdef _MODULE 47#ifdef _MODULE
48#include <sys/module.h> 48#include <sys/module.h>
49#endif 49#endif
50 50
51#include <sys/param.h> 51#include <sys/param.h>
52#include <sys/systm.h> 52#include <sys/systm.h>
53#include <sys/kernel.h> 53#include <sys/kernel.h>
54/* #include <sys/malloc.h> */ 54/* #include <sys/malloc.h> */
55#include <sys/kmem.h> 55#include <sys/kmem.h>
56#include <sys/device.h> 56#include <sys/device.h>
57#include <sys/ioctl.h> 57#include <sys/ioctl.h>
58#include <sys/uio.h> 58#include <sys/uio.h>
@@ -1245,26 +1245,28 @@ uvideo_stream_init_frame_based_format(st @@ -1245,26 +1245,28 @@ uvideo_stream_init_frame_based_format(st
1245 switch (format_desc->bDescriptorSubtype) { 1245 switch (format_desc->bDescriptorSubtype) {
1246 case UDESC_VS_FORMAT_UNCOMPRESSED: 1246 case UDESC_VS_FORMAT_UNCOMPRESSED:
1247 subtype = UDESC_VS_FRAME_UNCOMPRESSED; 1247 subtype = UDESC_VS_FRAME_UNCOMPRESSED;
1248 default_index = GET(uvideo_vs_format_uncompressed_descriptor_t, 1248 default_index = GET(uvideo_vs_format_uncompressed_descriptor_t,
1249 format_desc, 1249 format_desc,
1250 bDefaultFrameIndex); 1250 bDefaultFrameIndex);
1251 guid = GETP(uvideo_vs_format_uncompressed_descriptor_t, 1251 guid = GETP(uvideo_vs_format_uncompressed_descriptor_t,
1252 format_desc, 1252 format_desc,
1253 guidFormat); 1253 guidFormat);
1254 if (usb_guid_cmp(guid, &uvideo_guid_format_yuy2) == 0) 1254 if (usb_guid_cmp(guid, &uvideo_guid_format_yuy2) == 0)
1255 pixel_format = VIDEO_FORMAT_YUY2; 1255 pixel_format = VIDEO_FORMAT_YUY2;
1256 else if (usb_guid_cmp(guid, &uvideo_guid_format_nv12) == 0) 1256 else if (usb_guid_cmp(guid, &uvideo_guid_format_nv12) == 0)
1257 pixel_format = VIDEO_FORMAT_NV12; 1257 pixel_format = VIDEO_FORMAT_NV12;
 1258 else if (usb_guid_cmp(guid, &uvideo_guid_format_uyvy) == 0)
 1259 pixel_format = VIDEO_FORMAT_UYVY;
1258 break; 1260 break;
1259 case UDESC_VS_FORMAT_FRAME_BASED: 1261 case UDESC_VS_FORMAT_FRAME_BASED:
1260 subtype = UDESC_VS_FRAME_FRAME_BASED; 1262 subtype = UDESC_VS_FRAME_FRAME_BASED;
1261 default_index = GET(uvideo_format_frame_based_descriptor_t, 1263 default_index = GET(uvideo_format_frame_based_descriptor_t,
1262 format_desc, 1264 format_desc,
1263 bDefaultFrameIndex); 1265 bDefaultFrameIndex);
1264 break; 1266 break;
1265 case UDESC_VS_FORMAT_MJPEG: 1267 case UDESC_VS_FORMAT_MJPEG:
1266 subtype = UDESC_VS_FRAME_MJPEG; 1268 subtype = UDESC_VS_FRAME_MJPEG;
1267 default_index = GET(uvideo_vs_format_mjpeg_descriptor_t, 1269 default_index = GET(uvideo_vs_format_mjpeg_descriptor_t,
1268 format_desc, 1270 format_desc,
1269 bDefaultFrameIndex); 1271 bDefaultFrameIndex);
1270 pixel_format = VIDEO_FORMAT_MJPEG; 1272 pixel_format = VIDEO_FORMAT_MJPEG;

cvs diff -r1.1 -r1.2 src/sys/dev/usb/uvideoreg.h (expand / switch to unified diff)

--- src/sys/dev/usb/uvideoreg.h 2008/09/09 01:13:42 1.1
+++ src/sys/dev/usb/uvideoreg.h 2008/09/20 18:17:56 1.2
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: uvideoreg.h,v 1.1 2008/09/09 01:13:42 jmcneill Exp $ */ 1/* $NetBSD: uvideoreg.h,v 1.2 2008/09/20 18:17:56 jmcneill Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 2008 Patrick Mahoney 4 * Copyright (c) 2008 Patrick Mahoney
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * This code was written by Patrick Mahoney (pat@polycrystal.org) as 7 * This code was written by Patrick Mahoney (pat@polycrystal.org) as
8 * part of Google Summer of Code 2008. 8 * part of Google Summer of Code 2008.
9 * 9 *
10 * Redistribution and use in source and binary forms, with or without 10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions 11 * modification, are permitted provided that the following conditions
12 * are met: 12 * are met:
13 * 1. Redistributions of source code must retain the above copyright 13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer. 14 * notice, this list of conditions and the following disclaimer.
@@ -390,26 +390,33 @@ static const guid_t uvideo_guid_format_y @@ -390,26 +390,33 @@ static const guid_t uvideo_guid_format_y
390 0x32595559, 390 0x32595559,
391 0x0000, 391 0x0000,
392 0x0010, 392 0x0010,
393 {0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71} 393 {0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71}
394}; 394};
395 395
396static const guid_t uvideo_guid_format_nv12 = { 396static const guid_t uvideo_guid_format_nv12 = {
397 0x3231564E, 397 0x3231564E,
398 0x0000, 398 0x0000,
399 0x0010, 399 0x0010,
400 {0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71} 400 {0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71}
401}; 401};
402 402
 403static const guid_t uvideo_guid_format_uyvy = {
 404 0x59565955,
 405 0x0000,
 406 0x0010,
 407 {0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71}
 408};
 409
403typedef struct { 410typedef struct {
404 uByte bLength; 411 uByte bLength;
405 uByte bDescriptorType; 412 uByte bDescriptorType;
406 uByte bDescriptorSubtype; 413 uByte bDescriptorSubtype;
407 uByte bFormatIndex; 414 uByte bFormatIndex;
408 uByte bNumFrameDescriptors; 415 uByte bNumFrameDescriptors;
409 usb_guid_t guidFormat; 416 usb_guid_t guidFormat;
410 uByte bBitsPerPixel; 417 uByte bBitsPerPixel;
411 uByte bDefaultFrameIndex; 418 uByte bDefaultFrameIndex;
412 uByte bAspectRatioX; 419 uByte bAspectRatioX;
413 uByte bAspectRatioY; 420 uByte bAspectRatioY;
414 uByte bmInterlaceFlags; 421 uByte bmInterlaceFlags;
415 uByte bCopyProtect; 422 uByte bCopyProtect;