linux-media.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Ming Qian <ming.qian@nxp.com>
To: Hans Verkuil <hverkuil-cisco@xs4all.nl>,
	"mchehab@kernel.org" <mchehab@kernel.org>,
	"shawnguo@kernel.org" <shawnguo@kernel.org>,
	"robh+dt@kernel.org" <robh+dt@kernel.org>,
	"s.hauer@pengutronix.de" <s.hauer@pengutronix.de>
Cc: "kernel@pengutronix.de" <kernel@pengutronix.de>,
	"festevam@gmail.com" <festevam@gmail.com>,
	dl-linux-imx <linux-imx@nxp.com>,
	Aisheng Dong <aisheng.dong@nxp.com>,
	"linux-media@vger.kernel.org" <linux-media@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"devicetree@vger.kernel.org" <devicetree@vger.kernel.org>,
	"linux-arm-kernel@lists.infradead.org" 
	<linux-arm-kernel@lists.infradead.org>
Subject: RE: [EXT] Re: [PATCH v13 06/13] media: amphion: add vpu v4l2 m2m support
Date: Fri, 3 Dec 2021 01:54:20 +0000	[thread overview]
Message-ID: <AM6PR04MB6341CDED2DB4CB01A49678A0E76A9@AM6PR04MB6341.eurprd04.prod.outlook.com> (raw)
In-Reply-To: <a26d2fab-30f1-9904-62fd-0d4c0dab6e18@xs4all.nl>

