Commit | Line | Data |
---|---|---|
8d754544 DV |
1 | /* |
2 | * Copyright (c) 2006-2008 Intel Corporation | |
3 | * Copyright (c) 2007 Dave Airlie <airlied@linux.ie> | |
4 | * | |
5 | * DRM core CRTC related functions | |
6 | * | |
7 | * Permission to use, copy, modify, distribute, and sell this software and its | |
8 | * documentation for any purpose is hereby granted without fee, provided that | |
9 | * the above copyright notice appear in all copies and that both that copyright | |
10 | * notice and this permission notice appear in supporting documentation, and | |
11 | * that the name of the copyright holders not be used in advertising or | |
12 | * publicity pertaining to distribution of the software without specific, | |
13 | * written prior permission. The copyright holders make no representations | |
14 | * about the suitability of this software for any purpose. It is provided "as | |
15 | * is" without express or implied warranty. | |
16 | * | |
17 | * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, | |
18 | * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO | |
19 | * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR | |
20 | * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, | |
21 | * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER | |
22 | * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE | |
23 | * OF THIS SOFTWARE. | |
24 | * | |
25 | * Authors: | |
26 | * Keith Packard | |
27 | * Eric Anholt <eric@anholt.net> | |
28 | * Dave Airlie <airlied@linux.ie> | |
29 | * Jesse Barnes <jesse.barnes@intel.com> | |
30 | */ | |
31 | ||
32 | #include <linux/export.h> | |
33 | #include <linux/moduleparam.h> | |
34 | ||
35 | #include <drm/drmP.h> | |
36 | #include <drm/drm_crtc.h> | |
37 | #include <drm/drm_fourcc.h> | |
38 | #include <drm/drm_crtc_helper.h> | |
39 | #include <drm/drm_fb_helper.h> | |
40 | #include <drm/drm_edid.h> | |
41 | ||
42 | /** | |
43 | * DOC: output probing helper overview | |
44 | * | |
45 | * This library provides some helper code for output probing. It provides an | |
46 | * implementation of the core connector->fill_modes interface with | |
47 | * drm_helper_probe_single_connector_modes. | |
48 | * | |
49 | * It also provides support for polling connectors with a work item and for | |
50 | * generic hotplug interrupt handling where the driver doesn't or cannot keep | |
51 | * track of a per-connector hpd interrupt. | |
52 | * | |
53 | * This helper library can be used independently of the modeset helper library. | |
54 | * Drivers can also overwrite different parts e.g. use their own hotplug | |
55 | * handling code to avoid probing unrelated outputs. | |
092d01da DV |
56 | * |
57 | * The probe helpers share the function table structures with other display | |
58 | * helper libraries. See struct &drm_connector_helper_funcs for the details. | |
8d754544 DV |
59 | */ |
60 | ||
61 | static bool drm_kms_helper_poll = true; | |
62 | module_param_named(poll, drm_kms_helper_poll, bool, 0600); | |
63 | ||
05acaec3 VS |
64 | static enum drm_mode_status |
65 | drm_mode_validate_flag(const struct drm_display_mode *mode, | |
66 | int flags) | |
8d754544 | 67 | { |
05acaec3 VS |
68 | if ((mode->flags & DRM_MODE_FLAG_INTERLACE) && |
69 | !(flags & DRM_MODE_FLAG_INTERLACE)) | |
70 | return MODE_NO_INTERLACE; | |
8d754544 | 71 | |
05acaec3 VS |
72 | if ((mode->flags & DRM_MODE_FLAG_DBLSCAN) && |
73 | !(flags & DRM_MODE_FLAG_DBLSCAN)) | |
74 | return MODE_NO_DBLESCAN; | |
8d754544 | 75 | |
05acaec3 VS |
76 | if ((mode->flags & DRM_MODE_FLAG_3D_MASK) && |
77 | !(flags & DRM_MODE_FLAG_3D_MASK)) | |
78 | return MODE_NO_STEREO; | |
8d754544 | 79 | |
05acaec3 | 80 | return MODE_OK; |
8d754544 DV |
81 | } |
82 | ||
eaf99c74 CW |
83 | static int drm_helper_probe_add_cmdline_mode(struct drm_connector *connector) |
84 | { | |
85 | struct drm_display_mode *mode; | |
86 | ||
87 | if (!connector->cmdline_mode.specified) | |
88 | return 0; | |
89 | ||
90 | mode = drm_mode_create_from_cmdline_mode(connector->dev, | |
91 | &connector->cmdline_mode); | |
92 | if (mode == NULL) | |
93 | return 0; | |
94 | ||
95 | drm_mode_probed_add(connector, mode); | |
96 | return 1; | |
97 | } | |
98 | ||
8c4ccc4a | 99 | #define DRM_OUTPUT_POLL_PERIOD (10*HZ) |
4ad640e9 EE |
100 | /** |
101 | * drm_kms_helper_poll_enable_locked - re-enable output polling. | |
102 | * @dev: drm_device | |
103 | * | |
104 | * This function re-enables the output polling work without | |
105 | * locking the mode_config mutex. | |
106 | * | |
107 | * This is like drm_kms_helper_poll_enable() however it is to be | |
108 | * called from a context where the mode_config mutex is locked | |
109 | * already. | |
110 | */ | |
111 | void drm_kms_helper_poll_enable_locked(struct drm_device *dev) | |
8c4ccc4a DV |
112 | { |
113 | bool poll = false; | |
114 | struct drm_connector *connector; | |
115 | ||
116 | WARN_ON(!mutex_is_locked(&dev->mode_config.mutex)); | |
117 | ||
118 | if (!dev->mode_config.poll_enabled || !drm_kms_helper_poll) | |
119 | return; | |
120 | ||
121 | drm_for_each_connector(connector, dev) { | |
122 | if (connector->polled & (DRM_CONNECTOR_POLL_CONNECT | | |
123 | DRM_CONNECTOR_POLL_DISCONNECT)) | |
124 | poll = true; | |
125 | } | |
126 | ||
127 | if (poll) | |
128 | schedule_delayed_work(&dev->mode_config.output_poll_work, DRM_OUTPUT_POLL_PERIOD); | |
129 | } | |
4ad640e9 EE |
130 | EXPORT_SYMBOL(drm_kms_helper_poll_enable_locked); |
131 | ||
6af3e656 VS |
132 | /** |
133 | * drm_helper_probe_single_connector_modes - get complete set of display modes | |
134 | * @connector: connector to probe | |
135 | * @maxX: max width for modes | |
136 | * @maxY: max height for modes | |
137 | * | |
138 | * Based on the helper callbacks implemented by @connector in struct | |
139 | * &drm_connector_helper_funcs try to detect all valid modes. Modes will first | |
140 | * be added to the connector's probed_modes list, then culled (based on validity | |
141 | * and the @maxX, @maxY parameters) and put into the normal modes list. | |
142 | * | |
143 | * Intended to be used as a generic implementation of the ->fill_modes() | |
144 | * @connector vfunc for drivers that use the CRTC helpers for output mode | |
145 | * filtering and detection. | |
146 | * | |
147 | * If the helper operation returns no mode, and if the connector status is | |
148 | * connector_status_connected, standard VESA DMT modes up to 1024x768 are | |
149 | * automatically added to the modes list by a call to | |
150 | * drm_add_modes_noedid(). | |
151 | * | |
152 | * The function then filters out modes larger than @maxX and maxY if specified. | |
153 | * It finally calls the optional connector ->mode_valid() helper operation for each | |
154 | * mode in the probed list to check whether the mode is valid for the connector. | |
155 | * | |
156 | * Compared to drm_helper_probe_single_connector_modes_nomerge() this function | |
157 | * merged the mode bits for the preferred mode, as a hack to work around some | |
158 | * quirky issues on funky hardware. | |
159 | * | |
160 | * Returns: | |
161 | * The number of modes found on @connector. | |
162 | */ | |
163 | int drm_helper_probe_single_connector_modes(struct drm_connector *connector, | |
164 | uint32_t maxX, uint32_t maxY) | |
8d754544 DV |
165 | { |
166 | struct drm_device *dev = connector->dev; | |
167 | struct drm_display_mode *mode; | |
be26a66d | 168 | const struct drm_connector_helper_funcs *connector_funcs = |
8d754544 DV |
169 | connector->helper_private; |
170 | int count = 0; | |
171 | int mode_flags = 0; | |
172 | bool verbose_prune = true; | |
162b6a57 | 173 | enum drm_connector_status old_status; |
8d754544 DV |
174 | |
175 | WARN_ON(!mutex_is_locked(&dev->mode_config.mutex)); | |
176 | ||
177 | DRM_DEBUG_KMS("[CONNECTOR:%d:%s]\n", connector->base.id, | |
25933820 | 178 | connector->name); |
5ba89406 | 179 | /* set all old modes to the stale state */ |
8d754544 | 180 | list_for_each_entry(mode, &connector->modes, head) |
5ba89406 | 181 | mode->status = MODE_STALE; |
8d754544 | 182 | |
ed293f77 DV |
183 | old_status = connector->status; |
184 | ||
8d754544 | 185 | if (connector->force) { |
2c4cc91b PH |
186 | if (connector->force == DRM_FORCE_ON || |
187 | connector->force == DRM_FORCE_ON_DIGITAL) | |
8d754544 DV |
188 | connector->status = connector_status_connected; |
189 | else | |
190 | connector->status = connector_status_disconnected; | |
191 | if (connector->funcs->force) | |
192 | connector->funcs->force(connector); | |
193 | } else { | |
194 | connector->status = connector->funcs->detect(connector, true); | |
ed293f77 DV |
195 | } |
196 | ||
197 | /* | |
198 | * Normally either the driver's hpd code or the poll loop should | |
199 | * pick up any changes and fire the hotplug event. But if | |
200 | * userspace sneaks in a probe, we might miss a change. Hence | |
201 | * check here, and if anything changed start the hotplug code. | |
202 | */ | |
203 | if (old_status != connector->status) { | |
4e15f2a1 | 204 | DRM_DEBUG_KMS("[CONNECTOR:%d:%s] status updated from %s to %s\n", |
ed293f77 DV |
205 | connector->base.id, |
206 | connector->name, | |
4e15f2a1 JN |
207 | drm_get_connector_status_name(old_status), |
208 | drm_get_connector_status_name(connector->status)); | |
162b6a57 DV |
209 | |
210 | /* | |
ed293f77 DV |
211 | * The hotplug event code might call into the fb |
212 | * helpers, and so expects that we do not hold any | |
213 | * locks. Fire up the poll struct instead, it will | |
214 | * disable itself again. | |
162b6a57 | 215 | */ |
ed293f77 DV |
216 | dev->mode_config.delayed_event = true; |
217 | if (dev->mode_config.poll_enabled) | |
218 | schedule_delayed_work(&dev->mode_config.output_poll_work, | |
219 | 0); | |
8d754544 DV |
220 | } |
221 | ||
222 | /* Re-enable polling in case the global poll config changed. */ | |
223 | if (drm_kms_helper_poll != dev->mode_config.poll_running) | |
4ad640e9 | 224 | drm_kms_helper_poll_enable_locked(dev); |
8d754544 DV |
225 | |
226 | dev->mode_config.poll_running = drm_kms_helper_poll; | |
227 | ||
228 | if (connector->status == connector_status_disconnected) { | |
229 | DRM_DEBUG_KMS("[CONNECTOR:%d:%s] disconnected\n", | |
25933820 | 230 | connector->base.id, connector->name); |
8d754544 DV |
231 | drm_mode_connector_update_edid_property(connector, NULL); |
232 | verbose_prune = false; | |
233 | goto prune; | |
234 | } | |
235 | ||
0e8578c9 VS |
236 | if (connector->override_edid) { |
237 | struct edid *edid = (struct edid *) connector->edid_blob_ptr->data; | |
238 | ||
239 | count = drm_add_edid_modes(connector, edid); | |
240 | drm_edid_to_eld(connector, edid); | |
241 | } else { | |
8d754544 | 242 | #ifdef CONFIG_DRM_LOAD_EDID_FIRMWARE |
0e8578c9 VS |
243 | count = drm_load_edid_firmware(connector); |
244 | if (count == 0) | |
8d754544 | 245 | #endif |
4cf2b281 TW |
246 | count = (*connector_funcs->get_modes)(connector); |
247 | } | |
8d754544 DV |
248 | |
249 | if (count == 0 && connector->status == connector_status_connected) | |
250 | count = drm_add_modes_noedid(connector, 1024, 768); | |
eaf99c74 | 251 | count += drm_helper_probe_add_cmdline_mode(connector); |
8d754544 DV |
252 | if (count == 0) |
253 | goto prune; | |
254 | ||
6af3e656 | 255 | drm_mode_connector_list_update(connector); |
8d754544 | 256 | |
8d754544 DV |
257 | if (connector->interlace_allowed) |
258 | mode_flags |= DRM_MODE_FLAG_INTERLACE; | |
259 | if (connector->doublescan_allowed) | |
260 | mode_flags |= DRM_MODE_FLAG_DBLSCAN; | |
261 | if (connector->stereo_allowed) | |
262 | mode_flags |= DRM_MODE_FLAG_3D_MASK; | |
8d754544 DV |
263 | |
264 | list_for_each_entry(mode, &connector->modes, head) { | |
be8719a6 VS |
265 | if (mode->status == MODE_OK) |
266 | mode->status = drm_mode_validate_basic(mode); | |
abc0b144 VS |
267 | |
268 | if (mode->status == MODE_OK) | |
269 | mode->status = drm_mode_validate_size(mode, maxX, maxY); | |
05acaec3 VS |
270 | |
271 | if (mode->status == MODE_OK) | |
272 | mode->status = drm_mode_validate_flag(mode, mode_flags); | |
273 | ||
f9b0e251 | 274 | if (mode->status == MODE_OK && connector_funcs->mode_valid) |
8d754544 DV |
275 | mode->status = connector_funcs->mode_valid(connector, |
276 | mode); | |
277 | } | |
278 | ||
279 | prune: | |
280 | drm_mode_prune_invalid(dev, &connector->modes, verbose_prune); | |
281 | ||
282 | if (list_empty(&connector->modes)) | |
283 | return 0; | |
284 | ||
285 | list_for_each_entry(mode, &connector->modes, head) | |
286 | mode->vrefresh = drm_mode_vrefresh(mode); | |
287 | ||
288 | drm_mode_sort(&connector->modes); | |
289 | ||
290 | DRM_DEBUG_KMS("[CONNECTOR:%d:%s] probed modes :\n", connector->base.id, | |
25933820 | 291 | connector->name); |
8d754544 DV |
292 | list_for_each_entry(mode, &connector->modes, head) { |
293 | drm_mode_set_crtcinfo(mode, CRTC_INTERLACE_HALVE_V); | |
294 | drm_mode_debug_printmodeline(mode); | |
295 | } | |
296 | ||
297 | return count; | |
298 | } | |
299 | EXPORT_SYMBOL(drm_helper_probe_single_connector_modes); | |
300 | ||
301 | /** | |
302 | * drm_kms_helper_hotplug_event - fire off KMS hotplug events | |
303 | * @dev: drm_device whose connector state changed | |
304 | * | |
305 | * This function fires off the uevent for userspace and also calls the | |
306 | * output_poll_changed function, which is most commonly used to inform the fbdev | |
307 | * emulation code and allow it to update the fbcon output configuration. | |
308 | * | |
309 | * Drivers should call this from their hotplug handling code when a change is | |
310 | * detected. Note that this function does not do any output detection of its | |
311 | * own, like drm_helper_hpd_irq_event() does - this is assumed to be done by the | |
312 | * driver already. | |
313 | * | |
314 | * This function must be called from process context with no mode | |
315 | * setting locks held. | |
316 | */ | |
317 | void drm_kms_helper_hotplug_event(struct drm_device *dev) | |
318 | { | |
319 | /* send a uevent + call fbdev */ | |
320 | drm_sysfs_hotplug_event(dev); | |
321 | if (dev->mode_config.funcs->output_poll_changed) | |
322 | dev->mode_config.funcs->output_poll_changed(dev); | |
323 | } | |
324 | EXPORT_SYMBOL(drm_kms_helper_hotplug_event); | |
325 | ||
8d754544 DV |
326 | static void output_poll_execute(struct work_struct *work) |
327 | { | |
328 | struct delayed_work *delayed_work = to_delayed_work(work); | |
329 | struct drm_device *dev = container_of(delayed_work, struct drm_device, mode_config.output_poll_work); | |
330 | struct drm_connector *connector; | |
331 | enum drm_connector_status old_status; | |
162b6a57 DV |
332 | bool repoll = false, changed; |
333 | ||
334 | /* Pick up any changes detected by the probe functions. */ | |
335 | changed = dev->mode_config.delayed_event; | |
336 | dev->mode_config.delayed_event = false; | |
8d754544 DV |
337 | |
338 | if (!drm_kms_helper_poll) | |
162b6a57 | 339 | goto out; |
8d754544 DV |
340 | |
341 | mutex_lock(&dev->mode_config.mutex); | |
6295d607 | 342 | drm_for_each_connector(connector, dev) { |
8d754544 DV |
343 | |
344 | /* Ignore forced connectors. */ | |
345 | if (connector->force) | |
346 | continue; | |
347 | ||
348 | /* Ignore HPD capable connectors and connectors where we don't | |
349 | * want any hotplug detection at all for polling. */ | |
350 | if (!connector->polled || connector->polled == DRM_CONNECTOR_POLL_HPD) | |
351 | continue; | |
352 | ||
8d754544 DV |
353 | old_status = connector->status; |
354 | /* if we are connected and don't want to poll for disconnect | |
355 | skip it */ | |
356 | if (old_status == connector_status_connected && | |
357 | !(connector->polled & DRM_CONNECTOR_POLL_DISCONNECT)) | |
358 | continue; | |
359 | ||
a3c6d686 JH |
360 | repoll = true; |
361 | ||
8d754544 DV |
362 | connector->status = connector->funcs->detect(connector, false); |
363 | if (old_status != connector->status) { | |
364 | const char *old, *new; | |
365 | ||
b7703726 DV |
366 | /* |
367 | * The poll work sets force=false when calling detect so | |
368 | * that drivers can avoid to do disruptive tests (e.g. | |
369 | * when load detect cycles could cause flickering on | |
370 | * other, running displays). This bears the risk that we | |
371 | * flip-flop between unknown here in the poll work and | |
372 | * the real state when userspace forces a full detect | |
373 | * call after receiving a hotplug event due to this | |
374 | * change. | |
375 | * | |
376 | * Hence clamp an unknown detect status to the old | |
377 | * value. | |
378 | */ | |
379 | if (connector->status == connector_status_unknown) { | |
380 | connector->status = old_status; | |
381 | continue; | |
382 | } | |
383 | ||
8d754544 DV |
384 | old = drm_get_connector_status_name(old_status); |
385 | new = drm_get_connector_status_name(connector->status); | |
386 | ||
387 | DRM_DEBUG_KMS("[CONNECTOR:%d:%s] " | |
388 | "status updated from %s to %s\n", | |
389 | connector->base.id, | |
25933820 | 390 | connector->name, |
8d754544 DV |
391 | old, new); |
392 | ||
393 | changed = true; | |
394 | } | |
395 | } | |
396 | ||
397 | mutex_unlock(&dev->mode_config.mutex); | |
398 | ||
162b6a57 | 399 | out: |
8d754544 DV |
400 | if (changed) |
401 | drm_kms_helper_hotplug_event(dev); | |
402 | ||
403 | if (repoll) | |
404 | schedule_delayed_work(delayed_work, DRM_OUTPUT_POLL_PERIOD); | |
405 | } | |
406 | ||
407 | /** | |
408 | * drm_kms_helper_poll_disable - disable output polling | |
409 | * @dev: drm_device | |
410 | * | |
411 | * This function disables the output polling work. | |
412 | * | |
413 | * Drivers can call this helper from their device suspend implementation. It is | |
414 | * not an error to call this even when output polling isn't enabled or arlready | |
415 | * disabled. | |
416 | */ | |
417 | void drm_kms_helper_poll_disable(struct drm_device *dev) | |
418 | { | |
419 | if (!dev->mode_config.poll_enabled) | |
420 | return; | |
421 | cancel_delayed_work_sync(&dev->mode_config.output_poll_work); | |
422 | } | |
423 | EXPORT_SYMBOL(drm_kms_helper_poll_disable); | |
424 | ||
425 | /** | |
426 | * drm_kms_helper_poll_enable - re-enable output polling. | |
427 | * @dev: drm_device | |
428 | * | |
429 | * This function re-enables the output polling work. | |
430 | * | |
431 | * Drivers can call this helper from their device resume implementation. It is | |
432 | * an error to call this when the output polling support has not yet been set | |
433 | * up. | |
434 | */ | |
435 | void drm_kms_helper_poll_enable(struct drm_device *dev) | |
436 | { | |
8c4ccc4a | 437 | mutex_lock(&dev->mode_config.mutex); |
4ad640e9 | 438 | drm_kms_helper_poll_enable_locked(dev); |
8c4ccc4a | 439 | mutex_unlock(&dev->mode_config.mutex); |
8d754544 DV |
440 | } |
441 | EXPORT_SYMBOL(drm_kms_helper_poll_enable); | |
442 | ||
443 | /** | |
444 | * drm_kms_helper_poll_init - initialize and enable output polling | |
445 | * @dev: drm_device | |
446 | * | |
447 | * This function intializes and then also enables output polling support for | |
448 | * @dev. Drivers which do not have reliable hotplug support in hardware can use | |
449 | * this helper infrastructure to regularly poll such connectors for changes in | |
450 | * their connection state. | |
451 | * | |
452 | * Drivers can control which connectors are polled by setting the | |
453 | * DRM_CONNECTOR_POLL_CONNECT and DRM_CONNECTOR_POLL_DISCONNECT flags. On | |
454 | * connectors where probing live outputs can result in visual distortion drivers | |
455 | * should not set the DRM_CONNECTOR_POLL_DISCONNECT flag to avoid this. | |
456 | * Connectors which have no flag or only DRM_CONNECTOR_POLL_HPD set are | |
457 | * completely ignored by the polling logic. | |
458 | * | |
459 | * Note that a connector can be both polled and probed from the hotplug handler, | |
460 | * in case the hotplug interrupt is known to be unreliable. | |
461 | */ | |
462 | void drm_kms_helper_poll_init(struct drm_device *dev) | |
463 | { | |
464 | INIT_DELAYED_WORK(&dev->mode_config.output_poll_work, output_poll_execute); | |
465 | dev->mode_config.poll_enabled = true; | |
466 | ||
467 | drm_kms_helper_poll_enable(dev); | |
468 | } | |
469 | EXPORT_SYMBOL(drm_kms_helper_poll_init); | |
470 | ||
471 | /** | |
472 | * drm_kms_helper_poll_fini - disable output polling and clean it up | |
473 | * @dev: drm_device | |
474 | */ | |
475 | void drm_kms_helper_poll_fini(struct drm_device *dev) | |
476 | { | |
477 | drm_kms_helper_poll_disable(dev); | |
478 | } | |
479 | EXPORT_SYMBOL(drm_kms_helper_poll_fini); | |
480 | ||
481 | /** | |
482 | * drm_helper_hpd_irq_event - hotplug processing | |
483 | * @dev: drm_device | |
484 | * | |
485 | * Drivers can use this helper function to run a detect cycle on all connectors | |
486 | * which have the DRM_CONNECTOR_POLL_HPD flag set in their &polled member. All | |
487 | * other connectors are ignored, which is useful to avoid reprobing fixed | |
488 | * panels. | |
489 | * | |
490 | * This helper function is useful for drivers which can't or don't track hotplug | |
491 | * interrupts for each connector. | |
492 | * | |
493 | * Drivers which support hotplug interrupts for each connector individually and | |
494 | * which have a more fine-grained detect logic should bypass this code and | |
495 | * directly call drm_kms_helper_hotplug_event() in case the connector state | |
496 | * changed. | |
497 | * | |
498 | * This function must be called from process context with no mode | |
499 | * setting locks held. | |
500 | * | |
501 | * Note that a connector can be both polled and probed from the hotplug handler, | |
502 | * in case the hotplug interrupt is known to be unreliable. | |
503 | */ | |
504 | bool drm_helper_hpd_irq_event(struct drm_device *dev) | |
505 | { | |
506 | struct drm_connector *connector; | |
507 | enum drm_connector_status old_status; | |
508 | bool changed = false; | |
509 | ||
510 | if (!dev->mode_config.poll_enabled) | |
511 | return false; | |
512 | ||
513 | mutex_lock(&dev->mode_config.mutex); | |
6295d607 | 514 | drm_for_each_connector(connector, dev) { |
8d754544 DV |
515 | |
516 | /* Only handle HPD capable connectors. */ | |
517 | if (!(connector->polled & DRM_CONNECTOR_POLL_HPD)) | |
518 | continue; | |
519 | ||
520 | old_status = connector->status; | |
521 | ||
522 | connector->status = connector->funcs->detect(connector, false); | |
523 | DRM_DEBUG_KMS("[CONNECTOR:%d:%s] status updated from %s to %s\n", | |
524 | connector->base.id, | |
25933820 | 525 | connector->name, |
8d754544 DV |
526 | drm_get_connector_status_name(old_status), |
527 | drm_get_connector_status_name(connector->status)); | |
528 | if (old_status != connector->status) | |
529 | changed = true; | |
530 | } | |
531 | ||
532 | mutex_unlock(&dev->mode_config.mutex); | |
533 | ||
534 | if (changed) | |
535 | drm_kms_helper_hotplug_event(dev); | |
536 | ||
537 | return changed; | |
538 | } | |
539 | EXPORT_SYMBOL(drm_helper_hpd_irq_event); |