| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: video.c,v 1.16 2008/09/20 18:13:40 jmcneill Exp $ */ | | 1 | /* $NetBSD: video.c,v 1.17 2008/09/21 19:29:50 jmcneill Exp $ */ |
2 | | | 2 | |
3 | /* | | 3 | /* |
4 | * Copyright (c) 2008 Patrick Mahoney <pat@polycrystal.org> | | 4 | * Copyright (c) 2008 Patrick Mahoney <pat@polycrystal.org> |
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. |
| @@ -26,27 +26,27 @@ | | | @@ -26,27 +26,27 @@ |
26 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | | 26 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
27 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | | 27 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
28 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | | 28 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
29 | * POSSIBILITY OF SUCH DAMAGE. | | 29 | * POSSIBILITY OF SUCH DAMAGE. |
30 | */ | | 30 | */ |
31 | | | 31 | |
32 | /* | | 32 | /* |
33 | * This ia a Video4Linux 2 compatible /dev/video driver for NetBSD | | 33 | * This ia a Video4Linux 2 compatible /dev/video driver for NetBSD |
34 | * | | 34 | * |
35 | * See http://v4l2spec.bytesex.org/ for Video4Linux 2 specifications | | 35 | * See http://v4l2spec.bytesex.org/ for Video4Linux 2 specifications |
36 | */ | | 36 | */ |
37 | | | 37 | |
38 | #include <sys/cdefs.h> | | 38 | #include <sys/cdefs.h> |
39 | __KERNEL_RCSID(0, "$NetBSD: video.c,v 1.16 2008/09/20 18:13:40 jmcneill Exp $"); | | 39 | __KERNEL_RCSID(0, "$NetBSD: video.c,v 1.17 2008/09/21 19:29:50 jmcneill Exp $"); |
40 | | | 40 | |
41 | #include "video.h" | | 41 | #include "video.h" |
42 | #if NVIDEO > 0 | | 42 | #if NVIDEO > 0 |
43 | | | 43 | |
44 | #include <sys/param.h> | | 44 | #include <sys/param.h> |
45 | #include <sys/ioctl.h> | | 45 | #include <sys/ioctl.h> |
46 | #include <sys/fcntl.h> | | 46 | #include <sys/fcntl.h> |
47 | #include <sys/vnode.h> | | 47 | #include <sys/vnode.h> |
48 | #include <sys/poll.h> | | 48 | #include <sys/poll.h> |
49 | #include <sys/select.h> | | 49 | #include <sys/select.h> |
50 | #include <sys/kmem.h> | | 50 | #include <sys/kmem.h> |
51 | #include <sys/pool.h> | | 51 | #include <sys/pool.h> |
52 | #include <sys/conf.h> | | 52 | #include <sys/conf.h> |
| @@ -301,26 +301,29 @@ video_attach(device_t parent, device_t s | | | @@ -301,26 +301,29 @@ video_attach(device_t parent, device_t s |
301 | sc->hw_softc = device_private(parent); | | 301 | sc->hw_softc = device_private(parent); |
302 | | | 302 | |
303 | sc->sc_open = 0; | | 303 | sc->sc_open = 0; |
304 | sc->sc_refcnt = 0; | | 304 | sc->sc_refcnt = 0; |
305 | sc->sc_opencnt = 0; | | 305 | sc->sc_opencnt = 0; |
306 | sc->sc_dying = false; | | 306 | sc->sc_dying = false; |
307 | | | 307 | |
308 | video_stream_init(&sc->sc_stream_in); | | 308 | video_stream_init(&sc->sc_stream_in); |
309 | | | 309 | |
310 | aprint_naive("\n"); | | 310 | aprint_naive("\n"); |
311 | aprint_normal(": %s\n", sc->hw_if->get_devname(sc->hw_softc)); | | 311 | aprint_normal(": %s\n", sc->hw_if->get_devname(sc->hw_softc)); |
312 | | | 312 | |
313 | DPRINTF(("video_attach: sc=%p hwif=%p\n", sc, sc->hw_if)); | | 313 | DPRINTF(("video_attach: sc=%p hwif=%p\n", sc, sc->hw_if)); |
| | | 314 | |
| | | 315 | if (!pmf_device_register(self, NULL, NULL)) |
| | | 316 | aprint_error_dev(self, "couldn't establish power handler\n"); |
314 | } | | 317 | } |
315 | | | 318 | |
316 | | | 319 | |
317 | static int | | 320 | static int |
318 | video_activate(device_t self, enum devact act) | | 321 | video_activate(device_t self, enum devact act) |
319 | { | | 322 | { |
320 | struct video_softc *sc; | | 323 | struct video_softc *sc; |
321 | | | 324 | |
322 | sc = device_private(self); | | 325 | sc = device_private(self); |
323 | DPRINTF(("video_activate: sc=%p\n", sc)); | | 326 | DPRINTF(("video_activate: sc=%p\n", sc)); |
324 | switch (act) { | | 327 | switch (act) { |
325 | case DVACT_ACTIVATE: | | 328 | case DVACT_ACTIVATE: |
326 | return EOPNOTSUPP; | | 329 | return EOPNOTSUPP; |
| @@ -333,26 +336,28 @@ video_activate(device_t self, enum devac | | | @@ -333,26 +336,28 @@ video_activate(device_t self, enum devac |
333 | } | | 336 | } |
334 | | | 337 | |
335 | | | 338 | |
336 | static int | | 339 | static int |
337 | video_detach(device_t self, int flags) | | 340 | video_detach(device_t self, int flags) |
338 | { | | 341 | { |
339 | struct video_softc *sc; | | 342 | struct video_softc *sc; |
340 | int maj, mn; | | 343 | int maj, mn; |
341 | | | 344 | |
342 | sc = device_private(self); | | 345 | sc = device_private(self); |
343 | DPRINTF(("video_detach: sc=%p flags=%d\n", sc, flags)); | | 346 | DPRINTF(("video_detach: sc=%p flags=%d\n", sc, flags)); |
344 | | | 347 | |
345 | sc->sc_dying = true; | | 348 | sc->sc_dying = true; |
| | | 349 | |
| | | 350 | pmf_device_deregister(self); |
346 | | | 351 | |
347 | maj = cdevsw_lookup_major(&video_cdevsw); | | 352 | maj = cdevsw_lookup_major(&video_cdevsw); |
348 | mn = device_unit(self); | | 353 | mn = device_unit(self); |
349 | /* close open instances */ | | 354 | /* close open instances */ |
350 | vdevgone(maj, mn, mn, VCHR); | | 355 | vdevgone(maj, mn, mn, VCHR); |
351 | | | 356 | |
352 | video_stream_fini(&sc->sc_stream_in); | | 357 | video_stream_fini(&sc->sc_stream_in); |
353 | | | 358 | |
354 | return 0; | | 359 | return 0; |
355 | } | | 360 | } |
356 | | | 361 | |
357 | | | 362 | |
358 | static int | | 363 | static int |