24
24
#include <drm/drmP.h>
25
25
#include <asm/mrst.h>
27
#include "psb_intel_bios.h"
27
#include "intel_bios.h"
28
28
#include "psb_drv.h"
29
29
#include "psb_intel_drv.h"
30
30
#include "psb_intel_reg.h"
31
#include "psb_powermgmt.h"
32
32
#include <linux/pm_runtime.h>
34
34
/* The max/min PWM frequency in BPCR[31:17] - */
46
46
struct psb_intel_output *output, bool on)
49
DRM_DRIVER_PRIVATE_T *dev_priv = dev->dev_private;
50
PSB_DEBUG_ENTRY("\n");
49
struct drm_psb_private *dev_priv = dev->dev_private;
52
51
if (!gma_power_begin(dev, true))
59
58
pp_status = REG_READ(PP_STATUS);
60
59
} while ((pp_status & (PP_ON | PP_READY)) == PP_READY);
61
60
dev_priv->is_lvds_on = true;
61
if (dev_priv->ops->lvds_bl_power)
62
dev_priv->ops->lvds_bl_power(dev, true);
64
if (dev_priv->ops->lvds_bl_power)
65
dev_priv->ops->lvds_bl_power(dev, false);
63
66
REG_WRITE(PP_CONTROL, REG_READ(PP_CONTROL) &
77
79
struct drm_device *dev = encoder->dev;
78
80
struct psb_intel_output *output = enc_to_psb_intel_output(encoder);
80
PSB_DEBUG_ENTRY("\n");
82
82
if (mode == DRM_MODE_DPMS_ON)
83
83
mrst_lvds_set_power(dev, output, true);
94
94
struct psb_intel_mode_device *mode_dev =
95
95
enc_to_psb_intel_output(encoder)->mode_dev;
96
96
struct drm_device *dev = encoder->dev;
97
struct drm_psb_private *dev_priv = dev->dev_private;
98
99
uint64_t v = DRM_MODE_SCALE_FULLSCREEN;
100
PSB_DEBUG_ENTRY("\n");
102
101
if (!gma_power_begin(dev, true))
115
if (mode_dev->panel_wants_dither)
114
/* If the firmware says dither on Moorestown, or the BIOS does
115
on Oaktrail then enable dithering */
116
if (mode_dev->panel_wants_dither || dev_priv->lvds_dither)
116
117
lvds_port |= MRST_PANEL_8TO6_DITHER_ENABLE;
118
119
REG_WRITE(LVDS, lvds_port);
146
147
gma_power_end(dev);
150
static void mrst_lvds_prepare(struct drm_encoder *encoder)
152
struct drm_device *dev = encoder->dev;
153
struct psb_intel_output *output = enc_to_psb_intel_output(encoder);
154
struct psb_intel_mode_device *mode_dev = output->mode_dev;
156
if (!gma_power_begin(dev, true))
159
mode_dev->saveBLC_PWM_CTL = REG_READ(BLC_PWM_CTL);
160
mode_dev->backlight_duty_cycle = (mode_dev->saveBLC_PWM_CTL &
161
BACKLIGHT_DUTY_CYCLE_MASK);
162
mrst_lvds_set_power(dev, output, false);
166
static u32 mrst_lvds_get_max_backlight(struct drm_device *dev)
168
struct drm_psb_private *dev_priv = dev->dev_private;
171
if (gma_power_begin(dev, false)) {
172
ret = ((REG_READ(BLC_PWM_CTL) &
173
BACKLIGHT_MODULATION_FREQ_MASK) >>
174
BACKLIGHT_MODULATION_FREQ_SHIFT) * 2;
178
ret = ((dev_priv->saveBLC_PWM_CTL &
179
BACKLIGHT_MODULATION_FREQ_MASK) >>
180
BACKLIGHT_MODULATION_FREQ_SHIFT) * 2;
185
static void mrst_lvds_commit(struct drm_encoder *encoder)
187
struct drm_device *dev = encoder->dev;
188
struct psb_intel_output *output = enc_to_psb_intel_output(encoder);
189
struct psb_intel_mode_device *mode_dev = output->mode_dev;
191
if (mode_dev->backlight_duty_cycle == 0)
192
mode_dev->backlight_duty_cycle =
193
mrst_lvds_get_max_backlight(dev);
194
mrst_lvds_set_power(dev, output, true);
150
197
static const struct drm_encoder_helper_funcs mrst_lvds_helper_funcs = {
151
198
.dpms = mrst_lvds_dpms,
152
199
.mode_fixup = psb_intel_lvds_mode_fixup,
153
.prepare = psb_intel_lvds_prepare,
200
.prepare = mrst_lvds_prepare,
154
201
.mode_set = mrst_lvds_mode_set,
155
.commit = psb_intel_lvds_commit,
202
.commit = mrst_lvds_commit,
158
205
static struct drm_display_mode lvds_configuration_modes[] = {
302
347
* if closed, act like it's not there for now
305
/* This ifdef can go once the cpu ident stuff is cleaned up in arch */
306
#if defined(CONFIG_X86_MRST)
307
if (mrst_identify_cpu())
308
i2c_adap = i2c_get_adapter(2);
309
else /* Oaktrail uses I2C 1 */
311
i2c_adap = i2c_get_adapter(1);
350
i2c_adap = i2c_get_adapter(dev_priv->ops->i2c_bus);
313
352
if (i2c_adap == NULL)
314
printk(KERN_ALERT "No ddc adapter available!\n");
353
dev_err(dev->dev, "No ddc adapter available!\n");
316
355
* Attempt to get the fixed panel mode from DDC. Assume that the
317
356
* preferred mode is the right one.
341
379
mode_dev->panel_fixed_mode = mrst_lvds_get_configuration_mode(dev);
343
381
if (mode_dev->panel_fixed_mode) {
344
mode_dev->panel_fixed_mode->type |=
345
DRM_MODE_TYPE_PREFERRED;
382
mode_dev->panel_fixed_mode->type |= DRM_MODE_TYPE_PREFERRED;
346
383
goto out; /* FIXME: check for quirks */
349
386
/* If we still don't have a mode after all that, give up. */
350
387
if (!mode_dev->panel_fixed_mode) {
352
("Found no modes on the lvds, ignoring the LVDS\n");
388
dev_err(dev->dev, "Found no modes on the lvds, ignoring the LVDS\n");
353
389
goto failed_find;
361
DRM_DEBUG("No LVDS modes found, disabling.\n");
397
dev_dbg(dev->dev, "No LVDS modes found, disabling.\n");
362
398
if (psb_intel_output->ddc_bus)
363
399
psb_intel_i2c_destroy(psb_intel_output->ddc_bus);