{"id":26320,"url":"https://patchwork.libcamera.org/api/1.1/patches/26320/?format=json","web_url":"https://patchwork.libcamera.org/patch/26320/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/1.1/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":"<20260324085612.14533-1-david.plowman@raspberrypi.com>","date":"2026-03-24T08:53:56","name":"[v2] gstreamer: Add sensor-config property","commit_ref":null,"pull_url":null,"state":"superseded","archived":false,"hash":"77c96b931956001346e82d445a3ac14ff4084c41","submitter":{"id":42,"url":"https://patchwork.libcamera.org/api/1.1/people/42/?format=json","name":"David Plowman","email":"david.plowman@raspberrypi.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/26320/mbox/","series":[{"id":5840,"url":"https://patchwork.libcamera.org/api/1.1/series/5840/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=5840","date":"2026-03-24T08:53:56","name":"[v2] gstreamer: Add sensor-config property","version":2,"mbox":"https://patchwork.libcamera.org/series/5840/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/26320/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/26320/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 8D0EBBE086\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 24 Mar 2026 08:56:18 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id CB6CF6277D;\n\tTue, 24 Mar 2026 09:56:17 +0100 (CET)","from mail-wr1-x429.google.com (mail-wr1-x429.google.com\n\t[IPv6:2a00:1450:4864:20::429])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 7F4CF62010\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 24 Mar 2026 09:56:15 +0100 (CET)","by mail-wr1-x429.google.com with SMTP id\n\tffacd0b85a97d-43b527ac5d0so1839553f8f.2\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 24 Mar 2026 01:56:15 -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-43b6470c239sm36461512f8f.27.2026.03.24.01.56.14\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tTue, 24 Mar 2026 01:56:14 -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=\"JvgKbkWS\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=raspberrypi.com; s=google; t=1774342575; x=1774947375;\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=mmvpptHl0lxYLm/QPncpa1bCeN+O2Eofb6RUrsroVQE=;\n\tb=JvgKbkWShIw2Q6PPbdz6H0zvbRWfKpuILzvrG36RcBsNLgco96Qe6J+zaEkyAdYjbx\n\t3tI3mEFUnUN4s0smIyvmQjX63a6QmT1li5/nl6uHVqNCIa5DrcbtcC4IJNFeea/3x3Uj\n\tSe9G7Jwlz/QljJLIEcrJQoSS9Iw3IljTpdsZpHnbIpQoaRpYinuZJ9sMUYjPMPomWu/Q\n\tDSOM7V7J9FqdHW2ZBaYwboDPqIDkm32Lshkp0s0+vZp4hGCYCKDXLlqaA8gzEehC15u9\n\tqJGtG/ffFHQAwRYJ7B7JmiZzpbHTWIX2secv3Bx/tG7W0Iov7CSYgRQUPaP3DR3n9Kfi\n\thUjg==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20251104; t=1774342575; x=1774947375;\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=mmvpptHl0lxYLm/QPncpa1bCeN+O2Eofb6RUrsroVQE=;\n\tb=Y/sVP75sOjpdHzurjO0E2VTDdV1XfxBTt4RufFPtHqFqJMWBjAbjhAodcaMi0jJwCD\n\tNKhsTGyOBVLN2mmxs3Mxjz6xQOCv3VfUeb7Sa6hMYKgl/okWhrILebKYpPLbG/AdR4ut\n\t+PmjHQ1adebQIBai5Qxm83nAZqJ97ZywcwxzXAD1viIOkJ86+7og48VOnspIiymBhaUh\n\t1KqkmKpxwSTdPNZDGlj//3m4N7gMbRwJONjyMBB/J+KVc63bRULYKebrOvf6p2GAdDLO\n\tLHwV92Y1PT8RKBihs+DsNUtLvc7ln+zFJRQqClAUgHhtoF0r1qXqcaIcSowcS7UDppcN\n\t+YsQ==","X-Gm-Message-State":"AOJu0YzL/mmzY36KNpsxKRNsBK9yECoGVLHDldGgR4ZZz/V4SlPcIFBn\n\tcQOY9906QKcNy/VD8Bp4lyoeLfyUVTqV+WAV3M8/lC2GmOKdIj1I0yq8fsUkFF0iZaxmqiru1cl\n\ttGcZk","X-Gm-Gg":"ATEYQzwN0Q/g4dctkXL4AMqZi1w+3lynPYIPTUq+1nhHnAuiVViaElTS4qZW1z+x9aT\n\tK7ZaCkd+Cy1+s3WDw2g5BSJIKuX2XIhRGUKBj3PnAGtOUl9MlKRaxw4ramylZT/WXtdpzLTtBow\n\tTARrhKkpss5xhDhC/4HFlgrevfK0MSr0ydMX04KBl4PV3mgydHIHEtBvqCpA7LDyJ1UMtPf75xb\n\tN2tsfm4Z/uQeeZ06bCijLG5tl8xfObqBTmfHkUjF8cbFGBhFxVaXTkPi6FhfFkuhrcBBimkNmxi\n\tHrFTgYqjhUxiHBNabKe6PIrdrc/OsE+gjDLK1H4RFhy2DD/t1C/5IurpOhpyLEXhEoB2alTllAm\n\tT5dYzdIokAvwm5vZbq2i35DCuY9tvalOlWiVhHxrZ7ueBtaSdW8SwJ7k13PlFEKID2uVTgWCanr\n\t1VmtPZKhVaJXx9RzxJyOaSdky77utgE+xD6i0+cnlKwHtHgu58kKyyeeQgCZmoX026+uRo1jQcp\n\tQDS/KrjfoPsEmiLgpDId4uGVecKi3Cs3kTBC1IROQ==","X-Received":"by 2002:a5d:5f49:0:b0:439:fcd5:c9bb with SMTP id\n\tffacd0b85a97d-43b64277e32mr24773451f8f.34.1774342574659; \n\tTue, 24 Mar 2026 01:56:14 -0700 (PDT)","From":"David Plowman <david.plowman@raspberrypi.com>","To":"libcamera-devel@lists.libcamera.org","Cc":"David Plowman <david.plowman@raspberrypi.com>","Subject":"[PATCH v2] gstreamer: Add sensor-config property","Date":"Tue, 24 Mar 2026 08:53:56 +0000","Message-ID":"<20260324085612.14533-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>\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..c7c183dd 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 = 0, binY = 0;\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 = 0, xEvenInc = 0, yOddInc = 0, yEvenInc = 0;\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 = gst_structure_copy((GstStructure *)g_value_get_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":["v2"]}