devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jack Zhu <jack.zhu@starfivetech.com>
To: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Cc: Hans Verkuil <hverkuil-cisco@xs4all.nl>,
	Mauro Carvalho Chehab <mchehab@kernel.org>,
	Robert Foss <rfoss@kernel.org>, Todor Tomov <todor.too@gmail.com>,
	<bryan.odonoghue@linaro.org>, Rob Herring <robh+dt@kernel.org>,
	Krzysztof Kozlowski <krzysztof.kozlowski+dt@linaro.org>,
	Conor Dooley <conor+dt@kernel.org>,
	Philipp Zabel <p.zabel@pengutronix.de>,
	Eugen Hristev <eugen.hristev@collabora.com>,
	Ezequiel Garcia <ezequiel@vanguardiasur.com.ar>,
	<linux-media@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
	<devicetree@vger.kernel.org>, <changhuang.liang@starfivetech.com>
Subject: Re: [PATCH v7 4/6] media: starfive: camss: Add video driver
Date: Wed, 2 Aug 2023 09:26:11 +0800	[thread overview]
Message-ID: <fd8cdd07-105e-a801-6186-d432cfaaf684@starfivetech.com> (raw)
In-Reply-To: <20230801184741.GB30382@pendragon.ideasonboard.com>



On 2023/8/2 2:47, Laurent Pinchart wrote:
> Hi Jack,
> 
> On Tue, Aug 01, 2023 at 02:23:07PM +0800, Jack Zhu wrote:
>> On 2023/7/27 16:49, Hans Verkuil wrote:
>> > On 19/06/2023 13:28, Jack Zhu wrote:
>> >> Add video driver for StarFive Camera Subsystem.
>> >> 
>> >> Signed-off-by: Jack Zhu <jack.zhu@starfivetech.com>
>> >> ---
>> >>  .../media/platform/starfive/camss/Makefile    |   4 +-
>> >>  .../media/platform/starfive/camss/stf_video.c | 724 ++++++++++++++++++
>> >>  .../media/platform/starfive/camss/stf_video.h |  92 +++
>> >>  3 files changed, 819 insertions(+), 1 deletion(-)
>> >>  create mode 100644 drivers/media/platform/starfive/camss/stf_video.c
>> >>  create mode 100644 drivers/media/platform/starfive/camss/stf_video.h
> 
> [snip]
> 
>> >> diff --git a/drivers/media/platform/starfive/camss/stf_video.c b/drivers/media/platform/starfive/camss/stf_video.c
>> >> new file mode 100644
>> >> index 000000000000..2e6472fe51c6
>> >> --- /dev/null
>> >> +++ b/drivers/media/platform/starfive/camss/stf_video.c
>> >> @@ -0,0 +1,724 @@
> 
> [snip]
> 
>> >> +int stf_video_register(struct stfcamss_video *video,
>> >> +		       struct v4l2_device *v4l2_dev, const char *name)
>> >> +{
>> >> +	struct video_device *vdev;
>> >> +	struct vb2_queue *q;
>> >> +	struct media_pad *pad = &video->pad;
>> >> +	int ret;
>> >> +
>> >> +	vdev = &video->vdev;
>> >> +
>> >> +	mutex_init(&video->q_lock);
>> >> +
>> >> +	q = &video->vb2_q;
>> >> +	q->drv_priv = video;
>> >> +	q->mem_ops = &vb2_dma_contig_memops;
>> >> +	q->ops = &stf_video_vb2_q_ops;
>> >> +	q->type = video->type;
>> >> +	q->io_modes = VB2_DMABUF | VB2_MMAP | VB2_READ;
>> > 
>> > VB2_READ support does not generally make sense for uncompressed video since
>> > read() always requires a memcpy, and that makes it very inefficient.
>> > 
>> > It doesn't hurt though, so it is up to you whether or not you want this.
>> 
>> Yes, we would like to retain this feature to meet some possible special needs.
> 
> The issue with enabling READ support in drivers is that it encourages
> applications to do the wrong thing. If you want to keep it, I'd like to
> know what use cases you envision would strongly require it.
> 

OK, I'll drop it. Thank you!

>> >> +	q->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
>> >> +	q->buf_struct_size = sizeof(struct stfcamss_buffer);
>> >> +	q->dev = video->stfcamss->dev;
>> >> +	q->lock = &video->q_lock;
>> >> +	q->min_buffers_needed = STFCAMSS_MIN_BUFFERS;
>> >> +	ret = vb2_queue_init(q);
>> >> +	if (ret < 0) {
>> >> +		dev_err(video->stfcamss->dev,
>> >> +			"Failed to init vb2 queue: %d\n", ret);
>> >> +		goto err_vb2_init;
>> >> +	}
>> >> +
>> >> +	pad->flags = MEDIA_PAD_FL_SINK;
>> >> +	ret = media_entity_pads_init(&vdev->entity, 1, pad);
>> >> +	if (ret < 0) {
>> >> +		dev_err(video->stfcamss->dev,
>> >> +			"Failed to init video entity: %d\n", ret);
>> >> +		goto err_vb2_init;
>> >> +	}
>> >> +
>> >> +	mutex_init(&video->lock);
>> >> +
>> >> +	if (video->id == STF_V_LINE_WR) {
>> >> +		video->formats = formats_pix_wr;
>> >> +		video->nformats = ARRAY_SIZE(formats_pix_wr);
>> >> +		video->bpl_alignment = 8;
>> >> +	} else {
>> >> +		video->formats = formats_pix_isp;
>> >> +		video->nformats = ARRAY_SIZE(formats_pix_isp);
>> >> +		video->bpl_alignment = 1;
>> >> +	}
>> >> +
>> >> +	ret = stf_video_init_format(video);
>> >> +	if (ret < 0) {
>> >> +		dev_err(video->stfcamss->dev,
>> >> +			"Failed to init format: %d\n", ret);
>> >> +		goto err_vid_init_format;
>> >> +	}
>> >> +
>> >> +	vdev->fops = &stf_vid_fops;
>> >> +	vdev->ioctl_ops = &stf_vid_ioctl_ops;
>> >> +	vdev->device_caps = V4L2_CAP_VIDEO_CAPTURE;
>> >> +	vdev->vfl_dir = VFL_DIR_RX;
>> >> +	vdev->device_caps |= V4L2_CAP_STREAMING | V4L2_CAP_READWRITE;
>> >> +	vdev->release = stf_video_release;
>> >> +	vdev->v4l2_dev = v4l2_dev;
>> >> +	vdev->queue = &video->vb2_q;
>> >> +	vdev->lock = &video->lock;
>> >> +	strscpy(vdev->name, name, sizeof(vdev->name));
>> >> +
>> >> +	ret = video_register_device(vdev, VFL_TYPE_VIDEO, video->id);
>> >> +	if (ret < 0) {
>> >> +		dev_err(video->stfcamss->dev,
>> >> +			"Failed to register video device: %d\n", ret);
>> >> +		goto err_vid_reg;
>> >> +	}
>> >> +
>> >> +	video_set_drvdata(vdev, video);
>> >> +	return 0;
>> >> +
>> >> +err_vid_reg:
>> >> +err_vid_init_format:
>> >> +	media_entity_cleanup(&vdev->entity);
>> >> +	mutex_destroy(&video->lock);
>> >> +err_vb2_init:
>> >> +	mutex_destroy(&video->q_lock);
>> >> +	return ret;
>> >> +}
> 
> [snip]
> 

  reply	other threads:[~2023-08-02  1:26 UTC|newest]

