From nobody Tue Dec 2 02:32:14 2025 Received: from mail-pf1-f178.google.com (mail-pf1-f178.google.com [209.85.210.178]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1CE7F311C22 for ; Thu, 20 Nov 2025 08:50:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.178 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763628602; cv=none; b=Ay8s+Xd0purTNh3Xvrel7xGMIuhxk/A1nGzDdvC3g8VjirhBPztsGY9/fUkh0/qgT2uMLq0JL2GJT1415dznEwuRUGblRXujkCFRrj7kSInWBuRmNtRN+y3DXG3/qDw54lgMha2NrpyObc0R/ykTByHSFQ2Mn7Ff+ASR0OPNBNg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763628602; c=relaxed/simple; bh=q9U2/lglyvUZ+6SzKjNSNlDwmEjWmsKN97d6E/pOIIw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ZUpeZPGJ2itZDLZ2ejUGl7Ya/M7e5OFxIBMZrDYBClLAag9zvIflbg4VQHY7yRBz0FAivdKDbL8ebwbprcjdCDBSTzQXWI1sKYYPabN26DeG+tZMjtzjkF4FPOfTSPPlVl+uEUPSraRUntRUQbMeiYNrK8+J8KGeMtViK7dZu/Q= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=GB/nbm5C; arc=none smtp.client-ip=209.85.210.178 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="GB/nbm5C" Received: by mail-pf1-f178.google.com with SMTP id d2e1a72fcca58-7b852bb31d9so803943b3a.0 for ; Thu, 20 Nov 2025 00:50:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1763628600; x=1764233400; darn=vger.kernel.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=n7GOu69hsNGmnIy0MHORKTrtvDnS7Wvg9FFJEsAiMq0=; b=GB/nbm5CqaiIYh0XzpNVZ5KKW85pPhZu50I/z6bZj3F1GEouQBSqfXaawMQSfm1zdN n/ndc7T3CFr3ISkX+d8FknMTZx4eDPnfR8YDkLYr1axwAypJx+8koiyh4GUap45h+IZT 5PFzN9/fyNUdLjsLD98KAgsLefYfA4xsZTgQp2bTNjV+iAKhWklnzTVUssiiWsuTWOv0 6RLJm534RfDTljqQhEVZYNkZtEtpwRIZ+c+rZNWaozyfYfjGDsdjxRks25i0k3oC5NIo 1y1kJK+LmfvatzP23yiI+G9mfk8G1cVYtZkgb/qXJVsvAiXFuYUVo3khkrDB1ls3bWoA gylQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1763628600; x=1764233400; 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=n7GOu69hsNGmnIy0MHORKTrtvDnS7Wvg9FFJEsAiMq0=; b=MOj8kzpcQtRyBG43Sr82GIbflav6XKdrIc6hHVhFaqRxMYHs7DNd9C1meqo5RvqhCy Sz5VWUHpX9A080E66Gr9nWnDevmkcKqPOn66RfyetixipXVylDC6GAgNFBVrNm3TGFbf LPgW0m0k8xMD/I6P70P+l1HUwNXCbtGz0zb6RGo9LfEGGaeEojiuxlBypOnwEc1i1oNJ wvY8r3NCfwsGSBeAyd8/PQOda12O7j1d5cOPgioyzsubj29UCaBLtDd1JlNECxt4Td6Y y7ErGz3Q2bjnpgifwJoyoFVts9Y3L6bN4RqdutubKljtUtKlUSRMpV4kYFIQP1in4axU nGJw== X-Gm-Message-State: AOJu0YxFuUCBhfAYOHEoifKUCYOEJ48uic6ij+uHk+EfUZPTirfF3h5c NnCxK3DKgLVw5TQRH2RoZ26w5oOjQ1gX5sl155Dcn+eNXYwfMIJPr7Sc X-Gm-Gg: ASbGncsQkSyrtuRtQr0YyCu0Ey7XrvkZQAexzv77Z7TyBbQQ+S15zzQEz/yNmtOHD2w loRFI1LPSlB3a0Hl/GWkhiuqEcEFyhZnsqMHTfPBZnYCUFYz8FOfvUK+vtNfSyBGSRreuB+LXu9 AvTIfJmDxRGo5+X8MENCJ44XjgPYyVghFU09z95Zv4HwEKD9m6DIRq0ZiCfdabZt2dF5J1VevDo ufB4Lwv7U1BUSWlKyliqxZs8YguUwcLKeR5yopfdKoVcWT5ZcDJpOycr2L4u8cx1c237pTwMmMV y/iBS5+jRe9LyYp7IMTR2SRj6d8EUIxSNLMAlbEnhnKnKcR8E+rojIZ8B8mD5LAVDw9adYDBcnt Dt0X4Amgyr3ZPwkRwlCko3PhZLzOQB70syZHnbTF1aQE4vvB8EZe5XnG8xc4BxitOHXMsGs+ShB BMITnS963JNehFuA5GaIjySuzJmLKM8qYgCzrxrP/SCuIu4iWp X-Google-Smtp-Source: AGHT+IETrPi74BdCXGprduZagz7q3BGs8jaQJi/0NaAzVeg4Go0h6DCV8yKgZzo5mAFfrmlHcc2nJA== X-Received: by 2002:a05:6a20:3d1a:b0:35e:6a5b:cbc9 with SMTP id adf61e73a8af0-3613b62b45fmr3420426637.50.1763628600413; Thu, 20 Nov 2025 00:50:00 -0800 (PST) Received: from opensource206.. ([157.50.102.16]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-7c3f023fba8sm1974900b3a.41.2025.11.20.00.49.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 20 Nov 2025 00:50:00 -0800 (PST) From: Pavan Bobba To: skhan@linuxfoundation.org, kieran.bingham@ideasonboard.com, mchehab@kernel.org Cc: linux-kernel@vger.kernel.org, linux-media@vger.kernel.org, Pavan Bobba Subject: [PATCH 4/5] media: vimc: capture: support custom bytesperline values Date: Thu, 20 Nov 2025 14:19:25 +0530 Message-ID: <20251120084926.18620-5-opensource206@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251120084926.18620-1-opensource206@gmail.com> References: <20251120084926.18620-1-opensource206@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Allow userspace to request custom bytesperline (stride) values in the vimc capture driver. The driver now clamps the requested value to a valid range instead of forcing a fixed stride. The minimum bytesperline is width * bytes_per_pixel, while the maximum is limited by VIMC_FRAME_MAX_WIDTH * bytes_per_pixel. This makes the virtual capture node behave more like real hardware that supports aligned or padded scanlines. Signed-off-by: Pavan Bobba --- drivers/media/test-drivers/vimc/vimc-capture.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/drivers/media/test-drivers/vimc/vimc-capture.c b/drivers/media= /test-drivers/vimc/vimc-capture.c index 7f6124025fc9..7164ec51eb80 100644 --- a/drivers/media/test-drivers/vimc/vimc-capture.c +++ b/drivers/media/test-drivers/vimc/vimc-capture.c @@ -85,6 +85,7 @@ static int vimc_capture_try_fmt_vid_cap(struct file *file= , void *priv, { struct v4l2_pix_format *format =3D &f->fmt.pix; const struct vimc_pix_map *vpix; + u32 min_bpl, max_bpl; =20 format->width =3D clamp_t(u32, format->width, VIMC_FRAME_MIN_WIDTH, VIMC_FRAME_MAX_WIDTH) & ~1; @@ -97,8 +98,18 @@ static int vimc_capture_try_fmt_vid_cap(struct file *fil= e, void *priv, format->pixelformat =3D fmt_default.pixelformat; vpix =3D vimc_pix_map_by_pixelformat(format->pixelformat); } - /* TODO: Add support for custom bytesperline values */ - format->bytesperline =3D format->width * vpix->bpp; + + /* Calculate the minimum supported bytesperline value */ + min_bpl =3D format->width * vpix->bpp; + /* Calculate the maximum supported bytesperline value */ + max_bpl =3D VIMC_FRAME_MAX_WIDTH * vpix->bpp; + + /* Clamp bytesperline to the valid range */ + if (format->bytesperline > max_bpl) + format->bytesperline =3D max_bpl; + if (format->bytesperline < min_bpl) + format->bytesperline =3D min_bpl; + format->sizeimage =3D format->bytesperline * format->height; =20 if (format->field =3D=3D V4L2_FIELD_ANY) --=20 2.43.0