From: Ivan Bornyakov <brnkv.i1@gmail.com>
To: sebastian.fricke@collabora.com
Cc: Ivan Bornyakov <brnkv.i1@gmail.com>,
bob.beckett@collabora.com, conor+dt@kernel.org,
devicetree@vger.kernel.org, festevam@gmail.com,
hverkuil@xs4all.nl, jackson.lee@chipsnmedia.com,
kernel@collabora.com, kernel@pengutronix.de,
krzysztof.kozlowski+dt@linaro.org,
linux-arm-kernel@lists.infradead.org, linux-imx@nxp.com,
linux-kernel@vger.kernel.org, linux-media@vger.kernel.org,
mchehab@kernel.org, nas.chung@chipsnmedia.com,
nicolas.dufresne@collabora.com, p.zabel@pengutronix.de,
robh+dt@kernel.org, s.hauer@pengutronix.de, shawnguo@kernel.org
Subject: Re: [PATCH v12 5/7] media: chips-media: wave5: Add the v4l2 layer
Date: Sat, 16 Sep 2023 23:28:15 +0300 [thread overview]
Message-ID: <20230916202819.7998-1-brnkv.i1@gmail.com> (raw)
In-Reply-To: <20230915-wave5_v12_on_media_master-v12-5-92fc66cd685d@collabora.com>
Hi, Sebastian,
On Fri, Sep 15, 2023 at 23:11:34 +0200, Sebastian Fricke wrote:
> From: Nas Chung <nas.chung@chipsnmedia.com>
>
> Add the decoder and encoder implementing the v4l2
> API. This patch also adds the Makefile and the VIDEO_WAVE_VPU config
>
> Signed-off-by: Sebastian Fricke <sebastian.fricke@collabora.com>
> Signed-off-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>
> Signed-off-by: Robert Beckett <bob.beckett@collabora.com>
> Signed-off-by: Dafna Hirschfeld <dafna.hirschfeld@collabora.com>
> Signed-off-by: Nas Chung <nas.chung@chipsnmedia.com>
[...]
> diff --git a/drivers/media/platform/chips-media/wave5/wave5-vpu.c b/drivers/media/platform/chips-media/wave5/wave5-vpu.c
> new file mode 100644
> index 000000000000..a13d968f5d04
> --- /dev/null
> +++ b/drivers/media/platform/chips-media/wave5/wave5-vpu.c
[...]
> +static void wave5_vpu_get_interrupt_for_inst(struct vpu_instance *inst, u32 status)
> +{
> + struct vpu_device *dev = inst->dev;
> + u32 seq_done;
> + u32 cmd_done;
> + int val;
> +
> + seq_done = wave5_vdi_read_register(dev, W5_RET_SEQ_DONE_INSTANCE_INFO);
> + cmd_done = wave5_vdi_read_register(dev, W5_RET_QUEUE_CMD_DONE_INST);
> +
> + if (status & BIT(INT_WAVE5_INIT_SEQ)) {
> + if (seq_done & BIT(inst->id)) {
> + seq_done &= ~BIT(inst->id);
> + wave5_vdi_write_register(dev, W5_RET_SEQ_DONE_INSTANCE_INFO, seq_done);
> + val = BIT(INT_WAVE5_INIT_SEQ);
> + kfifo_in(&inst->irq_status, &val, sizeof(int));
> + }
> + }
> + if (status & BIT(INT_WAVE5_ENC_SET_PARAM)) {
> + if (seq_done & BIT(inst->id)) {
> + seq_done &= ~BIT(inst->id);
> + wave5_vdi_write_register(dev, W5_RET_SEQ_DONE_INSTANCE_INFO, seq_done);
> + val = BIT(INT_WAVE5_ENC_SET_PARAM);
> + kfifo_in(&inst->irq_status, &val, sizeof(int));
> + }
> + }
> + if (status & BIT(INT_WAVE5_DEC_PIC) ||
> + status & BIT(INT_WAVE5_ENC_PIC)) {
> + if (cmd_done & BIT(inst->id)) {
> + cmd_done &= ~BIT(inst->id);
> + wave5_vdi_write_register(dev, W5_RET_QUEUE_CMD_DONE_INST, cmd_done);
> + val = BIT(INT_WAVE5_DEC_PIC);
> + kfifo_in(&inst->irq_status, &val, sizeof(int));
> + }
> + }
> +}
> +
> +static irqreturn_t wave5_vpu_irq(int irq, void *dev_id)
> +{
> + struct vpu_device *dev = dev_id;
> +
> + if (wave5_vdi_read_register(dev, W5_VPU_VPU_INT_STS)) {
> + struct vpu_instance *inst;
> + u32 irq_status = wave5_vdi_read_register(dev, W5_VPU_VINT_REASON);
> +
> + list_for_each_entry(inst, &dev->instances, list) {
> + wave5_vpu_get_interrupt_for_inst(inst, irq_status);
> + }
> +
> + wave5_vdi_write_register(dev, W5_VPU_VINT_REASON_CLR, irq_status);
> + wave5_vdi_write_register(dev, W5_VPU_VINT_CLEAR, 0x1);
> +
> + return IRQ_WAKE_THREAD;
> + }
> +
> + return IRQ_HANDLED;
> +}
> +
> +static irqreturn_t wave5_vpu_irq_thread(int irq, void *dev_id)
> +{
> + struct vpu_device *dev = dev_id;
> + struct vpu_instance *inst;
> + int irq_status, ret;
> +
> + list_for_each_entry(inst, &dev->instances, list) {
> + while (kfifo_len(&inst->irq_status)) {
> + ret = kfifo_out(&inst->irq_status, &irq_status, sizeof(int));
> + if (!ret)
> + break;
> +
> + if (irq_status == BIT(INT_WAVE5_INIT_SEQ) ||
> + irq_status == BIT(INT_WAVE5_ENC_SET_PARAM))
> + complete(&inst->irq_done);
> + else /* DEC/ENC_PIC */
> + inst->ops->finish_process(inst);
> +
> + wave5_vpu_clear_interrupt(inst, irq_status);
> + }
> + }
> +
> + return IRQ_HANDLED;
> +}
I believe, instead of
wave5_vpu_irq() + wave5_vpu_get_interrupt_for_inst() + wave5_vpu_irq_thread()
you can reduce interrupt handling to only threaded part with something like this:
static irqreturn_t wave5_vpu_irq_thread(int irq, void *dev_id)
{
u32 irq_status, seq_done, cmd_done;
struct vpu_device *dev = dev_id;
struct vpu_instance *inst;
while (wave5_vdi_read_register(dev, W5_VPU_VPU_INT_STS)) {
irq_status = wave5_vdi_read_register(dev, W5_VPU_VINT_REASON);
seq_done = wave5_vdi_read_register(dev, W5_RET_SEQ_DONE_INSTANCE_INFO);
cmd_done = wave5_vdi_read_register(dev, W5_RET_QUEUE_CMD_DONE_INST);
list_for_each_entry(inst, &dev->instances, list) {
if (irq_status & BIT(INT_WAVE5_INIT_SEQ) ||
irq_status & BIT(INT_WAVE5_ENC_SET_PARAM)) {
if (seq_done & BIT(inst->id)) {
seq_done &= ~BIT(inst->id);
wave5_vdi_write_register(dev,
W5_RET_SEQ_DONE_INSTANCE_INFO,
seq_done);
complete(&inst->irq_done);
}
}
if (status & BIT(INT_WAVE5_DEC_PIC) ||
status & BIT(INT_WAVE5_ENC_PIC)) {
if (cmd_done & BIT(inst->id)) {
cmd_done &= ~BIT(inst->id);
wave5_vdi_write_register(dev,
W5_RET_QUEUE_CMD_DONE_INST,
cmd_done);
inst->ops->finish_process(inst);
}
}
wave5_vpu_clear_interrupt(inst, irq_status);
}
wave5_vdi_write_register(dev, W5_VPU_VINT_REASON_CLR, irq_status);
wave5_vdi_write_register(dev, W5_VPU_VINT_CLEAR, 0x1);
}
return IRQ_HANDLED;
}
Is it better?
[...]
> +static int wave5_vpu_probe(struct platform_device *pdev)
> +{
> + int ret;
> + struct vpu_device *dev;
> + const struct wave5_match_data *match_data;
> + u32 fw_revision;
> +
> + match_data = device_get_match_data(&pdev->dev);
> + if (!match_data) {
> + dev_err(&pdev->dev, "missing device match data\n");
> + return -EINVAL;
> + }
> +
> + /* physical addresses limited to 32 bits */
> + dma_set_mask(&pdev->dev, DMA_BIT_MASK(32));
> + dma_set_coherent_mask(&pdev->dev, DMA_BIT_MASK(32));
dma_set_mask_and_coherent()? Also error check?
next prev parent reply other threads:[~2023-09-16 20:37 UTC|newest]
Thread overview: 61+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-09-15 21:11 [PATCH v12 0/7] Wave5 codec driver Sebastian Fricke
2023-09-15 21:11 ` Sebastian Fricke
2023-09-15 21:11 ` [PATCH v12 1/7] media: v4l2: Add ignore_streaming flag Sebastian Fricke
2023-09-15 21:11 ` Sebastian Fricke
2023-09-20 12:59 ` Hans Verkuil
2023-09-20 12:59 ` Hans Verkuil
2023-09-20 14:08 ` Nicolas Dufresne
2023-09-20 14:08 ` Nicolas Dufresne
2023-09-20 14:49 ` Hans Verkuil
2023-09-20 14:49 ` Hans Verkuil
2023-09-21 18:39 ` Nicolas Dufresne
2023-09-21 18:39 ` Nicolas Dufresne
2023-09-22 8:28 ` Hans Verkuil
2023-09-22 8:28 ` Hans Verkuil
2023-09-22 20:20 ` Nicolas Dufresne
2023-09-22 20:20 ` Nicolas Dufresne
2023-09-25 9:03 ` Hans Verkuil
2023-09-25 9:03 ` Hans Verkuil
2023-09-15 21:11 ` [PATCH v12 2/7] media: v4l2: Allow M2M job queuing w/o streaming CAP queue Sebastian Fricke
2023-09-15 21:11 ` Sebastian Fricke
2023-09-15 21:11 ` [PATCH v12 3/7] media: platform: chips-media: Move Coda to separate folder Sebastian Fricke
2023-09-15 21:11 ` Sebastian Fricke
2023-09-15 21:11 ` [PATCH v12 4/7] media: chips-media: wave5: Add vpuapi layer Sebastian Fricke
2023-09-25 11:35 ` Benjamin Gaignard
2023-09-15 21:11 ` [PATCH v12 5/7] media: chips-media: wave5: Add the v4l2 layer Sebastian Fricke
2023-09-15 21:22 ` Sebastian Fricke
2023-09-16 20:28 ` Ivan Bornyakov [this message]
2023-09-16 20:55 ` Ivan Bornyakov
2023-09-16 20:55 ` Ivan Bornyakov
2023-09-20 15:13 ` Hans Verkuil
2023-09-21 19:11 ` Nicolas Dufresne
2023-09-22 7:33 ` Hans Verkuil
2023-09-22 7:33 ` Hans Verkuil
2023-09-26 23:29 ` Nicolas Dufresne
2023-09-26 23:29 ` Nicolas Dufresne
2023-09-27 7:19 ` Hans Verkuil
2023-09-27 7:19 ` Hans Verkuil
2023-10-02 23:51 ` Deborah Brouwer
2023-10-02 23:51 ` Deborah Brouwer
2023-10-03 6:54 ` Hans Verkuil
2023-10-03 6:54 ` Hans Verkuil
2023-09-15 21:11 ` [PATCH v12 6/7] dt-bindings: media: wave5: add yaml devicetree bindings Sebastian Fricke
2023-09-15 21:11 ` Sebastian Fricke
2023-09-15 22:16 ` Rob Herring
2023-09-15 22:16 ` Rob Herring
2023-09-17 7:56 ` Krzysztof Kozlowski
2023-09-17 7:56 ` Krzysztof Kozlowski
2023-09-18 6:49 ` Sebastian Fricke
2023-09-18 6:49 ` Sebastian Fricke
2023-09-18 12:02 ` Krzysztof Kozlowski
2023-09-18 12:02 ` Krzysztof Kozlowski
2023-09-18 19:16 ` Nicolas Dufresne
2023-09-18 19:16 ` Nicolas Dufresne
2023-09-18 20:14 ` Krzysztof Kozlowski
2023-09-18 20:14 ` Krzysztof Kozlowski
2023-09-15 21:11 ` [PATCH v12 7/7] media: chips-media: wave5: Add wave5 driver to maintainers file Sebastian Fricke
2023-09-15 21:11 ` Sebastian Fricke
2023-09-20 13:02 ` Hans Verkuil
2023-09-20 13:02 ` Hans Verkuil
2023-09-20 15:32 ` Sebastian Fricke
2023-09-20 15:32 ` Sebastian Fricke
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=20230916202819.7998-1-brnkv.i1@gmail.com \
--to=brnkv.i1@gmail.com \
--cc=bob.beckett@collabora.com \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=festevam@gmail.com \
--cc=hverkuil@xs4all.nl \
--cc=jackson.lee@chipsnmedia.com \
--cc=kernel@collabora.com \
--cc=kernel@pengutronix.de \
--cc=krzysztof.kozlowski+dt@linaro.org \
--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=nas.chung@chipsnmedia.com \
--cc=nicolas.dufresne@collabora.com \
--cc=p.zabel@pengutronix.de \
--cc=robh+dt@kernel.org \
--cc=s.hauer@pengutronix.de \
--cc=sebastian.fricke@collabora.com \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.