drm/i915: Store port enum in intel_encoder
authorPandiyan, Dhinakaran <dhinakaran.pandiyan@intel.com>
Tue, 20 Sep 2016 01:24:38 +0000 (18:24 -0700)
committerRodrigo Vivi <rodrigo.vivi@intel.com>
Wed, 21 Sep 2016 16:32:00 +0000 (09:32 -0700)
Storing the port enum in intel_encoder makes it convenient to know the
port attached to an encoder. Moving the port information up from
intel_digital_port to intel_encoder avoids unecessary intel_digital_port
access and handles MST encoders cleanly without requiring conditional
checks for them (thanks danvet).

v2:
Renamed the port enum member from 'attached_port' to 'port' (danvet)
Fixed missing initialization of port in intel_sdvo.c (danvet)

v3:
Fixed missing initialization of port in intel_crt.c (Ville)

v4:
Storing port for DVO encoders too.

Signed-off-by: Dhinakaran Pandiyan <dhinakaran.pandiyan@intel.com>
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
Acked-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Reviewed-by: Lyude <cpaul@redhat.com>
Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
Link: http://patchwork.freedesktop.org/patch/msgid/1474334681-22690-3-git-send-email-dhinakaran.pandiyan@intel.com
12 files changed:
drivers/gpu/drm/i915/i915_drv.h
drivers/gpu/drm/i915/intel_crt.c
drivers/gpu/drm/i915/intel_ddi.c
drivers/gpu/drm/i915/intel_dp.c
drivers/gpu/drm/i915/intel_dp_mst.c
drivers/gpu/drm/i915/intel_drv.h
drivers/gpu/drm/i915/intel_dsi.c
drivers/gpu/drm/i915/intel_dvo.c
drivers/gpu/drm/i915/intel_hdmi.c
drivers/gpu/drm/i915/intel_lvds.c
drivers/gpu/drm/i915/intel_sdvo.c
drivers/gpu/drm/i915/intel_tv.c

