Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp657906imm; Wed, 19 Sep 2018 05:01:50 -0700 (PDT) X-Google-Smtp-Source: ANB0VdaQeU//o6he9eD3iOdM4xPoc5me/5/0Nz8ltjORc1pkl9rQT/OFnt0SgihOeLXkhJVy+Szn X-Received: by 2002:a17:902:290a:: with SMTP id g10-v6mr34198437plb.110.1537358510075; Wed, 19 Sep 2018 05:01:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537358510; cv=none; d=google.com; s=arc-20160816; b=EVrubOzX3IMuZI7SIO/xuHW30Rlk7m4oYcOCmHZPe1KYP+4KLdnGtKZYPIJkqIXlS1 FJhSq06nZ79WYXE8pz7QI7hue4OcQkqlELRoiz6RV668A8TkQXkuj8u6n0BhP2lFgs6P hJQMOvFul3R76GgrPn3IG2X40GOltQz8hEc86VpYzTmq7efmoHhm+SlZtyUD60vxjTiI BuyKqCM8pqSz0GH+9wvO9piTxiVXmNbNdjE6fexxz6ncZJq07ZYDScJz+5N6LAPJOqwx ZnAeVLRNhrVARAjpUOuD6e/RUoJHJcfFqE4mNiQLH8SFxwAXRoRkFFcvJ7ZQviwG7/ke T+8g== 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:date:cc:to:from:subject:message-id; bh=Y791XBSJ37rMDTa57SMgn0FymH7D7Fuaj5KHmhL0gwc=; b=mmb4zs/XnOIlbsyYpOoNg7LNtDJpRszUzkNByk5MXhb+737OocIYVYmNC8sS/m0Qmx TBjGt3zYHxTgSsOS04RrgqTSnUj4cjym12y/3Sa5/GnYmMUcjiKXW9ZHASlf8eqB8fPU YKppm+mwqfowvGZgbgfhSX/4n36pZ/AFUTFmQxEw+gV5Dx5ZUbGrg1CEWIqYqBl9T8ha scRtgBbglqLF5itkUa+q1Tr/ddU4qvp2FO1LPC6zMSgzoO8GnBWnHsB+GXFjCYmwUeYh dnYw7OyeolEQAy2RR7EGI5XhxKHugEHQTGqnFyCMsxXqwz5H3BeSITbYVYaGVesl6XCt 4+Hw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f94-v6si13443619plb.10.2018.09.19.05.01.34; Wed, 19 Sep 2018 05:01:50 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731355AbeISReR (ORCPT + 99 others); Wed, 19 Sep 2018 13:34:17 -0400 Received: from mailgw02.mediatek.com ([210.61.82.184]:22514 "EHLO mailgw02.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1727605AbeISReR (ORCPT ); Wed, 19 Sep 2018 13:34:17 -0400 X-UUID: 20c69bb11a9844c1bb9f2958b1268bbd-20180919 Received: from mtkcas06.mediatek.inc [(172.21.101.30)] by mailgw02.mediatek.com (envelope-from ) (mhqrelay.mediatek.com ESMTP with TLS) with ESMTP id 1217818313; Wed, 19 Sep 2018 19:56:37 +0800 Received: from mtkcas08.mediatek.inc (172.21.101.126) by mtkmbs01n2.mediatek.inc (172.21.101.79) with Microsoft SMTP Server (TLS) id 15.0.1210.3; Wed, 19 Sep 2018 19:56:35 +0800 Received: from [172.21.77.4] (172.21.77.4) by mtkcas08.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1210.3 via Frontend Transport; Wed, 19 Sep 2018 19:56:35 +0800 Message-ID: <1537358195.5124.6.camel@mtksdaap41> Subject: Re: [PATCH v1 1/1] drm/mediatek: add function to match the connector and crtc From: CK Hu To: Stu Hsieh CC: Philipp Zabel , David Airlie , Matthias Brugger , , , , , Date: Wed, 19 Sep 2018 19:56:35 +0800 In-Reply-To: <1536732170-30046-2-git-send-email-stu.hsieh@mediatek.com> References: <1536732170-30046-1-git-send-email-stu.hsieh@mediatek.com> <1536732170-30046-2-git-send-email-stu.hsieh@mediatek.com> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.10.4-0ubuntu2 MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-TM-SNTS-SMTP: FAA62B2151F10AFB96BD095B2FF043BA0BE4A01AF910BE48DAA34D8AC2F7A2652000:8 X-MTK: N Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, Stu: On Wed, 2018-09-12 at 14:02 +0800, Stu Hsieh wrote: > 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; > + } The variable naming is very important. If one day there are fourth path, fifth path, and sixth path, you would find everywhere where are such 'if else'. So I would like you to change main_path, ext_path, third_path to an array such as path[]. So this patch would be only a simple for-loop and when you add more path, you need not to modify this function. And would you also send the patch that include the caller call mtk_drm_find_possible_crtc_by_comp(), so I could understand how do you pass the parameter. Regards, CK > + > + 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,