> > +
> > +int vpu_v4l2_open(struct file *file, struct vpu_inst *inst)
> > +{
> > +     struct vpu_dev *vpu = video_drvdata(file);
> > +     struct vpu_func *func;
> > +     int ret = 0;
> > +
> > +     WARN_ON(!file || !inst || !inst->ops);
> > +
> > +     if (inst->type == VPU_CORE_TYPE_ENC)
> > +             func = &vpu->encoder;
> > +     else
> > +             func = &vpu->decoder;
> > +
> > +     atomic_set(&inst->ref_count, 0);
> > +     vpu_inst_get(inst);
> > +     inst->vpu = vpu;
> > +     inst->core = vpu_request_core(vpu, inst->type);
> > +     if (inst->core)
> > +             inst->dev = get_device(inst->core->dev);
> > +     mutex_init(&inst->lock);
> > +     INIT_LIST_HEAD(&inst->cmd_q);
> > +     inst->id = VPU_INST_NULL_ID;
> > +     inst->release = vpu_v4l2_release;
> > +     inst->pid = current->pid;
> > +     inst->tgid = current->tgid;
> > +     inst->min_buffer_cap = 2;
> > +     inst->min_buffer_out = 2;
> 
> Assuming this means the minimum number of buffers needed, why is
> min_buffers_needed set to 1 when initializing the vb2_queue structs?

In my opinion, the min_buffers_needed determine when vb2_start_streaming will be called,
Like the following code:
if (q->queued_count >= q->min_buffers_needed) {
        ... ...
        ret = vb2_start_streaming(q);
        ... ...
}
I hope driver starts a vpu instance when 1 frame is queued, so I set the min_buffers_needed to 1.
And the min_buffer_cap means the minimum vb2 buffer count, and it will changed according to the stream,
I just set default value to 2, it will be changed after vpu parsed the stream info.

> 
> > +     v4l2_fh_init(&inst->fh, func->vfd);
> > +     v4l2_fh_add(&inst->fh);
> > +
> > +     ret = call_vop(inst, ctrl_init);
> > +     if (ret)
> > +             goto error;
> > +
> > +     inst->fh.m2m_ctx = v4l2_m2m_ctx_init(func->m2m_dev,
> > +                                     inst, vpu_m2m_queue_init);
> > +     if (IS_ERR(inst->fh.m2m_ctx)) {
> > +             dev_err(vpu->dev, "v4l2_m2m_ctx_init fail\n");
> > +             ret = PTR_ERR(func->m2m_dev);
> > +             goto error;
> > +     }
> > +
> > +     inst->fh.ctrl_handler = &inst->ctrl_handler;
> > +     file->private_data = &inst->fh;
> > +     inst->state = VPU_CODEC_STATE_DEINIT;
> > +     inst->workqueue = alloc_workqueue("vpu_inst", WQ_UNBOUND |
> WQ_MEM_RECLAIM, 1);
> > +     if (inst->workqueue) {
> > +             INIT_WORK(&inst->msg_work, vpu_inst_run_work);
> > +             ret = kfifo_init(&inst->msg_fifo,
> > +                             inst->msg_buffer,
> > +
> roundup_pow_of_two(sizeof(inst->msg_buffer)));
> > +             if (ret) {
> > +                     destroy_workqueue(inst->workqueue);
> > +                     inst->workqueue = NULL;
> > +             }
> > +     }
> > +     vpu_trace(vpu->dev, "tgid = %d, pid = %d, type = %s, inst = %p\n",
> > +                     inst->tgid, inst->pid,
> vpu_core_type_desc(inst->type), inst);
> > +
> > +     return 0;
> > +error:
> > +     vpu_inst_put(inst);
> > +     return ret;
> > +}
> > +

  reply	other threads:[~2021-12-03  1:54 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-30  9:48 [PATCH v13 00/13] amphion video decoder/encoder driver Ming Qian
2021-11-30  9:48 ` [PATCH v13 01/13] dt-bindings: media: amphion: add amphion video codec bindings Ming Qian
2021-11-30  9:48 ` [PATCH v13 02/13] media:Add nv12mt_8l128 and nv12mt_10be_8l128 video format Ming Qian
2021-12-02  9:39   ` Hans Verkuil
2021-12-02 10:02     ` [EXT] " Ming Qian
2021-11-30  9:48 ` [PATCH v13 03/13] media: amphion: add amphion vpu device driver Ming Qian
2021-12-02  9:44   ` Hans Verkuil
2021-12-02 10:03     ` [EXT] " Ming Qian
2021-11-30  9:48 ` [PATCH v13 04/13] media: amphion: add vpu core driver Ming Qian
2021-12-02  9:04   ` Hans Verkuil
2021-12-02  9:13     ` [EXT] " Ming Qian
2021-12-02  9:24     ` Ming Qian
2021-12-02  9:54   ` Hans Verkuil
2021-12-02 10:07     ` [EXT] " Ming Qian
2021-11-30  9:48 ` [PATCH v13 05/13] media: amphion: implement vpu core communication based on mailbox Ming Qian
2021-11-30  9:48 ` [PATCH v13 06/13] media: amphion: add vpu v4l2 m2m support Ming Qian
2021-12-02 10:29   ` Hans Verkuil
2021-12-03  1:54     ` Ming Qian [this message]
2021-12-03  4:48   ` Nicolas Dufresne
2021-11-30  9:48 ` [PATCH v13 07/13] media: amphion: add v4l2 m2m vpu encoder stateful driver Ming Qian
2021-12-02 10:41   ` Hans Verkuil
2021-11-30  9:48 ` [PATCH v13 08/13] media: amphion: add v4l2 m2m vpu decoder " Ming Qian
2021-12-03  4:55   ` Nicolas Dufresne
2021-12-03  5:42     ` [EXT] " Ming Qian
2021-12-03  6:01       ` Ming Qian
2021-12-03 15:09         ` Nicolas Dufresne
2021-12-04  2:39           ` Ming Qian
2021-11-30  9:48 ` [PATCH v13 09/13] media: amphion: implement windsor encoder rpc interface Ming Qian
2021-11-30  9:48 ` [PATCH v13 10/13] media: amphion: implement malone decoder " Ming Qian
2021-11-30  9:48 ` [PATCH v13 11/13] ARM64: dts: freescale: imx8q: add imx vpu codec entries Ming Qian
2021-11-30  9:48 ` [PATCH v13 12/13] firmware: imx: scu-pd: imx8q: add vpu mu resources Ming Qian
2021-11-30  9:48 ` [PATCH v13 13/13] MAINTAINERS: add AMPHION VPU CODEC V4L2 driver entry Ming Qian

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=AM6PR04MB6341CDED2DB4CB01A49678A0E76A9@AM6PR04MB6341.eurprd04.prod.outlook.com \
    --to=ming.qian@nxp.com \
    --cc=aisheng.dong@nxp.com \
    --cc=devicetree@vger.kernel.org \
    --cc=festevam@gmail.com \
    --cc=hverkuil-cisco@xs4all.nl \
    --cc=kernel@pengutronix.de \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-imx@nxp.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=mchehab@kernel.org \
    --cc=robh+dt@kernel.org \
    --cc=s.hauer@pengutronix.de \
    --cc=shawnguo@kernel.org \
    /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).