| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: uvideo.c,v 1.66 2022/03/03 06:22:03 riastradh Exp $ */ | | 1 | /* $NetBSD: uvideo.c,v 1.67 2022/03/03 06:22:40 riastradh 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.66 2022/03/03 06:22:03 riastradh Exp $"); | | 45 | __KERNEL_RCSID(0, "$NetBSD: uvideo.c,v 1.67 2022/03/03 06:22:40 riastradh Exp $"); |
46 | | | 46 | |
47 | #ifdef _KERNEL_OPT | | 47 | #ifdef _KERNEL_OPT |
48 | #include "opt_usb.h" | | 48 | #include "opt_usb.h" |
49 | #endif | | 49 | #endif |
50 | | | 50 | |
51 | #ifdef _MODULE | | 51 | #ifdef _MODULE |
52 | #include <sys/module.h> | | 52 | #include <sys/module.h> |
53 | #endif | | 53 | #endif |
54 | | | 54 | |
55 | #include <sys/param.h> | | 55 | #include <sys/param.h> |
56 | #include <sys/systm.h> | | 56 | #include <sys/systm.h> |
57 | #include <sys/kernel.h> | | 57 | #include <sys/kernel.h> |
58 | #include <sys/kmem.h> | | 58 | #include <sys/kmem.h> |
| @@ -742,27 +742,27 @@ uvideo_stream_guess_format(struct uvideo | | | @@ -742,27 +742,27 @@ uvideo_stream_guess_format(struct uvideo |
742 | if (gformat == NULL || | | 742 | if (gformat == NULL || |
743 | (gformat->format.width < format->format.width && | | 743 | (gformat->format.width < format->format.width && |
744 | gformat->format.height < format->format.height)) | | 744 | gformat->format.height < format->format.height)) |
745 | gformat = format; | | 745 | gformat = format; |
746 | } | | 746 | } |
747 | } | | 747 | } |
748 | | | 748 | |
749 | return gformat; | | 749 | return gformat; |
750 | } | | 750 | } |
751 | | | 751 | |
752 | static struct uvideo_stream * | | 752 | static struct uvideo_stream * |
753 | uvideo_stream_alloc(void) | | 753 | uvideo_stream_alloc(void) |
754 | { | | 754 | { |
755 | return kmem_alloc(sizeof(struct uvideo_stream), KM_SLEEP); | | 755 | return kmem_zalloc(sizeof(struct uvideo_stream), KM_SLEEP); |
756 | } | | 756 | } |
757 | | | 757 | |
758 | | | 758 | |
759 | static usbd_status | | 759 | static usbd_status |
760 | uvideo_init_control(struct uvideo_softc *sc, | | 760 | uvideo_init_control(struct uvideo_softc *sc, |
761 | const usb_interface_descriptor_t *ifdesc, | | 761 | const usb_interface_descriptor_t *ifdesc, |
762 | usbd_desc_iter_t *iter) | | 762 | usbd_desc_iter_t *iter) |
763 | { | | 763 | { |
764 | const usb_descriptor_t *desc; | | 764 | const usb_descriptor_t *desc; |
765 | const uvideo_descriptor_t *uvdesc; | | 765 | const uvideo_descriptor_t *uvdesc; |
766 | usbd_desc_iter_t orig; | | 766 | usbd_desc_iter_t orig; |
767 | uint8_t i, j, nunits; | | 767 | uint8_t i, j, nunits; |
768 | | | 768 | |
| @@ -1021,27 +1021,26 @@ static usbd_status | | | @@ -1021,27 +1021,26 @@ static usbd_status |
1021 | uvideo_stream_init(struct uvideo_stream *vs, | | 1021 | uvideo_stream_init(struct uvideo_stream *vs, |
1022 | struct uvideo_softc *sc, | | 1022 | struct uvideo_softc *sc, |
1023 | const usb_interface_descriptor_t *ifdesc) | | 1023 | const usb_interface_descriptor_t *ifdesc) |
1024 | { | | 1024 | { |
1025 | uWord len; | | 1025 | uWord len; |
1026 | usbd_status err; | | 1026 | usbd_status err; |
1027 | | | 1027 | |
1028 | DPRINTF(("%s: %s ifaceno=%d vs=%p\n", __func__, | | 1028 | DPRINTF(("%s: %s ifaceno=%d vs=%p\n", __func__, |
1029 | device_xname(sc->sc_dev), | | 1029 | device_xname(sc->sc_dev), |
1030 | ifdesc->bInterfaceNumber, | | 1030 | ifdesc->bInterfaceNumber, |
1031 | vs)); | | 1031 | vs)); |
1032 | | | 1032 | |
1033 | SLIST_INSERT_HEAD(&sc->sc_stream_list, vs, entries); | | 1033 | SLIST_INSERT_HEAD(&sc->sc_stream_list, vs, entries); |
1034 | memset(vs, 0, sizeof(*vs)); | | | |
1035 | vs->vs_parent = sc; | | 1034 | vs->vs_parent = sc; |
1036 | vs->vs_ifaceno = ifdesc->bInterfaceNumber; | | 1035 | vs->vs_ifaceno = ifdesc->bInterfaceNumber; |
1037 | vs->vs_subtype = 0; | | 1036 | vs->vs_subtype = 0; |
1038 | SIMPLEQ_INIT(&vs->vs_formats); | | 1037 | SIMPLEQ_INIT(&vs->vs_formats); |
1039 | SIMPLEQ_INIT(&vs->vs_pixel_formats); | | 1038 | SIMPLEQ_INIT(&vs->vs_pixel_formats); |
1040 | vs->vs_default_format = NULL; | | 1039 | vs->vs_default_format = NULL; |
1041 | vs->vs_current_format.priv = -1; | | 1040 | vs->vs_current_format.priv = -1; |
1042 | vs->vs_xfer_type = 0; | | 1041 | vs->vs_xfer_type = 0; |
1043 | | | 1042 | |
1044 | err = usbd_device2interface_handle(sc->sc_udev, vs->vs_ifaceno, | | 1043 | err = usbd_device2interface_handle(sc->sc_udev, vs->vs_ifaceno, |
1045 | &vs->vs_iface); | | 1044 | &vs->vs_iface); |
1046 | if (err != USBD_NORMAL_COMPLETION) { | | 1045 | if (err != USBD_NORMAL_COMPLETION) { |
1047 | DPRINTF(("uvideo_stream_init: " | | 1046 | DPRINTF(("uvideo_stream_init: " |