Commit fac3274c authored by Daniel Vetter's avatar Daniel Vetter

drm/i915: simplify dvo dpms interface

All dvo drivers only support 2 dpms states, and our dvo driver
even switches of the dvo port for anything else than DPMS_ON. Hence
ditch this complexity and simply use bool enable.

While reading through this code I've noticed that the mode_set
function of ch7017 is a bit peculiar - it disable the lvds again, even
though the crtc helper code should have done that ... This might be to
work around an issue at driver load, we pretty much ignore the hw
state when taking over.

v2: Also do the conversion for the new ns2501 driver.
Reviewed-by: default avatarChris Wilson <chris@chris-wilson.co.uk>
Signed-Off-by: default avatarDaniel Vetter <daniel.vetter@ffwll.ch>
parent d2434ab7
...@@ -58,13 +58,12 @@ struct intel_dvo_dev_ops { ...@@ -58,13 +58,12 @@ struct intel_dvo_dev_ops {
void (*create_resources)(struct intel_dvo_device *dvo); void (*create_resources)(struct intel_dvo_device *dvo);
/* /*
* Turn on/off output or set intermediate power levels if available. * Turn on/off output.
* *
* Unsupported intermediate modes drop to the lower power setting. * Because none of our dvo drivers support an intermediate power levels,
* If the mode is DPMSModeOff, the output must be disabled, * we don't expose this in the interfac.
* as the DPLL may be disabled afterwards.
*/ */
void (*dpms)(struct intel_dvo_device *dvo, int mode); void (*dpms)(struct intel_dvo_device *dvo, bool enable);
/* /*
* Callback for testing a video mode for a given output. * Callback for testing a video mode for a given output.
......
...@@ -163,7 +163,7 @@ struct ch7017_priv { ...@@ -163,7 +163,7 @@ struct ch7017_priv {
}; };
static void ch7017_dump_regs(struct intel_dvo_device *dvo); static void ch7017_dump_regs(struct intel_dvo_device *dvo);
static void ch7017_dpms(struct intel_dvo_device *dvo, int mode); static void ch7017_dpms(struct intel_dvo_device *dvo, bool enable);
static bool ch7017_read(struct intel_dvo_device *dvo, u8 addr, u8 *val) static bool ch7017_read(struct intel_dvo_device *dvo, u8 addr, u8 *val)
{ {
...@@ -309,7 +309,7 @@ static void ch7017_mode_set(struct intel_dvo_device *dvo, ...@@ -309,7 +309,7 @@ static void ch7017_mode_set(struct intel_dvo_device *dvo,
lvds_power_down = CH7017_LVDS_POWER_DOWN_DEFAULT_RESERVED | lvds_power_down = CH7017_LVDS_POWER_DOWN_DEFAULT_RESERVED |
(mode->hdisplay & 0x0700) >> 8; (mode->hdisplay & 0x0700) >> 8;
ch7017_dpms(dvo, DRM_MODE_DPMS_OFF); ch7017_dpms(dvo, false);
ch7017_write(dvo, CH7017_HORIZONTAL_ACTIVE_PIXEL_INPUT, ch7017_write(dvo, CH7017_HORIZONTAL_ACTIVE_PIXEL_INPUT,
horizontal_active_pixel_input); horizontal_active_pixel_input);
ch7017_write(dvo, CH7017_HORIZONTAL_ACTIVE_PIXEL_OUTPUT, ch7017_write(dvo, CH7017_HORIZONTAL_ACTIVE_PIXEL_OUTPUT,
...@@ -331,7 +331,7 @@ static void ch7017_mode_set(struct intel_dvo_device *dvo, ...@@ -331,7 +331,7 @@ static void ch7017_mode_set(struct intel_dvo_device *dvo,
} }
/* set the CH7017 power state */ /* set the CH7017 power state */
static void ch7017_dpms(struct intel_dvo_device *dvo, int mode) static void ch7017_dpms(struct intel_dvo_device *dvo, bool enable)
{ {
uint8_t val; uint8_t val;
...@@ -345,7 +345,7 @@ static void ch7017_dpms(struct intel_dvo_device *dvo, int mode) ...@@ -345,7 +345,7 @@ static void ch7017_dpms(struct intel_dvo_device *dvo, int mode)
CH7017_DAC3_POWER_DOWN | CH7017_DAC3_POWER_DOWN |
CH7017_TV_POWER_DOWN_EN); CH7017_TV_POWER_DOWN_EN);
if (mode == DRM_MODE_DPMS_ON) { if (enable) {
/* Turn on the LVDS */ /* Turn on the LVDS */
ch7017_write(dvo, CH7017_LVDS_POWER_DOWN, ch7017_write(dvo, CH7017_LVDS_POWER_DOWN,
val & ~CH7017_LVDS_POWER_DOWN_EN); val & ~CH7017_LVDS_POWER_DOWN_EN);
......
...@@ -289,9 +289,9 @@ static void ch7xxx_mode_set(struct intel_dvo_device *dvo, ...@@ -289,9 +289,9 @@ static void ch7xxx_mode_set(struct intel_dvo_device *dvo,
} }
/* set the CH7xxx power state */ /* set the CH7xxx power state */
static void ch7xxx_dpms(struct intel_dvo_device *dvo, int mode) static void ch7xxx_dpms(struct intel_dvo_device *dvo, bool enable)
{ {
if (mode == DRM_MODE_DPMS_ON) if (enable)
ch7xxx_writeb(dvo, CH7xxx_PM, CH7xxx_PM_DVIL | CH7xxx_PM_DVIP); ch7xxx_writeb(dvo, CH7xxx_PM, CH7xxx_PM_DVIL | CH7xxx_PM_DVIP);
else else
ch7xxx_writeb(dvo, CH7xxx_PM, CH7xxx_PM_FPD); ch7xxx_writeb(dvo, CH7xxx_PM, CH7xxx_PM_FPD);
......
...@@ -288,7 +288,7 @@ static enum drm_mode_status ivch_mode_valid(struct intel_dvo_device *dvo, ...@@ -288,7 +288,7 @@ static enum drm_mode_status ivch_mode_valid(struct intel_dvo_device *dvo,
} }
/** Sets the power state of the panel connected to the ivch */ /** Sets the power state of the panel connected to the ivch */
static void ivch_dpms(struct intel_dvo_device *dvo, int mode) static void ivch_dpms(struct intel_dvo_device *dvo, bool enable)
{ {
int i; int i;
uint16_t vr01, vr30, backlight; uint16_t vr01, vr30, backlight;
...@@ -297,13 +297,13 @@ static void ivch_dpms(struct intel_dvo_device *dvo, int mode) ...@@ -297,13 +297,13 @@ static void ivch_dpms(struct intel_dvo_device *dvo, int mode)
if (!ivch_read(dvo, VR01, &vr01)) if (!ivch_read(dvo, VR01, &vr01))
return; return;
if (mode == DRM_MODE_DPMS_ON) if (enable)
backlight = 1; backlight = 1;
else else
backlight = 0; backlight = 0;
ivch_write(dvo, VR80, backlight); ivch_write(dvo, VR80, backlight);
if (mode == DRM_MODE_DPMS_ON) if (enable)
vr01 |= VR01_LCD_ENABLE | VR01_DVO_ENABLE; vr01 |= VR01_LCD_ENABLE | VR01_DVO_ENABLE;
else else
vr01 &= ~(VR01_LCD_ENABLE | VR01_DVO_ENABLE); vr01 &= ~(VR01_LCD_ENABLE | VR01_DVO_ENABLE);
...@@ -315,7 +315,7 @@ static void ivch_dpms(struct intel_dvo_device *dvo, int mode) ...@@ -315,7 +315,7 @@ static void ivch_dpms(struct intel_dvo_device *dvo, int mode)
if (!ivch_read(dvo, VR30, &vr30)) if (!ivch_read(dvo, VR30, &vr30))
break; break;
if (((vr30 & VR30_PANEL_ON) != 0) == (mode == DRM_MODE_DPMS_ON)) if (((vr30 & VR30_PANEL_ON) != 0) == enable)
break; break;
udelay(1000); udelay(1000);
} }
......
...@@ -493,19 +493,19 @@ static void ns2501_mode_set(struct intel_dvo_device *dvo, ...@@ -493,19 +493,19 @@ static void ns2501_mode_set(struct intel_dvo_device *dvo,
} }
/* set the NS2501 power state */ /* set the NS2501 power state */
static void ns2501_dpms(struct intel_dvo_device *dvo, int mode) static void ns2501_dpms(struct intel_dvo_device *dvo, bool enable)
{ {
bool ok; bool ok;
bool restore = false; bool restore = false;
struct ns2501_priv *ns = (struct ns2501_priv *)(dvo->dev_priv); struct ns2501_priv *ns = (struct ns2501_priv *)(dvo->dev_priv);
unsigned char ch; unsigned char ch;
DRM_DEBUG_KMS("%s: Trying set the dpms of the DVO to %d\n", DRM_DEBUG_KMS("%s: Trying set the dpms of the DVO to %i\n",
__FUNCTION__, mode); __FUNCTION__, enable);
ch = ns->reg_8_shadow; ch = ns->reg_8_shadow;
if (mode == DRM_MODE_DPMS_ON) if (enable)
ch |= NS2501_8_PD; ch |= NS2501_8_PD;
else else
ch &= ~NS2501_8_PD; ch &= ~NS2501_8_PD;
...@@ -519,12 +519,10 @@ static void ns2501_dpms(struct intel_dvo_device *dvo, int mode) ...@@ -519,12 +519,10 @@ static void ns2501_dpms(struct intel_dvo_device *dvo, int mode)
ok &= ns2501_writeb(dvo, NS2501_REG8, ch); ok &= ns2501_writeb(dvo, NS2501_REG8, ch);
ok &= ok &=
ns2501_writeb(dvo, 0x34, ns2501_writeb(dvo, 0x34,
(mode == enable ? 0x03 : 0x00);
DRM_MODE_DPMS_ON) ? (0x03) : (0x00));
ok &= ok &=
ns2501_writeb(dvo, 0x35, ns2501_writeb(dvo, 0x35,
(mode == enable ? 0xff : 0x00);
DRM_MODE_DPMS_ON) ? (0xff) : (0x00));
if (!ok) { if (!ok) {
if (restore) if (restore)
restore_dvo(dvo); restore_dvo(dvo);
......
...@@ -208,7 +208,7 @@ static void sil164_mode_set(struct intel_dvo_device *dvo, ...@@ -208,7 +208,7 @@ static void sil164_mode_set(struct intel_dvo_device *dvo,
} }
/* set the SIL164 power state */ /* set the SIL164 power state */
static void sil164_dpms(struct intel_dvo_device *dvo, int mode) static void sil164_dpms(struct intel_dvo_device *dvo, bool enable)
{ {
int ret; int ret;
unsigned char ch; unsigned char ch;
...@@ -217,7 +217,7 @@ static void sil164_dpms(struct intel_dvo_device *dvo, int mode) ...@@ -217,7 +217,7 @@ static void sil164_dpms(struct intel_dvo_device *dvo, int mode)
if (ret == false) if (ret == false)
return; return;
if (mode == DRM_MODE_DPMS_ON) if (enable)
ch |= SIL164_8_PD; ch |= SIL164_8_PD;
else else
ch &= ~SIL164_8_PD; ch &= ~SIL164_8_PD;
......
...@@ -234,14 +234,14 @@ static void tfp410_mode_set(struct intel_dvo_device *dvo, ...@@ -234,14 +234,14 @@ static void tfp410_mode_set(struct intel_dvo_device *dvo,
} }
/* set the tfp410 power state */ /* set the tfp410 power state */
static void tfp410_dpms(struct intel_dvo_device *dvo, int mode) static void tfp410_dpms(struct intel_dvo_device *dvo, bool enable)
{ {
uint8_t ctl1; uint8_t ctl1;
if (!tfp410_readb(dvo, TFP410_CTL_1, &ctl1)) if (!tfp410_readb(dvo, TFP410_CTL_1, &ctl1))
return; return;
if (mode == DRM_MODE_DPMS_ON) if (enable)
ctl1 |= TFP410_CTL_1_PD; ctl1 |= TFP410_CTL_1_PD;
else else
ctl1 &= ~TFP410_CTL_1_PD; ctl1 &= ~TFP410_CTL_1_PD;
......
...@@ -115,9 +115,9 @@ static void intel_dvo_dpms(struct drm_encoder *encoder, int mode) ...@@ -115,9 +115,9 @@ static void intel_dvo_dpms(struct drm_encoder *encoder, int mode)
if (mode == DRM_MODE_DPMS_ON) { if (mode == DRM_MODE_DPMS_ON) {
I915_WRITE(dvo_reg, temp | DVO_ENABLE); I915_WRITE(dvo_reg, temp | DVO_ENABLE);
I915_READ(dvo_reg); I915_READ(dvo_reg);
intel_dvo->dev.dev_ops->dpms(&intel_dvo->dev, mode); intel_dvo->dev.dev_ops->dpms(&intel_dvo->dev, true);
} else { } else {
intel_dvo->dev.dev_ops->dpms(&intel_dvo->dev, mode); intel_dvo->dev.dev_ops->dpms(&intel_dvo->dev, false);
I915_WRITE(dvo_reg, temp & ~DVO_ENABLE); I915_WRITE(dvo_reg, temp & ~DVO_ENABLE);
I915_READ(dvo_reg); I915_READ(dvo_reg);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment