From patchwork Sun Jul 25 04:24:32 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bjorn Andersson X-Patchwork-Id: 12397995 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1411DC432BE for ; Sun, 25 Jul 2021 04:26:32 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id D500B60E77 for ; Sun, 25 Jul 2021 04:26:31 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org D500B60E77 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 2269F737FB; Sun, 25 Jul 2021 04:26:29 +0000 (UTC) Received: from mail-ot1-x32d.google.com (mail-ot1-x32d.google.com [IPv6:2607:f8b0:4864:20::32d]) by gabe.freedesktop.org (Postfix) with ESMTPS id 5204273049 for ; Sun, 25 Jul 2021 04:26:26 +0000 (UTC) Received: by mail-ot1-x32d.google.com with SMTP id c2-20020a0568303482b029048bcf4c6bd9so5076272otu.8 for ; Sat, 24 Jul 2021 21:26:26 -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=kLIpHKwFlMuHXbvXnn7lcDZQY67Dtyth80Io278/rNM=; b=Y5Ai3brq2K5DR9ucCChonXVGTYduqDK3BdwGhM+jz9Ia7mWW/pfsXoLJlGBGub9YMj 597wrEKirFSD62Uilrms59MVw4H1IEdmgSKKDlBEsnQy9tQssrIZ/E06F550Co+vWe43 80trfKhcDXDxpZgCUfS2fJaIVmfDTrZafaByjJ5siMB2vTXDpehT77Pi6sKqeQuyBYZ3 poLBWGeYRrHvYSp5qnGIaHDqLUUbjS/TRukyigXGtnaQo4VJ3Okp2Fxqja1y/KZptR+S Xtn2wPZI4D1aqfjk+7Gbpd4LdEw8j8eN/Calx78ZIw3U6yC7HwfviI/nHqC/pPTSifj4 fhZw== 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=kLIpHKwFlMuHXbvXnn7lcDZQY67Dtyth80Io278/rNM=; b=eGZkw133VlDMj14TxQUo/ua1GRiI+IN0b1+WELm4ahbphWjh6osftOtZmJrZUub3S+ HfoYYF+x6q6TS3RW33Uy1oVGTlv4SQRRtyI1foPZ7AsfDSr7x1S5IhP8DU8OzhSJ5M5X +agxy+dAAqvZv9gEwLk9j1WDNbk9+yBg1UZS+1gF3jBQgmUTfjqWJDJpmPBVhBYXUSYs bssag5Vo9kgWcmiJGjtPod1DliNzWsh2NZDdaOLr/6qY3cn3C6ERfaro/6ilNcvUEYcX EZx8/b2tN3UkIbZ41YDi4DJZNqj1CiyWBDh//CoXQIhC1iKmI6TUVSBsiHBtXnCiOucX ll4A== X-Gm-Message-State: AOAM5311U1I6jy63vKctU2Xlwc3NYFDUBtUtWjbOl2wuCM9P4P6VPVy0 FTAtePqBiuYe65osR4h5h80dow== X-Google-Smtp-Source: ABdhPJyeN1G9YfFLpWScjFsEnbMYVbrcJYDddgLmpUj1BYLkBpR0btwUuyuvVdz0UhFCbA8QVx3HoA== X-Received: by 2002:a9d:39e3:: with SMTP id y90mr8228160otb.257.1627187185599; Sat, 24 Jul 2021 21:26:25 -0700 (PDT) Received: from localhost.localdomain (104-57-184-186.lightspeed.austtx.sbcglobal.net. [104.57.184.186]) by smtp.gmail.com with ESMTPSA id t144sm6986200oih.57.2021.07.24.21.26.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 24 Jul 2021 21:26:25 -0700 (PDT) From: Bjorn Andersson To: Rob Clark , Sean Paul , David Airlie , Daniel Vetter , Abhinav Kumar , Dmitry Baryshkov , Kalyan Thota , Kuogee Hsieh Subject: [PATCH 2/5] drm/msm/dp: Modify prototype of encoder based API Date: Sat, 24 Jul 2021 21:24:32 -0700 Message-Id: <20210725042436.3967173-3-bjorn.andersson@linaro.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210725042436.3967173-1-bjorn.andersson@linaro.org> References: <20210725042436.3967173-1-bjorn.andersson@linaro.org> MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, Stephen Boyd , Rob Herring , freedreno@lists.freedesktop.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Functions in the DisplayPort code that relates to individual instances (encoders) are passed both the struct msm_dp and the struct drm_encoder. But in a situation where multiple DP instances would exist this means that the caller need to resolve which struct msm_dp relates to the struct drm_encoder at hand. The information for doing this lookup is available inside the DP driver, so update the API to take the struct msm_drm_private and the struct drm_encoder and have the DP code figure out which struct msm_dp the operation relates to. Signed-off-by: Bjorn Andersson Reviewed-by: Stephen Boyd --- drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c | 17 +++++---- drivers/gpu/drm/msm/dp/dp_display.c | 38 +++++++++++++++++---- drivers/gpu/drm/msm/msm_drv.h | 31 +++++++++-------- 3 files changed, 56 insertions(+), 30 deletions(-) diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c b/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c index 1c04b7cce43e..0d64ef0819af 100644 --- a/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c +++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c @@ -1002,8 +1002,8 @@ static void dpu_encoder_virt_mode_set(struct drm_encoder *drm_enc, trace_dpu_enc_mode_set(DRMID(drm_enc)); - if (drm_enc->encoder_type == DRM_MODE_ENCODER_TMDS && priv->dp) - msm_dp_display_mode_set(priv->dp, drm_enc, mode, adj_mode); + if (drm_enc->encoder_type == DRM_MODE_ENCODER_TMDS) + msm_dp_display_mode_set(priv, drm_enc, mode, adj_mode); list_for_each_entry(conn_iter, connector_list, head) if (conn_iter->encoder == drm_enc) @@ -1184,9 +1184,8 @@ static void dpu_encoder_virt_enable(struct drm_encoder *drm_enc) _dpu_encoder_virt_enable_helper(drm_enc); - if (drm_enc->encoder_type == DRM_MODE_ENCODER_TMDS && priv->dp) { - ret = msm_dp_display_enable(priv->dp, - drm_enc); + if (drm_enc->encoder_type == DRM_MODE_ENCODER_TMDS) { + ret = msm_dp_display_enable(priv, drm_enc); if (ret) { DPU_ERROR_ENC(dpu_enc, "dp display enable failed: %d\n", ret); @@ -1226,8 +1225,8 @@ static void dpu_encoder_virt_disable(struct drm_encoder *drm_enc) /* wait for idle */ dpu_encoder_wait_for_event(drm_enc, MSM_ENC_TX_COMPLETE); - if (drm_enc->encoder_type == DRM_MODE_ENCODER_TMDS && priv->dp) { - if (msm_dp_display_pre_disable(priv->dp, drm_enc)) + if (drm_enc->encoder_type == DRM_MODE_ENCODER_TMDS) { + if (msm_dp_display_pre_disable(priv, drm_enc)) DPU_ERROR_ENC(dpu_enc, "dp display push idle failed\n"); } @@ -1255,8 +1254,8 @@ static void dpu_encoder_virt_disable(struct drm_encoder *drm_enc) DPU_DEBUG_ENC(dpu_enc, "encoder disabled\n"); - if (drm_enc->encoder_type == DRM_MODE_ENCODER_TMDS && priv->dp) { - if (msm_dp_display_disable(priv->dp, drm_enc)) + if (drm_enc->encoder_type == DRM_MODE_ENCODER_TMDS) { + if (msm_dp_display_disable(priv, drm_enc)) DPU_ERROR_ENC(dpu_enc, "dp display disable failed\n"); } diff --git a/drivers/gpu/drm/msm/dp/dp_display.c b/drivers/gpu/drm/msm/dp/dp_display.c index 8696b36d30e4..59ffd6c8f41f 100644 --- a/drivers/gpu/drm/msm/dp/dp_display.c +++ b/drivers/gpu/drm/msm/dp/dp_display.c @@ -1432,12 +1432,25 @@ int msm_dp_modeset_init(struct msm_dp *dp_display, struct drm_device *dev, return 0; } -int msm_dp_display_enable(struct msm_dp *dp, struct drm_encoder *encoder) +static struct msm_dp *msm_dp_from_drm_encoder(struct msm_drm_private *priv, + struct drm_encoder *encoder) +{ + if (priv->dp && priv->dp->encoder == encoder) + return priv->dp; + + return NULL; +} + +int msm_dp_display_enable(struct msm_drm_private *priv, struct drm_encoder *encoder) { int rc = 0; struct dp_display_private *dp_display; + struct msm_dp *dp = msm_dp_from_drm_encoder(priv, encoder); u32 state; + if (!dp) + return -EINVAL; + dp_display = container_of(dp, struct dp_display_private, dp_display); if (!dp_display->dp_mode.drm_mode.clock) { DRM_ERROR("invalid params\n"); @@ -1489,9 +1502,13 @@ int msm_dp_display_enable(struct msm_dp *dp, struct drm_encoder *encoder) return rc; } -int msm_dp_display_pre_disable(struct msm_dp *dp, struct drm_encoder *encoder) +int msm_dp_display_pre_disable(struct msm_drm_private *priv, struct drm_encoder *encoder) { struct dp_display_private *dp_display; + struct msm_dp *dp = msm_dp_from_drm_encoder(priv, encoder); + + if (!dp) + return 0; dp_display = container_of(dp, struct dp_display_private, dp_display); @@ -1500,11 +1517,15 @@ int msm_dp_display_pre_disable(struct msm_dp *dp, struct drm_encoder *encoder) return 0; } -int msm_dp_display_disable(struct msm_dp *dp, struct drm_encoder *encoder) +int msm_dp_display_disable(struct msm_drm_private *priv, struct drm_encoder *encoder) { int rc = 0; u32 state; struct dp_display_private *dp_display; + struct msm_dp *dp = msm_dp_from_drm_encoder(priv, encoder); + + if (!dp) + return 0; dp_display = container_of(dp, struct dp_display_private, dp_display); @@ -1531,11 +1552,16 @@ int msm_dp_display_disable(struct msm_dp *dp, struct drm_encoder *encoder) return rc; } -void msm_dp_display_mode_set(struct msm_dp *dp, struct drm_encoder *encoder, - struct drm_display_mode *mode, - struct drm_display_mode *adjusted_mode) +void msm_dp_display_mode_set(struct msm_drm_private *priv, + struct drm_encoder *encoder, + struct drm_display_mode *mode, + struct drm_display_mode *adjusted_mode) { struct dp_display_private *dp_display; + struct msm_dp *dp = msm_dp_from_drm_encoder(priv, encoder); + + if (!dp) + return; dp_display = container_of(dp, struct dp_display_private, dp_display); diff --git a/drivers/gpu/drm/msm/msm_drv.h b/drivers/gpu/drm/msm/msm_drv.h index 9bfd37855969..e9232032b266 100644 --- a/drivers/gpu/drm/msm/msm_drv.h +++ b/drivers/gpu/drm/msm/msm_drv.h @@ -388,12 +388,13 @@ int __init msm_dp_register(void); void __exit msm_dp_unregister(void); int msm_dp_modeset_init(struct msm_dp *dp_display, struct drm_device *dev, struct drm_encoder *encoder); -int msm_dp_display_enable(struct msm_dp *dp, struct drm_encoder *encoder); -int msm_dp_display_disable(struct msm_dp *dp, struct drm_encoder *encoder); -int msm_dp_display_pre_disable(struct msm_dp *dp, struct drm_encoder *encoder); -void msm_dp_display_mode_set(struct msm_dp *dp, struct drm_encoder *encoder, - struct drm_display_mode *mode, - struct drm_display_mode *adjusted_mode); +int msm_dp_display_enable(struct msm_drm_private *priv, struct drm_encoder *encoder); +int msm_dp_display_disable(struct msm_drm_private *priv, struct drm_encoder *encoder); +int msm_dp_display_pre_disable(struct msm_drm_private *priv, struct drm_encoder *encoder); +void msm_dp_display_mode_set(struct msm_drm_private *priv, + struct drm_encoder *encoder, + struct drm_display_mode *mode, + struct drm_display_mode *adjusted_mode); void msm_dp_irq_postinstall(struct msm_dp *dp_display); void msm_dp_snapshot(struct msm_disp_state *disp_state, struct msm_dp *dp_display); @@ -413,25 +414,25 @@ static inline int msm_dp_modeset_init(struct msm_dp *dp_display, { return -EINVAL; } -static inline int msm_dp_display_enable(struct msm_dp *dp, +static inline int msm_dp_display_enable(struct msm_drm_private *priv, struct drm_encoder *encoder) { return -EINVAL; } -static inline int msm_dp_display_disable(struct msm_dp *dp, - struct drm_encoder *encoder) +static inline int msm_dp_display_disable(struct msm_drm_private *priv, + struct drm_encoder *encoder) { return -EINVAL; } -static inline int msm_dp_display_pre_disable(struct msm_dp *dp, - struct drm_encoder *encoder) +static inline int msm_dp_display_pre_disable(struct msm_drm_private *priv, + struct drm_encoder *encoder) { return -EINVAL; } -static inline void msm_dp_display_mode_set(struct msm_dp *dp, - struct drm_encoder *encoder, - struct drm_display_mode *mode, - struct drm_display_mode *adjusted_mode) +static inline void msm_dp_display_mode_set(struct msm_drm_private *priv, + struct drm_encoder *encoder, + struct drm_display_mode *mode, + struct drm_display_mode *adjusted_mode) { }