mpeg2: CB2 v4l stream mode error stream stuck. [1/1]

PD#SWPL-197724

Problem:
1.When the error stream frame is output,
get_ref and field_num do not match, causing buf to not recycle.
2.interlace stream second field pts error.
3.The error frame called peek to get pts, but pts not *1000.

Solution:
1.When frame output, get_ref is obtained based on field_num.
2.Fixed interlace stream second field pts.
3.Fixed error frame peek's pts.

Verify:
S905X4

Change-Id: I680b6e11543a96b5db0a60fe25f9c54bb7f1d699
Signed-off-by: yuna.liu <yuna.liu@amlogic.com>
diff --git a/drivers/amvdec_ports/aml_vcodec_ts.c b/drivers/amvdec_ports/aml_vcodec_ts.c
index 5f91126..06e2c54 100644
--- a/drivers/amvdec_ports/aml_vcodec_ts.c
+++ b/drivers/amvdec_ports/aml_vcodec_ts.c
@@ -64,6 +64,8 @@
 	}
 
 	*pts = mCheckOutPtsOffset;
+	pts->pts = pts->pts * 1000;
+	pts->pts_64 = pts->pts_64 * 1000;
 
 	pr_debug("%s duration: %lld offset: 0x%llx pts: 0x%x pts64: %llu\n",
 		__func__, (offset >> 32) & 0xffffffff,
diff --git a/drivers/frame_provider/decoder_v4l/mpeg12/vmpeg12_multi.c b/drivers/frame_provider/decoder_v4l/mpeg12/vmpeg12_multi.c
index 9a73c11..1774028 100644
--- a/drivers/frame_provider/decoder_v4l/mpeg12/vmpeg12_multi.c
+++ b/drivers/frame_provider/decoder_v4l/mpeg12/vmpeg12_multi.c
@@ -1947,8 +1947,16 @@
 		first_field_type = (info & PICINFO_TOP_FIRST) ?
 			VIDTYPE_INTERLACE_TOP : VIDTYPE_INTERLACE_BOTTOM;
 		field_num = (info & PICINFO_RPT_FIRST) ? 3 : 2;
+	}
 
-		if (v4l2_ctx->enable_di_post || v4l2_ctx->vpp_is_need) {
+	if ((vdec->prog_only) || (hw->report_field & V4L2_FIELD_NONE) ||
+		(!v4l2_ctx->vpp_is_need && !v4l2_ctx->enable_di_post)) {
+		field_num = 1;
+		type |= VIDTYPE_PROGRESSIVE | VIDTYPE_VIU_FIELD | nv_order;
+	}
+
+	if (v4l2_ctx->enable_di_post || v4l2_ctx->vpp_is_need) {
+		if ((field_num == 2) || (field_num == 3)) {
 			aml_buf = (struct aml_buf *)hw->pics[index].v4l_ref_buf_addr;
 			aml_buf_get_ref(&v4l2_ctx->bm, aml_buf);
 			sub0_buf = (struct aml_buf *)aml_buf->sub_buf[0];
@@ -1970,12 +1978,6 @@
 		}
 	}
 
-	if ((vdec->prog_only) || (hw->report_field & V4L2_FIELD_NONE) ||
-		(!v4l2_ctx->vpp_is_need && !v4l2_ctx->enable_di_post)) {
-		field_num = 1;
-		type |= VIDTYPE_PROGRESSIVE | VIDTYPE_VIU_FIELD | nv_order;
-	}
-
 	for (i = 0; i < field_num; i++) {
 		if (kfifo_get(&hw->newframe_q, &vf) == 0) {
 			debug_print(DECODE_ID(hw), PRINT_FLAG_ERROR,
@@ -2084,7 +2086,7 @@
 					vf->timestamp = 0;
 				}
 			} else if (i > 0) {
-				pts_st.offset = -1;
+				dur_offset = -1;
 				if (!v4l2_ctx->pts_serves_ops->checkout(v4l2_ctx->ptsserver_id, dur_offset, &pts_st)) {
 					vf->pts = pts_st.pts;
 					vf->pts_us64 = pts_st.pts_64;