diff options
author | Álvaro Fernández Rojas <noltari@gmail.com> | 2021-02-18 18:04:33 +0100 |
---|---|---|
committer | Álvaro Fernández Rojas <noltari@gmail.com> | 2021-02-18 23:42:32 +0100 |
commit | f07e572f6447465d8938679533d604e402b0f066 (patch) | |
tree | cb333bd2a67e59e7c07659514850a0fd55fc825e /target/linux/bcm27xx/patches-5.4/950-0907-media-v4l2-fwnode-Add-helper-to-parse-device-propert.patch | |
parent | 5d3a6fd970619dfc55f8259035c3027d7613a2a6 (diff) | |
download | upstream-f07e572f6447465d8938679533d604e402b0f066.tar.gz upstream-f07e572f6447465d8938679533d604e402b0f066.tar.bz2 upstream-f07e572f6447465d8938679533d604e402b0f066.zip |
bcm27xx: import latest patches from the RPi foundation
bcm2708: boot tested on RPi B+ v1.2
bcm2709: boot tested on RPi 3B v1.2 and RPi 4B v1.1 4G
bcm2710: boot tested on RPi 3B v1.2
bcm2711: boot tested on RPi 4B v1.1 4G
Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com>
Diffstat (limited to 'target/linux/bcm27xx/patches-5.4/950-0907-media-v4l2-fwnode-Add-helper-to-parse-device-propert.patch')
-rw-r--r-- | target/linux/bcm27xx/patches-5.4/950-0907-media-v4l2-fwnode-Add-helper-to-parse-device-propert.patch | 138 |
1 files changed, 138 insertions, 0 deletions
diff --git a/target/linux/bcm27xx/patches-5.4/950-0907-media-v4l2-fwnode-Add-helper-to-parse-device-propert.patch b/target/linux/bcm27xx/patches-5.4/950-0907-media-v4l2-fwnode-Add-helper-to-parse-device-propert.patch new file mode 100644 index 0000000000..d0d21fc7f2 --- /dev/null +++ b/target/linux/bcm27xx/patches-5.4/950-0907-media-v4l2-fwnode-Add-helper-to-parse-device-propert.patch @@ -0,0 +1,138 @@ +From 1cc9056759e1f500de5e401afd4b0acff90cc653 Mon Sep 17 00:00:00 2001 +From: Jacopo Mondi <jacopo@jmondi.org> +Date: Sat, 9 May 2020 11:04:49 +0200 +Subject: [PATCH] media: v4l2-fwnode: Add helper to parse device + properties + +Add an helper function to parse common device properties in the same +way as v4l2_fwnode_endpoint_parse() parses common endpoint properties. + +Parse the 'rotation' and 'orientation' properties from the firmware +interface. + +Signed-off-by: Jacopo Mondi <jacopo@jmondi.org> +Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> +Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org> + +Commit 344897ef1d9b33e246b64e255d807ca6c053f349 upstream + +Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> +--- + drivers/media/v4l2-core/v4l2-fwnode.c | 42 ++++++++++++++++++++++++ + include/media/v4l2-fwnode.h | 47 +++++++++++++++++++++++++++ + 2 files changed, 89 insertions(+) + +--- a/drivers/media/v4l2-core/v4l2-fwnode.c ++++ b/drivers/media/v4l2-core/v4l2-fwnode.c +@@ -599,6 +599,48 @@ void v4l2_fwnode_put_link(struct v4l2_fw + } + EXPORT_SYMBOL_GPL(v4l2_fwnode_put_link); + ++int v4l2_fwnode_device_parse(struct device *dev, ++ struct v4l2_fwnode_device_properties *props) ++{ ++ struct fwnode_handle *fwnode = dev_fwnode(dev); ++ u32 val; ++ int ret; ++ ++ memset(props, 0, sizeof(*props)); ++ ++ props->orientation = V4L2_FWNODE_PROPERTY_UNSET; ++ ret = fwnode_property_read_u32(fwnode, "orientation", &val); ++ if (!ret) { ++ switch (val) { ++ case V4L2_FWNODE_ORIENTATION_FRONT: ++ case V4L2_FWNODE_ORIENTATION_BACK: ++ case V4L2_FWNODE_ORIENTATION_EXTERNAL: ++ break; ++ default: ++ dev_warn(dev, "Unsupported device orientation: %u\n", val); ++ return -EINVAL; ++ } ++ ++ props->orientation = val; ++ dev_dbg(dev, "device orientation: %u\n", val); ++ } ++ ++ props->rotation = V4L2_FWNODE_PROPERTY_UNSET; ++ ret = fwnode_property_read_u32(fwnode, "rotation", &val); ++ if (!ret) { ++ if (val >= 360) { ++ dev_warn(dev, "Unsupported device rotation: %u\n", val); ++ return -EINVAL; ++ } ++ ++ props->rotation = val; ++ dev_dbg(dev, "device rotation: %u\n", val); ++ } ++ ++ return 0; ++} ++EXPORT_SYMBOL_GPL(v4l2_fwnode_device_parse); ++ + static int + v4l2_async_notifier_fwnode_parse_endpoint(struct device *dev, + struct v4l2_async_notifier *notifier, +--- a/include/media/v4l2-fwnode.h ++++ b/include/media/v4l2-fwnode.h +@@ -110,6 +110,36 @@ struct v4l2_fwnode_endpoint { + }; + + /** ++ * V4L2_FWNODE_PROPERTY_UNSET - identify a non initialized property ++ * ++ * All properties in &struct v4l2_fwnode_device_properties are initialized ++ * to this value. ++ */ ++#define V4L2_FWNODE_PROPERTY_UNSET (-1U) ++ ++/** ++ * enum v4l2_fwnode_orientation - possible device orientation ++ * @V4L2_FWNODE_ORIENTATION_FRONT: device installed on the front side ++ * @V4L2_FWNODE_ORIENTATION_BACK: device installed on the back side ++ * @V4L2_FWNODE_ORIENTATION_EXTERNAL: device externally located ++ */ ++enum v4l2_fwnode_orientation { ++ V4L2_FWNODE_ORIENTATION_FRONT, ++ V4L2_FWNODE_ORIENTATION_BACK, ++ V4L2_FWNODE_ORIENTATION_EXTERNAL ++}; ++ ++/** ++ * struct v4l2_fwnode_device_properties - fwnode device properties ++ * @orientation: device orientation. See &enum v4l2_fwnode_orientation ++ * @rotation: device rotation ++ */ ++struct v4l2_fwnode_device_properties { ++ enum v4l2_fwnode_orientation orientation; ++ unsigned int rotation; ++}; ++ ++/** + * struct v4l2_fwnode_link - a link between two endpoints + * @local_node: pointer to device_node of this endpoint + * @local_port: identifier of the port this endpoint belongs to +@@ -234,6 +264,23 @@ int v4l2_fwnode_parse_link(struct fwnode + void v4l2_fwnode_put_link(struct v4l2_fwnode_link *link); + + /** ++ * v4l2_fwnode_device_parse() - parse fwnode device properties ++ * @dev: pointer to &struct device ++ * @props: pointer to &struct v4l2_fwnode_device_properties where to store the ++ * parsed properties values ++ * ++ * This function parses and validates the V4L2 fwnode device properties from the ++ * firmware interface, and fills the @struct v4l2_fwnode_device_properties ++ * provided by the caller. ++ * ++ * Return: ++ * % 0 on success ++ * %-EINVAL if a parsed property value is not valid ++ */ ++int v4l2_fwnode_device_parse(struct device *dev, ++ struct v4l2_fwnode_device_properties *props); ++ ++/** + * typedef parse_endpoint_func - Driver's callback function to be called on + * each V4L2 fwnode endpoint. + * |