index++;
}
} else if (q->type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE) {
+ if (ctx->state == MFCINST_FREE) {
+ mfc_debug(2, "already closed\n");
+ } else {
+ s5p_mfc_change_state(ctx, MFCINST_FINISHING);
+ s5p_mfc_set_bit(ctx->num, &dev->work_bits);
+
+ while (s5p_mfc_get_buf(&ctx->buf_queue_lock, &ctx->dst_buf_queue, MFC_BUF_NO_TOUCH_USED)) {
+ ret = s5p_mfc_just_run(dev, ctx->num);
+ if (ret) {
+ mfc_err_ctx("Failed to run MFC.\n");
+ break;
+ }
+ if (s5p_mfc_wait_for_done_ctx(ctx, S5P_FIMV_R2H_CMD_FRAME_DONE_RET)) {
+ mfc_err_ctx("Waiting for LAST_SEQ timed out\n");
+ break;
+ }
+ if (ctx->state == MFCINST_RUNNING) {
+ mfc_debug(2, "all encoded buffers out\n");
+ break;
+ }
+ }
+ }
+
s5p_mfc_move_all_bufs(&ctx->buf_queue_lock, &ctx->src_buf_queue,
&ctx->ref_buf_queue, MFC_QUEUE_ADD_BOTTOM);
s5p_mfc_cleanup_enc_src_queue(ctx);
s5p_mfc_clear_bit(ctx->num, &dev->work_bits);
s5p_mfc_release_hwlock_ctx(ctx);
- if (s5p_mfc_enc_ctx_ready(ctx))
- s5p_mfc_set_bit(ctx->num, &dev->work_bits);
if (s5p_mfc_is_work_to_do(dev))
queue_work(dev->butler_wq, &dev->butler_work);
}
raw = &ctx->raw_buf;
- if (!ctx->enc_res_change_re_input && slice_type >= 0 &&
- ctx->state != MFCINST_FINISHING) {
+ if (!ctx->enc_res_change_re_input && slice_type >= 0) {
if (ctx->state == MFCINST_RUNNING_NO_OUTPUT ||
ctx->state == MFCINST_RUNNING_BUF_FULL)
s5p_mfc_change_state(ctx, MFCINST_RUNNING);
}
}
}
- } else if (ctx->state == MFCINST_FINISHING) {
- src_mb = s5p_mfc_get_del_buf(&ctx->buf_queue_lock,
- &ctx->src_buf_queue, MFC_BUF_NO_TOUCH_USED);
- if (!src_mb) {
- mfc_err_ctx("no src buffers.\n");
- return;
- }
-
- vb2_buffer_done(&src_mb->vb.vb2_buf, VB2_BUF_STATE_DONE);
-
- /* encoder src buffer CFW UNPROT */
- if (ctx->is_drm) {
- index = src_mb->vb.vb2_buf.index;
- s5p_mfc_raw_unprotect(ctx, src_mb, index);
- }
}
}
struct s5p_mfc_buf *dst_mb;
unsigned int index;
- if (strm_size > 0 || ctx->state == MFCINST_FINISHING
- || ctx->state == MFCINST_RUNNING_BUF_FULL) {
+ if (strm_size > 0 || ctx->state == MFCINST_RUNNING_BUF_FULL) {
/* at least one more dest. buffers exist always */
dst_mb = s5p_mfc_get_del_buf(&ctx->buf_queue_lock,
&ctx->dst_buf_queue, MFC_BUF_NO_TOUCH_USED);
if (call_cop(ctx, get_buf_ctrls_val, ctx, &ctx->dst_ctrls[index]) < 0)
mfc_err_ctx("failed in get_buf_ctrls_val\n");
- if (strm_size == 0 && ctx->state == MFCINST_FINISHING)
- call_cop(ctx, get_buf_update_val, ctx,
- &ctx->dst_ctrls[index],
- V4L2_CID_MPEG_MFC51_VIDEO_FRAME_TAG,
- enc->stored_tag);
-
vb2_buffer_done(&dst_mb->vb.vb2_buf, VB2_BUF_STATE_DONE);
/* encoder dst buffer CFW UNPROT */
p->codec.bpg.thumb_size,
p->codec.bpg.exif_size);
} else {
- /* TODO: is there other case? */
if ((p->seq_hdr_mode == V4L2_MPEG_VIDEO_HEADER_MODE_SEPARATE) ||
(p->seq_hdr_mode == V4L2_MPEG_VIDEO_HEADER_MODE_AT_THE_READY)) {
dst_mb = s5p_mfc_get_del_buf(&ctx->buf_queue_lock,
s5p_mfc_stream_unprotect(ctx, dst_mb, index);
}
-
}
}
/* If the ROI is enabled at SEQ_START, clear ROI_ENABLE bit */
s5p_mfc_clear_roi_enable(dev);
+ if (!ctx->codec_buffer_allocated) {
+ mfc_debug(2, "previous codec buffer is exist\n");
+
+ if (dev->has_mmcache && dev->mmcache.is_on_status)
+ s5p_mfc_invalidate_mmcache(dev);
+
+ s5p_mfc_release_codec_buffers(ctx);
+ }
ret = s5p_mfc_alloc_codec_buffers(ctx);
if (ret) {
mfc_err_ctx("Failed to allocate encoding buffers.\n");
case S5P_FIMV_R2H_CMD_SLICE_DONE_RET:
case S5P_FIMV_R2H_CMD_FIELD_DONE_RET:
case S5P_FIMV_R2H_CMD_FRAME_DONE_RET:
- case S5P_FIMV_R2H_CMD_COMPLETE_SEQ_RET:
case S5P_FIMV_R2H_CMD_ENC_BUFFER_FULL_RET:
return mfc_handle_done_frame(ctx, reason, err);
+ case S5P_FIMV_R2H_CMD_COMPLETE_SEQ_RET:
+ if (ctx->type == MFCINST_ENCODER) {
+ mfc_handle_stream(ctx);
+ s5p_mfc_change_state(ctx, MFCINST_RUNNING);
+ } else if (ctx->type == MFCINST_DECODER) {
+ return mfc_handle_done_frame(ctx, reason, err);
+ }
+ break;
case S5P_FIMV_R2H_CMD_SEQ_DONE_RET:
if (ctx->type == MFCINST_ENCODER) {
if (ctx->otf_handle) {