Patch Detail
Show a patch.
GET /api/1.1/patches/2436/?format=api
{ "id": 2436, "url": "https://patchwork.libcamera.org/api/1.1/patches/2436/?format=api", "web_url": "https://patchwork.libcamera.org/patch/2436/", "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": "<20191218145001.22283-2-jacopo@jmondi.org>", "date": "2019-12-18T14:49:55", "name": "[libcamera-devel,RFC,1/7] libcamera: camera_sensor: Introduce CameraSensorFactory", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": false, "hash": "6344cfd7e26a2245ad4c51ee2d91ee88ad264ab5", "submitter": { "id": 3, "url": "https://patchwork.libcamera.org/api/1.1/people/3/?format=api", "name": "Jacopo Mondi", "email": "jacopo@jmondi.org" }, "delegate": { "id": 15, "url": "https://patchwork.libcamera.org/api/1.1/users/15/?format=api", "username": "jmondi", "first_name": "Jacopo", "last_name": "Mondi", "email": "jacopo@jmondi.org" }, "mbox": "https://patchwork.libcamera.org/patch/2436/mbox/", "series": [ { "id": 591, "url": "https://patchwork.libcamera.org/api/1.1/series/591/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=591", "date": "2019-12-18T14:49:54", "name": "Define and register 'sensor' and 'lens' properties", "version": 1, "mbox": "https://patchwork.libcamera.org/series/591/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/2436/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/2436/checks/", "tags": {}, "headers": { "Return-Path": "<jacopo@jmondi.org>", "Received": [ "from relay3-d.mail.gandi.net (relay3-d.mail.gandi.net\n\t[217.70.183.195])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id A41D960475\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 18 Dec 2019 15:47:52 +0100 (CET)", "from uno.lan (93-34-114-233.ip49.fastwebnet.it [93.34.114.233])\n\t(Authenticated sender: jacopo@jmondi.org)\n\tby relay3-d.mail.gandi.net (Postfix) with ESMTPSA id 3932060012;\n\tWed, 18 Dec 2019 14:47:52 +0000 (UTC)" ], "X-Originating-IP": "93.34.114.233", "From": "Jacopo Mondi <jacopo@jmondi.org>", "To": "libcamera-devel@lists.libcamera.org", "Date": "Wed, 18 Dec 2019 15:49:55 +0100", "Message-Id": "<20191218145001.22283-2-jacopo@jmondi.org>", "X-Mailer": "git-send-email 2.24.0", "In-Reply-To": "<20191218145001.22283-1-jacopo@jmondi.org>", "References": "<20191218145001.22283-1-jacopo@jmondi.org>", "MIME-Version": "1.0", "Content-Transfer-Encoding": "8bit", "Subject": "[libcamera-devel] [RFC 1/7] libcamera: camera_sensor: Introduce\n\tCameraSensorFactory", "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>", "X-List-Received-Date": "Wed, 18 Dec 2019 14:47:52 -0000" }, "content": "Introduce a factory to create CameraSensor derived classes instances by\ninspecting the sensor media entity name.\n\nFor now, unconditionally create and return an instance of the only\nexisting CameraSensor class in CameraSensorFactory::create()\n\nSigned-off-by: Jacopo Mondi <jacopo@jmondi.org>\n---\n src/libcamera/camera_sensor.cpp | 22 +++++++++++++++++++\n src/libcamera/include/camera_sensor.h | 10 ++++++++-\n src/libcamera/pipeline/ipu3/ipu3.cpp | 2 +-\n src/libcamera/pipeline/rkisp1/rkisp1.cpp | 2 +-\n src/libcamera/pipeline/vimc.cpp | 2 +-\n test/camera-sensor.cpp | 2 +-\n .../v4l2_videodevice_test.cpp | 2 +-\n 7 files changed, 36 insertions(+), 6 deletions(-)", "diff": "diff --git a/src/libcamera/camera_sensor.cpp b/src/libcamera/camera_sensor.cpp\nindex bc8b9e78bc42..ac8878fe336e 100644\n--- a/src/libcamera/camera_sensor.cpp\n+++ b/src/libcamera/camera_sensor.cpp\n@@ -28,6 +28,28 @@ namespace libcamera {\n \n LOG_DEFINE_CATEGORY(CameraSensor);\n \n+/**\n+ * \\class CameraSensorFactory\n+ * \\brief Factory of camera sensor\n+ *\n+ * The CameraSensorFactory instantiate and return the opportune CameraSensor\n+ * sub-class by inspecting the name of the sensor entity to handle.\n+ */\n+\n+/**\n+ * \\brief Create and return a CameraSensor\n+ * \\param[in] entity The media entity that represents the sensor to handle\n+ *\n+ * Instantiate and return the opportune CameraSensor subclass inspecting the\n+ * \\a entity name.\n+ *\n+ * \\return A pointer to a CameraSensor derived class instance\n+ */\n+CameraSensor *CameraSensorFactory::create(const MediaEntity *entity)\n+{\n+\treturn new CameraSensor(entity);\n+}\n+\n /**\n * \\class CameraSensor\n * \\brief A camera sensor based on V4L2 subdevices\ndiff --git a/src/libcamera/include/camera_sensor.h b/src/libcamera/include/camera_sensor.h\nindex 99cff98128dc..2c09b1bdb61b 100644\n--- a/src/libcamera/include/camera_sensor.h\n+++ b/src/libcamera/include/camera_sensor.h\n@@ -22,10 +22,16 @@ class V4L2Subdevice;\n \n struct V4L2SubdeviceFormat;\n \n+class CameraSensor;\n+class CameraSensorFactory final\n+{\n+public:\n+\tstatic CameraSensor *create(const MediaEntity *entity);\n+};\n+\n class CameraSensor : protected Loggable\n {\n public:\n-\texplicit CameraSensor(const MediaEntity *entity);\n \t~CameraSensor();\n \n \tCameraSensor(const CameraSensor &) = delete;\n@@ -49,6 +55,8 @@ public:\n \tconst ControlList &properties() const { return properties_; }\n \n protected:\n+\tfriend class CameraSensorFactory;\n+\texplicit CameraSensor(const MediaEntity *entity);\n \tstd::string logPrefix() const;\n \n private:\ndiff --git a/src/libcamera/pipeline/ipu3/ipu3.cpp b/src/libcamera/pipeline/ipu3/ipu3.cpp\nindex 536a63a30018..6de2f548fe1c 100644\n--- a/src/libcamera/pipeline/ipu3/ipu3.cpp\n+++ b/src/libcamera/pipeline/ipu3/ipu3.cpp\n@@ -1362,7 +1362,7 @@ int CIO2Device::init(const MediaDevice *media, unsigned int index)\n \n \tMediaLink *link = links[0];\n \tMediaEntity *sensorEntity = link->source()->entity();\n-\tsensor_ = new CameraSensor(sensorEntity);\n+\tsensor_ = CameraSensorFactory::create(sensorEntity);\n \tret = sensor_->init();\n \tif (ret)\n \t\treturn ret;\ndiff --git a/src/libcamera/pipeline/rkisp1/rkisp1.cpp b/src/libcamera/pipeline/rkisp1/rkisp1.cpp\nindex e9a70755f4c5..276a12755f59 100644\n--- a/src/libcamera/pipeline/rkisp1/rkisp1.cpp\n+++ b/src/libcamera/pipeline/rkisp1/rkisp1.cpp\n@@ -883,7 +883,7 @@ int PipelineHandlerRkISP1::createCamera(MediaEntity *sensor)\n \n \tdata->controlInfo_ = std::move(ctrls);\n \n-\tdata->sensor_ = new CameraSensor(sensor);\n+\tdata->sensor_ = CameraSensorFactory::create(sensor);\n \tret = data->sensor_->init();\n \tif (ret)\n \t\treturn ret;\ndiff --git a/src/libcamera/pipeline/vimc.cpp b/src/libcamera/pipeline/vimc.cpp\nindex 2bfab35314c4..5d6baa56ba8b 100644\n--- a/src/libcamera/pipeline/vimc.cpp\n+++ b/src/libcamera/pipeline/vimc.cpp\n@@ -403,7 +403,7 @@ int VimcCameraData::init(MediaDevice *media)\n \t\treturn ret;\n \n \t/* Create and open the camera sensor, debayer, scaler and video device. */\n-\tsensor_ = new CameraSensor(media->getEntityByName(\"Sensor B\"));\n+\tsensor_ = CameraSensorFactory::create(media->getEntityByName(\"Sensor B\"));\n \tret = sensor_->init();\n \tif (ret)\n \t\treturn ret;\ndiff --git a/test/camera-sensor.cpp b/test/camera-sensor.cpp\nindex 27c190fe7ace..0e7e3f5585d2 100644\n--- a/test/camera-sensor.cpp\n+++ b/test/camera-sensor.cpp\n@@ -50,7 +50,7 @@ protected:\n \t\t\treturn TestFail;\n \t\t}\n \n-\t\tsensor_ = new CameraSensor(entity);\n+\t\tsensor_ = CameraSensorFactory::create(entity);\n \t\tif (sensor_->init() < 0) {\n \t\t\tcerr << \"Unable to initialise camera sensor\" << endl;\n \t\t\treturn TestFail;\ndiff --git a/test/v4l2_videodevice/v4l2_videodevice_test.cpp b/test/v4l2_videodevice/v4l2_videodevice_test.cpp\nindex 577da4cb601c..3c4ca60b9076 100644\n--- a/test/v4l2_videodevice/v4l2_videodevice_test.cpp\n+++ b/test/v4l2_videodevice/v4l2_videodevice_test.cpp\n@@ -61,7 +61,7 @@ int V4L2VideoDeviceTest::init()\n \t\treturn TestFail;\n \n \tif (driver_ == \"vimc\") {\n-\t\tsensor_ = new CameraSensor(media_->getEntityByName(\"Sensor A\"));\n+\t\tsensor_ = CameraSensorFactory::create(media_->getEntityByName(\"Sensor A\"));\n \t\tif (sensor_->init())\n \t\t\treturn TestFail;\n \n", "prefixes": [ "libcamera-devel", "RFC", "1/7" ] }