Message ID | 20220716093408.29734-7-irui.wang@mediatek.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | Support multi-hardware jpeg decoder for MT8195 | expand |
Il 16/07/22 11:34, Irui Wang ha scritto: > From: kyrie wu <kyrie.wu@mediatek.com> > > add output reorder func to reorder the output images > to ensure the output pic is consistent with the input images. > > Signed-off-by: kyrie wu <kyrie.wu@mediatek.com> > Signed-off-by: irui wang <irui.wang@mediatek.com> > > --- > .../platform/mediatek/jpeg/mtk_jpeg_dec_hw.c | 49 ++++++++++++++++++- > 1 file changed, 47 insertions(+), 2 deletions(-) > > diff --git a/drivers/media/platform/mediatek/jpeg/mtk_jpeg_dec_hw.c b/drivers/media/platform/mediatek/jpeg/mtk_jpeg_dec_hw.c > index 590300108bff..c0468cf96d74 100644 > --- a/drivers/media/platform/mediatek/jpeg/mtk_jpeg_dec_hw.c > +++ b/drivers/media/platform/mediatek/jpeg/mtk_jpeg_dec_hw.c > @@ -440,6 +440,51 @@ void mtk_jpeg_dec_set_config(void __iomem *base, > } > EXPORT_SYMBOL_GPL(mtk_jpeg_dec_set_config); > > +static void mtk_jpegdec_put_buf(struct mtk_jpegdec_comp_dev *jpeg) > +{ > + struct mtk_jpeg_src_buf *dst_done_buf, *tmp_dst_done_buf; > + struct vb2_v4l2_buffer *dst_buffer; > + struct list_head *temp_entry; > + struct list_head *pos = NULL; > + struct mtk_jpeg_ctx *ctx; > + unsigned long flags; > + > + ctx = jpeg->hw_param.curr_ctx; > + if (unlikely(!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; > + } > + > + dst_done_buf = container_of(dst_buffer, struct mtk_jpeg_src_buf, b); > + > + 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)) { > + list_for_each_prev_safe(pos, > + temp_entry, > + (&ctx->dst_done_queue)) { This fits in one line, as it results in being 81 columns long, and parenthesis are redundant for dst_done_queue. Everything else looks ok to me. Regards, Angelo
On Mon, 2022-07-18 at 12:36 +0200, AngeloGioacchino Del Regno wrote: > Il 16/07/22 11:34, Irui Wang ha scritto: > > From: kyrie wu <kyrie.wu@mediatek.com> > > > > add output reorder func to reorder the output images > > to ensure the output pic is consistent with the input images. > > > > Signed-off-by: kyrie wu <kyrie.wu@mediatek.com> > > Signed-off-by: irui wang <irui.wang@mediatek.com> > > > > --- > > .../platform/mediatek/jpeg/mtk_jpeg_dec_hw.c | 49 > > ++++++++++++++++++- > > 1 file changed, 47 insertions(+), 2 deletions(-) > > > > diff --git a/drivers/media/platform/mediatek/jpeg/mtk_jpeg_dec_hw.c > > b/drivers/media/platform/mediatek/jpeg/mtk_jpeg_dec_hw.c > > index 590300108bff..c0468cf96d74 100644 > > --- a/drivers/media/platform/mediatek/jpeg/mtk_jpeg_dec_hw.c > > +++ b/drivers/media/platform/mediatek/jpeg/mtk_jpeg_dec_hw.c > > @@ -440,6 +440,51 @@ void mtk_jpeg_dec_set_config(void __iomem > > *base, > > } > > EXPORT_SYMBOL_GPL(mtk_jpeg_dec_set_config); > > > > +static void mtk_jpegdec_put_buf(struct mtk_jpegdec_comp_dev *jpeg) > > +{ > > + struct mtk_jpeg_src_buf *dst_done_buf, *tmp_dst_done_buf; > > + struct vb2_v4l2_buffer *dst_buffer; > > + struct list_head *temp_entry; > > + struct list_head *pos = NULL; > > + struct mtk_jpeg_ctx *ctx; > > + unsigned long flags; > > + > > + ctx = jpeg->hw_param.curr_ctx; > > + if (unlikely(!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; > > + } > > + > > + dst_done_buf = container_of(dst_buffer, struct > > mtk_jpeg_src_buf, b); > > + > > + 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)) { > > + list_for_each_prev_safe(pos, > > + temp_entry, > > + (&ctx->dst_done_queue)) { > > This fits in one line, as it results in being 81 columns long, and > parenthesis > are redundant for dst_done_queue. > > Everything else looks ok to me. > > Regards, > Angelo Hi Angelo, Thanks. I will fix this problem. Regards, Kyrie.
diff --git a/drivers/media/platform/mediatek/jpeg/mtk_jpeg_dec_hw.c b/drivers/media/platform/mediatek/jpeg/mtk_jpeg_dec_hw.c index 590300108bff..c0468cf96d74 100644 --- a/drivers/media/platform/mediatek/jpeg/mtk_jpeg_dec_hw.c +++ b/drivers/media/platform/mediatek/jpeg/mtk_jpeg_dec_hw.c @@ -440,6 +440,51 @@ void mtk_jpeg_dec_set_config(void __iomem *base, } EXPORT_SYMBOL_GPL(mtk_jpeg_dec_set_config); +static void mtk_jpegdec_put_buf(struct mtk_jpegdec_comp_dev *jpeg) +{ + struct mtk_jpeg_src_buf *dst_done_buf, *tmp_dst_done_buf; + struct vb2_v4l2_buffer *dst_buffer; + struct list_head *temp_entry; + struct list_head *pos = NULL; + struct mtk_jpeg_ctx *ctx; + unsigned long flags; + + ctx = jpeg->hw_param.curr_ctx; + if (unlikely(!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; + } + + dst_done_buf = container_of(dst_buffer, struct mtk_jpeg_src_buf, b); + + 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)) { + list_for_each_prev_safe(pos, + temp_entry, + (&ctx->dst_done_queue)) { + tmp_dst_done_buf = list_entry(pos, + struct mtk_jpeg_src_buf, + list); + if (tmp_dst_done_buf->frame_num == + ctx->last_done_frame_num) { + list_del(&tmp_dst_done_buf->list); + v4l2_m2m_buf_done(&tmp_dst_done_buf->b, + VB2_BUF_STATE_DONE); + ctx->last_done_frame_num++; + } + } + } + spin_unlock_irqrestore(&ctx->done_queue_lock, flags); +} + static void mtk_jpegdec_timeout_work(struct work_struct *work) { enum vb2_buffer_state buf_state = VB2_BUF_STATE_ERROR; @@ -460,7 +505,7 @@ static void mtk_jpegdec_timeout_work(struct work_struct *work) atomic_inc(&master_jpeg->dechw_rdy); wake_up(&master_jpeg->dec_hw_wq); v4l2_m2m_buf_done(src_buf, buf_state); - v4l2_m2m_buf_done(dst_buf, buf_state); + mtk_jpegdec_put_buf(cjpeg); } static irqreturn_t mtk_jpegdec_hw_irq_handler(int irq, void *priv) @@ -500,7 +545,7 @@ static irqreturn_t mtk_jpegdec_hw_irq_handler(int irq, void *priv) buf_state = VB2_BUF_STATE_DONE; v4l2_m2m_buf_done(src_buf, buf_state); - v4l2_m2m_buf_done(dst_buf, buf_state); + mtk_jpegdec_put_buf(jpeg); pm_runtime_put(ctx->jpeg->dev); clk_disable_unprepare(jpeg->jdec_clk.clks->clk);