From patchwork Wed Feb 4 20:37:26 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Faizel K B X-Patchwork-Id: 26090 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id 18AEBBD78E for ; Wed, 4 Feb 2026 20:38:18 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id C1BF562053; Wed, 4 Feb 2026 21:38:17 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="HpCRo7AZ"; dkim-atps=neutral Received: from mail-pl1-x631.google.com (mail-pl1-x631.google.com [IPv6:2607:f8b0:4864:20::631]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 24D126204A for ; Wed, 4 Feb 2026 21:38:15 +0100 (CET) Received: by mail-pl1-x631.google.com with SMTP id d9443c01a7336-2a08cb5e30eso561635ad.1 for ; Wed, 04 Feb 2026 12:38:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1770237494; x=1770842294; darn=lists.libcamera.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=PvVwdLZlh8MPfXBeT9fb7vVP3darfYnE88ZGrjLridM=; b=HpCRo7AZo7SL5d3lfDLU4jUCihf73jwn0b50uLONJNthQ/nFMdTXJsn3gm8+2ewv1C 0ovSUBsfbzY0TqCS4+8Q0/aIVmqCw9foZzph+apUDRN4rGIx4n8w9EyuIXnrRaJorelS iz/Rm3n6jKcJvv5u9yyfgaUnWR5ffnfYcQ+qoREthqPIe8PktIekAhWQTPRkE/2FAkdm HkzyIqSJ3QoK7Tdh3q8F6UT/xwZ+US2FisteTEA0cjXBgwiUf4wnyFvTEjpTaNTXlFIc 58is1Zrk0CEsNpLnMinRT3c4v2uWVgn06kObXajdgR45A9ZyxJTfdNYQW9kIiPEC4fyB uvyg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1770237494; x=1770842294; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=PvVwdLZlh8MPfXBeT9fb7vVP3darfYnE88ZGrjLridM=; b=pkHRtNnMZuF3VlHaBGUCuVq6lyBUFpZxP1CCLXwoIfaIFgDMzfMhR126DS9sN0c4K5 YR0b8xoThRsoFqoO0f5qnVIHEJU9SlgtPuNLorvAc03GtrMScMStzvxXrkJM946p3cQu 4bm4loasMf1PmGF8OLo3mz1NqmoKRL+Z/+03CfAlHiW+6D6zjJffglLOpS00HgSOXBP9 o6+p7GZQJ5XIaF7VfJtuVbKfkm/qkV+RxQeSN49QA/SxggVfPoNxPsoucxzegwzYnzjP ENzbAyjtbFas3AGjkdbCP1x2BWndojVo7srYekhifXiaB7G1Hp1Gpq2tC4flc3yMGG8c SSLA== X-Forwarded-Encrypted: i=1; AJvYcCVvOZCfo7vAu4ODjBdrpTUEgTfEb249FA2oHFB9+BcU/+YSMizDtvPOjV805gNUS/QcaJJ7xFEILNbw4+PFm6k=@lists.libcamera.org X-Gm-Message-State: AOJu0YxFk5zgHMoAgwRKVSB+oP0TuMUrTuuZ4Qhj8AboDwT5xbBkMN4b DlydyMMwycINBuSGSoAsTJNbXwjwzVmWfLtzQ6wBwRT2a2PG1edOtQYEMDx12dye X-Gm-Gg: AZuq6aK64N/yuOGVZEGBM+F+BebsNPDj/Pkj2DSAtv/XTgynkLPDMdP1/OSqkkR//A6 //0k/jIfXa21KaAVxypHYvqbkq9iOYQzJgoqR3hWci7dtXr0SZL5Z47jbRNUO8wtvacdsGOYtLM abR4rc66SWf/BqYNb43sSWOexYEU3noxS12hkpwcRIwpBKoPp/qM/qb5pDuAyXyy4i09OvoADOf xljpfAudNH08JUgkfbRk7C0DWEHDO4SqYzlbtMb/Pb/KTP2+7Uts0W3DU+OqU9VAV867fBA9DvA sAOV52STVfe+wNzxjyW5MVIlibLJntvC2iaWtnUynRfilThRE8x9s9S9xwAqj/w0EbjvbotA/WU ap1RL9uPpJQMFlc5uQpqjKSnwcklh3lkixsBDVF7oMlCc38Eh4T79yt2dV6a1011MS1yZTXafHA j3mRj+CmyUGvPZNdlKRxnoeQ2mgbyGay4GsuXQi6MNaOL7 X-Received: by 2002:a17:902:c411:b0:2a0:f0c7:9998 with SMTP id d9443c01a7336-2a933fb7ed4mr30227995ad.6.1770237493772; Wed, 04 Feb 2026 12:38:13 -0800 (PST) Received: from FAIZEL-KB.. ([2001:569:5999:dc00:876b:c389:85e5:7957]) by smtp.googlemail.com with ESMTPSA id d9443c01a7336-2a933974884sm31136955ad.83.2026.02.04.12.38.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Feb 2026 12:38:13 -0800 (PST) From: Faizel K B To: Shuah Khan , Laurent Pinchart , Kieran Bingham , linux-media@vger.kernel.org Cc: Mauro Carvalho Chehab , libcamera-devel@lists.libcamera.org, Faizel K B Subject: [PATCH v3 3/3] media: vimc: streamer: Apply sensor frame rate in streamer thread Date: Wed, 4 Feb 2026 12:37:26 -0800 Message-ID: <20260204203726.1820226-4-faizel.kb@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260204203726.1820226-1-faizel.kb@gmail.com> References: <20260204203726.1820226-1-faizel.kb@gmail.com> MIME-Version: 1.0 X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Use the sensor's pre-calculated jiffies value to add appropriate delay between frames according to the configured timing value. The actual frame rate will vary depending on processing delays in other media pipeline components. Tested using yavta frame rate display with QCIF resolution: yavta --capture= Signed-off-by: Faizel K B --- .../media/test-drivers/vimc/vimc-streamer.c | 33 +++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) diff --git a/drivers/media/test-drivers/vimc/vimc-streamer.c b/drivers/media/test-drivers/vimc/vimc-streamer.c index 15d863f97cbf..3ebf5798fa3d 100644 --- a/drivers/media/test-drivers/vimc/vimc-streamer.c +++ b/drivers/media/test-drivers/vimc/vimc-streamer.c @@ -139,6 +139,29 @@ static int vimc_streamer_pipeline_init(struct vimc_stream *stream, return -EINVAL; } +/** + * vimc_streamer_get_sensor() - Get sensor from pipeline + * @stream: the pipeline + * + * Helper function to find the sensor device in the pipeline. + * Returns pointer to sensor device or NULL if not found. + */ +static struct vimc_sensor_device *vimc_streamer_get_sensor(struct vimc_stream *stream) +{ + int i; + + for (i = 0; i < stream->pipe_size; i++) { + struct vimc_ent_device *ved = stream->ved_pipeline[i]; + + if (ved && ved->ent && + ved->ent->function == MEDIA_ENT_F_CAM_SENSOR) { + return container_of(ved, struct vimc_sensor_device, ved); + } + } + + return NULL; +} + /** * vimc_streamer_thread - Process frames through the pipeline * @@ -154,25 +177,31 @@ static int vimc_streamer_pipeline_init(struct vimc_stream *stream, static int vimc_streamer_thread(void *data) { struct vimc_stream *stream = data; + struct vimc_sensor_device *vsensor; u8 *frame = NULL; int i; + unsigned long fps_jiffies; + const unsigned long default_jiffies = HZ / 30; set_freezable(); + vsensor = vimc_streamer_get_sensor(stream); for (;;) { try_to_freeze(); if (kthread_should_stop()) break; + /* Read from hardware configuration */ + fps_jiffies = vsensor ? vsensor->hw.fps_jiffies : default_jiffies; + for (i = stream->pipe_size - 1; i >= 0; i--) { frame = stream->ved_pipeline[i]->process_frame( stream->ved_pipeline[i], frame); if (!frame || IS_ERR(frame)) break; } - //wait for 60hz set_current_state(TASK_UNINTERRUPTIBLE); - schedule_timeout(HZ / 60); + schedule_timeout(fps_jiffies); } return 0;