From patchwork Mon Aug 14 16:28:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bryan O'Donoghue X-Patchwork-Id: 713857 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 0CEC6C001DB for ; Mon, 14 Aug 2023 16:30:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230201AbjHNQ3j (ORCPT ); Mon, 14 Aug 2023 12:29:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50492 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230388AbjHNQ3O (ORCPT ); Mon, 14 Aug 2023 12:29:14 -0400 Received: from mail-wm1-x32c.google.com (mail-wm1-x32c.google.com [IPv6:2a00:1450:4864:20::32c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 861B3E0 for ; Mon, 14 Aug 2023 09:29:12 -0700 (PDT) Received: by mail-wm1-x32c.google.com with SMTP id 5b1f17b1804b1-3fe32016bc8so40712175e9.1 for ; Mon, 14 Aug 2023 09:29:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1692030551; x=1692635351; 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=C8psMUq0iqH+OXqOqofmYwmYllHPKA+2p1Ttr9t5uqUT5YcSEEsHIAOnhU6PxFM1PG /+bzuA6VZyzDHUOAh9ItyHY1IEQnOsoTUQ8FWoe3AeCCdGwkDMkJhuCwEzzGynD018cD g+Q0DXgn6ELYsucHbLF6EFMBhHZ0loEbYI2h98wYZi8OkSoPlSGnwJ8cB0HnLrpvAuf5 a3R8MunFEy9lZl+hjJ1KxeWMuTkagj3JebPx2Q6xDio7d/ETUCyQCMn67n7bHTrGIK7R JamtP52pvLNwCcLC5vIxMWH3fH8ZvvGq9IMPs6RbPEI+DqDm0jaMnC0GAFmnKQkFJhIp E2yA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692030551; x=1692635351; 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=D3vIGi9yD5ckfwHyG+UcRO8roN/lsARDvKtAuXaJ2fC2GGJt4VS1YAsH6rZwxV1aL1 S0TMRiDlVUJsTeWWldTD74Uyi0BAo9eRjZ8EccwhiVjdDWWnbau9w5nitsVGJsFkvGBM LnD3OA3s/7GZPMh9EivjlhM9s8HVEZO+JqR+mPPp7St5Sjbxm7NQcnRTaHI4Smqjn0t/ pO6DYOTcXwIIdsjy6qJtbG1zD9TftxdZfD7OUKiZo9KvbjGd3HzDhDG2T2lE2ssLNF+a ov152x8rsUmpq/3Sw3forMDxMOsshRImjqLNSOwPaj+ns2swfZuyLaMjAdnH7KjbNQEt kbtA== X-Gm-Message-State: AOJu0YyhZx9ahqojg4AL7puIba30jUcWAKPhRwluvjIT1iE05R9AfKFF hv3v2Nkd+KspT9y2BCCTLAg+OA== X-Google-Smtp-Source: AGHT+IESoC56OpCDz8pkuKRkSvrWA37gsSBl0e5gCilyzJP7aXLHS1OSA0YNVYfjqbe+CVW2QIMyOg== X-Received: by 2002:a05:600c:2041:b0:3f7:3699:c294 with SMTP id p1-20020a05600c204100b003f73699c294mr7719780wmg.29.1692030551066; Mon, 14 Aug 2023 09:29:11 -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 l14-20020a1c790e000000b003fc16ee2864sm14743475wme.48.2023.08.14.09.29.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Aug 2023 09:29:10 -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 v1 01/14] media: qcom: camss: Amalgamate struct resource with struct resource_ispif Date: Mon, 14 Aug 2023 17:28:54 +0100 Message-ID: <20230814162907.3878421-2-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230814162907.3878421-1-bryan.odonoghue@linaro.org> References: <20230814162907.3878421-1-bryan.odonoghue@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org There is no good reason to differentiate the two resource structures here. As part of a general tidyup of the declaration and passing of resources within in the CAMSS driver it will be advantageous to have one unified resource structure. The two structures are very similar anyway thus leading more credence still to the argument there should be only one. Signed-off-by: Bryan O'Donoghue --- drivers/media/platform/qcom/camss/camss-ispif.c | 4 ++-- drivers/media/platform/qcom/camss/camss-ispif.h | 4 ++-- drivers/media/platform/qcom/camss/camss.c | 14 +++++++------- drivers/media/platform/qcom/camss/camss.h | 8 +------- 4 files changed, 12 insertions(+), 18 deletions(-) diff --git a/drivers/media/platform/qcom/camss/camss-ispif.c b/drivers/media/platform/qcom/camss/camss-ispif.c index 1c7e4b1b49401..61765b874b9a2 100644 --- a/drivers/media/platform/qcom/camss/camss-ispif.c +++ b/drivers/media/platform/qcom/camss/camss-ispif.c @@ -1095,7 +1095,7 @@ static int ispif_init_formats(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh) * Return 0 on success or a negative error code otherwise */ int msm_ispif_subdev_init(struct camss *camss, - const struct resources_ispif *res) + const struct resources *res) { struct device *dev = camss->dev; struct ispif_device *ispif = camss->ispif; @@ -1152,7 +1152,7 @@ int msm_ispif_subdev_init(struct camss *camss, /* Interrupt */ - ret = platform_get_irq_byname(pdev, res->interrupt); + ret = platform_get_irq_byname(pdev, res->interrupt[0]); if (ret < 0) return ret; diff --git a/drivers/media/platform/qcom/camss/camss-ispif.h b/drivers/media/platform/qcom/camss/camss-ispif.h index fdf28e68cc7d8..c7c41f7afcaad 100644 --- a/drivers/media/platform/qcom/camss/camss-ispif.h +++ b/drivers/media/platform/qcom/camss/camss-ispif.h @@ -66,10 +66,10 @@ struct ispif_device { struct camss *camss; }; -struct resources_ispif; +struct resources; int msm_ispif_subdev_init(struct camss *camss, - const struct resources_ispif *res); + const struct resources *res); int msm_ispif_register_entities(struct ispif_device *ispif, struct v4l2_device *v4l2_dev); diff --git a/drivers/media/platform/qcom/camss/camss.c b/drivers/media/platform/qcom/camss/camss.c index f4948bdf3f8f9..de39dc987444f 100644 --- a/drivers/media/platform/qcom/camss/camss.c +++ b/drivers/media/platform/qcom/camss/camss.c @@ -93,14 +93,14 @@ static const struct resources csid_res_8x16[] = { }, }; -static const struct resources_ispif ispif_res_8x16 = { +static const struct resources ispif_res_8x16 = { /* ISPIF */ .clock = { "top_ahb", "ahb", "ispif_ahb", "csi0", "csi0_pix", "csi0_rdi", "csi1", "csi1_pix", "csi1_rdi" }, .clock_for_reset = { "vfe0", "csi_vfe0" }, .reg = { "ispif", "csi_clk_mux" }, - .interrupt = "ispif" + .interrupt = { "ispif" } }; @@ -234,7 +234,7 @@ static const struct resources csid_res_8x96[] = { } }; -static const struct resources_ispif ispif_res_8x96 = { +static const struct resources ispif_res_8x96 = { /* ISPIF */ .clock = { "top_ahb", "ahb", "ispif_ahb", "csi0", "csi0_pix", "csi0_rdi", @@ -243,7 +243,7 @@ static const struct resources_ispif ispif_res_8x96 = { "csi3", "csi3_pix", "csi3_rdi" }, .clock_for_reset = { "vfe0", "csi_vfe0", "vfe1", "csi_vfe1" }, .reg = { "ispif", "csi_clk_mux" }, - .interrupt = "ispif" + .interrupt = { "ispif" } }; static const struct resources vfe_res_8x96[] = { @@ -410,7 +410,7 @@ static const struct resources csid_res_660[] = { } }; -static const struct resources_ispif ispif_res_660 = { +static const struct resources ispif_res_660 = { /* ISPIF */ .clock = { "top_ahb", "ahb", "ispif_ahb", "csi0", "csi0_pix", "csi0_rdi", @@ -419,7 +419,7 @@ static const struct resources_ispif ispif_res_660 = { "csi3", "csi3_pix", "csi3_rdi" }, .clock_for_reset = { "vfe0", "csi_vfe0", "vfe1", "csi_vfe1" }, .reg = { "ispif", "csi_clk_mux" }, - .interrupt = "ispif" + .interrupt = { "ispif" } }; static const struct resources vfe_res_660[] = { @@ -1122,7 +1122,7 @@ static int camss_init_subdevices(struct camss *camss) { const struct resources *csiphy_res; const struct resources *csid_res; - const struct resources_ispif *ispif_res; + const struct resources *ispif_res; const struct resources *vfe_res; unsigned int i; int ret; diff --git a/drivers/media/platform/qcom/camss/camss.h b/drivers/media/platform/qcom/camss/camss.h index f6c326cb853b8..e95211cdb1fd6 100644 --- a/drivers/media/platform/qcom/camss/camss.h +++ b/drivers/media/platform/qcom/camss/camss.h @@ -44,18 +44,12 @@ struct resources { char *regulators[CAMSS_RES_MAX]; char *clock[CAMSS_RES_MAX]; + char *clock_for_reset[CAMSS_RES_MAX]; u32 clock_rate[CAMSS_RES_MAX][CAMSS_RES_MAX]; char *reg[CAMSS_RES_MAX]; char *interrupt[CAMSS_RES_MAX]; }; -struct resources_ispif { - char *clock[CAMSS_RES_MAX]; - char *clock_for_reset[CAMSS_RES_MAX]; - char *reg[CAMSS_RES_MAX]; - char *interrupt; -}; - struct icc_bw_tbl { u32 avg; u32 peak; From patchwork Mon Aug 14 16:28:55 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bryan O'Donoghue X-Patchwork-Id: 713855 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 C3DACC05052 for ; Mon, 14 Aug 2023 16:30:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230219AbjHNQ3k (ORCPT ); Mon, 14 Aug 2023 12:29:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50526 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231161AbjHNQ3P (ORCPT ); Mon, 14 Aug 2023 12:29:15 -0400 Received: from mail-wm1-x336.google.com (mail-wm1-x336.google.com [IPv6:2a00:1450:4864:20::336]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2A1DCE6E for ; Mon, 14 Aug 2023 09:29:14 -0700 (PDT) Received: by mail-wm1-x336.google.com with SMTP id 5b1f17b1804b1-3fe426b8583so45757695e9.2 for ; Mon, 14 Aug 2023 09:29:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1692030552; x=1692635352; 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=J5JfFhIVZUjE4T/juShhT0ogcGZ3tmBN1oiHpQTIPt1dU8eJby/iFCvbQC61YyP2im nZ9Z+bX84S5Qz5ctGKpoEfMDImflLqyBko1BTCedG8f01uUi7/QnYmpx1h1nBEDWXS0F TfFcNClYqisD65BUJoI1Bea6j9ERqfWL3sQysmL7NxVe59JkbyOvrjvesZOVcMlW74cU OXe42pcsWYna82QFqHZi6gjc/p0PSPkC+8j639cM/s0NmEk0edoNuKnw9/DsFF8ZpsXB OCyxB65sdaxEo8HPOmdfXOGp+dUOB2KeTdsjyh5kDaeo2NoQydbNUi5CMsfPj19MCmAZ 0leQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692030552; x=1692635352; 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=loaT7/vh5CyMXU5QoMb1+W6l7mMxwtbknRxNmq3qGW1HEQ3+iPNCxbYxKx2aIznSJw U5fLY1svS7oLEJHYS47xIgDxzA++Yt/gxukPZE8q9Dd537sUgYCtGbj2suERJuhAHo2R 5uYpZF4RdlTB+byIidr2sMbvZv6xvS0wo/VihWW7I2mCv+nlfAmFbCAluiFO05augLWU PE7Isj/04BoeqdZ5St8RHAMC7jM7Tcrp/0woGxsW8fx7uQrId9XkpP/39lPy8uIuoAWp 42YgCqw3urJ5VDSJRFBBhrFKm7VyzKtx3Ypf0phkq5zcBp5M72jTLADBIWw+UV0o41rx Y84w== X-Gm-Message-State: AOJu0YzOd1BIAUCWKkzrGkERwcCsLkMWM6WLd/UNYvHtJZaCvsBzPWWs evN1pl3NenXqNC3P/N/01Kjyvg== X-Google-Smtp-Source: AGHT+IE9E3L5yPUC3j+Y+bl9r5Qf+nfFZpxQ53y8NxlKlp+Vx6X21dDcJw7W9QzAM8Cq0W8E6FHXBw== X-Received: by 2002:a7b:cc1a:0:b0:3fe:179a:9ee2 with SMTP id f26-20020a7bcc1a000000b003fe179a9ee2mr7580686wmh.0.1692030552429; Mon, 14 Aug 2023 09:29:12 -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 l14-20020a1c790e000000b003fc16ee2864sm14743475wme.48.2023.08.14.09.29.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Aug 2023 09:29:11 -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 v1 02/14] media: qcom: camss: Start to move to module compat matched resources Date: Mon, 14 Aug 2023 17:28:55 +0100 Message-ID: <20230814162907.3878421-3-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230814162907.3878421-1-bryan.odonoghue@linaro.org> References: <20230814162907.3878421-1-bryan.odonoghue@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org 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/platform/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; - if (camss->version == CAMSS_8x16) { - csiphy_res = csiphy_res_8x16; - csid_res = csid_res_8x16; - ispif_res = &ispif_res_8x16; - vfe_res = vfe_res_8x16; - } else if (camss->version == CAMSS_8x96) { - csiphy_res = csiphy_res_8x96; - csid_res = csid_res_8x96; - ispif_res = &ispif_res_8x96; - vfe_res = vfe_res_8x96; - } else if (camss->version == CAMSS_660) { - csiphy_res = csiphy_res_660; - csid_res = csid_res_660; - ispif_res = &ispif_res_660; - vfe_res = vfe_res_660; - } else if (camss->version == CAMSS_845) { - csiphy_res = csiphy_res_845; - csid_res = csid_res_845; - /* Titan VFEs don't have an ISPIF */ - ispif_res = NULL; - vfe_res = vfe_res_845; - } else if (camss->version == CAMSS_8250) { - csiphy_res = csiphy_res_8250; - csid_res = csid_res_8250; - /* Titan VFEs don't have an ISPIF */ - ispif_res = NULL; - vfe_res = vfe_res_8250; - } else { - return -EINVAL; - } - for (i = 0; i < camss->csiphy_num; i++) { ret = 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 = 0; i < camss->vfe_num + camss->vfe_lite_num; i++) { ret = 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) for (i = 0; i < camss->csid_num; i++) { ret = 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) } } - ret = msm_ispif_subdev_init(camss, ispif_res); + ret = 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; + camss->res = of_device_get_match_data(dev); + if (!camss->res) + return -ENODEV; + atomic_set(&camss->ref_count, 0); camss->dev = dev; platform_set_drvdata(pdev, camss); @@ -1735,12 +1705,47 @@ static void camss_remove(struct platform_device *pdev) camss_delete(camss); } +static const struct camss_resources msm8916_resources = { + .csiphy_res = csiphy_res_8x16, + .csid_res = csid_res_8x16, + .ispif_res = &ispif_res_8x16, + .vfe_res = vfe_res_8x16, +}; + +static const struct camss_resources msm8996_resources = { + .csiphy_res = csiphy_res_8x96, + .csid_res = csid_res_8x96, + .ispif_res = &ispif_res_8x96, + .vfe_res = vfe_res_8x96, +}; + +static const struct camss_resources sdm660_resources = { + .csiphy_res = csiphy_res_660, + .csid_res = csid_res_660, + .ispif_res = &ispif_res_660, + .vfe_res = vfe_res_660, +}; + +static const struct camss_resources sdm845_resources = { + .csiphy_res = csiphy_res_845, + .csid_res = csid_res_845, + .ispif_res = NULL, + .vfe_res = vfe_res_845, +}; + +static const struct camss_resources sm8250_resources = { + .csiphy_res = csiphy_res_8250, + .csid_res = csid_res_8250, + .ispif_res = NULL, + .vfe_res = vfe_res_8250, +}; + static const struct of_device_id camss_dt_match[] = { - { .compatible = "qcom,msm8916-camss" }, - { .compatible = "qcom,msm8996-camss" }, - { .compatible = "qcom,sdm660-camss" }, - { .compatible = "qcom,sdm845-camss" }, - { .compatible = "qcom,sm8250-camss" }, + { .compatible = "qcom,msm8916-camss", .data = &msm8916_resources }, + { .compatible = "qcom,msm8996-camss", .data = &msm8996_resources }, + { .compatible = "qcom,sdm660-camss", .data = &sdm660_resources }, + { .compatible = "qcom,sdm845-camss", .data = &sdm845_resources }, + { .compatible = "qcom,sm8250-camss", .data = &sm8250_resources }, { } }; diff --git a/drivers/media/platform/qcom/camss/camss.h b/drivers/media/platform/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 = 4, }; +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; }; struct camss_camera_interface { From patchwork Mon Aug 14 16:28:56 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bryan O'Donoghue X-Patchwork-Id: 713531 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 87501C04FE2 for ; Mon, 14 Aug 2023 16:30:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231239AbjHNQ3k (ORCPT ); Mon, 14 Aug 2023 12:29:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50576 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231340AbjHNQ3Q (ORCPT ); Mon, 14 Aug 2023 12:29:16 -0400 Received: from mail-wm1-x32c.google.com (mail-wm1-x32c.google.com [IPv6:2a00:1450:4864:20::32c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 269A7E7D for ; Mon, 14 Aug 2023 09:29:15 -0700 (PDT) Received: by mail-wm1-x32c.google.com with SMTP id 5b1f17b1804b1-3fe2048c910so41569815e9.1 for ; Mon, 14 Aug 2023 09:29:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1692030553; x=1692635353; 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=lVylwUoPcHqSk5F2gMB5oQ+4rf1xoT03hIVlQ0nH7RWxTPTXOkWaF2ArLEjE9/XfBv Pho1vZn21uCsBzinj09JqrBxvIronc/CDzjEkSty7NaIkpmitMUEOo0n6SylgVfCZaYE z1K3jIZBoRTpJzRtJm9H5lCoJnVsnqQZRAIBGh/NFWOFZ0GV9bsulpHVs+kSU+HK08e4 dMquqhPDuDaA0kKeCJOkAhXu7uMG9tdqSkQ/v9uuY1/WdnRlcMx1auWwyrRYS66xGh1b J/iizd1MNy4HaVGLAGtoVyMrnj9GY/VXJajzJ7LJabHP4Bq9ObiOmz/j7GiPVQ/GIqSG o6Lw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692030553; x=1692635353; 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=TpRutGFxhQJiT2Oj3lO5j+jeGqkhDjZQw/ZGE48hi3fZgKnVL5Iu4RtWmFuRZaa92a Wll4u7mQiC/3h5OLxFLtj1jUb1zZSwLkjFbsdkTkAxZLiDImMb+U51y5dGxFI5tJhd4u HdjXXyGQ2IPuRHtvcnQOP3G3WHMmZVECqVmZE3wPcgEyXc07saCAQZdCCd9vEVS374Vp IKyvXLKHSPGJ4Op95sIj4yu8QOOo4Uzp+G+zxPJ8NDd/GlUcpXkBzpB6ZIBH0rsLV3gp Zq3Cnwme8lSnupyuCbyfWJ7WWoSiOiE5pZp7O/7O1sXryQaKT2kb6CCZJsKtCkK+tbAX 7m/g== X-Gm-Message-State: AOJu0YyWk0BvtoI2oSxpdfmRK4euWFgI27TXawOaCaLgGT0fsV9ka/W7 lBb1cvWLxlJgQa52afBa33G+Rg== X-Google-Smtp-Source: AGHT+IFqeySrjeuMrAJtZDtfzevKsZGX50dzPFfzPupHnYq/yBFk6VCEBeZrWxNQNsJZdLIAmvJJfg== X-Received: by 2002:a05:600c:2207:b0:3fe:6199:939f with SMTP id z7-20020a05600c220700b003fe6199939fmr8238659wml.33.1692030553643; Mon, 14 Aug 2023 09:29:13 -0700 (PDT) Received: from sagittarius-a.chello.ie (188-141-3-169.dynamic.upc.ie. [188.141.3.169]) by smtp.gmail.com with ESMTPSA id l14-20020a1c790e000000b003fc16ee2864sm14743475wme.48.2023.08.14.09.29.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Aug 2023 09:29:13 -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 v1 03/14] media: qcom: camss: Drop useless NULL assignment for ispif resources Date: Mon, 14 Aug 2023 17:28:56 +0100 Message-ID: <20230814162907.3878421-4-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230814162907.3878421-1-bryan.odonoghue@linaro.org> References: <20230814162907.3878421-1-bryan.odonoghue@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org 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/platform/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_resources = { static const struct camss_resources sdm845_resources = { .csiphy_res = csiphy_res_845, .csid_res = csid_res_845, - .ispif_res = NULL, .vfe_res = vfe_res_845, }; static const struct camss_resources sm8250_resources = { .csiphy_res = csiphy_res_8250, .csid_res = csid_res_8250, - .ispif_res = NULL, .vfe_res = vfe_res_8250, }; From patchwork Mon Aug 14 16:28:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bryan O'Donoghue X-Patchwork-Id: 713856 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 71FFBC04FE0 for ; Mon, 14 Aug 2023 16:30:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231340AbjHNQ3l (ORCPT ); Mon, 14 Aug 2023 12:29:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50622 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231495AbjHNQ3S (ORCPT ); Mon, 14 Aug 2023 12:29:18 -0400 Received: from mail-wr1-x42e.google.com (mail-wr1-x42e.google.com [IPv6:2a00:1450:4864:20::42e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6260EE6E for ; Mon, 14 Aug 2023 09:29:16 -0700 (PDT) Received: by mail-wr1-x42e.google.com with SMTP id ffacd0b85a97d-313e742a787so2627492f8f.1 for ; Mon, 14 Aug 2023 09:29:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1692030555; x=1692635355; 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=U+xR+U4Ypv5p+nWfYUEsJK8A95hC5TSV/S6BjJk5MgR2qtuz7ZqHHGyxJrgvc2Pe+z 2h41xfpqL/vjnbw+wzMOOewTXyq9cl2Re7xSMaF7wA0vMAFIOXfOP3yDK00Qizkji7I0 ZkJduEHIEAWTbOoyrX3mUvdh63FusaiM8tZdXUDCU/N5gsYZ2HxSWLOngMSGMyqofTcI s/4DFj7Ivr2Ak0NhyJ0yvzboY1YHCUzqeEX13nem1hg5Ffx6nuX4Ix2+hbTlRsuYUFY1 KYLv9qCWGQl5XP+LniaPZN/DEE1AB/hWo7i7p/kelM/3MAC7mP7c/47+4/EXePqg32gB Xj4Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692030555; x=1692635355; 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=JsYo+gt2vVPcMRdJs2J5ugboWvXrjf4z/vvnIfDrE8qus7hUCtA7ohAZ3CKirxl+nQ UZHtDNYMl6bf/eWDWha0Augd3Ow9R6akhzpxY97zI14c/aWbh/Bjm7L8GiUit0Jjbj6T drum61rk8iX82MStqAkmPDaI5JoaE+NessxrpWvmSFHqW1vJasHlEBiCD8Xz25GyrzUn 32czU5yOQp01a2fNBSd377/qDL3hvRh4Np23P+PGUP0++cFTjvN5iF2b8JUmK4F79INX ViwKAVd29kjYbLDn+FiRyqOfXNoLMyfgvOiJ+YVxWTKAIo6kl+FJHw6l+pjgrOd0xz9Z c0yA== X-Gm-Message-State: AOJu0Yz3gdAKwCAOTlp6MLBN3KjmFxFY0fm5KCgJVgR2+ak00yhBw8lc 3M9PJpZqTxJEq6i/NWrLMq+DMg== X-Google-Smtp-Source: AGHT+IGbEwAy5M0yZ6nr93W2yJ6shYlS2jYv8WsGC3fFX2azKGj4UjFBH2ux7Hl5CfENVDeA0y2G8A== X-Received: by 2002:a5d:4fc3:0:b0:317:558c:c15e with SMTP id h3-20020a5d4fc3000000b00317558cc15emr9996307wrw.27.1692030554858; Mon, 14 Aug 2023 09:29:14 -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 l14-20020a1c790e000000b003fc16ee2864sm14743475wme.48.2023.08.14.09.29.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Aug 2023 09:29:14 -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 v1 04/14] media: qcom: camss: Pass icc bandwidth table as a platform parameter Date: Mon, 14 Aug 2023 17:28:57 +0100 Message-ID: <20230814162907.3878421-5-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230814162907.3878421-1-bryan.odonoghue@linaro.org> References: <20230814162907.3878421-1-bryan.odonoghue@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org Pass the bandwidth table as a platform parameter not if/else derived pointer to the static table. Signed-off-by: Bryan O'Donoghue --- drivers/media/platform/qcom/camss/camss.c | 29 +++++++---------------- drivers/media/platform/qcom/camss/camss.h | 3 ++- 2 files changed, 11 insertions(+), 21 deletions(-) diff --git a/drivers/media/platform/qcom/camss/camss.c b/drivers/media/platform/qcom/camss/camss.c index 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 = 0; int i; - if (camss->version == CAMSS_8250) { - icc_res = &icc_res_sm8250[0]; - nbr_icc_paths = ICC_SM8250_COUNT; - } + icc_res = camss->res->icc_res; - for (i = 0; i < nbr_icc_paths; i++) { + for (i = 0; i < camss->res->icc_path_num; i++) { camss->icc_path[i] = devm_of_icc_get(camss->dev, icc_res[i].name); if (IS_ERR(camss->icc_path[i])) return PTR_ERR(camss->icc_path[i]); - - camss->icc_bw_tbl[i] = icc_res[i].icc_bw_tbl; } return 0; @@ -1736,6 +1730,8 @@ static const struct camss_resources sm8250_resources = { .csiphy_res = csiphy_res_8250, .csid_res = csid_res_8250, .vfe_res = vfe_res_8250, + .icc_res = icc_res_sm8250, + .icc_path_num = ARRAY_SIZE(icc_res_sm8250), }; static const struct of_device_id camss_dt_match[] = { @@ -1752,14 +1748,10 @@ MODULE_DEVICE_TABLE(of, camss_dt_match); static int __maybe_unused camss_runtime_suspend(struct device *dev) { struct camss *camss = dev_get_drvdata(dev); - int nbr_icc_paths = 0; int i; int ret; - if (camss->version == CAMSS_8250) - nbr_icc_paths = ICC_SM8250_COUNT; - - for (i = 0; i < nbr_icc_paths; i++) { + for (i = 0; i < camss->res->icc_path_num; i++) { ret = icc_set_bw(camss->icc_path[i], 0, 0); if (ret) return ret; @@ -1771,17 +1763,14 @@ static int __maybe_unused camss_runtime_suspend(struct device *dev) static int __maybe_unused camss_runtime_resume(struct device *dev) { struct camss *camss = dev_get_drvdata(dev); - int nbr_icc_paths = 0; + const struct resources_icc *icc_res = camss->res->icc_res; int i; int ret; - if (camss->version == CAMSS_8250) - nbr_icc_paths = ICC_SM8250_COUNT; - - for (i = 0; i < nbr_icc_paths; i++) { + for (i = 0; i < camss->res->icc_path_num; i++) { ret = icc_set_bw(camss->icc_path[i], - camss->icc_bw_tbl[i].avg, - camss->icc_bw_tbl[i].peak); + icc_res[i].icc_bw_tbl.avg, + icc_res[i].icc_bw_tbl.peak); if (ret) return ret; } diff --git a/drivers/media/platform/qcom/camss/camss.h b/drivers/media/platform/qcom/camss/camss.h index f632ee49ad83e..988c313b63551 100644 --- a/drivers/media/platform/qcom/camss/camss.h +++ b/drivers/media/platform/qcom/camss/camss.h @@ -84,6 +84,8 @@ struct camss_resources { const struct resources *csid_res; const struct resources *ispif_res; const struct resources *vfe_res; + const struct resources_icc *icc_res; + const int icc_path_num; }; struct camss { @@ -105,7 +107,6 @@ struct camss { struct device **genpd; struct device_link **genpd_link; struct icc_path *icc_path[ICC_SM8250_COUNT]; - struct icc_bw_tbl icc_bw_tbl[ICC_SM8250_COUNT]; const struct camss_resources *res; }; From patchwork Mon Aug 14 16:28:58 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bryan O'Donoghue X-Patchwork-Id: 713529 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 3EB8EC07E8D for ; Mon, 14 Aug 2023 16:30:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231396AbjHNQ3l (ORCPT ); Mon, 14 Aug 2023 12:29:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46896 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231896AbjHNQ3W (ORCPT ); Mon, 14 Aug 2023 12:29:22 -0400 Received: from mail-wm1-x32a.google.com (mail-wm1-x32a.google.com [IPv6:2a00:1450:4864:20::32a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C91EDE7D for ; Mon, 14 Aug 2023 09:29:17 -0700 (PDT) Received: by mail-wm1-x32a.google.com with SMTP id 5b1f17b1804b1-3fe5c0e5747so26564045e9.0 for ; Mon, 14 Aug 2023 09:29:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1692030556; x=1692635356; 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=C/3Glsegg6Rp/XGBbKoCcdsQkbdvDOMlMAFxo3hr01Q5bHHbDdj4RnXkJg5y/1GQus /mCH3sCoaLSDR7P95/RYIMZ9CXeRseYYkrRlQNSlpDD7OR1xKZL/CCbPVH0J4Hd/GP62 3F/JMSEE7IRfW1vPCbCp812nv/er0cxRg26jRmtOfevHJgFCWQ5M6x1VwgA81cn2w8SO lT/++1bbWVSyx0rlc9Nl5G7j1maX0AsRyvB7EtYCZGIlJ4Dyt6N81geHFg8awR+0H3bR v4BUAM9ge4bmUI2mn3phnwgO4xUceHED1sbCPf21PqcfA4j1iUo1QYd0CDYdDQD8+tzL u3mA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692030556; x=1692635356; 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=jLVEwL1RSeA6BJ9YQle67699/bq5pDc1q5VS8E35P1mVZz0G3CcdNqALKZqyaLO4hw TpxCpU1Vl5KMvGLJ1YVUrFx6usJk5VKFGmt+8144QpuSIy/DnF0I//L3PMOQUA01f1U6 iycyj+8/8b+ApIXUJbHNfke5oYr+FGGuUL90vLhQunsibj7hBpfGovc7AqJVZWCmuv2z 14cLNvtd9CFOlhax20Cmiwnsfgudr8/190p4bWzFfsem5ObqPKN0DqF3ScCRZvKVs8Tc VdNs6NhCjUSWHrtZCtY8IYH+goj0Bht5sL29WKtU6xDNMzubSCZH8lZdzZkkvd2NLDNu oT4g== X-Gm-Message-State: AOJu0YwzD0y1Vyy3lKF1OMFt17oH9Ep5aE8eHlmcS4OQxO/AmLyQS6na TRKhT/3Bpa3inj5Dz3bh+1aRuQ== X-Google-Smtp-Source: AGHT+IF1ie5hwiN6LXJCzeWRQYXZhzY1tECE+SIxo2CHbWhTUYRW2q8Z++PUsDrvfT4/W+99lZR9ww== X-Received: by 2002:a05:600c:252:b0:3fc:6e8:d675 with SMTP id 18-20020a05600c025200b003fc06e8d675mr7660778wmj.13.1692030556199; Mon, 14 Aug 2023 09:29:16 -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 l14-20020a1c790e000000b003fc16ee2864sm14743475wme.48.2023.08.14.09.29.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Aug 2023 09:29:15 -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 v1 05/14] media: qcom: camss: Pass remainder of variables as resources Date: Mon, 14 Aug 2023 17:28:58 +0100 Message-ID: <20230814162907.3878421-6-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230814162907.3878421-1-bryan.odonoghue@linaro.org> References: <20230814162907.3878421-1-bryan.odonoghue@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org 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 on) struct camss *camss = csid->camss; struct device *dev = camss->dev; struct vfe_device *vfe = &camss->vfe[csid->id]; - u32 version = camss->version; + u32 version = camss->res->version; int ret = 0; if (on) { @@ -576,13 +576,13 @@ int msm_csid_subdev_init(struct camss *camss, struct csid_device *csid, csid->camss = camss; csid->id = id; - if (camss->version == CAMSS_8x16) { + if (camss->res->version == CAMSS_8x16) { csid->ops = &csid_ops_4_1; - } else if (camss->version == CAMSS_8x96 || - camss->version == CAMSS_660) { + } else if (camss->res->version == CAMSS_8x96 || + camss->res->version == CAMSS_660) { csid->ops = &csid_ops_4_7; - } else if (camss->version == CAMSS_845 || - camss->version == CAMSS_8250) { + } else if (camss->res->version == CAMSS_845 || + camss->res->version == CAMSS_8250) { csid->ops = &csid_ops_gen2; } else { return -EINVAL; @@ -591,7 +591,7 @@ int msm_csid_subdev_init(struct camss *camss, struct csid_device *csid, /* Memory */ - if (camss->version == CAMSS_8250) { + if (camss->res->version == 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/drivers/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_device *csiphy, val = CSIPHY_3PH_LNn_CFG1_SWI_REC_DLY_PRG; writel_relaxed(val, csiphy->base + CSIPHY_3PH_LNn_CFG1(l)); - if (csiphy->camss->version == CAMSS_660) + if (csiphy->camss->res->version == CAMSS_660) val = CSIPHY_3PH_LNn_CFG4_T_HS_CLK_MISS_660; else val = CSIPHY_3PH_LNn_CFG4_T_HS_CLK_MISS; @@ -419,7 +419,7 @@ static void csiphy_gen2_config_lanes(struct csiphy_device *csiphy, int i, l, array_size; u32 val; - switch (csiphy->camss->version) { + switch (csiphy->camss->res->version) { case CAMSS_845: r = &lane_regs_sdm845[0][0]; array_size = ARRAY_SIZE(lane_regs_sdm845[0]); @@ -468,8 +468,8 @@ static void csiphy_lanes_enable(struct csiphy_device *csiphy, s64 link_freq, u8 lane_mask) { struct csiphy_lanes_cfg *c = &cfg->csi2->lane_cfg; - bool is_gen2 = (csiphy->camss->version == CAMSS_845 || - csiphy->camss->version == CAMSS_8250); + bool is_gen2 = (csiphy->camss->res->version == CAMSS_845 || + csiphy->camss->res->version == CAMSS_8250); u8 settle_cnt; u8 val; int i; diff --git a/drivers/media/platform/qcom/camss/camss-csiphy.c b/drivers/media/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 = id; csiphy->cfg.combo_mode = 0; - if (camss->version == CAMSS_8x16) { + if (camss->res->version == CAMSS_8x16) { csiphy->ops = &csiphy_ops_2ph_1_0; csiphy->formats = csiphy_formats_8x16; csiphy->nformats = ARRAY_SIZE(csiphy_formats_8x16); - } else if (camss->version == CAMSS_8x96 || - camss->version == CAMSS_660) { + } else if (camss->res->version == CAMSS_8x96 || + camss->res->version == CAMSS_660) { csiphy->ops = &csiphy_ops_3ph_1_0; csiphy->formats = csiphy_formats_8x96; csiphy->nformats = ARRAY_SIZE(csiphy_formats_8x96); - } else if (camss->version == CAMSS_845 || - camss->version == CAMSS_8250) { + } else if (camss->res->version == CAMSS_845 || + camss->res->version == CAMSS_8250) { csiphy->ops = &csiphy_ops_3ph_1_0; csiphy->formats = csiphy_formats_sdm845; csiphy->nformats = 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); - if (camss->version == CAMSS_8x16 || - camss->version == CAMSS_8x96) { + if (camss->res->version == CAMSS_8x16 || + camss->res->version == CAMSS_8x96) { csiphy->base_clk_mux = 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] = true; - if (camss->version == CAMSS_660 && + if (camss->res->version == 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/media/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; - 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 == CAMSS_8x96 || - camss->version == CAMSS_660) + if (camss->res->version == CAMSS_8x96 || + camss->res->version == 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; mutex_lock(&ispif->config_lock); - if (camss->version == CAMSS_8x96 || - camss->version == CAMSS_660) + if (camss->res->version == CAMSS_8x96 || + camss->res->version == 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 = camss; /* Number of ISPIF lines - same as number of CSID hardware modules */ - if (camss->version == CAMSS_8x16) + if (camss->res->version == CAMSS_8x16) ispif->line_num = 2; - else if (camss->version == CAMSS_8x96 || - camss->version == CAMSS_660) + else if (camss->res->version == CAMSS_8x96 || + camss->res->version == CAMSS_660) ispif->line_num = 4; else return -EINVAL; @@ -1126,12 +1126,12 @@ int msm_ispif_subdev_init(struct camss *camss, ispif->line[i].ispif = ispif; ispif->line[i].id = i; - if (camss->version == CAMSS_8x16) { + if (camss->res->version == CAMSS_8x16) { ispif->line[i].formats = ispif_formats_8x16; ispif->line[i].nformats = ARRAY_SIZE(ispif_formats_8x16); - } else if (camss->version == CAMSS_8x96 || - camss->version == CAMSS_660) { + } else if (camss->res->version == CAMSS_8x96 || + camss->res->version == CAMSS_660) { ispif->line[i].formats = ispif_formats_8x96; ispif->line[i].nformats = ARRAY_SIZE(ispif_formats_8x96); @@ -1159,11 +1159,11 @@ int msm_ispif_subdev_init(struct camss *camss, ispif->irq = ret; snprintf(ispif->irq_name, sizeof(ispif->irq_name), "%s_%s", dev_name(dev), MSM_ISPIF_NAME); - if (camss->version == CAMSS_8x16) + if (camss->res->version == CAMSS_8x16) ret = devm_request_irq(dev, ispif->irq, ispif_isr_8x16, IRQF_TRIGGER_RISING, ispif->irq_name, ispif); - else if (camss->version == CAMSS_8x96 || - camss->version == CAMSS_660) + else if (camss->res->version == CAMSS_8x96 || + camss->res->version == CAMSS_660) ret = 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/media/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 = vfe->camss; - if (vfe->id >= camss->vfe_num) + if (vfe->id >= camss->res->vfe_num) return; 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 = vfe->camss; enum vfe_line_id id = vfe->id; - if (id >= camss->vfe_num) + if (id >= camss->res->vfe_num) return 0; camss->genpd_link[id] = device_link_add(camss->dev, camss->genpd[id], diff --git a/drivers/media/platform/qcom/camss/camss-vfe-480.c b/drivers/media/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 = vfe->camss; - if (vfe->id >= camss->vfe_num) + if (vfe->id >= camss->res->vfe_num) return; 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 = vfe->camss; enum vfe_line_id id = vfe->id; - if (id >= camss->vfe_num) + if (id >= camss->res->vfe_num) return 0; camss->genpd_link[id] = 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 = to_vfe(line); - if (vfe->camss->version == CAMSS_8x16) + if (vfe->camss->res->version == 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, u32 sink_code, return sink_code; } - else if (vfe->camss->version == CAMSS_8x96 || - vfe->camss->version == CAMSS_660 || - vfe->camss->version == CAMSS_845 || - vfe->camss->version == CAMSS_8250) + else if (vfe->camss->res->version == CAMSS_8x96 || + vfe->camss->res->version == CAMSS_660 || + vfe->camss->res->version == CAMSS_845 || + vfe->camss->res->version == CAMSS_8250) switch (sink_code) { case MEDIA_BUS_FMT_YUYV8_1X16: { @@ -1286,7 +1286,7 @@ int msm_vfe_subdev_init(struct camss *camss, struct vfe_device *vfe, int i, j; int ret; - switch (camss->version) { + switch (camss->res->version) { case CAMSS_8x16: vfe->ops = &vfe_ops_4_1; break; @@ -1392,7 +1392,7 @@ int msm_vfe_subdev_init(struct camss *camss, struct vfe_device *vfe, init_completion(&l->output.sof); init_completion(&l->output.reg_update); - if (camss->version == CAMSS_8x16) { + if (camss->res->version == CAMSS_8x16) { if (i == VFE_LINE_PIX) { l->formats = formats_pix_8x16; l->nformats = ARRAY_SIZE(formats_pix_8x16); @@ -1400,8 +1400,8 @@ int msm_vfe_subdev_init(struct camss *camss, struct vfe_device *vfe, l->formats = formats_rdi_8x16; l->nformats = ARRAY_SIZE(formats_rdi_8x16); } - } else if (camss->version == CAMSS_8x96 || - camss->version == CAMSS_660) { + } else if (camss->res->version == CAMSS_8x96 || + camss->res->version == CAMSS_660) { if (i == VFE_LINE_PIX) { l->formats = formats_pix_8x96; l->nformats = ARRAY_SIZE(formats_pix_8x96); @@ -1409,8 +1409,8 @@ int msm_vfe_subdev_init(struct camss *camss, struct vfe_device *vfe, l->formats = formats_rdi_8x96; l->nformats = ARRAY_SIZE(formats_rdi_8x96); } - } else if (camss->version == CAMSS_845 || - camss->version == CAMSS_8250) { + } else if (camss->res->version == CAMSS_845 || + camss->res->version == CAMSS_8250) { l->formats = formats_rdi_845; l->nformats = ARRAY_SIZE(formats_rdi_845); } else { @@ -1542,8 +1542,8 @@ int msm_vfe_register_entities(struct vfe_device *vfe, } video_out->ops = &vfe->video_ops; - if (vfe->camss->version == CAMSS_845 || - vfe->camss->version == CAMSS_8250) + if (vfe->camss->res->version == CAMSS_845 || + vfe->camss->res->version == CAMSS_8250) video_out->bpl_alignment = 16; else video_out->bpl_alignment = 8; diff --git a/drivers/media/platform/qcom/camss/camss-video.c b/drivers/media/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, struct v4l2_device *v4l2_dev, mutex_init(&video->lock); - if (video->camss->version == CAMSS_8x16) { + if (video->camss->res->version == CAMSS_8x16) { if (is_pix) { video->formats = formats_pix_8x16; video->nformats = ARRAY_SIZE(formats_pix_8x16); @@ -1014,8 +1014,8 @@ int msm_video_register(struct camss_video *video, struct v4l2_device *v4l2_dev, video->formats = formats_rdi_8x16; video->nformats = ARRAY_SIZE(formats_rdi_8x16); } - } else if (video->camss->version == CAMSS_8x96 || - video->camss->version == CAMSS_660) { + } else if (video->camss->res->version == CAMSS_8x96 || + video->camss->res->version == CAMSS_660) { if (is_pix) { video->formats = formats_pix_8x96; video->nformats = ARRAY_SIZE(formats_pix_8x96); @@ -1023,8 +1023,8 @@ int msm_video_register(struct camss_video *video, struct v4l2_device *v4l2_dev, video->formats = formats_rdi_8x96; video->nformats = ARRAY_SIZE(formats_rdi_8x96); } - } else if (video->camss->version == CAMSS_845 || - video->camss->version == CAMSS_8250) { + } else if (video->camss->res->version == CAMSS_845 || + video->camss->res->version == CAMSS_8250) { video->formats = formats_rdi_845; video->nformats = ARRAY_SIZE(formats_rdi_845); } else { diff --git a/drivers/media/platform/qcom/camss/camss.c b/drivers/media/platform/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 = 0; - if (id < camss->vfe_num) { + if (id < camss->res->vfe_num) { struct vfe_device *vfe = &camss->vfe[id]; ret = vfe->ops->pm_domain_on(vfe); @@ -1016,7 +1016,7 @@ int camss_pm_domain_on(struct camss *camss, int id) 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 = &camss->vfe[id]; vfe->ops->pm_domain_off(vfe); @@ -1124,7 +1124,7 @@ static int camss_init_subdevices(struct camss *camss) unsigned int i; int ret; - for (i = 0; i < camss->csiphy_num; i++) { + for (i = 0; i < camss->res->csiphy_num; i++) { ret = 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) } /* note: SM8250 requires VFE to be initialized before CSID */ - for (i = 0; i < camss->vfe_num + camss->vfe_lite_num; i++) { + for (i = 0; i < camss->res->vfe_total_num; i++) { ret = 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) } } - for (i = 0; i < camss->csid_num; i++) { + for (i = 0; i < camss->res->csid_num; i++) { ret = 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 *camss) int i, j, k; int ret; - for (i = 0; i < camss->csiphy_num; i++) { + for (i = 0; i < camss->res->csiphy_num; i++) { ret = msm_csiphy_register_entity(&camss->csiphy[i], &camss->v4l2_dev); if (ret < 0) { @@ -1189,7 +1189,7 @@ static int camss_register_entities(struct camss *camss) } } - for (i = 0; i < camss->csid_num; i++) { + for (i = 0; i < camss->res->csid_num; i++) { ret = msm_csid_register_entity(&camss->csid[i], &camss->v4l2_dev); if (ret < 0) { @@ -1208,7 +1208,7 @@ static int camss_register_entities(struct camss *camss) goto err_reg_ispif; } - for (i = 0; i < camss->vfe_num + camss->vfe_lite_num; i++) { + for (i = 0; i < camss->res->vfe_total_num; i++) { ret = msm_vfe_register_entities(&camss->vfe[i], &camss->v4l2_dev); if (ret < 0) { @@ -1219,8 +1219,8 @@ static int camss_register_entities(struct camss *camss) } } - for (i = 0; i < camss->csiphy_num; i++) { - for (j = 0; j < camss->csid_num; j++) { + for (i = 0; i < camss->res->csiphy_num; i++) { + for (j = 0; j < camss->res->csid_num; j++) { ret = media_create_pad_link( &camss->csiphy[i].subdev.entity, MSM_CSIPHY_PAD_SRC, @@ -1239,7 +1239,7 @@ static int camss_register_entities(struct camss *camss) } if (camss->ispif) { - for (i = 0; i < camss->csid_num; i++) { + for (i = 0; i < camss->res->csid_num; i++) { for (j = 0; j < camss->ispif->line_num; j++) { ret = media_create_pad_link( &camss->csid[i].subdev.entity, @@ -1259,7 +1259,7 @@ static int camss_register_entities(struct camss *camss) } for (i = 0; i < camss->ispif->line_num; i++) - for (k = 0; k < camss->vfe_num; k++) + for (k = 0; k < camss->res->vfe_num; k++) for (j = 0; j < camss->vfe[k].line_num; j++) { struct v4l2_subdev *ispif = &camss->ispif->line[i].subdev; struct v4l2_subdev *vfe = &camss->vfe[k].line[j].subdev; @@ -1279,8 +1279,8 @@ static int camss_register_entities(struct camss *camss) } } } else { - for (i = 0; i < camss->csid_num; i++) - for (k = 0; k < camss->vfe_num + camss->vfe_lite_num; k++) + for (i = 0; i < camss->res->csid_num; i++) + for (k = 0; k < camss->res->vfe_total_num; k++) for (j = 0; j < camss->vfe[k].line_num; j++) { struct v4l2_subdev *csid = &camss->csid[i].subdev; struct v4l2_subdev *vfe = &camss->vfe[k].line[j].subdev; @@ -1304,7 +1304,7 @@ static int camss_register_entities(struct camss *camss) return 0; err_link: - i = camss->vfe_num + camss->vfe_lite_num; + i = camss->res->vfe_total_num; err_reg_vfe: for (i--; i >= 0; i--) msm_vfe_unregister_entities(&camss->vfe[i]); @@ -1312,12 +1312,12 @@ static int camss_register_entities(struct camss *camss) err_reg_ispif: msm_ispif_unregister_entities(camss->ispif); - i = camss->csid_num; + i = camss->res->csid_num; err_reg_csid: for (i--; i >= 0; i--) msm_csid_unregister_entity(&camss->csid[i]); - i = camss->csiphy_num; + i = camss->res->csiphy_num; err_reg_csiphy: for (i--; i >= 0; i--) msm_csiphy_unregister_entity(&camss->csiphy[i]); @@ -1335,15 +1335,15 @@ static void camss_unregister_entities(struct camss *camss) { unsigned int i; - for (i = 0; i < camss->csiphy_num; i++) + for (i = 0; i < camss->res->csiphy_num; i++) msm_csiphy_unregister_entity(&camss->csiphy[i]); - for (i = 0; i < camss->csid_num; i++) + for (i = 0; i < camss->res->csid_num; i++) msm_csid_unregister_entity(&camss->csid[i]); msm_ispif_unregister_entities(camss->ispif); - for (i = 0; i < camss->vfe_num + camss->vfe_lite_num; i++) + for (i = 0; i < camss->res->vfe_total_num; i++) msm_vfe_unregister_entities(&camss->vfe[i]); } @@ -1462,7 +1462,7 @@ static int camss_configure_pd(struct camss *camss) } } - if (i > camss->vfe_num) { + if (i > camss->res->vfe_num) { camss->genpd_link[i - 1] = 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 = &pdev->dev; struct camss *camss; - int num_subdevs, ret; + int num_subdevs; + int ret; camss = devm_kzalloc(dev, sizeof(*camss), GFP_KERNEL); if (!camss) @@ -1522,59 +1523,24 @@ static int camss_probe(struct platform_device *pdev) camss->dev = dev; platform_set_drvdata(pdev, camss); - if (of_device_is_compatible(dev->of_node, "qcom,msm8916-camss")) { - camss->version = CAMSS_8x16; - camss->csiphy_num = 2; - camss->csid_num = 2; - camss->vfe_num = 1; - } else if (of_device_is_compatible(dev->of_node, - "qcom,msm8996-camss")) { - camss->version = CAMSS_8x96; - camss->csiphy_num = 3; - camss->csid_num = 4; - camss->vfe_num = 2; - } else if (of_device_is_compatible(dev->of_node, - "qcom,sdm660-camss")) { - camss->version = CAMSS_660; - camss->csiphy_num = 3; - camss->csid_num = 4; - camss->vfe_num = 2; - } else if (of_device_is_compatible(dev->of_node, - "qcom,sdm845-camss")) { - camss->version = CAMSS_845; - camss->csiphy_num = 4; - camss->csid_num = 3; - camss->vfe_num = 2; - camss->vfe_lite_num = 1; - } else if (of_device_is_compatible(dev->of_node, - "qcom,sm8250-camss")) { - camss->version = CAMSS_8250; - camss->csiphy_num = 6; - camss->csid_num = 4; - camss->vfe_num = 2; - camss->vfe_lite_num = 2; - } else { - return -EINVAL; - } - - camss->csiphy = devm_kcalloc(dev, camss->csiphy_num, + camss->csiphy = devm_kcalloc(dev, camss->res->csiphy_num, sizeof(*camss->csiphy), GFP_KERNEL); if (!camss->csiphy) return -ENOMEM; - camss->csid = devm_kcalloc(dev, camss->csid_num, sizeof(*camss->csid), + camss->csid = devm_kcalloc(dev, camss->res->csid_num, sizeof(*camss->csid), GFP_KERNEL); if (!camss->csid) return -ENOMEM; - if (camss->version == CAMSS_8x16 || - camss->version == CAMSS_8x96) { + if (camss->res->version == CAMSS_8x16 || + camss->res->version == CAMSS_8x96) { camss->ispif = devm_kcalloc(dev, 1, sizeof(*camss->ispif), GFP_KERNEL); if (!camss->ispif) return -ENOMEM; } - camss->vfe = devm_kcalloc(dev, camss->vfe_num + camss->vfe_lite_num, + camss->vfe = 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 == 1) return; - 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]); for (i = 0; i < camss->genpd_num; i++) @@ -1700,38 +1666,65 @@ static void camss_remove(struct platform_device *pdev) } static const struct camss_resources msm8916_resources = { + .version = CAMSS_8x16, .csiphy_res = csiphy_res_8x16, .csid_res = csid_res_8x16, .ispif_res = &ispif_res_8x16, .vfe_res = vfe_res_8x16, + .csiphy_num = ARRAY_SIZE(csiphy_res_8x16), + .csid_num = ARRAY_SIZE(csid_res_8x16), + .vfe_num = ARRAY_SIZE(vfe_res_8x16), + .vfe_total_num = ARRAY_SIZE(vfe_res_8x16), }; static const struct camss_resources msm8996_resources = { + .version = CAMSS_8x96, .csiphy_res = csiphy_res_8x96, .csid_res = csid_res_8x96, .ispif_res = &ispif_res_8x96, .vfe_res = vfe_res_8x96, + .csiphy_num = ARRAY_SIZE(csiphy_res_8x96), + .csid_num = ARRAY_SIZE(csid_res_8x96), + .vfe_num = ARRAY_SIZE(vfe_res_8x96), + .vfe_total_num = ARRAY_SIZE(vfe_res_8x96), }; static const struct camss_resources sdm660_resources = { + .version = CAMSS_660, .csiphy_res = csiphy_res_660, .csid_res = csid_res_660, .ispif_res = &ispif_res_660, .vfe_res = vfe_res_660, + .csiphy_num = ARRAY_SIZE(csiphy_res_660), + .csid_num = ARRAY_SIZE(csid_res_660), + .vfe_num = ARRAY_SIZE(vfe_res_660), + .vfe_total_num = ARRAY_SIZE(vfe_res_660), }; static const struct camss_resources sdm845_resources = { + .version = CAMSS_845, .csiphy_res = csiphy_res_845, .csid_res = csid_res_845, .vfe_res = vfe_res_845, + .csiphy_num = ARRAY_SIZE(csiphy_res_845), + .csid_num = ARRAY_SIZE(csid_res_845), + .vfe_num = 2, + .vfe_lite_num = 1, + .vfe_total_num = 3, }; static const struct camss_resources sm8250_resources = { + .version = CAMSS_8250, .csiphy_res = csiphy_res_8250, .csid_res = csid_res_8250, .vfe_res = vfe_res_8250, .icc_res = icc_res_sm8250, .icc_path_num = ARRAY_SIZE(icc_res_sm8250), + .csiphy_num = ARRAY_SIZE(csiphy_res_8250), + .csid_num = ARRAY_SIZE(csid_res_8250), + .vfe_num = 2, + .vfe_lite_num = 2, + .vfe_total_num = 4, }; static const struct of_device_id camss_dt_match[] = { diff --git a/drivers/media/platform/qcom/camss/camss.h b/drivers/media/platform/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 { }; 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; }; 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; From patchwork Mon Aug 14 16:28:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bryan O'Donoghue X-Patchwork-Id: 713853 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 185B0C07E8C for ; Mon, 14 Aug 2023 16:30:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231615AbjHNQ3l (ORCPT ); Mon, 14 Aug 2023 12:29:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46906 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231951AbjHNQ3X (ORCPT ); Mon, 14 Aug 2023 12:29:23 -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 13264E65 for ; Mon, 14 Aug 2023 09:29:19 -0700 (PDT) Received: by mail-wm1-x334.google.com with SMTP id 5b1f17b1804b1-3fe4b95c371so26426795e9.1 for ; Mon, 14 Aug 2023 09:29:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1692030557; x=1692635357; 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=A+lz2e/yJYhSTpjM4QTBwBcI/HJiJHRCgKpARFQVfFYd547Ow5xr/1Z0jB/u/VyqG1 GogFga1kpkoU7w6V3BwFu/YDDbJXkpLUZruZh9zHFbq3SQ85YZsSm2xcgoAKxMIwDHpW BmiDDgOw3d9dEMrwsmXTvarHv2cSyNZKfx8vhWb9RmrSvKg/1sVvkTiV1z6qYk4SxUy2 3MNv8g1ni5BDflDXlQsyuHQFdXO/Dhdsod5zM18lWvc2j+TlgIU3ozc7MOnze+gsYx2c 07RZ4Eg8tKYe0cOMpkAzCruzpYkaGYF5hTZqtexolynvzmTRCut9P88tXils91Ssczj9 Xp/A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692030557; x=1692635357; 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=Ly32TTgOBxCePQxJGzCisB84FXLpi+jWEbD1laebG9C4IgpZNRDTT5mqtlbERxIBZJ TQrp7/IjMPKdaX+sdI10Ql2mMm3wVSHBV25MwTKqFVBAu1QqRXZGFqRkV0vbZZTb78gK R/UNKLMt6Kd/ZV4i3riWtWmJPG/XXl6CLKfa9zOONghLZS1pMEBNe68gOUdm1KKmEJtP J3OOMJ1QI00XekPaY5ERs8W/0lW+Q7kuSQPOAsbqICyk+TVxdjTS6OVY4bYhQGddFdnW PtOqS7eUVrTWz9TyfIuF4hNXr+TD/Oo6ZfUKwLqJ9+air+ca4/EsYZZ9t4phshMCM0fd h2Kw== X-Gm-Message-State: AOJu0YxmtHZHRyJt90oQAiMegThueeukZ8mr0Tb59fXsYL+FctwZyBTU N7E3rRf7kRo8eNC//UGgguSP1w== X-Google-Smtp-Source: AGHT+IGCE/S1HGeyrWeVSUblNVi41GPzkNKxzQcqCVRl/C7e/4Sb5u6qZftXED+TenOd5rtLjqKGGA== X-Received: by 2002:a05:600c:820:b0:3fe:4c29:e626 with SMTP id k32-20020a05600c082000b003fe4c29e626mr10259595wmp.13.1692030557621; Mon, 14 Aug 2023 09:29:17 -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 l14-20020a1c790e000000b003fc16ee2864sm14743475wme.48.2023.08.14.09.29.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Aug 2023 09:29:17 -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 v1 06/14] media: qcom: camss: Pass line_num from compat resources Date: Mon, 14 Aug 2023 17:28:59 +0100 Message-ID: <20230814162907.3878421-7-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230814162907.3878421-1-bryan.odonoghue@linaro.org> References: <20230814162907.3878421-1-bryan.odonoghue@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org line_num indicates the number of RDI - raw data interface channels which are associated with a given IFE/VFE - image/video front end. On several SoCs the RDI number is not static for each VFE - for example on sm8250 VFE Lite has four RDIs where regular VFE has three. Assigning line_num statically in the subdev_init() phase initialises each VFE to the lower number, meaning in practical terms that we are lobbing off one RDI on some VFEs. Interrupt handling uses static for (i = RDI0; i < RDI2; i++) {} in some of our VFE blocks but this can't work for situations where we have a mixture of VFE @ 3 RDI and VFE-lite @ 4 RDI blocks. First step to remediate is to pass line_num from a compat string controlled data-structure and do so on a per-VFE basis. Later patches will assign the correct number of RDI blocks per VFE. Signed-off-by: Bryan O'Donoghue --- .../media/platform/qcom/camss/camss-vfe-170.c | 2 -- .../media/platform/qcom/camss/camss-vfe-4-1.c | 2 -- .../media/platform/qcom/camss/camss-vfe-4-7.c | 2 -- .../media/platform/qcom/camss/camss-vfe-4-8.c | 2 -- .../media/platform/qcom/camss/camss-vfe-480.c | 1 - drivers/media/platform/qcom/camss/camss-vfe.c | 5 +++ drivers/media/platform/qcom/camss/camss.c | 36 ++++++++++++------- drivers/media/platform/qcom/camss/camss.h | 1 + 8 files changed, 30 insertions(+), 21 deletions(-) diff --git a/drivers/media/platform/qcom/camss/camss-vfe-170.c b/drivers/media/platform/qcom/camss/camss-vfe-170.c index 9905bb06b3823..8aa921400ded0 100644 --- a/drivers/media/platform/qcom/camss/camss-vfe-170.c +++ b/drivers/media/platform/qcom/camss/camss-vfe-170.c @@ -756,8 +756,6 @@ static void vfe_subdev_init(struct device *dev, struct vfe_device *vfe) { vfe->isr_ops = vfe_isr_ops_170; vfe->video_ops = vfe_video_ops_170; - - vfe->line_num = VFE_LINE_NUM_GEN2; } const struct vfe_hw_ops vfe_ops_170 = { diff --git a/drivers/media/platform/qcom/camss/camss-vfe-4-1.c b/drivers/media/platform/qcom/camss/camss-vfe-4-1.c index bc309f326f519..2911e4126e7ad 100644 --- a/drivers/media/platform/qcom/camss/camss-vfe-4-1.c +++ b/drivers/media/platform/qcom/camss/camss-vfe-4-1.c @@ -992,8 +992,6 @@ static void vfe_subdev_init(struct device *dev, struct vfe_device *vfe) vfe->isr_ops = vfe_isr_ops_gen1; vfe->ops_gen1 = &vfe_ops_gen1_4_1; vfe->video_ops = vfe_video_ops_gen1; - - vfe->line_num = VFE_LINE_NUM_GEN1; } const struct vfe_hw_ops vfe_ops_4_1 = { diff --git a/drivers/media/platform/qcom/camss/camss-vfe-4-7.c b/drivers/media/platform/qcom/camss/camss-vfe-4-7.c index 8acd76c9746ba..b65ed0fef595e 100644 --- a/drivers/media/platform/qcom/camss/camss-vfe-4-7.c +++ b/drivers/media/platform/qcom/camss/camss-vfe-4-7.c @@ -1188,8 +1188,6 @@ static void vfe_subdev_init(struct device *dev, struct vfe_device *vfe) vfe->isr_ops = vfe_isr_ops_gen1; vfe->ops_gen1 = &vfe_ops_gen1_4_7; vfe->video_ops = vfe_video_ops_gen1; - - vfe->line_num = VFE_LINE_NUM_GEN1; } const struct vfe_hw_ops vfe_ops_4_7 = { diff --git a/drivers/media/platform/qcom/camss/camss-vfe-4-8.c b/drivers/media/platform/qcom/camss/camss-vfe-4-8.c index 3a0167ecf873a..7b3805177f037 100644 --- a/drivers/media/platform/qcom/camss/camss-vfe-4-8.c +++ b/drivers/media/platform/qcom/camss/camss-vfe-4-8.c @@ -1173,8 +1173,6 @@ static void vfe_subdev_init(struct device *dev, struct vfe_device *vfe) vfe->isr_ops = vfe_isr_ops_gen1; vfe->ops_gen1 = &vfe_ops_gen1_4_8; vfe->video_ops = vfe_video_ops_gen1; - - vfe->line_num = VFE_LINE_NUM_GEN1; } const struct vfe_hw_ops vfe_ops_4_8 = { diff --git a/drivers/media/platform/qcom/camss/camss-vfe-480.c b/drivers/media/platform/qcom/camss/camss-vfe-480.c index 80338efceb9e1..b1a07e846e25b 100644 --- a/drivers/media/platform/qcom/camss/camss-vfe-480.c +++ b/drivers/media/platform/qcom/camss/camss-vfe-480.c @@ -572,7 +572,6 @@ static const struct camss_video_ops vfe_video_ops_480 = { static void vfe_subdev_init(struct device *dev, struct vfe_device *vfe) { vfe->video_ops = vfe_video_ops_480; - vfe->line_num = MAX_VFE_OUTPUT_LINES; } const struct vfe_hw_ops vfe_ops_480 = { diff --git a/drivers/media/platform/qcom/camss/camss-vfe.c b/drivers/media/platform/qcom/camss/camss-vfe.c index 526dd4ab343fe..b789b3b2e4cfd 100644 --- a/drivers/media/platform/qcom/camss/camss-vfe.c +++ b/drivers/media/platform/qcom/camss/camss-vfe.c @@ -1305,6 +1305,11 @@ int msm_vfe_subdev_init(struct camss *camss, struct vfe_device *vfe, default: return -EINVAL; } + + if (!res->line_num) + return -EINVAL; + + vfe->line_num = res->line_num; vfe->ops->subdev_init(dev, vfe); /* Memory */ diff --git a/drivers/media/platform/qcom/camss/camss.c b/drivers/media/platform/qcom/camss/camss.c index 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[] = { { 0 }, { 0 } }, .reg = { "vfe0" }, - .interrupt = { "vfe0" } + .interrupt = { "vfe0" }, + .line_num = VFE_LINE_NUM_GEN1, } }; @@ -263,7 +264,8 @@ static const struct resources vfe_res_8x96[] = { { 0 }, { 0 } }, .reg = { "vfe0" }, - .interrupt = { "vfe0" } + .interrupt = { "vfe0" }, + .line_num = VFE_LINE_NUM_GEN1, }, /* VFE1 */ @@ -281,7 +283,8 @@ static const struct resources vfe_res_8x96[] = { { 0 }, { 0 } }, .reg = { "vfe1" }, - .interrupt = { "vfe1" } + .interrupt = { "vfe1" }, + .line_num = VFE_LINE_NUM_GEN1, } }; @@ -442,7 +445,8 @@ static const struct resources vfe_res_660[] = { { 0 }, { 0 } }, .reg = { "vfe0" }, - .interrupt = { "vfe0" } + .interrupt = { "vfe0" }, + .line_num = VFE_LINE_NUM_GEN1, }, /* VFE1 */ @@ -463,7 +467,8 @@ static const struct resources vfe_res_660[] = { { 0 }, { 0 } }, .reg = { "vfe1" }, - .interrupt = { "vfe1" } + .interrupt = { "vfe1" }, + .line_num = VFE_LINE_NUM_GEN1, } }; @@ -621,7 +626,8 @@ static const struct resources vfe_res_845[] = { { 19200000, 75000000, 384000000, 538666667 }, { 384000000 } }, .reg = { "vfe0" }, - .interrupt = { "vfe0" } + .interrupt = { "vfe0" }, + .line_num = VFE_LINE_NUM_GEN2, }, /* VFE1 */ @@ -641,7 +647,8 @@ static const struct resources vfe_res_845[] = { { 19200000, 75000000, 384000000, 538666667 }, { 384000000 } }, .reg = { "vfe1" }, - .interrupt = { "vfe1" } + .interrupt = { "vfe1" }, + .line_num = VFE_LINE_NUM_GEN2, }, /* VFE-lite */ @@ -660,7 +667,8 @@ static const struct resources vfe_res_845[] = { { 19200000, 75000000, 384000000, 538666667 }, { 384000000 } }, .reg = { "vfe_lite" }, - .interrupt = { "vfe_lite" } + .interrupt = { "vfe_lite" }, + .line_num = VFE_LINE_NUM_GEN2, } }; @@ -787,7 +795,8 @@ static const struct resources vfe_res_8250[] = { { 0 }, { 0 } }, .reg = { "vfe0" }, - .interrupt = { "vfe0" } + .interrupt = { "vfe0" }, + .line_num = 4, }, /* VFE1 */ { @@ -805,7 +814,8 @@ static const struct resources vfe_res_8250[] = { { 0 }, { 0 } }, .reg = { "vfe1" }, - .interrupt = { "vfe1" } + .interrupt = { "vfe1" }, + .line_num = 4, }, /* VFE2 (lite) */ { @@ -822,7 +832,8 @@ static const struct resources vfe_res_8250[] = { { 400000000, 480000000 }, { 0 } }, .reg = { "vfe_lite0" }, - .interrupt = { "vfe_lite0" } + .interrupt = { "vfe_lite0" }, + .line_num = 4, }, /* VFE3 (lite) */ { @@ -839,7 +850,8 @@ static const struct resources vfe_res_8250[] = { { 400000000, 480000000 }, { 0 } }, .reg = { "vfe_lite1" }, - .interrupt = { "vfe_lite1" } + .interrupt = { "vfe_lite1" }, + .line_num = 4, }, }; diff --git a/drivers/media/platform/qcom/camss/camss.h b/drivers/media/platform/qcom/camss/camss.h index dd8c58d349685..101ce6e527931 100644 --- a/drivers/media/platform/qcom/camss/camss.h +++ b/drivers/media/platform/qcom/camss/camss.h @@ -48,6 +48,7 @@ struct resources { u32 clock_rate[CAMSS_RES_MAX][CAMSS_RES_MAX]; char *reg[CAMSS_RES_MAX]; char *interrupt[CAMSS_RES_MAX]; + u8 line_num; }; struct icc_bw_tbl { From patchwork Mon Aug 14 16:29:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bryan O'Donoghue X-Patchwork-Id: 713530 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 D8DCDC07E8B for ; Mon, 14 Aug 2023 16:30:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231688AbjHNQ3m (ORCPT ); Mon, 14 Aug 2023 12:29:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46974 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232012AbjHNQ3Y (ORCPT ); Mon, 14 Aug 2023 12:29:24 -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 30C5B10FA for ; Mon, 14 Aug 2023 09:29:20 -0700 (PDT) Received: by mail-wm1-x335.google.com with SMTP id 5b1f17b1804b1-3fea0640d88so6580255e9.2 for ; Mon, 14 Aug 2023 09:29:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1692030558; x=1692635358; 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=OYH+1QHhpiOHsvhfxhZb5PYNfvsgcJdnB0R19DVzZBT//tu5lEc8jPibKrq8pYRime QsSCGcZHo0AHf746qUDg+JQvf1Mc37GJJUat+lMO3WKV+2VEfOzgWfX4MGtl1yXPfMoV klQ9gun+VTrcCPM7TrF3dY4MXP+2agI5yIhQDMDgixdz67OQi6hySOP0nDzVRnFh871D KDjWGNEWmnrpaRXyvza8KMsoMKVEVtYOrSyesD78g/0JYrAOz9n8cnagZwo5rsX0QC1V OPhWwloHSjFjk5CnQmvUGkhRIr0CqRSNX2F0BHOh8YCVYkjoijiK8Wc4Kxog5TzVTsyJ sQVw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692030558; x=1692635358; 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=SbPt6gDKxOw3ZAdRPzqjUeSBYG8Q14I98lG3rUsJfUuuIxRYVyI77pfP0Lj39Qosji x9FdHoz2Bi28ehgltz89KfxICaZpqJmLYvxQei2ExBGL5oyAeaJq1oKfmJaI40SBUFBh jvmFbmM9j9WZW8gQSaZG2btdP+pUFOdVd4PqfH4PBkZdT8eJ0MLSWDUy7Zt0LilWvKOY 6/skUpOE8exS52Jy/kPAm8mqF+IfVBSuv8LS8/RH+nhY3cZHLKynNL7HpPTtxUcyqrXT 4Y0CtX/onzSIAocXrhYrZiEqEQ6RP2ZHdIp4R4O1+Ddrxm0OI4UEGy4ut3n4pE1wq4v0 gfGw== X-Gm-Message-State: AOJu0YyLNXak31zLKjaOSUzlxIFh/LkTzGPETcMLU2NiYIMismMqN+YA EcHQv0QSEZgR/ngLOIC8Cm8VhQ== X-Google-Smtp-Source: AGHT+IGG2cYVNnSrsZXPpu1AakyzL7/AeL91evUthmQy7zf7onNrQ+zWE2haU9XVcs+5FyjEnheFGQ== X-Received: by 2002:a05:600c:2242:b0:3fa:97ad:2ba5 with SMTP id a2-20020a05600c224200b003fa97ad2ba5mr7715214wmm.31.1692030558746; Mon, 14 Aug 2023 09:29:18 -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 l14-20020a1c790e000000b003fc16ee2864sm14743475wme.48.2023.08.14.09.29.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Aug 2023 09:29:18 -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 v1 07/14] media: qcom: camss: Assign the correct number of RDIs per VFE Date: Mon, 14 Aug 2023 17:29:00 +0100 Message-ID: <20230814162907.3878421-8-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230814162907.3878421-1-bryan.odonoghue@linaro.org> References: <20230814162907.3878421-1-bryan.odonoghue@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org 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/platform/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[] = { { 0 } }, .reg = { "vfe0" }, .interrupt = { "vfe0" }, - .line_num = VFE_LINE_NUM_GEN1, + .line_num = 3, } }; @@ -265,7 +265,7 @@ static const struct resources vfe_res_8x96[] = { { 0 } }, .reg = { "vfe0" }, .interrupt = { "vfe0" }, - .line_num = VFE_LINE_NUM_GEN1, + .line_num = 3, }, /* VFE1 */ @@ -284,7 +284,7 @@ static const struct resources vfe_res_8x96[] = { { 0 } }, .reg = { "vfe1" }, .interrupt = { "vfe1" }, - .line_num = VFE_LINE_NUM_GEN1, + .line_num = 3, } }; @@ -446,7 +446,7 @@ static const struct resources vfe_res_660[] = { { 0 } }, .reg = { "vfe0" }, .interrupt = { "vfe0" }, - .line_num = VFE_LINE_NUM_GEN1, + .line_num = 3, }, /* VFE1 */ @@ -468,7 +468,7 @@ static const struct resources vfe_res_660[] = { { 0 } }, .reg = { "vfe1" }, .interrupt = { "vfe1" }, - .line_num = VFE_LINE_NUM_GEN1, + .line_num = 3, } }; @@ -627,7 +627,7 @@ static const struct resources vfe_res_845[] = { { 384000000 } }, .reg = { "vfe0" }, .interrupt = { "vfe0" }, - .line_num = VFE_LINE_NUM_GEN2, + .line_num = 4, }, /* VFE1 */ @@ -648,7 +648,7 @@ static const struct resources vfe_res_845[] = { { 384000000 } }, .reg = { "vfe1" }, .interrupt = { "vfe1" }, - .line_num = VFE_LINE_NUM_GEN2, + .line_num = 4, }, /* VFE-lite */ @@ -668,7 +668,7 @@ static const struct resources vfe_res_845[] = { { 384000000 } }, .reg = { "vfe_lite" }, .interrupt = { "vfe_lite" }, - .line_num = VFE_LINE_NUM_GEN2, + .line_num = 4, } }; @@ -796,7 +796,7 @@ static const struct resources vfe_res_8250[] = { { 0 } }, .reg = { "vfe0" }, .interrupt = { "vfe0" }, - .line_num = 4, + .line_num = 3, }, /* VFE1 */ { @@ -815,7 +815,7 @@ static const struct resources vfe_res_8250[] = { { 0 } }, .reg = { "vfe1" }, .interrupt = { "vfe1" }, - .line_num = 4, + .line_num = 3, }, /* VFE2 (lite) */ { From patchwork Mon Aug 14 16:29:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bryan O'Donoghue X-Patchwork-Id: 713854 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 600B5C07E8F for ; Mon, 14 Aug 2023 16:30:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232012AbjHNQ3n (ORCPT ); Mon, 14 Aug 2023 12:29:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47072 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232378AbjHNQ31 (ORCPT ); Mon, 14 Aug 2023 12:29:27 -0400 Received: from mail-wm1-x330.google.com (mail-wm1-x330.google.com [IPv6:2a00:1450:4864:20::330]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 81C6C170B for ; Mon, 14 Aug 2023 09:29:22 -0700 (PDT) Received: by mail-wm1-x330.google.com with SMTP id 5b1f17b1804b1-3fe8a1591c8so30376345e9.3 for ; Mon, 14 Aug 2023 09:29:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1692030561; x=1692635361; 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=YpxlJXe4KVO2RDw8fcJYaYNJJC7CWElamn3mvs2pqvMbYOyQCC/0ll0Qj7WBxDewOl OBKWT8zmo9b41Oj5JgVD3uSqDdAP9RkWHGsLd2UQ/1XnMzkDYeaokv/NYuN6QGbS1CER GeJ98fUbi+3SyV7QbtjOpQ+3KfyN7o6eDqMyfAbradj/3B8MNNM3ATwyg0972KrRWFZO gC2zPTbQCj3Q5bm4bqLEwnUs54neGPSLGmZcZ1Yduvb0wHFCF5fKfrXj+ogyJCbbQTmF ncYVbzmB96ZccwNzQNSNQ2uurPYz9ZWZsTX/unAPnXEAqgd8HmHayz7+pS2uHCTXiilb VchQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692030561; x=1692635361; 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=lyverfjhzdCj97BFIY+IlArVht/S4VtEzFmhaBluBzT1BDnTnUnkxOF4hKmV64lIsh jz6ztnS0eZvcSwCwOcwQYdJjXclM0EMGhEi65DumNcsH21P1B3P/PvqP1G8alQ+WA8aY zbpr3251qxMK6+fKHAV0xZVPrI62/TVhwGL64tMKlcPlxS2Qj6jz+YqSUvCnA4HzS8RV r5YI4n/Ggt1FGBoCQomqETn8mSPpGzz9TLprzttoPqXhYa4kUg5CjAXVfDknEnMV59sq yAlgYi7IkEie3hySRr4+Gbv8RQC2u+OiBSXsueCDAbAcIwTs/34r7DiFZGPVrD8fCXrI 8m2g== X-Gm-Message-State: AOJu0YxAv+k0JaS/DgQ2pohR2xEcX2c7YL+cNspBiLJ1CHi7mhPcdGjC e3iJYxIHwPURbj6A1qe2sUJJTw== X-Google-Smtp-Source: AGHT+IFRjUf4/FBZ1XzLy3z08V2+jeCWAcpcboZxLSnFJW+N5iStTffIDMTH7bSdDtw4eGWbNoPxSQ== X-Received: by 2002:a05:600c:217:b0:3fe:10d8:e7ef with SMTP id 23-20020a05600c021700b003fe10d8e7efmr9401170wmi.19.1692030561123; Mon, 14 Aug 2023 09:29:21 -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 l14-20020a1c790e000000b003fc16ee2864sm14743475wme.48.2023.08.14.09.29.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Aug 2023 09:29:20 -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 v1 09/14] media: qcom: camss: Untangle if/else spaghetti in camss Date: Mon, 14 Aug 2023 17:29:02 +0100 Message-ID: <20230814162907.3878421-10-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230814162907.3878421-1-bryan.odonoghue@linaro.org> References: <20230814162907.3878421-1-bryan.odonoghue@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org I refuse to add another SoC to this convoluted if/else structure. By the time we added in a third SoC we ought to have transitioned these control flow strutures to switches. Adding in another Soc or two will make some of these if statements into five clause behemoths. Introduce switches in the obvious places to despaghetiify. Signed-off-by: Bryan O'Donoghue --- .../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 = camss; csid->id = id; - if (camss->res->version == CAMSS_8x16) { + switch (camss->res->version) { + case CAMSS_8x16: csid->ops = &csid_ops_4_1; - } else if (camss->res->version == CAMSS_8x96 || - camss->res->version == CAMSS_660) { + break; + case CAMSS_8x96: + case CAMSS_660: csid->ops = &csid_ops_4_7; - } else if (camss->res->version == CAMSS_845 || - camss->res->version == CAMSS_8250) { + break; + case CAMSS_845: + case CAMSS_8250: csid->ops = &csid_ops_gen2; - } else { + break; + default: return -EINVAL; } csid->ops->subdev_init(csid); diff --git a/drivers/media/platform/qcom/camss/camss-csiphy.c b/drivers/media/platform/qcom/camss/camss-csiphy.c index 593aec5c97bc2..0e8c2a59ea241 100644 --- a/drivers/media/platform/qcom/camss/camss-csiphy.c +++ b/drivers/media/platform/qcom/camss/camss-csiphy.c @@ -557,21 +557,31 @@ int msm_csiphy_subdev_init(struct camss *camss, csiphy->id = id; csiphy->cfg.combo_mode = 0; - if (camss->res->version == CAMSS_8x16) { + switch (camss->res->version) { + case CAMSS_8x16: + { csiphy->ops = &csiphy_ops_2ph_1_0; csiphy->formats = csiphy_formats_8x16; csiphy->nformats = ARRAY_SIZE(csiphy_formats_8x16); - } else if (camss->res->version == CAMSS_8x96 || - camss->res->version == CAMSS_660) { + break; + } + case CAMSS_8x96: + case CAMSS_660: + { csiphy->ops = &csiphy_ops_3ph_1_0; csiphy->formats = csiphy_formats_8x96; csiphy->nformats = ARRAY_SIZE(csiphy_formats_8x96); - } else if (camss->res->version == CAMSS_845 || - camss->res->version == CAMSS_8250) { + break; + } + case CAMSS_845: + case CAMSS_8250: + { csiphy->ops = &csiphy_ops_3ph_1_0; csiphy->formats = csiphy_formats_sdm845; csiphy->nformats = ARRAY_SIZE(csiphy_formats_sdm845); - } else { + break; + } + default: return -EINVAL; } diff --git a/drivers/media/platform/qcom/camss/camss-vfe.c b/drivers/media/platform/qcom/camss/camss-vfe.c index b789b3b2e4cfd..8f48401e31cd3 100644 --- a/drivers/media/platform/qcom/camss/camss-vfe.c +++ b/drivers/media/platform/qcom/camss/camss-vfe.c @@ -170,7 +170,9 @@ static u32 vfe_src_pad_code(struct vfe_line *line, u32 sink_code, { struct vfe_device *vfe = to_vfe(line); - if (vfe->camss->res->version == CAMSS_8x16) + switch (vfe->camss->res->version) { + case CAMSS_8x16: + { switch (sink_code) { case MEDIA_BUS_FMT_YUYV8_1X16: { @@ -218,10 +220,13 @@ static u32 vfe_src_pad_code(struct vfe_line *line, u32 sink_code, return sink_code; } - else if (vfe->camss->res->version == CAMSS_8x96 || - vfe->camss->res->version == CAMSS_660 || - vfe->camss->res->version == CAMSS_845 || - vfe->camss->res->version == CAMSS_8250) + break; + } + case CAMSS_8x96: + case CAMSS_660: + case CAMSS_845: + case CAMSS_8250: + { switch (sink_code) { case MEDIA_BUS_FMT_YUYV8_1X16: { @@ -281,8 +286,12 @@ static u32 vfe_src_pad_code(struct vfe_line *line, u32 sink_code, return sink_code; } - else - return 0; + break; + } + default: + break; + } + return 0; } int vfe_reset(struct vfe_device *vfe) @@ -1397,7 +1406,9 @@ int msm_vfe_subdev_init(struct camss *camss, struct vfe_device *vfe, init_completion(&l->output.sof); init_completion(&l->output.reg_update); - if (camss->res->version == CAMSS_8x16) { + switch (camss->res->version) { + case CAMSS_8x16: + { if (i == VFE_LINE_PIX) { l->formats = formats_pix_8x16; l->nformats = ARRAY_SIZE(formats_pix_8x16); @@ -1405,8 +1416,11 @@ int msm_vfe_subdev_init(struct camss *camss, struct vfe_device *vfe, l->formats = formats_rdi_8x16; l->nformats = ARRAY_SIZE(formats_rdi_8x16); } - } else if (camss->res->version == CAMSS_8x96 || - camss->res->version == CAMSS_660) { + break; + } + case CAMSS_8x96: + case CAMSS_660: + { if (i == VFE_LINE_PIX) { l->formats = formats_pix_8x96; l->nformats = ARRAY_SIZE(formats_pix_8x96); @@ -1414,11 +1428,16 @@ int msm_vfe_subdev_init(struct camss *camss, struct vfe_device *vfe, l->formats = formats_rdi_8x96; l->nformats = ARRAY_SIZE(formats_rdi_8x96); } - } else if (camss->res->version == CAMSS_845 || - camss->res->version == CAMSS_8250) { + break; + } + case CAMSS_845: + case CAMSS_8250: + { l->formats = formats_rdi_845; l->nformats = ARRAY_SIZE(formats_rdi_845); - } else { + break; + } + default: return -EINVAL; } } diff --git a/drivers/media/platform/qcom/camss/camss-video.c b/drivers/media/platform/qcom/camss/camss-video.c index 46a89b5f6c171..e695724437ce1 100644 --- a/drivers/media/platform/qcom/camss/camss-video.c +++ b/drivers/media/platform/qcom/camss/camss-video.c @@ -1006,7 +1006,8 @@ int msm_video_register(struct camss_video *video, struct v4l2_device *v4l2_dev, mutex_init(&video->lock); - if (video->camss->res->version == CAMSS_8x16) { + switch (video->camss->res->version) { + case CAMSS_8x16: if (is_pix) { video->formats = formats_pix_8x16; video->nformats = ARRAY_SIZE(formats_pix_8x16); @@ -1014,8 +1015,9 @@ int msm_video_register(struct camss_video *video, struct v4l2_device *v4l2_dev, video->formats = formats_rdi_8x16; video->nformats = ARRAY_SIZE(formats_rdi_8x16); } - } else if (video->camss->res->version == CAMSS_8x96 || - video->camss->res->version == CAMSS_660) { + break; + case CAMSS_8x96: + case CAMSS_660: if (is_pix) { video->formats = formats_pix_8x96; video->nformats = ARRAY_SIZE(formats_pix_8x96); @@ -1023,11 +1025,13 @@ int msm_video_register(struct camss_video *video, struct v4l2_device *v4l2_dev, video->formats = formats_rdi_8x96; video->nformats = ARRAY_SIZE(formats_rdi_8x96); } - } else if (video->camss->res->version == CAMSS_845 || - video->camss->res->version == CAMSS_8250) { + break; + case CAMSS_845: + case CAMSS_8250: video->formats = formats_rdi_845; video->nformats = ARRAY_SIZE(formats_rdi_845); - } else { + break; + default: ret = -EINVAL; goto error_video_register; } From patchwork Mon Aug 14 16:29:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bryan O'Donoghue X-Patchwork-Id: 713528 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 E0D98C25B4F for ; Mon, 14 Aug 2023 16:30:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232199AbjHNQ3n (ORCPT ); Mon, 14 Aug 2023 12:29:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47140 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232428AbjHNQ32 (ORCPT ); Mon, 14 Aug 2023 12:29:28 -0400 Received: from mail-wm1-x32d.google.com (mail-wm1-x32d.google.com [IPv6:2a00:1450:4864:20::32d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A43701711 for ; Mon, 14 Aug 2023 09:29:23 -0700 (PDT) Received: by mail-wm1-x32d.google.com with SMTP id 5b1f17b1804b1-3fe5c0e57d2so40868555e9.0 for ; Mon, 14 Aug 2023 09:29:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1692030562; x=1692635362; 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=zv0UdT8cU4B1emaIFFn2U40x/r6KMVhhrRPL84WWK1jMdaScDd3xz+1lnzXXU2pR1w DwsZLDi3ifSFVNM01YqOkXQrRuc0WfYrVvk5FSE/KRHpD9nwTLVzcO/IcuazWbbVsV0+ KqLDQZcVzLjxSM9G4MScdlUq3sPVR1SlrXRV5Ko8jZrjxbywVxCto+J4DgXad4t22zI4 Rl7QnhTdzAR0oIKPo701x2r/jmzSArrtXEjqGmH7iLjmRLAWM9s7901Xgk4ni8hMA5K3 sKM7IAytgzR9SAImdcVEIIGLx9vVIoXqXWSzt2/2aQ5DlaM8ZRGem82ArEqemJZMbiUZ 03kQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692030562; x=1692635362; 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=cFk0OkLrlMnQMMMT7MWpAT7p/ZeQ+nI4qsUjm6zvjoZrwpo/z7bNZ5QxmTGMfipl/K BZyUv4LIvBOZW2VfGgOYn4xXBqsgimyYTFlaX5F+BGAhwLIcMac25m/4w92S7+hl6W9u rtjgxO8T1PqcPtWQsZedXoDJmIGo4FTkcZQ6jeRgj06mWT6lZsGtyK7ZIAFC4aWF3Xp8 7uBPacgDsedq6SsBGqwsgBDHh28eB5cU1FrRYFQYAv/ljD+G73A0WtmjfriYc6usKCkB NuDLX4aGNAe96Tk4LBHXu6TGt043PkI34hbxc51fpgx+xJr9Z16XBkBuY/uXkZnVPHeo j0bg== X-Gm-Message-State: AOJu0Yxq92/7XscrssWmDQEXPbGoAW95/dSHo5E/sn7UfjffDwGLno0r dVUsq0Jl8S/31BdA07OgFZCZ4w== X-Google-Smtp-Source: AGHT+IECoMn8HV1r7XAFBGwtKYR2TnzZR4SvUL69mUbVJiybowWdfkF2YKKyciPTbBaB523EhEaetw== X-Received: by 2002:a7b:c44f:0:b0:3fb:abd0:2b52 with SMTP id l15-20020a7bc44f000000b003fbabd02b52mr8152475wmi.13.1692030562227; Mon, 14 Aug 2023 09:29:22 -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 l14-20020a1c790e000000b003fc16ee2864sm14743475wme.48.2023.08.14.09.29.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Aug 2023 09:29:21 -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 v1 10/14] media: qcom: camss: Improve error printout on icc_get fail Date: Mon, 14 Aug 2023 17:29:03 +0100 Message-ID: <20230814162907.3878421-11-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230814162907.3878421-1-bryan.odonoghue@linaro.org> References: <20230814162907.3878421-1-bryan.odonoghue@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org 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/platform/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 = 0; i < camss->res->icc_path_num; i++) { camss->icc_path[i] = devm_of_icc_get(camss->dev, icc_res[i].name); - if (IS_ERR(camss->icc_path[i])) + 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]); + } } return 0; From patchwork Mon Aug 14 16:29:04 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bryan O'Donoghue X-Patchwork-Id: 713851 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 C184CC18E72 for ; Mon, 14 Aug 2023 16:30:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232331AbjHNQ3o (ORCPT ); Mon, 14 Aug 2023 12:29:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47162 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232457AbjHNQ33 (ORCPT ); Mon, 14 Aug 2023 12:29:29 -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 2DC3EA8 for ; Mon, 14 Aug 2023 09:29:25 -0700 (PDT) Received: by mail-wm1-x329.google.com with SMTP id 5b1f17b1804b1-3fe2fb9b4d7so41071035e9.1 for ; Mon, 14 Aug 2023 09:29:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1692030563; x=1692635363; 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=MVDUyLNo9O6sKi/JQRUyfv3hbSM3DpAfbwkGmXCuB9+MFbnW8JPBHUHQ+u/AvSSFRf nitMHru2LgEDjO3BcmDYMLPOCePhwIu08gs9S7cjjvWG+IKB3S7kwrLK7r04tvCaroIV y0s8ruLwq1w0hdMQF5e0xi9rHJwvL3wXtFxNPl53Yd32l7H9cd0FIMYeOIM30BpPFHo9 wmnWvgIuQs0R3I0X3zQOVlNWI+sin3RfngrsfrEUQ6xpJidsQyMPVr2yNrVwozV795Yc c3tTdJx4BEh05MBbarGmW/sJf6Pwxrn0dIk+CsH2EBefaH97Mzv4Aex3Zr+AYkv7pmeM ZRaw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692030563; x=1692635363; 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=jnz56XdYNjapICDhffS/pFQDuR9sT+58FpsbYyE0/q2gdLfp+YmEb8Deg3gMZJZurd UOQ3BHJhCy+J7MXQrNJD5tsQ1UcFp6c/NJ/NC7OXQLbvNm77v/QOECX9ythwv4FA3HTo QgwyyCS346l7szdLIDp1Mls1BvJbb4G6MmGY7xtCYZhEJKSsqLlSTgYlncccodt1LMH/ fzfVDm1Nl7ZJCDCZ/ZuVrVPlA6xobFaxX4PbTOonQeicQzhuFkQPdjFMNQr6wgrZbCzs G4s4R13skPs4xNgnO+UWXxwYgRjIUcy4akXhXoNHQWTOq1Y/Zgza7hUmqhkpWgadQxfA kuKg== X-Gm-Message-State: AOJu0YwY2zAJRZ+jmb4frxdNr/k0b2PWG/7zDrrBxKzjTDbeo3AmA9zV /T0tRdu1V72D6CgoLXy+fvAbKw== X-Google-Smtp-Source: AGHT+IGSwzHnuII53JUnS2cqb2gI4Us3pnCdsRZ7zkLFwYBDRrpbqqROTZjHYH8r5Cgn/MQgBUePbA== X-Received: by 2002:a05:600c:218:b0:3fb:b5dc:dab1 with SMTP id 24-20020a05600c021800b003fbb5dcdab1mr7879728wmi.39.1692030563632; Mon, 14 Aug 2023 09:29:23 -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 l14-20020a1c790e000000b003fc16ee2864sm14743475wme.48.2023.08.14.09.29.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Aug 2023 09:29:22 -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 v1 11/14] media: qcom: camss: Allow clocks vfeN vfe_liteN or vfe_lite Date: Mon, 14 Aug 2023 17:29:04 +0100 Message-ID: <20230814162907.3878421-12-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230814162907.3878421-1-bryan.odonoghue@linaro.org> References: <20230814162907.3878421-1-bryan.odonoghue@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org 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); } +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 = 0; i < vfe->nclocks; i++) { struct camss_clock *clock = &vfe->clock[i]; - if (!strcmp(clock->name, "vfe0") || - !strcmp(clock->name, "vfe1") || - !strcmp(clock->name, "vfe_lite")) { + if (vfe_match_clock_names(vfe, clock)) { u64 min_rate = 0; long rate; @@ -543,9 +555,7 @@ static int vfe_check_clock_rates(struct vfe_device *vfe) for (i = 0; i < vfe->nclocks; i++) { struct camss_clock *clock = &vfe->clock[i]; - if (!strcmp(clock->name, "vfe0") || - !strcmp(clock->name, "vfe1") || - !strcmp(clock->name, "vfe_lite")) { + if (vfe_match_clock_names(vfe, clock)) { u64 min_rate = 0; unsigned long rate; From patchwork Mon Aug 14 16:29:05 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bryan O'Donoghue X-Patchwork-Id: 713850 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 6CB26C25B75 for ; Mon, 14 Aug 2023 16:30:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232366AbjHNQ3o (ORCPT ); Mon, 14 Aug 2023 12:29:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52252 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232491AbjHNQ3a (ORCPT ); Mon, 14 Aug 2023 12:29:30 -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 4494910FA for ; Mon, 14 Aug 2023 09:29:26 -0700 (PDT) Received: by mail-wm1-x329.google.com with SMTP id 5b1f17b1804b1-3fe2ba3e260so44530725e9.2 for ; Mon, 14 Aug 2023 09:29:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1692030565; x=1692635365; 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=t0DrTBKAUnZsOhKTySRBhIZjBEyiCu6lrIZbKlxcEhX6zO1Ez+fk0jM/I6CoLWplDS ntt6v5+8AXCoamgE9CwhyNauIGGhB5vI+AUO6towiMb7WC/K62f7Tw69AyzUY5Mmu+ck 4TqxDvSRKcyTu1c3YonMVg/VVhb6f/FF6NQi54/GTMeuSXqikJpYaLrAix5rsPjDFP7a xxOebx1jx3FWvnIfSbh0Mbc5CNX2ZseiM0RbbtmOP7RTPhfCp8sX7ADwJmmZ02MvBins oexMWOyPM46Y7BI/3IaFBT5msykygWtnD7W2JiHoGS/xWY14wFfdMJETFskRv0N9Mtkk /97g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692030565; x=1692635365; 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=L8Iix9Q1qvdb8aGGSTEmMAo4+/LeRyS5AtCKGhS3dQeEYynjj3dftQRTIL/OpYWB3F JbE69l5KJooYjcos8k+27LJh6MCt3Xenpe05le9INKn2R4n/HpmutZ+YQZc5TbPhq8em 8GhfY3Y3D6hAwj6mkOClc3znPuDupvwziNuXgdz6+ayP3L60rGybFiXl6cKm1XeMPHzO kaW6i3ejcY+ejAi4ABivZOeXxKVp3ySapJ4VHD3SnXdpekznVF4lLi+9YeyDkbW/rEbK iII3YxqAGjQiSXT1419wAEYNFsZVX89/iYg19hSHNznPKRfwfToRz1AuPpYo2w0aATRN rh6w== X-Gm-Message-State: AOJu0YyLRXEmtd5zkj54L+cS34Xzqq2zb7sOOxqwO8qLx3hAl1mMXrz0 ksyOgDKq/UenU6Vjy06iw5BjFQ== X-Google-Smtp-Source: AGHT+IFlFBtMXWXtNjBPfw8b8tvKeO1O7fSNRBA1UJ1pf4U/UG4KqA5s8MZcofKggbrJ3oqsyE9+Bw== X-Received: by 2002:a05:600c:82c5:b0:3fe:90f:8496 with SMTP id eo5-20020a05600c82c500b003fe090f8496mr7756053wmb.1.1692030564860; Mon, 14 Aug 2023 09:29:24 -0700 (PDT) Received: from sagittarius-a.chello.ie (188-141-3-169.dynamic.upc.ie. [188.141.3.169]) by smtp.gmail.com with ESMTPSA id l14-20020a1c790e000000b003fc16ee2864sm14743475wme.48.2023.08.14.09.29.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Aug 2023 09:29:24 -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 v1 12/14] media: qcom: camss: Functionally decompose CSIPHY clock lookups Date: Mon, 14 Aug 2023 17:29:05 +0100 Message-ID: <20230814162907.3878421-13-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230814162907.3878421-1-bryan.odonoghue@linaro.org> References: <20230814162907.3878421-1-bryan.odonoghue@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org The csiphyX_timer and csiX_phy values need not be hard-coded. We can functionally decompose the string matching inside of a loop. Static string values are brittle, difficult to extend and not required anyway since the camss->res->csiphy_num value informs us of the number of CSIPHYs and hence the set of potential clocks for a given CSIPHY. In simple terms if we have five CSIPHYs we can have no more and no less than five csiphy_timer clocks. Similarly csi_phy core clocks have a 1:1 relationship with the PHY they clock. Signed-off-by: Bryan O'Donoghue --- .../media/platform/qcom/camss/camss-csiphy.c | 37 ++++++++++++------- 1 file changed, 23 insertions(+), 14 deletions(-) diff --git a/drivers/media/platform/qcom/camss/camss-csiphy.c b/drivers/media/platform/qcom/camss/camss-csiphy.c index 0e8c2a59ea241..baf78c525fbfc 100644 --- a/drivers/media/platform/qcom/camss/camss-csiphy.c +++ b/drivers/media/platform/qcom/camss/camss-csiphy.c @@ -536,6 +536,15 @@ static int csiphy_init_formats(struct v4l2_subdev *sd, return csiphy_set_format(sd, fh ? fh->state : NULL, &format); } +static bool csiphy_match_clock_name(const char *clock_name, const char *format, + int index) +{ + char name[CAMSS_RES_MAX]; + + snprintf(name, sizeof(name), format, index); + return !strcmp(clock_name, name); +} + /* * msm_csiphy_subdev_init - Initialize CSIPHY device structure and resources * @csiphy: CSIPHY device @@ -550,7 +559,7 @@ int msm_csiphy_subdev_init(struct camss *camss, { struct device *dev = camss->dev; struct platform_device *pdev = to_platform_device(dev); - int i, j; + int i, j, k; int ret; csiphy->camss = camss; @@ -666,19 +675,19 @@ int msm_csiphy_subdev_init(struct camss *camss, for (j = 0; j < clock->nfreqs; j++) clock->freq[j] = res->clock_rate[i][j]; - if (!strcmp(clock->name, "csiphy0_timer") || - !strcmp(clock->name, "csiphy1_timer") || - !strcmp(clock->name, "csiphy2_timer") || - !strcmp(clock->name, "csiphy3_timer") || - !strcmp(clock->name, "csiphy4_timer") || - !strcmp(clock->name, "csiphy5_timer")) - csiphy->rate_set[i] = true; - - if (camss->res->version == CAMSS_660 && - (!strcmp(clock->name, "csi0_phy") || - !strcmp(clock->name, "csi1_phy") || - !strcmp(clock->name, "csi2_phy"))) - csiphy->rate_set[i] = true; + for (k = 0; k < camss->res->csiphy_num; k++) { + csiphy->rate_set[i] = csiphy_match_clock_name(clock->name, + "csiphy%d_timer", k); + if (csiphy->rate_set[i]) + break; + + if (camss->res->version == CAMSS_660) { + csiphy->rate_set[i] = csiphy_match_clock_name(clock->name, + "csi%d_phy", k); + if (csiphy->rate_set[i]) + break; + } + } } return 0; From patchwork Mon Aug 14 16:29:06 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bryan O'Donoghue X-Patchwork-Id: 713852 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 EFAB2C25B5F for ; Mon, 14 Aug 2023 16:30:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232424AbjHNQ3p (ORCPT ); Mon, 14 Aug 2023 12:29:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52304 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232521AbjHNQ3a (ORCPT ); Mon, 14 Aug 2023 12:29:30 -0400 Received: from mail-wm1-x32a.google.com (mail-wm1-x32a.google.com [IPv6:2a00:1450:4864:20::32a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A81A01701 for ; Mon, 14 Aug 2023 09:29:27 -0700 (PDT) Received: by mail-wm1-x32a.google.com with SMTP id 5b1f17b1804b1-3fe2fb9b4d7so41071425e9.1 for ; Mon, 14 Aug 2023 09:29:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1692030566; x=1692635366; 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=K3tfo/pRi0hQAQaOE5/zas7ptBfHYn16dneCzYANrATrmd3cGIQCdpXrOSTG7KmZ0W TREFgrM33FiAO9NawMoyEQPXfIrpXtWmy1S2UkQpjLruNNOQZMCNcnZcE43w2x0gQ1F7 PwHBa1x8W/wHh8Mclgn8dxWfDBHDyXvzNIdmhydpliJl+L+T/kkzvE1aWvxsCFKs+f19 kXxHbRMC8pILpeMi3haQMoCmGZTY/RR8BvW94n69Pv3FSWxwn3broP1bIJX7PyuMoHq4 LPCIW/J04ZkRRczjawHFJnvixsSAUBGQowv/xwk1Ysr5hjVYH+DQl+nF1EfHngThbg0R oh7A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692030566; x=1692635366; 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=iDT6L5Q8akA/RyfllxDNE1M1rbc8wJmBHGOnJpBSwpo6GubOpwKW9JktOwyZw9AzK4 q22pDVnn6Wv3IjOZsNkNizy1biBYfsnQ5fyqGJqePXdvbVKcDn77ozjYBbQRcDAQWzn8 BCqvnbXHlXtXUn8ELzwsLufz0TwfiLouUteBKKOH4euNAjcZR5xzkZRoQXGEmWDhR5Lp /bjMDoU1dE0gNwYW158Y2wyFHIpHzhn7vK0LqwCMF7V7yfrf9LEFw4z0I1uKvzNBjKch lrVlbTjnKSaNoQ4guoHHpYti1OXe19IMX3DR1MzSReFEPv4Zzm5tcXmURpRDkB6Xnx6F 2cAQ== X-Gm-Message-State: AOJu0YxYTgzeOCcmzNoNDGlCYdM20+PXk0+TqCE0DXdWqJ1jaSHlHd4f KUR2enFdJcNZ7P8tbWUlvRHmVg== X-Google-Smtp-Source: AGHT+IEVRfTa9DMGNwpE9nPby1QLZhfKTJZIH+YKW3oHOD/I3sg191THtlrKM2s/wSAsQb5bpSxyug== X-Received: by 2002:a7b:c3d8:0:b0:3fe:22a9:907 with SMTP id t24-20020a7bc3d8000000b003fe22a90907mr7548285wmj.20.1692030566183; Mon, 14 Aug 2023 09:29:26 -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 l14-20020a1c790e000000b003fc16ee2864sm14743475wme.48.2023.08.14.09.29.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Aug 2023 09:29:25 -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 v1 13/14] media: qcom: camss: Add support for setting CSIPHY clock name csiphyX Date: Mon, 14 Aug 2023 17:29:06 +0100 Message-ID: <20230814162907.3878421-14-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230814162907.3878421-1-bryan.odonoghue@linaro.org> References: <20230814162907.3878421-1-bryan.odonoghue@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org 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/media/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] = csiphy_match_clock_name(clock->name, "csiphy%d", k); + if (csiphy->rate_set[i]) + break; } } From patchwork Mon Aug 14 16:29:07 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bryan O'Donoghue X-Patchwork-Id: 713527 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 0A85FC25B5E for ; Mon, 14 Aug 2023 16:30:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232399AbjHNQ3o (ORCPT ); Mon, 14 Aug 2023 12:29:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52288 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232538AbjHNQ3b (ORCPT ); Mon, 14 Aug 2023 12:29:31 -0400 Received: from mail-lj1-x22f.google.com (mail-lj1-x22f.google.com [IPv6:2a00:1450:4864:20::22f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 19FB8E65 for ; Mon, 14 Aug 2023 09:29:29 -0700 (PDT) Received: by mail-lj1-x22f.google.com with SMTP id 38308e7fff4ca-2b9cdbf682eso67248891fa.2 for ; Mon, 14 Aug 2023 09:29:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1692030567; x=1692635367; 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=yWSfC4PTyf3c1S/i4WTl2tNnfkmumB5Ykd84R92bEPk=; b=cDDA/x6uAs9Fb/p3fnZNPWdLRpHIQkICXRmvtfXsLYbPEZca3GQOyIdWbd+wKaP+zR GXYTESy+Qrymyvq8hhqNN6c2KnCs0uGhbrjLYDRxo7s6rZVTW7VLLZSaY5+2iesYM6gs ebTMwFkfw8bmn4HleDEp62P+LOjHOEVl3rLStV9VyU0boggl8UZovgllNrHT3xuSdKok rDhgeEfAEcOydaO3skzqsi5vcpX2h0iGp2e4+1+hfy/VQLgJql+i3r+qiwWajascFSJR WL7QreSstUophq3R1rxFu36oP1SWEnNz9+xt1gOvKLORSFe/wr/E3hwOMy8NxVHzUmSL xOMw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692030567; x=1692635367; 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=yWSfC4PTyf3c1S/i4WTl2tNnfkmumB5Ykd84R92bEPk=; b=LYbvhHDFdgWiisizT+bEOUXubsrYN9iL50WxMxZqZYFIWKoUrs7ncEq/jcumX6ZNHN bOp0ILE5CmQKg4+whQ1kPJI7axPyLfKrpCG1lQSZUv9GoN5Astte04tXeugWDLRpaQNM XGZk65iLwzpXUL01CSCKKrUpiWohBzXSE5RHStjchUHCF+yI7hN5Qvaq0HB/rkuNm4QP 1vPU6kxkgf3yu37qYQvcGurf9iq1pW3GBSE8/jarFemVpEhRtBBFq37BX65N57kLjvSY HExWeRBN561DifSKgAqe4rF9xTusSep+VfdOB/ghwGzXM7Qu/+j1IXFu8yp//YcH91OW Uyew== X-Gm-Message-State: AOJu0YwXQh1GyXJhlNtsHxKNzeuQQPmGWV1S8jgNJJHGI53nPBELDVKN kpCI/B/wdZ2mzmbFN+67d3LIcA== X-Google-Smtp-Source: AGHT+IGxL4rwwl5RznxLtL6TcAZQpkatRNqXTeSe59I18disUu3EHlmBG24zBMwT/Yw3qKiWQJTA1w== X-Received: by 2002:a05:6512:10d4:b0:4fe:746:63d1 with SMTP id k20-20020a05651210d400b004fe074663d1mr7639216lfg.5.1692030567400; Mon, 14 Aug 2023 09:29:27 -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 l14-20020a1c790e000000b003fc16ee2864sm14743475wme.48.2023.08.14.09.29.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Aug 2023 09:29:26 -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 v1 14/14] media: qcom: camss: Support RDI3 for VFE 17x Date: Mon, 14 Aug 2023 17:29:07 +0100 Message-ID: <20230814162907.3878421-15-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230814162907.3878421-1-bryan.odonoghue@linaro.org> References: <20230814162907.3878421-1-bryan.odonoghue@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org Some VFEs have four RDIs apiece. Right now the ISR code has a hard-coded value which tops-out at RDI2 meaning only three RDIs can be utilised in practice. Extend out the various routines in camss-vfe-17x.c to support the higher RDI count. Signed-off-by: Bryan O'Donoghue --- drivers/media/platform/qcom/camss/camss-vfe-170.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/drivers/media/platform/qcom/camss/camss-vfe-170.c b/drivers/media/platform/qcom/camss/camss-vfe-170.c index 8aa921400ded0..c2487a8196db7 100644 --- a/drivers/media/platform/qcom/camss/camss-vfe-170.c +++ b/drivers/media/platform/qcom/camss/camss-vfe-170.c @@ -210,7 +210,8 @@ static void vfe_global_reset(struct vfe_device *vfe) GLOBAL_RESET_CMD_IDLE_CGC | GLOBAL_RESET_CMD_RDI0 | GLOBAL_RESET_CMD_RDI1 | - GLOBAL_RESET_CMD_RDI2; + GLOBAL_RESET_CMD_RDI2 | + GLOBAL_RESET_CMD_RDI3; writel_relaxed(BIT(31), vfe->base + VFE_IRQ_MASK_0); @@ -344,7 +345,7 @@ static void vfe_violation_read(struct vfe_device *vfe) static irqreturn_t vfe_isr(int irq, void *dev) { struct vfe_device *vfe = dev; - u32 status0, status1, vfe_bus_status[3]; + u32 status0, status1, vfe_bus_status[VFE_LINE_NUM_MAX]; int i, wm; status0 = readl_relaxed(vfe->base + VFE_IRQ_STATUS_0); @@ -353,7 +354,7 @@ static irqreturn_t vfe_isr(int irq, void *dev) writel_relaxed(status0, vfe->base + VFE_IRQ_CLEAR_0); writel_relaxed(status1, vfe->base + VFE_IRQ_CLEAR_1); - for (i = VFE_LINE_RDI0; i <= VFE_LINE_RDI2; i++) { + for (i = VFE_LINE_RDI0; i < vfe->line_num; i++) { vfe_bus_status[i] = readl_relaxed(vfe->base + VFE_BUS_IRQ_STATUS(i)); writel_relaxed(vfe_bus_status[i], vfe->base + VFE_BUS_IRQ_CLEAR(i)); } @@ -367,11 +368,11 @@ static irqreturn_t vfe_isr(int irq, void *dev) if (status0 & STATUS_0_RESET_ACK) vfe->isr_ops.reset_ack(vfe); - for (i = VFE_LINE_RDI0; i <= VFE_LINE_RDI2; i++) + for (i = VFE_LINE_RDI0; i < vfe->line_num; i++) if (status0 & STATUS_0_RDI_REG_UPDATE(i)) vfe->isr_ops.reg_update(vfe, i); - for (i = VFE_LINE_RDI0; i <= VFE_LINE_RDI2; i++) + for (i = VFE_LINE_RDI0; i < vfe->line_num; i++) if (status0 & STATUS_1_RDI_SOF(i)) vfe->isr_ops.sof(vfe, i);