index 008c74bfabada7634c6e6830628183326f0ac3c5..46462b181f5e44582c5bf844c6604bbae9ba1c0b 100644 (file)
@@ -185,6 +185,7 @@ enum plane {
 #define sprite_name(p, s) ((p) * INTEL_INFO(dev)->num_sprites[(p)] + (s) + 'A')
 
 enum port {
+       PORT_NONE = -1,
        PORT_A = 0,
        PORT_B,
        PORT_C,
index dfbcf16b41dfb956dddfff8f8cc90aef9d1b579c..88ebbdde185a549ea37c5f58b069aab1d62b094e 100644 (file)
@@ -917,10 +917,12 @@ void intel_crt_init(struct drm_device *dev)
        if (I915_HAS_HOTPLUG(dev))
                crt->base.hpd_pin = HPD_CRT;
        if (HAS_DDI(dev)) {
+               crt->base.port = PORT_E;
                crt->base.get_config = hsw_crt_get_config;
                crt->base.get_hw_state = intel_ddi_get_hw_state;
                crt->base.post_disable = hsw_post_disable_crt;
        } else {
+               crt->base.port = PORT_NONE;
                crt->base.get_config = intel_crt_get_config;
                crt->base.get_hw_state = intel_crt_get_hw_state;
        }
index 15d47c87def67bf8418684160ad7decabce0db2e..35f0b7c9d0a6dc3d41a4b965957826625c9cc8da 100644 (file)
@@ -2520,6 +2520,7 @@ void intel_ddi_init(struct drm_device *dev, enum port port)
        intel_dig_port->max_lanes = max_lanes;
 
        intel_encoder->type = INTEL_OUTPUT_UNKNOWN;
+       intel_encoder->port = port;
        intel_encoder->crtc_mask = (1 << 0) | (1 << 1) | (1 << 2);
        intel_encoder->cloneable = 0;
 
index acd0c51f74d5e2621e62903c1329a44cfec8d648..0568fb53b7cd746e35e40ea56592b8975e0cd8ce 100644 (file)
@@ -5832,6 +5832,7 @@ bool intel_dp_init(struct drm_device *dev,
                intel_encoder->crtc_mask = (1 << 0) | (1 << 1) | (1 << 2);
        }
        intel_encoder->cloneable = 0;
+       intel_encoder->port = port;
 
        intel_dig_port->hpd_pulse = intel_dp_hpd_pulse;
        dev_priv->hotplug.irq_port[port] = intel_dig_port;
index 54a9d7610d8ff184bbe9800b223fa43c9e4a0d99..3ffbd69e4551820b713e4707bbfbcd07ce247fe0 100644 (file)
@@ -523,6 +523,7 @@ intel_dp_create_fake_mst_encoder(struct intel_digital_port *intel_dig_port, enum
                         DRM_MODE_ENCODER_DPMST, "DP-MST %c", pipe_name(pipe));
 
        intel_encoder->type = INTEL_OUTPUT_DP_MST;
+       intel_encoder->port = intel_dig_port->port;
        intel_encoder->crtc_mask = 0x7;
        intel_encoder->cloneable = 0;
 
index 1b451e7599766aaabb61aed0238a519166850393..14da0422fce81d970ef61717bc2fc1ccf9d7a59c 100644 (file)
@@ -206,6 +206,7 @@ struct intel_encoder {
        struct drm_encoder base;
 
        enum intel_output_type type;
+       enum port port;
        unsigned int cloneable;
        void (*hot_plug)(struct intel_encoder *);
        bool (*compute_config)(struct intel_encoder *,
index b2e3d3a334f7bf2a20047f2d144e4bb54afe1856..727adaace96c336b0893a7116108ea9ab6b8368e 100644 (file)
@@ -1488,6 +1488,7 @@ void intel_dsi_init(struct drm_device *dev)
 
        intel_connector->get_hw_state = intel_connector_get_hw_state;
 
+       intel_encoder->port = port;
        /*
         * On BYT/CHV, pipe A maps to MIPI DSI port A, pipe B maps to MIPI DSI
         * port C. BXT isn't limited like this.
index 648975588cc288a114f62f7b7a07a3ceb0b9c73b..cd574900cd8d03d58a95e7b74609a975e6d93ae2 100644 (file)
@@ -516,7 +516,9 @@ void intel_dvo_init(struct drm_device *dev)
                                 "DVO %c", port_name(port));
 
                intel_encoder->type = INTEL_OUTPUT_DVO;
+               intel_encoder->port = port;
                intel_encoder->crtc_mask = (1 << 0) | (1 << 1);
+
                switch (dvo->type) {
                case INTEL_DVO_CHIP_TMDS:
                        intel_encoder->cloneable = (1 << INTEL_OUTPUT_ANALOG) |
index c51073f78730c4367459cffbb620bdeeeea08a2e..8d49800064df6e6067d56c23582712b09d44e949 100644 (file)
@@ -1972,6 +1972,7 @@ void intel_hdmi_init(struct drm_device *dev,
        }
 
        intel_encoder->type = INTEL_OUTPUT_HDMI;
+       intel_encoder->port = port;
        if (IS_CHERRYVIEW(dev)) {
                if (port == PORT_D)
                        intel_encoder->crtc_mask = 1 << 2;
index 4987d972e60a00aeac7acfc465a1046ed4691c57..c44f074f54aece447ba6154c201027002fdf05ae 100644 (file)
@@ -1064,8 +1064,9 @@ void intel_lvds_init(struct drm_device *dev)
        intel_connector->get_hw_state = intel_connector_get_hw_state;
 
        intel_connector_attach_encoder(intel_connector, intel_encoder);
-       intel_encoder->type = INTEL_OUTPUT_LVDS;
 
+       intel_encoder->type = INTEL_OUTPUT_LVDS;
+       intel_encoder->port = PORT_NONE;
        intel_encoder->cloneable = 0;
        if (HAS_PCH_SPLIT(dev))
                intel_encoder->crtc_mask = (1 << 0) | (1 << 1) | (1 << 2);
index c551024d487141c00e75d7b977909a2a76966327..a061b00297971c39d5996cea1cf4ba274259b2b3 100644 (file)
@@ -2981,6 +2981,7 @@ bool intel_sdvo_init(struct drm_device *dev,
        /* encoder type will be decided later */
        intel_encoder = &intel_sdvo->base;
        intel_encoder->type = INTEL_OUTPUT_SDVO;
+       intel_encoder->port = port;
        drm_encoder_init(dev, &intel_encoder->base, &intel_sdvo_enc_funcs, 0,
                         "SDVO %c", port_name(port));
 
index d960e48665954fa4796fbfc11b3f9d8b76e2584d..3988c45f9e5fc097315efebca13a23a28bfd5a9f 100644 (file)
@@ -1610,7 +1610,9 @@ intel_tv_init(struct drm_device *dev)
        intel_connector->get_hw_state = intel_connector_get_hw_state;
 
        intel_connector_attach_encoder(intel_connector, intel_encoder);
+
        intel_encoder->type = INTEL_OUTPUT_TVOUT;
+       intel_encoder->port = PORT_NONE;
        intel_encoder->crtc_mask = (1 << 0) | (1 << 1);
        intel_encoder->cloneable = 0;
        intel_encoder->base.possible_crtcs = ((1 << 0) | (1 << 1));