[Intel-gfx] [PATCH v2] drm/i915: Set up SDVO encoder type only at detect

2014-04-15 Thread Egbert Eich
Depending on the SDVO output_flags SDVO may have multiple connectors.
These are all initialized in intel_sdvo_output_setup(). The connector
that is initialized later will override the encoder_type that has been
set up by an earlier connector type initialization. Eventually the
one that comes last wins.
Eventually when intel_sdvo_detect() is called the active connector is
determined.
Delay encoder type initialization until the active connector is known
and set it to the type that corresponds to this connector.

v2: Remove explicit encoder type initialization to
DRM_MODE_ENCODER_NONE in the SDVO connector setup functions
as suggested by Chris Wilson ch...@chris-wilson.co.uk.

Signed-off-by: Egbert Eich e...@suse.de
---
 drivers/gpu/drm/i915/intel_sdvo.c | 21 +++--
 1 file changed, 15 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/i915/intel_sdvo.c 
b/drivers/gpu/drm/i915/intel_sdvo.c
index d27155a..f324ca1 100644
--- a/drivers/gpu/drm/i915/intel_sdvo.c
+++ b/drivers/gpu/drm/i915/intel_sdvo.c
@@ -154,6 +154,9 @@ struct intel_sdvo_connector {
/* Mark the type of connector */
uint16_t output_flag;
 
+   /* store encoder type for convenience */
+   int encoder_type;
+
enum hdmi_force_audio force_audio;
 
/* This contains all current supported TV format */
@@ -1746,6 +1749,7 @@ intel_sdvo_detect(struct drm_connector *connector, bool 
force)
if (response == 0)
return connector_status_disconnected;
 
+   intel_sdvo-base.base.encoder_type = intel_sdvo_connector-encoder_type;
intel_sdvo-attached_output = response;
 
intel_sdvo-has_hdmi_monitor = false;
@@ -2489,7 +2493,8 @@ intel_sdvo_dvi_init(struct intel_sdvo *intel_sdvo, int 
device)
} else {
intel_connector-polled = DRM_CONNECTOR_POLL_CONNECT | 
DRM_CONNECTOR_POLL_DISCONNECT;
}
-   encoder-encoder_type = DRM_MODE_ENCODER_TMDS;
+   /* delay encoder_type setting until detection */
+   intel_sdvo_connector-encoder_type = DRM_MODE_ENCODER_TMDS;
connector-connector_type = DRM_MODE_CONNECTOR_DVID;
 
if (intel_sdvo_is_hdmi_connector(intel_sdvo, device)) {
@@ -2524,7 +2529,8 @@ intel_sdvo_tv_init(struct intel_sdvo *intel_sdvo, int 
type)
 
intel_connector = intel_sdvo_connector-base;
connector = intel_connector-base;
-   encoder-encoder_type = DRM_MODE_ENCODER_TVDAC;
+   /* delay encoder_type setting until detection */
+   intel_sdvo_connector-encoder_type = DRM_MODE_ENCODER_TVDAC;
connector-connector_type = DRM_MODE_CONNECTOR_SVIDEO;
 
intel_sdvo-controlled_output |= type;
@@ -2568,7 +2574,8 @@ intel_sdvo_analog_init(struct intel_sdvo *intel_sdvo, int 
device)
intel_connector = intel_sdvo_connector-base;
connector = intel_connector-base;
intel_connector-polled = DRM_CONNECTOR_POLL_CONNECT;
-   encoder-encoder_type = DRM_MODE_ENCODER_DAC;
+   /* delay encoder_type setting until detection */
+   intel_sdvo_connector-encoder_type = DRM_MODE_ENCODER_DAC;
connector-connector_type = DRM_MODE_CONNECTOR_VGA;
 
if (device == 0) {
@@ -2603,7 +2610,8 @@ intel_sdvo_lvds_init(struct intel_sdvo *intel_sdvo, int 
device)
 
intel_connector = intel_sdvo_connector-base;
connector = intel_connector-base;
-   encoder-encoder_type = DRM_MODE_ENCODER_LVDS;
+   /* delay encoder_type setting until detection */
+   intel_sdvo_connector-encoder_type = DRM_MODE_ENCODER_LVDS;
connector-connector_type = DRM_MODE_CONNECTOR_LVDS;
 
if (device == 0) {
@@ -2981,10 +2989,11 @@ bool intel_sdvo_init(struct drm_device *dev, uint32_t 
sdvo_reg, bool is_sdvob)
if (!intel_sdvo_init_ddc_proxy(intel_sdvo, dev))
goto err_i2c_bus;
 
-   /* encoder type will be decided later */
+   /* encoder type will be decided in intel_sdvo_detect() */
intel_encoder = intel_sdvo-base;
intel_encoder-type = INTEL_OUTPUT_SDVO;
-   drm_encoder_init(dev, intel_encoder-base, intel_sdvo_enc_funcs, 0);
+   drm_encoder_init(dev, intel_encoder-base, intel_sdvo_enc_funcs,
+DRM_MODE_ENCODER_NONE);
 
/* Read the regs to test if we can talk to the device */
for (i = 0; i  0x40; i++) {
-- 
1.8.4.5

___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx


Re: [Intel-gfx] [PATCH v2] drm/i915: Set up SDVO encoder type only at detect

2014-04-15 Thread Chris Wilson
On Tue, Apr 15, 2014 at 09:14:13PM +0200, Egbert Eich wrote:
 Depending on the SDVO output_flags SDVO may have multiple connectors.
 These are all initialized in intel_sdvo_output_setup(). The connector
 that is initialized later will override the encoder_type that has been
 set up by an earlier connector type initialization. Eventually the
 one that comes last wins.
 Eventually when intel_sdvo_detect() is called the active connector is
 determined.
 Delay encoder type initialization until the active connector is known
 and set it to the type that corresponds to this connector.
 
 v2: Remove explicit encoder type initialization to
 DRM_MODE_ENCODER_NONE in the SDVO connector setup functions
 as suggested by Chris Wilson ch...@chris-wilson.co.uk.
 
 Signed-off-by: Egbert Eich e...@suse.de
Reviewed-by: Chris Wilson ch...@chris-wilson.co.uk
-Chris

-- 
Chris Wilson, Intel Open Source Technology Centre
___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx