Show a patch.

GET /api/1.1/patches/9036/?format=api
HTTP 200 OK
Allow: GET, PUT, PATCH, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
    "id": 9036,
    "url": "https://patchwork.libcamera.org/api/1.1/patches/9036/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/9036/",
    "project": {
        "id": 1,
        "url": "https://patchwork.libcamera.org/api/1.1/projects/1/?format=api",
        "name": "libcamera",
        "link_name": "libcamera",
        "list_id": "libcamera_core",
        "list_email": "libcamera-devel@lists.libcamera.org",
        "web_url": "",
        "scm_url": "",
        "webscm_url": ""
    },
    "msgid": "<20200728003058.2871461-3-niklas.soderlund@ragnatech.se>",
    "date": "2020-07-28T00:30:54",
    "name": "[libcamera-devel,v2,2/6] libcamera: camera: Generate camera name from a CameraSensor",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": false,
    "hash": "ab34f0b437306a5b3d869bfc004d01fbd2ce1de0",
    "submitter": {
        "id": 5,
        "url": "https://patchwork.libcamera.org/api/1.1/people/5/?format=api",
        "name": "Niklas Söderlund",
        "email": "niklas.soderlund@ragnatech.se"
    },
    "delegate": null,
    "mbox": "https://patchwork.libcamera.org/patch/9036/mbox/",
    "series": [
        {
            "id": 1155,
            "url": "https://patchwork.libcamera.org/api/1.1/series/1155/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=1155",
            "date": "2020-07-28T00:30:52",
            "name": "libcamera: Generate unique and stable camera names",
            "version": 2,
            "mbox": "https://patchwork.libcamera.org/series/1155/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/9036/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/9036/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 18710BD86F\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 28 Jul 2020 00:31:22 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id E23596196D;\n\tTue, 28 Jul 2020 02:31:21 +0200 (CEST)",
            "from vsp-unauthed02.binero.net (vsp-unauthed02.binero.net\n\t[195.74.38.227])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id DC4AC60939\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 28 Jul 2020 02:31:17 +0200 (CEST)",
            "from bismarck.berto.se (p4fca2eca.dip0.t-ipconnect.de\n\t[79.202.46.202]) by bin-vsp-out-01.atm.binero.net (Halon) with ESMTPA\n\tid a3cf7bbb-d069-11ea-933e-005056917a89;\n\tTue, 28 Jul 2020 02:31:12 +0200 (CEST)"
        ],
        "X-Halon-ID": "a3cf7bbb-d069-11ea-933e-005056917a89",
        "Authorized-sender": "niklas@soderlund.pp.se",
        "From": "=?utf-8?q?Niklas_S=C3=B6derlund?= <niklas.soderlund@ragnatech.se>",
        "To": "libcamera-devel@lists.libcamera.org",
        "Date": "Tue, 28 Jul 2020 02:30:54 +0200",
        "Message-Id": "<20200728003058.2871461-3-niklas.soderlund@ragnatech.se>",
        "X-Mailer": "git-send-email 2.27.0",
        "In-Reply-To": "<20200728003058.2871461-1-niklas.soderlund@ragnatech.se>",
        "References": "<20200728003058.2871461-1-niklas.soderlund@ragnatech.se>",
        "MIME-Version": "1.0",
        "Subject": "[libcamera-devel] [PATCH v2 2/6] libcamera: camera: Generate camera\n\tname from a CameraSensor",
        "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>",
        "Content-Type": "text/plain; charset=\"utf-8\"",
        "Content-Transfer-Encoding": "base64",
        "Errors-To": "libcamera-devel-bounces@lists.libcamera.org",
        "Sender": "\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"
    },
    "content": "Add a create() that generates a camera name from information in a\nCameraSensor. The intention is to keep the style of camera names more\nstandardised and to ease adding more parameters to the name as they\nbecome available.\n\nThe goal is to generate a unique name that describes where the camera is\nlocated in the system without using bus information, as enumerated bus\ninformation is not guaranteed to be static between resets of the system.\nMore parameters should be added to the name as CameraSensor is extended.\n\nIn this first change the name is made up of the mandatory CameraSensor\ncontrols model, location and rotation if it is not 0. As many platforms\nhardware description (devicetree or ACPI) do not yet describe these\nproperties the default location front is used for some cameras which is\nnot true.\n\nAll pipelines that implements a CameraSensor (all but UVC) are updated\nto make use of this new function. All names of cameras created by the\nupdated pipelines are modified.\n\nBefore this change example of camera names:\n\nov5695 7-0036 (PipelineHandlerRkISP1)\nov2685 7-003c (PipelineHandlerRkISP1)\n\nAfter this change the same cameras are:\n\nov5695 location front (PipelineHandlerRkISP1)\nov2685 location front (PipelineHandlerRkISP1)\n\nSigned-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>\n---\n include/libcamera/camera.h                    |  5 +++\n src/libcamera/camera.cpp                      | 38 +++++++++++++++++++\n src/libcamera/pipeline/ipu3/ipu3.cpp          | 12 +++---\n .../pipeline/raspberrypi/raspberrypi.cpp      |  3 +-\n src/libcamera/pipeline/rkisp1/rkisp1.cpp      |  2 +-\n src/libcamera/pipeline/simple/simple.cpp      |  2 +-\n src/libcamera/pipeline/vimc/vimc.cpp          |  4 +-\n test/camera/buffer_import.cpp                 |  2 +-\n test/camera/capture.cpp                       |  2 +-\n test/camera/configuration_default.cpp         |  2 +-\n test/camera/configuration_set.cpp             |  2 +-\n test/camera/statemachine.cpp                  |  2 +-\n test/controls/control_info_map.cpp            |  2 +-\n test/controls/control_list.cpp                |  2 +-\n test/serialization/serialization_test.h       |  2 +-\n 15 files changed, 62 insertions(+), 20 deletions(-)",
    "diff": "diff --git a/include/libcamera/camera.h b/include/libcamera/camera.h\nindex 4d1a4a9f52ec0fac..784510c9a79d44b9 100644\n--- a/include/libcamera/camera.h\n+++ b/include/libcamera/camera.h\n@@ -19,6 +19,7 @@\n \n namespace libcamera {\n \n+class CameraSensor;\n class FrameBuffer;\n class FrameBufferAllocator;\n class PipelineHandler;\n@@ -73,6 +74,10 @@ public:\n \t\t\t\t\t      const std::string &name,\n \t\t\t\t\t      const std::set<Stream *> &streams);\n \n+\tstatic std::shared_ptr<Camera> create(PipelineHandler *pipe,\n+\t\t\t\t\t      const CameraSensor *sensor,\n+\t\t\t\t\t      const std::set<Stream *> &streams);\n+\n \tCamera(const Camera &) = delete;\n \tCamera &operator=(const Camera &) = delete;\n \ndiff --git a/src/libcamera/camera.cpp b/src/libcamera/camera.cpp\nindex 81d5816ef6a653b3..c5413341fefa1124 100644\n--- a/src/libcamera/camera.cpp\n+++ b/src/libcamera/camera.cpp\n@@ -11,9 +11,11 @@\n #include <iomanip>\n \n #include <libcamera/framebuffer_allocator.h>\n+#include <libcamera/property_ids.h>\n #include <libcamera/request.h>\n #include <libcamera/stream.h>\n \n+#include \"libcamera/internal/camera_sensor.h\"\n #include \"libcamera/internal/log.h\"\n #include \"libcamera/internal/pipeline_handler.h\"\n #include \"libcamera/internal/utils.h\"\n@@ -475,6 +477,42 @@ std::shared_ptr<Camera> Camera::create(PipelineHandler *pipe,\n \treturn std::shared_ptr<Camera>(camera, Deleter());\n }\n \n+/**\n+ * \\brief Create a camera instance\n+ * \\param[in] pipe The pipeline handler responsible for the camera device\n+ * \\param[in] sensor The sensor of the camera device\n+ * \\param[in] streams Array of streams the camera provides\n+ *\n+ * Create a camera with name generated from \\a sensor.\n+ *\n+ * \\return A shared pointer to the newly created camera object\n+ */\n+std::shared_ptr<Camera> Camera::create(PipelineHandler *pipe,\n+\t\t\t\t       const CameraSensor *sensor,\n+\t\t\t\t       const std::set<Stream *> &streams)\n+{\n+\tstd::string name = sensor->model();\n+\n+\tname += \" location \";\n+\tswitch (sensor->properties().get(properties::Location)) {\n+\tcase properties::CameraLocationFront:\n+\t\tname += \"front\";\n+\t\tbreak;\n+\tcase properties::CameraLocationBack:\n+\t\tname += \"back\";\n+\t\tbreak;\n+\tcase properties::CameraLocationExternal:\n+\t\tname += \"external\";\n+\t\tbreak;\n+\t}\n+\n+\tunsigned int rotation = sensor->properties().get(properties::Location);\n+\tif (rotation)\n+\t\tname += \" rotated \" + std::to_string(rotation) + \" degrees\";\n+\n+\treturn Camera::create(pipe, name, streams);\n+}\n+\n /**\n  * \\brief Retrieve the name of the camera\n  * \\context This function is \\threadsafe.\ndiff --git a/src/libcamera/pipeline/ipu3/ipu3.cpp b/src/libcamera/pipeline/ipu3/ipu3.cpp\nindex eb00eecfd10a89e4..72da6ed62a7f0de5 100644\n--- a/src/libcamera/pipeline/ipu3/ipu3.cpp\n+++ b/src/libcamera/pipeline/ipu3/ipu3.cpp\n@@ -813,18 +813,16 @@ int PipelineHandlerIPU3::registerCameras()\n \t\t\t\t\t&IPU3CameraData::imguOutputBufferReady);\n \n \t\t/* Create and register the Camera instance. */\n-\t\tstd::string cameraName = cio2->sensor()->entity()->name();\n-\t\tstd::shared_ptr<Camera> camera = Camera::create(this,\n-\t\t\t\t\t\t\t\tcameraName,\n-\t\t\t\t\t\t\t\tstreams);\n-\n-\t\tregisterCamera(std::move(camera), std::move(data));\n+\t\tstd::shared_ptr<Camera> camera =\n+\t\t\tCamera::create(this, cio2->sensor(), streams);\n \n \t\tLOG(IPU3, Info)\n \t\t\t<< \"Registered Camera[\" << numCameras << \"] \\\"\"\n-\t\t\t<< cameraName << \"\\\"\"\n+\t\t\t<< camera->name() << \"\\\"\"\n \t\t\t<< \" connected to CSI-2 receiver \" << id;\n \n+\t\tregisterCamera(std::move(camera), std::move(data));\n+\n \t\tnumCameras++;\n \t}\n \ndiff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\nindex 82a0a4dfd6824fce..a62dd24b1ab76b87 100644\n--- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\n+++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\n@@ -972,7 +972,8 @@ bool PipelineHandlerRPi::match(DeviceEnumerator *enumerator)\n \tstreams.insert(&data->isp_[Isp::Stats]);\n \n \t/* Create and register the camera. */\n-\tstd::shared_ptr<Camera> camera = Camera::create(this, data->sensor_->model(), streams);\n+\tstd::shared_ptr<Camera> camera =\n+\t\tCamera::create(this, data->sensor_, streams);\n \tregisterCamera(std::move(camera), std::move(data));\n \n \treturn true;\ndiff --git a/src/libcamera/pipeline/rkisp1/rkisp1.cpp b/src/libcamera/pipeline/rkisp1/rkisp1.cpp\nindex 52a0d862417cc4ec..663e45b109aae9eb 100644\n--- a/src/libcamera/pipeline/rkisp1/rkisp1.cpp\n+++ b/src/libcamera/pipeline/rkisp1/rkisp1.cpp\n@@ -971,7 +971,7 @@ int PipelineHandlerRkISP1::createCamera(MediaEntity *sensor)\n \n \tstd::set<Stream *> streams{ &data->stream_ };\n \tstd::shared_ptr<Camera> camera =\n-\t\tCamera::create(this, sensor->name(), streams);\n+\t\tCamera::create(this, data->sensor_, streams);\n \tregisterCamera(std::move(camera), std::move(data));\n \n \treturn 0;\ndiff --git a/src/libcamera/pipeline/simple/simple.cpp b/src/libcamera/pipeline/simple/simple.cpp\nindex 5221ff3384923f56..fcbf0723b69f87d4 100644\n--- a/src/libcamera/pipeline/simple/simple.cpp\n+++ b/src/libcamera/pipeline/simple/simple.cpp\n@@ -800,7 +800,7 @@ bool SimplePipelineHandler::match(DeviceEnumerator *enumerator)\n \t\t\tcontinue;\n \n \t\tstd::shared_ptr<Camera> camera =\n-\t\t\tCamera::create(this, data->sensor_->entity()->name(),\n+\t\t\tCamera::create(this, data->sensor_.get(),\n \t\t\t\t       data->streams());\n \t\tregisterCamera(std::move(camera), std::move(data));\n \t}\ndiff --git a/src/libcamera/pipeline/vimc/vimc.cpp b/src/libcamera/pipeline/vimc/vimc.cpp\nindex 4f461b928514022d..74243de13346d4a8 100644\n--- a/src/libcamera/pipeline/vimc/vimc.cpp\n+++ b/src/libcamera/pipeline/vimc/vimc.cpp\n@@ -432,9 +432,9 @@ bool PipelineHandlerVimc::match(DeviceEnumerator *enumerator)\n \t\treturn false;\n \n \t/* Create and register the camera. */\n-\tstd::string name{ \"VIMC \" + data->sensor_->model() };\n \tstd::set<Stream *> streams{ &data->stream_ };\n-\tstd::shared_ptr<Camera> camera = Camera::create(this, name, streams);\n+\tstd::shared_ptr<Camera> camera =\n+\t\tCamera::create(this, data->sensor_, streams);\n \tregisterCamera(std::move(camera), std::move(data));\n \n \treturn true;\ndiff --git a/test/camera/buffer_import.cpp b/test/camera/buffer_import.cpp\nindex ab406c35fe9e07e7..838b3e867b220adc 100644\n--- a/test/camera/buffer_import.cpp\n+++ b/test/camera/buffer_import.cpp\n@@ -28,7 +28,7 @@ class BufferImportTest : public CameraTest, public Test\n {\n public:\n \tBufferImportTest()\n-\t\t: CameraTest(\"VIMC Sensor B (PipelineHandlerVimc)\")\n+\t\t: CameraTest(\"Sensor B location front (PipelineHandlerVimc)\")\n \t{\n \t}\n \ndiff --git a/test/camera/capture.cpp b/test/camera/capture.cpp\nindex 1d57201ef83de1aa..a0d7c5cba8b16c56 100644\n--- a/test/camera/capture.cpp\n+++ b/test/camera/capture.cpp\n@@ -18,7 +18,7 @@ class Capture : public CameraTest, public Test\n {\n public:\n \tCapture()\n-\t\t: CameraTest(\"VIMC Sensor B (PipelineHandlerVimc)\")\n+\t\t: CameraTest(\"Sensor B location front (PipelineHandlerVimc)\")\n \t{\n \t}\n \ndiff --git a/test/camera/configuration_default.cpp b/test/camera/configuration_default.cpp\nindex a1159c18d78c8493..7e87c2f84add463d 100644\n--- a/test/camera/configuration_default.cpp\n+++ b/test/camera/configuration_default.cpp\n@@ -18,7 +18,7 @@ class ConfigurationDefault : public CameraTest, public Test\n {\n public:\n \tConfigurationDefault()\n-\t\t: CameraTest(\"VIMC Sensor B (PipelineHandlerVimc)\")\n+\t\t: CameraTest(\"Sensor B location front (PipelineHandlerVimc)\")\n \t{\n \t}\n \ndiff --git a/test/camera/configuration_set.cpp b/test/camera/configuration_set.cpp\nindex 63331c0a2c7df799..80a78f63d59b8d7c 100644\n--- a/test/camera/configuration_set.cpp\n+++ b/test/camera/configuration_set.cpp\n@@ -18,7 +18,7 @@ class ConfigurationSet : public CameraTest, public Test\n {\n public:\n \tConfigurationSet()\n-\t\t: CameraTest(\"VIMC Sensor B (PipelineHandlerVimc)\")\n+\t\t: CameraTest(\"Sensor B location front (PipelineHandlerVimc)\")\n \t{\n \t}\n \ndiff --git a/test/camera/statemachine.cpp b/test/camera/statemachine.cpp\nindex 77d021823774a674..1fa63a243405613c 100644\n--- a/test/camera/statemachine.cpp\n+++ b/test/camera/statemachine.cpp\n@@ -18,7 +18,7 @@ class Statemachine : public CameraTest, public Test\n {\n public:\n \tStatemachine()\n-\t\t: CameraTest(\"VIMC Sensor B (PipelineHandlerVimc)\")\n+\t\t: CameraTest(\"Sensor B location front (PipelineHandlerVimc)\")\n \t{\n \t}\n \ndiff --git a/test/controls/control_info_map.cpp b/test/controls/control_info_map.cpp\nindex 1d601a827e10e995..c2bf583eaeeb3d04 100644\n--- a/test/controls/control_info_map.cpp\n+++ b/test/controls/control_info_map.cpp\n@@ -24,7 +24,7 @@ class ControlInfoMapTest : public CameraTest, public Test\n {\n public:\n \tControlInfoMapTest()\n-\t\t: CameraTest(\"VIMC Sensor B (PipelineHandlerVimc)\")\n+\t\t: CameraTest(\"Sensor B location front (PipelineHandlerVimc)\")\n \t{\n \t}\n \ndiff --git a/test/controls/control_list.cpp b/test/controls/control_list.cpp\nindex 5dad297501d009a5..b33e44f5014bbb98 100644\n--- a/test/controls/control_list.cpp\n+++ b/test/controls/control_list.cpp\n@@ -24,7 +24,7 @@ class ControlListTest : public CameraTest, public Test\n {\n public:\n \tControlListTest()\n-\t\t: CameraTest(\"VIMC Sensor B (PipelineHandlerVimc)\")\n+\t\t: CameraTest(\"Sensor B location front (PipelineHandlerVimc)\")\n \t{\n \t}\n \ndiff --git a/test/serialization/serialization_test.h b/test/serialization/serialization_test.h\nindex 621c6d6279525300..3f326e8f9c90ff34 100644\n--- a/test/serialization/serialization_test.h\n+++ b/test/serialization/serialization_test.h\n@@ -20,7 +20,7 @@ class SerializationTest : public CameraTest, public Test\n {\n public:\n \tSerializationTest()\n-\t\t: CameraTest(\"VIMC Sensor B (PipelineHandlerVimc)\")\n+\t\t: CameraTest(\"Sensor B facing forward (PipelineHandlerVimc)\")\n \t{\n \t}\n \n",
    "prefixes": [
        "libcamera-devel",
        "v2",
        "2/6"
    ]
}