[RAMEN9610-10029][COMMON] media: mfc: fix the WAIT state for decoder DRC
authorSunyoung Kang <sy0816.kang@samsung.com>
Tue, 23 Oct 2018 09:23:23 +0000 (18:23 +0900)
committerCosmin Tanislav <demonsingur@gmail.com>
Mon, 22 Apr 2024 17:23:10 +0000 (20:23 +0300)
In case of UTC, it calls g_fmt after streamoff so can't out from
WAIT_DPB_FLUSH state. This modified that it can wait both g_fmt and
streamoff regardless of the order.
When DRC is detected the wait_state set to (WAIT_G_FMT | WAIT_STOP).
If the g_fmt is called WAIT_G_FMT is cleared and
if the streamoff is called WAIT_STOP is cleared.

Change-Id: I90326d191de2ba164060673e8b124227fda3a397
Signed-off-by: Sunyoung Kang <sy0816.kang@samsung.com>
drivers/media/platform/exynos/mfc/mfc_data_struct.h
drivers/media/platform/exynos/mfc/mfc_dec_v4l2.c
drivers/media/platform/exynos/mfc/mfc_dec_vb2.c
drivers/media/platform/exynos/mfc/mfc_isr.c
drivers/media/platform/exynos/mfc/mfc_nal_q.c

index bda4b0556eaa7b8188bf3ead73b2be9f5468f3f2..5a2b015d7c8076ca0a22f170528c3b66c3d773f6 100644 (file)
@@ -130,9 +130,9 @@ enum mfc_queue_state {
 };
 
 enum mfc_dec_wait_state {
-       WAIT_NONE = 0,
-       WAIT_DECODING,
-       WAIT_DPB_FLUSH,
+       WAIT_NONE       = 0,
+       WAIT_G_FMT      = (1 << 0),
+       WAIT_STOP       = (1 << 1),
 };
 
 /**
index 785de4bcbbf141e04f083ef781826cba866f7f25..727ff581f6f2e35a53fd145796f50243a4609f1a 100644 (file)
@@ -285,7 +285,7 @@ static int mfc_dec_g_fmt_vid_cap_mplane(struct file *file, void *priv,
            ctx->state == MFCINST_RES_CHANGE_FLUSH ||
            ctx->state == MFCINST_RES_CHANGE_END) {
                /* If there is no source buffer to parsing, we can't SEQ_START */
-               if ((ctx->wait_state == WAIT_DECODING) &&
+               if (((ctx->wait_state & WAIT_G_FMT) != 0) &&
                        mfc_is_queue_count_same(&ctx->buf_queue_lock, &ctx->src_buf_queue, 0)) {
                        mfc_err_dev("There is no source buffer to parsing, keep previous resolution\n");
                        return -EAGAIN;
@@ -357,9 +357,9 @@ static int mfc_dec_g_fmt_vid_cap_mplane(struct file *file, void *priv,
                }
        }
 
-       if (ctx->wait_state == WAIT_DECODING) {
-               ctx->wait_state = WAIT_DPB_FLUSH;
-               mfc_debug(2, "wait DPB flush for decoding(INIT_BUFFER)\n");
+       if ((ctx->wait_state & WAIT_G_FMT) != 0) {
+               ctx->wait_state &= ~(WAIT_G_FMT);
+               mfc_debug(2, "clear WAIT_G_FMT %d\n", ctx->wait_state);
        }
 
        mfc_debug_leave();
index bcc8a2629e3d8bac09134502c5b145f356e6626a..215496c52108c272f5d1ea55b203db97a8df319f 100644 (file)
@@ -365,9 +365,9 @@ static void __mfc_dec_dst_stop_streaming(struct mfc_ctx *ctx)
                index++;
        }
 
-       if (ctx->wait_state == WAIT_DPB_FLUSH) {
-               ctx->wait_state = WAIT_NONE;
-               mfc_debug(2, "Decoding(INIT_BUFFER) can be started now\n");
+       if (ctx->wait_state & WAIT_STOP) {
+               ctx->wait_state &= ~(WAIT_STOP);
+               mfc_debug(2, "clear WAIT_STOP %d\n", ctx->wait_state);
        }
 }
 
index ba32eb746b45e3e736b5c9fdb6463eca7dc4f48f..f2edb84493925ad52968b2ca3436d003c44d5cba 100644 (file)
@@ -643,7 +643,7 @@ static void __mfc_handle_frame(struct mfc_ctx *ctx,
        if (res_change) {
                mfc_debug(2, "[DRC] Resolution change set to %d\n", res_change);
                mfc_change_state(ctx, MFCINST_RES_CHANGE_INIT);
-               ctx->wait_state = WAIT_DECODING;
+               ctx->wait_state = WAIT_G_FMT | WAIT_STOP;
                mfc_debug(2, "[DRC] Decoding waiting! : %d\n", ctx->wait_state);
                return;
        }
@@ -667,7 +667,7 @@ static void __mfc_handle_frame(struct mfc_ctx *ctx,
                ctx->is_dpb_realloc = 1;
                mfc_change_state(ctx, MFCINST_HEAD_PARSED);
                ctx->capture_state = QUEUE_FREE;
-               ctx->wait_state = WAIT_DECODING;
+               ctx->wait_state = WAIT_STOP;
                __mfc_handle_frame_all_extracted(ctx);
                goto leave_handle_frame;
        }
index e3889948e95654821621ad589c9ce1d5dc6f8ec1..987ab982033d081ac1dd1750cd77a95428a13446 100644 (file)
@@ -1652,7 +1652,7 @@ void __mfc_nal_q_handle_frame(struct mfc_ctx *ctx, DecoderOutputStr *pOutStr)
        if (res_change) {
                mfc_debug(2, "[NALQ][DRC] Resolution change set to %d\n", res_change);
                mfc_change_state(ctx, MFCINST_RES_CHANGE_INIT);
-               ctx->wait_state = WAIT_DECODING;
+               ctx->wait_state = WAIT_G_FMT | WAIT_STOP;
                dev->nal_q_handle->nal_q_exception = 1;
                mfc_info_ctx("[NALQ][DRC] nal_q_exception is set (res change)\n");
                goto leave_handle_frame;