Commit dc7cec23 authored by Dave Airlie's avatar Dave Airlie

Merge remote branch 'intel/drm-intel-fixes' of /ssd/git/drm-next into drm-fixes

* 'intel/drm-intel-fixes' of /ssd/git/drm-next:
  drm/i915: Fix resume regression from 5d1d0cc8
  drm/i915/tv: Use polling rather than interrupt-based hotplug
  drm/i915: Trigger modesetting if force-audio changes
  drm/i915/sdvo: If we have an EDID confirm it matches the mode of the connection
  drm/i915: Disable RC6 on Ironlake
  drm/i915/lvds: Restore dithering on native modes for gen2/3
  drm/i915: Invalidate TLB caches on SNB BLT/BSD rings
parents c2049b3d 04dbff52
...@@ -46,6 +46,9 @@ module_param_named(fbpercrtc, i915_fbpercrtc, int, 0400); ...@@ -46,6 +46,9 @@ module_param_named(fbpercrtc, i915_fbpercrtc, int, 0400);
unsigned int i915_powersave = 1; unsigned int i915_powersave = 1;
module_param_named(powersave, i915_powersave, int, 0600); module_param_named(powersave, i915_powersave, int, 0600);
unsigned int i915_enable_rc6 = 0;
module_param_named(i915_enable_rc6, i915_enable_rc6, int, 0600);
unsigned int i915_lvds_downclock = 0; unsigned int i915_lvds_downclock = 0;
module_param_named(lvds_downclock, i915_lvds_downclock, int, 0400); module_param_named(lvds_downclock, i915_lvds_downclock, int, 0400);
...@@ -360,7 +363,7 @@ static int i915_drm_thaw(struct drm_device *dev) ...@@ -360,7 +363,7 @@ static int i915_drm_thaw(struct drm_device *dev)
/* Resume the modeset for every activated CRTC */ /* Resume the modeset for every activated CRTC */
drm_helper_resume_force_mode(dev); drm_helper_resume_force_mode(dev);
if (dev_priv->renderctx && dev_priv->pwrctx) if (IS_IRONLAKE_M(dev))
ironlake_enable_rc6(dev); ironlake_enable_rc6(dev);
} }
......
...@@ -958,6 +958,7 @@ extern unsigned int i915_fbpercrtc; ...@@ -958,6 +958,7 @@ extern unsigned int i915_fbpercrtc;
extern unsigned int i915_powersave; extern unsigned int i915_powersave;
extern unsigned int i915_lvds_downclock; extern unsigned int i915_lvds_downclock;
extern unsigned int i915_panel_use_ssc; extern unsigned int i915_panel_use_ssc;
extern unsigned int i915_enable_rc6;
extern int i915_suspend(struct drm_device *dev, pm_message_t state); extern int i915_suspend(struct drm_device *dev, pm_message_t state);
extern int i915_resume(struct drm_device *dev); extern int i915_resume(struct drm_device *dev);
......
...@@ -174,7 +174,9 @@ ...@@ -174,7 +174,9 @@
* address/value pairs. Don't overdue it, though, x <= 2^4 must hold! * address/value pairs. Don't overdue it, though, x <= 2^4 must hold!
*/ */
#define MI_LOAD_REGISTER_IMM(x) MI_INSTR(0x22, 2*x-1) #define MI_LOAD_REGISTER_IMM(x) MI_INSTR(0x22, 2*x-1)
#define MI_FLUSH_DW MI_INSTR(0x26, 2) /* for GEN6 */ #define MI_FLUSH_DW MI_INSTR(0x26, 1) /* for GEN6 */
#define MI_INVALIDATE_TLB (1<<18)
#define MI_INVALIDATE_BSD (1<<7)
#define MI_BATCH_BUFFER MI_INSTR(0x30, 1) #define MI_BATCH_BUFFER MI_INSTR(0x30, 1)
#define MI_BATCH_NON_SECURE (1) #define MI_BATCH_NON_SECURE (1)
#define MI_BATCH_NON_SECURE_I965 (1<<8) #define MI_BATCH_NON_SECURE_I965 (1<<8)
......
...@@ -5558,9 +5558,7 @@ static void intel_crtc_reset(struct drm_crtc *crtc) ...@@ -5558,9 +5558,7 @@ static void intel_crtc_reset(struct drm_crtc *crtc)
/* Reset flags back to the 'unknown' status so that they /* Reset flags back to the 'unknown' status so that they
* will be correctly set on the initial modeset. * will be correctly set on the initial modeset.
*/ */
intel_crtc->cursor_addr = 0;
intel_crtc->dpms_mode = -1; intel_crtc->dpms_mode = -1;
intel_crtc->active = true; /* force the pipe off on setup_init_config */
} }
static struct drm_crtc_helper_funcs intel_helper_funcs = { static struct drm_crtc_helper_funcs intel_helper_funcs = {
...@@ -5666,6 +5664,7 @@ static void intel_crtc_init(struct drm_device *dev, int pipe) ...@@ -5666,6 +5664,7 @@ static void intel_crtc_init(struct drm_device *dev, int pipe)
dev_priv->pipe_to_crtc_mapping[intel_crtc->pipe] = &intel_crtc->base; dev_priv->pipe_to_crtc_mapping[intel_crtc->pipe] = &intel_crtc->base;
intel_crtc_reset(&intel_crtc->base); intel_crtc_reset(&intel_crtc->base);
intel_crtc->active = true; /* force the pipe off on setup_init_config */
if (HAS_PCH_SPLIT(dev)) { if (HAS_PCH_SPLIT(dev)) {
intel_helper_funcs.prepare = ironlake_crtc_prepare; intel_helper_funcs.prepare = ironlake_crtc_prepare;
...@@ -6463,29 +6462,19 @@ void intel_enable_clock_gating(struct drm_device *dev) ...@@ -6463,29 +6462,19 @@ void intel_enable_clock_gating(struct drm_device *dev)
} }
} }
void intel_disable_clock_gating(struct drm_device *dev) static void ironlake_teardown_rc6(struct drm_device *dev)
{ {
struct drm_i915_private *dev_priv = dev->dev_private; struct drm_i915_private *dev_priv = dev->dev_private;
if (dev_priv->renderctx) { if (dev_priv->renderctx) {
struct drm_i915_gem_object *obj = dev_priv->renderctx; i915_gem_object_unpin(dev_priv->renderctx);
drm_gem_object_unreference(&dev_priv->renderctx->base);
I915_WRITE(CCID, 0);
POSTING_READ(CCID);
i915_gem_object_unpin(obj);
drm_gem_object_unreference(&obj->base);
dev_priv->renderctx = NULL; dev_priv->renderctx = NULL;
} }
if (dev_priv->pwrctx) { if (dev_priv->pwrctx) {
struct drm_i915_gem_object *obj = dev_priv->pwrctx; i915_gem_object_unpin(dev_priv->pwrctx);
drm_gem_object_unreference(&dev_priv->pwrctx->base);
I915_WRITE(PWRCTXA, 0);
POSTING_READ(PWRCTXA);
i915_gem_object_unpin(obj);
drm_gem_object_unreference(&obj->base);
dev_priv->pwrctx = NULL; dev_priv->pwrctx = NULL;
} }
} }
...@@ -6494,21 +6483,39 @@ static void ironlake_disable_rc6(struct drm_device *dev) ...@@ -6494,21 +6483,39 @@ static void ironlake_disable_rc6(struct drm_device *dev)
{ {
struct drm_i915_private *dev_priv = dev->dev_private; struct drm_i915_private *dev_priv = dev->dev_private;
if (I915_READ(PWRCTXA)) {
/* Wake the GPU, prevent RC6, then restore RSTDBYCTL */ /* Wake the GPU, prevent RC6, then restore RSTDBYCTL */
I915_WRITE(RSTDBYCTL, I915_READ(RSTDBYCTL) | RCX_SW_EXIT); I915_WRITE(RSTDBYCTL, I915_READ(RSTDBYCTL) | RCX_SW_EXIT);
wait_for(((I915_READ(RSTDBYCTL) & RSX_STATUS_MASK) == RSX_STATUS_ON), wait_for(((I915_READ(RSTDBYCTL) & RSX_STATUS_MASK) == RSX_STATUS_ON),
10); 50);
POSTING_READ(CCID);
I915_WRITE(PWRCTXA, 0); I915_WRITE(PWRCTXA, 0);
POSTING_READ(PWRCTXA); POSTING_READ(PWRCTXA);
I915_WRITE(RSTDBYCTL, I915_READ(RSTDBYCTL) & ~RCX_SW_EXIT); I915_WRITE(RSTDBYCTL, I915_READ(RSTDBYCTL) & ~RCX_SW_EXIT);
POSTING_READ(RSTDBYCTL); POSTING_READ(RSTDBYCTL);
i915_gem_object_unpin(dev_priv->renderctx); }
drm_gem_object_unreference(&dev_priv->renderctx->base);
dev_priv->renderctx = NULL; ironlake_disable_rc6(dev);
i915_gem_object_unpin(dev_priv->pwrctx); }
drm_gem_object_unreference(&dev_priv->pwrctx->base);
dev_priv->pwrctx = NULL; static int ironlake_setup_rc6(struct drm_device *dev)
{
struct drm_i915_private *dev_priv = dev->dev_private;
if (dev_priv->renderctx == NULL)
dev_priv->renderctx = intel_alloc_context_page(dev);
if (!dev_priv->renderctx)
return -ENOMEM;
if (dev_priv->pwrctx == NULL)
dev_priv->pwrctx = intel_alloc_context_page(dev);
if (!dev_priv->pwrctx) {
ironlake_teardown_rc6(dev);
return -ENOMEM;
}
return 0;
} }
void ironlake_enable_rc6(struct drm_device *dev) void ironlake_enable_rc6(struct drm_device *dev)
...@@ -6516,15 +6523,26 @@ void ironlake_enable_rc6(struct drm_device *dev) ...@@ -6516,15 +6523,26 @@ void ironlake_enable_rc6(struct drm_device *dev)
struct drm_i915_private *dev_priv = dev->dev_private; struct drm_i915_private *dev_priv = dev->dev_private;
int ret; int ret;
/* rc6 disabled by default due to repeated reports of hanging during
* boot and resume.
*/
if (!i915_enable_rc6)
return;
ret = ironlake_setup_rc6(dev);
if (ret)
return;
/* /*
* GPU can automatically power down the render unit if given a page * GPU can automatically power down the render unit if given a page
* to save state. * to save state.
*/ */
ret = BEGIN_LP_RING(6); ret = BEGIN_LP_RING(6);
if (ret) { if (ret) {
ironlake_disable_rc6(dev); ironlake_teardown_rc6(dev);
return; return;
} }
OUT_RING(MI_SUSPEND_FLUSH | MI_SUSPEND_FLUSH_EN); OUT_RING(MI_SUSPEND_FLUSH | MI_SUSPEND_FLUSH_EN);
OUT_RING(MI_SET_CONTEXT); OUT_RING(MI_SET_CONTEXT);
OUT_RING(dev_priv->renderctx->gtt_offset | OUT_RING(dev_priv->renderctx->gtt_offset |
...@@ -6541,6 +6559,7 @@ void ironlake_enable_rc6(struct drm_device *dev) ...@@ -6541,6 +6559,7 @@ void ironlake_enable_rc6(struct drm_device *dev)
I915_WRITE(RSTDBYCTL, I915_READ(RSTDBYCTL) & ~RCX_SW_EXIT); I915_WRITE(RSTDBYCTL, I915_READ(RSTDBYCTL) & ~RCX_SW_EXIT);
} }
/* Set up chip specific display functions */ /* Set up chip specific display functions */
static void intel_init_display(struct drm_device *dev) static void intel_init_display(struct drm_device *dev)
{ {
...@@ -6783,21 +6802,9 @@ void intel_modeset_init(struct drm_device *dev) ...@@ -6783,21 +6802,9 @@ void intel_modeset_init(struct drm_device *dev)
if (IS_GEN6(dev)) if (IS_GEN6(dev))
gen6_enable_rps(dev_priv); gen6_enable_rps(dev_priv);
if (IS_IRONLAKE_M(dev)) { if (IS_IRONLAKE_M(dev))
dev_priv->renderctx = intel_alloc_context_page(dev);
if (!dev_priv->renderctx)
goto skip_rc6;
dev_priv->pwrctx = intel_alloc_context_page(dev);
if (!dev_priv->pwrctx) {
i915_gem_object_unpin(dev_priv->renderctx);
drm_gem_object_unreference(&dev_priv->renderctx->base);
dev_priv->renderctx = NULL;
goto skip_rc6;
}
ironlake_enable_rc6(dev); ironlake_enable_rc6(dev);
}
skip_rc6:
INIT_WORK(&dev_priv->idle_work, intel_idle_update); INIT_WORK(&dev_priv->idle_work, intel_idle_update);
setup_timer(&dev_priv->idle_timer, intel_gpu_idle_timer, setup_timer(&dev_priv->idle_timer, intel_gpu_idle_timer,
(unsigned long)dev); (unsigned long)dev);
......
...@@ -1639,6 +1639,24 @@ static int intel_dp_get_modes(struct drm_connector *connector) ...@@ -1639,6 +1639,24 @@ static int intel_dp_get_modes(struct drm_connector *connector)
return 0; return 0;
} }
static bool
intel_dp_detect_audio(struct drm_connector *connector)
{
struct intel_dp *intel_dp = intel_attached_dp(connector);
struct edid *edid;
bool has_audio = false;
edid = drm_get_edid(connector, &intel_dp->adapter);
if (edid) {
has_audio = drm_detect_monitor_audio(edid);
connector->display_info.raw_edid = NULL;
kfree(edid);
}
return has_audio;
}
static int static int
intel_dp_set_property(struct drm_connector *connector, intel_dp_set_property(struct drm_connector *connector,
struct drm_property *property, struct drm_property *property,
...@@ -1652,17 +1670,23 @@ intel_dp_set_property(struct drm_connector *connector, ...@@ -1652,17 +1670,23 @@ intel_dp_set_property(struct drm_connector *connector,
return ret; return ret;
if (property == intel_dp->force_audio_property) { if (property == intel_dp->force_audio_property) {
if (val == intel_dp->force_audio) int i = val;
bool has_audio;
if (i == intel_dp->force_audio)
return 0; return 0;
intel_dp->force_audio = val; intel_dp->force_audio = i;
if (val > 0 && intel_dp->has_audio) if (i == 0)
return 0; has_audio = intel_dp_detect_audio(connector);
if (val < 0 && !intel_dp->has_audio) else
has_audio = i > 0;
if (has_audio == intel_dp->has_audio)
return 0; return 0;
intel_dp->has_audio = val > 0; intel_dp->has_audio = has_audio;
goto done; goto done;
} }
......
...@@ -298,7 +298,6 @@ extern void intel_crtc_fb_gamma_set(struct drm_crtc *crtc, u16 red, u16 green, ...@@ -298,7 +298,6 @@ extern void intel_crtc_fb_gamma_set(struct drm_crtc *crtc, u16 red, u16 green,
extern void intel_crtc_fb_gamma_get(struct drm_crtc *crtc, u16 *red, u16 *green, extern void intel_crtc_fb_gamma_get(struct drm_crtc *crtc, u16 *red, u16 *green,
u16 *blue, int regno); u16 *blue, int regno);
extern void intel_enable_clock_gating(struct drm_device *dev); extern void intel_enable_clock_gating(struct drm_device *dev);
extern void intel_disable_clock_gating(struct drm_device *dev);
extern void ironlake_enable_drps(struct drm_device *dev); extern void ironlake_enable_drps(struct drm_device *dev);
extern void ironlake_disable_drps(struct drm_device *dev); extern void ironlake_disable_drps(struct drm_device *dev);
extern void gen6_enable_rps(struct drm_i915_private *dev_priv); extern void gen6_enable_rps(struct drm_i915_private *dev_priv);
......
...@@ -251,6 +251,27 @@ static int intel_hdmi_get_modes(struct drm_connector *connector) ...@@ -251,6 +251,27 @@ static int intel_hdmi_get_modes(struct drm_connector *connector)
&dev_priv->gmbus[intel_hdmi->ddc_bus].adapter); &dev_priv->gmbus[intel_hdmi->ddc_bus].adapter);
} }
static bool
intel_hdmi_detect_audio(struct drm_connector *connector)
{
struct intel_hdmi *intel_hdmi = intel_attached_hdmi(connector);
struct drm_i915_private *dev_priv = connector->dev->dev_private;
struct edid *edid;
bool has_audio = false;
edid = drm_get_edid(connector,
&dev_priv->gmbus[intel_hdmi->ddc_bus].adapter);
if (edid) {
if (edid->input & DRM_EDID_INPUT_DIGITAL)
has_audio = drm_detect_monitor_audio(edid);
connector->display_info.raw_edid = NULL;
kfree(edid);
}
return has_audio;
}
static int static int
intel_hdmi_set_property(struct drm_connector *connector, intel_hdmi_set_property(struct drm_connector *connector,
struct drm_property *property, struct drm_property *property,
...@@ -264,17 +285,23 @@ intel_hdmi_set_property(struct drm_connector *connector, ...@@ -264,17 +285,23 @@ intel_hdmi_set_property(struct drm_connector *connector,
return ret; return ret;
if (property == intel_hdmi->force_audio_property) { if (property == intel_hdmi->force_audio_property) {
if (val == intel_hdmi->force_audio) int i = val;
bool has_audio;
if (i == intel_hdmi->force_audio)
return 0; return 0;
intel_hdmi->force_audio = val; intel_hdmi->force_audio = i;
if (val > 0 && intel_hdmi->has_audio) if (i == 0)
return 0; has_audio = intel_hdmi_detect_audio(connector);
if (val < 0 && !intel_hdmi->has_audio) else
has_audio = i > 0;
if (has_audio == intel_hdmi->has_audio)
return 0; return 0;
intel_hdmi->has_audio = val > 0; intel_hdmi->has_audio = has_audio;
goto done; goto done;
} }
......
...@@ -261,12 +261,6 @@ static bool intel_lvds_mode_fixup(struct drm_encoder *encoder, ...@@ -261,12 +261,6 @@ static bool intel_lvds_mode_fixup(struct drm_encoder *encoder,
return true; return true;
} }
/* Make sure pre-965s set dither correctly */
if (INTEL_INFO(dev)->gen < 4) {
if (dev_priv->lvds_dither)
pfit_control |= PANEL_8TO6_DITHER_ENABLE;
}
/* Native modes don't need fitting */ /* Native modes don't need fitting */
if (adjusted_mode->hdisplay == mode->hdisplay && if (adjusted_mode->hdisplay == mode->hdisplay &&
adjusted_mode->vdisplay == mode->vdisplay) adjusted_mode->vdisplay == mode->vdisplay)
...@@ -374,10 +368,16 @@ static bool intel_lvds_mode_fixup(struct drm_encoder *encoder, ...@@ -374,10 +368,16 @@ static bool intel_lvds_mode_fixup(struct drm_encoder *encoder,
} }
out: out:
/* If not enabling scaling, be consistent and always use 0. */
if ((pfit_control & PFIT_ENABLE) == 0) { if ((pfit_control & PFIT_ENABLE) == 0) {
pfit_control = 0; pfit_control = 0;
pfit_pgm_ratios = 0; pfit_pgm_ratios = 0;
} }
/* Make sure pre-965 set dither correctly */
if (INTEL_INFO(dev)->gen < 4 && dev_priv->lvds_dither)
pfit_control |= PANEL_8TO6_DITHER_ENABLE;
if (pfit_control != intel_lvds->pfit_control || if (pfit_control != intel_lvds->pfit_control ||
pfit_pgm_ratios != intel_lvds->pfit_pgm_ratios) { pfit_pgm_ratios != intel_lvds->pfit_pgm_ratios) {
intel_lvds->pfit_control = pfit_control; intel_lvds->pfit_control = pfit_control;
......
...@@ -1059,22 +1059,25 @@ static void gen6_bsd_ring_write_tail(struct intel_ring_buffer *ring, ...@@ -1059,22 +1059,25 @@ static void gen6_bsd_ring_write_tail(struct intel_ring_buffer *ring,
} }
static int gen6_ring_flush(struct intel_ring_buffer *ring, static int gen6_ring_flush(struct intel_ring_buffer *ring,
u32 invalidate_domains, u32 invalidate, u32 flush)
u32 flush_domains)
{ {
uint32_t cmd;
int ret; int ret;
if ((flush_domains & I915_GEM_DOMAIN_RENDER) == 0) if (((invalidate | flush) & I915_GEM_GPU_DOMAINS) == 0)
return 0; return 0;
ret = intel_ring_begin(ring, 4); ret = intel_ring_begin(ring, 4);
if (ret) if (ret)
return ret; return ret;
intel_ring_emit(ring, MI_FLUSH_DW); cmd = MI_FLUSH_DW;
intel_ring_emit(ring, 0); if (invalidate & I915_GEM_GPU_DOMAINS)
cmd |= MI_INVALIDATE_TLB | MI_INVALIDATE_BSD;
intel_ring_emit(ring, cmd);
intel_ring_emit(ring, 0); intel_ring_emit(ring, 0);
intel_ring_emit(ring, 0); intel_ring_emit(ring, 0);
intel_ring_emit(ring, MI_NOOP);
intel_ring_advance(ring); intel_ring_advance(ring);
return 0; return 0;
} }
...@@ -1230,22 +1233,25 @@ static int blt_ring_begin(struct intel_ring_buffer *ring, ...@@ -1230,22 +1233,25 @@ static int blt_ring_begin(struct intel_ring_buffer *ring,
} }
static int blt_ring_flush(struct intel_ring_buffer *ring, static int blt_ring_flush(struct intel_ring_buffer *ring,
u32 invalidate_domains, u32 invalidate, u32 flush)
u32 flush_domains)
{ {
uint32_t cmd;
int ret; int ret;
if ((flush_domains & I915_GEM_DOMAIN_RENDER) == 0) if (((invalidate | flush) & I915_GEM_DOMAIN_RENDER) == 0)
return 0; return 0;
ret = blt_ring_begin(ring, 4); ret = blt_ring_begin(ring, 4);
if (ret) if (ret)
return ret; return ret;
intel_ring_emit(ring, MI_FLUSH_DW); cmd = MI_FLUSH_DW;
intel_ring_emit(ring, 0); if (invalidate & I915_GEM_DOMAIN_RENDER)
cmd |= MI_INVALIDATE_TLB;
intel_ring_emit(ring, cmd);
intel_ring_emit(ring, 0); intel_ring_emit(ring, 0);
intel_ring_emit(ring, 0); intel_ring_emit(ring, 0);
intel_ring_emit(ring, MI_NOOP);
intel_ring_advance(ring); intel_ring_advance(ring);
return 0; return 0;
} }
......
...@@ -46,6 +46,7 @@ ...@@ -46,6 +46,7 @@
SDVO_TV_MASK) SDVO_TV_MASK)
#define IS_TV(c) (c->output_flag & SDVO_TV_MASK) #define IS_TV(c) (c->output_flag & SDVO_TV_MASK)
#define IS_TMDS(c) (c->output_flag & SDVO_TMDS_MASK)
#define IS_LVDS(c) (c->output_flag & SDVO_LVDS_MASK) #define IS_LVDS(c) (c->output_flag & SDVO_LVDS_MASK)
#define IS_TV_OR_LVDS(c) (c->output_flag & (SDVO_TV_MASK | SDVO_LVDS_MASK)) #define IS_TV_OR_LVDS(c) (c->output_flag & (SDVO_TV_MASK | SDVO_LVDS_MASK))
...@@ -1359,7 +1360,8 @@ intel_sdvo_hdmi_sink_detect(struct drm_connector *connector) ...@@ -1359,7 +1360,8 @@ intel_sdvo_hdmi_sink_detect(struct drm_connector *connector)
intel_sdvo->has_hdmi_monitor = drm_detect_hdmi_monitor(edid); intel_sdvo->has_hdmi_monitor = drm_detect_hdmi_monitor(edid);
intel_sdvo->has_hdmi_audio = drm_detect_monitor_audio(edid); intel_sdvo->has_hdmi_audio = drm_detect_monitor_audio(edid);
} }
} } else
status = connector_status_disconnected;
connector->display_info.raw_edid = NULL; connector->display_info.raw_edid = NULL;
kfree(edid); kfree(edid);
} }
...@@ -1407,10 +1409,25 @@ intel_sdvo_detect(struct drm_connector *connector, bool force) ...@@ -1407,10 +1409,25 @@ intel_sdvo_detect(struct drm_connector *connector, bool force)
if ((intel_sdvo_connector->output_flag & response) == 0) if ((intel_sdvo_connector->output_flag & response) == 0)
ret = connector_status_disconnected; ret = connector_status_disconnected;
else if (response & SDVO_TMDS_MASK) else if (IS_TMDS(intel_sdvo_connector))
ret = intel_sdvo_hdmi_sink_detect(connector); ret = intel_sdvo_hdmi_sink_detect(connector);
else {
struct edid *edid;
/* if we have an edid check it matches the connection */
edid = intel_sdvo_get_edid(connector);
if (edid == NULL)
edid = intel_sdvo_get_analog_edid(connector);
if (edid != NULL) {
if (edid->input & DRM_EDID_INPUT_DIGITAL)
ret = connector_status_disconnected;
else else
ret = connector_status_connected; ret = connector_status_connected;
connector->display_info.raw_edid = NULL;
kfree(edid);
} else
ret = connector_status_connected;
}
/* May update encoder flag for like clock for SDVO TV, etc.*/ /* May update encoder flag for like clock for SDVO TV, etc.*/
if (ret == connector_status_connected) { if (ret == connector_status_connected) {
...@@ -1446,10 +1463,15 @@ static void intel_sdvo_get_ddc_modes(struct drm_connector *connector) ...@@ -1446,10 +1463,15 @@ static void intel_sdvo_get_ddc_modes(struct drm_connector *connector)
edid = intel_sdvo_get_analog_edid(connector); edid = intel_sdvo_get_analog_edid(connector);
if (edid != NULL) { if (edid != NULL) {
if (edid->input & DRM_EDID_INPUT_DIGITAL) { struct intel_sdvo_connector *intel_sdvo_connector = to_intel_sdvo_connector(connector);
bool monitor_is_digital = !!(edid->input & DRM_EDID_INPUT_DIGITAL);
bool connector_is_digital = !!IS_TMDS(intel_sdvo_connector);
if (connector_is_digital == monitor_is_digital) {
drm_mode_connector_update_edid_property(connector, edid); drm_mode_connector_update_edid_property(connector, edid);
drm_add_edid_modes(connector, edid); drm_add_edid_modes(connector, edid);
} }
connector->display_info.raw_edid = NULL; connector->display_info.raw_edid = NULL;
kfree(edid); kfree(edid);
} }
...@@ -1668,6 +1690,22 @@ static void intel_sdvo_destroy(struct drm_connector *connector) ...@@ -1668,6 +1690,22 @@ static void intel_sdvo_destroy(struct drm_connector *connector)
kfree(connector); kfree(connector);
} }
static bool intel_sdvo_detect_hdmi_audio(struct drm_connector *connector)
{
struct intel_sdvo *intel_sdvo = intel_attached_sdvo(connector);
struct edid *edid;
bool has_audio = false;
if (!intel_sdvo->is_hdmi)
return false;
edid = intel_sdvo_get_edid(connector);
if (edid != NULL && edid->input & DRM_EDID_INPUT_DIGITAL)
has_audio = drm_detect_monitor_audio(edid);
return has_audio;
}
static int static int
intel_sdvo_set_property(struct drm_connector *connector, intel_sdvo_set_property(struct drm_connector *connector,
struct drm_property *property, struct drm_property *property,
...@@ -1684,17 +1722,23 @@ intel_sdvo_set_property(struct drm_connector *connector, ...@@ -1684,17 +1722,23 @@ intel_sdvo_set_property(struct drm_connector *connector,
return ret; return ret;
if (property == intel_sdvo_connector->force_audio_property) { if (property == intel_sdvo_connector->force_audio_property) {
if (val == intel_sdvo_connector->force_audio) int i = val;
bool has_audio;
if (i == intel_sdvo_connector->force_audio)
return 0; return 0;
intel_sdvo_connector->force_audio = val; intel_sdvo_connector->force_audio = i;
if (val > 0 && intel_sdvo->has_hdmi_audio) if (i == 0)
return 0; has_audio = intel_sdvo_detect_hdmi_audio(connector);
if (val < 0 && !intel_sdvo->has_hdmi_audio) else
has_audio = i > 0;
if (has_audio == intel_sdvo->has_hdmi_audio)
return 0; return 0;
intel_sdvo->has_hdmi_audio = val > 0; intel_sdvo->has_hdmi_audio = has_audio;
goto done; goto done;
} }
......
...@@ -1234,7 +1234,8 @@ static const struct drm_display_mode reported_modes[] = { ...@@ -1234,7 +1234,8 @@ static const struct drm_display_mode reported_modes[] = {
* \return false if TV is disconnected. * \return false if TV is disconnected.
*/ */
static int static int
intel_tv_detect_type (struct intel_tv *intel_tv) intel_tv_detect_type (struct intel_tv *intel_tv,
struct drm_connector *connector)
{ {
struct drm_encoder *encoder = &intel_tv->base.base; struct drm_encoder *encoder = &intel_tv->base.base;
struct drm_device *dev = encoder->dev; struct drm_device *dev = encoder->dev;
...@@ -1245,11 +1246,13 @@ intel_tv_detect_type (struct intel_tv *intel_tv) ...@@ -1245,11 +1246,13 @@ intel_tv_detect_type (struct intel_tv *intel_tv)
int type; int type;
/* Disable TV interrupts around load detect or we'll recurse */ /* Disable TV interrupts around load detect or we'll recurse */
if (connector->polled & DRM_CONNECTOR_POLL_HPD) {
spin_lock_irqsave(&dev_priv->irq_lock, irqflags); spin_lock_irqsave(&dev_priv->irq_lock, irqflags);
i915_disable_pipestat(dev_priv, 0, i915_disable_pipestat(dev_priv, 0,
PIPE_HOTPLUG_INTERRUPT_ENABLE | PIPE_HOTPLUG_INTERRUPT_ENABLE |
PIPE_HOTPLUG_TV_INTERRUPT_ENABLE); PIPE_HOTPLUG_TV_INTERRUPT_ENABLE);
spin_unlock_irqrestore(&dev_priv->irq_lock, irqflags); spin_unlock_irqrestore(&dev_priv->irq_lock, irqflags);
}
save_tv_dac = tv_dac = I915_READ(TV_DAC); save_tv_dac = tv_dac = I915_READ(TV_DAC);
save_tv_ctl = tv_ctl = I915_READ(TV_CTL); save_tv_ctl = tv_ctl = I915_READ(TV_CTL);
...@@ -1302,11 +1305,13 @@ intel_tv_detect_type (struct intel_tv *intel_tv) ...@@ -1302,11 +1305,13 @@ intel_tv_detect_type (struct intel_tv *intel_tv)
I915_WRITE(TV_CTL, save_tv_ctl); I915_WRITE(TV_CTL, save_tv_ctl);
/* Restore interrupt config */ /* Restore interrupt config */
if (connector->polled & DRM_CONNECTOR_POLL_HPD) {
spin_lock_irqsave(&dev_priv->irq_lock, irqflags); spin_lock_irqsave(&dev_priv->irq_lock, irqflags);
i915_enable_pipestat(dev_priv, 0, i915_enable_pipestat(dev_priv, 0,
PIPE_HOTPLUG_INTERRUPT_ENABLE | PIPE_HOTPLUG_INTERRUPT_ENABLE |
PIPE_HOTPLUG_TV_INTERRUPT_ENABLE); PIPE_HOTPLUG_TV_INTERRUPT_ENABLE);
spin_unlock_irqrestore(&dev_priv->irq_lock, irqflags); spin_unlock_irqrestore(&dev_priv->irq_lock, irqflags);
}
return type; return type;
} }
...@@ -1356,7 +1361,7 @@ intel_tv_detect(struct drm_connector *connector, bool force) ...@@ -1356,7 +1361,7 @@ intel_tv_detect(struct drm_connector *connector, bool force)
drm_mode_set_crtcinfo(&mode, CRTC_INTERLACE_HALVE_V); drm_mode_set_crtcinfo(&mode, CRTC_INTERLACE_HALVE_V);
if (intel_tv->base.base.crtc && intel_tv->base.base.crtc->enabled) { if (intel_tv->base.base.crtc && intel_tv->base.base.crtc->enabled) {
type = intel_tv_detect_type(intel_tv); type = intel_tv_detect_type(intel_tv, connector);
} else if (force) { } else if (force) {
struct drm_crtc *crtc; struct drm_crtc *crtc;
int dpms_mode; int dpms_mode;
...@@ -1364,7 +1369,7 @@ intel_tv_detect(struct drm_connector *connector, bool force) ...@@ -1364,7 +1369,7 @@ intel_tv_detect(struct drm_connector *connector, bool force)
crtc = intel_get_load_detect_pipe(&intel_tv->base, connector, crtc = intel_get_load_detect_pipe(&intel_tv->base, connector,
&mode, &dpms_mode); &mode, &dpms_mode);
if (crtc) { if (crtc) {
type = intel_tv_detect_type(intel_tv); type = intel_tv_detect_type(intel_tv, connector);
intel_release_load_detect_pipe(&intel_tv->base, connector, intel_release_load_detect_pipe(&intel_tv->base, connector,
dpms_mode); dpms_mode);
} else } else
...@@ -1658,6 +1663,18 @@ intel_tv_init(struct drm_device *dev) ...@@ -1658,6 +1663,18 @@ intel_tv_init(struct drm_device *dev)
intel_encoder = &intel_tv->base; intel_encoder = &intel_tv->base;
connector = &intel_connector->base; connector = &intel_connector->base;
/* The documentation, for the older chipsets at least, recommend
* using a polling method rather than hotplug detection for TVs.
* This is because in order to perform the hotplug detection, the PLLs
* for the TV must be kept alive increasing power drain and starving
* bandwidth from other encoders. Notably for instance, it causes
* pipe underruns on Crestline when this encoder is supposedly idle.
*
* More recent chipsets favour HDMI rather than integrated S-Video.
*/
connector->polled =
DRM_CONNECTOR_POLL_CONNECT | DRM_CONNECTOR_POLL_DISCONNECT;
drm_connector_init(dev, connector, &intel_tv_connector_funcs, drm_connector_init(dev, connector, &intel_tv_connector_funcs,
DRM_MODE_CONNECTOR_SVIDEO); DRM_MODE_CONNECTOR_SVIDEO);
......
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