@@ -1285,6 +1285,43 @@ irqreturn_t mtk_jpegenc_hw_irq_handler(int irq, void *priv)
return IRQ_HANDLED;
}
+void mtk_jpegenc_timeout_work(struct work_struct *work)
+{
+ struct mtk_jpeg_dev *jpeg = container_of(work, struct mtk_jpeg_dev,
+ job_timeout_work.work);
+ struct mtk_jpeg_ctx *ctx;
+ struct mtk_jpeg_dev *master_jpeg;
+ struct vb2_v4l2_buffer *src_buf, *dst_buf;
+ struct mtk_jpeg_src_buf *jpeg_src_buf, *jpeg_dst_buf;
+ enum vb2_buffer_state buf_state = VB2_BUF_STATE_ERROR;
+
+ src_buf = jpeg->hw_param.src_buffer;
+ dst_buf = jpeg->hw_param.dst_buffer;
+ ctx = jpeg->hw_param.curr_ctx;
+ if (!ctx) {
+ v4l2_err(&jpeg->v4l2_dev, "Context is NULL\n");
+ return;
+ }
+
+ master_jpeg = ctx->jpeg;
+ if (!master_jpeg) {
+ v4l2_err(&jpeg->v4l2_dev, "master_jpeg is NULL\n");
+ return;
+ }
+
+ jpeg_src_buf = mtk_jpeg_vb2_to_srcbuf(&src_buf->vb2_buf);
+ jpeg_dst_buf = mtk_jpeg_vb2_to_srcbuf(&dst_buf->vb2_buf);
+
+ mtk_jpeg_enc_reset(jpeg->reg_base[MTK_JPEGENC_HW0]);
+ pm_runtime_put(jpeg->pm.dev);
+ clk_disable_unprepare(jpeg->pm.venc_clk.clk_info->jpegenc_clk);
+ jpeg->hw_state = MTK_JPEG_HW_IDLE;
+ atomic_inc(&jpeg->hw_rdy);
+ wake_up(&master_jpeg->hw_wq);
+ v4l2_m2m_buf_done(src_buf, buf_state);
+ mtk_jpeg_put_buf(jpeg);
+}
+
static void mtk_jpeg_set_default_params(struct mtk_jpeg_ctx *ctx)
{
struct mtk_jpeg_q_data *q = &ctx->out_q;
Generalizes jpegenc HW timeout interfaces to handle HW timeout. Signed-off-by: kyrie.wu <kyrie.wu@mediatek.com> --- drivers/media/platform/mtk-jpeg/mtk_jpeg_core.c | 37 +++++++++++++++++++++++++ 1 file changed, 37 insertions(+)