/*
*/
/*
* Copyright (c) 2006-2007, 2013, Intel Corporation
* Copyright (c) 2006 Dave Airlie <airlied@linux.ie>
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice (including the next
* paragraph) shall be included in all copies or substantial portions of the
* Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*
* Authors:
* Eric Anholt <eric@anholt.net>
* Dave Airlie <airlied@linux.ie>
* Jesse Barnes <jesse.barnes@intel.com>
*/
#include "drmP.h"
#include "drm.h"
#include "drm_crtc.h"
#include "drm_edid.h"
#include "drm_sun_i2c.h" /* OSOL_i915 */
#include "intel_drv.h"
#include "i915_drm.h"
#include "i915_drv.h"
/* Private structure for the integrated LVDS support */
struct intel_lvds_connector {
int fitting_mode;
};
struct intel_lvds_encoder {
bool is_dual_link;
};
{
}
{
}
{
if (!(tmp & LVDS_PORT_EN))
return false;
if (HAS_PCH_CPT(dev))
else
return true;
}
struct intel_crtc_config *pipe_config)
{
if (HAS_PCH_SPLIT(dev))
else
if (tmp & LVDS_HSYNC_POLARITY)
else
if (tmp & LVDS_VSYNC_POLARITY)
else
/* gen2/3 store dither state in pfit control, needs to match */
}
}
/* The LVDS pin pair needs to be on before the DPLLs are enabled.
* This is an exception to the general rule that mode_set doesn't turn
* things on.
*/
{
if (HAS_PCH_CPT(dev)) {
temp &= ~PORT_TRANS_SEL_MASK;
} else {
if (pipe == 1) {
} else {
temp &= ~LVDS_PIPEB_SELECT;
}
}
/* set the corresponsding LVDS_BORDER bit */
temp &= ~LVDS_BORDER_ENABLE;
/* Set the B0-B3 data pairs corresponding to whether we're going to
* set the DPLLs for dual-channel mode or not.
*/
if (lvds_encoder->is_dual_link)
else
/* It would be nice to set 24 vs 18-bit mode (LVDS_A3_POWER_UP)
* appropriately here, but we need to look more thoroughly into how
* panels behave in the two modes.
*/
/* Set the dithering flag on LVDS as needed, note that there is no
* special lvds dither control bit on pch-split platforms, dithering is
* only controlled through the PIPECONF reg. */
/* Bspec wording suggests that LVDS port dithering only exists
* for 18bpp panels. */
else
temp &= ~LVDS_ENABLE_DITHER;
}
}
/**
* Sets the power state for the panel.
*/
{
if (HAS_PCH_SPLIT(dev)) {
} else {
}
DRM_ERROR("timed out waiting for panel to power on\n");
}
{
if (HAS_PCH_SPLIT(dev)) {
} else {
}
DRM_ERROR("timed out waiting for panel to power off\n");
}
struct drm_display_mode *mode)
{
return MODE_PANEL;
return MODE_PANEL;
return MODE_OK;
}
struct intel_crtc_config *pipe_config)
{
unsigned int lvds_bpp;
/* Should never happen!! */
DRM_ERROR("Can't support LVDS on pipe A\n");
return false;
}
else
DRM_DEBUG_KMS("forcing display bpp (was %d) to LVDS (%d)\n",
}
/*
* We have timings from the BIOS for the panel, put them in
* to the adjusted mode. The CRTC will be set up for this mode,
* of the original mode.
*/
if (HAS_PCH_SPLIT(dev)) {
pipe_config->has_pch_encoder = true;
} else {
}
/*
* XXX: It would be nice to support lower refresh rates on the
* panels to reduce power consumption, and perhaps match the
* user's requested refresh rate.
*/
return true;
}
/* LINTED */
struct drm_display_mode *mode,
/* LINTED */
struct drm_display_mode *adjusted_mode)
{
/*
* The LVDS pin pair will already have been turned on in the
* intel_crtc_mode_set since it has a large impact on the DPLL
* settings.
*/
}
/**
* Detect the LVDS connection.
*
* Since LVDS doesn't have hotlug, we use the lid as a proxy. Open means
* connected and closed means disconnected. We also send hotplug events as
* needed, using lid status notification from the input layer.
*/
static enum drm_connector_status
{
if (status != connector_status_unknown)
return status;
return connector_status_connected;
}
/**
* Return the list of DDC modes if available, or the BIOS fixed mode otherwise.
*/
{
/* use cached edid if we have one */
return 0;
return 1;
}
/* OSOL_I915 */
#if 0
{
return 1;
}
/* The GPU hangs up on these systems if modeset is performed on LID open */
static const struct dmi_system_id intel_no_modeset_on_lid[] = {
{
.ident = "Toshiba Tecra A11",
.matches = {
},
},
{ } /* terminating entry */
};
/*
* Lid events. Note the use of 'modeset_on_lid':
* - we set it on lid close, and reset it on open
* - we use it as a "only once" bit (ie we ignore
* duplicate events where it was already properly
* zero, since they restore the mode ("lid open").
*/
void *unused)
{
struct intel_lvds_connector *lvds_connector =
return NOTIFY_OK;
goto exit;
/*
* check and update the status of LVDS connector after receiving
* the LID nofication event.
*/
/* Don't force modeset on machines where it causes a GPU lockup */
goto exit;
if (!acpi_lid_open()) {
/* do modeset on next lid open event */
goto exit;
}
goto exit;
intel_modeset_setup_hw_state(dev, true);
exit:
return NOTIFY_OK;
}
#endif
/**
* intel_lvds_destroy - unregister and free LVDS structures
* @connector: connector to free
*
* Unregister the DDC bus for this connector then free the driver private
* structure.
*/
{
/* OSOL_i915: drm_sysfs_connector_remove(connector); */
}
struct drm_property *property,
{
if (value == DRM_MODE_SCALE_NONE) {
DRM_DEBUG_KMS("no scaling not supported\n");
return -EINVAL;
}
/* the LVDS scaling property is not changed */
return 0;
}
/*
* If the CRTC is enabled, the display will be changed
* according to the new panel fitting mode.
*/
}
}
return 0;
}
};
};
};
};
/* OSOL_I915 */
#if 0
{
return 1;
}
/* These systems claim to have LVDS, but really don't */
static const struct dmi_system_id intel_no_lvds[] = {
{
.ident = "Apple Mac Mini (Core series)",
.matches = {
},
},
{
.ident = "Apple Mac Mini (Core 2 series)",
.matches = {
},
},
{
.ident = "MSI IM-945GSE-A",
.matches = {
},
},
{
.ident = "Dell Studio Hybrid",
.matches = {
},
},
{
.ident = "Dell OptiPlex FX170",
.matches = {
},
},
{
.ident = "AOpen Mini PC",
.matches = {
},
},
{
.ident = "AOpen Mini PC MP915",
.matches = {
},
},
{
.ident = "AOpen i915GMm-HFS",
.matches = {
},
},
{
.ident = "AOpen i45GMx-I",
.matches = {
},
},
{
.ident = "Aopen i945GTt-VFA",
.matches = {
},
},
{
.ident = "Clientron U800",
.matches = {
},
},
{
.ident = "Clientron E830",
.matches = {
},
},
{
.ident = "Asus EeeBox PC EB1007",
.matches = {
},
},
{
.ident = "Asus AT5NM10T-I",
.matches = {
},
},
{
.ident = "Hewlett-Packard HP t5740",
.matches = {
},
},
{
.ident = "Hewlett-Packard t5745",
.matches = {
},
},
{
.ident = "Hewlett-Packard st5747",
.matches = {
},
},
{
.ident = "MSI Wind Box DC500",
.matches = {
},
},
{
.ident = "Gigabyte GA-D525TUD",
.matches = {
},
},
{
.ident = "Supermicro X7SPA-H",
.matches = {
},
},
{
.ident = "Fujitsu Esprimo Q900",
.matches = {
},
},
{
.ident = "Intel D510MO",
.matches = {
},
},
{
.ident = "Intel D525MW",
.matches = {
},
},
{ } /* terminating entry */
};
#endif
/**
* intel_find_lvds_downclock - find the reduced downclock for LVDS in EDID
* @dev: drm device
* @connector: LVDS connector
*
* Find the reduced downclock for LVDS in EDID.
*/
struct drm_display_mode *fixed_mode,
struct drm_connector *connector)
{
int temp_downclock;
/*
* If one mode has the same resolution with the fixed_panel
* mode while they have the different refresh rate, it means
* that the reduced downclock is found for the LVDS. In such
* case we can set the different FPx0/1 to dynamically select
* between low and high frequency.
*/
/*
* The downclock is already found. But we
* expect to find the lower downclock.
*/
}
}
}
/* We found the downclock for LVDS. */
DRM_DEBUG_KMS("LVDS downclock is found in EDID. "
"Normal clock %dKhz, downclock %dKhz\n",
}
}
/*
* Enumerate the child dev array parsed from VBT to check whether
* the LVDS is present.
* If it is present, return 1.
* If it is not present, return false.
* If no child dev is parsed from VBT, it assumes that the LVDS is present.
*/
{
int i;
return true;
/*
* If the device type is not LFP, continue.
* If the device type is 0x22, it is also regarded as LFP.
* old for compatibility with some BIOSes.
*/
continue;
/* However, we cannot trust the BIOS writers to populate
* the VBT correctly. Since LVDS requires additional
* information from AIM blocks, a non-zero addin offset is
* a good indicator that the LVDS is actually present.
*/
if (child->addin_offset)
return true;
/* But even then some BIOS writers perform some black magic
* and instantiate the device without reference to any
* additional data. Trust that if the VBT was written into
* the OpRegion then they have validated the LVDS's existence.
*/
return true;
}
return false;
}
{
return lvds_encoder->is_dual_link;
}
}
return false;
}
{
unsigned int val;
/* use the module option value if specified */
if (i915_lvds_channel_mode > 0)
return i915_lvds_channel_mode == 2;
/* BIOS should set the proper LVDS register value at boot, but
* in reality, it doesn't set the value when the lid is closed;
* we need to check "the value to be set" in VBT when LVDS
* register is uninitialized.
*/
}
{
/* With the introduction of the PCH we gained a dedicated
* LVDS presence pin, use it. */
return true;
/* Otherwise LVDS was only attached to mobile products,
* except for the inglorious 830gm */
return true;
return false;
}
/**
* intel_lvds_init - setup LVDS connectors on this device
* @dev: drm device
*
* Create the connector, register the LVDS DDC bus, and try to figure out what
* modes we can display on the LVDS panel (if present).
*/
{
int pipe;
if (!intel_lvds_supported(dev))
return;
/* Skip init on machines we know falsely report LVDS */
//XXX if (dmi_check_system(intel_no_lvds))
// return;
DRM_DEBUG_KMS("LVDS is not present in VBT\n");
return;
}
if (HAS_PCH_SPLIT(dev)) {
return;
DRM_DEBUG_KMS("disable LVDS for eDP support\n");
return;
}
}
if (!lvds_encoder)
return;
if (!lvds_connector) {
return;
}
intel_encoder->cloneable = false;
if (HAS_PCH_SPLIT(dev))
else
connector->interlace_allowed = false;
connector->doublescan_allowed = false;
if (HAS_PCH_SPLIT(dev)) {
} else {
}
/* create the scaling mode property */
(void) drm_mode_create_scaling_mode_property(dev);
/*
* LVDS discovery:
* 1) check for EDID on DDC
* 2) check for VBT data
* 3) check to see if LVDS is already on
* if none of the above, no panel
* 4) make sure lid is open
* if closed, act like it's not there for now
*/
/*
* Attempt to get the fixed panel mode from DDC. Assume that the
* preferred mode is the right one.
*/
if (edid) {
edid);
} else {
}
} else {
}
if (IS_ERR_OR_NULL(edid)) {
/* Didn't get an EDID, so
* Set wide sync ranges so we get all modes
* handed to valid_mode for checking
*/
}
DRM_DEBUG_KMS("using preferred mode from EDID: ");
if (fixed_mode) {
goto out;
}
}
}
/* Failed to get EDID, what about VBT? */
DRM_DEBUG_KMS("using mode from VBT: ");
if (fixed_mode) {
goto out;
}
}
/*
* If we didn't get EDID, try checking if the panel is already turned
* on. If so, assume that whatever is currently programmed is the
* correct mode.
*/
/* Ironlake: FIXME if still fail, not try pipe mode now */
if (HAS_PCH_SPLIT(dev))
goto failed;
if (fixed_mode) {
DRM_DEBUG_KMS("using current (BIOS) mode: ");
goto out;
}
}
/* If we still don't have a mode after all that, give up. */
if (!fixed_mode)
goto failed;
out:
DRM_DEBUG_KMS("detected %s-link lvds configuration\n",
/*
* Unlock registers and just
* leave them unlocked
*/
if (HAS_PCH_SPLIT(dev)) {
} else {
}
// XXX dev_priv->lid_notifier.notifier_call = intel_lid_notify;
/* XXX lack of acpi support
if (acpi_lid_notifier_register(&dev_priv->lid_notifier)) {
DRM_DEBUG("lid notifier registration failed\n");
dev_priv->lid_notifier.notifier_call = NULL;
} */
/* OSOL_i915: drm_sysfs_connector_add(connector); */
return;
DRM_DEBUG_KMS("No LVDS modes found, disabling.\n");
if (fixed_mode)
return;
}