From patchwork Mon Sep 25 15:40:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bryan O'Donoghue X-Patchwork-Id: 144628 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:cae8:0:b0:403:3b70:6f57 with SMTP id r8csp1547118vqu; Mon, 25 Sep 2023 16:20:38 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFgNS1LBP2mehZkNF4i2zFasuCKN/PqbO9B+sROmofoX53AYn5JRGOUPbmYJr+5+Nt1WrPp X-Received: by 2002:a05:6808:18a1:b0:3ad:f866:39bd with SMTP id bi33-20020a05680818a100b003adf86639bdmr11147201oib.27.1695684038438; Mon, 25 Sep 2023 16:20:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695684038; cv=none; d=google.com; s=arc-20160816; b=tlCmOIEmRrhtdvHK4WwFweuBj8oNIu6SEkrP/gEr32nqMiQVJjn1rciMpt1fuf3FYl YTXdPbEKt1E/auE5LZ1AGW/xAiPySoC+anr5Gc4fnEIcvyenqIgiUF24uG70HEoVZoom E943o3vjDDV7Xiz2ipY8/6L13g1l9hSdFsG1tSOOFfKt+a/Hn78CMYv2Iq1HmB7CHZnk fqKuy/qVtaTuib+mVGXHnbLlwfhh4Y4bhLi0vqeFB9Ayhp13Z6z/N2EgcD4DaVBSy3yo NCssfaUg7QGN976iM2SuOMovYQIQOOkC51syprZMHpc0RcOAv3bhcWoSe+AcjMg7LFdk YS/Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=XhSKtn1WWoetbFcEPefpk8WL/CMtB2nONd2TgD1HTnc=; fh=11LKKpIlt6rtONTt+h6X+e6wp8mj+pGxb3/fOJjZKK8=; b=OD1OH3GbizDZwtXOni0h6qsB+5k8Y58Wi8L2SD26oli9q2Ry5iQPQ55ROz62pNKRnb joS/xQ2G72/2IyvD8bgB27Jo+hI2KdG95ybwM7o2L6MKNRjRWBQThmfjklcXXs9luGQh /wt9wwhLvl7o84l4MldNTHAHeJQRGKdsAkTlRFqf9Uqvg+bmN9BEX4nWFU6uo8KEGVpA 4m+T+52d/5zk00yruzkfG6a8BsJKA7tUTsUA7CdToK9DvGVmYPTJb8/7dbuVZmRC4+71 iHvlhpLRJdkOnTLkRnCXplddqWU88L8TNdFc4TIK2IEwf/bQ2yuS51rp7evT29SZnGQj TI1A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=oaVWQyEY; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id 145-20020a630297000000b0056a8dc222f1si11225201pgc.259.2023.09.25.16.20.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Sep 2023 16:20:38 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=oaVWQyEY; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 376F48028E61; Mon, 25 Sep 2023 08:41:41 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230026AbjIYPlh (ORCPT + 29 others); Mon, 25 Sep 2023 11:41:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53462 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232721AbjIYPlZ (ORCPT ); Mon, 25 Sep 2023 11:41:25 -0400 Received: from mail-wm1-x32c.google.com (mail-wm1-x32c.google.com [IPv6:2a00:1450:4864:20::32c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0AA1D109 for ; Mon, 25 Sep 2023 08:41:15 -0700 (PDT) Received: by mail-wm1-x32c.google.com with SMTP id 5b1f17b1804b1-4056ce55e7eso33759565e9.2 for ; Mon, 25 Sep 2023 08:41:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1695656473; x=1696261273; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=XhSKtn1WWoetbFcEPefpk8WL/CMtB2nONd2TgD1HTnc=; b=oaVWQyEY/Fb3qLAbi289u5rgNukfv8i+OrFUoqm5NdORG3ccZyvQiUSHzyjM3nWvAC X3byZLejI3kXGrRZVAj4lWYz54NynYgIkbBQ3qpENOiZ7E2K3WMCiufqSlqTKXokMBRF hS0ChC2geChQcIa2TbrBMmxEn+srSMNPbRtvgb7NWIiQ2FDL630rfEGTpfRAya8cwOZf LXnkFK+Qnuzc4CvwRT2l9WuW+Qp87YPpOg7hweEMnwr1bPMh+NdmCY1nmkvNmInI3po2 CpfQszWbeA3etOF5DxvGvn3kLpMzxFox0JeA/aUz8xs9L/VbyGkp7cS2uz1PpgNazSc6 BwPQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695656473; x=1696261273; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=XhSKtn1WWoetbFcEPefpk8WL/CMtB2nONd2TgD1HTnc=; b=BMH0TOfOYCNey2o+K1l+uNZnfRQjsBzUPJ2PMBI4bHrMoyiKqkOeTqhvCCJYw4peYS sWTMOvqtzv0/tpDQmQRy3vvNGfajBwRb0CJsbnlKmZFlrbsroeIlQj/KhzX6DRx+rD4r d0oa7YCbaBQwQOXD/n6zxxCVMVUpA26cv0rblJXCe5Fpnck2V8S1T2Wk+E3vKUYq6xEd 4bS7Dr1Ykwa6+HxpqgRMMblM3CZIAytgfuOW6pYekfXTL9p9/UbxmjhMRAA90op2syqC 38DwFRstVGokuCRHdipTZDZIvnxUytejRXVNNSWwPs9PrYY7l2slseX6Is0aOfDyWhET iStw== X-Gm-Message-State: AOJu0YzrWvacXfc3LjrifXstcx1PF/R0Ql6uitHGCG56cLhAkFzasLuJ g5Tb3fLqejeCetnKyRRUUwcK+A== X-Received: by 2002:a05:600c:d4:b0:405:3a3d:6f42 with SMTP id u20-20020a05600c00d400b004053a3d6f42mr5841513wmm.39.1695656473410; Mon, 25 Sep 2023 08:41:13 -0700 (PDT) Received: from sagittarius-a.chello.ie (188-141-3-169.dynamic.upc.ie. [188.141.3.169]) by smtp.gmail.com with ESMTPSA id m15-20020a7bca4f000000b003fe4548188bsm15206155wml.48.2023.09.25.08.41.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Sep 2023 08:41:13 -0700 (PDT) From: Bryan O'Donoghue To: linux-arm-msm@vger.kernel.org, linux-media@vger.kernel.org, hverkuil@xs4all.nl, laurent.pinchart@ideasonboard.com, robert.foss@linaro.org, todor.too@gmail.com, agross@kernel.org, andersson@kernel.org, konrad.dybcio@linaro.org, mchehab@kernel.org, sakari.ailus@linux.intel.com, andrey.konovalov@linaro.org Cc: linux-kernel@vger.kernel.org, Bryan O'Donoghue Subject: [PATCH v6 08/17] media: qcom: camss: Assign the correct number of RDIs per VFE Date: Mon, 25 Sep 2023 16:40:50 +0100 Message-ID: <20230925154059.837152-9-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20230925154059.837152-1-bryan.odonoghue@linaro.org> References: <20230925154059.837152-1-bryan.odonoghue@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net 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 (snail.vger.email [0.0.0.0]); Mon, 25 Sep 2023 08:41:41 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1778053586259229261 X-GMAIL-MSGID: 1778053586259229261 Each Video Front End - VFE - has a variable number of Raw Data Interfaces - RDIs associated with it. The CAMSS code started from a naive implementation where a fixed define was used as a control in a for(){} loop iterating through RDIs. That model scales badly. An attempt was made with VFE_LINE_NUM_GEN2 and VFE_LINE_NUM_GEN1 to differentiate between SoCs but, the problem with that is "gen1" and "gen2" have no meaning in the silicon. There is no fixed constraint in the silicon between VFE and RDI, it is entirely up to the SoC designers how many VFEs are populated and how many RDIs to associate with each VFE. As an example sdm845 has VFE version 175 and sm8250 VFE version 480. sdm845 has 2 VFEs with 4 RDIs and 1 VFE Lite with 4 RDIs. sm8250 has 2 VFEs with 3 RDIs and 2 VFE Lite with 4 RDIs. Clearly then we need a more granular model to capture the necessary data. The defines have gone away to be replaced with per-SoC data but, we haven't populated the parameter data with the real values. Let's call those values out now msm8916: 1 x VFE 3 x RDI per VFE (not 4) msm8996: 2 x VFE 3 x RDI per VFE (not 4) sdm660: 2 x VFE 3 x RDI per VFE (not 4) sdm845: 2 x VFE 4 x RDI per VFE (not 3) 1 x VFE Lite 4 x RDI per VFE Lite (not 3) sm8250: 2 x VFE 3 x RDI per VFE (not 4) 2 x VFE Lite 4 x RDI per VFE Lite This more complex and correct mapping was not possible prior to passing values via driver data. Now that we have that change in place we can correctly map VFEs to RDIs for each VFE. Signed-off-by: Bryan O'Donoghue Acked-by: Konrad Dybcio Reviewed-by: Laurent Pinchart --- drivers/media/platform/qcom/camss/camss-vfe.h | 2 -- drivers/media/platform/qcom/camss/camss.c | 20 +++++++++---------- 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/drivers/media/platform/qcom/camss/camss-vfe.h b/drivers/media/platform/qcom/camss/camss-vfe.h index b4bae9f65c68f..4783afa73a365 100644 --- a/drivers/media/platform/qcom/camss/camss-vfe.h +++ b/drivers/media/platform/qcom/camss/camss-vfe.h @@ -52,9 +52,7 @@ enum vfe_line_id { VFE_LINE_RDI0 = 0, VFE_LINE_RDI1 = 1, VFE_LINE_RDI2 = 2, - VFE_LINE_NUM_GEN2 = 3, VFE_LINE_PIX = 3, - VFE_LINE_NUM_GEN1 = 4, VFE_LINE_NUM_MAX = 4 }; diff --git a/drivers/media/platform/qcom/camss/camss.c b/drivers/media/platform/qcom/camss/camss.c index 12131d9ea7ca8..8e78dd8d5961e 100644 --- a/drivers/media/platform/qcom/camss/camss.c +++ b/drivers/media/platform/qcom/camss/camss.c @@ -128,7 +128,7 @@ static const struct camss_subdev_resources vfe_res_8x16[] = { { 0 } }, .reg = { "vfe0" }, .interrupt = { "vfe0" }, - .line_num = VFE_LINE_NUM_GEN1, + .line_num = 3, .ops = &vfe_ops_4_1 } }; @@ -277,7 +277,7 @@ static const struct camss_subdev_resources vfe_res_8x96[] = { { 0 } }, .reg = { "vfe0" }, .interrupt = { "vfe0" }, - .line_num = VFE_LINE_NUM_GEN1, + .line_num = 3, .ops = &vfe_ops_4_7 }, @@ -297,7 +297,7 @@ static const struct camss_subdev_resources vfe_res_8x96[] = { { 0 } }, .reg = { "vfe1" }, .interrupt = { "vfe1" }, - .line_num = VFE_LINE_NUM_GEN1, + .line_num = 3, .ops = &vfe_ops_4_7 } }; @@ -467,7 +467,7 @@ static const struct camss_subdev_resources vfe_res_660[] = { { 0 } }, .reg = { "vfe0" }, .interrupt = { "vfe0" }, - .line_num = VFE_LINE_NUM_GEN1, + .line_num = 3, .ops = &vfe_ops_4_8 }, @@ -490,7 +490,7 @@ static const struct camss_subdev_resources vfe_res_660[] = { { 0 } }, .reg = { "vfe1" }, .interrupt = { "vfe1" }, - .line_num = VFE_LINE_NUM_GEN1, + .line_num = 3, .ops = &vfe_ops_4_8 } }; @@ -657,7 +657,7 @@ static const struct camss_subdev_resources vfe_res_845[] = { { 384000000 } }, .reg = { "vfe0" }, .interrupt = { "vfe0" }, - .line_num = VFE_LINE_NUM_GEN2, + .line_num = 4, .ops = &vfe_ops_170 }, @@ -679,7 +679,7 @@ static const struct camss_subdev_resources vfe_res_845[] = { { 384000000 } }, .reg = { "vfe1" }, .interrupt = { "vfe1" }, - .line_num = VFE_LINE_NUM_GEN2, + .line_num = 4, .ops = &vfe_ops_170 }, @@ -700,7 +700,7 @@ static const struct camss_subdev_resources vfe_res_845[] = { { 384000000 } }, .reg = { "vfe_lite" }, .interrupt = { "vfe_lite" }, - .line_num = VFE_LINE_NUM_GEN2, + .line_num = 4, .ops = &vfe_ops_170 } }; @@ -839,7 +839,7 @@ static const struct camss_subdev_resources vfe_res_8250[] = { { 0 } }, .reg = { "vfe0" }, .interrupt = { "vfe0" }, - .line_num = 4, + .line_num = 3, .ops = &vfe_ops_480 }, /* VFE1 */ @@ -859,7 +859,7 @@ static const struct camss_subdev_resources vfe_res_8250[] = { { 0 } }, .reg = { "vfe1" }, .interrupt = { "vfe1" }, - .line_num = 4, + .line_num = 3, .ops = &vfe_ops_480 }, /* VFE2 (lite) */ From patchwork Mon Sep 25 15:47:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bryan O'Donoghue X-Patchwork-Id: 144611 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:cae8:0:b0:403:3b70:6f57 with SMTP id r8csp1524010vqu; Mon, 25 Sep 2023 15:31:16 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGGVsSIRUMNOQXNGimyBA+DJ1R9EKVlJmYFILw4eyg8o0PZ49ITQgX2MCA2ACYTnylqZCho X-Received: by 2002:a05:6a00:23d3:b0:690:3b59:cc7b with SMTP id g19-20020a056a0023d300b006903b59cc7bmr7148958pfc.32.1695681076628; Mon, 25 Sep 2023 15:31:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695681076; cv=none; d=google.com; s=arc-20160816; b=vCBRtGOR2GQERwaRG52hHKT6FM8e7iM7EyhzmwTHZNWJHPtSGUMlexMRq1JZ55wyOS qZPDKPBFFhKKnoSxxtHEPoZ51lUPB9qf7/X4Glo26yM88LkzIauuFhAcopPveLXyOGWJ LdYzv9WKw1JWpXgTLgm+Mavo7miEw8P3uMfbJ+Lv6fhzfqm+o82j+Y/1EH9DFK/n7eKO 5dspz03fU8UL4W9PHrX7Dae2MPnFn90RgBpcf4oD6+H+AeLHCYsLSgt8Mzm/Ixm/gsCv Q/yAT5m3L0sEVcOx2dtSgaRoG95EpeE9aXugffXWUv6JC2R20Im6Ek8nmfr8mwqBEO4x l+oQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=ifKMgYO+e5m0ffw4v7ouj4QBUnl9Qz7bbgTpHwp8oVo=; fh=YrDxnoZE2zu1w4A5O/pMyb6W2NB5EAkKDOR3m7KPwy0=; b=UJQ5aCRMreVdLHakUzg6r9viP6pe1ATUo4wa+Zg8+DJQrGz6z4xq13g77Tt8k8qlZH 1b+qpeC4AqOMrkZCVaYlbJ4pzJNIhFtNmv7WzjjBXPOPK3LKmTVIH7gBqluiHWKPrzuF 42J92G5f5i0+OiVt6OScHOqnrLHB3NbI98uoeH5gLwaSc9lyiLfrN00s7Q7P6maq4X8v fElRCeWKNCXKC5rkvF1/J6eLNzZFAfyYc9D++9KHAJ4VuhTl6EqUjMN540RaRwrz2yZv JQM3qE3DF7Qz0RqWYjyHUjV0tzxIkr01hmg0N71LJXD03htNktKaakwFifco2+CIKxB/ 5+6A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=K+57JA1J; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id e23-20020a637457000000b0057d08dac754si8416461pgn.671.2023.09.25.15.31.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Sep 2023 15:31:16 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=K+57JA1J; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 42AF680E7109; Mon, 25 Sep 2023 08:48:08 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233085AbjIYPr4 (ORCPT + 29 others); Mon, 25 Sep 2023 11:47:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58160 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233019AbjIYPrg (ORCPT ); Mon, 25 Sep 2023 11:47:36 -0400 Received: from mail-wm1-x332.google.com (mail-wm1-x332.google.com [IPv6:2a00:1450:4864:20::332]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DBBF8C0 for ; Mon, 25 Sep 2023 08:47:25 -0700 (PDT) Received: by mail-wm1-x332.google.com with SMTP id 5b1f17b1804b1-404fbfac998so75579095e9.3 for ; Mon, 25 Sep 2023 08:47:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1695656844; x=1696261644; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=ifKMgYO+e5m0ffw4v7ouj4QBUnl9Qz7bbgTpHwp8oVo=; b=K+57JA1JTNQddncyEyFtdVtdRHABVLYfi6DobSLG9gpCkHtqW6GPQubP9Hr+vkNDZN kRu0ySF0mvgUXkFrPmHa/Gc3DFqUoM770Cb5hDS2xLLAXTMusRQmZ2Nv3Kvlod4yXyZ8 Phi7SWuaotMMRVGTQpg6IWE8H8J8yfivpR59a+FJC7Isyk7ak9+xyHiOl+JItuCFZ+Mq pUmqdOj9z8oJJTmUqQ5TTNItJeII3zvvLgQ9R6K5eb2thnf1vg0Ux5TjRyDsls7hL8aY xCcOBODJsHd9U2ywL6yVikulhCUMxnTJAWgfj6wNs3pyPtl/zdM1y1te2y2BZWMWzjNN 2CrA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695656844; x=1696261644; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ifKMgYO+e5m0ffw4v7ouj4QBUnl9Qz7bbgTpHwp8oVo=; b=XGiVxN5IxTACUDTwWY/2H1MO3JDtdtzHFjjnX3TSjduoBn/0sUjia5z9jz0noIzks+ sjhzpjDkMQ/Nz23GGp74s4Tl2IRvJyQGoh+RfngGAgohWFMKnChasBwgN0KFvUN0Qlof gc+N7+C7Pw+REHtaolikB2V+F98GNFFEkefoaUhNePnl7OfWaoFxbc5a7N5T5760CcHn U8yyqhUcgT9DOdD/wM7IGK7rTLhOVkC93sMLt6/Dg0HjqzielSD9bFLhDMkbdXgVzbGV Mw8FWsCuH83Qa4aa6VhVgK2jJQgR1VSnlTaYV2mDB45SkV6wGXSi/iMLDRDRKRZPyjG+ XqPQ== X-Gm-Message-State: AOJu0Yxgc/7dgEDyBd1ELjC3Lje2J6k2FIJ/INSJJFAUVhxWonc9MP6h 3u7jRU2F8iY1CELdujV7KVxV+qsefmAF8U/JSOw= X-Received: by 2002:a05:600c:291:b0:404:fc5c:15ed with SMTP id 17-20020a05600c029100b00404fc5c15edmr6507315wmk.35.1695656844381; Mon, 25 Sep 2023 08:47:24 -0700 (PDT) Received: from sagittarius-a.chello.ie (188-141-3-169.dynamic.upc.ie. [188.141.3.169]) by smtp.gmail.com with ESMTPSA id d4-20020adffd84000000b0031f34a395e7sm12077536wrr.45.2023.09.25.08.47.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Sep 2023 08:47:24 -0700 (PDT) From: Bryan O'Donoghue To: linux-arm-msm@vger.kernel.org, linux-media@vger.kernel.org, hverkuil@xs4all.nl, laurent.pinchart@ideasonboard.com, rfoss@kernel.org, todor.too@gmail.com, agross@kernel.org, andersson@kernel.org, konrad.dybcio@linaro.org, mchehab@kernel.org, sakari.ailus@linux.intel.com, andrey.konovalov@linaro.org Cc: linux-kernel@vger.kernel.org, Bryan O'Donoghue Subject: [RESEND PATCH v6 12/17] media: qcom: camss: Functionally decompose CSIPHY clock lookups Date: Mon, 25 Sep 2023 16:47:02 +0100 Message-ID: <20230925154707.837542-13-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20230925154707.837542-1-bryan.odonoghue@linaro.org> References: <20230925154707.837542-1-bryan.odonoghue@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net 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 (snail.vger.email [0.0.0.0]); Mon, 25 Sep 2023 08:48:08 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1778050480581324363 X-GMAIL-MSGID: 1778050480581324363 The csiphyX_timer and csiX_phy values need not be hard-coded. We can functionally decompose the string matching inside of a loop. Static string values are brittle, difficult to extend and not required anyway since the camss->res->csiphy_num value informs us of the number of CSIPHYs and hence the set of potential clocks for a given CSIPHY. In simple terms if we have five CSIPHYs we can have no more and no less than five csiphy_timer clocks. Similarly csi_phy core clocks have a 1:1 relationship with the PHY they clock. Signed-off-by: Bryan O'Donoghue --- .../media/platform/qcom/camss/camss-csiphy.c | 37 ++++++++++++------- 1 file changed, 23 insertions(+), 14 deletions(-) diff --git a/drivers/media/platform/qcom/camss/camss-csiphy.c b/drivers/media/platform/qcom/camss/camss-csiphy.c index 18f9a4defb2a4..20bb361e9ad05 100644 --- a/drivers/media/platform/qcom/camss/camss-csiphy.c +++ b/drivers/media/platform/qcom/camss/camss-csiphy.c @@ -536,6 +536,15 @@ static int csiphy_init_formats(struct v4l2_subdev *sd, return csiphy_set_format(sd, fh ? fh->state : NULL, &format); } +static bool csiphy_match_clock_name(const char *clock_name, const char *format, + int index) +{ + char name[16]; /* csiphyXXX_timer\0 */ + + snprintf(name, sizeof(name), format, index); + return !strcmp(clock_name, name); +} + /* * msm_csiphy_subdev_init - Initialize CSIPHY device structure and resources * @csiphy: CSIPHY device @@ -550,7 +559,7 @@ int msm_csiphy_subdev_init(struct camss *camss, { struct device *dev = camss->dev; struct platform_device *pdev = to_platform_device(dev); - int i, j; + int i, j, k; int ret; csiphy->camss = camss; @@ -656,19 +665,19 @@ int msm_csiphy_subdev_init(struct camss *camss, for (j = 0; j < clock->nfreqs; j++) clock->freq[j] = res->clock_rate[i][j]; - if (!strcmp(clock->name, "csiphy0_timer") || - !strcmp(clock->name, "csiphy1_timer") || - !strcmp(clock->name, "csiphy2_timer") || - !strcmp(clock->name, "csiphy3_timer") || - !strcmp(clock->name, "csiphy4_timer") || - !strcmp(clock->name, "csiphy5_timer")) - csiphy->rate_set[i] = true; - - if (camss->res->version == CAMSS_660 && - (!strcmp(clock->name, "csi0_phy") || - !strcmp(clock->name, "csi1_phy") || - !strcmp(clock->name, "csi2_phy"))) - csiphy->rate_set[i] = true; + for (k = 0; k < camss->res->csiphy_num; k++) { + csiphy->rate_set[i] = csiphy_match_clock_name(clock->name, + "csiphy%d_timer", k); + if (csiphy->rate_set[i]) + break; + + if (camss->res->version == CAMSS_660) { + csiphy->rate_set[i] = csiphy_match_clock_name(clock->name, + "csi%d_phy", k); + if (csiphy->rate_set[i]) + break; + } + } } return 0;