Commit e63fea163319d9784abc0c82aeaef451cc80116e
Committed by
Greg Kroah-Hartman
1 parent
f1d5aa4663
drm: fix fb-helper vs MST dangling connector ptrs (v2)
commit 2148f18fdb45f31ca269a7787fbc24053cd42e70 upstream. VT switch back/forth from console to xserver (for example) has potential to go horribly wrong if a dynamic DP MST connector ends up in the saved modeset that is restored when switching back to fbcon. When removing a dynamic connector, don't forget to clean up the saved state. v1: original v2: null out set->fb if no more connectors to avoid making i915 cranky Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1184968 Signed-off-by: Rob Clark <robdclark@gmail.com> Signed-off-by: Dave Airlie <airlied@redhat.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Showing 1 changed file with 30 additions and 0 deletions Inline Diff
drivers/gpu/drm/drm_fb_helper.c
1 | /* | 1 | /* |
2 | * Copyright (c) 2006-2009 Red Hat Inc. | 2 | * Copyright (c) 2006-2009 Red Hat Inc. |
3 | * Copyright (c) 2006-2008 Intel Corporation | 3 | * Copyright (c) 2006-2008 Intel Corporation |
4 | * Copyright (c) 2007 Dave Airlie <airlied@linux.ie> | 4 | * Copyright (c) 2007 Dave Airlie <airlied@linux.ie> |
5 | * | 5 | * |
6 | * DRM framebuffer helper functions | 6 | * DRM framebuffer helper functions |
7 | * | 7 | * |
8 | * Permission to use, copy, modify, distribute, and sell this software and its | 8 | * Permission to use, copy, modify, distribute, and sell this software and its |
9 | * documentation for any purpose is hereby granted without fee, provided that | 9 | * documentation for any purpose is hereby granted without fee, provided that |
10 | * the above copyright notice appear in all copies and that both that copyright | 10 | * the above copyright notice appear in all copies and that both that copyright |
11 | * notice and this permission notice appear in supporting documentation, and | 11 | * notice and this permission notice appear in supporting documentation, and |
12 | * that the name of the copyright holders not be used in advertising or | 12 | * that the name of the copyright holders not be used in advertising or |
13 | * publicity pertaining to distribution of the software without specific, | 13 | * publicity pertaining to distribution of the software without specific, |
14 | * written prior permission. The copyright holders make no representations | 14 | * written prior permission. The copyright holders make no representations |
15 | * about the suitability of this software for any purpose. It is provided "as | 15 | * about the suitability of this software for any purpose. It is provided "as |
16 | * is" without express or implied warranty. | 16 | * is" without express or implied warranty. |
17 | * | 17 | * |
18 | * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, | 18 | * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, |
19 | * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO | 19 | * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO |
20 | * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR | 20 | * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR |
21 | * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, | 21 | * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, |
22 | * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER | 22 | * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER |
23 | * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE | 23 | * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE |
24 | * OF THIS SOFTWARE. | 24 | * OF THIS SOFTWARE. |
25 | * | 25 | * |
26 | * Authors: | 26 | * Authors: |
27 | * Dave Airlie <airlied@linux.ie> | 27 | * Dave Airlie <airlied@linux.ie> |
28 | * Jesse Barnes <jesse.barnes@intel.com> | 28 | * Jesse Barnes <jesse.barnes@intel.com> |
29 | */ | 29 | */ |
30 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt | 30 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt |
31 | 31 | ||
32 | #include <linux/kernel.h> | 32 | #include <linux/kernel.h> |
33 | #include <linux/sysrq.h> | 33 | #include <linux/sysrq.h> |
34 | #include <linux/slab.h> | 34 | #include <linux/slab.h> |
35 | #include <linux/fb.h> | 35 | #include <linux/fb.h> |
36 | #include <linux/module.h> | 36 | #include <linux/module.h> |
37 | #include <drm/drmP.h> | 37 | #include <drm/drmP.h> |
38 | #include <drm/drm_crtc.h> | 38 | #include <drm/drm_crtc.h> |
39 | #include <drm/drm_fb_helper.h> | 39 | #include <drm/drm_fb_helper.h> |
40 | #include <drm/drm_crtc_helper.h> | 40 | #include <drm/drm_crtc_helper.h> |
41 | 41 | ||
42 | static LIST_HEAD(kernel_fb_helper_list); | 42 | static LIST_HEAD(kernel_fb_helper_list); |
43 | 43 | ||
44 | /** | 44 | /** |
45 | * DOC: fbdev helpers | 45 | * DOC: fbdev helpers |
46 | * | 46 | * |
47 | * The fb helper functions are useful to provide an fbdev on top of a drm kernel | 47 | * The fb helper functions are useful to provide an fbdev on top of a drm kernel |
48 | * mode setting driver. They can be used mostly independently from the crtc | 48 | * mode setting driver. They can be used mostly independently from the crtc |
49 | * helper functions used by many drivers to implement the kernel mode setting | 49 | * helper functions used by many drivers to implement the kernel mode setting |
50 | * interfaces. | 50 | * interfaces. |
51 | * | 51 | * |
52 | * Initialization is done as a four-step process with drm_fb_helper_prepare(), | 52 | * Initialization is done as a four-step process with drm_fb_helper_prepare(), |
53 | * drm_fb_helper_init(), drm_fb_helper_single_add_all_connectors() and | 53 | * drm_fb_helper_init(), drm_fb_helper_single_add_all_connectors() and |
54 | * drm_fb_helper_initial_config(). Drivers with fancier requirements than the | 54 | * drm_fb_helper_initial_config(). Drivers with fancier requirements than the |
55 | * default behaviour can override the third step with their own code. | 55 | * default behaviour can override the third step with their own code. |
56 | * Teardown is done with drm_fb_helper_fini(). | 56 | * Teardown is done with drm_fb_helper_fini(). |
57 | * | 57 | * |
58 | * At runtime drivers should restore the fbdev console by calling | 58 | * At runtime drivers should restore the fbdev console by calling |
59 | * drm_fb_helper_restore_fbdev_mode() from their ->lastclose callback. They | 59 | * drm_fb_helper_restore_fbdev_mode() from their ->lastclose callback. They |
60 | * should also notify the fb helper code from updates to the output | 60 | * should also notify the fb helper code from updates to the output |
61 | * configuration by calling drm_fb_helper_hotplug_event(). For easier | 61 | * configuration by calling drm_fb_helper_hotplug_event(). For easier |
62 | * integration with the output polling code in drm_crtc_helper.c the modeset | 62 | * integration with the output polling code in drm_crtc_helper.c the modeset |
63 | * code provides a ->output_poll_changed callback. | 63 | * code provides a ->output_poll_changed callback. |
64 | * | 64 | * |
65 | * All other functions exported by the fb helper library can be used to | 65 | * All other functions exported by the fb helper library can be used to |
66 | * implement the fbdev driver interface by the driver. | 66 | * implement the fbdev driver interface by the driver. |
67 | * | 67 | * |
68 | * It is possible, though perhaps somewhat tricky, to implement race-free | 68 | * It is possible, though perhaps somewhat tricky, to implement race-free |
69 | * hotplug detection using the fbdev helpers. The drm_fb_helper_prepare() | 69 | * hotplug detection using the fbdev helpers. The drm_fb_helper_prepare() |
70 | * helper must be called first to initialize the minimum required to make | 70 | * helper must be called first to initialize the minimum required to make |
71 | * hotplug detection work. Drivers also need to make sure to properly set up | 71 | * hotplug detection work. Drivers also need to make sure to properly set up |
72 | * the dev->mode_config.funcs member. After calling drm_kms_helper_poll_init() | 72 | * the dev->mode_config.funcs member. After calling drm_kms_helper_poll_init() |
73 | * it is safe to enable interrupts and start processing hotplug events. At the | 73 | * it is safe to enable interrupts and start processing hotplug events. At the |
74 | * same time, drivers should initialize all modeset objects such as CRTCs, | 74 | * same time, drivers should initialize all modeset objects such as CRTCs, |
75 | * encoders and connectors. To finish up the fbdev helper initialization, the | 75 | * encoders and connectors. To finish up the fbdev helper initialization, the |
76 | * drm_fb_helper_init() function is called. To probe for all attached displays | 76 | * drm_fb_helper_init() function is called. To probe for all attached displays |
77 | * and set up an initial configuration using the detected hardware, drivers | 77 | * and set up an initial configuration using the detected hardware, drivers |
78 | * should call drm_fb_helper_single_add_all_connectors() followed by | 78 | * should call drm_fb_helper_single_add_all_connectors() followed by |
79 | * drm_fb_helper_initial_config(). | 79 | * drm_fb_helper_initial_config(). |
80 | */ | 80 | */ |
81 | 81 | ||
82 | /** | 82 | /** |
83 | * drm_fb_helper_single_add_all_connectors() - add all connectors to fbdev | 83 | * drm_fb_helper_single_add_all_connectors() - add all connectors to fbdev |
84 | * emulation helper | 84 | * emulation helper |
85 | * @fb_helper: fbdev initialized with drm_fb_helper_init | 85 | * @fb_helper: fbdev initialized with drm_fb_helper_init |
86 | * | 86 | * |
87 | * This functions adds all the available connectors for use with the given | 87 | * This functions adds all the available connectors for use with the given |
88 | * fb_helper. This is a separate step to allow drivers to freely assign | 88 | * fb_helper. This is a separate step to allow drivers to freely assign |
89 | * connectors to the fbdev, e.g. if some are reserved for special purposes or | 89 | * connectors to the fbdev, e.g. if some are reserved for special purposes or |
90 | * not adequate to be used for the fbcon. | 90 | * not adequate to be used for the fbcon. |
91 | * | 91 | * |
92 | * Since this is part of the initial setup before the fbdev is published, no | 92 | * Since this is part of the initial setup before the fbdev is published, no |
93 | * locking is required. | 93 | * locking is required. |
94 | */ | 94 | */ |
95 | int drm_fb_helper_single_add_all_connectors(struct drm_fb_helper *fb_helper) | 95 | int drm_fb_helper_single_add_all_connectors(struct drm_fb_helper *fb_helper) |
96 | { | 96 | { |
97 | struct drm_device *dev = fb_helper->dev; | 97 | struct drm_device *dev = fb_helper->dev; |
98 | struct drm_connector *connector; | 98 | struct drm_connector *connector; |
99 | int i; | 99 | int i; |
100 | 100 | ||
101 | list_for_each_entry(connector, &dev->mode_config.connector_list, head) { | 101 | list_for_each_entry(connector, &dev->mode_config.connector_list, head) { |
102 | struct drm_fb_helper_connector *fb_helper_connector; | 102 | struct drm_fb_helper_connector *fb_helper_connector; |
103 | 103 | ||
104 | fb_helper_connector = kzalloc(sizeof(struct drm_fb_helper_connector), GFP_KERNEL); | 104 | fb_helper_connector = kzalloc(sizeof(struct drm_fb_helper_connector), GFP_KERNEL); |
105 | if (!fb_helper_connector) | 105 | if (!fb_helper_connector) |
106 | goto fail; | 106 | goto fail; |
107 | 107 | ||
108 | fb_helper_connector->connector = connector; | 108 | fb_helper_connector->connector = connector; |
109 | fb_helper->connector_info[fb_helper->connector_count++] = fb_helper_connector; | 109 | fb_helper->connector_info[fb_helper->connector_count++] = fb_helper_connector; |
110 | } | 110 | } |
111 | return 0; | 111 | return 0; |
112 | fail: | 112 | fail: |
113 | for (i = 0; i < fb_helper->connector_count; i++) { | 113 | for (i = 0; i < fb_helper->connector_count; i++) { |
114 | kfree(fb_helper->connector_info[i]); | 114 | kfree(fb_helper->connector_info[i]); |
115 | fb_helper->connector_info[i] = NULL; | 115 | fb_helper->connector_info[i] = NULL; |
116 | } | 116 | } |
117 | fb_helper->connector_count = 0; | 117 | fb_helper->connector_count = 0; |
118 | return -ENOMEM; | 118 | return -ENOMEM; |
119 | } | 119 | } |
120 | EXPORT_SYMBOL(drm_fb_helper_single_add_all_connectors); | 120 | EXPORT_SYMBOL(drm_fb_helper_single_add_all_connectors); |
121 | 121 | ||
122 | int drm_fb_helper_add_one_connector(struct drm_fb_helper *fb_helper, struct drm_connector *connector) | 122 | int drm_fb_helper_add_one_connector(struct drm_fb_helper *fb_helper, struct drm_connector *connector) |
123 | { | 123 | { |
124 | struct drm_fb_helper_connector **temp; | 124 | struct drm_fb_helper_connector **temp; |
125 | struct drm_fb_helper_connector *fb_helper_connector; | 125 | struct drm_fb_helper_connector *fb_helper_connector; |
126 | 126 | ||
127 | WARN_ON(!mutex_is_locked(&fb_helper->dev->mode_config.mutex)); | 127 | WARN_ON(!mutex_is_locked(&fb_helper->dev->mode_config.mutex)); |
128 | if (fb_helper->connector_count + 1 > fb_helper->connector_info_alloc_count) { | 128 | if (fb_helper->connector_count + 1 > fb_helper->connector_info_alloc_count) { |
129 | temp = krealloc(fb_helper->connector_info, sizeof(struct drm_fb_helper_connector *) * (fb_helper->connector_count + 1), GFP_KERNEL); | 129 | temp = krealloc(fb_helper->connector_info, sizeof(struct drm_fb_helper_connector *) * (fb_helper->connector_count + 1), GFP_KERNEL); |
130 | if (!temp) | 130 | if (!temp) |
131 | return -ENOMEM; | 131 | return -ENOMEM; |
132 | 132 | ||
133 | fb_helper->connector_info_alloc_count = fb_helper->connector_count + 1; | 133 | fb_helper->connector_info_alloc_count = fb_helper->connector_count + 1; |
134 | fb_helper->connector_info = temp; | 134 | fb_helper->connector_info = temp; |
135 | } | 135 | } |
136 | 136 | ||
137 | 137 | ||
138 | fb_helper_connector = kzalloc(sizeof(struct drm_fb_helper_connector), GFP_KERNEL); | 138 | fb_helper_connector = kzalloc(sizeof(struct drm_fb_helper_connector), GFP_KERNEL); |
139 | if (!fb_helper_connector) | 139 | if (!fb_helper_connector) |
140 | return -ENOMEM; | 140 | return -ENOMEM; |
141 | 141 | ||
142 | fb_helper_connector->connector = connector; | 142 | fb_helper_connector->connector = connector; |
143 | fb_helper->connector_info[fb_helper->connector_count++] = fb_helper_connector; | 143 | fb_helper->connector_info[fb_helper->connector_count++] = fb_helper_connector; |
144 | return 0; | 144 | return 0; |
145 | } | 145 | } |
146 | EXPORT_SYMBOL(drm_fb_helper_add_one_connector); | 146 | EXPORT_SYMBOL(drm_fb_helper_add_one_connector); |
147 | 147 | ||
148 | static void remove_from_modeset(struct drm_mode_set *set, | ||
149 | struct drm_connector *connector) | ||
150 | { | ||
151 | int i, j; | ||
152 | |||
153 | for (i = 0; i < set->num_connectors; i++) { | ||
154 | if (set->connectors[i] == connector) | ||
155 | break; | ||
156 | } | ||
157 | |||
158 | if (i == set->num_connectors) | ||
159 | return; | ||
160 | |||
161 | for (j = i + 1; j < set->num_connectors; j++) { | ||
162 | set->connectors[j - 1] = set->connectors[j]; | ||
163 | } | ||
164 | set->num_connectors--; | ||
165 | |||
166 | /* because i915 is pissy about this.. | ||
167 | * TODO maybe need to makes sure we set it back to !=NULL somewhere? | ||
168 | */ | ||
169 | if (set->num_connectors == 0) | ||
170 | set->fb = NULL; | ||
171 | } | ||
172 | |||
148 | int drm_fb_helper_remove_one_connector(struct drm_fb_helper *fb_helper, | 173 | int drm_fb_helper_remove_one_connector(struct drm_fb_helper *fb_helper, |
149 | struct drm_connector *connector) | 174 | struct drm_connector *connector) |
150 | { | 175 | { |
151 | struct drm_fb_helper_connector *fb_helper_connector; | 176 | struct drm_fb_helper_connector *fb_helper_connector; |
152 | int i, j; | 177 | int i, j; |
153 | 178 | ||
154 | WARN_ON(!mutex_is_locked(&fb_helper->dev->mode_config.mutex)); | 179 | WARN_ON(!mutex_is_locked(&fb_helper->dev->mode_config.mutex)); |
155 | 180 | ||
156 | for (i = 0; i < fb_helper->connector_count; i++) { | 181 | for (i = 0; i < fb_helper->connector_count; i++) { |
157 | if (fb_helper->connector_info[i]->connector == connector) | 182 | if (fb_helper->connector_info[i]->connector == connector) |
158 | break; | 183 | break; |
159 | } | 184 | } |
160 | 185 | ||
161 | if (i == fb_helper->connector_count) | 186 | if (i == fb_helper->connector_count) |
162 | return -EINVAL; | 187 | return -EINVAL; |
163 | fb_helper_connector = fb_helper->connector_info[i]; | 188 | fb_helper_connector = fb_helper->connector_info[i]; |
164 | 189 | ||
165 | for (j = i + 1; j < fb_helper->connector_count; j++) { | 190 | for (j = i + 1; j < fb_helper->connector_count; j++) { |
166 | fb_helper->connector_info[j - 1] = fb_helper->connector_info[j]; | 191 | fb_helper->connector_info[j - 1] = fb_helper->connector_info[j]; |
167 | } | 192 | } |
168 | fb_helper->connector_count--; | 193 | fb_helper->connector_count--; |
169 | kfree(fb_helper_connector); | 194 | kfree(fb_helper_connector); |
195 | |||
196 | /* also cleanup dangling references to the connector: */ | ||
197 | for (i = 0; i < fb_helper->crtc_count; i++) | ||
198 | remove_from_modeset(&fb_helper->crtc_info[i].mode_set, connector); | ||
199 | |||
170 | return 0; | 200 | return 0; |
171 | } | 201 | } |
172 | EXPORT_SYMBOL(drm_fb_helper_remove_one_connector); | 202 | EXPORT_SYMBOL(drm_fb_helper_remove_one_connector); |
173 | 203 | ||
174 | static void drm_fb_helper_save_lut_atomic(struct drm_crtc *crtc, struct drm_fb_helper *helper) | 204 | static void drm_fb_helper_save_lut_atomic(struct drm_crtc *crtc, struct drm_fb_helper *helper) |
175 | { | 205 | { |
176 | uint16_t *r_base, *g_base, *b_base; | 206 | uint16_t *r_base, *g_base, *b_base; |
177 | int i; | 207 | int i; |
178 | 208 | ||
179 | if (helper->funcs->gamma_get == NULL) | 209 | if (helper->funcs->gamma_get == NULL) |
180 | return; | 210 | return; |
181 | 211 | ||
182 | r_base = crtc->gamma_store; | 212 | r_base = crtc->gamma_store; |
183 | g_base = r_base + crtc->gamma_size; | 213 | g_base = r_base + crtc->gamma_size; |
184 | b_base = g_base + crtc->gamma_size; | 214 | b_base = g_base + crtc->gamma_size; |
185 | 215 | ||
186 | for (i = 0; i < crtc->gamma_size; i++) | 216 | for (i = 0; i < crtc->gamma_size; i++) |
187 | helper->funcs->gamma_get(crtc, &r_base[i], &g_base[i], &b_base[i], i); | 217 | helper->funcs->gamma_get(crtc, &r_base[i], &g_base[i], &b_base[i], i); |
188 | } | 218 | } |
189 | 219 | ||
190 | static void drm_fb_helper_restore_lut_atomic(struct drm_crtc *crtc) | 220 | static void drm_fb_helper_restore_lut_atomic(struct drm_crtc *crtc) |
191 | { | 221 | { |
192 | uint16_t *r_base, *g_base, *b_base; | 222 | uint16_t *r_base, *g_base, *b_base; |
193 | 223 | ||
194 | if (crtc->funcs->gamma_set == NULL) | 224 | if (crtc->funcs->gamma_set == NULL) |
195 | return; | 225 | return; |
196 | 226 | ||
197 | r_base = crtc->gamma_store; | 227 | r_base = crtc->gamma_store; |
198 | g_base = r_base + crtc->gamma_size; | 228 | g_base = r_base + crtc->gamma_size; |
199 | b_base = g_base + crtc->gamma_size; | 229 | b_base = g_base + crtc->gamma_size; |
200 | 230 | ||
201 | crtc->funcs->gamma_set(crtc, r_base, g_base, b_base, 0, crtc->gamma_size); | 231 | crtc->funcs->gamma_set(crtc, r_base, g_base, b_base, 0, crtc->gamma_size); |
202 | } | 232 | } |
203 | 233 | ||
204 | /** | 234 | /** |
205 | * drm_fb_helper_debug_enter - implementation for ->fb_debug_enter | 235 | * drm_fb_helper_debug_enter - implementation for ->fb_debug_enter |
206 | * @info: fbdev registered by the helper | 236 | * @info: fbdev registered by the helper |
207 | */ | 237 | */ |
208 | int drm_fb_helper_debug_enter(struct fb_info *info) | 238 | int drm_fb_helper_debug_enter(struct fb_info *info) |
209 | { | 239 | { |
210 | struct drm_fb_helper *helper = info->par; | 240 | struct drm_fb_helper *helper = info->par; |
211 | struct drm_crtc_helper_funcs *funcs; | 241 | struct drm_crtc_helper_funcs *funcs; |
212 | int i; | 242 | int i; |
213 | 243 | ||
214 | list_for_each_entry(helper, &kernel_fb_helper_list, kernel_fb_list) { | 244 | list_for_each_entry(helper, &kernel_fb_helper_list, kernel_fb_list) { |
215 | for (i = 0; i < helper->crtc_count; i++) { | 245 | for (i = 0; i < helper->crtc_count; i++) { |
216 | struct drm_mode_set *mode_set = | 246 | struct drm_mode_set *mode_set = |
217 | &helper->crtc_info[i].mode_set; | 247 | &helper->crtc_info[i].mode_set; |
218 | 248 | ||
219 | if (!mode_set->crtc->enabled) | 249 | if (!mode_set->crtc->enabled) |
220 | continue; | 250 | continue; |
221 | 251 | ||
222 | funcs = mode_set->crtc->helper_private; | 252 | funcs = mode_set->crtc->helper_private; |
223 | drm_fb_helper_save_lut_atomic(mode_set->crtc, helper); | 253 | drm_fb_helper_save_lut_atomic(mode_set->crtc, helper); |
224 | funcs->mode_set_base_atomic(mode_set->crtc, | 254 | funcs->mode_set_base_atomic(mode_set->crtc, |
225 | mode_set->fb, | 255 | mode_set->fb, |
226 | mode_set->x, | 256 | mode_set->x, |
227 | mode_set->y, | 257 | mode_set->y, |
228 | ENTER_ATOMIC_MODE_SET); | 258 | ENTER_ATOMIC_MODE_SET); |
229 | } | 259 | } |
230 | } | 260 | } |
231 | 261 | ||
232 | return 0; | 262 | return 0; |
233 | } | 263 | } |
234 | EXPORT_SYMBOL(drm_fb_helper_debug_enter); | 264 | EXPORT_SYMBOL(drm_fb_helper_debug_enter); |
235 | 265 | ||
236 | /* Find the real fb for a given fb helper CRTC */ | 266 | /* Find the real fb for a given fb helper CRTC */ |
237 | static struct drm_framebuffer *drm_mode_config_fb(struct drm_crtc *crtc) | 267 | static struct drm_framebuffer *drm_mode_config_fb(struct drm_crtc *crtc) |
238 | { | 268 | { |
239 | struct drm_device *dev = crtc->dev; | 269 | struct drm_device *dev = crtc->dev; |
240 | struct drm_crtc *c; | 270 | struct drm_crtc *c; |
241 | 271 | ||
242 | list_for_each_entry(c, &dev->mode_config.crtc_list, head) { | 272 | list_for_each_entry(c, &dev->mode_config.crtc_list, head) { |
243 | if (crtc->base.id == c->base.id) | 273 | if (crtc->base.id == c->base.id) |
244 | return c->primary->fb; | 274 | return c->primary->fb; |
245 | } | 275 | } |
246 | 276 | ||
247 | return NULL; | 277 | return NULL; |
248 | } | 278 | } |
249 | 279 | ||
250 | /** | 280 | /** |
251 | * drm_fb_helper_debug_leave - implementation for ->fb_debug_leave | 281 | * drm_fb_helper_debug_leave - implementation for ->fb_debug_leave |
252 | * @info: fbdev registered by the helper | 282 | * @info: fbdev registered by the helper |
253 | */ | 283 | */ |
254 | int drm_fb_helper_debug_leave(struct fb_info *info) | 284 | int drm_fb_helper_debug_leave(struct fb_info *info) |
255 | { | 285 | { |
256 | struct drm_fb_helper *helper = info->par; | 286 | struct drm_fb_helper *helper = info->par; |
257 | struct drm_crtc *crtc; | 287 | struct drm_crtc *crtc; |
258 | struct drm_crtc_helper_funcs *funcs; | 288 | struct drm_crtc_helper_funcs *funcs; |
259 | struct drm_framebuffer *fb; | 289 | struct drm_framebuffer *fb; |
260 | int i; | 290 | int i; |
261 | 291 | ||
262 | for (i = 0; i < helper->crtc_count; i++) { | 292 | for (i = 0; i < helper->crtc_count; i++) { |
263 | struct drm_mode_set *mode_set = &helper->crtc_info[i].mode_set; | 293 | struct drm_mode_set *mode_set = &helper->crtc_info[i].mode_set; |
264 | crtc = mode_set->crtc; | 294 | crtc = mode_set->crtc; |
265 | funcs = crtc->helper_private; | 295 | funcs = crtc->helper_private; |
266 | fb = drm_mode_config_fb(crtc); | 296 | fb = drm_mode_config_fb(crtc); |
267 | 297 | ||
268 | if (!crtc->enabled) | 298 | if (!crtc->enabled) |
269 | continue; | 299 | continue; |
270 | 300 | ||
271 | if (!fb) { | 301 | if (!fb) { |
272 | DRM_ERROR("no fb to restore??\n"); | 302 | DRM_ERROR("no fb to restore??\n"); |
273 | continue; | 303 | continue; |
274 | } | 304 | } |
275 | 305 | ||
276 | drm_fb_helper_restore_lut_atomic(mode_set->crtc); | 306 | drm_fb_helper_restore_lut_atomic(mode_set->crtc); |
277 | funcs->mode_set_base_atomic(mode_set->crtc, fb, crtc->x, | 307 | funcs->mode_set_base_atomic(mode_set->crtc, fb, crtc->x, |
278 | crtc->y, LEAVE_ATOMIC_MODE_SET); | 308 | crtc->y, LEAVE_ATOMIC_MODE_SET); |
279 | } | 309 | } |
280 | 310 | ||
281 | return 0; | 311 | return 0; |
282 | } | 312 | } |
283 | EXPORT_SYMBOL(drm_fb_helper_debug_leave); | 313 | EXPORT_SYMBOL(drm_fb_helper_debug_leave); |
284 | 314 | ||
285 | static bool restore_fbdev_mode(struct drm_fb_helper *fb_helper) | 315 | static bool restore_fbdev_mode(struct drm_fb_helper *fb_helper) |
286 | { | 316 | { |
287 | struct drm_device *dev = fb_helper->dev; | 317 | struct drm_device *dev = fb_helper->dev; |
288 | struct drm_plane *plane; | 318 | struct drm_plane *plane; |
289 | bool error = false; | 319 | bool error = false; |
290 | int i; | 320 | int i; |
291 | 321 | ||
292 | drm_warn_on_modeset_not_all_locked(dev); | 322 | drm_warn_on_modeset_not_all_locked(dev); |
293 | 323 | ||
294 | list_for_each_entry(plane, &dev->mode_config.plane_list, head) { | 324 | list_for_each_entry(plane, &dev->mode_config.plane_list, head) { |
295 | if (plane->type != DRM_PLANE_TYPE_PRIMARY) | 325 | if (plane->type != DRM_PLANE_TYPE_PRIMARY) |
296 | drm_plane_force_disable(plane); | 326 | drm_plane_force_disable(plane); |
297 | 327 | ||
298 | if (dev->mode_config.rotation_property) { | 328 | if (dev->mode_config.rotation_property) { |
299 | drm_mode_plane_set_obj_prop(plane, | 329 | drm_mode_plane_set_obj_prop(plane, |
300 | dev->mode_config.rotation_property, | 330 | dev->mode_config.rotation_property, |
301 | BIT(DRM_ROTATE_0)); | 331 | BIT(DRM_ROTATE_0)); |
302 | } | 332 | } |
303 | } | 333 | } |
304 | 334 | ||
305 | for (i = 0; i < fb_helper->crtc_count; i++) { | 335 | for (i = 0; i < fb_helper->crtc_count; i++) { |
306 | struct drm_mode_set *mode_set = &fb_helper->crtc_info[i].mode_set; | 336 | struct drm_mode_set *mode_set = &fb_helper->crtc_info[i].mode_set; |
307 | struct drm_crtc *crtc = mode_set->crtc; | 337 | struct drm_crtc *crtc = mode_set->crtc; |
308 | int ret; | 338 | int ret; |
309 | 339 | ||
310 | if (crtc->funcs->cursor_set) { | 340 | if (crtc->funcs->cursor_set) { |
311 | ret = crtc->funcs->cursor_set(crtc, NULL, 0, 0, 0); | 341 | ret = crtc->funcs->cursor_set(crtc, NULL, 0, 0, 0); |
312 | if (ret) | 342 | if (ret) |
313 | error = true; | 343 | error = true; |
314 | } | 344 | } |
315 | 345 | ||
316 | ret = drm_mode_set_config_internal(mode_set); | 346 | ret = drm_mode_set_config_internal(mode_set); |
317 | if (ret) | 347 | if (ret) |
318 | error = true; | 348 | error = true; |
319 | } | 349 | } |
320 | return error; | 350 | return error; |
321 | } | 351 | } |
322 | /** | 352 | /** |
323 | * drm_fb_helper_restore_fbdev_mode - restore fbdev configuration | 353 | * drm_fb_helper_restore_fbdev_mode - restore fbdev configuration |
324 | * @fb_helper: fbcon to restore | 354 | * @fb_helper: fbcon to restore |
325 | * | 355 | * |
326 | * This should be called from driver's drm ->lastclose callback | 356 | * This should be called from driver's drm ->lastclose callback |
327 | * when implementing an fbcon on top of kms using this helper. This ensures that | 357 | * when implementing an fbcon on top of kms using this helper. This ensures that |
328 | * the user isn't greeted with a black screen when e.g. X dies. | 358 | * the user isn't greeted with a black screen when e.g. X dies. |
329 | * | 359 | * |
330 | * Use this variant if you need to bypass locking (panic), or already | 360 | * Use this variant if you need to bypass locking (panic), or already |
331 | * hold all modeset locks. Otherwise use drm_fb_helper_restore_fbdev_mode_unlocked() | 361 | * hold all modeset locks. Otherwise use drm_fb_helper_restore_fbdev_mode_unlocked() |
332 | */ | 362 | */ |
333 | static bool drm_fb_helper_restore_fbdev_mode(struct drm_fb_helper *fb_helper) | 363 | static bool drm_fb_helper_restore_fbdev_mode(struct drm_fb_helper *fb_helper) |
334 | { | 364 | { |
335 | return restore_fbdev_mode(fb_helper); | 365 | return restore_fbdev_mode(fb_helper); |
336 | } | 366 | } |
337 | 367 | ||
338 | /** | 368 | /** |
339 | * drm_fb_helper_restore_fbdev_mode_unlocked - restore fbdev configuration | 369 | * drm_fb_helper_restore_fbdev_mode_unlocked - restore fbdev configuration |
340 | * @fb_helper: fbcon to restore | 370 | * @fb_helper: fbcon to restore |
341 | * | 371 | * |
342 | * This should be called from driver's drm ->lastclose callback | 372 | * This should be called from driver's drm ->lastclose callback |
343 | * when implementing an fbcon on top of kms using this helper. This ensures that | 373 | * when implementing an fbcon on top of kms using this helper. This ensures that |
344 | * the user isn't greeted with a black screen when e.g. X dies. | 374 | * the user isn't greeted with a black screen when e.g. X dies. |
345 | */ | 375 | */ |
346 | bool drm_fb_helper_restore_fbdev_mode_unlocked(struct drm_fb_helper *fb_helper) | 376 | bool drm_fb_helper_restore_fbdev_mode_unlocked(struct drm_fb_helper *fb_helper) |
347 | { | 377 | { |
348 | struct drm_device *dev = fb_helper->dev; | 378 | struct drm_device *dev = fb_helper->dev; |
349 | bool ret; | 379 | bool ret; |
350 | bool do_delayed = false; | 380 | bool do_delayed = false; |
351 | 381 | ||
352 | drm_modeset_lock_all(dev); | 382 | drm_modeset_lock_all(dev); |
353 | ret = restore_fbdev_mode(fb_helper); | 383 | ret = restore_fbdev_mode(fb_helper); |
354 | 384 | ||
355 | do_delayed = fb_helper->delayed_hotplug; | 385 | do_delayed = fb_helper->delayed_hotplug; |
356 | if (do_delayed) | 386 | if (do_delayed) |
357 | fb_helper->delayed_hotplug = false; | 387 | fb_helper->delayed_hotplug = false; |
358 | drm_modeset_unlock_all(dev); | 388 | drm_modeset_unlock_all(dev); |
359 | 389 | ||
360 | if (do_delayed) | 390 | if (do_delayed) |
361 | drm_fb_helper_hotplug_event(fb_helper); | 391 | drm_fb_helper_hotplug_event(fb_helper); |
362 | return ret; | 392 | return ret; |
363 | } | 393 | } |
364 | EXPORT_SYMBOL(drm_fb_helper_restore_fbdev_mode_unlocked); | 394 | EXPORT_SYMBOL(drm_fb_helper_restore_fbdev_mode_unlocked); |
365 | 395 | ||
366 | /* | 396 | /* |
367 | * restore fbcon display for all kms driver's using this helper, used for sysrq | 397 | * restore fbcon display for all kms driver's using this helper, used for sysrq |
368 | * and panic handling. | 398 | * and panic handling. |
369 | */ | 399 | */ |
370 | static bool drm_fb_helper_force_kernel_mode(void) | 400 | static bool drm_fb_helper_force_kernel_mode(void) |
371 | { | 401 | { |
372 | bool ret, error = false; | 402 | bool ret, error = false; |
373 | struct drm_fb_helper *helper; | 403 | struct drm_fb_helper *helper; |
374 | 404 | ||
375 | if (list_empty(&kernel_fb_helper_list)) | 405 | if (list_empty(&kernel_fb_helper_list)) |
376 | return false; | 406 | return false; |
377 | 407 | ||
378 | list_for_each_entry(helper, &kernel_fb_helper_list, kernel_fb_list) { | 408 | list_for_each_entry(helper, &kernel_fb_helper_list, kernel_fb_list) { |
379 | struct drm_device *dev = helper->dev; | 409 | struct drm_device *dev = helper->dev; |
380 | 410 | ||
381 | if (dev->switch_power_state == DRM_SWITCH_POWER_OFF) | 411 | if (dev->switch_power_state == DRM_SWITCH_POWER_OFF) |
382 | continue; | 412 | continue; |
383 | 413 | ||
384 | /* | 414 | /* |
385 | * NOTE: Use trylock mode to avoid deadlocks and sleeping in | 415 | * NOTE: Use trylock mode to avoid deadlocks and sleeping in |
386 | * panic context. | 416 | * panic context. |
387 | */ | 417 | */ |
388 | if (__drm_modeset_lock_all(dev, true) != 0) { | 418 | if (__drm_modeset_lock_all(dev, true) != 0) { |
389 | error = true; | 419 | error = true; |
390 | continue; | 420 | continue; |
391 | } | 421 | } |
392 | 422 | ||
393 | ret = drm_fb_helper_restore_fbdev_mode(helper); | 423 | ret = drm_fb_helper_restore_fbdev_mode(helper); |
394 | if (ret) | 424 | if (ret) |
395 | error = true; | 425 | error = true; |
396 | 426 | ||
397 | drm_modeset_unlock_all(dev); | 427 | drm_modeset_unlock_all(dev); |
398 | } | 428 | } |
399 | return error; | 429 | return error; |
400 | } | 430 | } |
401 | 431 | ||
402 | static int drm_fb_helper_panic(struct notifier_block *n, unsigned long ununsed, | 432 | static int drm_fb_helper_panic(struct notifier_block *n, unsigned long ununsed, |
403 | void *panic_str) | 433 | void *panic_str) |
404 | { | 434 | { |
405 | /* | 435 | /* |
406 | * It's a waste of time and effort to switch back to text console | 436 | * It's a waste of time and effort to switch back to text console |
407 | * if the kernel should reboot before panic messages can be seen. | 437 | * if the kernel should reboot before panic messages can be seen. |
408 | */ | 438 | */ |
409 | if (panic_timeout < 0) | 439 | if (panic_timeout < 0) |
410 | return 0; | 440 | return 0; |
411 | 441 | ||
412 | pr_err("panic occurred, switching back to text console\n"); | 442 | pr_err("panic occurred, switching back to text console\n"); |
413 | return drm_fb_helper_force_kernel_mode(); | 443 | return drm_fb_helper_force_kernel_mode(); |
414 | } | 444 | } |
415 | 445 | ||
416 | static struct notifier_block paniced = { | 446 | static struct notifier_block paniced = { |
417 | .notifier_call = drm_fb_helper_panic, | 447 | .notifier_call = drm_fb_helper_panic, |
418 | }; | 448 | }; |
419 | 449 | ||
420 | static bool drm_fb_helper_is_bound(struct drm_fb_helper *fb_helper) | 450 | static bool drm_fb_helper_is_bound(struct drm_fb_helper *fb_helper) |
421 | { | 451 | { |
422 | struct drm_device *dev = fb_helper->dev; | 452 | struct drm_device *dev = fb_helper->dev; |
423 | struct drm_crtc *crtc; | 453 | struct drm_crtc *crtc; |
424 | int bound = 0, crtcs_bound = 0; | 454 | int bound = 0, crtcs_bound = 0; |
425 | 455 | ||
426 | /* Sometimes user space wants everything disabled, so don't steal the | 456 | /* Sometimes user space wants everything disabled, so don't steal the |
427 | * display if there's a master. */ | 457 | * display if there's a master. */ |
428 | if (dev->primary->master) | 458 | if (dev->primary->master) |
429 | return false; | 459 | return false; |
430 | 460 | ||
431 | list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) { | 461 | list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) { |
432 | if (crtc->primary->fb) | 462 | if (crtc->primary->fb) |
433 | crtcs_bound++; | 463 | crtcs_bound++; |
434 | if (crtc->primary->fb == fb_helper->fb) | 464 | if (crtc->primary->fb == fb_helper->fb) |
435 | bound++; | 465 | bound++; |
436 | } | 466 | } |
437 | 467 | ||
438 | if (bound < crtcs_bound) | 468 | if (bound < crtcs_bound) |
439 | return false; | 469 | return false; |
440 | 470 | ||
441 | return true; | 471 | return true; |
442 | } | 472 | } |
443 | 473 | ||
444 | #ifdef CONFIG_MAGIC_SYSRQ | 474 | #ifdef CONFIG_MAGIC_SYSRQ |
445 | static void drm_fb_helper_restore_work_fn(struct work_struct *ignored) | 475 | static void drm_fb_helper_restore_work_fn(struct work_struct *ignored) |
446 | { | 476 | { |
447 | bool ret; | 477 | bool ret; |
448 | ret = drm_fb_helper_force_kernel_mode(); | 478 | ret = drm_fb_helper_force_kernel_mode(); |
449 | if (ret == true) | 479 | if (ret == true) |
450 | DRM_ERROR("Failed to restore crtc configuration\n"); | 480 | DRM_ERROR("Failed to restore crtc configuration\n"); |
451 | } | 481 | } |
452 | static DECLARE_WORK(drm_fb_helper_restore_work, drm_fb_helper_restore_work_fn); | 482 | static DECLARE_WORK(drm_fb_helper_restore_work, drm_fb_helper_restore_work_fn); |
453 | 483 | ||
454 | static void drm_fb_helper_sysrq(int dummy1) | 484 | static void drm_fb_helper_sysrq(int dummy1) |
455 | { | 485 | { |
456 | schedule_work(&drm_fb_helper_restore_work); | 486 | schedule_work(&drm_fb_helper_restore_work); |
457 | } | 487 | } |
458 | 488 | ||
459 | static struct sysrq_key_op sysrq_drm_fb_helper_restore_op = { | 489 | static struct sysrq_key_op sysrq_drm_fb_helper_restore_op = { |
460 | .handler = drm_fb_helper_sysrq, | 490 | .handler = drm_fb_helper_sysrq, |
461 | .help_msg = "force-fb(V)", | 491 | .help_msg = "force-fb(V)", |
462 | .action_msg = "Restore framebuffer console", | 492 | .action_msg = "Restore framebuffer console", |
463 | }; | 493 | }; |
464 | #else | 494 | #else |
465 | static struct sysrq_key_op sysrq_drm_fb_helper_restore_op = { }; | 495 | static struct sysrq_key_op sysrq_drm_fb_helper_restore_op = { }; |
466 | #endif | 496 | #endif |
467 | 497 | ||
468 | static void drm_fb_helper_dpms(struct fb_info *info, int dpms_mode) | 498 | static void drm_fb_helper_dpms(struct fb_info *info, int dpms_mode) |
469 | { | 499 | { |
470 | struct drm_fb_helper *fb_helper = info->par; | 500 | struct drm_fb_helper *fb_helper = info->par; |
471 | struct drm_device *dev = fb_helper->dev; | 501 | struct drm_device *dev = fb_helper->dev; |
472 | struct drm_crtc *crtc; | 502 | struct drm_crtc *crtc; |
473 | struct drm_connector *connector; | 503 | struct drm_connector *connector; |
474 | int i, j; | 504 | int i, j; |
475 | 505 | ||
476 | /* | 506 | /* |
477 | * fbdev->blank can be called from irq context in case of a panic. | 507 | * fbdev->blank can be called from irq context in case of a panic. |
478 | * Since we already have our own special panic handler which will | 508 | * Since we already have our own special panic handler which will |
479 | * restore the fbdev console mode completely, just bail out early. | 509 | * restore the fbdev console mode completely, just bail out early. |
480 | */ | 510 | */ |
481 | if (oops_in_progress) | 511 | if (oops_in_progress) |
482 | return; | 512 | return; |
483 | 513 | ||
484 | /* | 514 | /* |
485 | * For each CRTC in this fb, turn the connectors on/off. | 515 | * For each CRTC in this fb, turn the connectors on/off. |
486 | */ | 516 | */ |
487 | drm_modeset_lock_all(dev); | 517 | drm_modeset_lock_all(dev); |
488 | if (!drm_fb_helper_is_bound(fb_helper)) { | 518 | if (!drm_fb_helper_is_bound(fb_helper)) { |
489 | drm_modeset_unlock_all(dev); | 519 | drm_modeset_unlock_all(dev); |
490 | return; | 520 | return; |
491 | } | 521 | } |
492 | 522 | ||
493 | for (i = 0; i < fb_helper->crtc_count; i++) { | 523 | for (i = 0; i < fb_helper->crtc_count; i++) { |
494 | crtc = fb_helper->crtc_info[i].mode_set.crtc; | 524 | crtc = fb_helper->crtc_info[i].mode_set.crtc; |
495 | 525 | ||
496 | if (!crtc->enabled) | 526 | if (!crtc->enabled) |
497 | continue; | 527 | continue; |
498 | 528 | ||
499 | /* Walk the connectors & encoders on this fb turning them on/off */ | 529 | /* Walk the connectors & encoders on this fb turning them on/off */ |
500 | for (j = 0; j < fb_helper->connector_count; j++) { | 530 | for (j = 0; j < fb_helper->connector_count; j++) { |
501 | connector = fb_helper->connector_info[j]->connector; | 531 | connector = fb_helper->connector_info[j]->connector; |
502 | connector->funcs->dpms(connector, dpms_mode); | 532 | connector->funcs->dpms(connector, dpms_mode); |
503 | drm_object_property_set_value(&connector->base, | 533 | drm_object_property_set_value(&connector->base, |
504 | dev->mode_config.dpms_property, dpms_mode); | 534 | dev->mode_config.dpms_property, dpms_mode); |
505 | } | 535 | } |
506 | } | 536 | } |
507 | drm_modeset_unlock_all(dev); | 537 | drm_modeset_unlock_all(dev); |
508 | } | 538 | } |
509 | 539 | ||
510 | /** | 540 | /** |
511 | * drm_fb_helper_blank - implementation for ->fb_blank | 541 | * drm_fb_helper_blank - implementation for ->fb_blank |
512 | * @blank: desired blanking state | 542 | * @blank: desired blanking state |
513 | * @info: fbdev registered by the helper | 543 | * @info: fbdev registered by the helper |
514 | */ | 544 | */ |
515 | int drm_fb_helper_blank(int blank, struct fb_info *info) | 545 | int drm_fb_helper_blank(int blank, struct fb_info *info) |
516 | { | 546 | { |
517 | switch (blank) { | 547 | switch (blank) { |
518 | /* Display: On; HSync: On, VSync: On */ | 548 | /* Display: On; HSync: On, VSync: On */ |
519 | case FB_BLANK_UNBLANK: | 549 | case FB_BLANK_UNBLANK: |
520 | drm_fb_helper_dpms(info, DRM_MODE_DPMS_ON); | 550 | drm_fb_helper_dpms(info, DRM_MODE_DPMS_ON); |
521 | break; | 551 | break; |
522 | /* Display: Off; HSync: On, VSync: On */ | 552 | /* Display: Off; HSync: On, VSync: On */ |
523 | case FB_BLANK_NORMAL: | 553 | case FB_BLANK_NORMAL: |
524 | drm_fb_helper_dpms(info, DRM_MODE_DPMS_STANDBY); | 554 | drm_fb_helper_dpms(info, DRM_MODE_DPMS_STANDBY); |
525 | break; | 555 | break; |
526 | /* Display: Off; HSync: Off, VSync: On */ | 556 | /* Display: Off; HSync: Off, VSync: On */ |
527 | case FB_BLANK_HSYNC_SUSPEND: | 557 | case FB_BLANK_HSYNC_SUSPEND: |
528 | drm_fb_helper_dpms(info, DRM_MODE_DPMS_STANDBY); | 558 | drm_fb_helper_dpms(info, DRM_MODE_DPMS_STANDBY); |
529 | break; | 559 | break; |
530 | /* Display: Off; HSync: On, VSync: Off */ | 560 | /* Display: Off; HSync: On, VSync: Off */ |
531 | case FB_BLANK_VSYNC_SUSPEND: | 561 | case FB_BLANK_VSYNC_SUSPEND: |
532 | drm_fb_helper_dpms(info, DRM_MODE_DPMS_SUSPEND); | 562 | drm_fb_helper_dpms(info, DRM_MODE_DPMS_SUSPEND); |
533 | break; | 563 | break; |
534 | /* Display: Off; HSync: Off, VSync: Off */ | 564 | /* Display: Off; HSync: Off, VSync: Off */ |
535 | case FB_BLANK_POWERDOWN: | 565 | case FB_BLANK_POWERDOWN: |
536 | drm_fb_helper_dpms(info, DRM_MODE_DPMS_OFF); | 566 | drm_fb_helper_dpms(info, DRM_MODE_DPMS_OFF); |
537 | break; | 567 | break; |
538 | } | 568 | } |
539 | return 0; | 569 | return 0; |
540 | } | 570 | } |
541 | EXPORT_SYMBOL(drm_fb_helper_blank); | 571 | EXPORT_SYMBOL(drm_fb_helper_blank); |
542 | 572 | ||
543 | static void drm_fb_helper_crtc_free(struct drm_fb_helper *helper) | 573 | static void drm_fb_helper_crtc_free(struct drm_fb_helper *helper) |
544 | { | 574 | { |
545 | int i; | 575 | int i; |
546 | 576 | ||
547 | for (i = 0; i < helper->connector_count; i++) | 577 | for (i = 0; i < helper->connector_count; i++) |
548 | kfree(helper->connector_info[i]); | 578 | kfree(helper->connector_info[i]); |
549 | kfree(helper->connector_info); | 579 | kfree(helper->connector_info); |
550 | for (i = 0; i < helper->crtc_count; i++) { | 580 | for (i = 0; i < helper->crtc_count; i++) { |
551 | kfree(helper->crtc_info[i].mode_set.connectors); | 581 | kfree(helper->crtc_info[i].mode_set.connectors); |
552 | if (helper->crtc_info[i].mode_set.mode) | 582 | if (helper->crtc_info[i].mode_set.mode) |
553 | drm_mode_destroy(helper->dev, helper->crtc_info[i].mode_set.mode); | 583 | drm_mode_destroy(helper->dev, helper->crtc_info[i].mode_set.mode); |
554 | } | 584 | } |
555 | kfree(helper->crtc_info); | 585 | kfree(helper->crtc_info); |
556 | } | 586 | } |
557 | 587 | ||
558 | /** | 588 | /** |
559 | * drm_fb_helper_prepare - setup a drm_fb_helper structure | 589 | * drm_fb_helper_prepare - setup a drm_fb_helper structure |
560 | * @dev: DRM device | 590 | * @dev: DRM device |
561 | * @helper: driver-allocated fbdev helper structure to set up | 591 | * @helper: driver-allocated fbdev helper structure to set up |
562 | * @funcs: pointer to structure of functions associate with this helper | 592 | * @funcs: pointer to structure of functions associate with this helper |
563 | * | 593 | * |
564 | * Sets up the bare minimum to make the framebuffer helper usable. This is | 594 | * Sets up the bare minimum to make the framebuffer helper usable. This is |
565 | * useful to implement race-free initialization of the polling helpers. | 595 | * useful to implement race-free initialization of the polling helpers. |
566 | */ | 596 | */ |
567 | void drm_fb_helper_prepare(struct drm_device *dev, struct drm_fb_helper *helper, | 597 | void drm_fb_helper_prepare(struct drm_device *dev, struct drm_fb_helper *helper, |
568 | const struct drm_fb_helper_funcs *funcs) | 598 | const struct drm_fb_helper_funcs *funcs) |
569 | { | 599 | { |
570 | INIT_LIST_HEAD(&helper->kernel_fb_list); | 600 | INIT_LIST_HEAD(&helper->kernel_fb_list); |
571 | helper->funcs = funcs; | 601 | helper->funcs = funcs; |
572 | helper->dev = dev; | 602 | helper->dev = dev; |
573 | } | 603 | } |
574 | EXPORT_SYMBOL(drm_fb_helper_prepare); | 604 | EXPORT_SYMBOL(drm_fb_helper_prepare); |
575 | 605 | ||
576 | /** | 606 | /** |
577 | * drm_fb_helper_init - initialize a drm_fb_helper structure | 607 | * drm_fb_helper_init - initialize a drm_fb_helper structure |
578 | * @dev: drm device | 608 | * @dev: drm device |
579 | * @fb_helper: driver-allocated fbdev helper structure to initialize | 609 | * @fb_helper: driver-allocated fbdev helper structure to initialize |
580 | * @crtc_count: maximum number of crtcs to support in this fbdev emulation | 610 | * @crtc_count: maximum number of crtcs to support in this fbdev emulation |
581 | * @max_conn_count: max connector count | 611 | * @max_conn_count: max connector count |
582 | * | 612 | * |
583 | * This allocates the structures for the fbdev helper with the given limits. | 613 | * This allocates the structures for the fbdev helper with the given limits. |
584 | * Note that this won't yet touch the hardware (through the driver interfaces) | 614 | * Note that this won't yet touch the hardware (through the driver interfaces) |
585 | * nor register the fbdev. This is only done in drm_fb_helper_initial_config() | 615 | * nor register the fbdev. This is only done in drm_fb_helper_initial_config() |
586 | * to allow driver writes more control over the exact init sequence. | 616 | * to allow driver writes more control over the exact init sequence. |
587 | * | 617 | * |
588 | * Drivers must call drm_fb_helper_prepare() before calling this function. | 618 | * Drivers must call drm_fb_helper_prepare() before calling this function. |
589 | * | 619 | * |
590 | * RETURNS: | 620 | * RETURNS: |
591 | * Zero if everything went ok, nonzero otherwise. | 621 | * Zero if everything went ok, nonzero otherwise. |
592 | */ | 622 | */ |
593 | int drm_fb_helper_init(struct drm_device *dev, | 623 | int drm_fb_helper_init(struct drm_device *dev, |
594 | struct drm_fb_helper *fb_helper, | 624 | struct drm_fb_helper *fb_helper, |
595 | int crtc_count, int max_conn_count) | 625 | int crtc_count, int max_conn_count) |
596 | { | 626 | { |
597 | struct drm_crtc *crtc; | 627 | struct drm_crtc *crtc; |
598 | int i; | 628 | int i; |
599 | 629 | ||
600 | if (!max_conn_count) | 630 | if (!max_conn_count) |
601 | return -EINVAL; | 631 | return -EINVAL; |
602 | 632 | ||
603 | fb_helper->crtc_info = kcalloc(crtc_count, sizeof(struct drm_fb_helper_crtc), GFP_KERNEL); | 633 | fb_helper->crtc_info = kcalloc(crtc_count, sizeof(struct drm_fb_helper_crtc), GFP_KERNEL); |
604 | if (!fb_helper->crtc_info) | 634 | if (!fb_helper->crtc_info) |
605 | return -ENOMEM; | 635 | return -ENOMEM; |
606 | 636 | ||
607 | fb_helper->crtc_count = crtc_count; | 637 | fb_helper->crtc_count = crtc_count; |
608 | fb_helper->connector_info = kcalloc(dev->mode_config.num_connector, sizeof(struct drm_fb_helper_connector *), GFP_KERNEL); | 638 | fb_helper->connector_info = kcalloc(dev->mode_config.num_connector, sizeof(struct drm_fb_helper_connector *), GFP_KERNEL); |
609 | if (!fb_helper->connector_info) { | 639 | if (!fb_helper->connector_info) { |
610 | kfree(fb_helper->crtc_info); | 640 | kfree(fb_helper->crtc_info); |
611 | return -ENOMEM; | 641 | return -ENOMEM; |
612 | } | 642 | } |
613 | fb_helper->connector_info_alloc_count = dev->mode_config.num_connector; | 643 | fb_helper->connector_info_alloc_count = dev->mode_config.num_connector; |
614 | fb_helper->connector_count = 0; | 644 | fb_helper->connector_count = 0; |
615 | 645 | ||
616 | for (i = 0; i < crtc_count; i++) { | 646 | for (i = 0; i < crtc_count; i++) { |
617 | fb_helper->crtc_info[i].mode_set.connectors = | 647 | fb_helper->crtc_info[i].mode_set.connectors = |
618 | kcalloc(max_conn_count, | 648 | kcalloc(max_conn_count, |
619 | sizeof(struct drm_connector *), | 649 | sizeof(struct drm_connector *), |
620 | GFP_KERNEL); | 650 | GFP_KERNEL); |
621 | 651 | ||
622 | if (!fb_helper->crtc_info[i].mode_set.connectors) | 652 | if (!fb_helper->crtc_info[i].mode_set.connectors) |
623 | goto out_free; | 653 | goto out_free; |
624 | fb_helper->crtc_info[i].mode_set.num_connectors = 0; | 654 | fb_helper->crtc_info[i].mode_set.num_connectors = 0; |
625 | } | 655 | } |
626 | 656 | ||
627 | i = 0; | 657 | i = 0; |
628 | list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) { | 658 | list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) { |
629 | fb_helper->crtc_info[i].mode_set.crtc = crtc; | 659 | fb_helper->crtc_info[i].mode_set.crtc = crtc; |
630 | i++; | 660 | i++; |
631 | } | 661 | } |
632 | 662 | ||
633 | return 0; | 663 | return 0; |
634 | out_free: | 664 | out_free: |
635 | drm_fb_helper_crtc_free(fb_helper); | 665 | drm_fb_helper_crtc_free(fb_helper); |
636 | return -ENOMEM; | 666 | return -ENOMEM; |
637 | } | 667 | } |
638 | EXPORT_SYMBOL(drm_fb_helper_init); | 668 | EXPORT_SYMBOL(drm_fb_helper_init); |
639 | 669 | ||
640 | void drm_fb_helper_fini(struct drm_fb_helper *fb_helper) | 670 | void drm_fb_helper_fini(struct drm_fb_helper *fb_helper) |
641 | { | 671 | { |
642 | if (!list_empty(&fb_helper->kernel_fb_list)) { | 672 | if (!list_empty(&fb_helper->kernel_fb_list)) { |
643 | list_del(&fb_helper->kernel_fb_list); | 673 | list_del(&fb_helper->kernel_fb_list); |
644 | if (list_empty(&kernel_fb_helper_list)) { | 674 | if (list_empty(&kernel_fb_helper_list)) { |
645 | pr_info("drm: unregistered panic notifier\n"); | 675 | pr_info("drm: unregistered panic notifier\n"); |
646 | atomic_notifier_chain_unregister(&panic_notifier_list, | 676 | atomic_notifier_chain_unregister(&panic_notifier_list, |
647 | &paniced); | 677 | &paniced); |
648 | unregister_sysrq_key('v', &sysrq_drm_fb_helper_restore_op); | 678 | unregister_sysrq_key('v', &sysrq_drm_fb_helper_restore_op); |
649 | } | 679 | } |
650 | } | 680 | } |
651 | 681 | ||
652 | drm_fb_helper_crtc_free(fb_helper); | 682 | drm_fb_helper_crtc_free(fb_helper); |
653 | 683 | ||
654 | } | 684 | } |
655 | EXPORT_SYMBOL(drm_fb_helper_fini); | 685 | EXPORT_SYMBOL(drm_fb_helper_fini); |
656 | 686 | ||
657 | static int setcolreg(struct drm_crtc *crtc, u16 red, u16 green, | 687 | static int setcolreg(struct drm_crtc *crtc, u16 red, u16 green, |
658 | u16 blue, u16 regno, struct fb_info *info) | 688 | u16 blue, u16 regno, struct fb_info *info) |
659 | { | 689 | { |
660 | struct drm_fb_helper *fb_helper = info->par; | 690 | struct drm_fb_helper *fb_helper = info->par; |
661 | struct drm_framebuffer *fb = fb_helper->fb; | 691 | struct drm_framebuffer *fb = fb_helper->fb; |
662 | int pindex; | 692 | int pindex; |
663 | 693 | ||
664 | if (info->fix.visual == FB_VISUAL_TRUECOLOR) { | 694 | if (info->fix.visual == FB_VISUAL_TRUECOLOR) { |
665 | u32 *palette; | 695 | u32 *palette; |
666 | u32 value; | 696 | u32 value; |
667 | /* place color in psuedopalette */ | 697 | /* place color in psuedopalette */ |
668 | if (regno > 16) | 698 | if (regno > 16) |
669 | return -EINVAL; | 699 | return -EINVAL; |
670 | palette = (u32 *)info->pseudo_palette; | 700 | palette = (u32 *)info->pseudo_palette; |
671 | red >>= (16 - info->var.red.length); | 701 | red >>= (16 - info->var.red.length); |
672 | green >>= (16 - info->var.green.length); | 702 | green >>= (16 - info->var.green.length); |
673 | blue >>= (16 - info->var.blue.length); | 703 | blue >>= (16 - info->var.blue.length); |
674 | value = (red << info->var.red.offset) | | 704 | value = (red << info->var.red.offset) | |
675 | (green << info->var.green.offset) | | 705 | (green << info->var.green.offset) | |
676 | (blue << info->var.blue.offset); | 706 | (blue << info->var.blue.offset); |
677 | if (info->var.transp.length > 0) { | 707 | if (info->var.transp.length > 0) { |
678 | u32 mask = (1 << info->var.transp.length) - 1; | 708 | u32 mask = (1 << info->var.transp.length) - 1; |
679 | mask <<= info->var.transp.offset; | 709 | mask <<= info->var.transp.offset; |
680 | value |= mask; | 710 | value |= mask; |
681 | } | 711 | } |
682 | palette[regno] = value; | 712 | palette[regno] = value; |
683 | return 0; | 713 | return 0; |
684 | } | 714 | } |
685 | 715 | ||
686 | /* | 716 | /* |
687 | * The driver really shouldn't advertise pseudo/directcolor | 717 | * The driver really shouldn't advertise pseudo/directcolor |
688 | * visuals if it can't deal with the palette. | 718 | * visuals if it can't deal with the palette. |
689 | */ | 719 | */ |
690 | if (WARN_ON(!fb_helper->funcs->gamma_set || | 720 | if (WARN_ON(!fb_helper->funcs->gamma_set || |
691 | !fb_helper->funcs->gamma_get)) | 721 | !fb_helper->funcs->gamma_get)) |
692 | return -EINVAL; | 722 | return -EINVAL; |
693 | 723 | ||
694 | pindex = regno; | 724 | pindex = regno; |
695 | 725 | ||
696 | if (fb->bits_per_pixel == 16) { | 726 | if (fb->bits_per_pixel == 16) { |
697 | pindex = regno << 3; | 727 | pindex = regno << 3; |
698 | 728 | ||
699 | if (fb->depth == 16 && regno > 63) | 729 | if (fb->depth == 16 && regno > 63) |
700 | return -EINVAL; | 730 | return -EINVAL; |
701 | if (fb->depth == 15 && regno > 31) | 731 | if (fb->depth == 15 && regno > 31) |
702 | return -EINVAL; | 732 | return -EINVAL; |
703 | 733 | ||
704 | if (fb->depth == 16) { | 734 | if (fb->depth == 16) { |
705 | u16 r, g, b; | 735 | u16 r, g, b; |
706 | int i; | 736 | int i; |
707 | if (regno < 32) { | 737 | if (regno < 32) { |
708 | for (i = 0; i < 8; i++) | 738 | for (i = 0; i < 8; i++) |
709 | fb_helper->funcs->gamma_set(crtc, red, | 739 | fb_helper->funcs->gamma_set(crtc, red, |
710 | green, blue, pindex + i); | 740 | green, blue, pindex + i); |
711 | } | 741 | } |
712 | 742 | ||
713 | fb_helper->funcs->gamma_get(crtc, &r, | 743 | fb_helper->funcs->gamma_get(crtc, &r, |
714 | &g, &b, | 744 | &g, &b, |
715 | pindex >> 1); | 745 | pindex >> 1); |
716 | 746 | ||
717 | for (i = 0; i < 4; i++) | 747 | for (i = 0; i < 4; i++) |
718 | fb_helper->funcs->gamma_set(crtc, r, | 748 | fb_helper->funcs->gamma_set(crtc, r, |
719 | green, b, | 749 | green, b, |
720 | (pindex >> 1) + i); | 750 | (pindex >> 1) + i); |
721 | } | 751 | } |
722 | } | 752 | } |
723 | 753 | ||
724 | if (fb->depth != 16) | 754 | if (fb->depth != 16) |
725 | fb_helper->funcs->gamma_set(crtc, red, green, blue, pindex); | 755 | fb_helper->funcs->gamma_set(crtc, red, green, blue, pindex); |
726 | return 0; | 756 | return 0; |
727 | } | 757 | } |
728 | 758 | ||
729 | /** | 759 | /** |
730 | * drm_fb_helper_setcmap - implementation for ->fb_setcmap | 760 | * drm_fb_helper_setcmap - implementation for ->fb_setcmap |
731 | * @cmap: cmap to set | 761 | * @cmap: cmap to set |
732 | * @info: fbdev registered by the helper | 762 | * @info: fbdev registered by the helper |
733 | */ | 763 | */ |
734 | int drm_fb_helper_setcmap(struct fb_cmap *cmap, struct fb_info *info) | 764 | int drm_fb_helper_setcmap(struct fb_cmap *cmap, struct fb_info *info) |
735 | { | 765 | { |
736 | struct drm_fb_helper *fb_helper = info->par; | 766 | struct drm_fb_helper *fb_helper = info->par; |
737 | struct drm_device *dev = fb_helper->dev; | 767 | struct drm_device *dev = fb_helper->dev; |
738 | struct drm_crtc_helper_funcs *crtc_funcs; | 768 | struct drm_crtc_helper_funcs *crtc_funcs; |
739 | u16 *red, *green, *blue, *transp; | 769 | u16 *red, *green, *blue, *transp; |
740 | struct drm_crtc *crtc; | 770 | struct drm_crtc *crtc; |
741 | int i, j, rc = 0; | 771 | int i, j, rc = 0; |
742 | int start; | 772 | int start; |
743 | 773 | ||
744 | drm_modeset_lock_all(dev); | 774 | drm_modeset_lock_all(dev); |
745 | if (!drm_fb_helper_is_bound(fb_helper)) { | 775 | if (!drm_fb_helper_is_bound(fb_helper)) { |
746 | drm_modeset_unlock_all(dev); | 776 | drm_modeset_unlock_all(dev); |
747 | return -EBUSY; | 777 | return -EBUSY; |
748 | } | 778 | } |
749 | 779 | ||
750 | for (i = 0; i < fb_helper->crtc_count; i++) { | 780 | for (i = 0; i < fb_helper->crtc_count; i++) { |
751 | crtc = fb_helper->crtc_info[i].mode_set.crtc; | 781 | crtc = fb_helper->crtc_info[i].mode_set.crtc; |
752 | crtc_funcs = crtc->helper_private; | 782 | crtc_funcs = crtc->helper_private; |
753 | 783 | ||
754 | red = cmap->red; | 784 | red = cmap->red; |
755 | green = cmap->green; | 785 | green = cmap->green; |
756 | blue = cmap->blue; | 786 | blue = cmap->blue; |
757 | transp = cmap->transp; | 787 | transp = cmap->transp; |
758 | start = cmap->start; | 788 | start = cmap->start; |
759 | 789 | ||
760 | for (j = 0; j < cmap->len; j++) { | 790 | for (j = 0; j < cmap->len; j++) { |
761 | u16 hred, hgreen, hblue, htransp = 0xffff; | 791 | u16 hred, hgreen, hblue, htransp = 0xffff; |
762 | 792 | ||
763 | hred = *red++; | 793 | hred = *red++; |
764 | hgreen = *green++; | 794 | hgreen = *green++; |
765 | hblue = *blue++; | 795 | hblue = *blue++; |
766 | 796 | ||
767 | if (transp) | 797 | if (transp) |
768 | htransp = *transp++; | 798 | htransp = *transp++; |
769 | 799 | ||
770 | rc = setcolreg(crtc, hred, hgreen, hblue, start++, info); | 800 | rc = setcolreg(crtc, hred, hgreen, hblue, start++, info); |
771 | if (rc) | 801 | if (rc) |
772 | goto out; | 802 | goto out; |
773 | } | 803 | } |
774 | if (crtc_funcs->load_lut) | 804 | if (crtc_funcs->load_lut) |
775 | crtc_funcs->load_lut(crtc); | 805 | crtc_funcs->load_lut(crtc); |
776 | } | 806 | } |
777 | out: | 807 | out: |
778 | drm_modeset_unlock_all(dev); | 808 | drm_modeset_unlock_all(dev); |
779 | return rc; | 809 | return rc; |
780 | } | 810 | } |
781 | EXPORT_SYMBOL(drm_fb_helper_setcmap); | 811 | EXPORT_SYMBOL(drm_fb_helper_setcmap); |
782 | 812 | ||
783 | /** | 813 | /** |
784 | * drm_fb_helper_check_var - implementation for ->fb_check_var | 814 | * drm_fb_helper_check_var - implementation for ->fb_check_var |
785 | * @var: screeninfo to check | 815 | * @var: screeninfo to check |
786 | * @info: fbdev registered by the helper | 816 | * @info: fbdev registered by the helper |
787 | */ | 817 | */ |
788 | int drm_fb_helper_check_var(struct fb_var_screeninfo *var, | 818 | int drm_fb_helper_check_var(struct fb_var_screeninfo *var, |
789 | struct fb_info *info) | 819 | struct fb_info *info) |
790 | { | 820 | { |
791 | struct drm_fb_helper *fb_helper = info->par; | 821 | struct drm_fb_helper *fb_helper = info->par; |
792 | struct drm_framebuffer *fb = fb_helper->fb; | 822 | struct drm_framebuffer *fb = fb_helper->fb; |
793 | int depth; | 823 | int depth; |
794 | 824 | ||
795 | if (var->pixclock != 0 || in_dbg_master()) | 825 | if (var->pixclock != 0 || in_dbg_master()) |
796 | return -EINVAL; | 826 | return -EINVAL; |
797 | 827 | ||
798 | /* Need to resize the fb object !!! */ | 828 | /* Need to resize the fb object !!! */ |
799 | if (var->bits_per_pixel > fb->bits_per_pixel || | 829 | if (var->bits_per_pixel > fb->bits_per_pixel || |
800 | var->xres > fb->width || var->yres > fb->height || | 830 | var->xres > fb->width || var->yres > fb->height || |
801 | var->xres_virtual > fb->width || var->yres_virtual > fb->height) { | 831 | var->xres_virtual > fb->width || var->yres_virtual > fb->height) { |
802 | DRM_DEBUG("fb userspace requested width/height/bpp is greater than current fb " | 832 | DRM_DEBUG("fb userspace requested width/height/bpp is greater than current fb " |
803 | "request %dx%d-%d (virtual %dx%d) > %dx%d-%d\n", | 833 | "request %dx%d-%d (virtual %dx%d) > %dx%d-%d\n", |
804 | var->xres, var->yres, var->bits_per_pixel, | 834 | var->xres, var->yres, var->bits_per_pixel, |
805 | var->xres_virtual, var->yres_virtual, | 835 | var->xres_virtual, var->yres_virtual, |
806 | fb->width, fb->height, fb->bits_per_pixel); | 836 | fb->width, fb->height, fb->bits_per_pixel); |
807 | return -EINVAL; | 837 | return -EINVAL; |
808 | } | 838 | } |
809 | 839 | ||
810 | switch (var->bits_per_pixel) { | 840 | switch (var->bits_per_pixel) { |
811 | case 16: | 841 | case 16: |
812 | depth = (var->green.length == 6) ? 16 : 15; | 842 | depth = (var->green.length == 6) ? 16 : 15; |
813 | break; | 843 | break; |
814 | case 32: | 844 | case 32: |
815 | depth = (var->transp.length > 0) ? 32 : 24; | 845 | depth = (var->transp.length > 0) ? 32 : 24; |
816 | break; | 846 | break; |
817 | default: | 847 | default: |
818 | depth = var->bits_per_pixel; | 848 | depth = var->bits_per_pixel; |
819 | break; | 849 | break; |
820 | } | 850 | } |
821 | 851 | ||
822 | switch (depth) { | 852 | switch (depth) { |
823 | case 8: | 853 | case 8: |
824 | var->red.offset = 0; | 854 | var->red.offset = 0; |
825 | var->green.offset = 0; | 855 | var->green.offset = 0; |
826 | var->blue.offset = 0; | 856 | var->blue.offset = 0; |
827 | var->red.length = 8; | 857 | var->red.length = 8; |
828 | var->green.length = 8; | 858 | var->green.length = 8; |
829 | var->blue.length = 8; | 859 | var->blue.length = 8; |
830 | var->transp.length = 0; | 860 | var->transp.length = 0; |
831 | var->transp.offset = 0; | 861 | var->transp.offset = 0; |
832 | break; | 862 | break; |
833 | case 15: | 863 | case 15: |
834 | var->red.offset = 10; | 864 | var->red.offset = 10; |
835 | var->green.offset = 5; | 865 | var->green.offset = 5; |
836 | var->blue.offset = 0; | 866 | var->blue.offset = 0; |
837 | var->red.length = 5; | 867 | var->red.length = 5; |
838 | var->green.length = 5; | 868 | var->green.length = 5; |
839 | var->blue.length = 5; | 869 | var->blue.length = 5; |
840 | var->transp.length = 1; | 870 | var->transp.length = 1; |
841 | var->transp.offset = 15; | 871 | var->transp.offset = 15; |
842 | break; | 872 | break; |
843 | case 16: | 873 | case 16: |
844 | var->red.offset = 11; | 874 | var->red.offset = 11; |
845 | var->green.offset = 5; | 875 | var->green.offset = 5; |
846 | var->blue.offset = 0; | 876 | var->blue.offset = 0; |
847 | var->red.length = 5; | 877 | var->red.length = 5; |
848 | var->green.length = 6; | 878 | var->green.length = 6; |
849 | var->blue.length = 5; | 879 | var->blue.length = 5; |
850 | var->transp.length = 0; | 880 | var->transp.length = 0; |
851 | var->transp.offset = 0; | 881 | var->transp.offset = 0; |
852 | break; | 882 | break; |
853 | case 24: | 883 | case 24: |
854 | var->red.offset = 16; | 884 | var->red.offset = 16; |
855 | var->green.offset = 8; | 885 | var->green.offset = 8; |
856 | var->blue.offset = 0; | 886 | var->blue.offset = 0; |
857 | var->red.length = 8; | 887 | var->red.length = 8; |
858 | var->green.length = 8; | 888 | var->green.length = 8; |
859 | var->blue.length = 8; | 889 | var->blue.length = 8; |
860 | var->transp.length = 0; | 890 | var->transp.length = 0; |
861 | var->transp.offset = 0; | 891 | var->transp.offset = 0; |
862 | break; | 892 | break; |
863 | case 32: | 893 | case 32: |
864 | var->red.offset = 16; | 894 | var->red.offset = 16; |
865 | var->green.offset = 8; | 895 | var->green.offset = 8; |
866 | var->blue.offset = 0; | 896 | var->blue.offset = 0; |
867 | var->red.length = 8; | 897 | var->red.length = 8; |
868 | var->green.length = 8; | 898 | var->green.length = 8; |
869 | var->blue.length = 8; | 899 | var->blue.length = 8; |
870 | var->transp.length = 8; | 900 | var->transp.length = 8; |
871 | var->transp.offset = 24; | 901 | var->transp.offset = 24; |
872 | break; | 902 | break; |
873 | default: | 903 | default: |
874 | return -EINVAL; | 904 | return -EINVAL; |
875 | } | 905 | } |
876 | return 0; | 906 | return 0; |
877 | } | 907 | } |
878 | EXPORT_SYMBOL(drm_fb_helper_check_var); | 908 | EXPORT_SYMBOL(drm_fb_helper_check_var); |
879 | 909 | ||
880 | /** | 910 | /** |
881 | * drm_fb_helper_set_par - implementation for ->fb_set_par | 911 | * drm_fb_helper_set_par - implementation for ->fb_set_par |
882 | * @info: fbdev registered by the helper | 912 | * @info: fbdev registered by the helper |
883 | * | 913 | * |
884 | * This will let fbcon do the mode init and is called at initialization time by | 914 | * This will let fbcon do the mode init and is called at initialization time by |
885 | * the fbdev core when registering the driver, and later on through the hotplug | 915 | * the fbdev core when registering the driver, and later on through the hotplug |
886 | * callback. | 916 | * callback. |
887 | */ | 917 | */ |
888 | int drm_fb_helper_set_par(struct fb_info *info) | 918 | int drm_fb_helper_set_par(struct fb_info *info) |
889 | { | 919 | { |
890 | struct drm_fb_helper *fb_helper = info->par; | 920 | struct drm_fb_helper *fb_helper = info->par; |
891 | struct fb_var_screeninfo *var = &info->var; | 921 | struct fb_var_screeninfo *var = &info->var; |
892 | 922 | ||
893 | if (var->pixclock != 0) { | 923 | if (var->pixclock != 0) { |
894 | DRM_ERROR("PIXEL CLOCK SET\n"); | 924 | DRM_ERROR("PIXEL CLOCK SET\n"); |
895 | return -EINVAL; | 925 | return -EINVAL; |
896 | } | 926 | } |
897 | 927 | ||
898 | drm_fb_helper_restore_fbdev_mode_unlocked(fb_helper); | 928 | drm_fb_helper_restore_fbdev_mode_unlocked(fb_helper); |
899 | 929 | ||
900 | return 0; | 930 | return 0; |
901 | } | 931 | } |
902 | EXPORT_SYMBOL(drm_fb_helper_set_par); | 932 | EXPORT_SYMBOL(drm_fb_helper_set_par); |
903 | 933 | ||
904 | /** | 934 | /** |
905 | * drm_fb_helper_pan_display - implementation for ->fb_pan_display | 935 | * drm_fb_helper_pan_display - implementation for ->fb_pan_display |
906 | * @var: updated screen information | 936 | * @var: updated screen information |
907 | * @info: fbdev registered by the helper | 937 | * @info: fbdev registered by the helper |
908 | */ | 938 | */ |
909 | int drm_fb_helper_pan_display(struct fb_var_screeninfo *var, | 939 | int drm_fb_helper_pan_display(struct fb_var_screeninfo *var, |
910 | struct fb_info *info) | 940 | struct fb_info *info) |
911 | { | 941 | { |
912 | struct drm_fb_helper *fb_helper = info->par; | 942 | struct drm_fb_helper *fb_helper = info->par; |
913 | struct drm_device *dev = fb_helper->dev; | 943 | struct drm_device *dev = fb_helper->dev; |
914 | struct drm_mode_set *modeset; | 944 | struct drm_mode_set *modeset; |
915 | int ret = 0; | 945 | int ret = 0; |
916 | int i; | 946 | int i; |
917 | 947 | ||
918 | drm_modeset_lock_all(dev); | 948 | drm_modeset_lock_all(dev); |
919 | if (!drm_fb_helper_is_bound(fb_helper)) { | 949 | if (!drm_fb_helper_is_bound(fb_helper)) { |
920 | drm_modeset_unlock_all(dev); | 950 | drm_modeset_unlock_all(dev); |
921 | return -EBUSY; | 951 | return -EBUSY; |
922 | } | 952 | } |
923 | 953 | ||
924 | for (i = 0; i < fb_helper->crtc_count; i++) { | 954 | for (i = 0; i < fb_helper->crtc_count; i++) { |
925 | modeset = &fb_helper->crtc_info[i].mode_set; | 955 | modeset = &fb_helper->crtc_info[i].mode_set; |
926 | 956 | ||
927 | modeset->x = var->xoffset; | 957 | modeset->x = var->xoffset; |
928 | modeset->y = var->yoffset; | 958 | modeset->y = var->yoffset; |
929 | 959 | ||
930 | if (modeset->num_connectors) { | 960 | if (modeset->num_connectors) { |
931 | ret = drm_mode_set_config_internal(modeset); | 961 | ret = drm_mode_set_config_internal(modeset); |
932 | if (!ret) { | 962 | if (!ret) { |
933 | info->var.xoffset = var->xoffset; | 963 | info->var.xoffset = var->xoffset; |
934 | info->var.yoffset = var->yoffset; | 964 | info->var.yoffset = var->yoffset; |
935 | } | 965 | } |
936 | } | 966 | } |
937 | } | 967 | } |
938 | drm_modeset_unlock_all(dev); | 968 | drm_modeset_unlock_all(dev); |
939 | return ret; | 969 | return ret; |
940 | } | 970 | } |
941 | EXPORT_SYMBOL(drm_fb_helper_pan_display); | 971 | EXPORT_SYMBOL(drm_fb_helper_pan_display); |
942 | 972 | ||
943 | /* | 973 | /* |
944 | * Allocates the backing storage and sets up the fbdev info structure through | 974 | * Allocates the backing storage and sets up the fbdev info structure through |
945 | * the ->fb_probe callback and then registers the fbdev and sets up the panic | 975 | * the ->fb_probe callback and then registers the fbdev and sets up the panic |
946 | * notifier. | 976 | * notifier. |
947 | */ | 977 | */ |
948 | static int drm_fb_helper_single_fb_probe(struct drm_fb_helper *fb_helper, | 978 | static int drm_fb_helper_single_fb_probe(struct drm_fb_helper *fb_helper, |
949 | int preferred_bpp) | 979 | int preferred_bpp) |
950 | { | 980 | { |
951 | int ret = 0; | 981 | int ret = 0; |
952 | int crtc_count = 0; | 982 | int crtc_count = 0; |
953 | int i; | 983 | int i; |
954 | struct fb_info *info; | 984 | struct fb_info *info; |
955 | struct drm_fb_helper_surface_size sizes; | 985 | struct drm_fb_helper_surface_size sizes; |
956 | int gamma_size = 0; | 986 | int gamma_size = 0; |
957 | 987 | ||
958 | memset(&sizes, 0, sizeof(struct drm_fb_helper_surface_size)); | 988 | memset(&sizes, 0, sizeof(struct drm_fb_helper_surface_size)); |
959 | sizes.surface_depth = 24; | 989 | sizes.surface_depth = 24; |
960 | sizes.surface_bpp = 32; | 990 | sizes.surface_bpp = 32; |
961 | sizes.fb_width = (unsigned)-1; | 991 | sizes.fb_width = (unsigned)-1; |
962 | sizes.fb_height = (unsigned)-1; | 992 | sizes.fb_height = (unsigned)-1; |
963 | 993 | ||
964 | /* if driver picks 8 or 16 by default use that | 994 | /* if driver picks 8 or 16 by default use that |
965 | for both depth/bpp */ | 995 | for both depth/bpp */ |
966 | if (preferred_bpp != sizes.surface_bpp) | 996 | if (preferred_bpp != sizes.surface_bpp) |
967 | sizes.surface_depth = sizes.surface_bpp = preferred_bpp; | 997 | sizes.surface_depth = sizes.surface_bpp = preferred_bpp; |
968 | 998 | ||
969 | /* first up get a count of crtcs now in use and new min/maxes width/heights */ | 999 | /* first up get a count of crtcs now in use and new min/maxes width/heights */ |
970 | for (i = 0; i < fb_helper->connector_count; i++) { | 1000 | for (i = 0; i < fb_helper->connector_count; i++) { |
971 | struct drm_fb_helper_connector *fb_helper_conn = fb_helper->connector_info[i]; | 1001 | struct drm_fb_helper_connector *fb_helper_conn = fb_helper->connector_info[i]; |
972 | struct drm_cmdline_mode *cmdline_mode; | 1002 | struct drm_cmdline_mode *cmdline_mode; |
973 | 1003 | ||
974 | cmdline_mode = &fb_helper_conn->connector->cmdline_mode; | 1004 | cmdline_mode = &fb_helper_conn->connector->cmdline_mode; |
975 | 1005 | ||
976 | if (cmdline_mode->bpp_specified) { | 1006 | if (cmdline_mode->bpp_specified) { |
977 | switch (cmdline_mode->bpp) { | 1007 | switch (cmdline_mode->bpp) { |
978 | case 8: | 1008 | case 8: |
979 | sizes.surface_depth = sizes.surface_bpp = 8; | 1009 | sizes.surface_depth = sizes.surface_bpp = 8; |
980 | break; | 1010 | break; |
981 | case 15: | 1011 | case 15: |
982 | sizes.surface_depth = 15; | 1012 | sizes.surface_depth = 15; |
983 | sizes.surface_bpp = 16; | 1013 | sizes.surface_bpp = 16; |
984 | break; | 1014 | break; |
985 | case 16: | 1015 | case 16: |
986 | sizes.surface_depth = sizes.surface_bpp = 16; | 1016 | sizes.surface_depth = sizes.surface_bpp = 16; |
987 | break; | 1017 | break; |
988 | case 24: | 1018 | case 24: |
989 | sizes.surface_depth = sizes.surface_bpp = 24; | 1019 | sizes.surface_depth = sizes.surface_bpp = 24; |
990 | break; | 1020 | break; |
991 | case 32: | 1021 | case 32: |
992 | sizes.surface_depth = 24; | 1022 | sizes.surface_depth = 24; |
993 | sizes.surface_bpp = 32; | 1023 | sizes.surface_bpp = 32; |
994 | break; | 1024 | break; |
995 | } | 1025 | } |
996 | break; | 1026 | break; |
997 | } | 1027 | } |
998 | } | 1028 | } |
999 | 1029 | ||
1000 | crtc_count = 0; | 1030 | crtc_count = 0; |
1001 | for (i = 0; i < fb_helper->crtc_count; i++) { | 1031 | for (i = 0; i < fb_helper->crtc_count; i++) { |
1002 | struct drm_display_mode *desired_mode; | 1032 | struct drm_display_mode *desired_mode; |
1003 | desired_mode = fb_helper->crtc_info[i].desired_mode; | 1033 | desired_mode = fb_helper->crtc_info[i].desired_mode; |
1004 | 1034 | ||
1005 | if (desired_mode) { | 1035 | if (desired_mode) { |
1006 | if (gamma_size == 0) | 1036 | if (gamma_size == 0) |
1007 | gamma_size = fb_helper->crtc_info[i].mode_set.crtc->gamma_size; | 1037 | gamma_size = fb_helper->crtc_info[i].mode_set.crtc->gamma_size; |
1008 | if (desired_mode->hdisplay < sizes.fb_width) | 1038 | if (desired_mode->hdisplay < sizes.fb_width) |
1009 | sizes.fb_width = desired_mode->hdisplay; | 1039 | sizes.fb_width = desired_mode->hdisplay; |
1010 | if (desired_mode->vdisplay < sizes.fb_height) | 1040 | if (desired_mode->vdisplay < sizes.fb_height) |
1011 | sizes.fb_height = desired_mode->vdisplay; | 1041 | sizes.fb_height = desired_mode->vdisplay; |
1012 | if (desired_mode->hdisplay > sizes.surface_width) | 1042 | if (desired_mode->hdisplay > sizes.surface_width) |
1013 | sizes.surface_width = desired_mode->hdisplay; | 1043 | sizes.surface_width = desired_mode->hdisplay; |
1014 | if (desired_mode->vdisplay > sizes.surface_height) | 1044 | if (desired_mode->vdisplay > sizes.surface_height) |
1015 | sizes.surface_height = desired_mode->vdisplay; | 1045 | sizes.surface_height = desired_mode->vdisplay; |
1016 | crtc_count++; | 1046 | crtc_count++; |
1017 | } | 1047 | } |
1018 | } | 1048 | } |
1019 | 1049 | ||
1020 | if (crtc_count == 0 || sizes.fb_width == -1 || sizes.fb_height == -1) { | 1050 | if (crtc_count == 0 || sizes.fb_width == -1 || sizes.fb_height == -1) { |
1021 | /* hmm everyone went away - assume VGA cable just fell out | 1051 | /* hmm everyone went away - assume VGA cable just fell out |
1022 | and will come back later. */ | 1052 | and will come back later. */ |
1023 | DRM_INFO("Cannot find any crtc or sizes - going 1024x768\n"); | 1053 | DRM_INFO("Cannot find any crtc or sizes - going 1024x768\n"); |
1024 | sizes.fb_width = sizes.surface_width = 1024; | 1054 | sizes.fb_width = sizes.surface_width = 1024; |
1025 | sizes.fb_height = sizes.surface_height = 768; | 1055 | sizes.fb_height = sizes.surface_height = 768; |
1026 | } | 1056 | } |
1027 | 1057 | ||
1028 | /* push down into drivers */ | 1058 | /* push down into drivers */ |
1029 | ret = (*fb_helper->funcs->fb_probe)(fb_helper, &sizes); | 1059 | ret = (*fb_helper->funcs->fb_probe)(fb_helper, &sizes); |
1030 | if (ret < 0) | 1060 | if (ret < 0) |
1031 | return ret; | 1061 | return ret; |
1032 | 1062 | ||
1033 | info = fb_helper->fbdev; | 1063 | info = fb_helper->fbdev; |
1034 | 1064 | ||
1035 | /* | 1065 | /* |
1036 | * Set the fb pointer - usually drm_setup_crtcs does this for hotplug | 1066 | * Set the fb pointer - usually drm_setup_crtcs does this for hotplug |
1037 | * events, but at init time drm_setup_crtcs needs to be called before | 1067 | * events, but at init time drm_setup_crtcs needs to be called before |
1038 | * the fb is allocated (since we need to figure out the desired size of | 1068 | * the fb is allocated (since we need to figure out the desired size of |
1039 | * the fb before we can allocate it ...). Hence we need to fix things up | 1069 | * the fb before we can allocate it ...). Hence we need to fix things up |
1040 | * here again. | 1070 | * here again. |
1041 | */ | 1071 | */ |
1042 | for (i = 0; i < fb_helper->crtc_count; i++) | 1072 | for (i = 0; i < fb_helper->crtc_count; i++) |
1043 | if (fb_helper->crtc_info[i].mode_set.num_connectors) | 1073 | if (fb_helper->crtc_info[i].mode_set.num_connectors) |
1044 | fb_helper->crtc_info[i].mode_set.fb = fb_helper->fb; | 1074 | fb_helper->crtc_info[i].mode_set.fb = fb_helper->fb; |
1045 | 1075 | ||
1046 | 1076 | ||
1047 | info->var.pixclock = 0; | 1077 | info->var.pixclock = 0; |
1048 | if (register_framebuffer(info) < 0) | 1078 | if (register_framebuffer(info) < 0) |
1049 | return -EINVAL; | 1079 | return -EINVAL; |
1050 | 1080 | ||
1051 | dev_info(fb_helper->dev->dev, "fb%d: %s frame buffer device\n", | 1081 | dev_info(fb_helper->dev->dev, "fb%d: %s frame buffer device\n", |
1052 | info->node, info->fix.id); | 1082 | info->node, info->fix.id); |
1053 | 1083 | ||
1054 | /* Switch back to kernel console on panic */ | 1084 | /* Switch back to kernel console on panic */ |
1055 | /* multi card linked list maybe */ | 1085 | /* multi card linked list maybe */ |
1056 | if (list_empty(&kernel_fb_helper_list)) { | 1086 | if (list_empty(&kernel_fb_helper_list)) { |
1057 | dev_info(fb_helper->dev->dev, "registered panic notifier\n"); | 1087 | dev_info(fb_helper->dev->dev, "registered panic notifier\n"); |
1058 | atomic_notifier_chain_register(&panic_notifier_list, | 1088 | atomic_notifier_chain_register(&panic_notifier_list, |
1059 | &paniced); | 1089 | &paniced); |
1060 | register_sysrq_key('v', &sysrq_drm_fb_helper_restore_op); | 1090 | register_sysrq_key('v', &sysrq_drm_fb_helper_restore_op); |
1061 | } | 1091 | } |
1062 | 1092 | ||
1063 | list_add(&fb_helper->kernel_fb_list, &kernel_fb_helper_list); | 1093 | list_add(&fb_helper->kernel_fb_list, &kernel_fb_helper_list); |
1064 | 1094 | ||
1065 | return 0; | 1095 | return 0; |
1066 | } | 1096 | } |
1067 | 1097 | ||
1068 | /** | 1098 | /** |
1069 | * drm_fb_helper_fill_fix - initializes fixed fbdev information | 1099 | * drm_fb_helper_fill_fix - initializes fixed fbdev information |
1070 | * @info: fbdev registered by the helper | 1100 | * @info: fbdev registered by the helper |
1071 | * @pitch: desired pitch | 1101 | * @pitch: desired pitch |
1072 | * @depth: desired depth | 1102 | * @depth: desired depth |
1073 | * | 1103 | * |
1074 | * Helper to fill in the fixed fbdev information useful for a non-accelerated | 1104 | * Helper to fill in the fixed fbdev information useful for a non-accelerated |
1075 | * fbdev emulations. Drivers which support acceleration methods which impose | 1105 | * fbdev emulations. Drivers which support acceleration methods which impose |
1076 | * additional constraints need to set up their own limits. | 1106 | * additional constraints need to set up their own limits. |
1077 | * | 1107 | * |
1078 | * Drivers should call this (or their equivalent setup code) from their | 1108 | * Drivers should call this (or their equivalent setup code) from their |
1079 | * ->fb_probe callback. | 1109 | * ->fb_probe callback. |
1080 | */ | 1110 | */ |
1081 | void drm_fb_helper_fill_fix(struct fb_info *info, uint32_t pitch, | 1111 | void drm_fb_helper_fill_fix(struct fb_info *info, uint32_t pitch, |
1082 | uint32_t depth) | 1112 | uint32_t depth) |
1083 | { | 1113 | { |
1084 | info->fix.type = FB_TYPE_PACKED_PIXELS; | 1114 | info->fix.type = FB_TYPE_PACKED_PIXELS; |
1085 | info->fix.visual = depth == 8 ? FB_VISUAL_PSEUDOCOLOR : | 1115 | info->fix.visual = depth == 8 ? FB_VISUAL_PSEUDOCOLOR : |
1086 | FB_VISUAL_TRUECOLOR; | 1116 | FB_VISUAL_TRUECOLOR; |
1087 | info->fix.mmio_start = 0; | 1117 | info->fix.mmio_start = 0; |
1088 | info->fix.mmio_len = 0; | 1118 | info->fix.mmio_len = 0; |
1089 | info->fix.type_aux = 0; | 1119 | info->fix.type_aux = 0; |
1090 | info->fix.xpanstep = 1; /* doing it in hw */ | 1120 | info->fix.xpanstep = 1; /* doing it in hw */ |
1091 | info->fix.ypanstep = 1; /* doing it in hw */ | 1121 | info->fix.ypanstep = 1; /* doing it in hw */ |
1092 | info->fix.ywrapstep = 0; | 1122 | info->fix.ywrapstep = 0; |
1093 | info->fix.accel = FB_ACCEL_NONE; | 1123 | info->fix.accel = FB_ACCEL_NONE; |
1094 | 1124 | ||
1095 | info->fix.line_length = pitch; | 1125 | info->fix.line_length = pitch; |
1096 | return; | 1126 | return; |
1097 | } | 1127 | } |
1098 | EXPORT_SYMBOL(drm_fb_helper_fill_fix); | 1128 | EXPORT_SYMBOL(drm_fb_helper_fill_fix); |
1099 | 1129 | ||
1100 | /** | 1130 | /** |
1101 | * drm_fb_helper_fill_var - initalizes variable fbdev information | 1131 | * drm_fb_helper_fill_var - initalizes variable fbdev information |
1102 | * @info: fbdev instance to set up | 1132 | * @info: fbdev instance to set up |
1103 | * @fb_helper: fb helper instance to use as template | 1133 | * @fb_helper: fb helper instance to use as template |
1104 | * @fb_width: desired fb width | 1134 | * @fb_width: desired fb width |
1105 | * @fb_height: desired fb height | 1135 | * @fb_height: desired fb height |
1106 | * | 1136 | * |
1107 | * Sets up the variable fbdev metainformation from the given fb helper instance | 1137 | * Sets up the variable fbdev metainformation from the given fb helper instance |
1108 | * and the drm framebuffer allocated in fb_helper->fb. | 1138 | * and the drm framebuffer allocated in fb_helper->fb. |
1109 | * | 1139 | * |
1110 | * Drivers should call this (or their equivalent setup code) from their | 1140 | * Drivers should call this (or their equivalent setup code) from their |
1111 | * ->fb_probe callback after having allocated the fbdev backing | 1141 | * ->fb_probe callback after having allocated the fbdev backing |
1112 | * storage framebuffer. | 1142 | * storage framebuffer. |
1113 | */ | 1143 | */ |
1114 | void drm_fb_helper_fill_var(struct fb_info *info, struct drm_fb_helper *fb_helper, | 1144 | void drm_fb_helper_fill_var(struct fb_info *info, struct drm_fb_helper *fb_helper, |
1115 | uint32_t fb_width, uint32_t fb_height) | 1145 | uint32_t fb_width, uint32_t fb_height) |
1116 | { | 1146 | { |
1117 | struct drm_framebuffer *fb = fb_helper->fb; | 1147 | struct drm_framebuffer *fb = fb_helper->fb; |
1118 | info->pseudo_palette = fb_helper->pseudo_palette; | 1148 | info->pseudo_palette = fb_helper->pseudo_palette; |
1119 | info->var.xres_virtual = fb->width; | 1149 | info->var.xres_virtual = fb->width; |
1120 | info->var.yres_virtual = fb->height; | 1150 | info->var.yres_virtual = fb->height; |
1121 | info->var.bits_per_pixel = fb->bits_per_pixel; | 1151 | info->var.bits_per_pixel = fb->bits_per_pixel; |
1122 | info->var.accel_flags = FB_ACCELF_TEXT; | 1152 | info->var.accel_flags = FB_ACCELF_TEXT; |
1123 | info->var.xoffset = 0; | 1153 | info->var.xoffset = 0; |
1124 | info->var.yoffset = 0; | 1154 | info->var.yoffset = 0; |
1125 | info->var.activate = FB_ACTIVATE_NOW; | 1155 | info->var.activate = FB_ACTIVATE_NOW; |
1126 | info->var.height = -1; | 1156 | info->var.height = -1; |
1127 | info->var.width = -1; | 1157 | info->var.width = -1; |
1128 | 1158 | ||
1129 | switch (fb->depth) { | 1159 | switch (fb->depth) { |
1130 | case 8: | 1160 | case 8: |
1131 | info->var.red.offset = 0; | 1161 | info->var.red.offset = 0; |
1132 | info->var.green.offset = 0; | 1162 | info->var.green.offset = 0; |
1133 | info->var.blue.offset = 0; | 1163 | info->var.blue.offset = 0; |
1134 | info->var.red.length = 8; /* 8bit DAC */ | 1164 | info->var.red.length = 8; /* 8bit DAC */ |
1135 | info->var.green.length = 8; | 1165 | info->var.green.length = 8; |
1136 | info->var.blue.length = 8; | 1166 | info->var.blue.length = 8; |
1137 | info->var.transp.offset = 0; | 1167 | info->var.transp.offset = 0; |
1138 | info->var.transp.length = 0; | 1168 | info->var.transp.length = 0; |
1139 | break; | 1169 | break; |
1140 | case 15: | 1170 | case 15: |
1141 | info->var.red.offset = 10; | 1171 | info->var.red.offset = 10; |
1142 | info->var.green.offset = 5; | 1172 | info->var.green.offset = 5; |
1143 | info->var.blue.offset = 0; | 1173 | info->var.blue.offset = 0; |
1144 | info->var.red.length = 5; | 1174 | info->var.red.length = 5; |
1145 | info->var.green.length = 5; | 1175 | info->var.green.length = 5; |
1146 | info->var.blue.length = 5; | 1176 | info->var.blue.length = 5; |
1147 | info->var.transp.offset = 15; | 1177 | info->var.transp.offset = 15; |
1148 | info->var.transp.length = 1; | 1178 | info->var.transp.length = 1; |
1149 | break; | 1179 | break; |
1150 | case 16: | 1180 | case 16: |
1151 | info->var.red.offset = 11; | 1181 | info->var.red.offset = 11; |
1152 | info->var.green.offset = 5; | 1182 | info->var.green.offset = 5; |
1153 | info->var.blue.offset = 0; | 1183 | info->var.blue.offset = 0; |
1154 | info->var.red.length = 5; | 1184 | info->var.red.length = 5; |
1155 | info->var.green.length = 6; | 1185 | info->var.green.length = 6; |
1156 | info->var.blue.length = 5; | 1186 | info->var.blue.length = 5; |
1157 | info->var.transp.offset = 0; | 1187 | info->var.transp.offset = 0; |
1158 | break; | 1188 | break; |
1159 | case 24: | 1189 | case 24: |
1160 | info->var.red.offset = 16; | 1190 | info->var.red.offset = 16; |
1161 | info->var.green.offset = 8; | 1191 | info->var.green.offset = 8; |
1162 | info->var.blue.offset = 0; | 1192 | info->var.blue.offset = 0; |
1163 | info->var.red.length = 8; | 1193 | info->var.red.length = 8; |
1164 | info->var.green.length = 8; | 1194 | info->var.green.length = 8; |
1165 | info->var.blue.length = 8; | 1195 | info->var.blue.length = 8; |
1166 | info->var.transp.offset = 0; | 1196 | info->var.transp.offset = 0; |
1167 | info->var.transp.length = 0; | 1197 | info->var.transp.length = 0; |
1168 | break; | 1198 | break; |
1169 | case 32: | 1199 | case 32: |
1170 | info->var.red.offset = 16; | 1200 | info->var.red.offset = 16; |
1171 | info->var.green.offset = 8; | 1201 | info->var.green.offset = 8; |
1172 | info->var.blue.offset = 0; | 1202 | info->var.blue.offset = 0; |
1173 | info->var.red.length = 8; | 1203 | info->var.red.length = 8; |
1174 | info->var.green.length = 8; | 1204 | info->var.green.length = 8; |
1175 | info->var.blue.length = 8; | 1205 | info->var.blue.length = 8; |
1176 | info->var.transp.offset = 24; | 1206 | info->var.transp.offset = 24; |
1177 | info->var.transp.length = 8; | 1207 | info->var.transp.length = 8; |
1178 | break; | 1208 | break; |
1179 | default: | 1209 | default: |
1180 | break; | 1210 | break; |
1181 | } | 1211 | } |
1182 | 1212 | ||
1183 | info->var.xres = fb_width; | 1213 | info->var.xres = fb_width; |
1184 | info->var.yres = fb_height; | 1214 | info->var.yres = fb_height; |
1185 | } | 1215 | } |
1186 | EXPORT_SYMBOL(drm_fb_helper_fill_var); | 1216 | EXPORT_SYMBOL(drm_fb_helper_fill_var); |
1187 | 1217 | ||
1188 | static int drm_fb_helper_probe_connector_modes(struct drm_fb_helper *fb_helper, | 1218 | static int drm_fb_helper_probe_connector_modes(struct drm_fb_helper *fb_helper, |
1189 | uint32_t maxX, | 1219 | uint32_t maxX, |
1190 | uint32_t maxY) | 1220 | uint32_t maxY) |
1191 | { | 1221 | { |
1192 | struct drm_connector *connector; | 1222 | struct drm_connector *connector; |
1193 | int count = 0; | 1223 | int count = 0; |
1194 | int i; | 1224 | int i; |
1195 | 1225 | ||
1196 | for (i = 0; i < fb_helper->connector_count; i++) { | 1226 | for (i = 0; i < fb_helper->connector_count; i++) { |
1197 | connector = fb_helper->connector_info[i]->connector; | 1227 | connector = fb_helper->connector_info[i]->connector; |
1198 | count += connector->funcs->fill_modes(connector, maxX, maxY); | 1228 | count += connector->funcs->fill_modes(connector, maxX, maxY); |
1199 | } | 1229 | } |
1200 | 1230 | ||
1201 | return count; | 1231 | return count; |
1202 | } | 1232 | } |
1203 | 1233 | ||
1204 | struct drm_display_mode *drm_has_preferred_mode(struct drm_fb_helper_connector *fb_connector, int width, int height) | 1234 | struct drm_display_mode *drm_has_preferred_mode(struct drm_fb_helper_connector *fb_connector, int width, int height) |
1205 | { | 1235 | { |
1206 | struct drm_display_mode *mode; | 1236 | struct drm_display_mode *mode; |
1207 | 1237 | ||
1208 | list_for_each_entry(mode, &fb_connector->connector->modes, head) { | 1238 | list_for_each_entry(mode, &fb_connector->connector->modes, head) { |
1209 | if (mode->hdisplay > width || | 1239 | if (mode->hdisplay > width || |
1210 | mode->vdisplay > height) | 1240 | mode->vdisplay > height) |
1211 | continue; | 1241 | continue; |
1212 | if (mode->type & DRM_MODE_TYPE_PREFERRED) | 1242 | if (mode->type & DRM_MODE_TYPE_PREFERRED) |
1213 | return mode; | 1243 | return mode; |
1214 | } | 1244 | } |
1215 | return NULL; | 1245 | return NULL; |
1216 | } | 1246 | } |
1217 | EXPORT_SYMBOL(drm_has_preferred_mode); | 1247 | EXPORT_SYMBOL(drm_has_preferred_mode); |
1218 | 1248 | ||
1219 | static bool drm_has_cmdline_mode(struct drm_fb_helper_connector *fb_connector) | 1249 | static bool drm_has_cmdline_mode(struct drm_fb_helper_connector *fb_connector) |
1220 | { | 1250 | { |
1221 | return fb_connector->connector->cmdline_mode.specified; | 1251 | return fb_connector->connector->cmdline_mode.specified; |
1222 | } | 1252 | } |
1223 | 1253 | ||
1224 | struct drm_display_mode *drm_pick_cmdline_mode(struct drm_fb_helper_connector *fb_helper_conn, | 1254 | struct drm_display_mode *drm_pick_cmdline_mode(struct drm_fb_helper_connector *fb_helper_conn, |
1225 | int width, int height) | 1255 | int width, int height) |
1226 | { | 1256 | { |
1227 | struct drm_cmdline_mode *cmdline_mode; | 1257 | struct drm_cmdline_mode *cmdline_mode; |
1228 | struct drm_display_mode *mode = NULL; | 1258 | struct drm_display_mode *mode = NULL; |
1229 | bool prefer_non_interlace; | 1259 | bool prefer_non_interlace; |
1230 | 1260 | ||
1231 | cmdline_mode = &fb_helper_conn->connector->cmdline_mode; | 1261 | cmdline_mode = &fb_helper_conn->connector->cmdline_mode; |
1232 | if (cmdline_mode->specified == false) | 1262 | if (cmdline_mode->specified == false) |
1233 | return mode; | 1263 | return mode; |
1234 | 1264 | ||
1235 | /* attempt to find a matching mode in the list of modes | 1265 | /* attempt to find a matching mode in the list of modes |
1236 | * we have gotten so far, if not add a CVT mode that conforms | 1266 | * we have gotten so far, if not add a CVT mode that conforms |
1237 | */ | 1267 | */ |
1238 | if (cmdline_mode->rb || cmdline_mode->margins) | 1268 | if (cmdline_mode->rb || cmdline_mode->margins) |
1239 | goto create_mode; | 1269 | goto create_mode; |
1240 | 1270 | ||
1241 | prefer_non_interlace = !cmdline_mode->interlace; | 1271 | prefer_non_interlace = !cmdline_mode->interlace; |
1242 | again: | 1272 | again: |
1243 | list_for_each_entry(mode, &fb_helper_conn->connector->modes, head) { | 1273 | list_for_each_entry(mode, &fb_helper_conn->connector->modes, head) { |
1244 | /* check width/height */ | 1274 | /* check width/height */ |
1245 | if (mode->hdisplay != cmdline_mode->xres || | 1275 | if (mode->hdisplay != cmdline_mode->xres || |
1246 | mode->vdisplay != cmdline_mode->yres) | 1276 | mode->vdisplay != cmdline_mode->yres) |
1247 | continue; | 1277 | continue; |
1248 | 1278 | ||
1249 | if (cmdline_mode->refresh_specified) { | 1279 | if (cmdline_mode->refresh_specified) { |
1250 | if (mode->vrefresh != cmdline_mode->refresh) | 1280 | if (mode->vrefresh != cmdline_mode->refresh) |
1251 | continue; | 1281 | continue; |
1252 | } | 1282 | } |
1253 | 1283 | ||
1254 | if (cmdline_mode->interlace) { | 1284 | if (cmdline_mode->interlace) { |
1255 | if (!(mode->flags & DRM_MODE_FLAG_INTERLACE)) | 1285 | if (!(mode->flags & DRM_MODE_FLAG_INTERLACE)) |
1256 | continue; | 1286 | continue; |
1257 | } else if (prefer_non_interlace) { | 1287 | } else if (prefer_non_interlace) { |
1258 | if (mode->flags & DRM_MODE_FLAG_INTERLACE) | 1288 | if (mode->flags & DRM_MODE_FLAG_INTERLACE) |
1259 | continue; | 1289 | continue; |
1260 | } | 1290 | } |
1261 | return mode; | 1291 | return mode; |
1262 | } | 1292 | } |
1263 | 1293 | ||
1264 | if (prefer_non_interlace) { | 1294 | if (prefer_non_interlace) { |
1265 | prefer_non_interlace = false; | 1295 | prefer_non_interlace = false; |
1266 | goto again; | 1296 | goto again; |
1267 | } | 1297 | } |
1268 | 1298 | ||
1269 | create_mode: | 1299 | create_mode: |
1270 | mode = drm_mode_create_from_cmdline_mode(fb_helper_conn->connector->dev, | 1300 | mode = drm_mode_create_from_cmdline_mode(fb_helper_conn->connector->dev, |
1271 | cmdline_mode); | 1301 | cmdline_mode); |
1272 | list_add(&mode->head, &fb_helper_conn->connector->modes); | 1302 | list_add(&mode->head, &fb_helper_conn->connector->modes); |
1273 | return mode; | 1303 | return mode; |
1274 | } | 1304 | } |
1275 | EXPORT_SYMBOL(drm_pick_cmdline_mode); | 1305 | EXPORT_SYMBOL(drm_pick_cmdline_mode); |
1276 | 1306 | ||
1277 | static bool drm_connector_enabled(struct drm_connector *connector, bool strict) | 1307 | static bool drm_connector_enabled(struct drm_connector *connector, bool strict) |
1278 | { | 1308 | { |
1279 | bool enable; | 1309 | bool enable; |
1280 | 1310 | ||
1281 | if (strict) | 1311 | if (strict) |
1282 | enable = connector->status == connector_status_connected; | 1312 | enable = connector->status == connector_status_connected; |
1283 | else | 1313 | else |
1284 | enable = connector->status != connector_status_disconnected; | 1314 | enable = connector->status != connector_status_disconnected; |
1285 | 1315 | ||
1286 | return enable; | 1316 | return enable; |
1287 | } | 1317 | } |
1288 | 1318 | ||
1289 | static void drm_enable_connectors(struct drm_fb_helper *fb_helper, | 1319 | static void drm_enable_connectors(struct drm_fb_helper *fb_helper, |
1290 | bool *enabled) | 1320 | bool *enabled) |
1291 | { | 1321 | { |
1292 | bool any_enabled = false; | 1322 | bool any_enabled = false; |
1293 | struct drm_connector *connector; | 1323 | struct drm_connector *connector; |
1294 | int i = 0; | 1324 | int i = 0; |
1295 | 1325 | ||
1296 | for (i = 0; i < fb_helper->connector_count; i++) { | 1326 | for (i = 0; i < fb_helper->connector_count; i++) { |
1297 | connector = fb_helper->connector_info[i]->connector; | 1327 | connector = fb_helper->connector_info[i]->connector; |
1298 | enabled[i] = drm_connector_enabled(connector, true); | 1328 | enabled[i] = drm_connector_enabled(connector, true); |
1299 | DRM_DEBUG_KMS("connector %d enabled? %s\n", connector->base.id, | 1329 | DRM_DEBUG_KMS("connector %d enabled? %s\n", connector->base.id, |
1300 | enabled[i] ? "yes" : "no"); | 1330 | enabled[i] ? "yes" : "no"); |
1301 | any_enabled |= enabled[i]; | 1331 | any_enabled |= enabled[i]; |
1302 | } | 1332 | } |
1303 | 1333 | ||
1304 | if (any_enabled) | 1334 | if (any_enabled) |
1305 | return; | 1335 | return; |
1306 | 1336 | ||
1307 | for (i = 0; i < fb_helper->connector_count; i++) { | 1337 | for (i = 0; i < fb_helper->connector_count; i++) { |
1308 | connector = fb_helper->connector_info[i]->connector; | 1338 | connector = fb_helper->connector_info[i]->connector; |
1309 | enabled[i] = drm_connector_enabled(connector, false); | 1339 | enabled[i] = drm_connector_enabled(connector, false); |
1310 | } | 1340 | } |
1311 | } | 1341 | } |
1312 | 1342 | ||
1313 | static bool drm_target_cloned(struct drm_fb_helper *fb_helper, | 1343 | static bool drm_target_cloned(struct drm_fb_helper *fb_helper, |
1314 | struct drm_display_mode **modes, | 1344 | struct drm_display_mode **modes, |
1315 | bool *enabled, int width, int height) | 1345 | bool *enabled, int width, int height) |
1316 | { | 1346 | { |
1317 | int count, i, j; | 1347 | int count, i, j; |
1318 | bool can_clone = false; | 1348 | bool can_clone = false; |
1319 | struct drm_fb_helper_connector *fb_helper_conn; | 1349 | struct drm_fb_helper_connector *fb_helper_conn; |
1320 | struct drm_display_mode *dmt_mode, *mode; | 1350 | struct drm_display_mode *dmt_mode, *mode; |
1321 | 1351 | ||
1322 | /* only contemplate cloning in the single crtc case */ | 1352 | /* only contemplate cloning in the single crtc case */ |
1323 | if (fb_helper->crtc_count > 1) | 1353 | if (fb_helper->crtc_count > 1) |
1324 | return false; | 1354 | return false; |
1325 | 1355 | ||
1326 | count = 0; | 1356 | count = 0; |
1327 | for (i = 0; i < fb_helper->connector_count; i++) { | 1357 | for (i = 0; i < fb_helper->connector_count; i++) { |
1328 | if (enabled[i]) | 1358 | if (enabled[i]) |
1329 | count++; | 1359 | count++; |
1330 | } | 1360 | } |
1331 | 1361 | ||
1332 | /* only contemplate cloning if more than one connector is enabled */ | 1362 | /* only contemplate cloning if more than one connector is enabled */ |
1333 | if (count <= 1) | 1363 | if (count <= 1) |
1334 | return false; | 1364 | return false; |
1335 | 1365 | ||
1336 | /* check the command line or if nothing common pick 1024x768 */ | 1366 | /* check the command line or if nothing common pick 1024x768 */ |
1337 | can_clone = true; | 1367 | can_clone = true; |
1338 | for (i = 0; i < fb_helper->connector_count; i++) { | 1368 | for (i = 0; i < fb_helper->connector_count; i++) { |
1339 | if (!enabled[i]) | 1369 | if (!enabled[i]) |
1340 | continue; | 1370 | continue; |
1341 | fb_helper_conn = fb_helper->connector_info[i]; | 1371 | fb_helper_conn = fb_helper->connector_info[i]; |
1342 | modes[i] = drm_pick_cmdline_mode(fb_helper_conn, width, height); | 1372 | modes[i] = drm_pick_cmdline_mode(fb_helper_conn, width, height); |
1343 | if (!modes[i]) { | 1373 | if (!modes[i]) { |
1344 | can_clone = false; | 1374 | can_clone = false; |
1345 | break; | 1375 | break; |
1346 | } | 1376 | } |
1347 | for (j = 0; j < i; j++) { | 1377 | for (j = 0; j < i; j++) { |
1348 | if (!enabled[j]) | 1378 | if (!enabled[j]) |
1349 | continue; | 1379 | continue; |
1350 | if (!drm_mode_equal(modes[j], modes[i])) | 1380 | if (!drm_mode_equal(modes[j], modes[i])) |
1351 | can_clone = false; | 1381 | can_clone = false; |
1352 | } | 1382 | } |
1353 | } | 1383 | } |
1354 | 1384 | ||
1355 | if (can_clone) { | 1385 | if (can_clone) { |
1356 | DRM_DEBUG_KMS("can clone using command line\n"); | 1386 | DRM_DEBUG_KMS("can clone using command line\n"); |
1357 | return true; | 1387 | return true; |
1358 | } | 1388 | } |
1359 | 1389 | ||
1360 | /* try and find a 1024x768 mode on each connector */ | 1390 | /* try and find a 1024x768 mode on each connector */ |
1361 | can_clone = true; | 1391 | can_clone = true; |
1362 | dmt_mode = drm_mode_find_dmt(fb_helper->dev, 1024, 768, 60, false); | 1392 | dmt_mode = drm_mode_find_dmt(fb_helper->dev, 1024, 768, 60, false); |
1363 | 1393 | ||
1364 | for (i = 0; i < fb_helper->connector_count; i++) { | 1394 | for (i = 0; i < fb_helper->connector_count; i++) { |
1365 | 1395 | ||
1366 | if (!enabled[i]) | 1396 | if (!enabled[i]) |
1367 | continue; | 1397 | continue; |
1368 | 1398 | ||
1369 | fb_helper_conn = fb_helper->connector_info[i]; | 1399 | fb_helper_conn = fb_helper->connector_info[i]; |
1370 | list_for_each_entry(mode, &fb_helper_conn->connector->modes, head) { | 1400 | list_for_each_entry(mode, &fb_helper_conn->connector->modes, head) { |
1371 | if (drm_mode_equal(mode, dmt_mode)) | 1401 | if (drm_mode_equal(mode, dmt_mode)) |
1372 | modes[i] = mode; | 1402 | modes[i] = mode; |
1373 | } | 1403 | } |
1374 | if (!modes[i]) | 1404 | if (!modes[i]) |
1375 | can_clone = false; | 1405 | can_clone = false; |
1376 | } | 1406 | } |
1377 | 1407 | ||
1378 | if (can_clone) { | 1408 | if (can_clone) { |
1379 | DRM_DEBUG_KMS("can clone using 1024x768\n"); | 1409 | DRM_DEBUG_KMS("can clone using 1024x768\n"); |
1380 | return true; | 1410 | return true; |
1381 | } | 1411 | } |
1382 | DRM_INFO("kms: can't enable cloning when we probably wanted to.\n"); | 1412 | DRM_INFO("kms: can't enable cloning when we probably wanted to.\n"); |
1383 | return false; | 1413 | return false; |
1384 | } | 1414 | } |
1385 | 1415 | ||
1386 | static bool drm_target_preferred(struct drm_fb_helper *fb_helper, | 1416 | static bool drm_target_preferred(struct drm_fb_helper *fb_helper, |
1387 | struct drm_display_mode **modes, | 1417 | struct drm_display_mode **modes, |
1388 | bool *enabled, int width, int height) | 1418 | bool *enabled, int width, int height) |
1389 | { | 1419 | { |
1390 | struct drm_fb_helper_connector *fb_helper_conn; | 1420 | struct drm_fb_helper_connector *fb_helper_conn; |
1391 | int i; | 1421 | int i; |
1392 | 1422 | ||
1393 | for (i = 0; i < fb_helper->connector_count; i++) { | 1423 | for (i = 0; i < fb_helper->connector_count; i++) { |
1394 | fb_helper_conn = fb_helper->connector_info[i]; | 1424 | fb_helper_conn = fb_helper->connector_info[i]; |
1395 | 1425 | ||
1396 | if (enabled[i] == false) | 1426 | if (enabled[i] == false) |
1397 | continue; | 1427 | continue; |
1398 | 1428 | ||
1399 | DRM_DEBUG_KMS("looking for cmdline mode on connector %d\n", | 1429 | DRM_DEBUG_KMS("looking for cmdline mode on connector %d\n", |
1400 | fb_helper_conn->connector->base.id); | 1430 | fb_helper_conn->connector->base.id); |
1401 | 1431 | ||
1402 | /* got for command line mode first */ | 1432 | /* got for command line mode first */ |
1403 | modes[i] = drm_pick_cmdline_mode(fb_helper_conn, width, height); | 1433 | modes[i] = drm_pick_cmdline_mode(fb_helper_conn, width, height); |
1404 | if (!modes[i]) { | 1434 | if (!modes[i]) { |
1405 | DRM_DEBUG_KMS("looking for preferred mode on connector %d\n", | 1435 | DRM_DEBUG_KMS("looking for preferred mode on connector %d\n", |
1406 | fb_helper_conn->connector->base.id); | 1436 | fb_helper_conn->connector->base.id); |
1407 | modes[i] = drm_has_preferred_mode(fb_helper_conn, width, height); | 1437 | modes[i] = drm_has_preferred_mode(fb_helper_conn, width, height); |
1408 | } | 1438 | } |
1409 | /* No preferred modes, pick one off the list */ | 1439 | /* No preferred modes, pick one off the list */ |
1410 | if (!modes[i] && !list_empty(&fb_helper_conn->connector->modes)) { | 1440 | if (!modes[i] && !list_empty(&fb_helper_conn->connector->modes)) { |
1411 | list_for_each_entry(modes[i], &fb_helper_conn->connector->modes, head) | 1441 | list_for_each_entry(modes[i], &fb_helper_conn->connector->modes, head) |
1412 | break; | 1442 | break; |
1413 | } | 1443 | } |
1414 | DRM_DEBUG_KMS("found mode %s\n", modes[i] ? modes[i]->name : | 1444 | DRM_DEBUG_KMS("found mode %s\n", modes[i] ? modes[i]->name : |
1415 | "none"); | 1445 | "none"); |
1416 | } | 1446 | } |
1417 | return true; | 1447 | return true; |
1418 | } | 1448 | } |
1419 | 1449 | ||
1420 | static int drm_pick_crtcs(struct drm_fb_helper *fb_helper, | 1450 | static int drm_pick_crtcs(struct drm_fb_helper *fb_helper, |
1421 | struct drm_fb_helper_crtc **best_crtcs, | 1451 | struct drm_fb_helper_crtc **best_crtcs, |
1422 | struct drm_display_mode **modes, | 1452 | struct drm_display_mode **modes, |
1423 | int n, int width, int height) | 1453 | int n, int width, int height) |
1424 | { | 1454 | { |
1425 | int c, o; | 1455 | int c, o; |
1426 | struct drm_device *dev = fb_helper->dev; | 1456 | struct drm_device *dev = fb_helper->dev; |
1427 | struct drm_connector *connector; | 1457 | struct drm_connector *connector; |
1428 | struct drm_connector_helper_funcs *connector_funcs; | 1458 | struct drm_connector_helper_funcs *connector_funcs; |
1429 | struct drm_encoder *encoder; | 1459 | struct drm_encoder *encoder; |
1430 | int my_score, best_score, score; | 1460 | int my_score, best_score, score; |
1431 | struct drm_fb_helper_crtc **crtcs, *crtc; | 1461 | struct drm_fb_helper_crtc **crtcs, *crtc; |
1432 | struct drm_fb_helper_connector *fb_helper_conn; | 1462 | struct drm_fb_helper_connector *fb_helper_conn; |
1433 | 1463 | ||
1434 | if (n == fb_helper->connector_count) | 1464 | if (n == fb_helper->connector_count) |
1435 | return 0; | 1465 | return 0; |
1436 | 1466 | ||
1437 | fb_helper_conn = fb_helper->connector_info[n]; | 1467 | fb_helper_conn = fb_helper->connector_info[n]; |
1438 | connector = fb_helper_conn->connector; | 1468 | connector = fb_helper_conn->connector; |
1439 | 1469 | ||
1440 | best_crtcs[n] = NULL; | 1470 | best_crtcs[n] = NULL; |
1441 | best_score = drm_pick_crtcs(fb_helper, best_crtcs, modes, n+1, width, height); | 1471 | best_score = drm_pick_crtcs(fb_helper, best_crtcs, modes, n+1, width, height); |
1442 | if (modes[n] == NULL) | 1472 | if (modes[n] == NULL) |
1443 | return best_score; | 1473 | return best_score; |
1444 | 1474 | ||
1445 | crtcs = kzalloc(dev->mode_config.num_connector * | 1475 | crtcs = kzalloc(dev->mode_config.num_connector * |
1446 | sizeof(struct drm_fb_helper_crtc *), GFP_KERNEL); | 1476 | sizeof(struct drm_fb_helper_crtc *), GFP_KERNEL); |
1447 | if (!crtcs) | 1477 | if (!crtcs) |
1448 | return best_score; | 1478 | return best_score; |
1449 | 1479 | ||
1450 | my_score = 1; | 1480 | my_score = 1; |
1451 | if (connector->status == connector_status_connected) | 1481 | if (connector->status == connector_status_connected) |
1452 | my_score++; | 1482 | my_score++; |
1453 | if (drm_has_cmdline_mode(fb_helper_conn)) | 1483 | if (drm_has_cmdline_mode(fb_helper_conn)) |
1454 | my_score++; | 1484 | my_score++; |
1455 | if (drm_has_preferred_mode(fb_helper_conn, width, height)) | 1485 | if (drm_has_preferred_mode(fb_helper_conn, width, height)) |
1456 | my_score++; | 1486 | my_score++; |
1457 | 1487 | ||
1458 | connector_funcs = connector->helper_private; | 1488 | connector_funcs = connector->helper_private; |
1459 | encoder = connector_funcs->best_encoder(connector); | 1489 | encoder = connector_funcs->best_encoder(connector); |
1460 | if (!encoder) | 1490 | if (!encoder) |
1461 | goto out; | 1491 | goto out; |
1462 | 1492 | ||
1463 | /* select a crtc for this connector and then attempt to configure | 1493 | /* select a crtc for this connector and then attempt to configure |
1464 | remaining connectors */ | 1494 | remaining connectors */ |
1465 | for (c = 0; c < fb_helper->crtc_count; c++) { | 1495 | for (c = 0; c < fb_helper->crtc_count; c++) { |
1466 | crtc = &fb_helper->crtc_info[c]; | 1496 | crtc = &fb_helper->crtc_info[c]; |
1467 | 1497 | ||
1468 | if ((encoder->possible_crtcs & (1 << c)) == 0) | 1498 | if ((encoder->possible_crtcs & (1 << c)) == 0) |
1469 | continue; | 1499 | continue; |
1470 | 1500 | ||
1471 | for (o = 0; o < n; o++) | 1501 | for (o = 0; o < n; o++) |
1472 | if (best_crtcs[o] == crtc) | 1502 | if (best_crtcs[o] == crtc) |
1473 | break; | 1503 | break; |
1474 | 1504 | ||
1475 | if (o < n) { | 1505 | if (o < n) { |
1476 | /* ignore cloning unless only a single crtc */ | 1506 | /* ignore cloning unless only a single crtc */ |
1477 | if (fb_helper->crtc_count > 1) | 1507 | if (fb_helper->crtc_count > 1) |
1478 | continue; | 1508 | continue; |
1479 | 1509 | ||
1480 | if (!drm_mode_equal(modes[o], modes[n])) | 1510 | if (!drm_mode_equal(modes[o], modes[n])) |
1481 | continue; | 1511 | continue; |
1482 | } | 1512 | } |
1483 | 1513 | ||
1484 | crtcs[n] = crtc; | 1514 | crtcs[n] = crtc; |
1485 | memcpy(crtcs, best_crtcs, n * sizeof(struct drm_fb_helper_crtc *)); | 1515 | memcpy(crtcs, best_crtcs, n * sizeof(struct drm_fb_helper_crtc *)); |
1486 | score = my_score + drm_pick_crtcs(fb_helper, crtcs, modes, n + 1, | 1516 | score = my_score + drm_pick_crtcs(fb_helper, crtcs, modes, n + 1, |
1487 | width, height); | 1517 | width, height); |
1488 | if (score > best_score) { | 1518 | if (score > best_score) { |
1489 | best_score = score; | 1519 | best_score = score; |
1490 | memcpy(best_crtcs, crtcs, | 1520 | memcpy(best_crtcs, crtcs, |
1491 | dev->mode_config.num_connector * | 1521 | dev->mode_config.num_connector * |
1492 | sizeof(struct drm_fb_helper_crtc *)); | 1522 | sizeof(struct drm_fb_helper_crtc *)); |
1493 | } | 1523 | } |
1494 | } | 1524 | } |
1495 | out: | 1525 | out: |
1496 | kfree(crtcs); | 1526 | kfree(crtcs); |
1497 | return best_score; | 1527 | return best_score; |
1498 | } | 1528 | } |
1499 | 1529 | ||
1500 | static void drm_setup_crtcs(struct drm_fb_helper *fb_helper) | 1530 | static void drm_setup_crtcs(struct drm_fb_helper *fb_helper) |
1501 | { | 1531 | { |
1502 | struct drm_device *dev = fb_helper->dev; | 1532 | struct drm_device *dev = fb_helper->dev; |
1503 | struct drm_fb_helper_crtc **crtcs; | 1533 | struct drm_fb_helper_crtc **crtcs; |
1504 | struct drm_display_mode **modes; | 1534 | struct drm_display_mode **modes; |
1505 | struct drm_mode_set *modeset; | 1535 | struct drm_mode_set *modeset; |
1506 | bool *enabled; | 1536 | bool *enabled; |
1507 | int width, height; | 1537 | int width, height; |
1508 | int i; | 1538 | int i; |
1509 | 1539 | ||
1510 | DRM_DEBUG_KMS("\n"); | 1540 | DRM_DEBUG_KMS("\n"); |
1511 | 1541 | ||
1512 | width = dev->mode_config.max_width; | 1542 | width = dev->mode_config.max_width; |
1513 | height = dev->mode_config.max_height; | 1543 | height = dev->mode_config.max_height; |
1514 | 1544 | ||
1515 | crtcs = kcalloc(dev->mode_config.num_connector, | 1545 | crtcs = kcalloc(dev->mode_config.num_connector, |
1516 | sizeof(struct drm_fb_helper_crtc *), GFP_KERNEL); | 1546 | sizeof(struct drm_fb_helper_crtc *), GFP_KERNEL); |
1517 | modes = kcalloc(dev->mode_config.num_connector, | 1547 | modes = kcalloc(dev->mode_config.num_connector, |
1518 | sizeof(struct drm_display_mode *), GFP_KERNEL); | 1548 | sizeof(struct drm_display_mode *), GFP_KERNEL); |
1519 | enabled = kcalloc(dev->mode_config.num_connector, | 1549 | enabled = kcalloc(dev->mode_config.num_connector, |
1520 | sizeof(bool), GFP_KERNEL); | 1550 | sizeof(bool), GFP_KERNEL); |
1521 | if (!crtcs || !modes || !enabled) { | 1551 | if (!crtcs || !modes || !enabled) { |
1522 | DRM_ERROR("Memory allocation failed\n"); | 1552 | DRM_ERROR("Memory allocation failed\n"); |
1523 | goto out; | 1553 | goto out; |
1524 | } | 1554 | } |
1525 | 1555 | ||
1526 | 1556 | ||
1527 | drm_enable_connectors(fb_helper, enabled); | 1557 | drm_enable_connectors(fb_helper, enabled); |
1528 | 1558 | ||
1529 | if (!(fb_helper->funcs->initial_config && | 1559 | if (!(fb_helper->funcs->initial_config && |
1530 | fb_helper->funcs->initial_config(fb_helper, crtcs, modes, | 1560 | fb_helper->funcs->initial_config(fb_helper, crtcs, modes, |
1531 | enabled, width, height))) { | 1561 | enabled, width, height))) { |
1532 | memset(modes, 0, dev->mode_config.num_connector*sizeof(modes[0])); | 1562 | memset(modes, 0, dev->mode_config.num_connector*sizeof(modes[0])); |
1533 | memset(crtcs, 0, dev->mode_config.num_connector*sizeof(crtcs[0])); | 1563 | memset(crtcs, 0, dev->mode_config.num_connector*sizeof(crtcs[0])); |
1534 | 1564 | ||
1535 | if (!drm_target_cloned(fb_helper, | 1565 | if (!drm_target_cloned(fb_helper, |
1536 | modes, enabled, width, height) && | 1566 | modes, enabled, width, height) && |
1537 | !drm_target_preferred(fb_helper, | 1567 | !drm_target_preferred(fb_helper, |
1538 | modes, enabled, width, height)) | 1568 | modes, enabled, width, height)) |
1539 | DRM_ERROR("Unable to find initial modes\n"); | 1569 | DRM_ERROR("Unable to find initial modes\n"); |
1540 | 1570 | ||
1541 | DRM_DEBUG_KMS("picking CRTCs for %dx%d config\n", | 1571 | DRM_DEBUG_KMS("picking CRTCs for %dx%d config\n", |
1542 | width, height); | 1572 | width, height); |
1543 | 1573 | ||
1544 | drm_pick_crtcs(fb_helper, crtcs, modes, 0, width, height); | 1574 | drm_pick_crtcs(fb_helper, crtcs, modes, 0, width, height); |
1545 | } | 1575 | } |
1546 | 1576 | ||
1547 | /* need to set the modesets up here for use later */ | 1577 | /* need to set the modesets up here for use later */ |
1548 | /* fill out the connector<->crtc mappings into the modesets */ | 1578 | /* fill out the connector<->crtc mappings into the modesets */ |
1549 | for (i = 0; i < fb_helper->crtc_count; i++) { | 1579 | for (i = 0; i < fb_helper->crtc_count; i++) { |
1550 | modeset = &fb_helper->crtc_info[i].mode_set; | 1580 | modeset = &fb_helper->crtc_info[i].mode_set; |
1551 | modeset->num_connectors = 0; | 1581 | modeset->num_connectors = 0; |
1552 | modeset->fb = NULL; | 1582 | modeset->fb = NULL; |
1553 | } | 1583 | } |
1554 | 1584 | ||
1555 | for (i = 0; i < fb_helper->connector_count; i++) { | 1585 | for (i = 0; i < fb_helper->connector_count; i++) { |
1556 | struct drm_display_mode *mode = modes[i]; | 1586 | struct drm_display_mode *mode = modes[i]; |
1557 | struct drm_fb_helper_crtc *fb_crtc = crtcs[i]; | 1587 | struct drm_fb_helper_crtc *fb_crtc = crtcs[i]; |
1558 | modeset = &fb_crtc->mode_set; | 1588 | modeset = &fb_crtc->mode_set; |
1559 | 1589 | ||
1560 | if (mode && fb_crtc) { | 1590 | if (mode && fb_crtc) { |
1561 | DRM_DEBUG_KMS("desired mode %s set on crtc %d\n", | 1591 | DRM_DEBUG_KMS("desired mode %s set on crtc %d\n", |
1562 | mode->name, fb_crtc->mode_set.crtc->base.id); | 1592 | mode->name, fb_crtc->mode_set.crtc->base.id); |
1563 | fb_crtc->desired_mode = mode; | 1593 | fb_crtc->desired_mode = mode; |
1564 | if (modeset->mode) | 1594 | if (modeset->mode) |
1565 | drm_mode_destroy(dev, modeset->mode); | 1595 | drm_mode_destroy(dev, modeset->mode); |
1566 | modeset->mode = drm_mode_duplicate(dev, | 1596 | modeset->mode = drm_mode_duplicate(dev, |
1567 | fb_crtc->desired_mode); | 1597 | fb_crtc->desired_mode); |
1568 | modeset->connectors[modeset->num_connectors++] = fb_helper->connector_info[i]->connector; | 1598 | modeset->connectors[modeset->num_connectors++] = fb_helper->connector_info[i]->connector; |
1569 | modeset->fb = fb_helper->fb; | 1599 | modeset->fb = fb_helper->fb; |
1570 | } | 1600 | } |
1571 | } | 1601 | } |
1572 | 1602 | ||
1573 | /* Clear out any old modes if there are no more connected outputs. */ | 1603 | /* Clear out any old modes if there are no more connected outputs. */ |
1574 | for (i = 0; i < fb_helper->crtc_count; i++) { | 1604 | for (i = 0; i < fb_helper->crtc_count; i++) { |
1575 | modeset = &fb_helper->crtc_info[i].mode_set; | 1605 | modeset = &fb_helper->crtc_info[i].mode_set; |
1576 | if (modeset->num_connectors == 0) { | 1606 | if (modeset->num_connectors == 0) { |
1577 | BUG_ON(modeset->fb); | 1607 | BUG_ON(modeset->fb); |
1578 | BUG_ON(modeset->num_connectors); | 1608 | BUG_ON(modeset->num_connectors); |
1579 | if (modeset->mode) | 1609 | if (modeset->mode) |
1580 | drm_mode_destroy(dev, modeset->mode); | 1610 | drm_mode_destroy(dev, modeset->mode); |
1581 | modeset->mode = NULL; | 1611 | modeset->mode = NULL; |
1582 | } | 1612 | } |
1583 | } | 1613 | } |
1584 | out: | 1614 | out: |
1585 | kfree(crtcs); | 1615 | kfree(crtcs); |
1586 | kfree(modes); | 1616 | kfree(modes); |
1587 | kfree(enabled); | 1617 | kfree(enabled); |
1588 | } | 1618 | } |
1589 | 1619 | ||
1590 | /** | 1620 | /** |
1591 | * drm_fb_helper_initial_config - setup a sane initial connector configuration | 1621 | * drm_fb_helper_initial_config - setup a sane initial connector configuration |
1592 | * @fb_helper: fb_helper device struct | 1622 | * @fb_helper: fb_helper device struct |
1593 | * @bpp_sel: bpp value to use for the framebuffer configuration | 1623 | * @bpp_sel: bpp value to use for the framebuffer configuration |
1594 | * | 1624 | * |
1595 | * Scans the CRTCs and connectors and tries to put together an initial setup. | 1625 | * Scans the CRTCs and connectors and tries to put together an initial setup. |
1596 | * At the moment, this is a cloned configuration across all heads with | 1626 | * At the moment, this is a cloned configuration across all heads with |
1597 | * a new framebuffer object as the backing store. | 1627 | * a new framebuffer object as the backing store. |
1598 | * | 1628 | * |
1599 | * Note that this also registers the fbdev and so allows userspace to call into | 1629 | * Note that this also registers the fbdev and so allows userspace to call into |
1600 | * the driver through the fbdev interfaces. | 1630 | * the driver through the fbdev interfaces. |
1601 | * | 1631 | * |
1602 | * This function will call down into the ->fb_probe callback to let | 1632 | * This function will call down into the ->fb_probe callback to let |
1603 | * the driver allocate and initialize the fbdev info structure and the drm | 1633 | * the driver allocate and initialize the fbdev info structure and the drm |
1604 | * framebuffer used to back the fbdev. drm_fb_helper_fill_var() and | 1634 | * framebuffer used to back the fbdev. drm_fb_helper_fill_var() and |
1605 | * drm_fb_helper_fill_fix() are provided as helpers to setup simple default | 1635 | * drm_fb_helper_fill_fix() are provided as helpers to setup simple default |
1606 | * values for the fbdev info structure. | 1636 | * values for the fbdev info structure. |
1607 | * | 1637 | * |
1608 | * RETURNS: | 1638 | * RETURNS: |
1609 | * Zero if everything went ok, nonzero otherwise. | 1639 | * Zero if everything went ok, nonzero otherwise. |
1610 | */ | 1640 | */ |
1611 | bool drm_fb_helper_initial_config(struct drm_fb_helper *fb_helper, int bpp_sel) | 1641 | bool drm_fb_helper_initial_config(struct drm_fb_helper *fb_helper, int bpp_sel) |
1612 | { | 1642 | { |
1613 | struct drm_device *dev = fb_helper->dev; | 1643 | struct drm_device *dev = fb_helper->dev; |
1614 | int count = 0; | 1644 | int count = 0; |
1615 | 1645 | ||
1616 | mutex_lock(&dev->mode_config.mutex); | 1646 | mutex_lock(&dev->mode_config.mutex); |
1617 | count = drm_fb_helper_probe_connector_modes(fb_helper, | 1647 | count = drm_fb_helper_probe_connector_modes(fb_helper, |
1618 | dev->mode_config.max_width, | 1648 | dev->mode_config.max_width, |
1619 | dev->mode_config.max_height); | 1649 | dev->mode_config.max_height); |
1620 | mutex_unlock(&dev->mode_config.mutex); | 1650 | mutex_unlock(&dev->mode_config.mutex); |
1621 | /* | 1651 | /* |
1622 | * we shouldn't end up with no modes here. | 1652 | * we shouldn't end up with no modes here. |
1623 | */ | 1653 | */ |
1624 | if (count == 0) | 1654 | if (count == 0) |
1625 | dev_info(fb_helper->dev->dev, "No connectors reported connected with modes\n"); | 1655 | dev_info(fb_helper->dev->dev, "No connectors reported connected with modes\n"); |
1626 | 1656 | ||
1627 | drm_setup_crtcs(fb_helper); | 1657 | drm_setup_crtcs(fb_helper); |
1628 | 1658 | ||
1629 | return drm_fb_helper_single_fb_probe(fb_helper, bpp_sel); | 1659 | return drm_fb_helper_single_fb_probe(fb_helper, bpp_sel); |
1630 | } | 1660 | } |
1631 | EXPORT_SYMBOL(drm_fb_helper_initial_config); | 1661 | EXPORT_SYMBOL(drm_fb_helper_initial_config); |
1632 | 1662 | ||
1633 | /** | 1663 | /** |
1634 | * drm_fb_helper_hotplug_event - respond to a hotplug notification by | 1664 | * drm_fb_helper_hotplug_event - respond to a hotplug notification by |
1635 | * probing all the outputs attached to the fb | 1665 | * probing all the outputs attached to the fb |
1636 | * @fb_helper: the drm_fb_helper | 1666 | * @fb_helper: the drm_fb_helper |
1637 | * | 1667 | * |
1638 | * Scan the connectors attached to the fb_helper and try to put together a | 1668 | * Scan the connectors attached to the fb_helper and try to put together a |
1639 | * setup after *notification of a change in output configuration. | 1669 | * setup after *notification of a change in output configuration. |
1640 | * | 1670 | * |
1641 | * Called at runtime, takes the mode config locks to be able to check/change the | 1671 | * Called at runtime, takes the mode config locks to be able to check/change the |
1642 | * modeset configuration. Must be run from process context (which usually means | 1672 | * modeset configuration. Must be run from process context (which usually means |
1643 | * either the output polling work or a work item launched from the driver's | 1673 | * either the output polling work or a work item launched from the driver's |
1644 | * hotplug interrupt). | 1674 | * hotplug interrupt). |
1645 | * | 1675 | * |
1646 | * Note that drivers may call this even before calling | 1676 | * Note that drivers may call this even before calling |
1647 | * drm_fb_helper_initial_config but only aftert drm_fb_helper_init. This allows | 1677 | * drm_fb_helper_initial_config but only aftert drm_fb_helper_init. This allows |
1648 | * for a race-free fbcon setup and will make sure that the fbdev emulation will | 1678 | * for a race-free fbcon setup and will make sure that the fbdev emulation will |
1649 | * not miss any hotplug events. | 1679 | * not miss any hotplug events. |
1650 | * | 1680 | * |
1651 | * RETURNS: | 1681 | * RETURNS: |
1652 | * 0 on success and a non-zero error code otherwise. | 1682 | * 0 on success and a non-zero error code otherwise. |
1653 | */ | 1683 | */ |
1654 | int drm_fb_helper_hotplug_event(struct drm_fb_helper *fb_helper) | 1684 | int drm_fb_helper_hotplug_event(struct drm_fb_helper *fb_helper) |
1655 | { | 1685 | { |
1656 | struct drm_device *dev = fb_helper->dev; | 1686 | struct drm_device *dev = fb_helper->dev; |
1657 | u32 max_width, max_height; | 1687 | u32 max_width, max_height; |
1658 | 1688 | ||
1659 | mutex_lock(&fb_helper->dev->mode_config.mutex); | 1689 | mutex_lock(&fb_helper->dev->mode_config.mutex); |
1660 | if (!fb_helper->fb || !drm_fb_helper_is_bound(fb_helper)) { | 1690 | if (!fb_helper->fb || !drm_fb_helper_is_bound(fb_helper)) { |
1661 | fb_helper->delayed_hotplug = true; | 1691 | fb_helper->delayed_hotplug = true; |
1662 | mutex_unlock(&fb_helper->dev->mode_config.mutex); | 1692 | mutex_unlock(&fb_helper->dev->mode_config.mutex); |
1663 | return 0; | 1693 | return 0; |
1664 | } | 1694 | } |
1665 | DRM_DEBUG_KMS("\n"); | 1695 | DRM_DEBUG_KMS("\n"); |
1666 | 1696 | ||
1667 | max_width = fb_helper->fb->width; | 1697 | max_width = fb_helper->fb->width; |
1668 | max_height = fb_helper->fb->height; | 1698 | max_height = fb_helper->fb->height; |
1669 | 1699 | ||
1670 | drm_fb_helper_probe_connector_modes(fb_helper, max_width, max_height); | 1700 | drm_fb_helper_probe_connector_modes(fb_helper, max_width, max_height); |
1671 | mutex_unlock(&fb_helper->dev->mode_config.mutex); | 1701 | mutex_unlock(&fb_helper->dev->mode_config.mutex); |
1672 | 1702 | ||
1673 | drm_modeset_lock_all(dev); | 1703 | drm_modeset_lock_all(dev); |
1674 | drm_setup_crtcs(fb_helper); | 1704 | drm_setup_crtcs(fb_helper); |
1675 | drm_modeset_unlock_all(dev); | 1705 | drm_modeset_unlock_all(dev); |
1676 | drm_fb_helper_set_par(fb_helper->fbdev); | 1706 | drm_fb_helper_set_par(fb_helper->fbdev); |
1677 | 1707 | ||
1678 | return 0; | 1708 | return 0; |
1679 | } | 1709 | } |
1680 | EXPORT_SYMBOL(drm_fb_helper_hotplug_event); | 1710 | EXPORT_SYMBOL(drm_fb_helper_hotplug_event); |
1681 | 1711 | ||
1682 | /* The Kconfig DRM_KMS_HELPER selects FRAMEBUFFER_CONSOLE (if !EXPERT) | 1712 | /* The Kconfig DRM_KMS_HELPER selects FRAMEBUFFER_CONSOLE (if !EXPERT) |
1683 | * but the module doesn't depend on any fb console symbols. At least | 1713 | * but the module doesn't depend on any fb console symbols. At least |
1684 | * attempt to load fbcon to avoid leaving the system without a usable console. | 1714 | * attempt to load fbcon to avoid leaving the system without a usable console. |
1685 | */ | 1715 | */ |
1686 | #if defined(CONFIG_FRAMEBUFFER_CONSOLE_MODULE) && !defined(CONFIG_EXPERT) | 1716 | #if defined(CONFIG_FRAMEBUFFER_CONSOLE_MODULE) && !defined(CONFIG_EXPERT) |
1687 | static int __init drm_fb_helper_modinit(void) | 1717 | static int __init drm_fb_helper_modinit(void) |
1688 | { | 1718 | { |
1689 | const char *name = "fbcon"; | 1719 | const char *name = "fbcon"; |
1690 | struct module *fbcon; | 1720 | struct module *fbcon; |
1691 | 1721 | ||
1692 | mutex_lock(&module_mutex); | 1722 | mutex_lock(&module_mutex); |
1693 | fbcon = find_module(name); | 1723 | fbcon = find_module(name); |
1694 | mutex_unlock(&module_mutex); | 1724 | mutex_unlock(&module_mutex); |
1695 | 1725 | ||
1696 | if (!fbcon) | 1726 | if (!fbcon) |
1697 | request_module_nowait(name); | 1727 | request_module_nowait(name); |
1698 | return 0; | 1728 | return 0; |
1699 | } | 1729 | } |
1700 | 1730 | ||
1701 | module_init(drm_fb_helper_modinit); | 1731 | module_init(drm_fb_helper_modinit); |
1702 | #endif | 1732 | #endif |
1703 | 1733 |