On Wed, Nov 23, 2011 at 02:25:14AM +0800, Keith Packard wrote:> On Tue, 22 Nov 2011 15:40:55 +0800, Wu Fengguang <fengguang.wu@intel.com> wrote:> > > So the v3 patch will behave equally well on KMS console, gnome desktop> > and bare X. Shall we just use it, or go back and use the original> > ->hot_remove patch?> > I'm not sure why we need any change to the core DRM code. The HDMI and> DP drivers will be told when to turn the monitors on and off, and that's

Yeah, The DP driver will be notified via the intel_dp_hot_plug() hookif I understand it right.

> the appropriate time to control whether audio is routed to them.

However ->hot_plug() is called too early to be useful for this case.

What I need is a hot plug hook that knows whether the monitor isplugged or removed, which is only possible if the hook is calledafter ->detect().

Or, we can avoid adding the ->hotplug() hook and just add the calldirectly to intel_hdmi_detect() and intel_dp_detect().

The below patch does this and eliminates the DRM callback :-)

> Hotplug is considered simply a notification to user space that> something has changed -- user space is in charge of configuring> which outputs are in use.

Yeah, and here is another notification to the audio driver demanded bythe HD audio spec.

On monitor hot plug/unplug, set/clear SDVO_AUDIO_ENABLE orDP_AUDIO_OUTPUT_ENABLE accordingly, so that the audio driver willreceive hot plug events and take action to refresh its device state andELD contents.

After intel_dp_detect() knows whether the monitor is plugged orremoved, it will call intel_dp_hotplug_audio() to notify the audiodriver of the event.

It's noticed that bare metal X may not call ->mode_set() at monitor hotplug, so it's necessary to call drm_edid_to_eld() earlier at ->detect()time rather than in intel_ddc_get_modes(), so that intel_write_eld() cansee the new ELD in intel_dp_hotplug_audio().