2 * Copyright (c) 2006-2008 Intel Corporation
3 * Copyright (c) 2007 Dave Airlie <airlied@linux.ie>
5 * DRM core CRTC related functions
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.
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
27 * Eric Anholt <eric@anholt.net>
28 * Dave Airlie <airlied@linux.ie>
29 * Jesse Barnes <jesse.barnes@intel.com>
34 #include "drm_crtc_helper.h"
37 * Detailed mode info for 800x600@60Hz
39 static struct drm_display_mode std_modes
[] = {
40 { DRM_MODE("800x600", DRM_MODE_TYPE_DEFAULT
, 40000, 800, 840,
41 968, 1056, 0, 600, 601, 605, 628, 0,
42 DRM_MODE_FLAG_PHSYNC
| DRM_MODE_FLAG_PVSYNC
) },
46 * drm_helper_probe_connector_modes - get complete set of display modes
48 * @maxX: max width for modes
49 * @maxY: max height for modes
52 * Caller must hold mode config lock.
54 * Based on @dev's mode_config layout, scan all the connectors and try to detect
55 * modes on them. Modes will first be added to the connector's probed_modes
56 * list, then culled (based on validity and the @maxX, @maxY parameters) and
57 * put into the normal modes list.
59 * Intended to be used either at bootup time or when major configuration
60 * changes have occurred.
62 * FIXME: take into account monitor limits
65 * Number of modes found on @connector.
67 int drm_helper_probe_single_connector_modes(struct drm_connector
*connector
,
68 uint32_t maxX
, uint32_t maxY
)
70 struct drm_device
*dev
= connector
->dev
;
71 struct drm_display_mode
*mode
, *t
;
72 struct drm_connector_helper_funcs
*connector_funcs
=
73 connector
->helper_private
;
76 DRM_DEBUG("%s\n", drm_get_connector_name(connector
));
77 /* set all modes to the unverified state */
78 list_for_each_entry_safe(mode
, t
, &connector
->modes
, head
)
79 mode
->status
= MODE_UNVERIFIED
;
81 connector
->status
= connector
->funcs
->detect(connector
);
83 if (connector
->status
== connector_status_disconnected
) {
84 DRM_DEBUG("%s is disconnected\n",
85 drm_get_connector_name(connector
));
86 /* TODO set EDID to NULL */
90 count
= (*connector_funcs
->get_modes
)(connector
);
94 drm_mode_connector_list_update(connector
);
97 drm_mode_validate_size(dev
, &connector
->modes
, maxX
,
99 list_for_each_entry_safe(mode
, t
, &connector
->modes
, head
) {
100 if (mode
->status
== MODE_OK
)
101 mode
->status
= connector_funcs
->mode_valid(connector
,
106 drm_mode_prune_invalid(dev
, &connector
->modes
, true);
108 if (list_empty(&connector
->modes
))
111 drm_mode_sort(&connector
->modes
);
113 DRM_DEBUG("Probed modes for %s\n", drm_get_connector_name(connector
));
114 list_for_each_entry_safe(mode
, t
, &connector
->modes
, head
) {
115 mode
->vrefresh
= drm_mode_vrefresh(mode
);
117 drm_mode_set_crtcinfo(mode
, CRTC_INTERLACE_HALVE_V
);
118 drm_mode_debug_printmodeline(mode
);
123 EXPORT_SYMBOL(drm_helper_probe_single_connector_modes
);
125 int drm_helper_probe_connector_modes(struct drm_device
*dev
, uint32_t maxX
,
128 struct drm_connector
*connector
;
131 list_for_each_entry(connector
, &dev
->mode_config
.connector_list
, head
) {
132 count
+= drm_helper_probe_single_connector_modes(connector
,
138 EXPORT_SYMBOL(drm_helper_probe_connector_modes
);
140 static void drm_helper_add_std_modes(struct drm_device
*dev
,
141 struct drm_connector
*connector
)
143 struct drm_display_mode
*mode
, *t
;
146 for (i
= 0; i
< ARRAY_SIZE(std_modes
); i
++) {
147 struct drm_display_mode
*stdmode
;
150 * When no valid EDID modes are available we end up
151 * here and bailed in the past, now we add some standard
154 stdmode
= drm_mode_duplicate(dev
, &std_modes
[i
]);
155 drm_mode_probed_add(connector
, stdmode
);
156 drm_mode_list_concat(&connector
->probed_modes
,
159 DRM_DEBUG("Adding mode %s to %s\n", stdmode
->name
,
160 drm_get_connector_name(connector
));
162 drm_mode_sort(&connector
->modes
);
164 DRM_DEBUG("Added std modes on %s\n", drm_get_connector_name(connector
));
165 list_for_each_entry_safe(mode
, t
, &connector
->modes
, head
) {
166 mode
->vrefresh
= drm_mode_vrefresh(mode
);
168 drm_mode_set_crtcinfo(mode
, CRTC_INTERLACE_HALVE_V
);
169 drm_mode_debug_printmodeline(mode
);
174 * drm_helper_crtc_in_use - check if a given CRTC is in a mode_config
175 * @crtc: CRTC to check
178 * Caller must hold mode config lock.
180 * Walk @crtc's DRM device's mode_config and see if it's in use.
183 * True if @crtc is part of the mode_config, false otherwise.
185 bool drm_helper_crtc_in_use(struct drm_crtc
*crtc
)
187 struct drm_encoder
*encoder
;
188 struct drm_device
*dev
= crtc
->dev
;
189 /* FIXME: Locking around list access? */
190 list_for_each_entry(encoder
, &dev
->mode_config
.encoder_list
, head
)
191 if (encoder
->crtc
== crtc
)
195 EXPORT_SYMBOL(drm_helper_crtc_in_use
);
198 * drm_disable_unused_functions - disable unused objects
202 * Caller must hold mode config lock.
204 * If an connector or CRTC isn't part of @dev's mode_config, it can be disabled
205 * by calling its dpms function, which should power it off.
207 void drm_helper_disable_unused_functions(struct drm_device
*dev
)
209 struct drm_encoder
*encoder
;
210 struct drm_encoder_helper_funcs
*encoder_funcs
;
211 struct drm_crtc
*crtc
;
213 list_for_each_entry(encoder
, &dev
->mode_config
.encoder_list
, head
) {
214 encoder_funcs
= encoder
->helper_private
;
216 (*encoder_funcs
->dpms
)(encoder
, DRM_MODE_DPMS_OFF
);
219 list_for_each_entry(crtc
, &dev
->mode_config
.crtc_list
, head
) {
220 struct drm_crtc_helper_funcs
*crtc_funcs
= crtc
->helper_private
;
221 crtc
->enabled
= drm_helper_crtc_in_use(crtc
);
222 if (!crtc
->enabled
) {
223 crtc_funcs
->dpms(crtc
, DRM_MODE_DPMS_OFF
);
228 EXPORT_SYMBOL(drm_helper_disable_unused_functions
);
230 static struct drm_display_mode
*drm_has_preferred_mode(struct drm_connector
*connector
, int width
, int height
)
232 struct drm_display_mode
*mode
;
234 list_for_each_entry(mode
, &connector
->modes
, head
) {
235 if (drm_mode_width(mode
) > width
||
236 drm_mode_height(mode
) > height
)
238 if (mode
->type
& DRM_MODE_TYPE_PREFERRED
)
244 static bool drm_connector_enabled(struct drm_connector
*connector
, bool strict
)
249 enable
= connector
->status
== connector_status_connected
;
251 enable
= connector
->status
!= connector_status_disconnected
;
256 static void drm_enable_connectors(struct drm_device
*dev
, bool *enabled
)
258 bool any_enabled
= false;
259 struct drm_connector
*connector
;
262 list_for_each_entry(connector
, &dev
->mode_config
.connector_list
, head
) {
263 enabled
[i
] = drm_connector_enabled(connector
, true);
264 DRM_DEBUG("connector %d enabled? %s\n", connector
->base
.id
,
265 enabled
[i
] ? "yes" : "no");
266 any_enabled
|= enabled
[i
];
274 list_for_each_entry(connector
, &dev
->mode_config
.connector_list
, head
) {
275 enabled
[i
] = drm_connector_enabled(connector
, false);
280 static bool drm_target_preferred(struct drm_device
*dev
,
281 struct drm_display_mode
**modes
,
282 bool *enabled
, int width
, int height
)
284 struct drm_connector
*connector
;
287 list_for_each_entry(connector
, &dev
->mode_config
.connector_list
, head
) {
289 if (enabled
[i
] == false) {
294 DRM_DEBUG("looking for preferred mode on connector %d\n",
297 modes
[i
] = drm_has_preferred_mode(connector
, width
, height
);
298 /* No preferred modes, pick one off the list */
299 if (!modes
[i
] && !list_empty(&connector
->modes
)) {
300 list_for_each_entry(modes
[i
], &connector
->modes
, head
)
303 DRM_DEBUG("found mode %s\n", modes
[i
] ? modes
[i
]->name
:
310 static int drm_pick_crtcs(struct drm_device
*dev
,
311 struct drm_crtc
**best_crtcs
,
312 struct drm_display_mode
**modes
,
313 int n
, int width
, int height
)
316 struct drm_connector
*connector
;
317 struct drm_connector_helper_funcs
*connector_funcs
;
318 struct drm_encoder
*encoder
;
319 struct drm_crtc
*best_crtc
;
320 int my_score
, best_score
, score
;
321 struct drm_crtc
**crtcs
, *crtc
;
323 if (n
== dev
->mode_config
.num_connector
)
326 list_for_each_entry(connector
, &dev
->mode_config
.connector_list
, head
) {
332 best_crtcs
[n
] = NULL
;
334 best_score
= drm_pick_crtcs(dev
, best_crtcs
, modes
, n
+1, width
, height
);
335 if (modes
[n
] == NULL
)
338 crtcs
= kmalloc(dev
->mode_config
.num_connector
*
339 sizeof(struct drm_crtc
*), GFP_KERNEL
);
344 if (connector
->status
== connector_status_connected
)
346 if (drm_has_preferred_mode(connector
, width
, height
))
349 connector_funcs
= connector
->helper_private
;
350 encoder
= connector_funcs
->best_encoder(connector
);
354 connector
->encoder
= encoder
;
356 /* select a crtc for this connector and then attempt to configure
357 remaining connectors */
359 list_for_each_entry(crtc
, &dev
->mode_config
.crtc_list
, head
) {
361 if ((connector
->encoder
->possible_crtcs
& (1 << c
)) == 0) {
366 for (o
= 0; o
< n
; o
++)
367 if (best_crtcs
[o
] == crtc
)
371 /* ignore cloning for now */
377 memcpy(crtcs
, best_crtcs
, n
* sizeof(struct drm_crtc
*));
378 score
= my_score
+ drm_pick_crtcs(dev
, crtcs
, modes
, n
+ 1,
380 if (score
> best_score
) {
383 memcpy(best_crtcs
, crtcs
,
384 dev
->mode_config
.num_connector
*
385 sizeof(struct drm_crtc
*));
394 static void drm_setup_crtcs(struct drm_device
*dev
)
396 struct drm_crtc
**crtcs
;
397 struct drm_display_mode
**modes
;
398 struct drm_encoder
*encoder
;
399 struct drm_connector
*connector
;
406 width
= dev
->mode_config
.max_width
;
407 height
= dev
->mode_config
.max_height
;
409 /* clean out all the encoder/crtc combos */
410 list_for_each_entry(encoder
, &dev
->mode_config
.encoder_list
, head
) {
411 encoder
->crtc
= NULL
;
414 crtcs
= kcalloc(dev
->mode_config
.num_connector
,
415 sizeof(struct drm_crtc
*), GFP_KERNEL
);
416 modes
= kcalloc(dev
->mode_config
.num_connector
,
417 sizeof(struct drm_display_mode
*), GFP_KERNEL
);
418 enabled
= kcalloc(dev
->mode_config
.num_connector
,
419 sizeof(bool), GFP_KERNEL
);
421 drm_enable_connectors(dev
, enabled
);
423 ret
= drm_target_preferred(dev
, modes
, enabled
, width
, height
);
425 DRM_ERROR("Unable to find initial modes\n");
427 DRM_DEBUG("picking CRTCs for %dx%d config\n", width
, height
);
429 drm_pick_crtcs(dev
, crtcs
, modes
, 0, width
, height
);
432 list_for_each_entry(connector
, &dev
->mode_config
.connector_list
, head
) {
433 struct drm_display_mode
*mode
= modes
[i
];
434 struct drm_crtc
*crtc
= crtcs
[i
];
436 if (connector
->encoder
== NULL
) {
442 DRM_DEBUG("desired mode %s set on crtc %d\n",
443 mode
->name
, crtc
->base
.id
);
444 crtc
->desired_mode
= mode
;
445 connector
->encoder
->crtc
= crtc
;
447 connector
->encoder
->crtc
= NULL
;
456 * drm_crtc_set_mode - set a mode
457 * @crtc: CRTC to program
463 * Caller must hold mode config lock.
465 * Try to set @mode on @crtc. Give @crtc and its associated connectors a chance
466 * to fixup or reject the mode prior to trying to set it.
469 * True if the mode was set successfully, or false otherwise.
471 bool drm_crtc_helper_set_mode(struct drm_crtc
*crtc
,
472 struct drm_display_mode
*mode
,
474 struct drm_framebuffer
*old_fb
)
476 struct drm_device
*dev
= crtc
->dev
;
477 struct drm_display_mode
*adjusted_mode
, saved_mode
;
478 struct drm_crtc_helper_funcs
*crtc_funcs
= crtc
->helper_private
;
479 struct drm_encoder_helper_funcs
*encoder_funcs
;
480 int saved_x
, saved_y
;
481 struct drm_encoder
*encoder
;
483 bool depth_changed
, bpp_changed
;
485 adjusted_mode
= drm_mode_duplicate(dev
, mode
);
487 crtc
->enabled
= drm_helper_crtc_in_use(crtc
);
492 if (old_fb
&& crtc
->fb
) {
493 depth_changed
= (old_fb
->depth
!= crtc
->fb
->depth
);
494 bpp_changed
= (old_fb
->bits_per_pixel
!=
495 crtc
->fb
->bits_per_pixel
);
497 depth_changed
= true;
501 saved_mode
= crtc
->mode
;
505 /* Update crtc values up front so the driver can rely on them for mode
512 if (drm_mode_equal(&saved_mode
, &crtc
->mode
)) {
513 if (saved_x
!= crtc
->x
|| saved_y
!= crtc
->y
||
514 depth_changed
|| bpp_changed
) {
515 ret
= !crtc_funcs
->mode_set_base(crtc
, crtc
->x
, crtc
->y
,
521 /* Pass our mode to the connectors and the CRTC to give them a chance to
522 * adjust it according to limitations or connector properties, and also
523 * a chance to reject the mode entirely.
525 list_for_each_entry(encoder
, &dev
->mode_config
.encoder_list
, head
) {
527 if (encoder
->crtc
!= crtc
)
529 encoder_funcs
= encoder
->helper_private
;
530 if (!(ret
= encoder_funcs
->mode_fixup(encoder
, mode
,
536 if (!(ret
= crtc_funcs
->mode_fixup(crtc
, mode
, adjusted_mode
))) {
540 /* Prepare the encoders and CRTCs before setting the mode. */
541 list_for_each_entry(encoder
, &dev
->mode_config
.encoder_list
, head
) {
543 if (encoder
->crtc
!= crtc
)
545 encoder_funcs
= encoder
->helper_private
;
546 /* Disable the encoders as the first thing we do. */
547 encoder_funcs
->prepare(encoder
);
550 crtc_funcs
->prepare(crtc
);
552 /* Set up the DPLL and any encoders state that needs to adjust or depend
555 ret
= !crtc_funcs
->mode_set(crtc
, mode
, adjusted_mode
, x
, y
, old_fb
);
559 list_for_each_entry(encoder
, &dev
->mode_config
.encoder_list
, head
) {
561 if (encoder
->crtc
!= crtc
)
564 DRM_INFO("%s: set mode %s %x\n", drm_get_encoder_name(encoder
),
565 mode
->name
, mode
->base
.id
);
566 encoder_funcs
= encoder
->helper_private
;
567 encoder_funcs
->mode_set(encoder
, mode
, adjusted_mode
);
570 /* Now enable the clocks, plane, pipe, and connectors that we set up. */
571 crtc_funcs
->commit(crtc
);
573 list_for_each_entry(encoder
, &dev
->mode_config
.encoder_list
, head
) {
575 if (encoder
->crtc
!= crtc
)
578 encoder_funcs
= encoder
->helper_private
;
579 encoder_funcs
->commit(encoder
);
583 /* XXX free adjustedmode */
584 drm_mode_destroy(dev
, adjusted_mode
);
585 /* FIXME: add subpixel order */
588 crtc
->mode
= saved_mode
;
595 EXPORT_SYMBOL(drm_crtc_helper_set_mode
);
599 * drm_crtc_helper_set_config - set a new config from userspace
600 * @crtc: CRTC to setup
601 * @crtc_info: user provided configuration
602 * @new_mode: new mode to set
603 * @connector_set: set of connectors for the new config
604 * @fb: new framebuffer
607 * Caller must hold mode config lock.
609 * Setup a new configuration, provided by the user in @crtc_info, and enable
615 int drm_crtc_helper_set_config(struct drm_mode_set
*set
)
617 struct drm_device
*dev
;
618 struct drm_crtc
**save_crtcs
, *new_crtc
;
619 struct drm_encoder
**save_encoders
, *new_encoder
;
620 struct drm_framebuffer
*old_fb
;
622 bool mode_changed
= false;
623 bool fb_changed
= false;
624 struct drm_connector
*connector
;
625 int count
= 0, ro
, fail
= 0;
626 struct drm_crtc_helper_funcs
*crtc_funcs
;
637 if (!set
->crtc
->helper_private
)
640 crtc_funcs
= set
->crtc
->helper_private
;
642 DRM_DEBUG("crtc: %p %d fb: %p connectors: %p num_connectors: %d (x, y) (%i, %i)\n",
643 set
->crtc
, set
->crtc
->base
.id
, set
->fb
, set
->connectors
,
644 (int)set
->num_connectors
, set
->x
, set
->y
);
646 dev
= set
->crtc
->dev
;
648 /* save previous config */
649 save_enabled
= set
->crtc
->enabled
;
652 * We do mode_config.num_connectors here since we'll look at the
653 * CRTC and encoder associated with each connector later.
655 save_crtcs
= kzalloc(dev
->mode_config
.num_connector
*
656 sizeof(struct drm_crtc
*), GFP_KERNEL
);
660 save_encoders
= kzalloc(dev
->mode_config
.num_connector
*
661 sizeof(struct drm_encoders
*), GFP_KERNEL
);
662 if (!save_encoders
) {
667 /* We should be able to check here if the fb has the same properties
668 * and then just flip_or_move it */
669 if (set
->crtc
->fb
!= set
->fb
) {
670 /* If we have no fb then treat it as a full mode set */
671 if (set
->crtc
->fb
== NULL
)
673 else if ((set
->fb
->bits_per_pixel
!=
674 set
->crtc
->fb
->bits_per_pixel
) ||
675 set
->fb
->depth
!= set
->crtc
->fb
->depth
)
681 if (set
->x
!= set
->crtc
->x
|| set
->y
!= set
->crtc
->y
)
684 if (set
->mode
&& !drm_mode_equal(set
->mode
, &set
->crtc
->mode
)) {
685 DRM_DEBUG("modes are different\n");
686 drm_mode_debug_printmodeline(&set
->crtc
->mode
);
687 drm_mode_debug_printmodeline(set
->mode
);
691 /* a) traverse passed in connector list and get encoders for them */
693 list_for_each_entry(connector
, &dev
->mode_config
.connector_list
, head
) {
694 struct drm_connector_helper_funcs
*connector_funcs
=
695 connector
->helper_private
;
696 save_encoders
[count
++] = connector
->encoder
;
697 new_encoder
= connector
->encoder
;
698 for (ro
= 0; ro
< set
->num_connectors
; ro
++) {
699 if (set
->connectors
[ro
] == connector
) {
700 new_encoder
= connector_funcs
->best_encoder(connector
);
701 /* if we can't get an encoder for a connector
702 we are setting now - then fail */
703 if (new_encoder
== NULL
)
704 /* don't break so fail path works correct */
710 if (new_encoder
!= connector
->encoder
) {
712 connector
->encoder
= new_encoder
;
718 goto fail_no_encoder
;
722 list_for_each_entry(connector
, &dev
->mode_config
.connector_list
, head
) {
723 if (!connector
->encoder
)
726 save_crtcs
[count
++] = connector
->encoder
->crtc
;
728 if (connector
->encoder
->crtc
== set
->crtc
)
731 new_crtc
= connector
->encoder
->crtc
;
733 for (ro
= 0; ro
< set
->num_connectors
; ro
++) {
734 if (set
->connectors
[ro
] == connector
)
735 new_crtc
= set
->crtc
;
737 if (new_crtc
!= connector
->encoder
->crtc
) {
739 connector
->encoder
->crtc
= new_crtc
;
743 /* mode_set_base is not a required function */
744 if (fb_changed
&& !crtc_funcs
->mode_set_base
)
748 old_fb
= set
->crtc
->fb
;
749 set
->crtc
->fb
= set
->fb
;
750 set
->crtc
->enabled
= (set
->mode
!= NULL
);
751 if (set
->mode
!= NULL
) {
752 DRM_DEBUG("attempting to set mode from userspace\n");
753 drm_mode_debug_printmodeline(set
->mode
);
754 if (!drm_crtc_helper_set_mode(set
->crtc
, set
->mode
,
757 DRM_ERROR("failed to set mode on crtc %p\n",
762 /* TODO are these needed? */
763 set
->crtc
->desired_x
= set
->x
;
764 set
->crtc
->desired_y
= set
->y
;
765 set
->crtc
->desired_mode
= set
->mode
;
767 drm_helper_disable_unused_functions(dev
);
768 } else if (fb_changed
) {
769 old_fb
= set
->crtc
->fb
;
770 if (set
->crtc
->fb
!= set
->fb
)
771 set
->crtc
->fb
= set
->fb
;
772 ret
= crtc_funcs
->mode_set_base(set
->crtc
,
773 set
->x
, set
->y
, old_fb
);
778 kfree(save_encoders
);
783 set
->crtc
->enabled
= save_enabled
;
785 list_for_each_entry(connector
, &dev
->mode_config
.connector_list
, head
) {
786 if (!connector
->encoder
)
789 connector
->encoder
->crtc
= save_crtcs
[count
++];
794 list_for_each_entry(connector
, &dev
->mode_config
.connector_list
, head
) {
795 connector
->encoder
= save_encoders
[count
++];
797 kfree(save_encoders
);
800 EXPORT_SYMBOL(drm_crtc_helper_set_config
);
802 bool drm_helper_plugged_event(struct drm_device
*dev
)
806 drm_helper_probe_connector_modes(dev
, dev
->mode_config
.max_width
,
807 dev
->mode_config
.max_height
);
809 drm_setup_crtcs(dev
);
811 /* alert the driver fb layer */
812 dev
->mode_config
.funcs
->fb_changed(dev
);
814 /* FIXME: send hotplug event */
818 * drm_initial_config - setup a sane initial connector configuration
820 * @can_grow: this configuration is growable
823 * Called at init time, must take mode config lock.
825 * Scan the CRTCs and connectors and try to put together an initial setup.
826 * At the moment, this is a cloned configuration across all heads with
827 * a new framebuffer object as the backing store.
830 * Zero if everything went ok, nonzero otherwise.
832 bool drm_helper_initial_config(struct drm_device
*dev
, bool can_grow
)
834 struct drm_connector
*connector
;
837 count
= drm_helper_probe_connector_modes(dev
,
838 dev
->mode_config
.max_width
,
839 dev
->mode_config
.max_height
);
842 * None of the available connectors had any modes, so add some
843 * and try to light them up anyway
846 DRM_ERROR("connectors have no modes, using standard modes\n");
847 list_for_each_entry(connector
,
848 &dev
->mode_config
.connector_list
,
850 drm_helper_add_std_modes(dev
, connector
);
853 drm_setup_crtcs(dev
);
855 /* alert the driver fb layer */
856 dev
->mode_config
.funcs
->fb_changed(dev
);
860 EXPORT_SYMBOL(drm_helper_initial_config
);
863 * drm_hotplug_stage_two
865 * @connector hotpluged connector
868 * Caller must hold mode config lock, function might grab struct lock.
870 * Stage two of a hotplug.
873 * Zero on success, errno on failure.
875 int drm_helper_hotplug_stage_two(struct drm_device
*dev
)
877 drm_helper_plugged_event(dev
);
881 EXPORT_SYMBOL(drm_helper_hotplug_stage_two
);
883 int drm_helper_mode_fill_fb_struct(struct drm_framebuffer
*fb
,
884 struct drm_mode_fb_cmd
*mode_cmd
)
886 fb
->width
= mode_cmd
->width
;
887 fb
->height
= mode_cmd
->height
;
888 fb
->pitch
= mode_cmd
->pitch
;
889 fb
->bits_per_pixel
= mode_cmd
->bpp
;
890 fb
->depth
= mode_cmd
->depth
;
894 EXPORT_SYMBOL(drm_helper_mode_fill_fb_struct
);
896 int drm_helper_resume_force_mode(struct drm_device
*dev
)
898 struct drm_crtc
*crtc
;
901 list_for_each_entry(crtc
, &dev
->mode_config
.crtc_list
, head
) {
906 ret
= drm_crtc_helper_set_mode(crtc
, &crtc
->mode
,
907 crtc
->x
, crtc
->y
, crtc
->fb
);
910 DRM_ERROR("failed to set mode on crtc %p\n", crtc
);
914 EXPORT_SYMBOL(drm_helper_resume_force_mode
);