[COMMON] media: mfc: expand encoder LAST_SEQ
authorAyoung Sim <a.sim@samsung.com>
Fri, 24 May 2019 05:04:53 +0000 (14:04 +0900)
committerKim Gunho <gunho.kim@samsung.com>
Fri, 28 Jun 2019 14:45:51 +0000 (23:45 +0900)
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 <a.sim@samsung.com>
drivers/media/platform/exynos/mfc/mfc_common.h
drivers/media/platform/exynos/mfc/mfc_enc_v4l2.c
drivers/media/platform/exynos/mfc/mfc_enc_vb2.c
drivers/media/platform/exynos/mfc/mfc_isr.c
drivers/media/platform/exynos/mfc/mfc_reg_api.c
drivers/media/platform/exynos/mfc/mfc_run.c

index c387cec69b31899141ab70e0f586b96c5b1adc34..64bb87db6122e7bfae5a10406eadc0b7a9a33c51 100644 (file)
@@ -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
 
index 2fe96fbd90a9f7ef0fccc165f29e99b5fcfa5df9..fa0f70b3cf063284b764b5156a94c2e6f3fe3263 100644 (file)
@@ -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;
index fd6e811eb8f81bf00a892a149e4d7115b895ea88..3643c73f5ef6fb1ced7ddc3cebbea33a2768ffed 100644 (file)
@@ -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;
-                               }
                        }
                }
 
index 95a90f798663e2dc05a47b1a458d299f03748686..4a78fa15f1535f1b7f445273c872002ce9175f43 100644 (file)
@@ -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 */
index 0bb0cd0cbccd1feba6c83dc868c322b6e597bdf3..50f07d5f7c00b9143ae84d821e4d8f2275780e22 100644 (file)
@@ -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);
index f38c33d0d20c5b60a29389c6521e0176120b9a40..db344ff1245aac5678c95f5cf643e76e6f459bf4 100644 (file)
@@ -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);