From: Ayoung Sim Date: Fri, 24 May 2019 05:04:53 +0000 (+0900) Subject: [COMMON] media: mfc: expand encoder LAST_SEQ X-Git-Tag: MMI-QSAS30.62-33-3~877 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=597df2c2981d221d3edd1a7c1f546ca2d00d627c;p=GitHub%2FMotorolaMobilityLLC%2Fkernel-slsi.git [COMMON] media: mfc: expand encoder LAST_SEQ Even if we don't have the src/dst buffer, we can send the LAST_SEQ command. And if the header only data(SPS or SPS+PPS not including IDR) is created in dst buffer, drvier update the tag with specific data("0xC5D") becasue we don't have the proper tag. Change-Id: Ia5e71d17c2b345314ff2f03f09b712b80203b77c Signed-off-by: Ayoung Sim --- diff --git a/drivers/media/platform/exynos/mfc/mfc_common.h b/drivers/media/platform/exynos/mfc/mfc_common.h index c387cec69b31..64bb87db6122 100644 --- a/drivers/media/platform/exynos/mfc/mfc_common.h +++ b/drivers/media/platform/exynos/mfc/mfc_common.h @@ -58,6 +58,8 @@ #define FRAME_RATE_RESOLUTION 1000 #define DEFAULT_TAG (0xE05) +#define IGNORE_TAG (0xD5C) /* ex) encoder DRC */ +#define HEADER_TAG (0xC5D) #define MFC_NO_INSTANCE_SET -1 diff --git a/drivers/media/platform/exynos/mfc/mfc_enc_v4l2.c b/drivers/media/platform/exynos/mfc/mfc_enc_v4l2.c index 2fe96fbd90a9..fa0f70b3cf06 100644 --- a/drivers/media/platform/exynos/mfc/mfc_enc_v4l2.c +++ b/drivers/media/platform/exynos/mfc/mfc_enc_v4l2.c @@ -942,7 +942,10 @@ static int __mfc_enc_get_ctrl_val(struct mfc_ctx *ctx, struct v4l2_control *ctrl mfc_debug(5, "[CTRLS] Control value " "is not up to date: " "0x%08x\n", ctrl->id); - return -EINVAL; + if (ctrl->id == V4L2_CID_MPEG_MFC51_VIDEO_FRAME_TAG) + ctrl->value = IGNORE_TAG; + else + return -EINVAL; } found = 1; diff --git a/drivers/media/platform/exynos/mfc/mfc_enc_vb2.c b/drivers/media/platform/exynos/mfc/mfc_enc_vb2.c index fd6e811eb8f8..3643c73f5ef6 100644 --- a/drivers/media/platform/exynos/mfc/mfc_enc_vb2.c +++ b/drivers/media/platform/exynos/mfc/mfc_enc_vb2.c @@ -370,7 +370,7 @@ static void mfc_enc_stop_streaming(struct vb2_queue *q) mfc_change_state(ctx, MFCINST_FINISHING); mfc_set_bit(ctx->num, &dev->work_bits); - while (mfc_get_buf(&ctx->buf_queue_lock, &ctx->dst_buf_queue, MFC_BUF_NO_TOUCH_USED)) { + while (ctx->state != MFCINST_FINISHED) { ret = mfc_just_run(dev, ctx->num); if (ret) { mfc_err_ctx("Failed to run MFC\n"); @@ -380,10 +380,6 @@ static void mfc_enc_stop_streaming(struct vb2_queue *q) mfc_err_ctx("Waiting for LAST_SEQ timed out\n"); break; } - if (ctx->state == MFCINST_FINISHED) { - mfc_debug(2, "all encoded buffers out\n"); - break; - } } } diff --git a/drivers/media/platform/exynos/mfc/mfc_isr.c b/drivers/media/platform/exynos/mfc/mfc_isr.c index 95a90f798663..4a78fa15f153 100644 --- a/drivers/media/platform/exynos/mfc/mfc_isr.c +++ b/drivers/media/platform/exynos/mfc/mfc_isr.c @@ -1147,7 +1147,7 @@ static int __mfc_handle_seq_enc(struct mfc_ctx *ctx) struct mfc_enc *enc = ctx->enc_priv; struct mfc_enc_params *p = &enc->params; struct mfc_buf *dst_mb; - int ret; + int ret, index; enc->header_size = mfc_get_enc_strm_size(); mfc_debug(2, "[STREAM] encoded slice type: %d, header size: %d, display order: %d\n", @@ -1179,6 +1179,13 @@ static int __mfc_handle_seq_enc(struct mfc_ctx *ctx) } vb2_set_plane_payload(&dst_mb->vb.vb2_buf, 0, mfc_get_enc_strm_size()); + + index = dst_mb->vb.vb2_buf.index; + if (call_cop(ctx, get_buf_ctrls_val, ctx, &ctx->dst_ctrls[index]) < 0) + mfc_err_ctx("failed in get_buf_ctrls_val\n"); + call_cop(ctx, get_buf_update_val, ctx, &ctx->dst_ctrls[index], + V4L2_CID_MPEG_MFC51_VIDEO_FRAME_TAG, HEADER_TAG); + vb2_buffer_done(&dst_mb->vb.vb2_buf, VB2_BUF_STATE_DONE); /* encoder dst buffer CFW UNPROT */ diff --git a/drivers/media/platform/exynos/mfc/mfc_reg_api.c b/drivers/media/platform/exynos/mfc/mfc_reg_api.c index 0bb0cd0cbccd..50f07d5f7c00 100644 --- a/drivers/media/platform/exynos/mfc/mfc_reg_api.c +++ b/drivers/media/platform/exynos/mfc/mfc_reg_api.c @@ -356,14 +356,16 @@ int mfc_set_enc_stream_buffer(struct mfc_ctx *ctx, struct mfc_buf *mfc_buf) { struct mfc_dev *dev = ctx->dev; - dma_addr_t addr; - unsigned int size, offset, index; + dma_addr_t addr = 0; + unsigned int size = 0, offset = 0, index = -1; - index = mfc_buf->vb.vb2_buf.index; - addr = mfc_buf->addr[0][0]; - offset = mfc_buf->vb.vb2_buf.planes[0].data_offset; - size = (unsigned int)vb2_plane_size(&mfc_buf->vb.vb2_buf, 0); - size = ALIGN(size, 512); + if (mfc_buf) { + index = mfc_buf->vb.vb2_buf.index; + addr = mfc_buf->addr[0][0]; + offset = mfc_buf->vb.vb2_buf.planes[0].data_offset; + size = (unsigned int)vb2_plane_size(&mfc_buf->vb.vb2_buf, 0); + size = ALIGN(size, 512); + } MFC_WRITEL(addr, MFC_REG_E_STREAM_BUFFER_ADDR); /* 16B align */ MFC_WRITEL(size, MFC_REG_E_STREAM_BUFFER_SIZE); diff --git a/drivers/media/platform/exynos/mfc/mfc_run.c b/drivers/media/platform/exynos/mfc/mfc_run.c index f38c33d0d20c..db344ff1245a 100644 --- a/drivers/media/platform/exynos/mfc/mfc_run.c +++ b/drivers/media/platform/exynos/mfc/mfc_run.c @@ -581,16 +581,14 @@ int mfc_run_enc_frame(struct mfc_ctx *ctx) int mfc_run_enc_last_frames(struct mfc_ctx *ctx) { - struct mfc_buf *dst_mb; + struct mfc_buf *dst_mb = NULL; struct mfc_raw_info *raw; raw = &ctx->raw_buf; dst_mb = mfc_get_buf(&ctx->buf_queue_lock, &ctx->dst_buf_queue, MFC_BUF_SET_USED); - if (!dst_mb) { - mfc_debug(2, "no dst buffers\n"); - return -EAGAIN; - } + if (!dst_mb) + mfc_debug(2, "no dst buffers set to zero\n"); mfc_debug(2, "Set address zero for all planes\n"); mfc_set_enc_frame_buffer(ctx, 0, raw->num_planes);