Thread overview: 43+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-19 11:28 [PATCH v7 0/6] Add StarFive Camera Subsystem driver Jack Zhu
2023-06-19 11:28 ` [PATCH v7 1/6] media: dt-bindings: Add JH7110 Camera Subsystem Jack Zhu
2023-06-19 11:28 ` [PATCH v7 2/6] media: admin-guide: Add starfive_camss.rst for Starfive " Jack Zhu
2023-07-26 11:26   ` Bryan O'Donoghue
2023-07-26 22:26     ` Jack Zhu
2023-07-27 10:23     ` Laurent Pinchart
2023-07-31  3:39       ` Jack Zhu
2023-06-19 11:28 ` [PATCH v7 3/6] media: starfive: camss: Add basic driver Jack Zhu
2023-07-26 10:55   ` Bryan O'Donoghue
2023-07-26 22:14     ` Jack Zhu
2023-07-26 10:58   ` Bryan O'Donoghue
2023-07-26 22:18     ` Jack Zhu
2023-07-27 11:33   ` Laurent Pinchart
2023-08-01  3:24     ` Jack Zhu
2023-08-01 18:45       ` Laurent Pinchart
2023-08-02  1:22         ` Jack Zhu
2023-06-19 11:28 ` [PATCH v7 4/6] media: starfive: camss: Add video driver Jack Zhu
2023-07-27  8:49   ` Hans Verkuil
2023-08-01  6:23     ` Jack Zhu
2023-08-01 18:47       ` Laurent Pinchart
2023-08-02  1:26         ` Jack Zhu [this message]
2023-07-27 15:25   ` Laurent Pinchart
2023-08-02  2:57     ` Jack Zhu
2023-08-02  9:13       ` Laurent Pinchart
2023-06-19 11:28 ` [PATCH v7 5/6] media: starfive: camss: Add ISP driver Jack Zhu
2023-06-22  3:29   ` kernel test robot
2023-07-26  9:11   ` Hans Verkuil
2023-07-26 10:01     ` Jack Zhu
2023-07-27 20:41   ` Laurent Pinchart
2023-08-02  9:57     ` Jack Zhu
2023-08-02 10:48       ` Laurent Pinchart
2023-08-03  2:41         ` Jack Zhu
2023-08-03 22:07           ` Laurent Pinchart
2023-06-19 11:28 ` [PATCH v7 6/6] media: starfive: camss: Add VIN driver Jack Zhu
2023-07-27 20:49   ` Laurent Pinchart
2023-08-02  9:58     ` Jack Zhu
2023-08-02 10:38       ` Laurent Pinchart
2023-08-03  2:44         ` Jack Zhu
2023-08-03 22:18           ` Laurent Pinchart
2023-08-04 11:14             ` Jack Zhu
2023-08-24 13:38               ` Laurent Pinchart
2023-07-10  5:45 ` [PATCH v7 0/6] Add StarFive Camera Subsystem driver Jack Zhu
2023-07-26  7:28 ` 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=fd8cdd07-105e-a801-6186-d432cfaaf684@starfivetech.com \
    --to=jack.zhu@starfivetech.com \
    --cc=bryan.odonoghue@linaro.org \
    --cc=changhuang.liang@starfivetech.com \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=eugen.hristev@collabora.com \
    --cc=ezequiel@vanguardiasur.com.ar \
    --cc=hverkuil-cisco@xs4all.nl \
    --cc=krzysztof.kozlowski+dt@linaro.org \
    --cc=laurent.pinchart@ideasonboard.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=mchehab@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;
as well as URLs for NNTP newsgroup(s).