From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.20]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 981632DF6F4 for ; Mon, 25 Aug 2025 09:51:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.20 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1756115515; cv=none; b=MQtjVvI25M8Km4X7MZgcSoA+ireNV3j20Jm4TmLutTDWxkEIRty0oS8iQ5+XFjCKybfuhjpshE0wSDNOS8y63kSaupqcGJ9IDdvj8FfvA1SbsPmRPqKhXft1KYptFQgszVSVnEgA7S3TFSeAqNkhqGg3Faj6V5uU1IPa0vIPG/s= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1756115515; c=relaxed/simple; bh=50LCVsXFqX3R3jq+il6VgraYsi45QNMs0B2da8St4D4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=uBnIXN8agCZydMiI4r70eGw7UA6Mk9OEqogUbytXmaywmDY00SGl5gcE54MbiItOKMFB9DjNVtjR+tyQZ+1Ptx5cHnXH9y2TlGPt2ZHiZBbsimerh/dPtKPxYtIJ5rK7BVotKQSHQlyDdGGYCEa7JxW/kXiPiri8gzPa2Mbbj2A= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=CNm5H/Df; arc=none smtp.client-ip=198.175.65.20 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="CNm5H/Df" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1756115514; x=1787651514; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=50LCVsXFqX3R3jq+il6VgraYsi45QNMs0B2da8St4D4=; b=CNm5H/DfqMI3XMBY9eA0ULxX+Vr//d/1o/wL/eD+9rS4FtdHIoIzhRzR PUz4wtc19XDtymnI+DP5KGmp4xZvpeaBzlzj1AbXhry8ro5oq8bCLGu8V UBHaSWgXKLPgVJwy8lasABiQLG/84gbv+kQr9l8qqxwNd8esIlBl1OBaR hKCv2jchxMZkZICcDZZd7aHb3O1vfp/3M2+3DIYMovigr3czONW2vHaNB 17jIMNVzqvgjttwn4gbHeXbbr5XBoYTXHvLp6Y9K5XGgSqLwIEfR/boan dooHPzTb7b6M5h/4Vq3vTpQH0aB5iVf6H6NOsBrEA0ID1CXQGzp0XABHu w==; X-CSE-ConnectionGUID: ABUuhlTNRue8Vf2tbyAevA== X-CSE-MsgGUID: SgWChOTaR4mrJvkSEVrQlA== X-IronPort-AV: E=McAfee;i="6800,10657,11532"; a="58032292" X-IronPort-AV: E=Sophos;i="6.17,312,1747724400"; d="scan'208";a="58032292" Received: from orviesa003.jf.intel.com ([10.64.159.143]) by orvoesa112.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Aug 2025 02:51:46 -0700 X-CSE-ConnectionGUID: WCByvH3+Q/CZ4hqzw5pKJA== X-CSE-MsgGUID: uk+atSgLS9apHGZenbh+lg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.17,312,1747724400"; d="scan'208";a="173431094" Received: from vpanait-mobl.ger.corp.intel.com (HELO kekkonen.fi.intel.com) ([10.245.245.7]) by ORVIESA003-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Aug 2025 02:51:38 -0700 Received: from punajuuri.localdomain (unknown [192.168.240.130]) by kekkonen.fi.intel.com (Postfix) with ESMTP id B690F121FF5; Mon, 25 Aug 2025 12:51:08 +0300 (EEST) Received: from sailus by punajuuri.localdomain with local (Exim 4.98.2) (envelope-from ) id 1uqTr2-00000005agk-2yhQ; Mon, 25 Aug 2025 12:51:08 +0300 Organization: Intel Finland Oy - BIC 0357606-4 - c/o Alberga Business Park, 6 krs, Bertel Jungin Aukio 5, 02600 Espoo From: Sakari Ailus To: linux-media@vger.kernel.org Cc: hans@jjverkuil.nl, laurent.pinchart@ideasonboard.com, Prabhakar , Kate Hsuan , Alexander Shiyan , Dave Stevenson , Tommaso Merciai , Umang Jain , Benjamin Mugnier , Sylvain Petinot , Christophe JAILLET , Julien Massot , Naushir Patuck , "Yan, Dongcheng" , "Cao, Bingbu" , "Qiu, Tian Shu" , "Wang, Hongju" , Stefan Klug , Mirela Rabulea , =?UTF-8?q?Andr=C3=A9=20Apitzsch?= , Heimir Thor Sverrisson , Kieran Bingham , Stanislaw Gruszka , Mehdi Djait , Ricardo Ribalda Delgado , Hans de Goede , Jacopo Mondi , Tomi Valkeinen Subject: [PATCH v11 44/66] media: uapi: Add controls for sub-sampling configuration Date: Mon, 25 Aug 2025 12:50:45 +0300 Message-ID: <20250825095107.1332313-45-sakari.ailus@linux.intel.com> X-Mailer: git-send-email 2.47.2 In-Reply-To: <20250825095107.1332313-1-sakari.ailus@linux.intel.com> References: <20250825095107.1332313-1-sakari.ailus@linux.intel.com> Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sub-sampling is a way to decrease the data rates after the pixel array by systematically discarding some samples, either vertically or horizontally or both. Add two controls for the purpose and document them. The sub-sampling configuration is taken into account in the compose rectangle. Signed-off-by: Sakari Ailus Reviewed-by: Tomi Valkeinen --- .../media/drivers/camera-sensor.rst | 16 +++++++++++++--- .../userspace-api/media/v4l/ext-ctrls-camera.rst | 11 +++++++++++ drivers/media/v4l2-core/v4l2-ctrls-defs.c | 2 ++ include/uapi/linux/v4l2-controls.h | 2 ++ 4 files changed, 28 insertions(+), 3 deletions(-) diff --git a/Documentation/userspace-api/media/drivers/camera-sensor.rst b/Documentation/userspace-api/media/drivers/camera-sensor.rst index ef1f51862980..b0ad0d778396 100644 --- a/Documentation/userspace-api/media/drivers/camera-sensor.rst +++ b/Documentation/userspace-api/media/drivers/camera-sensor.rst @@ -120,8 +120,8 @@ values programmed by the register sequences. The default values of these controls shall be 0 (disabled). Especially these controls shall not be inverted, independently of the sensor's mounting rotation. -Binning -------- +Binning and sub-sampling +------------------------ Binning has traditionally been configured using :ref:`the compose selection rectangle `. The :ref:`V4L2_CID_BINNING @@ -130,7 +130,17 @@ users should use it when it's available. Drivers supporting the control shall also support the compose rectangle, albeit the rectangle may be read-only when the control is present. -Binning isn't affected by flipping. +Sub-sampling is often supported as part of a camera sensor's binning +functionality and performed after the binning operation. Sub-sampling typically +produces quality-wise worse results than binning. Sub-sampling factors are +independent horizontally and vertically and they are controlled using two +controls, :ref:`V4L2_CID_SUBSAMPLING_HORIZONTAL and +V4L2_CID_SUBSAMPLING_VERTICAL `. In +sub-sampling, the image size before sub-sampling is horizontally and vertically +divided by the respective sub-sampling factors. Drivers supporting the control shall +also reflect the sub-sampling configuration in the compose rectangle. + +Binning and sub-sampling aren't affected by flipping. .. _media_using_camera_sensor_drivers_embedded_data: diff --git a/Documentation/userspace-api/media/v4l/ext-ctrls-camera.rst b/Documentation/userspace-api/media/v4l/ext-ctrls-camera.rst index 18b484ff5d75..577b73045bee 100644 --- a/Documentation/userspace-api/media/v4l/ext-ctrls-camera.rst +++ b/Documentation/userspace-api/media/v4l/ext-ctrls-camera.rst @@ -701,3 +701,14 @@ enum v4l2_scene_mode - For instance, a value of ``0x0001000300020003`` indicates binning by 3 (horizontally) * 3/2 (vertically). + +.. _v4l2-cid-camera-sensor-subsampling: + +``V4L2_CID_SUBSAMPLING_HORIZONTAL`` and ``V4L2_CID_SUBSAMPLING_VERTICAL`` +(integer) + + Horizontal and vertical subsampling factors. + + Sub-sampling is used to downscale an image, horizontally and vertically, by + discarding a part of the image data. Typically sub-sampling produces lower + quality images than binning. diff --git a/drivers/media/v4l2-core/v4l2-ctrls-defs.c b/drivers/media/v4l2-core/v4l2-ctrls-defs.c index 5e1c28850e87..9f8816bfffbe 100644 --- a/drivers/media/v4l2-core/v4l2-ctrls-defs.c +++ b/drivers/media/v4l2-core/v4l2-ctrls-defs.c @@ -1088,6 +1088,8 @@ const char *v4l2_ctrl_get_name(u32 id) case V4L2_CID_CAMERA_SENSOR_ROTATION: return "Camera Sensor Rotation"; case V4L2_CID_HDR_SENSOR_MODE: return "HDR Sensor Mode"; case V4L2_CID_BINNING_FACTORS: return "Binning Factors"; + case V4L2_CID_SUBSAMPLING_HORIZONTAL: return "Sub-Sampling Factor, Horizontal"; + case V4L2_CID_SUBSAMPLING_VERTICAL: return "Sub-Sampling Factor, Vertical"; /* FM Radio Modulator controls */ /* Keep the order of the 'case's the same as in v4l2-controls.h! */ diff --git a/include/uapi/linux/v4l2-controls.h b/include/uapi/linux/v4l2-controls.h index 90f47f4780e5..51d43d4a3151 100644 --- a/include/uapi/linux/v4l2-controls.h +++ b/include/uapi/linux/v4l2-controls.h @@ -1102,6 +1102,8 @@ enum v4l2_auto_focus_range { #define V4L2_CID_HDR_SENSOR_MODE (V4L2_CID_CAMERA_CLASS_BASE+36) #define V4L2_CID_BINNING_FACTORS (V4L2_CID_CAMERA_CLASS_BASE+37) +#define V4L2_CID_SUBSAMPLING_HORIZONTAL (V4L2_CID_CAMERA_CLASS_BASE+38) +#define V4L2_CID_SUBSAMPLING_VERTICAL (V4L2_CID_CAMERA_CLASS_BASE+39) /* FM Modulator class control IDs */ -- 2.47.2