decoder: fix too much get status failed. [1/1]

PD#SWPL-2241

Problem:
too much print like below,
"amstream_do_ioctl error :ffffffed, c02053c3"

Solution:
set dec_status return 0 in multi-dec driver.

Verify:
Verify by x301

Change-Id: Ibd07e487706176b5c6a316ce48234b608112d0ce
Signed-off-by: shihong.zheng <shihong.zheng@amlogic.com>
This commit is contained in:
shihong.zheng
2018-11-17 16:03:29 +08:00
committed by Dongjin Kim
parent b4627f5d56
commit 711917ca2a
17 changed files with 69 additions and 16 deletions

View File

@@ -780,7 +780,7 @@ static void vavs_vf_put(struct vframe_s *vf, void *op_arg)
int vavs_dec_status(struct vdec_s *vdec, struct vdec_info *vstatus)
{
if (!(stat & STAT_VDEC_RUN))
return 0;
return -1;
vstatus->frame_width = frame_width;
vstatus->frame_height = frame_height;
@@ -1661,7 +1661,7 @@ static int amvdec_avs_probe(struct platform_device *pdev)
pr_info("amvdec_avs init failed.\n");
kfree(gvs);
gvs = NULL;
pdata->dec_status = NULL;
return -ENODEV;
}
vdec = pdata;

View File

@@ -5444,7 +5444,7 @@ int vavs2_dec_status(struct vdec_s *vdec, struct vdec_info *vstatus)
struct AVS2Decoder_s *dec =
(struct AVS2Decoder_s *)vdec->private;
if (!dec || !(dec->stat & STAT_VDEC_RUN))
if (!dec)
return -1;
vstatus->frame_width = dec->frame_width;
@@ -5888,6 +5888,7 @@ static int amvdec_avs2_probe(struct platform_device *pdev)
pr_info("\namvdec_avs2 init failed.\n");
avs2_local_uninit(dec);
uninit_mmu_buffers(dec);
pdata->dec_status = NULL;
mutex_unlock(&vavs2_mutex);
return -ENODEV;
}
@@ -6688,6 +6689,7 @@ static int ammvdec_avs2_probe(struct platform_device *pdev)
uninit_mmu_buffers(dec);
/* devm_kfree(&pdev->dev, (void *)dec); */
vfree((void *)dec);
pdata->dec_status = NULL;
return -ENODEV;
}
vdec_set_prepare_level(pdata, start_decode_buf_level);

View File

@@ -3059,6 +3059,7 @@ static int amvdec_h264_probe(struct platform_device *pdev)
pr_info("\namvdec_h264 init failed.\n");
kfree(gvs);
gvs = NULL;
pdata->dec_status = NULL;
mutex_unlock(&vh264_mutex);
return -ENODEV;
}

View File

@@ -5238,7 +5238,7 @@ static int dec_status(struct vdec_s *vdec, struct vdec_info *vstatus)
{
struct vdec_h264_hw_s *hw = (struct vdec_h264_hw_s *)vdec->private;
if (!hw || !(hw->stat & STAT_VDEC_RUN))
if (!hw)
return -1;
vstatus->frame_width = hw->frame_width;
@@ -7381,6 +7381,7 @@ static int ammvdec_h264_probe(struct platform_device *pdev)
if (decoder_bmmu_box_alloc_buf_phy(hw->bmmu_box, BMMU_DPB_IDX,
V_BUF_ADDR_OFFSET, DRIVER_NAME, &hw->cma_alloc_addr) < 0) {
h264_free_hw_stru(&pdev->dev, (void *)hw);
pdata->dec_status = NULL;
return -ENOMEM;
}
@@ -7393,6 +7394,7 @@ static int ammvdec_h264_probe(struct platform_device *pdev)
if (decoder_bmmu_box_alloc_buf_phy(hw->bmmu_box, BMMU_EXTIF_IDX,
extif_size, DRIVER_NAME, &hw->extif_addr) < 0) {
h264_free_hw_stru(&pdev->dev, (void *)hw);
pdata->dec_status = NULL;
return -ENOMEM;
}
}
@@ -7464,6 +7466,7 @@ static int ammvdec_h264_probe(struct platform_device *pdev)
pr_info("\nammvdec_h264 init failed.\n");
ammvdec_h264_mmu_release(hw);
h264_free_hw_stru(&pdev->dev, (void *)hw);
pdata->dec_status = NULL;
return -ENODEV;
}
#ifdef MH264_USERDATA_ENABLE

View File

@@ -9078,7 +9078,7 @@ int vh265_dec_status(struct vdec_info *vstatus)
#else
struct hevc_state_s *hevc = gHevc;
#endif
if (!hevc || !(hevc->stat & STAT_VDEC_RUN))
if (!hevc)
return -1;
vstatus->frame_width = hevc->frame_width;
@@ -10488,6 +10488,7 @@ static int amvdec_h265_probe(struct platform_device *pdev)
hevc_local_uninit(hevc);
uninit_mmu_buffers(hevc);
vfree(hevc);
pdata->dec_status = NULL;
mutex_unlock(&vh265_mutex);
return -ENODEV;
}
@@ -10830,6 +10831,7 @@ static int ammvdec_h265_probe(struct platform_device *pdev)
/* devm_kfree(&pdev->dev, (void *)hevc);*/
if (hevc)
vfree((void *)hevc);
pdata->dec_status = NULL;
return -EFAULT;
}
#if 0
@@ -10845,6 +10847,7 @@ static int ammvdec_h265_probe(struct platform_device *pdev)
/* devm_kfree(&pdev->dev, (void *)hevc); */
if (hevc)
vfree((void *)hevc);
pdata->dec_status = NULL;
mutex_unlock(&vh265_mutex);
return ret;
}
@@ -10887,6 +10890,7 @@ static int ammvdec_h265_probe(struct platform_device *pdev)
/* devm_kfree(&pdev->dev, (void *)hevc); */
if (hevc)
vfree((void *)hevc);
pdata->dec_status = NULL;
return -ENODEV;
}

View File

@@ -844,6 +844,7 @@ static int amvdec_mjpeg_probe(struct platform_device *pdev)
mutex_unlock(&vmjpeg_mutex);
kfree(gvs);
gvs = NULL;
pdata->dec_status = NULL;
return -ENODEV;
}

View File

@@ -385,7 +385,7 @@ static int vmjpeg_dec_status(struct vdec_s *vdec, struct vdec_info *vstatus)
{
struct vdec_mjpeg_hw_s *hw = (struct vdec_mjpeg_hw_s *)vdec->private;
if (!hw || !(hw->stat & STAT_VDEC_RUN))
if (!hw)
return -1;
vstatus->frame_width = hw->frame_width;
@@ -1148,6 +1148,7 @@ static int ammvdec_mjpeg_probe(struct platform_device *pdev)
if (vmjpeg_init(pdata) < 0) {
pr_info("ammvdec_mjpeg init failed.\n");
devm_kfree(&pdev->dev, (void *)hw);
pdata->dec_status = NULL;
return -ENODEV;
}

View File

@@ -2057,7 +2057,7 @@ static int amvdec_mpeg12_probe(struct platform_device *pdev)
amlog_level(LOG_LEVEL_ERROR, "amvdec_mpeg12 init failed.\n");
kfree(gvs);
gvs = NULL;
pdata->dec_status = NULL;
return -ENODEV;
}
vdec = pdata;

View File

@@ -1085,7 +1085,7 @@ static int vmmpeg12_dec_status(struct vdec_s *vdec, struct vdec_info *vstatus)
struct vdec_mpeg12_hw_s *hw =
(struct vdec_mpeg12_hw_s *)vdec->private;
if (!hw || !(hw->stat & STAT_VDEC_RUN))
if (!hw)
return -1;
vstatus->frame_width = hw->frame_width;
@@ -1785,6 +1785,7 @@ static int ammvdec_mpeg12_probe(struct platform_device *pdev)
if (vmpeg12_init(hw) < 0) {
pr_info("ammvdec_mpeg12 init failed.\n");
devm_kfree(&pdev->dev, (void *)hw);
pdata->dec_status = NULL;
return -ENODEV;
}

