From patchwork Thu Oct 15 19:43:26 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ray Strode X-Patchwork-Id: 28460 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 98321C3305 for ; Thu, 15 Oct 2026 19:49:46 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id CC5CC68E20; Thu, 15 Oct 2026 21:49:43 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="rvrLXKra"; dkim-atps=neutral Received: from mail-qk1-x72a.google.com (mail-qk1-x72a.google.com [IPv6:2607:f8b0:4864:20::72a]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 8DCA468E05 for ; Thu, 15 Oct 2026 21:43:36 +0200 (CEST) Received: by mail-qk1-x72a.google.com with SMTP id af79cd13be357-93efc0452b5so132275285a.0 for ; Thu, 15 Oct 2026 12:43:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1792093415; x=1792698215; darn=lists.libcamera.org; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:from:to:cc:subject:date:message-id:reply-to:content-type; bh=5s8faA7jZdteqp28EQ0GdY0QY4x2WiCEleQ1o7WB1iE=; b=rvrLXKraNxq8jadtXlaWV0O4yAWEFwy/6YYGTjERZjbrtn0rrWkZyrD/1UY963Zu3n 3zv6nPAhUTMtCA7lSa1xZmQePLmdfV24SHJ+JLw8SxQfUCP6NhEOglOGhqGghSYUefvU JdLIbOdenvCJ9hvPNQ/Eqb+A2bnV6cg8S1DApdTMn0usVCcEDKANUZyXUPN7bVMcS42n Nelk5YVyzILdH3ZAIfI4PgPDlqpdbgzP4gJtvdS1J46uzprjFmVibhr/hfEOma4G10xk kGZwyfI1h0nNPb4/OyRkRgfcrC+uaoZx/FWAFvxv4DflpQHYM8LOjGamohnCx/UW/omX Zafw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1792093415; x=1792698215; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to:content-type; bh=5s8faA7jZdteqp28EQ0GdY0QY4x2WiCEleQ1o7WB1iE=; b=boKjNtgvmBJOKt3ykFLWq2nKh2/K0Hk60xCmYCQqjsvgbCfYCt2D518cqob/9Z300C SPsPBwiA9OegVLplJdKhXjD1jay+vNbItyIJvsXL9Q6/4HXgL9AIlLIwQHkZc16a+/OD QZnG5DOWCUrvYvXWeIXIbvP9g5k/1wQ9bzftqw51SL5pDRMWFR6V7zDiY3ON7RTYIuVV nevnv7DrOvXxWunhI98HJnqoG1tlOR/74bHlTaGu6QQyTK7IyxT509oGE5XwBATuaMyR UA3HCIKL93PtkzG8lFJszWSk5m6b1Ya3KjRncQtoIkkjp+lSBZpjEXlLaUyMUf/C3I+F XPmA== X-Gm-Message-State: AFq9FYJswOIz2vqJdEDm8bGxUWiXBv86+BikynOuXAqM71Q68PHgNEao VCufw3y955mPRjNcp30glXHS6wtZeN8byIACmo2Mz0RvwTWG6RLWiqOUbhwf5H6iiyk= X-Gm-Gg: AYBFou0HrdhVp7M3FTCwMPnAshkQlicHvjZhGjjZWLRMkWIq7ClGWgDuUXjzf4WH/q5 ebBOPOeil5wcVj4WKfxw7jFMi1mpz3dZ2LdPXZVm2DAiHE5Eae8V7VVFj/x9Sw0h7L+0IcsEQhJ FybXhOUVGZgvQx0DRS1ZxNc5RzWbbjZne4AwjzJWyS+6zdLESBqJSPiBnNkm582ZEJtG6DeXlBa 1+2mXfs4SKTDGhDaB7f1jKprfnoMPDUMulFD11FI9M/9q2pSFVBA37m4uRjzX41UP2+nkMEAXxg I/JAdZ0a1QJT3nqQ/8rgspK3jbGC41+a1Cu/p7b0/3deNjag2/Ct0is3iW1Lo18D/1yfr+z0vBN c+8pmquf/C/JqygfdFB8tYrGe9gzXRykuYxFrutDdnPVFyBF6XQa6JrfH9OKZLpURtkWGchmMSp Aa4OcTE02KHuy7hOGedfVmikiC44/pR5Bhp85qIUvBVIBPPMLz4PCwfd9UTkwkLMSCg7m0wgU1/ VTQXL1DCQQC0rJ7fwfCFKkFvQ== X-Received: by 2002:a05:620a:6405:b0:939:b8d6:9b1c with SMTP id af79cd13be357-93ebd211377mr3118371485a.19.1792093415177; Thu, 15 Oct 2026 12:43:35 -0700 (PDT) Received: from localhost ([144.121.52.163]) by smtp.gmail.com with ESMTPSA id af79cd13be357-93f1a16b5e4sm15446685a.14.2026.10.15.12.43.34 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Oct 2026 12:43:34 -0700 (PDT) From: Ray Strode To: libcamera-devel@lists.libcamera.org Subject: [PATCH] v4l2: Read fixed format when the setter is unsupported Date: Thu, 15 Oct 2026 15:43:26 -0400 Message-ID: <20261015194326.287935-1-halfline@gmail.com> X-Mailer: git-send-email 2.56.0 MIME-Version: 1.0 X-Mailman-Approved-At: Thu, 15 Oct 2026 21:49:41 +0200 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" From: Ray Strode V4L2 subdevice format negotiation uses the format setter to obtain an accepted pad format. Fixed-format subdevices may omit that ioctl, so their existing format cannot be returned through the setter path. This commit reads the existing format when the setter reports ENOTTY, using the same active or try format selection. Other failures retain the usual error handling. Signed-off-by: Ray Strode --- src/libcamera/v4l2_subdevice.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/libcamera/v4l2_subdevice.cpp b/src/libcamera/v4l2_subdevice.cpp index a69de154..12a320d6 100644 --- a/src/libcamera/v4l2_subdevice.cpp +++ b/src/libcamera/v4l2_subdevice.cpp @@ -1393,60 +1393,64 @@ int V4L2Subdevice::getFormat(const Stream &stream, V4L2SubdeviceFormat *format, * \param[in] stream The stream the format is to be applied to * \param[inout] format The image bus format to apply to the stream * \param[in] whence The format to set, \ref V4L2Subdevice::ActiveFormat * "ActiveFormat" or \ref V4L2Subdevice::TryFormat "TryFormat" * * Apply the requested image format to the desired stream and return the * actually applied format parameters, as getFormat() would do. * * \return 0 on success or a negative error code otherwise */ int V4L2Subdevice::setFormat(const Stream &stream, V4L2SubdeviceFormat *format, Whence whence) { struct v4l2_subdev_format subdevFmt = {}; subdevFmt.which = whence; subdevFmt.pad = stream.pad; subdevFmt.stream = stream.stream; subdevFmt.format.width = format->size.width; subdevFmt.format.height = format->size.height; subdevFmt.format.code = format->code; subdevFmt.format.field = V4L2_FIELD_NONE; if (format->colorSpace) { fromColorSpace(format->colorSpace, subdevFmt.format); /* The CSC flag is only applicable to source pads. */ if (entity_->pads()[stream.pad]->flags() & MEDIA_PAD_FL_SOURCE) subdevFmt.format.flags |= V4L2_MBUS_FRAMEFMT_SET_CSC; } int ret = ioctl(VIDIOC_SUBDEV_S_FMT, &subdevFmt); + /* Fixed-format subdevices may not implement a format setter. */ + if (ret == -ENOTTY) + return getFormat(stream, format, whence); + if (ret) { LOG(V4L2, Error) << "Unable to set format on pad " << stream << ": " << strerror(-ret); return ret; } format->size.width = subdevFmt.format.width; format->size.height = subdevFmt.format.height; format->code = subdevFmt.format.code; format->colorSpace = toColorSpace(subdevFmt.format); return 0; } /** * \fn V4L2Subdevice::setFormat(unsigned int pad, V4L2SubdeviceFormat *format, * Whence whence) * \brief Set an image format on one of the V4L2 subdevice pads * \param[in] pad The 0-indexed pad number the format is to be applied to * \param[inout] format The image bus format to apply to the subdevice's pad * \param[in] whence The format to set, \ref V4L2Subdevice::ActiveFormat * "ActiveFormat" or \ref V4L2Subdevice::TryFormat "TryFormat" * * Apply the requested image format to the desired media pad and return the * actually applied format parameters, as getFormat() would do. * * \return 0 on success or a negative error code otherwise */