From patchwork Sat Jul 17 12:40:12 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Baryshkov X-Patchwork-Id: 479233 Delivered-To: patch@linaro.org Received: by 2002:a02:c94a:0:0:0:0:0 with SMTP id u10csp2346509jao; Sat, 17 Jul 2021 05:40:27 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwmVo537mk00Edxucfqtx3fQulvkFRl1p3tTtkuzpFi9W0+uTI2CuYL+9LbOItTYdvScpQm X-Received: by 2002:a6b:f707:: with SMTP id k7mr11292028iog.125.1626525626913; Sat, 17 Jul 2021 05:40:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626525626; cv=none; d=google.com; s=arc-20160816; b=RwhQJKPmzlzApgl34xgAklmSK05Prld5Mk4MHJWP0DDe4eNl/56vhtmcgzFhyT45bq mEAF9ztPB7JCi7f8prWhZmg3iXSR2OECYxXD0+SeUGKPNbC8fBBZx2E9SwdU0QTEnElF 43k9dcdBGog+koCT5mpuSpHPVo4jv2/9o4U3Ay3bbwfVgNyHlAW6M3HT1k5GXHgR6axD 2lcUgmyoCSeVQk5UnLGROZMXbQTxfzaJsa9JbtjwG6ULbtEwPAAw+yaJ4h8JEb5zsy+T rk/jzaSZfHM07MpWVSDTfPZbgCnGjTGepL6EtIkMF+L20jBfU5R24hUW94NJZ6HXxJlz XAzg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=pY5tuMhqcs2nX4bIZTKuCC5v/MwQ9tPhYnoCq8ESggM=; b=r/mbJ/9KQfJsxUf5O5VWJcZhaIrqy+m+jijg/iz07GYPiOfVA0O+3sKMD5aLwaYt2+ +Y7m3YlCeX77eNEQOqhA3vNSuV0ntFTTjc+xSd/0YtK0XYJEBJdqapYgU3aW3sZcyiSW ir+yH0boTrxxuY8EnOgS427Q0nRxYkOCC8SiDF39PbcLIKAnwksVFokRdaMEw8RCJ/Kj H0eBf5qTM5meJtrL/oKLbYxWnaeihtJQjDp9eIJthOKQRmtcvmyjeWKh5bnCsue7z3td HyQyhsRFCNvcs/RemvjtiwqIHfzk6AuKqoNumDkzC4AAWvgtqo5Jd8d6mwjnP5yAc+xE kBqg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=RScO7UiS; spf=pass (google.com: domain of linux-arm-msm-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-arm-msm-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id v19si3403533jat.76.2021.07.17.05.40.26; Sat, 17 Jul 2021 05:40:26 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-arm-msm-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=RScO7UiS; spf=pass (google.com: domain of linux-arm-msm-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-arm-msm-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230112AbhGQMnW (ORCPT + 17 others); Sat, 17 Jul 2021 08:43:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53716 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233568AbhGQMnV (ORCPT ); Sat, 17 Jul 2021 08:43:21 -0400 Received: from mail-lj1-x236.google.com (mail-lj1-x236.google.com [IPv6:2a00:1450:4864:20::236]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4266FC06175F for ; Sat, 17 Jul 2021 05:40:25 -0700 (PDT) Received: by mail-lj1-x236.google.com with SMTP id s17so7282081ljo.12 for ; Sat, 17 Jul 2021 05:40:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=pY5tuMhqcs2nX4bIZTKuCC5v/MwQ9tPhYnoCq8ESggM=; b=RScO7UiSlmgt/wMghC9y9mRllC39zhSLpDPvwt34rVjRLBoDOEFQPlvvqmQpIQ/xdd s9ozE7UEGiTpZs61mfE/Slcs8qSb/ZQ8SKyOk/GYUYp5B481Y9hqxU9akZdCshcn7nb5 89bwZMnbkVQJaLK/cInH1dsvL1GloR7m7j+XS/iNFgPzbGJtosqPbNqGUAMIjpqPpCk2 46bWoPzyisvE5DdxavRLb4UcYnB86X37C8HGMpQiMrbez8TKTG/bWrqWXd+JalBgqKmu BFKpKYdl5FmaD7neWyrxi/zmFAXqdKGIhAZa1s7AcONS2LZDV4rq4aR3eLnVTV9ieGR4 ctXg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=pY5tuMhqcs2nX4bIZTKuCC5v/MwQ9tPhYnoCq8ESggM=; b=Wj4jrRtyCHZZOMWA8fVKEeRIWXl6pKFF2FI0gf9Tbsx8AMcVTnq2UnjptRpAditV95 ybpxJHAS9RQQvn4vlG4CJzZfvPpbIysCZNqNdbcSn7XpHwHxC8LepPNGt7HMQ3SYa11/ /K3MkL/HRuh6qefYGsAU3lH+uJYu+z9RzZfKOz0ajH+pB6NSX2d3YG6Fh0cG/JM2dmz6 NxRSEGy26yrq8lf/VlPDf49A+uwz6KfxGjS7btLNeteGk9NSujnyu3vIxT9LceLOWqLS PGNmx0HigWEwkCKfVtDWxbxIN9ISzye631StUHpTKI0oZ5kN9w3V/lxXLlxCmBWYYhvb HKFQ== X-Gm-Message-State: AOAM533SmAHoxrs+LWX89iuvluksiNVm7jockRd98+IWqx6R/+Rv5zAS 3OIU/twnIycfmGMlXKQMS3iSlA== X-Received: by 2002:a2e:7a18:: with SMTP id v24mr619548ljc.420.1626525623657; Sat, 17 Jul 2021 05:40:23 -0700 (PDT) Received: from eriador.lan ([37.153.55.125]) by smtp.gmail.com with ESMTPSA id f25sm794264ljo.126.2021.07.17.05.40.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 17 Jul 2021 05:40:23 -0700 (PDT) From: Dmitry Baryshkov To: Bjorn Andersson , Rob Clark , Sean Paul , Abhinav Kumar Cc: Jonathan Marek , Stephen Boyd , David Airlie , Daniel Vetter , linux-arm-msm@vger.kernel.org, dri-devel@lists.freedesktop.org, freedreno@lists.freedesktop.org Subject: [PATCH v4 3/7] drm/msm/dpu: support setting up two independent DSI connectors Date: Sat, 17 Jul 2021 15:40:12 +0300 Message-Id: <20210717124016.316020-4-dmitry.baryshkov@linaro.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210717124016.316020-1-dmitry.baryshkov@linaro.org> References: <20210717124016.316020-1-dmitry.baryshkov@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org Move setting up encoders from set_encoder_mode to _dpu_kms_initialize_dsi() / _dpu_kms_initialize_displayport(). This allows us to support not only "single DSI" and "bonded DSI" but also "two independent DSI" configurations. In future this would also help adding support for multiple DP connectors. Signed-off-by: Dmitry Baryshkov Reviewed-by: Abhinav Kumar --- drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c | 102 +++++++++++++----------- 1 file changed, 57 insertions(+), 45 deletions(-) -- 2.30.2 Reviewed-by: Bjorn Andersson diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c b/drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c index 1d3a4f395e74..3cd2011e18d4 100644 --- a/drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c +++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c @@ -471,30 +471,68 @@ static int _dpu_kms_initialize_dsi(struct drm_device *dev, struct dpu_kms *dpu_kms) { struct drm_encoder *encoder = NULL; + struct msm_display_info info; int i, rc = 0; if (!(priv->dsi[0] || priv->dsi[1])) return rc; - /*TODO: Support two independent DSI connectors */ - encoder = dpu_encoder_init(dev, DRM_MODE_ENCODER_DSI); - if (IS_ERR(encoder)) { - DPU_ERROR("encoder init failed for dsi display\n"); - return PTR_ERR(encoder); - } - - priv->encoders[priv->num_encoders++] = encoder; - + /* + * We support following confiurations: + * - Single DSI host (dsi0 or dsi1) + * - Two independent DSI hosts + * - Bonded DSI0 and DSI1 hosts + * + * TODO: Support swapping DSI0 and DSI1 in the bonded setup. + */ for (i = 0; i < ARRAY_SIZE(priv->dsi); i++) { + int other = (i + 1) % 2; + if (!priv->dsi[i]) continue; + if (msm_dsi_is_bonded_dsi(priv->dsi[i]) && + !msm_dsi_is_master_dsi(priv->dsi[i])) + continue; + + encoder = dpu_encoder_init(dev, DRM_MODE_ENCODER_DSI); + if (IS_ERR(encoder)) { + DPU_ERROR("encoder init failed for dsi display\n"); + return PTR_ERR(encoder); + } + + priv->encoders[priv->num_encoders++] = encoder; + + memset(&info, 0, sizeof(info)); + info.intf_type = encoder->encoder_type; + rc = msm_dsi_modeset_init(priv->dsi[i], dev, encoder); if (rc) { DPU_ERROR("modeset_init failed for dsi[%d], rc = %d\n", i, rc); break; } + + info.h_tile_instance[info.num_of_h_tiles++] = i; + info.capabilities = msm_dsi_is_cmd_mode(priv->dsi[i]) ? + MSM_DISPLAY_CAP_CMD_MODE : + MSM_DISPLAY_CAP_VID_MODE; + + if (msm_dsi_is_bonded_dsi(priv->dsi[i]) && priv->dsi[other]) { + rc = msm_dsi_modeset_init(priv->dsi[other], dev, encoder); + if (rc) { + DPU_ERROR("modeset_init failed for dsi[%d], rc = %d\n", + other, rc); + break; + } + + info.h_tile_instance[info.num_of_h_tiles++] = other; + } + + rc = dpu_encoder_setup(dev, encoder, &info); + if (rc) + DPU_ERROR("failed to setup DPU encoder %d: rc:%d\n", + encoder->base.id, rc); } return rc; @@ -505,6 +543,7 @@ static int _dpu_kms_initialize_displayport(struct drm_device *dev, struct dpu_kms *dpu_kms) { struct drm_encoder *encoder = NULL; + struct msm_display_info info; int rc = 0; if (!priv->dp) @@ -516,6 +555,7 @@ static int _dpu_kms_initialize_displayport(struct drm_device *dev, return PTR_ERR(encoder); } + memset(&info, 0, sizeof(info)); rc = msm_dp_modeset_init(priv->dp, dev, encoder); if (rc) { DPU_ERROR("modeset_init failed for DP, rc = %d\n", rc); @@ -524,6 +564,14 @@ static int _dpu_kms_initialize_displayport(struct drm_device *dev, } priv->encoders[priv->num_encoders++] = encoder; + + info.num_of_h_tiles = 1; + info.capabilities = MSM_DISPLAY_CAP_VID_MODE; + info.intf_type = encoder->encoder_type; + rc = dpu_encoder_setup(dev, encoder, &info); + if (rc) + DPU_ERROR("failed to setup DPU encoder %d: rc:%d\n", + encoder->base.id, rc); return rc; } @@ -726,41 +774,6 @@ static void dpu_kms_destroy(struct msm_kms *kms) msm_kms_destroy(&dpu_kms->base); } -static void _dpu_kms_set_encoder_mode(struct msm_kms *kms, - struct drm_encoder *encoder, - bool cmd_mode) -{ - struct msm_display_info info; - struct msm_drm_private *priv = encoder->dev->dev_private; - int i, rc = 0; - - memset(&info, 0, sizeof(info)); - - info.intf_type = encoder->encoder_type; - info.capabilities = cmd_mode ? MSM_DISPLAY_CAP_CMD_MODE : - MSM_DISPLAY_CAP_VID_MODE; - - switch (info.intf_type) { - case DRM_MODE_ENCODER_DSI: - /* TODO: No support for DSI swap */ - for (i = 0; i < ARRAY_SIZE(priv->dsi); i++) { - if (priv->dsi[i]) { - info.h_tile_instance[info.num_of_h_tiles] = i; - info.num_of_h_tiles++; - } - } - break; - case DRM_MODE_ENCODER_TMDS: - info.num_of_h_tiles = 1; - break; - } - - rc = dpu_encoder_setup(encoder->dev, encoder, &info); - if (rc) - DPU_ERROR("failed to setup DPU encoder %d: rc:%d\n", - encoder->base.id, rc); -} - static irqreturn_t dpu_irq(struct msm_kms *kms) { struct dpu_kms *dpu_kms = to_dpu_kms(kms); @@ -863,7 +876,6 @@ static const struct msm_kms_funcs kms_funcs = { .get_format = dpu_get_msm_format, .round_pixclk = dpu_kms_round_pixclk, .destroy = dpu_kms_destroy, - .set_encoder_mode = _dpu_kms_set_encoder_mode, .snapshot = dpu_kms_mdp_snapshot, #ifdef CONFIG_DEBUG_FS .debugfs_init = dpu_kms_debugfs_init,