Received: by 2002:a05:7412:da14:b0:e2:908c:2ebd with SMTP id fe20csp212168rdb; Fri, 6 Oct 2023 00:40:28 -0700 (PDT) X-Google-Smtp-Source: AGHT+IErZNJoEY7a1QywSjcEvjkVqg5eTjqzEZ65tMj8l6tuNxZG5xvHLxeIJ8GN9/6sRHZKNGXY X-Received: by 2002:a05:6a20:8f08:b0:154:d3ac:2076 with SMTP id b8-20020a056a208f0800b00154d3ac2076mr9079308pzk.40.1696578027742; Fri, 06 Oct 2023 00:40:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696578027; cv=none; d=google.com; s=arc-20160816; b=NUU+9nxymNcnZQ7ihZTXpTd66C/t/SLF8LQpGzw/wHP6LkNAe0huBr6eePa8wqz3lX XvZSDalBOs6mGthEyXzBmaULrV5ALm9U0xjzl1PDY/ESh8Yv8wgInlpIx4xlsyQdKHbP 4MdIuw7J6UxFcp1qPrLKOzRc/k6fqWgOCYsfyRR0z2eUYovOV+1EWXOF4ItQy6W17LTq UddfU34lpb2Nybs82lmGh/VtQjm7//LAMYmz1JzpnKsGm+GWooaygV65dQok3QvDM4zf zvVJ2FNRvB4YvsqJMBJEnru5Kdnn2bm9xk8oyEnuyR082s0YVzXLZsS6PpnBfc5Q3k9U XdQA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=csULzFllOM4TetJVur8dMwONuhpyRUT3dkDgVktGYR0=; fh=kY3/KDC2qEzU7tuRfKV0Ke/m2LpBFtrYwW4wOL/Oepc=; b=EOlA2YqsK5GwtfCviBlUKYjRda+dOIN+WTc+saL4UQzdc18JdpGPoM3P4YW8zb1yOr gZiB+M6nerAl83kuScTaT24r8aArVLn4RY1CX3x4hlfmvw5K0uZK1HEIvZJUON/nHz4D voXQgTCFPOrBaVxSmELIGRRMPi3zcwsM6XBo2K57jcoO1dPUT52U91eqI5r1aug7Dad/ U6aPL8golBtFwZVbJaL9mepy0vCs3nNxagwsHPhyniU+horW6o3ga61w2RCojz/8pCjE 4259wAls4pMNbNrCuQGj2cvzehkkR+Pvx4ECDcO3octU7mGc16zt9jP4unomeEkS3WRN umrw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mediatek.com header.s=dk header.b="L/pKKU+N"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=mediatek.com Return-Path: Received: from lipwig.vger.email (lipwig.vger.email. [23.128.96.33]) by mx.google.com with ESMTPS id t11-20020a056a0021cb00b00696f1c14972si954590pfj.208.2023.10.06.00.40.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 Oct 2023 00:40:27 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) client-ip=23.128.96.33; Authentication-Results: mx.google.com; dkim=pass header.i=@mediatek.com header.s=dk header.b="L/pKKU+N"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=mediatek.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id ADBAE801CCE9; Fri, 6 Oct 2023 00:40:22 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231221AbjJFHju (ORCPT + 99 others); Fri, 6 Oct 2023 03:39:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58610 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230428AbjJFHi6 (ORCPT ); Fri, 6 Oct 2023 03:38:58 -0400 Received: from mailgw02.mediatek.com (unknown [210.61.82.184]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BF76CE9; Fri, 6 Oct 2023 00:38:46 -0700 (PDT) X-UUID: 5eb92b2a641b11ee8051498923ad61e6-20231006 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mediatek.com; s=dk; h=Content-Type:MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:CC:To:From; bh=csULzFllOM4TetJVur8dMwONuhpyRUT3dkDgVktGYR0=; b=L/pKKU+NqCX6kIJeVS0M2bdZNaRvS/brEOLlOFttX7UvgkO5Occhw/yTGLxiCIOAUsFC70OdwcBHBlMHv3jBIf8zHRBAsSsAmi1NDgiHfDHMTN8M9zpUlQVNLnmix21S1kqQNDZ8zE+jxDvwLUJHWMYnrWS2m1UrWwNV6rw4dh4=; X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.32,REQID:7d8fe89c-ead2-49d3-9a86-351b8b89394f,IP:0,U RL:0,TC:0,Content:0,EDM:0,RT:0,SF:0,FILE:0,BULK:0,RULE:Release_Ham,ACTION: release,TS:0 X-CID-META: VersionHash:5f78ec9,CLOUDID:d2adc014-4929-4845-9571-38c601e9c3c9,B ulkID:nil,BulkQuantity:0,Recheck:0,SF:102,TC:nil,Content:0,EDM:-3,IP:nil,U RL:0,File:nil,Bulk:nil,QS:nil,BEC:nil,COL:0,OSI:0,OSA:0,AV:0,LES:1,SPR:NO, DKR:0,DKP:0,BRR:0,BRE:0 X-CID-BVR: 0 X-CID-BAS: 0,_,0,_ X-CID-FACTOR: TF_CID_SPAM_SNR X-UUID: 5eb92b2a641b11ee8051498923ad61e6-20231006 Received: from mtkmbs14n2.mediatek.inc [(172.21.101.76)] by mailgw02.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-GCM-SHA384 256/256) with ESMTP id 1235336626; Fri, 06 Oct 2023 15:38:41 +0800 Received: from mtkmbs11n2.mediatek.inc (172.21.101.187) by mtkmbs10n2.mediatek.inc (172.21.101.183) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.26; Fri, 6 Oct 2023 15:38:39 +0800 Received: from mtksdccf07.mediatek.inc (172.21.84.99) by mtkmbs11n2.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.2.1118.26 via Frontend Transport; Fri, 6 Oct 2023 15:38:39 +0800 From: Hsiao Chien Sung To: AngeloGioacchino Del Regno , "CK Hu" , Krzysztof Kozlowski , Matthias Brugger , Rob Herring CC: Conor Dooley , Philipp Zabel , David Airlie , Daniel Vetter , Chun-Kuang Hu , "Mauro Carvalho Chehab" , , , , , , Singo Chang , "Nancy . Lin" , "Jason-JH . Lin" , "Hsiao Chien Sung" Subject: [PATCH v7 16/23] drm/mediatek: Start/Stop components with function pointers Date: Fri, 6 Oct 2023 15:38:24 +0800 Message-ID: <20231006073831.10402-17-shawn.sung@mediatek.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20231006073831.10402-1-shawn.sung@mediatek.com> References: <20231006073831.10402-1-shawn.sung@mediatek.com> MIME-Version: 1.0 Content-Type: text/plain X-TM-AS-Product-Ver: SMEX-14.0.0.3152-9.1.1006-23728.005 X-TM-AS-Result: No-10--2.509900-8.000000 X-TMASE-MatchedRID: Fx2QhdRtN3gb7D0aLEL5Ob2xWbKjBfWPeL05i8GXPoAIgSDinsA6bPDR cRAxsuj7tVKtZME67h5q7k1NHAqvKwTsy5Ctk/ajDko+EYiDQxG5+1figft3LiS30GKAkBxWWP6 BnnaU6Kji8zVgXoAltsIJ+4gwXrEtWBd6ltyXuvvKw7XAQdv9BdKzeQAXIybU6E0yODFYJFy4bZ xtB062qtgeYH8o1G69vf6/7twa2RV8jBBK0biDbsGfImu98AUW6afx0vH21weAhOcaQrQ0U1GyR coeF18qmKP0zzpTAeGwod8xOMKmvMCBO+zxAW5pftwZ3X11IV0= X-TM-AS-User-Approved-Sender: No X-TM-AS-User-Blocked-Sender: No X-TMASE-Result: 10--2.509900-8.000000 X-TMASE-Version: SMEX-14.0.0.3152-9.1.1006-23728.005 X-TM-SNTS-SMTP: DC877514C351E19A7940FACFA601F280EF15F2FA89800BFEC41F9C543200F95E2000:8 X-MTK: N X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,UNPARSEABLE_RELAY autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Fri, 06 Oct 2023 00:40:23 -0700 (PDT) By registering component related functions to the pointers, we can easily manage them within a for-loop and simplify the logic of component start/stop process. Signed-off-by: Hsiao Chien Sung --- .../gpu/drm/mediatek/mtk_disp_ovl_adaptor.c | 20 +++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/mediatek/mtk_disp_ovl_adaptor.c b/drivers/gpu/drm/mediatek/mtk_disp_ovl_adaptor.c index 84133303a6ec..812a1df9732f 100644 --- a/drivers/gpu/drm/mediatek/mtk_disp_ovl_adaptor.c +++ b/drivers/gpu/drm/mediatek/mtk_disp_ovl_adaptor.c @@ -72,6 +72,8 @@ static const char * const private_comp_stem[OVL_ADAPTOR_TYPE_NUM] = { static const struct mtk_ddp_comp_funcs _ethdr = { .clk_enable = mtk_ethdr_clk_enable, .clk_disable = mtk_ethdr_clk_disable, + .start = mtk_ethdr_start, + .stop = mtk_ethdr_stop, }; static const struct mtk_ddp_comp_funcs _merge = { @@ -189,16 +191,30 @@ void mtk_ovl_adaptor_config(struct device *dev, unsigned int w, void mtk_ovl_adaptor_start(struct device *dev) { + int i; struct mtk_disp_ovl_adaptor *ovl_adaptor = dev_get_drvdata(dev); - mtk_ethdr_start(ovl_adaptor->ovl_adaptor_comp[OVL_ADAPTOR_ETHDR0]); + for (i = 0; i < OVL_ADAPTOR_ID_MAX; i++) { + if (!ovl_adaptor->ovl_adaptor_comp[i] || + !comp_matches[i].funcs->start) + continue; + + comp_matches[i].funcs->start(ovl_adaptor->ovl_adaptor_comp[i]); + } } void mtk_ovl_adaptor_stop(struct device *dev) { + int i; struct mtk_disp_ovl_adaptor *ovl_adaptor = dev_get_drvdata(dev); - mtk_ethdr_stop(ovl_adaptor->ovl_adaptor_comp[OVL_ADAPTOR_ETHDR0]); + for (i = 0; i < OVL_ADAPTOR_ID_MAX; i++) { + if (!ovl_adaptor->ovl_adaptor_comp[i] || + !comp_matches[i].funcs->stop) + continue; + + comp_matches[i].funcs->stop(ovl_adaptor->ovl_adaptor_comp[i]); + } } int mtk_ovl_adaptor_clk_enable(struct device *dev) -- 2.18.0