Commit e5f969dd authored by kyrie wu's avatar kyrie wu Committed by Hans Verkuil

media: mtk-jpegdec: add jpegdec timeout func interface

Generalizes jpegdec timeout func interfaces to handle HW timeout.
Signed-off-by: default avatarkyrie wu <kyrie.wu@mediatek.com>
Signed-off-by: default avatarirui wang <irui.wang@mediatek.com>
Signed-off-by: default avatarHans Verkuil <hverkuil-cisco@xs4all.nl>
parent 0fa49df4
...@@ -165,6 +165,8 @@ struct mtk_jpegenc_comp_dev { ...@@ -165,6 +165,8 @@ struct mtk_jpegenc_comp_dev {
* @master_dev: mtk_jpeg_dev device * @master_dev: mtk_jpeg_dev device
* @jdec_clk: mtk_jpegdec_clk * @jdec_clk: mtk_jpegdec_clk
* @jpegdec_irq: jpeg decode irq num * @jpegdec_irq: jpeg decode irq num
* @job_timeout_work: decode timeout workqueue
* @hw_param: jpeg decode hw parameters
*/ */
struct mtk_jpegdec_comp_dev { struct mtk_jpegdec_comp_dev {
struct device *dev; struct device *dev;
...@@ -173,6 +175,8 @@ struct mtk_jpegdec_comp_dev { ...@@ -173,6 +175,8 @@ struct mtk_jpegdec_comp_dev {
struct mtk_jpeg_dev *master_dev; struct mtk_jpeg_dev *master_dev;
struct mtk_jpegdec_clk jdec_clk; struct mtk_jpegdec_clk jdec_clk;
int jpegdec_irq; int jpegdec_irq;
struct delayed_work job_timeout_work;
struct mtk_jpeg_hw_param hw_param;
}; };
/** /**
......
...@@ -440,6 +440,25 @@ void mtk_jpeg_dec_set_config(void __iomem *base, ...@@ -440,6 +440,25 @@ void mtk_jpeg_dec_set_config(void __iomem *base,
} }
EXPORT_SYMBOL_GPL(mtk_jpeg_dec_set_config); EXPORT_SYMBOL_GPL(mtk_jpeg_dec_set_config);
static void mtk_jpegdec_timeout_work(struct work_struct *work)
{
enum vb2_buffer_state buf_state = VB2_BUF_STATE_ERROR;
struct mtk_jpegdec_comp_dev *cjpeg =
container_of(work, struct mtk_jpegdec_comp_dev,
job_timeout_work.work);
struct vb2_v4l2_buffer *src_buf, *dst_buf;
src_buf = cjpeg->hw_param.src_buffer;
dst_buf = cjpeg->hw_param.dst_buffer;
v4l2_m2m_buf_copy_metadata(src_buf, dst_buf, true);
mtk_jpeg_dec_reset(cjpeg->reg_base);
clk_disable_unprepare(cjpeg->jdec_clk.clks->clk);
pm_runtime_put(cjpeg->dev);
v4l2_m2m_buf_done(src_buf, buf_state);
v4l2_m2m_buf_done(dst_buf, buf_state);
}
static irqreturn_t mtk_jpegdec_hw_irq_handler(int irq, void *priv) static irqreturn_t mtk_jpegdec_hw_irq_handler(int irq, void *priv)
{ {
struct vb2_v4l2_buffer *src_buf, *dst_buf; struct vb2_v4l2_buffer *src_buf, *dst_buf;
...@@ -453,6 +472,8 @@ static irqreturn_t mtk_jpegdec_hw_irq_handler(int irq, void *priv) ...@@ -453,6 +472,8 @@ static irqreturn_t mtk_jpegdec_hw_irq_handler(int irq, void *priv)
struct mtk_jpegdec_comp_dev *jpeg = priv; struct mtk_jpegdec_comp_dev *jpeg = priv;
struct mtk_jpeg_dev *master_jpeg = jpeg->master_dev; struct mtk_jpeg_dev *master_jpeg = jpeg->master_dev;
cancel_delayed_work(&jpeg->job_timeout_work);
irq_status = mtk_jpeg_dec_get_int_status(jpeg->reg_base); irq_status = mtk_jpeg_dec_get_int_status(jpeg->reg_base);
dec_irq_ret = mtk_jpeg_dec_enum_result(irq_status); dec_irq_ret = mtk_jpeg_dec_enum_result(irq_status);
if (dec_irq_ret >= MTK_JPEG_DEC_RESULT_UNDERFLOW) if (dec_irq_ret >= MTK_JPEG_DEC_RESULT_UNDERFLOW)
...@@ -538,6 +559,9 @@ static int mtk_jpegdec_hw_probe(struct platform_device *pdev) ...@@ -538,6 +559,9 @@ static int mtk_jpegdec_hw_probe(struct platform_device *pdev)
master_dev->dec_hw_dev[i] = NULL; master_dev->dec_hw_dev[i] = NULL;
} }
INIT_DELAYED_WORK(&dev->job_timeout_work,
mtk_jpegdec_timeout_work);
jpegdec_clk = &dev->jdec_clk; jpegdec_clk = &dev->jdec_clk;
jpegdec_clk->clk_num = devm_clk_bulk_get_all(&pdev->dev, jpegdec_clk->clk_num = devm_clk_bulk_get_all(&pdev->dev,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment