1494N/A * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. 1494N/A * Copyright (c) 2006-2009 Red Hat Inc. 1494N/A * Copyright (c) 2006-2008, 2013, Intel Corporation 1494N/A * Copyright (c) 2007 Dave Airlie <airlied@linux.ie> 1494N/A * DRM framebuffer helper functions 1494N/A * Permission to use, copy, modify, distribute, and sell this software and its 1494N/A * documentation for any purpose is hereby granted without fee, provided that 1494N/A * the above copyright notice appear in all copies and that both that copyright 1494N/A * notice and this permission notice appear in supporting documentation, and 1494N/A * that the name of the copyright holders not be used in advertising or 1494N/A * publicity pertaining to distribution of the software without specific, 1494N/A * written prior permission. The copyright holders make no representations 1494N/A * about the suitability of this software for any purpose. It is provided "as 1494N/A * is" without express or implied warranty. 1494N/A * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, 1494N/A * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO 1494N/A * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR 1494N/A * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, 1494N/A * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER 1494N/A * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE 1494N/A * Dave Airlie <airlied@linux.ie> 1494N/A * Jesse Barnes <jesse.barnes@intel.com> 1494N/A * The fb helper functions are useful to provide an fbdev on top of a drm kernel 1494N/A * mode setting driver. They can be used mostly independantely from the crtc 1494N/A * helper functions used by many drivers to implement the kernel mode setting 1494N/A * Initialization is done as a three-step process with drm_fb_helper_init(), 1494N/A * drm_fb_helper_single_add_all_connectors() and drm_fb_helper_initial_config(). 1494N/A * Drivers with fancier requirements than the default beheviour can override the 1494N/A * second step with their own code. Teardown is done with drm_fb_helper_fini(). 1494N/A * At runtime drivers should restore the fbdev console by calling 1494N/A * drm_fb_helper_restore_fbdev_mode() from their ->lastclose callback. They 1494N/A * should also notify the fb helper code from updates to the output 1494N/A * configuration by calling drm_fb_helper_hotplug_event(). For easier 1494N/A * code proves a ->output_poll_changed callback. 1494N/A * All other functions exported by the fb helper library can be used to 1494N/A * implement the fbdev driver interface by the driver. 1494N/A/* simple single crtc case helper function 1494N/A * drm_fb_helper_single_add_all_connectors() - add all connectors to fbdev 1494N/A * @fb_helper: fbdev initialized with drm_fb_helper_init 1494N/A * This functions adds all the available connectors for use with the given 1494N/A * fb_helper. This is a separate step to allow drivers to freely assign 1494N/A * connectors to the fbdev, e.g. if some are reserved for special purposes or 1494N/A * not adequate to be used for the fbcon. 1494N/A * Since this is part of the initial setup before the fbdev is published, no 1494N/A/* Find the real fb for a given fb helper CRTC */ 1494N/A/* maximum connectors per crtcs in the mode set */ 1494N/A /* if driver picks 8 or 16 by default use that 1494N/A /* hmm everyone went away - assume VGA cable just fell out 1494N/A and will come back later. */ 1494N/A /* push down into drivers */ 1494N/A * Set the fb pointer - usually drm_setup_crtcs does this for hotplug 1494N/A * events, but at init time drm_setup_crtcs needs to be called before 1494N/A * the fb is allocated (since we need to figure out the desired size of 1494N/A * the fb before we can allocate it ...). Hence we need to fix things up 1494N/A /* Switch back to kernel console on panic */ 1494N/A /* multi card linked list maybe */ 1494N/A /* LINTED E_FUNC_ARG_UNUSED */ 1494N/A /* attempt to find a matching mode in the list of modes 1494N/A * we have gotten so far, if not add a CVT mode that conforms 1494N/A /* only contemplate cloning in the single crtc case */ 1494N/A /* only contemplate cloning if more than one connector is enabled */ 1494N/A /* check the command line or if nothing common pick 1024x768 */ 1494N/A /* try and find a 1024x768 mode on each connector */ 1494N/A DRM_INFO(
"kms: can't enable cloning when we probably wanted to.\n");
1494N/A /* got for command line mode first */ 1494N/A /* No preferred modes, pick one off the list */ 1494N/A /* select a crtc for this connector and then attempt to configure 1494N/A /* ignore cloning unless only a single crtc */ 1494N/A /* need to set the modesets up here for use later */ 1494N/A /* fill out the connector<->crtc mappings into the modesets */ 1494N/A /* Clear out any old modes if there are no more connected outputs. */ 1494N/A * drm_helper_initial_config - setup a sane initial connector configuration 1494N/A * Scan the CRTCs and connectors and try to put together an initial setup. 1494N/A * At the moment, this is a cloned configuration across all heads with 1494N/A * a new framebuffer object as the backing store. 1494N/A * Note that this also registers the fbdev and so allows userspace to call into 1494N/A * the driver through the fbdev interfaces. 1494N/A * This function will call down into the ->fb_probe callback to let 1494N/A * the driver allocate and initialize the fbdev info structure and the drm 1494N/A * framebuffer used to back the fbdev. drm_fb_helper_fill_var() and 1494N/A * drm_fb_helper_fill_fix() are provided as helpers to setup simple default 1494N/A * values for the fbdev info structure. 1494N/A * Zero if everything went ok, nonzero otherwise. 1494N/A * we shouldn't end up with no modes here. 1494N/A * drm_fb_helper_hotplug_event - respond to a hotplug notification by 1494N/A * probing all the outputs attached to the fb. 1494N/A * @fb_helper: the drm_fb_helper 1494N/A * Scan the connectors attached to the fb_helper and try to put together a 1494N/A * setup after *notification of a change in output configuration. 1494N/A * modeset configuration. Must be run from process context (which usually means 1494N/A * either the output polling work or a work item launched from the driver's 1494N/A * Scan the connectors attached to the fb_helper and try to put together a 1494N/A * setup after *notification of a change in output configuration. 1494N/A * 0 on success and a non-zero error code otherwise.