gma500: Add Poulsbo support
This provides the specific code for Poulsbo, some of which is also used for the later chipsets. We support the GTT, the 2D engine (for console), and the display setup/management. We do not support 3D or the video overlays. In theory enough public info is available to do the video overlay work but that represents a large task. Framebuffer X will run nicely with this but do *NOT* use the VESA X server at the same time as KMS. With a Dell mini 10 things like Xfce4 are nice and usable even when compositing as the CPU has a good path to the memory. Signed-off-by: Alan Cox <alan@linux.intel.com> Signed-off-by: Dave Airlie <airlied@redhat.com>
This commit is contained in:
Родитель
5c49fd3aa0
Коммит
89c78134cc
|
@ -0,0 +1,353 @@
|
|||
/**************************************************************************
|
||||
* Copyright (c) 2011, Intel Corporation.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms and conditions of the GNU General Public License,
|
||||
* version 2, as published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
* more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
**************************************************************************/
|
||||
|
||||
#include <linux/backlight.h>
|
||||
#include <drm/drmP.h>
|
||||
#include <drm/drm.h>
|
||||
#include "psb_drm.h"
|
||||
#include "psb_drv.h"
|
||||
#include "psb_reg.h"
|
||||
#include "psb_intel_reg.h"
|
||||
#include "intel_bios.h"
|
||||
|
||||
|
||||
static int psb_output_init(struct drm_device *dev)
|
||||
{
|
||||
struct drm_psb_private *dev_priv = dev->dev_private;
|
||||
psb_intel_lvds_init(dev, &dev_priv->mode_dev);
|
||||
psb_intel_sdvo_init(dev, SDVOB);
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifdef CONFIG_BACKLIGHT_CLASS_DEVICE
|
||||
|
||||
/*
|
||||
* Poulsbo Backlight Interfaces
|
||||
*/
|
||||
|
||||
#define BLC_PWM_PRECISION_FACTOR 100 /* 10000000 */
|
||||
#define BLC_PWM_FREQ_CALC_CONSTANT 32
|
||||
#define MHz 1000000
|
||||
|
||||
#define PSB_BLC_PWM_PRECISION_FACTOR 10
|
||||
#define PSB_BLC_MAX_PWM_REG_FREQ 0xFFFE
|
||||
#define PSB_BLC_MIN_PWM_REG_FREQ 0x2
|
||||
|
||||
#define PSB_BACKLIGHT_PWM_POLARITY_BIT_CLEAR (0xFFFE)
|
||||
#define PSB_BACKLIGHT_PWM_CTL_SHIFT (16)
|
||||
|
||||
static int psb_brightness;
|
||||
static struct backlight_device *psb_backlight_device;
|
||||
|
||||
static int psb_get_brightness(struct backlight_device *bd)
|
||||
{
|
||||
/* return locally cached var instead of HW read (due to DPST etc.) */
|
||||
/* FIXME: ideally return actual value in case firmware fiddled with
|
||||
it */
|
||||
return psb_brightness;
|
||||
}
|
||||
|
||||
|
||||
static int psb_backlight_setup(struct drm_device *dev)
|
||||
{
|
||||
struct drm_psb_private *dev_priv = dev->dev_private;
|
||||
unsigned long core_clock;
|
||||
/* u32 bl_max_freq; */
|
||||
/* unsigned long value; */
|
||||
u16 bl_max_freq;
|
||||
uint32_t value;
|
||||
uint32_t blc_pwm_precision_factor;
|
||||
|
||||
/* get bl_max_freq and pol from dev_priv*/
|
||||
if (!dev_priv->lvds_bl) {
|
||||
dev_err(dev->dev, "Has no valid LVDS backlight info\n");
|
||||
return -ENOENT;
|
||||
}
|
||||
bl_max_freq = dev_priv->lvds_bl->freq;
|
||||
blc_pwm_precision_factor = PSB_BLC_PWM_PRECISION_FACTOR;
|
||||
|
||||
core_clock = dev_priv->core_freq;
|
||||
|
||||
value = (core_clock * MHz) / BLC_PWM_FREQ_CALC_CONSTANT;
|
||||
value *= blc_pwm_precision_factor;
|
||||
value /= bl_max_freq;
|
||||
value /= blc_pwm_precision_factor;
|
||||
|
||||
if (value > (unsigned long long)PSB_BLC_MAX_PWM_REG_FREQ ||
|
||||
value < (unsigned long long)PSB_BLC_MIN_PWM_REG_FREQ)
|
||||
return -ERANGE;
|
||||
else {
|
||||
value &= PSB_BACKLIGHT_PWM_POLARITY_BIT_CLEAR;
|
||||
REG_WRITE(BLC_PWM_CTL,
|
||||
(value << PSB_BACKLIGHT_PWM_CTL_SHIFT) | (value));
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int psb_set_brightness(struct backlight_device *bd)
|
||||
{
|
||||
struct drm_device *dev = bl_get_data(psb_backlight_device);
|
||||
int level = bd->props.brightness;
|
||||
|
||||
/* Percentage 1-100% being valid */
|
||||
if (level < 1)
|
||||
level = 1;
|
||||
|
||||
psb_intel_lvds_set_brightness(dev, level);
|
||||
psb_brightness = level;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const struct backlight_ops psb_ops = {
|
||||
.get_brightness = psb_get_brightness,
|
||||
.update_status = psb_set_brightness,
|
||||
};
|
||||
|
||||
static int psb_backlight_init(struct drm_device *dev)
|
||||
{
|
||||
struct drm_psb_private *dev_priv = dev->dev_private;
|
||||
int ret;
|
||||
struct backlight_properties props;
|
||||
|
||||
memset(&props, 0, sizeof(struct backlight_properties));
|
||||
props.max_brightness = 100;
|
||||
props.type = BACKLIGHT_PLATFORM;
|
||||
|
||||
psb_backlight_device = backlight_device_register("psb-bl",
|
||||
NULL, (void *)dev, &psb_ops, &props);
|
||||
if (IS_ERR(psb_backlight_device))
|
||||
return PTR_ERR(psb_backlight_device);
|
||||
|
||||
ret = psb_backlight_setup(dev);
|
||||
if (ret < 0) {
|
||||
backlight_device_unregister(psb_backlight_device);
|
||||
psb_backlight_device = NULL;
|
||||
return ret;
|
||||
}
|
||||
psb_backlight_device->props.brightness = 100;
|
||||
psb_backlight_device->props.max_brightness = 100;
|
||||
backlight_update_status(psb_backlight_device);
|
||||
dev_priv->backlight_device = psb_backlight_device;
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Provide the Poulsbo specific chip logic and low level methods
|
||||
* for power management
|
||||
*/
|
||||
|
||||
static void psb_init_pm(struct drm_device *dev)
|
||||
{
|
||||
struct drm_psb_private *dev_priv = dev->dev_private;
|
||||
|
||||
u32 gating = PSB_RSGX32(PSB_CR_CLKGATECTL);
|
||||
gating &= ~3; /* Disable 2D clock gating */
|
||||
gating |= 1;
|
||||
PSB_WSGX32(gating, PSB_CR_CLKGATECTL);
|
||||
PSB_RSGX32(PSB_CR_CLKGATECTL);
|
||||
}
|
||||
|
||||
/**
|
||||
* psb_save_display_registers - save registers lost on suspend
|
||||
* @dev: our DRM device
|
||||
*
|
||||
* Save the state we need in order to be able to restore the interface
|
||||
* upon resume from suspend
|
||||
*/
|
||||
static int psb_save_display_registers(struct drm_device *dev)
|
||||
{
|
||||
struct drm_psb_private *dev_priv = dev->dev_private;
|
||||
struct drm_crtc *crtc;
|
||||
struct drm_connector *connector;
|
||||
|
||||
/* Display arbitration control + watermarks */
|
||||
dev_priv->saveDSPARB = PSB_RVDC32(DSPARB);
|
||||
dev_priv->saveDSPFW1 = PSB_RVDC32(DSPFW1);
|
||||
dev_priv->saveDSPFW2 = PSB_RVDC32(DSPFW2);
|
||||
dev_priv->saveDSPFW3 = PSB_RVDC32(DSPFW3);
|
||||
dev_priv->saveDSPFW4 = PSB_RVDC32(DSPFW4);
|
||||
dev_priv->saveDSPFW5 = PSB_RVDC32(DSPFW5);
|
||||
dev_priv->saveDSPFW6 = PSB_RVDC32(DSPFW6);
|
||||
dev_priv->saveCHICKENBIT = PSB_RVDC32(DSPCHICKENBIT);
|
||||
|
||||
/* Save crtc and output state */
|
||||
mutex_lock(&dev->mode_config.mutex);
|
||||
list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) {
|
||||
if (drm_helper_crtc_in_use(crtc))
|
||||
crtc->funcs->save(crtc);
|
||||
}
|
||||
|
||||
list_for_each_entry(connector, &dev->mode_config.connector_list, head)
|
||||
connector->funcs->save(connector);
|
||||
|
||||
mutex_unlock(&dev->mode_config.mutex);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* psb_restore_display_registers - restore lost register state
|
||||
* @dev: our DRM device
|
||||
*
|
||||
* Restore register state that was lost during suspend and resume.
|
||||
*/
|
||||
static int psb_restore_display_registers(struct drm_device *dev)
|
||||
{
|
||||
struct drm_psb_private *dev_priv = dev->dev_private;
|
||||
struct drm_crtc *crtc;
|
||||
struct drm_connector *connector;
|
||||
int pp_stat;
|
||||
|
||||
/* Display arbitration + watermarks */
|
||||
PSB_WVDC32(dev_priv->saveDSPARB, DSPARB);
|
||||
PSB_WVDC32(dev_priv->saveDSPFW1, DSPFW1);
|
||||
PSB_WVDC32(dev_priv->saveDSPFW2, DSPFW2);
|
||||
PSB_WVDC32(dev_priv->saveDSPFW3, DSPFW3);
|
||||
PSB_WVDC32(dev_priv->saveDSPFW4, DSPFW4);
|
||||
PSB_WVDC32(dev_priv->saveDSPFW5, DSPFW5);
|
||||
PSB_WVDC32(dev_priv->saveDSPFW6, DSPFW6);
|
||||
PSB_WVDC32(dev_priv->saveCHICKENBIT, DSPCHICKENBIT);
|
||||
|
||||
/*make sure VGA plane is off. it initializes to on after reset!*/
|
||||
PSB_WVDC32(0x80000000, VGACNTRL);
|
||||
|
||||
mutex_lock(&dev->mode_config.mutex);
|
||||
list_for_each_entry(crtc, &dev->mode_config.crtc_list, head)
|
||||
if (drm_helper_crtc_in_use(crtc))
|
||||
crtc->funcs->restore(crtc);
|
||||
|
||||
list_for_each_entry(connector, &dev->mode_config.connector_list, head)
|
||||
connector->funcs->restore(connector);
|
||||
|
||||
mutex_unlock(&dev->mode_config.mutex);
|
||||
|
||||
if (dev_priv->iLVDS_enable) {
|
||||
/*shutdown the panel*/
|
||||
PSB_WVDC32(0, PP_CONTROL);
|
||||
do {
|
||||
pp_stat = PSB_RVDC32(PP_STATUS);
|
||||
} while (pp_stat & 0x80000000);
|
||||
|
||||
/* Turn off the plane */
|
||||
PSB_WVDC32(0x58000000, DSPACNTR);
|
||||
PSB_WVDC32(0, DSPASURF);/*trigger the plane disable*/
|
||||
/* Wait ~4 ticks */
|
||||
msleep(4);
|
||||
/* Turn off pipe */
|
||||
PSB_WVDC32(0x0, PIPEACONF);
|
||||
/* Wait ~8 ticks */
|
||||
msleep(8);
|
||||
|
||||
/* Turn off PLLs */
|
||||
PSB_WVDC32(0, MRST_DPLL_A);
|
||||
} else {
|
||||
PSB_WVDC32(DPI_SHUT_DOWN, DPI_CONTROL_REG);
|
||||
PSB_WVDC32(0x0, PIPEACONF);
|
||||
PSB_WVDC32(0x2faf0000, BLC_PWM_CTL);
|
||||
while (REG_READ(0x70008) & 0x40000000)
|
||||
cpu_relax();
|
||||
while ((PSB_RVDC32(GEN_FIFO_STAT_REG) & DPI_FIFO_EMPTY)
|
||||
!= DPI_FIFO_EMPTY)
|
||||
cpu_relax();
|
||||
PSB_WVDC32(0, DEVICE_READY_REG);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int psb_power_down(struct drm_device *dev)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int psb_power_up(struct drm_device *dev)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void psb_get_core_freq(struct drm_device *dev)
|
||||
{
|
||||
uint32_t clock;
|
||||
struct pci_dev *pci_root = pci_get_bus_and_slot(0, 0);
|
||||
struct drm_psb_private *dev_priv = dev->dev_private;
|
||||
|
||||
/*pci_write_config_dword(pci_root, 0xD4, 0x00C32004);*/
|
||||
/*pci_write_config_dword(pci_root, 0xD0, 0xE0033000);*/
|
||||
|
||||
pci_write_config_dword(pci_root, 0xD0, 0xD0050300);
|
||||
pci_read_config_dword(pci_root, 0xD4, &clock);
|
||||
pci_dev_put(pci_root);
|
||||
|
||||
switch (clock & 0x07) {
|
||||
case 0:
|
||||
dev_priv->core_freq = 100;
|
||||
break;
|
||||
case 1:
|
||||
dev_priv->core_freq = 133;
|
||||
break;
|
||||
case 2:
|
||||
dev_priv->core_freq = 150;
|
||||
break;
|
||||
case 3:
|
||||
dev_priv->core_freq = 178;
|
||||
break;
|
||||
case 4:
|
||||
dev_priv->core_freq = 200;
|
||||
break;
|
||||
case 5:
|
||||
case 6:
|
||||
case 7:
|
||||
dev_priv->core_freq = 266;
|
||||
default:
|
||||
dev_priv->core_freq = 0;
|
||||
}
|
||||
}
|
||||
|
||||
static int psb_chip_setup(struct drm_device *dev)
|
||||
{
|
||||
psb_get_core_freq(dev);
|
||||
gma_intel_opregion_init(dev);
|
||||
psb_intel_init_bios(dev);
|
||||
return 0;
|
||||
}
|
||||
|
||||
const struct psb_ops psb_chip_ops = {
|
||||
.name = "Poulsbo",
|
||||
.accel_2d = 1,
|
||||
.pipes = 2,
|
||||
.crtcs = 2,
|
||||
.sgx_offset = PSB_SGX_OFFSET,
|
||||
.chip_setup = psb_chip_setup,
|
||||
|
||||
.crtc_helper = &psb_intel_helper_funcs,
|
||||
.crtc_funcs = &psb_intel_crtc_funcs,
|
||||
|
||||
.output_init = psb_output_init,
|
||||
|
||||
#ifdef CONFIG_BACKLIGHT_CLASS_DEVICE
|
||||
.backlight_init = psb_backlight_init,
|
||||
#endif
|
||||
|
||||
.init_pm = psb_init_pm,
|
||||
.save_regs = psb_save_display_registers,
|
||||
.restore_regs = psb_restore_display_registers,
|
||||
.power_down = psb_power_down,
|
||||
.power_up = psb_power_up,
|
||||
};
|
||||
|
|
@ -0,0 +1,51 @@
|
|||
#include <linux/module.h>
|
||||
#include <linux/vermagic.h>
|
||||
#include <linux/compiler.h>
|
||||
|
||||
MODULE_INFO(vermagic, VERMAGIC_STRING);
|
||||
|
||||
struct module __this_module
|
||||
__attribute__((section(".gnu.linkonce.this_module"))) = {
|
||||
.name = KBUILD_MODNAME,
|
||||
.init = init_module,
|
||||
#ifdef CONFIG_MODULE_UNLOAD
|
||||
.exit = cleanup_module,
|
||||
#endif
|
||||
.arch = MODULE_ARCH_INIT,
|
||||
};
|
||||
|
||||
MODULE_INFO(staging, "Y");
|
||||
|
||||
static const char __module_depends[]
|
||||
__used
|
||||
__attribute__((section(".modinfo"))) =
|
||||
"depends=drm,drm_kms_helper,video,i2c-algo-bit";
|
||||
|
||||
MODULE_ALIAS("pci:v00008086d00008108sv*sd*bc*sc*i*");
|
||||
MODULE_ALIAS("pci:v00008086d00008109sv*sd*bc*sc*i*");
|
||||
MODULE_ALIAS("pci:v00008086d00004100sv*sd*bc*sc*i*");
|
||||
MODULE_ALIAS("pci:v00008086d00004101sv*sd*bc*sc*i*");
|
||||
MODULE_ALIAS("pci:v00008086d00004102sv*sd*bc*sc*i*");
|
||||
MODULE_ALIAS("pci:v00008086d00004103sv*sd*bc*sc*i*");
|
||||
MODULE_ALIAS("pci:v00008086d00004104sv*sd*bc*sc*i*");
|
||||
MODULE_ALIAS("pci:v00008086d00004105sv*sd*bc*sc*i*");
|
||||
MODULE_ALIAS("pci:v00008086d00004106sv*sd*bc*sc*i*");
|
||||
MODULE_ALIAS("pci:v00008086d00004107sv*sd*bc*sc*i*");
|
||||
MODULE_ALIAS("pci:v00008086d00000130sv*sd*bc*sc*i*");
|
||||
MODULE_ALIAS("pci:v00008086d00000131sv*sd*bc*sc*i*");
|
||||
MODULE_ALIAS("pci:v00008086d00000132sv*sd*bc*sc*i*");
|
||||
MODULE_ALIAS("pci:v00008086d00000133sv*sd*bc*sc*i*");
|
||||
MODULE_ALIAS("pci:v00008086d00000134sv*sd*bc*sc*i*");
|
||||
MODULE_ALIAS("pci:v00008086d00000135sv*sd*bc*sc*i*");
|
||||
MODULE_ALIAS("pci:v00008086d00000136sv*sd*bc*sc*i*");
|
||||
MODULE_ALIAS("pci:v00008086d00000137sv*sd*bc*sc*i*");
|
||||
MODULE_ALIAS("pci:v00008086d00000BE0sv*sd*bc*sc*i*");
|
||||
MODULE_ALIAS("pci:v00008086d00000BE1sv*sd*bc*sc*i*");
|
||||
MODULE_ALIAS("pci:v00008086d00000BE2sv*sd*bc*sc*i*");
|
||||
MODULE_ALIAS("pci:v00008086d00000BE3sv*sd*bc*sc*i*");
|
||||
MODULE_ALIAS("pci:v00008086d00000BE4sv*sd*bc*sc*i*");
|
||||
MODULE_ALIAS("pci:v00008086d00000BE5sv*sd*bc*sc*i*");
|
||||
MODULE_ALIAS("pci:v00008086d00000BE6sv*sd*bc*sc*i*");
|
||||
MODULE_ALIAS("pci:v00008086d00000BE7sv*sd*bc*sc*i*");
|
||||
|
||||
MODULE_INFO(srcversion, "51B3334F342F5EEAC93AF22");
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -0,0 +1,28 @@
|
|||
/* copyright (c) 2008, Intel Corporation
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms and conditions of the GNU General Public License,
|
||||
* version 2, as published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
* more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Authors:
|
||||
* Eric Anholt <eric@anholt.net>
|
||||
*/
|
||||
|
||||
#ifndef _INTEL_DISPLAY_H_
|
||||
#define _INTEL_DISPLAY_H_
|
||||
|
||||
bool psb_intel_pipe_has_type(struct drm_crtc *crtc, int type);
|
||||
void psb_intel_crtc_gamma_set(struct drm_crtc *crtc, u16 *red,
|
||||
u16 *green, u16 *blue, uint32_t type, uint32_t size);
|
||||
void psb_intel_crtc_destroy(struct drm_crtc *crtc);
|
||||
|
||||
#endif
|
|
@ -0,0 +1,228 @@
|
|||
/*
|
||||
* Copyright (c) 2009-2011, Intel Corporation.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms and conditions of the GNU General Public License,
|
||||
* version 2, as published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
* more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __INTEL_DRV_H__
|
||||
#define __INTEL_DRV_H__
|
||||
|
||||
#include <linux/i2c.h>
|
||||
#include <linux/i2c-algo-bit.h>
|
||||
#include <drm/drm_crtc.h>
|
||||
#include <drm/drm_crtc_helper.h>
|
||||
#include <linux/gpio.h>
|
||||
|
||||
/*
|
||||
* Display related stuff
|
||||
*/
|
||||
|
||||
/* store information about an Ixxx DVO */
|
||||
/* The i830->i865 use multiple DVOs with multiple i2cs */
|
||||
/* the i915, i945 have a single sDVO i2c bus - which is different */
|
||||
#define MAX_OUTPUTS 6
|
||||
/* maximum connectors per crtcs in the mode set */
|
||||
#define INTELFB_CONN_LIMIT 4
|
||||
|
||||
#define INTEL_I2C_BUS_DVO 1
|
||||
#define INTEL_I2C_BUS_SDVO 2
|
||||
|
||||
/* these are outputs from the chip - integrated only
|
||||
* external chips are via DVO or SDVO output */
|
||||
#define INTEL_OUTPUT_UNUSED 0
|
||||
#define INTEL_OUTPUT_ANALOG 1
|
||||
#define INTEL_OUTPUT_DVO 2
|
||||
#define INTEL_OUTPUT_SDVO 3
|
||||
#define INTEL_OUTPUT_LVDS 4
|
||||
#define INTEL_OUTPUT_TVOUT 5
|
||||
#define INTEL_OUTPUT_HDMI 6
|
||||
#define INTEL_OUTPUT_MIPI 7
|
||||
#define INTEL_OUTPUT_MIPI2 8
|
||||
|
||||
#define INTEL_DVO_CHIP_NONE 0
|
||||
#define INTEL_DVO_CHIP_LVDS 1
|
||||
#define INTEL_DVO_CHIP_TMDS 2
|
||||
#define INTEL_DVO_CHIP_TVOUT 4
|
||||
|
||||
/*
|
||||
* Hold information useally put on the device driver privates here,
|
||||
* since it needs to be shared across multiple of devices drivers privates.
|
||||
*/
|
||||
struct psb_intel_mode_device {
|
||||
|
||||
/*
|
||||
* Abstracted memory manager operations
|
||||
*/
|
||||
size_t(*bo_offset) (struct drm_device *dev, void *bo);
|
||||
|
||||
/*
|
||||
* Cursor (Can go ?)
|
||||
*/
|
||||
int cursor_needs_physical;
|
||||
|
||||
/*
|
||||
* LVDS info
|
||||
*/
|
||||
int backlight_duty_cycle; /* restore backlight to this value */
|
||||
bool panel_wants_dither;
|
||||
struct drm_display_mode *panel_fixed_mode;
|
||||
struct drm_display_mode *panel_fixed_mode2;
|
||||
struct drm_display_mode *vbt_mode; /* if any */
|
||||
|
||||
uint32_t saveBLC_PWM_CTL;
|
||||
};
|
||||
|
||||
struct psb_intel_i2c_chan {
|
||||
/* for getting at dev. private (mmio etc.) */
|
||||
struct drm_device *drm_dev;
|
||||
u32 reg; /* GPIO reg */
|
||||
struct i2c_adapter adapter;
|
||||
struct i2c_algo_bit_data algo;
|
||||
u8 slave_addr;
|
||||
};
|
||||
|
||||
struct psb_intel_output {
|
||||
struct drm_connector base;
|
||||
|
||||
struct drm_encoder enc;
|
||||
int type;
|
||||
|
||||
struct psb_intel_i2c_chan *i2c_bus; /* for control functions */
|
||||
struct psb_intel_i2c_chan *ddc_bus; /* for DDC only stuff */
|
||||
bool load_detect_temp;
|
||||
void *dev_priv;
|
||||
|
||||
struct psb_intel_mode_device *mode_dev;
|
||||
struct i2c_adapter *hdmi_i2c_adapter; /* for control functions */
|
||||
};
|
||||
|
||||
struct psb_intel_crtc_state {
|
||||
uint32_t saveDSPCNTR;
|
||||
uint32_t savePIPECONF;
|
||||
uint32_t savePIPESRC;
|
||||
uint32_t saveDPLL;
|
||||
uint32_t saveFP0;
|
||||
uint32_t saveFP1;
|
||||
uint32_t saveHTOTAL;
|
||||
uint32_t saveHBLANK;
|
||||
uint32_t saveHSYNC;
|
||||
uint32_t saveVTOTAL;
|
||||
uint32_t saveVBLANK;
|
||||
uint32_t saveVSYNC;
|
||||
uint32_t saveDSPSTRIDE;
|
||||
uint32_t saveDSPSIZE;
|
||||
uint32_t saveDSPPOS;
|
||||
uint32_t saveDSPBASE;
|
||||
uint32_t savePalette[256];
|
||||
};
|
||||
|
||||
struct psb_intel_crtc {
|
||||
struct drm_crtc base;
|
||||
int pipe;
|
||||
int plane;
|
||||
uint32_t cursor_addr;
|
||||
u8 lut_r[256], lut_g[256], lut_b[256];
|
||||
u8 lut_adj[256];
|
||||
struct psb_intel_framebuffer *fbdev_fb;
|
||||
/* a mode_set for fbdev users on this crtc */
|
||||
struct drm_mode_set mode_set;
|
||||
|
||||
/* GEM object that holds our cursor */
|
||||
struct drm_gem_object *cursor_obj;
|
||||
|
||||
struct drm_display_mode saved_mode;
|
||||
struct drm_display_mode saved_adjusted_mode;
|
||||
|
||||
struct psb_intel_mode_device *mode_dev;
|
||||
|
||||
/*crtc mode setting flags*/
|
||||
u32 mode_flags;
|
||||
|
||||
/* Saved Crtc HW states */
|
||||
struct psb_intel_crtc_state *crtc_state;
|
||||
};
|
||||
|
||||
#define to_psb_intel_crtc(x) \
|
||||
container_of(x, struct psb_intel_crtc, base)
|
||||
#define to_psb_intel_output(x) \
|
||||
container_of(x, struct psb_intel_output, base)
|
||||
#define enc_to_psb_intel_output(x) \
|
||||
container_of(x, struct psb_intel_output, enc)
|
||||
#define to_psb_intel_framebuffer(x) \
|
||||
container_of(x, struct psb_intel_framebuffer, base)
|
||||
|
||||
struct psb_intel_i2c_chan *psb_intel_i2c_create(struct drm_device *dev,
|
||||
const u32 reg, const char *name);
|
||||
void psb_intel_i2c_destroy(struct psb_intel_i2c_chan *chan);
|
||||
int psb_intel_ddc_get_modes(struct psb_intel_output *psb_intel_output);
|
||||
extern bool psb_intel_ddc_probe(struct psb_intel_output *psb_intel_output);
|
||||
|
||||
extern void psb_intel_crtc_init(struct drm_device *dev, int pipe,
|
||||
struct psb_intel_mode_device *mode_dev);
|
||||
extern void psb_intel_crt_init(struct drm_device *dev);
|
||||
extern void psb_intel_sdvo_init(struct drm_device *dev, int output_device);
|
||||
extern void psb_intel_dvo_init(struct drm_device *dev);
|
||||
extern void psb_intel_tv_init(struct drm_device *dev);
|
||||
extern void psb_intel_lvds_init(struct drm_device *dev,
|
||||
struct psb_intel_mode_device *mode_dev);
|
||||
extern void psb_intel_lvds_set_brightness(struct drm_device *dev, int level);
|
||||
extern void oaktrail_lvds_init(struct drm_device *dev,
|
||||
struct psb_intel_mode_device *mode_dev);
|
||||
extern void oaktrail_wait_for_INTR_PKT_SENT(struct drm_device *dev);
|
||||
extern void oaktrail_dsi_init(struct drm_device *dev,
|
||||
struct psb_intel_mode_device *mode_dev);
|
||||
extern void mid_dsi_init(struct drm_device *dev,
|
||||
struct psb_intel_mode_device *mode_dev, int dsi_num);
|
||||
|
||||
extern void psb_intel_crtc_load_lut(struct drm_crtc *crtc);
|
||||
extern void psb_intel_encoder_prepare(struct drm_encoder *encoder);
|
||||
extern void psb_intel_encoder_commit(struct drm_encoder *encoder);
|
||||
|
||||
extern struct drm_encoder *psb_intel_best_encoder(struct drm_connector
|
||||
*connector);
|
||||
|
||||
extern struct drm_display_mode *psb_intel_crtc_mode_get(struct drm_device *dev,
|
||||
struct drm_crtc *crtc);
|
||||
extern void psb_intel_wait_for_vblank(struct drm_device *dev);
|
||||
extern int psb_intel_get_pipe_from_crtc_id(struct drm_device *dev, void *data,
|
||||
struct drm_file *file_priv);
|
||||
extern struct drm_crtc *psb_intel_get_crtc_from_pipe(struct drm_device *dev,
|
||||
int pipe);
|
||||
extern struct drm_connector *psb_intel_sdvo_find(struct drm_device *dev,
|
||||
int sdvoB);
|
||||
extern int psb_intel_sdvo_supports_hotplug(struct drm_connector *connector);
|
||||
extern void psb_intel_sdvo_set_hotplug(struct drm_connector *connector,
|
||||
int enable);
|
||||
extern int intelfb_probe(struct drm_device *dev);
|
||||
extern int intelfb_remove(struct drm_device *dev,
|
||||
struct drm_framebuffer *fb);
|
||||
extern struct drm_framebuffer *psb_intel_framebuffer_create(struct drm_device
|
||||
*dev, struct
|
||||
drm_mode_fb_cmd
|
||||
*mode_cmd,
|
||||
void *mm_private);
|
||||
extern bool psb_intel_lvds_mode_fixup(struct drm_encoder *encoder,
|
||||
struct drm_display_mode *mode,
|
||||
struct drm_display_mode *adjusted_mode);
|
||||
extern int psb_intel_lvds_mode_valid(struct drm_connector *connector,
|
||||
struct drm_display_mode *mode);
|
||||
extern int psb_intel_lvds_set_property(struct drm_connector *connector,
|
||||
struct drm_property *property,
|
||||
uint64_t value);
|
||||
extern void psb_intel_lvds_destroy(struct drm_connector *connector);
|
||||
extern const struct drm_encoder_funcs psb_intel_lvds_enc_funcs;
|
||||
|
||||
|
||||
#endif /* __INTEL_DRV_H__ */
|
|
@ -0,0 +1,849 @@
|
|||
/*
|
||||
* Copyright © 2006-2007 Intel Corporation
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms and conditions of the GNU General Public License,
|
||||
* version 2, as published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
* more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Authors:
|
||||
* Eric Anholt <eric@anholt.net>
|
||||
* Dave Airlie <airlied@linux.ie>
|
||||
* Jesse Barnes <jesse.barnes@intel.com>
|
||||
*/
|
||||
|
||||
#include <linux/i2c.h>
|
||||
#include <drm/drmP.h>
|
||||
|
||||
#include "intel_bios.h"
|
||||
#include "psb_drv.h"
|
||||
#include "psb_intel_drv.h"
|
||||
#include "psb_intel_reg.h"
|
||||
#include "power.h"
|
||||
#include <linux/pm_runtime.h>
|
||||
|
||||
/*
|
||||
* LVDS I2C backlight control macros
|
||||
*/
|
||||
#define BRIGHTNESS_MAX_LEVEL 100
|
||||
#define BRIGHTNESS_MASK 0xFF
|
||||
#define BLC_I2C_TYPE 0x01
|
||||
#define BLC_PWM_TYPT 0x02
|
||||
|
||||
#define BLC_POLARITY_NORMAL 0
|
||||
#define BLC_POLARITY_INVERSE 1
|
||||
|
||||
#define PSB_BLC_MAX_PWM_REG_FREQ (0xFFFE)
|
||||
#define PSB_BLC_MIN_PWM_REG_FREQ (0x2)
|
||||
#define PSB_BLC_PWM_PRECISION_FACTOR (10)
|
||||
#define PSB_BACKLIGHT_PWM_CTL_SHIFT (16)
|
||||
#define PSB_BACKLIGHT_PWM_POLARITY_BIT_CLEAR (0xFFFE)
|
||||
|
||||
struct psb_intel_lvds_priv {
|
||||
/*
|
||||
* Saved LVDO output states
|
||||
*/
|
||||
uint32_t savePP_ON;
|
||||
uint32_t savePP_OFF;
|
||||
uint32_t saveLVDS;
|
||||
uint32_t savePP_CONTROL;
|
||||
uint32_t savePP_CYCLE;
|
||||
uint32_t savePFIT_CONTROL;
|
||||
uint32_t savePFIT_PGM_RATIOS;
|
||||
uint32_t saveBLC_PWM_CTL;
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
* Returns the maximum level of the backlight duty cycle field.
|
||||
*/
|
||||
static u32 psb_intel_lvds_get_max_backlight(struct drm_device *dev)
|
||||
{
|
||||
struct drm_psb_private *dev_priv = dev->dev_private;
|
||||
u32 retVal;
|
||||
|
||||
if (gma_power_begin(dev, false)) {
|
||||
retVal = ((REG_READ(BLC_PWM_CTL) &
|
||||
BACKLIGHT_MODULATION_FREQ_MASK) >>
|
||||
BACKLIGHT_MODULATION_FREQ_SHIFT) * 2;
|
||||
|
||||
gma_power_end(dev);
|
||||
} else
|
||||
retVal = ((dev_priv->saveBLC_PWM_CTL &
|
||||
BACKLIGHT_MODULATION_FREQ_MASK) >>
|
||||
BACKLIGHT_MODULATION_FREQ_SHIFT) * 2;
|
||||
|
||||
return retVal;
|
||||
}
|
||||
|
||||
/*
|
||||
* Set LVDS backlight level by I2C command
|
||||
*
|
||||
* FIXME: at some point we need to both track this for PM and also
|
||||
* disable runtime pm on MRST if the brightness is nil (ie blanked)
|
||||
*/
|
||||
static int psb_lvds_i2c_set_brightness(struct drm_device *dev,
|
||||
unsigned int level)
|
||||
{
|
||||
struct drm_psb_private *dev_priv =
|
||||
(struct drm_psb_private *)dev->dev_private;
|
||||
|
||||
struct psb_intel_i2c_chan *lvds_i2c_bus = dev_priv->lvds_i2c_bus;
|
||||
u8 out_buf[2];
|
||||
unsigned int blc_i2c_brightness;
|
||||
|
||||
struct i2c_msg msgs[] = {
|
||||
{
|
||||
.addr = lvds_i2c_bus->slave_addr,
|
||||
.flags = 0,
|
||||
.len = 2,
|
||||
.buf = out_buf,
|
||||
}
|
||||
};
|
||||
|
||||
blc_i2c_brightness = BRIGHTNESS_MASK & ((unsigned int)level *
|
||||
BRIGHTNESS_MASK /
|
||||
BRIGHTNESS_MAX_LEVEL);
|
||||
|
||||
if (dev_priv->lvds_bl->pol == BLC_POLARITY_INVERSE)
|
||||
blc_i2c_brightness = BRIGHTNESS_MASK - blc_i2c_brightness;
|
||||
|
||||
out_buf[0] = dev_priv->lvds_bl->brightnesscmd;
|
||||
out_buf[1] = (u8)blc_i2c_brightness;
|
||||
|
||||
if (i2c_transfer(&lvds_i2c_bus->adapter, msgs, 1) == 1) {
|
||||
dev_dbg(dev->dev, "I2C set brightness.(command, value) (%d, %d)\n",
|
||||
dev_priv->lvds_bl->brightnesscmd,
|
||||
blc_i2c_brightness);
|
||||
return 0;
|
||||
}
|
||||
|
||||
dev_err(dev->dev, "I2C transfer error\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
static int psb_lvds_pwm_set_brightness(struct drm_device *dev, int level)
|
||||
{
|
||||
struct drm_psb_private *dev_priv =
|
||||
(struct drm_psb_private *)dev->dev_private;
|
||||
|
||||
u32 max_pwm_blc;
|
||||
u32 blc_pwm_duty_cycle;
|
||||
|
||||
max_pwm_blc = psb_intel_lvds_get_max_backlight(dev);
|
||||
|
||||
/*BLC_PWM_CTL Should be initiated while backlight device init*/
|
||||
BUG_ON((max_pwm_blc & PSB_BLC_MAX_PWM_REG_FREQ) == 0);
|
||||
|
||||
blc_pwm_duty_cycle = level * max_pwm_blc / BRIGHTNESS_MAX_LEVEL;
|
||||
|
||||
if (dev_priv->lvds_bl->pol == BLC_POLARITY_INVERSE)
|
||||
blc_pwm_duty_cycle = max_pwm_blc - blc_pwm_duty_cycle;
|
||||
|
||||
blc_pwm_duty_cycle &= PSB_BACKLIGHT_PWM_POLARITY_BIT_CLEAR;
|
||||
REG_WRITE(BLC_PWM_CTL,
|
||||
(max_pwm_blc << PSB_BACKLIGHT_PWM_CTL_SHIFT) |
|
||||
(blc_pwm_duty_cycle));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Set LVDS backlight level either by I2C or PWM
|
||||
*/
|
||||
void psb_intel_lvds_set_brightness(struct drm_device *dev, int level)
|
||||
{
|
||||
/*u32 blc_pwm_ctl;*/
|
||||
struct drm_psb_private *dev_priv =
|
||||
(struct drm_psb_private *)dev->dev_private;
|
||||
|
||||
dev_dbg(dev->dev, "backlight level is %d\n", level);
|
||||
|
||||
if (!dev_priv->lvds_bl) {
|
||||
dev_err(dev->dev, "NO LVDS Backlight Info\n");
|
||||
return;
|
||||
}
|
||||
|
||||
if (dev_priv->lvds_bl->type == BLC_I2C_TYPE)
|
||||
psb_lvds_i2c_set_brightness(dev, level);
|
||||
else
|
||||
psb_lvds_pwm_set_brightness(dev, level);
|
||||
}
|
||||
|
||||
/*
|
||||
* Sets the backlight level.
|
||||
*
|
||||
* level: backlight level, from 0 to psb_intel_lvds_get_max_backlight().
|
||||
*/
|
||||
static void psb_intel_lvds_set_backlight(struct drm_device *dev, int level)
|
||||
{
|
||||
struct drm_psb_private *dev_priv = dev->dev_private;
|
||||
u32 blc_pwm_ctl;
|
||||
|
||||
if (gma_power_begin(dev, false)) {
|
||||
blc_pwm_ctl =
|
||||
REG_READ(BLC_PWM_CTL) & ~BACKLIGHT_DUTY_CYCLE_MASK;
|
||||
REG_WRITE(BLC_PWM_CTL,
|
||||
(blc_pwm_ctl |
|
||||
(level << BACKLIGHT_DUTY_CYCLE_SHIFT)));
|
||||
gma_power_end(dev);
|
||||
} else {
|
||||
blc_pwm_ctl = dev_priv->saveBLC_PWM_CTL &
|
||||
~BACKLIGHT_DUTY_CYCLE_MASK;
|
||||
dev_priv->saveBLC_PWM_CTL = (blc_pwm_ctl |
|
||||
(level << BACKLIGHT_DUTY_CYCLE_SHIFT));
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Sets the power state for the panel.
|
||||
*/
|
||||
static void psb_intel_lvds_set_power(struct drm_device *dev,
|
||||
struct psb_intel_output *output, bool on)
|
||||
{
|
||||
u32 pp_status;
|
||||
|
||||
if (!gma_power_begin(dev, true))
|
||||
return;
|
||||
|
||||
if (on) {
|
||||
REG_WRITE(PP_CONTROL, REG_READ(PP_CONTROL) |
|
||||
POWER_TARGET_ON);
|
||||
do {
|
||||
pp_status = REG_READ(PP_STATUS);
|
||||
} while ((pp_status & PP_ON) == 0);
|
||||
|
||||
psb_intel_lvds_set_backlight(dev,
|
||||
output->
|
||||
mode_dev->backlight_duty_cycle);
|
||||
} else {
|
||||
psb_intel_lvds_set_backlight(dev, 0);
|
||||
|
||||
REG_WRITE(PP_CONTROL, REG_READ(PP_CONTROL) &
|
||||
~POWER_TARGET_ON);
|
||||
do {
|
||||
pp_status = REG_READ(PP_STATUS);
|
||||
} while (pp_status & PP_ON);
|
||||
}
|
||||
|
||||
gma_power_end(dev);
|
||||
}
|
||||
|
||||
static void psb_intel_lvds_encoder_dpms(struct drm_encoder *encoder, int mode)
|
||||
{
|
||||
struct drm_device *dev = encoder->dev;
|
||||
struct psb_intel_output *output = enc_to_psb_intel_output(encoder);
|
||||
|
||||
if (mode == DRM_MODE_DPMS_ON)
|
||||
psb_intel_lvds_set_power(dev, output, true);
|
||||
else
|
||||
psb_intel_lvds_set_power(dev, output, false);
|
||||
|
||||
/* XXX: We never power down the LVDS pairs. */
|
||||
}
|
||||
|
||||
static void psb_intel_lvds_save(struct drm_connector *connector)
|
||||
{
|
||||
struct drm_device *dev = connector->dev;
|
||||
struct drm_psb_private *dev_priv =
|
||||
(struct drm_psb_private *)dev->dev_private;
|
||||
struct psb_intel_output *psb_intel_output =
|
||||
to_psb_intel_output(connector);
|
||||
struct psb_intel_lvds_priv *lvds_priv =
|
||||
(struct psb_intel_lvds_priv *)psb_intel_output->dev_priv;
|
||||
|
||||
lvds_priv->savePP_ON = REG_READ(LVDSPP_ON);
|
||||
lvds_priv->savePP_OFF = REG_READ(LVDSPP_OFF);
|
||||
lvds_priv->saveLVDS = REG_READ(LVDS);
|
||||
lvds_priv->savePP_CONTROL = REG_READ(PP_CONTROL);
|
||||
lvds_priv->savePP_CYCLE = REG_READ(PP_CYCLE);
|
||||
/*lvds_priv->savePP_DIVISOR = REG_READ(PP_DIVISOR);*/
|
||||
lvds_priv->saveBLC_PWM_CTL = REG_READ(BLC_PWM_CTL);
|
||||
lvds_priv->savePFIT_CONTROL = REG_READ(PFIT_CONTROL);
|
||||
lvds_priv->savePFIT_PGM_RATIOS = REG_READ(PFIT_PGM_RATIOS);
|
||||
|
||||
/*TODO: move backlight_duty_cycle to psb_intel_lvds_priv*/
|
||||
dev_priv->backlight_duty_cycle = (dev_priv->saveBLC_PWM_CTL &
|
||||
BACKLIGHT_DUTY_CYCLE_MASK);
|
||||
|
||||
/*
|
||||
* If the light is off at server startup,
|
||||
* just make it full brightness
|
||||
*/
|
||||
if (dev_priv->backlight_duty_cycle == 0)
|
||||
dev_priv->backlight_duty_cycle =
|
||||
psb_intel_lvds_get_max_backlight(dev);
|
||||
|
||||
dev_dbg(dev->dev, "(0x%x, 0x%x, 0x%x, 0x%x, 0x%x, 0x%x)\n",
|
||||
lvds_priv->savePP_ON,
|
||||
lvds_priv->savePP_OFF,
|
||||
lvds_priv->saveLVDS,
|
||||
lvds_priv->savePP_CONTROL,
|
||||
lvds_priv->savePP_CYCLE,
|
||||
lvds_priv->saveBLC_PWM_CTL);
|
||||
}
|
||||
|
||||
static void psb_intel_lvds_restore(struct drm_connector *connector)
|
||||
{
|
||||
struct drm_device *dev = connector->dev;
|
||||
u32 pp_status;
|
||||
|
||||
/*struct drm_psb_private *dev_priv =
|
||||
(struct drm_psb_private *)dev->dev_private;*/
|
||||
struct psb_intel_output *psb_intel_output =
|
||||
to_psb_intel_output(connector);
|
||||
struct psb_intel_lvds_priv *lvds_priv =
|
||||
(struct psb_intel_lvds_priv *)psb_intel_output->dev_priv;
|
||||
|
||||
dev_dbg(dev->dev, "(0x%x, 0x%x, 0x%x, 0x%x, 0x%x, 0x%x)\n",
|
||||
lvds_priv->savePP_ON,
|
||||
lvds_priv->savePP_OFF,
|
||||
lvds_priv->saveLVDS,
|
||||
lvds_priv->savePP_CONTROL,
|
||||
lvds_priv->savePP_CYCLE,
|
||||
lvds_priv->saveBLC_PWM_CTL);
|
||||
|
||||
REG_WRITE(BLC_PWM_CTL, lvds_priv->saveBLC_PWM_CTL);
|
||||
REG_WRITE(PFIT_CONTROL, lvds_priv->savePFIT_CONTROL);
|
||||
REG_WRITE(PFIT_PGM_RATIOS, lvds_priv->savePFIT_PGM_RATIOS);
|
||||
REG_WRITE(LVDSPP_ON, lvds_priv->savePP_ON);
|
||||
REG_WRITE(LVDSPP_OFF, lvds_priv->savePP_OFF);
|
||||
/*REG_WRITE(PP_DIVISOR, lvds_priv->savePP_DIVISOR);*/
|
||||
REG_WRITE(PP_CYCLE, lvds_priv->savePP_CYCLE);
|
||||
REG_WRITE(PP_CONTROL, lvds_priv->savePP_CONTROL);
|
||||
REG_WRITE(LVDS, lvds_priv->saveLVDS);
|
||||
|
||||
if (lvds_priv->savePP_CONTROL & POWER_TARGET_ON) {
|
||||
REG_WRITE(PP_CONTROL, REG_READ(PP_CONTROL) |
|
||||
POWER_TARGET_ON);
|
||||
do {
|
||||
pp_status = REG_READ(PP_STATUS);
|
||||
} while ((pp_status & PP_ON) == 0);
|
||||
} else {
|
||||
REG_WRITE(PP_CONTROL, REG_READ(PP_CONTROL) &
|
||||
~POWER_TARGET_ON);
|
||||
do {
|
||||
pp_status = REG_READ(PP_STATUS);
|
||||
} while (pp_status & PP_ON);
|
||||
}
|
||||
}
|
||||
|
||||
int psb_intel_lvds_mode_valid(struct drm_connector *connector,
|
||||
struct drm_display_mode *mode)
|
||||
{
|
||||
struct psb_intel_output *psb_intel_output =
|
||||
to_psb_intel_output(connector);
|
||||
struct drm_display_mode *fixed_mode =
|
||||
psb_intel_output->mode_dev->panel_fixed_mode;
|
||||
|
||||
if (psb_intel_output->type == INTEL_OUTPUT_MIPI2)
|
||||
fixed_mode = psb_intel_output->mode_dev->panel_fixed_mode2;
|
||||
|
||||
/* just in case */
|
||||
if (mode->flags & DRM_MODE_FLAG_DBLSCAN)
|
||||
return MODE_NO_DBLESCAN;
|
||||
|
||||
/* just in case */
|
||||
if (mode->flags & DRM_MODE_FLAG_INTERLACE)
|
||||
return MODE_NO_INTERLACE;
|
||||
|
||||
if (fixed_mode) {
|
||||
if (mode->hdisplay > fixed_mode->hdisplay)
|
||||
return MODE_PANEL;
|
||||
if (mode->vdisplay > fixed_mode->vdisplay)
|
||||
return MODE_PANEL;
|
||||
}
|
||||
return MODE_OK;
|
||||
}
|
||||
|
||||
bool psb_intel_lvds_mode_fixup(struct drm_encoder *encoder,
|
||||
struct drm_display_mode *mode,
|
||||
struct drm_display_mode *adjusted_mode)
|
||||
{
|
||||
struct psb_intel_mode_device *mode_dev =
|
||||
enc_to_psb_intel_output(encoder)->mode_dev;
|
||||
struct drm_device *dev = encoder->dev;
|
||||
struct psb_intel_crtc *psb_intel_crtc =
|
||||
to_psb_intel_crtc(encoder->crtc);
|
||||
struct drm_encoder *tmp_encoder;
|
||||
struct drm_display_mode *panel_fixed_mode = mode_dev->panel_fixed_mode;
|
||||
struct psb_intel_output *psb_intel_output =
|
||||
enc_to_psb_intel_output(encoder);
|
||||
|
||||
if (psb_intel_output->type == INTEL_OUTPUT_MIPI2)
|
||||
panel_fixed_mode = mode_dev->panel_fixed_mode2;
|
||||
|
||||
/* FIXME: review for Medfield */
|
||||
/* PSB requires the LVDS is on pipe B, MRST has only one pipe anyway */
|
||||
if (!IS_MRST(dev) && psb_intel_crtc->pipe == 0) {
|
||||
printk(KERN_ERR "Can't support LVDS on pipe A\n");
|
||||
return false;
|
||||
}
|
||||
if (IS_MRST(dev) && psb_intel_crtc->pipe != 0) {
|
||||
printk(KERN_ERR "Must use PIPE A\n");
|
||||
return false;
|
||||
}
|
||||
/* Should never happen!! */
|
||||
list_for_each_entry(tmp_encoder, &dev->mode_config.encoder_list,
|
||||
head) {
|
||||
if (tmp_encoder != encoder
|
||||
&& tmp_encoder->crtc == encoder->crtc) {
|
||||
printk(KERN_ERR "Can't enable LVDS and another "
|
||||
"encoder on the same pipe\n");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* If 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,
|
||||
* with the panel scaling set up to source from the H/VDisplay
|
||||
* of the original mode.
|
||||
*/
|
||||
if (panel_fixed_mode != NULL) {
|
||||
adjusted_mode->hdisplay = panel_fixed_mode->hdisplay;
|
||||
adjusted_mode->hsync_start = panel_fixed_mode->hsync_start;
|
||||
adjusted_mode->hsync_end = panel_fixed_mode->hsync_end;
|
||||
adjusted_mode->htotal = panel_fixed_mode->htotal;
|
||||
adjusted_mode->vdisplay = panel_fixed_mode->vdisplay;
|
||||
adjusted_mode->vsync_start = panel_fixed_mode->vsync_start;
|
||||
adjusted_mode->vsync_end = panel_fixed_mode->vsync_end;
|
||||
adjusted_mode->vtotal = panel_fixed_mode->vtotal;
|
||||
adjusted_mode->clock = panel_fixed_mode->clock;
|
||||
drm_mode_set_crtcinfo(adjusted_mode,
|
||||
CRTC_INTERLACE_HALVE_V);
|
||||
}
|
||||
|
||||
/*
|
||||
* 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;
|
||||
}
|
||||
|
||||
static void psb_intel_lvds_prepare(struct drm_encoder *encoder)
|
||||
{
|
||||
struct drm_device *dev = encoder->dev;
|
||||
struct psb_intel_output *output = enc_to_psb_intel_output(encoder);
|
||||
struct psb_intel_mode_device *mode_dev = output->mode_dev;
|
||||
|
||||
if (!gma_power_begin(dev, true))
|
||||
return;
|
||||
|
||||
mode_dev->saveBLC_PWM_CTL = REG_READ(BLC_PWM_CTL);
|
||||
mode_dev->backlight_duty_cycle = (mode_dev->saveBLC_PWM_CTL &
|
||||
BACKLIGHT_DUTY_CYCLE_MASK);
|
||||
|
||||
psb_intel_lvds_set_power(dev, output, false);
|
||||
|
||||
gma_power_end(dev);
|
||||
}
|
||||
|
||||
static void psb_intel_lvds_commit(struct drm_encoder *encoder)
|
||||
{
|
||||
struct drm_device *dev = encoder->dev;
|
||||
struct psb_intel_output *output = enc_to_psb_intel_output(encoder);
|
||||
struct psb_intel_mode_device *mode_dev = output->mode_dev;
|
||||
|
||||
if (mode_dev->backlight_duty_cycle == 0)
|
||||
mode_dev->backlight_duty_cycle =
|
||||
psb_intel_lvds_get_max_backlight(dev);
|
||||
|
||||
psb_intel_lvds_set_power(dev, output, true);
|
||||
}
|
||||
|
||||
static void psb_intel_lvds_mode_set(struct drm_encoder *encoder,
|
||||
struct drm_display_mode *mode,
|
||||
struct drm_display_mode *adjusted_mode)
|
||||
{
|
||||
struct drm_device *dev = encoder->dev;
|
||||
struct drm_psb_private *dev_priv = dev->dev_private;
|
||||
u32 pfit_control;
|
||||
|
||||
/*
|
||||
* The LVDS pin pair will already have been turned on in the
|
||||
* psb_intel_crtc_mode_set since it has a large impact on the DPLL
|
||||
* settings.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Enable automatic panel scaling so that non-native modes fill the
|
||||
* screen. Should be enabled before the pipe is enabled, according to
|
||||
* register description and PRM.
|
||||
*/
|
||||
if (mode->hdisplay != adjusted_mode->hdisplay ||
|
||||
mode->vdisplay != adjusted_mode->vdisplay)
|
||||
pfit_control = (PFIT_ENABLE | VERT_AUTO_SCALE |
|
||||
HORIZ_AUTO_SCALE | VERT_INTERP_BILINEAR |
|
||||
HORIZ_INTERP_BILINEAR);
|
||||
else
|
||||
pfit_control = 0;
|
||||
|
||||
if (dev_priv->lvds_dither)
|
||||
pfit_control |= PANEL_8TO6_DITHER_ENABLE;
|
||||
|
||||
REG_WRITE(PFIT_CONTROL, pfit_control);
|
||||
}
|
||||
|
||||
/*
|
||||
* Detect the LVDS connection.
|
||||
*
|
||||
* This always returns CONNECTOR_STATUS_CONNECTED.
|
||||
* This connector should only have
|
||||
* been set up if the LVDS was actually connected anyway.
|
||||
*/
|
||||
static enum drm_connector_status psb_intel_lvds_detect(struct drm_connector
|
||||
*connector, bool force)
|
||||
{
|
||||
return connector_status_connected;
|
||||
}
|
||||
|
||||
/*
|
||||
* Return the list of DDC modes if available, or the BIOS fixed mode otherwise.
|
||||
*/
|
||||
static int psb_intel_lvds_get_modes(struct drm_connector *connector)
|
||||
{
|
||||
struct drm_device *dev = connector->dev;
|
||||
struct psb_intel_output *psb_intel_output =
|
||||
to_psb_intel_output(connector);
|
||||
struct psb_intel_mode_device *mode_dev =
|
||||
psb_intel_output->mode_dev;
|
||||
int ret = 0;
|
||||
|
||||
if (!IS_MRST(dev))
|
||||
ret = psb_intel_ddc_get_modes(psb_intel_output);
|
||||
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
/* Didn't get an EDID, so
|
||||
* Set wide sync ranges so we get all modes
|
||||
* handed to valid_mode for checking
|
||||
*/
|
||||
connector->display_info.min_vfreq = 0;
|
||||
connector->display_info.max_vfreq = 200;
|
||||
connector->display_info.min_hfreq = 0;
|
||||
connector->display_info.max_hfreq = 200;
|
||||
|
||||
if (mode_dev->panel_fixed_mode != NULL) {
|
||||
struct drm_display_mode *mode =
|
||||
drm_mode_duplicate(dev, mode_dev->panel_fixed_mode);
|
||||
drm_mode_probed_add(connector, mode);
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* psb_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.
|
||||
*/
|
||||
void psb_intel_lvds_destroy(struct drm_connector *connector)
|
||||
{
|
||||
struct psb_intel_output *psb_intel_output =
|
||||
to_psb_intel_output(connector);
|
||||
|
||||
if (psb_intel_output->ddc_bus)
|
||||
psb_intel_i2c_destroy(psb_intel_output->ddc_bus);
|
||||
drm_sysfs_connector_remove(connector);
|
||||
drm_connector_cleanup(connector);
|
||||
kfree(connector);
|
||||
}
|
||||
|
||||
int psb_intel_lvds_set_property(struct drm_connector *connector,
|
||||
struct drm_property *property,
|
||||
uint64_t value)
|
||||
{
|
||||
struct drm_encoder *encoder = connector->encoder;
|
||||
|
||||
if (!encoder)
|
||||
return -1;
|
||||
|
||||
if (!strcmp(property->name, "scaling mode")) {
|
||||
struct psb_intel_crtc *crtc =
|
||||
to_psb_intel_crtc(encoder->crtc);
|
||||
uint64_t curval;
|
||||
|
||||
if (!crtc)
|
||||
goto set_prop_error;
|
||||
|
||||
switch (value) {
|
||||
case DRM_MODE_SCALE_FULLSCREEN:
|
||||
break;
|
||||
case DRM_MODE_SCALE_NO_SCALE:
|
||||
break;
|
||||
case DRM_MODE_SCALE_ASPECT:
|
||||
break;
|
||||
default:
|
||||
goto set_prop_error;
|
||||
}
|
||||
|
||||
if (drm_connector_property_get_value(connector,
|
||||
property,
|
||||
&curval))
|
||||
goto set_prop_error;
|
||||
|
||||
if (curval == value)
|
||||
goto set_prop_done;
|
||||
|
||||
if (drm_connector_property_set_value(connector,
|
||||
property,
|
||||
value))
|
||||
goto set_prop_error;
|
||||
|
||||
if (crtc->saved_mode.hdisplay != 0 &&
|
||||
crtc->saved_mode.vdisplay != 0) {
|
||||
if (!drm_crtc_helper_set_mode(encoder->crtc,
|
||||
&crtc->saved_mode,
|
||||
encoder->crtc->x,
|
||||
encoder->crtc->y,
|
||||
encoder->crtc->fb))
|
||||
goto set_prop_error;
|
||||
}
|
||||
} else if (!strcmp(property->name, "backlight")) {
|
||||
if (drm_connector_property_set_value(connector,
|
||||
property,
|
||||
value))
|
||||
goto set_prop_error;
|
||||
else {
|
||||
#ifdef CONFIG_BACKLIGHT_CLASS_DEVICE
|
||||
struct drm_psb_private *devp = encoder->dev->dev_private;
|
||||
struct backlight_device *bd = devp->backlight_device;
|
||||
if (bd) {
|
||||
bd->props.brightness = value;
|
||||
backlight_update_status(bd);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
} else if (!strcmp(property->name, "DPMS")) {
|
||||
struct drm_encoder_helper_funcs *hfuncs
|
||||
= encoder->helper_private;
|
||||
hfuncs->dpms(encoder, value);
|
||||
}
|
||||
|
||||
set_prop_done:
|
||||
return 0;
|
||||
set_prop_error:
|
||||
return -1;
|
||||
}
|
||||
|
||||
static const struct drm_encoder_helper_funcs psb_intel_lvds_helper_funcs = {
|
||||
.dpms = psb_intel_lvds_encoder_dpms,
|
||||
.mode_fixup = psb_intel_lvds_mode_fixup,
|
||||
.prepare = psb_intel_lvds_prepare,
|
||||
.mode_set = psb_intel_lvds_mode_set,
|
||||
.commit = psb_intel_lvds_commit,
|
||||
};
|
||||
|
||||
const struct drm_connector_helper_funcs
|
||||
psb_intel_lvds_connector_helper_funcs = {
|
||||
.get_modes = psb_intel_lvds_get_modes,
|
||||
.mode_valid = psb_intel_lvds_mode_valid,
|
||||
.best_encoder = psb_intel_best_encoder,
|
||||
};
|
||||
|
||||
const struct drm_connector_funcs psb_intel_lvds_connector_funcs = {
|
||||
.dpms = drm_helper_connector_dpms,
|
||||
.save = psb_intel_lvds_save,
|
||||
.restore = psb_intel_lvds_restore,
|
||||
.detect = psb_intel_lvds_detect,
|
||||
.fill_modes = drm_helper_probe_single_connector_modes,
|
||||
.set_property = psb_intel_lvds_set_property,
|
||||
.destroy = psb_intel_lvds_destroy,
|
||||
};
|
||||
|
||||
|
||||
static void psb_intel_lvds_enc_destroy(struct drm_encoder *encoder)
|
||||
{
|
||||
drm_encoder_cleanup(encoder);
|
||||
}
|
||||
|
||||
const struct drm_encoder_funcs psb_intel_lvds_enc_funcs = {
|
||||
.destroy = psb_intel_lvds_enc_destroy,
|
||||
};
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* psb_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).
|
||||
*/
|
||||
void psb_intel_lvds_init(struct drm_device *dev,
|
||||
struct psb_intel_mode_device *mode_dev)
|
||||
{
|
||||
struct psb_intel_output *psb_intel_output;
|
||||
struct psb_intel_lvds_priv *lvds_priv;
|
||||
struct drm_connector *connector;
|
||||
struct drm_encoder *encoder;
|
||||
struct drm_display_mode *scan; /* *modes, *bios_mode; */
|
||||
struct drm_crtc *crtc;
|
||||
struct drm_psb_private *dev_priv =
|
||||
(struct drm_psb_private *)dev->dev_private;
|
||||
u32 lvds;
|
||||
int pipe;
|
||||
|
||||
psb_intel_output = kzalloc(sizeof(struct psb_intel_output), GFP_KERNEL);
|
||||
if (!psb_intel_output)
|
||||
return;
|
||||
|
||||
lvds_priv = kzalloc(sizeof(struct psb_intel_lvds_priv), GFP_KERNEL);
|
||||
if (!lvds_priv) {
|
||||
kfree(psb_intel_output);
|
||||
dev_err(dev->dev, "LVDS private allocation error\n");
|
||||
return;
|
||||
}
|
||||
|
||||
psb_intel_output->dev_priv = lvds_priv;
|
||||
|
||||
psb_intel_output->mode_dev = mode_dev;
|
||||
connector = &psb_intel_output->base;
|
||||
encoder = &psb_intel_output->enc;
|
||||
drm_connector_init(dev, &psb_intel_output->base,
|
||||
&psb_intel_lvds_connector_funcs,
|
||||
DRM_MODE_CONNECTOR_LVDS);
|
||||
|
||||
drm_encoder_init(dev, &psb_intel_output->enc,
|
||||
&psb_intel_lvds_enc_funcs,
|
||||
DRM_MODE_ENCODER_LVDS);
|
||||
|
||||
drm_mode_connector_attach_encoder(&psb_intel_output->base,
|
||||
&psb_intel_output->enc);
|
||||
psb_intel_output->type = INTEL_OUTPUT_LVDS;
|
||||
|
||||
drm_encoder_helper_add(encoder, &psb_intel_lvds_helper_funcs);
|
||||
drm_connector_helper_add(connector,
|
||||
&psb_intel_lvds_connector_helper_funcs);
|
||||
connector->display_info.subpixel_order = SubPixelHorizontalRGB;
|
||||
connector->interlace_allowed = false;
|
||||
connector->doublescan_allowed = false;
|
||||
|
||||
/*Attach connector properties*/
|
||||
drm_connector_attach_property(connector,
|
||||
dev->mode_config.scaling_mode_property,
|
||||
DRM_MODE_SCALE_FULLSCREEN);
|
||||
drm_connector_attach_property(connector,
|
||||
dev_priv->backlight_property,
|
||||
BRIGHTNESS_MAX_LEVEL);
|
||||
|
||||
/*
|
||||
* Set up I2C bus
|
||||
* FIXME: distroy i2c_bus when exit
|
||||
*/
|
||||
psb_intel_output->i2c_bus = psb_intel_i2c_create(dev,
|
||||
GPIOB,
|
||||
"LVDSBLC_B");
|
||||
if (!psb_intel_output->i2c_bus) {
|
||||
dev_printk(KERN_ERR,
|
||||
&dev->pdev->dev, "I2C bus registration failed.\n");
|
||||
goto failed_blc_i2c;
|
||||
}
|
||||
psb_intel_output->i2c_bus->slave_addr = 0x2C;
|
||||
dev_priv->lvds_i2c_bus = psb_intel_output->i2c_bus;
|
||||
|
||||
/*
|
||||
* 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
|
||||
*/
|
||||
|
||||
/* Set up the DDC bus. */
|
||||
psb_intel_output->ddc_bus = psb_intel_i2c_create(dev,
|
||||
GPIOC,
|
||||
"LVDSDDC_C");
|
||||
if (!psb_intel_output->ddc_bus) {
|
||||
dev_printk(KERN_ERR, &dev->pdev->dev,
|
||||
"DDC bus registration " "failed.\n");
|
||||
goto failed_ddc;
|
||||
}
|
||||
|
||||
/*
|
||||
* Attempt to get the fixed panel mode from DDC. Assume that the
|
||||
* preferred mode is the right one.
|
||||
*/
|
||||
psb_intel_ddc_get_modes(psb_intel_output);
|
||||
list_for_each_entry(scan, &connector->probed_modes, head) {
|
||||
if (scan->type & DRM_MODE_TYPE_PREFERRED) {
|
||||
mode_dev->panel_fixed_mode =
|
||||
drm_mode_duplicate(dev, scan);
|
||||
goto out; /* FIXME: check for quirks */
|
||||
}
|
||||
}
|
||||
|
||||
/* Failed to get EDID, what about VBT? do we need this? */
|
||||
if (mode_dev->vbt_mode)
|
||||
mode_dev->panel_fixed_mode =
|
||||
drm_mode_duplicate(dev, mode_dev->vbt_mode);
|
||||
|
||||
if (!mode_dev->panel_fixed_mode)
|
||||
if (dev_priv->lfp_lvds_vbt_mode)
|
||||
mode_dev->panel_fixed_mode =
|
||||
drm_mode_duplicate(dev,
|
||||
dev_priv->lfp_lvds_vbt_mode);
|
||||
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
lvds = REG_READ(LVDS);
|
||||
pipe = (lvds & LVDS_PIPEB_SELECT) ? 1 : 0;
|
||||
crtc = psb_intel_get_crtc_from_pipe(dev, pipe);
|
||||
|
||||
if (crtc && (lvds & LVDS_PORT_EN)) {
|
||||
mode_dev->panel_fixed_mode =
|
||||
psb_intel_crtc_mode_get(dev, crtc);
|
||||
if (mode_dev->panel_fixed_mode) {
|
||||
mode_dev->panel_fixed_mode->type |=
|
||||
DRM_MODE_TYPE_PREFERRED;
|
||||
goto out; /* FIXME: check for quirks */
|
||||
}
|
||||
}
|
||||
|
||||
/* If we still don't have a mode after all that, give up. */
|
||||
if (!mode_dev->panel_fixed_mode) {
|
||||
dev_err(dev->dev, "Found no modes on the lvds, ignoring the LVDS\n");
|
||||
goto failed_find;
|
||||
}
|
||||
|
||||
/*
|
||||
* Blacklist machines with BIOSes that list an LVDS panel without
|
||||
* actually having one.
|
||||
*/
|
||||
out:
|
||||
drm_sysfs_connector_add(connector);
|
||||
return;
|
||||
|
||||
failed_find:
|
||||
if (psb_intel_output->ddc_bus)
|
||||
psb_intel_i2c_destroy(psb_intel_output->ddc_bus);
|
||||
failed_ddc:
|
||||
if (psb_intel_output->i2c_bus)
|
||||
psb_intel_i2c_destroy(psb_intel_output->i2c_bus);
|
||||
failed_blc_i2c:
|
||||
drm_encoder_cleanup(encoder);
|
||||
drm_connector_cleanup(connector);
|
||||
kfree(connector);
|
||||
}
|
||||
|
|
@ -0,0 +1,77 @@
|
|||
/*
|
||||
* Copyright (c) 2007 Intel Corporation
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms and conditions of the GNU General Public License,
|
||||
* version 2, as published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
* more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Authers: Jesse Barnes <jesse.barnes@intel.com>
|
||||
*/
|
||||
|
||||
#include <linux/i2c.h>
|
||||
#include <linux/fb.h>
|
||||
#include <drm/drmP.h>
|
||||
#include "psb_intel_drv.h"
|
||||
|
||||
/**
|
||||
* psb_intel_ddc_probe
|
||||
*
|
||||
*/
|
||||
bool psb_intel_ddc_probe(struct psb_intel_output *psb_intel_output)
|
||||
{
|
||||
u8 out_buf[] = { 0x0, 0x0 };
|
||||
u8 buf[2];
|
||||
int ret;
|
||||
struct i2c_msg msgs[] = {
|
||||
{
|
||||
.addr = 0x50,
|
||||
.flags = 0,
|
||||
.len = 1,
|
||||
.buf = out_buf,
|
||||
},
|
||||
{
|
||||
.addr = 0x50,
|
||||
.flags = I2C_M_RD,
|
||||
.len = 1,
|
||||
.buf = buf,
|
||||
}
|
||||
};
|
||||
|
||||
ret = i2c_transfer(&psb_intel_output->ddc_bus->adapter, msgs, 2);
|
||||
if (ret == 2)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* psb_intel_ddc_get_modes - get modelist from monitor
|
||||
* @connector: DRM connector device to use
|
||||
*
|
||||
* Fetch the EDID information from @connector using the DDC bus.
|
||||
*/
|
||||
int psb_intel_ddc_get_modes(struct psb_intel_output *psb_intel_output)
|
||||
{
|
||||
struct edid *edid;
|
||||
int ret = 0;
|
||||
|
||||
edid =
|
||||
drm_get_edid(&psb_intel_output->base,
|
||||
&psb_intel_output->ddc_bus->adapter);
|
||||
if (edid) {
|
||||
drm_mode_connector_update_edid_property(&psb_intel_output->
|
||||
base, edid);
|
||||
ret = drm_add_edid_modes(&psb_intel_output->base, edid);
|
||||
kfree(edid);
|
||||
}
|
||||
return ret;
|
||||
}
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -0,0 +1,338 @@
|
|||
/*
|
||||
* SDVO command definitions and structures.
|
||||
*
|
||||
* Copyright (c) 2008, Intel Corporation
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms and conditions of the GNU General Public License,
|
||||
* version 2, as published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
* more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Authors:
|
||||
* Eric Anholt <eric@anholt.net>
|
||||
*/
|
||||
|
||||
#define SDVO_OUTPUT_FIRST (0)
|
||||
#define SDVO_OUTPUT_TMDS0 (1 << 0)
|
||||
#define SDVO_OUTPUT_RGB0 (1 << 1)
|
||||
#define SDVO_OUTPUT_CVBS0 (1 << 2)
|
||||
#define SDVO_OUTPUT_SVID0 (1 << 3)
|
||||
#define SDVO_OUTPUT_YPRPB0 (1 << 4)
|
||||
#define SDVO_OUTPUT_SCART0 (1 << 5)
|
||||
#define SDVO_OUTPUT_LVDS0 (1 << 6)
|
||||
#define SDVO_OUTPUT_TMDS1 (1 << 8)
|
||||
#define SDVO_OUTPUT_RGB1 (1 << 9)
|
||||
#define SDVO_OUTPUT_CVBS1 (1 << 10)
|
||||
#define SDVO_OUTPUT_SVID1 (1 << 11)
|
||||
#define SDVO_OUTPUT_YPRPB1 (1 << 12)
|
||||
#define SDVO_OUTPUT_SCART1 (1 << 13)
|
||||
#define SDVO_OUTPUT_LVDS1 (1 << 14)
|
||||
#define SDVO_OUTPUT_LAST (14)
|
||||
|
||||
struct psb_intel_sdvo_caps {
|
||||
u8 vendor_id;
|
||||
u8 device_id;
|
||||
u8 device_rev_id;
|
||||
u8 sdvo_version_major;
|
||||
u8 sdvo_version_minor;
|
||||
unsigned int sdvo_inputs_mask:2;
|
||||
unsigned int smooth_scaling:1;
|
||||
unsigned int sharp_scaling:1;
|
||||
unsigned int up_scaling:1;
|
||||
unsigned int down_scaling:1;
|
||||
unsigned int stall_support:1;
|
||||
unsigned int pad:1;
|
||||
u16 output_flags;
|
||||
} __packed;
|
||||
|
||||
/** This matches the EDID DTD structure, more or less */
|
||||
struct psb_intel_sdvo_dtd {
|
||||
struct {
|
||||
u16 clock; /**< pixel clock, in 10kHz units */
|
||||
u8 h_active; /**< lower 8 bits (pixels) */
|
||||
u8 h_blank; /**< lower 8 bits (pixels) */
|
||||
u8 h_high; /**< upper 4 bits each h_active, h_blank */
|
||||
u8 v_active; /**< lower 8 bits (lines) */
|
||||
u8 v_blank; /**< lower 8 bits (lines) */
|
||||
u8 v_high; /**< upper 4 bits each v_active, v_blank */
|
||||
} part1;
|
||||
|
||||
struct {
|
||||
u8 h_sync_off;
|
||||
/**< lower 8 bits, from hblank start */
|
||||
u8 h_sync_width;/**< lower 8 bits (pixels) */
|
||||
/** lower 4 bits each vsync offset, vsync width */
|
||||
u8 v_sync_off_width;
|
||||
/**
|
||||
* 2 high bits of hsync offset, 2 high bits of hsync width,
|
||||
* bits 4-5 of vsync offset, and 2 high bits of vsync width.
|
||||
*/
|
||||
u8 sync_off_width_high;
|
||||
u8 dtd_flags;
|
||||
u8 sdvo_flags;
|
||||
/** bits 6-7 of vsync offset at bits 6-7 */
|
||||
u8 v_sync_off_high;
|
||||
u8 reserved;
|
||||
} part2;
|
||||
} __packed;
|
||||
|
||||
struct psb_intel_sdvo_pixel_clock_range {
|
||||
u16 min; /**< pixel clock, in 10kHz units */
|
||||
u16 max; /**< pixel clock, in 10kHz units */
|
||||
} __packed;
|
||||
|
||||
struct psb_intel_sdvo_preferred_input_timing_args {
|
||||
u16 clock;
|
||||
u16 width;
|
||||
u16 height;
|
||||
} __packed;
|
||||
|
||||
/* I2C registers for SDVO */
|
||||
#define SDVO_I2C_ARG_0 0x07
|
||||
#define SDVO_I2C_ARG_1 0x06
|
||||
#define SDVO_I2C_ARG_2 0x05
|
||||
#define SDVO_I2C_ARG_3 0x04
|
||||
#define SDVO_I2C_ARG_4 0x03
|
||||
#define SDVO_I2C_ARG_5 0x02
|
||||
#define SDVO_I2C_ARG_6 0x01
|
||||
#define SDVO_I2C_ARG_7 0x00
|
||||
#define SDVO_I2C_OPCODE 0x08
|
||||
#define SDVO_I2C_CMD_STATUS 0x09
|
||||
#define SDVO_I2C_RETURN_0 0x0a
|
||||
#define SDVO_I2C_RETURN_1 0x0b
|
||||
#define SDVO_I2C_RETURN_2 0x0c
|
||||
#define SDVO_I2C_RETURN_3 0x0d
|
||||
#define SDVO_I2C_RETURN_4 0x0e
|
||||
#define SDVO_I2C_RETURN_5 0x0f
|
||||
#define SDVO_I2C_RETURN_6 0x10
|
||||
#define SDVO_I2C_RETURN_7 0x11
|
||||
#define SDVO_I2C_VENDOR_BEGIN 0x20
|
||||
|
||||
/* Status results */
|
||||
#define SDVO_CMD_STATUS_POWER_ON 0x0
|
||||
#define SDVO_CMD_STATUS_SUCCESS 0x1
|
||||
#define SDVO_CMD_STATUS_NOTSUPP 0x2
|
||||
#define SDVO_CMD_STATUS_INVALID_ARG 0x3
|
||||
#define SDVO_CMD_STATUS_PENDING 0x4
|
||||
#define SDVO_CMD_STATUS_TARGET_NOT_SPECIFIED 0x5
|
||||
#define SDVO_CMD_STATUS_SCALING_NOT_SUPP 0x6
|
||||
|
||||
/* SDVO commands, argument/result registers */
|
||||
|
||||
#define SDVO_CMD_RESET 0x01
|
||||
|
||||
/** Returns a struct psb_intel_sdvo_caps */
|
||||
#define SDVO_CMD_GET_DEVICE_CAPS 0x02
|
||||
|
||||
#define SDVO_CMD_GET_FIRMWARE_REV 0x86
|
||||
# define SDVO_DEVICE_FIRMWARE_MINOR SDVO_I2C_RETURN_0
|
||||
# define SDVO_DEVICE_FIRMWARE_MAJOR SDVO_I2C_RETURN_1
|
||||
# define SDVO_DEVICE_FIRMWARE_PATCH SDVO_I2C_RETURN_2
|
||||
|
||||
/**
|
||||
* Reports which inputs are trained (managed to sync).
|
||||
*
|
||||
* Devices must have trained within 2 vsyncs of a mode change.
|
||||
*/
|
||||
#define SDVO_CMD_GET_TRAINED_INPUTS 0x03
|
||||
struct psb_intel_sdvo_get_trained_inputs_response {
|
||||
unsigned int input0_trained:1;
|
||||
unsigned int input1_trained:1;
|
||||
unsigned int pad:6;
|
||||
} __packed;
|
||||
|
||||
/** Returns a struct psb_intel_sdvo_output_flags of active outputs. */
|
||||
#define SDVO_CMD_GET_ACTIVE_OUTPUTS 0x04
|
||||
|
||||
/**
|
||||
* Sets the current set of active outputs.
|
||||
*
|
||||
* Takes a struct psb_intel_sdvo_output_flags.
|
||||
* Must be preceded by a SET_IN_OUT_MAP
|
||||
* on multi-output devices.
|
||||
*/
|
||||
#define SDVO_CMD_SET_ACTIVE_OUTPUTS 0x05
|
||||
|
||||
/**
|
||||
* Returns the current mapping of SDVO inputs to outputs on the device.
|
||||
*
|
||||
* Returns two struct psb_intel_sdvo_output_flags structures.
|
||||
*/
|
||||
#define SDVO_CMD_GET_IN_OUT_MAP 0x06
|
||||
|
||||
/**
|
||||
* Sets the current mapping of SDVO inputs to outputs on the device.
|
||||
*
|
||||
* Takes two struct i380_sdvo_output_flags structures.
|
||||
*/
|
||||
#define SDVO_CMD_SET_IN_OUT_MAP 0x07
|
||||
|
||||
/**
|
||||
* Returns a struct psb_intel_sdvo_output_flags of attached displays.
|
||||
*/
|
||||
#define SDVO_CMD_GET_ATTACHED_DISPLAYS 0x0b
|
||||
|
||||
/**
|
||||
* Returns a struct psb_intel_sdvo_ouptut_flags of displays supporting hot plugging.
|
||||
*/
|
||||
#define SDVO_CMD_GET_HOT_PLUG_SUPPORT 0x0c
|
||||
|
||||
/**
|
||||
* Takes a struct psb_intel_sdvo_output_flags.
|
||||
*/
|
||||
#define SDVO_CMD_SET_ACTIVE_HOT_PLUG 0x0d
|
||||
|
||||
/**
|
||||
* Returns a struct psb_intel_sdvo_output_flags of displays with hot plug
|
||||
* interrupts enabled.
|
||||
*/
|
||||
#define SDVO_CMD_GET_ACTIVE_HOT_PLUG 0x0e
|
||||
|
||||
#define SDVO_CMD_GET_INTERRUPT_EVENT_SOURCE 0x0f
|
||||
struct psb_intel_sdvo_get_interrupt_event_source_response {
|
||||
u16 interrupt_status;
|
||||
unsigned int ambient_light_interrupt:1;
|
||||
unsigned int pad:7;
|
||||
} __packed;
|
||||
|
||||
/**
|
||||
* Selects which input is affected by future input commands.
|
||||
*
|
||||
* Commands affected include SET_INPUT_TIMINGS_PART[12],
|
||||
* GET_INPUT_TIMINGS_PART[12], GET_PREFERRED_INPUT_TIMINGS_PART[12],
|
||||
* GET_INPUT_PIXEL_CLOCK_RANGE, and CREATE_PREFERRED_INPUT_TIMINGS.
|
||||
*/
|
||||
#define SDVO_CMD_SET_TARGET_INPUT 0x10
|
||||
struct psb_intel_sdvo_set_target_input_args {
|
||||
unsigned int target_1:1;
|
||||
unsigned int pad:7;
|
||||
} __packed;
|
||||
|
||||
/**
|
||||
* Takes a struct psb_intel_sdvo_output_flags of which outputs are targeted by
|
||||
* future output commands.
|
||||
*
|
||||
* Affected commands inclue SET_OUTPUT_TIMINGS_PART[12],
|
||||
* GET_OUTPUT_TIMINGS_PART[12], and GET_OUTPUT_PIXEL_CLOCK_RANGE.
|
||||
*/
|
||||
#define SDVO_CMD_SET_TARGET_OUTPUT 0x11
|
||||
|
||||
#define SDVO_CMD_GET_INPUT_TIMINGS_PART1 0x12
|
||||
#define SDVO_CMD_GET_INPUT_TIMINGS_PART2 0x13
|
||||
#define SDVO_CMD_SET_INPUT_TIMINGS_PART1 0x14
|
||||
#define SDVO_CMD_SET_INPUT_TIMINGS_PART2 0x15
|
||||
#define SDVO_CMD_SET_OUTPUT_TIMINGS_PART1 0x16
|
||||
#define SDVO_CMD_SET_OUTPUT_TIMINGS_PART2 0x17
|
||||
#define SDVO_CMD_GET_OUTPUT_TIMINGS_PART1 0x18
|
||||
#define SDVO_CMD_GET_OUTPUT_TIMINGS_PART2 0x19
|
||||
/* Part 1 */
|
||||
# define SDVO_DTD_CLOCK_LOW SDVO_I2C_ARG_0
|
||||
# define SDVO_DTD_CLOCK_HIGH SDVO_I2C_ARG_1
|
||||
# define SDVO_DTD_H_ACTIVE SDVO_I2C_ARG_2
|
||||
# define SDVO_DTD_H_BLANK SDVO_I2C_ARG_3
|
||||
# define SDVO_DTD_H_HIGH SDVO_I2C_ARG_4
|
||||
# define SDVO_DTD_V_ACTIVE SDVO_I2C_ARG_5
|
||||
# define SDVO_DTD_V_BLANK SDVO_I2C_ARG_6
|
||||
# define SDVO_DTD_V_HIGH SDVO_I2C_ARG_7
|
||||
/* Part 2 */
|
||||
# define SDVO_DTD_HSYNC_OFF SDVO_I2C_ARG_0
|
||||
# define SDVO_DTD_HSYNC_WIDTH SDVO_I2C_ARG_1
|
||||
# define SDVO_DTD_VSYNC_OFF_WIDTH SDVO_I2C_ARG_2
|
||||
# define SDVO_DTD_SYNC_OFF_WIDTH_HIGH SDVO_I2C_ARG_3
|
||||
# define SDVO_DTD_DTD_FLAGS SDVO_I2C_ARG_4
|
||||
# define SDVO_DTD_DTD_FLAG_INTERLACED (1 << 7)
|
||||
# define SDVO_DTD_DTD_FLAG_STEREO_MASK (3 << 5)
|
||||
# define SDVO_DTD_DTD_FLAG_INPUT_MASK (3 << 3)
|
||||
# define SDVO_DTD_DTD_FLAG_SYNC_MASK (3 << 1)
|
||||
# define SDVO_DTD_SDVO_FLAS SDVO_I2C_ARG_5
|
||||
# define SDVO_DTD_SDVO_FLAG_STALL (1 << 7)
|
||||
# define SDVO_DTD_SDVO_FLAG_CENTERED (0 << 6)
|
||||
# define SDVO_DTD_SDVO_FLAG_UPPER_LEFT (1 << 6)
|
||||
# define SDVO_DTD_SDVO_FLAG_SCALING_MASK (3 << 4)
|
||||
# define SDVO_DTD_SDVO_FLAG_SCALING_NONE (0 << 4)
|
||||
# define SDVO_DTD_SDVO_FLAG_SCALING_SHARP (1 << 4)
|
||||
# define SDVO_DTD_SDVO_FLAG_SCALING_SMOOTH (2 << 4)
|
||||
# define SDVO_DTD_VSYNC_OFF_HIGH SDVO_I2C_ARG_6
|
||||
|
||||
/**
|
||||
* Generates a DTD based on the given width, height, and flags.
|
||||
*
|
||||
* This will be supported by any device supporting scaling or interlaced
|
||||
* modes.
|
||||
*/
|
||||
#define SDVO_CMD_CREATE_PREFERRED_INPUT_TIMING 0x1a
|
||||
# define SDVO_PREFERRED_INPUT_TIMING_CLOCK_LOW SDVO_I2C_ARG_0
|
||||
# define SDVO_PREFERRED_INPUT_TIMING_CLOCK_HIGH SDVO_I2C_ARG_1
|
||||
# define SDVO_PREFERRED_INPUT_TIMING_WIDTH_LOW SDVO_I2C_ARG_2
|
||||
# define SDVO_PREFERRED_INPUT_TIMING_WIDTH_HIGH SDVO_I2C_ARG_3
|
||||
# define SDVO_PREFERRED_INPUT_TIMING_HEIGHT_LOW SDVO_I2C_ARG_4
|
||||
# define SDVO_PREFERRED_INPUT_TIMING_HEIGHT_HIGH SDVO_I2C_ARG_5
|
||||
# define SDVO_PREFERRED_INPUT_TIMING_FLAGS SDVO_I2C_ARG_6
|
||||
# define SDVO_PREFERRED_INPUT_TIMING_FLAGS_INTERLACED (1 << 0)
|
||||
# define SDVO_PREFERRED_INPUT_TIMING_FLAGS_SCALED (1 << 1)
|
||||
|
||||
#define SDVO_CMD_GET_PREFERRED_INPUT_TIMING_PART1 0x1b
|
||||
#define SDVO_CMD_GET_PREFERRED_INPUT_TIMING_PART2 0x1c
|
||||
|
||||
/** Returns a struct psb_intel_sdvo_pixel_clock_range */
|
||||
#define SDVO_CMD_GET_INPUT_PIXEL_CLOCK_RANGE 0x1d
|
||||
/** Returns a struct psb_intel_sdvo_pixel_clock_range */
|
||||
#define SDVO_CMD_GET_OUTPUT_PIXEL_CLOCK_RANGE 0x1e
|
||||
|
||||
/** Returns a byte bitfield containing SDVO_CLOCK_RATE_MULT_* flags */
|
||||
#define SDVO_CMD_GET_SUPPORTED_CLOCK_RATE_MULTS 0x1f
|
||||
|
||||
/** Returns a byte containing a SDVO_CLOCK_RATE_MULT_* flag */
|
||||
#define SDVO_CMD_GET_CLOCK_RATE_MULT 0x20
|
||||
/** Takes a byte containing a SDVO_CLOCK_RATE_MULT_* flag */
|
||||
#define SDVO_CMD_SET_CLOCK_RATE_MULT 0x21
|
||||
# define SDVO_CLOCK_RATE_MULT_1X (1 << 0)
|
||||
# define SDVO_CLOCK_RATE_MULT_2X (1 << 1)
|
||||
# define SDVO_CLOCK_RATE_MULT_4X (1 << 3)
|
||||
|
||||
#define SDVO_CMD_GET_SUPPORTED_TV_FORMATS 0x27
|
||||
|
||||
#define SDVO_CMD_GET_TV_FORMAT 0x28
|
||||
|
||||
#define SDVO_CMD_SET_TV_FORMAT 0x29
|
||||
|
||||
#define SDVO_CMD_GET_SUPPORTED_POWER_STATES 0x2a
|
||||
#define SDVO_CMD_GET_ENCODER_POWER_STATE 0x2b
|
||||
#define SDVO_CMD_SET_ENCODER_POWER_STATE 0x2c
|
||||
# define SDVO_ENCODER_STATE_ON (1 << 0)
|
||||
# define SDVO_ENCODER_STATE_STANDBY (1 << 1)
|
||||
# define SDVO_ENCODER_STATE_SUSPEND (1 << 2)
|
||||
# define SDVO_ENCODER_STATE_OFF (1 << 3)
|
||||
|
||||
#define SDVO_CMD_SET_TV_RESOLUTION_SUPPORT 0x93
|
||||
|
||||
#define SDVO_CMD_SET_CONTROL_BUS_SWITCH 0x7a
|
||||
# define SDVO_CONTROL_BUS_PROM 0x0
|
||||
# define SDVO_CONTROL_BUS_DDC1 0x1
|
||||
# define SDVO_CONTROL_BUS_DDC2 0x2
|
||||
# define SDVO_CONTROL_BUS_DDC3 0x3
|
||||
|
||||
/* SDVO Bus & SDVO Inputs wiring details*/
|
||||
/* Bit 0: Is SDVOB connected to In0 (1 = yes, 0 = no*/
|
||||
/* Bit 1: Is SDVOB connected to In1 (1 = yes, 0 = no*/
|
||||
/* Bit 2: Is SDVOC connected to In0 (1 = yes, 0 = no*/
|
||||
/* Bit 3: Is SDVOC connected to In1 (1 = yes, 0 = no*/
|
||||
#define SDVOB_IN0 0x01
|
||||
#define SDVOB_IN1 0x02
|
||||
#define SDVOC_IN0 0x04
|
||||
#define SDVOC_IN1 0x08
|
||||
|
||||
#define SDVO_DEVICE_NONE 0x00
|
||||
#define SDVO_DEVICE_CRT 0x01
|
||||
#define SDVO_DEVICE_TV 0x02
|
||||
#define SDVO_DEVICE_LVDS 0x04
|
||||
#define SDVO_DEVICE_TMDS 0x08
|
||||
|
|
@ -0,0 +1,90 @@
|
|||
/**************************************************************************
|
||||
* Copyright (c) 2007, Intel Corporation.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms and conditions of the GNU General Public License,
|
||||
* version 2, as published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
* more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Authors: Thomas Hellstrom <thomas-at-tungstengraphics-dot-com>
|
||||
**************************************************************************/
|
||||
|
||||
#include <drm/drmP.h>
|
||||
#include "psb_drv.h"
|
||||
#include "psb_reg.h"
|
||||
#include "psb_intel_reg.h"
|
||||
#include <linux/spinlock.h>
|
||||
|
||||
static void psb_lid_timer_func(unsigned long data)
|
||||
{
|
||||
struct drm_psb_private * dev_priv = (struct drm_psb_private *)data;
|
||||
struct drm_device *dev = (struct drm_device *)dev_priv->dev;
|
||||
struct timer_list *lid_timer = &dev_priv->lid_timer;
|
||||
unsigned long irq_flags;
|
||||
u32 *lid_state = dev_priv->lid_state;
|
||||
u32 pp_status;
|
||||
|
||||
if (readl(lid_state) == dev_priv->lid_last_state)
|
||||
goto lid_timer_schedule;
|
||||
|
||||
if ((readl(lid_state)) & 0x01) {
|
||||
/*lid state is open*/
|
||||
REG_WRITE(PP_CONTROL, REG_READ(PP_CONTROL) | POWER_TARGET_ON);
|
||||
do {
|
||||
pp_status = REG_READ(PP_STATUS);
|
||||
} while ((pp_status & PP_ON) == 0);
|
||||
|
||||
/*FIXME: should be backlight level before*/
|
||||
psb_intel_lvds_set_brightness(dev, 100);
|
||||
} else {
|
||||
psb_intel_lvds_set_brightness(dev, 0);
|
||||
|
||||
REG_WRITE(PP_CONTROL, REG_READ(PP_CONTROL) & ~POWER_TARGET_ON);
|
||||
do {
|
||||
pp_status = REG_READ(PP_STATUS);
|
||||
} while ((pp_status & PP_ON) == 0);
|
||||
}
|
||||
/* printk(KERN_INFO"%s: lid: closed\n", __FUNCTION__); */
|
||||
|
||||
dev_priv->lid_last_state = readl(lid_state);
|
||||
|
||||
lid_timer_schedule:
|
||||
spin_lock_irqsave(&dev_priv->lid_lock, irq_flags);
|
||||
if (!timer_pending(lid_timer)) {
|
||||
lid_timer->expires = jiffies + PSB_LID_DELAY;
|
||||
add_timer(lid_timer);
|
||||
}
|
||||
spin_unlock_irqrestore(&dev_priv->lid_lock, irq_flags);
|
||||
}
|
||||
|
||||
void psb_lid_timer_init(struct drm_psb_private *dev_priv)
|
||||
{
|
||||
struct timer_list *lid_timer = &dev_priv->lid_timer;
|
||||
unsigned long irq_flags;
|
||||
|
||||
spin_lock_init(&dev_priv->lid_lock);
|
||||
spin_lock_irqsave(&dev_priv->lid_lock, irq_flags);
|
||||
|
||||
init_timer(lid_timer);
|
||||
|
||||
lid_timer->data = (unsigned long)dev_priv;
|
||||
lid_timer->function = psb_lid_timer_func;
|
||||
lid_timer->expires = jiffies + PSB_LID_DELAY;
|
||||
|
||||
add_timer(lid_timer);
|
||||
spin_unlock_irqrestore(&dev_priv->lid_lock, irq_flags);
|
||||
}
|
||||
|
||||
void psb_lid_timer_takedown(struct drm_psb_private *dev_priv)
|
||||
{
|
||||
del_timer_sync(&dev_priv->lid_timer);
|
||||
}
|
||||
|
Загрузка…
Ссылка в новой задаче