From patchwork Tue Aug 16 00:00:53 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dhinakaran Pandiyan X-Patchwork-Id: 9282335 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 37998607FD for ; Mon, 15 Aug 2016 23:47:07 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2833828E39 for ; Mon, 15 Aug 2016 23:47:07 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1C98028E96; Mon, 15 Aug 2016 23:47:07 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 6975328E39 for ; Mon, 15 Aug 2016 23:47:06 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 15A856E187; Mon, 15 Aug 2016 23:47:06 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by gabe.freedesktop.org (Postfix) with ESMTP id F2CEE6E187 for ; Mon, 15 Aug 2016 23:47:02 +0000 (UTC) Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga102.fm.intel.com with ESMTP; 15 Aug 2016 16:47:02 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.28,527,1464678000"; d="scan'208";a="865949170" Received: from skynet.jf.intel.com ([10.54.75.148]) by orsmga003.jf.intel.com with ESMTP; 15 Aug 2016 16:47:02 -0700 From: Dhinakaran Pandiyan To: intel-gfx@lists.freedesktop.org Date: Mon, 15 Aug 2016 17:00:53 -0700 Message-Id: <1471305655-4695-2-git-send-email-dhinakaran.pandiyan@intel.com> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1471305655-4695-1-git-send-email-dhinakaran.pandiyan@intel.com> References: <1471305655-4695-1-git-send-email-dhinakaran.pandiyan@intel.com> Cc: libin.yang@linux.intel.com, Dhinakaran Pandiyan Subject: [Intel-gfx] [PATCH v2 1/3] drm/i915: Add function to return port from an encoder X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Virus-Scanned: ClamAV using ClamSMTP There are places in the driver where we just need the 'port' associated with an encoder and not 'struct intel_digital_port' that contains it. This basically is a generic implementation of intel_ddi_get_encoder_port() handling both DDI and Non-DDI encoders. The handling of the analog encoder is delegated to the DDI specific function. The idea to have a generic implementation that returned the 'enum port' from 'struct intel_encoder' came from Ville. Signed-off-by: Dhinakaran Pandiyan --- drivers/gpu/drm/i915/intel_ddi.c | 42 ++++++++++------------------------- drivers/gpu/drm/i915/intel_display.c | 18 +++++++++++++++ drivers/gpu/drm/i915/intel_drv.h | 8 ++++++- drivers/gpu/drm/i915/intel_opregion.c | 2 +- 4 files changed, 38 insertions(+), 32 deletions(-) diff --git a/drivers/gpu/drm/i915/intel_ddi.c b/drivers/gpu/drm/i915/intel_ddi.c index c2df4e4..13ceef4 100644 --- a/drivers/gpu/drm/i915/intel_ddi.c +++ b/drivers/gpu/drm/i915/intel_ddi.c @@ -301,24 +301,6 @@ static const struct bxt_ddi_buf_trans bxt_ddi_translations_hdmi[] = { { 154, 0x9A, 1, 128, true }, /* 9: 1200 0 */ }; -enum port intel_ddi_get_encoder_port(struct intel_encoder *encoder) -{ - switch (encoder->type) { - case INTEL_OUTPUT_DP_MST: - return enc_to_mst(&encoder->base)->primary->port; - case INTEL_OUTPUT_DP: - case INTEL_OUTPUT_EDP: - case INTEL_OUTPUT_HDMI: - case INTEL_OUTPUT_UNKNOWN: - return enc_to_dig_port(&encoder->base)->port; - case INTEL_OUTPUT_ANALOG: - return PORT_E; - default: - MISSING_CASE(encoder->type); - return PORT_A; - } -} - static const struct ddi_buf_trans * bdw_get_buf_trans_edp(struct drm_i915_private *dev_priv, int *n_entries) { @@ -421,7 +403,7 @@ void intel_prepare_dp_ddi_buffers(struct intel_encoder *encoder) struct drm_i915_private *dev_priv = to_i915(encoder->base.dev); u32 iboost_bit = 0; int i, n_dp_entries, n_edp_entries, size; - enum port port = intel_ddi_get_encoder_port(encoder); + enum port port = intel_get_encoder_port(encoder); const struct ddi_buf_trans *ddi_translations_fdi; const struct ddi_buf_trans *ddi_translations_dp; const struct ddi_buf_trans *ddi_translations_edp; @@ -499,7 +481,7 @@ static void intel_prepare_hdmi_ddi_buffers(struct intel_encoder *encoder) struct drm_i915_private *dev_priv = to_i915(encoder->base.dev); u32 iboost_bit = 0; int n_hdmi_entries, hdmi_level; - enum port port = intel_ddi_get_encoder_port(encoder); + enum port port = intel_get_encoder_port(encoder); const struct ddi_buf_trans *ddi_translations_hdmi; if (IS_BROXTON(dev_priv)) @@ -987,7 +969,7 @@ static void bxt_ddi_clock_get(struct intel_encoder *encoder, struct intel_crtc_state *pipe_config) { struct drm_i915_private *dev_priv = to_i915(encoder->base.dev); - enum port port = intel_ddi_get_encoder_port(encoder); + enum port port = intel_get_encoder_port(encoder); uint32_t dpll = port; pipe_config->port_clock = bxt_calc_pll_link(dev_priv, dpll); @@ -1130,7 +1112,7 @@ void intel_ddi_enable_transcoder_func(struct drm_crtc *crtc) struct drm_i915_private *dev_priv = to_i915(dev); enum pipe pipe = intel_crtc->pipe; enum transcoder cpu_transcoder = intel_crtc->config->cpu_transcoder; - enum port port = intel_ddi_get_encoder_port(intel_encoder); + enum port port = intel_get_encoder_port(intel_encoder); int type = intel_encoder->type; uint32_t temp; @@ -1226,7 +1208,7 @@ bool intel_ddi_connector_get_hw_state(struct intel_connector *intel_connector) struct drm_i915_private *dev_priv = to_i915(dev); struct intel_encoder *intel_encoder = intel_connector->encoder; int type = intel_connector->base.connector_type; - enum port port = intel_ddi_get_encoder_port(intel_encoder); + enum port port = intel_get_encoder_port(intel_encoder); enum pipe pipe = 0; enum transcoder cpu_transcoder; enum intel_display_power_domain power_domain; @@ -1286,7 +1268,7 @@ bool intel_ddi_get_hw_state(struct intel_encoder *encoder, { struct drm_device *dev = encoder->base.dev; struct drm_i915_private *dev_priv = to_i915(dev); - enum port port = intel_ddi_get_encoder_port(encoder); + enum port port = intel_get_encoder_port(encoder); enum intel_display_power_domain power_domain; u32 tmp; int i; @@ -1361,7 +1343,7 @@ void intel_ddi_enable_pipe_clock(struct intel_crtc *intel_crtc) struct drm_device *dev = crtc->dev; struct drm_i915_private *dev_priv = to_i915(dev); struct intel_encoder *intel_encoder = intel_ddi_get_crtc_encoder(crtc); - enum port port = intel_ddi_get_encoder_port(intel_encoder); + enum port port = intel_get_encoder_port(intel_encoder); enum transcoder cpu_transcoder = intel_crtc->config->cpu_transcoder; if (cpu_transcoder != TRANSCODER_EDP) @@ -1589,7 +1571,7 @@ void intel_ddi_clk_select(struct intel_encoder *encoder, const struct intel_crtc_state *pipe_config) { struct drm_i915_private *dev_priv = to_i915(encoder->base.dev); - enum port port = intel_ddi_get_encoder_port(encoder); + enum port port = intel_get_encoder_port(encoder); if (IS_SKYLAKE(dev_priv) || IS_KABYLAKE(dev_priv)) { uint32_t dpll = pipe_config->ddi_pll_sel; @@ -1616,7 +1598,7 @@ static void intel_ddi_pre_enable(struct intel_encoder *intel_encoder) struct drm_encoder *encoder = &intel_encoder->base; struct drm_i915_private *dev_priv = to_i915(encoder->dev); struct intel_crtc *crtc = to_intel_crtc(encoder->crtc); - enum port port = intel_ddi_get_encoder_port(intel_encoder); + enum port port = intel_get_encoder_port(intel_encoder); int type = intel_encoder->type; if (type == INTEL_OUTPUT_HDMI) { @@ -1668,7 +1650,7 @@ static void intel_ddi_post_disable(struct intel_encoder *intel_encoder) struct drm_encoder *encoder = &intel_encoder->base; struct drm_device *dev = encoder->dev; struct drm_i915_private *dev_priv = to_i915(dev); - enum port port = intel_ddi_get_encoder_port(intel_encoder); + enum port port = intel_get_encoder_port(intel_encoder); int type = intel_encoder->type; uint32_t val; bool wait = false; @@ -1715,7 +1697,7 @@ static void intel_enable_ddi(struct intel_encoder *intel_encoder) struct intel_crtc *intel_crtc = to_intel_crtc(crtc); struct drm_device *dev = encoder->dev; struct drm_i915_private *dev_priv = to_i915(dev); - enum port port = intel_ddi_get_encoder_port(intel_encoder); + enum port port = intel_get_encoder_port(intel_encoder); int type = intel_encoder->type; if (type == INTEL_OUTPUT_HDMI) { @@ -2276,7 +2258,7 @@ static bool intel_ddi_compute_config(struct intel_encoder *encoder, { struct drm_i915_private *dev_priv = to_i915(encoder->base.dev); int type = encoder->type; - int port = intel_ddi_get_encoder_port(encoder); + int port = intel_get_encoder_port(encoder); int ret; WARN(type == INTEL_OUTPUT_UNKNOWN, "compute_config() on unknown output!\n"); diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c index 9cbf543..44d20bd 100644 --- a/drivers/gpu/drm/i915/intel_display.c +++ b/drivers/gpu/drm/i915/intel_display.c @@ -16277,6 +16277,24 @@ err: return ret; } +enum port intel_get_encoder_port(struct intel_encoder *encoder) +{ + switch (encoder->type) { + case INTEL_OUTPUT_DP_MST: + return enc_to_mst(&encoder->base)->primary->port; + case INTEL_OUTPUT_DP: + case INTEL_OUTPUT_EDP: + case INTEL_OUTPUT_HDMI: + case INTEL_OUTPUT_UNKNOWN: + return enc_to_dig_port(&encoder->base)->port; + case INTEL_OUTPUT_ANALOG: + return intel_ddi_get_analog_port(); + default: + MISSING_CASE(encoder->type); + return PORT_A; + } +} + void intel_connector_unregister(struct drm_connector *connector) { struct intel_connector *intel_connector = to_intel_connector(connector); diff --git a/drivers/gpu/drm/i915/intel_drv.h b/drivers/gpu/drm/i915/intel_drv.h index b1fc67e..19aab7b 100644 --- a/drivers/gpu/drm/i915/intel_drv.h +++ b/drivers/gpu/drm/i915/intel_drv.h @@ -1111,7 +1111,12 @@ void intel_ddi_clk_select(struct intel_encoder *encoder, void intel_prepare_dp_ddi_buffers(struct intel_encoder *encoder); void hsw_fdi_link_train(struct drm_crtc *crtc); void intel_ddi_init(struct drm_device *dev, enum port port); -enum port intel_ddi_get_encoder_port(struct intel_encoder *intel_encoder); + +static inline enum port intel_ddi_get_analog_port(void) +{ + return PORT_A; +} + bool intel_ddi_get_hw_state(struct intel_encoder *encoder, enum pipe *pipe); void intel_ddi_enable_transcoder_func(struct drm_crtc *crtc); void intel_ddi_disable_transcoder_func(struct drm_i915_private *dev_priv, @@ -1189,6 +1194,7 @@ intel_crtc_has_dp_encoder(const struct intel_crtc_state *crtc_state) (1 << INTEL_OUTPUT_DP_MST) | (1 << INTEL_OUTPUT_EDP)); } +enum port intel_get_encoder_port(struct intel_encoder *encoder); static inline void intel_wait_for_vblank(struct drm_device *dev, int pipe) { diff --git a/drivers/gpu/drm/i915/intel_opregion.c b/drivers/gpu/drm/i915/intel_opregion.c index adca262..9c0043e 100644 --- a/drivers/gpu/drm/i915/intel_opregion.c +++ b/drivers/gpu/drm/i915/intel_opregion.c @@ -366,7 +366,7 @@ int intel_opregion_notify_encoder(struct intel_encoder *intel_encoder, if (intel_encoder->type == INTEL_OUTPUT_DSI) port = 0; else - port = intel_ddi_get_encoder_port(intel_encoder); + port = intel_get_encoder_port(intel_encoder); if (port == PORT_E) { port = 0;