Patch Detail
Show a patch.
GET /api/patches/3731/?format=api
{ "id": 3731, "url": "https://patchwork.libcamera.org/api/patches/3731/?format=api", "web_url": "https://patchwork.libcamera.org/patch/3731/", "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": "<20200509090456.3496481-7-jacopo@jmondi.org>", "date": "2020-05-09T09:04:49", "name": "[libcamera-devel,v11,06/13] media: v4l2-fwnode: Add helper to parse device properties", "commit_ref": null, "pull_url": null, "state": "not-applicable", "archived": false, "hash": "9e5020299eeef1eddf9c08e63860f406675319b6", "submitter": { "id": 3, "url": "https://patchwork.libcamera.org/api/people/3/?format=api", "name": "Jacopo Mondi", "email": "jacopo@jmondi.org" }, "delegate": { "id": 15, "url": "https://patchwork.libcamera.org/api/users/15/?format=api", "username": "jmondi", "first_name": "Jacopo", "last_name": "Mondi", "email": "jacopo@jmondi.org" }, "mbox": "https://patchwork.libcamera.org/patch/3731/mbox/", "series": [ { "id": 889, "url": "https://patchwork.libcamera.org/api/series/889/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=889", "date": "2020-05-09T09:04:43", "name": "media: report camera properties", "version": 11, "mbox": "https://patchwork.libcamera.org/series/889/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/3731/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/3731/checks/", "tags": {}, "headers": { "Return-Path": "<jacopo@jmondi.org>", "Received": [ "from relay5-d.mail.gandi.net (relay5-d.mail.gandi.net\n\t[217.70.183.197])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 72423603E2\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSat, 9 May 2020 11:02:12 +0200 (CEST)", "from uno.homenet.telecomitalia.it (a-ur1-85.tin.it\n\t[212.216.150.148]) (Authenticated sender: jacopo@jmondi.org)\n\tby relay5-d.mail.gandi.net (Postfix) with ESMTPSA id 6FC691C0008;\n\tSat, 9 May 2020 09:02:09 +0000 (UTC)" ], "X-Originating-IP": "212.216.150.148", "From": "Jacopo Mondi <jacopo@jmondi.org>", "To": "linux-media@vger.kernel.org (open list:MEDIA INPUT INFRASTRUCTURE\n\t(V4L/DVB)), libcamera-devel@lists.libcamera.org,\n\tMauro Carvalho Chehab <mchehab@kernel.org>,\n\tHans Verkuil <hverkuil-cisco@xs4all.nl>,\n\tSakari Ailus <sakari.ailus@linux.intel.com>,\n\tLaurent Pinchart <laurent.pinchart@ideasonboard.com>", "Cc": "Jacopo Mondi <jacopo@jmondi.org>,\n\ttfiga@google.com,\n\tpavel@ucw.cz", "Date": "Sat, 9 May 2020 11:04:49 +0200", "Message-Id": "<20200509090456.3496481-7-jacopo@jmondi.org>", "X-Mailer": "git-send-email 2.26.1", "In-Reply-To": "<20200509090456.3496481-1-jacopo@jmondi.org>", "References": "<20200509090456.3496481-1-jacopo@jmondi.org>", "MIME-Version": "1.0", "Content-Transfer-Encoding": "8bit", "Subject": "[libcamera-devel] [PATCH v11 06/13] media: v4l2-fwnode: Add helper\n\tto parse device properties", "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": "Sat, 09 May 2020 09:02:12 -0000" }, "content": "Add an helper function to parse common device properties in the same\nway as v4l2_fwnode_endpoint_parse() parses common endpoint properties.\n\nParse the 'rotation' and 'orientation' properties from the firmware\ninterface.\n\nSigned-off-by: Jacopo Mondi <jacopo@jmondi.org>\n---\n drivers/media/v4l2-core/v4l2-fwnode.c | 42 ++++++++++++++++++++++++\n include/media/v4l2-fwnode.h | 47 +++++++++++++++++++++++++++\n 2 files changed, 89 insertions(+)", "diff": "diff --git a/drivers/media/v4l2-core/v4l2-fwnode.c b/drivers/media/v4l2-core/v4l2-fwnode.c\nindex 97f0f8b23b5dd..17b68cec8b083 100644\n--- a/drivers/media/v4l2-core/v4l2-fwnode.c\n+++ b/drivers/media/v4l2-core/v4l2-fwnode.c\n@@ -756,6 +756,48 @@ int v4l2_fwnode_connector_add_link(struct fwnode_handle *fwnode,\n }\n EXPORT_SYMBOL_GPL(v4l2_fwnode_connector_add_link);\n \n+int v4l2_fwnode_device_parse(struct device *dev,\n+\t\t\t struct v4l2_fwnode_device_properties *props)\n+{\n+\tstruct fwnode_handle *fwnode = dev_fwnode(dev);\n+\tu32 val;\n+\tint ret;\n+\n+\tmemset(props, 0, sizeof(*props));\n+\n+\tprops->orientation = V4L2_FWNODE_PROPERTY_UNSET;\n+\tret = fwnode_property_read_u32(fwnode, \"orientation\", &val);\n+\tif (!ret) {\n+\t\tswitch (val) {\n+\t\tcase V4L2_FWNODE_ORIENTATION_FRONT:\n+\t\tcase V4L2_FWNODE_ORIENTATION_BACK:\n+\t\tcase V4L2_FWNODE_ORIENTATION_EXTERNAL:\n+\t\t\tbreak;\n+\t\tdefault:\n+\t\t\tdev_warn(dev, \"Unsupported device orientation: %u\\n\", val);\n+\t\t\treturn -EINVAL;\n+\t\t}\n+\n+\t\tprops->orientation = val;\n+\t\tdev_dbg(dev, \"device orientation: %u\\n\", val);\n+\t}\n+\n+\tprops->rotation = V4L2_FWNODE_PROPERTY_UNSET;\n+\tret = fwnode_property_read_u32(fwnode, \"rotation\", &val);\n+\tif (!ret) {\n+\t\tif (val >= 360) {\n+\t\t\tdev_warn(dev, \"Unsupported device rotation: %u\\n\", val);\n+\t\t\treturn -EINVAL;\n+\t\t}\n+\n+\t\tprops->rotation = val;\n+\t\tdev_dbg(dev, \"device rotation: %u\\n\", val);\n+\t}\n+\n+\treturn 0;\n+}\n+EXPORT_SYMBOL_GPL(v4l2_fwnode_device_parse);\n+\n static int\n v4l2_async_notifier_fwnode_parse_endpoint(struct device *dev,\n \t\t\t\t\t struct v4l2_async_notifier *notifier,\ndiff --git a/include/media/v4l2-fwnode.h b/include/media/v4l2-fwnode.h\nindex dd82d6d9764ef..68c415fdaac53 100644\n--- a/include/media/v4l2-fwnode.h\n+++ b/include/media/v4l2-fwnode.h\n@@ -109,6 +109,36 @@ struct v4l2_fwnode_endpoint {\n \tunsigned int nr_of_link_frequencies;\n };\n \n+/**\n+ * V4L2_FWNODE_PROPERTY_UNSET - identify a non initialized property\n+ *\n+ * All properties in &struct v4l2_fwnode_device_properties are initialized\n+ * to this value.\n+ */\n+#define V4L2_FWNODE_PROPERTY_UNSET (-1U)\n+\n+/**\n+ * enum v4l2_fwnode_orientation - possible device orientation\n+ * @V4L2_FWNODE_ORIENTATION_FRONT: device installed on the front side\n+ * @V4L2_FWNODE_ORIENTATION_BACK: device installed on the back side\n+ * @V4L2_FWNODE_ORIENTATION_EXTERNAL: device externally located\n+ */\n+enum v4l2_fwnode_orientation {\n+\tV4L2_FWNODE_ORIENTATION_FRONT,\n+\tV4L2_FWNODE_ORIENTATION_BACK,\n+\tV4L2_FWNODE_ORIENTATION_EXTERNAL\n+};\n+\n+/**\n+ * struct v4l2_fwnode_device_properties - fwnode device properties\n+ * @orientation: device orientation. See &enum v4l2_fwnode_orientation\n+ * @rotation: device rotation\n+ */\n+struct v4l2_fwnode_device_properties {\n+\tenum v4l2_fwnode_orientation orientation;\n+\tunsigned int rotation;\n+};\n+\n /**\n * struct v4l2_fwnode_link - a link between two endpoints\n * @local_node: pointer to device_node of this endpoint\n@@ -354,6 +384,23 @@ int v4l2_fwnode_connector_parse(struct fwnode_handle *fwnode,\n int v4l2_fwnode_connector_add_link(struct fwnode_handle *fwnode,\n \t\t\t\t struct v4l2_fwnode_connector *connector);\n \n+/**\n+ * v4l2_fwnode_device_parse() - parse fwnode device properties\n+ * @dev: pointer to &struct device\n+ * @props: pointer to &struct v4l2_fwnode_device_properties where to store the\n+ *\t parsed properties values\n+ *\n+ * This function parses and validates the V4L2 fwnode device properties from the\n+ * firmware interface, and fills the @struct v4l2_fwnode_device_properties\n+ * provided by the caller.\n+ *\n+ * Return:\n+ *\t% 0 on success\n+ *\t%-EINVAL if a parsed property value is not valid\n+ */\n+int v4l2_fwnode_device_parse(struct device *dev,\n+\t\t\t struct v4l2_fwnode_device_properties *props);\n+\n /**\n * typedef parse_endpoint_func - Driver's callback function to be called on\n *\teach V4L2 fwnode endpoint.\n", "prefixes": [ "libcamera-devel", "v11", "06/13" ] }