| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: drm_drv.c,v 1.1.2.28 2014/01/21 20:56:00 riastradh Exp $ */ | | 1 | /* $NetBSD: drm_drv.c,v 1.1.2.29 2014/01/21 20:56:20 riastradh Exp $ */ |
2 | | | 2 | |
3 | /*- | | 3 | /*- |
4 | * Copyright (c) 2013 The NetBSD Foundation, Inc. | | 4 | * Copyright (c) 2013 The NetBSD Foundation, Inc. |
5 | * All rights reserved. | | 5 | * All rights reserved. |
6 | * | | 6 | * |
7 | * This code is derived from software contributed to The NetBSD Foundation | | 7 | * This code is derived from software contributed to The NetBSD Foundation |
8 | * by Taylor R. Campbell. | | 8 | * by Taylor R. Campbell. |
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. |
| @@ -20,49 +20,57 @@ | | | @@ -20,49 +20,57 @@ |
20 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED | | 20 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED |
21 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | | 21 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
22 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS | | 22 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS |
23 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | | 23 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
24 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | | 24 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
25 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | | 25 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
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 | #include <sys/cdefs.h> | | 32 | #include <sys/cdefs.h> |
33 | __KERNEL_RCSID(0, "$NetBSD: drm_drv.c,v 1.1.2.28 2014/01/21 20:56:00 riastradh Exp $"); | | 33 | __KERNEL_RCSID(0, "$NetBSD: drm_drv.c,v 1.1.2.29 2014/01/21 20:56:20 riastradh Exp $"); |
34 | | | 34 | |
35 | #include <sys/param.h> | | 35 | #include <sys/param.h> |
36 | #include <sys/types.h> | | 36 | #include <sys/types.h> |
37 | #include <sys/conf.h> | | 37 | #include <sys/conf.h> |
38 | #include <sys/device.h> | | 38 | #include <sys/device.h> |
39 | #include <sys/file.h> | | 39 | #include <sys/file.h> |
40 | #include <sys/filedesc.h> | | 40 | #include <sys/filedesc.h> |
41 | #include <sys/ioccom.h> | | 41 | #include <sys/ioccom.h> |
42 | #include <sys/kauth.h> | | 42 | #include <sys/kauth.h> |
43 | #include <sys/poll.h> | | 43 | #include <sys/poll.h> |
44 | #include <sys/select.h> | | 44 | #include <sys/select.h> |
45 | | | 45 | |
46 | #include <drm/drmP.h> | | 46 | #include <drm/drmP.h> |
47 | | | 47 | |
48 | static int drm_minor_types[] = { | | 48 | static int drm_minor_types[] = { |
49 | DRM_MINOR_LEGACY, | | 49 | DRM_MINOR_LEGACY, |
50 | DRM_MINOR_CONTROL, | | 50 | DRM_MINOR_CONTROL, |
51 | #if 0 /* XXX Nothing seems to use this? */ | | 51 | #if 0 /* XXX Nothing seems to use this? */ |
52 | DRM_MINOR_RENDER, | | 52 | DRM_MINOR_RENDER, |
53 | #endif | | 53 | #endif |
54 | }; | | 54 | }; |
55 | | | 55 | |
| | | 56 | static int drm_type_minors[] = { |
| | | 57 | [DRM_MINOR_LEGACY] = 0, |
| | | 58 | [DRM_MINOR_CONTROL] = 1, |
| | | 59 | #if 0 |
| | | 60 | [DRM_MINOR_RENDER] = 2, |
| | | 61 | #endif |
| | | 62 | }; |
| | | 63 | |
56 | struct drm_softc { | | 64 | struct drm_softc { |
57 | struct drm_device *sc_drm_dev; | | 65 | struct drm_device *sc_drm_dev; |
58 | struct drm_minor sc_minor[__arraycount(drm_minor_types)]; | | 66 | struct drm_minor sc_minor[__arraycount(drm_minor_types)]; |
59 | unsigned int sc_opencount; | | 67 | unsigned int sc_opencount; |
60 | bool sc_initialized; | | 68 | bool sc_initialized; |
61 | }; | | 69 | }; |
62 | | | 70 | |
63 | struct drm_attach_args { | | 71 | struct drm_attach_args { |
64 | struct drm_device *daa_drm_dev; | | 72 | struct drm_device *daa_drm_dev; |
65 | struct drm_driver *daa_driver; | | 73 | struct drm_driver *daa_driver; |
66 | unsigned long daa_flags; | | 74 | unsigned long daa_flags; |
67 | }; | | 75 | }; |
68 | | | 76 | |
| @@ -287,28 +295,29 @@ drm_attach(device_t parent, device_t sel | | | @@ -287,28 +295,29 @@ drm_attach(device_t parent, device_t sel |
287 | makedev(cdevsw_lookup_major(&drm_cdevsw), | | 295 | makedev(cdevsw_lookup_major(&drm_cdevsw), |
288 | sc->sc_minor[i].index); | | 296 | sc->sc_minor[i].index); |
289 | sc->sc_minor[i].kdev = self; | | 297 | sc->sc_minor[i].kdev = self; |
290 | sc->sc_minor[i].dev = dev; | | 298 | sc->sc_minor[i].dev = dev; |
291 | sc->sc_minor[i].master = NULL; | | 299 | sc->sc_minor[i].master = NULL; |
292 | INIT_LIST_HEAD(&sc->sc_minor[i].master_list); | | 300 | INIT_LIST_HEAD(&sc->sc_minor[i].master_list); |
293 | (void)memset(&sc->sc_minor[i].mode_group, 0, | | 301 | (void)memset(&sc->sc_minor[i].mode_group, 0, |
294 | sizeof(sc->sc_minor[i].mode_group)); | | 302 | sizeof(sc->sc_minor[i].mode_group)); |
295 | } | | 303 | } |
296 | | | 304 | |
297 | dev->dev = self; | | 305 | dev->dev = self; |
298 | | | 306 | |
299 | if (drm_core_check_feature(dev, DRIVER_MODESET)) | | 307 | if (drm_core_check_feature(dev, DRIVER_MODESET)) |
300 | dev->control = &sc->sc_minor[DRM_MINOR_CONTROL]; | | 308 | dev->control = |
301 | dev->primary = &sc->sc_minor[DRM_MINOR_LEGACY]; | | 309 | &sc->sc_minor[drm_type_minors[DRM_MINOR_CONTROL]]; |
| | | 310 | dev->primary = &sc->sc_minor[drm_type_minors[DRM_MINOR_LEGACY]]; |
302 | | | 311 | |
303 | error = drm_fill_in_dev(dev, NULL, daa->daa_driver); | | 312 | error = drm_fill_in_dev(dev, NULL, daa->daa_driver); |
304 | if (error) { | | 313 | if (error) { |
305 | aprint_error_dev(parent, "unable to initialize drm: %d\n", | | 314 | aprint_error_dev(parent, "unable to initialize drm: %d\n", |
306 | error); | | 315 | error); |
307 | goto fail0; | | 316 | goto fail0; |
308 | } | | 317 | } |
309 | KASSERT(dev->driver == daa->daa_driver); | | 318 | KASSERT(dev->driver == daa->daa_driver); |
310 | | | 319 | |
311 | if (dev->driver->load != NULL) { | | 320 | if (dev->driver->load != NULL) { |
312 | error = (*dev->driver->load)(dev, daa->daa_flags); | | 321 | error = (*dev->driver->load)(dev, daa->daa_flags); |
313 | if (error) { | | 322 | if (error) { |
314 | aprint_error_dev(parent, "unable to load driver: %d\n", | | 323 | aprint_error_dev(parent, "unable to load driver: %d\n", |