View File

@@ -1142,6 +1142,7 @@ static int amvdec_mpeg4_probe(struct platform_device *pdev)
amlog_level(LOG_LEVEL_ERROR, "amvdec_mpeg4 init failed.\n");
kfree(gvs);
gvs = NULL;
pdata->dec_status = NULL;
return -ENODEV;
}

View File

@@ -1040,7 +1040,7 @@ static int dec_status(struct vdec_s *vdec, struct vdec_info *vstatus)
{
struct vdec_mpeg4_hw_s *hw = (struct vdec_mpeg4_hw_s *)vdec->private;
if (!hw || !(hw->stat & STAT_VDEC_RUN))
if (!hw)
return -1;
vstatus->frame_width = hw->vmpeg4_amstream_dec_info.width;
@@ -1855,6 +1855,7 @@ static int ammvdec_mpeg4_probe(struct platform_device *pdev)
vfree((void *)hw);
hw = NULL;
}
pdata->dec_status = NULL;
return -ENODEV;
}

View File

@@ -944,6 +944,7 @@ static int amvdec_real_probe(struct platform_device *pdev)
if (vreal_init(pdata) < 0) {
pr_info("amvdec_real init failed.\n");
pdata->dec_status = NULL;
return -ENODEV;
}
INIT_WORK(&set_clk_work, vreal_set_clk);

View File

@@ -227,10 +227,12 @@ static int get_canvas(unsigned int index, unsigned int base)
int vdec_status(struct vdec_s *vdec, struct vdec_info *vstatus)
{
if (vdec && vdec->dec_status)
if (vdec && vdec->dec_status &&
((vdec->status == VDEC_STATUS_CONNECTED ||
vdec->status == VDEC_STATUS_ACTIVE)))
return vdec->dec_status(vdec, vstatus);
return -1;
return 0;
}
EXPORT_SYMBOL(vdec_status);
@@ -3617,7 +3619,8 @@ static ssize_t vdec_status_show(struct class *class,
}
list_for_each_entry(vdec, &core->connected_vdec_list, list) {
if (VDEC_STATUS_CONNECTED == vdec->status) {
if ((vdec->status == VDEC_STATUS_CONNECTED
|| vdec->status == VDEC_STATUS_ACTIVE)) {
memset(&vs, 0, sizeof(vs));
if (vdec_status(vdec, &vs)) {
pbuf += sprintf(pbuf, "err.\n");

View File

@@ -1150,6 +1150,7 @@ static int amvdec_vc1_probe(struct platform_device *pdev)
pr_info("amvdec_vc1 init failed.\n");
kfree(gvs);
gvs = NULL;
pdata->dec_status = NULL;
return -ENODEV;
}
INIT_WORK(&set_clk_work, vvc1_set_clk);

View File

@@ -7743,7 +7743,7 @@ int vvp9_dec_status(struct vdec_s *vdec, struct vdec_info *vstatus)
struct VP9Decoder_s *vp9 =
(struct VP9Decoder_s *)vdec->private;
if (!vp9 || !(vp9->stat & STAT_VDEC_RUN))
if (!vp9)
return -1;
vstatus->frame_width = frame_width;
@@ -8366,6 +8366,7 @@ static int amvdec_vp9_probe(struct platform_device *pdev)
vp9_local_uninit(pbi);
uninit_mmu_buffers(pbi);
vfree(pbi);
pdata->dec_status = NULL;
mutex_unlock(&vvp9_mutex);
return -ENODEV;
}
@@ -9364,6 +9365,7 @@ static int ammvdec_vp9_probe(struct platform_device *pdev)
pr_err("vp9 alloc bmmu box failed!!\n");
/* devm_kfree(&pdev->dev, (void *)pbi); */
vfree((void *)pbi);
pdata->dec_status = NULL;
return -1;
}
@@ -9375,6 +9377,7 @@ static int ammvdec_vp9_probe(struct platform_device *pdev)
uninit_mmu_buffers(pbi);
/* devm_kfree(&pdev->dev, (void *)pbi); */
vfree((void *)pbi);
pdata->dec_status = NULL;
return ret;
}
pbi->buf_start = pbi->cma_alloc_addr;
@@ -9406,6 +9409,7 @@ static int ammvdec_vp9_probe(struct platform_device *pdev)
uninit_mmu_buffers(pbi);
/* devm_kfree(&pdev->dev, (void *)pbi); */
vfree((void *)pbi);
pdata->dec_status = NULL;
return -ENODEV;
}
vdec_set_prepare_level(pdata, start_decode_buf_level);

