Skip to content

Commit 732ce74

Browse files
committed
drm/i915/dvo: implement get_hw_state
Similar to the sdvo code we poke the dvo encoder whether the output is active. Safe that dvo encoders are not standardized, so this requires a new callback into the dvo chip driver. Hence implement that for all 6 dvo drivers. v2: With the newly added ns2501 we now have 6 dvo drivers instead of just 5 ... Acked-by: Jesse Barnes <jbarnes@virtuousgeek.org> Signed-Off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
1 parent 4ac41f4 commit 732ce74

File tree

8 files changed

+119
-0
lines changed

8 files changed

+119
-0
lines changed

drivers/gpu/drm/i915/dvo.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,12 @@ struct intel_dvo_dev_ops {
114114
*/
115115
enum drm_connector_status (*detect)(struct intel_dvo_device *dvo);
116116

117+
/*
118+
* Probe the current hw status, returning true if the connected output
119+
* is active.
120+
*/
121+
bool (*get_hw_state)(struct intel_dvo_device *dev);
122+
117123
/**
118124
* Query the device for the modes it provides.
119125
*

drivers/gpu/drm/i915/dvo_ch7017.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -359,6 +359,18 @@ static void ch7017_dpms(struct intel_dvo_device *dvo, bool enable)
359359
msleep(20);
360360
}
361361

362+
static bool ch7017_get_hw_state(struct intel_dvo_device *dvo)
363+
{
364+
uint8_t val;
365+
366+
ch7017_read(dvo, CH7017_LVDS_POWER_DOWN, &val);
367+
368+
if (val & CH7017_LVDS_POWER_DOWN_EN)
369+
return false;
370+
else
371+
return true;
372+
}
373+
362374
static void ch7017_dump_regs(struct intel_dvo_device *dvo)
363375
{
364376
uint8_t val;
@@ -396,6 +408,7 @@ struct intel_dvo_dev_ops ch7017_ops = {
396408
.mode_valid = ch7017_mode_valid,
397409
.mode_set = ch7017_mode_set,
398410
.dpms = ch7017_dpms,
411+
.get_hw_state = ch7017_get_hw_state,
399412
.dump_regs = ch7017_dump_regs,
400413
.destroy = ch7017_destroy,
401414
};

drivers/gpu/drm/i915/dvo_ch7xxx.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,18 @@ static void ch7xxx_dpms(struct intel_dvo_device *dvo, bool enable)
297297
ch7xxx_writeb(dvo, CH7xxx_PM, CH7xxx_PM_FPD);
298298
}
299299

300+
static bool ch7xxx_get_hw_state(struct intel_dvo_device *dvo)
301+
{
302+
u8 val;
303+
304+
ch7xxx_readb(dvo, CH7xxx_PM, &val);
305+
306+
if (val & CH7xxx_PM_FPD)
307+
return false;
308+
else
309+
return true;
310+
}
311+
300312
static void ch7xxx_dump_regs(struct intel_dvo_device *dvo)
301313
{
302314
int i;
@@ -326,6 +338,7 @@ struct intel_dvo_dev_ops ch7xxx_ops = {
326338
.mode_valid = ch7xxx_mode_valid,
327339
.mode_set = ch7xxx_mode_set,
328340
.dpms = ch7xxx_dpms,
341+
.get_hw_state = ch7xxx_get_hw_state,
329342
.dump_regs = ch7xxx_dump_regs,
330343
.destroy = ch7xxx_destroy,
331344
};

drivers/gpu/drm/i915/dvo_ivch.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -323,6 +323,20 @@ static void ivch_dpms(struct intel_dvo_device *dvo, bool enable)
323323
udelay(16 * 1000);
324324
}
325325

326+
static bool ivch_get_hw_state(struct intel_dvo_device *dvo)
327+
{
328+
uint16_t vr01;
329+
330+
/* Set the new power state of the panel. */
331+
if (!ivch_read(dvo, VR01, &vr01))
332+
return false;
333+
334+
if (vr01 & VR01_LCD_ENABLE)
335+
return true;
336+
else
337+
return false;
338+
}
339+
326340
static void ivch_mode_set(struct intel_dvo_device *dvo,
327341
struct drm_display_mode *mode,
328342
struct drm_display_mode *adjusted_mode)
@@ -413,6 +427,7 @@ static void ivch_destroy(struct intel_dvo_device *dvo)
413427
struct intel_dvo_dev_ops ivch_ops = {
414428
.init = ivch_init,
415429
.dpms = ivch_dpms,
430+
.get_hw_state = ivch_get_hw_state,
416431
.mode_valid = ivch_mode_valid,
417432
.mode_set = ivch_mode_set,
418433
.detect = ivch_detect,

drivers/gpu/drm/i915/dvo_ns2501.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -492,6 +492,20 @@ static void ns2501_mode_set(struct intel_dvo_device *dvo,
492492
restore_dvo(dvo);
493493
}
494494

495+
/* set the NS2501 power state */
496+
static bool ns2501_get_hw_state(struct intel_dvo_device *dvo)
497+
{
498+
unsigned char ch;
499+
500+
if (!ns2501_readb(dvo, NS2501_REG8, &ch))
501+
return false;
502+
503+
if (ch & NS2501_8_PD)
504+
return true;
505+
else
506+
return false;
507+
}
508+
495509
/* set the NS2501 power state */
496510
static void ns2501_dpms(struct intel_dvo_device *dvo, bool enable)
497511
{
@@ -568,6 +582,7 @@ struct intel_dvo_dev_ops ns2501_ops = {
568582
.mode_valid = ns2501_mode_valid,
569583
.mode_set = ns2501_mode_set,
570584
.dpms = ns2501_dpms,
585+
.get_hw_state = ns2501_get_hw_state,
571586
.dump_regs = ns2501_dump_regs,
572587
.destroy = ns2501_destroy,
573588
};

drivers/gpu/drm/i915/dvo_sil164.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,21 @@ static void sil164_dpms(struct intel_dvo_device *dvo, bool enable)
226226
return;
227227
}
228228

229+
static bool sil164_get_hw_state(struct intel_dvo_device *dvo)
230+
{
231+
int ret;
232+
unsigned char ch;
233+
234+
ret = sil164_readb(dvo, SIL164_REG8, &ch);
235+
if (ret == false)
236+
return false;
237+
238+
if (ch & SIL164_8_PD)
239+
return true;
240+
else
241+
return false;
242+
}
243+
229244
static void sil164_dump_regs(struct intel_dvo_device *dvo)
230245
{
231246
uint8_t val;
@@ -258,6 +273,7 @@ struct intel_dvo_dev_ops sil164_ops = {
258273
.mode_valid = sil164_mode_valid,
259274
.mode_set = sil164_mode_set,
260275
.dpms = sil164_dpms,
276+
.get_hw_state = sil164_get_hw_state,
261277
.dump_regs = sil164_dump_regs,
262278
.destroy = sil164_destroy,
263279
};

drivers/gpu/drm/i915/dvo_tfp410.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,19 @@ static void tfp410_dpms(struct intel_dvo_device *dvo, bool enable)
249249
tfp410_writeb(dvo, TFP410_CTL_1, ctl1);
250250
}
251251

252+
static bool tfp410_get_hw_state(struct intel_dvo_device *dvo)
253+
{
254+
uint8_t ctl1;
255+
256+
if (!tfp410_readb(dvo, TFP410_CTL_1, &ctl1))
257+
return false;
258+
259+
if (ctl1 & TFP410_CTL_1_PD)
260+
return true;
261+
else
262+
return false;
263+
}
264+
252265
static void tfp410_dump_regs(struct intel_dvo_device *dvo)
253266
{
254267
uint8_t val, val2;
@@ -299,6 +312,7 @@ struct intel_dvo_dev_ops tfp410_ops = {
299312
.mode_valid = tfp410_mode_valid,
300313
.mode_set = tfp410_mode_set,
301314
.dpms = tfp410_dpms,
315+
.get_hw_state = tfp410_get_hw_state,
302316
.dump_regs = tfp410_dump_regs,
303317
.destroy = tfp410_destroy,
304318
};

drivers/gpu/drm/i915/intel_dvo.c

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,31 @@ static struct intel_dvo *intel_attached_dvo(struct drm_connector *connector)
105105
struct intel_dvo, base);
106106
}
107107

