From patchwork Wed Sep 12 06:02:50 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stu Hsieh X-Patchwork-Id: 10596751 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A0A3D920 for ; Wed, 12 Sep 2018 06:03:28 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8F30D2991D for ; Wed, 12 Sep 2018 06:03:28 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 832EC29924; Wed, 12 Sep 2018 06:03:28 +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=-2.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 02B362991D for ; Wed, 12 Sep 2018 06:03:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=AiCdSIQhJWcdcK5R1eCIPl414BHaNB/vvXjL2cy7x0M=; b=nWL5myV9Qj3y8B rb6tHRrPnfpLloquIi8Z0lGFL4vmHVfvHy3N221bkKtbBs2Xt8xNPPpxi8WZDhphh3eNQ2BEsuEE3 yW2w2ELWDWweXBrcb+7VjwyweE81Uh2g8SxvsxETV7x6uALagF8rHurDkynDZaI0SLfmwFkuq3bdg GvTIQTp+i/wFHR1+Xp8d8Vr3Q5Qa+VWh5pK62RlBYtozZ+Xwnt5rYwz4dk2TNG2dkOO80+57QWrt4 rubwq6K3EHlfUWNL30agPeWhnUFohZhIEOaUes2ZjDsTZKXk5XaEBBICOdtAYb2JUXYoTSkB0Yi4g T04JL5YCvayQ7LkDM3Tw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1fzyFK-000477-JG for patchwork-linux-mediatek@patchwork.kernel.org; Wed, 12 Sep 2018 06:03:26 +0000 Received: from [210.61.82.183] (helo=mailgw01.mediatek.com) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fzyFF-00043y-EA; Wed, 12 Sep 2018 06:03:23 +0000 X-UUID: f235e538202b4d4288a316f88d459fd8-20180912 Received: from mtkexhb01.mediatek.inc [(172.21.101.102)] by mailgw01.mediatek.com (envelope-from ) (mhqrelay.mediatek.com ESMTP with TLS) with ESMTP id 959829480; Wed, 12 Sep 2018 14:03:00 +0800 Received: from mtkcas09.mediatek.inc (172.21.101.178) by mtkmbs01n2.mediatek.inc (172.21.101.79) with Microsoft SMTP Server (TLS) id 15.0.1210.3; Wed, 12 Sep 2018 14:02:55 +0800 Received: from mtksdccf07.mediatek.inc (172.21.84.99) by mtkcas09.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1210.3 via Frontend Transport; Wed, 12 Sep 2018 14:02:55 +0800 From: Stu Hsieh To: CK Hu , Philipp Zabel Subject: [PATCH v1 1/1] drm/mediatek: add function to match the connector and crtc Date: Wed, 12 Sep 2018 14:02:50 +0800 Message-ID: <1536732170-30046-2-git-send-email-stu.hsieh@mediatek.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1536732170-30046-1-git-send-email-stu.hsieh@mediatek.com> References: <1536732170-30046-1-git-send-email-stu.hsieh@mediatek.com> MIME-Version: 1.0 X-TM-SNTS-SMTP: 24DD10C6BBEE98A34316FF5EC742783176C4298690238399664AB9431FDFF5B62000:8 X-MTK: N X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180911_230321_615343_509E56C0 X-CRM114-Status: GOOD ( 11.50 ) X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: srv_heupstream@mediatek.com, David Airlie , linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-mediatek@lists.infradead.org, Stu Hsieh , Matthias Brugger , linux-arm-kernel@lists.infradead.org Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+patchwork-linux-mediatek=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP This patch add function to match the connector and crtc Because the connector set the possible_crtc to match the crtc. This function would search the connector in every ddp path and return the corresponding value for possible_crtc. Change-Id: Id51de53b95039f8174462d483eb9bfee31b3b93b Signed-off-by: Stu Hsieh --- drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.c | 41 +++++++++++++++++++++++++++++ drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.h | 2 ++ 2 files changed, 43 insertions(+) diff --git a/drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.c b/drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.c index ff974d82a4a6..1f734b806a00 100644 --- a/drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.c +++ b/drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.c @@ -245,6 +245,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) +{ + int i; + + if (!path) + return false; + + for (i = 0; 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) { @@ -260,6 +276,31 @@ 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 8399229e6ad2..f882e69088b8 100644 --- a/drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.h +++ b/drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.h @@ -166,6 +166,8 @@ static inline void mtk_ddp_gamma_set(struct mtk_ddp_comp *comp, comp->funcs->gamma_set(comp, state); } +unsigned int mtk_drm_find_possible_crtc_by_comp(struct drm_device *drm, + struct mtk_ddp_comp ddp_comp); int mtk_ddp_comp_get_id(struct device_node *node, enum mtk_ddp_comp_type comp_type); int mtk_ddp_comp_init(struct device *dev, struct device_node *comp_node,