View File

@@ -26,6 +26,7 @@
struct port_priv_s {
struct vdec_s *vdec;
struct stream_port_s *port;
struct mutex mutex;
};
struct stream_buf_s *get_buf_by_type(u32 type);

View File

@@ -917,11 +917,14 @@ static int amstream_port_init(struct port_priv_s *priv)
port->vformat == VFORMAT_VP9)
pvbuf = &bufs[BUF_TYPE_HEVC];
}
mutex_lock(&priv->mutex);
r = video_port_init(priv, pvbuf);
if (r < 0) {
mutex_unlock(&priv->mutex);
pr_err("video_port_init failed\n");
goto error2;
}
mutex_unlock(&priv->mutex);
}
if ((port->type & PORT_TYPE_SUB) && (port->flag & PORT_FLAG_SID)) {
@@ -1597,6 +1600,8 @@ static int amstream_open(struct inode *inode, struct file *file)
return -ENOMEM;
}
mutex_init(&priv->mutex);
priv->port = port;
if (get_cpu_major_id() >= AM_MESON_CPU_MAJOR_ID_M6) {
@@ -1775,6 +1780,8 @@ static int amstream_release(struct inode *inode, struct file *file)
amports_switch_gate("demux", 0);
}
mutex_destroy(&priv->mutex);
kfree(priv);
mutex_unlock(&amstream_mutex);
@@ -2317,8 +2324,15 @@ static long amstream_ioctl_get_ex(struct port_priv_s *priv, ulong arg)
struct vdec_info vstatus;
struct am_ioctl_parm_ex *p = &parm;
if (vdec_status(priv->vdec, &vstatus) == -1)
memset(&vstatus, 0, sizeof(vstatus));
mutex_lock(&priv->mutex);
if (vdec_status(priv->vdec, &vstatus) == -1) {
mutex_unlock(&priv->mutex);
return -ENODEV;
}
mutex_unlock(&priv->mutex);
p->vstatus.width = vstatus.frame_width;
p->vstatus.height = vstatus.frame_height;
p->vstatus.fps = vstatus.frame_rate;
@@ -2790,13 +2804,21 @@ static long amstream_do_ioctl_old(struct port_priv_s *priv,
struct am_io_param para;
struct am_io_param *p = &para;
if (vdec_status(priv->vdec, &vstatus) == -1)
memset(&vstatus, 0, sizeof(vstatus));
mutex_lock(&priv->mutex);
if (vdec_status(priv->vdec, &vstatus) == -1) {
mutex_unlock(&priv->mutex);
return -ENODEV;
}
mutex_unlock(&priv->mutex);
p->vstatus.width = vstatus.frame_width;
p->vstatus.height = vstatus.frame_height;
p->vstatus.fps = vstatus.frame_rate;
p->vstatus.error_count = vstatus.error_count;
p->vstatus.status = vstatus.status;
if (copy_to_user((void *)arg, p, sizeof(para)))
r = -EFAULT;
return r;
@@ -2810,8 +2832,14 @@ static long amstream_do_ioctl_old(struct port_priv_s *priv,
struct am_io_info para;
memset(&para, 0x0, sizeof(struct am_io_info));
if (vdec_status(priv->vdec, &vinfo) == -1)
mutex_lock(&priv->mutex);
if (vdec_status(priv->vdec, &vinfo) == -1) {
mutex_unlock(&priv->mutex);
return -ENODEV;
}
mutex_unlock(&priv->mutex);
memcpy(&para.vinfo, &vinfo, sizeof(struct vdec_info));
if (copy_to_user((void *)arg, &para, sizeof(para)))
r = -EFAULT;