{"id":26332,"url":"https://patchwork.libcamera.org/api/patches/26332/?format=json","web_url":"https://patchwork.libcamera.org/patch/26332/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/projects/1/?format=json","name":"libcamera","link_name":"libcamera","list_id":"libcamera_core","list_email":"libcamera-devel@lists.libcamera.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20260325094829.9119-1-david.plowman@raspberrypi.com>","date":"2026-03-25T09:47:54","name":"[v3] gstreamer: Add sensor-config property","commit_ref":null,"pull_url":null,"state":"superseded","archived":false,"hash":"0cad221de1ce76ef5956efcd7381cd9879df59dd","submitter":{"id":42,"url":"https://patchwork.libcamera.org/api/people/42/?format=json","name":"David Plowman","email":"david.plowman@raspberrypi.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/26332/mbox/","series":[{"id":5846,"url":"https://patchwork.libcamera.org/api/series/5846/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=5846","date":"2026-03-25T09:47:54","name":"[v3] gstreamer: Add sensor-config property","version":3,"mbox":"https://patchwork.libcamera.org/series/5846/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/26332/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/26332/checks/","tags":{},"headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id DE372BD87C\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed, 25 Mar 2026 09:48:36 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id D6DFA627A7;\n\tWed, 25 Mar 2026 10:48:35 +0100 (CET)","from mail-wr1-x42a.google.com (mail-wr1-x42a.google.com\n\t[IPv6:2a00:1450:4864:20::42a])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 1829D62791\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 25 Mar 2026 10:48:34 +0100 (CET)","by mail-wr1-x42a.google.com with SMTP id\n\tffacd0b85a97d-43b4915161fso4621260f8f.2\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 25 Mar 2026 02:48:34 -0700 (PDT)","from davidp-pi5.pitowers.org\n\t([2a00:1098:3142:1f:88ea:c658:5b20:5e46])\n\tby smtp.gmail.com with ESMTPSA id\n\tffacd0b85a97d-43b644ae37dsm47651682f8f.2.2026.03.25.02.48.32\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tWed, 25 Mar 2026 02:48:32 -0700 (PDT)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (2048-bit key;\n\tunprotected) header.d=raspberrypi.com header.i=@raspberrypi.com\n\theader.b=\"kMwmQZxl\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=raspberrypi.com; s=google; t=1774432113; x=1775036913;\n\tdarn=lists.libcamera.org; \n\th=content-transfer-encoding:mime-version:message-id:date:subject:cc\n\t:to:from:from:to:cc:subject:date:message-id:reply-to;\n\tbh=x/iqV879zAFn8TLhOPPoOnXH1prlabfd3brBut4X4qc=;\n\tb=kMwmQZxlQ9Dm27gIYZQgcJlUMjX0u0OMBX4SbaVbTHOBk13kWjtfBdckDQWmFMvIRE\n\tnOg/0oNI/8FpnuSBiDcl4cNSx8KaSxlrq6WlA/WANDjwQKODiD6VFdB5xBwUMqpjWJ3O\n\twv0Iq13PepmVHvgPDMJznLla8p3vzJ1G1OJXcCeoUWaOYbrAThLSj/GFu5Gd1qyILItG\n\tN5lIsRrmvaDRljkHNHhyByogwWm81UdiG9wP1zJSMXItqLzX5PmmFz5nBpBuVTJvpo9C\n\t+vNxXj0Sm5v7F2R6ti0qrIlgownIZDM39037Ncg0XAqhqkfywMmHUdkqJYvP0KJYZPNq\n\trCUQ==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20251104; t=1774432113; x=1775036913;\n\th=content-transfer-encoding:mime-version:message-id:date:subject:cc\n\t:to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date\n\t:message-id:reply-to;\n\tbh=x/iqV879zAFn8TLhOPPoOnXH1prlabfd3brBut4X4qc=;\n\tb=qFewJ9nWmb1HMUVGqvl9UKyaw9apUd1383CH33WlGDFbs3hrbSeYdiusIahU77M5I0\n\tGM0v6bVAgK5CSFBjNj2PO1We4F3lwsM8uh5MZMew1mXaifElUoHYBePQ009QsREwx+xY\n\t5KDtrR+5QiVcdssvQjZZhDPuepY+ro1Xp2BFEdoHU6eI0QMVRnfqa6lKOv6cE6MLvCg+\n\tGUqvxrLWXuaZj8WU8eS5yLlMQp7hTtpOJKpxCmWyE2BpNj8oBsr26ouaPTYiRzjUrI8J\n\tDL/MIhlH2QK+seDCfOQVyl/Pa1Fj/dNv7f3gZoRbPor2hphkrDfaXlninH8HZcz2CqMr\n\tVOWQ==","X-Gm-Message-State":"AOJu0YwfSVqyEGGHShHe7QZmsJ9BmQG+WYkWR8O3oCrPxSKMM+1DGf34\n\tHrCKVQPIsS+WL1lwYf5oJe1dGySd+7F7GfwWINWUtNPlq5LI2bEZW0NHPZLg0gqSYAaSlcDFVw5\n\tDdzZF","X-Gm-Gg":"ATEYQzwIyguxEgqWIJdNxoMC+H0uT3aq2Gw+pdn2s5Nq2ky88M3zDl02uJ232yxDYK7\n\t43lLlTYCXyyQ+cxeXQA1gwq5KpxNyPSa826W+VLpC4zst8Atplx52Cko8GVEuk9LQfckZ5DjTw/\n\tSIOi57yT2DYUbEoQjuehXkwzKXoRj6lcAg5wHic7pQl7s2oNppodgl4XWMbwPx+6S7ukPka6ZHB\n\tVmuUDiIp5BjK0Aw15pVy/Us9vxkkZJv/5EHR1fXzewh0FE2BpMAHTrcu8ZMY5MxYKeUAg+KhVLQ\n\tgA7UOiYeOXDGexI/7UR1M/Zhrg9U70iXnjxNQi00YhMZRr4awbjksDk/A/XZgQe1mq5ELpcivdY\n\tzekBc/i0+7oVE8XsXDj2dm4X8L+rB00hoKO2RLZo0LpQHnhpdcNQHLugRqJkMKhx49RxQ4fhYv+\n\ttn11IfaIjASm/+bZD1NUMZvjndyyops8+VoFIGxKghzzELOkXnNEiInEAAyQQ8rh8FnupdCFxkp\n\tK3hogNUJ01ZwyA4p4yZYhaOqdAtKoPYqcd76OEGVg==","X-Received":"by 2002:a5d:64e6:0:b0:43b:4ae5:d7c8 with SMTP id\n\tffacd0b85a97d-43b8899530fmr3792795f8f.2.1774432113164; \n\tWed, 25 Mar 2026 02:48:33 -0700 (PDT)","From":"David Plowman <david.plowman@raspberrypi.com>","To":"libcamera-devel@lists.libcamera.org","Cc":"David Plowman <david.plowman@raspberrypi.com>,\n\tNicolas Dufresne <nicolas.dufresne@collabora.com>","Subject":"[PATCH v3] gstreamer: Add sensor-config property","Date":"Wed, 25 Mar 2026 09:47:54 +0000","Message-ID":"<20260325094829.9119-1-david.plowman@raspberrypi.com>","X-Mailer":"git-send-email 2.47.3","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"},"content":"The sensor-config property may optionally be specified to give the\noutputSize and bitDepth of the SensorConfiguration that is applied to\nthe camera configuration. For example, use\n\nlibcamerasrc sensor-config=\"sensor/config,width=2304,height=1296,depth=10\"\n\nto request the 10-bit 2304x1296 mode of a sensor.\n\nAll three parameters, width, height and bit depth, must be present, or\nit will issue a warning and revert to automatic mode selection (as if\nthere were no sensor-config at all).\n\nIf a mode is requested that doesn't exist then camera configuration\nwill fail and the pipeline won't start.\n\nAs future-proofing, the SensorConfiguration's binning and increment\nparameters may be specified, though libcamera currently ignores them.\n\nSigned-off-by: David Plowman <david.plowman@raspberrypi.com>\nReviewed-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>\nCloses: https://gitlab.freedesktop.org/camera/libcamera/-/issues/300\n---\n src/gstreamer/gstlibcamerasrc.cpp | 61 +++++++++++++++++++++++++++++++\n 1 file changed, 61 insertions(+)","diff":"diff --git a/src/gstreamer/gstlibcamerasrc.cpp b/src/gstreamer/gstlibcamerasrc.cpp\nindex a7241e9b..482b4761 100644\n--- a/src/gstreamer/gstlibcamerasrc.cpp\n+++ b/src/gstreamer/gstlibcamerasrc.cpp\n@@ -141,6 +141,7 @@ struct _GstLibcameraSrc {\n \tGstTask *task;\n \n \tgchar *camera_name;\n+\tGstStructure *sensor_config;\n \n \tstd::atomic<GstEvent *> pending_eos;\n \n@@ -152,6 +153,7 @@ struct _GstLibcameraSrc {\n enum {\n \tPROP_0,\n \tPROP_CAMERA_NAME,\n+\tPROP_SENSOR_CONFIG,\n \tPROP_LAST\n };\n \n@@ -846,6 +848,44 @@ gst_libcamera_src_task_enter(GstTask *task, [[maybe_unused]] GThread *thread,\n \t}\n \tg_assert(state->config_->size() == state->srcpads_.size());\n \n+\t/* Apply optional sensor configuration. */\n+\tif (self->sensor_config) {\n+\t\tgint w = 0, h = 0, depth = 0;\n+\t\tif (!gst_structure_get_int(self->sensor_config, \"width\", &w) ||\n+\t\t    !gst_structure_get_int(self->sensor_config, \"height\", &h) ||\n+\t\t    !gst_structure_get_int(self->sensor_config, \"depth\", &depth) ||\n+\t\t    w <= 0 || h <= 0 || depth <= 0) {\n+\t\t\tGST_ELEMENT_WARNING(self, RESOURCE, SETTINGS,\n+\t\t\t\t\t    (\"sensor-config requires non-zero width, height and depth\"\n+\t\t\t\t\t     \" fields, ignoring\"),\n+\t\t\t\t\t    (nullptr));\n+\t\t} else {\n+\t\t\tSensorConfiguration sensorCfg;\n+\t\t\tsensorCfg.outputSize = Size(w, h);\n+\t\t\tsensorCfg.bitDepth = depth;\n+\n+\t\t\t/* Optional binning (defaults to 1x1). */\n+\t\t\tgint binX, binY;\n+\t\t\tif (gst_structure_get_int(self->sensor_config, \"bin-x\", &binX) && binX > 0)\n+\t\t\t\tsensorCfg.binning.binX = binX;\n+\t\t\tif (gst_structure_get_int(self->sensor_config, \"bin-y\", &binY) && binY > 0)\n+\t\t\t\tsensorCfg.binning.binY = binY;\n+\n+\t\t\t/* Optional skipping (defaults to 1 for all increments). */\n+\t\t\tgint xOddInc, xEvenInc, yOddInc, yEvenInc;\n+\t\t\tif (gst_structure_get_int(self->sensor_config, \"x-odd-inc\", &xOddInc) && xOddInc > 0)\n+\t\t\t\tsensorCfg.skipping.xOddInc = xOddInc;\n+\t\t\tif (gst_structure_get_int(self->sensor_config, \"x-even-inc\", &xEvenInc) && xEvenInc > 0)\n+\t\t\t\tsensorCfg.skipping.xEvenInc = xEvenInc;\n+\t\t\tif (gst_structure_get_int(self->sensor_config, \"y-odd-inc\", &yOddInc) && yOddInc > 0)\n+\t\t\t\tsensorCfg.skipping.yOddInc = yOddInc;\n+\t\t\tif (gst_structure_get_int(self->sensor_config, \"y-even-inc\", &yEvenInc) && yEvenInc > 0)\n+\t\t\t\tsensorCfg.skipping.yEvenInc = yEvenInc;\n+\n+\t\t\tstate->config_->sensorConfig = sensorCfg;\n+\t\t}\n+\t}\n+\n \tif (!gst_libcamera_src_negotiate(self)) {\n \t\tstate->initControls_.clear();\n \t\tGST_ELEMENT_FLOW_ERROR(self, GST_FLOW_NOT_NEGOTIATED);\n@@ -934,6 +974,10 @@ gst_libcamera_src_set_property(GObject *object, guint prop_id,\n \t\tg_free(self->camera_name);\n \t\tself->camera_name = g_value_dup_string(value);\n \t\tbreak;\n+\tcase PROP_SENSOR_CONFIG:\n+\t\tg_clear_pointer(&self->sensor_config, gst_structure_free);\n+\t\tself->sensor_config = (GstStructure *)g_value_dup_boxed(value);\n+\t\tbreak;\n \tdefault:\n \t\tif (!state->controls_.setProperty(prop_id - PROP_LAST, value, pspec))\n \t\t\tG_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);\n@@ -953,6 +997,9 @@ gst_libcamera_src_get_property(GObject *object, guint prop_id, GValue *value,\n \tcase PROP_CAMERA_NAME:\n \t\tg_value_set_string(value, self->camera_name);\n \t\tbreak;\n+\tcase PROP_SENSOR_CONFIG:\n+\t\tg_value_set_boxed(value, self->sensor_config);\n+\t\tbreak;\n \tdefault:\n \t\tif (!state->controls_.getProperty(prop_id - PROP_LAST, value, pspec))\n \t\t\tG_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);\n@@ -1040,6 +1087,7 @@ gst_libcamera_src_finalize(GObject *object)\n \tg_clear_object(&self->task);\n \tg_mutex_clear(&self->state->lock_);\n \tg_free(self->camera_name);\n+\tg_clear_pointer(&self->sensor_config, gst_structure_free);\n \tdelete self->state;\n \n \treturn klass->finalize(object);\n@@ -1162,6 +1210,19 @@ gst_libcamera_src_class_init(GstLibcameraSrcClass *klass)\n \t\t\t\t\t\t\t     | G_PARAM_STATIC_STRINGS));\n \tg_object_class_install_property(object_class, PROP_CAMERA_NAME, spec);\n \n+\tspec = g_param_spec_boxed(\"sensor-config\", \"Sensor Config\",\n+\t\t\t\t  \"Desired sensor configuration as a GstStructure with mandatory \"\n+\t\t\t\t  \"fields width, height and depth, and optional fields bin-x, bin-y, \"\n+\t\t\t\t  \"x-odd-inc, x-even-inc, y-odd-inc, y-even-inc \"\n+\t\t\t\t  \"(e.g. \\\"sensor/config,width=2304,height=1296,depth=10\\\"). \"\n+\t\t\t\t  \"Leave unset to let the pipeline negotiate the sensor mode automatically.\",\n+\t\t\t\t  GST_TYPE_STRUCTURE,\n+\t\t\t\t  (GParamFlags)(GST_PARAM_MUTABLE_READY\n+\t\t\t\t\t\t| G_PARAM_CONSTRUCT\n+\t\t\t\t\t\t| G_PARAM_READWRITE\n+\t\t\t\t\t\t| G_PARAM_STATIC_STRINGS));\n+\tg_object_class_install_property(object_class, PROP_SENSOR_CONFIG, spec);\n+\n \tGstCameraControls::installProperties(object_class, PROP_LAST);\n }\n \n","prefixes":["v3"]}