From patchwork Thu Mar 26 23:25:14 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hai Li X-Patchwork-Id: 6102691 Return-Path: X-Original-To: patchwork-linux-arm-msm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id BAF13BF90F for ; Thu, 26 Mar 2015 23:26:58 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id A7ED920434 for ; Thu, 26 Mar 2015 23:26:57 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A2B082042B for ; Thu, 26 Mar 2015 23:26:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753561AbbCZXZv (ORCPT ); Thu, 26 Mar 2015 19:25:51 -0400 Received: from smtp.codeaurora.org ([198.145.29.96]:59644 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753554AbbCZXZt (ORCPT ); Thu, 26 Mar 2015 19:25:49 -0400 Received: from smtp.codeaurora.org (localhost [127.0.0.1]) by smtp.codeaurora.org (Postfix) with ESMTP id 9ACD11413AF; Thu, 26 Mar 2015 23:25:48 +0000 (UTC) Received: by smtp.codeaurora.org (Postfix, from userid 486) id 8B5AC1413F0; Thu, 26 Mar 2015 23:25:48 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 Received: from yyzubuntu32.qualcomm.com (rrcs-67-52-130-30.west.biz.rr.com [67.52.130.30]) (using TLSv1.1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) (Authenticated sender: hali@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id 56EC31413AF; Thu, 26 Mar 2015 23:25:47 +0000 (UTC) From: Hai Li To: dri-devel@lists.freedesktop.org Cc: linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, robdclark@gmail.com, Hai Li Subject: [PATCH v2 1/4] drm/msm/mdp5: Move *_modeset_init out of construct_encoder function Date: Thu, 26 Mar 2015 19:25:14 -0400 Message-Id: <1427412317-17741-2-git-send-email-hali@codeaurora.org> X-Mailer: git-send-email 1.8.2.1 In-Reply-To: <1427412317-17741-1-git-send-email-hali@codeaurora.org> References: <1427412317-17741-1-git-send-email-hali@codeaurora.org> X-Virus-Scanned: ClamAV using ClamSMTP Sender: linux-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This change is to make the content in construct_encoder reflect its name. Also, DSI connector may be connected to video mode or command mode encoder, so that 2 different encoders need to be constructed for DSI. Signed-off-by: Hai Li --- drivers/gpu/drm/msm/mdp/mdp5/mdp5_kms.c | 89 ++++++++++++++++++++------------- 1 file changed, 54 insertions(+), 35 deletions(-) diff --git a/drivers/gpu/drm/msm/mdp/mdp5/mdp5_kms.c b/drivers/gpu/drm/msm/mdp/mdp5/mdp5_kms.c index f882019..6d967a8 100644 --- a/drivers/gpu/drm/msm/mdp/mdp5/mdp5_kms.c +++ b/drivers/gpu/drm/msm/mdp/mdp5/mdp5_kms.c @@ -163,8 +163,9 @@ int mdp5_enable(struct mdp5_kms *mdp5_kms) return 0; } -static int construct_encoder(struct mdp5_kms *mdp5_kms, - enum mdp5_intf_type intf_type, int intf_num) +static struct drm_encoder *construct_encoder(struct mdp5_kms *mdp5_kms, + enum mdp5_intf_type intf_type, int intf_num, + enum mdp5_intf_mode intf_mode) { struct drm_device *dev = mdp5_kms->dev; struct msm_drm_private *priv = dev->dev_private; @@ -172,30 +173,64 @@ static int construct_encoder(struct mdp5_kms *mdp5_kms, struct mdp5_interface intf = { .num = intf_num, .type = intf_type, - .mode = MDP5_INTF_MODE_NONE, + .mode = intf_mode, }; - int ret = 0; encoder = mdp5_encoder_init(dev, &intf); if (IS_ERR(encoder)) { - ret = PTR_ERR(encoder); - dev_err(dev->dev, "failed to construct encoder: %d\n", ret); - return ret; + dev_err(dev->dev, "failed to construct encoder\n"); + return encoder; } encoder->possible_crtcs = (1 << priv->num_crtcs) - 1; priv->encoders[priv->num_encoders++] = encoder; - if (intf_type == INTF_HDMI) { - ret = hdmi_modeset_init(priv->hdmi, dev, encoder); - if (ret) - dev_err(dev->dev, "failed to init HDMI: %d\n", ret); + return encoder; +} + +static int modeset_init_intf(struct mdp5_kms *mdp5_kms, int intf_num) +{ + struct drm_device *dev = mdp5_kms->dev; + struct msm_drm_private *priv = dev->dev_private; + const struct mdp5_cfg_hw *hw_cfg = + mdp5_cfg_get_hw_config(mdp5_kms->cfg); + enum mdp5_intf_type intf_type = hw_cfg->intfs[intf_num]; + struct drm_encoder *encoder; + int ret = 0; + + switch (intf_type) { + case INTF_DISABLED: + break; + case INTF_eDP: + if (!priv->edp) + break; + + encoder = construct_encoder(mdp5_kms, INTF_eDP, intf_num, + MDP5_INTF_MODE_NONE); + if (IS_ERR(encoder)) { + ret = PTR_ERR(encoder); + break; + } - } else if (intf_type == INTF_eDP) { - /* Construct bridge/connector for eDP: */ ret = msm_edp_modeset_init(priv->edp, dev, encoder); - if (ret) - dev_err(dev->dev, "failed to init eDP: %d\n", ret); + break; + case INTF_HDMI: + if (!priv->hdmi) + break; + + encoder = construct_encoder(mdp5_kms, INTF_HDMI, intf_num, + MDP5_INTF_MODE_NONE); + if (IS_ERR(encoder)) { + ret = PTR_ERR(encoder); + break; + } + + ret = hdmi_modeset_init(priv->hdmi, dev, encoder); + break; + default: + dev_err(dev->dev, "unknown intf: %d\n", intf_type); + ret = -EINVAL; + break; } return ret; @@ -261,27 +296,11 @@ static int modeset_init(struct mdp5_kms *mdp5_kms) } } - /* Construct external display interfaces' encoders: */ + /* Construct encoders and modeset initialize connector devices + * for each external display interface. + */ for (i = 0; i < ARRAY_SIZE(hw_cfg->intfs); i++) { - enum mdp5_intf_type intf_type = hw_cfg->intfs[i]; - - switch (intf_type) { - case INTF_DISABLED: - break; - case INTF_eDP: - if (priv->edp) - ret = construct_encoder(mdp5_kms, INTF_eDP, i); - break; - case INTF_HDMI: - if (priv->hdmi) - ret = construct_encoder(mdp5_kms, INTF_HDMI, i); - break; - default: - dev_err(dev->dev, "unknown intf: %d\n", intf_type); - ret = -EINVAL; - break; - } - + ret = modeset_init_intf(mdp5_kms, i); if (ret) goto fail; }