Show a patch.

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

{
    "id": 3523,
    "url": "https://patchwork.libcamera.org/api/patches/3523/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/3523/",
    "project": {
        "id": 1,
        "url": "https://patchwork.libcamera.org/api/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": "<20200424215304.558317-6-jacopo@jmondi.org>",
    "date": "2020-04-24T21:52:56",
    "name": "[libcamera-devel,v3,05/13] libcamera: camera_sensor: Break out properties initialization",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": false,
    "hash": "2bd85af350679ec0f79476a0a912c9b3162ffe47",
    "submitter": {
        "id": 3,
        "url": "https://patchwork.libcamera.org/api/people/3/?format=api",
        "name": "Jacopo Mondi",
        "email": "jacopo@jmondi.org"
    },
    "delegate": null,
    "mbox": "https://patchwork.libcamera.org/patch/3523/mbox/",
    "series": [
        {
            "id": 822,
            "url": "https://patchwork.libcamera.org/api/series/822/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=822",
            "date": "2020-04-24T21:52:51",
            "name": "libcamera: Add CameraSensorInfo",
            "version": 3,
            "mbox": "https://patchwork.libcamera.org/series/822/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/3523/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/3523/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 6FC7462E4D\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 24 Apr 2020 23:50:09 +0200 (CEST)",
            "from uno.homenet.telecomitalia.it\n\t(host240-55-dynamic.3-87-r.retail.telecomitalia.it [87.3.55.240])\n\t(Authenticated sender: jacopo@jmondi.org)\n\tby relay3-d.mail.gandi.net (Postfix) with ESMTPSA id C272860002;\n\tFri, 24 Apr 2020 21:50:07 +0000 (UTC)"
        ],
        "X-Originating-IP": "87.3.55.240",
        "From": "Jacopo Mondi <jacopo@jmondi.org>",
        "To": "libcamera-devel@lists.libcamera.org",
        "Date": "Fri, 24 Apr 2020 23:52:56 +0200",
        "Message-Id": "<20200424215304.558317-6-jacopo@jmondi.org>",
        "X-Mailer": "git-send-email 2.26.1",
        "In-Reply-To": "<20200424215304.558317-1-jacopo@jmondi.org>",
        "References": "<20200424215304.558317-1-jacopo@jmondi.org>",
        "MIME-Version": "1.0",
        "Content-Type": "text/plain; charset=UTF-8",
        "Content-Transfer-Encoding": "8bit",
        "Subject": "[libcamera-devel] [PATCH v3 05/13] libcamera: camera_sensor: Break\n\tout properties initialization",
        "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": "Fri, 24 Apr 2020 21:50:09 -0000"
    },
    "content": "Refactor the CameraSensor properties initialization to a dedicated\nfunction as it is expected to grow as we augment the number of\nproperties.\n\nWhile at it, move documentation of the properties() method to match the\ndeclaration order in the class definition.\n\nReviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\nReviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>\nSigned-off-by: Jacopo Mondi <jacopo@jmondi.org>\n---\n src/libcamera/camera_sensor.cpp       | 99 +++++++++++++++------------\n src/libcamera/include/camera_sensor.h |  1 +\n 2 files changed, 55 insertions(+), 45 deletions(-)",
    "diff": "diff --git a/src/libcamera/camera_sensor.cpp b/src/libcamera/camera_sensor.cpp\nindex 2219a4307436..8d7abc7147a7 100644\n--- a/src/libcamera/camera_sensor.cpp\n+++ b/src/libcamera/camera_sensor.cpp\n@@ -91,45 +91,6 @@ int CameraSensor::init()\n \tif (ret < 0)\n \t\treturn ret;\n \n-\t/* Retrieve and store the camera sensor properties. */\n-\tconst ControlInfoMap &controls = subdev_->controls();\n-\tint32_t propertyValue;\n-\n-\t/* Camera Location: default is front location. */\n-\tconst auto &locationControl = controls.find(V4L2_CID_CAMERA_SENSOR_LOCATION);\n-\tif (locationControl != controls.end()) {\n-\t\tint32_t v4l2Location =\n-\t\t\tlocationControl->second.def().get<int32_t>();\n-\n-\t\tswitch (v4l2Location) {\n-\t\tdefault:\n-\t\t\tLOG(CameraSensor, Warning)\n-\t\t\t\t<< \"Unsupported camera location \"\n-\t\t\t\t<< v4l2Location << \", setting to Front\";\n-\t\t\t/* Fall-through */\n-\t\tcase V4L2_LOCATION_FRONT:\n-\t\t\tpropertyValue = properties::CameraLocationFront;\n-\t\t\tbreak;\n-\t\tcase V4L2_LOCATION_BACK:\n-\t\t\tpropertyValue = properties::CameraLocationBack;\n-\t\t\tbreak;\n-\t\tcase V4L2_LOCATION_EXTERNAL:\n-\t\t\tpropertyValue = properties::CameraLocationExternal;\n-\t\t\tbreak;\n-\t\t}\n-\t} else {\n-\t\tpropertyValue = properties::CameraLocationFront;\n-\t}\n-\tproperties_.set(properties::Location, propertyValue);\n-\n-\t/* Camera Rotation: default is 0 degrees. */\n-\tconst auto &rotationControl = controls.find(V4L2_CID_CAMERA_SENSOR_ROTATION);\n-\tif (rotationControl != controls.end())\n-\t\tpropertyValue = rotationControl->second.def().get<int32_t>();\n-\telse\n-\t\tpropertyValue = 0;\n-\tproperties_.set(properties::Rotation, propertyValue);\n-\n \t/* Enumerate and cache media bus codes and sizes. */\n \tconst ImageFormats formats = subdev_->formats(0);\n \tif (formats.isEmpty()) {\n@@ -160,6 +121,54 @@ int CameraSensor::init()\n \tstd::sort(mbusCodes_.begin(), mbusCodes_.end());\n \tstd::sort(sizes_.begin(), sizes_.end());\n \n+\treturn initProperties();\n+}\n+\n+/**\n+ * \\brief Initialize the camera sensor standard properties\n+ *\n+ * This method initializes the camera sensor standard properties, by inspecting\n+ * the control information reported by the sensor subdevice.\n+ *\n+ * \\return 0 on success, a negative error code otherwise\n+ */\n+int CameraSensor::initProperties()\n+{\n+\tconst ControlInfoMap &controlMap = subdev_->controls();\n+\tint32_t propertyValue;\n+\n+\t/* Camera Location: default is front location. */\n+\tconst auto &locationControl = controlMap.find(V4L2_CID_CAMERA_SENSOR_LOCATION);\n+\tif (locationControl != controlMap.end()) {\n+\t\tint32_t v4l2Location =\n+\t\t\tlocationControl->second.def().get<int32_t>();\n+\t\tswitch (v4l2Location) {\n+\t\tcase V4L2_LOCATION_EXTERNAL:\n+\t\t\tpropertyValue = properties::CameraLocationExternal;\n+\t\t\tbreak;\n+\t\tcase V4L2_LOCATION_FRONT:\n+\t\t\tpropertyValue = properties::CameraLocationFront;\n+\t\t\tbreak;\n+\t\tcase V4L2_LOCATION_BACK:\n+\t\t\tpropertyValue = properties::CameraLocationBack;\n+\t\t\tbreak;\n+\t\tdefault:\n+\t\t\tLOG(CameraSensor, Error)\n+\t\t\t\t<< \"Unsupported camera location: \" << v4l2Location;\n+\t\t\treturn -EINVAL;\n+\t\t}\n+\t} else {\n+\t\tpropertyValue = properties::CameraLocationFront;\n+\t}\n+\tproperties_.set(properties::Location, propertyValue);\n+\n+\t/* Camera Rotation: default is 0 degrees. */\n+\tpropertyValue = 0;\n+\tconst auto &rotationControl = controlMap.find(V4L2_CID_CAMERA_SENSOR_ROTATION);\n+\tif (rotationControl != controlMap.end())\n+\t\tpropertyValue = rotationControl->second.def().get<int32_t>();\n+\tproperties_.set(properties::Rotation, propertyValue);\n+\n \treturn 0;\n }\n \n@@ -325,12 +334,6 @@ int CameraSensor::getControls(ControlList *ctrls)\n \treturn subdev_->getControls(ctrls);\n }\n \n-/**\n- * \\fn CameraSensor::properties()\n- * \\brief Retrieve the camera sensor properties\n- * \\return The list of camera sensor properties\n- */\n-\n /**\n  * \\brief Write controls to the sensor\n  * \\param[in] ctrls The list of controls to write\n@@ -361,6 +364,12 @@ int CameraSensor::setControls(ControlList *ctrls)\n \treturn subdev_->setControls(ctrls);\n }\n \n+/**\n+ * \\fn CameraSensor::properties()\n+ * \\brief Retrieve the camera sensor properties\n+ * \\return The list of camera sensor properties\n+ */\n+\n std::string CameraSensor::logPrefix() const\n {\n \treturn \"'\" + subdev_->entity()->name() + \"'\";\ndiff --git a/src/libcamera/include/camera_sensor.h b/src/libcamera/include/camera_sensor.h\nindex 99cff98128dc..8fa4d450f959 100644\n--- a/src/libcamera/include/camera_sensor.h\n+++ b/src/libcamera/include/camera_sensor.h\n@@ -32,6 +32,7 @@ public:\n \tCameraSensor &operator=(const CameraSensor &) = delete;\n \n \tint init();\n+\tint initProperties();\n \n \tconst MediaEntity *entity() const { return entity_; }\n \tconst std::vector<unsigned int> &mbusCodes() const { return mbusCodes_; }\n",
    "prefixes": [
        "libcamera-devel",
        "v3",
        "05/13"
    ]
}