| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: drmfb.c,v 1.13 2022/02/16 23:30:10 riastradh Exp $ */ | | 1 | /* $NetBSD: drmfb.c,v 1.14 2022/02/18 18:31:18 wiz Exp $ */ |
2 | | | 2 | |
3 | /*- | | 3 | /*- |
4 | * Copyright (c) 2014 The NetBSD Foundation, Inc. | | 4 | * Copyright (c) 2014 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. |
| @@ -29,27 +29,27 @@ | | | @@ -29,27 +29,27 @@ |
29 | * POSSIBILITY OF SUCH DAMAGE. | | 29 | * POSSIBILITY OF SUCH DAMAGE. |
30 | */ | | 30 | */ |
31 | | | 31 | |
32 | /* | | 32 | /* |
33 | * drmfb: wsdisplay support, via genfb, for any drm device. Use this | | 33 | * drmfb: wsdisplay support, via genfb, for any drm device. Use this |
34 | * if you're too lazy to write a hardware-accelerated framebuffer using | | 34 | * if you're too lazy to write a hardware-accelerated framebuffer using |
35 | * wsdisplay directly. | | 35 | * wsdisplay directly. |
36 | * | | 36 | * |
37 | * This doesn't actually do anything interesting -- just hooks up | | 37 | * This doesn't actually do anything interesting -- just hooks up |
38 | * drmkms crap and genfb crap. | | 38 | * drmkms crap and genfb crap. |
39 | */ | | 39 | */ |
40 | | | 40 | |
41 | #include <sys/cdefs.h> | | 41 | #include <sys/cdefs.h> |
42 | __KERNEL_RCSID(0, "$NetBSD: drmfb.c,v 1.13 2022/02/16 23:30:10 riastradh Exp $"); | | 42 | __KERNEL_RCSID(0, "$NetBSD: drmfb.c,v 1.14 2022/02/18 18:31:18 wiz Exp $"); |
43 | | | 43 | |
44 | #ifdef _KERNEL_OPT | | 44 | #ifdef _KERNEL_OPT |
45 | #include "vga.h" | | 45 | #include "vga.h" |
46 | #endif | | 46 | #endif |
47 | | | 47 | |
48 | #include <sys/types.h> | | 48 | #include <sys/types.h> |
49 | #include <sys/param.h> | | 49 | #include <sys/param.h> |
50 | #include <sys/bus.h> | | 50 | #include <sys/bus.h> |
51 | #include <sys/device.h> | | 51 | #include <sys/device.h> |
52 | #include <sys/kauth.h> | | 52 | #include <sys/kauth.h> |
53 | | | 53 | |
54 | #if NVGA > 0 | | 54 | #if NVGA > 0 |
55 | /* | | 55 | /* |
| @@ -83,51 +83,48 @@ static const struct genfb_mode_callback | | | @@ -83,51 +83,48 @@ static const struct genfb_mode_callback |
83 | int | | 83 | int |
84 | drmfb_attach(struct drmfb_softc *sc, const struct drmfb_attach_args *da) | | 84 | drmfb_attach(struct drmfb_softc *sc, const struct drmfb_attach_args *da) |
85 | { | | 85 | { |
86 | const struct drm_fb_helper_surface_size *const sizes = da->da_fb_sizes; | | 86 | const struct drm_fb_helper_surface_size *const sizes = da->da_fb_sizes; |
87 | struct drm_connector_list_iter conn_iter; | | 87 | struct drm_connector_list_iter conn_iter; |
88 | struct drm_connector *connector; | | 88 | struct drm_connector *connector; |
89 | const prop_dictionary_t dict = device_properties(da->da_dev); | | 89 | const prop_dictionary_t dict = device_properties(da->da_dev); |
90 | #if NVGA > 0 | | 90 | #if NVGA > 0 |
91 | struct drm_device *const dev = da->da_fb_helper->dev; | | 91 | struct drm_device *const dev = da->da_fb_helper->dev; |
92 | #endif | | 92 | #endif |
93 | static const struct genfb_ops zero_genfb_ops; | | 93 | static const struct genfb_ops zero_genfb_ops; |
94 | struct genfb_ops genfb_ops = zero_genfb_ops; | | 94 | struct genfb_ops genfb_ops = zero_genfb_ops; |
95 | enum { CONS_VGA, CONS_GENFB, CONS_NONE } what_was_cons; | | 95 | enum { CONS_VGA, CONS_GENFB, CONS_NONE } what_was_cons; |
96 | device_t parent = device_parent(da->da_dev); | | | |
97 | bool is_console; | | 96 | bool is_console; |
98 | int error; | | 97 | int error; |
99 | | | 98 | |
100 | /* genfb requires this. */ | | 99 | /* genfb requires this. */ |
101 | KASSERTMSG((void *)&sc->sc_genfb == device_private(da->da_dev), | | 100 | KASSERTMSG((void *)&sc->sc_genfb == device_private(da->da_dev), |
102 | "drmfb_softc must be first member of device softc"); | | 101 | "drmfb_softc must be first member of device softc"); |
103 | | | 102 | |
104 | sc->sc_da = *da; | | 103 | sc->sc_da = *da; |
105 | | | 104 | |
106 | prop_dictionary_set_uint32(dict, "width", sizes->surface_width); | | 105 | prop_dictionary_set_uint32(dict, "width", sizes->surface_width); |
107 | prop_dictionary_set_uint32(dict, "height", sizes->surface_height); | | 106 | prop_dictionary_set_uint32(dict, "height", sizes->surface_height); |
108 | prop_dictionary_set_uint8(dict, "depth", sizes->surface_bpp); | | 107 | prop_dictionary_set_uint8(dict, "depth", sizes->surface_bpp); |
109 | prop_dictionary_set_uint16(dict, "linebytes", da->da_fb_linebytes); | | 108 | prop_dictionary_set_uint16(dict, "linebytes", da->da_fb_linebytes); |
110 | prop_dictionary_set_uint32(dict, "address", 0); /* XXX >32-bit */ | | 109 | prop_dictionary_set_uint32(dict, "address", 0); /* XXX >32-bit */ |
111 | CTASSERT(sizeof(uintptr_t) <= sizeof(uint64_t)); | | 110 | CTASSERT(sizeof(uintptr_t) <= sizeof(uint64_t)); |
112 | prop_dictionary_set_uint64(dict, "virtual_address", | | 111 | prop_dictionary_set_uint64(dict, "virtual_address", |
113 | (uint64_t)(uintptr_t)da->da_fb_vaddr); | | 112 | (uint64_t)(uintptr_t)da->da_fb_vaddr); |
114 | | | 113 | |
115 | prop_dictionary_set_uint64(dict, "mode_callback", | | 114 | prop_dictionary_set_uint64(dict, "mode_callback", |
116 | (uint64_t)(uintptr_t)&drmfb_genfb_mode_callback); | | 115 | (uint64_t)(uintptr_t)&drmfb_genfb_mode_callback); |
117 | | | 116 | |
118 | if (!prop_dictionary_get_bool(dict, "is_console", &is_console) && | | 117 | if (!prop_dictionary_get_bool(dict, "is_console", &is_console)) { |
119 | !prop_dictionary_get_bool(device_properties(parent), "is_console", | | | |
120 | &is_console)) { | | | |
121 | /* XXX Whattakludge! */ | | 118 | /* XXX Whattakludge! */ |
122 | #if NVGA > 0 | | 119 | #if NVGA > 0 |
123 | if ((da->da_params->dp_is_vga_console != NULL) && | | 120 | if ((da->da_params->dp_is_vga_console != NULL) && |
124 | (*da->da_params->dp_is_vga_console)(dev)) { | | 121 | (*da->da_params->dp_is_vga_console)(dev)) { |
125 | what_was_cons = CONS_VGA; | | 122 | what_was_cons = CONS_VGA; |
126 | prop_dictionary_set_bool(dict, "is_console", true); | | 123 | prop_dictionary_set_bool(dict, "is_console", true); |
127 | vga_cndetach(); | | 124 | vga_cndetach(); |
128 | if (da->da_params->dp_disable_vga) | | 125 | if (da->da_params->dp_disable_vga) |
129 | (*da->da_params->dp_disable_vga)(dev); | | 126 | (*da->da_params->dp_disable_vga)(dev); |
130 | } else | | 127 | } else |
131 | #endif | | 128 | #endif |
132 | if (genfb_is_console() && genfb_is_enabled()) { | | 129 | if (genfb_is_console() && genfb_is_enabled()) { |
133 | what_was_cons = CONS_GENFB; | | 130 | what_was_cons = CONS_GENFB; |