From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
To: Jack Zhu <jack.zhu@starfivetech.com>
Cc: Mauro Carvalho Chehab <mchehab@kernel.org>,
Maxime Ripard <mripard@kernel.org>,
Rob Herring <robh+dt@kernel.org>,
Krzysztof Kozlowski <krzysztof.kozlowski+dt@linaro.org>,
Robert Foss <rfoss@kernel.org>, Todor Tomov <todor.too@gmail.com>,
Philipp Zabel <p.zabel@pengutronix.de>,
Jernej Skrabec <jernej.skrabec@gmail.com>,
Andrzej Pietrasiewicz <andrzejtp2010@gmail.com>,
Hans Verkuil <hverkuil-cisco@xs4all.nl>,
Eugen Hristev <eugen.hristev@collabora.com>,
linux-media@vger.kernel.org, devicetree@vger.kernel.org,
linux-kernel@vger.kernel.org, changhuang.liang@starfivetech.com
Subject: Re: [PATCH v2 6/6] media: starfive: Add Starfive Camera Subsystem driver
Date: Tue, 21 Mar 2023 19:56:26 +0200 [thread overview]
Message-ID: <20230321175626.GD20234@pendragon.ideasonboard.com> (raw)
In-Reply-To: <650b6882-ea02-e4c8-1f73-9e5bdeab290d@starfivetech.com>
Hi Jack,
On Tue, Mar 21, 2023 at 08:56:34PM +0800, Jack Zhu wrote:
> On 2023/3/12 20:43, Laurent Pinchart wrote:
> > Hi Jack,
> >
> > Thank you for the patch.
> >
> > I'll do a partial review here as the patch is huge and I'm lacking time
> > at the moment.
>
> Thank you for the review and your time.
>
> > On Fri, Mar 10, 2023 at 08:05:53PM +0800, Jack Zhu wrote:
> >> Add the driver for Starfive Camera Subsystem found on
> >> Starfive JH7110 SoC. It is used for handing image sensor
> >> data.
> >>
> >> Signed-off-by: Jack Zhu <jack.zhu@starfivetech.com>
> >> ---
> >> drivers/media/platform/Kconfig | 1 +
> >> drivers/media/platform/Makefile | 1 +
> >> drivers/media/platform/starfive/Kconfig | 18 +
> >> drivers/media/platform/starfive/Makefile | 14 +
> >> drivers/media/platform/starfive/stf_camss.c | 728 +++++++++
> >> drivers/media/platform/starfive/stf_camss.h | 104 ++
> >> drivers/media/platform/starfive/stf_common.h | 149 ++
> >> drivers/media/platform/starfive/stf_isp.c | 1079 ++++++++++++++
> >> drivers/media/platform/starfive/stf_isp.h | 183 +++
> >> .../media/platform/starfive/stf_isp_hw_ops.c | 1286 ++++++++++++++++
> >> drivers/media/platform/starfive/stf_video.c | 1286 ++++++++++++++++
> >> drivers/media/platform/starfive/stf_video.h | 89 ++
> >> drivers/media/platform/starfive/stf_vin.c | 1314 +++++++++++++++++
> >> drivers/media/platform/starfive/stf_vin.h | 194 +++
> >> .../media/platform/starfive/stf_vin_hw_ops.c | 357 +++++
> >> include/uapi/linux/stf_isp_ioctl.h | 127 ++
> >> 16 files changed, 6930 insertions(+)
> >> create mode 100644 drivers/media/platform/starfive/Kconfig
> >> create mode 100644 drivers/media/platform/starfive/Makefile
> >> create mode 100644 drivers/media/platform/starfive/stf_camss.c
> >> create mode 100644 drivers/media/platform/starfive/stf_camss.h
> >> create mode 100644 drivers/media/platform/starfive/stf_common.h
> >> create mode 100644 drivers/media/platform/starfive/stf_isp.c
> >> create mode 100644 drivers/media/platform/starfive/stf_isp.h
> >> create mode 100644 drivers/media/platform/starfive/stf_isp_hw_ops.c
> >> create mode 100644 drivers/media/platform/starfive/stf_video.c
> >> create mode 100644 drivers/media/platform/starfive/stf_video.h
> >> create mode 100644 drivers/media/platform/starfive/stf_vin.c
> >> create mode 100644 drivers/media/platform/starfive/stf_vin.h
> >> create mode 100644 drivers/media/platform/starfive/stf_vin_hw_ops.c
> >> create mode 100644 include/uapi/linux/stf_isp_ioctl.h
[snip]
> >> diff --git a/drivers/media/platform/starfive/stf_camss.c b/drivers/media/platform/starfive/stf_camss.c
> >> new file mode 100644
> >> index 000000000000..525f2d80c5eb
> >> --- /dev/null
> >> +++ b/drivers/media/platform/starfive/stf_camss.c
> >> @@ -0,0 +1,728 @@
[snip]
> >> +/*
> >> + * stfcamss_find_sensor - Find a linked media entity which represents a sensor
> >> + * @entity: Media entity to start searching from
> >> + *
> >> + * Return a pointer to sensor media entity or NULL if not found
> >> + */
> >> +struct media_entity *stfcamss_find_sensor(struct media_entity *entity)
> >
> > From a camss point of view, the source is the csi2rx. You shouldn't
> > need to access the sensor directly, only the csi2rx. If you think you
> > have a need to access the sensor, please explain why and we can discuss
> > it.
>
> need to use format and bpp of sensor to configure isp HW.
You can obtain the same information from the ISP sink pad:
+----------+ +------------+ +-----------+
| | | | | |
| Sensor [0| ----> |0] csi2rx [1| ----> |0] ISP |
| | | | | |
+----------+ +------------+ +-----------+
(I'm not entirely sure if the csi2rx and ISP pad numbers are correct,
but that's the idea.)
The csi2rx can't modify the format (size and bpp), so the format on the
sensor's pad 0, csi2rx pad 0, csi2rx pad 1 and ISP pad 0 must be
identical.
In isp_sensor_fmt_to_index(), the ISP driver doesn't need to get the
format from the sensor, it can use the format on ISP pad 0 instead.
In video_enum_framesizes(), the ISP driver shouldn't look at the format
on the ISP input at all, it must enumerate all sizes that the video node
supports, regardless of what is connected to its input.
video_enum_frameintervals() should be dropped, the ISP itself has no
notion of frame interval. Userspace can query and configure the frame
rate from the sensor subdev directly.
In video_pipeline_s_fmt(), the ISP driver shouldn't look at the format
on the ISP input at all either. It must accept any format supported by
the ISP. It's only when starting streaming that the pipeline is
validated to make sure the formats configured on all subdevs match. I
recommend reading https://git.ideasonboard.org/doc/mc-v4l2.git for an
overview of how Media Controller-based drivers should behave. The
documentation describes how the API is meant to be used from userspace,
but the operating principles apply to driver development too.
video_subscribe_event() and video_unsubscribe_event() should also be
dropped, events from the sensor can be accessed by userspace on the
sensor subdev directly.
vin_set_stream() should call .s_stream() on the csi2rx, not the sensor.
The csi2rx .s_stream() handler will forward the call to the sensor.
> >> +{
> >> + struct media_pad *pad;
> >> +
> >> + while (1) {
> >> + if (!entity->pads)
> >> + return NULL;
> >> +
> >> + pad = &entity->pads[0];
> >> + if (!(pad->flags & MEDIA_PAD_FL_SINK))
> >> + return NULL;
> >> +
> >> + pad = media_pad_remote_pad_first(pad);
> >> + if (!pad || !is_media_entity_v4l2_subdev(pad->entity))
> >> + return NULL;
> >> +
> >> + entity = pad->entity;
> >> +
> >> + if (entity->function == MEDIA_ENT_F_CAM_SENSOR)
> >> + return entity;
> >> + }
> >> +}
[snip]
> >> diff --git a/include/uapi/linux/stf_isp_ioctl.h b/include/uapi/linux/stf_isp_ioctl.h
> >> new file mode 100644
> >> index 000000000000..3f302ef235d2
> >> --- /dev/null
> >> +++ b/include/uapi/linux/stf_isp_ioctl.h
> >> @@ -0,0 +1,127 @@
[snip]
> >> +enum _STF_ISP_IOCTL {
> >
> > Device-specific ioctls are allowed, but they must all be clearly
> > documented.
>
> OK, I will add annotations for these ioctls.
>
> >
> >> + STF_ISP_IOCTL_LOAD_FW = BASE_VIDIOC_PRIVATE + 1,
> >
> > Why can't you use the Linux kernel firmware API ?
>
> The ioctl is used for loading config file, it is different from
> the Linux kernel firmware API. I will rename it.
Could you explain what the config file is used for ?
> >> + STF_ISP_IOCTL_DMABUF_ALLOC,
> >> + STF_ISP_IOCTL_DMABUF_FREE,
> >> + STF_ISP_IOCTL_GET_HW_VER,
> >
> > Not used, drop them.
>
> OK, will drop them.
>
> >
> >> + STF_ISP_IOCTL_REG,
> >
> > Setting registers from userspace isn't allowed. No exception.
>
> OK, will fix.
>
> >
> >> + STF_ISP_IOCTL_SHADOW_LOCK,
> >> + STF_ISP_IOCTL_SHADOW_UNLOCK,
> >> + STF_ISP_IOCTL_SHADOW_UNLOCK_N_TRIGGER,
> >> + STF_ISP_IOCTL_SET_USER_CONFIG_ISP,
> >
> > I'm not sure what these ioctls do exactly as documentation is missing,
> > but I don't think they are the right API. Please describe the problem
> > you're trying to solve, and we'll find a good API.
>
> These were used for debugging, I will drop them. Thanks.
>
> >> + STF_ISP_IOCTL_MAX
> >> +};
[snip]
--
Regards,
Laurent Pinchart
next prev parent reply other threads:[~2023-03-21 17:57 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-10 12:05 [PATCH v2 0/6] Add Starfive Camera Subsystem driver Jack Zhu
2023-03-10 12:05 ` [PATCH v2 1/6] media: dt-bindings: Add bindings for JH7110 Camera Subsystem Jack Zhu
2023-03-12 11:12 ` Laurent Pinchart
2023-03-20 6:24 ` Jack Zhu
2023-03-12 11:16 ` Krzysztof Kozlowski
2023-03-20 6:27 ` Jack Zhu
2023-03-10 12:05 ` [PATCH v2 2/6] media: dt-bindings: cadence-csi2rx: Convert to DT schema Jack Zhu
2023-03-10 13:55 ` Rob Herring
2023-03-20 6:30 ` Jack Zhu
2023-03-12 11:09 ` Laurent Pinchart
2023-03-20 8:08 ` Jack Zhu
2023-03-12 11:17 ` Krzysztof Kozlowski
2023-03-20 8:19 ` Jack Zhu
2023-03-10 12:05 ` [PATCH v2 3/6] media: admin-guide: Add starfive_camss.rst for Starfive Camera Subsystem Jack Zhu
2023-03-10 12:05 ` [PATCH v2 4/6] media: cadence: Add support for external dphy and JH7110 SoC Jack Zhu
2023-03-12 11:33 ` Laurent Pinchart
2023-03-20 11:54 ` Jack Zhu
2023-03-10 12:05 ` [PATCH v2 5/6] MAINTAINERS: Add Starfive Camera Subsystem driver Jack Zhu
2023-03-12 11:14 ` Laurent Pinchart
2023-03-20 12:03 ` Jack Zhu
2023-03-10 12:05 ` [PATCH v2 6/6] media: starfive: " Jack Zhu
2023-03-10 14:09 ` kernel test robot
2023-03-10 14:09 ` kernel test robot
[not found] ` <20230312124339.GD2545@pendragon.ideasonboard.com>
[not found] ` <650b6882-ea02-e4c8-1f73-9e5bdeab290d@starfivetech.com>
2023-03-21 17:56 ` Laurent Pinchart [this message]
2023-03-23 11:22 ` Jack Zhu
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=20230321175626.GD20234@pendragon.ideasonboard.com \
--to=laurent.pinchart@ideasonboard.com \
--cc=andrzejtp2010@gmail.com \
--cc=changhuang.liang@starfivetech.com \
--cc=devicetree@vger.kernel.org \
--cc=eugen.hristev@collabora.com \
--cc=hverkuil-cisco@xs4all.nl \
--cc=jack.zhu@starfivetech.com \
--cc=jernej.skrabec@gmail.com \
--cc=krzysztof.kozlowski+dt@linaro.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=mchehab@kernel.org \
--cc=mripard@kernel.org \
--cc=p.zabel@pengutronix.de \
--cc=rfoss@kernel.org \
--cc=robh+dt@kernel.org \
--cc=todor.too@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