From nobody Thu Dec 18 07:53:30 2025 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 A4D7DC25B7B for ; Mon, 14 Aug 2023 15:13:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232968AbjHNPN3 (ORCPT ); Mon, 14 Aug 2023 11:13:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49740 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232771AbjHNPMu (ORCPT ); Mon, 14 Aug 2023 11:12:50 -0400 Received: from mail-wm1-x32e.google.com (mail-wm1-x32e.google.com [IPv6:2a00:1450:4864:20::32e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3FD38E77 for ; Mon, 14 Aug 2023 08:12:49 -0700 (PDT) Received: by mail-wm1-x32e.google.com with SMTP id 5b1f17b1804b1-3fe1d462762so40936025e9.0 for ; Mon, 14 Aug 2023 08:12:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1692025968; x=1692630768; 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=Hy4eJNHbs7lN8Svv9td7HPvAuE4TuSc3ANo+bLeTvvb7h9F24hWhh0KLOurS8lM+st ls7xCrA/G1BjEHgFbdavcMpCbQvW+XFwMjFUBEiQWTf7iicnGcyj5rK4oi+P3L89rS8Q 9phJdAMu6qtx9TpQiSwpjHQr9GgOl+qCmG0gMSIUCaROz4m2R1vybUqum14o+2wsZ8ai Gj1yYaxYc+CX8VihOn6658WAVxLgvNQvROk33j7ocPuKnU5L2/D1QfNukuqhdY4ajsHa AZx4dFl72rVM3KVsiJNN2Y2N46mmzuQcBpsYkjnUAqWh4p9FToeZxE7NJokwwSS6rNEP xcXQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692025968; x=1692630768; 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=XdtamyMBCxewjzzoqaXUOxZ0OORS22BdXM9h8FIv1g11b8GdLwtoBjJduKVNHmH9GC LoRtH8+FqEPrZOZEBMBkJcEYjYLybfaSSoCmXoB+fUoFJCoRECLhMQL6sAnvGlOtw6fO RXe7NbwW00CesajDaqrfaT7d3whTAxSb3Szu7dWKVAiSmaVntvx2EeJbj4F+475wijij 3JGlRcDt4q3F/MzZ9VnY2YGRTsYsIPAaU9D2kjKsn5M/Lkp/O4rdfAs5TzAWsblcKNHA 4h9AwnIF3yvDGSkVhqet+715ud03+rX/68vvl/I1U4XhkT7YiFL+mdFlCHTwUhM4bTeW XSqg== X-Gm-Message-State: AOJu0Yxhz4smekgqBj/0Xil7FahRjjR/xPb1mUtoekj+ZCsFf9isUEIf pV18xm/IkZHKIzhvUTNqnzRBiA== X-Google-Smtp-Source: AGHT+IEQMdoWrRPiCXAdefiZRUGiuHZonSPrmrT9fDgliosmhz1FgcdnjRKHR2WKT5Y/8FbSca+NfA== X-Received: by 2002:a7b:cd02:0:b0:3fe:21b9:806 with SMTP id f2-20020a7bcd02000000b003fe21b90806mr7361061wmj.0.1692025967720; Mon, 14 Aug 2023 08:12:47 -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 17-20020a05600c021100b003fe1c332810sm17644572wmi.33.2023.08.14.08.12.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Aug 2023 08:12:47 -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 v0 01/13] media: qcom: camss: Amalgamate struct resource with struct resource_ispif Date: Mon, 14 Aug 2023 16:12:31 +0100 Message-ID: <20230814151243.3801456-2-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230814151243.3801456-1-bryan.odonoghue@linaro.org> References: <20230814151243.3801456-1-bryan.odonoghue@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" 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 --- 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/medi= a/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 =3D camss->dev; struct ispif_device *ispif =3D camss->ispif; @@ -1152,7 +1152,7 @@ int msm_ispif_subdev_init(struct camss *camss, =20 /* Interrupt */ =20 - ret =3D platform_get_irq_byname(pdev, res->interrupt); + ret =3D platform_get_irq_byname(pdev, res->interrupt[0]); if (ret < 0) return ret; =20 diff --git a/drivers/media/platform/qcom/camss/camss-ispif.h b/drivers/medi= a/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; }; =20 -struct resources_ispif; +struct resources; =20 int msm_ispif_subdev_init(struct camss *camss, - const struct resources_ispif *res); + const struct resources *res); =20 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/plat= form/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[] =3D { }, }; =20 -static const struct resources_ispif ispif_res_8x16 =3D { +static const struct resources ispif_res_8x16 =3D { /* ISPIF */ .clock =3D { "top_ahb", "ahb", "ispif_ahb", "csi0", "csi0_pix", "csi0_rdi", "csi1", "csi1_pix", "csi1_rdi" }, .clock_for_reset =3D { "vfe0", "csi_vfe0" }, .reg =3D { "ispif", "csi_clk_mux" }, - .interrupt =3D "ispif" + .interrupt =3D { "ispif" } =20 }; =20 @@ -234,7 +234,7 @@ static const struct resources csid_res_8x96[] =3D { } }; =20 -static const struct resources_ispif ispif_res_8x96 =3D { +static const struct resources ispif_res_8x96 =3D { /* ISPIF */ .clock =3D { "top_ahb", "ahb", "ispif_ahb", "csi0", "csi0_pix", "csi0_rdi", @@ -243,7 +243,7 @@ static const struct resources_ispif ispif_res_8x96 =3D { "csi3", "csi3_pix", "csi3_rdi" }, .clock_for_reset =3D { "vfe0", "csi_vfe0", "vfe1", "csi_vfe1" }, .reg =3D { "ispif", "csi_clk_mux" }, - .interrupt =3D "ispif" + .interrupt =3D { "ispif" } }; =20 static const struct resources vfe_res_8x96[] =3D { @@ -410,7 +410,7 @@ static const struct resources csid_res_660[] =3D { } }; =20 -static const struct resources_ispif ispif_res_660 =3D { +static const struct resources ispif_res_660 =3D { /* ISPIF */ .clock =3D { "top_ahb", "ahb", "ispif_ahb", "csi0", "csi0_pix", "csi0_rdi", @@ -419,7 +419,7 @@ static const struct resources_ispif ispif_res_660 =3D { "csi3", "csi3_pix", "csi3_rdi" }, .clock_for_reset =3D { "vfe0", "csi_vfe0", "vfe1", "csi_vfe1" }, .reg =3D { "ispif", "csi_clk_mux" }, - .interrupt =3D "ispif" + .interrupt =3D { "ispif" } }; =20 static const struct resources vfe_res_660[] =3D { @@ -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/plat= form/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]; }; =20 -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; --=20 2.41.0 From nobody Thu Dec 18 07:53:30 2025 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 6D0ECC16B13 for ; Mon, 14 Aug 2023 15:13:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232874AbjHNPNT (ORCPT ); Mon, 14 Aug 2023 11:13:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49748 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232777AbjHNPMv (ORCPT ); Mon, 14 Aug 2023 11:12:51 -0400 Received: from mail-wm1-x334.google.com (mail-wm1-x334.google.com [IPv6:2a00:1450:4864:20::334]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 58BD718F for ; Mon, 14 Aug 2023 08:12:50 -0700 (PDT) Received: by mail-wm1-x334.google.com with SMTP id 5b1f17b1804b1-3fea0640d7aso5670905e9.0 for ; Mon, 14 Aug 2023 08:12:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1692025969; x=1692630769; 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=e3guWzZn/6c5CIoZe7iyvq9mt4EnNY7G4PvY6L/0SGU=; b=vR3s4dOl1Lu5ALhgMmPvZzkP0TTEDoGBZjA2cuvSpgS5i8MdaLEjCffnROwuStBZr9 D7DrYzHdQNTKJ0tXzHEwNPyK/mT9eR4aIrUTmtRawCqfkogs2T0+/6KUaUq1UoYb38/G Ag9O8QDfwW49CisDs1AWArqVc7XTQfe3PeMg5ZPpun3NbPqMLCbed5Zw+tFR/spZ+DHJ /Pil94RJnpzRqG1vOdepYKdIin2PPIhT3oUx6NvNmMoERmEpbhoy96Zbf6+il7izGpEQ 8/aFt7NVZrrOPcWECAoLDHbN+W2TPXuInaaknDR1ftW2Lq1PbqmNkhQqsYROK2sjfJDb 0x4Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692025969; x=1692630769; 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=e3guWzZn/6c5CIoZe7iyvq9mt4EnNY7G4PvY6L/0SGU=; b=MrYFxMB0nDsXC2ZCheWDfBUk34SUZymNH/2oDd6eCJa8FUW9uuFXLZ7bWrDvB0wZdn zRj8qK/xyVJBnGFR4VUK2ucmcF6kXYMgV1mTLMPaw4AcQ/ms88Fr8ub5pyXpR6LRE5rw ImXXGtTIyqgQdd2HwTKXEmFljaXYKfnB0OD5Mgrx75Ob7avfAOkZ1/eFLiu2uViUgaYF zChStwZf8Mr/nRIkKhl1JKOn7Ira7NhHANZYiRQ7uu8mQ9/5i2L0ekPc3caeXJcAySaN KdieSoNTJxtZxh4fll+UC9qPADCf/EHXjCx+FGWy6xdJpcb3YkoLdU18MiT1rkFaJe9v zH4w== X-Gm-Message-State: AOJu0YyoRUGeW7OStix/xx1D4QQ+XF/W7f2jVd6hy5o2CuC8FdIB5kef BKsUawxnkMgDcVlFpJusxUkyWQ== X-Google-Smtp-Source: AGHT+IEksEKWVSh/XDnpfwX29OUeaNVkRbq1pFPq73ca7eluZ030PPcdcCygAruOaBN8r476zLzPrg== X-Received: by 2002:a05:600c:217:b0:3fe:34c2:654b with SMTP id 23-20020a05600c021700b003fe34c2654bmr7224177wmi.14.1692025968914; Mon, 14 Aug 2023 08:12:48 -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 17-20020a05600c021100b003fe1c332810sm17644572wmi.33.2023.08.14.08.12.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Aug 2023 08:12:48 -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 v0 02/13] media: qcom: camss: Start to move to module compat matched resources Date: Mon, 14 Aug 2023 16:12:32 +0100 Message-ID: <20230814151243.3801456-3-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230814151243.3801456-1-bryan.odonoghue@linaro.org> References: <20230814151243.3801456-1-bryan.odonoghue@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" There is a lot of unnecessary if/elsing in this code that arguably should never have made it upstream when adding a second let alone subsequent SoC. I'm guilty of not fixing the mess myself when adding in the sm8250. Before adding in any new SoCs or resources lets take the time to cleanup the resource passing. First step is to pass the generic struct camss_resources as a parameter per the compatible list. Subsequent patches will address the other somewhat dispirate strutures which we are also doing if/else on and assigning statically. Signed-off-by: Bryan O'Donoghue --- drivers/media/platform/qcom/camss/camss.c | 93 ++++++++++++----------- drivers/media/platform/qcom/camss/camss.h | 8 ++ 2 files changed, 57 insertions(+), 44 deletions(-) diff --git a/drivers/media/platform/qcom/camss/camss.c b/drivers/media/plat= form/qcom/camss/camss.c index de39dc987444f..d9e1672b74bd7 100644 --- a/drivers/media/platform/qcom/camss/camss.c +++ b/drivers/media/platform/qcom/camss/camss.c @@ -14,6 +14,7 @@ #include #include #include +#include #include #include #include @@ -1120,47 +1121,12 @@ static int camss_of_parse_ports(struct camss *camss) */ static int camss_init_subdevices(struct camss *camss) { - const struct resources *csiphy_res; - const struct resources *csid_res; - const struct resources *ispif_res; - const struct resources *vfe_res; unsigned int i; int ret; =20 - if (camss->version =3D=3D CAMSS_8x16) { - csiphy_res =3D csiphy_res_8x16; - csid_res =3D csid_res_8x16; - ispif_res =3D &ispif_res_8x16; - vfe_res =3D vfe_res_8x16; - } else if (camss->version =3D=3D CAMSS_8x96) { - csiphy_res =3D csiphy_res_8x96; - csid_res =3D csid_res_8x96; - ispif_res =3D &ispif_res_8x96; - vfe_res =3D vfe_res_8x96; - } else if (camss->version =3D=3D CAMSS_660) { - csiphy_res =3D csiphy_res_660; - csid_res =3D csid_res_660; - ispif_res =3D &ispif_res_660; - vfe_res =3D vfe_res_660; - } else if (camss->version =3D=3D CAMSS_845) { - csiphy_res =3D csiphy_res_845; - csid_res =3D csid_res_845; - /* Titan VFEs don't have an ISPIF */ - ispif_res =3D NULL; - vfe_res =3D vfe_res_845; - } else if (camss->version =3D=3D CAMSS_8250) { - csiphy_res =3D csiphy_res_8250; - csid_res =3D csid_res_8250; - /* Titan VFEs don't have an ISPIF */ - ispif_res =3D NULL; - vfe_res =3D vfe_res_8250; - } else { - return -EINVAL; - } - for (i =3D 0; i < camss->csiphy_num; i++) { ret =3D msm_csiphy_subdev_init(camss, &camss->csiphy[i], - &csiphy_res[i], i); + &camss->res->csiphy_res[i], i); if (ret < 0) { dev_err(camss->dev, "Failed to init csiphy%d sub-device: %d\n", @@ -1172,7 +1138,7 @@ static int camss_init_subdevices(struct camss *camss) /* note: SM8250 requires VFE to be initialized before CSID */ for (i =3D 0; i < camss->vfe_num + camss->vfe_lite_num; i++) { ret =3D msm_vfe_subdev_init(camss, &camss->vfe[i], - &vfe_res[i], i); + &camss->res->vfe_res[i], i); if (ret < 0) { dev_err(camss->dev, "Fail to init vfe%d sub-device: %d\n", i, ret); @@ -1182,7 +1148,7 @@ static int camss_init_subdevices(struct camss *camss) =20 for (i =3D 0; i < camss->csid_num; i++) { ret =3D msm_csid_subdev_init(camss, &camss->csid[i], - &csid_res[i], i); + &camss->res->csid_res[i], i); if (ret < 0) { dev_err(camss->dev, "Failed to init csid%d sub-device: %d\n", @@ -1191,7 +1157,7 @@ static int camss_init_subdevices(struct camss *camss) } } =20 - ret =3D msm_ispif_subdev_init(camss, ispif_res); + ret =3D msm_ispif_subdev_init(camss, camss->res->ispif_res); if (ret < 0) { dev_err(camss->dev, "Failed to init ispif sub-device: %d\n", ret); @@ -1554,6 +1520,10 @@ static int camss_probe(struct platform_device *pdev) if (!camss) return -ENOMEM; =20 + camss->res =3D of_device_get_match_data(dev); + if (!camss->res) + return -ENODEV; + atomic_set(&camss->ref_count, 0); camss->dev =3D dev; platform_set_drvdata(pdev, camss); @@ -1735,12 +1705,47 @@ static void camss_remove(struct platform_device *pd= ev) camss_delete(camss); } =20 +static const struct camss_resources msm8916_resources =3D { + .csiphy_res =3D csiphy_res_8x16, + .csid_res =3D csid_res_8x16, + .ispif_res =3D &ispif_res_8x16, + .vfe_res =3D vfe_res_8x16, +}; + +static const struct camss_resources msm8996_resources =3D { + .csiphy_res =3D csiphy_res_8x96, + .csid_res =3D csid_res_8x96, + .ispif_res =3D &ispif_res_8x96, + .vfe_res =3D vfe_res_8x96, +}; + +static const struct camss_resources sdm660_resources =3D { + .csiphy_res =3D csiphy_res_660, + .csid_res =3D csid_res_660, + .ispif_res =3D &ispif_res_660, + .vfe_res =3D vfe_res_660, +}; + +static const struct camss_resources sdm845_resources =3D { + .csiphy_res =3D csiphy_res_845, + .csid_res =3D csid_res_845, + .ispif_res =3D NULL, + .vfe_res =3D vfe_res_845, +}; + +static const struct camss_resources sm8250_resources =3D { + .csiphy_res =3D csiphy_res_8250, + .csid_res =3D csid_res_8250, + .ispif_res =3D NULL, + .vfe_res =3D vfe_res_8250, +}; + static const struct of_device_id camss_dt_match[] =3D { - { .compatible =3D "qcom,msm8916-camss" }, - { .compatible =3D "qcom,msm8996-camss" }, - { .compatible =3D "qcom,sdm660-camss" }, - { .compatible =3D "qcom,sdm845-camss" }, - { .compatible =3D "qcom,sm8250-camss" }, + { .compatible =3D "qcom,msm8916-camss", .data =3D &msm8916_resources }, + { .compatible =3D "qcom,msm8996-camss", .data =3D &msm8996_resources }, + { .compatible =3D "qcom,sdm660-camss", .data =3D &sdm660_resources }, + { .compatible =3D "qcom,sdm845-camss", .data =3D &sdm845_resources }, + { .compatible =3D "qcom,sm8250-camss", .data =3D &sm8250_resources }, { } }; =20 diff --git a/drivers/media/platform/qcom/camss/camss.h b/drivers/media/plat= form/qcom/camss/camss.h index e95211cdb1fd6..f632ee49ad83e 100644 --- a/drivers/media/platform/qcom/camss/camss.h +++ b/drivers/media/platform/qcom/camss/camss.h @@ -79,6 +79,13 @@ enum icc_count { ICC_SM8250_COUNT =3D 4, }; =20 +struct camss_resources { + const struct resources *csiphy_res; + const struct resources *csid_res; + const struct resources *ispif_res; + const struct resources *vfe_res; +}; + struct camss { enum camss_version version; struct v4l2_device v4l2_dev; @@ -99,6 +106,7 @@ struct camss { 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; }; =20 struct camss_camera_interface { --=20 2.41.0 From nobody Thu Dec 18 07:53:30 2025 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 D240DC25B7C for ; Mon, 14 Aug 2023 15:13:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233019AbjHNPNf (ORCPT ); Mon, 14 Aug 2023 11:13:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49794 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232790AbjHNPMx (ORCPT ); Mon, 14 Aug 2023 11:12:53 -0400 Received: from mail-lj1-x22c.google.com (mail-lj1-x22c.google.com [IPv6:2a00:1450:4864:20::22c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 460B8E6A for ; Mon, 14 Aug 2023 08:12:52 -0700 (PDT) Received: by mail-lj1-x22c.google.com with SMTP id 38308e7fff4ca-2b9b5ee9c5aso68809821fa.1 for ; Mon, 14 Aug 2023 08:12:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1692025970; x=1692630770; 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=qqmcrIOgwT4P/m/Qo0pGRwGzeNac3H+8rfjS3Os1OQE=; b=za+f3pRtJG0rthDi5azffRqi/A06+IPasCTBle2NC/Bm/aznOXiFyp9Ig7FB9wMQxW TVlgFlEZtqhAA5Jf4UCYqw7VStHHj0SDJHU1PMjBz3NqVbeAi5KoRuigXQEJupNeVzuD P7/nQ4N+kyQSJNaHr9MxtKXMrxbeC9334qc4rP45XDFQPyrrhQ/pRIbXECzcM0RzHc7R /SSA9W+LVG7KRObt37zdGiO6zrdGI1HyG+avmDmCjyRoBjtgaLhIcXNOauMNYMLYMCkD e4XT2XaPSLloQ5c97fgAkHLpCQiqzU8mp285sjxs/aMrswG+Bul+CF9769pD29lj/5vj wwXw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692025970; x=1692630770; 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=qqmcrIOgwT4P/m/Qo0pGRwGzeNac3H+8rfjS3Os1OQE=; b=bl4j41TLxKkGk16tSQHz6VOyPq+ZMz0o/IHJfumyKcXKRXbKjcO7AT75GrOoShpnAB 7sZQhG+DUCEuPNCH+DuNq6gXmYlkpbiHQVnG/uC8Z3C3aWRmaaHKvLMnesHkqKk9EIvi EelotD9z89m2bKotf9xwk1IWFvU3rCVxZfAmmXkFATvsjDZR2sjfnevWTTkMYvDF+2m1 V9TietaTaq01BSzFef0SeAez1Uu050B/DQgIIC2PcZ1/p/m2CQHw6z7Viij8ccOTmzjq nxn6c0QiJAPyExROB200SjD6MADijBYaIwD7pRoqO/QMty7Om30XkRdNlL2e3SyrF5uo n3vQ== X-Gm-Message-State: AOJu0YyDID30PNEZ6LLHHK8axZiWfzVVHwxsdK6LUWN4Mmab+1O6a7Tm NJVVqTNuHqM5FS5l0TKprDT6TQ== X-Google-Smtp-Source: AGHT+IFP2/JfYkQLXDXM6RMvej5FYQ0Il9A4TqLJszbuZPWvX9l59q1ZFCk4VaLKQg7n15XSrxrKsQ== X-Received: by 2002:a2e:a174:0:b0:2b0:297c:cbdf with SMTP id u20-20020a2ea174000000b002b0297ccbdfmr7452279ljl.1.1692025970497; Mon, 14 Aug 2023 08:12: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 17-20020a05600c021100b003fe1c332810sm17644572wmi.33.2023.08.14.08.12.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Aug 2023 08:12: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 v0 03/13] media: qcom: camss: Drop useless NULL assignment for ispif resources Date: Mon, 14 Aug 2023 16:12:33 +0100 Message-ID: <20230814151243.3801456-4-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230814151243.3801456-1-bryan.odonoghue@linaro.org> References: <20230814151243.3801456-1-bryan.odonoghue@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" The NULL pointer assignement is a redundant step our compiler will initialize unpopulated fields as zero. We check for logical ! later on in the code as opposed to NULL anyway. Signed-off-by: Bryan O'Donoghue --- drivers/media/platform/qcom/camss/camss.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/media/platform/qcom/camss/camss.c b/drivers/media/plat= form/qcom/camss/camss.c index d9e1672b74bd7..68eb45b2c0aaa 100644 --- a/drivers/media/platform/qcom/camss/camss.c +++ b/drivers/media/platform/qcom/camss/camss.c @@ -1729,14 +1729,12 @@ static const struct camss_resources sdm660_resource= s =3D { static const struct camss_resources sdm845_resources =3D { .csiphy_res =3D csiphy_res_845, .csid_res =3D csid_res_845, - .ispif_res =3D NULL, .vfe_res =3D vfe_res_845, }; =20 static const struct camss_resources sm8250_resources =3D { .csiphy_res =3D csiphy_res_8250, .csid_res =3D csid_res_8250, - .ispif_res =3D NULL, .vfe_res =3D vfe_res_8250, }; =20 --=20 2.41.0 From nobody Thu Dec 18 07:53:30 2025 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 94CA2C25B78 for ; Mon, 14 Aug 2023 15:13:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232919AbjHNPN1 (ORCPT ); Mon, 14 Aug 2023 11:13:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49800 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232796AbjHNPMy (ORCPT ); Mon, 14 Aug 2023 11:12:54 -0400 Received: from mail-wm1-x32e.google.com (mail-wm1-x32e.google.com [IPv6:2a00:1450:4864:20::32e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2C5CDE6E for ; Mon, 14 Aug 2023 08:12:53 -0700 (PDT) Received: by mail-wm1-x32e.google.com with SMTP id 5b1f17b1804b1-3fe1e1142caso43992185e9.0 for ; Mon, 14 Aug 2023 08:12:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1692025971; x=1692630771; 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=ocJS1nXGrg9KUDSz6ydfTmzG4q/9Tzxynl3mXG6FazY=; b=VhoDoCLhtMXQbjvsXylJsc8VzXIflgqWEyOBYhB3z14NdZsOEdtFdl0gju0b/pMwtK JIlGy5gVKsOnHp0ZYGYyBL6XKejmeobJ3SZynFOMuAXIo6H79mO2NBARyhYKwKmTVj7H LD1UZDmUxfSWFb2K07PytjgKIAMhz1CaDfK/J75nh2zYwD6CmJm4rNowyU6vmlknuS7r e3/zGHrceyuhKY9UP3DukNu81xGbluhDbIegNJxgldlnRnY4ub9HRzn6aXwRFH2i5GBM E53ApoAHP1p7dJWUXkFdlgqGZuphT8qd8PKbf+xABvOhH0plotYAmNa+p5Iqx4RsaAvc I0HA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692025971; x=1692630771; 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=ocJS1nXGrg9KUDSz6ydfTmzG4q/9Tzxynl3mXG6FazY=; b=bpIotNmJpMb7Kql1OeaNd/3r3OiXzL5YAlWhRD5BmnKBuEVtp7INt+owg5SeDnewdm wWuScT97QR2UmxfjGNM4cAt79VZ3cUuC3k47QHOEKrXODtzv3HeomfHWeIvL4Wqtc82S 4NILRUteP4XxFUyVJQZkffq8ghhbAnGcpOOykJRGtKZzSVNxpFRS1ke9bsD54xNWDq1u JL8owo3AqIrDQ0BiAk6qC+IyE51S51RyEvvTwmnN+yiEZg+BxkWSBzgZ05tH50WhcBrq cf+WKY+B5cNAGBdHHr9rkKSe+9mv4f/2HqDp0DwHAcgQNKX4Tmw1IiQNPdy0w21XHXqv gGUA== X-Gm-Message-State: AOJu0Ywe5WHhmG/ENqTDuos3//moYYfLLPx00qF3qHSN6e+NGONp+dpI lcTQAgndw9OnDxi2LuHicSpOww== X-Google-Smtp-Source: AGHT+IHp0adq2Own21y+ewG89R+AmYf6CoxJPbeODa60h8OfL8WzJ18WT6WiFvnee4adaPrJUO3zbw== X-Received: by 2002:a7b:cc8d:0:b0:3f4:d18f:b2fb with SMTP id p13-20020a7bcc8d000000b003f4d18fb2fbmr7922350wma.8.1692025971785; Mon, 14 Aug 2023 08:12:51 -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 17-20020a05600c021100b003fe1c332810sm17644572wmi.33.2023.08.14.08.12.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Aug 2023 08:12:51 -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 v0 04/13] media: qcom: camss: Pass icc bandwidth table as a platform parameter Date: Mon, 14 Aug 2023 16:12:34 +0100 Message-ID: <20230814151243.3801456-5-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230814151243.3801456-1-bryan.odonoghue@linaro.org> References: <20230814151243.3801456-1-bryan.odonoghue@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Pass the bandwidth table as a platform parameter not if/else derived pointer to the static table. Signed-off-by: Bryan O'Donoghue --- 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/plat= form/qcom/camss/camss.c index 68eb45b2c0aaa..1a195eb4298a5 100644 --- a/drivers/media/platform/qcom/camss/camss.c +++ b/drivers/media/platform/qcom/camss/camss.c @@ -1484,21 +1484,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 =3D 0; int i; =20 - if (camss->version =3D=3D CAMSS_8250) { - icc_res =3D &icc_res_sm8250[0]; - nbr_icc_paths =3D ICC_SM8250_COUNT; - } + icc_res =3D camss->res->icc_res; =20 - for (i =3D 0; i < nbr_icc_paths; i++) { + for (i =3D 0; i < camss->res->icc_path_num; i++) { camss->icc_path[i] =3D 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] =3D icc_res[i].icc_bw_tbl; } =20 return 0; @@ -1736,6 +1730,8 @@ static const struct camss_resources sm8250_resources = =3D { .csiphy_res =3D csiphy_res_8250, .csid_res =3D csid_res_8250, .vfe_res =3D vfe_res_8250, + .icc_res =3D icc_res_sm8250, + .icc_path_num =3D ARRAY_SIZE(icc_res_sm8250), }; =20 static const struct of_device_id camss_dt_match[] =3D { @@ -1752,14 +1748,10 @@ MODULE_DEVICE_TABLE(of, camss_dt_match); static int __maybe_unused camss_runtime_suspend(struct device *dev) { struct camss *camss =3D dev_get_drvdata(dev); - int nbr_icc_paths =3D 0; int i; int ret; =20 - if (camss->version =3D=3D CAMSS_8250) - nbr_icc_paths =3D ICC_SM8250_COUNT; - - for (i =3D 0; i < nbr_icc_paths; i++) { + for (i =3D 0; i < camss->res->icc_path_num; i++) { ret =3D icc_set_bw(camss->icc_path[i], 0, 0); if (ret) return ret; @@ -1771,17 +1763,14 @@ static int __maybe_unused camss_runtime_suspend(str= uct device *dev) static int __maybe_unused camss_runtime_resume(struct device *dev) { struct camss *camss =3D dev_get_drvdata(dev); - int nbr_icc_paths =3D 0; + const struct resources_icc *icc_res =3D camss->res->icc_res; int i; int ret; =20 - if (camss->version =3D=3D CAMSS_8250) - nbr_icc_paths =3D ICC_SM8250_COUNT; - - for (i =3D 0; i < nbr_icc_paths; i++) { + for (i =3D 0; i < camss->res->icc_path_num; i++) { ret =3D 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/plat= form/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; }; =20 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; }; =20 --=20 2.41.0 From nobody Thu Dec 18 07:53:30 2025 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 F0C77C25B7E for ; Mon, 14 Aug 2023 15:13:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233050AbjHNPNi (ORCPT ); Mon, 14 Aug 2023 11:13:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49852 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232809AbjHNPM5 (ORCPT ); Mon, 14 Aug 2023 11:12:57 -0400 Received: from mail-wm1-x333.google.com (mail-wm1-x333.google.com [IPv6:2a00:1450:4864:20::333]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 75C04E6A for ; Mon, 14 Aug 2023 08:12:54 -0700 (PDT) Received: by mail-wm1-x333.google.com with SMTP id 5b1f17b1804b1-3fe5c0e587eso44905905e9.0 for ; Mon, 14 Aug 2023 08:12:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1692025973; x=1692630773; 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=RTUJtl5OV5vaSY5oXQ9x+gljikd5Nnj6tCnfTA4VUtg=; b=pABL5SdcqX5rc/JH5wLzto3pQ7kSSK8d30Y7S4BQIJ7rQojq1kqo48KfMgKEypqHnB xd2YxAX59IW9uunHAHKa87JGK52lM4EkN5mvicRz9fTZ6Eops4qCL8yUFWNlGnoZPkNR WPB1q5l+8lQGyVv8MyGP1XbsO1zjANoV3JdoVXyWwQmZ2WfKZh5sgOo+MpLXwaV6T27+ doaetxOHjvSZwqXSLlFxXY2qckLaNEkDS4Ttnhd9JxxFEY03IF4UzwccKvZKQF39hsMb MfsmzxTSGPCGvh/B1JZiwrfgOpTjkq1NPoXVxo2CD9C2UnWI41MkOjBFvPinH/5XHsFX axAA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692025973; x=1692630773; 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=RTUJtl5OV5vaSY5oXQ9x+gljikd5Nnj6tCnfTA4VUtg=; b=DY1NjsnumIY+SY2JAM8mI/2TuSzeBZUZ/RhUXP5UJTxpnA59t1JzPeUhCUkMEnSH9d xP9YnQ+mCkBOSDVyQZNfd1y1pg4ewEa2z2q0Hfik3ZL61KaGipcgsEw2cXYcRxHj+mUT FeQsGD4+BZ9L8he5i3spRQGtLoqS0cLwdChqPYxEU0wp37bTCasQ5SMoUxE6S5Dd5QiU xSpewddtTdjFnDpug3DH8Ib9d3oLIo7CHGKpls8Ca3Cuz8NhMUHCFIJlaZ1ReHmk2zxC dxIfc1i7R+Tp9lJUqnjVXW3SqJ0p38bfqzm+FKjq/kjBRMobyLgwOkjd5X6RpSLd1CAz /Uww== X-Gm-Message-State: AOJu0YwsKBmq/jiaudOs79hSSngazYjVuyOHFYdJqu2K3rCUY5nBSxgT WPtbkpUHq5C4hxclVA12fJYlJg== X-Google-Smtp-Source: AGHT+IG5/7B52t2QXQG0//IgWJ/f3vZ5Xat8ujz/DZDcaTQJZa9eyB7rRRi8dvPJ8+K7cUm70Lw/yg== X-Received: by 2002:a05:600c:155:b0:3fc:25:ced6 with SMTP id w21-20020a05600c015500b003fc0025ced6mr9187145wmm.13.1692025972945; Mon, 14 Aug 2023 08:12:52 -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 17-20020a05600c021100b003fe1c332810sm17644572wmi.33.2023.08.14.08.12.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Aug 2023 08:12: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 v0 05/13] media: qcom: camss: Pass remainder of variables as resources Date: Mon, 14 Aug 2023 16:12:35 +0100 Message-ID: <20230814151243.3801456-6-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230814151243.3801456-1-bryan.odonoghue@linaro.org> References: <20230814151243.3801456-1-bryan.odonoghue@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" The following variables are being assigned statically based on compatible strings in the probe path. * enum camss_version version; * int csiphy_num; * int csid_num; * int vfe_num; * int vfe_lite_num; * int vfe_total_num; Migrate those variables to resource parameters passed in on platform probe arguments. The one caveat is for VFE it has been necessary to intoduce a new variable vfe_total_num to capture the aggregate value of vfe_num + vfe_lite_num. All the rest of the changes are rote camss->variable to camss->res->variable with the parameter tables now populating the listed variables. Signed-off-by: Bryan O'Donoghue --- .../media/platform/qcom/camss/camss-csid.c | 14 +-- .../qcom/camss/camss-csiphy-3ph-1-0.c | 8 +- .../media/platform/qcom/camss/camss-csiphy.c | 16 +-- .../media/platform/qcom/camss/camss-ispif.c | 28 ++--- .../media/platform/qcom/camss/camss-vfe-170.c | 4 +- .../media/platform/qcom/camss/camss-vfe-480.c | 4 +- drivers/media/platform/qcom/camss/camss-vfe.c | 26 ++-- .../media/platform/qcom/camss/camss-video.c | 10 +- drivers/media/platform/qcom/camss/camss.c | 119 +++++++++--------- drivers/media/platform/qcom/camss/camss.h | 11 +- 10 files changed, 117 insertions(+), 123 deletions(-) diff --git a/drivers/media/platform/qcom/camss/camss-csid.c b/drivers/media= /platform/qcom/camss/camss-csid.c index 9d7fb1adebb98..08991b070bd61 100644 --- a/drivers/media/platform/qcom/camss/camss-csid.c +++ b/drivers/media/platform/qcom/camss/camss-csid.c @@ -159,7 +159,7 @@ static int csid_set_power(struct v4l2_subdev *sd, int o= n) struct camss *camss =3D csid->camss; struct device *dev =3D camss->dev; struct vfe_device *vfe =3D &camss->vfe[csid->id]; - u32 version =3D camss->version; + u32 version =3D camss->res->version; int ret =3D 0; =20 if (on) { @@ -576,13 +576,13 @@ int msm_csid_subdev_init(struct camss *camss, struct = csid_device *csid, csid->camss =3D camss; csid->id =3D id; =20 - if (camss->version =3D=3D CAMSS_8x16) { + if (camss->res->version =3D=3D CAMSS_8x16) { csid->ops =3D &csid_ops_4_1; - } else if (camss->version =3D=3D CAMSS_8x96 || - camss->version =3D=3D CAMSS_660) { + } else if (camss->res->version =3D=3D CAMSS_8x96 || + camss->res->version =3D=3D CAMSS_660) { csid->ops =3D &csid_ops_4_7; - } else if (camss->version =3D=3D CAMSS_845 || - camss->version =3D=3D CAMSS_8250) { + } else if (camss->res->version =3D=3D CAMSS_845 || + camss->res->version =3D=3D CAMSS_8250) { csid->ops =3D &csid_ops_gen2; } else { return -EINVAL; @@ -591,7 +591,7 @@ int msm_csid_subdev_init(struct camss *camss, struct cs= id_device *csid, =20 /* Memory */ =20 - if (camss->version =3D=3D CAMSS_8250) { + if (camss->res->version =3D=3D CAMSS_8250) { /* for titan 480, CSID registers are inside the VFE region, * between the VFE "top" and "bus" registers. this requires * VFE to be initialized before CSID diff --git a/drivers/media/platform/qcom/camss/camss-csiphy-3ph-1-0.c b/dri= vers/media/platform/qcom/camss/camss-csiphy-3ph-1-0.c index 4dba61b8d3f2a..f50e2235c37fc 100644 --- a/drivers/media/platform/qcom/camss/camss-csiphy-3ph-1-0.c +++ b/drivers/media/platform/qcom/camss/camss-csiphy-3ph-1-0.c @@ -402,7 +402,7 @@ static void csiphy_gen1_config_lanes(struct csiphy_devi= ce *csiphy, val =3D CSIPHY_3PH_LNn_CFG1_SWI_REC_DLY_PRG; writel_relaxed(val, csiphy->base + CSIPHY_3PH_LNn_CFG1(l)); =20 - if (csiphy->camss->version =3D=3D CAMSS_660) + if (csiphy->camss->res->version =3D=3D CAMSS_660) val =3D CSIPHY_3PH_LNn_CFG4_T_HS_CLK_MISS_660; else val =3D CSIPHY_3PH_LNn_CFG4_T_HS_CLK_MISS; @@ -419,7 +419,7 @@ static void csiphy_gen2_config_lanes(struct csiphy_devi= ce *csiphy, int i, l, array_size; u32 val; =20 - switch (csiphy->camss->version) { + switch (csiphy->camss->res->version) { case CAMSS_845: r =3D &lane_regs_sdm845[0][0]; array_size =3D ARRAY_SIZE(lane_regs_sdm845[0]); @@ -468,8 +468,8 @@ static void csiphy_lanes_enable(struct csiphy_device *c= siphy, s64 link_freq, u8 lane_mask) { struct csiphy_lanes_cfg *c =3D &cfg->csi2->lane_cfg; - bool is_gen2 =3D (csiphy->camss->version =3D=3D CAMSS_845 || - csiphy->camss->version =3D=3D CAMSS_8250); + bool is_gen2 =3D (csiphy->camss->res->version =3D=3D CAMSS_845 || + csiphy->camss->res->version =3D=3D CAMSS_8250); u8 settle_cnt; u8 val; int i; diff --git a/drivers/media/platform/qcom/camss/camss-csiphy.c b/drivers/med= ia/platform/qcom/camss/camss-csiphy.c index c5ae9c61ee0b1..593aec5c97bc2 100644 --- a/drivers/media/platform/qcom/camss/camss-csiphy.c +++ b/drivers/media/platform/qcom/camss/camss-csiphy.c @@ -557,17 +557,17 @@ int msm_csiphy_subdev_init(struct camss *camss, csiphy->id =3D id; csiphy->cfg.combo_mode =3D 0; =20 - if (camss->version =3D=3D CAMSS_8x16) { + if (camss->res->version =3D=3D CAMSS_8x16) { csiphy->ops =3D &csiphy_ops_2ph_1_0; csiphy->formats =3D csiphy_formats_8x16; csiphy->nformats =3D ARRAY_SIZE(csiphy_formats_8x16); - } else if (camss->version =3D=3D CAMSS_8x96 || - camss->version =3D=3D CAMSS_660) { + } else if (camss->res->version =3D=3D CAMSS_8x96 || + camss->res->version =3D=3D CAMSS_660) { csiphy->ops =3D &csiphy_ops_3ph_1_0; csiphy->formats =3D csiphy_formats_8x96; csiphy->nformats =3D ARRAY_SIZE(csiphy_formats_8x96); - } else if (camss->version =3D=3D CAMSS_845 || - camss->version =3D=3D CAMSS_8250) { + } else if (camss->res->version =3D=3D CAMSS_845 || + camss->res->version =3D=3D CAMSS_8250) { csiphy->ops =3D &csiphy_ops_3ph_1_0; csiphy->formats =3D csiphy_formats_sdm845; csiphy->nformats =3D ARRAY_SIZE(csiphy_formats_sdm845); @@ -581,8 +581,8 @@ int msm_csiphy_subdev_init(struct camss *camss, if (IS_ERR(csiphy->base)) return PTR_ERR(csiphy->base); =20 - if (camss->version =3D=3D CAMSS_8x16 || - camss->version =3D=3D CAMSS_8x96) { + if (camss->res->version =3D=3D CAMSS_8x16 || + camss->res->version =3D=3D CAMSS_8x96) { csiphy->base_clk_mux =3D devm_platform_ioremap_resource_byname(pdev, res->reg[1]); if (IS_ERR(csiphy->base_clk_mux)) @@ -664,7 +664,7 @@ int msm_csiphy_subdev_init(struct camss *camss, !strcmp(clock->name, "csiphy5_timer")) csiphy->rate_set[i] =3D true; =20 - if (camss->version =3D=3D CAMSS_660 && + if (camss->res->version =3D=3D CAMSS_660 && (!strcmp(clock->name, "csi0_phy") || !strcmp(clock->name, "csi1_phy") || !strcmp(clock->name, "csi2_phy"))) diff --git a/drivers/media/platform/qcom/camss/camss-ispif.c b/drivers/medi= a/platform/qcom/camss/camss-ispif.c index 61765b874b9a2..0a58d2cf45007 100644 --- a/drivers/media/platform/qcom/camss/camss-ispif.c +++ b/drivers/media/platform/qcom/camss/camss-ispif.c @@ -270,7 +270,7 @@ static int ispif_vfe_reset(struct ispif_device *ispif, = u8 vfe_id) unsigned long time; u32 val; =20 - if (vfe_id > (camss->vfe_num - 1)) { + if (vfe_id > (camss->res->vfe_num - 1)) { dev_err(camss->dev, "Error: asked reset for invalid VFE%d\n", vfe_id); return -ENOENT; @@ -829,8 +829,8 @@ static int ispif_set_stream(struct v4l2_subdev *sd, int= enable) ispif_select_csid(ispif, intf, csid, vfe, 1); ispif_select_cid(ispif, intf, cid, vfe, 1); ispif_config_irq(ispif, intf, vfe, 1); - if (camss->version =3D=3D CAMSS_8x96 || - camss->version =3D=3D CAMSS_660) + if (camss->res->version =3D=3D CAMSS_8x96 || + camss->res->version =3D=3D CAMSS_660) ispif_config_pack(ispif, line->fmt[MSM_ISPIF_PAD_SINK].code, intf, cid, vfe, 1); @@ -847,8 +847,8 @@ static int ispif_set_stream(struct v4l2_subdev *sd, int= enable) return ret; =20 mutex_lock(&ispif->config_lock); - if (camss->version =3D=3D CAMSS_8x96 || - camss->version =3D=3D CAMSS_660) + if (camss->res->version =3D=3D CAMSS_8x96 || + camss->res->version =3D=3D CAMSS_660) ispif_config_pack(ispif, line->fmt[MSM_ISPIF_PAD_SINK].code, intf, cid, vfe, 0); @@ -1109,10 +1109,10 @@ int msm_ispif_subdev_init(struct camss *camss, ispif->camss =3D camss; =20 /* Number of ISPIF lines - same as number of CSID hardware modules */ - if (camss->version =3D=3D CAMSS_8x16) + if (camss->res->version =3D=3D CAMSS_8x16) ispif->line_num =3D 2; - else if (camss->version =3D=3D CAMSS_8x96 || - camss->version =3D=3D CAMSS_660) + else if (camss->res->version =3D=3D CAMSS_8x96 || + camss->res->version =3D=3D CAMSS_660) ispif->line_num =3D 4; else return -EINVAL; @@ -1126,12 +1126,12 @@ int msm_ispif_subdev_init(struct camss *camss, ispif->line[i].ispif =3D ispif; ispif->line[i].id =3D i; =20 - if (camss->version =3D=3D CAMSS_8x16) { + if (camss->res->version =3D=3D CAMSS_8x16) { ispif->line[i].formats =3D ispif_formats_8x16; ispif->line[i].nformats =3D ARRAY_SIZE(ispif_formats_8x16); - } else if (camss->version =3D=3D CAMSS_8x96 || - camss->version =3D=3D CAMSS_660) { + } else if (camss->res->version =3D=3D CAMSS_8x96 || + camss->res->version =3D=3D CAMSS_660) { ispif->line[i].formats =3D ispif_formats_8x96; ispif->line[i].nformats =3D ARRAY_SIZE(ispif_formats_8x96); @@ -1159,11 +1159,11 @@ int msm_ispif_subdev_init(struct camss *camss, ispif->irq =3D ret; snprintf(ispif->irq_name, sizeof(ispif->irq_name), "%s_%s", dev_name(dev), MSM_ISPIF_NAME); - if (camss->version =3D=3D CAMSS_8x16) + if (camss->res->version =3D=3D CAMSS_8x16) ret =3D devm_request_irq(dev, ispif->irq, ispif_isr_8x16, IRQF_TRIGGER_RISING, ispif->irq_name, ispif); - else if (camss->version =3D=3D CAMSS_8x96 || - camss->version =3D=3D CAMSS_660) + else if (camss->res->version =3D=3D CAMSS_8x96 || + camss->res->version =3D=3D CAMSS_660) ret =3D devm_request_irq(dev, ispif->irq, ispif_isr_8x96, IRQF_TRIGGER_RISING, ispif->irq_name, ispif); else diff --git a/drivers/media/platform/qcom/camss/camss-vfe-170.c b/drivers/me= dia/platform/qcom/camss/camss-vfe-170.c index ae9137633c301..9905bb06b3823 100644 --- a/drivers/media/platform/qcom/camss/camss-vfe-170.c +++ b/drivers/media/platform/qcom/camss/camss-vfe-170.c @@ -676,7 +676,7 @@ static void vfe_pm_domain_off(struct vfe_device *vfe) { struct camss *camss =3D vfe->camss; =20 - if (vfe->id >=3D camss->vfe_num) + if (vfe->id >=3D camss->res->vfe_num) return; =20 device_link_del(camss->genpd_link[vfe->id]); @@ -691,7 +691,7 @@ static int vfe_pm_domain_on(struct vfe_device *vfe) struct camss *camss =3D vfe->camss; enum vfe_line_id id =3D vfe->id; =20 - if (id >=3D camss->vfe_num) + if (id >=3D camss->res->vfe_num) return 0; =20 camss->genpd_link[id] =3D device_link_add(camss->dev, camss->genpd[id], diff --git a/drivers/media/platform/qcom/camss/camss-vfe-480.c b/drivers/me= dia/platform/qcom/camss/camss-vfe-480.c index a64d660abc538..80338efceb9e1 100644 --- a/drivers/media/platform/qcom/camss/camss-vfe-480.c +++ b/drivers/media/platform/qcom/camss/camss-vfe-480.c @@ -502,7 +502,7 @@ static void vfe_pm_domain_off(struct vfe_device *vfe) { struct camss *camss =3D vfe->camss; =20 - if (vfe->id >=3D camss->vfe_num) + if (vfe->id >=3D camss->res->vfe_num) return; =20 device_link_del(camss->genpd_link[vfe->id]); @@ -517,7 +517,7 @@ static int vfe_pm_domain_on(struct vfe_device *vfe) struct camss *camss =3D vfe->camss; enum vfe_line_id id =3D vfe->id; =20 - if (id >=3D camss->vfe_num) + if (id >=3D camss->res->vfe_num) return 0; =20 camss->genpd_link[id] =3D device_link_add(camss->dev, camss->genpd[id], diff --git a/drivers/media/platform/qcom/camss/camss-vfe.c b/drivers/media/= platform/qcom/camss/camss-vfe.c index b021f81cef123..526dd4ab343fe 100644 --- a/drivers/media/platform/qcom/camss/camss-vfe.c +++ b/drivers/media/platform/qcom/camss/camss-vfe.c @@ -170,7 +170,7 @@ static u32 vfe_src_pad_code(struct vfe_line *line, u32 = sink_code, { struct vfe_device *vfe =3D to_vfe(line); =20 - if (vfe->camss->version =3D=3D CAMSS_8x16) + if (vfe->camss->res->version =3D=3D CAMSS_8x16) switch (sink_code) { case MEDIA_BUS_FMT_YUYV8_1X16: { @@ -218,10 +218,10 @@ static u32 vfe_src_pad_code(struct vfe_line *line, u3= 2 sink_code, =20 return sink_code; } - else if (vfe->camss->version =3D=3D CAMSS_8x96 || - vfe->camss->version =3D=3D CAMSS_660 || - vfe->camss->version =3D=3D CAMSS_845 || - vfe->camss->version =3D=3D CAMSS_8250) + else if (vfe->camss->res->version =3D=3D CAMSS_8x96 || + vfe->camss->res->version =3D=3D CAMSS_660 || + vfe->camss->res->version =3D=3D CAMSS_845 || + vfe->camss->res->version =3D=3D CAMSS_8250) switch (sink_code) { case MEDIA_BUS_FMT_YUYV8_1X16: { @@ -1286,7 +1286,7 @@ int msm_vfe_subdev_init(struct camss *camss, struct v= fe_device *vfe, int i, j; int ret; =20 - switch (camss->version) { + switch (camss->res->version) { case CAMSS_8x16: vfe->ops =3D &vfe_ops_4_1; break; @@ -1392,7 +1392,7 @@ int msm_vfe_subdev_init(struct camss *camss, struct v= fe_device *vfe, init_completion(&l->output.sof); init_completion(&l->output.reg_update); =20 - if (camss->version =3D=3D CAMSS_8x16) { + if (camss->res->version =3D=3D CAMSS_8x16) { if (i =3D=3D VFE_LINE_PIX) { l->formats =3D formats_pix_8x16; l->nformats =3D ARRAY_SIZE(formats_pix_8x16); @@ -1400,8 +1400,8 @@ int msm_vfe_subdev_init(struct camss *camss, struct v= fe_device *vfe, l->formats =3D formats_rdi_8x16; l->nformats =3D ARRAY_SIZE(formats_rdi_8x16); } - } else if (camss->version =3D=3D CAMSS_8x96 || - camss->version =3D=3D CAMSS_660) { + } else if (camss->res->version =3D=3D CAMSS_8x96 || + camss->res->version =3D=3D CAMSS_660) { if (i =3D=3D VFE_LINE_PIX) { l->formats =3D formats_pix_8x96; l->nformats =3D ARRAY_SIZE(formats_pix_8x96); @@ -1409,8 +1409,8 @@ int msm_vfe_subdev_init(struct camss *camss, struct v= fe_device *vfe, l->formats =3D formats_rdi_8x96; l->nformats =3D ARRAY_SIZE(formats_rdi_8x96); } - } else if (camss->version =3D=3D CAMSS_845 || - camss->version =3D=3D CAMSS_8250) { + } else if (camss->res->version =3D=3D CAMSS_845 || + camss->res->version =3D=3D CAMSS_8250) { l->formats =3D formats_rdi_845; l->nformats =3D ARRAY_SIZE(formats_rdi_845); } else { @@ -1542,8 +1542,8 @@ int msm_vfe_register_entities(struct vfe_device *vfe, } =20 video_out->ops =3D &vfe->video_ops; - if (vfe->camss->version =3D=3D CAMSS_845 || - vfe->camss->version =3D=3D CAMSS_8250) + if (vfe->camss->res->version =3D=3D CAMSS_845 || + vfe->camss->res->version =3D=3D CAMSS_8250) video_out->bpl_alignment =3D 16; else video_out->bpl_alignment =3D 8; diff --git a/drivers/media/platform/qcom/camss/camss-video.c b/drivers/medi= a/platform/qcom/camss/camss-video.c index 1d686aef92eaf..46a89b5f6c171 100644 --- a/drivers/media/platform/qcom/camss/camss-video.c +++ b/drivers/media/platform/qcom/camss/camss-video.c @@ -1006,7 +1006,7 @@ int msm_video_register(struct camss_video *video, str= uct v4l2_device *v4l2_dev, =20 mutex_init(&video->lock); =20 - if (video->camss->version =3D=3D CAMSS_8x16) { + if (video->camss->res->version =3D=3D CAMSS_8x16) { if (is_pix) { video->formats =3D formats_pix_8x16; video->nformats =3D ARRAY_SIZE(formats_pix_8x16); @@ -1014,8 +1014,8 @@ int msm_video_register(struct camss_video *video, str= uct v4l2_device *v4l2_dev, video->formats =3D formats_rdi_8x16; video->nformats =3D ARRAY_SIZE(formats_rdi_8x16); } - } else if (video->camss->version =3D=3D CAMSS_8x96 || - video->camss->version =3D=3D CAMSS_660) { + } else if (video->camss->res->version =3D=3D CAMSS_8x96 || + video->camss->res->version =3D=3D CAMSS_660) { if (is_pix) { video->formats =3D formats_pix_8x96; video->nformats =3D ARRAY_SIZE(formats_pix_8x96); @@ -1023,8 +1023,8 @@ int msm_video_register(struct camss_video *video, str= uct v4l2_device *v4l2_dev, video->formats =3D formats_rdi_8x96; video->nformats =3D ARRAY_SIZE(formats_rdi_8x96); } - } else if (video->camss->version =3D=3D CAMSS_845 || - video->camss->version =3D=3D CAMSS_8250) { + } else if (video->camss->res->version =3D=3D CAMSS_845 || + video->camss->res->version =3D=3D CAMSS_8250) { video->formats =3D formats_rdi_845; video->nformats =3D ARRAY_SIZE(formats_rdi_845); } else { diff --git a/drivers/media/platform/qcom/camss/camss.c b/drivers/media/plat= form/qcom/camss/camss.c index 1a195eb4298a5..e257559472323 100644 --- a/drivers/media/platform/qcom/camss/camss.c +++ b/drivers/media/platform/qcom/camss/camss.c @@ -1005,7 +1005,7 @@ int camss_pm_domain_on(struct camss *camss, int id) { int ret =3D 0; =20 - if (id < camss->vfe_num) { + if (id < camss->res->vfe_num) { struct vfe_device *vfe =3D &camss->vfe[id]; =20 ret =3D vfe->ops->pm_domain_on(vfe); @@ -1016,7 +1016,7 @@ int camss_pm_domain_on(struct camss *camss, int id) =20 void camss_pm_domain_off(struct camss *camss, int id) { - if (id < camss->vfe_num) { + if (id < camss->res->vfe_num) { struct vfe_device *vfe =3D &camss->vfe[id]; =20 vfe->ops->pm_domain_off(vfe); @@ -1124,7 +1124,7 @@ static int camss_init_subdevices(struct camss *camss) unsigned int i; int ret; =20 - for (i =3D 0; i < camss->csiphy_num; i++) { + for (i =3D 0; i < camss->res->csiphy_num; i++) { ret =3D msm_csiphy_subdev_init(camss, &camss->csiphy[i], &camss->res->csiphy_res[i], i); if (ret < 0) { @@ -1136,7 +1136,7 @@ static int camss_init_subdevices(struct camss *camss) } =20 /* note: SM8250 requires VFE to be initialized before CSID */ - for (i =3D 0; i < camss->vfe_num + camss->vfe_lite_num; i++) { + for (i =3D 0; i < camss->res->vfe_total_num; i++) { ret =3D msm_vfe_subdev_init(camss, &camss->vfe[i], &camss->res->vfe_res[i], i); if (ret < 0) { @@ -1146,7 +1146,7 @@ static int camss_init_subdevices(struct camss *camss) } } =20 - for (i =3D 0; i < camss->csid_num; i++) { + for (i =3D 0; i < camss->res->csid_num; i++) { ret =3D msm_csid_subdev_init(camss, &camss->csid[i], &camss->res->csid_res[i], i); if (ret < 0) { @@ -1178,7 +1178,7 @@ static int camss_register_entities(struct camss *cams= s) int i, j, k; int ret; =20 - for (i =3D 0; i < camss->csiphy_num; i++) { + for (i =3D 0; i < camss->res->csiphy_num; i++) { ret =3D msm_csiphy_register_entity(&camss->csiphy[i], &camss->v4l2_dev); if (ret < 0) { @@ -1189,7 +1189,7 @@ static int camss_register_entities(struct camss *cams= s) } } =20 - for (i =3D 0; i < camss->csid_num; i++) { + for (i =3D 0; i < camss->res->csid_num; i++) { ret =3D msm_csid_register_entity(&camss->csid[i], &camss->v4l2_dev); if (ret < 0) { @@ -1208,7 +1208,7 @@ static int camss_register_entities(struct camss *cams= s) goto err_reg_ispif; } =20 - for (i =3D 0; i < camss->vfe_num + camss->vfe_lite_num; i++) { + for (i =3D 0; i < camss->res->vfe_total_num; i++) { ret =3D msm_vfe_register_entities(&camss->vfe[i], &camss->v4l2_dev); if (ret < 0) { @@ -1219,8 +1219,8 @@ static int camss_register_entities(struct camss *cams= s) } } =20 - for (i =3D 0; i < camss->csiphy_num; i++) { - for (j =3D 0; j < camss->csid_num; j++) { + for (i =3D 0; i < camss->res->csiphy_num; i++) { + for (j =3D 0; j < camss->res->csid_num; j++) { ret =3D media_create_pad_link( &camss->csiphy[i].subdev.entity, MSM_CSIPHY_PAD_SRC, @@ -1239,7 +1239,7 @@ static int camss_register_entities(struct camss *cams= s) } =20 if (camss->ispif) { - for (i =3D 0; i < camss->csid_num; i++) { + for (i =3D 0; i < camss->res->csid_num; i++) { for (j =3D 0; j < camss->ispif->line_num; j++) { ret =3D media_create_pad_link( &camss->csid[i].subdev.entity, @@ -1259,7 +1259,7 @@ static int camss_register_entities(struct camss *cams= s) } =20 for (i =3D 0; i < camss->ispif->line_num; i++) - for (k =3D 0; k < camss->vfe_num; k++) + for (k =3D 0; k < camss->res->vfe_num; k++) for (j =3D 0; j < camss->vfe[k].line_num; j++) { struct v4l2_subdev *ispif =3D &camss->ispif->line[i].subdev; struct v4l2_subdev *vfe =3D &camss->vfe[k].line[j].subdev; @@ -1279,8 +1279,8 @@ static int camss_register_entities(struct camss *cams= s) } } } else { - for (i =3D 0; i < camss->csid_num; i++) - for (k =3D 0; k < camss->vfe_num + camss->vfe_lite_num; k++) + for (i =3D 0; i < camss->res->csid_num; i++) + for (k =3D 0; k < camss->res->vfe_total_num; k++) for (j =3D 0; j < camss->vfe[k].line_num; j++) { struct v4l2_subdev *csid =3D &camss->csid[i].subdev; struct v4l2_subdev *vfe =3D &camss->vfe[k].line[j].subdev; @@ -1304,7 +1304,7 @@ static int camss_register_entities(struct camss *cams= s) return 0; =20 err_link: - i =3D camss->vfe_num + camss->vfe_lite_num; + i =3D camss->res->vfe_total_num; err_reg_vfe: for (i--; i >=3D 0; i--) msm_vfe_unregister_entities(&camss->vfe[i]); @@ -1312,12 +1312,12 @@ static int camss_register_entities(struct camss *ca= mss) err_reg_ispif: msm_ispif_unregister_entities(camss->ispif); =20 - i =3D camss->csid_num; + i =3D camss->res->csid_num; err_reg_csid: for (i--; i >=3D 0; i--) msm_csid_unregister_entity(&camss->csid[i]); =20 - i =3D camss->csiphy_num; + i =3D camss->res->csiphy_num; err_reg_csiphy: for (i--; i >=3D 0; i--) msm_csiphy_unregister_entity(&camss->csiphy[i]); @@ -1335,15 +1335,15 @@ static void camss_unregister_entities(struct camss = *camss) { unsigned int i; =20 - for (i =3D 0; i < camss->csiphy_num; i++) + for (i =3D 0; i < camss->res->csiphy_num; i++) msm_csiphy_unregister_entity(&camss->csiphy[i]); =20 - for (i =3D 0; i < camss->csid_num; i++) + for (i =3D 0; i < camss->res->csid_num; i++) msm_csid_unregister_entity(&camss->csid[i]); =20 msm_ispif_unregister_entities(camss->ispif); =20 - for (i =3D 0; i < camss->vfe_num + camss->vfe_lite_num; i++) + for (i =3D 0; i < camss->res->vfe_total_num; i++) msm_vfe_unregister_entities(&camss->vfe[i]); } =20 @@ -1462,7 +1462,7 @@ static int camss_configure_pd(struct camss *camss) } } =20 - if (i > camss->vfe_num) { + if (i > camss->res->vfe_num) { camss->genpd_link[i - 1] =3D device_link_add(camss->dev, camss->genpd[i = - 1], DL_FLAG_STATELESS | DL_FLAG_PM_RUNTIME | DL_FLAG_RPM_ACTIVE); @@ -1508,7 +1508,8 @@ static int camss_probe(struct platform_device *pdev) { struct device *dev =3D &pdev->dev; struct camss *camss; - int num_subdevs, ret; + int num_subdevs; + int ret; =20 camss =3D devm_kzalloc(dev, sizeof(*camss), GFP_KERNEL); if (!camss) @@ -1522,59 +1523,24 @@ static int camss_probe(struct platform_device *pdev) camss->dev =3D dev; platform_set_drvdata(pdev, camss); =20 - if (of_device_is_compatible(dev->of_node, "qcom,msm8916-camss")) { - camss->version =3D CAMSS_8x16; - camss->csiphy_num =3D 2; - camss->csid_num =3D 2; - camss->vfe_num =3D 1; - } else if (of_device_is_compatible(dev->of_node, - "qcom,msm8996-camss")) { - camss->version =3D CAMSS_8x96; - camss->csiphy_num =3D 3; - camss->csid_num =3D 4; - camss->vfe_num =3D 2; - } else if (of_device_is_compatible(dev->of_node, - "qcom,sdm660-camss")) { - camss->version =3D CAMSS_660; - camss->csiphy_num =3D 3; - camss->csid_num =3D 4; - camss->vfe_num =3D 2; - } else if (of_device_is_compatible(dev->of_node, - "qcom,sdm845-camss")) { - camss->version =3D CAMSS_845; - camss->csiphy_num =3D 4; - camss->csid_num =3D 3; - camss->vfe_num =3D 2; - camss->vfe_lite_num =3D 1; - } else if (of_device_is_compatible(dev->of_node, - "qcom,sm8250-camss")) { - camss->version =3D CAMSS_8250; - camss->csiphy_num =3D 6; - camss->csid_num =3D 4; - camss->vfe_num =3D 2; - camss->vfe_lite_num =3D 2; - } else { - return -EINVAL; - } - - camss->csiphy =3D devm_kcalloc(dev, camss->csiphy_num, + camss->csiphy =3D devm_kcalloc(dev, camss->res->csiphy_num, sizeof(*camss->csiphy), GFP_KERNEL); if (!camss->csiphy) return -ENOMEM; =20 - camss->csid =3D devm_kcalloc(dev, camss->csid_num, sizeof(*camss->csid), + camss->csid =3D devm_kcalloc(dev, camss->res->csid_num, sizeof(*camss->cs= id), GFP_KERNEL); if (!camss->csid) return -ENOMEM; =20 - if (camss->version =3D=3D CAMSS_8x16 || - camss->version =3D=3D CAMSS_8x96) { + if (camss->res->version =3D=3D CAMSS_8x16 || + camss->res->version =3D=3D CAMSS_8x96) { camss->ispif =3D devm_kcalloc(dev, 1, sizeof(*camss->ispif), GFP_KERNEL); if (!camss->ispif) return -ENOMEM; } =20 - camss->vfe =3D devm_kcalloc(dev, camss->vfe_num + camss->vfe_lite_num, + camss->vfe =3D devm_kcalloc(dev, camss->res->vfe_total_num, sizeof(*camss->vfe), GFP_KERNEL); if (!camss->vfe) return -ENOMEM; @@ -1674,7 +1640,7 @@ void camss_delete(struct camss *camss) if (camss->genpd_num =3D=3D 1) return; =20 - if (camss->genpd_num > camss->vfe_num) + if (camss->genpd_num > camss->res->vfe_num) device_link_del(camss->genpd_link[camss->genpd_num - 1]); =20 for (i =3D 0; i < camss->genpd_num; i++) @@ -1700,38 +1666,65 @@ static void camss_remove(struct platform_device *pd= ev) } =20 static const struct camss_resources msm8916_resources =3D { + .version =3D CAMSS_8x16, .csiphy_res =3D csiphy_res_8x16, .csid_res =3D csid_res_8x16, .ispif_res =3D &ispif_res_8x16, .vfe_res =3D vfe_res_8x16, + .csiphy_num =3D ARRAY_SIZE(csiphy_res_8x16), + .csid_num =3D ARRAY_SIZE(csid_res_8x16), + .vfe_num =3D ARRAY_SIZE(vfe_res_8x16), + .vfe_total_num =3D ARRAY_SIZE(vfe_res_8x16), }; =20 static const struct camss_resources msm8996_resources =3D { + .version =3D CAMSS_8x96, .csiphy_res =3D csiphy_res_8x96, .csid_res =3D csid_res_8x96, .ispif_res =3D &ispif_res_8x96, .vfe_res =3D vfe_res_8x96, + .csiphy_num =3D ARRAY_SIZE(csiphy_res_8x96), + .csid_num =3D ARRAY_SIZE(csid_res_8x96), + .vfe_num =3D ARRAY_SIZE(vfe_res_8x96), + .vfe_total_num =3D ARRAY_SIZE(vfe_res_8x96), }; =20 static const struct camss_resources sdm660_resources =3D { + .version =3D CAMSS_660, .csiphy_res =3D csiphy_res_660, .csid_res =3D csid_res_660, .ispif_res =3D &ispif_res_660, .vfe_res =3D vfe_res_660, + .csiphy_num =3D ARRAY_SIZE(csiphy_res_660), + .csid_num =3D ARRAY_SIZE(csid_res_660), + .vfe_num =3D ARRAY_SIZE(vfe_res_660), + .vfe_total_num =3D ARRAY_SIZE(vfe_res_660), }; =20 static const struct camss_resources sdm845_resources =3D { + .version =3D CAMSS_845, .csiphy_res =3D csiphy_res_845, .csid_res =3D csid_res_845, .vfe_res =3D vfe_res_845, + .csiphy_num =3D ARRAY_SIZE(csiphy_res_845), + .csid_num =3D ARRAY_SIZE(csid_res_845), + .vfe_num =3D 2, + .vfe_lite_num =3D 1, + .vfe_total_num =3D 3, }; =20 static const struct camss_resources sm8250_resources =3D { + .version =3D CAMSS_8250, .csiphy_res =3D csiphy_res_8250, .csid_res =3D csid_res_8250, .vfe_res =3D vfe_res_8250, .icc_res =3D icc_res_sm8250, .icc_path_num =3D ARRAY_SIZE(icc_res_sm8250), + .csiphy_num =3D ARRAY_SIZE(csiphy_res_8250), + .csid_num =3D ARRAY_SIZE(csid_res_8250), + .vfe_num =3D 2, + .vfe_lite_num =3D 2, + .vfe_total_num =3D 4, }; =20 static const struct of_device_id camss_dt_match[] =3D { diff --git a/drivers/media/platform/qcom/camss/camss.h b/drivers/media/plat= form/qcom/camss/camss.h index 988c313b63551..dd8c58d349685 100644 --- a/drivers/media/platform/qcom/camss/camss.h +++ b/drivers/media/platform/qcom/camss/camss.h @@ -80,27 +80,28 @@ enum icc_count { }; =20 struct camss_resources { + enum camss_version version; const struct resources *csiphy_res; 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; + int csiphy_num; + int csid_num; + int vfe_num; + int vfe_lite_num; + int vfe_total_num; }; =20 struct camss { - enum camss_version version; struct v4l2_device v4l2_dev; struct v4l2_async_notifier notifier; struct media_device media_dev; struct device *dev; - int csiphy_num; struct csiphy_device *csiphy; - int csid_num; struct csid_device *csid; struct ispif_device *ispif; - int vfe_num; - int vfe_lite_num; struct vfe_device *vfe; atomic_t ref_count; int genpd_num; --=20 2.41.0 From nobody Thu Dec 18 07:53:30 2025 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 C3105C25B7D for ; Mon, 14 Aug 2023 15:13:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233007AbjHNPNd (ORCPT ); Mon, 14 Aug 2023 11:13:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49864 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232820AbjHNPM6 (ORCPT ); Mon, 14 Aug 2023 11:12:58 -0400 Received: from mail-wr1-x430.google.com (mail-wr1-x430.google.com [IPv6:2a00:1450:4864:20::430]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A5FF818F for ; Mon, 14 Aug 2023 08:12:55 -0700 (PDT) Received: by mail-wr1-x430.google.com with SMTP id ffacd0b85a97d-3090d3e9c92so3950908f8f.2 for ; Mon, 14 Aug 2023 08:12:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1692025974; x=1692630774; 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=Pzg3X0plNFdFq8mogDfi/ytxmVpikMwYLKMn9LJIoqc=; b=MhVi/FlgNo4yenOO/AtPh5JerhVPaAI9gqnnhU6+FcfYHR3l+omj5cLpeu0hU7cNyc f+yyQafAF6hxXvNtAAMtn2Ye+bU8in+a2vpVl7BW8rzPL2WU2Pe3z34SiRRbYjLF2fZc MHB8nJPCPdWBrbK/tabnbCJr25MLdcwKACRGErairiKRomM5mXiVnFLKFO7MVA8FDw+0 fiawJrBjquN8Iz68r+z9BFapgUdaHjLQebes9ObDA7GGtmf1sM48uhDy4Je56MZRipY/ Shyo4b7vzTPqaDRVVwjTFgN8AtS83EtWw0RFSTC5h5xRR7SVqcElqMHTeqfM1YA38Cp7 ZIYg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692025974; x=1692630774; 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=Pzg3X0plNFdFq8mogDfi/ytxmVpikMwYLKMn9LJIoqc=; b=MYO4OAQZ8LB2mOC0ktFpiY9LkxkuYc1O3l3rTYcSyouqoAD/rWllHmwy0b65a33FJZ how5KHzPQfCvc3JsNd3K8N1r2CO/RXf7EipfUFOAhMgthIOecipmxO2SjhNzrkqLM0uy 4/PfTq4wguQGluXNyyWJWFHyZDx+xxsBo8RVmsZX6o06w8bSKRg664KtsJ+S9p/KPxGh jstgqCr5C0rrupfeuMcSQWdu5u2JCHPRZZHRS5IsasMvZeS3errpHhNqye9oCOqrmMBG CGqJlGJ63Zuwehd7TeDm22lLDGQr+aHi3XGjf328INU89hIQ5dQOtecsRmODyLVXDVwk 3mqQ== X-Gm-Message-State: AOJu0YypTDuWZyvuHVKmHlzLbNOTH23gnc0guqChWXrkB08/ZOCaj79f o9z4JRuW1tcvdaqwbRh2+C9A/w== X-Google-Smtp-Source: AGHT+IHRMFyeS8BDcJ7h1NuXK6iJITv89ZEh9Iy6Ulwz1N9TJQqU8x5VvIe7U5sZPChqYkpa7bUjnQ== X-Received: by 2002:adf:f252:0:b0:314:3740:7f69 with SMTP id b18-20020adff252000000b0031437407f69mr7728528wrp.37.1692025974234; Mon, 14 Aug 2023 08:12:54 -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 17-20020a05600c021100b003fe1c332810sm17644572wmi.33.2023.08.14.08.12.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Aug 2023 08:12:53 -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 v0 06/13] media: qcom: camss: Pass line_num from compat resources Date: Mon, 14 Aug 2023 16:12:36 +0100 Message-ID: <20230814151243.3801456-7-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230814151243.3801456-1-bryan.odonoghue@linaro.org> References: <20230814151243.3801456-1-bryan.odonoghue@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" 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 =3D 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 --- .../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/me= dia/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 =3D vfe_isr_ops_170; vfe->video_ops =3D vfe_video_ops_170; - - vfe->line_num =3D VFE_LINE_NUM_GEN2; } =20 const struct vfe_hw_ops vfe_ops_170 =3D { diff --git a/drivers/media/platform/qcom/camss/camss-vfe-4-1.c b/drivers/me= dia/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 =3D vfe_isr_ops_gen1; vfe->ops_gen1 =3D &vfe_ops_gen1_4_1; vfe->video_ops =3D vfe_video_ops_gen1; - - vfe->line_num =3D VFE_LINE_NUM_GEN1; } =20 const struct vfe_hw_ops vfe_ops_4_1 =3D { diff --git a/drivers/media/platform/qcom/camss/camss-vfe-4-7.c b/drivers/me= dia/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, struc= t vfe_device *vfe) vfe->isr_ops =3D vfe_isr_ops_gen1; vfe->ops_gen1 =3D &vfe_ops_gen1_4_7; vfe->video_ops =3D vfe_video_ops_gen1; - - vfe->line_num =3D VFE_LINE_NUM_GEN1; } =20 const struct vfe_hw_ops vfe_ops_4_7 =3D { diff --git a/drivers/media/platform/qcom/camss/camss-vfe-4-8.c b/drivers/me= dia/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, struc= t vfe_device *vfe) vfe->isr_ops =3D vfe_isr_ops_gen1; vfe->ops_gen1 =3D &vfe_ops_gen1_4_8; vfe->video_ops =3D vfe_video_ops_gen1; - - vfe->line_num =3D VFE_LINE_NUM_GEN1; } =20 const struct vfe_hw_ops vfe_ops_4_8 =3D { diff --git a/drivers/media/platform/qcom/camss/camss-vfe-480.c b/drivers/me= dia/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 = =3D { static void vfe_subdev_init(struct device *dev, struct vfe_device *vfe) { vfe->video_ops =3D vfe_video_ops_480; - vfe->line_num =3D MAX_VFE_OUTPUT_LINES; } =20 const struct vfe_hw_ops vfe_ops_480 =3D { 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 =3D res->line_num; vfe->ops->subdev_init(dev, vfe); =20 /* Memory */ diff --git a/drivers/media/platform/qcom/camss/camss.c b/drivers/media/plat= form/qcom/camss/camss.c index e257559472323..0e39d123a2113 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[] =3D { { 0 }, { 0 } }, .reg =3D { "vfe0" }, - .interrupt =3D { "vfe0" } + .interrupt =3D { "vfe0" }, + .line_num =3D VFE_LINE_NUM_GEN1, } }; =20 @@ -263,7 +264,8 @@ static const struct resources vfe_res_8x96[] =3D { { 0 }, { 0 } }, .reg =3D { "vfe0" }, - .interrupt =3D { "vfe0" } + .interrupt =3D { "vfe0" }, + .line_num =3D VFE_LINE_NUM_GEN1, }, =20 /* VFE1 */ @@ -281,7 +283,8 @@ static const struct resources vfe_res_8x96[] =3D { { 0 }, { 0 } }, .reg =3D { "vfe1" }, - .interrupt =3D { "vfe1" } + .interrupt =3D { "vfe1" }, + .line_num =3D VFE_LINE_NUM_GEN1, } }; =20 @@ -442,7 +445,8 @@ static const struct resources vfe_res_660[] =3D { { 0 }, { 0 } }, .reg =3D { "vfe0" }, - .interrupt =3D { "vfe0" } + .interrupt =3D { "vfe0" }, + .line_num =3D VFE_LINE_NUM_GEN1, }, =20 /* VFE1 */ @@ -463,7 +467,8 @@ static const struct resources vfe_res_660[] =3D { { 0 }, { 0 } }, .reg =3D { "vfe1" }, - .interrupt =3D { "vfe1" } + .interrupt =3D { "vfe1" }, + .line_num =3D VFE_LINE_NUM_GEN1, } }; =20 @@ -621,7 +626,8 @@ static const struct resources vfe_res_845[] =3D { { 19200000, 75000000, 384000000, 538666667 }, { 384000000 } }, .reg =3D { "vfe0" }, - .interrupt =3D { "vfe0" } + .interrupt =3D { "vfe0" }, + .line_num =3D VFE_LINE_NUM_GEN2, }, =20 /* VFE1 */ @@ -641,7 +647,8 @@ static const struct resources vfe_res_845[] =3D { { 19200000, 75000000, 384000000, 538666667 }, { 384000000 } }, .reg =3D { "vfe1" }, - .interrupt =3D { "vfe1" } + .interrupt =3D { "vfe1" }, + .line_num =3D VFE_LINE_NUM_GEN2, }, =20 /* VFE-lite */ @@ -660,7 +667,8 @@ static const struct resources vfe_res_845[] =3D { { 19200000, 75000000, 384000000, 538666667 }, { 384000000 } }, .reg =3D { "vfe_lite" }, - .interrupt =3D { "vfe_lite" } + .interrupt =3D { "vfe_lite" }, + .line_num =3D VFE_LINE_NUM_GEN2, } }; =20 @@ -787,7 +795,8 @@ static const struct resources vfe_res_8250[] =3D { { 0 }, { 0 } }, .reg =3D { "vfe0" }, - .interrupt =3D { "vfe0" } + .interrupt =3D { "vfe0" }, + .line_num =3D 4, }, /* VFE1 */ { @@ -805,7 +814,8 @@ static const struct resources vfe_res_8250[] =3D { { 0 }, { 0 } }, .reg =3D { "vfe1" }, - .interrupt =3D { "vfe1" } + .interrupt =3D { "vfe1" }, + .line_num =3D 4, }, /* VFE2 (lite) */ { @@ -822,7 +832,8 @@ static const struct resources vfe_res_8250[] =3D { { 400000000, 480000000 }, { 0 } }, .reg =3D { "vfe_lite0" }, - .interrupt =3D { "vfe_lite0" } + .interrupt =3D { "vfe_lite0" }, + .line_num =3D 4, }, /* VFE3 (lite) */ { @@ -839,7 +850,8 @@ static const struct resources vfe_res_8250[] =3D { { 400000000, 480000000 }, { 0 } }, .reg =3D { "vfe_lite1" }, - .interrupt =3D { "vfe_lite1" } + .interrupt =3D { "vfe_lite1" }, + .line_num =3D 4, }, }; =20 diff --git a/drivers/media/platform/qcom/camss/camss.h b/drivers/media/plat= form/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; }; =20 struct icc_bw_tbl { --=20 2.41.0 From nobody Thu Dec 18 07:53:30 2025 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 B2ABFC25B5C for ; Mon, 14 Aug 2023 15:13:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232889AbjHNPNW (ORCPT ); Mon, 14 Aug 2023 11:13:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49920 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232829AbjHNPM6 (ORCPT ); Mon, 14 Aug 2023 11:12:58 -0400 Received: from mail-lf1-x134.google.com (mail-lf1-x134.google.com [IPv6:2a00:1450:4864:20::134]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4C90A10C8 for ; Mon, 14 Aug 2023 08:12:57 -0700 (PDT) Received: by mail-lf1-x134.google.com with SMTP id 2adb3069b0e04-4fe1489ced6so7073537e87.0 for ; Mon, 14 Aug 2023 08:12:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1692025975; x=1692630775; 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=Tu5wgrby+aWezgOUb3gHoMCl+XR0Y7Fji2fknL0oJ5Q=; b=vjcLYDP61hU7VME07h7zl4x07VmWeOyVjlag6OshKhFfj+Ynp2HzTFOLxgiYdzNq4L qiZhrGTRAUN/kZHD8I5cmqsFiUii1xznAPn14I0neq4F1dXhIHBIOkJcptU0VThW4Ram bk/qarbDSx637L+OIQ1wAF3vUVocl+TuA7A0zGv0UJj9y2lA1T2YXUjcqRP54oT6dEpO reJ4SLVg7ZcpbyS+0EOwBDKRXCjTneP+yDwJz60J6tDrawcDa9DowT0W+YfOu28uV6yv CMf8fjTMqDBgl8bs2XqN5/C4t69NnVPBYNKlp2rqRs42ALZYMGrO9OGy51ig7qmU75tV 3uXA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692025975; x=1692630775; 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=Tu5wgrby+aWezgOUb3gHoMCl+XR0Y7Fji2fknL0oJ5Q=; b=ivmwZu8dmrTtMHJ+e6xM/qzbH39qK02x0tEKzYZJvZthbfFcpW3SuC/blQg0cJvVXr OZbO6kML4gTDu6t8jHyVYCgXq6waJg0aK3mO0XyI6uvwGSF7+wXDSWFn9RWnF5wiv1pU ZF9ocHqPGOcxfZyQgjf1SuZqZWe0ANZRiVDAoXI3mRYcDG+wqhs0xNlBSpwus+RTWeaE flzymubGgDJHES4IVyNuMlynrsEJy0w5nMJ+B6BZK1RkoM20DG2EokTTuOjrTnkOhvXY 91FRS3j0CITlNFEW2Kjo+NNCLg1ZYhPZKF0T2pKfM7Mllh1H4/j247JKpm0JbgJuiapZ 0Mrw== X-Gm-Message-State: AOJu0YyB2Ob2hxMK7oUHooGM8x6fMmz8BKVLESNEx3DFYmAQ1s5cnxhQ NOxWNW/fvsLOk7ITPtRoyavXpg== X-Google-Smtp-Source: AGHT+IFZHTTYDCNMVdAnggwH+bH0hlimo9VZAlH0SWZbdqRoddr5Wl4rRJITKc0lO0lzM1X8LMxBmw== X-Received: by 2002:a05:6512:3da0:b0:4f8:71cc:2b6e with SMTP id k32-20020a0565123da000b004f871cc2b6emr8958353lfv.33.1692025975644; Mon, 14 Aug 2023 08:12: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 17-20020a05600c021100b003fe1c332810sm17644572wmi.33.2023.08.14.08.12.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Aug 2023 08:12:54 -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 v0 07/13] media: qcom: camss: Assign the correct number of RDIs per VFE Date: Mon, 14 Aug 2023 16:12:37 +0100 Message-ID: <20230814151243.3801456-8-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230814151243.3801456-1-bryan.odonoghue@linaro.org> References: <20230814151243.3801456-1-bryan.odonoghue@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" 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 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 --- drivers/media/platform/qcom/camss/camss.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/drivers/media/platform/qcom/camss/camss.c b/drivers/media/plat= form/qcom/camss/camss.c index 0e39d123a2113..6114ea15fd4a0 100644 --- a/drivers/media/platform/qcom/camss/camss.c +++ b/drivers/media/platform/qcom/camss/camss.c @@ -124,7 +124,7 @@ static const struct resources vfe_res_8x16[] =3D { { 0 } }, .reg =3D { "vfe0" }, .interrupt =3D { "vfe0" }, - .line_num =3D VFE_LINE_NUM_GEN1, + .line_num =3D 3, } }; =20 @@ -265,7 +265,7 @@ static const struct resources vfe_res_8x96[] =3D { { 0 } }, .reg =3D { "vfe0" }, .interrupt =3D { "vfe0" }, - .line_num =3D VFE_LINE_NUM_GEN1, + .line_num =3D 3, }, =20 /* VFE1 */ @@ -284,7 +284,7 @@ static const struct resources vfe_res_8x96[] =3D { { 0 } }, .reg =3D { "vfe1" }, .interrupt =3D { "vfe1" }, - .line_num =3D VFE_LINE_NUM_GEN1, + .line_num =3D 3, } }; =20 @@ -446,7 +446,7 @@ static const struct resources vfe_res_660[] =3D { { 0 } }, .reg =3D { "vfe0" }, .interrupt =3D { "vfe0" }, - .line_num =3D VFE_LINE_NUM_GEN1, + .line_num =3D 3, }, =20 /* VFE1 */ @@ -468,7 +468,7 @@ static const struct resources vfe_res_660[] =3D { { 0 } }, .reg =3D { "vfe1" }, .interrupt =3D { "vfe1" }, - .line_num =3D VFE_LINE_NUM_GEN1, + .line_num =3D 3, } }; =20 @@ -627,7 +627,7 @@ static const struct resources vfe_res_845[] =3D { { 384000000 } }, .reg =3D { "vfe0" }, .interrupt =3D { "vfe0" }, - .line_num =3D VFE_LINE_NUM_GEN2, + .line_num =3D 4, }, =20 /* VFE1 */ @@ -648,7 +648,7 @@ static const struct resources vfe_res_845[] =3D { { 384000000 } }, .reg =3D { "vfe1" }, .interrupt =3D { "vfe1" }, - .line_num =3D VFE_LINE_NUM_GEN2, + .line_num =3D 4, }, =20 /* VFE-lite */ @@ -668,7 +668,7 @@ static const struct resources vfe_res_845[] =3D { { 384000000 } }, .reg =3D { "vfe_lite" }, .interrupt =3D { "vfe_lite" }, - .line_num =3D VFE_LINE_NUM_GEN2, + .line_num =3D 4, } }; =20 @@ -796,7 +796,7 @@ static const struct resources vfe_res_8250[] =3D { { 0 } }, .reg =3D { "vfe0" }, .interrupt =3D { "vfe0" }, - .line_num =3D 4, + .line_num =3D 3, }, /* VFE1 */ { @@ -815,7 +815,7 @@ static const struct resources vfe_res_8250[] =3D { { 0 } }, .reg =3D { "vfe1" }, .interrupt =3D { "vfe1" }, - .line_num =3D 4, + .line_num =3D 3, }, /* VFE2 (lite) */ { --=20 2.41.0 From nobody Thu Dec 18 07:53:30 2025 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 CE261C07E8C for ; Mon, 14 Aug 2023 15:13:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232840AbjHNPNR (ORCPT ); Mon, 14 Aug 2023 11:13:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33416 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232831AbjHNPM7 (ORCPT ); Mon, 14 Aug 2023 11:12:59 -0400 Received: from mail-lf1-x12b.google.com (mail-lf1-x12b.google.com [IPv6:2a00:1450:4864:20::12b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E65C2DE for ; Mon, 14 Aug 2023 08:12:58 -0700 (PDT) Received: by mail-lf1-x12b.google.com with SMTP id 2adb3069b0e04-4ff1b5c93e7so2570285e87.3 for ; Mon, 14 Aug 2023 08:12:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1692025977; x=1692630777; 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=S0Y9xd+Pad6+mtTQhoMXOE7QF4dtRzmv/Ky6w4Tfu3A=; b=el4m7gi85yGJ2Rs7TYZZykxEmiPkT5ps7mvfAidVWOVRdgmMz3EaltcJ0YaUsPBjk+ NZNPPFITHVpERzencYGVHkuUTOIROl91h0zr6rWdHGJ5o44N/3N4CcCpJQnm2ep+A0V0 fEu1vP0xFNVuK0IT+/RyW92j0QeoAz8FUQGvHKg3+XvX4uQw9SQAkaJh4bNLh7VOfKJK V7hYhVLv4SNFYuBszq3nD3k3DCkeOGN6dQxW+DtsNv+CACal4ZR6rz7r+eLL5wA43Og4 /2f2MuIoTL5BZZgpxgl2eUNEoFlD6klwF83s0ljfCGYYJg7g8Rk03tnzbteameudOj89 wCEg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692025977; x=1692630777; 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=S0Y9xd+Pad6+mtTQhoMXOE7QF4dtRzmv/Ky6w4Tfu3A=; b=KJyt9KTalQApnHfebu/6EMYwWjR1ebpeWVhey1Jkq5aR9KCTdkWr1ifg3ZI1izGbJL reUi+a0FNitJ9oAPGknnzAhYDqocNRc5O2Qd7HKraJkSx+1+qUkkH3tM5hFG01kttD1d /Z/s4rt641awBOG5x7hhkm+uJp9eFVk7Xk3/41t1mEcZDHhcOCn9LuNl8GLvGfHtrF5R h8CuL0YVugP12RREBmnJME0phqqdUBFNOm8QA8xL+Og8nGs8uuOTpY27iJWpspFv5pmT IYDVPX+dS18BdS1ckegD0xl5TsVbYDpFNzdyMrtxTSVUO1jyLQuagni8ZsjSaT/OlRa3 IzoQ== X-Gm-Message-State: AOJu0YwqD6d1KZORVnGGMFXyhatV7gDCYBg3RZbMgf1F6/flGOyeynHc n8FWWkHdntWJvR7ymCymYWvbiw== X-Google-Smtp-Source: AGHT+IHi9E2kY4yI4UvPkkciqTuO4mcOUPSlgi8q7FjbIfZny9L0ie6U+RL7ggWXXjmgsuELBnNYSQ== X-Received: by 2002:a05:6512:3985:b0:4fb:740a:81ae with SMTP id j5-20020a056512398500b004fb740a81aemr8217185lfu.16.1692025977110; Mon, 14 Aug 2023 08:12:57 -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 17-20020a05600c021100b003fe1c332810sm17644572wmi.33.2023.08.14.08.12.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Aug 2023 08:12:56 -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 v0 08/13] media: qcom: camss: Use >= CAMSS_SDM845 for vfe_get/vfe_put Date: Mon, 14 Aug 2023 16:12:38 +0100 Message-ID: <20230814151243.3801456-9-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230814151243.3801456-1-bryan.odonoghue@linaro.org> References: <20230814151243.3801456-1-bryan.odonoghue@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From sdm845 onwards we need to ensure the VFE is powered on prior to switching on the CSID. Alternatively we could model up the GDSCs and clocks the CSID needs without the VFE but, there's a real question of the legitimacy of such a use-case. For now drawing a line at sdm845 and switching on the associated VFEs is a perfectly valid thing to do. Rather than continually extend out this clause for at least two new SoCs with this same model - making the vfe_get/vfe_put path start to look like spaghetti we can simply test for >=3D sdm845 here. Signed-off-by: Bryan O'Donoghue --- drivers/media/platform/qcom/camss/camss-csid.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/media/platform/qcom/camss/camss-csid.c b/drivers/media= /platform/qcom/camss/camss-csid.c index 08991b070bd61..7ff450039ec3f 100644 --- a/drivers/media/platform/qcom/camss/camss-csid.c +++ b/drivers/media/platform/qcom/camss/camss-csid.c @@ -163,7 +163,7 @@ static int csid_set_power(struct v4l2_subdev *sd, int o= n) int ret =3D 0; =20 if (on) { - if (version =3D=3D CAMSS_8250 || version =3D=3D CAMSS_845) { + if (version >=3D CAMSS_845) { ret =3D vfe_get(vfe); if (ret < 0) return ret; @@ -217,7 +217,7 @@ static int csid_set_power(struct v4l2_subdev *sd, int o= n) regulator_bulk_disable(csid->num_supplies, csid->supplies); pm_runtime_put_sync(dev); - if (version =3D=3D CAMSS_8250 || version =3D=3D CAMSS_845) + if (version >=3D CAMSS_845) vfe_put(vfe); } =20 --=20 2.41.0 From nobody Thu Dec 18 07:53:30 2025 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 B413FC25B7A for ; Mon, 14 Aug 2023 15:13:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232990AbjHNPNb (ORCPT ); Mon, 14 Aug 2023 11:13:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33440 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232833AbjHNPNB (ORCPT ); Mon, 14 Aug 2023 11:13:01 -0400 Received: from mail-wm1-x32e.google.com (mail-wm1-x32e.google.com [IPv6:2a00:1450:4864:20::32e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C8109E6A for ; Mon, 14 Aug 2023 08:12:59 -0700 (PDT) Received: by mail-wm1-x32e.google.com with SMTP id 5b1f17b1804b1-3fe2ba3e260so43758675e9.2 for ; Mon, 14 Aug 2023 08:12:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1692025978; x=1692630778; 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=0x4ozwHcR60yAzmxM62laa6YE67TcNzLtskHx94XiuY=; b=NR+tWI2p9tWodyUEqe41Fo/PQntf4NmE6AAZzgycxCiCjRbFceISnPAjipsUgXr7Ip qQQL6ExQMNsD3ZOSrYiPA7PfP2Z6/6AptDdzchRs+47u7mqFvG62C5jFdZccUGCE4Kse Q3zJAop0JeYBnuoTdTnii08VlLK5RZTnU6LnUFcLFqNHpdnh8oqfoFVUx/USn8OyTsxC Ly6uzfe0/d8cTs9ElYXgfrg5i5WiENaciyUaao5lq5mIjnZ5mTtcdcgA81wpJHuCY/LZ C7CYL8p2QtiRZ2iDyg6FznU22ov/zsQRWhYiwTZDiW84XLNNskoHsaRTlsXIncjhrt/a IjfQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692025978; x=1692630778; 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=0x4ozwHcR60yAzmxM62laa6YE67TcNzLtskHx94XiuY=; b=QKRzdFf0EEVcC22XSGCz8wqGVOY6EIwAb/SUlb8qUbm7zJSW4QrtFrYK3gbVxYtNaf 1kzfQPOh7tArPDxI9HjGES91k/9diaciuNfi5w8EUB4/3ZBt2jKI0I+lfjY5uH4qHs4P lDGhbgK0HTAjVuZZTk71CDsF+KhBBX3lt/yLNgY1yFKuDRD09u2FVHHBVxSK3/40roaV 51RTSI2fazyo+dWq/eKTcsBOMRwDuUHYgzzQ3di5StHVWQ6TkoNYh9V+1cDD+BmvNz9s bm9wbWhRD5/CKsRscO9onSrKRAvCvTq+g2fhSlkZ68jvn7qkxUnQPjjChZoDjKIx0n9s JO3Q== X-Gm-Message-State: AOJu0YxuBWQB/MxblhQ3ww+vLN+WYYQioCI3aFpww2R9Pqx9kdESLang BuNgA7l4JVah9CmHBDD2KswGtA== X-Google-Smtp-Source: AGHT+IHKc17lMVbfZKLIgLIlhESVgnyycna/yBLBfnwT5VLrAEXTYqkANqPtJa7ZTa6zi5w5pdD3+A== X-Received: by 2002:a05:600c:2482:b0:3fc:5bcc:a909 with SMTP id 2-20020a05600c248200b003fc5bcca909mr8467105wms.2.1692025978429; Mon, 14 Aug 2023 08:12:58 -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 17-20020a05600c021100b003fe1c332810sm17644572wmi.33.2023.08.14.08.12.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Aug 2023 08:12:57 -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 v0 09/13] media: qcom: camss: Untangle if/else spaghetti in camss Date: Mon, 14 Aug 2023 16:12:39 +0100 Message-ID: <20230814151243.3801456-10-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230814151243.3801456-1-bryan.odonoghue@linaro.org> References: <20230814151243.3801456-1-bryan.odonoghue@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" 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 --- .../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 7ff450039ec3f..9e91d9414bebc 100644 --- a/drivers/media/platform/qcom/camss/camss-csid.c +++ b/drivers/media/platform/qcom/camss/camss-csid.c @@ -576,15 +576,19 @@ int msm_csid_subdev_init(struct camss *camss, struct = csid_device *csid, csid->camss =3D camss; csid->id =3D id; =20 - if (camss->res->version =3D=3D CAMSS_8x16) { + switch (camss->res->version) { + case CAMSS_8x16: csid->ops =3D &csid_ops_4_1; - } else if (camss->res->version =3D=3D CAMSS_8x96 || - camss->res->version =3D=3D CAMSS_660) { + break; + case CAMSS_8x96: + case CAMSS_660: csid->ops =3D &csid_ops_4_7; - } else if (camss->res->version =3D=3D CAMSS_845 || - camss->res->version =3D=3D CAMSS_8250) { + break; + case CAMSS_845: + case CAMSS_8250: csid->ops =3D &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/med= ia/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 =3D id; csiphy->cfg.combo_mode =3D 0; =20 - if (camss->res->version =3D=3D CAMSS_8x16) { + switch (camss->res->version) { + case CAMSS_8x16: + { csiphy->ops =3D &csiphy_ops_2ph_1_0; csiphy->formats =3D csiphy_formats_8x16; csiphy->nformats =3D ARRAY_SIZE(csiphy_formats_8x16); - } else if (camss->res->version =3D=3D CAMSS_8x96 || - camss->res->version =3D=3D CAMSS_660) { + break; + } + case CAMSS_8x96: + case CAMSS_660: + { csiphy->ops =3D &csiphy_ops_3ph_1_0; csiphy->formats =3D csiphy_formats_8x96; csiphy->nformats =3D ARRAY_SIZE(csiphy_formats_8x96); - } else if (camss->res->version =3D=3D CAMSS_845 || - camss->res->version =3D=3D CAMSS_8250) { + break; + } + case CAMSS_845: + case CAMSS_8250: + { csiphy->ops =3D &csiphy_ops_3ph_1_0; csiphy->formats =3D csiphy_formats_sdm845; csiphy->nformats =3D ARRAY_SIZE(csiphy_formats_sdm845); - } else { + break; + } + default: return -EINVAL; } =20 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 =3D to_vfe(line); =20 - if (vfe->camss->res->version =3D=3D 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, u3= 2 sink_code, =20 return sink_code; } - else if (vfe->camss->res->version =3D=3D CAMSS_8x96 || - vfe->camss->res->version =3D=3D CAMSS_660 || - vfe->camss->res->version =3D=3D CAMSS_845 || - vfe->camss->res->version =3D=3D 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, =20 return sink_code; } - else - return 0; + break; + } + default: + break; + } + return 0; } =20 int vfe_reset(struct vfe_device *vfe) @@ -1397,7 +1406,9 @@ int msm_vfe_subdev_init(struct camss *camss, struct v= fe_device *vfe, init_completion(&l->output.sof); init_completion(&l->output.reg_update); =20 - if (camss->res->version =3D=3D CAMSS_8x16) { + switch (camss->res->version) { + case CAMSS_8x16: + { if (i =3D=3D VFE_LINE_PIX) { l->formats =3D formats_pix_8x16; l->nformats =3D ARRAY_SIZE(formats_pix_8x16); @@ -1405,8 +1416,11 @@ int msm_vfe_subdev_init(struct camss *camss, struct = vfe_device *vfe, l->formats =3D formats_rdi_8x16; l->nformats =3D ARRAY_SIZE(formats_rdi_8x16); } - } else if (camss->res->version =3D=3D CAMSS_8x96 || - camss->res->version =3D=3D CAMSS_660) { + break; + } + case CAMSS_8x96: + case CAMSS_660: + { if (i =3D=3D VFE_LINE_PIX) { l->formats =3D formats_pix_8x96; l->nformats =3D ARRAY_SIZE(formats_pix_8x96); @@ -1414,11 +1428,16 @@ int msm_vfe_subdev_init(struct camss *camss, struct= vfe_device *vfe, l->formats =3D formats_rdi_8x96; l->nformats =3D ARRAY_SIZE(formats_rdi_8x96); } - } else if (camss->res->version =3D=3D CAMSS_845 || - camss->res->version =3D=3D CAMSS_8250) { + break; + } + case CAMSS_845: + case CAMSS_8250: + { l->formats =3D formats_rdi_845; l->nformats =3D ARRAY_SIZE(formats_rdi_845); - } else { + break; + } + default: return -EINVAL; } } diff --git a/drivers/media/platform/qcom/camss/camss-video.c b/drivers/medi= a/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, str= uct v4l2_device *v4l2_dev, =20 mutex_init(&video->lock); =20 - if (video->camss->res->version =3D=3D CAMSS_8x16) { + switch (video->camss->res->version) { + case CAMSS_8x16: if (is_pix) { video->formats =3D formats_pix_8x16; video->nformats =3D ARRAY_SIZE(formats_pix_8x16); @@ -1014,8 +1015,9 @@ int msm_video_register(struct camss_video *video, str= uct v4l2_device *v4l2_dev, video->formats =3D formats_rdi_8x16; video->nformats =3D ARRAY_SIZE(formats_rdi_8x16); } - } else if (video->camss->res->version =3D=3D CAMSS_8x96 || - video->camss->res->version =3D=3D CAMSS_660) { + break; + case CAMSS_8x96: + case CAMSS_660: if (is_pix) { video->formats =3D formats_pix_8x96; video->nformats =3D ARRAY_SIZE(formats_pix_8x96); @@ -1023,11 +1025,13 @@ int msm_video_register(struct camss_video *video, s= truct v4l2_device *v4l2_dev, video->formats =3D formats_rdi_8x96; video->nformats =3D ARRAY_SIZE(formats_rdi_8x96); } - } else if (video->camss->res->version =3D=3D CAMSS_845 || - video->camss->res->version =3D=3D CAMSS_8250) { + break; + case CAMSS_845: + case CAMSS_8250: video->formats =3D formats_rdi_845; video->nformats =3D ARRAY_SIZE(formats_rdi_845); - } else { + break; + default: ret =3D -EINVAL; goto error_video_register; } --=20 2.41.0 From nobody Thu Dec 18 07:53:30 2025 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 0B373C27C41 for ; Mon, 14 Aug 2023 15:13:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233075AbjHNPNk (ORCPT ); Mon, 14 Aug 2023 11:13:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33474 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232841AbjHNPNC (ORCPT ); Mon, 14 Aug 2023 11:13:02 -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 35D0F18F for ; Mon, 14 Aug 2023 08:13:01 -0700 (PDT) Received: by mail-wm1-x329.google.com with SMTP id 5b1f17b1804b1-3fe8a1591c7so29650825e9.3 for ; Mon, 14 Aug 2023 08:13:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1692025980; x=1692630780; 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=NIpw90Bh2xViXJnbQ5nWex1TBW8RXK/K06cNQuH8aJM=; b=YV9zqATVNyHz5P3/exF7Cn0JX28gAlvMM72CuTfV8BHK0Ibtxw1jwknqUwc0iI/uCq 3kq3JOSPO8+2vcN1xFrh36knksXI41b6IrPDtgtBa1mEO1EyQI2TKYcKx4zZaZbT2RYB zyudFat6tIz8AW0vfr2ezfY3iMyyNI4L12OYbpSt/KZ9tPb57cKzIldv/pDNp1QAY8Xi hcTOI7lRodeHG4p6YzHmjMIVpGVSJcbuKrcuVy5kDL1A8kuIo6IdRJJpKqq4eoDm3qIX lJ4fv7NmXrpGANBHNCO0RqwIPZUMMF4Rn822BeLCdcw2FrdzzhFz56CbaJimuSWYe+iS cRkQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692025980; x=1692630780; 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=NIpw90Bh2xViXJnbQ5nWex1TBW8RXK/K06cNQuH8aJM=; b=W7AIpqSKluIGIlVenu2XOQLOu2krZ63/yhxlfo2LQtuzcgbEnIpQdzMPo2mQltkcjP 2LHJ958pyMOC4Km8HKAfoU7SvpMVDWe+nqGAW0XwJ2oxKkT3xC1PI1vFbE5W4u4+Rja5 8X+Qc92Qds+O8f22xL145Y4HPdwU4mxi7zX6tua10taSpTOC8u+9qi1pheXWcivfESOD FXhfkTz967jOf2ZVzmWQz2MMzx35wQbJ+kGe74xn2xKl5p8TfsvvbXi2sF+TsO4caudf UWEohsaCIf1x6/cqFJVkSeFElmmahS+fQf6xPgKXC62ZcUgkDvCWkKclnrgwKgNLAJof bqAQ== X-Gm-Message-State: AOJu0Yzdt6CJSxmqK8uqh9ICBeEkpR+UA+s9unfK6w8zNt/yKNtbOQS5 PL4OCYv8SJIUB4CpdTDPVwCJZQ== X-Google-Smtp-Source: AGHT+IHuaU0igsK2MLbRLzabxg5jQKok3Miba00QEZQulLpYfDF15sgVW/HE+BQdwBSSbP1SHyNRrw== X-Received: by 2002:a7b:cd99:0:b0:3fe:63ca:ccf6 with SMTP id y25-20020a7bcd99000000b003fe63caccf6mr7885819wmj.16.1692025979724; Mon, 14 Aug 2023 08:12: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 17-20020a05600c021100b003fe1c332810sm17644572wmi.33.2023.08.14.08.12.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Aug 2023 08:12:59 -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 v0 10/13] media: qcom: camss: Improve error printout on icc_get fail Date: Mon, 14 Aug 2023 16:12:40 +0100 Message-ID: <20230814151243.3801456-11-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230814151243.3801456-1-bryan.odonoghue@linaro.org> References: <20230814151243.3801456-1-bryan.odonoghue@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" If icc_get() fails print the name of the failing path. Signed-off-by: Bryan O'Donoghue --- drivers/media/platform/qcom/camss/camss.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/media/platform/qcom/camss/camss.c b/drivers/media/plat= form/qcom/camss/camss.c index 6114ea15fd4a0..d0f149db908c1 100644 --- a/drivers/media/platform/qcom/camss/camss.c +++ b/drivers/media/platform/qcom/camss/camss.c @@ -1503,8 +1503,11 @@ static int camss_icc_get(struct camss *camss) for (i =3D 0; i < camss->res->icc_path_num; i++) { camss->icc_path[i] =3D devm_of_icc_get(camss->dev, icc_res[i].name); - if (IS_ERR(camss->icc_path[i])) + if (IS_ERR(camss->icc_path[i])) { + dev_err(camss->dev, "Unable to icc_get %s\n", + icc_res[i].name); return PTR_ERR(camss->icc_path[i]); + } } =20 return 0; --=20 2.41.0 From nobody Thu Dec 18 07:53:30 2025 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 6E2B3C04A94 for ; Mon, 14 Aug 2023 15:13:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232912AbjHNPN0 (ORCPT ); Mon, 14 Aug 2023 11:13:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33494 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232846AbjHNPND (ORCPT ); Mon, 14 Aug 2023 11:13:03 -0400 Received: from mail-wm1-x335.google.com (mail-wm1-x335.google.com [IPv6:2a00:1450:4864:20::335]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 69ACAE0 for ; Mon, 14 Aug 2023 08:13:02 -0700 (PDT) Received: by mail-wm1-x335.google.com with SMTP id 5b1f17b1804b1-3fe4cdb724cso41283815e9.1 for ; Mon, 14 Aug 2023 08:13:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1692025981; x=1692630781; 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=rHxvfmBq2wQcZEqJeTw0BxrGFmAlBN3kn0Ir0lpbaw4=; b=fFr7IcU9zLzY9T98mm/BX6HDp6EPfkSf0pa6+HInbwRrBiiNuwg7mKic2vgtpYiu7F AHF6wbKvVCjLnPHFn82VKtOr0mZPq3H4dkk8TzWnEzKLVGP8J+sFqjFPdiiMAXTzMDk7 IWrIfTrw0Q3Pg0aAbBXf7JMRrrsIbCiTdnIisxgPdBwqHZgTrppmfdQPp//z+q+SMPf+ aqUpo6mu52HGqJ7wqqF6o68HQH1wQoC7E2y11b5p33ocUH6Lg2k+MQPOmri3TzLu4EUM f5tUWteos/mXBsjL5Akns2qdyoUKPANSCrhjUe0fqxttcrKb3O/DOO442lkkuHI7QDuE L2fQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692025981; x=1692630781; 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=rHxvfmBq2wQcZEqJeTw0BxrGFmAlBN3kn0Ir0lpbaw4=; b=eWEL+vmfQFRhNtQB5mXYFYjUXnivIhXojSSZJLOf3vPTaGjBeZ0KKtrjY+z8WWMh5g Lpd5H5+6IbniuXKh+evv1OSCpyz46Sm+/C7zy0KCavseexcqoXOEDNUTI+buwMsyC1OT fJZDkxsgdD+ifk4N8lBlz+5JZmv9wbgOvVzvg8nacsz+gwYXCZcqgoCm4i55vZOwwZ5P F2VWCtoprwdkIvBetycc0GmE1aL06bm1WLIgA/0T+9HhdaK13EQW5Vorhlg+PY2VLWu2 7xZXDs5Eg/LZxEhfZ2kH3MPZp7jN4lyVuQURfg7faOS2NtygngJ6bf1KzMJPEf0cdn3h 72xg== X-Gm-Message-State: AOJu0YyIsN7HuBzf6UVNpoNWKmytfkgcKWYNzcx9SxPjnr8oaorngpLW BrQPj5Z7r8Yjnz7zwjJD13IuMw== X-Google-Smtp-Source: AGHT+IEjFG0DujsHM87qHijilhHZRGP0bl7W5DcJIBGkrJ8/GOZB/NfMGN2iEl0sAhH7Fd/jEeNlQw== X-Received: by 2002:a05:600c:3789:b0:3fe:1c11:7788 with SMTP id o9-20020a05600c378900b003fe1c117788mr8121542wmr.33.1692025980951; Mon, 14 Aug 2023 08:13:00 -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 17-20020a05600c021100b003fe1c332810sm17644572wmi.33.2023.08.14.08.12.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Aug 2023 08:13:00 -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 v0 11/13] media: qcom: camss: Allow clocks vfeN vfe_liteN or vfe_lite Date: Mon, 14 Aug 2023 16:12:41 +0100 Message-ID: <20230814151243.3801456-12-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230814151243.3801456-1-bryan.odonoghue@linaro.org> References: <20230814151243.3801456-1-bryan.odonoghue@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" The number of Video Front End - VFE or Image Front End - IFE supported with new SoCs can vary both for the full and lite cases. For example sdm845 has one vfe_lite and two vfe interfaces with the vfe clock called simply "vfe_lite" with no integer postfix. sc8280xp has four vfe and four vfe lite blocks. We need to support the following clock name formats - vfeN - vfe_liteN - vfe_lite with N being any reasonably sized integer. There are two sites in this code which need to do the same thing, constructing and matching strings with the pattern above, so encapsulate the logic in one function. Signed-off-by: Bryan O'Donoghue --- drivers/media/platform/qcom/camss/camss-vfe.c | 22 ++++++++++++++----- 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/drivers/media/platform/qcom/camss/camss-vfe.c b/drivers/media/= platform/qcom/camss/camss-vfe.c index 8f48401e31cd3..73380e75dbb22 100644 --- a/drivers/media/platform/qcom/camss/camss-vfe.c +++ b/drivers/media/platform/qcom/camss/camss-vfe.c @@ -437,6 +437,20 @@ void vfe_isr_reset_ack(struct vfe_device *vfe) complete(&vfe->reset_complete); } =20 +static int vfe_match_clock_names(struct vfe_device *vfe, + struct camss_clock *clock) +{ + char vfe_name[CAMSS_RES_MAX]; + char vfe_lite_name[CAMSS_RES_MAX]; + + snprintf(vfe_name, sizeof(vfe_name), "vfe%d", vfe->id); + snprintf(vfe_lite_name, sizeof(vfe_lite_name), "vfe_lite%d", vfe->id); + + return (!strcmp(clock->name, vfe_name) || + !strcmp(clock->name, vfe_lite_name) || + !strcmp(clock->name, "vfe_lite")); +} + /* * vfe_set_clock_rates - Calculate and set clock rates on VFE module * @vfe: VFE device @@ -460,9 +474,7 @@ static int vfe_set_clock_rates(struct vfe_device *vfe) for (i =3D 0; i < vfe->nclocks; i++) { struct camss_clock *clock =3D &vfe->clock[i]; =20 - if (!strcmp(clock->name, "vfe0") || - !strcmp(clock->name, "vfe1") || - !strcmp(clock->name, "vfe_lite")) { + if (vfe_match_clock_names(vfe, clock)) { u64 min_rate =3D 0; long rate; =20 @@ -543,9 +555,7 @@ static int vfe_check_clock_rates(struct vfe_device *vfe) for (i =3D 0; i < vfe->nclocks; i++) { struct camss_clock *clock =3D &vfe->clock[i]; =20 - if (!strcmp(clock->name, "vfe0") || - !strcmp(clock->name, "vfe1") || - !strcmp(clock->name, "vfe_lite")) { + if (vfe_match_clock_names(vfe, clock)) { u64 min_rate =3D 0; unsigned long rate; =20 --=20 2.41.0 From nobody Thu Dec 18 07:53:30 2025 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 1F8DAC27C43 for ; Mon, 14 Aug 2023 15:13:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233082AbjHNPNk (ORCPT ); Mon, 14 Aug 2023 11:13:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33522 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232849AbjHNPNE (ORCPT ); Mon, 14 Aug 2023 11:13:04 -0400 Received: from mail-wm1-x335.google.com (mail-wm1-x335.google.com [IPv6:2a00:1450:4864:20::335]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7B933E73 for ; Mon, 14 Aug 2023 08:13:03 -0700 (PDT) Received: by mail-wm1-x335.google.com with SMTP id 5b1f17b1804b1-3fe426b86a8so41175005e9.3 for ; Mon, 14 Aug 2023 08:13:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1692025982; x=1692630782; 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=d0XKVdJROqHz64+NzKJLv7ggTEC2T+UUELAWm3vTRWRRy8kJg11ZFS0JtVl1zgayDp sA0odmDqueyJDOWDdBSHrUPHwE7E/Zbp3HTYEMco70aIsOZCWHpP049PkPErFWpb7MUq hb6hokJjzkswJHDnoCRhe5vuwMF7Z+g1z44hgphVPVrLRKkKP6XzR9gv4Pl8zMInXL5H ST8IkGgQgzoygYMYdpHcWIRI8Q75+5XXcWghCP2K3HhKlBvg0Mkf7+WUNE9uRUiLL07W 2t20Eq+CdotBHtdcXtD+FJlh59yWtHb0SxMWHULeWtKBWDB+Hl3M3Ss5WILbfm6jlK4X CRQQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692025982; x=1692630782; 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=dJ7MyV+ZERdQMemEbwsPROYm26rWlh6YajWZ7CPev0LrRB7L+SXFg72W3ezTUgDak2 S2FjMnEDttw7T7urcuIKEMs79pQr7e4IhSKaTbUQvAr18AWsVCVHiC2k9ANAPp/4UHqf CTo6gfKi/XeWSPS3DkZunlhL6ytZ4hhpR9Tzu196llpLq7pFNsVRfIorrLJT+Ngl19Ok BWo3XxbbwB/XhQPyyvTdm2c1FLBzWJ+P07zUEs88f5XV9HoJx1EtXH6vj/Ue1DuVYvPd RNk+auXfXhUIAipg+W6dj6KiGuyuQA/oAnHzSW5t1RSZ9HY2VWeGiAUq8xwoxPXOdUW8 WdFw== X-Gm-Message-State: AOJu0YyrGeEcyjIhk2Nc63wTcEig2DrIZJqEqBf165+4yidcDWQo8CYD T///CNwjV4Akt+UYqVA+X3aZ8Q== X-Google-Smtp-Source: AGHT+IEZBO9hVdh7hDE9krFngD5XL9CpRlHhZ/LJA0vyApYOQ66jxhoBJOhZVYsBQSVGRvoV2LmJSw== X-Received: by 2002:a05:600c:2990:b0:3fe:485f:ed13 with SMTP id r16-20020a05600c299000b003fe485fed13mr8031524wmd.29.1692025982131; Mon, 14 Aug 2023 08:13:02 -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 17-20020a05600c021100b003fe1c332810sm17644572wmi.33.2023.08.14.08.13.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Aug 2023 08:13:01 -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 v0 12/13] media: qcom: camss: Functionally decompose CSIPHY clock lookups Date: Mon, 14 Aug 2023 16:12:42 +0100 Message-ID: <20230814151243.3801456-13-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230814151243.3801456-1-bryan.odonoghue@linaro.org> References: <20230814151243.3801456-1-bryan.odonoghue@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" 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/med= ia/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); } =20 +static bool csiphy_match_clock_name(const char *clock_name, const char *fo= rmat, + 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 resourc= es * @csiphy: CSIPHY device @@ -550,7 +559,7 @@ int msm_csiphy_subdev_init(struct camss *camss, { struct device *dev =3D camss->dev; struct platform_device *pdev =3D to_platform_device(dev); - int i, j; + int i, j, k; int ret; =20 csiphy->camss =3D camss; @@ -666,19 +675,19 @@ int msm_csiphy_subdev_init(struct camss *camss, for (j =3D 0; j < clock->nfreqs; j++) clock->freq[j] =3D res->clock_rate[i][j]; =20 - 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] =3D true; - - if (camss->res->version =3D=3D CAMSS_660 && - (!strcmp(clock->name, "csi0_phy") || - !strcmp(clock->name, "csi1_phy") || - !strcmp(clock->name, "csi2_phy"))) - csiphy->rate_set[i] =3D true; + for (k =3D 0; k < camss->res->csiphy_num; k++) { + csiphy->rate_set[i] =3D csiphy_match_clock_name(clock->name, + "csiphy%d_timer", k); + if (csiphy->rate_set[i]) + break; + + if (camss->res->version =3D=3D CAMSS_660) { + csiphy->rate_set[i] =3D csiphy_match_clock_name(clock->name, + "csi%d_phy", k); + if (csiphy->rate_set[i]) + break; + } + } } =20 return 0; --=20 2.41.0 From nobody Thu Dec 18 07:53:30 2025 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 E1A3BC25B7F for ; Mon, 14 Aug 2023 15:13:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233040AbjHNPNh (ORCPT ); Mon, 14 Aug 2023 11:13:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33554 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232856AbjHNPNG (ORCPT ); Mon, 14 Aug 2023 11:13:06 -0400 Received: from mail-wm1-x331.google.com (mail-wm1-x331.google.com [IPv6:2a00:1450:4864:20::331]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EE1B71B5 for ; Mon, 14 Aug 2023 08:13:04 -0700 (PDT) Received: by mail-wm1-x331.google.com with SMTP id 5b1f17b1804b1-3fe2048c910so40825865e9.1 for ; Mon, 14 Aug 2023 08:13:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1692025983; x=1692630783; 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=5CilnvTYr96ahQ3O2WrOgBxIJx4YDnh0XI4B0xmqb0M=; b=BFvmf1AHI5Aq8gzxukHQqOLdavI/MlU/TWd29OnFQgc7zEfL5xyaQ22w5xrfdPTlGZ DplE5xmYHqAXMIPzS60HIAHJtiQVW2eGv/9EZHqwHpscHdcYx82K+YbyxzEPNKW0qSOk WBA9qQNuzVkeBEWHyS2fwlyNjPWMVkc7M8owuLhLMXp/4BW+V3245BVWp0H+pvgoq0Yo awgWb5Ej+ZtE2eJELwELhS2IPUh6sSPQu6kh36mRMm9D8irwkIbF8b8d7gO1jUx3trdV K1zDTnkqt/RoxJeQntrRkj+IT8o7A8g27skabyDv3rZig7GczqFy9pEvicwDtATIrEMb y2pQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692025983; x=1692630783; 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=5CilnvTYr96ahQ3O2WrOgBxIJx4YDnh0XI4B0xmqb0M=; b=IZMcuxgLdi5rZBn3s47a6UrVLksLho96xJLJo213SyyUkFiyPuervjkrZtAgA5e3bT 9LZGiAW3fXds4wwXmDpceGmDZKibAFsKXv1YOzgVDDMiJGpAhMAG9a+xN4ddumBXPAsU Ga2zW+07s+ft6seWVaVqK/JAluz+AnqOclfNDyDqOtaLRH/Bi7BTZBw7feDTkWSY7nHr ABPjk5EGUYqmfQhUMfhwRtkd1aoY5iTk2yvvCw1JUcsV2h8WeW0n68W97UdlP7fkBhT/ XWll348rswdsHLAqv2oUNcOoYIrgQJCXrY9tlYhnpggMLLaBz2qrQEjCKjZmEflP4D6t nhew== X-Gm-Message-State: AOJu0YydxZWHQTKFgXz6hYunTUVeSw4f7wJssJ6Qvu9lJI4G3jA0k5Cr W5q8ppypLyn0qojBUpdsHVgraw== X-Google-Smtp-Source: AGHT+IGRs50M0vPLfuQzjUUguCsbH9hS+8qdTzuOGeZllLUzfNeRYgMsdcliQzEV40UAzc8haxOEkg== X-Received: by 2002:a1c:750f:0:b0:3fe:2624:484e with SMTP id o15-20020a1c750f000000b003fe2624484emr7929347wmc.38.1692025983526; Mon, 14 Aug 2023 08:13: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 17-20020a05600c021100b003fe1c332810sm17644572wmi.33.2023.08.14.08.13.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Aug 2023 08:13: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 v0 13/13] media: qcom: camss: Add support for setting CSIPHY clock name csiphyX Date: Mon, 14 Aug 2023 16:12:43 +0100 Message-ID: <20230814151243.3801456-14-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230814151243.3801456-1-bryan.odonoghue@linaro.org> References: <20230814151243.3801456-1-bryan.odonoghue@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Several of our upstream and soon-to-be upstream SoC CAMSS dtsi declare csiphyX as opposed to the older clock name csiX_phy. For newer SoCs csiphyX turns out to be a clock you really need to set. On sc8280xp for example we will encounter difficult to track down and root-cause RX CRC errors without setting the csiX_phy clock. On sdm845 and sm8250 we declare the csiXphy clock but seem to get away with not setting it. The right approach here is to set the clock when it is declared. If a SoC doesn't require or a SoC driver implementer doesn't think we need, then the clock ought to simply be omitted from the clock list. Include csiphyX in the set of permissible strings which will subsequently lead to the csiphyX clock being set during csiphy_set_clock_rates() phase. Signed-off-by: Bryan O'Donoghue --- drivers/media/platform/qcom/camss/camss-csiphy.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/media/platform/qcom/camss/camss-csiphy.c b/drivers/med= ia/platform/qcom/camss/camss-csiphy.c index baf78c525fbfc..d9c751f457703 100644 --- a/drivers/media/platform/qcom/camss/camss-csiphy.c +++ b/drivers/media/platform/qcom/camss/camss-csiphy.c @@ -687,6 +687,10 @@ int msm_csiphy_subdev_init(struct camss *camss, if (csiphy->rate_set[i]) break; } + + csiphy->rate_set[i] =3D csiphy_match_clock_name(clock->name, "csiphy%d"= , k); + if (csiphy->rate_set[i]) + break; } } =20 --=20 2.41.0