drm/crtc-helper: remove LOCKING from kerneldoc
[deliverable/linux.git] / drivers / gpu / drm / drm_crtc_helper.c
CommitLineData
f453ba04
DA
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
2d1a8a48 32#include <linux/export.h>
0603ba14 33#include <linux/moduleparam.h>
2d1a8a48 34
760285e7
DH
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>
f453ba04 41
92b6f89f
DV
42MODULE_AUTHOR("David Airlie, Jesse Barnes");
43MODULE_DESCRIPTION("DRM KMS helper");
44MODULE_LICENSE("GPL and additional rights");
45
0d4ed4c8
DV
46/**
47 * drm_helper_move_panel_connectors_to_head() - move panels to the front in the
48 * connector list
49 * @dev: drm device to operate on
50 *
51 * Some userspace presumes that the first connected connector is the main
52 * display, where it's supposed to display e.g. the login screen. For
53 * laptops, this should be the main panel. Use this function to sort all
54 * (eDP/LVDS) panels to the front of the connector list, instead of
55 * painstakingly trying to initialize them in the right order.
56 */
cfc1a062
DV
57void drm_helper_move_panel_connectors_to_head(struct drm_device *dev)
58{
59 struct drm_connector *connector, *tmp;
60 struct list_head panel_list;
61
62 INIT_LIST_HEAD(&panel_list);
63
64 list_for_each_entry_safe(connector, tmp,
65 &dev->mode_config.connector_list, head) {
66 if (connector->connector_type == DRM_MODE_CONNECTOR_LVDS ||
67 connector->connector_type == DRM_MODE_CONNECTOR_eDP)
68 list_move_tail(&connector->head, &panel_list);
69 }
70
71 list_splice(&panel_list, &dev->mode_config.connector_list);
72}
73EXPORT_SYMBOL(drm_helper_move_panel_connectors_to_head);
74
e58f637b
CW
75static bool drm_kms_helper_poll = true;
76module_param_named(poll, drm_kms_helper_poll, bool, 0600);
77
6714977b 78static void drm_mode_validate_flag(struct drm_connector *connector,
79 int flags)
80{
a1178ca0 81 struct drm_display_mode *mode;
6714977b 82
560a067a
DL
83 if (flags == (DRM_MODE_FLAG_DBLSCAN | DRM_MODE_FLAG_INTERLACE |
84 DRM_MODE_FLAG_3D_MASK))
6714977b 85 return;
86
a1178ca0 87 list_for_each_entry(mode, &connector->modes, head) {
6714977b 88 if ((mode->flags & DRM_MODE_FLAG_INTERLACE) &&
89 !(flags & DRM_MODE_FLAG_INTERLACE))
90 mode->status = MODE_NO_INTERLACE;
91 if ((mode->flags & DRM_MODE_FLAG_DBLSCAN) &&
92 !(flags & DRM_MODE_FLAG_DBLSCAN))
93 mode->status = MODE_NO_DBLESCAN;
560a067a
DL
94 if ((mode->flags & DRM_MODE_FLAG_3D_MASK) &&
95 !(flags & DRM_MODE_FLAG_3D_MASK))
96 mode->status = MODE_NO_STEREO;
6714977b 97 }
98
99 return;
100}
101
f453ba04 102/**
38651674 103 * drm_helper_probe_single_connector_modes - get complete set of display modes
0d4ed4c8 104 * @connector: connector to probe
f453ba04
DA
105 * @maxX: max width for modes
106 * @maxY: max height for modes
107 *
0d4ed4c8
DV
108 * Based on the helper callbacks implemented by @connector try to detect all
109 * valid modes. Modes will first be added to the connector's probed_modes list,
110 * then culled (based on validity and the @maxX, @maxY parameters) and put into
111 * the normal modes list.
f453ba04 112 *
1eee814d
LD
113 * Intended to be use as a generic implementation of the ->fill_modes()
114 * @connector vfunc for drivers that use the crtc helpers for output mode
115 * filtering and detection.
40a518d9
JB
116 *
117 * RETURNS:
118 * Number of modes found on @connector.
f453ba04 119 */
40a518d9
JB
120int drm_helper_probe_single_connector_modes(struct drm_connector *connector,
121 uint32_t maxX, uint32_t maxY)
f453ba04
DA
122{
123 struct drm_device *dev = connector->dev;
a1178ca0 124 struct drm_display_mode *mode;
f453ba04
DA
125 struct drm_connector_helper_funcs *connector_funcs =
126 connector->helper_private;
40a518d9 127 int count = 0;
6714977b 128 int mode_flags = 0;
ebbd97ad 129 bool verbose_prune = true;
f453ba04 130
62ff94a5
DV
131 WARN_ON(!mutex_is_locked(&dev->mode_config.mutex));
132
9440106b
JG
133 DRM_DEBUG_KMS("[CONNECTOR:%d:%s]\n", connector->base.id,
134 drm_get_connector_name(connector));
f453ba04 135 /* set all modes to the unverified state */
a1178ca0 136 list_for_each_entry(mode, &connector->modes, head)
f453ba04
DA
137 mode->status = MODE_UNVERIFIED;
138
d50ba256
DA
139 if (connector->force) {
140 if (connector->force == DRM_FORCE_ON)
141 connector->status = connector_status_connected;
142 else
143 connector->status = connector_status_disconnected;
144 if (connector->funcs->force)
145 connector->funcs->force(connector);
e58f637b 146 } else {
930a9e28 147 connector->status = connector->funcs->detect(connector, true);
e58f637b 148 }
f453ba04 149
905bc9ff
DV
150 /* Re-enable polling in case the global poll config changed. */
151 if (drm_kms_helper_poll != dev->mode_config.poll_running)
152 drm_kms_helper_poll_enable(dev);
153
154 dev->mode_config.poll_running = drm_kms_helper_poll;
155
f453ba04 156 if (connector->status == connector_status_disconnected) {
9440106b
JG
157 DRM_DEBUG_KMS("[CONNECTOR:%d:%s] disconnected\n",
158 connector->base.id, drm_get_connector_name(connector));
72539832 159 drm_mode_connector_update_edid_property(connector, NULL);
ebbd97ad 160 verbose_prune = false;
620f3781 161 goto prune;
f453ba04
DA
162 }
163
da0df92b
CE
164#ifdef CONFIG_DRM_LOAD_EDID_FIRMWARE
165 count = drm_load_edid_firmware(connector);
166 if (count == 0)
167#endif
168 count = (*connector_funcs->get_modes)(connector);
169
c7ef35a9 170 if (count == 0 && connector->status == connector_status_connected)
9632b41f 171 count = drm_add_modes_noedid(connector, 1024, 768);
c7ef35a9
CW
172 if (count == 0)
173 goto prune;
f453ba04 174
40a518d9 175 drm_mode_connector_list_update(connector);
f453ba04
DA
176
177 if (maxX && maxY)
3e70292c 178 drm_mode_validate_size(dev, &connector->modes, maxX, maxY);
6714977b 179
180 if (connector->interlace_allowed)
181 mode_flags |= DRM_MODE_FLAG_INTERLACE;
182 if (connector->doublescan_allowed)
183 mode_flags |= DRM_MODE_FLAG_DBLSCAN;
560a067a
DL
184 if (connector->stereo_allowed)
185 mode_flags |= DRM_MODE_FLAG_3D_MASK;
6714977b 186 drm_mode_validate_flag(connector, mode_flags);
187
a1178ca0 188 list_for_each_entry(mode, &connector->modes, head) {
f453ba04
DA
189 if (mode->status == MODE_OK)
190 mode->status = connector_funcs->mode_valid(connector,
191 mode);
192 }
193
620f3781 194prune:
ebbd97ad 195 drm_mode_prune_invalid(dev, &connector->modes, verbose_prune);
f453ba04 196
40a518d9
JB
197 if (list_empty(&connector->modes))
198 return 0;
f453ba04 199
9bc3cd56
VS
200 list_for_each_entry(mode, &connector->modes, head)
201 mode->vrefresh = drm_mode_vrefresh(mode);
202
f453ba04
DA
203 drm_mode_sort(&connector->modes);
204
9440106b
JG
205 DRM_DEBUG_KMS("[CONNECTOR:%d:%s] probed modes :\n", connector->base.id,
206 drm_get_connector_name(connector));
a1178ca0 207 list_for_each_entry(mode, &connector->modes, head) {
f453ba04
DA
208 drm_mode_set_crtcinfo(mode, CRTC_INTERLACE_HALVE_V);
209 drm_mode_debug_printmodeline(mode);
210 }
40a518d9
JB
211
212 return count;
f453ba04
DA
213}
214EXPORT_SYMBOL(drm_helper_probe_single_connector_modes);
215
c9fb15f6
KP
216/**
217 * drm_helper_encoder_in_use - check if a given encoder is in use
218 * @encoder: encoder to check
219 *
c9fb15f6
KP
220 * Walk @encoders's DRM device's mode_config and see if it's in use.
221 *
222 * RETURNS:
223 * True if @encoder is part of the mode_config, false otherwise.
224 */
225bool drm_helper_encoder_in_use(struct drm_encoder *encoder)
226{
227 struct drm_connector *connector;
228 struct drm_device *dev = encoder->dev;
62ff94a5
DV
229
230 WARN_ON(!mutex_is_locked(&dev->mode_config.mutex));
c9fb15f6
KP
231 list_for_each_entry(connector, &dev->mode_config.connector_list, head)
232 if (connector->encoder == encoder)
233 return true;
234 return false;
235}
236EXPORT_SYMBOL(drm_helper_encoder_in_use);
237
f453ba04
DA
238/**
239 * drm_helper_crtc_in_use - check if a given CRTC is in a mode_config
240 * @crtc: CRTC to check
241 *
f453ba04
DA
242 * Walk @crtc's DRM device's mode_config and see if it's in use.
243 *
244 * RETURNS:
245 * True if @crtc is part of the mode_config, false otherwise.
246 */
247bool drm_helper_crtc_in_use(struct drm_crtc *crtc)
248{
249 struct drm_encoder *encoder;
250 struct drm_device *dev = crtc->dev;
62ff94a5
DV
251
252 WARN_ON(!mutex_is_locked(&dev->mode_config.mutex));
f453ba04 253 list_for_each_entry(encoder, &dev->mode_config.encoder_list, head)
c9fb15f6 254 if (encoder->crtc == crtc && drm_helper_encoder_in_use(encoder))
f453ba04
DA
255 return true;
256 return false;
257}
258EXPORT_SYMBOL(drm_helper_crtc_in_use);
259
86a1b9d1
BS
260static void
261drm_encoder_disable(struct drm_encoder *encoder)
262{
263 struct drm_encoder_helper_funcs *encoder_funcs = encoder->helper_private;
264
3b336ec4
SP
265 if (encoder->bridge)
266 encoder->bridge->funcs->disable(encoder->bridge);
267
86a1b9d1
BS
268 if (encoder_funcs->disable)
269 (*encoder_funcs->disable)(encoder);
270 else
271 (*encoder_funcs->dpms)(encoder, DRM_MODE_DPMS_OFF);
3b336ec4
SP
272
273 if (encoder->bridge)
274 encoder->bridge->funcs->post_disable(encoder->bridge);
86a1b9d1
BS
275}
276
f453ba04 277/**
89347bb8 278 * drm_helper_disable_unused_functions - disable unused objects
f453ba04
DA
279 * @dev: DRM device
280 *
f453ba04
DA
281 * If an connector or CRTC isn't part of @dev's mode_config, it can be disabled
282 * by calling its dpms function, which should power it off.
283 */
284void drm_helper_disable_unused_functions(struct drm_device *dev)
285{
286 struct drm_encoder *encoder;
a3a0544b 287 struct drm_connector *connector;
f453ba04
DA
288 struct drm_crtc *crtc;
289
62ff94a5
DV
290 drm_warn_on_modeset_not_all_locked(dev);
291
a3a0544b
DA
292 list_for_each_entry(connector, &dev->mode_config.connector_list, head) {
293 if (!connector->encoder)
294 continue;
295 if (connector->status == connector_status_disconnected)
296 connector->encoder = NULL;
297 }
298
f453ba04 299 list_for_each_entry(encoder, &dev->mode_config.encoder_list, head) {
92971021 300 if (!drm_helper_encoder_in_use(encoder)) {
86a1b9d1 301 drm_encoder_disable(encoder);
9c552dd7
DA
302 /* disconnector encoder from any connector */
303 encoder->crtc = NULL;
a3a0544b 304 }
f453ba04
DA
305 }
306
307 list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) {
308 struct drm_crtc_helper_funcs *crtc_funcs = crtc->helper_private;
309 crtc->enabled = drm_helper_crtc_in_use(crtc);
310 if (!crtc->enabled) {
5c8d7171
AD
311 if (crtc_funcs->disable)
312 (*crtc_funcs->disable)(crtc);
313 else
314 (*crtc_funcs->dpms)(crtc, DRM_MODE_DPMS_OFF);
f453ba04
DA
315 crtc->fb = NULL;
316 }
317 }
318}
319EXPORT_SYMBOL(drm_helper_disable_unused_functions);
320
7bec756c
JB
321/*
322 * Check the CRTC we're going to map each output to vs. its current
323 * CRTC. If they don't match, we have to disable the output and the CRTC
324 * since the driver will have to re-route things.
325 */
326static void
327drm_crtc_prepare_encoders(struct drm_device *dev)
328{
329 struct drm_encoder_helper_funcs *encoder_funcs;
330 struct drm_encoder *encoder;
331
332 list_for_each_entry(encoder, &dev->mode_config.encoder_list, head) {
333 encoder_funcs = encoder->helper_private;
334 /* Disable unused encoders */
335 if (encoder->crtc == NULL)
86a1b9d1 336 drm_encoder_disable(encoder);
7bec756c
JB
337 /* Disable encoders whose CRTC is about to change */
338 if (encoder_funcs->get_crtc &&
339 encoder->crtc != (*encoder_funcs->get_crtc)(encoder))
86a1b9d1 340 drm_encoder_disable(encoder);
7bec756c
JB
341 }
342}
343
f453ba04 344/**
0d4ed4c8 345 * drm_crtc_helper_set_mode - internal helper to set a mode
f453ba04
DA
346 * @crtc: CRTC to program
347 * @mode: mode to use
4c9287c6
AD
348 * @x: horizontal offset into the surface
349 * @y: vertical offset into the surface
0d4ed4c8 350 * @old_fb: old framebuffer, for cleanup
f453ba04 351 *
f453ba04 352 * Try to set @mode on @crtc. Give @crtc and its associated connectors a chance
0d4ed4c8
DV
353 * to fixup or reject the mode prior to trying to set it. This is an internal
354 * helper that drivers could e.g. use to update properties that require the
355 * entire output pipe to be disabled and re-enabled in a new configuration. For
356 * example for changing whether audio is enabled on a hdmi link or for changing
357 * panel fitter or dither attributes. It is also called by the
358 * drm_crtc_helper_set_config() helper function to drive the mode setting
359 * sequence.
f453ba04
DA
360 *
361 * RETURNS:
362 * True if the mode was set successfully, or false otherwise.
363 */
364bool drm_crtc_helper_set_mode(struct drm_crtc *crtc,
365 struct drm_display_mode *mode,
3c4fdcfb
KH
366 int x, int y,
367 struct drm_framebuffer *old_fb)
f453ba04
DA
368{
369 struct drm_device *dev = crtc->dev;
7e99acdc 370 struct drm_display_mode *adjusted_mode, saved_mode;
f453ba04
DA
371 struct drm_crtc_helper_funcs *crtc_funcs = crtc->helper_private;
372 struct drm_encoder_helper_funcs *encoder_funcs;
373 int saved_x, saved_y;
7e99acdc 374 bool saved_enabled;
f453ba04
DA
375 struct drm_encoder *encoder;
376 bool ret = true;
377
62ff94a5
DV
378 drm_warn_on_modeset_not_all_locked(dev);
379
7e99acdc 380 saved_enabled = crtc->enabled;
f453ba04 381 crtc->enabled = drm_helper_crtc_in_use(crtc);
f453ba04
DA
382 if (!crtc->enabled)
383 return true;
384
021a8455 385 adjusted_mode = drm_mode_duplicate(dev, mode);
7e99acdc
IH
386 if (!adjusted_mode) {
387 crtc->enabled = saved_enabled;
6bfc56aa 388 return false;
7e99acdc 389 }
021a8455 390
f453ba04
DA
391 saved_mode = crtc->mode;
392 saved_x = crtc->x;
393 saved_y = crtc->y;
394
395 /* Update crtc values up front so the driver can rely on them for mode
396 * setting.
397 */
398 crtc->mode = *mode;
399 crtc->x = x;
400 crtc->y = y;
401
f453ba04
DA
402 /* Pass our mode to the connectors and the CRTC to give them a chance to
403 * adjust it according to limitations or connector properties, and also
404 * a chance to reject the mode entirely.
405 */
406 list_for_each_entry(encoder, &dev->mode_config.encoder_list, head) {
407
408 if (encoder->crtc != crtc)
409 continue;
3b336ec4
SP
410
411 if (encoder->bridge && encoder->bridge->funcs->mode_fixup) {
412 ret = encoder->bridge->funcs->mode_fixup(
413 encoder->bridge, mode, adjusted_mode);
414 if (!ret) {
415 DRM_DEBUG_KMS("Bridge fixup failed\n");
416 goto done;
417 }
418 }
419
f453ba04
DA
420 encoder_funcs = encoder->helper_private;
421 if (!(ret = encoder_funcs->mode_fixup(encoder, mode,
422 adjusted_mode))) {
836e53d7 423 DRM_DEBUG_KMS("Encoder fixup failed\n");
f453ba04
DA
424 goto done;
425 }
426 }
427
428 if (!(ret = crtc_funcs->mode_fixup(crtc, mode, adjusted_mode))) {
836e53d7 429 DRM_DEBUG_KMS("CRTC fixup failed\n");
f453ba04
DA
430 goto done;
431 }
9440106b 432 DRM_DEBUG_KMS("[CRTC:%d]\n", crtc->base.id);
f453ba04
DA
433
434 /* Prepare the encoders and CRTCs before setting the mode. */
435 list_for_each_entry(encoder, &dev->mode_config.encoder_list, head) {
436
437 if (encoder->crtc != crtc)
438 continue;
3b336ec4
SP
439
440 if (encoder->bridge)
441 encoder->bridge->funcs->disable(encoder->bridge);
442
f453ba04
DA
443 encoder_funcs = encoder->helper_private;
444 /* Disable the encoders as the first thing we do. */
445 encoder_funcs->prepare(encoder);
3b336ec4
SP
446
447 if (encoder->bridge)
448 encoder->bridge->funcs->post_disable(encoder->bridge);
f453ba04
DA
449 }
450
7bec756c
JB
451 drm_crtc_prepare_encoders(dev);
452
f453ba04
DA
453 crtc_funcs->prepare(crtc);
454
455 /* Set up the DPLL and any encoders state that needs to adjust or depend
456 * on the DPLL.
457 */
5c3b82e2
CW
458 ret = !crtc_funcs->mode_set(crtc, mode, adjusted_mode, x, y, old_fb);
459 if (!ret)
460 goto done;
f453ba04
DA
461
462 list_for_each_entry(encoder, &dev->mode_config.encoder_list, head) {
463
464 if (encoder->crtc != crtc)
465 continue;
466
9440106b
JG
467 DRM_DEBUG_KMS("[ENCODER:%d:%s] set [MODE:%d:%s]\n",
468 encoder->base.id, drm_get_encoder_name(encoder),
469 mode->base.id, mode->name);
f453ba04
DA
470 encoder_funcs = encoder->helper_private;
471 encoder_funcs->mode_set(encoder, mode, adjusted_mode);
3b336ec4
SP
472
473 if (encoder->bridge && encoder->bridge->funcs->mode_set)
474 encoder->bridge->funcs->mode_set(encoder->bridge, mode,
475 adjusted_mode);
f453ba04
DA
476 }
477
478 /* Now enable the clocks, plane, pipe, and connectors that we set up. */
479 crtc_funcs->commit(crtc);
480
481 list_for_each_entry(encoder, &dev->mode_config.encoder_list, head) {
482
483 if (encoder->crtc != crtc)
484 continue;
485
3b336ec4
SP
486 if (encoder->bridge)
487 encoder->bridge->funcs->pre_enable(encoder->bridge);
488
f453ba04
DA
489 encoder_funcs = encoder->helper_private;
490 encoder_funcs->commit(encoder);
491
3b336ec4
SP
492 if (encoder->bridge)
493 encoder->bridge->funcs->enable(encoder->bridge);
f453ba04
DA
494 }
495
27641c3f
MK
496 /* Store real post-adjustment hardware mode. */
497 crtc->hwmode = *adjusted_mode;
498
499 /* Calculate and store various constants which
500 * are later needed by vblank and swap-completion
501 * timestamping. They are derived from true hwmode.
502 */
545cdd55 503 drm_calc_timestamping_constants(crtc, &crtc->hwmode);
27641c3f 504
f453ba04
DA
505 /* FIXME: add subpixel order */
506done:
021a8455 507 drm_mode_destroy(dev, adjusted_mode);
f453ba04 508 if (!ret) {
7e99acdc 509 crtc->enabled = saved_enabled;
f453ba04
DA
510 crtc->mode = saved_mode;
511 crtc->x = saved_x;
512 crtc->y = saved_y;
513 }
514
515 return ret;
516}
517EXPORT_SYMBOL(drm_crtc_helper_set_mode);
518
519
6eebd6bb
CW
520static int
521drm_crtc_helper_disable(struct drm_crtc *crtc)
522{
523 struct drm_device *dev = crtc->dev;
524 struct drm_connector *connector;
525 struct drm_encoder *encoder;
526
527 /* Decouple all encoders and their attached connectors from this crtc */
528 list_for_each_entry(encoder, &dev->mode_config.encoder_list, head) {
529 if (encoder->crtc != crtc)
530 continue;
531
532 list_for_each_entry(connector, &dev->mode_config.connector_list, head) {
533 if (connector->encoder != encoder)
534 continue;
535
536 connector->encoder = NULL;
a6ad6230
TR
537
538 /*
539 * drm_helper_disable_unused_functions() ought to be
540 * doing this, but since we've decoupled the encoder
541 * from the connector above, the required connection
542 * between them is henceforth no longer available.
543 */
544 connector->dpms = DRM_MODE_DPMS_OFF;
6eebd6bb
CW
545 }
546 }
547
548 drm_helper_disable_unused_functions(dev);
549 return 0;
550}
551
f453ba04
DA
552/**
553 * drm_crtc_helper_set_config - set a new config from userspace
0d4ed4c8 554 * @set: mode set configuration
f453ba04 555 *
0d4ed4c8
DV
556 * Setup a new configuration, provided by the upper layers (either an ioctl call
557 * from userspace or internally e.g. from the fbdev suppport code) in @set, and
558 * enable it. This is the main helper functions for drivers that implement
559 * kernel mode setting with the crtc helper functions and the assorted
560 * ->prepare(), ->modeset() and ->commit() helper callbacks.
f453ba04
DA
561 *
562 * RETURNS:
0d4ed4c8 563 * Returns 0 on success, -ERRNO on failure.
f453ba04
DA
564 */
565int drm_crtc_helper_set_config(struct drm_mode_set *set)
566{
567 struct drm_device *dev;
02ee4e94 568 struct drm_crtc *new_crtc;
e67aae79 569 struct drm_encoder *save_encoders, *new_encoder, *encoder;
4cb72b17
JB
570 bool mode_changed = false; /* if true do a full mode set */
571 bool fb_changed = false; /* if true and !mode_changed just do a flip */
e67aae79 572 struct drm_connector *save_connectors, *connector;
f453ba04
DA
573 int count = 0, ro, fail = 0;
574 struct drm_crtc_helper_funcs *crtc_funcs;
c5006cfe 575 struct drm_mode_set save_set;
4a1b0714 576 int ret;
bf9dc102 577 int i;
f453ba04 578
58367ed6 579 DRM_DEBUG_KMS("\n");
f453ba04 580
e58de880
DV
581 BUG_ON(!set);
582 BUG_ON(!set->crtc);
583 BUG_ON(!set->crtc->helper_private);
f453ba04 584
e58de880
DV
585 /* Enforce sane interface api - has been abused by the fb helper. */
586 BUG_ON(!set->mode && set->fb);
587 BUG_ON(set->fb && set->num_connectors == 0);
f453ba04
DA
588
589 crtc_funcs = set->crtc->helper_private;
590
ede3ff52
CW
591 if (!set->mode)
592 set->fb = NULL;
593
9440106b
JG
594 if (set->fb) {
595 DRM_DEBUG_KMS("[CRTC:%d] [FB:%d] #connectors=%d (x y) (%i %i)\n",
596 set->crtc->base.id, set->fb->base.id,
597 (int)set->num_connectors, set->x, set->y);
598 } else {
ede3ff52 599 DRM_DEBUG_KMS("[CRTC:%d] [NOFB]\n", set->crtc->base.id);
6eebd6bb 600 return drm_crtc_helper_disable(set->crtc);
9440106b 601 }
f453ba04
DA
602
603 dev = set->crtc->dev;
604
62ff94a5
DV
605 drm_warn_on_modeset_not_all_locked(dev);
606
02ee4e94
IH
607 /*
608 * Allocate space for the backup of all (non-pointer) encoder and
609 * connector data.
610 */
e67aae79
MM
611 save_encoders = kzalloc(dev->mode_config.num_encoder *
612 sizeof(struct drm_encoder), GFP_KERNEL);
02ee4e94 613 if (!save_encoders)
f453ba04 614 return -ENOMEM;
f453ba04 615
e67aae79
MM
616 save_connectors = kzalloc(dev->mode_config.num_connector *
617 sizeof(struct drm_connector), GFP_KERNEL);
618 if (!save_connectors) {
e67aae79
MM
619 kfree(save_encoders);
620 return -ENOMEM;
621 }
622
02ee4e94
IH
623 /*
624 * Copy data. Note that driver private data is not affected.
e67aae79
MM
625 * Should anything bad happen only the expected state is
626 * restored, not the drivers personal bookkeeping.
627 */
e67aae79
MM
628 count = 0;
629 list_for_each_entry(encoder, &dev->mode_config.encoder_list, head) {
630 save_encoders[count++] = *encoder;
631 }
632
633 count = 0;
634 list_for_each_entry(connector, &dev->mode_config.connector_list, head) {
635 save_connectors[count++] = *connector;
636 }
637
c5006cfe
JB
638 save_set.crtc = set->crtc;
639 save_set.mode = &set->crtc->mode;
640 save_set.x = set->crtc->x;
641 save_set.y = set->crtc->y;
642 save_set.fb = set->crtc->fb;
643
f453ba04
DA
644 /* We should be able to check here if the fb has the same properties
645 * and then just flip_or_move it */
646 if (set->crtc->fb != set->fb) {
712531bf 647 /* If we have no fb then treat it as a full mode set */
7bec756c 648 if (set->crtc->fb == NULL) {
58367ed6 649 DRM_DEBUG_KMS("crtc has no fb, full mode set\n");
712531bf 650 mode_changed = true;
4cb72b17
JB
651 } else if (set->fb == NULL) {
652 mode_changed = true;
ce83adf7
LP
653 } else if (set->fb->pixel_format !=
654 set->crtc->fb->pixel_format) {
655 mode_changed = true;
8dff4742 656 } else
712531bf 657 fb_changed = true;
f453ba04
DA
658 }
659
660 if (set->x != set->crtc->x || set->y != set->crtc->y)
712531bf 661 fb_changed = true;
f453ba04
DA
662
663 if (set->mode && !drm_mode_equal(set->mode, &set->crtc->mode)) {
58367ed6 664 DRM_DEBUG_KMS("modes are different, full mode set\n");
f453ba04
DA
665 drm_mode_debug_printmodeline(&set->crtc->mode);
666 drm_mode_debug_printmodeline(set->mode);
712531bf 667 mode_changed = true;
f453ba04
DA
668 }
669
670 /* a) traverse passed in connector list and get encoders for them */
671 count = 0;
672 list_for_each_entry(connector, &dev->mode_config.connector_list, head) {
673 struct drm_connector_helper_funcs *connector_funcs =
674 connector->helper_private;
f453ba04
DA
675 new_encoder = connector->encoder;
676 for (ro = 0; ro < set->num_connectors; ro++) {
677 if (set->connectors[ro] == connector) {
678 new_encoder = connector_funcs->best_encoder(connector);
679 /* if we can't get an encoder for a connector
680 we are setting now - then fail */
681 if (new_encoder == NULL)
682 /* don't break so fail path works correct */
683 fail = 1;
684 break;
25f397a4
DV
685
686 if (connector->dpms != DRM_MODE_DPMS_ON) {
687 DRM_DEBUG_KMS("connector dpms not on, full mode switch\n");
688 mode_changed = true;
689 }
f453ba04
DA
690 }
691 }
692
693 if (new_encoder != connector->encoder) {
58367ed6 694 DRM_DEBUG_KMS("encoder changed, full mode switch\n");
712531bf 695 mode_changed = true;
ff846ab7
MM
696 /* If the encoder is reused for another connector, then
697 * the appropriate crtc will be set later.
698 */
ff6fdbed
MM
699 if (connector->encoder)
700 connector->encoder->crtc = NULL;
f453ba04
DA
701 connector->encoder = new_encoder;
702 }
703 }
704
705 if (fail) {
706 ret = -EINVAL;
e67aae79 707 goto fail;
f453ba04
DA
708 }
709
710 count = 0;
711 list_for_each_entry(connector, &dev->mode_config.connector_list, head) {
712 if (!connector->encoder)
713 continue;
714
f453ba04
DA
715 if (connector->encoder->crtc == set->crtc)
716 new_crtc = NULL;
717 else
718 new_crtc = connector->encoder->crtc;
719
720 for (ro = 0; ro < set->num_connectors; ro++) {
721 if (set->connectors[ro] == connector)
722 new_crtc = set->crtc;
723 }
7bec756c
JB
724
725 /* Make sure the new CRTC will work with the encoder */
726 if (new_crtc &&
727 !drm_encoder_crtc_ok(connector->encoder, new_crtc)) {
728 ret = -EINVAL;
e67aae79 729 goto fail;
7bec756c 730 }
f453ba04 731 if (new_crtc != connector->encoder->crtc) {
58367ed6 732 DRM_DEBUG_KMS("crtc changed, full mode switch\n");
712531bf 733 mode_changed = true;
f453ba04
DA
734 connector->encoder->crtc = new_crtc;
735 }
9440106b
JG
736 if (new_crtc) {
737 DRM_DEBUG_KMS("[CONNECTOR:%d:%s] to [CRTC:%d]\n",
738 connector->base.id, drm_get_connector_name(connector),
739 new_crtc->base.id);
740 } else {
741 DRM_DEBUG_KMS("[CONNECTOR:%d:%s] to [NOCRTC]\n",
742 connector->base.id, drm_get_connector_name(connector));
743 }
f453ba04
DA
744 }
745
746 /* mode_set_base is not a required function */
712531bf
JB
747 if (fb_changed && !crtc_funcs->mode_set_base)
748 mode_changed = true;
f453ba04 749
712531bf 750 if (mode_changed) {
48b1f5dd 751 if (drm_helper_crtc_in_use(set->crtc)) {
58367ed6
ZY
752 DRM_DEBUG_KMS("attempting to set mode from"
753 " userspace\n");
f453ba04 754 drm_mode_debug_printmodeline(set->mode);
356ad3cd 755 set->crtc->fb = set->fb;
f453ba04 756 if (!drm_crtc_helper_set_mode(set->crtc, set->mode,
3c4fdcfb 757 set->x, set->y,
bec2eac3 758 save_set.fb)) {
9440106b
JG
759 DRM_ERROR("failed to set mode on [CRTC:%d]\n",
760 set->crtc->base.id);
bec2eac3 761 set->crtc->fb = save_set.fb;
f453ba04 762 ret = -EINVAL;
e67aae79 763 goto fail;
f453ba04 764 }
25f397a4
DV
765 DRM_DEBUG_KMS("Setting connector DPMS state to on\n");
766 for (i = 0; i < set->num_connectors; i++) {
767 DRM_DEBUG_KMS("\t[CONNECTOR:%d:%s] set DPMS on\n", set->connectors[i]->base.id,
768 drm_get_connector_name(set->connectors[i]));
769 set->connectors[i]->funcs->dpms(set->connectors[i], DRM_MODE_DPMS_ON);
770 }
f453ba04
DA
771 }
772 drm_helper_disable_unused_functions(dev);
712531bf 773 } else if (fb_changed) {
9b1596af
BS
774 set->crtc->x = set->x;
775 set->crtc->y = set->y;
fc50a890 776 set->crtc->fb = set->fb;
5c3b82e2 777 ret = crtc_funcs->mode_set_base(set->crtc,
bec2eac3 778 set->x, set->y, save_set.fb);
0ba41e44 779 if (ret != 0) {
fbce4064
IH
780 set->crtc->x = save_set.x;
781 set->crtc->y = save_set.y;
bec2eac3 782 set->crtc->fb = save_set.fb;
e67aae79 783 goto fail;
0ba41e44 784 }
f453ba04
DA
785 }
786
e67aae79 787 kfree(save_connectors);
f453ba04 788 kfree(save_encoders);
f453ba04
DA
789 return 0;
790
e67aae79
MM
791fail:
792 /* Restore all previous data. */
e67aae79
MM
793 count = 0;
794 list_for_each_entry(encoder, &dev->mode_config.encoder_list, head) {
795 *encoder = save_encoders[count++];
e62fb64e 796 }
e67aae79 797
f453ba04
DA
798 count = 0;
799 list_for_each_entry(connector, &dev->mode_config.connector_list, head) {
e67aae79 800 *connector = save_connectors[count++];
f453ba04 801 }
e67aae79 802
c5006cfe
JB
803 /* Try to restore the config */
804 if (mode_changed &&
805 !drm_crtc_helper_set_mode(save_set.crtc, save_set.mode, save_set.x,
806 save_set.y, save_set.fb))
807 DRM_ERROR("failed to restore config after modeset failure\n");
808
e67aae79 809 kfree(save_connectors);
f453ba04
DA
810 kfree(save_encoders);
811 return ret;
812}
813EXPORT_SYMBOL(drm_crtc_helper_set_config);
814
c9fb15f6
KP
815static int drm_helper_choose_encoder_dpms(struct drm_encoder *encoder)
816{
817 int dpms = DRM_MODE_DPMS_OFF;
818 struct drm_connector *connector;
819 struct drm_device *dev = encoder->dev;
820
821 list_for_each_entry(connector, &dev->mode_config.connector_list, head)
822 if (connector->encoder == encoder)
823 if (connector->dpms < dpms)
824 dpms = connector->dpms;
825 return dpms;
826}
827
3b336ec4
SP
828/* Helper which handles bridge ordering around encoder dpms */
829static void drm_helper_encoder_dpms(struct drm_encoder *encoder, int mode)
830{
831 struct drm_bridge *bridge = encoder->bridge;
832 struct drm_encoder_helper_funcs *encoder_funcs;
833
834 if (bridge) {
835 if (mode == DRM_MODE_DPMS_ON)
836 bridge->funcs->pre_enable(bridge);
837 else
838 bridge->funcs->disable(bridge);
839 }
840
841 encoder_funcs = encoder->helper_private;
842 if (encoder_funcs->dpms)
843 encoder_funcs->dpms(encoder, mode);
844
845 if (bridge) {
846 if (mode == DRM_MODE_DPMS_ON)
847 bridge->funcs->enable(bridge);
848 else
849 bridge->funcs->post_disable(bridge);
850 }
851}
852
c9fb15f6
KP
853static int drm_helper_choose_crtc_dpms(struct drm_crtc *crtc)
854{
855 int dpms = DRM_MODE_DPMS_OFF;
856 struct drm_connector *connector;
857 struct drm_device *dev = crtc->dev;
858
859 list_for_each_entry(connector, &dev->mode_config.connector_list, head)
860 if (connector->encoder && connector->encoder->crtc == crtc)
861 if (connector->dpms < dpms)
862 dpms = connector->dpms;
863 return dpms;
864}
865
866/**
0d4ed4c8
DV
867 * drm_helper_connector_dpms() - connector dpms helper implementation
868 * @connector: affected connector
869 * @mode: DPMS mode
c9fb15f6 870 *
0d4ed4c8
DV
871 * This is the main helper function provided by the crtc helper framework for
872 * implementing the DPMS connector attribute. It computes the new desired DPMS
873 * state for all encoders and crtcs in the output mesh and calls the ->dpms()
874 * callback provided by the driver appropriately.
c9fb15f6
KP
875 */
876void drm_helper_connector_dpms(struct drm_connector *connector, int mode)
877{
878 struct drm_encoder *encoder = connector->encoder;
879 struct drm_crtc *crtc = encoder ? encoder->crtc : NULL;
3b336ec4 880 int old_dpms, encoder_dpms = DRM_MODE_DPMS_OFF;
c9fb15f6
KP
881
882 if (mode == connector->dpms)
883 return;
884
885 old_dpms = connector->dpms;
886 connector->dpms = mode;
887
3b336ec4
SP
888 if (encoder)
889 encoder_dpms = drm_helper_choose_encoder_dpms(encoder);
890
c9fb15f6
KP
891 /* from off to on, do crtc then encoder */
892 if (mode < old_dpms) {
893 if (crtc) {
894 struct drm_crtc_helper_funcs *crtc_funcs = crtc->helper_private;
895 if (crtc_funcs->dpms)
896 (*crtc_funcs->dpms) (crtc,
897 drm_helper_choose_crtc_dpms(crtc));
898 }
3b336ec4
SP
899 if (encoder)
900 drm_helper_encoder_dpms(encoder, encoder_dpms);
c9fb15f6
KP
901 }
902
903 /* from on to off, do encoder then crtc */
904 if (mode > old_dpms) {
3b336ec4
SP
905 if (encoder)
906 drm_helper_encoder_dpms(encoder, encoder_dpms);
c9fb15f6
KP
907 if (crtc) {
908 struct drm_crtc_helper_funcs *crtc_funcs = crtc->helper_private;
909 if (crtc_funcs->dpms)
910 (*crtc_funcs->dpms) (crtc,
911 drm_helper_choose_crtc_dpms(crtc));
912 }
913 }
914
915 return;
916}
917EXPORT_SYMBOL(drm_helper_connector_dpms);
918
9fd93784
DV
919void drm_helper_mode_fill_fb_struct(struct drm_framebuffer *fb,
920 struct drm_mode_fb_cmd2 *mode_cmd)
f453ba04 921{
01f2c773
VS
922 int i;
923
f453ba04
DA
924 fb->width = mode_cmd->width;
925 fb->height = mode_cmd->height;
01f2c773
VS
926 for (i = 0; i < 4; i++) {
927 fb->pitches[i] = mode_cmd->pitches[i];
928 fb->offsets[i] = mode_cmd->offsets[i];
929 }
248dbc23 930 drm_fb_get_bpp_depth(mode_cmd->pixel_format, &fb->depth,
308e5bcb
JB
931 &fb->bits_per_pixel);
932 fb->pixel_format = mode_cmd->pixel_format;
f453ba04
DA
933}
934EXPORT_SYMBOL(drm_helper_mode_fill_fb_struct);
935
aa4cd910
DV
936/**
937 * drm_helper_resume_force_mode - force-restore mode setting configuration
938 * @dev: drm_device which should be restored
939 *
940 * Drivers which use the mode setting helpers can use this function to
941 * force-restore the mode setting configuration e.g. on resume or when something
942 * else might have trampled over the hw state (like some overzealous old BIOSen
943 * tended to do).
944 */
f453ba04
DA
945int drm_helper_resume_force_mode(struct drm_device *dev)
946{
947 struct drm_crtc *crtc;
89347bb8 948 struct drm_encoder *encoder;
89347bb8 949 struct drm_crtc_helper_funcs *crtc_funcs;
3b336ec4 950 int ret, encoder_dpms;
f453ba04
DA
951
952 list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) {
953
954 if (!crtc->enabled)
955 continue;
956
3c4fdcfb
KH
957 ret = drm_crtc_helper_set_mode(crtc, &crtc->mode,
958 crtc->x, crtc->y, crtc->fb);
f453ba04
DA
959
960 if (ret == false)
961 DRM_ERROR("failed to set mode on crtc %p\n", crtc);
89347bb8
DJ
962
963 /* Turn off outputs that were already powered off */
964 if (drm_helper_choose_crtc_dpms(crtc)) {
965 list_for_each_entry(encoder, &dev->mode_config.encoder_list, head) {
966
967 if(encoder->crtc != crtc)
968 continue;
969
3b336ec4
SP
970 encoder_dpms = drm_helper_choose_encoder_dpms(
971 encoder);
972
973 drm_helper_encoder_dpms(encoder, encoder_dpms);
89347bb8 974 }
817e631e
CW
975
976 crtc_funcs = crtc->helper_private;
977 if (crtc_funcs->dpms)
978 (*crtc_funcs->dpms) (crtc,
979 drm_helper_choose_crtc_dpms(crtc));
89347bb8 980 }
f453ba04 981 }
af4fcb57
ZY
982 /* disable the unused connectors while restoring the modesetting */
983 drm_helper_disable_unused_functions(dev);
f453ba04
DA
984 return 0;
985}
986EXPORT_SYMBOL(drm_helper_resume_force_mode);
eb1f8e4f 987
3d3683f0
DV
988void drm_kms_helper_hotplug_event(struct drm_device *dev)
989{
990 /* send a uevent + call fbdev */
991 drm_sysfs_hotplug_event(dev);
992 if (dev->mode_config.funcs->output_poll_changed)
993 dev->mode_config.funcs->output_poll_changed(dev);
994}
995EXPORT_SYMBOL(drm_kms_helper_hotplug_event);
996
eb1f8e4f 997#define DRM_OUTPUT_POLL_PERIOD (10*HZ)
991ea75c 998static void output_poll_execute(struct work_struct *work)
eb1f8e4f 999{
991ea75c
TH
1000 struct delayed_work *delayed_work = to_delayed_work(work);
1001 struct drm_device *dev = container_of(delayed_work, struct drm_device, mode_config.output_poll_work);
eb1f8e4f 1002 struct drm_connector *connector;
c5027dec 1003 enum drm_connector_status old_status;
d482e5fa 1004 bool repoll = false, changed = false;
eb1f8e4f 1005
e58f637b
CW
1006 if (!drm_kms_helper_poll)
1007 return;
1008
eb1f8e4f
DA
1009 mutex_lock(&dev->mode_config.mutex);
1010 list_for_each_entry(connector, &dev->mode_config.connector_list, head) {
1011
11e68685
DV
1012 /* Ignore forced connectors. */
1013 if (connector->force)
1014 continue;
1015
816da85a
DV
1016 /* Ignore HPD capable connectors and connectors where we don't
1017 * want any hotplug detection at all for polling. */
1018 if (!connector->polled || connector->polled == DRM_CONNECTOR_POLL_HPD)
eb1f8e4f
DA
1019 continue;
1020
a4f968d8 1021 repoll = true;
eb1f8e4f
DA
1022
1023 old_status = connector->status;
1024 /* if we are connected and don't want to poll for disconnect
1025 skip it */
1026 if (old_status == connector_status_connected &&
816da85a 1027 !(connector->polled & DRM_CONNECTOR_POLL_DISCONNECT))
eb1f8e4f
DA
1028 continue;
1029
c5027dec 1030 connector->status = connector->funcs->detect(connector, false);
b2dfcae3
LD
1031 if (old_status != connector->status) {
1032 const char *old, *new;
1033
1034 old = drm_get_connector_status_name(old_status);
1035 new = drm_get_connector_status_name(connector->status);
1036
1037 DRM_DEBUG_KMS("[CONNECTOR:%d:%s] "
1038 "status updated from %s to %s\n",
1039 connector->base.id,
1040 drm_get_connector_name(connector),
1041 old, new);
1042
eb1f8e4f 1043 changed = true;
b2dfcae3 1044 }
eb1f8e4f
DA
1045 }
1046
1047 mutex_unlock(&dev->mode_config.mutex);
1048
3d3683f0
DV
1049 if (changed)
1050 drm_kms_helper_hotplug_event(dev);
eb1f8e4f 1051
9a919c46 1052 if (repoll)
3b07e9ca 1053 schedule_delayed_work(delayed_work, DRM_OUTPUT_POLL_PERIOD);
eb1f8e4f
DA
1054}
1055
fbf81762
DA
1056void drm_kms_helper_poll_disable(struct drm_device *dev)
1057{
1058 if (!dev->mode_config.poll_enabled)
1059 return;
991ea75c 1060 cancel_delayed_work_sync(&dev->mode_config.output_poll_work);
fbf81762
DA
1061}
1062EXPORT_SYMBOL(drm_kms_helper_poll_disable);
1063
1064void drm_kms_helper_poll_enable(struct drm_device *dev)
eb1f8e4f 1065{
eb1f8e4f 1066 bool poll = false;
fbf81762 1067 struct drm_connector *connector;
eb1f8e4f 1068
e58f637b
CW
1069 if (!dev->mode_config.poll_enabled || !drm_kms_helper_poll)
1070 return;
1071
eb1f8e4f 1072 list_for_each_entry(connector, &dev->mode_config.connector_list, head) {
a4f968d8
DV
1073 if (connector->polled & (DRM_CONNECTOR_POLL_CONNECT |
1074 DRM_CONNECTOR_POLL_DISCONNECT))
eb1f8e4f
DA
1075 poll = true;
1076 }
eb1f8e4f 1077
9a919c46 1078 if (poll)
3b07e9ca 1079 schedule_delayed_work(&dev->mode_config.output_poll_work, DRM_OUTPUT_POLL_PERIOD);
eb1f8e4f 1080}
fbf81762
DA
1081EXPORT_SYMBOL(drm_kms_helper_poll_enable);
1082
1083void drm_kms_helper_poll_init(struct drm_device *dev)
1084{
991ea75c 1085 INIT_DELAYED_WORK(&dev->mode_config.output_poll_work, output_poll_execute);
fbf81762
DA
1086 dev->mode_config.poll_enabled = true;
1087
1088 drm_kms_helper_poll_enable(dev);
1089}
eb1f8e4f
DA
1090EXPORT_SYMBOL(drm_kms_helper_poll_init);
1091
1092void drm_kms_helper_poll_fini(struct drm_device *dev)
1093{
fbf81762 1094 drm_kms_helper_poll_disable(dev);
eb1f8e4f
DA
1095}
1096EXPORT_SYMBOL(drm_kms_helper_poll_fini);
1097
b8206d39 1098bool drm_helper_hpd_irq_event(struct drm_device *dev)
eb1f8e4f 1099{
816da85a
DV
1100 struct drm_connector *connector;
1101 enum drm_connector_status old_status;
1102 bool changed = false;
1103
eb1f8e4f 1104 if (!dev->mode_config.poll_enabled)
b8206d39 1105 return false;
e58f637b 1106
816da85a
DV
1107 mutex_lock(&dev->mode_config.mutex);
1108 list_for_each_entry(connector, &dev->mode_config.connector_list, head) {
1109
1110 /* Only handle HPD capable connectors. */
1111 if (!(connector->polled & DRM_CONNECTOR_POLL_HPD))
1112 continue;
1113
1114 old_status = connector->status;
1115
1116 connector->status = connector->funcs->detect(connector, false);
ed7951dc 1117 DRM_DEBUG_KMS("[CONNECTOR:%d:%s] status updated from %s to %s\n",
816da85a
DV
1118 connector->base.id,
1119 drm_get_connector_name(connector),
ed7951dc
LD
1120 drm_get_connector_status_name(old_status),
1121 drm_get_connector_status_name(connector->status));
816da85a
DV
1122 if (old_status != connector->status)
1123 changed = true;
1124 }
1125
1126 mutex_unlock(&dev->mode_config.mutex);
1127
1128 if (changed)
1129 drm_kms_helper_hotplug_event(dev);
b8206d39
MAL
1130
1131 return changed;
816da85a 1132}
eb1f8e4f 1133EXPORT_SYMBOL(drm_helper_hpd_irq_event);
This page took 0.327677 seconds and 5 git commands to generate.