{"id":26384,"url":"https://patchwork.libcamera.org/api/1.1/patches/26384/?format=json","web_url":"https://patchwork.libcamera.org/patch/26384/","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":"<20260330101654.3332-1-david.plowman@raspberrypi.com>","date":"2026-03-30T10:14:43","name":"[v4] gstreamer: Add sensor-config property","commit_ref":null,"pull_url":null,"state":"new","archived":false,"hash":"00e8a151c3a8786e0bfea6f98538a2c50ef47c70","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/26384/mbox/","series":[{"id":5856,"url":"https://patchwork.libcamera.org/api/1.1/series/5856/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=5856","date":"2026-03-30T10:14:43","name":"[v4] gstreamer: Add sensor-config property","version":4,"mbox":"https://patchwork.libcamera.org/series/5856/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/26384/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/26384/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 E513ABE086\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 30 Mar 2026 10:17:00 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 2879A62CFD;\n\tMon, 30 Mar 2026 12:17:00 +0200 (CEST)","from mail-wr1-x42b.google.com (mail-wr1-x42b.google.com\n\t[IPv6:2a00:1450:4864:20::42b])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id AA2C962733\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 30 Mar 2026 12:16:57 +0200 (CEST)","by mail-wr1-x42b.google.com with SMTP id\n\tffacd0b85a97d-43cf3ee0fc1so1010685f8f.1\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 30 Mar 2026 03:16:57 -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-43cf21e2a7asm19744293f8f.7.2026.03.30.03.16.56\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tMon, 30 Mar 2026 03:16:56 -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=\"FPKBd5sC\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=raspberrypi.com; s=google; t=1774865817; x=1775470617;\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=24RHKpIgZmtyY1fGa2ArRF9nFVbAxTh6oyve8jry8zM=;\n\tb=FPKBd5sCxk+S0Rt7CJwjJdHqhIJhuZQb2iYuRHbT2qL7o9yKyF/Vz9V4csfkeknIUA\n\tjxkylvr13OizVU4rZ5CXDgFjoEcMMHeqjch2V7LzFGaDQMXnDCxvoUvs0AEg06Ba5moE\n\t7xFfe/Gg27yND5advzUdI4ko0yQ9je+/lxhy1L0PEPFXDjYx+sMkJs8elWYZDbOyaVH1\n\txQCd9Hy0L0W2TJjTZZ3+t8wzng+/0aIInReT82W+iPvqlZc4WBx4ZGWTtUP3+WvflSjO\n\thQV6GWKwapcyb4P2SNTaKVjhVNuijbwhKlpXykNAK8ltuFDbmnYcx7TQmk38TGrlxUxZ\n\tf5cA==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20251104; t=1774865817; x=1775470617;\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=24RHKpIgZmtyY1fGa2ArRF9nFVbAxTh6oyve8jry8zM=;\n\tb=T6PmKLWHMJHkKx/EgBTEGGJb5XrjHfOPbX7XKgJ8K2JW1UdLY7Zu90qKHBGsTsYpjm\n\tI1QlxloWLuA+jyr/m+vs2S/Utmft/xaHv9HDtvKFYNhT9//pnkAoxoWiEuF6q0HNkkXu\n\tSdck+UBeuPE2xtJjR/LQsmx9wrfApNsF38t+op+xSxcg+sKkvxTxwweAO05d4UHtZmGl\n\tIQ+xt/fwtp5l7h4ijX5ts7Ya5NCMKxRZOaob8yd+ac1fXTp3hAym7J55G4rB7vkMiVTC\n\t/Hx2CSm/jzxYrN46F8Mm//LQ5zSgmho7ZHpHN7zTuAOy79qQBxoPnE5aXa4UqS1QoAKB\n\trE+A==","X-Gm-Message-State":"AOJu0YweEVu4hi5O1ncbPlFfXIKqhgEQDr8axkG/3G3jDsZcUjBmREBk\n\tUYQRhn66mRlqiygBzfQKweRe34m1A1D/ksg3IrEpBgGnCvkyAxlHSVg8rwCxw6zXSelg/pxAYkr\n\taYrh2","X-Gm-Gg":"ATEYQzzKlDaTBTiyxMXtJJKyRG+TExugxj31oG8XNVmjp5L4FE20i/ALVGp++qhPD4T\n\tsY+k8jW9jMyRj6tlhw3Po6tG+dj8c063FSqMCImK/SlF3rTrnlMT/7HADfAnD37+797Viq10+0t\n\teWOqvTSm4+ccrTYZwr52hUpSpnLx+FOCKGacNkNs+yFoLPjtNNhCksO+5IaVBP2HE0tImNJY8bt\n\tuV54h3hKgIeKEQp/lOAlzc1FxqlssUJmhLic//sZGZsHDRM9ZdI0uqE9rcKsPeCBzuuJlor8qvo\n\t/+xU4EDNaPLfY5b9qG3d0Ljr5J3YwUV4NKWqfwHChk5n+KcsZP07xIeYVjKWyUnnt7loM0qB+mm\n\tIvN+eeJLeMOOgLGpDtyAB2mEYzQCTo3aRzNg9z+RDC5DR5JzKV6MDtxUYAUNWr9bwrSFtFVll8U\n\tNA/41qfrPV1M6KAuyW3EXl1wpCrchsaZ81z5r1vx/vCKGdTNoXna50ItGcZANO5BPGCoq6kz8QV\n\tpitpt/ZdvGIEx34QkMDS5rak3It1N7HH2Rde3WD2Q==","X-Received":"by 2002:a05:6000:3109:b0:43c:a352:c34f with SMTP id\n\tffacd0b85a97d-43ca352c69cmr16818445f8f.7.1774865816655; \n\tMon, 30 Mar 2026 03:16:56 -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 v4] gstreamer: Add sensor-config property","Date":"Mon, 30 Mar 2026 11:14:43 +0100","Message-ID":"<20260330101654.3332-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, increment and\nanalog-crop parameters may be specified, though libcamera currently\nignores 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 | 73 +++++++++++++++++++++++++++++++\n 1 file changed, 73 insertions(+)","diff":"diff --git a/src/gstreamer/gstlibcamerasrc.cpp b/src/gstreamer/gstlibcamerasrc.cpp\nindex a7241e9b..5d3ee3a2 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,55 @@ 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\t/* Optional analog crop (defaults to \"unset\"). */\n+\t\t\tgint cropX, cropY, cropW, cropH;\n+\t\t\tif (gst_structure_get_int(self->sensor_config, \"analog-crop-x\", &cropX) &&\n+\t\t\t    gst_structure_get_int(self->sensor_config, \"analog-crop-y\", &cropY) &&\n+\t\t\t    gst_structure_get_int(self->sensor_config, \"analog-crop-width\", &cropW) &&\n+\t\t\t    gst_structure_get_int(self->sensor_config, \"analog-crop-height\", &cropH) &&\n+\t\t\t    cropX >= 0 && cropY >= 0 && cropW > 0 && cropH > 0)\n+\t\t\t\tsensorCfg.analogCrop = Rectangle(cropX, cropY,\n+\t\t\t\t\t\t\t\t static_cast<unsigned int>(cropW),\n+\t\t\t\t\t\t\t\t static_cast<unsigned int>(cropH));\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 +985,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 +1008,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 +1098,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 +1221,20 @@ 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  \"analog-crop-x, analog-crop-y, analog-crop-width, analog-crop-height \"\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":["v4"]}