Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp478121pxa; Tue, 4 Aug 2020 10:00:47 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw2ogOtJd4+ov9u2oW8SJEmVRw9ES7RDgja3Ot4GWi2EL7eJ3iLZH9fsIJfJpR1KcR5CaEp X-Received: by 2002:aa7:dcd2:: with SMTP id w18mr22174326edu.307.1596560447184; Tue, 04 Aug 2020 10:00:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1596560447; cv=none; d=google.com; s=arc-20160816; b=Ug1Yu/xjP8BfcL1CV5zE2NHmkRKFCJeNfhEGs3LOwM7FTTJK34dfxkOqUUAkSnDabF pWFo7wTJ7g/1myHhrxtUQHXW0DBJScF5OhnRh0VOKJnMqr2i1Z1ccgyDCm2mGYci1xjo BGbwIvi9/0QmG/29GeexyIgEoWXAl+iZKI9QQDh71J6nvDUtBMpbwtdOwSntTvhhPrc/ Gq5RBpjWkXwipajQhY7MNQHkSJcqNZ9NbFhNP/k4yMhKikHqzG1MvI4SFQ3QZ3En+Awo q8VYbqaSbiO7DQz4oG2vzVHYs56jCMuOk8emfRqevngKRKOaUOLczIKe3iJLEmFR1ipE rf5g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=fCnnVcg/G7GdQeEsbRfkh+kAyhmqBcsohyCq/tDvKFE=; b=IRYc/peWP9g+FaaJorF4wrV95d7Gj8Vm+nHmXYiuiHlNxc3WfBthuu2+NDgF4CWq32 fmfocTC7b08fnBw5iflDr/X1bmM/IuxBBNqLkwAkGRmS9TlFVjTQ6+W4bYap0UxYNA67 k/Vx+i9RLyzGH2HwCWaSM3UDM6ARM5zVem/P+bMDt75m0uKHaVNRyxarGWeJlqnDjRe/ xmWmMjbrVGUsy9ZObUejp2R8WaVdH+49x7AADFOl6mYejq1JGeliFnAHufnNmVua9A0i tSnqZbFgOhuhTgL6DjIvZIOv+cjPFiyqQoflccqHiGbhqiKd2dVCQbVSZOEFV8rn9rxV Cn3A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mailerdienst.de header.s=20200217 header.b=ns5d5up8; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id m19si13037186edq.355.2020.08.04.10.00.07; Tue, 04 Aug 2020 10:00:47 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-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=@mailerdienst.de header.s=20200217 header.b=ns5d5up8; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729620AbgHDQ4w (ORCPT + 99 others); Tue, 4 Aug 2020 12:56:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51768 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728269AbgHDQ4X (ORCPT ); Tue, 4 Aug 2020 12:56:23 -0400 Received: from mxwww.masterlogin.de (mxwww.masterlogin.de [IPv6:2a03:2900:1:1::b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 797D5C061757 for ; Tue, 4 Aug 2020 09:56:18 -0700 (PDT) Received: from mxout2.routing.net (unknown [192.168.10.82]) by forward.mxwww.masterlogin.de (Postfix) with ESMTPS id 8FDE996149; Tue, 4 Aug 2020 16:56:12 +0000 (UTC) Received: from mxbox3.masterlogin.de (unknown [192.168.10.78]) by mxout2.routing.net (Postfix) with ESMTP id 6A9525FA21; Tue, 4 Aug 2020 16:56:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mailerdienst.de; s=20200217; t=1596560172; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=fCnnVcg/G7GdQeEsbRfkh+kAyhmqBcsohyCq/tDvKFE=; b=ns5d5up80fI/wkjh3mXXW7yrF6yGuDeJpnt+d3L0aFVHIzNg7/mrgPa+YIyOv0jvjt9jmD myd2inuXmUsOtdRnkwLmj2n39FnifpjPD8XG7ooilw4SoFkwhbjK0vLz+VBOBIojPMHS+G L0UgdES3J0K06dFZwu34DyUw6bgtv30= Received: from localhost.localdomain (fttx-pool-217.61.144.119.bambit.de [217.61.144.119]) by mxbox3.masterlogin.de (Postfix) with ESMTPSA id BA9E13600F8; Tue, 4 Aug 2020 16:56:11 +0000 (UTC) From: Frank Wunderlich To: linux-mediatek@lists.infradead.org Cc: Frank Wunderlich , Chun-Kuang Hu , Philipp Zabel , David Airlie , Daniel Vetter , Matthias Brugger , dri-devel@lists.freedesktop.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Stu Hsieh Subject: [PATCH v4 4/6] drm/mediatek: Add get_possible_crtc API for dpi, dsi Date: Tue, 4 Aug 2020 18:55:53 +0200 Message-Id: <20200804165555.75159-6-linux@fw-web.de> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200804165555.75159-1-linux@fw-web.de> References: <20200804165555.75159-1-linux@fw-web.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Stu Hsieh For current mediatek dsi encoder, its possible crtc is fixed in crtc 0, and mediatek dpi encoder's possible crtc is fixed in crtc 1. In some SoC the possible crtc is not fixed in this case, so search pipeline information to find out the correct possible crtc. Signed-off-by: Stu Hsieh Signed-off-by: Frank Wunderlich Reviewed-by: Chun-Kuang Hu --- drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.c | 42 +++++++++++++++++++++ drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.h | 2 + 2 files changed, 44 insertions(+) diff --git a/drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.c b/drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.c index 57c88de9a329..a5f2ff6bea93 100644 --- a/drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.c +++ b/drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.c @@ -13,6 +13,8 @@ #include #include #include +#include + #include "mtk_drm_drv.h" #include "mtk_drm_plane.h" #include "mtk_drm_ddp_comp.h" @@ -412,6 +414,22 @@ static const struct mtk_ddp_comp_match mtk_ddp_matches[DDP_COMPONENT_ID_MAX] = { [DDP_COMPONENT_WDMA1] = { MTK_DISP_WDMA, 1, NULL }, }; +static bool mtk_drm_find_comp_in_ddp(struct mtk_ddp_comp ddp_comp, + const enum mtk_ddp_comp_id *path, + unsigned int path_len) +{ + unsigned int i; + + if (path == NULL) + return false; + + for (i = 0U; i < path_len; i++) + if (ddp_comp.id == path[i]) + return true; + + return false; +} + int mtk_ddp_comp_get_id(struct device_node *node, enum mtk_ddp_comp_type comp_type) { @@ -427,6 +445,30 @@ int mtk_ddp_comp_get_id(struct device_node *node, return -EINVAL; } +unsigned int mtk_drm_find_possible_crtc_by_comp(struct drm_device *drm, + struct mtk_ddp_comp ddp_comp) +{ + struct mtk_drm_private *private = drm->dev_private; + unsigned int ret; + + if (mtk_drm_find_comp_in_ddp(ddp_comp, private->data->main_path, + private->data->main_len) == true) { + ret = BIT(0); + } else if (mtk_drm_find_comp_in_ddp(ddp_comp, + private->data->ext_path, + private->data->ext_len) == true) { + ret = BIT(1); + } else if (mtk_drm_find_comp_in_ddp(ddp_comp, + private->data->third_path, + private->data->third_len) == true) { + ret = BIT(2); + } else { + DRM_INFO("Failed to find comp in ddp table\n"); + ret = 0; + } + return ret; +} + int mtk_ddp_comp_init(struct device *dev, struct device_node *node, struct mtk_ddp_comp *comp, enum mtk_ddp_comp_id comp_id, const struct mtk_ddp_comp_funcs *funcs) diff --git a/drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.h b/drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.h index debe36395fe7..1d9e00b69462 100644 --- a/drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.h +++ b/drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.h @@ -202,6 +202,8 @@ static inline void mtk_ddp_ctm_set(struct mtk_ddp_comp *comp, int mtk_ddp_comp_get_id(struct device_node *node, enum mtk_ddp_comp_type comp_type); +unsigned int mtk_drm_find_possible_crtc_by_comp(struct drm_device *drm, + struct mtk_ddp_comp ddp_comp); int mtk_ddp_comp_init(struct device *dev, struct device_node *comp_node, struct mtk_ddp_comp *comp, enum mtk_ddp_comp_id comp_id, const struct mtk_ddp_comp_funcs *funcs); -- 2.25.1