summaryrefslogtreecommitdiff
path: root/drivers/staging/media/atomisp/pci/atomisp_cmd.c
diff options
context:
space:
mode:
authorHans de Goede <hdegoede@redhat.com>2024-04-11 23:21:37 +0300
committerMauro Carvalho Chehab <mchehab@kernel.org>2024-04-26 12:50:54 +0300
commit2ab6c22d61e49518b6abd10105b747bc11780b95 (patch)
tree22bb10cbebd25dc14d2c47267d970a95176ac767 /drivers/staging/media/atomisp/pci/atomisp_cmd.c
parent2bcbeeb2979d6f97c150ed88488b16e2bf83bf64 (diff)
downloadlinux-2ab6c22d61e49518b6abd10105b747bc11780b95.tar.xz
media: atomisp: Ensure CSI-receiver[x] -> ISP links correctly reflect current sensor
Add a new atomisp_setup_input_links() helper which ensures that the CSI-receiver -> ISP link for input_curr is marked as enabled and the other CSI-receiver -> ISP links are disabled. And call this helper from atomisp_register_device_nodes() for the initial setup and from atomisp_select_input() for runtime input_curr changes. Reviewed-by: Andy Shevchenko <andy@kernel.org> Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
Diffstat (limited to 'drivers/staging/media/atomisp/pci/atomisp_cmd.c')
-rw-r--r--drivers/staging/media/atomisp/pci/atomisp_cmd.c34
1 files changed, 34 insertions, 0 deletions
diff --git a/drivers/staging/media/atomisp/pci/atomisp_cmd.c b/drivers/staging/media/atomisp/pci/atomisp_cmd.c
index 6c93bab17955..b273234dc439 100644
--- a/drivers/staging/media/atomisp/pci/atomisp_cmd.c
+++ b/drivers/staging/media/atomisp/pci/atomisp_cmd.c
@@ -3755,9 +3755,43 @@ int atomisp_select_input(struct atomisp_device *isp, unsigned int input)
if (input != input_orig)
atomisp_s_sensor_power(isp, input_orig, 0);
+ atomisp_setup_input_links(isp);
return 0;
}
+/*
+ * Ensure the CSI-receiver -> ISP link for input_curr is marked as enabled and
+ * the other CSI-receiver -> ISP links are disabled.
+ */
+void atomisp_setup_input_links(struct atomisp_device *isp)
+{
+ struct media_link *link;
+
+ lockdep_assert_held(&isp->media_dev.graph_mutex);
+
+ for (int i = 0; i < ATOMISP_CAMERA_NR_PORTS; i++) {
+ link = media_entity_find_link(
+ &isp->csi2_port[i].subdev.entity.pads[CSI2_PAD_SOURCE],
+ &isp->asd.subdev.entity.pads[ATOMISP_SUBDEV_PAD_SINK]);
+ if (!link) {
+ dev_err(isp->dev, "Error cannot find CSI2-port[%d] -> ISP link\n", i);
+ continue; /* Should never happen */
+ }
+
+ /*
+ * Modify the flags directly, calling media_entity_setup_link()
+ * will end up calling atomisp_link_setup() which calls this
+ * function again leading to endless recursion.
+ */
+ if (isp->sensor_subdevs[i] == isp->inputs[isp->asd.input_curr].camera)
+ link->flags |= MEDIA_LNK_FL_ENABLED;
+ else
+ link->flags &= ~MEDIA_LNK_FL_ENABLED;
+
+ link->reverse->flags = link->flags;
+ }
+}
+
static int atomisp_set_sensor_crop_and_fmt(struct atomisp_device *isp,
struct v4l2_mbus_framefmt *ffmt,
int which)