From: Tzung-Bi Shih <tzungbi@google.com>
To: "kyrie.wu" <kyrie.wu@mediatek.com>
Cc: Hans Verkuil <hverkuil-cisco@xs4all.nl>,
Mauro Carvalho Chehab <mchehab@kernel.org>,
Rob Herring <robh+dt@kernel.org>, Bin Liu <bin.liu@mediatek.com>,
Matthias Brugger <matthias.bgg@gmail.com>,
Tzung-Bi Shih <tzungbi@chromium.org>,
Project_Global_Chrome_Upstream_Group@mediatek.com,
linux-media@vger.kernel.org, devicetree@vger.kernel.org,
linux-kernel@vger.kernel.org,
linux-arm-kernel@lists.infradead.org,
linux-mediatek@lists.infradead.org,
Tomasz Figa <tfiga@chromium.org>,
xia.jiang@mediatek.com, maoguang.meng@mediatek.com,
srv_heupstream@mediatek.com
Subject: Re: [PATCH v2, 5/9] media: mtk-jpegenc: Generalize jpeg encode irq interfaces
Date: Tue, 6 Jul 2021 19:00:43 +0800 [thread overview]
Message-ID: <CA+Px+wVLtRWsqZ3Nbd5rPrh_4dScay6BhPLCwjQaCkU8F5McuA@mail.gmail.com> (raw)
In-Reply-To: <1625038079-25815-6-git-send-email-kyrie.wu@mediatek.com>
On Wed, Jun 30, 2021 at 3:28 PM kyrie.wu <kyrie.wu@mediatek.com> wrote:
> Generalizes jpeg encode irq interfaces to support different hardware.
There are some missing pieces for using the code. I guess the patch
needs to be submitted with other patches or needs to further be
divided.
> + * mtk_jpeg_enc_param: General jpeg encoding parameters
> + * @enc_w: image width
> + * @enc_h: image height
> + * @enable_exif: EXIF enable for jpeg encode mode
> + * @enc_quality: destination image quality in encode mode
> + * @enc_format: input image format
> + * @restart_interval: JPEG restart interval for JPEG encoding
> + * @img_stride: jpeg encoder image stride
> + * @mem_stride: jpeg encoder memory stride
> + * @total_encdu: total 8x8 block number
They are not well-aligned.
> +struct mtk_jpeg_enc_param {
> + u32 enc_w;
> + u32 enc_h;
> + u32 enable_exif;
> + u32 enc_quality;
> + u32 enc_format;
> + u32 restart_interval;
> + u32 img_stride;
> + u32 mem_stride;
> + u32 total_encdu;
> +};
They are not used.
> + u32 bs_size;
> + int flags;
They are not used.
> + struct mtk_jpeg_enc_param enc_param;
> + struct mtk_jpeg_ctx *curr_ctx;
They are not used.
> +void mtk_jpeg_put_buf(struct mtk_jpeg_dev *jpeg)
> +{
> + struct mtk_jpeg_ctx *ctx;
> + struct vb2_v4l2_buffer *dst_buffer;
> + struct list_head *temp_entry;
> + struct list_head *pos;
> + struct mtk_jpeg_src_buf *dst_done_buf, *tmp_dst_done_buf;
> + unsigned long flags;
> +
> + ctx = jpeg->hw_param.curr_ctx;
> + if (!ctx) {
> + dev_err(jpeg->dev, "comp_jpeg ctx fail !!!\n");
> + return;
> + }
> +
> + dst_buffer = jpeg->hw_param.dst_buffer;
> + if (!dst_buffer) {
> + dev_err(jpeg->dev, "comp_jpeg dst_buffer fail !!!\n");
> + return;
> + }
The caller "mtk_jpegenc_hw_irq_handler()" doesn't even check ctx and
dst_buffer. Does mtk_jpeg_put_buf() need to validate them?
> + spin_lock_irqsave(&ctx->done_queue_lock, flags);
> + list_add_tail(&dst_done_buf->list, &ctx->dst_done_queue);
> + while (!list_empty(&ctx->dst_done_queue) &&
> + (pos != &ctx->dst_done_queue)) {
Why does it need to compare `pos != &ctx->dst_done_queue`? On a
related note, at the first time, pos will be some garbage data from
stack.
> +irqreturn_t mtk_jpegenc_hw_irq_handler(int irq, void *priv)
No code is using mtk_jpegenc_hw_irq_handler. Have no enough context
to review the code.
> + src_buf = jpeg->hw_param.src_buffer;
> + dst_buf = jpeg->hw_param.dst_buffer;
> + ctx = jpeg->hw_param.curr_ctx;
> + master_jpeg = ctx->jpeg;
Could they be inlined to above where the variables are declared?
> +enum mtk_jpeg_hw_state {
> + MTK_JPEG_HW_IDLE = 0,
> + MTK_JPEG_HW_BUSY = 1,
MTK_JPEG_HW_BUSY is not used.
> @@ -124,13 +135,18 @@ struct mtk_jpeg_dev {
> struct v4l2_m2m_dev *m2m_dev;
> void *alloc_ctx;
> struct video_device *vdev;
> - void __iomem *reg_base;
> struct device *larb;
> struct delayed_work job_timeout_work;
> const struct mtk_jpeg_variant *variant;
>
> + void __iomem *reg_base[MTK_JPEGENC_HW_MAX];
> + int jpegenc_irq;
jpegenc_irq is not used.
> @@ -189,6 +205,12 @@ struct mtk_jpeg_ctx {
> u8 enc_quality;
> u8 restart_interval;
> struct v4l2_ctrl_handler ctrl_hdl;
> +
> + struct list_head dst_done_queue;
> + spinlock_t done_queue_lock; /* spinlock protecting done queue */
> + u32 total_frame_num;
total_frame_num is not used.
Need to double confirm: why sometimes the code uses
jpeg->reg_base[MTK_JPEGENC_HW0] but sometimes jpeg->reg_base[0]?
next prev parent reply other threads:[~2021-07-06 11:00 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <1625038079-25815-1-git-send-email-kyrie.wu@mediatek.com>
2021-07-06 11:00 ` [PATCH v2,0/9] Support jpeg encode for MT8195 Tzung-Bi Shih
2021-07-09 8:27 ` Tomasz Figa
[not found] ` <1625038079-25815-3-git-send-email-kyrie.wu@mediatek.com>
2021-07-06 11:00 ` [PATCH v2,2/9] media: mtk-jpegenc: Add MT8195 JPEG venc driver Tzung-Bi Shih
[not found] ` <1625038079-25815-4-git-send-email-kyrie.wu@mediatek.com>
2021-07-06 11:00 ` [PATCH v2,3/9] media: mtk-jpegenc: remove redundant code of irq Tzung-Bi Shih
2021-07-09 9:07 ` Tomasz Figa
[not found] ` <1625038079-25815-7-git-send-email-kyrie.wu@mediatek.com>
2021-07-06 11:00 ` [PATCH v2,6/9] media: mtk-jpegenc: Generalize jpegenc HW timeout interfaces Tzung-Bi Shih
[not found] ` <1625038079-25815-8-git-send-email-kyrie.wu@mediatek.com>
2021-07-06 11:00 ` [PATCH v2,7/9] media: mtk-jpegenc: Use component framework to manage each hardware information Tzung-Bi Shih
[not found] ` <1625038079-25815-9-git-send-email-kyrie.wu@mediatek.com>
2021-07-06 11:00 ` [PATCH v2,8/9] media: mtk-jpegenc: Generalize jpegenc HW operations interfaces Tzung-Bi Shih
[not found] ` <1625038079-25815-10-git-send-email-kyrie.wu@mediatek.com>
2021-07-06 11:01 ` [PATCH v2,9/9] media: mtk-jpegenc: Refactor jpegenc device run interface Tzung-Bi Shih
[not found] ` <1625038079-25815-5-git-send-email-kyrie.wu@mediatek.com>
2021-07-06 11:00 ` [PATCH v2,4/9] media: mtk-jpegenc: Refactor jpeg clock interface Tzung-Bi Shih
2021-07-09 9:20 ` Tomasz Figa
[not found] ` <1625038079-25815-6-git-send-email-kyrie.wu@mediatek.com>
2021-07-06 11:00 ` Tzung-Bi Shih [this message]
2021-07-09 10:20 ` [PATCH v2,5/9] media: mtk-jpegenc: Generalize jpeg encode irq interfaces Tomasz Figa
2021-07-09 10:26 ` [PATCH v2,0/9] Support jpeg encode for MT8195 Tomasz Figa
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=CA+Px+wVLtRWsqZ3Nbd5rPrh_4dScay6BhPLCwjQaCkU8F5McuA@mail.gmail.com \
--to=tzungbi@google.com \
--cc=Project_Global_Chrome_Upstream_Group@mediatek.com \
--cc=bin.liu@mediatek.com \
--cc=devicetree@vger.kernel.org \
--cc=hverkuil-cisco@xs4all.nl \
--cc=kyrie.wu@mediatek.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=linux-mediatek@lists.infradead.org \
--cc=maoguang.meng@mediatek.com \
--cc=matthias.bgg@gmail.com \
--cc=mchehab@kernel.org \
--cc=robh+dt@kernel.org \
--cc=srv_heupstream@mediatek.com \
--cc=tfiga@chromium.org \
--cc=tzungbi@chromium.org \
--cc=xia.jiang@mediatek.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).