From: Hans de Goede <hdegoede@redhat.com>
To: Mauro Carvalho Chehab <mchehab@kernel.org>,
Sakari Ailus <sakari.ailus@linux.intel.com>,
Andy Shevchenko <andy@kernel.org>
Cc: Hans de Goede <hdegoede@redhat.com>, Kate Hsuan <hpa@redhat.com>,
Tsuchiya Yuto <kitakar@gmail.com>,
Yury Luneff <yury.lunev@gmail.com>,
Nable <nable.maininbox@googlemail.com>,
andrey.i.trufanov@gmail.com, Fabio Aiuto <fabioaiuto83@gmail.com>,
linux-media@vger.kernel.org, linux-staging@lists.linux.dev
Subject: [PATCH 9/9] media: atomisp: Implement link_setup op for ISP subdev MC entity
Date: Sat, 17 Feb 2024 12:24:38 +0100 [thread overview]
Message-ID: <20240217112438.15240-10-hdegoede@redhat.com> (raw)
In-Reply-To: <20240217112438.15240-1-hdegoede@redhat.com>
The atomisp driver's Android heritage makes it weird in that
even though it uses MC + subdev-s it is designed to primarily
be controlled through its /dev/video# node.
It implements s_input on /dev/video# to select which sensor to use,
while ignoring setup_link calls to enable a link to another sensor.
Add support for selecting the active sensor the MC way by adding
setup_link support.
The implementation is a bit convoluted due to the atomisp driver's
heritage.
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
.../media/atomisp/pci/atomisp_subdev.c | 52 +++++++++++++++++++
1 file changed, 52 insertions(+)
diff --git a/drivers/staging/media/atomisp/pci/atomisp_subdev.c b/drivers/staging/media/atomisp/pci/atomisp_subdev.c
index 822fe7d129e2..17819d7586dd 100644
--- a/drivers/staging/media/atomisp/pci/atomisp_subdev.c
+++ b/drivers/staging/media/atomisp/pci/atomisp_subdev.c
@@ -30,6 +30,7 @@
#include "atomisp_common.h"
#include "atomisp_compat.h"
#include "atomisp_fops.h"
+#include "atomisp_ioctl.h"
#include "atomisp_internal.h"
const struct atomisp_in_fmt_conv atomisp_in_fmt_conv[] = {
@@ -634,8 +635,59 @@ static void isp_subdev_init_params(struct atomisp_sub_device *asd)
}
/* media operations */
+static int atomisp_link_setup(struct media_entity *entity,
+ const struct media_pad *local,
+ const struct media_pad *remote, u32 flags)
+{
+ struct v4l2_subdev *sd = container_of(entity, struct v4l2_subdev,
+ entity);
+ struct atomisp_sub_device *asd = v4l2_get_subdevdata(sd);
+ struct atomisp_device *isp = asd->isp;
+ int i, csi_idx, ret;
+
+ /* ISP's source is immutable */
+ if (local != &asd->pads[ATOMISP_SUBDEV_PAD_SINK]) {
+ v4l2_err(sd, "Error pad %d does not support changing flags\n",
+ local->index);
+ return -EINVAL;
+ }
+
+ for (csi_idx = 0; csi_idx < ATOMISP_CAMERA_NR_PORTS; csi_idx++) {
+ if (&isp->csi2_port[csi_idx].pads[CSI2_PAD_SOURCE] == remote)
+ break;
+ }
+
+ if (csi_idx == ATOMISP_CAMERA_NR_PORTS) {
+ v4l2_err(sd, "Error cannot find CSI receiver for remote pad\n");
+ return -EINVAL;
+ }
+
+ /* Ignore disables, input_curr should only be updated on enables */
+ if (!(flags & MEDIA_LNK_FL_ENABLED))
+ return 0;
+
+ for (i = 0; i < isp->input_cnt; i++) {
+ if (isp->inputs[i].camera == isp->sensor_subdevs[csi_idx])
+ break;
+ }
+
+ if (i == isp->input_cnt) {
+ v4l2_err(sd, "Error no sensor for CSI receiver %d\n", csi_idx);
+ return -EINVAL;
+ }
+
+ mutex_lock(&isp->mutex);
+ ret = atomisp_pipe_check(&asd->video_out, true);
+ if (ret == 0)
+ asd->input_curr = i;
+ mutex_unlock(&isp->mutex);
+
+ return ret;
+}
+
static const struct media_entity_operations isp_subdev_media_ops = {
.link_validate = v4l2_subdev_link_validate,
+ .link_setup = atomisp_link_setup,
/* .set_power = v4l2_subdev_set_power, */
};
--
2.43.0
next prev parent reply other threads:[~2024-02-17 11:25 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-02-17 11:24 [PATCH 0/9] media: atomisp: Changes for libcamera support Hans de Goede
2024-02-17 11:24 ` [PATCH 1/9] media: atomisp: Remove isp_subdev_propagate() Hans de Goede
2024-02-17 14:57 ` Kieran Bingham
2024-02-17 11:24 ` [PATCH 2/9] media: atomisp: Rename atomisp_set_crop_and_fmt() Hans de Goede
2024-02-17 15:07 ` Kieran Bingham
2024-02-17 11:24 ` [PATCH 3/9] media: atomisp: Remove custom VCM handling Hans de Goede
2024-02-17 15:09 ` Kieran Bingham
2024-02-17 11:24 ` [PATCH 4/9] media: atomisp: Remove ISP controls which get passed through to the camera Hans de Goede
2024-02-17 15:13 ` Kieran Bingham
2024-02-17 11:24 ` [PATCH 5/9] media: atomisp: Stop setting sd->devnode for the ATOMISP_SUBDEV v4l2-subdev Hans de Goede
2024-02-17 11:24 ` [PATCH 6/9] media: atomisp: Add DMABUF support Hans de Goede
2024-02-17 15:21 ` Kieran Bingham
2024-02-17 11:24 ` [PATCH 7/9] media: atomisp: Change ISP subdev name to "ATOM ISP" Hans de Goede
2024-02-17 16:00 ` Kieran Bingham
2024-02-17 18:48 ` Andy Shevchenko
2024-02-18 11:10 ` Hans de Goede
2024-02-17 11:24 ` [PATCH 8/9] media: atomisp: Make MC link from ISP to /dev/video# output node immutable Hans de Goede
2024-02-17 15:22 ` Kieran Bingham
2024-02-17 11:24 ` Hans de Goede [this message]
2024-02-17 18:52 ` [PATCH 9/9] media: atomisp: Implement link_setup op for ISP subdev MC entity Andy Shevchenko
2024-02-18 11:08 ` Hans de Goede
2024-02-17 18:53 ` [PATCH 0/9] media: atomisp: Changes for libcamera support Andy Shevchenko
2024-02-18 11:15 ` Hans de Goede
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240217112438.15240-10-hdegoede@redhat.com \
--to=hdegoede@redhat.com \
--cc=andrey.i.trufanov@gmail.com \
--cc=andy@kernel.org \
--cc=fabioaiuto83@gmail.com \
--cc=hpa@redhat.com \
--cc=kitakar@gmail.com \
--cc=linux-media@vger.kernel.org \
--cc=linux-staging@lists.linux.dev \
--cc=mchehab@kernel.org \
--cc=nable.maininbox@googlemail.com \
--cc=sakari.ailus@linux.intel.com \
--cc=yury.lunev@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox