From: Atanas Filipov <atanas.filipov@oss.qualcomm.com>
To: Bryan O'Donoghue <bryan.odonoghue@linaro.org>,
Mauro Carvalho Chehab <mchehab@kernel.org>
Cc: atanas.filipov@oss.qualcomm.com,
Vladimir Zapolskiy <vladimir.zapolskiy@linaro.org>,
Loic Poulain <loic.poulain@oss.qualcomm.com>,
Gjorgji Rosikopulos <gjorgji.rosikopulos@oss.qualcomm.com>,
linux-media@vger.kernel.org, linux-arm-msm@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: [PATCH v2 1/6] media: qcom: camss: factor out the VFE minimum clock rate
Date: Sat, 24 Oct 2026 12:40:22 +0300 [thread overview]
Message-ID: <20261024094027.3095475-2-atanas.filipov@oss.qualcomm.com> (raw)
In-Reply-To: <20261024094027.3095475-1-atanas.filipov@oss.qualcomm.com>
vfe_set_clock_rates() and vfe_check_clock_rates() both compute the
minimum clock rate needed by the VFE lines from their pixel rates,
inside the loop over the VFE clocks. The result is the same for every
clock.
Move the computation into vfe_get_min_clock_rate() and call it once
per VFE, so that the clock loops only select and check rates. No
functional change.
Signed-off-by: Atanas Filipov <atanas.filipov@oss.qualcomm.com>
---
drivers/media/platform/qcom/camss/camss-vfe.c | 108 ++++++++----------
1 file changed, 46 insertions(+), 62 deletions(-)
diff --git a/drivers/media/platform/qcom/camss/camss-vfe.c b/drivers/media/platform/qcom/camss/camss-vfe.c
index 2680a9914765..59be37f83df3 100644
--- a/drivers/media/platform/qcom/camss/camss-vfe.c
+++ b/drivers/media/platform/qcom/camss/camss-vfe.c
@@ -935,52 +935,66 @@ static bool vfe_check_clock_levels(struct camss_clock *clock)
}
/*
- * vfe_set_clock_rates - Calculate and set clock rates on VFE module
+ * vfe_get_min_clock_rate - Get the minimum VFE clock rate for its lines
* @vfe: VFE device
*
- * Return 0 on success or a negative error code otherwise
+ * Return the highest rate needed by the VFE lines for their pixel rates,
+ * including the clock margin, or 0 if no pixel rate is available
*/
-static int vfe_set_clock_rates(struct vfe_device *vfe)
+static u64 vfe_get_min_clock_rate(struct vfe_device *vfe)
{
- struct device *dev = vfe->camss->dev;
u64 pixel_clock[VFE_LINE_NUM_MAX];
- int i, j;
- int ret;
+ u64 min_rate = 0;
+ int i;
for (i = VFE_LINE_RDI0; i < vfe->res->line_num; i++) {
- ret = camss_get_pixel_clock(&vfe->line[i].subdev.entity,
- &pixel_clock[i]);
- if (ret)
+ if (camss_get_pixel_clock(&vfe->line[i].subdev.entity,
+ &pixel_clock[i]))
pixel_clock[i] = 0;
}
- for (i = 0; i < vfe->nclocks; i++) {
- struct camss_clock *clock = &vfe->clock[i];
+ for (i = VFE_LINE_RDI0; i < vfe->res->line_num; i++) {
+ u32 tmp;
+ u8 bpp;
- if (vfe_match_clock_names(vfe, clock) && vfe_check_clock_levels(clock)) {
- u64 min_rate = 0;
- long rate;
+ if (i == VFE_LINE_PIX) {
+ tmp = pixel_clock[i];
+ } else {
+ struct vfe_line *l = &vfe->line[i];
- for (j = VFE_LINE_RDI0; j < vfe->res->line_num; j++) {
- u32 tmp;
- u8 bpp;
+ bpp = camss_format_get_bpp(l->formats,
+ l->nformats,
+ l->fmt[MSM_VFE_PAD_SINK].code);
+ tmp = pixel_clock[i] * bpp / 64;
+ }
- if (j == VFE_LINE_PIX) {
- tmp = pixel_clock[j];
- } else {
- struct vfe_line *l = &vfe->line[j];
+ if (min_rate < tmp)
+ min_rate = tmp;
+ }
- bpp = camss_format_get_bpp(l->formats,
- l->nformats,
- l->fmt[MSM_VFE_PAD_SINK].code);
- tmp = pixel_clock[j] * bpp / 64;
- }
+ camss_add_clock_margin(&min_rate);
- if (min_rate < tmp)
- min_rate = tmp;
- }
+ return min_rate;
+}
- camss_add_clock_margin(&min_rate);
+/*
+ * vfe_set_clock_rates - Calculate and set clock rates on VFE module
+ * @vfe: VFE device
+ *
+ * Return 0 on success or a negative error code otherwise
+ */
+static int vfe_set_clock_rates(struct vfe_device *vfe)
+{
+ struct device *dev = vfe->camss->dev;
+ u64 min_rate = vfe_get_min_clock_rate(vfe);
+ int i, j;
+ int ret;
+
+ for (i = 0; i < vfe->nclocks; i++) {
+ struct camss_clock *clock = &vfe->clock[i];
+
+ if (vfe_match_clock_names(vfe, clock) && vfe_check_clock_levels(clock)) {
+ long rate;
for (j = 0; j < clock->nfreqs; j++)
if (min_rate < clock->freq[j])
@@ -1024,45 +1038,15 @@ static int vfe_set_clock_rates(struct vfe_device *vfe)
*/
static int vfe_check_clock_rates(struct vfe_device *vfe)
{
- u64 pixel_clock[VFE_LINE_NUM_MAX];
- int i, j;
- int ret;
-
- for (i = VFE_LINE_RDI0; i < vfe->res->line_num; i++) {
- ret = camss_get_pixel_clock(&vfe->line[i].subdev.entity,
- &pixel_clock[i]);
- if (ret)
- pixel_clock[i] = 0;
- }
+ u64 min_rate = vfe_get_min_clock_rate(vfe);
+ int i;
for (i = 0; i < vfe->nclocks; i++) {
struct camss_clock *clock = &vfe->clock[i];
if (vfe_match_clock_names(vfe, clock) && vfe_check_clock_levels(clock)) {
- u64 min_rate = 0;
unsigned long rate;
- for (j = VFE_LINE_RDI0; j < vfe->res->line_num; j++) {
- u32 tmp;
- u8 bpp;
-
- if (j == VFE_LINE_PIX) {
- tmp = pixel_clock[j];
- } else {
- struct vfe_line *l = &vfe->line[j];
-
- bpp = camss_format_get_bpp(l->formats,
- l->nformats,
- l->fmt[MSM_VFE_PAD_SINK].code);
- tmp = pixel_clock[j] * bpp / 64;
- }
-
- if (min_rate < tmp)
- min_rate = tmp;
- }
-
- camss_add_clock_margin(&min_rate);
-
rate = clk_get_rate(clock->clk);
if (rate < min_rate)
return -EBUSY;
--
2.34.1
next prev parent reply other threads:[~2026-10-24 9:40 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-24 9:40 [PATCH v2 0/6] media: qcom: camss: share VFE clock sources on SM8250 Atanas Filipov
2026-10-24 9:40 ` Atanas Filipov [this message]
2026-10-26 9:07 ` [PATCH v2 1/6] media: qcom: camss: factor out the VFE minimum clock rate Bryan O'Donoghue
2026-10-24 9:40 ` [PATCH v2 2/6] media: qcom: camss: clamp VFE clock rates to the highest level Atanas Filipov
2026-10-26 9:08 ` Bryan O'Donoghue
2026-10-26 9:28 ` Loic Poulain
2026-10-26 13:18 ` Atanas Filipov
2026-10-24 9:40 ` [PATCH v2 3/6] media: qcom: camss: sm8250: do not set VFE core clock rates from CSID Atanas Filipov
2026-10-26 9:08 ` Bryan O'Donoghue
2026-10-24 9:40 ` [PATCH v2 4/6] media: qcom: camss: share VFE clock sources by the highest rate Atanas Filipov
2026-10-26 9:13 ` Bryan O'Donoghue
2026-10-26 13:18 ` Atanas Filipov
2026-10-24 9:40 ` [PATCH v2 5/6] media: qcom: camss: sm8250: set the VFE AREG clock rate from the VFE Atanas Filipov
2026-10-26 9:22 ` Bryan O'Donoghue
2026-10-26 13:18 ` Atanas Filipov
2026-10-24 9:40 ` [PATCH v2 6/6] media: qcom: camss: sm8250: set the camera NoC AXI " Atanas Filipov
2026-10-26 9:25 ` Bryan O'Donoghue
2026-10-26 13:18 ` Atanas Filipov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261024094027.3095475-2-atanas.filipov@oss.qualcomm.com \
--to=atanas.filipov@oss.qualcomm.com \
--cc=bryan.odonoghue@linaro.org \
--cc=gjorgji.rosikopulos@oss.qualcomm.com \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=loic.poulain@oss.qualcomm.com \
--cc=mchehab@kernel.org \
--cc=vladimir.zapolskiy@linaro.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®