108+
static bool intel_dvo_connector_get_hw_state(struct intel_connector *connector)
109+
{
110+
struct intel_dvo *intel_dvo = intel_attached_dvo(&connector->base);
111+
112+
return intel_dvo->dev.dev_ops->get_hw_state(&intel_dvo->dev);
113+
}
114+
115+
static bool intel_dvo_get_hw_state(struct intel_encoder *encoder,
116+
enum pipe *pipe)
117+
{
118+
struct drm_device *dev = encoder->base.dev;
119+
struct drm_i915_private *dev_priv = dev->dev_private;
120+
struct intel_dvo *intel_dvo = enc_to_intel_dvo(&encoder->base);
121+
u32 tmp;
122+
123+
tmp = I915_READ(intel_dvo->dev.dvo_reg);
124+
125+
if (!(tmp & DVO_ENABLE))
126+
return false;
127+
128+
*pipe = PORT_TO_PIPE(tmp);
129+
130+
return true;
131+
}
132+
108133
static void intel_disable_dvo(struct intel_encoder *encoder)
109134
{
110135
struct drm_i915_private *dev_priv = encoder->base.dev->dev_private;
@@ -414,6 +439,8 @@ void intel_dvo_init(struct drm_device *dev)
414439

415440
intel_encoder->disable = intel_disable_dvo;
416441
intel_encoder->enable = intel_enable_dvo;
442+
intel_encoder->get_hw_state = intel_dvo_get_hw_state;
443+
intel_connector->get_hw_state = intel_dvo_connector_get_hw_state;
417444

418445
/* Now, try to find a controller */
419446
for (i = 0; i < ARRAY_SIZE(intel_dvo_devices); i++) {

0 commit comments

Comments
 (0)