From patchwork Tue Sep 16 12:28:22 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 24368 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 7CF85BE173 for ; Tue, 16 Sep 2025 12:28:41 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id E500169371; Tue, 16 Sep 2025 14:28:40 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="Gwj2Ci92"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 266A269371 for ; Tue, 16 Sep 2025 14:28:38 +0200 (CEST) Received: from [192.168.0.172] (mob-5-90-51-255.net.vodafone.it [5.90.51.255]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id BAD64DF3; Tue, 16 Sep 2025 14:27:18 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1758025639; bh=m6UKSto21lH4DyPU8izBwOOwuVC+d0tBZtGMWkTJvDE=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=Gwj2Ci92up1nRJnXpqbV51ALSH2LtrMJVUuq39Qo9ulECneOQGFuOX+Bk8h1s9ppv CYmwvc81TdLL1FS5d2nVxpNFsNnUbIi2OFSxPTzYdlfD+uzmEVQphZEWgj6x2lw16p 8eS2zBWIN4TvzcD8kHbqfkH0hS/zb82+ewuqgBm4= From: Jacopo Mondi Date: Tue, 16 Sep 2025 14:28:22 +0200 Subject: [PATCH v2 1/4] include: linux: Add v4l2-isp.h MIME-Version: 1.0 Message-Id: <20250916-v4l2-params-v2-1-764471ed6435@ideasonboard.com> References: <20250916-v4l2-params-v2-0-764471ed6435@ideasonboard.com> In-Reply-To: <20250916-v4l2-params-v2-0-764471ed6435@ideasonboard.com> To: libcamera-devel@lists.libcamera.org Cc: Jacopo Mondi , Antoine Bouyer X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=5197; i=jacopo.mondi@ideasonboard.com; h=from:subject:message-id; bh=m6UKSto21lH4DyPU8izBwOOwuVC+d0tBZtGMWkTJvDE=; b=owEBbQKS/ZANAwAKAXI0Bo8WoVY8AcsmYgBoyVfxSEwUApcymPTjAHbZd4mSbHxBl85OsOgtE SE5QnUfYdWJAjMEAAEKAB0WIQS1xD1IgJogio9YOMByNAaPFqFWPAUCaMlX8QAKCRByNAaPFqFW PLQuEACnuswjJZj8jnhLhYh3Yh528F8KskvQd094JKdZl+SX6rIOMchdEX8no/9F/9uNEBrWypo r8X9vJsg569qynYSPixsJP8SfZ/zNJHvUVXxZuQw61f+oyOXs3ayyabWOBvX0kopPmdXxrIM3vM spq8F65sRfk66QoHmaklPdMeViWfCf7VfintAVjx502/FI3kDC/+HcbBCIZLrJ+Vak/h/QgwGV2 5ylaKAQL6JV7Th9DLJf6oJ0Yjijuvt11bZ9tJnefrXFOS0Ej00sRXf7+B97KwU959OvEzHPSlGj Tnr/UMScxrzhQm7oLwPWbjI/2Om6+8sOaezs/NT8DuhX0k6M6UxkCn9JYcwpkSwg4AND9QCAKVH WjdYEX7I0rFnmnQpPzVZDxCyJ0/8fV3052PSFj5/T3MLSNuvfg9RDrc/2qfXS6MlVC5zqWTvCtg prVxXniiKdgJsiPtX1a+j6N0NuaSjttlngwa0iJs3af49uZMSxqhRZ2cZZBf0PJ/2sTBxGBVnhX CPWq/+C7VeHk9rtXN/SO+euDgL+ZfNy3HhWkoGxSuaa3TUQ8cBdPNdvi9FPsPkde4ckRz46GcSx TmT/ddML3zwT+uYqzSjPUl1GYBujADGUS7kuJ/l4lVbPWzZ1Zn9cz70svuOdGuLy3ldTi+hQe6P bVQC8O1orO15N/Q== X-Developer-Key: i=jacopo.mondi@ideasonboard.com; a=openpgp; fpr=72392EDC88144A65C701EA9BA5826A2587AD026B 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" Import the v4l2-isp.h header from the Linux kernel sources. The file has not been merged in mainline Linux yet but is available at: https://lore.kernel.org/all/20250915-extensible-parameters-validation-v5-0-e6db94468af3@ideasonboard.com/ Create the include/linux/media/ directory so that header files exported from the kernel which include this file do not need to be adjusted when imported in libcamera. Signed-off-by: Jacopo Mondi Tested-By: Antoine Bouyer --- include/linux/media/v4l2-isp.h | 100 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 100 insertions(+) diff --git a/include/linux/media/v4l2-isp.h b/include/linux/media/v4l2-isp.h new file mode 100644 index 0000000000000000000000000000000000000000..fed89b5678585a3565d33cf873d0313dc089524f --- /dev/null +++ b/include/linux/media/v4l2-isp.h @@ -0,0 +1,100 @@ +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ +/* + * Video4Linux2 generic ISP parameters and statistics support + * + * Copyright (C) 2025 Ideas On Board Oy + * Author: Jacopo Mondi + */ + +#ifndef _V4L2_ISP_H_ +#define _V4L2_ISP_H_ + +#include +#include + +#define V4L2_PARAMS_FL_BLOCK_DISABLE (1U << 0) +#define V4L2_PARAMS_FL_BLOCK_ENABLE (1U << 1) + +/* + * Reserve the first 8 bits for V4L2_PARAMS_FL_* flag. + * + * Driver-specific flags should be defined as: + * #define PLATFORM_SPECIFIC_FLAG0 ((1U << V4L2_PARAMS_FL_DRIVER_FLAGS(0)) + * #define PLATFORM_SPECIFIC_FLAG1 ((1U << V4L2_PARAMS_FL_DRIVER_FLAGS(1)) + */ +#define V4L2_PARAMS_FL_DRIVER_FLAGS(n) ((n) + 8) + +/** + * struct v4l2_params_block_header - V4L2 extensible parameters block header + * + * This structure represents the common part of all the ISP configuration + * blocks. Each parameters block shall embed an instance of this structure type + * as its first member, followed by the block-specific configuration data. The + * driver inspects this common header to discern the block type and its size and + * properly handle the block content. + * + * The @type field is an ISP driver-specific value that identifies the block + * type. The @size field specifies the size of the parameters block. + * + * The @flags field is a bitmask of per-block flags V4L2_PARAMS_FL_* and + * driver-specific flags specified by the driver header. + * + * @type: The parameters block type (driver-specific) + * @flags: A bitmask of block flags (driver-specific) + * @size: Size (in bytes) of the parameters block, including this header + */ +struct v4l2_params_block_header { + __u16 type; + __u16 flags; + __u32 size; +} __attribute__((aligned(8))); + +/** + * v4l2_params_buffer_size - Calculate size of v4l2_params_buffer for a platform + * + * Users of the v4l2 extensible parameters will have differing sized data arrays + * depending on their specific parameter buffers. Drivers and userspace will + * need to be able to calculate the appropriate size of the struct to + * accommodate all ISP configuration blocks provided by the platform. + * This macro provides a convenient tool for the calculation. + * + * @max_params_size: The total size of the ISP configuration blocks + */ +#define v4l2_params_buffer_size(max_params_size) \ + (offsetof(struct v4l2_params_buffer, data) + (max_params_size)) + +/** + * struct v4l2_params_buffer - V4L2 extensible parameters configuration + * + * This struct contains the configuration parameters of the ISP algorithms, + * serialized by userspace into a data buffer. Each configuration parameter + * block is represented by a block-specific structure which contains a + * :c:type:`v4l2_params_block_header` entry as first member. Userspace populates + * the @data buffer with configuration parameters for the blocks that it intends + * to configure. As a consequence, the data buffer effective size changes + * according to the number of ISP blocks that userspace intends to configure and + * is set by userspace in the @data_size field. + * + * The parameters buffer is versioned by the @version field to allow modifying + * and extending its definition. Userspace shall populate the @version field to + * inform the driver about the version it intends to use. The driver will parse + * and handle the @data buffer according to the data layout specific to the + * indicated version and return an error if the desired version is not + * supported. + * + * For each ISP block that userspace wants to configure, a block-specific + * structure is appended to the @data buffer, one after the other without gaps + * in between nor overlaps. Userspace shall populate the @data_size field with + * the effective size, in bytes, of the @data buffer. + * + * @version: The parameters buffer version (driver-specific) + * @data_size: The configuration data effective size, excluding this header + * @data: The configuration data + */ +struct v4l2_params_buffer { + __u32 version; + __u32 data_size; + __u8 data[] __counted_by(data_size); +}; + +#endif /* _V4L2_ISP_H_ */