From 12563ffefd37000698259b41b4366bb8f850e4c5 Mon Sep 17 00:00:00 2001 From: Aishwarya Kothari Date: Thu, 9 Mar 2023 14:00:07 +0100 Subject: linux-toradex-mainline: Backport camera patches This makes the ov5640 camera work on Apalis iMX6. Related-to: ELB-4616 Signed-off-by: Aishwarya Kothari (cherry picked from commit 6b5fb95b3d0fabc30fe236e82ac48488433b7ce0) --- ...async-fix-binding-async-subdevs-with-mult.patch | 107 +++++++++++++++++++++ ...edia-i2c-ov5640-Implement-get_mbus_config.patch | 54 +++++++++++ recipes-kernel/linux/linux-toradex-mainline_git.bb | 2 + 3 files changed, 163 insertions(+) create mode 100644 recipes-kernel/linux/linux-toradex-mainline-git/0001-media-v4l2-async-fix-binding-async-subdevs-with-mult.patch create mode 100644 recipes-kernel/linux/linux-toradex-mainline-git/0002-media-i2c-ov5640-Implement-get_mbus_config.patch (limited to 'recipes-kernel') diff --git a/recipes-kernel/linux/linux-toradex-mainline-git/0001-media-v4l2-async-fix-binding-async-subdevs-with-mult.patch b/recipes-kernel/linux/linux-toradex-mainline-git/0001-media-v4l2-async-fix-binding-async-subdevs-with-mult.patch new file mode 100644 index 0000000..cff4391 --- /dev/null +++ b/recipes-kernel/linux/linux-toradex-mainline-git/0001-media-v4l2-async-fix-binding-async-subdevs-with-mult.patch @@ -0,0 +1,107 @@ +From ba50876f7b4fd05b51b19a6774ff6748ba9b6902 Mon Sep 17 00:00:00 2001 +From: Philipp Zabel +Date: Wed, 10 Aug 2022 12:48:48 +0200 +Subject: [PATCH 1/2] media: v4l2-async: fix binding async subdevs with + multiple source ports + +Asynchronous subdevice probing on imx-media with imx6-mipi-csi2 is +broken since commit 1f391df44607 ("media: v4l2-async: Use endpoints in +__v4l2_async_nf_add_fwnode_remote()"). + +This is a side effect of imx6-mipi-csi2 having a single subdevice with +four separate source ports connected to different subdevices. Before, +the imx-media-csi and video-mux devices registered async sub-devices +via device fwnode that matched the imx6-mipi-csi2 device on their +respective notifiers. This caused the first asd to be put on the +notifier waiting list, and the other three to return -EEXIST and be +ignored. + +With async subdev registration via endpoint fwnode, all four asds are +distinct and three of them keep dangling on their notifiers after the +first one is bound. + +This patch modifies __v4l2_async_nf_has_async_subdev() to consider +asds matching different fwnode endpoints of the same sub-device equal +if the latter is already bound and matches via device fwnode. Further, +v4l2_async_register_subdev() is modified to remove dangling duplicate +asds that were registered before the sub-device was available to check +its fwnode. + +Fixes: 1f391df44607 ("media: v4l2-async: Use endpoints in __v4l2_async_nf_add_fwnode_remote()") +Signed-off-by: Philipp Zabel +Upstream-Status: Submitted [https://lore.kernel.org/all/20220810104848.846783-1-p.zabel@pengutronix.de/] +--- + drivers/media/v4l2-core/v4l2-async.c | 43 ++++++++++++++++++++++++++++ + 1 file changed, 43 insertions(+) + +diff --git a/drivers/media/v4l2-core/v4l2-async.c b/drivers/media/v4l2-core/v4l2-async.c +index 2f1b718a9189..b24220ed7077 100644 +--- a/drivers/media/v4l2-core/v4l2-async.c ++++ b/drivers/media/v4l2-core/v4l2-async.c +@@ -452,6 +452,22 @@ __v4l2_async_nf_has_async_subdev(struct v4l2_async_notifier *notifier, + + if (asd_equal(asd, sd->asd)) + return true; ++ ++ /* ++ * If the asd matches an endpoint fwnode, handle sub-devices ++ * with device fwnode that were already matched by another asd ++ * with a different endpoint fwnode on the same device. ++ */ ++ if (asd->match_type == V4L2_ASYNC_MATCH_FWNODE && ++ fwnode_graph_is_endpoint(asd->match.fwnode) && ++ sd->fwnode && !fwnode_graph_is_endpoint(sd->fwnode)) { ++ struct fwnode_handle *devnode; ++ ++ devnode = fwnode_graph_get_port_parent(asd->match.fwnode); ++ fwnode_handle_put(devnode); ++ if (devnode == sd->fwnode) ++ return true; ++ } + } + + return false; +@@ -749,6 +765,24 @@ __v4l2_async_nf_add_i2c(struct v4l2_async_notifier *notifier, int adapter_id, + } + EXPORT_SYMBOL_GPL(__v4l2_async_nf_add_i2c); + ++static void v4l2_async_remove_duplicate_matches(struct v4l2_subdev *sd) ++{ ++ struct v4l2_async_notifier *notifier; ++ ++ lockdep_assert_held(&list_lock); ++ ++ list_for_each_entry(notifier, ¬ifier_list, list) { ++ struct v4l2_async_subdev *asd; ++ ++ asd = v4l2_async_find_match(notifier, sd); ++ if (!asd) ++ continue; ++ ++ /* Remove from the waiting list */ ++ list_del(&asd->list); ++ } ++} ++ + int v4l2_async_register_subdev(struct v4l2_subdev *sd) + { + struct v4l2_async_notifier *subdev_notifier; +@@ -783,6 +817,15 @@ int v4l2_async_register_subdev(struct v4l2_subdev *sd) + if (ret) + goto err_unbind; + ++ /* ++ * At this point the asd is removed from the notifier wait list. ++ * There might be other notifiers with asds matching different ++ * fwnode endpoints of the same sd remaining. If the sd matches ++ * by device fwnode, remove the dangling asds. ++ */ ++ if (sd->fwnode && !fwnode_graph_is_endpoint(sd->fwnode)) ++ v4l2_async_remove_duplicate_matches(sd); ++ + ret = v4l2_async_nf_try_complete(notifier); + if (ret) + goto err_unbind; +-- +2.34.1 + diff --git a/recipes-kernel/linux/linux-toradex-mainline-git/0002-media-i2c-ov5640-Implement-get_mbus_config.patch b/recipes-kernel/linux/linux-toradex-mainline-git/0002-media-i2c-ov5640-Implement-get_mbus_config.patch new file mode 100644 index 0000000..1d9bdb5 --- /dev/null +++ b/recipes-kernel/linux/linux-toradex-mainline-git/0002-media-i2c-ov5640-Implement-get_mbus_config.patch @@ -0,0 +1,54 @@ +From 9d247c3a53a1603d912e19ed7fc23eff13555fca Mon Sep 17 00:00:00 2001 +From: Aishwarya Kothari +Date: Wed, 25 Jan 2023 13:09:15 +0100 +Subject: [PATCH 2/2] media: i2c: ov5640: Implement get_mbus_config + +Implement the introduced get_mbus_config operation to report the +config of the MIPI CSI-2, BT.656 and Parallel interface. + +Signed-off-by: Aishwarya Kothari +Upstream-Status: Submitted [https://lore.kernel.org/all/20230306063649.7387-1-marcel@ziswiler.com/] +--- + drivers/media/i2c/ov5640.c | 19 +++++++++++++++++++ + 1 file changed, 19 insertions(+) + +diff --git a/drivers/media/i2c/ov5640.c b/drivers/media/i2c/ov5640.c +index e0f908af581b..d50ce58d8032 100644 +--- a/drivers/media/i2c/ov5640.c ++++ b/drivers/media/i2c/ov5640.c +@@ -3733,6 +3733,24 @@ static int ov5640_init_cfg(struct v4l2_subdev *sd, + return 0; + } + ++static int ov5640_get_mbus_config(struct v4l2_subdev *sd, ++ unsigned int pad, ++ struct v4l2_mbus_config *cfg) ++{ ++ struct ov5640_dev *sensor = to_ov5640_dev(sd); ++ ++ cfg->type = sensor->ep.bus_type; ++ if (ov5640_is_csi2(sensor)) { ++ cfg->bus.mipi_csi2.num_data_lanes = ++ sensor->ep.bus.mipi_csi2.num_data_lanes; ++ cfg->bus.mipi_csi2.flags = sensor->ep.bus.mipi_csi2.flags; ++ } else { ++ cfg->bus.parallel.flags = sensor->ep.bus.parallel.flags; ++ } ++ ++ return 0; ++} ++ + static const struct v4l2_subdev_core_ops ov5640_core_ops = { + .log_status = v4l2_ctrl_subdev_log_status, + .subscribe_event = v4l2_ctrl_subdev_subscribe_event, +@@ -3753,6 +3771,7 @@ static const struct v4l2_subdev_pad_ops ov5640_pad_ops = { + .get_selection = ov5640_get_selection, + .enum_frame_size = ov5640_enum_frame_size, + .enum_frame_interval = ov5640_enum_frame_interval, ++ .get_mbus_config = ov5640_get_mbus_config, + }; + + static const struct v4l2_subdev_ops ov5640_subdev_ops = { +-- +2.34.1 + diff --git a/recipes-kernel/linux/linux-toradex-mainline_git.bb b/recipes-kernel/linux/linux-toradex-mainline_git.bb index db3e223..c2902e6 100644 --- a/recipes-kernel/linux/linux-toradex-mainline_git.bb +++ b/recipes-kernel/linux/linux-toradex-mainline_git.bb @@ -29,6 +29,8 @@ SRC_URI:append = " \ file://0001-thermal-imx-Update-critical-temp-threshold.patch \ file://0001-Revert-drm-panel-simple-drop-use-of-data-mapping-pro.patch \ file://0002-drivers-chipidea-disable-runtime-pm-for-imx6ul.patch \ + file://0001-media-v4l2-async-fix-binding-async-subdevs-with-mult.patch \ + file://0002-media-i2c-ov5640-Implement-get_mbus_config.patch \ " LINUX_VERSION ?= "6.3-rc" -- cgit v1.2.3