From patchwork Wed Aug 23 10:44:30 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: 716183 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8CC2EEE49B0 for ; Wed, 23 Aug 2023 10:44:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233952AbjHWKoy (ORCPT ); Wed, 23 Aug 2023 06:44:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33562 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233955AbjHWKoy (ORCPT ); Wed, 23 Aug 2023 06:44:54 -0400 Received: from mail-wm1-x32d.google.com (mail-wm1-x32d.google.com [IPv6:2a00:1450:4864:20::32d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DDD2CFB for ; Wed, 23 Aug 2023 03:44:51 -0700 (PDT) Received: by mail-wm1-x32d.google.com with SMTP id 5b1f17b1804b1-3fef2f05356so26215575e9.0 for ; Wed, 23 Aug 2023 03:44:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1692787490; x=1693392290; 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=bLS0B+SArRid/e9AB/VEkQGWQx14zSatlMTcSargJZU=; b=nXV88WHPOYY9HGbq1FnGn9LiAQCFnGn0qNe6AauoCnz4hWRTn+NY8kZMklHW4eL4uy aD8ZXPNs5wS25inqE9OxVjMAVdkApSUr7ZXtWSMgqtZovmKgKofmwtDutfwdirhvo/0h WQqqbTc5O0GPEvgumuhXiocAPtHCfPHhHgLN3ZT5jviOg5e4+9CBcx/PgtJiv0dJBOH6 j20EfmTZhMZOlBIWDnHE9hNp18DLpLweG2RefVl6QE8uq0ilTsxD6t1E4TQy3ubnJlvu qG7JipC3pHX2uEztcQBlIFCnFGxMVWv6ZDKltTuXeiQuuzAozLtu0MIigSmoge2Ji/+0 xsoQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692787490; x=1693392290; 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=bLS0B+SArRid/e9AB/VEkQGWQx14zSatlMTcSargJZU=; b=GsoicHpCgejxGOPUk+/Mn0T9O1KmkeYGNW3L/ihjx+WMqeR85+KGeitrC9766f7Iub LH3bqIIgEznyqFh3Z6e8bAliaG2WBA77ULg2cWpklzmhZAicG52XSMAMx30bTIkZDAMh ULpONK+pph5EzIEyQ4EyDcOIdsHaykvVLlnOAllG/lbe3eWvtmeCJC7EmrF2G4vRxMUA RaY9Pf/OeQdpAgto/77cirsil4WKeDRQT0FcOiutewD9s9NstFy/zcc1X5JuM84p0g+m 566Qm2/OKxCZLDuelCZCiYCS78ks442C5V+qVsCyccMc4BCfHl7nc3Y8ZLXRM3YH5Q8H wjHg== X-Gm-Message-State: AOJu0YzGrNJaAlh7/g/FI4U3FwUOWfKYuN00sfo0lP1FUGWsw8d5gf6f 7EbCvWRFL28uXPdu1KueYq445A== X-Google-Smtp-Source: AGHT+IGTCInGt3SIRkdiOlVQctVvqEx6n0AIAtNdDfsbxUsOSKf+y4irFY7Qqvc2cY3q8ANvkzwpyQ== X-Received: by 2002:a1c:f304:0:b0:3fe:4900:db95 with SMTP id q4-20020a1cf304000000b003fe4900db95mr10142976wmq.37.1692787490508; Wed, 23 Aug 2023 03:44:50 -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 n4-20020a5d4204000000b0031c5dda3aedsm6281213wrq.95.2023.08.23.03.44.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Aug 2023 03:44:49 -0700 (PDT) From: Bryan O'Donoghue To: rfoss@kernel.org, todor.too@gmail.com, bryan.odonoghue@linaro.org, agross@kernel.org, andersson@kernel.org, konrad.dybcio@linaro.org, mchehab@kernel.org, hverkuil-cisco@xs4all.nl, laurent.pinchart@ideasonboard.com, sakari.ailus@linux.intel.com, andrey.konovalov@linaro.org Cc: linux-media@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 01/15] media: qcom: camss: Amalgamate struct resource with struct resource_ispif Date: Wed, 23 Aug 2023 11:44:30 +0100 Message-ID: <20230823104444.1954663-2-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230823104444.1954663-1-bryan.odonoghue@linaro.org> References: <20230823104444.1954663-1-bryan.odonoghue@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org There is no good reason to differentiate the two resource structures here. As part of a general tidyup of the declaration and passing of resources within in the CAMSS driver it will be advantageous to have one unified resource structure. The two structures are very similar anyway thus leading more credence still to the argument there should be only one. Signed-off-by: Bryan O'Donoghue Acked-by: Konrad Dybcio Reviewed-by: Laurent Pinchart --- drivers/media/platform/qcom/camss/camss-ispif.c | 4 ++-- drivers/media/platform/qcom/camss/camss-ispif.h | 4 ++-- drivers/media/platform/qcom/camss/camss.c | 14 +++++++------- drivers/media/platform/qcom/camss/camss.h | 8 +------- 4 files changed, 12 insertions(+), 18 deletions(-) diff --git a/drivers/media/platform/qcom/camss/camss-ispif.c b/drivers/media/platform/qcom/camss/camss-ispif.c index 1c7e4b1b49401..61765b874b9a2 100644 --- a/drivers/media/platform/qcom/camss/camss-ispif.c +++ b/drivers/media/platform/qcom/camss/camss-ispif.c @@ -1095,7 +1095,7 @@ static int ispif_init_formats(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh) * Return 0 on success or a negative error code otherwise */ int msm_ispif_subdev_init(struct camss *camss, - const struct resources_ispif *res) + const struct resources *res) { struct device *dev = camss->dev; struct ispif_device *ispif = camss->ispif; @@ -1152,7 +1152,7 @@ int msm_ispif_subdev_init(struct camss *camss, /* Interrupt */ - ret = platform_get_irq_byname(pdev, res->interrupt); + ret = platform_get_irq_byname(pdev, res->interrupt[0]); if (ret < 0) return ret; diff --git a/drivers/media/platform/qcom/camss/camss-ispif.h b/drivers/media/platform/qcom/camss/camss-ispif.h index fdf28e68cc7d8..c7c41f7afcaad 100644 --- a/drivers/media/platform/qcom/camss/camss-ispif.h +++ b/drivers/media/platform/qcom/camss/camss-ispif.h @@ -66,10 +66,10 @@ struct ispif_device { struct camss *camss; }; -struct resources_ispif; +struct resources; int msm_ispif_subdev_init(struct camss *camss, - const struct resources_ispif *res); + const struct resources *res); int msm_ispif_register_entities(struct ispif_device *ispif, struct v4l2_device *v4l2_dev); diff --git a/drivers/media/platform/qcom/camss/camss.c b/drivers/media/platform/qcom/camss/camss.c index f4948bdf3f8f9..de39dc987444f 100644 --- a/drivers/media/platform/qcom/camss/camss.c +++ b/drivers/media/platform/qcom/camss/camss.c @@ -93,14 +93,14 @@ static const struct resources csid_res_8x16[] = { }, }; -static const struct resources_ispif ispif_res_8x16 = { +static const struct resources ispif_res_8x16 = { /* ISPIF */ .clock = { "top_ahb", "ahb", "ispif_ahb", "csi0", "csi0_pix", "csi0_rdi", "csi1", "csi1_pix", "csi1_rdi" }, .clock_for_reset = { "vfe0", "csi_vfe0" }, .reg = { "ispif", "csi_clk_mux" }, - .interrupt = "ispif" + .interrupt = { "ispif" } }; @@ -234,7 +234,7 @@ static const struct resources csid_res_8x96[] = { } }; -static const struct resources_ispif ispif_res_8x96 = { +static const struct resources ispif_res_8x96 = { /* ISPIF */ .clock = { "top_ahb", "ahb", "ispif_ahb", "csi0", "csi0_pix", "csi0_rdi", @@ -243,7 +243,7 @@ static const struct resources_ispif ispif_res_8x96 = { "csi3", "csi3_pix", "csi3_rdi" }, .clock_for_reset = { "vfe0", "csi_vfe0", "vfe1", "csi_vfe1" }, .reg = { "ispif", "csi_clk_mux" }, - .interrupt = "ispif" + .interrupt = { "ispif" } }; static const struct resources vfe_res_8x96[] = { @@ -410,7 +410,7 @@ static const struct resources csid_res_660[] = { } }; -static const struct resources_ispif ispif_res_660 = { +static const struct resources ispif_res_660 = { /* ISPIF */ .clock = { "top_ahb", "ahb", "ispif_ahb", "csi0", "csi0_pix", "csi0_rdi", @@ -419,7 +419,7 @@ static const struct resources_ispif ispif_res_660 = { "csi3", "csi3_pix", "csi3_rdi" }, .clock_for_reset = { "vfe0", "csi_vfe0", "vfe1", "csi_vfe1" }, .reg = { "ispif", "csi_clk_mux" }, - .interrupt = "ispif" + .interrupt = { "ispif" } }; static const struct resources vfe_res_660[] = { @@ -1122,7 +1122,7 @@ static int camss_init_subdevices(struct camss *camss) { const struct resources *csiphy_res; const struct resources *csid_res; - const struct resources_ispif *ispif_res; + const struct resources *ispif_res; const struct resources *vfe_res; unsigned int i; int ret; diff --git a/drivers/media/platform/qcom/camss/camss.h b/drivers/media/platform/qcom/camss/camss.h index f6c326cb853b8..e95211cdb1fd6 100644 --- a/drivers/media/platform/qcom/camss/camss.h +++ b/drivers/media/platform/qcom/camss/camss.h @@ -44,18 +44,12 @@ struct resources { char *regulators[CAMSS_RES_MAX]; char *clock[CAMSS_RES_MAX]; + char *clock_for_reset[CAMSS_RES_MAX]; u32 clock_rate[CAMSS_RES_MAX][CAMSS_RES_MAX]; char *reg[CAMSS_RES_MAX]; char *interrupt[CAMSS_RES_MAX]; }; -struct resources_ispif { - char *clock[CAMSS_RES_MAX]; - char *clock_for_reset[CAMSS_RES_MAX]; - char *reg[CAMSS_RES_MAX]; - char *interrupt; -}; - struct icc_bw_tbl { u32 avg; u32 peak; From patchwork Wed Aug 23 10:44:32 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: 716182 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7E797EE49B4 for ; Wed, 23 Aug 2023 10:45:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234013AbjHWKpD (ORCPT ); Wed, 23 Aug 2023 06:45:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33636 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233985AbjHWKo5 (ORCPT ); Wed, 23 Aug 2023 06:44:57 -0400 Received: from mail-wm1-x32a.google.com (mail-wm1-x32a.google.com [IPv6:2a00:1450:4864:20::32a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CF70BFB for ; Wed, 23 Aug 2023 03:44:54 -0700 (PDT) Received: by mail-wm1-x32a.google.com with SMTP id 5b1f17b1804b1-3fee8af9cb9so34549275e9.1 for ; Wed, 23 Aug 2023 03:44:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1692787493; x=1693392293; 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=KIWSC2EXa4HC3O/Hi/O/D4z9uJ3T4+wrp3sKyTVS8eA=; b=wCYkjiMl12JkIIhXpD1ukArWwsuDfqjnN7xONtU0ClDyUfnpCeYvZ2VtS4IpMutdWI DVxZrGT1VIcuH7OF4s5oI0aS+IYslZZKTOnRH8XA3isMuiZ2yYRWKsWfaxzAYhufwRe1 AIRse4YxfM9YTcmCHyn32cJSaA/PnKtW3qhrAoIEO+0BRLgEgTjQM7Ve18oajWxaLQLD 4Im8lEJXHGFAA8BJ40juC1uzSDHRlq5TRS8cLbeLmkEEH8Grj9GFiPmDcm6OQrcrA78d Pm9fAbgHCFr8dfhO6CzjJuUM6TViUHQb5c+ABqPrQQJZ4HWkM9DxcU564UF/2+gKVfNf Dhpw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692787493; x=1693392293; 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=KIWSC2EXa4HC3O/Hi/O/D4z9uJ3T4+wrp3sKyTVS8eA=; b=DXukHIw6kzwZv0J7bYncdXo9M1F4glHOQQUiut8ocdH3/dRsP9jpeSVZUG5PcOUGRJ +sOWrsmm+HJ8phNBchu40KvjXcfjcYmkfTew5qKPAJef8LWx/ZWRimCRAKp9SFWNBVXZ gIxw1pGgY7hNRBXJLLNLp7wsxv+Ffz7jWN/nzIuQAWDJFmSGLaDaA9d8lO0cUrxmys71 V+eA5CeWpmfnVWuUu+j5d8bzDu7WBvV5ONf1512dI/nnJ7/BPDvxT++ZfBkz3+7080UM 4EIuzSjuWMqSWdYGTJsbl07Gc+X9tG50XwGPtJvuOjMxla8AGTlbkQlnJiO/COjROBLi V2og== X-Gm-Message-State: AOJu0YwENmB0PryDREEDPgWl0wnPREbGyGrkYh4iVOLwWDkDRRrsDuJF EL5Wpqs1egxIJstOdZp9guXtEQ== X-Google-Smtp-Source: AGHT+IEvB8PxZ0J0910A09wrsJb9MtH6J4s1XlznJTO7A9F2iD1Plu9djHIS0SR83V/CaFASyQJ4Wg== X-Received: by 2002:a05:600c:2901:b0:3fe:ef11:d79f with SMTP id i1-20020a05600c290100b003feef11d79fmr7491278wmd.36.1692787493280; Wed, 23 Aug 2023 03:44:53 -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 n4-20020a5d4204000000b0031c5dda3aedsm6281213wrq.95.2023.08.23.03.44.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Aug 2023 03:44:52 -0700 (PDT) From: Bryan O'Donoghue To: rfoss@kernel.org, todor.too@gmail.com, bryan.odonoghue@linaro.org, agross@kernel.org, andersson@kernel.org, konrad.dybcio@linaro.org, mchehab@kernel.org, hverkuil-cisco@xs4all.nl, laurent.pinchart@ideasonboard.com, sakari.ailus@linux.intel.com, andrey.konovalov@linaro.org Cc: linux-media@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 03/15] media: qcom: camss: Pass icc bandwidth table as a platform parameter Date: Wed, 23 Aug 2023 11:44:32 +0100 Message-ID: <20230823104444.1954663-4-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230823104444.1954663-1-bryan.odonoghue@linaro.org> References: <20230823104444.1954663-1-bryan.odonoghue@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org Pass the bandwidth table as a platform parameter not if/else derived pointer to the static table. Signed-off-by: Bryan O'Donoghue Acked-by: Konrad Dybcio Reviewed-by: Laurent Pinchart --- drivers/media/platform/qcom/camss/camss.c | 29 +++++++---------------- drivers/media/platform/qcom/camss/camss.h | 3 ++- 2 files changed, 11 insertions(+), 21 deletions(-) diff --git a/drivers/media/platform/qcom/camss/camss.c b/drivers/media/platform/qcom/camss/camss.c index 82e679c8ca011..9a15f2253aa20 100644 --- a/drivers/media/platform/qcom/camss/camss.c +++ b/drivers/media/platform/qcom/camss/camss.c @@ -1485,21 +1485,15 @@ static int camss_configure_pd(struct camss *camss) static int camss_icc_get(struct camss *camss) { const struct resources_icc *icc_res; - int nbr_icc_paths = 0; int i; - if (camss->version == CAMSS_8250) { - icc_res = &icc_res_sm8250[0]; - nbr_icc_paths = ICC_SM8250_COUNT; - } + icc_res = camss->res->icc_res; - for (i = 0; i < nbr_icc_paths; i++) { + for (i = 0; i < camss->res->icc_path_num; i++) { camss->icc_path[i] = devm_of_icc_get(camss->dev, icc_res[i].name); if (IS_ERR(camss->icc_path[i])) return PTR_ERR(camss->icc_path[i]); - - camss->icc_bw_tbl[i] = icc_res[i].icc_bw_tbl; } return 0; @@ -1737,6 +1731,8 @@ static const struct camss_resources sm8250_resources = { .csiphy_res = csiphy_res_8250, .csid_res = csid_res_8250, .vfe_res = vfe_res_8250, + .icc_res = icc_res_sm8250, + .icc_path_num = ARRAY_SIZE(icc_res_sm8250), }; static const struct of_device_id camss_dt_match[] = { @@ -1753,14 +1749,10 @@ MODULE_DEVICE_TABLE(of, camss_dt_match); static int __maybe_unused camss_runtime_suspend(struct device *dev) { struct camss *camss = dev_get_drvdata(dev); - int nbr_icc_paths = 0; int i; int ret; - if (camss->version == CAMSS_8250) - nbr_icc_paths = ICC_SM8250_COUNT; - - for (i = 0; i < nbr_icc_paths; i++) { + for (i = 0; i < camss->res->icc_path_num; i++) { ret = icc_set_bw(camss->icc_path[i], 0, 0); if (ret) return ret; @@ -1772,17 +1764,14 @@ static int __maybe_unused camss_runtime_suspend(struct device *dev) static int __maybe_unused camss_runtime_resume(struct device *dev) { struct camss *camss = dev_get_drvdata(dev); - int nbr_icc_paths = 0; + const struct resources_icc *icc_res = camss->res->icc_res; int i; int ret; - if (camss->version == CAMSS_8250) - nbr_icc_paths = ICC_SM8250_COUNT; - - for (i = 0; i < nbr_icc_paths; i++) { + for (i = 0; i < camss->res->icc_path_num; i++) { ret = icc_set_bw(camss->icc_path[i], - camss->icc_bw_tbl[i].avg, - camss->icc_bw_tbl[i].peak); + icc_res[i].icc_bw_tbl.avg, + icc_res[i].icc_bw_tbl.peak); if (ret) return ret; } diff --git a/drivers/media/platform/qcom/camss/camss.h b/drivers/media/platform/qcom/camss/camss.h index f632ee49ad83e..988c313b63551 100644 --- a/drivers/media/platform/qcom/camss/camss.h +++ b/drivers/media/platform/qcom/camss/camss.h @@ -84,6 +84,8 @@ struct camss_resources { const struct resources *csid_res; const struct resources *ispif_res; const struct resources *vfe_res; + const struct resources_icc *icc_res; + const int icc_path_num; }; struct camss { @@ -105,7 +107,6 @@ struct camss { struct device **genpd; struct device_link **genpd_link; struct icc_path *icc_path[ICC_SM8250_COUNT]; - struct icc_bw_tbl icc_bw_tbl[ICC_SM8250_COUNT]; const struct camss_resources *res; }; From patchwork Wed Aug 23 10:44:34 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: 716181 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 079D2EE49A0 for ; Wed, 23 Aug 2023 10:45:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234007AbjHWKpG (ORCPT ); Wed, 23 Aug 2023 06:45:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58040 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233994AbjHWKpC (ORCPT ); Wed, 23 Aug 2023 06:45:02 -0400 Received: from mail-wr1-x431.google.com (mail-wr1-x431.google.com [IPv6:2a00:1450:4864:20::431]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7AF38E47 for ; Wed, 23 Aug 2023 03:44:57 -0700 (PDT) Received: by mail-wr1-x431.google.com with SMTP id ffacd0b85a97d-31963263938so4726838f8f.2 for ; Wed, 23 Aug 2023 03:44:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1692787496; x=1693392296; 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=V3EVM4NSh4sU0uIYCvXtqdOfYy3wiLidXcUOiCRG0qw=; b=h59sQOBsXwNJUZ9Canihv66exOSu6HqI8yy7h37hE1ly6XLg2Nj3murXw7x+3BeuvP 01ZKJxDgv1mLWoLyrsqgFHvUOvqwZaPWegohCB1gy12LvTMTHBPyfxdqZu1K2grQ+eW+ hC2+q7LflLOlIKuV8YSJ2auH+vVdiyFxWnDGXxMmdzpSN2ASJPvoXuqrdts00nLe1vMk DedN41WI6buB+dPK+YRvBMD3/vfgHxDwY0vxOWLHja6dLS9/LyfVcsZhyrO6X3dfCfCm 6XMPf40Jx3vCyPJxp320h1EN4gyNyGxCT2ESw7eA/SAHMgHXXDqTHsoYEkDFI8ByhH48 Hvng== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692787496; x=1693392296; 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=V3EVM4NSh4sU0uIYCvXtqdOfYy3wiLidXcUOiCRG0qw=; b=L5POPth+o4nkRfk2xvRLdtVsVGnnANmI2t+FZ2N64ybYWxaY7VrtOtaE0ezsxaIsy8 ObcpZlVIcf4dskDiErzmZnQ7iPsbVy5J7r0X/4J6b9LpobhAqsUe12rzn6WlV1nyMxZU Ed5V2+KRm7cnLn/mz/ay/N81GXrhzyXPIyCUHI3jWE5/abp8BC+FPt6nLSXaN1s72L6G N6l55gclDnbf48MVdRel88U4oRHTvLafywxTq86KpuELnqP7AFjWJIxcoHHIXNxJ2fxm nW5xLKKJIerDSUx40HoHz7y4/3RU4TzpT57WFWcMeEnmD+obXzKTguSKXLy5LKYaeQin +PMg== X-Gm-Message-State: AOJu0Yyeql/E8apGyceHwyJhhB91uzA0NTK7YHAWuQB9jUTbUqRV/EZG xlIqmEciwFRekTkVaUJv9+Hqfg== X-Google-Smtp-Source: AGHT+IEKyzbY5tiGk0x9wY+NW/nCfHACfkEFuDHkVk+Ms0tmU5QNI1Ubrn4wqYbRYfKgSR1CafbqzQ== X-Received: by 2002:adf:fd04:0:b0:319:76a3:1006 with SMTP id e4-20020adffd04000000b0031976a31006mr9343106wrr.40.1692787495903; Wed, 23 Aug 2023 03:44:55 -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 n4-20020a5d4204000000b0031c5dda3aedsm6281213wrq.95.2023.08.23.03.44.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Aug 2023 03:44:55 -0700 (PDT) From: Bryan O'Donoghue To: rfoss@kernel.org, todor.too@gmail.com, bryan.odonoghue@linaro.org, agross@kernel.org, andersson@kernel.org, konrad.dybcio@linaro.org, mchehab@kernel.org, hverkuil-cisco@xs4all.nl, laurent.pinchart@ideasonboard.com, sakari.ailus@linux.intel.com, andrey.konovalov@linaro.org Cc: linux-media@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 05/15] media: qcom: camss: Pass line_num from compat resources Date: Wed, 23 Aug 2023 11:44:34 +0100 Message-ID: <20230823104444.1954663-6-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230823104444.1954663-1-bryan.odonoghue@linaro.org> References: <20230823104444.1954663-1-bryan.odonoghue@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org line_num indicates the number of RDI - raw data interface channels which are associated with a given IFE/VFE - image/video front end. On several SoCs the RDI number is not static for each VFE - for example on sm8250 VFE Lite has four RDIs where regular VFE has three. Assigning line_num statically in the subdev_init() phase initialises each VFE to the lower number, meaning in practical terms that we are lobbing off one RDI on some VFEs. Interrupt handling uses static for (i = RDI0; i < RDI2; i++) {} in some of our VFE blocks but this can't work for situations where we have a mixture of VFE @ 3 RDI and VFE-lite @ 4 RDI blocks. First step to remediate is to pass line_num from a compat string controlled data-structure and do so on a per-VFE basis. Later patches will assign the correct number of RDI blocks per VFE. Signed-off-by: Bryan O'Donoghue Reviewed-by: Konrad Dybcio Reviewed-by: Laurent Pinchart --- .../media/platform/qcom/camss/camss-vfe-170.c | 2 -- .../media/platform/qcom/camss/camss-vfe-4-1.c | 2 -- .../media/platform/qcom/camss/camss-vfe-4-7.c | 2 -- .../media/platform/qcom/camss/camss-vfe-4-8.c | 2 -- .../media/platform/qcom/camss/camss-vfe-480.c | 1 - drivers/media/platform/qcom/camss/camss-vfe.c | 5 +++ drivers/media/platform/qcom/camss/camss.c | 36 ++++++++++++------- drivers/media/platform/qcom/camss/camss.h | 1 + 8 files changed, 30 insertions(+), 21 deletions(-) diff --git a/drivers/media/platform/qcom/camss/camss-vfe-170.c b/drivers/media/platform/qcom/camss/camss-vfe-170.c index 9905bb06b3823..8aa921400ded0 100644 --- a/drivers/media/platform/qcom/camss/camss-vfe-170.c +++ b/drivers/media/platform/qcom/camss/camss-vfe-170.c @@ -756,8 +756,6 @@ static void vfe_subdev_init(struct device *dev, struct vfe_device *vfe) { vfe->isr_ops = vfe_isr_ops_170; vfe->video_ops = vfe_video_ops_170; - - vfe->line_num = VFE_LINE_NUM_GEN2; } const struct vfe_hw_ops vfe_ops_170 = { diff --git a/drivers/media/platform/qcom/camss/camss-vfe-4-1.c b/drivers/media/platform/qcom/camss/camss-vfe-4-1.c index bc309f326f519..2911e4126e7ad 100644 --- a/drivers/media/platform/qcom/camss/camss-vfe-4-1.c +++ b/drivers/media/platform/qcom/camss/camss-vfe-4-1.c @@ -992,8 +992,6 @@ static void vfe_subdev_init(struct device *dev, struct vfe_device *vfe) vfe->isr_ops = vfe_isr_ops_gen1; vfe->ops_gen1 = &vfe_ops_gen1_4_1; vfe->video_ops = vfe_video_ops_gen1; - - vfe->line_num = VFE_LINE_NUM_GEN1; } const struct vfe_hw_ops vfe_ops_4_1 = { diff --git a/drivers/media/platform/qcom/camss/camss-vfe-4-7.c b/drivers/media/platform/qcom/camss/camss-vfe-4-7.c index 8acd76c9746ba..b65ed0fef595e 100644 --- a/drivers/media/platform/qcom/camss/camss-vfe-4-7.c +++ b/drivers/media/platform/qcom/camss/camss-vfe-4-7.c @@ -1188,8 +1188,6 @@ static void vfe_subdev_init(struct device *dev, struct vfe_device *vfe) vfe->isr_ops = vfe_isr_ops_gen1; vfe->ops_gen1 = &vfe_ops_gen1_4_7; vfe->video_ops = vfe_video_ops_gen1; - - vfe->line_num = VFE_LINE_NUM_GEN1; } const struct vfe_hw_ops vfe_ops_4_7 = { diff --git a/drivers/media/platform/qcom/camss/camss-vfe-4-8.c b/drivers/media/platform/qcom/camss/camss-vfe-4-8.c index 3a0167ecf873a..7b3805177f037 100644 --- a/drivers/media/platform/qcom/camss/camss-vfe-4-8.c +++ b/drivers/media/platform/qcom/camss/camss-vfe-4-8.c @@ -1173,8 +1173,6 @@ static void vfe_subdev_init(struct device *dev, struct vfe_device *vfe) vfe->isr_ops = vfe_isr_ops_gen1; vfe->ops_gen1 = &vfe_ops_gen1_4_8; vfe->video_ops = vfe_video_ops_gen1; - - vfe->line_num = VFE_LINE_NUM_GEN1; } const struct vfe_hw_ops vfe_ops_4_8 = { diff --git a/drivers/media/platform/qcom/camss/camss-vfe-480.c b/drivers/media/platform/qcom/camss/camss-vfe-480.c index 80338efceb9e1..b1a07e846e25b 100644 --- a/drivers/media/platform/qcom/camss/camss-vfe-480.c +++ b/drivers/media/platform/qcom/camss/camss-vfe-480.c @@ -572,7 +572,6 @@ static const struct camss_video_ops vfe_video_ops_480 = { static void vfe_subdev_init(struct device *dev, struct vfe_device *vfe) { vfe->video_ops = vfe_video_ops_480; - vfe->line_num = MAX_VFE_OUTPUT_LINES; } const struct vfe_hw_ops vfe_ops_480 = { diff --git a/drivers/media/platform/qcom/camss/camss-vfe.c b/drivers/media/platform/qcom/camss/camss-vfe.c index 526dd4ab343fe..b789b3b2e4cfd 100644 --- a/drivers/media/platform/qcom/camss/camss-vfe.c +++ b/drivers/media/platform/qcom/camss/camss-vfe.c @@ -1305,6 +1305,11 @@ int msm_vfe_subdev_init(struct camss *camss, struct vfe_device *vfe, default: return -EINVAL; } + + if (!res->line_num) + return -EINVAL; + + vfe->line_num = res->line_num; vfe->ops->subdev_init(dev, vfe); /* Memory */ diff --git a/drivers/media/platform/qcom/camss/camss.c b/drivers/media/platform/qcom/camss/camss.c index c8a2571e664fe..ce0d86e45fe48 100644 --- a/drivers/media/platform/qcom/camss/camss.c +++ b/drivers/media/platform/qcom/camss/camss.c @@ -123,7 +123,8 @@ static const struct resources vfe_res_8x16[] = { { 0 }, { 0 } }, .reg = { "vfe0" }, - .interrupt = { "vfe0" } + .interrupt = { "vfe0" }, + .line_num = VFE_LINE_NUM_GEN1, } }; @@ -263,7 +264,8 @@ static const struct resources vfe_res_8x96[] = { { 0 }, { 0 } }, .reg = { "vfe0" }, - .interrupt = { "vfe0" } + .interrupt = { "vfe0" }, + .line_num = VFE_LINE_NUM_GEN1, }, /* VFE1 */ @@ -281,7 +283,8 @@ static const struct resources vfe_res_8x96[] = { { 0 }, { 0 } }, .reg = { "vfe1" }, - .interrupt = { "vfe1" } + .interrupt = { "vfe1" }, + .line_num = VFE_LINE_NUM_GEN1, } }; @@ -442,7 +445,8 @@ static const struct resources vfe_res_660[] = { { 0 }, { 0 } }, .reg = { "vfe0" }, - .interrupt = { "vfe0" } + .interrupt = { "vfe0" }, + .line_num = VFE_LINE_NUM_GEN1, }, /* VFE1 */ @@ -463,7 +467,8 @@ static const struct resources vfe_res_660[] = { { 0 }, { 0 } }, .reg = { "vfe1" }, - .interrupt = { "vfe1" } + .interrupt = { "vfe1" }, + .line_num = VFE_LINE_NUM_GEN1, } }; @@ -621,7 +626,8 @@ static const struct resources vfe_res_845[] = { { 19200000, 75000000, 384000000, 538666667 }, { 384000000 } }, .reg = { "vfe0" }, - .interrupt = { "vfe0" } + .interrupt = { "vfe0" }, + .line_num = VFE_LINE_NUM_GEN2, }, /* VFE1 */ @@ -641,7 +647,8 @@ static const struct resources vfe_res_845[] = { { 19200000, 75000000, 384000000, 538666667 }, { 384000000 } }, .reg = { "vfe1" }, - .interrupt = { "vfe1" } + .interrupt = { "vfe1" }, + .line_num = VFE_LINE_NUM_GEN2, }, /* VFE-lite */ @@ -660,7 +667,8 @@ static const struct resources vfe_res_845[] = { { 19200000, 75000000, 384000000, 538666667 }, { 384000000 } }, .reg = { "vfe_lite" }, - .interrupt = { "vfe_lite" } + .interrupt = { "vfe_lite" }, + .line_num = VFE_LINE_NUM_GEN2, } }; @@ -787,7 +795,8 @@ static const struct resources vfe_res_8250[] = { { 0 }, { 0 } }, .reg = { "vfe0" }, - .interrupt = { "vfe0" } + .interrupt = { "vfe0" }, + .line_num = 4, }, /* VFE1 */ { @@ -805,7 +814,8 @@ static const struct resources vfe_res_8250[] = { { 0 }, { 0 } }, .reg = { "vfe1" }, - .interrupt = { "vfe1" } + .interrupt = { "vfe1" }, + .line_num = 4, }, /* VFE2 (lite) */ { @@ -822,7 +832,8 @@ static const struct resources vfe_res_8250[] = { { 400000000, 480000000 }, { 0 } }, .reg = { "vfe_lite0" }, - .interrupt = { "vfe_lite0" } + .interrupt = { "vfe_lite0" }, + .line_num = 4, }, /* VFE3 (lite) */ { @@ -839,7 +850,8 @@ static const struct resources vfe_res_8250[] = { { 400000000, 480000000 }, { 0 } }, .reg = { "vfe_lite1" }, - .interrupt = { "vfe_lite1" } + .interrupt = { "vfe_lite1" }, + .line_num = 4, }, }; diff --git a/drivers/media/platform/qcom/camss/camss.h b/drivers/media/platform/qcom/camss/camss.h index dd8c58d349685..101ce6e527931 100644 --- a/drivers/media/platform/qcom/camss/camss.h +++ b/drivers/media/platform/qcom/camss/camss.h @@ -48,6 +48,7 @@ struct resources { u32 clock_rate[CAMSS_RES_MAX][CAMSS_RES_MAX]; char *reg[CAMSS_RES_MAX]; char *interrupt[CAMSS_RES_MAX]; + u8 line_num; }; struct icc_bw_tbl { From patchwork Wed Aug 23 10:44:37 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: 716180 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D1D67EE49B0 for ; Wed, 23 Aug 2023 10:45:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234026AbjHWKpJ (ORCPT ); Wed, 23 Aug 2023 06:45:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58156 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234029AbjHWKpG (ORCPT ); Wed, 23 Aug 2023 06:45:06 -0400 Received: from mail-wr1-x42b.google.com (mail-wr1-x42b.google.com [IPv6:2a00:1450:4864:20::42b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3AB96CFE for ; Wed, 23 Aug 2023 03:45:01 -0700 (PDT) Received: by mail-wr1-x42b.google.com with SMTP id ffacd0b85a97d-31427ddd3fbso4838380f8f.0 for ; Wed, 23 Aug 2023 03:45:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1692787499; x=1693392299; 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=8tKoNzN5CncFfvVbG92Xx/lZwuygM9C2OyND5O4Dtxs=; b=TEDzZknJjVS0LY0xouhqlbgCyV1UKWs/EWWyAFWrkQo0vKa7sa4PDDWojDUvih7PTC WCwDdhfgIMxLdtdOoeCtQQa4s64MoqkGOCdXhCUNJpRySuLI3w5Wnynq/6WIDEcV+gj6 u0Wdhwoxr05GutCoC3vtMDwiNcRQBs1b89PvNZgBBHJXmd0TZn381hP0FuWgfBMw+FiW n75JDmpf0jquh8N4TYjYHYo2fbVSUG9QUm3kyZo7hQIAx+cxScOxpZhKw9J7r9MtkKan 8oPmVfffCaQUvjDSuqi+xsXBHDB6j2gYbxElAbtshlWMdf4/hMkU1Uw39qbwzGaGUAJ+ Njng== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692787499; x=1693392299; 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=8tKoNzN5CncFfvVbG92Xx/lZwuygM9C2OyND5O4Dtxs=; b=VvoTPDCtF6/gU08fFTVf+9c+jU4EvISvbhAwPh7ezLiVNS7Mm4/0XBF2oLb1LEtZIT VhNYaFNGIQ49RMBtRSNmYZvS9t0Gym30Vmik2SxnQB4ovEXY6S4I/+FeYtDOQLFR39PV whlMftuqBppyM+/TPf9gonnAxV4BFUXv0m3ZLEejzpnFZ73nqch4vhlWXLq9XL0P1er/ 43329XQvsPeZML57oGsOx5FtYJlMOLuk75ij0XVbZIQNBnOwTz2R1lwBueP0j0Gn9qPP LgtOaZzG0kc9vPxO26Pkptt+Dql/YrMNSeLraFv3n7NMratEpXDcltjr1f0hUFn568wR FBfg== X-Gm-Message-State: AOJu0YyIrS7ezEPrPbg4UqgEWGbAzp+FlPhUabLAdWZy11PjYjptLqX8 fBBTpkyuawEFUazcBRXX+jLuWw== X-Google-Smtp-Source: AGHT+IE9MGitIC2dnpdm810e19wbjxEv5dcPWWWpANyXIgkCuR2BxcWwTrMSmWMocY0T1GNB5cHUdQ== X-Received: by 2002:adf:cd0b:0:b0:31c:3013:9fa5 with SMTP id w11-20020adfcd0b000000b0031c30139fa5mr7830811wrm.59.1692787499519; Wed, 23 Aug 2023 03:44:59 -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 n4-20020a5d4204000000b0031c5dda3aedsm6281213wrq.95.2023.08.23.03.44.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Aug 2023 03:44:58 -0700 (PDT) From: Bryan O'Donoghue To: rfoss@kernel.org, todor.too@gmail.com, bryan.odonoghue@linaro.org, agross@kernel.org, andersson@kernel.org, konrad.dybcio@linaro.org, mchehab@kernel.org, hverkuil-cisco@xs4all.nl, laurent.pinchart@ideasonboard.com, sakari.ailus@linux.intel.com, andrey.konovalov@linaro.org Cc: linux-media@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 08/15] media: qcom: camss: Untangle if/else spaghetti in camss Date: Wed, 23 Aug 2023 11:44:37 +0100 Message-ID: <20230823104444.1954663-9-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230823104444.1954663-1-bryan.odonoghue@linaro.org> References: <20230823104444.1954663-1-bryan.odonoghue@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org I refuse to add another SoC to this convoluted if/else structure. By the time we added in a third SoC we ought to have transitioned these control flow strutures to switches. Adding in another Soc or two will make some of these if statements into five clause behemoths. Introduce switches in the obvious places to despaghetiify. Signed-off-by: Bryan O'Donoghue Acked-by: Konrad Dybcio --- .../media/platform/qcom/camss/camss-csid.c | 16 ++++--- .../media/platform/qcom/camss/camss-csiphy.c | 22 ++++++--- drivers/media/platform/qcom/camss/camss-vfe.c | 45 +++++++++++++------ .../media/platform/qcom/camss/camss-video.c | 16 ++++--- 4 files changed, 68 insertions(+), 31 deletions(-) diff --git a/drivers/media/platform/qcom/camss/camss-csid.c b/drivers/media/platform/qcom/camss/camss-csid.c index fd04ed112b564..5dbbcda5232ac 100644 --- a/drivers/media/platform/qcom/camss/camss-csid.c +++ b/drivers/media/platform/qcom/camss/camss-csid.c @@ -592,15 +592,19 @@ int msm_csid_subdev_init(struct camss *camss, struct csid_device *csid, csid->camss = camss; csid->id = id; - if (camss->res->version == CAMSS_8x16) { + switch (camss->res->version) { + case CAMSS_8x16: csid->ops = &csid_ops_4_1; - } else if (camss->res->version == CAMSS_8x96 || - camss->res->version == CAMSS_660) { + break; + case CAMSS_8x96: + case CAMSS_660: csid->ops = &csid_ops_4_7; - } else if (camss->res->version == CAMSS_845 || - camss->res->version == CAMSS_8250) { + break; + case CAMSS_845: + case CAMSS_8250: csid->ops = &csid_ops_gen2; - } else { + break; + default: return -EINVAL; } csid->ops->subdev_init(csid); diff --git a/drivers/media/platform/qcom/camss/camss-csiphy.c b/drivers/media/platform/qcom/camss/camss-csiphy.c index 593aec5c97bc2..0e8c2a59ea241 100644 --- a/drivers/media/platform/qcom/camss/camss-csiphy.c +++ b/drivers/media/platform/qcom/camss/camss-csiphy.c @@ -557,21 +557,31 @@ int msm_csiphy_subdev_init(struct camss *camss, csiphy->id = id; csiphy->cfg.combo_mode = 0; - if (camss->res->version == CAMSS_8x16) { + switch (camss->res->version) { + case CAMSS_8x16: + { csiphy->ops = &csiphy_ops_2ph_1_0; csiphy->formats = csiphy_formats_8x16; csiphy->nformats = ARRAY_SIZE(csiphy_formats_8x16); - } else if (camss->res->version == CAMSS_8x96 || - camss->res->version == CAMSS_660) { + break; + } + case CAMSS_8x96: + case CAMSS_660: + { csiphy->ops = &csiphy_ops_3ph_1_0; csiphy->formats = csiphy_formats_8x96; csiphy->nformats = ARRAY_SIZE(csiphy_formats_8x96); - } else if (camss->res->version == CAMSS_845 || - camss->res->version == CAMSS_8250) { + break; + } + case CAMSS_845: + case CAMSS_8250: + { csiphy->ops = &csiphy_ops_3ph_1_0; csiphy->formats = csiphy_formats_sdm845; csiphy->nformats = ARRAY_SIZE(csiphy_formats_sdm845); - } else { + break; + } + default: return -EINVAL; } diff --git a/drivers/media/platform/qcom/camss/camss-vfe.c b/drivers/media/platform/qcom/camss/camss-vfe.c index b789b3b2e4cfd..8f48401e31cd3 100644 --- a/drivers/media/platform/qcom/camss/camss-vfe.c +++ b/drivers/media/platform/qcom/camss/camss-vfe.c @@ -170,7 +170,9 @@ static u32 vfe_src_pad_code(struct vfe_line *line, u32 sink_code, { struct vfe_device *vfe = to_vfe(line); - if (vfe->camss->res->version == CAMSS_8x16) + switch (vfe->camss->res->version) { + case CAMSS_8x16: + { switch (sink_code) { case MEDIA_BUS_FMT_YUYV8_1X16: { @@ -218,10 +220,13 @@ static u32 vfe_src_pad_code(struct vfe_line *line, u32 sink_code, return sink_code; } - else if (vfe->camss->res->version == CAMSS_8x96 || - vfe->camss->res->version == CAMSS_660 || - vfe->camss->res->version == CAMSS_845 || - vfe->camss->res->version == CAMSS_8250) + break; + } + case CAMSS_8x96: + case CAMSS_660: + case CAMSS_845: + case CAMSS_8250: + { switch (sink_code) { case MEDIA_BUS_FMT_YUYV8_1X16: { @@ -281,8 +286,12 @@ static u32 vfe_src_pad_code(struct vfe_line *line, u32 sink_code, return sink_code; } - else - return 0; + break; + } + default: + break; + } + return 0; } int vfe_reset(struct vfe_device *vfe) @@ -1397,7 +1406,9 @@ int msm_vfe_subdev_init(struct camss *camss, struct vfe_device *vfe, init_completion(&l->output.sof); init_completion(&l->output.reg_update); - if (camss->res->version == CAMSS_8x16) { + switch (camss->res->version) { + case CAMSS_8x16: + { if (i == VFE_LINE_PIX) { l->formats = formats_pix_8x16; l->nformats = ARRAY_SIZE(formats_pix_8x16); @@ -1405,8 +1416,11 @@ int msm_vfe_subdev_init(struct camss *camss, struct vfe_device *vfe, l->formats = formats_rdi_8x16; l->nformats = ARRAY_SIZE(formats_rdi_8x16); } - } else if (camss->res->version == CAMSS_8x96 || - camss->res->version == CAMSS_660) { + break; + } + case CAMSS_8x96: + case CAMSS_660: + { if (i == VFE_LINE_PIX) { l->formats = formats_pix_8x96; l->nformats = ARRAY_SIZE(formats_pix_8x96); @@ -1414,11 +1428,16 @@ int msm_vfe_subdev_init(struct camss *camss, struct vfe_device *vfe, l->formats = formats_rdi_8x96; l->nformats = ARRAY_SIZE(formats_rdi_8x96); } - } else if (camss->res->version == CAMSS_845 || - camss->res->version == CAMSS_8250) { + break; + } + case CAMSS_845: + case CAMSS_8250: + { l->formats = formats_rdi_845; l->nformats = ARRAY_SIZE(formats_rdi_845); - } else { + break; + } + default: return -EINVAL; } } diff --git a/drivers/media/platform/qcom/camss/camss-video.c b/drivers/media/platform/qcom/camss/camss-video.c index 46a89b5f6c171..e695724437ce1 100644 --- a/drivers/media/platform/qcom/camss/camss-video.c +++ b/drivers/media/platform/qcom/camss/camss-video.c @@ -1006,7 +1006,8 @@ int msm_video_register(struct camss_video *video, struct v4l2_device *v4l2_dev, mutex_init(&video->lock); - if (video->camss->res->version == CAMSS_8x16) { + switch (video->camss->res->version) { + case CAMSS_8x16: if (is_pix) { video->formats = formats_pix_8x16; video->nformats = ARRAY_SIZE(formats_pix_8x16); @@ -1014,8 +1015,9 @@ int msm_video_register(struct camss_video *video, struct v4l2_device *v4l2_dev, video->formats = formats_rdi_8x16; video->nformats = ARRAY_SIZE(formats_rdi_8x16); } - } else if (video->camss->res->version == CAMSS_8x96 || - video->camss->res->version == CAMSS_660) { + break; + case CAMSS_8x96: + case CAMSS_660: if (is_pix) { video->formats = formats_pix_8x96; video->nformats = ARRAY_SIZE(formats_pix_8x96); @@ -1023,11 +1025,13 @@ int msm_video_register(struct camss_video *video, struct v4l2_device *v4l2_dev, video->formats = formats_rdi_8x96; video->nformats = ARRAY_SIZE(formats_rdi_8x96); } - } else if (video->camss->res->version == CAMSS_845 || - video->camss->res->version == CAMSS_8250) { + break; + case CAMSS_845: + case CAMSS_8250: video->formats = formats_rdi_845; video->nformats = ARRAY_SIZE(formats_rdi_845); - } else { + break; + default: ret = -EINVAL; goto error_video_register; } From patchwork Wed Aug 23 10:44:40 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: 716179 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 13AA8EE49B5 for ; Wed, 23 Aug 2023 10:45:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234038AbjHWKpT (ORCPT ); Wed, 23 Aug 2023 06:45:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58000 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234045AbjHWKpL (ORCPT ); Wed, 23 Aug 2023 06:45:11 -0400 Received: from mail-wr1-x42e.google.com (mail-wr1-x42e.google.com [IPv6:2a00:1450:4864:20::42e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DD2D110CE for ; Wed, 23 Aug 2023 03:45:04 -0700 (PDT) Received: by mail-wr1-x42e.google.com with SMTP id ffacd0b85a97d-317f1c480eeso4834287f8f.2 for ; Wed, 23 Aug 2023 03:45:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1692787503; x=1693392303; 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=l9FgIR5BO1ZA/xwnNK7HzsY7163eVVAl221xkKgdSQ4=; b=mhAJonHk82O1JU38yvxq//f+PgwfunLi3MPyMMxfsOJEb0ZCqmh5XBUy/1UdB0f74l cHECz8xH1UvCOEDmrCPDR1+4j+6Dv8cGzofbVMulHAL/aDchojUGnS2wGv60ewN6ao/o D19WNIpawZ8kRgsVpnchBH60LMuZB1MW8kRiWMbZVtC6miQVYEOlbl5SCA5FwwXuSc+x U1c71nCjLDWMoq5qTHSih++bHWPpzAQPba22VtPTSwIBljwVmstxDXWcd2Unh+vGb33E Llag17Zk3cCGLA+LDB94GZw/3kbkEEs/wAEOMqnPYOpWhfGYPPNRK66r+hOPwso9/CmO uIpg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692787503; x=1693392303; 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=l9FgIR5BO1ZA/xwnNK7HzsY7163eVVAl221xkKgdSQ4=; b=fYAqemoswZnzbd+fxWAg4tl7zWEmIUHbqVbHffU130NyVVtIBLpdotDmROC/Ay2rsl bVnkseoAvws+Bpb2k5WkOjNDufbTa6NCb6a3a1iZE6oP0s5158CDl+cVEst3WmHo7tkx YZYFbjk6L+rMYp08JEDmFYoYV9SjGpp4KRsYi2nIBiQjwdIgNSM+wg+zdnVpDGrgNPq+ DIroTzQHeMIn64YTDuaS/g4cWbe/46a8pjUdg7WaCfSAiA2Ag8HfAXO5Z0cDDB+SeV+A eDq+hJODTZE78ZxC1BK8p/WTixDFoPkHVJlovLr2fr6xifY6elsn4Jy6RmSnlPYVNlSh 0SRQ== X-Gm-Message-State: AOJu0Yy3AunHse7KPf4Hx+InlKKaQGqWs4ux2ZhfjHmWU+MsCsfU2Fqq xY5bUAY8uyxkPAVAT9SNNrnHXw== X-Google-Smtp-Source: AGHT+IG1+cvmYpNpk1eoo0KqVXeZN1HIsBfKTqiNgbwKTKafOvOkJR+Y/fxPgNluXdx8pZ5tnLXVHg== X-Received: by 2002:a5d:4fc7:0:b0:314:1b36:f440 with SMTP id h7-20020a5d4fc7000000b003141b36f440mr8428218wrw.70.1692787503323; Wed, 23 Aug 2023 03:45:03 -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 n4-20020a5d4204000000b0031c5dda3aedsm6281213wrq.95.2023.08.23.03.45.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Aug 2023 03:45:02 -0700 (PDT) From: Bryan O'Donoghue To: rfoss@kernel.org, todor.too@gmail.com, bryan.odonoghue@linaro.org, agross@kernel.org, andersson@kernel.org, konrad.dybcio@linaro.org, mchehab@kernel.org, hverkuil-cisco@xs4all.nl, laurent.pinchart@ideasonboard.com, sakari.ailus@linux.intel.com, andrey.konovalov@linaro.org Cc: linux-media@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 11/15] media: qcom: camss: Functionally decompose CSIPHY clock lookups Date: Wed, 23 Aug 2023 11:44:40 +0100 Message-ID: <20230823104444.1954663-12-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230823104444.1954663-1-bryan.odonoghue@linaro.org> References: <20230823104444.1954663-1-bryan.odonoghue@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org 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 0e8c2a59ea241..baf78c525fbfc 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[CAMSS_RES_MAX]; + + 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; @@ -666,19 +675,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; From patchwork Wed Aug 23 10:44:42 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: 716178 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7DF42EE49A0 for ; Wed, 23 Aug 2023 10:45:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234008AbjHWKpo (ORCPT ); Wed, 23 Aug 2023 06:45:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58026 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234049AbjHWKpT (ORCPT ); Wed, 23 Aug 2023 06:45:19 -0400 Received: from mail-wr1-x42f.google.com (mail-wr1-x42f.google.com [IPv6:2a00:1450:4864:20::42f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 428CF10D9 for ; Wed, 23 Aug 2023 03:45:07 -0700 (PDT) Received: by mail-wr1-x42f.google.com with SMTP id ffacd0b85a97d-31427ddd3fbso4838449f8f.0 for ; Wed, 23 Aug 2023 03:45:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1692787505; x=1693392305; 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=TCd7GbPPAXe7wBQWBz5Iyr/diRlD1CNdqcFal/PKyLw=; b=H6uJQcVzryfjYSV6JMb3V1q9wO1vw54u/N7gmajjhKcL+QVvZk+JDoPdCID4huXbbb /jQw9ZuKB23Y92K08ejwK/u9isaH1da4f6lq/thdnSioSj9tVrNEKiKLUeYYeT8NJTrk BZ7KONeHT/gyBg/frz0JQ8KrBo4Wh5/pWbF0753smrJIpK4x86gHK7z0oiXj34e4WF4b HVTkf25A7JZt/0FaiKffvpRcIqR9dDAXvRTE8BDyXTqNwnQS6F8ESJ+0+c9nKvFF/wyH 9hKkA2BaTmE/8+yNEllRRoBwaVmtQIB3dDG/RoAGJPSbSWHQMiNcXXSkxxSlyPOp+PGi 1qdQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692787505; x=1693392305; 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=TCd7GbPPAXe7wBQWBz5Iyr/diRlD1CNdqcFal/PKyLw=; b=XSiW2Z8VGuypvVvdmvRbX53+qPlDjHvXVHJhc6trych8TQLFheTJLTJihwk76QGc9S PKXO/IX/YWf2FXYYlHtyo2AMJxpPu1HgYgZjPmXbkuTxS4byvXACjQNM4SsoDH8FQb8f 80Lgt9H0FtuxCNbK4qfW+yl07VWs8IHB6bvnBuYDQJOukQKyh7tDRAPhDGryJBtb4+/I j6ZEMXtJC+da3drrmDCRkEu9lBJADAMcaEPPmRlIeTRECn09BUjFIi7NlVuOsvg5fR2q uPvYDtPVK/Me8nNrbk2acO1nUAVIMNSqexWpL6/IDvmiyDWsrJG9CZf4FXnclPZfF66h BPbQ== X-Gm-Message-State: AOJu0YzZkGhl4JGndBFOcdqtNP2PmBEk6ca2XVKQ2r3RF+aVH4aE7GPJ FUGWpUBr1Iz9KdecbzZ1VjpT/Q== X-Google-Smtp-Source: AGHT+IHFTgzCRaRfXXW9f0M92PiwFPDTi6wBLNXXA+cBYRX14+FSYG4I4TYBx7jMa0brq4Ir0itlvA== X-Received: by 2002:a5d:678d:0:b0:315:a17d:dbc6 with SMTP id v13-20020a5d678d000000b00315a17ddbc6mr9970701wru.14.1692787505788; Wed, 23 Aug 2023 03:45:05 -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 n4-20020a5d4204000000b0031c5dda3aedsm6281213wrq.95.2023.08.23.03.45.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Aug 2023 03:45:05 -0700 (PDT) From: Bryan O'Donoghue To: rfoss@kernel.org, todor.too@gmail.com, bryan.odonoghue@linaro.org, agross@kernel.org, andersson@kernel.org, konrad.dybcio@linaro.org, mchehab@kernel.org, hverkuil-cisco@xs4all.nl, laurent.pinchart@ideasonboard.com, sakari.ailus@linux.intel.com, andrey.konovalov@linaro.org Cc: linux-media@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 13/15] media: qcom: camss: Support RDI3 for VFE 17x Date: Wed, 23 Aug 2023 11:44:42 +0100 Message-ID: <20230823104444.1954663-14-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230823104444.1954663-1-bryan.odonoghue@linaro.org> References: <20230823104444.1954663-1-bryan.odonoghue@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org Some VFEs have four RDIs apiece. Right now the ISR code has a hard-coded value which tops-out at RDI2 meaning only three RDIs can be utilised in practice. Extend out the various routines in camss-vfe-17x.c to support the higher RDI count. Signed-off-by: Bryan O'Donoghue Acked-by: Konrad Dybcio Reviewed-by: Laurent Pinchart --- drivers/media/platform/qcom/camss/camss-vfe-170.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/drivers/media/platform/qcom/camss/camss-vfe-170.c b/drivers/media/platform/qcom/camss/camss-vfe-170.c index 8aa921400ded0..c2487a8196db7 100644 --- a/drivers/media/platform/qcom/camss/camss-vfe-170.c +++ b/drivers/media/platform/qcom/camss/camss-vfe-170.c @@ -210,7 +210,8 @@ static void vfe_global_reset(struct vfe_device *vfe) GLOBAL_RESET_CMD_IDLE_CGC | GLOBAL_RESET_CMD_RDI0 | GLOBAL_RESET_CMD_RDI1 | - GLOBAL_RESET_CMD_RDI2; + GLOBAL_RESET_CMD_RDI2 | + GLOBAL_RESET_CMD_RDI3; writel_relaxed(BIT(31), vfe->base + VFE_IRQ_MASK_0); @@ -344,7 +345,7 @@ static void vfe_violation_read(struct vfe_device *vfe) static irqreturn_t vfe_isr(int irq, void *dev) { struct vfe_device *vfe = dev; - u32 status0, status1, vfe_bus_status[3]; + u32 status0, status1, vfe_bus_status[VFE_LINE_NUM_MAX]; int i, wm; status0 = readl_relaxed(vfe->base + VFE_IRQ_STATUS_0); @@ -353,7 +354,7 @@ static irqreturn_t vfe_isr(int irq, void *dev) writel_relaxed(status0, vfe->base + VFE_IRQ_CLEAR_0); writel_relaxed(status1, vfe->base + VFE_IRQ_CLEAR_1); - for (i = VFE_LINE_RDI0; i <= VFE_LINE_RDI2; i++) { + for (i = VFE_LINE_RDI0; i < vfe->line_num; i++) { vfe_bus_status[i] = readl_relaxed(vfe->base + VFE_BUS_IRQ_STATUS(i)); writel_relaxed(vfe_bus_status[i], vfe->base + VFE_BUS_IRQ_CLEAR(i)); } @@ -367,11 +368,11 @@ static irqreturn_t vfe_isr(int irq, void *dev) if (status0 & STATUS_0_RESET_ACK) vfe->isr_ops.reset_ack(vfe); - for (i = VFE_LINE_RDI0; i <= VFE_LINE_RDI2; i++) + for (i = VFE_LINE_RDI0; i < vfe->line_num; i++) if (status0 & STATUS_0_RDI_REG_UPDATE(i)) vfe->isr_ops.reg_update(vfe, i); - for (i = VFE_LINE_RDI0; i <= VFE_LINE_RDI2; i++) + for (i = VFE_LINE_RDI0; i < vfe->line_num; i++) if (status0 & STATUS_1_RDI_SOF(i)) vfe->isr_ops.sof(vfe, i); From patchwork Wed Aug 23 10:44:44 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: 716177 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3857AEE49B6 for ; Wed, 23 Aug 2023 10:45:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234065AbjHWKpx (ORCPT ); Wed, 23 Aug 2023 06:45:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59380 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234129AbjHWKpi (ORCPT ); Wed, 23 Aug 2023 06:45:38 -0400 Received: from mail-wm1-x329.google.com (mail-wm1-x329.google.com [IPv6:2a00:1450:4864:20::329]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A8960E6F for ; Wed, 23 Aug 2023 03:45:09 -0700 (PDT) Received: by mail-wm1-x329.google.com with SMTP id 5b1f17b1804b1-3fe12baec61so53897435e9.2 for ; Wed, 23 Aug 2023 03:45:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1692787508; x=1693392308; 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=FIu4eWCkEOSVtI8FoLJRLwwONGivM5mrULXtY5Z5HVI=; b=iR1HQqxeBsupmS+Favm4zTSidm2aT6bx7ajaAl8rBuLII87IivTUcR2VWpznpsDE+R MCfdnWtCmOsEpUaFAl5mFZdQSr8nzotudFoQksQixrFdAXdx+r+oGFa8gWcd6vfaQqsH cVvlFANnHEouAyGGiZvq3xN0gruYNTynKcNGRwn4atmVlAZ8QnqQypDcdx2Qqc2Z0EWz RjY67jKMvacBJSfoIgHgxlCjphiFK106NYNXL14qgECQ67n5RjKd9cLiE7X+L30ngvis eil+bTCkEjRUoc1+IzIpjGuQFZp/chrfKSJ2Q6nrTaVUdpR94GxUzhjg/lx22O4He6hQ rQww== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692787508; x=1693392308; 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=FIu4eWCkEOSVtI8FoLJRLwwONGivM5mrULXtY5Z5HVI=; b=bnYhY6HeXP8ip/WissYJqBhE8xRYVlxVZ1lOiqQy8k5NxzMLO0nzKf7JCXPss9X59X P7dTEx04ZLyU26fVUjvwvQy7pTapvFCcEGOUYULa32sMqU5roUmDGyPdwuwmFisw02A6 FKgOwRjlsR58PWujfYy7cklvV+kO1X/MxOPArnppiB3+0SmaEIeTHxU0hxhG5EQ54YqJ wfXnAN5opgT3rYbnfHscsV+gJeXMxJSbX0dWsDG3tQ5/cCWEAKvGoa4a7eWIddKeVkiC mhzOQHQorwegChxJ946EnLfJvjpLrBEjotoSY4ryRmYcJBYzYK2YIW47fqT6TdRdawLX 3riQ== X-Gm-Message-State: AOJu0YwMw/8nIOPqviLv03zEw+tfeFL4lbpdjlrMbtyKgg5/M/GYe1FT dfwio/lloCP3PZCw8VksS9PZdg== X-Google-Smtp-Source: AGHT+IETgiaFMcrE1JfWFkGdddTyYkNG6PjtSRuCyiFhrM+u1c/VD06R+stwPw8nbB17oeoE3yvOFQ== X-Received: by 2002:a5d:6949:0:b0:319:7471:2965 with SMTP id r9-20020a5d6949000000b0031974712965mr9485144wrw.21.1692787508218; Wed, 23 Aug 2023 03:45:08 -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 n4-20020a5d4204000000b0031c5dda3aedsm6281213wrq.95.2023.08.23.03.45.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Aug 2023 03:45:07 -0700 (PDT) From: Bryan O'Donoghue To: rfoss@kernel.org, todor.too@gmail.com, bryan.odonoghue@linaro.org, agross@kernel.org, andersson@kernel.org, konrad.dybcio@linaro.org, mchehab@kernel.org, hverkuil-cisco@xs4all.nl, laurent.pinchart@ideasonboard.com, sakari.ailus@linux.intel.com, andrey.konovalov@linaro.org Cc: linux-media@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 15/15] media: qcom: camss: Comment CSID dt_id field Date: Wed, 23 Aug 2023 11:44:44 +0100 Message-ID: <20230823104444.1954663-16-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230823104444.1954663-1-bryan.odonoghue@linaro.org> References: <20230823104444.1954663-1-bryan.odonoghue@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org Digging into the documentation we find that the DT_ID bitfield is used to map the six bit DT to a two bit ID code. This value is concatenated to the VC bitfield to create a CID value. DT_ID is the two least significant bits of CID and VC the most significant bits. Originally we set dt_id = vc * 4 in and then subsequently set dt_id = vc. commit 3c4ed72a16bc ("media: camss: sm8250: Virtual channels for CSID") silently fixed the multiplication by four which would give a better value for the generated CID without mentioning what was being done or why. Next up I haplessly changed the value back to "dt_id = vc * 4" since there didn't appear to be any logic behind it. Hans asked what the change was for and I honestly couldn't remember the provenance of it, so I dug in. Link: https://lore.kernel.org/linux-arm-msm/edd4bf9b-0e1b-883c-1a4d-50f4102c3924@xs4all.nl/ Add a comment so the next hapless programmer doesn't make this same mistake. Signed-off-by: Bryan O'Donoghue --- drivers/media/platform/qcom/camss/camss-csid-gen2.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/media/platform/qcom/camss/camss-csid-gen2.c b/drivers/media/platform/qcom/camss/camss-csid-gen2.c index 6ba2b10326444..cee50fc87e9de 100644 --- a/drivers/media/platform/qcom/camss/camss-csid-gen2.c +++ b/drivers/media/platform/qcom/camss/camss-csid-gen2.c @@ -352,6 +352,11 @@ static void __csid_configure_stream(struct csid_device *csid, u8 enable, u8 vc) phy_sel = csid->phy.csiphy_id; if (enable) { + /* + * A value caled 'CID' gets generated internal to CAMSS logic + * which is a concatenation of [vc:6 | dt_id:2] hence we reuse + * the least significant two bits of the VC to 'stuff' the CID value. + */ u8 dt_id = vc; if (tg->enabled) {