2 * Copyright (c) 2006-2009 Red Hat Inc.
3 * Copyright (c) 2006-2008 Intel Corporation
4 * Copyright (c) 2007 Dave Airlie <airlied@linux.ie>
6 * DRM framebuffer helper functions
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
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
12 * that the name of the copyright holders not be used in advertising or
13 * publicity pertaining to distribution of the software without specific,
14 * written prior permission. The copyright holders make no representations
15 * about the suitability of this software for any purpose. It is provided "as
16 * is" without express or implied warranty.
18 * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
19 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
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,
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
27 * Dave Airlie <airlied@linux.ie>
28 * Jesse Barnes <jesse.barnes@intel.com>
31 #include <linux/kernel.h>
33 #include <linux/module.h>
35 #include <drm/drm_crtc.h>
36 #include <drm/drm_fb_helper.h>
37 #include <drm/drm_crtc_helper.h>
38 #include <drm/drm_atomic.h>
39 #include <drm/drm_atomic_helper.h>
41 static bool drm_fbdev_emulation
= true;
42 module_param_named(fbdev_emulation
, drm_fbdev_emulation
, bool, 0600);
43 MODULE_PARM_DESC(fbdev_emulation
,
44 "Enable legacy fbdev emulation [default=true]");
46 static LINUX_LIST_HEAD(kernel_fb_helper_list
);
51 * The fb helper functions are useful to provide an fbdev on top of a drm kernel
52 * mode setting driver. They can be used mostly independently from the crtc
53 * helper functions used by many drivers to implement the kernel mode setting
56 * Initialization is done as a four-step process with drm_fb_helper_prepare(),
57 * drm_fb_helper_init(), drm_fb_helper_single_add_all_connectors() and
58 * drm_fb_helper_initial_config(). Drivers with fancier requirements than the
59 * default behaviour can override the third step with their own code.
60 * Teardown is done with drm_fb_helper_fini().
62 * At runtime drivers should restore the fbdev console by calling
63 * drm_fb_helper_restore_fbdev_mode_unlocked() from their ->lastclose callback.
64 * They should also notify the fb helper code from updates to the output
65 * configuration by calling drm_fb_helper_hotplug_event(). For easier
66 * integration with the output polling code in drm_crtc_helper.c the modeset
67 * code provides a ->output_poll_changed callback.
69 * All other functions exported by the fb helper library can be used to
70 * implement the fbdev driver interface by the driver.
72 * It is possible, though perhaps somewhat tricky, to implement race-free
73 * hotplug detection using the fbdev helpers. The drm_fb_helper_prepare()
74 * helper must be called first to initialize the minimum required to make
75 * hotplug detection work. Drivers also need to make sure to properly set up
76 * the dev->mode_config.funcs member. After calling drm_kms_helper_poll_init()
77 * it is safe to enable interrupts and start processing hotplug events. At the
78 * same time, drivers should initialize all modeset objects such as CRTCs,
79 * encoders and connectors. To finish up the fbdev helper initialization, the
80 * drm_fb_helper_init() function is called. To probe for all attached displays
81 * and set up an initial configuration using the detected hardware, drivers
82 * should call drm_fb_helper_single_add_all_connectors() followed by
83 * drm_fb_helper_initial_config().
87 * drm_fb_helper_single_add_all_connectors() - add all connectors to fbdev
89 * @fb_helper: fbdev initialized with drm_fb_helper_init
91 * This functions adds all the available connectors for use with the given
92 * fb_helper. This is a separate step to allow drivers to freely assign
93 * connectors to the fbdev, e.g. if some are reserved for special purposes or
94 * not adequate to be used for the fbcon.
96 * This function is protected against concurrent connector hotadds/removals
97 * using drm_fb_helper_add_one_connector() and
98 * drm_fb_helper_remove_one_connector().
100 int drm_fb_helper_single_add_all_connectors(struct drm_fb_helper
*fb_helper
)
102 struct drm_device
*dev
= fb_helper
->dev
;
103 struct drm_connector
*connector
;
106 if (!drm_fbdev_emulation
)
109 mutex_lock(&dev
->mode_config
.mutex
);
110 drm_for_each_connector(connector
, dev
) {
111 ret
= drm_fb_helper_add_one_connector(fb_helper
, connector
);
116 mutex_unlock(&dev
->mode_config
.mutex
);
119 for (i
= 0; i
< fb_helper
->connector_count
; i
++) {
120 kfree(fb_helper
->connector_info
[i
]);
121 fb_helper
->connector_info
[i
] = NULL
;
123 fb_helper
->connector_count
= 0;
124 mutex_unlock(&dev
->mode_config
.mutex
);
128 EXPORT_SYMBOL(drm_fb_helper_single_add_all_connectors
);
130 int drm_fb_helper_add_one_connector(struct drm_fb_helper
*fb_helper
, struct drm_connector
*connector
)
132 struct drm_fb_helper_connector
**temp
;
133 struct drm_fb_helper_connector
*fb_helper_connector
;
135 if (!drm_fbdev_emulation
)
138 WARN_ON(!mutex_is_locked(&fb_helper
->dev
->mode_config
.mutex
));
139 if (fb_helper
->connector_count
+ 1 > fb_helper
->connector_info_alloc_count
) {
140 temp
= krealloc(fb_helper
->connector_info
, sizeof(struct drm_fb_helper_connector
*) * (fb_helper
->connector_count
+ 1), M_DRM
, M_WAITOK
);
144 fb_helper
->connector_info_alloc_count
= fb_helper
->connector_count
+ 1;
145 fb_helper
->connector_info
= temp
;
149 fb_helper_connector
= kzalloc(sizeof(struct drm_fb_helper_connector
), GFP_KERNEL
);
150 if (!fb_helper_connector
)
153 fb_helper_connector
->connector
= connector
;
154 fb_helper
->connector_info
[fb_helper
->connector_count
++] = fb_helper_connector
;
157 EXPORT_SYMBOL(drm_fb_helper_add_one_connector
);
159 static void remove_from_modeset(struct drm_mode_set
*set
,
160 struct drm_connector
*connector
)
164 for (i
= 0; i
< set
->num_connectors
; i
++) {
165 if (set
->connectors
[i
] == connector
)
169 if (i
== set
->num_connectors
)
172 for (j
= i
+ 1; j
< set
->num_connectors
; j
++) {
173 set
->connectors
[j
- 1] = set
->connectors
[j
];
175 set
->num_connectors
--;
178 * TODO maybe need to makes sure we set it back to !=NULL somewhere?
180 if (set
->num_connectors
== 0) {
182 drm_mode_destroy(connector
->dev
, set
->mode
);
187 int drm_fb_helper_remove_one_connector(struct drm_fb_helper
*fb_helper
,
188 struct drm_connector
*connector
)
190 struct drm_fb_helper_connector
*fb_helper_connector
;
193 if (!drm_fbdev_emulation
)
196 WARN_ON(!mutex_is_locked(&fb_helper
->dev
->mode_config
.mutex
));
198 for (i
= 0; i
< fb_helper
->connector_count
; i
++) {
199 if (fb_helper
->connector_info
[i
]->connector
== connector
)
203 if (i
== fb_helper
->connector_count
)
205 fb_helper_connector
= fb_helper
->connector_info
[i
];
207 for (j
= i
+ 1; j
< fb_helper
->connector_count
; j
++) {
208 fb_helper
->connector_info
[j
- 1] = fb_helper
->connector_info
[j
];
210 fb_helper
->connector_count
--;
211 kfree(fb_helper_connector
);
213 /* also cleanup dangling references to the connector: */
214 for (i
= 0; i
< fb_helper
->crtc_count
; i
++)
215 remove_from_modeset(&fb_helper
->crtc_info
[i
].mode_set
, connector
);
219 EXPORT_SYMBOL(drm_fb_helper_remove_one_connector
);
222 static void drm_fb_helper_save_lut_atomic(struct drm_crtc
*crtc
, struct drm_fb_helper
*helper
)
224 uint16_t *r_base
, *g_base
, *b_base
;
227 if (helper
->funcs
->gamma_get
== NULL
)
230 r_base
= crtc
->gamma_store
;
231 g_base
= r_base
+ crtc
->gamma_size
;
232 b_base
= g_base
+ crtc
->gamma_size
;
234 for (i
= 0; i
< crtc
->gamma_size
; i
++)
235 helper
->funcs
->gamma_get(crtc
, &r_base
[i
], &g_base
[i
], &b_base
[i
], i
);
238 static void drm_fb_helper_restore_lut_atomic(struct drm_crtc
*crtc
)
240 uint16_t *r_base
, *g_base
, *b_base
;
242 if (crtc
->funcs
->gamma_set
== NULL
)
245 r_base
= crtc
->gamma_store
;
246 g_base
= r_base
+ crtc
->gamma_size
;
247 b_base
= g_base
+ crtc
->gamma_size
;
249 crtc
->funcs
->gamma_set(crtc
, r_base
, g_base
, b_base
, 0, crtc
->gamma_size
);
254 * drm_fb_helper_debug_enter - implementation for ->fb_debug_enter
255 * @info: fbdev registered by the helper
257 int drm_fb_helper_debug_enter(struct fb_info
*info
)
259 struct drm_fb_helper
*helper
= info
->par
;
260 const struct drm_crtc_helper_funcs
*funcs
;
263 list_for_each_entry(helper
, &kernel_fb_helper_list
, kernel_fb_list
) {
264 for (i
= 0; i
< helper
->crtc_count
; i
++) {
265 struct drm_mode_set
*mode_set
=
266 &helper
->crtc_info
[i
].mode_set
;
268 if (!mode_set
->crtc
->enabled
)
271 funcs
= mode_set
->crtc
->helper_private
;
273 drm_fb_helper_save_lut_atomic(mode_set
->crtc
, helper
);
275 funcs
->mode_set_base_atomic(mode_set
->crtc
,
279 ENTER_ATOMIC_MODE_SET
);
285 EXPORT_SYMBOL(drm_fb_helper_debug_enter
);
288 /* Find the real fb for a given fb helper CRTC */
289 static struct drm_framebuffer
*drm_mode_config_fb(struct drm_crtc
*crtc
)
291 struct drm_device
*dev
= crtc
->dev
;
294 drm_for_each_crtc(c
, dev
) {
295 if (crtc
->base
.id
== c
->base
.id
)
296 return c
->primary
->fb
;
303 * drm_fb_helper_debug_leave - implementation for ->fb_debug_leave
304 * @info: fbdev registered by the helper
306 int drm_fb_helper_debug_leave(struct fb_info
*info
)
308 struct drm_fb_helper
*helper
= info
->par
;
309 struct drm_crtc
*crtc
;
310 const struct drm_crtc_helper_funcs
*funcs
;
311 struct drm_framebuffer
*fb
;
314 for (i
= 0; i
< helper
->crtc_count
; i
++) {
315 struct drm_mode_set
*mode_set
= &helper
->crtc_info
[i
].mode_set
;
316 crtc
= mode_set
->crtc
;
317 funcs
= crtc
->helper_private
;
318 fb
= drm_mode_config_fb(crtc
);
324 DRM_ERROR("no fb to restore??\n");
328 drm_fb_helper_restore_lut_atomic(mode_set
->crtc
);
329 funcs
->mode_set_base_atomic(mode_set
->crtc
, fb
, crtc
->x
,
330 crtc
->y
, LEAVE_ATOMIC_MODE_SET
);
335 EXPORT_SYMBOL(drm_fb_helper_debug_leave
);
338 static int restore_fbdev_mode_atomic(struct drm_fb_helper
*fb_helper
)
340 struct drm_device
*dev
= fb_helper
->dev
;
341 struct drm_plane
*plane
;
342 struct drm_atomic_state
*state
;
346 state
= drm_atomic_state_alloc(dev
);
350 state
->acquire_ctx
= dev
->mode_config
.acquire_ctx
;
353 drm_for_each_plane(plane
, dev
) {
354 struct drm_plane_state
*plane_state
;
356 plane_state
= drm_atomic_get_plane_state(state
, plane
);
357 if (IS_ERR(plane_state
)) {
358 ret
= PTR_ERR(plane_state
);
362 plane_state
->rotation
= BIT(DRM_ROTATE_0
);
364 plane
->old_fb
= plane
->fb
;
365 plane_mask
|= 1 << drm_plane_index(plane
);
367 /* disable non-primary: */
368 if (plane
->type
== DRM_PLANE_TYPE_PRIMARY
)
371 ret
= __drm_atomic_helper_disable_plane(plane
, plane_state
);
376 for(i
= 0; i
< fb_helper
->crtc_count
; i
++) {
377 struct drm_mode_set
*mode_set
= &fb_helper
->crtc_info
[i
].mode_set
;
379 ret
= __drm_atomic_helper_set_config(mode_set
, state
);
384 ret
= drm_atomic_commit(state
);
387 drm_atomic_clean_old_fb(dev
, plane_mask
, ret
);
393 drm_atomic_state_free(state
);
398 drm_atomic_state_clear(state
);
399 drm_atomic_legacy_backoff(state
);
404 static bool restore_fbdev_mode(struct drm_fb_helper
*fb_helper
)
406 struct drm_device
*dev
= fb_helper
->dev
;
407 struct drm_plane
*plane
;
411 drm_warn_on_modeset_not_all_locked(dev
);
413 if (fb_helper
->atomic
)
414 return restore_fbdev_mode_atomic(fb_helper
);
416 drm_for_each_plane(plane
, dev
) {
417 if (plane
->type
!= DRM_PLANE_TYPE_PRIMARY
)
418 drm_plane_force_disable(plane
);
420 if (dev
->mode_config
.rotation_property
) {
421 drm_mode_plane_set_obj_prop(plane
,
422 dev
->mode_config
.rotation_property
,
427 for (i
= 0; i
< fb_helper
->crtc_count
; i
++) {
428 struct drm_mode_set
*mode_set
= &fb_helper
->crtc_info
[i
].mode_set
;
429 struct drm_crtc
*crtc
= mode_set
->crtc
;
432 if (crtc
->funcs
->cursor_set
) {
433 ret
= crtc
->funcs
->cursor_set(crtc
, NULL
, 0, 0, 0);
438 ret
= drm_mode_set_config_internal(mode_set
);
446 * drm_fb_helper_restore_fbdev_mode_unlocked - restore fbdev configuration
447 * @fb_helper: fbcon to restore
449 * This should be called from driver's drm ->lastclose callback
450 * when implementing an fbcon on top of kms using this helper. This ensures that
451 * the user isn't greeted with a black screen when e.g. X dies.
454 * Zero if everything went ok, negative error code otherwise.
456 int drm_fb_helper_restore_fbdev_mode_unlocked(struct drm_fb_helper
*fb_helper
)
458 struct drm_device
*dev
= fb_helper
->dev
;
462 if (!drm_fbdev_emulation
)
465 drm_modeset_lock_all(dev
);
466 ret
= restore_fbdev_mode(fb_helper
);
468 do_delayed
= fb_helper
->delayed_hotplug
;
470 fb_helper
->delayed_hotplug
= false;
471 drm_modeset_unlock_all(dev
);
474 drm_fb_helper_hotplug_event(fb_helper
);
477 EXPORT_SYMBOL(drm_fb_helper_restore_fbdev_mode_unlocked
);
479 static bool drm_fb_helper_is_bound(struct drm_fb_helper
*fb_helper
)
481 struct drm_device
*dev
= fb_helper
->dev
;
482 struct drm_crtc
*crtc
;
483 int bound
= 0, crtcs_bound
= 0;
485 /* Sometimes user space wants everything disabled, so don't steal the
486 * display if there's a master. */
488 if (dev
->primary
->master
)
492 drm_for_each_crtc(crtc
, dev
) {
493 if (crtc
->primary
->fb
)
495 if (crtc
->primary
->fb
== fb_helper
->fb
)
499 if (bound
< crtcs_bound
)
505 #ifdef CONFIG_MAGIC_SYSRQ
507 * restore fbcon display for all kms driver's using this helper, used for sysrq
508 * and panic handling.
510 static bool drm_fb_helper_force_kernel_mode(void)
512 bool ret
, error
= false;
513 struct drm_fb_helper
*helper
;
515 if (list_empty(&kernel_fb_helper_list
))
518 list_for_each_entry(helper
, &kernel_fb_helper_list
, kernel_fb_list
) {
519 struct drm_device
*dev
= helper
->dev
;
521 if (dev
->switch_power_state
== DRM_SWITCH_POWER_OFF
)
524 drm_modeset_lock_all(dev
);
525 ret
= restore_fbdev_mode(helper
);
528 drm_modeset_unlock_all(dev
);
534 static void drm_fb_helper_restore_work_fn(struct work_struct
*ignored
)
537 ret
= drm_fb_helper_force_kernel_mode();
539 DRM_ERROR("Failed to restore crtc configuration\n");
541 static DECLARE_WORK(drm_fb_helper_restore_work
, drm_fb_helper_restore_work_fn
);
543 static void drm_fb_helper_sysrq(int dummy1
)
545 schedule_work(&drm_fb_helper_restore_work
);
548 static struct sysrq_key_op sysrq_drm_fb_helper_restore_op
= {
549 .handler
= drm_fb_helper_sysrq
,
550 .help_msg
= "force-fb(V)",
551 .action_msg
= "Restore framebuffer console",
554 static struct sysrq_key_op sysrq_drm_fb_helper_restore_op
= { };
558 static void drm_fb_helper_dpms(struct fb_info
*info
, int dpms_mode
)
560 struct drm_fb_helper
*fb_helper
= info
->par
;
561 struct drm_device
*dev
= fb_helper
->dev
;
562 struct drm_crtc
*crtc
;
563 struct drm_connector
*connector
;
567 * For each CRTC in this fb, turn the connectors on/off.
569 drm_modeset_lock_all(dev
);
570 if (!drm_fb_helper_is_bound(fb_helper
)) {
571 drm_modeset_unlock_all(dev
);
575 for (i
= 0; i
< fb_helper
->crtc_count
; i
++) {
576 crtc
= fb_helper
->crtc_info
[i
].mode_set
.crtc
;
581 /* Walk the connectors & encoders on this fb turning them on/off */
582 for (j
= 0; j
< fb_helper
->connector_count
; j
++) {
583 connector
= fb_helper
->connector_info
[j
]->connector
;
584 connector
->funcs
->dpms(connector
, dpms_mode
);
585 drm_object_property_set_value(&connector
->base
,
586 dev
->mode_config
.dpms_property
, dpms_mode
);
589 drm_modeset_unlock_all(dev
);
593 * drm_fb_helper_blank - implementation for ->fb_blank
594 * @blank: desired blanking state
595 * @info: fbdev registered by the helper
597 int drm_fb_helper_blank(int blank
, struct fb_info
*info
)
603 if (oops_in_progress
)
608 /* Display: On; HSync: On, VSync: On */
609 case FB_BLANK_UNBLANK
:
610 drm_fb_helper_dpms(info
, DRM_MODE_DPMS_ON
);
613 /* Display: Off; HSync: On, VSync: On */
614 case FB_BLANK_NORMAL
:
615 drm_fb_helper_dpms(info
, DRM_MODE_DPMS_STANDBY
);
617 /* Display: Off; HSync: Off, VSync: On */
618 case FB_BLANK_HSYNC_SUSPEND
:
619 drm_fb_helper_dpms(info
, DRM_MODE_DPMS_STANDBY
);
621 /* Display: Off; HSync: On, VSync: Off */
622 case FB_BLANK_VSYNC_SUSPEND
:
623 drm_fb_helper_dpms(info
, DRM_MODE_DPMS_SUSPEND
);
626 /* Display: Off; HSync: Off, VSync: Off */
627 case FB_BLANK_POWERDOWN
:
628 drm_fb_helper_dpms(info
, DRM_MODE_DPMS_OFF
);
633 EXPORT_SYMBOL(drm_fb_helper_blank
);
635 static void drm_fb_helper_crtc_free(struct drm_fb_helper
*helper
)
639 for (i
= 0; i
< helper
->connector_count
; i
++)
640 kfree(helper
->connector_info
[i
]);
641 kfree(helper
->connector_info
);
642 for (i
= 0; i
< helper
->crtc_count
; i
++) {
643 kfree(helper
->crtc_info
[i
].mode_set
.connectors
);
644 if (helper
->crtc_info
[i
].mode_set
.mode
)
645 drm_mode_destroy(helper
->dev
, helper
->crtc_info
[i
].mode_set
.mode
);
647 kfree(helper
->crtc_info
);
651 * drm_fb_helper_prepare - setup a drm_fb_helper structure
653 * @helper: driver-allocated fbdev helper structure to set up
654 * @funcs: pointer to structure of functions associate with this helper
656 * Sets up the bare minimum to make the framebuffer helper usable. This is
657 * useful to implement race-free initialization of the polling helpers.
659 void drm_fb_helper_prepare(struct drm_device
*dev
, struct drm_fb_helper
*helper
,
660 const struct drm_fb_helper_funcs
*funcs
)
662 INIT_LIST_HEAD(&helper
->kernel_fb_list
);
663 helper
->funcs
= funcs
;
666 EXPORT_SYMBOL(drm_fb_helper_prepare
);
669 * drm_fb_helper_init - initialize a drm_fb_helper structure
671 * @fb_helper: driver-allocated fbdev helper structure to initialize
672 * @crtc_count: maximum number of crtcs to support in this fbdev emulation
673 * @max_conn_count: max connector count
675 * This allocates the structures for the fbdev helper with the given limits.
676 * Note that this won't yet touch the hardware (through the driver interfaces)
677 * nor register the fbdev. This is only done in drm_fb_helper_initial_config()
678 * to allow driver writes more control over the exact init sequence.
680 * Drivers must call drm_fb_helper_prepare() before calling this function.
683 * Zero if everything went ok, nonzero otherwise.
685 int drm_fb_helper_init(struct drm_device
*dev
,
686 struct drm_fb_helper
*fb_helper
,
687 int crtc_count
, int max_conn_count
)
689 struct drm_crtc
*crtc
;
692 if (!drm_fbdev_emulation
)
698 fb_helper
->crtc_info
= kcalloc(crtc_count
, sizeof(struct drm_fb_helper_crtc
), GFP_KERNEL
);
699 if (!fb_helper
->crtc_info
)
702 fb_helper
->crtc_count
= crtc_count
;
703 fb_helper
->connector_info
= kcalloc(dev
->mode_config
.num_connector
, sizeof(struct drm_fb_helper_connector
*), GFP_KERNEL
);
704 if (!fb_helper
->connector_info
) {
705 kfree(fb_helper
->crtc_info
);
708 fb_helper
->connector_info_alloc_count
= dev
->mode_config
.num_connector
;
709 fb_helper
->connector_count
= 0;
711 for (i
= 0; i
< crtc_count
; i
++) {
712 fb_helper
->crtc_info
[i
].mode_set
.connectors
=
713 kcalloc(max_conn_count
,
714 sizeof(struct drm_connector
*),
717 if (!fb_helper
->crtc_info
[i
].mode_set
.connectors
)
719 fb_helper
->crtc_info
[i
].mode_set
.num_connectors
= 0;
723 drm_for_each_crtc(crtc
, dev
) {
724 fb_helper
->crtc_info
[i
].mode_set
.crtc
= crtc
;
728 fb_helper
->atomic
= !!drm_core_check_feature(dev
, DRIVER_ATOMIC
);
732 drm_fb_helper_crtc_free(fb_helper
);
735 EXPORT_SYMBOL(drm_fb_helper_init
);
738 * drm_fb_helper_alloc_fbi - allocate fb_info and some of its members
739 * @fb_helper: driver-allocated fbdev helper
741 * A helper to alloc fb_info and the members cmap and apertures. Called
742 * by the driver within the fb_probe fb_helper callback function.
745 * fb_info pointer if things went okay, pointer containing error code
748 struct fb_info
*drm_fb_helper_alloc_fbi(struct drm_fb_helper
*fb_helper
)
750 struct fb_info
*info
;
753 info
= kzalloc(sizeof(struct fb_info
), GFP_KERNEL
);
755 info
= framebuffer_alloc(0, dev
);
758 return ERR_PTR(-ENOMEM
);
761 ret
= fb_alloc_cmap(&info
->cmap
, 256, 0);
765 info
->apertures
= alloc_apertures(1);
766 if (!info
->apertures
) {
772 fb_helper
->fbdev
= info
;
778 fb_dealloc_cmap(&info
->cmap
);
780 framebuffer_release(info
);
784 EXPORT_SYMBOL(drm_fb_helper_alloc_fbi
);
787 * drm_fb_helper_unregister_fbi - unregister fb_info framebuffer device
788 * @fb_helper: driver-allocated fbdev helper
790 * A wrapper around unregister_framebuffer, to release the fb_info
793 void drm_fb_helper_unregister_fbi(struct drm_fb_helper
*fb_helper
)
795 if (fb_helper
&& fb_helper
->fbdev
)
796 unregister_framebuffer(fb_helper
->fbdev
);
798 EXPORT_SYMBOL(drm_fb_helper_unregister_fbi
);
801 * drm_fb_helper_release_fbi - dealloc fb_info and its members
802 * @fb_helper: driver-allocated fbdev helper
804 * A helper to free memory taken by fb_info and the members cmap and
807 void drm_fb_helper_release_fbi(struct drm_fb_helper
*fb_helper
)
810 struct fb_info
*info
= fb_helper
->fbdev
;
817 fb_dealloc_cmap(&info
->cmap
);
818 framebuffer_release(info
);
822 fb_helper
->fbdev
= NULL
;
825 EXPORT_SYMBOL(drm_fb_helper_release_fbi
);
827 void drm_fb_helper_fini(struct drm_fb_helper
*fb_helper
)
829 if (!drm_fbdev_emulation
)
832 if (!list_empty(&fb_helper
->kernel_fb_list
)) {
833 list_del(&fb_helper
->kernel_fb_list
);
834 if (list_empty(&kernel_fb_helper_list
)) {
836 unregister_sysrq_key('v', &sysrq_drm_fb_helper_restore_op
);
841 drm_fb_helper_crtc_free(fb_helper
);
844 EXPORT_SYMBOL(drm_fb_helper_fini
);
848 * drm_fb_helper_unlink_fbi - wrapper around unlink_framebuffer
849 * @fb_helper: driver-allocated fbdev helper
851 * A wrapper around unlink_framebuffer implemented by fbdev core
853 void drm_fb_helper_unlink_fbi(struct drm_fb_helper
*fb_helper
)
855 if (fb_helper
&& fb_helper
->fbdev
)
856 unlink_framebuffer(fb_helper
->fbdev
);
858 EXPORT_SYMBOL(drm_fb_helper_unlink_fbi
);
861 * drm_fb_helper_sys_read - wrapper around fb_sys_read
862 * @info: fb_info struct pointer
863 * @buf: userspace buffer to read from framebuffer memory
864 * @count: number of bytes to read from framebuffer memory
865 * @ppos: read offset within framebuffer memory
867 * A wrapper around fb_sys_read implemented by fbdev core
869 ssize_t
drm_fb_helper_sys_read(struct fb_info
*info
, char __user
*buf
,
870 size_t count
, loff_t
*ppos
)
872 return fb_sys_read(info
, buf
, count
, ppos
);
874 EXPORT_SYMBOL(drm_fb_helper_sys_read
);
877 * drm_fb_helper_sys_write - wrapper around fb_sys_write
878 * @info: fb_info struct pointer
879 * @buf: userspace buffer to write to framebuffer memory
880 * @count: number of bytes to write to framebuffer memory
881 * @ppos: write offset within framebuffer memory
883 * A wrapper around fb_sys_write implemented by fbdev core
885 ssize_t
drm_fb_helper_sys_write(struct fb_info
*info
, const char __user
*buf
,
886 size_t count
, loff_t
*ppos
)
888 return fb_sys_write(info
, buf
, count
, ppos
);
890 EXPORT_SYMBOL(drm_fb_helper_sys_write
);
893 * drm_fb_helper_sys_fillrect - wrapper around sys_fillrect
894 * @info: fbdev registered by the helper
895 * @rect: info about rectangle to fill
897 * A wrapper around sys_fillrect implemented by fbdev core
899 void drm_fb_helper_sys_fillrect(struct fb_info
*info
,
900 const struct fb_fillrect
*rect
)
902 sys_fillrect(info
, rect
);
904 EXPORT_SYMBOL(drm_fb_helper_sys_fillrect
);
907 * drm_fb_helper_sys_copyarea - wrapper around sys_copyarea
908 * @info: fbdev registered by the helper
909 * @area: info about area to copy
911 * A wrapper around sys_copyarea implemented by fbdev core
913 void drm_fb_helper_sys_copyarea(struct fb_info
*info
,
914 const struct fb_copyarea
*area
)
916 sys_copyarea(info
, area
);
918 EXPORT_SYMBOL(drm_fb_helper_sys_copyarea
);
921 * drm_fb_helper_sys_imageblit - wrapper around sys_imageblit
922 * @info: fbdev registered by the helper
923 * @image: info about image to blit
925 * A wrapper around sys_imageblit implemented by fbdev core
927 void drm_fb_helper_sys_imageblit(struct fb_info
*info
,
928 const struct fb_image
*image
)
930 sys_imageblit(info
, image
);
932 EXPORT_SYMBOL(drm_fb_helper_sys_imageblit
);
935 * drm_fb_helper_cfb_fillrect - wrapper around cfb_fillrect
936 * @info: fbdev registered by the helper
937 * @rect: info about rectangle to fill
939 * A wrapper around cfb_imageblit implemented by fbdev core
941 void drm_fb_helper_cfb_fillrect(struct fb_info
*info
,
942 const struct fb_fillrect
*rect
)
944 cfb_fillrect(info
, rect
);
946 EXPORT_SYMBOL(drm_fb_helper_cfb_fillrect
);
949 * drm_fb_helper_cfb_copyarea - wrapper around cfb_copyarea
950 * @info: fbdev registered by the helper
951 * @area: info about area to copy
953 * A wrapper around cfb_copyarea implemented by fbdev core
955 void drm_fb_helper_cfb_copyarea(struct fb_info
*info
,
956 const struct fb_copyarea
*area
)
958 cfb_copyarea(info
, area
);
960 EXPORT_SYMBOL(drm_fb_helper_cfb_copyarea
);
963 * drm_fb_helper_cfb_imageblit - wrapper around cfb_imageblit
964 * @info: fbdev registered by the helper
965 * @image: info about image to blit
967 * A wrapper around cfb_imageblit implemented by fbdev core
969 void drm_fb_helper_cfb_imageblit(struct fb_info
*info
,
970 const struct fb_image
*image
)
972 cfb_imageblit(info
, image
);
974 EXPORT_SYMBOL(drm_fb_helper_cfb_imageblit
);
977 * drm_fb_helper_set_suspend - wrapper around fb_set_suspend
978 * @fb_helper: driver-allocated fbdev helper
979 * @state: desired state, zero to resume, non-zero to suspend
981 * A wrapper around fb_set_suspend implemented by fbdev core
983 void drm_fb_helper_set_suspend(struct drm_fb_helper
*fb_helper
, int state
)
985 if (fb_helper
&& fb_helper
->fbdev
)
986 fb_set_suspend(fb_helper
->fbdev
, state
);
988 EXPORT_SYMBOL(drm_fb_helper_set_suspend
);
990 static int setcolreg(struct drm_crtc
*crtc
, u16 red
, u16 green
,
991 u16 blue
, u16 regno
, struct fb_info
*info
)
993 struct drm_fb_helper
*fb_helper
= info
->par
;
994 struct drm_framebuffer
*fb
= fb_helper
->fb
;
997 if (info
->fix
.visual
== FB_VISUAL_TRUECOLOR
) {
1000 /* place color in psuedopalette */
1003 palette
= (u32
*)info
->pseudo_palette
;
1004 red
>>= (16 - info
->var
.red
.length
);
1005 green
>>= (16 - info
->var
.green
.length
);
1006 blue
>>= (16 - info
->var
.blue
.length
);
1007 value
= (red
<< info
->var
.red
.offset
) |
1008 (green
<< info
->var
.green
.offset
) |
1009 (blue
<< info
->var
.blue
.offset
);
1010 if (info
->var
.transp
.length
> 0) {
1011 u32 mask
= (1 << info
->var
.transp
.length
) - 1;
1012 mask
<<= info
->var
.transp
.offset
;
1015 palette
[regno
] = value
;
1020 * The driver really shouldn't advertise pseudo/directcolor
1021 * visuals if it can't deal with the palette.
1023 if (WARN_ON(!fb_helper
->funcs
->gamma_set
||
1024 !fb_helper
->funcs
->gamma_get
))
1029 if (fb
->bits_per_pixel
== 16) {
1030 pindex
= regno
<< 3;
1032 if (fb
->depth
== 16 && regno
> 63)
1034 if (fb
->depth
== 15 && regno
> 31)
1037 if (fb
->depth
== 16) {
1041 for (i
= 0; i
< 8; i
++)
1042 fb_helper
->funcs
->gamma_set(crtc
, red
,
1043 green
, blue
, pindex
+ i
);
1046 fb_helper
->funcs
->gamma_get(crtc
, &r
,
1050 for (i
= 0; i
< 4; i
++)
1051 fb_helper
->funcs
->gamma_set(crtc
, r
,
1057 if (fb
->depth
!= 16)
1058 fb_helper
->funcs
->gamma_set(crtc
, red
, green
, blue
, pindex
);
1063 * drm_fb_helper_setcmap - implementation for ->fb_setcmap
1064 * @cmap: cmap to set
1065 * @info: fbdev registered by the helper
1067 int drm_fb_helper_setcmap(struct fb_cmap
*cmap
, struct fb_info
*info
)
1069 struct drm_fb_helper
*fb_helper
= info
->par
;
1070 struct drm_device
*dev
= fb_helper
->dev
;
1071 const struct drm_crtc_helper_funcs
*crtc_funcs
;
1072 u16
*red
, *green
, *blue
, *transp
;
1073 struct drm_crtc
*crtc
;
1077 if (oops_in_progress
)
1080 drm_modeset_lock_all(dev
);
1081 if (!drm_fb_helper_is_bound(fb_helper
)) {
1082 drm_modeset_unlock_all(dev
);
1086 for (i
= 0; i
< fb_helper
->crtc_count
; i
++) {
1087 crtc
= fb_helper
->crtc_info
[i
].mode_set
.crtc
;
1088 crtc_funcs
= crtc
->helper_private
;
1091 green
= cmap
->green
;
1093 transp
= cmap
->transp
;
1094 start
= cmap
->start
;
1096 for (j
= 0; j
< cmap
->len
; j
++) {
1097 u16 hred
, hgreen
, hblue
, htransp
= 0xffff;
1104 htransp
= *transp
++;
1106 rc
= setcolreg(crtc
, hred
, hgreen
, hblue
, start
++, info
);
1110 if (crtc_funcs
->load_lut
)
1111 crtc_funcs
->load_lut(crtc
);
1114 drm_modeset_unlock_all(dev
);
1117 EXPORT_SYMBOL(drm_fb_helper_setcmap
);
1120 * drm_fb_helper_check_var - implementation for ->fb_check_var
1121 * @var: screeninfo to check
1122 * @info: fbdev registered by the helper
1124 int drm_fb_helper_check_var(struct fb_var_screeninfo
*var
,
1125 struct fb_info
*info
)
1127 struct drm_fb_helper
*fb_helper
= info
->par
;
1128 struct drm_framebuffer
*fb
= fb_helper
->fb
;
1131 if (var
->pixclock
!= 0 || in_dbg_master())
1134 /* Need to resize the fb object !!! */
1135 if (var
->bits_per_pixel
> fb
->bits_per_pixel
||
1136 var
->xres
> fb
->width
|| var
->yres
> fb
->height
||
1137 var
->xres_virtual
> fb
->width
|| var
->yres_virtual
> fb
->height
) {
1138 DRM_DEBUG("fb userspace requested width/height/bpp is greater than current fb "
1139 "request %dx%d-%d (virtual %dx%d) > %dx%d-%d\n",
1140 var
->xres
, var
->yres
, var
->bits_per_pixel
,
1141 var
->xres_virtual
, var
->yres_virtual
,
1142 fb
->width
, fb
->height
, fb
->bits_per_pixel
);
1146 switch (var
->bits_per_pixel
) {
1148 depth
= (var
->green
.length
== 6) ? 16 : 15;
1151 depth
= (var
->transp
.length
> 0) ? 32 : 24;
1154 depth
= var
->bits_per_pixel
;
1160 var
->red
.offset
= 0;
1161 var
->green
.offset
= 0;
1162 var
->blue
.offset
= 0;
1163 var
->red
.length
= 8;
1164 var
->green
.length
= 8;
1165 var
->blue
.length
= 8;
1166 var
->transp
.length
= 0;
1167 var
->transp
.offset
= 0;
1170 var
->red
.offset
= 10;
1171 var
->green
.offset
= 5;
1172 var
->blue
.offset
= 0;
1173 var
->red
.length
= 5;
1174 var
->green
.length
= 5;
1175 var
->blue
.length
= 5;
1176 var
->transp
.length
= 1;
1177 var
->transp
.offset
= 15;
1180 var
->red
.offset
= 11;
1181 var
->green
.offset
= 5;
1182 var
->blue
.offset
= 0;
1183 var
->red
.length
= 5;
1184 var
->green
.length
= 6;
1185 var
->blue
.length
= 5;
1186 var
->transp
.length
= 0;
1187 var
->transp
.offset
= 0;
1190 var
->red
.offset
= 16;
1191 var
->green
.offset
= 8;
1192 var
->blue
.offset
= 0;
1193 var
->red
.length
= 8;
1194 var
->green
.length
= 8;
1195 var
->blue
.length
= 8;
1196 var
->transp
.length
= 0;
1197 var
->transp
.offset
= 0;
1200 var
->red
.offset
= 16;
1201 var
->green
.offset
= 8;
1202 var
->blue
.offset
= 0;
1203 var
->red
.length
= 8;
1204 var
->green
.length
= 8;
1205 var
->blue
.length
= 8;
1206 var
->transp
.length
= 8;
1207 var
->transp
.offset
= 24;
1214 EXPORT_SYMBOL(drm_fb_helper_check_var
);
1218 * drm_fb_helper_set_par - implementation for ->fb_set_par
1219 * @info: fbdev registered by the helper
1221 * This will let fbcon do the mode init and is called at initialization time by
1222 * the fbdev core when registering the driver, and later on through the hotplug
1225 int drm_fb_helper_set_par(struct fb_info
*info
)
1227 struct drm_fb_helper
*fb_helper
= info
->par
;
1229 struct fb_var_screeninfo
*var
= &info
->var
;
1232 #ifdef __DragonFly__
1236 if (oops_in_progress
)
1241 if (var
->pixclock
!= 0) {
1242 DRM_ERROR("PIXEL CLOCK SET\n");
1247 drm_fb_helper_restore_fbdev_mode_unlocked(fb_helper
);
1251 EXPORT_SYMBOL(drm_fb_helper_set_par
);
1254 static int pan_display_atomic(struct fb_var_screeninfo
*var
,
1255 struct fb_info
*info
)
1257 struct drm_fb_helper
*fb_helper
= info
->par
;
1258 struct drm_device
*dev
= fb_helper
->dev
;
1259 struct drm_atomic_state
*state
;
1260 struct drm_plane
*plane
;
1262 unsigned plane_mask
;
1264 state
= drm_atomic_state_alloc(dev
);
1268 state
->acquire_ctx
= dev
->mode_config
.acquire_ctx
;
1271 for(i
= 0; i
< fb_helper
->crtc_count
; i
++) {
1272 struct drm_mode_set
*mode_set
;
1274 mode_set
= &fb_helper
->crtc_info
[i
].mode_set
;
1276 mode_set
->x
= var
->xoffset
;
1277 mode_set
->y
= var
->yoffset
;
1279 ret
= __drm_atomic_helper_set_config(mode_set
, state
);
1283 plane
= mode_set
->crtc
->primary
;
1284 plane_mask
|= (1 << drm_plane_index(plane
));
1285 plane
->old_fb
= plane
->fb
;
1288 ret
= drm_atomic_commit(state
);
1292 info
->var
.xoffset
= var
->xoffset
;
1293 info
->var
.yoffset
= var
->yoffset
;
1297 drm_atomic_clean_old_fb(dev
, plane_mask
, ret
);
1299 if (ret
== -EDEADLK
)
1303 drm_atomic_state_free(state
);
1308 drm_atomic_state_clear(state
);
1309 drm_atomic_legacy_backoff(state
);
1315 * drm_fb_helper_pan_display - implementation for ->fb_pan_display
1316 * @var: updated screen information
1317 * @info: fbdev registered by the helper
1319 int drm_fb_helper_pan_display(struct fb_var_screeninfo
*var
,
1320 struct fb_info
*info
)
1322 struct drm_fb_helper
*fb_helper
= info
->par
;
1323 struct drm_device
*dev
= fb_helper
->dev
;
1324 struct drm_mode_set
*modeset
;
1328 if (oops_in_progress
)
1331 drm_modeset_lock_all(dev
);
1332 if (!drm_fb_helper_is_bound(fb_helper
)) {
1333 drm_modeset_unlock_all(dev
);
1337 if (fb_helper
->atomic
) {
1338 ret
= pan_display_atomic(var
, info
);
1342 for (i
= 0; i
< fb_helper
->crtc_count
; i
++) {
1343 modeset
= &fb_helper
->crtc_info
[i
].mode_set
;
1345 modeset
->x
= var
->xoffset
;
1346 modeset
->y
= var
->yoffset
;
1348 if (modeset
->num_connectors
) {
1349 ret
= drm_mode_set_config_internal(modeset
);
1351 info
->var
.xoffset
= var
->xoffset
;
1352 info
->var
.yoffset
= var
->yoffset
;
1357 drm_modeset_unlock_all(dev
);
1360 EXPORT_SYMBOL(drm_fb_helper_pan_display
);
1364 * Allocates the backing storage and sets up the fbdev info structure through
1365 * the ->fb_probe callback and then registers the fbdev and sets up the panic
1368 static int drm_fb_helper_single_fb_probe(struct drm_fb_helper
*fb_helper
,
1374 struct fb_info
*info
;
1375 struct drm_fb_helper_surface_size sizes
;
1377 #ifdef __DragonFly__
1378 int kms_console
= 1;
1381 memset(&sizes
, 0, sizeof(struct drm_fb_helper_surface_size
));
1382 sizes
.surface_depth
= 24;
1383 sizes
.surface_bpp
= 32;
1384 sizes
.fb_width
= (unsigned)-1;
1385 sizes
.fb_height
= (unsigned)-1;
1387 /* if driver picks 8 or 16 by default use that
1388 for both depth/bpp */
1389 if (preferred_bpp
!= sizes
.surface_bpp
)
1390 sizes
.surface_depth
= sizes
.surface_bpp
= preferred_bpp
;
1392 /* first up get a count of crtcs now in use and new min/maxes width/heights */
1393 for (i
= 0; i
< fb_helper
->connector_count
; i
++) {
1394 struct drm_fb_helper_connector
*fb_helper_conn
= fb_helper
->connector_info
[i
];
1395 struct drm_cmdline_mode
*cmdline_mode
;
1397 cmdline_mode
= &fb_helper_conn
->connector
->cmdline_mode
;
1399 if (cmdline_mode
->bpp_specified
) {
1400 switch (cmdline_mode
->bpp
) {
1402 sizes
.surface_depth
= sizes
.surface_bpp
= 8;
1405 sizes
.surface_depth
= 15;
1406 sizes
.surface_bpp
= 16;
1409 sizes
.surface_depth
= sizes
.surface_bpp
= 16;
1412 sizes
.surface_depth
= sizes
.surface_bpp
= 24;
1415 sizes
.surface_depth
= 24;
1416 sizes
.surface_bpp
= 32;
1424 for (i
= 0; i
< fb_helper
->crtc_count
; i
++) {
1425 struct drm_display_mode
*desired_mode
;
1426 struct drm_mode_set
*mode_set
;
1428 /* in case of tile group, are we the last tile vert or horiz?
1429 * If no tile group you are always the last one both vertically
1432 bool lastv
= true, lasth
= true;
1434 desired_mode
= fb_helper
->crtc_info
[i
].desired_mode
;
1435 mode_set
= &fb_helper
->crtc_info
[i
].mode_set
;
1442 x
= fb_helper
->crtc_info
[i
].x
;
1443 y
= fb_helper
->crtc_info
[i
].y
;
1445 if (gamma_size
== 0)
1446 gamma_size
= fb_helper
->crtc_info
[i
].mode_set
.crtc
->gamma_size
;
1448 sizes
.surface_width
= max_t(u32
, desired_mode
->hdisplay
+ x
, sizes
.surface_width
);
1449 sizes
.surface_height
= max_t(u32
, desired_mode
->vdisplay
+ y
, sizes
.surface_height
);
1451 for (j
= 0; j
< mode_set
->num_connectors
; j
++) {
1452 struct drm_connector
*connector
= mode_set
->connectors
[j
];
1453 if (connector
->has_tile
) {
1454 lasth
= (connector
->tile_h_loc
== (connector
->num_h_tile
- 1));
1455 lastv
= (connector
->tile_v_loc
== (connector
->num_v_tile
- 1));
1456 /* cloning to multiple tiles is just crazy-talk, so: */
1462 sizes
.fb_width
= min_t(u32
, desired_mode
->hdisplay
+ x
, sizes
.fb_width
);
1464 sizes
.fb_height
= min_t(u32
, desired_mode
->vdisplay
+ y
, sizes
.fb_height
);
1467 if (crtc_count
== 0 || sizes
.fb_width
== -1 || sizes
.fb_height
== -1) {
1468 /* hmm everyone went away - assume VGA cable just fell out
1469 and will come back later. */
1470 DRM_INFO("Cannot find any crtc or sizes - going 1024x768\n");
1471 sizes
.fb_width
= sizes
.surface_width
= 1024;
1472 sizes
.fb_height
= sizes
.surface_height
= 768;
1475 /* push down into drivers */
1476 ret
= (*fb_helper
->funcs
->fb_probe
)(fb_helper
, &sizes
);
1480 info
= fb_helper
->fbdev
;
1483 * Set the fb pointer - usually drm_setup_crtcs does this for hotplug
1484 * events, but at init time drm_setup_crtcs needs to be called before
1485 * the fb is allocated (since we need to figure out the desired size of
1486 * the fb before we can allocate it ...). Hence we need to fix things up
1489 for (i
= 0; i
< fb_helper
->crtc_count
; i
++)
1490 if (fb_helper
->crtc_info
[i
].mode_set
.num_connectors
)
1491 fb_helper
->crtc_info
[i
].mode_set
.fb
= fb_helper
->fb
;
1493 #ifdef __DragonFly__
1494 TUNABLE_INT_FETCH("kern.kms_console", &kms_console
);
1496 if (register_framebuffer(info
) < 0)
1499 list_add(&fb_helper
->kernel_fb_list
, &kernel_fb_helper_list
);
1502 info
->var
.pixclock
= 0;
1503 if (register_framebuffer(info
) < 0)
1506 dev_info(fb_helper
->dev
->dev
, "fb%d: %s frame buffer device\n",
1507 info
->node
, info
->fix
.id
);
1509 if (list_empty(&kernel_fb_helper_list
)) {
1510 register_sysrq_key('v', &sysrq_drm_fb_helper_restore_op
);
1513 list_add(&fb_helper
->kernel_fb_list
, &kernel_fb_helper_list
);
1521 * drm_fb_helper_fill_fix - initializes fixed fbdev information
1522 * @info: fbdev registered by the helper
1523 * @pitch: desired pitch
1524 * @depth: desired depth
1526 * Helper to fill in the fixed fbdev information useful for a non-accelerated
1527 * fbdev emulations. Drivers which support acceleration methods which impose
1528 * additional constraints need to set up their own limits.
1530 * Drivers should call this (or their equivalent setup code) from their
1531 * ->fb_probe callback.
1533 void drm_fb_helper_fill_fix(struct fb_info
*info
, uint32_t pitch
,
1536 info
->fix
.type
= FB_TYPE_PACKED_PIXELS
;
1537 info
->fix
.visual
= depth
== 8 ? FB_VISUAL_PSEUDOCOLOR
:
1538 FB_VISUAL_TRUECOLOR
;
1539 info
->fix
.mmio_start
= 0;
1540 info
->fix
.mmio_len
= 0;
1541 info
->fix
.type_aux
= 0;
1542 info
->fix
.xpanstep
= 1; /* doing it in hw */
1543 info
->fix
.ypanstep
= 1; /* doing it in hw */
1544 info
->fix
.ywrapstep
= 0;
1545 info
->fix
.accel
= FB_ACCEL_NONE
;
1547 info
->fix
.line_length
= pitch
;
1550 EXPORT_SYMBOL(drm_fb_helper_fill_fix
);
1553 * drm_fb_helper_fill_var - initalizes variable fbdev information
1554 * @info: fbdev instance to set up
1555 * @fb_helper: fb helper instance to use as template
1556 * @fb_width: desired fb width
1557 * @fb_height: desired fb height
1559 * Sets up the variable fbdev metainformation from the given fb helper instance
1560 * and the drm framebuffer allocated in fb_helper->fb.
1562 * Drivers should call this (or their equivalent setup code) from their
1563 * ->fb_probe callback after having allocated the fbdev backing
1564 * storage framebuffer.
1566 void drm_fb_helper_fill_var(struct fb_info
*info
, struct drm_fb_helper
*fb_helper
,
1567 uint32_t fb_width
, uint32_t fb_height
)
1569 struct drm_framebuffer
*fb
= fb_helper
->fb
;
1570 info
->pseudo_palette
= fb_helper
->pseudo_palette
;
1571 info
->var
.xres_virtual
= fb
->width
;
1572 info
->var
.yres_virtual
= fb
->height
;
1573 info
->var
.bits_per_pixel
= fb
->bits_per_pixel
;
1574 info
->var
.accel_flags
= FB_ACCELF_TEXT
;
1575 info
->var
.xoffset
= 0;
1576 info
->var
.yoffset
= 0;
1577 info
->var
.activate
= FB_ACTIVATE_NOW
;
1578 info
->var
.height
= -1;
1579 info
->var
.width
= -1;
1581 switch (fb
->depth
) {
1583 info
->var
.red
.offset
= 0;
1584 info
->var
.green
.offset
= 0;
1585 info
->var
.blue
.offset
= 0;
1586 info
->var
.red
.length
= 8; /* 8bit DAC */
1587 info
->var
.green
.length
= 8;
1588 info
->var
.blue
.length
= 8;
1589 info
->var
.transp
.offset
= 0;
1590 info
->var
.transp
.length
= 0;
1593 info
->var
.red
.offset
= 10;
1594 info
->var
.green
.offset
= 5;
1595 info
->var
.blue
.offset
= 0;
1596 info
->var
.red
.length
= 5;
1597 info
->var
.green
.length
= 5;
1598 info
->var
.blue
.length
= 5;
1599 info
->var
.transp
.offset
= 15;
1600 info
->var
.transp
.length
= 1;
1603 info
->var
.red
.offset
= 11;
1604 info
->var
.green
.offset
= 5;
1605 info
->var
.blue
.offset
= 0;
1606 info
->var
.red
.length
= 5;
1607 info
->var
.green
.length
= 6;
1608 info
->var
.blue
.length
= 5;
1609 info
->var
.transp
.offset
= 0;
1612 info
->var
.red
.offset
= 16;
1613 info
->var
.green
.offset
= 8;
1614 info
->var
.blue
.offset
= 0;
1615 info
->var
.red
.length
= 8;
1616 info
->var
.green
.length
= 8;
1617 info
->var
.blue
.length
= 8;
1618 info
->var
.transp
.offset
= 0;
1619 info
->var
.transp
.length
= 0;
1622 info
->var
.red
.offset
= 16;
1623 info
->var
.green
.offset
= 8;
1624 info
->var
.blue
.offset
= 0;
1625 info
->var
.red
.length
= 8;
1626 info
->var
.green
.length
= 8;
1627 info
->var
.blue
.length
= 8;
1628 info
->var
.transp
.offset
= 24;
1629 info
->var
.transp
.length
= 8;
1635 info
->var
.xres
= fb_width
;
1636 info
->var
.yres
= fb_height
;
1638 EXPORT_SYMBOL(drm_fb_helper_fill_var
);
1641 static int drm_fb_helper_probe_connector_modes(struct drm_fb_helper
*fb_helper
,
1645 struct drm_connector
*connector
;
1649 for (i
= 0; i
< fb_helper
->connector_count
; i
++) {
1650 connector
= fb_helper
->connector_info
[i
]->connector
;
1651 count
+= connector
->funcs
->fill_modes(connector
, maxX
, maxY
);
1657 struct drm_display_mode
*drm_has_preferred_mode(struct drm_fb_helper_connector
*fb_connector
, int width
, int height
)
1659 struct drm_display_mode
*mode
;
1661 list_for_each_entry(mode
, &fb_connector
->connector
->modes
, head
) {
1662 if (mode
->hdisplay
> width
||
1663 mode
->vdisplay
> height
)
1665 if (mode
->type
& DRM_MODE_TYPE_PREFERRED
)
1670 EXPORT_SYMBOL(drm_has_preferred_mode
);
1672 static bool drm_has_cmdline_mode(struct drm_fb_helper_connector
*fb_connector
)
1674 return fb_connector
->connector
->cmdline_mode
.specified
;
1677 struct drm_display_mode
*drm_pick_cmdline_mode(struct drm_fb_helper_connector
*fb_helper_conn
,
1678 int width
, int height
)
1680 struct drm_cmdline_mode
*cmdline_mode
;
1681 struct drm_display_mode
*mode
;
1682 bool prefer_non_interlace
;
1684 cmdline_mode
= &fb_helper_conn
->connector
->cmdline_mode
;
1685 if (cmdline_mode
->specified
== false)
1688 /* attempt to find a matching mode in the list of modes
1689 * we have gotten so far, if not add a CVT mode that conforms
1691 if (cmdline_mode
->rb
|| cmdline_mode
->margins
)
1694 prefer_non_interlace
= !cmdline_mode
->interlace
;
1696 list_for_each_entry(mode
, &fb_helper_conn
->connector
->modes
, head
) {
1697 /* check width/height */
1698 if (mode
->hdisplay
!= cmdline_mode
->xres
||
1699 mode
->vdisplay
!= cmdline_mode
->yres
)
1702 if (cmdline_mode
->refresh_specified
) {
1703 if (mode
->vrefresh
!= cmdline_mode
->refresh
)
1707 if (cmdline_mode
->interlace
) {
1708 if (!(mode
->flags
& DRM_MODE_FLAG_INTERLACE
))
1710 } else if (prefer_non_interlace
) {
1711 if (mode
->flags
& DRM_MODE_FLAG_INTERLACE
)
1717 if (prefer_non_interlace
) {
1718 prefer_non_interlace
= false;
1723 mode
= drm_mode_create_from_cmdline_mode(fb_helper_conn
->connector
->dev
,
1725 list_add(&mode
->head
, &fb_helper_conn
->connector
->modes
);
1728 EXPORT_SYMBOL(drm_pick_cmdline_mode
);
1730 static bool drm_connector_enabled(struct drm_connector
*connector
, bool strict
)
1735 enable
= connector
->status
== connector_status_connected
;
1737 enable
= connector
->status
!= connector_status_disconnected
;
1742 static void drm_enable_connectors(struct drm_fb_helper
*fb_helper
,
1745 bool any_enabled
= false;
1746 struct drm_connector
*connector
;
1749 for (i
= 0; i
< fb_helper
->connector_count
; i
++) {
1750 connector
= fb_helper
->connector_info
[i
]->connector
;
1751 enabled
[i
] = drm_connector_enabled(connector
, true);
1752 DRM_DEBUG_KMS("connector %d enabled? %s\n", connector
->base
.id
,
1753 enabled
[i
] ? "yes" : "no");
1754 any_enabled
|= enabled
[i
];
1760 for (i
= 0; i
< fb_helper
->connector_count
; i
++) {
1761 connector
= fb_helper
->connector_info
[i
]->connector
;
1762 enabled
[i
] = drm_connector_enabled(connector
, false);
1766 static bool drm_target_cloned(struct drm_fb_helper
*fb_helper
,
1767 struct drm_display_mode
**modes
,
1768 struct drm_fb_offset
*offsets
,
1769 bool *enabled
, int width
, int height
)
1772 bool can_clone
= false;
1773 struct drm_fb_helper_connector
*fb_helper_conn
;
1774 struct drm_display_mode
*dmt_mode
, *mode
;
1776 /* only contemplate cloning in the single crtc case */
1777 if (fb_helper
->crtc_count
> 1)
1781 for (i
= 0; i
< fb_helper
->connector_count
; i
++) {
1786 /* only contemplate cloning if more than one connector is enabled */
1790 /* check the command line or if nothing common pick 1024x768 */
1792 for (i
= 0; i
< fb_helper
->connector_count
; i
++) {
1795 fb_helper_conn
= fb_helper
->connector_info
[i
];
1796 modes
[i
] = drm_pick_cmdline_mode(fb_helper_conn
, width
, height
);
1801 for (j
= 0; j
< i
; j
++) {
1804 if (!drm_mode_equal(modes
[j
], modes
[i
]))
1810 DRM_DEBUG_KMS("can clone using command line\n");
1814 /* try and find a 1024x768 mode on each connector */
1816 dmt_mode
= drm_mode_find_dmt(fb_helper
->dev
, 1024, 768, 60, false);
1818 for (i
= 0; i
< fb_helper
->connector_count
; i
++) {
1823 fb_helper_conn
= fb_helper
->connector_info
[i
];
1824 list_for_each_entry(mode
, &fb_helper_conn
->connector
->modes
, head
) {
1825 if (drm_mode_equal(mode
, dmt_mode
))
1833 DRM_DEBUG_KMS("can clone using 1024x768\n");
1836 DRM_INFO("kms: can't enable cloning when we probably wanted to.\n");
1840 static int drm_get_tile_offsets(struct drm_fb_helper
*fb_helper
,
1841 struct drm_display_mode
**modes
,
1842 struct drm_fb_offset
*offsets
,
1844 int h_idx
, int v_idx
)
1846 struct drm_fb_helper_connector
*fb_helper_conn
;
1848 int hoffset
= 0, voffset
= 0;
1850 for (i
= 0; i
< fb_helper
->connector_count
; i
++) {
1851 fb_helper_conn
= fb_helper
->connector_info
[i
];
1852 if (!fb_helper_conn
->connector
->has_tile
)
1855 if (!modes
[i
] && (h_idx
|| v_idx
)) {
1856 DRM_DEBUG_KMS("no modes for connector tiled %d %d\n", i
,
1857 fb_helper_conn
->connector
->base
.id
);
1860 if (fb_helper_conn
->connector
->tile_h_loc
< h_idx
)
1861 hoffset
+= modes
[i
]->hdisplay
;
1863 if (fb_helper_conn
->connector
->tile_v_loc
< v_idx
)
1864 voffset
+= modes
[i
]->vdisplay
;
1866 offsets
[idx
].x
= hoffset
;
1867 offsets
[idx
].y
= voffset
;
1868 DRM_DEBUG_KMS("returned %d %d for %d %d\n", hoffset
, voffset
, h_idx
, v_idx
);
1872 static bool drm_target_preferred(struct drm_fb_helper
*fb_helper
,
1873 struct drm_display_mode
**modes
,
1874 struct drm_fb_offset
*offsets
,
1875 bool *enabled
, int width
, int height
)
1877 struct drm_fb_helper_connector
*fb_helper_conn
;
1879 uint64_t conn_configured
= 0, mask
;
1881 mask
= (1 << fb_helper
->connector_count
) - 1;
1883 for (i
= 0; i
< fb_helper
->connector_count
; i
++) {
1884 fb_helper_conn
= fb_helper
->connector_info
[i
];
1886 if (conn_configured
& (1 << i
))
1889 if (enabled
[i
] == false) {
1890 conn_configured
|= (1 << i
);
1894 /* first pass over all the untiled connectors */
1895 if (tile_pass
== 0 && fb_helper_conn
->connector
->has_tile
)
1898 if (tile_pass
== 1) {
1899 if (fb_helper_conn
->connector
->tile_h_loc
!= 0 ||
1900 fb_helper_conn
->connector
->tile_v_loc
!= 0)
1904 if (fb_helper_conn
->connector
->tile_h_loc
!= tile_pass
-1 &&
1905 fb_helper_conn
->connector
->tile_v_loc
!= tile_pass
- 1)
1906 /* if this tile_pass doesn't cover any of the tiles - keep going */
1909 /* find the tile offsets for this pass - need
1910 to find all tiles left and above */
1911 drm_get_tile_offsets(fb_helper
, modes
, offsets
,
1912 i
, fb_helper_conn
->connector
->tile_h_loc
, fb_helper_conn
->connector
->tile_v_loc
);
1914 DRM_DEBUG_KMS("looking for cmdline mode on connector %d\n",
1915 fb_helper_conn
->connector
->base
.id
);
1917 /* got for command line mode first */
1918 modes
[i
] = drm_pick_cmdline_mode(fb_helper_conn
, width
, height
);
1920 DRM_DEBUG_KMS("looking for preferred mode on connector %d %d\n",
1921 fb_helper_conn
->connector
->base
.id
, fb_helper_conn
->connector
->tile_group
? fb_helper_conn
->connector
->tile_group
->id
: 0);
1922 modes
[i
] = drm_has_preferred_mode(fb_helper_conn
, width
, height
);
1924 /* No preferred modes, pick one off the list */
1925 if (!modes
[i
] && !list_empty(&fb_helper_conn
->connector
->modes
)) {
1926 list_for_each_entry(modes
[i
], &fb_helper_conn
->connector
->modes
, head
)
1929 DRM_DEBUG_KMS("found mode %s\n", modes
[i
] ? modes
[i
]->name
:
1931 conn_configured
|= (1 << i
);
1934 if ((conn_configured
& mask
) != mask
) {
1941 static int drm_pick_crtcs(struct drm_fb_helper
*fb_helper
,
1942 struct drm_fb_helper_crtc
**best_crtcs
,
1943 struct drm_display_mode
**modes
,
1944 int n
, int width
, int height
)
1947 struct drm_device
*dev
= fb_helper
->dev
;
1948 struct drm_connector
*connector
;
1949 const struct drm_connector_helper_funcs
*connector_funcs
;
1950 struct drm_encoder
*encoder
;
1951 int my_score
, best_score
, score
;
1952 struct drm_fb_helper_crtc
**crtcs
, *crtc
;
1953 struct drm_fb_helper_connector
*fb_helper_conn
;
1955 if (n
== fb_helper
->connector_count
)
1958 fb_helper_conn
= fb_helper
->connector_info
[n
];
1959 connector
= fb_helper_conn
->connector
;
1961 best_crtcs
[n
] = NULL
;
1962 best_score
= drm_pick_crtcs(fb_helper
, best_crtcs
, modes
, n
+1, width
, height
);
1963 if (modes
[n
] == NULL
)
1966 crtcs
= kzalloc(dev
->mode_config
.num_connector
*
1967 sizeof(struct drm_fb_helper_crtc
*), GFP_KERNEL
);
1972 if (connector
->status
== connector_status_connected
)
1974 if (drm_has_cmdline_mode(fb_helper_conn
))
1976 if (drm_has_preferred_mode(fb_helper_conn
, width
, height
))
1979 connector_funcs
= connector
->helper_private
;
1980 encoder
= connector_funcs
->best_encoder(connector
);
1984 /* select a crtc for this connector and then attempt to configure
1985 remaining connectors */
1986 for (c
= 0; c
< fb_helper
->crtc_count
; c
++) {
1987 crtc
= &fb_helper
->crtc_info
[c
];
1989 if ((encoder
->possible_crtcs
& (1 << c
)) == 0)
1992 for (o
= 0; o
< n
; o
++)
1993 if (best_crtcs
[o
] == crtc
)
1997 /* ignore cloning unless only a single crtc */
1998 if (fb_helper
->crtc_count
> 1)
2001 if (!drm_mode_equal(modes
[o
], modes
[n
]))
2006 memcpy(crtcs
, best_crtcs
, n
* sizeof(struct drm_fb_helper_crtc
*));
2007 score
= my_score
+ drm_pick_crtcs(fb_helper
, crtcs
, modes
, n
+ 1,
2009 if (score
> best_score
) {
2011 memcpy(best_crtcs
, crtcs
,
2012 dev
->mode_config
.num_connector
*
2013 sizeof(struct drm_fb_helper_crtc
*));
2021 static void drm_setup_crtcs(struct drm_fb_helper
*fb_helper
)
2023 struct drm_device
*dev
= fb_helper
->dev
;
2024 struct drm_fb_helper_crtc
**crtcs
;
2025 struct drm_display_mode
**modes
;
2026 struct drm_fb_offset
*offsets
;
2027 struct drm_mode_set
*modeset
;
2032 DRM_DEBUG_KMS("\n");
2034 width
= dev
->mode_config
.max_width
;
2035 height
= dev
->mode_config
.max_height
;
2037 crtcs
= kcalloc(fb_helper
->connector_count
,
2038 sizeof(struct drm_fb_helper_crtc
*), GFP_KERNEL
);
2039 modes
= kcalloc(fb_helper
->connector_count
,
2040 sizeof(struct drm_display_mode
*), GFP_KERNEL
);
2041 offsets
= kcalloc(fb_helper
->connector_count
,
2042 sizeof(struct drm_fb_offset
), GFP_KERNEL
);
2043 enabled
= kcalloc(fb_helper
->connector_count
,
2044 sizeof(bool), GFP_KERNEL
);
2045 if (!crtcs
|| !modes
|| !enabled
|| !offsets
) {
2046 DRM_ERROR("Memory allocation failed\n");
2051 drm_enable_connectors(fb_helper
, enabled
);
2053 if (!(fb_helper
->funcs
->initial_config
&&
2054 fb_helper
->funcs
->initial_config(fb_helper
, crtcs
, modes
,
2056 enabled
, width
, height
))) {
2057 memset(modes
, 0, fb_helper
->connector_count
*sizeof(modes
[0]));
2058 memset(crtcs
, 0, fb_helper
->connector_count
*sizeof(crtcs
[0]));
2059 memset(offsets
, 0, fb_helper
->connector_count
*sizeof(offsets
[0]));
2061 if (!drm_target_cloned(fb_helper
, modes
, offsets
,
2062 enabled
, width
, height
) &&
2063 !drm_target_preferred(fb_helper
, modes
, offsets
,
2064 enabled
, width
, height
))
2065 DRM_ERROR("Unable to find initial modes\n");
2067 DRM_DEBUG_KMS("picking CRTCs for %dx%d config\n",
2070 drm_pick_crtcs(fb_helper
, crtcs
, modes
, 0, width
, height
);
2073 /* need to set the modesets up here for use later */
2074 /* fill out the connector<->crtc mappings into the modesets */
2075 for (i
= 0; i
< fb_helper
->crtc_count
; i
++) {
2076 modeset
= &fb_helper
->crtc_info
[i
].mode_set
;
2077 modeset
->num_connectors
= 0;
2081 for (i
= 0; i
< fb_helper
->connector_count
; i
++) {
2082 struct drm_display_mode
*mode
= modes
[i
];
2083 struct drm_fb_helper_crtc
*fb_crtc
= crtcs
[i
];
2084 struct drm_fb_offset
*offset
= &offsets
[i
];
2085 modeset
= &fb_crtc
->mode_set
;
2087 if (mode
&& fb_crtc
) {
2088 DRM_DEBUG_KMS("desired mode %s set on crtc %d (%d,%d)\n",
2089 mode
->name
, fb_crtc
->mode_set
.crtc
->base
.id
, offset
->x
, offset
->y
);
2090 fb_crtc
->desired_mode
= mode
;
2091 fb_crtc
->x
= offset
->x
;
2092 fb_crtc
->y
= offset
->y
;
2094 drm_mode_destroy(dev
, modeset
->mode
);
2095 modeset
->mode
= drm_mode_duplicate(dev
,
2096 fb_crtc
->desired_mode
);
2097 modeset
->connectors
[modeset
->num_connectors
++] = fb_helper
->connector_info
[i
]->connector
;
2098 modeset
->fb
= fb_helper
->fb
;
2099 modeset
->x
= offset
->x
;
2100 modeset
->y
= offset
->y
;
2104 /* Clear out any old modes if there are no more connected outputs. */
2105 for (i
= 0; i
< fb_helper
->crtc_count
; i
++) {
2106 modeset
= &fb_helper
->crtc_info
[i
].mode_set
;
2107 if (modeset
->num_connectors
== 0) {
2108 BUG_ON(modeset
->fb
);
2110 drm_mode_destroy(dev
, modeset
->mode
);
2111 modeset
->mode
= NULL
;
2122 * drm_fb_helper_initial_config - setup a sane initial connector configuration
2123 * @fb_helper: fb_helper device struct
2124 * @bpp_sel: bpp value to use for the framebuffer configuration
2126 * Scans the CRTCs and connectors and tries to put together an initial setup.
2127 * At the moment, this is a cloned configuration across all heads with
2128 * a new framebuffer object as the backing store.
2130 * Note that this also registers the fbdev and so allows userspace to call into
2131 * the driver through the fbdev interfaces.
2133 * This function will call down into the ->fb_probe callback to let
2134 * the driver allocate and initialize the fbdev info structure and the drm
2135 * framebuffer used to back the fbdev. drm_fb_helper_fill_var() and
2136 * drm_fb_helper_fill_fix() are provided as helpers to setup simple default
2137 * values for the fbdev info structure.
2141 * When you have fbcon support built-in or already loaded, this function will do
2142 * a full modeset to setup the fbdev console. Due to locking misdesign in the
2143 * VT/fbdev subsystem that entire modeset sequence has to be done while holding
2144 * console_lock. Until console_unlock is called no dmesg lines will be sent out
2145 * to consoles, not even serial console. This means when your driver crashes,
2146 * you will see absolutely nothing else but a system stuck in this function,
2147 * with no further output. Any kind of printk() you place within your own driver
2148 * or in the drm core modeset code will also never show up.
2150 * Standard debug practice is to run the fbcon setup without taking the
2151 * console_lock as a hack, to be able to see backtraces and crashes on the
2152 * serial line. This can be done by setting the fb.lockless_register_fb=1 kernel
2155 * The other option is to just disable fbdev emulation since very likely the
2156 * first modest from userspace will crash in the same way, and is even easier to
2157 * debug. This can be done by setting the drm_kms_helper.fbdev_emulation=0
2158 * kernel cmdline option.
2161 * Zero if everything went ok, nonzero otherwise.
2163 int drm_fb_helper_initial_config(struct drm_fb_helper
*fb_helper
, int bpp_sel
)
2165 struct drm_device
*dev
= fb_helper
->dev
;
2168 if (!drm_fbdev_emulation
)
2171 mutex_lock(&dev
->mode_config
.mutex
);
2172 count
= drm_fb_helper_probe_connector_modes(fb_helper
,
2173 dev
->mode_config
.max_width
,
2174 dev
->mode_config
.max_height
);
2175 mutex_unlock(&dev
->mode_config
.mutex
);
2177 * we shouldn't end up with no modes here.
2180 dev_info(fb_helper
->dev
->dev
, "No connectors reported connected with modes\n");
2182 drm_setup_crtcs(fb_helper
);
2184 return drm_fb_helper_single_fb_probe(fb_helper
, bpp_sel
);
2186 EXPORT_SYMBOL(drm_fb_helper_initial_config
);
2189 * drm_fb_helper_hotplug_event - respond to a hotplug notification by
2190 * probing all the outputs attached to the fb
2191 * @fb_helper: the drm_fb_helper
2193 * Scan the connectors attached to the fb_helper and try to put together a
2194 * setup after *notification of a change in output configuration.
2196 * Called at runtime, takes the mode config locks to be able to check/change the
2197 * modeset configuration. Must be run from process context (which usually means
2198 * either the output polling work or a work item launched from the driver's
2199 * hotplug interrupt).
2201 * Note that drivers may call this even before calling
2202 * drm_fb_helper_initial_config but only aftert drm_fb_helper_init. This allows
2203 * for a race-free fbcon setup and will make sure that the fbdev emulation will
2204 * not miss any hotplug events.
2207 * 0 on success and a non-zero error code otherwise.
2209 int drm_fb_helper_hotplug_event(struct drm_fb_helper
*fb_helper
)
2211 struct drm_device
*dev
= fb_helper
->dev
;
2212 u32 max_width
, max_height
;
2214 if (!drm_fbdev_emulation
)
2217 mutex_lock(&fb_helper
->dev
->mode_config
.mutex
);
2218 if (!fb_helper
->fb
|| !drm_fb_helper_is_bound(fb_helper
)) {
2219 fb_helper
->delayed_hotplug
= true;
2220 mutex_unlock(&fb_helper
->dev
->mode_config
.mutex
);
2223 DRM_DEBUG_KMS("\n");
2225 max_width
= fb_helper
->fb
->width
;
2226 max_height
= fb_helper
->fb
->height
;
2228 drm_fb_helper_probe_connector_modes(fb_helper
, max_width
, max_height
);
2229 mutex_unlock(&fb_helper
->dev
->mode_config
.mutex
);
2231 drm_modeset_lock_all(dev
);
2232 drm_setup_crtcs(fb_helper
);
2233 drm_modeset_unlock_all(dev
);
2234 drm_fb_helper_set_par(fb_helper
->fbdev
);
2238 EXPORT_SYMBOL(drm_fb_helper_hotplug_event
);
2240 /* The Kconfig DRM_KMS_HELPER selects FRAMEBUFFER_CONSOLE (if !EXPERT)
2241 * but the module doesn't depend on any fb console symbols. At least
2242 * attempt to load fbcon to avoid leaving the system without a usable console.
2244 int __init
drm_fb_helper_modinit(void)
2246 #if defined(CONFIG_FRAMEBUFFER_CONSOLE_MODULE) && !defined(CONFIG_EXPERT)
2247 const char *name
= "fbcon";
2248 struct module
*fbcon
;
2250 mutex_lock(&module_mutex
);
2251 fbcon
= find_module(name
);
2252 mutex_unlock(&module_mutex
);
2255 request_module_nowait(name
);
2259 EXPORT_SYMBOL(drm_fb_helper_modinit
);