/*
*/
/*
* Copyright 2006 Dave Airlie <airlied@linux.ie>
* Copyright (c) 2006-2009, 2013, Intel Corporation
*
* 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>
* Jesse Barnes <jesse.barnes@intel.com>
*/
#include "drmP.h"
#include "drm.h"
#include "drm_crtc.h"
#include "drm_edid.h"
#include "intel_drv.h"
#include "i915_drm.h"
#include "i915_drv.h"
#include "drm_sun_i2c.h" /* OSOL_i915 */
{
}
static void
{
DRM_ERROR("HDMI port enabled, expecting disabled\n");
}
{
return &intel_dig_port->hdmi;
}
{
}
{
unsigned i;
}
{
case DIP_TYPE_AVI:
return VIDEO_DIP_SELECT_AVI;
case DIP_TYPE_SPD:
return VIDEO_DIP_SELECT_SPD;
default:
return 0;
}
}
{
case DIP_TYPE_AVI:
return VIDEO_DIP_ENABLE_AVI;
case DIP_TYPE_SPD:
return VIDEO_DIP_ENABLE_SPD;
default:
return 0;
}
}
{
case DIP_TYPE_AVI:
return VIDEO_DIP_ENABLE_AVI_HSW;
case DIP_TYPE_SPD:
return VIDEO_DIP_ENABLE_SPD_HSW;
default:
return 0;
}
}
enum transcoder cpu_transcoder)
{
case DIP_TYPE_AVI:
return HSW_TVIDEO_DIP_AVI_DATA(cpu_transcoder);
case DIP_TYPE_SPD:
return HSW_TVIDEO_DIP_SPD_DATA(cpu_transcoder);
default:
return 0;
}
}
struct dip_infoframe *frame)
{
/* LINTED */
if (!(val & VIDEO_DIP_ENABLE))
DRM_ERROR("Writing DIP with CTL reg disabled\n");
// mmiowb();
for (i = 0; i < len; i += 4) {
data++;
}
/* Write every possible data byte to force correct ECC calculation. */
for (; i < VIDEO_DIP_DATA_SIZE; i += 4)
I915_WRITE(VIDEO_DIP_DATA, 0);
// mmiowb();
val &= ~VIDEO_DIP_FREQ_MASK;
}
struct dip_infoframe *frame)
{
/* LINTED */
if (!(val & VIDEO_DIP_ENABLE))
DRM_ERROR("Writing DIP with CTL reg disabled\n");
// mmiowb();
for (i = 0; i < len; i += 4) {
data++;
}
/* Write every possible data byte to force correct ECC calculation. */
for (; i < VIDEO_DIP_DATA_SIZE; i += 4)
// mmiowb();
val &= ~VIDEO_DIP_FREQ_MASK;
}
struct dip_infoframe *frame)
{
/* LINTED */
if (!(val & VIDEO_DIP_ENABLE))
DRM_ERROR("Writing DIP with CTL reg disabled\n");
/* The DIP control register spec says that we need to update the AVI
* infoframe without clearing its enable bit */
// mmiowb();
for (i = 0; i < len; i += 4) {
data++;
}
/* Write every possible data byte to force correct ECC calculation. */
for (; i < VIDEO_DIP_DATA_SIZE; i += 4)
// mmiowb();
val &= ~VIDEO_DIP_FREQ_MASK;
}
struct dip_infoframe *frame)
{
/* LINTED */
if (!(val & VIDEO_DIP_ENABLE))
DRM_ERROR("Writing DIP with CTL reg disabled\n");
// mmiowb();
for (i = 0; i < len; i += 4) {
data++;
}
/* Write every possible data byte to force correct ECC calculation. */
for (; i < VIDEO_DIP_DATA_SIZE; i += 4)
// mmiowb();
val &= ~VIDEO_DIP_FREQ_MASK;
}
struct dip_infoframe *frame)
{
/* LINTED */
if (data_reg == 0)
return;
// mmiowb();
for (i = 0; i < len; i += 4) {
data++;
}
/* Write every possible data byte to force correct ECC calculation. */
for (; i < VIDEO_DIP_DATA_SIZE; i += 4)
I915_WRITE(data_reg + i, 0);
// mmiowb();
}
struct dip_infoframe *frame)
{
}
struct drm_display_mode *adjusted_mode)
{
.type = DIP_TYPE_AVI,
.ver = DIP_VERSION_AVI,
.len = DIP_LEN_AVI,
};
if (intel_hdmi->rgb_quant_range_selectable) {
else
}
}
{
}
struct drm_display_mode *adjusted_mode)
{
/* If the registers were not initialized yet, they might be zeroes,
* which means we're selecting the AVI DIP and we're setting its
* frequency to once. This seems to really confuse the HW and make
* things stop working (the register spec says the AVI always needs to
* be sent every VSync). So here we avoid writing to the register more
* than we need and also explicitly select the AVI DIP and explicitly
* set its frequency to every VSync. Avoiding to write it twice seems to
* be enough to solve the problem, but being defensive shouldn't hurt us
* either. */
if (!intel_hdmi->has_hdmi_sink) {
if (!(val & VIDEO_DIP_ENABLE))
return;
val &= ~VIDEO_DIP_ENABLE;
return;
}
switch (intel_dig_port->port) {
case PORT_B:
break;
case PORT_C:
break;
default:
BUG();
return;
}
if (val & VIDEO_DIP_ENABLE) {
val &= ~VIDEO_DIP_ENABLE;
}
val &= ~VIDEO_DIP_PORT_MASK;
}
val |= VIDEO_DIP_ENABLE;
}
struct drm_display_mode *adjusted_mode)
{
/* See the big comment in g4x_set_infoframes() */
if (!intel_hdmi->has_hdmi_sink) {
if (!(val & VIDEO_DIP_ENABLE))
return;
val &= ~VIDEO_DIP_ENABLE;
return;
}
switch (intel_dig_port->port) {
case PORT_B:
break;
case PORT_C:
break;
case PORT_D:
break;
default:
BUG();
return;
}
if (val & VIDEO_DIP_ENABLE) {
val &= ~VIDEO_DIP_ENABLE;
}
val &= ~VIDEO_DIP_PORT_MASK;
}
val |= VIDEO_DIP_ENABLE;
}
struct drm_display_mode *adjusted_mode)
{
/* See the big comment in g4x_set_infoframes() */
if (!intel_hdmi->has_hdmi_sink) {
if (!(val & VIDEO_DIP_ENABLE))
return;
return;
}
/* Set both together, unset both together: see the spec. */
}
struct drm_display_mode *adjusted_mode)
{
/* See the big comment in g4x_set_infoframes() */
if (!intel_hdmi->has_hdmi_sink) {
if (!(val & VIDEO_DIP_ENABLE))
return;
val &= ~VIDEO_DIP_ENABLE;
return;
}
val |= VIDEO_DIP_ENABLE;
}
struct drm_display_mode *adjusted_mode)
{
if (!intel_hdmi->has_hdmi_sink) {
I915_WRITE(reg, 0);
return;
}
}
/* LINTED */
struct drm_display_mode *mode,
struct drm_display_mode *adjusted_mode)
{
if (!HAS_PCH_SPLIT(dev))
else
/* Required on CPT */
if (intel_hdmi->has_audio) {
DRM_DEBUG_DRIVER("Enabling HDMI audio on pipe %c\n",
}
if (HAS_PCH_CPT(dev))
else
}
{
if (!(tmp & SDVO_ENABLE))
return false;
if (HAS_PCH_CPT(dev))
else
return true;
}
struct intel_crtc_config *pipe_config)
{
if (tmp & SDVO_HSYNC_ACTIVE_HIGH)
else
if (tmp & SDVO_VSYNC_ACTIVE_HIGH)
else
}
{
if (intel_hdmi->has_audio)
/* HW workaround for IBX, we need to move the port to transcoder A
* before disabling it, so restore the transcoder select bit here. */
if (HAS_PCH_IBX(dev))
/* HW workaround, need to toggle enable bit off and on for 12bpc, but
* we do this anyway which shows more stable in testing.
*/
if (HAS_PCH_SPLIT(dev)) {
}
temp |= enable_bits;
/* HW workaround, need to write this twice for issue that may result
* in first write getting masked.
*/
if (HAS_PCH_SPLIT(dev)) {
}
if (IS_VALLEYVIEW(dev)) {
}
}
{
/* HW workaround for IBX, we need to move the port to transcoder A
* before disabling it. */
if (HAS_PCH_IBX(dev)) {
if (temp & SDVO_PIPE_B_SELECT) {
temp &= ~SDVO_PIPE_B_SELECT;
/* Again we need to write this twice. */
/* Transcoder selection bits only update
* effectively on vblank. */
if (crtc)
else
msleep(50);
}
}
/* HW workaround, need to toggle enable bit off and on for 12bpc, but
* we do this anyway which shows more stable in testing.
*/
if (HAS_PCH_SPLIT(dev)) {
}
temp &= ~enable_bits;
/* HW workaround, need to write this twice for issue that may result
* in first write getting masked.
*/
if (HAS_PCH_SPLIT(dev)) {
}
}
{
return 165000;
else if (IS_HASWELL(dev))
return 300000;
else
return 225000;
}
struct drm_display_mode *mode)
{
return MODE_CLOCK_HIGH;
return MODE_CLOCK_LOW;
return MODE_NO_DBLESCAN;
return MODE_OK;
}
struct intel_crtc_config *pipe_config)
{
int desired_bpp;
if (intel_hdmi->color_range_auto) {
/* See CEA-861-E - 5.1 Default Encoding Parameters */
if (intel_hdmi->has_hdmi_sink &&
else
intel_hdmi->color_range = 0;
}
if (intel_hdmi->color_range)
pipe_config->limited_color_range = true;
pipe_config->has_pch_encoder = true;
/*
* HDMI is either 12 or 8, so if the display lets 10bpc sneak
* outputs. We also need to check that the higher clock still fits
* within limits.
*/
&& HAS_PCH_SPLIT(dev)) {
DRM_DEBUG_KMS("picking bpc to 12 for HDMI output\n");
/* Need to adjust the port link by 1.5x for 12bpc. */
} else {
DRM_DEBUG_KMS("picking bpc to 8 for HDMI output\n");
}
if (!pipe_config->bw_constrained) {
}
DRM_DEBUG_KMS("too high HDMI clock, rejecting mode\n");
return false;
}
return true;
}
static enum drm_connector_status
{
intel_hdmi->has_hdmi_sink = false;
intel_hdmi->has_audio = false;
intel_hdmi->rgb_quant_range_selectable = false;
intel_hdmi->ddc_bus));
if (edid) {
}
}
if (status == connector_status_connected) {
}
return status;
}
{
/* We should parse the EDID data and find out if it's an HDMI sink so
* we can send audio to it.
*/
return intel_ddc_get_modes(connector,
intel_hdmi->ddc_bus));
}
static bool
{
bool has_audio = false;
intel_hdmi->ddc_bus));
if (edid) {
}
return has_audio;
}
static int
struct drm_property *property,
{
int ret;
if (ret)
return ret;
bool has_audio;
if (i == intel_hdmi->force_audio)
return 0;
intel_hdmi->force_audio = i;
if (i == HDMI_AUDIO_AUTO)
else
has_audio = (i == HDMI_AUDIO_ON);
if (i == HDMI_AUDIO_OFF_DVI)
intel_hdmi->has_hdmi_sink = 0;
goto done;
}
switch (val) {
case INTEL_BROADCAST_RGB_AUTO:
intel_hdmi->color_range_auto = true;
break;
case INTEL_BROADCAST_RGB_FULL:
intel_hdmi->color_range_auto = false;
intel_hdmi->color_range = 0;
break;
intel_hdmi->color_range_auto = false;
break;
default:
return -EINVAL;
}
return 0;
goto done;
}
return -EINVAL;
done:
return 0;
}
{
if (!IS_VALLEYVIEW(dev))
return;
/* Enable clock channels for this port */
val = 0;
if (pipe)
else
val |= 0x001000c4;
/* HDMI 1.0V-2dB */
0x2b245f5f);
0x5578b83a);
0x0c782040);
0x2b247878);
0x00002000);
/* Program lane clock */
0x00760018);
0x00400888);
}
{
if (!IS_VALLEYVIEW(dev))
return;
/* Program Tx lane resets to default */
(1<<DPIO_PCS_CLK_DATAWIDTH_SHIFT) |
/* Fix up inter-pair skew failure */
0x00002000);
}
{
/* Reset lanes to avoid HDMI flicker (VLV w/a) */
}
{
}
};
};
};
};
static void
{
intel_hdmi->color_range_auto = true;
}
struct intel_connector *intel_connector)
{
connector->doublescan_allowed = 0;
switch (port) {
case PORT_B:
break;
case PORT_C:
break;
case PORT_D:
break;
case PORT_A:
/* Internal port only for eDP. */
default:
BUG();
}
if (IS_VALLEYVIEW(dev)) {
} else if (!HAS_PCH_SPLIT(dev)) {
} else if (HAS_PCH_IBX(dev)) {
} else {
}
else
// drm_sysfs_connector_add(connector);
/* For G4X desktop chip, PEG_BAND_GAP_DATA 3:0 must first be written
* 0xd. Failure to do so will result in spurious interrupts being
* generated on the port when a cable is not attached.
*/
}
}
{
if (!intel_dig_port)
return;
if (!intel_connector) {
return;
}
if (IS_VALLEYVIEW(dev)) {
}
intel_encoder->cloneable = false;
}